@coveo/push-api-client 3.0.122 → 3.0.124

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 (129) hide show
  1. package/dist/APICore.js +47 -47
  2. package/dist/definitions/APICore.d.ts +18 -18
  3. package/dist/definitions/document.d.ts +124 -124
  4. package/dist/definitions/documentBuilder.d.ts +168 -168
  5. package/dist/definitions/documentBuilder.spec.d.ts +1 -1
  6. package/dist/definitions/environment.d.ts +16 -16
  7. package/dist/definitions/errors/baseError.d.ts +4 -4
  8. package/dist/definitions/errors/fieldErrors.d.ts +18 -18
  9. package/dist/definitions/errors/index.d.ts +3 -3
  10. package/dist/definitions/errors/privilegeError.d.ts +6 -6
  11. package/dist/definitions/errors/validatorErrors.d.ts +20 -20
  12. package/dist/definitions/fieldAnalyser/fieldAnalyser.d.ts +36 -36
  13. package/dist/definitions/fieldAnalyser/fieldAnalyser.spec.d.ts +1 -1
  14. package/dist/definitions/fieldAnalyser/fieldStore.d.ts +5 -5
  15. package/dist/definitions/fieldAnalyser/fieldUtils.d.ts +6 -6
  16. package/dist/definitions/fieldAnalyser/fieldsUtils.spec.d.ts +1 -1
  17. package/dist/definitions/fieldAnalyser/inconsistencies.d.ts +5 -5
  18. package/dist/definitions/fieldAnalyser/inconsistencies.spec.d.ts +1 -1
  19. package/dist/definitions/fieldAnalyser/typeUtils.d.ts +3 -3
  20. package/dist/definitions/fieldAnalyser/typeUtils.spec.d.ts +1 -1
  21. package/dist/definitions/help/file.d.ts +3 -3
  22. package/dist/definitions/help/file.spec.d.ts +1 -1
  23. package/dist/definitions/help/fileConsumer.d.ts +31 -31
  24. package/dist/definitions/help/fileConsumer.spec.d.ts +1 -1
  25. package/dist/definitions/help/fileContainer.d.ts +8 -8
  26. package/dist/definitions/help/fileContainer.spec.d.ts +1 -1
  27. package/dist/definitions/help/function.d.ts +1 -1
  28. package/dist/definitions/help/generator.d.ts +11 -11
  29. package/dist/definitions/help/generator.spec.d.ts +1 -1
  30. package/dist/definitions/help/urlUtils.d.ts +27 -27
  31. package/dist/definitions/help/urlUtils.spec.d.ts +1 -1
  32. package/dist/definitions/index.d.ts +14 -14
  33. package/dist/definitions/interfaces.d.ts +70 -70
  34. package/dist/definitions/localtest.d.ts +1 -1
  35. package/dist/definitions/permissionSetBuilder.d.ts +34 -34
  36. package/dist/definitions/permissionSetBuilder.spec.d.ts +1 -1
  37. package/dist/definitions/securityIdentityBuilder.d.ts +105 -105
  38. package/dist/definitions/securityIdentityBuilder.spec.d.ts +1 -1
  39. package/dist/definitions/source/batchUploadDocumentsFromFile.d.ts +11 -11
  40. package/dist/definitions/source/batchUploadDocumentsFromFile.spec.d.ts +1 -1
  41. package/dist/definitions/source/catalog.d.ts +70 -70
  42. package/dist/definitions/source/catalog.spec.d.ts +1 -1
  43. package/dist/definitions/source/documentUploader.d.ts +11 -11
  44. package/dist/definitions/source/documentUploader.spec.d.ts +1 -1
  45. package/dist/definitions/source/push.d.ts +87 -87
  46. package/dist/definitions/source/push.spec.d.ts +1 -1
  47. package/dist/definitions/source/securityIdenty.d.ts +43 -43
  48. package/dist/definitions/uploadStrategy/fileContainerStrategy.d.ts +23 -23
  49. package/dist/definitions/uploadStrategy/fileContainerStrategy.spec.d.ts +1 -1
  50. package/dist/definitions/uploadStrategy/index.d.ts +3 -3
  51. package/dist/definitions/uploadStrategy/strategy.d.ts +23 -23
  52. package/dist/definitions/uploadStrategy/streamChunkStrategy.d.ts +28 -28
  53. package/dist/definitions/uploadStrategy/streamChunkStrategy.spec.d.ts +1 -1
  54. package/dist/definitions/validation/caseInsensitiveDocument.d.ts +13 -13
  55. package/dist/definitions/validation/knownKey.d.ts +10 -10
  56. package/dist/definitions/validation/parseFile.d.ts +4 -4
  57. package/dist/definitions/validation/parseFile.spec.d.ts +1 -1
  58. package/dist/definitions/validation/parsePermissions.d.ts +5 -5
  59. package/dist/definitions/validation/parsePermissions.spec.d.ts +1 -1
  60. package/dist/definitions/validation/preconditions/apiKeyPrivilege.d.ts +3 -3
  61. package/dist/definitions/validation/preconditions/apiKeyPrivilege.spec.d.ts +1 -1
  62. package/dist/definitions/validation/preconditions/platformPrivilege.d.ts +7 -7
  63. package/dist/definitions/validation/requiredKeyValidator.d.ts +17 -17
  64. package/dist/definitions/validation/transformers/transformer.d.ts +31 -31
  65. package/dist/definitions/validation/transformers/transformer.spec.d.ts +1 -1
  66. package/dist/document.js +2 -2
  67. package/dist/documentBuilder.js +292 -292
  68. package/dist/documentBuilder.spec.js +191 -191
  69. package/dist/environment.js +41 -41
  70. package/dist/errors/baseError.js +10 -10
  71. package/dist/errors/fieldErrors.js +42 -42
  72. package/dist/errors/index.js +19 -19
  73. package/dist/errors/privilegeError.js +12 -12
  74. package/dist/errors/validatorErrors.js +40 -40
  75. package/dist/fieldAnalyser/fieldAnalyser.js +95 -95
  76. package/dist/fieldAnalyser/fieldAnalyser.spec.js +230 -230
  77. package/dist/fieldAnalyser/fieldStore.js +21 -21
  78. package/dist/fieldAnalyser/fieldUtils.js +41 -41
  79. package/dist/fieldAnalyser/fieldsUtils.spec.js +116 -116
  80. package/dist/fieldAnalyser/inconsistencies.js +14 -14
  81. package/dist/fieldAnalyser/inconsistencies.spec.js +40 -40
  82. package/dist/fieldAnalyser/typeUtils.js +61 -61
  83. package/dist/fieldAnalyser/typeUtils.spec.js +142 -142
  84. package/dist/help/file.js +37 -37
  85. package/dist/help/file.spec.js +67 -67
  86. package/dist/help/fileConsumer.js +150 -150
  87. package/dist/help/fileConsumer.spec.js +153 -153
  88. package/dist/help/fileContainer.js +48 -48
  89. package/dist/help/fileContainer.spec.js +65 -65
  90. package/dist/help/function.js +5 -5
  91. package/dist/help/generator.js +32 -32
  92. package/dist/help/generator.spec.js +82 -82
  93. package/dist/help/urlUtils.js +42 -42
  94. package/dist/help/urlUtils.spec.js +41 -41
  95. package/dist/index.js +38 -38
  96. package/dist/interfaces.js +2 -2
  97. package/dist/localtest.js +55 -55
  98. package/dist/permissionSetBuilder.js +58 -58
  99. package/dist/permissionSetBuilder.spec.js +68 -68
  100. package/dist/securityIdentityBuilder.js +128 -128
  101. package/dist/securityIdentityBuilder.spec.js +50 -50
  102. package/dist/source/batchUploadDocumentsFromFile.js +46 -46
  103. package/dist/source/batchUploadDocumentsFromFile.spec.js +145 -145
  104. package/dist/source/catalog.js +111 -111
  105. package/dist/source/catalog.spec.js +64 -64
  106. package/dist/source/documentUploader.js +45 -45
  107. package/dist/source/documentUploader.spec.js +118 -118
  108. package/dist/source/push.js +140 -140
  109. package/dist/source/push.spec.js +152 -152
  110. package/dist/source/securityIdenty.js +57 -57
  111. package/dist/uploadStrategy/fileContainerStrategy.js +32 -32
  112. package/dist/uploadStrategy/fileContainerStrategy.spec.js +86 -86
  113. package/dist/uploadStrategy/index.js +19 -19
  114. package/dist/uploadStrategy/strategy.js +2 -2
  115. package/dist/uploadStrategy/streamChunkStrategy.js +52 -52
  116. package/dist/uploadStrategy/streamChunkStrategy.spec.js +77 -77
  117. package/dist/validation/caseInsensitiveDocument.js +31 -31
  118. package/dist/validation/knownKey.js +37 -37
  119. package/dist/validation/parseFile.js +120 -120
  120. package/dist/validation/parseFile.spec.js +96 -96
  121. package/dist/validation/parsePermissions.js +118 -118
  122. package/dist/validation/parsePermissions.spec.js +86 -86
  123. package/dist/validation/preconditions/apiKeyPrivilege.js +20 -20
  124. package/dist/validation/preconditions/apiKeyPrivilege.spec.js +66 -66
  125. package/dist/validation/preconditions/platformPrivilege.js +32 -32
  126. package/dist/validation/requiredKeyValidator.js +61 -61
  127. package/dist/validation/transformers/transformer.js +51 -51
  128. package/dist/validation/transformers/transformer.spec.js +21 -21
  129. package/package.json +4 -4
@@ -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