@coveo/push-api-client 2.8.13 → 3.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.
Files changed (135) hide show
  1. package/README.md +7 -6
  2. package/dist/APICore.js +18 -13
  3. package/dist/APICore.js.map +1 -1
  4. package/dist/definitions/APICore.d.ts +12 -5
  5. package/dist/definitions/document.d.ts +2 -45
  6. package/dist/definitions/documentBuilder.d.ts +32 -59
  7. package/dist/definitions/errors/validatorErrors.d.ts +2 -1
  8. package/dist/definitions/help/fileConsumer.d.ts +3 -3
  9. package/dist/definitions/help/fileContainer.d.ts +2 -3
  10. package/dist/definitions/help/fileContainer.spec.d.ts +1 -1
  11. package/dist/definitions/index.d.ts +1 -1
  12. package/dist/definitions/interfaces.d.ts +3 -3
  13. package/dist/definitions/permissionSetBuilder.d.ts +34 -0
  14. package/dist/definitions/permissionSetBuilder.spec.d.ts +1 -0
  15. package/dist/definitions/securityIdentityBuilder.d.ts +33 -24
  16. package/dist/definitions/securityIdentityBuilder.spec.d.ts +1 -0
  17. package/dist/definitions/source/catalog.d.ts +2 -1
  18. package/dist/definitions/source/documentUploader.d.ts +3 -3
  19. package/dist/definitions/source/push.d.ts +8 -37
  20. package/dist/definitions/source/securityIdenty.d.ts +1 -0
  21. package/dist/definitions/uploadStrategy/fileContainerStrategy.d.ts +1 -1
  22. package/dist/definitions/uploadStrategy/strategy.d.ts +2 -2
  23. package/dist/definitions/uploadStrategy/streamChunkStrategy.d.ts +1 -1
  24. package/dist/definitions/validation/caseInsensitiveDocument.d.ts +10 -1
  25. package/dist/definitions/validation/knownKey.d.ts +2 -1
  26. package/dist/definitions/validation/parsePermissions.d.ts +5 -0
  27. package/dist/definitions/validation/parsePermissions.spec.d.ts +1 -0
  28. package/dist/documentBuilder.js +28 -46
  29. package/dist/documentBuilder.js.map +1 -1
  30. package/dist/documentBuilder.spec.js +55 -74
  31. package/dist/documentBuilder.spec.js.map +1 -1
  32. package/dist/errors/validatorErrors.js +4 -1
  33. package/dist/errors/validatorErrors.js.map +1 -1
  34. package/dist/help/fileConsumer.js +1 -1
  35. package/dist/help/fileConsumer.js.map +1 -1
  36. package/dist/help/fileConsumer.spec.js +2 -3
  37. package/dist/help/fileConsumer.spec.js.map +1 -1
  38. package/dist/help/fileContainer.js +41 -24
  39. package/dist/help/fileContainer.js.map +1 -1
  40. package/dist/help/fileContainer.spec.js +38 -33
  41. package/dist/help/fileContainer.spec.js.map +1 -1
  42. package/dist/index.js +3 -3
  43. package/dist/index.js.map +1 -1
  44. package/dist/localtest.js +10 -8
  45. package/dist/localtest.js.map +1 -1
  46. package/dist/permissionSetBuilder.js +59 -0
  47. package/dist/permissionSetBuilder.js.map +1 -0
  48. package/dist/permissionSetBuilder.spec.js +69 -0
  49. package/dist/permissionSetBuilder.spec.js.map +1 -0
  50. package/dist/securityIdentityBuilder.js +34 -27
  51. package/dist/securityIdentityBuilder.js.map +1 -1
  52. package/dist/securityIdentityBuilder.spec.js +51 -0
  53. package/dist/securityIdentityBuilder.spec.js.map +1 -0
  54. package/dist/source/catalog.js +1 -2
  55. package/dist/source/catalog.js.map +1 -1
  56. package/dist/source/documentUploader.js +1 -1
  57. package/dist/source/documentUploader.js.map +1 -1
  58. package/dist/source/documentUploader.spec.js +5 -5
  59. package/dist/source/documentUploader.spec.js.map +1 -1
  60. package/dist/source/push.js +6 -47
  61. package/dist/source/push.js.map +1 -1
  62. package/dist/source/push.spec.js +3 -3
  63. package/dist/source/push.spec.js.map +1 -1
  64. package/dist/source/securityIdenty.js +1 -2
  65. package/dist/source/securityIdenty.js.map +1 -1
  66. package/dist/uploadStrategy/fileContainerStrategy.js +2 -2
  67. package/dist/uploadStrategy/fileContainerStrategy.js.map +1 -1
  68. package/dist/uploadStrategy/fileContainerStrategy.spec.js +2 -2
  69. package/dist/uploadStrategy/fileContainerStrategy.spec.js.map +1 -1
  70. package/dist/uploadStrategy/streamChunkStrategy.js +4 -4
  71. package/dist/uploadStrategy/streamChunkStrategy.js.map +1 -1
  72. package/dist/uploadStrategy/streamChunkStrategy.spec.js +8 -12
  73. package/dist/uploadStrategy/streamChunkStrategy.spec.js.map +1 -1
  74. package/dist/validation/caseInsensitiveDocument.js +21 -2
  75. package/dist/validation/caseInsensitiveDocument.js.map +1 -1
  76. package/dist/validation/knownKey.js +13 -4
  77. package/dist/validation/knownKey.js.map +1 -1
  78. package/dist/validation/parseFile.js +14 -60
  79. package/dist/validation/parseFile.js.map +1 -1
  80. package/dist/validation/parseFile.spec.js +42 -3
  81. package/dist/validation/parseFile.spec.js.map +1 -1
  82. package/dist/validation/parsePermissions.js +119 -0
  83. package/dist/validation/parsePermissions.js.map +1 -0
  84. package/dist/validation/parsePermissions.spec.js +87 -0
  85. package/dist/validation/parsePermissions.spec.js.map +1 -0
  86. package/dist/validation/requiredKeyValidator.js +1 -1
  87. package/dist/validation/requiredKeyValidator.js.map +1 -1
  88. package/package.json +18 -17
  89. package/dist/definitions/source/source.d.ts +0 -5
  90. package/dist/docs/.nojekyll +0 -1
  91. package/dist/docs/assets/highlight.css +0 -71
  92. package/dist/docs/assets/main.js +0 -58
  93. package/dist/docs/assets/search.js +0 -1
  94. package/dist/docs/assets/style.css +0 -1280
  95. package/dist/docs/classes/AnySecurityIdentityBuilder.html +0 -125
  96. package/dist/docs/classes/CatalogSource.html +0 -327
  97. package/dist/docs/classes/DocumentBuilder.html +0 -509
  98. package/dist/docs/classes/FieldAnalyser.html +0 -203
  99. package/dist/docs/classes/GroupSecurityIdentityBuilder.html +0 -128
  100. package/dist/docs/classes/PushSource.html +0 -465
  101. package/dist/docs/classes/UserSecurityIdentityBuilder.html +0 -128
  102. package/dist/docs/classes/VirtualGroupSecurityIdentityBuilder.html +0 -128
  103. package/dist/docs/classes/errors.FieldTypeInconsistencyError.html +0 -170
  104. package/dist/docs/classes/errors.InvalidDocument.html +0 -172
  105. package/dist/docs/classes/errors.InvalidPermanentId.html +0 -170
  106. package/dist/docs/classes/errors.NotAFileError.html +0 -170
  107. package/dist/docs/classes/errors.NotAJsonFileError.html +0 -170
  108. package/dist/docs/classes/errors.PrivilegeError.html +0 -170
  109. package/dist/docs/classes/errors.UnsupportedAttribute.html +0 -172
  110. package/dist/docs/classes/errors.UnsupportedFieldError.html +0 -199
  111. package/dist/docs/enums/PlatformEnvironment.html +0 -86
  112. package/dist/docs/enums/Region.html +0 -79
  113. package/dist/docs/enums/SourceVisibility.html +0 -79
  114. package/dist/docs/functions/parseAndGetDocumentBuilderFromJSONDocument.html +0 -86
  115. package/dist/docs/index.html +0 -121
  116. package/dist/docs/interfaces/BatchUpdateDocuments.html +0 -76
  117. package/dist/docs/interfaces/Document.html +0 -236
  118. package/dist/docs/interfaces/SecurityIdentity.html +0 -105
  119. package/dist/docs/interfaces/SecurityIdentityBuilder.html +0 -82
  120. package/dist/docs/interfaces/UploadBatchCallbackData.html +0 -100
  121. package/dist/docs/modules/errors.html +0 -68
  122. package/dist/docs/modules.html +0 -122
  123. package/dist/docs/types/BatchUpdateDocumentsFromFiles.html +0 -75
  124. package/dist/docs/types/CompressionType.html +0 -77
  125. package/dist/docs/types/FailedUploadCallback.html +0 -90
  126. package/dist/docs/types/Metadata.html +0 -75
  127. package/dist/docs/types/MetadataValue.html +0 -75
  128. package/dist/docs/types/PlatformUrlOptions.html +0 -82
  129. package/dist/docs/types/SecurityIdentityType.html +0 -75
  130. package/dist/docs/types/SuccessfulUploadCallback.html +0 -88
  131. package/dist/docs/types/Transformer.html +0 -88
  132. package/dist/docs/variables/BuiltInTransformers.html +0 -75
  133. package/dist/docs/variables/Source.html +0 -78
  134. package/dist/source/source.js +0 -9
  135. package/dist/source/source.js.map +0 -1
package/README.md CHANGED
@@ -7,11 +7,12 @@ Coveo Push API client
7
7
  `npm i @coveo/push-api-client`
8
8
 
9
9
  ## Features
10
- * Upload data to both Push and Catalog sources
11
- * Pre-push document validation
12
- * Automatic custom field creation
13
- * Full catalog upload and incremental document update
14
- * Optimized for large payload uploads
10
+
11
+ - Upload data to both Push and Catalog sources
12
+ - Pre-push document validation
13
+ - Automatic custom field creation
14
+ - Full catalog upload and incremental document update
15
+ - Optimized for large payload uploads
15
16
 
16
17
  ## Usage
17
18
 
@@ -33,6 +34,7 @@ main();
33
34
  ```
34
35
 
35
36
  You can also upload your data into a catalog source
37
+
36
38
  ```js
37
39
  async function main() {
38
40
  const source = new CatalogSource('my_api_key', 'my_coveo_organization_id');
@@ -42,7 +44,6 @@ async function main() {
42
44
  }
43
45
 
44
46
  main();
45
-
46
47
  ```
47
48
 
48
49
  See more examples in the `./samples` folder.
package/dist/APICore.js CHANGED
@@ -2,38 +2,43 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.APICore = void 0;
4
4
  const exponential_backoff_1 = require("exponential-backoff");
5
- const axios_1 = require("axios");
6
5
  class APICore {
7
6
  constructor(accessToken) {
8
7
  this.accessToken = accessToken;
9
8
  }
10
- async request(config) {
9
+ async request(url, config) {
11
10
  const req = async () => {
12
- const response = await axios_1.default.request(Object.assign(Object.assign({}, config), this.axiosRequestHeaders));
13
- if (this.isThrottled(response.status)) {
14
- throw response;
15
- }
11
+ const response = await fetch(url, Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, this.requestHeaders), config.headers) }));
16
12
  return response;
17
13
  };
18
14
  return (0, exponential_backoff_1.backOff)(req, {
19
15
  retry: (res) => this.isThrottled(res.status),
20
16
  });
21
17
  }
18
+ async requestJson(url, config) {
19
+ return (await this.request(url, config)).json();
20
+ }
22
21
  async post(url, data = {}) {
23
- return this.request({ url, data, method: 'post' });
22
+ return this.requestJson(url, { body: JSON.stringify(data), method: 'post' });
23
+ }
24
+ async put(url, data = {}, parse = true) {
25
+ return this.selectRequester(parse)(url, {
26
+ body: JSON.stringify(data),
27
+ method: 'put',
28
+ });
24
29
  }
25
- async put(url, data = {}) {
26
- return this.request({ url, data, method: 'put' });
30
+ selectRequester(parse) {
31
+ return parse ? this.requestJson : this.request;
27
32
  }
28
- async delete(url) {
29
- return this.request({ url, method: 'delete' });
33
+ async delete(url, parse = true) {
34
+ return this.selectRequester(parse)(url, { method: 'delete' });
30
35
  }
31
- get axiosRequestHeaders() {
36
+ get requestHeaders() {
32
37
  const authorizationHeader = {
33
38
  Authorization: `Bearer ${this.accessToken}`,
34
39
  };
35
40
  const documentsRequestHeaders = Object.assign(Object.assign({}, authorizationHeader), { 'Content-Type': 'application/json', Accept: 'application/json' });
36
- return { headers: documentsRequestHeaders };
41
+ return documentsRequestHeaders;
37
42
  }
38
43
  isThrottled(status) {
39
44
  return status === 429;
@@ -1 +1 @@
1
- {"version":3,"file":"APICore.js","sourceRoot":"","sources":["../src/APICore.ts"],"names":[],"mappings":";;;AAAA,6DAA4C;AAC5C,iCAA+D;AAE/D,MAAa,OAAO;IAClB,YAA2B,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAE1C,KAAK,CAAC,OAAO,CACnB,MAA0B;QAE1B,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE;YACrB,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,OAAO,iCAC/B,MAAM,GACN,IAAI,CAAC,mBAAmB,EAC3B,CAAC;YAEH,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBACrC,MAAM,QAAQ,CAAC;aAChB;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;QAEF,OAAO,IAAA,6BAAO,EAAC,GAAG,EAAE;YAClB,KAAK,EAAE,CAAC,GAAqB,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;SAC/D,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,IAAI,CACf,GAAW,EACX,OAAgB,EAAE;QAElB,OAAO,IAAI,CAAC,OAAO,CAAI,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK,CAAC,GAAG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WAAW,CAAC,MAAc;QAChC,OAAO,MAAM,KAAK,GAAG,CAAC;IACxB,CAAC;CACF;AAhED,0BAgEC"}
@@ -1,11 +1,18 @@
1
- import { AxiosResponse } from 'axios';
1
+ import type { Response } from 'undici';
2
2
  export declare class APICore {
3
3
  private accessToken;
4
4
  constructor(accessToken: string);
5
5
  private request;
6
- post<T>(url: string, data?: unknown): Promise<AxiosResponse<T>>;
7
- put<T>(url: string, data?: unknown): Promise<AxiosResponse<T>>;
8
- delete<T>(url: string): Promise<AxiosResponse<T>>;
9
- private get axiosRequestHeaders();
6
+ private requestJson;
7
+ post<T>(url: string, data?: unknown): Promise<T>;
8
+ put<T>(url: string): Promise<T>;
9
+ put<T>(url: string, data: unknown): Promise<T>;
10
+ put<T>(url: string, data: unknown, parse: true): Promise<T>;
11
+ put(url: string, data: unknown, parse: false): Promise<Response>;
12
+ private selectRequester;
13
+ delete<T>(url: string): Promise<T>;
14
+ delete(url: string, parse: false): Promise<Response>;
15
+ delete<T>(url: string, parse: true): Promise<T>;
16
+ private get requestHeaders();
10
17
  private isThrottled;
11
18
  }
@@ -1,32 +1,4 @@
1
- export type SecurityIdentityType = 'UNKNOWN' | 'USER' | 'GROUP' | 'VIRTUAL_GROUP';
2
- /**
3
- * A security identity. See https://docs.coveo.com/en/1719 for more information.
4
- */
5
- export interface SecurityIdentity {
6
- /**
7
- * The name of the security identity.
8
- *
9
- * Examples:
10
- * - `asmith@example.com`
11
- * - `SampleTeam2`
12
- */
13
- identity: string;
14
- /**
15
- * The type of the identity.
16
- * Valid values:
17
- * - `UNKNOWN`
18
- * - `USER` : Defines a single user.
19
- * - `GROUP` : Defines an existing group of identities within the indexed system. Individual members of this group can be of any valid identity Type (USER, GROUP, or VIRTUAL_GROUP).
20
- * - `VIRTUAL_GROUP` : Defines a group that doesn't exist within the indexed system. Mechanically, a `VIRTUAL_GROUP` is identical to a `GROUP`.
21
- */
22
- identityType: SecurityIdentityType;
23
- /**
24
- * The security identity provider through which the security identity is updated.
25
- *
26
- * Defaults to the first security identity provider associated with the target Push source.
27
- */
28
- securityProvider?: string;
29
- }
1
+ import { PermissionLevel, PermissionSet } from '@coveo/platform-client';
30
2
  type BaseMetadataValue = string | string[] | number | number[] | boolean;
31
3
  type DictionaryMetadataValue = Record<string, BaseMetadataValue>;
32
4
  export type MetadataValue = BaseMetadataValue | DictionaryMetadataValue;
@@ -137,22 +109,7 @@ export interface Document {
137
109
  *
138
110
  * See https://docs.coveo.com/en/107 for more information.
139
111
  */
140
- permissions?: {
141
- /**
142
- * Whether to allow anonymous users in this permission set.
143
- *
144
- * Default value is false.
145
- */
146
- allowAnonymous: boolean;
147
- /**
148
- * The list of allowed permissions for this permission set.
149
- */
150
- allowedPermissions?: SecurityIdentity[];
151
- /**
152
- * The list of denied permissions for this permission set.
153
- */
154
- deniedPermissions?: SecurityIdentity[];
155
- };
112
+ permissions?: Array<PermissionSet | PermissionLevel>;
156
113
  /**
157
114
  * The file extension of the data you're pushing.
158
115
  *
@@ -1,12 +1,13 @@
1
1
  import { CompressionType, Document, Metadata, MetadataValue } from './document';
2
- import { SecurityIdentityBuilder } from './securityIdentityBuilder';
3
2
  import { Transformer } from './validation/transformers/transformer';
3
+ import { PermissionSetBuilder } from './permissionSetBuilder';
4
4
  /**
5
5
  * Utility class to build a {@link Document}.
6
6
  */
7
7
  export declare class DocumentBuilder {
8
8
  private uri;
9
9
  private doc;
10
+ private permissions;
10
11
  /**
11
12
  *
12
13
  * @param uri The URI of the document. See {@link Document.uri}
@@ -90,23 +91,27 @@ export declare class DocumentBuilder {
90
91
  */
91
92
  withMetadata(metadata: Metadata, metadataKeyTransformer?: Transformer): this;
92
93
  /**
93
- * Set allowed identities on the document. See {@link Document.permissions}
94
- * @param securityIdentityBuilder
95
- * @returns
96
- */
97
- withAllowedPermissions(securityIdentityBuilder: SecurityIdentityBuilder): this;
98
- /**
99
- * Set denied identities on the document. See {@link Document.permissions}
100
- * @param securityIdentityBuilder
101
- * @returns
94
+ * Set a permission set on the document
95
+ * Multiple permission sets can be combined.
96
+ *
97
+ * See [Simple Permission Model Definition Examples](https://docs.coveo.com/en/107)
102
98
  */
103
- withDeniedPermissions(securityIdentityBuilder: SecurityIdentityBuilder): this;
99
+ withPermissionSet(permissionSetBuilder: PermissionSetBuilder): this;
104
100
  /**
105
- * Set allowAnonymous for permissions on the document. See {@link Document.permissions}
106
- * @param allowAnonymous
107
- * @returns
101
+ * Set a permission level on the document
102
+ * Multiple permission levels can be added to the document. In this case, the order at which this method is called will influence the permission hierarchy.
103
+ *
104
+ * Consider the following example:
105
+ * ```
106
+ * doc.withPermissionLevel('level1', [setA])
107
+ * .withPermissionLevel('level2', [setB, setC])
108
+ * ```
109
+ *
110
+ * Permission sets from level1 (`setA`) will supersed the ones from level2 (`setB` and `setC`).
111
+ *
112
+ * See [Complex Permission Model Definition](https://docs.coveo.com/en/25/index-content/complex-permission-model-definition-example)
108
113
  */
109
- withAllowAnonymousUsers(allowAnonymous: boolean): this;
114
+ withPermissionLevel(permissionLevelName: string, permissionSetBuilders: PermissionSetBuilder[]): this;
110
115
  build(): Document;
111
116
  /**
112
117
  * Marshal the document into a JSON format accepted by the push API.
@@ -114,28 +119,7 @@ export declare class DocumentBuilder {
114
119
  */
115
120
  marshal(): {
116
121
  documentId: string;
117
- permissions?: undefined;
118
- compressedBinaryData?: {
119
- compressionType: CompressionType;
120
- data: string;
121
- } | undefined;
122
- compressionType?: undefined;
123
- title: string;
124
- clickableUri?: string | undefined;
125
- author?: string | undefined;
126
- date?: string | undefined;
127
- modifiedDate?: string | undefined;
128
- permanentId?: string | undefined;
129
- parentId?: string | undefined;
130
- data?: string | undefined;
131
- fileExtension?: string | undefined;
132
- } | {
133
- documentId: string;
134
- permissions: {
135
- allowAnonymous: boolean;
136
- allowedPermissions: import("./document").SecurityIdentity[];
137
- deniedPermissions: import("./document").SecurityIdentity[];
138
- }[];
122
+ permissions?: (import("@coveo/platform-client").PermissionSet | import("@coveo/platform-client").PermissionLevel)[] | undefined;
139
123
  compressedBinaryData?: {
140
124
  compressionType: CompressionType;
141
125
  data: string;
@@ -143,21 +127,11 @@ export declare class DocumentBuilder {
143
127
  compressionType?: undefined;
144
128
  title: string;
145
129
  clickableUri?: string | undefined;
146
- author?: string | undefined;
147
- date?: string | undefined;
148
- modifiedDate?: string | undefined;
149
- permanentId?: string | undefined;
150
- parentId?: string | undefined;
151
- data?: string | undefined;
152
- fileExtension?: string | undefined;
153
- } | {
154
- documentId: string;
155
- permissions?: undefined;
156
- compressedBinaryData: string;
157
- compressionType: CompressionType;
158
- title: string;
159
- clickableUri?: string | undefined;
160
- author?: string | undefined;
130
+ author?: string | undefined; /**
131
+ * Set the data of the document. See {@link Document.data}
132
+ * @param data
133
+ * @returns
134
+ */
161
135
  date?: string | undefined;
162
136
  modifiedDate?: string | undefined;
163
137
  permanentId?: string | undefined;
@@ -166,16 +140,16 @@ export declare class DocumentBuilder {
166
140
  fileExtension?: string | undefined;
167
141
  } | {
168
142
  documentId: string;
169
- permissions: {
170
- allowAnonymous: boolean;
171
- allowedPermissions: import("./document").SecurityIdentity[];
172
- deniedPermissions: import("./document").SecurityIdentity[];
173
- }[];
143
+ permissions?: (import("@coveo/platform-client").PermissionSet | import("@coveo/platform-client").PermissionLevel)[] | undefined;
174
144
  compressedBinaryData: string;
175
145
  compressionType: CompressionType;
176
146
  title: string;
177
147
  clickableUri?: string | undefined;
178
- author?: string | undefined;
148
+ author?: string | undefined; /**
149
+ * Set the data of the document. See {@link Document.data}
150
+ * @param data
151
+ * @returns
152
+ */
179
153
  date?: string | undefined;
180
154
  modifiedDate?: string | undefined;
181
155
  permanentId?: string | undefined;
@@ -191,5 +165,4 @@ export declare class DocumentBuilder {
191
165
  private generatePermanentId;
192
166
  private validateDateAndReturnValidDate;
193
167
  private validateCompressedBinaryData;
194
- private setPermission;
195
168
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import { PrimitivesValues } from '@coveo/bueno';
2
3
  import { PathLike } from 'fs';
3
4
  import { PushApiClientBaseError } from './baseError';
4
5
  export declare class NotAFileError extends PushApiClientBaseError {
@@ -11,7 +12,7 @@ export declare class NotAJsonFileError extends PushApiClientBaseError {
11
12
  }
12
13
  export declare class InvalidDocument extends PushApiClientBaseError {
13
14
  name: string;
14
- constructor(p: PathLike, explanation: string);
15
+ constructor(p: PathLike, doc: Record<string, PrimitivesValues>, explanation: string);
15
16
  }
16
17
  export declare class UnsupportedAttribute extends PushApiClientBaseError {
17
18
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { BatchUpdateDocuments, UploadBatchCallbackData, ConcurrentProcessing, ParseDocumentOptions } from '../interfaces';
2
- import { AxiosResponse } from 'axios';
2
+ import type { Response } from 'undici';
3
3
  export type SuccessfulUploadCallback = (data: UploadBatchCallbackData) => void;
4
4
  export type FailedUploadCallback = (err: unknown, value: UploadBatchCallbackData) => void;
5
5
  /**
@@ -15,10 +15,10 @@ export declare class FileConsumer {
15
15
  private cbFail;
16
16
  /**
17
17
  * Creates an instance of FileConsumer.
18
- * @param {(batch: BatchUpdateDocuments) => Promise<AxiosResponse>} upload the upload operation to apply to every document batch
18
+ * @param {(batch: BatchUpdateDocuments) => Promise<Response>} upload the upload operation to apply to every document batch
19
19
  * @param {Required<ConcurrentProcessing>} processingConfig
20
20
  */
21
- constructor(upload: (batch: BatchUpdateDocuments) => Promise<AxiosResponse>, processingConfig: Required<ConcurrentProcessing>);
21
+ constructor(upload: (batch: BatchUpdateDocuments) => Promise<Response>, processingConfig: Required<ConcurrentProcessing>);
22
22
  consume(files: string[], options?: ParseDocumentOptions): Promise<void>;
23
23
  onSuccess(callback: SuccessfulUploadCallback): void;
24
24
  onError(callback: FailedUploadCallback): void;
@@ -1,9 +1,8 @@
1
- import { AxiosRequestConfig } from 'axios';
1
+ import type { Response } from 'undici';
2
2
  import { BatchUpdateDocuments } from '../interfaces';
3
3
  export interface FileContainerResponse {
4
4
  uploadUri: string;
5
5
  fileId: string;
6
6
  requiredHeaders: Record<string, string>;
7
7
  }
8
- export declare const uploadContentToFileContainer: (fileContainer: FileContainerResponse, batch: BatchUpdateDocuments) => Promise<import("axios").AxiosResponse<any, any>>;
9
- export declare const getFileContainerAxiosConfig: (fileContainer: FileContainerResponse) => AxiosRequestConfig;
8
+ export declare const uploadContentToFileContainer: (fileContainer: FileContainerResponse, batch: BatchUpdateDocuments) => Promise<Response>;
@@ -1 +1 @@
1
- export {};
1
+ import 'fetch-undici-polyfill';
@@ -1,7 +1,6 @@
1
1
  export * from './document';
2
2
  export * from './validation/transformers/transformer';
3
3
  export * as errors from './errors';
4
- export { Source } from './source/source';
5
4
  export { PushSource } from './source/push';
6
5
  export { CatalogSource } from './source/catalog';
7
6
  export { SuccessfulUploadCallback, FailedUploadCallback, } from './help/fileConsumer';
@@ -11,4 +10,5 @@ export { DocumentBuilder } from './documentBuilder';
11
10
  export * from './securityIdentityBuilder';
12
11
  export { PlatformEnvironment, Region, PlatformUrlOptions } from './environment';
13
12
  export { SourceVisibility } from '@coveo/platform-client';
13
+ export { PermissionSetBuilder } from './permissionSetBuilder';
14
14
  export { parseAndGetDocumentBuilderFromJSONDocument } from './validation/parseFile';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { AxiosResponse } from 'axios';
2
+ import type { Response } from 'undici';
3
3
  import { PathLike } from 'fs';
4
4
  import type { DocumentBuilder } from './documentBuilder';
5
5
  import type { Transformer } from './validation/transformers/transformer';
@@ -23,13 +23,13 @@ export interface UploadProgress {
23
23
  * @param {string[]} files Files from which the documentBuilders were generated
24
24
  * @param {DocumentBuilder[]} batch List of the uploaded DocumentBuilders
25
25
  * @param {UploadProgress} progress Progress of the upload process
26
- * @param {AxiosResponse} res Axios response
26
+ * @param {Response} res fetch response
27
27
  */
28
28
  export interface UploadBatchCallbackData {
29
29
  files: string[];
30
30
  batch: DocumentBuilder[];
31
31
  progress?: UploadProgress;
32
- res?: AxiosResponse;
32
+ res?: Response;
33
33
  }
34
34
  export interface BatchUpdateDocumentsOptions {
35
35
  /**
@@ -0,0 +1,34 @@
1
+ import { PermissionSet } from '@coveo/platform-client';
2
+ import { SecurityIdentityBuilder } from './securityIdentityBuilder';
3
+ export type PermissionSection = keyof Pick<PermissionSet, 'allowedPermissions' | 'deniedPermissions'>;
4
+ export declare class PermissionSetBuilder {
5
+ private permissionSet;
6
+ /**
7
+ * Builds a Permission Set Model
8
+ *
9
+ * See[Simple Permission Model Definition](https://docs.coveo.com/en/107/index-content/simple-permission-model-definition-examples)
10
+ * @param {boolean} allowAnonymous Whether to allow anonymous users in this permission set
11
+ */
12
+ constructor(allowAnonymous: boolean);
13
+ /**
14
+ * Set allowed identities on the document. See {@link PermissionSet}
15
+ *
16
+ * When the {@link PermissionsSetBuilder} class is instanciated with `allowAnonymous` property set to `true`, calling this method is redundant, and can therefore be omitted.
17
+ * @param securityIdentityBuilder The allowed security identities to add to the permission set
18
+ * @returns
19
+ */
20
+ withAllowedPermissions(securityIdentityBuilder: SecurityIdentityBuilder): this;
21
+ /**
22
+ * Set denied identities on the document. See {@link PermissionSet}
23
+ *
24
+ * @param securityIdentityBuilder The denied security identities to add to the permission set
25
+ * @returns
26
+ */
27
+ withDeniedPermissions(securityIdentityBuilder: SecurityIdentityBuilder): this;
28
+ /**
29
+ * Build and return the security identity or identities.
30
+ * @returns
31
+ */
32
+ build(): PermissionSet;
33
+ private setPermission;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,12 +1,12 @@
1
- import { SecurityIdentity, SecurityIdentityType } from './document';
1
+ import { Permission, PermissionIdentityType } from '@coveo/platform-client';
2
2
  /**
3
- * Build a security identity. See {@link SecurityIdentity}.
3
+ * Build a security identity. See {@link Permission}.
4
4
  */
5
5
  export interface SecurityIdentityBuilder {
6
- build(): SecurityIdentity | SecurityIdentity[];
6
+ build(): Permission | Permission[];
7
7
  }
8
8
  /**
9
- * Build any {@link SecurityIdentityType}.
9
+ * Build any {@link PermissionIdentityType}.
10
10
  *
11
11
  * Instead of using this class directly, use one of:
12
12
  * - {@link UserSecurityIdentityBuilder}
@@ -16,81 +16,90 @@ export interface SecurityIdentityBuilder {
16
16
  export declare class AnySecurityIdentityBuilder implements SecurityIdentityBuilder {
17
17
  private securityIdentity;
18
18
  /**
19
+ * @param identityType The type of the identity.
20
+ * Valid values:
21
+ * - `UNKNOWN`
22
+ * - `USER` : Defines a single user.
23
+ * - `GROUP` : Defines an existing group of identities within the indexed system. Individual members of this group can be of any valid identity Type (USER, GROUP, or VIRTUAL_GROUP).
24
+ * - `VIRTUAL_GROUP` : Defines a group that doesn't exist within the indexed system. Mechanically, a `VIRTUAL_GROUP` is identical to a `GROUP`.
19
25
  *
20
- * @param identityType
21
- * @param identity
22
- * @param securityProvider
26
+ * @param identity The name of the security identity.
27
+ * Examples:
28
+ * - `asmith@example.com`
29
+ * - `SampleTeam2`
30
+ *
31
+ * @param securityProvider The security identity provider through which the security identity is updated. Defaults to the first security identity provider associated with the target source.
23
32
  */
24
- constructor(identityType: SecurityIdentityType, identity: string, securityProvider?: string);
33
+ constructor(identityType: PermissionIdentityType, identity: string, securityProvider?: string);
25
34
  /**
26
35
  * Build and return the security identity.
27
36
  * @returns
28
37
  */
29
- build(): SecurityIdentity;
38
+ build(): Permission;
30
39
  }
31
40
  /**
32
41
  * Build a security identity of type `USER`.
33
42
  *
34
- * Typically used in conjunction with {@link DocumentBuilder.withAllowedPermissions} or {@link DocumentBuilder.withDeniedPermissions}.
43
+ * Typically used in conjunction with {@link PermissionSetBuilder.withAllowedPermissions} or {@link PermissionSetBuilder.withDeniedPermissions}.
35
44
  *
36
- * See {@link SecurityIdentity}.
45
+ * See {@link Permission}.
37
46
  */
38
47
  export declare class UserSecurityIdentityBuilder implements SecurityIdentityBuilder {
39
48
  private user;
40
49
  private securityProvider;
41
50
  /**
42
51
  * Pass either a single user, or an array of user to create multiple identities.
43
- * @param user
44
- * @param securityProvider
52
+ * @param {(string | string[])} user The user identity or identities
53
+ * @param {string} [securityProvider='Email Security Provider'] The security identity provider through which the security identity is updated. Defaults to the first security identity provider associated with the target source.
45
54
  */
46
55
  constructor(user: string | string[], securityProvider?: string);
47
56
  /**
48
57
  * Build and return the security identity or identities.
49
58
  * @returns
50
59
  */
51
- build(): SecurityIdentity | SecurityIdentity[];
60
+ build(): Permission | Permission[];
52
61
  }
53
62
  /**
54
63
  * Build a security identity of type `GROUP`.
55
64
  *
56
- * Typically used in conjunction with {@link DocumentBuilder.withAllowedPermissions} or {@link DocumentBuilder.withDeniedPermissions}.
65
+ * Typically used in conjunction with {@link PermissionSetBuilder.withAllowedPermissions} or {@link PermissionSetBuilder.withDeniedPermissions}.
57
66
  *
58
- * See {@link SecurityIdentity}.
67
+ * See {@link Permission}.
59
68
  */
60
69
  export declare class GroupSecurityIdentityBuilder implements SecurityIdentityBuilder {
61
70
  private group;
62
71
  private securityProvider?;
63
72
  /**
64
73
  * Pass either a single `group`, or an array of `group` to create multiple identities.
65
- * @param group
66
- * @param securityProvider
74
+ * @param {(string | string[])} group
75
+ * @param {string} [securityProvider] The security identity provider through which the security identity is updated. Defaults to the first security identity provider associated with the target source.
67
76
  */
68
77
  constructor(group: string | string[], securityProvider?: string | undefined);
69
78
  /**
70
79
  * Build and return the security identity or identities.
71
80
  * @returns
72
81
  */
73
- build(): SecurityIdentity | SecurityIdentity[];
82
+ build(): Permission | Permission[];
74
83
  }
75
84
  /**
76
85
  * Build a security identity of type `VIRTUAL_GROUP`.
77
86
  *
78
- * Typically used in conjunction with {@link DocumentBuilder.withAllowedPermissions} or {@link DocumentBuilder.withDeniedPermissions}.
87
+ * Typically used in conjunction with {@link PermissionSetBuilder.withAllowedPermissions} or {@link PermissionSetBuilder.withDeniedPermissions}.
79
88
  *
80
- * See {@link SecurityIdentity}.
89
+ * See {@link Permission}.
81
90
  */
82
91
  export declare class VirtualGroupSecurityIdentityBuilder implements SecurityIdentityBuilder {
83
92
  private virtualGroup;
84
93
  private securityProvider?;
85
94
  /**
86
95
  * Pass either a single `virtualGroup`, or an array of `virtualGroup` to create multiple identities.
87
- * @param group
88
- * @param securityProvider
96
+ * @param {(string | string[])} virtualGroup
97
+ * @param {string} [securityProvider] The security identity provider through which the security identity is updated. Defaults to the first security identity provider associated with the target source.
89
98
  */
90
99
  constructor(virtualGroup: string | string[], securityProvider?: string | undefined);
91
100
  /**
92
101
  * Build and return the security identity or identities.
93
102
  * @returns
94
103
  */
95
- build(): SecurityIdentity | SecurityIdentity[];
104
+ build(): Permission | Permission[];
96
105
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import 'fetch-undici-polyfill';
1
2
  import { SourceVisibility } from '@coveo/platform-client';
2
3
  import { PlatformUrlOptions } from '../environment';
3
4
  import { SecurityIdentity } from './securityIdenty';
@@ -39,7 +40,7 @@ export declare class CatalogSource {
39
40
  * @param {BatchUpdateDocumentsOptions}
40
41
  * @returns
41
42
  */
42
- batchUpdateDocuments(sourceId: string, batch: BatchUpdateDocuments, options?: BatchUpdateDocumentsOptions): Promise<import("axios").AxiosResponse<any, any>>;
43
+ batchUpdateDocuments(sourceId: string, batch: BatchUpdateDocuments, options?: BatchUpdateDocumentsOptions): Promise<import("undici").Response>;
43
44
  /**
44
45
  * Send your catalog data to your catalog source.
45
46
  * See [How to Stream Your Catalog Data to Your Source](https://docs.coveo.com/en/lb4a0344)
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import PlatformClient from '@coveo/platform-client';
3
- import { AxiosResponse } from 'axios';
3
+ import type { Response } from 'undici';
4
4
  import { APICore } from '../APICore';
5
5
  import { DocumentBuilder } from '../documentBuilder';
6
6
  import { BatchUpdateDocuments, BatchUpdateDocumentsFromFiles, BatchUpdateDocumentsOptions } from '../interfaces';
7
7
  import { UploadStrategy } from '../uploadStrategy';
8
8
  import { BatchUploadDocumentsFromFilesReturn } from './batchUploadDocumentsFromFile';
9
- export declare function uploadDocument(platformClient: PlatformClient, docBuilder: DocumentBuilder, addURL: URL, api: APICore, options?: BatchUpdateDocumentsOptions): Promise<AxiosResponse<unknown, any>>;
10
- export declare function uploadBatch(platformClient: PlatformClient, strategy: UploadStrategy, batch: BatchUpdateDocuments, options?: BatchUpdateDocumentsOptions): Promise<AxiosResponse>;
9
+ export declare function uploadDocument(platformClient: PlatformClient, docBuilder: DocumentBuilder, addURL: URL, api: APICore, options?: BatchUpdateDocumentsOptions): Promise<Response>;
10
+ export declare function uploadBatch(platformClient: PlatformClient, strategy: UploadStrategy, batch: BatchUpdateDocuments, options?: BatchUpdateDocumentsOptions): Promise<Response>;
11
11
  export declare function uploadBatchFromFile(platformClient: PlatformClient, strategy: UploadStrategy, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles): BatchUploadDocumentsFromFilesReturn;