@coveo/push-api-client 3.0.122 → 3.0.123
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/APICore.js +47 -47
- package/dist/definitions/APICore.d.ts +18 -18
- package/dist/definitions/document.d.ts +124 -124
- package/dist/definitions/documentBuilder.d.ts +168 -168
- package/dist/definitions/documentBuilder.spec.d.ts +1 -1
- package/dist/definitions/environment.d.ts +16 -16
- package/dist/definitions/errors/baseError.d.ts +4 -4
- package/dist/definitions/errors/fieldErrors.d.ts +18 -18
- package/dist/definitions/errors/index.d.ts +3 -3
- package/dist/definitions/errors/privilegeError.d.ts +6 -6
- package/dist/definitions/errors/validatorErrors.d.ts +20 -20
- package/dist/definitions/fieldAnalyser/fieldAnalyser.d.ts +36 -36
- package/dist/definitions/fieldAnalyser/fieldAnalyser.spec.d.ts +1 -1
- package/dist/definitions/fieldAnalyser/fieldStore.d.ts +5 -5
- package/dist/definitions/fieldAnalyser/fieldUtils.d.ts +6 -6
- package/dist/definitions/fieldAnalyser/fieldsUtils.spec.d.ts +1 -1
- package/dist/definitions/fieldAnalyser/inconsistencies.d.ts +5 -5
- package/dist/definitions/fieldAnalyser/inconsistencies.spec.d.ts +1 -1
- package/dist/definitions/fieldAnalyser/typeUtils.d.ts +3 -3
- package/dist/definitions/fieldAnalyser/typeUtils.spec.d.ts +1 -1
- package/dist/definitions/help/file.d.ts +3 -3
- package/dist/definitions/help/file.spec.d.ts +1 -1
- package/dist/definitions/help/fileConsumer.d.ts +31 -31
- package/dist/definitions/help/fileConsumer.spec.d.ts +1 -1
- package/dist/definitions/help/fileContainer.d.ts +8 -8
- package/dist/definitions/help/fileContainer.spec.d.ts +1 -1
- package/dist/definitions/help/function.d.ts +1 -1
- package/dist/definitions/help/generator.d.ts +11 -11
- package/dist/definitions/help/generator.spec.d.ts +1 -1
- package/dist/definitions/help/urlUtils.d.ts +27 -27
- package/dist/definitions/help/urlUtils.spec.d.ts +1 -1
- package/dist/definitions/index.d.ts +14 -14
- package/dist/definitions/interfaces.d.ts +70 -70
- package/dist/definitions/localtest.d.ts +1 -1
- package/dist/definitions/permissionSetBuilder.d.ts +34 -34
- package/dist/definitions/permissionSetBuilder.spec.d.ts +1 -1
- package/dist/definitions/securityIdentityBuilder.d.ts +105 -105
- package/dist/definitions/securityIdentityBuilder.spec.d.ts +1 -1
- package/dist/definitions/source/batchUploadDocumentsFromFile.d.ts +11 -11
- package/dist/definitions/source/batchUploadDocumentsFromFile.spec.d.ts +1 -1
- package/dist/definitions/source/catalog.d.ts +70 -70
- package/dist/definitions/source/catalog.spec.d.ts +1 -1
- package/dist/definitions/source/documentUploader.d.ts +11 -11
- package/dist/definitions/source/documentUploader.spec.d.ts +1 -1
- package/dist/definitions/source/push.d.ts +87 -87
- package/dist/definitions/source/push.spec.d.ts +1 -1
- package/dist/definitions/source/securityIdenty.d.ts +43 -43
- package/dist/definitions/uploadStrategy/fileContainerStrategy.d.ts +23 -23
- package/dist/definitions/uploadStrategy/fileContainerStrategy.spec.d.ts +1 -1
- package/dist/definitions/uploadStrategy/index.d.ts +3 -3
- package/dist/definitions/uploadStrategy/strategy.d.ts +23 -23
- package/dist/definitions/uploadStrategy/streamChunkStrategy.d.ts +28 -28
- package/dist/definitions/uploadStrategy/streamChunkStrategy.spec.d.ts +1 -1
- package/dist/definitions/validation/caseInsensitiveDocument.d.ts +13 -13
- package/dist/definitions/validation/knownKey.d.ts +10 -10
- package/dist/definitions/validation/parseFile.d.ts +4 -4
- package/dist/definitions/validation/parseFile.spec.d.ts +1 -1
- package/dist/definitions/validation/parsePermissions.d.ts +5 -5
- package/dist/definitions/validation/parsePermissions.spec.d.ts +1 -1
- package/dist/definitions/validation/preconditions/apiKeyPrivilege.d.ts +3 -3
- package/dist/definitions/validation/preconditions/apiKeyPrivilege.spec.d.ts +1 -1
- package/dist/definitions/validation/preconditions/platformPrivilege.d.ts +7 -7
- package/dist/definitions/validation/requiredKeyValidator.d.ts +17 -17
- package/dist/definitions/validation/transformers/transformer.d.ts +31 -31
- package/dist/definitions/validation/transformers/transformer.spec.d.ts +1 -1
- package/dist/document.js +2 -2
- package/dist/documentBuilder.js +292 -292
- package/dist/documentBuilder.spec.js +191 -191
- package/dist/environment.js +41 -41
- package/dist/errors/baseError.js +10 -10
- package/dist/errors/fieldErrors.js +42 -42
- package/dist/errors/index.js +19 -19
- package/dist/errors/privilegeError.js +12 -12
- package/dist/errors/validatorErrors.js +40 -40
- package/dist/fieldAnalyser/fieldAnalyser.js +95 -95
- package/dist/fieldAnalyser/fieldAnalyser.spec.js +230 -230
- package/dist/fieldAnalyser/fieldStore.js +21 -21
- package/dist/fieldAnalyser/fieldUtils.js +41 -41
- package/dist/fieldAnalyser/fieldsUtils.spec.js +116 -116
- package/dist/fieldAnalyser/inconsistencies.js +14 -14
- package/dist/fieldAnalyser/inconsistencies.spec.js +40 -40
- package/dist/fieldAnalyser/typeUtils.js +61 -61
- package/dist/fieldAnalyser/typeUtils.spec.js +142 -142
- package/dist/help/file.js +37 -37
- package/dist/help/file.spec.js +67 -67
- package/dist/help/fileConsumer.js +150 -150
- package/dist/help/fileConsumer.spec.js +153 -153
- package/dist/help/fileContainer.js +48 -48
- package/dist/help/fileContainer.spec.js +65 -65
- package/dist/help/function.js +5 -5
- package/dist/help/generator.js +32 -32
- package/dist/help/generator.spec.js +82 -82
- package/dist/help/urlUtils.js +42 -42
- package/dist/help/urlUtils.spec.js +41 -41
- package/dist/index.js +38 -38
- package/dist/interfaces.js +2 -2
- package/dist/localtest.js +55 -55
- package/dist/permissionSetBuilder.js +58 -58
- package/dist/permissionSetBuilder.spec.js +68 -68
- package/dist/securityIdentityBuilder.js +128 -128
- package/dist/securityIdentityBuilder.spec.js +50 -50
- package/dist/source/batchUploadDocumentsFromFile.js +46 -46
- package/dist/source/batchUploadDocumentsFromFile.spec.js +145 -145
- package/dist/source/catalog.js +111 -111
- package/dist/source/catalog.spec.js +64 -64
- package/dist/source/documentUploader.js +45 -45
- package/dist/source/documentUploader.spec.js +118 -118
- package/dist/source/push.js +140 -140
- package/dist/source/push.spec.js +152 -152
- package/dist/source/securityIdenty.js +57 -57
- package/dist/uploadStrategy/fileContainerStrategy.js +32 -32
- package/dist/uploadStrategy/fileContainerStrategy.spec.js +86 -86
- package/dist/uploadStrategy/index.js +19 -19
- package/dist/uploadStrategy/strategy.js +2 -2
- package/dist/uploadStrategy/streamChunkStrategy.js +52 -52
- package/dist/uploadStrategy/streamChunkStrategy.spec.js +77 -77
- package/dist/validation/caseInsensitiveDocument.js +31 -31
- package/dist/validation/knownKey.js +37 -37
- package/dist/validation/parseFile.js +120 -120
- package/dist/validation/parseFile.spec.js +96 -96
- package/dist/validation/parsePermissions.js +118 -118
- package/dist/validation/parsePermissions.spec.js +86 -86
- package/dist/validation/preconditions/apiKeyPrivilege.js +20 -20
- package/dist/validation/preconditions/apiKeyPrivilege.spec.js +66 -66
- package/dist/validation/preconditions/platformPrivilege.js +32 -32
- package/dist/validation/requiredKeyValidator.js +61 -61
- package/dist/validation/transformers/transformer.js +51 -51
- package/dist/validation/transformers/transformer.spec.js +21 -21
- package/package.json +1 -1
package/dist/source/push.spec.js
CHANGED
@@ -1,153 +1,153 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
/* eslint-disable node/no-unpublished-import */
|
4
|
-
jest.mock('@coveo/platform-client');
|
5
|
-
jest.mock('./documentUploader');
|
6
|
-
jest.mock('../uploadStrategy');
|
7
|
-
jest.mock('../APICore');
|
8
|
-
const platform_client_1 = require("@coveo/platform-client");
|
9
|
-
const push_1 = require("./push");
|
10
|
-
const documentBuilder_1 = require("../documentBuilder");
|
11
|
-
const path_1 = require("path");
|
12
|
-
const process_1 = require("process");
|
13
|
-
const __1 = require("..");
|
14
|
-
const APICore_1 = require("../APICore");
|
15
|
-
const documentUploader_1 = require("./documentUploader");
|
16
|
-
const uploadStrategy_1 = require("../uploadStrategy");
|
17
|
-
const urlUtils_1 = require("../help/urlUtils");
|
18
|
-
const mockedAPICore = jest.mocked(APICore_1.APICore);
|
19
|
-
const mockedDelete = jest.fn();
|
20
|
-
const mockedPost = jest.fn();
|
21
|
-
const mockedPlatformClient = jest.mocked(platform_client_1.default);
|
22
|
-
const mockCreateSource = jest.fn();
|
23
|
-
const mockedUploadDocument = jest.mocked(documentUploader_1.uploadDocument);
|
24
|
-
const mockedUploadBatch = jest.mocked(documentUploader_1.uploadBatch);
|
25
|
-
const mockedUploadBatchFromFile = jest.mocked(documentUploader_1.uploadBatchFromFile);
|
26
|
-
const pathToStub = (0, path_1.join)((0, process_1.cwd)(), 'src', '__stub__');
|
27
|
-
const dummyClient = {
|
28
|
-
source: {
|
29
|
-
create: mockCreateSource,
|
30
|
-
},
|
31
|
-
};
|
32
|
-
const dummyAPICore = {
|
33
|
-
delete: mockedDelete,
|
34
|
-
post: mockedPost,
|
35
|
-
};
|
36
|
-
const doMockPlatformClient = () => {
|
37
|
-
mockedPlatformClient.mockImplementation(() => dummyClient);
|
38
|
-
};
|
39
|
-
const doMockAPICore = () => {
|
40
|
-
mockedAPICore.mockImplementation(() => dummyAPICore);
|
41
|
-
};
|
42
|
-
describe('PushSource', () => {
|
43
|
-
let defaultSource;
|
44
|
-
beforeAll(() => {
|
45
|
-
doMockAPICore();
|
46
|
-
doMockPlatformClient();
|
47
|
-
});
|
48
|
-
beforeEach(() => {
|
49
|
-
defaultSource = new push_1.PushSource('the_key', 'the_org');
|
50
|
-
});
|
51
|
-
it('should call platform client on creation', () => {
|
52
|
-
defaultSource.create('the_name', platform_client_1.SourceVisibility.SHARED);
|
53
|
-
expect(mockCreateSource).toHaveBeenCalledWith({
|
54
|
-
name: 'the_name',
|
55
|
-
pushEnabled: true,
|
56
|
-
sourceType: 'PUSH',
|
57
|
-
sourceVisibility: 'SHARED',
|
58
|
-
});
|
59
|
-
});
|
60
|
-
it.each([
|
61
|
-
{
|
62
|
-
title: 'default region/environment',
|
63
|
-
expectedUrl: 'https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
64
|
-
},
|
65
|
-
{
|
66
|
-
title: 'non default region',
|
67
|
-
options: {
|
68
|
-
region: __1.Region.AU,
|
69
|
-
},
|
70
|
-
expectedUrl: 'https://api-au.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
71
|
-
},
|
72
|
-
{
|
73
|
-
title: 'non default environment',
|
74
|
-
options: {
|
75
|
-
environment: __1.PlatformEnvironment.Dev,
|
76
|
-
},
|
77
|
-
expectedUrl: 'https://apidev.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
78
|
-
},
|
79
|
-
{
|
80
|
-
title: 'non default region/environment',
|
81
|
-
options: {
|
82
|
-
environment: __1.PlatformEnvironment.Stg,
|
83
|
-
region: __1.Region.EU,
|
84
|
-
},
|
85
|
-
expectedUrl: 'https://apistg-eu.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
86
|
-
},
|
87
|
-
])('should call #uploadDocument with $title', async ({ options, expectedUrl }) => {
|
88
|
-
await new push_1.PushSource('the_key', 'the_org', options).addOrUpdateDocument('the_id', new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'));
|
89
|
-
expect(mockedUploadDocument).toHaveBeenCalledWith(dummyClient, new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'), new URL(expectedUrl), dummyAPICore, undefined);
|
90
|
-
});
|
91
|
-
it('should call #uploadDocument with right BatchUpdateDocumentsOptions', async () => {
|
92
|
-
await defaultSource.addOrUpdateDocument('the_id', new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'), { createFields: true });
|
93
|
-
expect(mockedUploadDocument).toHaveBeenCalledWith(dummyClient, new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'), new URL('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents'), dummyAPICore, { createFields: true });
|
94
|
-
});
|
95
|
-
it('should call #APICore on delete', () => {
|
96
|
-
defaultSource.deleteDocument('the_id', 'the_uri', true);
|
97
|
-
expect(mockedDelete).toHaveBeenCalledWith('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents?documentId=the_uri&deleteChildren=true', false);
|
98
|
-
});
|
99
|
-
it('should call #APICore on status update', () => {
|
100
|
-
defaultSource.setSourceStatus('the_id', 'INCREMENTAL');
|
101
|
-
expect(mockedPost).toHaveBeenCalledWith('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/status?statusType=INCREMENTAL');
|
102
|
-
});
|
103
|
-
describe('calls #APICore when doing delete olderthan', () => {
|
104
|
-
const expectCorrectOrderingId = (id) => {
|
105
|
-
expect(mockedDelete).toHaveBeenCalledWith(`https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents/olderthan?orderingId=${id}`, false);
|
106
|
-
};
|
107
|
-
it('with a date', () => {
|
108
|
-
const now = new Date();
|
109
|
-
defaultSource.deleteDocumentsOlderThan('the_id', now);
|
110
|
-
expectCorrectOrderingId(now.valueOf());
|
111
|
-
});
|
112
|
-
it('with a date string', () => {
|
113
|
-
defaultSource.deleteDocumentsOlderThan('the_id', '2001/01/01');
|
114
|
-
expectCorrectOrderingId(new Date('2001/01/01').valueOf());
|
115
|
-
});
|
116
|
-
it('with a timestamp', () => {
|
117
|
-
const nowInTimestamp = new Date().valueOf();
|
118
|
-
defaultSource.deleteDocumentsOlderThan('the_id', nowInTimestamp);
|
119
|
-
expectCorrectOrderingId(nowInTimestamp);
|
120
|
-
});
|
121
|
-
});
|
122
|
-
it('should call #APICore on delete', () => {
|
123
|
-
defaultSource.deleteDocument('the_id', 'the_uri', true);
|
124
|
-
expect(mockedDelete).toHaveBeenCalledWith('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents?documentId=the_uri&deleteChildren=true', false);
|
125
|
-
});
|
126
|
-
describe('when doing batch update', () => {
|
127
|
-
const batch = {
|
128
|
-
addOrUpdate: [
|
129
|
-
new documentBuilder_1.DocumentBuilder('the_uri_1', 'the_title_1'),
|
130
|
-
new documentBuilder_1.DocumentBuilder('the_uri_2', 'the_title_2'),
|
131
|
-
],
|
132
|
-
delete: [{ documentId: 'the_uri_3', deleteChildren: true }],
|
133
|
-
};
|
134
|
-
it('should call #uploadBatch', async () => {
|
135
|
-
await defaultSource.batchUpdateDocuments('the_id', batch, {
|
136
|
-
createFields: false,
|
137
|
-
});
|
138
|
-
expect(mockedUploadBatch).toHaveBeenCalledWith(dummyClient, expect.any(uploadStrategy_1.FileContainerStrategy), batch, { createFields: false });
|
139
|
-
});
|
140
|
-
it('should call #uploadBatch with the right strategy', async () => {
|
141
|
-
await defaultSource.batchUpdateDocuments('the_id', batch);
|
142
|
-
expect(uploadStrategy_1.FileContainerStrategy).toHaveBeenCalledWith(expect.any(urlUtils_1.PushUrlBuilder), dummyAPICore);
|
143
|
-
});
|
144
|
-
});
|
145
|
-
describe('when doing batch update from local files', () => {
|
146
|
-
it('should call #uploadBatchFromFile', async () => {
|
147
|
-
await defaultSource.batchUpdateDocumentsFromFiles('the_id', [(0, path_1.join)(pathToStub, 'mixdocuments')], { createFields: false });
|
148
|
-
expect(uploadStrategy_1.FileContainerStrategy).toHaveBeenCalledWith(expect.any(urlUtils_1.PushUrlBuilder), dummyAPICore);
|
149
|
-
expect(mockedUploadBatchFromFile).toHaveBeenCalledWith(dummyClient, expect.any(uploadStrategy_1.FileContainerStrategy), [(0, path_1.join)(pathToStub, 'mixdocuments')], { createFields: false });
|
150
|
-
});
|
151
|
-
});
|
152
|
-
});
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/* eslint-disable node/no-unpublished-import */
|
4
|
+
jest.mock('@coveo/platform-client');
|
5
|
+
jest.mock('./documentUploader');
|
6
|
+
jest.mock('../uploadStrategy');
|
7
|
+
jest.mock('../APICore');
|
8
|
+
const platform_client_1 = require("@coveo/platform-client");
|
9
|
+
const push_1 = require("./push");
|
10
|
+
const documentBuilder_1 = require("../documentBuilder");
|
11
|
+
const path_1 = require("path");
|
12
|
+
const process_1 = require("process");
|
13
|
+
const __1 = require("..");
|
14
|
+
const APICore_1 = require("../APICore");
|
15
|
+
const documentUploader_1 = require("./documentUploader");
|
16
|
+
const uploadStrategy_1 = require("../uploadStrategy");
|
17
|
+
const urlUtils_1 = require("../help/urlUtils");
|
18
|
+
const mockedAPICore = jest.mocked(APICore_1.APICore);
|
19
|
+
const mockedDelete = jest.fn();
|
20
|
+
const mockedPost = jest.fn();
|
21
|
+
const mockedPlatformClient = jest.mocked(platform_client_1.default);
|
22
|
+
const mockCreateSource = jest.fn();
|
23
|
+
const mockedUploadDocument = jest.mocked(documentUploader_1.uploadDocument);
|
24
|
+
const mockedUploadBatch = jest.mocked(documentUploader_1.uploadBatch);
|
25
|
+
const mockedUploadBatchFromFile = jest.mocked(documentUploader_1.uploadBatchFromFile);
|
26
|
+
const pathToStub = (0, path_1.join)((0, process_1.cwd)(), 'src', '__stub__');
|
27
|
+
const dummyClient = {
|
28
|
+
source: {
|
29
|
+
create: mockCreateSource,
|
30
|
+
},
|
31
|
+
};
|
32
|
+
const dummyAPICore = {
|
33
|
+
delete: mockedDelete,
|
34
|
+
post: mockedPost,
|
35
|
+
};
|
36
|
+
const doMockPlatformClient = () => {
|
37
|
+
mockedPlatformClient.mockImplementation(() => dummyClient);
|
38
|
+
};
|
39
|
+
const doMockAPICore = () => {
|
40
|
+
mockedAPICore.mockImplementation(() => dummyAPICore);
|
41
|
+
};
|
42
|
+
describe('PushSource', () => {
|
43
|
+
let defaultSource;
|
44
|
+
beforeAll(() => {
|
45
|
+
doMockAPICore();
|
46
|
+
doMockPlatformClient();
|
47
|
+
});
|
48
|
+
beforeEach(() => {
|
49
|
+
defaultSource = new push_1.PushSource('the_key', 'the_org');
|
50
|
+
});
|
51
|
+
it('should call platform client on creation', () => {
|
52
|
+
defaultSource.create('the_name', platform_client_1.SourceVisibility.SHARED);
|
53
|
+
expect(mockCreateSource).toHaveBeenCalledWith({
|
54
|
+
name: 'the_name',
|
55
|
+
pushEnabled: true,
|
56
|
+
sourceType: 'PUSH',
|
57
|
+
sourceVisibility: 'SHARED',
|
58
|
+
});
|
59
|
+
});
|
60
|
+
it.each([
|
61
|
+
{
|
62
|
+
title: 'default region/environment',
|
63
|
+
expectedUrl: 'https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
64
|
+
},
|
65
|
+
{
|
66
|
+
title: 'non default region',
|
67
|
+
options: {
|
68
|
+
region: __1.Region.AU,
|
69
|
+
},
|
70
|
+
expectedUrl: 'https://api-au.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
71
|
+
},
|
72
|
+
{
|
73
|
+
title: 'non default environment',
|
74
|
+
options: {
|
75
|
+
environment: __1.PlatformEnvironment.Dev,
|
76
|
+
},
|
77
|
+
expectedUrl: 'https://apidev.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
78
|
+
},
|
79
|
+
{
|
80
|
+
title: 'non default region/environment',
|
81
|
+
options: {
|
82
|
+
environment: __1.PlatformEnvironment.Stg,
|
83
|
+
region: __1.Region.EU,
|
84
|
+
},
|
85
|
+
expectedUrl: 'https://apistg-eu.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents',
|
86
|
+
},
|
87
|
+
])('should call #uploadDocument with $title', async ({ options, expectedUrl }) => {
|
88
|
+
await new push_1.PushSource('the_key', 'the_org', options).addOrUpdateDocument('the_id', new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'));
|
89
|
+
expect(mockedUploadDocument).toHaveBeenCalledWith(dummyClient, new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'), new URL(expectedUrl), dummyAPICore, undefined);
|
90
|
+
});
|
91
|
+
it('should call #uploadDocument with right BatchUpdateDocumentsOptions', async () => {
|
92
|
+
await defaultSource.addOrUpdateDocument('the_id', new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'), { createFields: true });
|
93
|
+
expect(mockedUploadDocument).toHaveBeenCalledWith(dummyClient, new documentBuilder_1.DocumentBuilder('the_uri', 'the_title'), new URL('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents'), dummyAPICore, { createFields: true });
|
94
|
+
});
|
95
|
+
it('should call #APICore on delete', () => {
|
96
|
+
defaultSource.deleteDocument('the_id', 'the_uri', true);
|
97
|
+
expect(mockedDelete).toHaveBeenCalledWith('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents?documentId=the_uri&deleteChildren=true', false);
|
98
|
+
});
|
99
|
+
it('should call #APICore on status update', () => {
|
100
|
+
defaultSource.setSourceStatus('the_id', 'INCREMENTAL');
|
101
|
+
expect(mockedPost).toHaveBeenCalledWith('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/status?statusType=INCREMENTAL');
|
102
|
+
});
|
103
|
+
describe('calls #APICore when doing delete olderthan', () => {
|
104
|
+
const expectCorrectOrderingId = (id) => {
|
105
|
+
expect(mockedDelete).toHaveBeenCalledWith(`https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents/olderthan?orderingId=${id}`, false);
|
106
|
+
};
|
107
|
+
it('with a date', () => {
|
108
|
+
const now = new Date();
|
109
|
+
defaultSource.deleteDocumentsOlderThan('the_id', now);
|
110
|
+
expectCorrectOrderingId(now.valueOf());
|
111
|
+
});
|
112
|
+
it('with a date string', () => {
|
113
|
+
defaultSource.deleteDocumentsOlderThan('the_id', '2001/01/01');
|
114
|
+
expectCorrectOrderingId(new Date('2001/01/01').valueOf());
|
115
|
+
});
|
116
|
+
it('with a timestamp', () => {
|
117
|
+
const nowInTimestamp = new Date().valueOf();
|
118
|
+
defaultSource.deleteDocumentsOlderThan('the_id', nowInTimestamp);
|
119
|
+
expectCorrectOrderingId(nowInTimestamp);
|
120
|
+
});
|
121
|
+
});
|
122
|
+
it('should call #APICore on delete', () => {
|
123
|
+
defaultSource.deleteDocument('the_id', 'the_uri', true);
|
124
|
+
expect(mockedDelete).toHaveBeenCalledWith('https://api.cloud.coveo.com/push/v1/organizations/the_org/sources/the_id/documents?documentId=the_uri&deleteChildren=true', false);
|
125
|
+
});
|
126
|
+
describe('when doing batch update', () => {
|
127
|
+
const batch = {
|
128
|
+
addOrUpdate: [
|
129
|
+
new documentBuilder_1.DocumentBuilder('the_uri_1', 'the_title_1'),
|
130
|
+
new documentBuilder_1.DocumentBuilder('the_uri_2', 'the_title_2'),
|
131
|
+
],
|
132
|
+
delete: [{ documentId: 'the_uri_3', deleteChildren: true }],
|
133
|
+
};
|
134
|
+
it('should call #uploadBatch', async () => {
|
135
|
+
await defaultSource.batchUpdateDocuments('the_id', batch, {
|
136
|
+
createFields: false,
|
137
|
+
});
|
138
|
+
expect(mockedUploadBatch).toHaveBeenCalledWith(dummyClient, expect.any(uploadStrategy_1.FileContainerStrategy), batch, { createFields: false });
|
139
|
+
});
|
140
|
+
it('should call #uploadBatch with the right strategy', async () => {
|
141
|
+
await defaultSource.batchUpdateDocuments('the_id', batch);
|
142
|
+
expect(uploadStrategy_1.FileContainerStrategy).toHaveBeenCalledWith(expect.any(urlUtils_1.PushUrlBuilder), dummyAPICore);
|
143
|
+
});
|
144
|
+
});
|
145
|
+
describe('when doing batch update from local files', () => {
|
146
|
+
it('should call #uploadBatchFromFile', async () => {
|
147
|
+
await defaultSource.batchUpdateDocumentsFromFiles('the_id', [(0, path_1.join)(pathToStub, 'mixdocuments')], { createFields: false });
|
148
|
+
expect(uploadStrategy_1.FileContainerStrategy).toHaveBeenCalledWith(expect.any(urlUtils_1.PushUrlBuilder), dummyAPICore);
|
149
|
+
expect(mockedUploadBatchFromFile).toHaveBeenCalledWith(dummyClient, expect.any(uploadStrategy_1.FileContainerStrategy), [(0, path_1.join)(pathToStub, 'mixdocuments')], { createFields: false });
|
150
|
+
});
|
151
|
+
});
|
152
|
+
});
|
153
153
|
//# sourceMappingURL=push.spec.js.map
|
@@ -1,58 +1,58 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SecurityIdentity = void 0;
|
4
|
-
require("fetch-undici-polyfill");
|
5
|
-
class SecurityIdentity {
|
6
|
-
/**
|
7
|
-
*
|
8
|
-
* @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).
|
9
|
-
* @param organizationid The Coveo Organization identifier.
|
10
|
-
*/
|
11
|
-
constructor(platformClient) {
|
12
|
-
this.platformClient = platformClient;
|
13
|
-
}
|
14
|
-
/**
|
15
|
-
* 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).
|
16
|
-
* @param securityProviderId
|
17
|
-
* @param securityIdentity
|
18
|
-
* @returns
|
19
|
-
*/
|
20
|
-
createSecurityIdentity(securityProviderId, securityIdentity) {
|
21
|
-
return this.platformClient.pushApi.createOrUpdateSecurityIdentity(securityProviderId, securityIdentity);
|
22
|
-
}
|
23
|
-
/**
|
24
|
-
* 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).
|
25
|
-
* @param securityProviderId
|
26
|
-
* @param securityIdentityAlias
|
27
|
-
* @returns
|
28
|
-
*/
|
29
|
-
createOrUpdateSecurityIdentityAlias(securityProviderId, securityIdentityAlias) {
|
30
|
-
return this.platformClient.pushApi.createOrUpdateSecurityIdentityAlias(securityProviderId, securityIdentityAlias);
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* Delete a security identity. See [Disabling a Single Security Identity](https://docs.coveo.com/en/84).
|
34
|
-
* @param securityProviderId
|
35
|
-
* @param securityIdentityToDelete
|
36
|
-
* @returns
|
37
|
-
*/
|
38
|
-
deleteSecurityIdentity(securityProviderId, securityIdentityToDelete) {
|
39
|
-
return this.platformClient.pushApi.deleteSecurityIdentity(securityProviderId, securityIdentityToDelete);
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Delete old security identities. See [Disabling Old Security Identities](https://docs.coveo.com/en/33).
|
43
|
-
* @param securityProviderId
|
44
|
-
* @param batchDelete
|
45
|
-
* @returns
|
46
|
-
*/
|
47
|
-
deleteOldSecurityIdentities(securityProviderId, batchDelete) {
|
48
|
-
return this.platformClient.pushApi.deleteOldSecurityIdentities(securityProviderId, batchDelete);
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Manage batches of security identities. See [Manage Batches of Security Identities](https://docs.coveo.com/en/55).
|
52
|
-
*/
|
53
|
-
manageSecurityIdentities(securityProviderId, batchConfig) {
|
54
|
-
return this.platformClient.pushApi.manageSecurityIdentities(securityProviderId, batchConfig);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
exports.SecurityIdentity = SecurityIdentity;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SecurityIdentity = void 0;
|
4
|
+
require("fetch-undici-polyfill");
|
5
|
+
class SecurityIdentity {
|
6
|
+
/**
|
7
|
+
*
|
8
|
+
* @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).
|
9
|
+
* @param organizationid The Coveo Organization identifier.
|
10
|
+
*/
|
11
|
+
constructor(platformClient) {
|
12
|
+
this.platformClient = platformClient;
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* 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).
|
16
|
+
* @param securityProviderId
|
17
|
+
* @param securityIdentity
|
18
|
+
* @returns
|
19
|
+
*/
|
20
|
+
createSecurityIdentity(securityProviderId, securityIdentity) {
|
21
|
+
return this.platformClient.pushApi.createOrUpdateSecurityIdentity(securityProviderId, securityIdentity);
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* 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).
|
25
|
+
* @param securityProviderId
|
26
|
+
* @param securityIdentityAlias
|
27
|
+
* @returns
|
28
|
+
*/
|
29
|
+
createOrUpdateSecurityIdentityAlias(securityProviderId, securityIdentityAlias) {
|
30
|
+
return this.platformClient.pushApi.createOrUpdateSecurityIdentityAlias(securityProviderId, securityIdentityAlias);
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Delete a security identity. See [Disabling a Single Security Identity](https://docs.coveo.com/en/84).
|
34
|
+
* @param securityProviderId
|
35
|
+
* @param securityIdentityToDelete
|
36
|
+
* @returns
|
37
|
+
*/
|
38
|
+
deleteSecurityIdentity(securityProviderId, securityIdentityToDelete) {
|
39
|
+
return this.platformClient.pushApi.deleteSecurityIdentity(securityProviderId, securityIdentityToDelete);
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* Delete old security identities. See [Disabling Old Security Identities](https://docs.coveo.com/en/33).
|
43
|
+
* @param securityProviderId
|
44
|
+
* @param batchDelete
|
45
|
+
* @returns
|
46
|
+
*/
|
47
|
+
deleteOldSecurityIdentities(securityProviderId, batchDelete) {
|
48
|
+
return this.platformClient.pushApi.deleteOldSecurityIdentities(securityProviderId, batchDelete);
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Manage batches of security identities. See [Manage Batches of Security Identities](https://docs.coveo.com/en/55).
|
52
|
+
*/
|
53
|
+
manageSecurityIdentities(securityProviderId, batchConfig) {
|
54
|
+
return this.platformClient.pushApi.manageSecurityIdentities(securityProviderId, batchConfig);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
exports.SecurityIdentity = SecurityIdentity;
|
58
58
|
//# sourceMappingURL=securityIdenty.js.map
|
@@ -1,33 +1,33 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.FileContainerStrategy = void 0;
|
4
|
-
const fileContainer_1 = require("../help/fileContainer");
|
5
|
-
/**
|
6
|
-
* Upload documents using the [File container](https://docs.coveo.com/en/43/index-content/creating-a-file-container)
|
7
|
-
*
|
8
|
-
* @class FileContainerStrategy
|
9
|
-
* @implements {UploadStrategy}
|
10
|
-
*/
|
11
|
-
class FileContainerStrategy {
|
12
|
-
constructor(urlBuilder, api) {
|
13
|
-
this.urlBuilder = urlBuilder;
|
14
|
-
this.api = api;
|
15
|
-
}
|
16
|
-
async upload(batch) {
|
17
|
-
const fileContainer = await this.createFileContainer();
|
18
|
-
await (0, fileContainer_1.uploadContentToFileContainer)(fileContainer, batch);
|
19
|
-
return this.pushFileContainerContent(fileContainer);
|
20
|
-
}
|
21
|
-
async createFileContainer() {
|
22
|
-
const fileContainerURL = this.urlBuilder.fileContainerUrl.toString();
|
23
|
-
const res = await this.api.post(fileContainerURL);
|
24
|
-
return res;
|
25
|
-
}
|
26
|
-
pushFileContainerContent(fileContainer) {
|
27
|
-
const pushURL = this.urlBuilder.baseAPIURLForUpdate;
|
28
|
-
pushURL.searchParams.append('fileId', fileContainer.fileId);
|
29
|
-
return this.api.put(pushURL.toString(), undefined, false);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
exports.FileContainerStrategy = FileContainerStrategy;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FileContainerStrategy = void 0;
|
4
|
+
const fileContainer_1 = require("../help/fileContainer");
|
5
|
+
/**
|
6
|
+
* Upload documents using the [File container](https://docs.coveo.com/en/43/index-content/creating-a-file-container)
|
7
|
+
*
|
8
|
+
* @class FileContainerStrategy
|
9
|
+
* @implements {UploadStrategy}
|
10
|
+
*/
|
11
|
+
class FileContainerStrategy {
|
12
|
+
constructor(urlBuilder, api) {
|
13
|
+
this.urlBuilder = urlBuilder;
|
14
|
+
this.api = api;
|
15
|
+
}
|
16
|
+
async upload(batch) {
|
17
|
+
const fileContainer = await this.createFileContainer();
|
18
|
+
await (0, fileContainer_1.uploadContentToFileContainer)(fileContainer, batch);
|
19
|
+
return this.pushFileContainerContent(fileContainer);
|
20
|
+
}
|
21
|
+
async createFileContainer() {
|
22
|
+
const fileContainerURL = this.urlBuilder.fileContainerUrl.toString();
|
23
|
+
const res = await this.api.post(fileContainerURL);
|
24
|
+
return res;
|
25
|
+
}
|
26
|
+
pushFileContainerContent(fileContainer) {
|
27
|
+
const pushURL = this.urlBuilder.baseAPIURLForUpdate;
|
28
|
+
pushURL.searchParams.append('fileId', fileContainer.fileId);
|
29
|
+
return this.api.put(pushURL.toString(), undefined, false);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
exports.FileContainerStrategy = FileContainerStrategy;
|
33
33
|
//# sourceMappingURL=fileContainerStrategy.js.map
|