@zimbra/api-client 65.0.0 → 69.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.json +16 -16
- package/.husky/pre-commit +2 -1
- package/dist/schema.graphql +10 -0
- package/dist/src/apollo/offline-queue-link/index.d.ts +2 -2
- package/dist/src/batch-client/index.d.ts +2 -0
- package/dist/src/batch-client/types.d.ts +1 -1
- package/dist/src/request/types.d.ts +1 -1
- package/dist/src/schema/generated-schema-types.d.ts +1056 -1048
- package/dist/zm-api-js-client.esm.js +1108 -1079
- package/dist/zm-api-js-client.esm.js.map +1 -1
- package/dist/zm-api-js-client.js +1 -1
- package/dist/zm-api-js-client.js.map +1 -1
- package/dist/zm-api-js-client.umd.js +1 -1
- package/dist/zm-api-js-client.umd.js.map +1 -1
- package/package-lock.json +2746 -5538
- package/package.json +92 -94
- package/src/apollo/offline-queue-link/index.ts +1 -1
- package/src/apollo/zimbra-in-memory-cache.ts +36 -0
- package/src/batch-client/index.ts +16 -8
- package/src/batch-client/types.ts +1 -1
- package/src/request/index.ts +2 -2
- package/src/request/types.ts +1 -1
- package/src/schema/generated-schema-types.ts +1108 -1100
- package/src/schema/schema.graphql +10 -0
- package/src/schema/schema.ts +10 -4
- package/src/utils/normalize-mime-parts.ts +1 -4
- package/src/utils/normalize-otherAttribute-contact.ts +2 -0
- package/tsconfig.json +21 -21
- package/tslint.json +18 -18
package/package.json
CHANGED
|
@@ -1,96 +1,94 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"uglify-js": "^3.12.1"
|
|
95
|
-
}
|
|
2
|
+
"name": "@zimbra/api-client",
|
|
3
|
+
"amdName": "zmApiJsClient",
|
|
4
|
+
"version": "69.0.0",
|
|
5
|
+
"description": "Zimbra JS API Client and GraphQL client for making requests against the Zimbra SOAP API.",
|
|
6
|
+
"main": "dist/zm-api-js-client.js",
|
|
7
|
+
"source": "index.ts",
|
|
8
|
+
"module": "dist/zm-api-js-client.esm.js",
|
|
9
|
+
"umd:main": "dist/zm-api-js-client.umd.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"generateSchemaTypes": "rimraf src/schema/generated-schema-types.ts && graphql-codegen",
|
|
13
|
+
"lint": "tslint --project .",
|
|
14
|
+
"lint:fix": "npm run lint -- --fix",
|
|
15
|
+
"test:unit": "BABEL_ENV=test mocha --require ./babelRegisterConfig.js test/**/*.js",
|
|
16
|
+
"test:watch": "npm run test:unit -- --watch",
|
|
17
|
+
"test:no-synacor-npm-refs": "node ./scripts/synacor-npm-refs.js",
|
|
18
|
+
"clean": "rimraf dist",
|
|
19
|
+
"build": "npm-run-all clean generateSchemaTypes rollup:* -p build:ts minify:* copySchema",
|
|
20
|
+
"build:ts": "tsc --emitDeclarationOnly --declaration --outDir \"dist\"",
|
|
21
|
+
"copySchema": "copyfiles -f src/schema/schema.graphql dist",
|
|
22
|
+
"rollup:cjs": "cross-var rollup -c rollup.config.js -m -f cjs -n $npm_package_amdName $npm_package_source -o $npm_package_main",
|
|
23
|
+
"rollup:umd": "cross-var rollup -c rollup.config.js -m -f umd -n $npm_package_amdName $npm_package_source -o $npm_package_umd_main",
|
|
24
|
+
"rollup:esm": "cross-var rollup -c rollup.config.js -m -f es --environment FORMAT:es -n $npm_package_amdName $npm_package_source -o $npm_package_module",
|
|
25
|
+
"linkedBuild": "npm run rollup:esm -- --watch",
|
|
26
|
+
"minify:cjs": "cross-var uglifyjs $npm_package_main -c pure_getters,pure_funcs=classCallCheck -m toplevel,reserved=['_createClass'] --keep-fnames -o $npm_package_main --source-map content=$npm_package_main.map,url=zm-api-js-client.js.map,filename=$npm_package_main.map",
|
|
27
|
+
"minify:umd": "cross-var uglifyjs $npm_package_umd_main -c pure_getters,pure_funcs=classCallCheck -m toplevel,reserved=['_createClass'] --keep-fnames -o $npm_package_umd_main --source-map content=$npm_package_umd_main.map,url=zm-api-js-client.umd.js.map,filename=$npm_package_umd_main.map",
|
|
28
|
+
"size": "echo \"Gzipped Size: $(gzip-size $npm_package_main | pretty-bytes)\"",
|
|
29
|
+
"prepublishOnly": "npm test && npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags",
|
|
30
|
+
"publish:beta": "npm publish --tag=beta",
|
|
31
|
+
"security:audit": "audit-ci --moderate --report-type summary --pass-enoaudit --skip-dev",
|
|
32
|
+
"prepare": "is-ci || husky install"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"zimbra",
|
|
36
|
+
"api",
|
|
37
|
+
"graphql"
|
|
38
|
+
],
|
|
39
|
+
"repository": "Zimbra/zm-api-js-client",
|
|
40
|
+
"license": "BSD-3-Clause",
|
|
41
|
+
"lint-staged": {
|
|
42
|
+
"**/*.ts": [
|
|
43
|
+
"tslint"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@apollo/client": "^3.4.16",
|
|
48
|
+
"dataloader": "^2.0.0",
|
|
49
|
+
"graphql": "^15.6.1",
|
|
50
|
+
"graphql-tools": "^8.2.0",
|
|
51
|
+
"lodash": "^4.17.21",
|
|
52
|
+
"mitt": "^3.0.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@babel/cli": "^7.15.7",
|
|
56
|
+
"@babel/core": "^7.15.8",
|
|
57
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
58
|
+
"@babel/preset-env": "^7.15.8",
|
|
59
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
60
|
+
"@babel/register": "^7.15.3",
|
|
61
|
+
"@graphql-codegen/cli": "^2.2.0",
|
|
62
|
+
"@graphql-codegen/typescript": "^2.2.2",
|
|
63
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
64
|
+
"@rollup/plugin-commonjs": "^21.0.0",
|
|
65
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
66
|
+
"@rollup/plugin-typescript": "^8.2.5",
|
|
67
|
+
"@types/graphql": "^14.5.0",
|
|
68
|
+
"@types/lodash": "^4.14.175",
|
|
69
|
+
"@types/node": "^16.10.3",
|
|
70
|
+
"@types/whatwg-fetch": "^0.0.33",
|
|
71
|
+
"audit-ci": "^4.1.0",
|
|
72
|
+
"babel-plugin-lodash": "^3.3.4",
|
|
73
|
+
"chai": "^4.3.4",
|
|
74
|
+
"copyfiles": "^2.4.1",
|
|
75
|
+
"cross-var": "^1.1.0",
|
|
76
|
+
"file-matcher": "^1.3.0",
|
|
77
|
+
"husky": "^7.0.2",
|
|
78
|
+
"is-ci": "^3.0.0",
|
|
79
|
+
"lint-staged": "^11.2.0",
|
|
80
|
+
"mocha": "^9.1.2",
|
|
81
|
+
"npm-run-all": "^4.1.5",
|
|
82
|
+
"prettier": "^2.4.1",
|
|
83
|
+
"rimraf": "^3.0.2",
|
|
84
|
+
"rollup": "^2.58.0",
|
|
85
|
+
"rollup-plugin-graphql": "^0.1.0",
|
|
86
|
+
"rollup-plugin-local-resolve": "^1.0.7",
|
|
87
|
+
"tslib": "^2.3.1",
|
|
88
|
+
"tslint": "^5.20.1",
|
|
89
|
+
"tslint-config-prettier": "^1.18.0",
|
|
90
|
+
"tslint-plugin-prettier": "^2.3.0",
|
|
91
|
+
"typescript": "^4.4.3",
|
|
92
|
+
"uglify-js": "^3.14.2"
|
|
93
|
+
}
|
|
96
94
|
}
|
|
@@ -127,7 +127,7 @@ export class OfflineQueueLink extends ApolloLink {
|
|
|
127
127
|
// Returns a Promise that resolves after all operations are processed
|
|
128
128
|
// regardless of success.
|
|
129
129
|
retry = () =>
|
|
130
|
-
new Promise(resolve => {
|
|
130
|
+
new Promise<void>(resolve => {
|
|
131
131
|
let outstandingReqs = this.operationQueue.length;
|
|
132
132
|
if (!outstandingReqs) {
|
|
133
133
|
return resolve();
|
|
@@ -20,6 +20,9 @@ const dataIdFromObject = (object: any) => {
|
|
|
20
20
|
// `zwc:implicit`.
|
|
21
21
|
return dataIdFromPath(object, 'meta.0.section');
|
|
22
22
|
case 'Folder':
|
|
23
|
+
if (object.local && object.local !== null) {
|
|
24
|
+
return `${defaultDataIdFromObject(object)}:local`;
|
|
25
|
+
}
|
|
23
26
|
if (object.id === '1') {
|
|
24
27
|
// Cache the root folder based on both ID and UUID from server
|
|
25
28
|
return `${object.__typename}:${object.id}:${object.uuid}`;
|
|
@@ -52,6 +55,39 @@ const typePolicies = {
|
|
|
52
55
|
merge: true
|
|
53
56
|
}
|
|
54
57
|
}
|
|
58
|
+
},
|
|
59
|
+
Contact: {
|
|
60
|
+
fields: {
|
|
61
|
+
attributes: {
|
|
62
|
+
merge: true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
Conversation: {
|
|
67
|
+
fields: {
|
|
68
|
+
messages: {
|
|
69
|
+
// @TODO ideally we should write proper merge function here,
|
|
70
|
+
// but as our app is already handling at caller level
|
|
71
|
+
// we are just overwriting cache data here
|
|
72
|
+
merge: false
|
|
73
|
+
},
|
|
74
|
+
emailAddresses: {
|
|
75
|
+
// @TODO ideally we should write proper merge function here,
|
|
76
|
+
// but as our app is already handling at caller level
|
|
77
|
+
// we are just overwriting cache data here
|
|
78
|
+
merge: false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
MessageInfo: {
|
|
83
|
+
fields: {
|
|
84
|
+
emailAddresses: {
|
|
85
|
+
// @TODO ideally we should write proper merge function here,
|
|
86
|
+
// but as our app is already handling at caller level
|
|
87
|
+
// we are just overwriting cache data here
|
|
88
|
+
merge: false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
55
91
|
}
|
|
56
92
|
};
|
|
57
93
|
|
|
@@ -280,6 +280,7 @@ export class ZimbraBatchClient {
|
|
|
280
280
|
private authToken?: string;
|
|
281
281
|
private batchDataLoader: DataLoader<RequestOptions, RequestBody>;
|
|
282
282
|
private csrfToken?: string;
|
|
283
|
+
private customFetch: any;
|
|
283
284
|
private dataLoader: DataLoader<RequestOptions, RequestBody>;
|
|
284
285
|
private jwtToken?: string;
|
|
285
286
|
private sessionHandler?: SessionHandler;
|
|
@@ -294,6 +295,7 @@ export class ZimbraBatchClient {
|
|
|
294
295
|
this.origin = options.zimbraOrigin !== undefined ? options.zimbraOrigin : DEFAULT_HOSTNAME;
|
|
295
296
|
this.soapPathname = options.soapPathname || DEFAULT_SOAP_PATHNAME;
|
|
296
297
|
this.localStoreClient = options.localStoreClient;
|
|
298
|
+
this.customFetch = options.customFetch;
|
|
297
299
|
|
|
298
300
|
this.notifier = new Notifier();
|
|
299
301
|
|
|
@@ -308,8 +310,8 @@ export class ZimbraBatchClient {
|
|
|
308
310
|
cache: false
|
|
309
311
|
});
|
|
310
312
|
|
|
311
|
-
if (
|
|
312
|
-
setCustomFetch(
|
|
313
|
+
if (this.customFetch) {
|
|
314
|
+
setCustomFetch(this.customFetch);
|
|
313
315
|
}
|
|
314
316
|
}
|
|
315
317
|
|
|
@@ -433,6 +435,9 @@ export class ZimbraBatchClient {
|
|
|
433
435
|
return ids ? ids.split(',') : [];
|
|
434
436
|
});
|
|
435
437
|
|
|
438
|
+
// For offline Drafts
|
|
439
|
+
public attach = (files: any, message: any) => this.localStoreClient.attach({ files, message });
|
|
440
|
+
|
|
436
441
|
public autoComplete = (options: AutoCompleteOptions) =>
|
|
437
442
|
this.jsonRequest({
|
|
438
443
|
name: 'AutoComplete',
|
|
@@ -1301,7 +1306,7 @@ export class ZimbraBatchClient {
|
|
|
1301
1306
|
password,
|
|
1302
1307
|
recoveryCode,
|
|
1303
1308
|
tokenType,
|
|
1304
|
-
persistAuthTokenCookie
|
|
1309
|
+
persistAuthTokenCookie,
|
|
1305
1310
|
twoFactorCode,
|
|
1306
1311
|
deviceTrusted,
|
|
1307
1312
|
csrfTokenSecured
|
|
@@ -1758,20 +1763,23 @@ export class ZimbraBatchClient {
|
|
|
1758
1763
|
const filename = 'message.eml';
|
|
1759
1764
|
const contentType = 'message/rfc822';
|
|
1760
1765
|
|
|
1761
|
-
return fetch(`${this.origin}/service/upload?fmt=raw`, {
|
|
1766
|
+
return (this.customFetch || fetch)(`${this.origin}/service/upload?fmt=raw`, {
|
|
1762
1767
|
method: 'POST',
|
|
1763
1768
|
body: message,
|
|
1764
1769
|
headers: {
|
|
1765
1770
|
'Content-Disposition': `${contentDisposition}; filename="${filename}"`,
|
|
1766
1771
|
'Content-Type': contentType,
|
|
1772
|
+
...(this.authToken && {
|
|
1773
|
+
Cookie: `ZM_AUTH_TOKEN=${this.authToken}`
|
|
1774
|
+
}),
|
|
1767
1775
|
...(this.csrfToken && {
|
|
1768
1776
|
'X-Zimbra-Csrf-Token': this.csrfToken
|
|
1769
1777
|
})
|
|
1770
1778
|
},
|
|
1771
1779
|
credentials: 'include'
|
|
1772
|
-
}).then(response => {
|
|
1780
|
+
}).then((response: any) => {
|
|
1773
1781
|
if (response.ok) {
|
|
1774
|
-
return response.text().then(result => {
|
|
1782
|
+
return response.text().then((result: any) => {
|
|
1775
1783
|
if (!result) {
|
|
1776
1784
|
return null;
|
|
1777
1785
|
}
|
|
@@ -1792,7 +1800,7 @@ export class ZimbraBatchClient {
|
|
|
1792
1800
|
});
|
|
1793
1801
|
};
|
|
1794
1802
|
|
|
1795
|
-
private batchDataHandler = (requests:
|
|
1803
|
+
private batchDataHandler = (requests: ReadonlyArray<RequestOptions>) =>
|
|
1796
1804
|
batchJsonRequest({
|
|
1797
1805
|
requests,
|
|
1798
1806
|
...this.getAdditionalRequestOptions()
|
|
@@ -1829,7 +1837,7 @@ export class ZimbraBatchClient {
|
|
|
1829
1837
|
}
|
|
1830
1838
|
};
|
|
1831
1839
|
|
|
1832
|
-
private dataHandler = (requests:
|
|
1840
|
+
private dataHandler = (requests: ReadonlyArray<JsonRequestOptions>) =>
|
|
1833
1841
|
jsonRequest({
|
|
1834
1842
|
...requests[0],
|
|
1835
1843
|
// check if login request then don't add csrfToken
|
|
@@ -193,6 +193,7 @@ export interface SearchOptions {
|
|
|
193
193
|
fullConversation?: boolean;
|
|
194
194
|
inDumpster?: boolean;
|
|
195
195
|
limit?: number;
|
|
196
|
+
name?: string;
|
|
196
197
|
needExp?: boolean;
|
|
197
198
|
needIsMember?: NeedIsMemberType;
|
|
198
199
|
needIsOwner?: boolean;
|
|
@@ -202,7 +203,6 @@ export interface SearchOptions {
|
|
|
202
203
|
sortBy?: SortBy;
|
|
203
204
|
type?: GalSearchType;
|
|
204
205
|
types?: SearchType;
|
|
205
|
-
name?: string;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
export interface SearchCalendarResourcesCondition {
|
package/src/request/index.ts
CHANGED
|
@@ -54,7 +54,7 @@ function _responseParseHandler(response: Response): Promise<ParsedResponse> {
|
|
|
54
54
|
return response;
|
|
55
55
|
});
|
|
56
56
|
} catch (e) {
|
|
57
|
-
(response as ParsedResponse).parseError = e;
|
|
57
|
+
(response as ParsedResponse).parseError = <any>e;
|
|
58
58
|
return Promise.resolve(response);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -97,7 +97,7 @@ function faultError(response: ParsedResponse, faults: any) {
|
|
|
97
97
|
* Create one key per SOAP command name, with a value
|
|
98
98
|
* containing an array of the requests for that command.
|
|
99
99
|
*/
|
|
100
|
-
function batchBody(requests:
|
|
100
|
+
function batchBody(requests: ReadonlyArray<RequestOptions>) {
|
|
101
101
|
return reduce(
|
|
102
102
|
requests,
|
|
103
103
|
(body: { [key: string]: any }, request) => {
|
package/src/request/types.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface RequestOptions {
|
|
|
39
39
|
export interface JsonRequestOptions extends BaseRequestOptions, RequestOptions {}
|
|
40
40
|
|
|
41
41
|
export interface BatchRequestOptions extends BaseRequestOptions {
|
|
42
|
-
requests:
|
|
42
|
+
requests: ReadonlyArray<RequestOptions>;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface RequestResponse {
|