@coveo/push-api-client 1.7.0 → 2.1.1

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 (113) hide show
  1. package/README.md +2 -2
  2. package/dist/definitions/environment.d.ts +3 -3
  3. package/dist/definitions/errors/privilegeError.d.ts +6 -0
  4. package/dist/definitions/help/axiosUtils.d.ts +2 -0
  5. package/dist/definitions/help/fileConsumer.d.ts +26 -0
  6. package/dist/definitions/{source.spec.d.ts → help/fileConsumer.spec.d.ts} +0 -0
  7. package/dist/definitions/help/fileContainer.d.ts +9 -0
  8. package/dist/definitions/help/fileContainer.spec.d.ts +1 -0
  9. package/dist/definitions/help/urlUtils.d.ts +27 -0
  10. package/dist/definitions/index.d.ts +7 -2
  11. package/dist/definitions/interfaces.d.ts +39 -0
  12. package/dist/definitions/source/batchUploadDocumentsFromFile.d.ts +11 -0
  13. package/dist/definitions/source/catalog.d.ts +69 -0
  14. package/dist/definitions/source/catalog.spec.d.ts +1 -0
  15. package/dist/definitions/source/catalog.stream.spec.d.ts +1 -0
  16. package/dist/definitions/source/documentUploader.d.ts +5 -0
  17. package/dist/definitions/{source.d.ts → source/push.d.ts} +35 -77
  18. package/dist/definitions/source/push.spec.d.ts +1 -0
  19. package/dist/definitions/source/securityIdenty.d.ts +42 -0
  20. package/dist/definitions/source/source.d.ts +5 -0
  21. package/dist/definitions/uploadStrategy/fileContainerStrategy.d.ts +23 -0
  22. package/dist/definitions/uploadStrategy/index.d.ts +3 -0
  23. package/dist/definitions/uploadStrategy/strategy.d.ts +16 -0
  24. package/dist/definitions/uploadStrategy/streamChunkStrategy.d.ts +27 -0
  25. package/dist/definitions/validation/preconditions/apiKeyPrivilege.d.ts +3 -0
  26. package/dist/definitions/validation/preconditions/apiKeyPrivilege.spec.d.ts +1 -0
  27. package/dist/definitions/validation/preconditions/platformPrivilege.d.ts +7 -0
  28. package/dist/docs/assets/search.js +1 -1
  29. package/dist/docs/classes/AnySecurityIdentityBuilder.html +3 -3
  30. package/dist/docs/classes/CatalogSource.html +40 -0
  31. package/dist/docs/classes/DocumentBuilder.html +17 -17
  32. package/dist/docs/classes/FieldAnalyser.html +3 -3
  33. package/dist/docs/classes/GroupSecurityIdentityBuilder.html +3 -3
  34. package/dist/docs/classes/PushSource.html +43 -0
  35. package/dist/docs/classes/UserSecurityIdentityBuilder.html +3 -3
  36. package/dist/docs/classes/VirtualGroupSecurityIdentityBuilder.html +3 -3
  37. package/dist/docs/enums/PlatformEnvironment.html +1 -1
  38. package/dist/docs/enums/Region.html +1 -1
  39. package/dist/docs/enums/SourceVisibility.html +1 -1
  40. package/dist/docs/index.html +2 -2
  41. package/dist/docs/interfaces/BatchUpdateDocuments.html +1 -1
  42. package/dist/docs/interfaces/Document.html +14 -14
  43. package/dist/docs/interfaces/SecurityIdentity.html +4 -4
  44. package/dist/docs/interfaces/SecurityIdentityBuilder.html +1 -1
  45. package/dist/docs/interfaces/UploadBatchCallbackData.html +1 -1
  46. package/dist/docs/modules.html +3 -2
  47. package/dist/environment.js.map +1 -1
  48. package/dist/errors/privilegeError.js +13 -0
  49. package/dist/errors/privilegeError.js.map +1 -0
  50. package/dist/fieldAnalyser/fieldAnalyser.js +3 -0
  51. package/dist/fieldAnalyser/fieldAnalyser.js.map +1 -1
  52. package/dist/fieldAnalyser/fieldAnalyser.spec.js +13 -0
  53. package/dist/fieldAnalyser/fieldAnalyser.spec.js.map +1 -1
  54. package/dist/fieldAnalyser/fieldUtils.js +4 -0
  55. package/dist/fieldAnalyser/fieldUtils.js.map +1 -1
  56. package/dist/fieldAnalyser/fieldsUtils.spec.js +3 -0
  57. package/dist/fieldAnalyser/fieldsUtils.spec.js.map +1 -1
  58. package/dist/help/axiosUtils.js +12 -0
  59. package/dist/help/axiosUtils.js.map +1 -0
  60. package/dist/help/fileConsumer.js +100 -0
  61. package/dist/help/fileConsumer.js.map +1 -0
  62. package/dist/help/fileConsumer.spec.js +75 -0
  63. package/dist/help/fileConsumer.spec.js.map +1 -0
  64. package/dist/help/fileContainer.js +20 -0
  65. package/dist/help/fileContainer.js.map +1 -0
  66. package/dist/help/fileContainer.spec.js +34 -0
  67. package/dist/help/fileContainer.spec.js.map +1 -0
  68. package/dist/help/urlUtils.js +43 -0
  69. package/dist/help/urlUtils.js.map +1 -0
  70. package/dist/index.js +8 -3
  71. package/dist/index.js.map +1 -1
  72. package/dist/interfaces.js +3 -0
  73. package/dist/interfaces.js.map +1 -0
  74. package/dist/localtest.js +2 -2
  75. package/dist/localtest.js.map +1 -1
  76. package/dist/source/batchUploadDocumentsFromFile.js +50 -0
  77. package/dist/source/batchUploadDocumentsFromFile.js.map +1 -0
  78. package/dist/source/catalog.js +115 -0
  79. package/dist/source/catalog.js.map +1 -0
  80. package/dist/source/catalog.spec.js +239 -0
  81. package/dist/source/catalog.spec.js.map +1 -0
  82. package/dist/source/catalog.stream.spec.js +189 -0
  83. package/dist/source/catalog.stream.spec.js.map +1 -0
  84. package/dist/source/documentUploader.js +23 -0
  85. package/dist/source/documentUploader.js.map +1 -0
  86. package/dist/source/push.js +199 -0
  87. package/dist/source/push.js.map +1 -0
  88. package/dist/{source.spec.js → source/push.spec.js} +44 -27
  89. package/dist/source/push.spec.js.map +1 -0
  90. package/dist/source/securityIdenty.js +59 -0
  91. package/dist/source/securityIdenty.js.map +1 -0
  92. package/dist/source/source.js +9 -0
  93. package/dist/source/source.js.map +1 -0
  94. package/dist/uploadStrategy/fileContainerStrategy.js +34 -0
  95. package/dist/uploadStrategy/fileContainerStrategy.js.map +1 -0
  96. package/dist/uploadStrategy/index.js +7 -0
  97. package/dist/uploadStrategy/index.js.map +1 -0
  98. package/dist/uploadStrategy/strategy.js +3 -0
  99. package/dist/uploadStrategy/strategy.js.map +1 -0
  100. package/dist/uploadStrategy/streamChunkStrategy.js +51 -0
  101. package/dist/uploadStrategy/streamChunkStrategy.js.map +1 -0
  102. package/dist/validation/preconditions/apiKeyPrivilege.js +21 -0
  103. package/dist/validation/preconditions/apiKeyPrivilege.js.map +1 -0
  104. package/dist/validation/preconditions/apiKeyPrivilege.spec.js +70 -0
  105. package/dist/validation/preconditions/apiKeyPrivilege.spec.js.map +1 -0
  106. package/dist/validation/preconditions/platformPrivilege.js +35 -0
  107. package/dist/validation/preconditions/platformPrivilege.js.map +1 -0
  108. package/package.json +1 -1
  109. package/dist/docs/classes/Source.html +0 -45
  110. package/dist/docs/interfaces/BatchUpdateDocumentsFromFiles.html +0 -7
  111. package/dist/source.js +0 -322
  112. package/dist/source.js.map +0 -1
  113. package/dist/source.spec.js.map +0 -1
package/README.md CHANGED
@@ -9,10 +9,10 @@ Coveo Push API client
9
9
  ## Usage
10
10
 
11
11
  ```js
12
- import {Source, DocumentBuilder} from '@coveo/push-api-client';
12
+ import {PushSource, DocumentBuilder} from '@coveo/push-api-client';
13
13
 
14
14
  async function main() {
15
- const source = new Source('my_api_key', 'my_coveo_organization_id');
15
+ const source = new PushSource('my_api_key', 'my_coveo_organization_id');
16
16
 
17
17
  const myDocument = new DocumentBuilder(
18
18
  'https://my.document.uri',
@@ -9,8 +9,8 @@ export declare enum PlatformEnvironment {
9
9
  export declare const DEFAULT_ENVIRONMENT: PlatformEnvironment.Prod;
10
10
  export declare const DEFAULT_REGION: Region.US;
11
11
  export declare type PlatformUrlOptions = {
12
- environment: PlatformEnvironment;
13
- region: Region;
12
+ environment?: PlatformEnvironment;
13
+ region?: Region;
14
14
  };
15
- export declare function platformUrl(options?: Partial<PlatformUrlOptions>): string;
15
+ export declare function platformUrl(options?: PlatformUrlOptions): string;
16
16
  export declare function castEnvironmentToPlatformClient(e: PlatformEnvironment): Environment;
@@ -0,0 +1,6 @@
1
+ import { PushApiClientBaseError } from './baseError';
2
+ export declare class PrivilegeError extends PushApiClientBaseError {
3
+ message: string;
4
+ name: string;
5
+ constructor(message: string);
6
+ }
@@ -0,0 +1,2 @@
1
+ import type { AxiosRequestConfig } from 'axios';
2
+ export declare const axiosRequestHeaders: (apikey: string) => AxiosRequestConfig;
@@ -0,0 +1,26 @@
1
+ import { BatchUpdateDocuments, UploadBatchCallbackData, ConcurrentProcessing } from '../interfaces';
2
+ import { AxiosResponse } from 'axios';
3
+ export declare type SuccessfulUploadCallback = (data: UploadBatchCallbackData) => void;
4
+ export declare type FailedUploadCallback = (err: unknown, value: UploadBatchCallbackData) => void;
5
+ /**
6
+ * Util class to help injesting documents through a list of files and uploading generated document batches.
7
+ */
8
+ export declare class FileConsumer {
9
+ private upload;
10
+ private processingConfig;
11
+ private static maxContentLength;
12
+ private cbSuccess;
13
+ private cbFail;
14
+ /**
15
+ * Creates an instance of FileConsumer.
16
+ * @param {(batch: BatchUpdateDocuments) => Promise<AxiosResponse>} upload the upload operation to apply to every document batch
17
+ * @param {Required<ConcurrentProcessing>} processingConfig
18
+ */
19
+ constructor(upload: (batch: BatchUpdateDocuments) => Promise<AxiosResponse>, processingConfig: Required<ConcurrentProcessing>);
20
+ consume(files: string[]): Promise<void>;
21
+ onSuccess(callback: SuccessfulUploadCallback): void;
22
+ onError(callback: FailedUploadCallback): void;
23
+ private splitByChunkAndUpload;
24
+ private uploadBatch;
25
+ private get accumulator();
26
+ }
@@ -0,0 +1,9 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { BatchUpdateDocuments } from '../interfaces';
3
+ export interface FileContainerResponse {
4
+ uploadUri: string;
5
+ fileId: string;
6
+ requiredHeaders: Record<string, string>;
7
+ }
8
+ export declare const uploadContentToFileContainer: (fileContainer: FileContainerResponse, batch: BatchUpdateDocuments) => Promise<import("axios").AxiosResponse<any, any>>;
9
+ export declare const getFileContainerAxiosConfig: (fileContainer: FileContainerResponse) => AxiosRequestConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ /// <reference types="node" />
2
+ import { PlatformUrlOptions } from '..';
3
+ export interface URLBuilder {
4
+ baseAPIURLForUpdate: URL;
5
+ fileContainerUrl: URL;
6
+ }
7
+ declare abstract class BaseUrlBuilder {
8
+ private organizationId;
9
+ private options;
10
+ protected constructor(organizationId: string, options: Required<PlatformUrlOptions>);
11
+ protected get platformURL(): string;
12
+ get fileContainerUrl(): import("url").URL;
13
+ abstract get baseAPIURLForUpdate(): URL;
14
+ }
15
+ export declare class PushUrlBuilder extends BaseUrlBuilder implements URLBuilder {
16
+ private sourceId;
17
+ constructor(sourceId: string, organizationId: string, options: Required<PlatformUrlOptions>);
18
+ get baseURL(): import("url").URL;
19
+ get baseAPIURLForUpdate(): import("url").URL;
20
+ }
21
+ export declare class StreamUrlBuilder extends BaseUrlBuilder implements URLBuilder {
22
+ private sourceId;
23
+ constructor(sourceId: string, organizationId: string, options: Required<PlatformUrlOptions>);
24
+ get baseStreamURL(): import("url").URL;
25
+ get baseAPIURLForUpdate(): import("url").URL;
26
+ }
27
+ export {};
@@ -1,6 +1,11 @@
1
1
  export * from './document';
2
- export { Source, SourceVisibility, BatchUpdateDocuments, UploadBatchCallback, UploadBatchCallbackData, BatchUpdateDocumentsFromFiles, } from './source';
2
+ export { Source } from './source/source';
3
+ export { PushSource } from './source/push';
4
+ export { CatalogSource } from './source/catalog';
5
+ export { SuccessfulUploadCallback, FailedUploadCallback, } from './help/fileConsumer';
6
+ export { UploadBatchCallbackData, BatchUpdateDocuments, BatchUpdateDocumentsFromFiles, } from './interfaces';
3
7
  export { FieldAnalyser } from './fieldAnalyser/fieldAnalyser';
4
8
  export { DocumentBuilder } from './documentBuilder';
5
9
  export * from './securityIdentityBuilder';
6
- export { PlatformEnvironment, Region } from './environment';
10
+ export { PlatformEnvironment, Region, PlatformUrlOptions } from './environment';
11
+ export { SourceVisibility } from '@coveord/platform-client';
@@ -0,0 +1,39 @@
1
+ import type { AxiosResponse } from 'axios';
2
+ import type { DocumentBuilder } from './documentBuilder';
3
+ export interface BatchUpdateDocuments {
4
+ addOrUpdate: DocumentBuilder[];
5
+ delete: {
6
+ documentId: string;
7
+ deleteChildren: boolean;
8
+ }[];
9
+ }
10
+ /**
11
+ *
12
+ * @param {string[]} files Files from which the documentBuilders were generated
13
+ * @param {DocumentBuilder[]} batch List of the uploaded DocumentBuilders
14
+ * @param {AxiosResponse} res Axios response
15
+ */
16
+ export interface UploadBatchCallbackData {
17
+ files: string[];
18
+ batch: DocumentBuilder[];
19
+ res?: AxiosResponse;
20
+ }
21
+ export interface BatchUpdateDocumentsOptions {
22
+ /**
23
+ * Whether to create the missing fields required in the index based on the document batch metadata.
24
+ *
25
+ * Make sure your API key is granted the privilege to EDIT fields before using this option.
26
+ * See https://docs.coveo.com/en/1707#fields-domain
27
+ */
28
+ createFields?: boolean;
29
+ }
30
+ export interface ConcurrentProcessing {
31
+ /**
32
+ * The maximum number of requests to send concurrently to the Coveo platform.
33
+ * Increasing this value will increase the speed at which documents are pushed but will also consume more memory.
34
+ *
35
+ * The default value is set to 10.
36
+ */
37
+ maxConcurrent?: number;
38
+ }
39
+ export declare type BatchUpdateDocumentsFromFiles = BatchUpdateDocumentsOptions & ConcurrentProcessing;
@@ -0,0 +1,11 @@
1
+ import PlatformClient from '@coveord/platform-client';
2
+ import { BatchUpdateDocumentsFromFiles, FailedUploadCallback, SuccessfulUploadCallback } from '../index';
3
+ import type { UploadStrategy } from '../uploadStrategy';
4
+ export declare class BatchUploadDocumentsFromFilesReturn {
5
+ private internalPromise;
6
+ private consumer;
7
+ constructor(platformClient: PlatformClient, strategy: UploadStrategy, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles);
8
+ onBatchUpload(cb: SuccessfulUploadCallback): this;
9
+ onBatchError(cb: FailedUploadCallback): this;
10
+ batch(): Promise<void>;
11
+ }
@@ -0,0 +1,69 @@
1
+ import { SourceVisibility } from '@coveord/platform-client';
2
+ import { PlatformUrlOptions } from '../environment';
3
+ import { SecurityIdentity } from './securityIdenty';
4
+ import { BatchUpdateDocuments, BatchUpdateDocumentsFromFiles, BatchUpdateDocumentsOptions } from '../interfaces';
5
+ import { BatchUploadDocumentsFromFilesReturn } from './batchUploadDocumentsFromFile';
6
+ /**
7
+ * Manage a catalog source.
8
+ *
9
+ * Allows you to create a new catalog source, manage security identities and documents in a Coveo organization.
10
+ */
11
+ export declare class CatalogSource {
12
+ private apikey;
13
+ private organizationid;
14
+ private platformClient;
15
+ private options;
16
+ private static defaultOptions;
17
+ /**
18
+ * Creates an instance of CatalogSource.
19
+ * @param {string} apikey An apiKey capable of pushing documents and managing sources in a Coveo organization. See [Manage API Keys](https://docs.coveo.com/en/1718).
20
+ * @param {string} organizationid The Coveo Organization identifier.
21
+ * @param {PlatformUrlOptions} [opts=CatalogSource.defaultOptions]
22
+ */
23
+ constructor(apikey: string, organizationid: string, opts?: PlatformUrlOptions);
24
+ /**
25
+ * Create a new catalog source
26
+ * @param name The name of the source to create.
27
+ * @param sourceVisibility The security option that should be applied to the content of the source. See [Content Security](https://docs.coveo.com/en/1779).
28
+ * @returns
29
+ */
30
+ create(name: string, sourceVisibility: SourceVisibility): Promise<{
31
+ id: string;
32
+ }>;
33
+ get identity(): SecurityIdentity;
34
+ /**
35
+ * Manage batches of items in a catalog source.
36
+ * See [Full Document Update](https://docs.coveo.com/en/l62e0540)
37
+ * @param sourceId
38
+ * @param batch
39
+ * @param {BatchUpdateDocumentsOptions} [{createFields: createFields = true}={}]
40
+ * @returns
41
+ */
42
+ batchUpdateDocuments(sourceId: string, batch: BatchUpdateDocuments, { createFields: createFields }?: BatchUpdateDocumentsOptions): Promise<import("axios").AxiosResponse<any, any>>;
43
+ /**
44
+ * Send your catalog data to your catalog source.
45
+ * See [How to Stream Your Catalog Data to Your Source](https://docs.coveo.com/en/lb4a0344)
46
+ * @param {string} sourceId
47
+ * @param {BatchUpdateDocuments} batch
48
+ * @param {BatchUpdateDocumentsOptions} [{createFields: createFields = true}={}]
49
+ */
50
+ batchStreamDocuments(sourceId: string, batch: BatchUpdateDocuments, { createFields: createFields }?: BatchUpdateDocumentsOptions): Promise<void>;
51
+ /**
52
+ * Manage batches of items in a catalog source from a list of JSON files. See [Full Document Update Source](https://docs.coveo.com/en/l62e0540)
53
+ * @param {string} sourceId The unique identifier of the target Push source
54
+ * @param {string[]} filesOrDirectories A list of JSON files or directories (containing JSON files) from which to extract documents.
55
+ * @param {BatchUpdateDocumentsFromFiles} options
56
+ */
57
+ batchUpdateDocumentsFromFiles(sourceId: string, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles): BatchUploadDocumentsFromFilesReturn;
58
+ /**
59
+ * Send your catalog data to your catalog source from a list of JSON files.
60
+ * See [How to Stream Your Catalog Data to Your Source](https://docs.coveo.com/en/lb4a0344)
61
+ * @param {string} sourceId The unique identifier of the target Push source
62
+ * @param {string[]} filesOrDirectories A list of JSON files or directories (containing JSON files) from which to extract documents.
63
+ * @param {BatchUpdateDocumentsFromFiles} [options]
64
+ */
65
+ batchStreamDocumentsFromFiles(sourceId: string, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles): BatchUploadDocumentsFromFilesReturn;
66
+ private urlBuilder;
67
+ private fileContainerStrategy;
68
+ private streamChunkStrategy;
69
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import PlatformClient from '@coveord/platform-client';
2
+ import { AxiosResponse } from 'axios';
3
+ import { BatchUpdateDocuments } from '../interfaces';
4
+ import { UploadStrategy } from '../uploadStrategy';
5
+ export declare function uploadBatch(platformClient: PlatformClient, strategy: UploadStrategy, batch: BatchUpdateDocuments, createFields?: boolean): Promise<AxiosResponse>;
@@ -1,61 +1,29 @@
1
- import { SecurityIdentityAliasModel, SecurityIdentityBatchConfig, SecurityIdentityDelete, SecurityIdentityDeleteOptions, SecurityIdentityModel, SourceVisibility } from '@coveord/platform-client';
1
+ import { PlatformClient, SecurityIdentityAliasModel, SecurityIdentityBatchConfig, SecurityIdentityDelete, SecurityIdentityDeleteOptions, SecurityIdentityModel, SourceVisibility } from '@coveord/platform-client';
2
2
  export { SourceVisibility } from '@coveord/platform-client';
3
- import { AxiosResponse } from 'axios';
4
- import { DocumentBuilder } from './documentBuilder';
5
- import { PlatformUrlOptions } from './environment';
3
+ import { DocumentBuilder } from '../documentBuilder';
4
+ import { PlatformUrlOptions } from '../environment';
5
+ import { FieldAnalyser } from '../fieldAnalyser/fieldAnalyser';
6
+ import { SecurityIdentity } from './securityIdenty';
7
+ import { BatchUpdateDocuments, BatchUpdateDocumentsFromFiles, BatchUpdateDocumentsOptions } from '../interfaces';
8
+ import { BatchUploadDocumentsFromFilesReturn } from './batchUploadDocumentsFromFile';
6
9
  export declare type SourceStatus = 'REBUILD' | 'REFRESH' | 'INCREMENTAL' | 'IDLE';
7
- export interface BatchUpdateDocuments {
8
- addOrUpdate: DocumentBuilder[];
9
- delete: {
10
- documentId: string;
11
- deleteChildren: boolean;
12
- }[];
13
- }
14
- /**
15
- *
16
- * @param {string[]} files Files from which the documentBuilders were generated
17
- * @param {DocumentBuilder[]} batch List of the uploaded DocumentBuilders
18
- * @param {AxiosResponse} res Axios response
19
- */
20
- export interface UploadBatchCallbackData {
21
- files: string[];
22
- batch: DocumentBuilder[];
23
- res?: AxiosResponse;
24
- }
25
- export declare type UploadBatchCallback = (err: unknown | null, data: UploadBatchCallbackData) => void;
26
- export interface BatchUpdateDocumentsOptions {
27
- /**
28
- * Whether to create fields required in the index based on the document batch metadata.
29
- */
30
- createFields?: boolean;
31
- }
32
- export interface BatchUpdateDocumentsFromFiles extends BatchUpdateDocumentsOptions {
33
- /**
34
- * The maximum number of requests to send concurrently to the Coveo platform.
35
- * Increasing this value will increase the speed at which documents are pushed but will also consume more memory.
36
- *
37
- * The default value is set to 10.
38
- */
39
- maxConcurrent?: number;
40
- }
41
10
  /**
42
11
  * Manage a push source.
43
12
  *
44
13
  * Allows you to create a new push source, manage security identities and documents in a Coveo organization.
45
14
  */
46
- export declare class Source {
15
+ export declare class PushSource {
47
16
  private apikey;
48
17
  private organizationid;
49
- private platformClient;
18
+ platformClient: PlatformClient;
50
19
  private options;
51
20
  private static defaultOptions;
52
- private static maxContentLength;
53
21
  /**
54
22
  *
55
23
  * @param apikey An apiKey capable of pushing documents and managing sources in a Coveo organization. See [Manage API Keys](https://docs.coveo.com/en/1718).
56
24
  * @param organizationid The Coveo Organization identifier.
57
25
  */
58
- constructor(apikey: string, organizationid: string, options?: Partial<PlatformUrlOptions>);
26
+ constructor(apikey: string, organizationid: string, options?: PlatformUrlOptions);
59
27
  /**
60
28
  * Create a new push source
61
29
  * @param name The name of the source to create.
@@ -66,37 +34,36 @@ export declare class Source {
66
34
  id: string;
67
35
  }>;
68
36
  /**
69
- * Create or update a security identity. See [Adding a Single Security Identity](https://docs.coveo.com/en/167) and [Security Identity Models](https://docs.coveo.com/en/139).
70
- * @param securityProviderId
71
- * @param securityIdentity
72
- * @returns
37
+ * @deprecated use `identity.createSecurityIdentity`
38
+ *
39
+ * See {@link Source.identity}
73
40
  */
74
41
  createSecurityIdentity(securityProviderId: string, securityIdentity: SecurityIdentityModel): Promise<void>;
75
42
  /**
76
- * Create or update a security identity alias. See [Adding a Single Alias](https://docs.coveo.com/en/142) and [User Alias Definition Examples](https://docs.coveo.com/en/46).
77
- * @param securityProviderId
78
- * @param securityIdentityAlias
79
- * @returns
43
+ * @deprecated use `identity.createOrUpdateSecurityIdentityAlias`
44
+ *
45
+ * See {@link Source.identity}
80
46
  */
81
47
  createOrUpdateSecurityIdentityAlias(securityProviderId: string, securityIdentityAlias: SecurityIdentityAliasModel): Promise<void>;
82
48
  /**
83
- * Delete a security identity. See [Disabling a Single Security Identity](https://docs.coveo.com/en/84).
84
- * @param securityProviderId
85
- * @param securityIdentityToDelete
86
- * @returns
49
+ * @deprecated use `identity.deleteSecurityIdentity`
50
+ *
51
+ * See {@link Source.identity}
87
52
  */
88
53
  deleteSecurityIdentity(securityProviderId: string, securityIdentityToDelete: SecurityIdentityDelete): Promise<void>;
89
54
  /**
90
- * Delete old security identities. See [Disabling Old Security Identities](https://docs.coveo.com/en/33).
91
- * @param securityProviderId
92
- * @param batchDelete
93
- * @returns
55
+ * @deprecated use `identity.deleteOldSecurityIdentities`
56
+ *
57
+ * See {@link Source.identity}
94
58
  */
95
59
  deleteOldSecurityIdentities(securityProviderId: string, batchDelete: SecurityIdentityDeleteOptions): Promise<void>;
96
60
  /**
97
- * Manage batches of security identities. See [Manage Batches of Security Identities](https://docs.coveo.com/en/55).
61
+ * @deprecated use `identity.manageSecurityIdentities`
62
+ *
63
+ * See {@link Source.identity}
98
64
  */
99
65
  manageSecurityIdentities(securityProviderId: string, batchConfig: SecurityIdentityBatchConfig): Promise<void>;
66
+ get identity(): SecurityIdentity;
100
67
  /**
101
68
  * Adds or updates an individual item in a push source. See [Adding a Single Item in a Push Source](https://docs.coveo.com/en/133).
102
69
  * @param sourceID
@@ -104,14 +71,14 @@ export declare class Source {
104
71
  * @param {BatchUpdateDocumentsOptions} [{createFields = true}={}]
105
72
  * @returns
106
73
  */
107
- addOrUpdateDocument(sourceID: string, docBuilder: DocumentBuilder, { createFields: createFields }?: BatchUpdateDocumentsOptions): Promise<AxiosResponse<any, any>>;
74
+ addOrUpdateDocument(sourceID: string, docBuilder: DocumentBuilder, { createFields: createFields }?: BatchUpdateDocumentsOptions): Promise<import("axios").AxiosResponse<any, any>>;
108
75
  /**
109
76
  * Manage batches of items in a push source. See [Manage Batches of Items in a Push Source](https://docs.coveo.com/en/90)
110
77
  * @param sourceID
111
78
  * @param batch
112
79
  * @returns
113
80
  */
114
- batchUpdateDocuments(sourceID: string, batch: BatchUpdateDocuments, { createFields: createFields }?: BatchUpdateDocumentsOptions): Promise<AxiosResponse<any, any>>;
81
+ batchUpdateDocuments(sourceID: string, batch: BatchUpdateDocuments, { createFields: createFields }?: BatchUpdateDocumentsOptions): Promise<import("axios").AxiosResponse<any, any>>;
115
82
  /**
116
83
  *
117
84
  * Manage batches of items in a push source from a list of JSON files. See [Manage Batches of Items in a Push Source](https://docs.coveo.com/en/90)
@@ -120,7 +87,7 @@ export declare class Source {
120
87
  * @param {UploadBatchCallback} callback Callback executed when a batch of documents is either successfully uploaded or when an error occurs during the upload
121
88
  * @param {BatchUpdateDocumentsFromFiles} options
122
89
  */
123
- batchUpdateDocumentsFromFiles(sourceID: string, filesOrDirectories: string[], callback: UploadBatchCallback, options?: BatchUpdateDocumentsFromFiles): Promise<void>;
90
+ batchUpdateDocumentsFromFiles(sourceID: string, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles): BatchUploadDocumentsFromFilesReturn;
124
91
  /**
125
92
  * Deletes a specific item from a Push source. Optionally, the child items of that item can also be deleted. See [Deleting an Item in a Push Source](https://docs.coveo.com/en/171).
126
93
  * @param sourceID
@@ -128,32 +95,23 @@ export declare class Source {
128
95
  * @param deleteChildren
129
96
  * @returns
130
97
  */
131
- deleteDocument(sourceID: string, documentId: string, deleteChildren?: boolean): Promise<AxiosResponse<any, any>>;
98
+ deleteDocument(sourceID: string, documentId: string, deleteChildren?: boolean): Promise<import("axios").AxiosResponse<any, any>>;
132
99
  /**
133
100
  * Deletes all items whose last update was made by a Push API operation whose orderingId is strictly lower than a specified value. See [Deleting Old Items in a Push Source](https://docs.coveo.com/en/131).
134
101
  * @param sourceID
135
102
  * @param olderThan
136
103
  * @returns
137
104
  */
138
- deleteDocumentsOlderThan(sourceID: string, olderThan: Date | string | number): Promise<AxiosResponse<any, any>>;
105
+ deleteDocumentsOlderThan(sourceID: string, olderThan: Date | string | number): Promise<import("axios").AxiosResponse<any, any>>;
139
106
  /**
140
107
  * Set the status of a push source. See [Updating the Status of a Push Source](https://docs.coveo.com/en/35/)
141
108
  * @param sourceID
142
109
  * @param status
143
110
  * @returns
144
111
  */
145
- setSourceStatus(sourceID: string, status: SourceStatus): Promise<AxiosResponse<any, any>>;
146
- private get baseAPIURL();
147
- private getBaseAPIURLForDocuments;
112
+ setSourceStatus(sourceID: string, status: SourceStatus): Promise<import("axios").AxiosResponse<any, any>>;
148
113
  private get documentsAxiosConfig();
149
- private createFields;
150
- private getFileContainerAxiosConfig;
151
- private get documentsRequestHeaders();
152
- private get authorizationHeader();
153
- private createFileContainer;
154
- private uploadContentToFileContainer;
155
- private pushFileContainerContent;
156
- private splitByChunkAndUpload;
157
- private uploadBatch;
158
- private get accumulator();
114
+ createFields(analyser: FieldAnalyser): Promise<void>;
115
+ private urlBuilder;
116
+ private fileContainerStrategy;
159
117
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import { PlatformClient, SecurityIdentityAliasModel, SecurityIdentityBatchConfig, SecurityIdentityDelete, SecurityIdentityDeleteOptions, SecurityIdentityModel } from '@coveord/platform-client';
2
+ export declare class SecurityIdentity {
3
+ private platformClient;
4
+ /**
5
+ *
6
+ * @param apikey An apiKey capable of pushing documents and managing sources in a Coveo organization. See [Manage API Keys](https://docs.coveo.com/en/1718).
7
+ * @param organizationid The Coveo Organization identifier.
8
+ */
9
+ constructor(platformClient: PlatformClient);
10
+ /**
11
+ * Create or update a security identity. See [Adding a Single Security Identity](https://docs.coveo.com/en/167) and [Security Identity Models](https://docs.coveo.com/en/139).
12
+ * @param securityProviderId
13
+ * @param securityIdentity
14
+ * @returns
15
+ */
16
+ createSecurityIdentity(securityProviderId: string, securityIdentity: SecurityIdentityModel): Promise<void>;
17
+ /**
18
+ * Create or update a security identity alias. See [Adding a Single Alias](https://docs.coveo.com/en/142) and [User Alias Definition Examples](https://docs.coveo.com/en/46).
19
+ * @param securityProviderId
20
+ * @param securityIdentityAlias
21
+ * @returns
22
+ */
23
+ createOrUpdateSecurityIdentityAlias(securityProviderId: string, securityIdentityAlias: SecurityIdentityAliasModel): Promise<void>;
24
+ /**
25
+ * Delete a security identity. See [Disabling a Single Security Identity](https://docs.coveo.com/en/84).
26
+ * @param securityProviderId
27
+ * @param securityIdentityToDelete
28
+ * @returns
29
+ */
30
+ deleteSecurityIdentity(securityProviderId: string, securityIdentityToDelete: SecurityIdentityDelete): Promise<void>;
31
+ /**
32
+ * Delete old security identities. See [Disabling Old Security Identities](https://docs.coveo.com/en/33).
33
+ * @param securityProviderId
34
+ * @param batchDelete
35
+ * @returns
36
+ */
37
+ deleteOldSecurityIdentities(securityProviderId: string, batchDelete: SecurityIdentityDeleteOptions): Promise<void>;
38
+ /**
39
+ * Manage batches of security identities. See [Manage Batches of Security Identities](https://docs.coveo.com/en/55).
40
+ */
41
+ manageSecurityIdentities(securityProviderId: string, batchConfig: SecurityIdentityBatchConfig): Promise<void>;
42
+ }
@@ -0,0 +1,5 @@
1
+ import { PushSource } from './push';
2
+ /**
3
+ * @deprecated This class has been replaced by {@link PushSource}
4
+ */
5
+ export declare const Source: typeof PushSource;
@@ -0,0 +1,23 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { BatchUpdateDocuments } from '../interfaces';
3
+ import { UploadStrategy } from './strategy';
4
+ import { URLBuilder } from '../help/urlUtils';
5
+ export interface FileContainerResponse {
6
+ uploadUri: string;
7
+ fileId: string;
8
+ requiredHeaders: Record<string, string>;
9
+ }
10
+ /**
11
+ * Upload documents using the [File container](https://docs.coveo.com/en/43/index-content/creating-a-file-container)
12
+ *
13
+ * @class FileContainerStrategy
14
+ * @implements {UploadStrategy}
15
+ */
16
+ export declare class FileContainerStrategy implements UploadStrategy {
17
+ private urlBuilder;
18
+ private documentsAxiosConfig;
19
+ constructor(urlBuilder: URLBuilder, documentsAxiosConfig: AxiosRequestConfig);
20
+ upload(batch: BatchUpdateDocuments): Promise<import("axios").AxiosResponse<any, any>>;
21
+ private createFileContainer;
22
+ private pushFileContainerContent;
23
+ }
@@ -0,0 +1,3 @@
1
+ export * from './fileContainerStrategy';
2
+ export * from './strategy';
3
+ export * from './streamChunkStrategy';
@@ -0,0 +1,16 @@
1
+ import type { AxiosResponse } from 'axios';
2
+ import type { BatchUpdateDocuments } from '../interfaces';
3
+ export interface UploadStrategy {
4
+ /**
5
+ * Upload a batch of documents
6
+ *
7
+ * @param {BatchUpdateDocuments} batch
8
+ */
9
+ upload: (batch: BatchUpdateDocuments) => Promise<AxiosResponse>;
10
+ /**
11
+ * Async operation to run once the batch upload is complete
12
+ *
13
+ * @memberof UploadStrategy
14
+ */
15
+ postUpload?: () => Promise<void>;
16
+ }
@@ -0,0 +1,27 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { BatchUpdateDocuments } from '../interfaces';
3
+ import { UploadStrategy } from './strategy';
4
+ import { StreamUrlBuilder } from '../help/urlUtils';
5
+ export interface StreamResponse {
6
+ uploadUri: string;
7
+ fileId: string;
8
+ requiredHeaders: Record<string, string>;
9
+ streamId: string;
10
+ }
11
+ /**
12
+ * Upload documents using the [Stream API](https://docs.coveo.com/en/lb4a0344/coveo-for-commerce/how-to-stream-your-catalog-data-to-your-source)
13
+ *
14
+ * @class StreamChunkStrategy
15
+ * @implements {UploadStrategy}
16
+ */
17
+ export declare class StreamChunkStrategy implements UploadStrategy {
18
+ private urlBuilder;
19
+ private documentsAxiosConfig;
20
+ private _openedStream;
21
+ constructor(urlBuilder: StreamUrlBuilder, documentsAxiosConfig: AxiosRequestConfig);
22
+ upload(batch: BatchUpdateDocuments): Promise<import("axios").AxiosResponse<any, any>>;
23
+ postUpload(): Promise<any>;
24
+ openStreamIfNotAlreadyOpen(): Promise<StreamResponse>;
25
+ closeOpenedStream(): Promise<any>;
26
+ private requestStreamChunk;
27
+ }
@@ -0,0 +1,3 @@
1
+ import type { PlatformPrivilege } from './platformPrivilege';
2
+ import PlatformClient from '@coveord/platform-client';
3
+ export declare function ensureNecessaryCoveoPrivileges(client: PlatformClient, ...privileges: PlatformPrivilege[]): Promise<void | never>;
@@ -0,0 +1,7 @@
1
+ import type { PrivilegeModel } from '@coveord/platform-client';
2
+ export interface PlatformPrivilege {
3
+ models: PrivilegeModel[];
4
+ unsatisfiedConditionMessage: string;
5
+ }
6
+ export declare const readFieldsPrivilege: PlatformPrivilege;
7
+ export declare const writeFieldsPrivilege: PlatformPrivilege;