@coveo/push-api-client 3.0.116 → 3.0.122

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 (130) hide show
  1. package/dist/APICore.js +47 -47
  2. package/dist/APICore.js.map +1 -1
  3. package/dist/definitions/APICore.d.ts +18 -18
  4. package/dist/definitions/document.d.ts +124 -124
  5. package/dist/definitions/documentBuilder.d.ts +168 -168
  6. package/dist/definitions/documentBuilder.spec.d.ts +1 -1
  7. package/dist/definitions/environment.d.ts +16 -16
  8. package/dist/definitions/errors/baseError.d.ts +4 -4
  9. package/dist/definitions/errors/fieldErrors.d.ts +18 -18
  10. package/dist/definitions/errors/index.d.ts +3 -3
  11. package/dist/definitions/errors/privilegeError.d.ts +6 -6
  12. package/dist/definitions/errors/validatorErrors.d.ts +20 -20
  13. package/dist/definitions/fieldAnalyser/fieldAnalyser.d.ts +36 -36
  14. package/dist/definitions/fieldAnalyser/fieldAnalyser.spec.d.ts +1 -1
  15. package/dist/definitions/fieldAnalyser/fieldStore.d.ts +5 -5
  16. package/dist/definitions/fieldAnalyser/fieldUtils.d.ts +6 -6
  17. package/dist/definitions/fieldAnalyser/fieldsUtils.spec.d.ts +1 -1
  18. package/dist/definitions/fieldAnalyser/inconsistencies.d.ts +5 -5
  19. package/dist/definitions/fieldAnalyser/inconsistencies.spec.d.ts +1 -1
  20. package/dist/definitions/fieldAnalyser/typeUtils.d.ts +3 -3
  21. package/dist/definitions/fieldAnalyser/typeUtils.spec.d.ts +1 -1
  22. package/dist/definitions/help/file.d.ts +3 -3
  23. package/dist/definitions/help/file.spec.d.ts +1 -1
  24. package/dist/definitions/help/fileConsumer.d.ts +31 -31
  25. package/dist/definitions/help/fileConsumer.spec.d.ts +1 -1
  26. package/dist/definitions/help/fileContainer.d.ts +8 -8
  27. package/dist/definitions/help/fileContainer.spec.d.ts +1 -1
  28. package/dist/definitions/help/function.d.ts +1 -1
  29. package/dist/definitions/help/generator.d.ts +11 -11
  30. package/dist/definitions/help/generator.spec.d.ts +1 -1
  31. package/dist/definitions/help/urlUtils.d.ts +27 -27
  32. package/dist/definitions/help/urlUtils.spec.d.ts +1 -1
  33. package/dist/definitions/index.d.ts +14 -14
  34. package/dist/definitions/interfaces.d.ts +70 -70
  35. package/dist/definitions/localtest.d.ts +1 -1
  36. package/dist/definitions/permissionSetBuilder.d.ts +34 -34
  37. package/dist/definitions/permissionSetBuilder.spec.d.ts +1 -1
  38. package/dist/definitions/securityIdentityBuilder.d.ts +105 -105
  39. package/dist/definitions/securityIdentityBuilder.spec.d.ts +1 -1
  40. package/dist/definitions/source/batchUploadDocumentsFromFile.d.ts +11 -11
  41. package/dist/definitions/source/batchUploadDocumentsFromFile.spec.d.ts +1 -1
  42. package/dist/definitions/source/catalog.d.ts +70 -70
  43. package/dist/definitions/source/catalog.spec.d.ts +1 -1
  44. package/dist/definitions/source/documentUploader.d.ts +11 -11
  45. package/dist/definitions/source/documentUploader.spec.d.ts +1 -1
  46. package/dist/definitions/source/push.d.ts +87 -87
  47. package/dist/definitions/source/push.spec.d.ts +1 -1
  48. package/dist/definitions/source/securityIdenty.d.ts +43 -43
  49. package/dist/definitions/uploadStrategy/fileContainerStrategy.d.ts +23 -23
  50. package/dist/definitions/uploadStrategy/fileContainerStrategy.spec.d.ts +1 -1
  51. package/dist/definitions/uploadStrategy/index.d.ts +3 -3
  52. package/dist/definitions/uploadStrategy/strategy.d.ts +23 -23
  53. package/dist/definitions/uploadStrategy/streamChunkStrategy.d.ts +28 -28
  54. package/dist/definitions/uploadStrategy/streamChunkStrategy.spec.d.ts +1 -1
  55. package/dist/definitions/validation/caseInsensitiveDocument.d.ts +13 -13
  56. package/dist/definitions/validation/knownKey.d.ts +10 -10
  57. package/dist/definitions/validation/parseFile.d.ts +4 -4
  58. package/dist/definitions/validation/parseFile.spec.d.ts +1 -1
  59. package/dist/definitions/validation/parsePermissions.d.ts +5 -5
  60. package/dist/definitions/validation/parsePermissions.spec.d.ts +1 -1
  61. package/dist/definitions/validation/preconditions/apiKeyPrivilege.d.ts +3 -3
  62. package/dist/definitions/validation/preconditions/apiKeyPrivilege.spec.d.ts +1 -1
  63. package/dist/definitions/validation/preconditions/platformPrivilege.d.ts +7 -7
  64. package/dist/definitions/validation/requiredKeyValidator.d.ts +17 -17
  65. package/dist/definitions/validation/transformers/transformer.d.ts +31 -31
  66. package/dist/definitions/validation/transformers/transformer.spec.d.ts +1 -1
  67. package/dist/document.js +2 -2
  68. package/dist/documentBuilder.js +292 -292
  69. package/dist/documentBuilder.spec.js +191 -191
  70. package/dist/environment.js +41 -41
  71. package/dist/errors/baseError.js +10 -10
  72. package/dist/errors/fieldErrors.js +42 -42
  73. package/dist/errors/index.js +19 -19
  74. package/dist/errors/privilegeError.js +12 -12
  75. package/dist/errors/validatorErrors.js +40 -40
  76. package/dist/fieldAnalyser/fieldAnalyser.js +95 -95
  77. package/dist/fieldAnalyser/fieldAnalyser.spec.js +230 -230
  78. package/dist/fieldAnalyser/fieldStore.js +21 -21
  79. package/dist/fieldAnalyser/fieldUtils.js +41 -41
  80. package/dist/fieldAnalyser/fieldsUtils.spec.js +116 -116
  81. package/dist/fieldAnalyser/inconsistencies.js +14 -14
  82. package/dist/fieldAnalyser/inconsistencies.spec.js +40 -40
  83. package/dist/fieldAnalyser/typeUtils.js +61 -61
  84. package/dist/fieldAnalyser/typeUtils.spec.js +142 -142
  85. package/dist/help/file.js +37 -37
  86. package/dist/help/file.spec.js +67 -67
  87. package/dist/help/fileConsumer.js +150 -150
  88. package/dist/help/fileConsumer.spec.js +153 -153
  89. package/dist/help/fileContainer.js +48 -48
  90. package/dist/help/fileContainer.spec.js +65 -65
  91. package/dist/help/function.js +5 -5
  92. package/dist/help/generator.js +32 -32
  93. package/dist/help/generator.spec.js +82 -82
  94. package/dist/help/urlUtils.js +42 -42
  95. package/dist/help/urlUtils.spec.js +41 -41
  96. package/dist/index.js +38 -38
  97. package/dist/interfaces.js +2 -2
  98. package/dist/localtest.js +55 -55
  99. package/dist/permissionSetBuilder.js +58 -58
  100. package/dist/permissionSetBuilder.spec.js +68 -68
  101. package/dist/securityIdentityBuilder.js +128 -128
  102. package/dist/securityIdentityBuilder.spec.js +50 -50
  103. package/dist/source/batchUploadDocumentsFromFile.js +46 -46
  104. package/dist/source/batchUploadDocumentsFromFile.spec.js +145 -145
  105. package/dist/source/catalog.js +111 -111
  106. package/dist/source/catalog.spec.js +64 -64
  107. package/dist/source/documentUploader.js +45 -45
  108. package/dist/source/documentUploader.spec.js +118 -118
  109. package/dist/source/push.js +140 -140
  110. package/dist/source/push.spec.js +152 -152
  111. package/dist/source/securityIdenty.js +57 -57
  112. package/dist/uploadStrategy/fileContainerStrategy.js +32 -32
  113. package/dist/uploadStrategy/fileContainerStrategy.spec.js +86 -86
  114. package/dist/uploadStrategy/index.js +19 -19
  115. package/dist/uploadStrategy/strategy.js +2 -2
  116. package/dist/uploadStrategy/streamChunkStrategy.js +52 -52
  117. package/dist/uploadStrategy/streamChunkStrategy.spec.js +77 -77
  118. package/dist/validation/caseInsensitiveDocument.js +31 -31
  119. package/dist/validation/knownKey.js +37 -37
  120. package/dist/validation/parseFile.js +120 -120
  121. package/dist/validation/parseFile.spec.js +96 -96
  122. package/dist/validation/parsePermissions.js +118 -118
  123. package/dist/validation/parsePermissions.spec.js +86 -86
  124. package/dist/validation/preconditions/apiKeyPrivilege.js +20 -20
  125. package/dist/validation/preconditions/apiKeyPrivilege.spec.js +66 -66
  126. package/dist/validation/preconditions/platformPrivilege.js +32 -32
  127. package/dist/validation/requiredKeyValidator.js +61 -61
  128. package/dist/validation/transformers/transformer.js +51 -51
  129. package/dist/validation/transformers/transformer.spec.js +21 -21
  130. package/package.json +11 -11
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrivilegeError = void 0;
4
- const baseError_1 = require("./baseError");
5
- class PrivilegeError extends baseError_1.PushApiClientBaseError {
6
- constructor(message) {
7
- super(message);
8
- this.message = message;
9
- this.name = 'Privilege Error';
10
- }
11
- }
12
- exports.PrivilegeError = PrivilegeError;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrivilegeError = void 0;
4
+ const baseError_1 = require("./baseError");
5
+ class PrivilegeError extends baseError_1.PushApiClientBaseError {
6
+ constructor(message) {
7
+ super(message);
8
+ this.message = message;
9
+ this.name = 'Privilege Error';
10
+ }
11
+ }
12
+ exports.PrivilegeError = PrivilegeError;
13
13
  //# sourceMappingURL=privilegeError.js.map
@@ -1,41 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnsupportedAttribute = exports.InvalidDocument = exports.NotAJsonFileError = exports.NotAFileError = void 0;
4
- const baseError_1 = require("./baseError");
5
- class NotAFileError extends baseError_1.PushApiClientBaseError {
6
- constructor(p) {
7
- super(`${p} is not a valid file, or does not exists.`);
8
- this.name = 'Not A File Error';
9
- }
10
- }
11
- exports.NotAFileError = NotAFileError;
12
- class NotAJsonFileError extends baseError_1.PushApiClientBaseError {
13
- constructor(p) {
14
- super(`${p} is not a valid JSON file.`);
15
- this.name = 'Not A JSON File Error';
16
- }
17
- }
18
- exports.NotAJsonFileError = NotAJsonFileError;
19
- class InvalidDocument extends baseError_1.PushApiClientBaseError {
20
- constructor(p, doc, explanation) {
21
- super([
22
- `${p} is not a valid JSON: ${explanation}`,
23
- 'Document in error:',
24
- JSON.stringify(doc, null, 2),
25
- '',
26
- 'Helpful links on the expected JSON format:',
27
- ' • JSON file example: https://github.com/coveo/push-api-client.js/tree/main/samples/json',
28
- ' • Document Body reference: https://docs.coveo.com/en/75#documentbody',
29
- ].join('\n'));
30
- this.name = 'Invalid JSON Document Error';
31
- }
32
- }
33
- exports.InvalidDocument = InvalidDocument;
34
- class UnsupportedAttribute extends baseError_1.PushApiClientBaseError {
35
- constructor(p, unsupported) {
36
- super(`${p} contains a currently unsupported document attribute: ${unsupported}`);
37
- this.name = 'Unsupported Attribute Error';
38
- }
39
- }
40
- exports.UnsupportedAttribute = UnsupportedAttribute;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedAttribute = exports.InvalidDocument = exports.NotAJsonFileError = exports.NotAFileError = void 0;
4
+ const baseError_1 = require("./baseError");
5
+ class NotAFileError extends baseError_1.PushApiClientBaseError {
6
+ constructor(p) {
7
+ super(`${p} is not a valid file, or does not exists.`);
8
+ this.name = 'Not A File Error';
9
+ }
10
+ }
11
+ exports.NotAFileError = NotAFileError;
12
+ class NotAJsonFileError extends baseError_1.PushApiClientBaseError {
13
+ constructor(p) {
14
+ super(`${p} is not a valid JSON file.`);
15
+ this.name = 'Not A JSON File Error';
16
+ }
17
+ }
18
+ exports.NotAJsonFileError = NotAJsonFileError;
19
+ class InvalidDocument extends baseError_1.PushApiClientBaseError {
20
+ constructor(p, doc, explanation) {
21
+ super([
22
+ `${p} is not a valid JSON: ${explanation}`,
23
+ 'Document in error:',
24
+ JSON.stringify(doc, null, 2),
25
+ '',
26
+ 'Helpful links on the expected JSON format:',
27
+ ' • JSON file example: https://github.com/coveo/push-api-client.js/tree/main/samples/json',
28
+ ' • Document Body reference: https://docs.coveo.com/en/75#documentbody',
29
+ ].join('\n'));
30
+ this.name = 'Invalid JSON Document Error';
31
+ }
32
+ }
33
+ exports.InvalidDocument = InvalidDocument;
34
+ class UnsupportedAttribute extends baseError_1.PushApiClientBaseError {
35
+ constructor(p, unsupported) {
36
+ super(`${p} contains a currently unsupported document attribute: ${unsupported}`);
37
+ this.name = 'Unsupported Attribute Error';
38
+ }
39
+ }
40
+ exports.UnsupportedAttribute = UnsupportedAttribute;
41
41
  //# sourceMappingURL=validatorErrors.js.map
@@ -1,96 +1,96 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FieldAnalyser = void 0;
4
- const platform_client_1 = require("@coveo/platform-client");
5
- const fieldUtils_1 = require("./fieldUtils");
6
- const fieldStore_1 = require("./fieldStore");
7
- const inconsistencies_1 = require("./inconsistencies");
8
- const fieldErrors_1 = require("../errors/fieldErrors");
9
- const typeUtils_1 = require("./typeUtils");
10
- /**
11
- * Analyse documents to detect type inconsistencies and missing fields in your index.
12
- *
13
- */
14
- class FieldAnalyser {
15
- constructor(platformClient) {
16
- this.platformClient = platformClient;
17
- this.inconsistencies = new inconsistencies_1.Inconsistencies();
18
- this.missingFields = new fieldStore_1.FieldStore();
19
- }
20
- /**
21
- * Adds a batch of document builders to the analyser to extract all the missing fields that need to be created in the organization.
22
- * This method can be called as many time as needed as it will take into consideration document builders previously added.
23
- *
24
- * @param {DocumentBuilder[]} batch
25
- * @return {*}
26
- */
27
- async add(batch) {
28
- const existingFields = await this.ensureExistingFields();
29
- batch.flatMap((doc) => {
30
- const documentMetadata = Object.entries(Object.assign({}, doc.build().metadata));
31
- for (const [metadataKey, metadataValue] of documentMetadata) {
32
- if (existingFields.some((field) => field.name === metadataKey)) {
33
- continue;
34
- }
35
- this.storeMetadata(metadataKey, metadataValue);
36
- }
37
- });
38
- return this;
39
- }
40
- /**
41
- * Returns the analyser report containing the fields to create as well as the type inconsistencies in the documents
42
- *
43
- * @return {*} {FieldAnalyserReport}
44
- */
45
- report() {
46
- this.ensurePermanentId(this.missingFields);
47
- this.removeInconsistentFields();
48
- return {
49
- fields: this.missingFields.marshal(),
50
- inconsistencies: this.inconsistencies,
51
- };
52
- }
53
- removeInconsistentFields() {
54
- for (const fieldname of this.inconsistencies.keys()) {
55
- this.missingFields.delete(fieldname);
56
- }
57
- }
58
- storeMetadata(metadataKey, metadataValue) {
59
- const alreadyGuessedType = this.missingFields.get(metadataKey);
60
- const firstTypeGuess = (0, typeUtils_1.getGuessedTypeFromValue)(metadataValue);
61
- if (!alreadyGuessedType) {
62
- this.missingFields.set(metadataKey, firstTypeGuess);
63
- return;
64
- }
65
- const secondTypeGuess = (0, typeUtils_1.getMostEnglobingType)(alreadyGuessedType, firstTypeGuess);
66
- if (secondTypeGuess) {
67
- this.missingFields.set(metadataKey, secondTypeGuess);
68
- }
69
- else {
70
- this.inconsistencies.add(metadataKey, [
71
- alreadyGuessedType,
72
- firstTypeGuess,
73
- ]);
74
- }
75
- }
76
- async ensureExistingFields() {
77
- if (this.existingFields === undefined) {
78
- this.existingFields = await (0, fieldUtils_1.listAllFieldsFromOrg)(this.platformClient);
79
- }
80
- return this.existingFields;
81
- }
82
- ensurePermanentId(fieldStore) {
83
- var _a;
84
- const permanentid = (_a = this.existingFields) === null || _a === void 0 ? void 0 : _a.find((field) => field.name === 'permanentid');
85
- if (permanentid) {
86
- if (permanentid.type !== platform_client_1.FieldTypes.STRING) {
87
- throw new fieldErrors_1.InvalidPermanentId(permanentid);
88
- }
89
- }
90
- else {
91
- fieldStore.set('permanentid', platform_client_1.FieldTypes.STRING);
92
- }
93
- }
94
- }
95
- exports.FieldAnalyser = FieldAnalyser;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldAnalyser = void 0;
4
+ const platform_client_1 = require("@coveo/platform-client");
5
+ const fieldUtils_1 = require("./fieldUtils");
6
+ const fieldStore_1 = require("./fieldStore");
7
+ const inconsistencies_1 = require("./inconsistencies");
8
+ const fieldErrors_1 = require("../errors/fieldErrors");
9
+ const typeUtils_1 = require("./typeUtils");
10
+ /**
11
+ * Analyse documents to detect type inconsistencies and missing fields in your index.
12
+ *
13
+ */
14
+ class FieldAnalyser {
15
+ constructor(platformClient) {
16
+ this.platformClient = platformClient;
17
+ this.inconsistencies = new inconsistencies_1.Inconsistencies();
18
+ this.missingFields = new fieldStore_1.FieldStore();
19
+ }
20
+ /**
21
+ * Adds a batch of document builders to the analyser to extract all the missing fields that need to be created in the organization.
22
+ * This method can be called as many time as needed as it will take into consideration document builders previously added.
23
+ *
24
+ * @param {DocumentBuilder[]} batch
25
+ * @return {*}
26
+ */
27
+ async add(batch) {
28
+ const existingFields = await this.ensureExistingFields();
29
+ batch.flatMap((doc) => {
30
+ const documentMetadata = Object.entries(Object.assign({}, doc.build().metadata));
31
+ for (const [metadataKey, metadataValue] of documentMetadata) {
32
+ if (existingFields.some((field) => field.name === metadataKey)) {
33
+ continue;
34
+ }
35
+ this.storeMetadata(metadataKey, metadataValue);
36
+ }
37
+ });
38
+ return this;
39
+ }
40
+ /**
41
+ * Returns the analyser report containing the fields to create as well as the type inconsistencies in the documents
42
+ *
43
+ * @return {*} {FieldAnalyserReport}
44
+ */
45
+ report() {
46
+ this.ensurePermanentId(this.missingFields);
47
+ this.removeInconsistentFields();
48
+ return {
49
+ fields: this.missingFields.marshal(),
50
+ inconsistencies: this.inconsistencies,
51
+ };
52
+ }
53
+ removeInconsistentFields() {
54
+ for (const fieldname of this.inconsistencies.keys()) {
55
+ this.missingFields.delete(fieldname);
56
+ }
57
+ }
58
+ storeMetadata(metadataKey, metadataValue) {
59
+ const alreadyGuessedType = this.missingFields.get(metadataKey);
60
+ const firstTypeGuess = (0, typeUtils_1.getGuessedTypeFromValue)(metadataValue);
61
+ if (!alreadyGuessedType) {
62
+ this.missingFields.set(metadataKey, firstTypeGuess);
63
+ return;
64
+ }
65
+ const secondTypeGuess = (0, typeUtils_1.getMostEnglobingType)(alreadyGuessedType, firstTypeGuess);
66
+ if (secondTypeGuess) {
67
+ this.missingFields.set(metadataKey, secondTypeGuess);
68
+ }
69
+ else {
70
+ this.inconsistencies.add(metadataKey, [
71
+ alreadyGuessedType,
72
+ firstTypeGuess,
73
+ ]);
74
+ }
75
+ }
76
+ async ensureExistingFields() {
77
+ if (this.existingFields === undefined) {
78
+ this.existingFields = await (0, fieldUtils_1.listAllFieldsFromOrg)(this.platformClient);
79
+ }
80
+ return this.existingFields;
81
+ }
82
+ ensurePermanentId(fieldStore) {
83
+ var _a;
84
+ const permanentid = (_a = this.existingFields) === null || _a === void 0 ? void 0 : _a.find((field) => field.name === 'permanentid');
85
+ if (permanentid) {
86
+ if (permanentid.type !== platform_client_1.FieldTypes.STRING) {
87
+ throw new fieldErrors_1.InvalidPermanentId(permanentid);
88
+ }
89
+ }
90
+ else {
91
+ fieldStore.set('permanentid', platform_client_1.FieldTypes.STRING);
92
+ }
93
+ }
94
+ }
95
+ exports.FieldAnalyser = FieldAnalyser;
96
96
  //# sourceMappingURL=fieldAnalyser.js.map