@coveo/push-api-client 1.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/definitions/environment.d.ts +3 -3
- package/dist/definitions/help/fileConsumer.d.ts +26 -0
- package/dist/definitions/{source.spec.d.ts → help/fileConsumer.spec.d.ts} +0 -0
- package/dist/definitions/index.d.ts +6 -2
- package/dist/definitions/interfaces.d.ts +36 -0
- package/dist/definitions/source/batchUpdateDocumentsFromFile.d.ts +10 -0
- package/dist/definitions/{source.d.ts → source/push.d.ts} +34 -69
- package/dist/definitions/source/push.spec.d.ts +1 -0
- package/dist/definitions/source/securityIdenty.d.ts +42 -0
- package/dist/definitions/source/source.d.ts +5 -0
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/AnySecurityIdentityBuilder.html +3 -3
- package/dist/docs/classes/DocumentBuilder.html +17 -17
- package/dist/docs/classes/FieldAnalyser.html +3 -3
- package/dist/docs/classes/GroupSecurityIdentityBuilder.html +3 -3
- package/dist/docs/classes/PushSource.html +43 -0
- package/dist/docs/classes/UserSecurityIdentityBuilder.html +3 -3
- package/dist/docs/classes/VirtualGroupSecurityIdentityBuilder.html +3 -3
- package/dist/docs/enums/PlatformEnvironment.html +1 -1
- package/dist/docs/enums/Region.html +1 -1
- package/dist/docs/enums/SourceVisibility.html +1 -1
- package/dist/docs/index.html +1 -1
- package/dist/docs/interfaces/BatchUpdateDocuments.html +1 -1
- package/dist/docs/interfaces/Document.html +14 -14
- package/dist/docs/interfaces/SecurityIdentity.html +4 -4
- package/dist/docs/interfaces/SecurityIdentityBuilder.html +1 -1
- package/dist/docs/interfaces/UploadBatchCallbackData.html +1 -1
- package/dist/docs/modules.html +3 -2
- package/dist/environment.js.map +1 -1
- package/dist/help/fileConsumer.js +100 -0
- package/dist/help/fileConsumer.js.map +1 -0
- package/dist/help/fileConsumer.spec.js +75 -0
- package/dist/help/fileConsumer.spec.js.map +1 -0
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/interfaces.js +3 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/localtest.js +2 -2
- package/dist/localtest.js.map +1 -1
- package/dist/source/batchUpdateDocumentsFromFile.js +42 -0
- package/dist/source/batchUpdateDocumentsFromFile.js.map +1 -0
- package/dist/{source.js → source/push.js} +42 -127
- package/dist/source/push.js.map +1 -0
- package/dist/{source.spec.js → source/push.spec.js} +41 -27
- package/dist/source/push.spec.js.map +1 -0
- package/dist/source/securityIdenty.js +59 -0
- package/dist/source/securityIdenty.js.map +1 -0
- package/dist/source/source.js +9 -0
- package/dist/source/source.js.map +1 -0
- package/package.json +1 -1
- package/dist/docs/classes/Source.html +0 -45
- package/dist/docs/interfaces/BatchUpdateDocumentsFromFiles.html +0 -7
- package/dist/source.js.map +0 -1
- package/dist/source.spec.js.map +0 -1
@@ -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
|
13
|
-
region
|
12
|
+
environment?: PlatformEnvironment;
|
13
|
+
region?: Region;
|
14
14
|
};
|
15
|
-
export declare function platformUrl(options?:
|
15
|
+
export declare function platformUrl(options?: PlatformUrlOptions): string;
|
16
16
|
export declare function castEnvironmentToPlatformClient(e: PlatformEnvironment): Environment;
|
@@ -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
|
+
}
|
File without changes
|
@@ -1,6 +1,10 @@
|
|
1
1
|
export * from './document';
|
2
|
-
export { Source
|
2
|
+
export { Source } from './source/source';
|
3
|
+
export { PushSource } from './source/push';
|
4
|
+
export { SuccessfulUploadCallback, FailedUploadCallback, } from './help/fileConsumer';
|
5
|
+
export { UploadBatchCallbackData, BatchUpdateDocuments, BatchUpdateDocumentsFromFiles, } from './interfaces';
|
3
6
|
export { FieldAnalyser } from './fieldAnalyser/fieldAnalyser';
|
4
7
|
export { DocumentBuilder } from './documentBuilder';
|
5
8
|
export * from './securityIdentityBuilder';
|
6
|
-
export { PlatformEnvironment, Region } from './environment';
|
9
|
+
export { PlatformEnvironment, Region, PlatformUrlOptions } from './environment';
|
10
|
+
export { SourceVisibility } from '@coveord/platform-client';
|
@@ -0,0 +1,36 @@
|
|
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 fields required in the index based on the document batch metadata.
|
24
|
+
*/
|
25
|
+
createFields?: boolean;
|
26
|
+
}
|
27
|
+
export interface ConcurrentProcessing {
|
28
|
+
/**
|
29
|
+
* The maximum number of requests to send concurrently to the Coveo platform.
|
30
|
+
* Increasing this value will increase the speed at which documents are pushed but will also consume more memory.
|
31
|
+
*
|
32
|
+
* The default value is set to 10.
|
33
|
+
*/
|
34
|
+
maxConcurrent?: number;
|
35
|
+
}
|
36
|
+
export declare type BatchUpdateDocumentsFromFiles = BatchUpdateDocumentsOptions & ConcurrentProcessing;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { BatchUpdateDocumentsFromFiles, FailedUploadCallback, SuccessfulUploadCallback } from '../index';
|
2
|
+
import type { PushSource } from './push';
|
3
|
+
export declare class BatchUpdateDocumentsFromFilesReturn {
|
4
|
+
private internalPromise;
|
5
|
+
private batchConsumer;
|
6
|
+
constructor(pushSource: PushSource, sourceId: string, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles);
|
7
|
+
onBatchUpload(cb: SuccessfulUploadCallback): this;
|
8
|
+
onBatchError(cb: FailedUploadCallback): this;
|
9
|
+
batch(): Promise<void>;
|
10
|
+
}
|
@@ -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 {
|
4
|
-
import {
|
5
|
-
import {
|
3
|
+
import { DocumentBuilder } from '../documentBuilder';
|
4
|
+
import { PlatformUrlOptions } from '../environment';
|
5
|
+
import { FieldAnalyser } from '../fieldAnalyser/fieldAnalyser';
|
6
|
+
import { SecurityIdentity } from './securityIdenty';
|
7
|
+
import { BatchUpdateDocuments, BatchUpdateDocumentsOptions, BatchUpdateDocumentsFromFiles } from '../interfaces';
|
8
|
+
import { BatchUpdateDocumentsFromFilesReturn } from './batchUpdateDocumentsFromFile';
|
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
|
15
|
+
export declare class PushSource {
|
47
16
|
private apikey;
|
48
17
|
private organizationid;
|
49
|
-
|
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?:
|
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
|
-
*
|
70
|
-
*
|
71
|
-
* @
|
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
|
-
*
|
77
|
-
*
|
78
|
-
* @
|
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
|
-
*
|
84
|
-
*
|
85
|
-
* @
|
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
|
-
*
|
91
|
-
*
|
92
|
-
* @
|
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
|
-
*
|
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[],
|
90
|
+
batchUpdateDocumentsFromFiles(sourceID: string, filesOrDirectories: string[], options?: BatchUpdateDocumentsFromFiles): BatchUpdateDocumentsFromFilesReturn;
|
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,30 @@ 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>>;
|
112
|
+
setSourceStatus(sourceID: string, status: SourceStatus): Promise<import("axios").AxiosResponse<any, any>>;
|
113
|
+
uploadBatch(sourceID: string, batch: BatchUpdateDocuments): Promise<import("axios").AxiosResponse<any, any>>;
|
146
114
|
private get baseAPIURL();
|
147
115
|
private getBaseAPIURLForDocuments;
|
148
116
|
private get documentsAxiosConfig();
|
149
|
-
|
117
|
+
createFields(analyser: FieldAnalyser): Promise<void>;
|
150
118
|
private getFileContainerAxiosConfig;
|
151
119
|
private get documentsRequestHeaders();
|
152
120
|
private get authorizationHeader();
|
153
121
|
private createFileContainer;
|
154
122
|
private uploadContentToFileContainer;
|
155
123
|
private pushFileContainerContent;
|
156
|
-
private splitByChunkAndUpload;
|
157
|
-
private uploadBatch;
|
158
|
-
private get accumulator();
|
159
124
|
}
|
@@ -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
|
+
}
|