@zimbra/api-client 78.0.0 → 80.1.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",
4
+ "version": "80.1.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,
@@ -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) =>
@@ -1353,6 +1353,33 @@ export class ZimbraBatchClient {
1353
1353
  // If account name is present that means we will not be able to batch requests
1354
1354
  this[options.singleRequest ? 'dataLoader' : 'batchDataLoader'].load(options);
1355
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
+
1356
1383
  public login = ({
1357
1384
  username,
1358
1385
  password,
@@ -1560,6 +1587,20 @@ export class ZimbraBatchClient {
1560
1587
  fetchOptions
1561
1588
  }).then(resp => resp);
1562
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
+
1563
1604
  public quarantineDeviceSync = (deviceId: String) =>
1564
1605
  this.jsonRequest({
1565
1606
  name: 'QuarantineDevice',
@@ -1629,7 +1670,7 @@ export class ZimbraBatchClient {
1629
1670
  cancelResetPassword
1630
1671
  },
1631
1672
  singleRequest: true
1632
- });
1673
+ }).then(res => mapValuesDeep(res, coerceStringToBoolean));
1633
1674
 
1634
1675
  public resolve = (path: string) => `${this.origin}${path}`;
1635
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']>;
@@ -1271,6 +1273,7 @@ export type Document = {
1271
1273
  contentType?: Maybe<Scalars['String']>;
1272
1274
  date?: Maybe<Scalars['Float']>;
1273
1275
  descriptionEnabled?: Maybe<Scalars['Boolean']>;
1276
+ docs?: Maybe<Array<Maybe<Document>>>;
1274
1277
  flags?: Maybe<Scalars['String']>;
1275
1278
  folderId?: Maybe<Scalars['ID']>;
1276
1279
  folderUuid?: Maybe<Scalars['String']>;
@@ -2452,6 +2455,7 @@ export type Mutation = {
2452
2455
  prefOutOfOfficeFromDate?: Maybe<Scalars['String']>;
2453
2456
  prefOutOfOfficeReply?: Maybe<Scalars['String']>;
2454
2457
  prefOutOfOfficeUntilDate?: Maybe<Scalars['String']>;
2458
+ purgeRevision?: Maybe<Scalars['Boolean']>;
2455
2459
  quarantineDeviceSync?: Maybe<Device>;
2456
2460
  recoverAccount?: Maybe<RecoverAccount>;
2457
2461
  remoteWipeSync?: Maybe<Device>;
@@ -2874,6 +2878,13 @@ export type MutationPrefOutOfOfficeUntilDateArgs = {
2874
2878
  };
2875
2879
 
2876
2880
 
2881
+ export type MutationPurgeRevisionArgs = {
2882
+ id: Scalars['ID'];
2883
+ includeOlderRevisions?: InputMaybe<Scalars['Int']>;
2884
+ ver: Scalars['Int'];
2885
+ };
2886
+
2887
+
2877
2888
  export type MutationQuarantineDeviceSyncArgs = {
2878
2889
  deviceId?: InputMaybe<Scalars['String']>;
2879
2890
  };
@@ -3273,6 +3284,12 @@ export type PropertiesInput = {
3273
3284
  zimlet: Scalars['String'];
3274
3285
  };
3275
3286
 
3287
+ export type PurgetRevisionInput = {
3288
+ id: Scalars['ID'];
3289
+ includeOlderRevisions?: InputMaybe<Scalars['Int']>;
3290
+ ver: Scalars['Int'];
3291
+ };
3292
+
3276
3293
  export type Query = {
3277
3294
  __typename?: 'Query';
3278
3295
  accountInfo?: Maybe<AccountInfo>;
@@ -3317,6 +3334,7 @@ export type Query = {
3317
3334
  getTrustedDevices?: Maybe<GetTrustedDevicesResponse>;
3318
3335
  getWhiteBlackList?: Maybe<WhiteBlackList>;
3319
3336
  getWorkingHours?: Maybe<Array<Maybe<WorkingHours>>>;
3337
+ listDocumentRevisions?: Maybe<Document>;
3320
3338
  noop?: Maybe<NoOpResponse>;
3321
3339
  recoverAccount?: Maybe<RecoverAccount>;
3322
3340
  relatedContacts?: Maybe<Array<Maybe<RelatedContact>>>;
@@ -3529,6 +3547,13 @@ export type QueryGetWorkingHoursArgs = {
3529
3547
  };
3530
3548
 
3531
3549
 
3550
+ export type QueryListDocumentRevisionsArgs = {
3551
+ count: Scalars['Int'];
3552
+ id: Scalars['ID'];
3553
+ version: Scalars['Int'];
3554
+ };
3555
+
3556
+
3532
3557
  export type QueryNoopArgs = {
3533
3558
  limitToOneBlocked?: InputMaybe<Scalars['Int']>;
3534
3559
  wait?: InputMaybe<Scalars['Int']>;
@@ -3770,6 +3795,7 @@ export type SaveDocumentInput = {
3770
3795
  action?: InputMaybe<SaveDocumentAction>;
3771
3796
  contentType?: InputMaybe<Scalars['String']>;
3772
3797
  descriptionEnabled?: InputMaybe<Scalars['Boolean']>;
3798
+ document?: InputMaybe<SaveDocumentInput>;
3773
3799
  folderId?: InputMaybe<Scalars['ID']>;
3774
3800
  id?: InputMaybe<Scalars['ID']>;
3775
3801
  messageData?: InputMaybe<Array<InputMaybe<MessagePartForDocument>>>;
@@ -1310,6 +1310,7 @@ type AccountInfoAttrs {
1310
1310
  zimbraFeatureMobileSyncEnabled: Boolean
1311
1311
  zimbraFeatureRelatedContactsEnabled: Boolean
1312
1312
  zimbraFeatureMailForwardingInFiltersEnabled: Boolean
1313
+ zimbraPasswordAllowUsername: Boolean
1313
1314
  zimbraPasswordBlockCommonEnabled: Boolean
1314
1315
  zimbraPasswordMinAlphaChars: Int
1315
1316
  zimbraPasswordMinNumericChars: Int
@@ -1353,6 +1354,7 @@ type AccountInfoAttrs {
1353
1354
  zimbraMailAttachmentMaxSize: Float
1354
1355
  zimbraMtaMaxMessageSize: Float
1355
1356
  zimbraMailAlias: [String]
1357
+ zimbraMailSignatureMaxLength: Float
1356
1358
  zimbraFeatureTaggingEnabled: Boolean
1357
1359
  zimbraIdentityMaxNumEntries: Int
1358
1360
  zimbraFeatureIdentitiesEnabled: Boolean
@@ -1552,6 +1554,7 @@ type Document {
1552
1554
  revisedCreationDate: Float #cd
1553
1555
  lockOwnerId: ID #loid
1554
1556
  flags: String #f
1557
+ docs: [Document]
1555
1558
  }
1556
1559
 
1557
1560
  type SearchResponse {
@@ -2452,6 +2455,12 @@ input InviteReplyInput {
2452
2455
  exceptId: InstanceDate
2453
2456
  }
2454
2457
 
2458
+ input PurgetRevisionInput {
2459
+ id: ID!
2460
+ ver: Int!
2461
+ includeOlderRevisions: Int
2462
+ }
2463
+
2455
2464
  input PropertiesInput {
2456
2465
  zimlet: String!
2457
2466
  name: String!
@@ -2972,6 +2981,7 @@ input SaveDocumentInput {
2972
2981
  descriptionEnabled: Boolean #descEnabled
2973
2982
  action: SaveDocumentAction
2974
2983
  type: SaveDocumentType
2984
+ document: SaveDocumentInput
2975
2985
  }
2976
2986
 
2977
2987
  type SaveDocument {
@@ -3188,6 +3198,7 @@ type Query {
3188
3198
  downloadMessage(id: ID!, isSecure: Boolean, isLocal: Boolean): SMimeMessage
3189
3199
  downloadAttachment(id: ID!, part: ID!): Attachment
3190
3200
  downloadDocument(id: ID!, url: String!): Attachment
3201
+ listDocumentRevisions(id: ID!, version: Int!, count: Int!): Document
3191
3202
  discoverRights(right: [DiscoverRightInput!]!): DiscoverRights
3192
3203
  freeBusy(names: [String!]!, start: Float, end: Float): [FreeBusy]
3193
3204
  getContact(
@@ -3491,6 +3502,7 @@ type Mutation {
3491
3502
  modifyTask(task: CalendarItemInput!): Boolean
3492
3503
  modifyWhiteBlackList(whiteBlackList: WhiteBlackListInput!): Boolean
3493
3504
  moveTask(inviteId: ID!, destFolderId: ID!): String
3505
+ purgeRevision(id: ID!, ver: Int!, includeOlderRevisions: Int): Boolean
3494
3506
  prefEnableOutOfOfficeAlertOnLogin(value: Boolean!): Boolean
3495
3507
  prefEnableOutOfOfficeReply(value: Boolean!): Boolean
3496
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';