@zimbra/api-client 78.0.0-beta → 80.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zimbra/api-client",
3
3
  "amdName": "zmApiJsClient",
4
- "version": "78.0.0-beta",
4
+ "version": "80.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",
@@ -46,7 +46,7 @@
46
46
  "@apollo/client": "^3.4.16",
47
47
  "dataloader": "^2.1.0",
48
48
  "graphql": "^15.8.0",
49
- "graphql-tools": "^8.2.8",
49
+ "graphql-tools": "^8.2.9",
50
50
  "lodash": "^4.17.21",
51
51
  "mitt": "^3.0.0"
52
52
  },
@@ -58,21 +58,21 @@
58
58
  "@babel/preset-typescript": "^7.16.7",
59
59
  "@babel/register": "^7.17.7",
60
60
  "@graphql-codegen/cli": "^2.6.2",
61
- "@graphql-codegen/typescript": "^2.4.10",
61
+ "@graphql-codegen/typescript": "^2.4.11",
62
62
  "@rollup/plugin-babel": "^5.3.1",
63
63
  "@rollup/plugin-commonjs": "^22.0.0",
64
64
  "@rollup/plugin-node-resolve": "^13.3.0",
65
65
  "@rollup/plugin-typescript": "^8.3.2",
66
66
  "@types/graphql": "^14.5.0",
67
67
  "@types/lodash": "^4.14.182",
68
- "@types/node": "^17.0.31",
68
+ "@types/node": "^17.0.32",
69
69
  "@types/whatwg-fetch": "^0.0.33",
70
70
  "audit-ci": "^6.2.0",
71
71
  "babel-plugin-lodash": "^3.3.4",
72
72
  "chai": "^4.3.6",
73
73
  "copyfiles": "^2.4.1",
74
74
  "cross-var": "^1.1.0",
75
- "husky": "^8.0.0",
75
+ "husky": "^8.0.1",
76
76
  "is-ci": "^3.0.1",
77
77
  "lint-staged": "^12.4.1",
78
78
  "mocha": "^10.0.0",
@@ -87,6 +87,6 @@
87
87
  "tslint-config-prettier": "^1.18.0",
88
88
  "tslint-plugin-prettier": "^2.3.0",
89
89
  "typescript": "^4.6.4",
90
- "uglify-js": "^3.15.4"
90
+ "uglify-js": "^3.15.5"
91
91
  }
92
92
  }
@@ -1,4 +1,4 @@
1
- import { ApolloLink, FetchResult, Observable, Operation } from '@apollo/client';
1
+ import { ApolloLink, FetchResult, Observable, Operation } from '@apollo/client/core';
2
2
  import { BatchLink } from '@apollo/client/link/batch';
3
3
  import { graphql, print } from 'graphql';
4
4
  import events from 'mitt';
@@ -1,4 +1,11 @@
1
- import { ApolloLink, FetchResult, NextLink, Observable, Observer, Operation } from '@apollo/client';
1
+ import {
2
+ ApolloLink,
3
+ FetchResult,
4
+ NextLink,
5
+ Observable,
6
+ Observer,
7
+ Operation
8
+ } from '@apollo/client/core';
2
9
 
3
10
  import { SyncOfflineOperations } from '../sync-offline-operations';
4
11
  import { OfflineQueueLinkOptions, OperationEntry, StorageProvider } from './types';
@@ -1,5 +1,4 @@
1
- import { FetchResult, NextLink, Operation } from '@apollo/client';
2
- import { Observer } from '@apollo/client';
1
+ import { FetchResult, NextLink, Observer, Operation } from '@apollo/client/core';
3
2
 
4
3
  export interface OfflineQueueLinkOptions {
5
4
  isOpen?: boolean;
@@ -1,4 +1,4 @@
1
- import { Operation } from '@apollo/client';
1
+ import { Operation } from '@apollo/client/core';
2
2
  import get from 'lodash/get';
3
3
  import { OfflineOperationEntry, OperationEntry } from './types';
4
4
 
@@ -1,4 +1,4 @@
1
- import { defaultDataIdFromObject, InMemoryCache, InMemoryCacheConfig } from '@apollo/client';
1
+ import { defaultDataIdFromObject, InMemoryCache, InMemoryCacheConfig } from '@apollo/client/core';
2
2
  import get from 'lodash/get';
3
3
 
4
4
  const dataIdFromPath = (result: any, path: string) => {
@@ -43,6 +43,8 @@ const dataIdFromObject = (object: any) => {
43
43
  return defaultDataIdFromObject(object);
44
44
  case 'SMimeMessage':
45
45
  return `${defaultDataIdFromObject(object)}:${object.isSecure}`;
46
+ case 'Document':
47
+ return `${defaultDataIdFromObject(object)}:${object.version}`;
46
48
  default:
47
49
  return defaultDataIdFromObject(object);
48
50
  }
@@ -37,6 +37,7 @@ import {
37
37
  GetRightsRequest,
38
38
  HabGroup,
39
39
  InviteReply,
40
+ ListDocumentRevisions,
40
41
  MessageInfo,
41
42
  SaveDocument,
42
43
  SaveDocuments,
@@ -541,7 +542,7 @@ export class ZimbraBatchClient {
541
542
  },
542
543
  singleRequest: true,
543
544
  namespace: Namespace.Account
544
- }).then(res => normalize(ClientInfoResponse)(res));
545
+ }).then(res => normalize(ClientInfoResponse)(mapValuesDeep(res, coerceStringToBoolean)));
545
546
 
546
547
  public contactAction = (options: ActionOptions) => this.action(ActionType.contact, options);
547
548
 
@@ -682,8 +683,7 @@ export class ZimbraBatchClient {
682
683
  this.jsonRequest({
683
684
  name: 'CreateSignature',
684
685
  namespace: Namespace.Account,
685
- body: denormalize(CreateSignatureRequest)(options),
686
- singleRequest: true
686
+ body: denormalize(CreateSignatureRequest)(options)
687
687
  });
688
688
 
689
689
  public createTag = (tag: CreateTagInput) =>
@@ -850,6 +850,41 @@ export class ZimbraBatchClient {
850
850
  singleRequest: true
851
851
  });
852
852
 
853
+ public endSessionBeaconRequest = (options: JsonRequestOptions) => {
854
+ const body = {
855
+ Body: {
856
+ EndSessionRequest: {
857
+ _jsns: Namespace.Account
858
+ }
859
+ },
860
+ Header: {
861
+ context: {
862
+ _jsns: Namespace.All,
863
+ csrfToken: this.csrfToken,
864
+ account: {
865
+ by: 'name',
866
+ _content: options.accountName
867
+ },
868
+ session: {
869
+ id: this.sessionId,
870
+ _content: this.sessionId
871
+ },
872
+ userAgent: this.userAgent
873
+ }
874
+ }
875
+ };
876
+
877
+ try {
878
+ const blob = new Blob([JSON.stringify(body)]);
879
+ if (navigator) {
880
+ // In zimbra desktop client navigator is null
881
+ navigator.sendBeacon(`${this.origin}/service/soap`, blob);
882
+ }
883
+ } catch (e) {
884
+ throw new Error('Error on endSessionBeaconRequest request' + e);
885
+ }
886
+ };
887
+
853
888
  public folderAction = (options: ActionOptions) => this.action(ActionType.folder, options);
854
889
 
855
890
  public forwardAppointment = (body: ForwardAppointmentInput) =>
@@ -1318,6 +1353,33 @@ export class ZimbraBatchClient {
1318
1353
  // If account name is present that means we will not be able to batch requests
1319
1354
  this[options.singleRequest ? 'dataLoader' : 'batchDataLoader'].load(options);
1320
1355
 
1356
+ public listDocumentRevisions = ({ id, version, count }: any) =>
1357
+ this.jsonRequest({
1358
+ name: 'ListDocumentRevisions',
1359
+ namespace: Namespace.Mail,
1360
+ body: {
1361
+ doc: {
1362
+ id,
1363
+ ver: version,
1364
+ count
1365
+ }
1366
+ }
1367
+ }).then(response => {
1368
+ const data = normalize(ListDocumentRevisions)(response);
1369
+ const versionIds = data.documents.map((doc: any) => doc.version);
1370
+ const maxVersion = Math.max(...versionIds);
1371
+ const latestDocumentVersion = data.documents.find((doc: any) => doc.version === maxVersion);
1372
+ const versionDocuments = data.documents.map((versionDoc: any) => ({
1373
+ ...versionDoc,
1374
+ name: latestDocumentVersion.name
1375
+ }));
1376
+
1377
+ return {
1378
+ ...latestDocumentVersion,
1379
+ docs: versionDocuments
1380
+ };
1381
+ });
1382
+
1321
1383
  public login = ({
1322
1384
  username,
1323
1385
  password,
@@ -1525,6 +1587,20 @@ export class ZimbraBatchClient {
1525
1587
  fetchOptions
1526
1588
  }).then(resp => resp);
1527
1589
 
1590
+ public purgeRevision = ({ id, ver, includeOlderRevisions }: any) =>
1591
+ this.jsonRequest({
1592
+ name: 'PurgeRevision',
1593
+ namespace: Namespace.Mail,
1594
+ body: {
1595
+ revision: {
1596
+ id,
1597
+ ver,
1598
+ includeOlderRevisions
1599
+ }
1600
+ },
1601
+ singleRequest: true
1602
+ }).then(Boolean);
1603
+
1528
1604
  public quarantineDeviceSync = (deviceId: String) =>
1529
1605
  this.jsonRequest({
1530
1606
  name: 'QuarantineDevice',
@@ -1594,7 +1670,7 @@ export class ZimbraBatchClient {
1594
1670
  cancelResetPassword
1595
1671
  },
1596
1672
  singleRequest: true
1597
- });
1673
+ }).then(res => mapValuesDeep(res, coerceStringToBoolean));
1598
1674
 
1599
1675
  public resolve = (path: string) => `${this.origin}${path}`;
1600
1676
 
@@ -524,6 +524,10 @@ export const Document = new Entity({
524
524
  f: 'flags'
525
525
  });
526
526
 
527
+ export const ListDocumentRevisions = new Entity({
528
+ doc: ['documents', Document]
529
+ });
530
+
527
531
  export const MessagePartInputForDocuments = new Entity({
528
532
  id: 'messageId',
529
533
  part: 'attachmentPart'
@@ -535,7 +539,8 @@ export const SaveDocument = new Entity({
535
539
  ver: 'version', //same item may have different versions (i.e same names) will need to implement ListDocumentRevisionsRequest
536
540
  ct: 'contentType',
537
541
  descEnabled: 'descriptionEnabled',
538
- m: ['messageData', MessagePartInputForDocuments]
542
+ m: ['messageData', MessagePartInputForDocuments],
543
+ doc: ['document', Document]
539
544
  });
540
545
 
541
546
  export const SearchResponse = new Entity({
@@ -127,7 +127,9 @@ export type AccountInfoAttrs = {
127
127
  zimbraMailAttachmentMaxSize?: Maybe<Scalars['Float']>;
128
128
  zimbraMailBlacklistMaxNumEntries?: Maybe<Scalars['Int']>;
129
129
  zimbraMailQuota?: Maybe<Scalars['String']>;
130
+ zimbraMailSignatureMaxLength?: Maybe<Scalars['Float']>;
130
131
  zimbraMtaMaxMessageSize?: Maybe<Scalars['Float']>;
132
+ zimbraPasswordAllowUsername?: Maybe<Scalars['Boolean']>;
131
133
  zimbraPasswordAllowedChars?: Maybe<Scalars['String']>;
132
134
  zimbraPasswordAllowedPunctuationChars?: Maybe<Scalars['String']>;
133
135
  zimbraPasswordBlockCommonEnabled?: Maybe<Scalars['Boolean']>;
@@ -793,6 +795,7 @@ export type ClientInfoAttributes = {
793
795
  zimbraFeatureResetPasswordStatus?: Maybe<ResetPasswordStatus>;
794
796
  zimbraWebClientLoginURL?: Maybe<Scalars['String']>;
795
797
  zimbraWebClientLogoutURL?: Maybe<Scalars['String']>;
798
+ zimbraWebClientSkipLogoff?: Maybe<Scalars['Boolean']>;
796
799
  };
797
800
 
798
801
  export type ClientInfoType = {
@@ -1270,6 +1273,7 @@ export type Document = {
1270
1273
  contentType?: Maybe<Scalars['String']>;
1271
1274
  date?: Maybe<Scalars['Float']>;
1272
1275
  descriptionEnabled?: Maybe<Scalars['Boolean']>;
1276
+ docs?: Maybe<Array<Maybe<Document>>>;
1273
1277
  flags?: Maybe<Scalars['String']>;
1274
1278
  folderId?: Maybe<Scalars['ID']>;
1275
1279
  folderUuid?: Maybe<Scalars['String']>;
@@ -2451,6 +2455,7 @@ export type Mutation = {
2451
2455
  prefOutOfOfficeFromDate?: Maybe<Scalars['String']>;
2452
2456
  prefOutOfOfficeReply?: Maybe<Scalars['String']>;
2453
2457
  prefOutOfOfficeUntilDate?: Maybe<Scalars['String']>;
2458
+ purgeRevision?: Maybe<Scalars['Boolean']>;
2454
2459
  quarantineDeviceSync?: Maybe<Device>;
2455
2460
  recoverAccount?: Maybe<RecoverAccount>;
2456
2461
  remoteWipeSync?: Maybe<Device>;
@@ -2873,6 +2878,13 @@ export type MutationPrefOutOfOfficeUntilDateArgs = {
2873
2878
  };
2874
2879
 
2875
2880
 
2881
+ export type MutationPurgeRevisionArgs = {
2882
+ id: Scalars['ID'];
2883
+ includeOlderRevisions?: InputMaybe<Scalars['Int']>;
2884
+ ver: Scalars['Int'];
2885
+ };
2886
+
2887
+
2876
2888
  export type MutationQuarantineDeviceSyncArgs = {
2877
2889
  deviceId?: InputMaybe<Scalars['String']>;
2878
2890
  };
@@ -3272,6 +3284,12 @@ export type PropertiesInput = {
3272
3284
  zimlet: Scalars['String'];
3273
3285
  };
3274
3286
 
3287
+ export type PurgetRevisionInput = {
3288
+ id: Scalars['ID'];
3289
+ includeOlderRevisions?: InputMaybe<Scalars['Int']>;
3290
+ ver: Scalars['Int'];
3291
+ };
3292
+
3275
3293
  export type Query = {
3276
3294
  __typename?: 'Query';
3277
3295
  accountInfo?: Maybe<AccountInfo>;
@@ -3316,6 +3334,7 @@ export type Query = {
3316
3334
  getTrustedDevices?: Maybe<GetTrustedDevicesResponse>;
3317
3335
  getWhiteBlackList?: Maybe<WhiteBlackList>;
3318
3336
  getWorkingHours?: Maybe<Array<Maybe<WorkingHours>>>;
3337
+ listDocumentRevisions?: Maybe<Document>;
3319
3338
  noop?: Maybe<NoOpResponse>;
3320
3339
  recoverAccount?: Maybe<RecoverAccount>;
3321
3340
  relatedContacts?: Maybe<Array<Maybe<RelatedContact>>>;
@@ -3528,6 +3547,13 @@ export type QueryGetWorkingHoursArgs = {
3528
3547
  };
3529
3548
 
3530
3549
 
3550
+ export type QueryListDocumentRevisionsArgs = {
3551
+ count: Scalars['Int'];
3552
+ id: Scalars['ID'];
3553
+ version: Scalars['Int'];
3554
+ };
3555
+
3556
+
3531
3557
  export type QueryNoopArgs = {
3532
3558
  limitToOneBlocked?: InputMaybe<Scalars['Int']>;
3533
3559
  wait?: InputMaybe<Scalars['Int']>;
@@ -3769,6 +3795,7 @@ export type SaveDocumentInput = {
3769
3795
  action?: InputMaybe<SaveDocumentAction>;
3770
3796
  contentType?: InputMaybe<Scalars['String']>;
3771
3797
  descriptionEnabled?: InputMaybe<Scalars['Boolean']>;
3798
+ document?: InputMaybe<SaveDocumentInput>;
3772
3799
  folderId?: InputMaybe<Scalars['ID']>;
3773
3800
  id?: InputMaybe<Scalars['ID']>;
3774
3801
  messageData?: InputMaybe<Array<InputMaybe<MessagePartForDocument>>>;
@@ -485,6 +485,7 @@ interface MailItem {
485
485
  type ClientInfoAttributes {
486
486
  zimbraWebClientLoginURL: String
487
487
  zimbraWebClientLogoutURL: String
488
+ zimbraWebClientSkipLogoff: Boolean
488
489
  zimbraFeatureResetPasswordStatus: ResetPasswordStatus
489
490
  }
490
491
 
@@ -1309,6 +1310,7 @@ type AccountInfoAttrs {
1309
1310
  zimbraFeatureMobileSyncEnabled: Boolean
1310
1311
  zimbraFeatureRelatedContactsEnabled: Boolean
1311
1312
  zimbraFeatureMailForwardingInFiltersEnabled: Boolean
1313
+ zimbraPasswordAllowUsername: Boolean
1312
1314
  zimbraPasswordBlockCommonEnabled: Boolean
1313
1315
  zimbraPasswordMinAlphaChars: Int
1314
1316
  zimbraPasswordMinNumericChars: Int
@@ -1352,6 +1354,7 @@ type AccountInfoAttrs {
1352
1354
  zimbraMailAttachmentMaxSize: Float
1353
1355
  zimbraMtaMaxMessageSize: Float
1354
1356
  zimbraMailAlias: [String]
1357
+ zimbraMailSignatureMaxLength: Float
1355
1358
  zimbraFeatureTaggingEnabled: Boolean
1356
1359
  zimbraIdentityMaxNumEntries: Int
1357
1360
  zimbraFeatureIdentitiesEnabled: Boolean
@@ -1551,6 +1554,7 @@ type Document {
1551
1554
  revisedCreationDate: Float #cd
1552
1555
  lockOwnerId: ID #loid
1553
1556
  flags: String #f
1557
+ docs: [Document]
1554
1558
  }
1555
1559
 
1556
1560
  type SearchResponse {
@@ -2451,6 +2455,12 @@ input InviteReplyInput {
2451
2455
  exceptId: InstanceDate
2452
2456
  }
2453
2457
 
2458
+ input PurgetRevisionInput {
2459
+ id: ID!
2460
+ ver: Int!
2461
+ includeOlderRevisions: Int
2462
+ }
2463
+
2454
2464
  input PropertiesInput {
2455
2465
  zimlet: String!
2456
2466
  name: String!
@@ -2971,6 +2981,7 @@ input SaveDocumentInput {
2971
2981
  descriptionEnabled: Boolean #descEnabled
2972
2982
  action: SaveDocumentAction
2973
2983
  type: SaveDocumentType
2984
+ document: SaveDocumentInput
2974
2985
  }
2975
2986
 
2976
2987
  type SaveDocument {
@@ -3187,6 +3198,7 @@ type Query {
3187
3198
  downloadMessage(id: ID!, isSecure: Boolean, isLocal: Boolean): SMimeMessage
3188
3199
  downloadAttachment(id: ID!, part: ID!): Attachment
3189
3200
  downloadDocument(id: ID!, url: String!): Attachment
3201
+ listDocumentRevisions(id: ID!, version: Int!, count: Int!): Document
3190
3202
  discoverRights(right: [DiscoverRightInput!]!): DiscoverRights
3191
3203
  freeBusy(names: [String!]!, start: Float, end: Float): [FreeBusy]
3192
3204
  getContact(
@@ -3490,6 +3502,7 @@ type Mutation {
3490
3502
  modifyTask(task: CalendarItemInput!): Boolean
3491
3503
  modifyWhiteBlackList(whiteBlackList: WhiteBlackListInput!): Boolean
3492
3504
  moveTask(inviteId: ID!, destFolderId: ID!): String
3505
+ purgeRevision(id: ID!, ver: Int!, includeOlderRevisions: Int): Boolean
3493
3506
  prefEnableOutOfOfficeAlertOnLogin(value: Boolean!): Boolean
3494
3507
  prefEnableOutOfOfficeReply(value: Boolean!): Boolean
3495
3508
  prefOutOfOfficeFromDate(value: String!): String
@@ -29,6 +29,7 @@ import {
29
29
  NameIdInput,
30
30
  PreferencesInput,
31
31
  PropertiesInput,
32
+ PurgetRevisionInput,
32
33
  RevokeRightsInput,
33
34
  SaveSMimeCertInputUpload,
34
35
  SearchFolderInput,
@@ -108,6 +109,7 @@ export function createZimbraSchema(options: ZimbraSchemaOptions): {
108
109
  discoverRights: (_, variables) => client.discoverRights(variables as DiscoverRightOptions),
109
110
  downloadAttachment: (_, variables) => client.downloadAttachment(variables),
110
111
  downloadDocument: (_, variables) => client.downloadDocument(variables),
112
+ listDocumentRevisions: (_, variables) => client.listDocumentRevisions(variables),
111
113
  downloadMessage: (_, variables, context = {}) => {
112
114
  const { local } = context;
113
115
 
@@ -320,6 +322,7 @@ export function createZimbraSchema(options: ZimbraSchemaOptions): {
320
322
  client.deleteExternalAccount(variables as ExternalAccountDeleteInput),
321
323
  importExternalAccount: (_, { externalAccount }) =>
322
324
  client.importExternalAccount(externalAccount as ExternalAccountImportInput),
325
+ purgeRevision: (_, variables) => client.purgeRevision(variables as PurgetRevisionInput),
323
326
  prefEnableOutOfOfficeAlertOnLogin: (_, { value }) =>
324
327
  client
325
328
  .modifyPrefs({
@@ -1,4 +1,4 @@
1
- import { gql } from '@apollo/client';
1
+ import { gql } from '@apollo/client/core';
2
2
  import get from 'lodash/get';
3
3
  import { ZimbraInMemoryCache } from '../apollo/zimbra-in-memory-cache';
4
4
  import { ZimbraSessionOptions } from './types';