Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit 4ab2a98

Browse files
authored
Merge pull request #56 from Alfresco/development
0.3.2
2 parents 8b8524b + 95d3ba3 commit 4ab2a98

File tree

10 files changed

+1858
-1964
lines changed

10 files changed

+1858
-1964
lines changed

dist/alfresco-js-api.js

Lines changed: 1465 additions & 1921 deletions
Large diffs are not rendered by default.

dist/alfresco-js-api.min.js

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "alfresco-js-api",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "JavaScript client library for the Alfresco REST API",
55
"main": "main.js",
66
"typings": "dist/alfresco-js-api.d.ts",
@@ -14,7 +14,7 @@
1414
"minify": "browserify -s AlfrescoApi dist/alfresco-js-api.js -d -p [minifyify --no-map] > dist/alfresco-js-api.min.js",
1515
"watchify": "watchify -s AlfrescoApi main.js -o dist/alfresco-js-api.js",
1616
"tslint": "tslint -c tslint.json bundle.d.ts",
17-
"toc" : "markdown-toc -i README.md && markdown-toc -i test/mockObjects/README.md"
17+
"toc": "markdown-toc -i README.md && markdown-toc -i test/mockObjects/README.md"
1818
},
1919
"repository": {
2020
"type": "git",
@@ -24,14 +24,16 @@
2424
"url": "https://github.com/Alfresco/alfresco-js-api/issues"
2525
},
2626
"dependencies": {
27-
"superagent": "1.7.1"
27+
"superagent": "1.7.1",
28+
"event-emitter": "^0.3.4",
29+
"lodash": "^4.13.1",
30+
"nock": "^8.0.0"
2831
},
2932
"devDependencies": {
3033
"babel-preset-es2015": "^6.9.0",
3134
"babelify": "^7.3.0",
3235
"browserify": "^13.0.1",
3336
"chai": "^3.5.0",
34-
"event-emitter": "^0.3.4",
3537
"expect.js": "~0.3.1",
3638
"grunt": "~0.4.0",
3739
"grunt-cli": "^1.1.0",
@@ -43,12 +45,10 @@
4345
"grunt-mocha-test": "^0.12.7",
4446
"grunt-open": "^0.2.3",
4547
"load-grunt-tasks": "^3.4.1",
46-
"lodash": "^4.13.1",
4748
"minifyify": "^7.3.3",
4849
"markdown-toc": "^0.12.14",
4950
"mocha": "^2.4.5",
5051
"mocha-lcov-reporter": "^1.2.0",
51-
"nock": "^8.0.0",
5252
"rimraf": "^2.5.2",
5353
"sinon": "^1.17.3",
5454
"sinon-chai": "^2.8.0",

src/alfresco-core-rest-api/src/ApiClient.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@
151151
if (typeof File === 'function' && param instanceof File) {
152152
return true;
153153
}
154+
// Safari fix
155+
if (typeof File === 'object' && param instanceof File) {
156+
return true;
157+
}
154158
return false;
155159
};
156160

@@ -419,7 +423,7 @@
419423
case 'String':
420424
return String(data);
421425
case 'Date':
422-
return this.parseDate(String(data));
426+
return data ? this.parseDate(String(data)) : null;
423427
default:
424428
if (type === Object) {
425429
// generic object, return directly

src/alfrescoApi.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ class AlfrescoApi {
2121
* hostEcm: // hostEcm Your share server IP or DNS name
2222
* hostBpm: // hostBpm Your activiti server IP or DNS name
2323
* contextRoot: // contextRoot default value alfresco
24-
* provider: // ECM BPM ALL
24+
* provider: // ECM BPM ALL, default ECM
2525
* ticketEcm: // Ticket if you already have a ECM ticket you can pass only the ticket and skip the login, in this case you don't need username and password
2626
* ticketBpm: // Ticket if you already have a BPM ticket you can pass only the ticket and skip the login, in this case you don't need username and password
2727
* };
2828
*/
2929
constructor(config) {
30+
31+
if (!config) {
32+
config = {};
33+
}
34+
3035
this.config = {
3136
hostEcm: config.hostEcm || 'http://127.0.0.1:8080',
3237
hostBpm: config.hostBpm || 'http://127.0.0.1:9999',
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
'use strict';
2+
3+
var nock = require('nock');
4+
var BaseMock = require('../baseMock');
5+
6+
class RenditionMock extends BaseMock {
7+
8+
constructor(host) {
9+
super(host);
10+
}
11+
12+
get200RenditionResponse() {
13+
nock(this.host, {'encodedQueryParams': true})
14+
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/97a29e9c-1e4f-4d9d-bb02-1ec920dda045/renditions/pdf')
15+
.reply(200, {
16+
'entry': {
17+
'id': 'pdf',
18+
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
19+
'status': 'NOT_CREATED'
20+
}
21+
});
22+
}
23+
24+
createRendition200() {
25+
nock(this.host, {'encodedQueryParams': true})
26+
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/97a29e9c-1e4f-4d9d-bb02-1ec920dda045/renditions', {'id': 'pdf'})
27+
.reply(202, '');
28+
}
29+
30+
get200RenditionList() {
31+
nock(this.host, {'encodedQueryParams': true})
32+
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/97a29e9c-1e4f-4d9d-bb02-1ec920dda045/renditions')
33+
.reply(200, {
34+
'list': {
35+
'pagination': {
36+
'count': 6,
37+
'hasMoreItems': false,
38+
'totalItems': 6,
39+
'skipCount': 0,
40+
'maxItems': 100
41+
},
42+
'entries': [{
43+
'entry': {
44+
'id': 'avatar',
45+
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
46+
'status': 'NOT_CREATED'
47+
}
48+
}, {
49+
'entry': {
50+
'id': 'avatar32',
51+
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
52+
'status': 'NOT_CREATED'
53+
}
54+
}, {
55+
'entry': {
56+
'id': 'doclib',
57+
'content': {'mimeType': 'image/png', 'mimeTypeName': 'PNG Image'},
58+
'status': 'NOT_CREATED'
59+
}
60+
}, {
61+
'entry': {
62+
'id': 'imgpreview',
63+
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
64+
'status': 'NOT_CREATED'
65+
}
66+
}, {
67+
'entry': {
68+
'id': 'medium',
69+
'content': {'mimeType': 'image/jpeg', 'mimeTypeName': 'JPEG Image'},
70+
'status': 'NOT_CREATED'
71+
}
72+
}, {
73+
'entry': {
74+
'id': 'pdf',
75+
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
76+
'status': 'NOT_CREATED'
77+
}
78+
}]
79+
}
80+
});
81+
}
82+
}
83+
module.exports = RenditionMock;

test/mockObjects/mockAlfrescoApi.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mockAlfrescoApi.Node = require('./alfresco/nodeMock.js');
66
mockAlfrescoApi.Upload = require('./alfresco/uploadMock.js');
77
mockAlfrescoApi.WebScript = require('./alfresco/webScriptMock.js');
88
mockAlfrescoApi.Tag = require('./alfresco/tagMock.js');
9+
mockAlfrescoApi.Rendition = require('./alfresco/renditionMock.js');
910

1011
//Bpm Mock
1112
mockAlfrescoApi.ActivitiMock = {};
@@ -15,4 +16,5 @@ mockAlfrescoApi.ActivitiMock.Tasks = require('./activiti/tasksMock.js');
1516
mockAlfrescoApi.ActivitiMock.Models = require('./activiti/modelsMock.js');
1617
mockAlfrescoApi.ActivitiMock.UserFilters = require('./activiti/userFiltersMock.js');
1718

19+
1820
module.exports = mockAlfrescoApi;

test/renditionApi.spec.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*global describe, it, beforeEach */
2+
3+
var AlfrescoApi = require('../main');
4+
var AuthResponseMock = require('../test/mockObjects/mockAlfrescoApi').Auth;
5+
var RenditionMock = require('../test/mockObjects/mockAlfrescoApi').Rendition;
6+
var expect = require('chai').expect;
7+
8+
describe('Rendition', function () {
9+
10+
beforeEach(function (done) {
11+
this.hostEcm = 'http://127.0.0.1:8080';
12+
13+
this.authResponseMock = new AuthResponseMock(this.hostEcm);
14+
this.renditionMock = new RenditionMock();
15+
16+
this.authResponseMock.get201Response();
17+
this.alfrescoJsApi = new AlfrescoApi({
18+
hostEcm: this.hostEcm
19+
});
20+
21+
this.alfrescoJsApi.login('admin', 'admin').then(() => {
22+
done();
23+
});
24+
});
25+
26+
it('Get Rendition', function (done) {
27+
this.renditionMock.get200RenditionResponse();
28+
29+
this.alfrescoJsApi.core.renditionsApi.getRendition('97a29e9c-1e4f-4d9d-bb02-1ec920dda045', 'pdf').then(function (data) {
30+
expect(data.entry.id).to.be.equal('pdf');
31+
done();
32+
}, function () {
33+
});
34+
});
35+
36+
it('Create Rendition', function (done) {
37+
this.renditionMock.createRendition200();
38+
39+
this.alfrescoJsApi.core.renditionsApi.createRendition('97a29e9c-1e4f-4d9d-bb02-1ec920dda045', {id: 'pdf'}).then(function () {
40+
done();
41+
}, function () {
42+
});
43+
});
44+
45+
it('Get Renditions list for node id', function (done) {
46+
this.renditionMock.get200RenditionList();
47+
48+
this.alfrescoJsApi.core.renditionsApi.getRenditions('97a29e9c-1e4f-4d9d-bb02-1ec920dda045').then(function (data) {
49+
expect(data.list.pagination.count).to.be.equal(6);
50+
expect(data.list.entries[0].entry.id).to.be.equal('avatar');
51+
done();
52+
}, function () {
53+
});
54+
});
55+
});

test/tagApi.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ describe('Tags', function () {
3131
expect(data.list.entries[0].entry.tag).to.be.equal('tag-test-1');
3232
expect(data.list.entries[1].entry.tag).to.be.equal('tag-test-2');
3333
done();
34-
}, function (error) {
35-
console.error(error);
36-
done();
34+
}, function () {
3735
});
3836
});
3937

0 commit comments

Comments
 (0)