@zimbra/api-client 89.0.0 → 91.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/dist/schema.graphql +164 -9
- package/dist/src/apollo/types.d.ts +8 -0
- package/dist/src/batch-client/index.d.ts +8 -4
- package/dist/src/normalize/entities.d.ts +2 -0
- package/dist/src/schema/generated-schema-types.d.ts +160 -1
- package/dist/src/utils/normalize-attrs-custommetadata.d.ts +1 -0
- package/dist/zm-api-js-client.esm.js +742 -487
- package/dist/zm-api-js-client.esm.js.map +1 -1
- package/dist/zm-api-js-client.js +5 -10
- package/dist/zm-api-js-client.js.map +1 -1
- package/dist/zm-api-js-client.umd.js +6 -11
- package/dist/zm-api-js-client.umd.js.map +1 -1
- package/package-lock.json +268 -158
- package/package.json +2 -2
- package/src/apollo/types.ts +9 -0
- package/src/apollo/zimbra-in-memory-cache.ts +6 -4
- package/src/batch-client/index.ts +116 -20
- package/src/normalize/entities.ts +12 -0
- package/src/schema/generated-schema-types.ts +191 -1
- package/src/schema/schema.graphql +164 -9
- package/src/schema/schema.ts +12 -3
- package/src/utils/normalize-attrs-custommetadata.ts +9 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zimbra/api-client",
|
|
3
3
|
"amdName": "zmApiJsClient",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "91.0.0",
|
|
5
5
|
"description": "Zimbra JS API Client and GraphQL client for making requests against the Zimbra SOAP API.",
|
|
6
6
|
"main": "dist/zm-api-js-client.js",
|
|
7
7
|
"source": "index.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@apollo/client": "3.4.16",
|
|
48
|
-
"@graphql-tools/schema": "^
|
|
48
|
+
"@graphql-tools/schema": "^10.0.3",
|
|
49
49
|
"dataloader": "^2.2.2",
|
|
50
50
|
"graphql": "^15.8.0",
|
|
51
51
|
"lodash": "^4.17.21",
|
package/src/apollo/types.ts
CHANGED
|
@@ -5,3 +5,12 @@ export interface LocalBatchLinkOptions extends BatchLink.Options {
|
|
|
5
5
|
context?: any;
|
|
6
6
|
schema: GraphQLSchema;
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export interface EmailAddress {
|
|
10
|
+
__typename?: 'EmailAddress';
|
|
11
|
+
address?: string;
|
|
12
|
+
displayName?: string;
|
|
13
|
+
isGroup?: boolean | null;
|
|
14
|
+
name?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defaultDataIdFromObject, InMemoryCache, InMemoryCacheConfig } from '@apollo/client/core';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
+
import isEqual from 'lodash/isEqual';
|
|
4
|
+
import uniqWith from 'lodash/uniqWith';
|
|
5
|
+
import { EmailAddress } from './types';
|
|
3
6
|
|
|
4
7
|
const dataIdFromPath = (result: any, path: string) => {
|
|
5
8
|
if (result.__typename) {
|
|
@@ -93,10 +96,9 @@ const typePolicies = {
|
|
|
93
96
|
MessageInfo: {
|
|
94
97
|
fields: {
|
|
95
98
|
emailAddresses: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
merge: false
|
|
99
|
+
merge(existing: EmailAddress[], incoming: EmailAddress[]) {
|
|
100
|
+
return uniqWith([...(existing || []), ...(incoming || [])], isEqual);
|
|
101
|
+
}
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
CreateMountpointRequest,
|
|
23
23
|
CreateSignatureRequest,
|
|
24
24
|
DiscoverRightsResponse,
|
|
25
|
+
DLActionEntity,
|
|
25
26
|
DlGroupMember,
|
|
26
27
|
DocumentActionData,
|
|
27
28
|
Filter,
|
|
@@ -67,6 +68,7 @@ import {
|
|
|
67
68
|
CreateTagInput,
|
|
68
69
|
DeleteAppointmentInput,
|
|
69
70
|
DeleteIdentityInput,
|
|
71
|
+
DistributionListActionInput,
|
|
70
72
|
EnableTwoFactorAuthInput,
|
|
71
73
|
ExternalAccountAddInput,
|
|
72
74
|
ExternalAccountImportInput,
|
|
@@ -87,6 +89,7 @@ import {
|
|
|
87
89
|
SaveSMimeCertInputUpload,
|
|
88
90
|
SearchFolderInput,
|
|
89
91
|
SendMessageInput,
|
|
92
|
+
SendTwoFactorAuthCodeInput,
|
|
90
93
|
ShareNotificationInput,
|
|
91
94
|
SignatureInput,
|
|
92
95
|
WhiteBlackListInput,
|
|
@@ -100,6 +103,7 @@ import {
|
|
|
100
103
|
import { mapValuesDeep } from '../utils/map-values-deep';
|
|
101
104
|
import {
|
|
102
105
|
normalizeCustomMetaDataAttrs,
|
|
106
|
+
normalizeHeaderAttrs,
|
|
103
107
|
setCustomMetaDataBody
|
|
104
108
|
} from '../utils/normalize-attrs-custommetadata';
|
|
105
109
|
import { normalizeEmailAddresses } from '../utils/normalize-email-addresses';
|
|
@@ -168,6 +172,9 @@ function normalizeMessage(
|
|
|
168
172
|
return entry;
|
|
169
173
|
});
|
|
170
174
|
}
|
|
175
|
+
if (message?._attrs) {
|
|
176
|
+
message._attrs = normalizeHeaderAttrs(message._attrs);
|
|
177
|
+
}
|
|
171
178
|
|
|
172
179
|
let normalizedMessage = normalize(MessageInfo)(message);
|
|
173
180
|
normalizedMessage = normalizedMessage && mapValuesDeep(normalizedMessage, coerceStringToBoolean);
|
|
@@ -333,30 +340,37 @@ export class ZimbraBatchClient {
|
|
|
333
340
|
body: {
|
|
334
341
|
sections: 'mbox,attrs,zimlets,props'
|
|
335
342
|
}
|
|
336
|
-
}).then(res =>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
343
|
+
}).then(res => {
|
|
344
|
+
const {
|
|
345
|
+
zimbraMailAlias,
|
|
346
|
+
zimbraTwoFactorAuthMethodAllowed,
|
|
347
|
+
zimbraTwoFactorAuthMethodEnabled
|
|
348
|
+
} = res?.attrs?._attrs || {};
|
|
349
|
+
return {
|
|
350
|
+
...res,
|
|
351
|
+
attrs: {
|
|
352
|
+
...mapValuesDeep(res?.attrs?._attrs, coerceStringToBoolean),
|
|
353
|
+
zimbraMailAlias: [].concat(zimbraMailAlias || []),
|
|
354
|
+
zimbraTwoFactorAuthMethodAllowed: [].concat(zimbraTwoFactorAuthMethodAllowed || []),
|
|
355
|
+
zimbraTwoFactorAuthMethodEnabled: [].concat(zimbraTwoFactorAuthMethodEnabled || [])
|
|
356
|
+
},
|
|
357
|
+
...(res?.license?.attr && {
|
|
358
|
+
license: {
|
|
359
|
+
status: res.license.status,
|
|
360
|
+
attr: mapValuesDeep(res.license.attr, coerceStringToBoolean)
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
363
|
+
zimlets: {
|
|
364
|
+
zimlet: res?.zimlets?.zimlet?.map(({ zimlet, zimletContext, zimletConfig }: any) => ({
|
|
352
365
|
zimlet,
|
|
353
366
|
zimletContext,
|
|
354
367
|
...(zimletConfig && {
|
|
355
368
|
zimletConfig: normalize(ZimletConfigEntity)(zimletConfig)
|
|
356
369
|
})
|
|
357
370
|
}))
|
|
358
|
-
|
|
359
|
-
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
});
|
|
360
374
|
|
|
361
375
|
public accountOnlyRemoteWipeSync = (deviceId: String) =>
|
|
362
376
|
this.jsonRequest({
|
|
@@ -757,10 +771,15 @@ export class ZimbraBatchClient {
|
|
|
757
771
|
singleRequest: true
|
|
758
772
|
}).then(Boolean);
|
|
759
773
|
|
|
760
|
-
public disableTwoFactorAuth = () =>
|
|
774
|
+
public disableTwoFactorAuth = (method: string) =>
|
|
761
775
|
this.jsonRequest({
|
|
762
776
|
name: 'DisableTwoFactorAuth',
|
|
763
777
|
namespace: Namespace.Account,
|
|
778
|
+
body: {
|
|
779
|
+
method: {
|
|
780
|
+
_content: method
|
|
781
|
+
}
|
|
782
|
+
},
|
|
764
783
|
singleRequest: true
|
|
765
784
|
}).then(Boolean);
|
|
766
785
|
|
|
@@ -783,6 +802,16 @@ export class ZimbraBatchClient {
|
|
|
783
802
|
singleRequest: true
|
|
784
803
|
}).then(Boolean);
|
|
785
804
|
|
|
805
|
+
public distributionListAction = ({ action, dl }: DistributionListActionInput) =>
|
|
806
|
+
this.jsonRequest({
|
|
807
|
+
name: 'DistributionListAction',
|
|
808
|
+
body: {
|
|
809
|
+
action: denormalize(DLActionEntity)(action),
|
|
810
|
+
dl
|
|
811
|
+
},
|
|
812
|
+
namespace: Namespace.Account
|
|
813
|
+
}).then(Boolean);
|
|
814
|
+
|
|
786
815
|
public documentAction = (options: ActionOptions) =>
|
|
787
816
|
this.documentActionResponse(ActionType.document, options);
|
|
788
817
|
|
|
@@ -826,6 +855,8 @@ export class ZimbraBatchClient {
|
|
|
826
855
|
|
|
827
856
|
public enableTwoFactorAuth = ({
|
|
828
857
|
name,
|
|
858
|
+
email,
|
|
859
|
+
method,
|
|
829
860
|
password,
|
|
830
861
|
authToken,
|
|
831
862
|
twoFactorCode,
|
|
@@ -838,6 +869,16 @@ export class ZimbraBatchClient {
|
|
|
838
869
|
name: {
|
|
839
870
|
_content: name
|
|
840
871
|
},
|
|
872
|
+
...(email && {
|
|
873
|
+
email: {
|
|
874
|
+
_content: email
|
|
875
|
+
}
|
|
876
|
+
}),
|
|
877
|
+
...(method && {
|
|
878
|
+
method: {
|
|
879
|
+
_content: method
|
|
880
|
+
}
|
|
881
|
+
}),
|
|
841
882
|
...(password && {
|
|
842
883
|
password: {
|
|
843
884
|
_content: password
|
|
@@ -1044,6 +1085,20 @@ export class ZimbraBatchClient {
|
|
|
1044
1085
|
namespace: Namespace.Sync
|
|
1045
1086
|
}).then(res => get(res, 'device') || []);
|
|
1046
1087
|
|
|
1088
|
+
public getDistributionList = (dl: String, needOwners: Boolean, needRights: String, by: String) =>
|
|
1089
|
+
this.jsonRequest({
|
|
1090
|
+
name: 'GetDistributionList',
|
|
1091
|
+
body: {
|
|
1092
|
+
dl: {
|
|
1093
|
+
by,
|
|
1094
|
+
_content: dl
|
|
1095
|
+
},
|
|
1096
|
+
needOwners,
|
|
1097
|
+
needRights
|
|
1098
|
+
},
|
|
1099
|
+
namespace: Namespace.Account
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1047
1102
|
public getDistributionListMembers = (limit: String, offset: String, dl: String) =>
|
|
1048
1103
|
this.jsonRequest({
|
|
1049
1104
|
name: 'GetDistributionListMembers',
|
|
@@ -1451,7 +1506,19 @@ export class ZimbraBatchClient {
|
|
|
1451
1506
|
...(deviceTrusted && { deviceTrusted })
|
|
1452
1507
|
},
|
|
1453
1508
|
namespace: Namespace.Account
|
|
1454
|
-
}).then(res =>
|
|
1509
|
+
}).then(res => {
|
|
1510
|
+
const zimbraTwoFactorAuthMethodAllowed = (
|
|
1511
|
+
res?.zimbraTwoFactorAuthMethodAllowed?.method || []
|
|
1512
|
+
).map((m: any) => m._content);
|
|
1513
|
+
const zimbraTwoFactorAuthMethodEnabled = (
|
|
1514
|
+
res?.zimbraTwoFactorAuthMethodEnabled?.method || []
|
|
1515
|
+
).map((m: any) => m._content);
|
|
1516
|
+
return {
|
|
1517
|
+
...mapValuesDeep(res, coerceStringToBoolean),
|
|
1518
|
+
...(zimbraTwoFactorAuthMethodAllowed && { zimbraTwoFactorAuthMethodAllowed }),
|
|
1519
|
+
...(zimbraTwoFactorAuthMethodEnabled && { zimbraTwoFactorAuthMethodEnabled })
|
|
1520
|
+
};
|
|
1521
|
+
});
|
|
1455
1522
|
|
|
1456
1523
|
public logout = () =>
|
|
1457
1524
|
this.jsonRequest({
|
|
@@ -1855,6 +1922,22 @@ export class ZimbraBatchClient {
|
|
|
1855
1922
|
singleRequest: true
|
|
1856
1923
|
}).then(Boolean);
|
|
1857
1924
|
|
|
1925
|
+
public sendTwoFactorAuthCode = ({ action, authToken }: SendTwoFactorAuthCodeInput) => {
|
|
1926
|
+
return this.jsonRequest({
|
|
1927
|
+
name: 'SendTwoFactorAuthCode',
|
|
1928
|
+
namespace: Namespace.Account,
|
|
1929
|
+
body: {
|
|
1930
|
+
action: {
|
|
1931
|
+
_content: action
|
|
1932
|
+
},
|
|
1933
|
+
authToken: {
|
|
1934
|
+
_content: authToken
|
|
1935
|
+
}
|
|
1936
|
+
},
|
|
1937
|
+
singleRequest: true
|
|
1938
|
+
});
|
|
1939
|
+
};
|
|
1940
|
+
|
|
1858
1941
|
public setCsrfToken = (csrfToken: string) => {
|
|
1859
1942
|
this.csrfToken = csrfToken;
|
|
1860
1943
|
};
|
|
@@ -1899,6 +1982,19 @@ export class ZimbraBatchClient {
|
|
|
1899
1982
|
singleRequest: true
|
|
1900
1983
|
}).then(Boolean);
|
|
1901
1984
|
|
|
1985
|
+
public subscribeDistributionList = (op: String, by: String, dl: String) =>
|
|
1986
|
+
this.jsonRequest({
|
|
1987
|
+
name: 'SubscribeDistributionList',
|
|
1988
|
+
body: {
|
|
1989
|
+
dl: {
|
|
1990
|
+
by,
|
|
1991
|
+
_content: dl
|
|
1992
|
+
},
|
|
1993
|
+
op
|
|
1994
|
+
},
|
|
1995
|
+
namespace: Namespace.Account
|
|
1996
|
+
}).then(res => res.status || '');
|
|
1997
|
+
|
|
1902
1998
|
public taskFolders = () =>
|
|
1903
1999
|
this.jsonRequest({
|
|
1904
2000
|
name: 'GetFolder',
|
|
@@ -243,6 +243,7 @@ const commonMailItemFields = {
|
|
|
243
243
|
inv: ['invitations', InviteInfo],
|
|
244
244
|
mp: ['mimeParts', MimePart],
|
|
245
245
|
shr: 'share',
|
|
246
|
+
dlSubs: 'subscribe',
|
|
246
247
|
su: 'subject',
|
|
247
248
|
origid: 'origId',
|
|
248
249
|
attach: ['attachments', AttachmentsInfo],
|
|
@@ -775,3 +776,14 @@ export const ActionData = new Entity({
|
|
|
775
776
|
export const DocumentActionData = new Entity({
|
|
776
777
|
action: ['action', ActionData]
|
|
777
778
|
});
|
|
779
|
+
|
|
780
|
+
export const DLActionAttrEntity = new Entity({
|
|
781
|
+
n: 'attributeName',
|
|
782
|
+
_content: 'content'
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
export const DLActionEntity = new Entity({
|
|
786
|
+
op: 'operation',
|
|
787
|
+
a: ['attributes', DLActionAttrEntity],
|
|
788
|
+
dlm: 'distributionListMembers'
|
|
789
|
+
});
|