@contrail/cli 3.6.0-alpha.f45f126 → 3.7.0-alpha.0d7ff29

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 (180) hide show
  1. package/README.md +405 -71
  2. package/dist/api/types.d.ts +35 -0
  3. package/dist/api/types.js +49 -1
  4. package/dist/auth/login.d.ts +1 -1
  5. package/dist/auth/login.js +47 -29
  6. package/dist/auth/login.spec.js +48 -15
  7. package/dist/auth/sign-in-error.d.ts +7 -0
  8. package/dist/auth/sign-in-error.js +24 -0
  9. package/dist/auth/sign-in-error.spec.d.ts +1 -0
  10. package/dist/auth/sign-in-error.spec.js +22 -0
  11. package/dist/auth/sso.d.ts +5 -3
  12. package/dist/auth/sso.js +34 -18
  13. package/dist/auth/sso.spec.js +63 -10
  14. package/dist/baseFlags.d.ts +4 -0
  15. package/dist/baseFlags.js +9 -1
  16. package/dist/basecommand.d.ts +5 -0
  17. package/dist/basecommand.js +17 -4
  18. package/dist/basecommand.spec.d.ts +1 -0
  19. package/dist/basecommand.spec.js +69 -0
  20. package/dist/commands/app/create.d.ts +1 -0
  21. package/dist/commands/app/delete.d.ts +1 -0
  22. package/dist/commands/app/extension/deploy.d.ts +1 -0
  23. package/dist/commands/app/extension/deployment/list.d.ts +1 -0
  24. package/dist/commands/app/getApiKey.d.ts +1 -0
  25. package/dist/commands/app/getApiKey.js +2 -2
  26. package/dist/commands/app/init.d.ts +1 -0
  27. package/dist/commands/app/install.d.ts +1 -0
  28. package/dist/commands/app/publish.d.ts +1 -0
  29. package/dist/commands/app/uninstall.d.ts +1 -0
  30. package/dist/commands/app/upgrade.d.ts +1 -0
  31. package/dist/commands/app/version/major.d.ts +1 -0
  32. package/dist/commands/app/version/minor.d.ts +1 -0
  33. package/dist/commands/app/version/patch.d.ts +1 -0
  34. package/dist/commands/config/create.d.ts +2 -0
  35. package/dist/commands/config/create.js +1 -0
  36. package/dist/commands/config/describe.d.ts +2 -0
  37. package/dist/commands/config/describe.js +7 -4
  38. package/dist/commands/config/list.d.ts +2 -0
  39. package/dist/commands/config/list.js +2 -3
  40. package/dist/commands/config/set.d.ts +1 -0
  41. package/dist/commands/config/set.js +11 -6
  42. package/dist/commands/config/use.d.ts +2 -0
  43. package/dist/commands/config/use.js +4 -0
  44. package/dist/commands/entities/create.d.ts +50 -0
  45. package/dist/commands/entities/create.js +618 -0
  46. package/dist/commands/entities/create.spec.d.ts +1 -0
  47. package/dist/commands/entities/create.spec.js +581 -0
  48. package/dist/commands/entities/delete.d.ts +21 -0
  49. package/dist/commands/entities/delete.js +146 -0
  50. package/dist/commands/entities/get.d.ts +26 -0
  51. package/dist/commands/entities/get.js +298 -0
  52. package/dist/commands/entities/grammar.spec.d.ts +1 -0
  53. package/dist/commands/entities/grammar.spec.js +79 -0
  54. package/dist/commands/entities/output.spec.d.ts +1 -0
  55. package/dist/commands/entities/output.spec.js +72 -0
  56. package/dist/commands/entities/update.d.ts +33 -0
  57. package/dist/commands/entities/update.js +212 -0
  58. package/dist/commands/feature-flags/export.d.ts +1 -0
  59. package/dist/commands/feature-flags/import.d.ts +1 -0
  60. package/dist/commands/file/upload.d.ts +1 -0
  61. package/dist/commands/groups/export.d.ts +1 -0
  62. package/dist/commands/groups/import.d.ts +1 -0
  63. package/dist/commands/instance/export.d.ts +1 -0
  64. package/dist/commands/instance/import.d.ts +1 -0
  65. package/dist/commands/load/colors.d.ts +1 -0
  66. package/dist/commands/load/custom-entity.d.ts +1 -0
  67. package/dist/commands/load/line-sheet.d.ts +1 -0
  68. package/dist/commands/load/upload-and-load.d.ts +1 -0
  69. package/dist/commands/load-local/index.d.ts +1 -0
  70. package/dist/commands/login.d.ts +1 -0
  71. package/dist/commands/login.js +1 -1
  72. package/dist/commands/org-config/export.d.ts +1 -0
  73. package/dist/commands/org-config/import.d.ts +1 -0
  74. package/dist/commands/projects/export.d.ts +1 -0
  75. package/dist/commands/projects/list.d.ts +1 -0
  76. package/dist/commands/projects/load.d.ts +1 -0
  77. package/dist/commands/types/exportOptionSetHierarchies.d.ts +1 -0
  78. package/dist/commands/types/getAll.d.ts +1 -0
  79. package/dist/commands/types/getOptionSets.d.ts +1 -0
  80. package/dist/commands/types/loadAll.d.ts +1 -0
  81. package/dist/commands/types/mergeOptionSets.d.ts +1 -0
  82. package/dist/commands/types/mergeTypeProperties.d.ts +1 -0
  83. package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +1 -0
  84. package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +1 -0
  85. package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +1 -0
  86. package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +1 -0
  87. package/dist/commands/types/parseTypesFromFiles.d.ts +1 -0
  88. package/dist/commands/types/parseTypesFromLocalFiles.d.ts +1 -0
  89. package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +1 -0
  90. package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +1 -0
  91. package/dist/commands/types/uploadOptionSetHierarchies.d.ts +1 -0
  92. package/dist/commands/types/uploadOptionSets.d.ts +1 -0
  93. package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +1 -0
  94. package/dist/commands/types/uploadRuleSets.d.ts +1 -0
  95. package/dist/commands/types/uploadTypeOverrides.d.ts +1 -0
  96. package/dist/commands/types/uploadTypePolicies.d.ts +1 -0
  97. package/dist/commands/types/uploadTypePropertyPolicies.d.ts +1 -0
  98. package/dist/commands/types/uploadTypes.d.ts +1 -0
  99. package/dist/commands/users/export.d.ts +1 -0
  100. package/dist/commands/users/import.d.ts +1 -0
  101. package/dist/commands/webhooks/create.d.ts +1 -0
  102. package/dist/commands/webhooks/delete.d.ts +1 -0
  103. package/dist/commands/webhooks/delete.js +2 -3
  104. package/dist/commands/webhooks/getWebhookTrigger.d.ts +1 -0
  105. package/dist/commands/webhooks/list.d.ts +1 -0
  106. package/dist/commands/workflow-template-definitions/install.d.ts +1 -0
  107. package/dist/commands/workflow-template-definitions/list.d.ts +1 -0
  108. package/dist/commands/workflow-templates/delete.d.ts +1 -0
  109. package/dist/commands/workflow-templates/export.d.ts +1 -0
  110. package/dist/commands/workflow-templates/list.d.ts +1 -0
  111. package/dist/commands/workflow-templates/load.d.ts +1 -0
  112. package/dist/common.d.ts +10 -1
  113. package/dist/common.js +37 -1
  114. package/dist/common.spec.d.ts +1 -0
  115. package/dist/common.spec.js +40 -0
  116. package/dist/helpers/config/config.d.ts +4 -3
  117. package/dist/helpers/config/config.js +52 -45
  118. package/dist/helpers/config/config.spec.d.ts +1 -0
  119. package/dist/helpers/config/config.spec.js +79 -0
  120. package/dist/helpers/config/redact-tokens.d.ts +1 -0
  121. package/dist/helpers/config/redact-tokens.js +14 -0
  122. package/dist/helpers/config/redact-tokens.spec.d.ts +1 -0
  123. package/dist/helpers/config/redact-tokens.spec.js +24 -0
  124. package/dist/helpers/entities/assortment-items.d.ts +11 -0
  125. package/dist/helpers/entities/assortment-items.js +76 -0
  126. package/dist/helpers/entities/batchFetch.d.ts +11 -0
  127. package/dist/helpers/entities/batchFetch.js +50 -0
  128. package/dist/helpers/entities/index.d.ts +3 -0
  129. package/dist/helpers/entities/index.js +6 -0
  130. package/dist/helpers/entities/items.d.ts +6 -0
  131. package/dist/helpers/entities/items.js +60 -0
  132. package/dist/helpers/entities/items.spec.d.ts +1 -0
  133. package/dist/helpers/entities/items.spec.js +19 -0
  134. package/dist/helpers/entities/project-items.d.ts +2 -0
  135. package/dist/helpers/entities/project-items.js +44 -0
  136. package/dist/helpers/file-helpers.d.ts +1 -0
  137. package/dist/helpers/file-helpers.js +20 -3
  138. package/dist/helpers/propertySpecifications/dateRanges.d.ts +34 -0
  139. package/dist/helpers/propertySpecifications/dateRanges.js +91 -0
  140. package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +1 -0
  141. package/dist/helpers/propertySpecifications/dateRanges.spec.js +97 -0
  142. package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +39 -0
  143. package/dist/helpers/propertySpecifications/propertySpecifications.js +102 -0
  144. package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +1 -0
  145. package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +387 -0
  146. package/dist/helpers/propertySpecifications/propertyValues.d.ts +31 -0
  147. package/dist/helpers/propertySpecifications/propertyValues.js +132 -0
  148. package/dist/helpers/propertySpecifications/propertyValues.spec.d.ts +1 -0
  149. package/dist/helpers/propertySpecifications/propertyValues.spec.js +156 -0
  150. package/dist/logger.js +4 -1
  151. package/dist/logger.spec.d.ts +1 -0
  152. package/dist/logger.spec.js +12 -0
  153. package/node_modules/@contrail/entity-compare/package.json +6 -3
  154. package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
  155. package/node_modules/@contrail/loader/lib/constants.d.ts +0 -8
  156. package/node_modules/@contrail/loader/lib/constants.js +1 -9
  157. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +0 -4
  158. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +0 -57
  159. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +34 -492
  160. package/node_modules/@contrail/loader/lib/pipeline/validate.js +52 -2
  161. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +85 -0
  162. package/node_modules/@contrail/loader/package.json +2 -2
  163. package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +1 -4
  164. package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
  165. package/node_modules/@contrail/sdk/lib/config/config.d.ts +3 -0
  166. package/node_modules/@contrail/sdk/lib/config/config.js +13 -7
  167. package/node_modules/@contrail/sdk/lib/core/request.js +6 -2
  168. package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +2 -0
  169. package/node_modules/@contrail/sdk/lib/entities/entities.client.js +3 -1
  170. package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +1 -0
  171. package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +34 -0
  172. package/node_modules/@contrail/sdk/lib/image-search/image-search.js +42 -0
  173. package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +1 -0
  174. package/node_modules/@contrail/sdk/lib/image-search/index.js +17 -0
  175. package/node_modules/@contrail/sdk/lib/index.d.ts +1 -0
  176. package/node_modules/@contrail/sdk/lib/index.js +1 -0
  177. package/node_modules/@contrail/sdk/package.json +1 -1
  178. package/node_modules/@contrail/sdk/scripts/replicate-bug.js +69 -0
  179. package/oclif.manifest.json +969 -9
  180. package/package.json +6 -12
@@ -631,6 +631,91 @@ describe('validate', () => {
631
631
  expect(issue).toBeUndefined();
632
632
  });
633
633
  });
634
+ describe('typePath format validation', () => {
635
+ const itemConfig = {
636
+ loadType: [types_1.LoadType.ITEM],
637
+ federatedMappings: { itemFamilyFederatedId: 'itemFamilyFederatedId', name: 'name' },
638
+ };
639
+ it('should error when rows have an invalid typePath', async () => {
640
+ const rows = [
641
+ { itemFamilyFederatedId: 'fam-1', name: 'A', typePath: 'custom-entity:product' },
642
+ { itemFamilyFederatedId: 'fam-2', name: 'B', typePath: 'item' },
643
+ ];
644
+ const result = await (0, validate_1.validate)(rows, itemConfig, makeAnalysis());
645
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
646
+ expect(issue).toBeDefined();
647
+ expect(issue.affectedRows).toHaveLength(1);
648
+ expect(issue.affectedRows[0].row).toBe(2);
649
+ });
650
+ it('should error when typePath is missing on rows', async () => {
651
+ const rows = [
652
+ { itemFamilyFederatedId: 'fam-1', name: 'A' },
653
+ { itemFamilyFederatedId: 'fam-2', name: 'B' },
654
+ ];
655
+ const result = await (0, validate_1.validate)(rows, itemConfig, makeAnalysis());
656
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
657
+ expect(issue).toBeDefined();
658
+ expect(issue.affectedRows).toHaveLength(2);
659
+ });
660
+ it('should not error when all rows have valid typePaths', async () => {
661
+ const rows = [
662
+ { itemFamilyFederatedId: 'fam-1', name: 'A', typePath: 'item' },
663
+ { itemFamilyFederatedId: 'fam-2', name: 'B', typePath: 'item:product' },
664
+ { itemFamilyFederatedId: 'fam-3', name: 'C', typePath: 'item:material:fabric' },
665
+ ];
666
+ const result = await (0, validate_1.validate)(rows, itemConfig, makeAnalysis());
667
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
668
+ expect(issue).toBeUndefined();
669
+ });
670
+ it('should not run for COLOR loads', async () => {
671
+ const colorConfig = {
672
+ loadType: [types_1.LoadType.COLOR],
673
+ federatedMappings: { federatedId: 'federatedId', name: 'name' },
674
+ };
675
+ const rows = [{ federatedId: '1', name: 'Red', typePath: 'bad-value' }];
676
+ const result = await (0, validate_1.validate)(rows, colorConfig, makeAnalysis());
677
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
678
+ expect(issue).toBeUndefined();
679
+ });
680
+ it('should not run for PROJECT_ITEM or ASSORTMENT loads (items already have a type)', async () => {
681
+ const projectItemConfig = {
682
+ loadType: [types_1.LoadType.PROJECT_ITEM, types_1.LoadType.ASSORTMENT],
683
+ federatedMappings: { itemFamilyFederatedId: 'itemFamilyFederatedId', name: 'name' },
684
+ };
685
+ const rows = [{ itemFamilyFederatedId: 'fam-1', name: 'A' }];
686
+ const result = await (0, validate_1.validate)(rows, projectItemConfig, makeAnalysis());
687
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
688
+ expect(issue).toBeUndefined();
689
+ });
690
+ it('should error for CUSTOM_ENTITY rows with missing subtype', async () => {
691
+ const customEntityConfig = {
692
+ loadType: [types_1.LoadType.CUSTOM_ENTITY],
693
+ federatedMappings: { federatedId: 'federatedId', name: 'name' },
694
+ };
695
+ const rows = [
696
+ { federatedId: '1', name: 'A', typePath: 'custom-entity:material' },
697
+ { federatedId: '2', name: 'B', typePath: 'custom-entity:' },
698
+ { federatedId: '3', name: 'C' },
699
+ ];
700
+ const result = await (0, validate_1.validate)(rows, customEntityConfig, makeAnalysis());
701
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
702
+ expect(issue).toBeDefined();
703
+ expect(issue.affectedRows).toHaveLength(2);
704
+ });
705
+ it('should not error for CUSTOM_ENTITY rows with valid typePath', async () => {
706
+ const customEntityConfig = {
707
+ loadType: [types_1.LoadType.CUSTOM_ENTITY],
708
+ federatedMappings: { federatedId: 'federatedId', name: 'name' },
709
+ };
710
+ const rows = [
711
+ { federatedId: '1', name: 'A', typePath: 'custom-entity:material' },
712
+ { federatedId: '2', name: 'B', typePath: 'custom-entity:material:fabric' },
713
+ ];
714
+ const result = await (0, validate_1.validate)(rows, customEntityConfig, makeAnalysis());
715
+ const issue = result.issues.find((i) => i.columnName === 'typePath' && i.category === types_3.PreValidationCategory.MISSING_REQUIRED_FIELD);
716
+ expect(issue).toBeUndefined();
717
+ });
718
+ });
634
719
  describe('typePath existence validation', () => {
635
720
  it('should error when typesByPath contains entries with errors (non-existent type)', async () => {
636
721
  const config = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/loader",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "Client library for helping with loader jobs.",
5
5
  "homepage": "https://archergreysorg.github.io/contrail-loader/",
6
6
  "main": "lib/index.js",
@@ -27,7 +27,7 @@
27
27
  "lib"
28
28
  ],
29
29
  "dependencies": {
30
- "@contrail/entity-compare": "^1.0.5",
30
+ "@contrail/entity-compare": "^1.2.1",
31
31
  "@contrail/entity-types": "1.6.1",
32
32
  "@contrail/policies": "^2.0.7",
33
33
  "@contrail/types": "^3.0.33",
@@ -3,11 +3,8 @@ name: Publish to NPM
3
3
  on:
4
4
  push:
5
5
  branches: [master]
6
- paths-ignore:
7
- - '.github/**'
8
6
  pull_request:
9
- paths-ignore:
10
- - '.github/**'
7
+ branches: ['**']
11
8
 
12
9
  jobs:
13
10
  check-version:
@@ -15,7 +15,7 @@ const config_1 = require("../config");
15
15
  const auth_1 = require("./auth");
16
16
  const DEV_CONFIGURATION = {
17
17
  userPoolId: 'us-east-1_e2cA0nJWu',
18
- clientId: 'nnio2uhtq7qfk1tjmi7tgg63p',
18
+ clientId: '209s9c62o165cqab0fu5ihjtu9',
19
19
  apiGateway: 'https://api.dev.vibeiq.com/dev/api',
20
20
  };
21
21
  const PROD_CONFIGURATION = {
@@ -26,6 +26,9 @@ export interface ContrailConfig {
26
26
  errorHandler?: ErrorHandler;
27
27
  networkErrorHandler?: NetworkErrorHandler;
28
28
  }
29
+ declare global {
30
+ var __CONTRAIL_SDK_CONFIG__: ContrailConfig | undefined;
31
+ }
29
32
  export declare const CONTRAIL_CONFIG: ContrailConfig;
30
33
  export declare function setConfig(config: ContrailConfig): void;
31
34
  export declare function getConfig(): ContrailConfig;
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
- var _a, _b;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.getGlobalContext = exports.setGlobalContext = exports.setFromContext = exports.getConfig = exports.setConfig = exports.CONTRAIL_CONFIG = void 0;
5
- exports.CONTRAIL_CONFIG = {
6
- apiGateway: ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.API_GATEWAY) || 'http://localhost:3000/api',
7
- orgId: (_b = process === null || process === void 0 ? void 0 : process.env) === null || _b === void 0 ? void 0 : _b.ORG_ID,
8
- };
4
+ function getOrInitGlobalConfig() {
5
+ var _a, _b;
6
+ if (!globalThis.__CONTRAIL_SDK_CONFIG__) {
7
+ globalThis.__CONTRAIL_SDK_CONFIG__ = {
8
+ apiGateway: ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.API_GATEWAY) || 'http://localhost:3000/api',
9
+ orgId: (_b = process === null || process === void 0 ? void 0 : process.env) === null || _b === void 0 ? void 0 : _b.ORG_ID,
10
+ };
11
+ }
12
+ return globalThis.__CONTRAIL_SDK_CONFIG__;
13
+ }
14
+ exports.CONTRAIL_CONFIG = getOrInitGlobalConfig();
9
15
  function setConfig(config) {
10
- Object.assign(exports.CONTRAIL_CONFIG, config);
16
+ Object.assign(getOrInitGlobalConfig(), config);
11
17
  }
12
18
  exports.setConfig = setConfig;
13
19
  function getConfig() {
14
- return exports.CONTRAIL_CONFIG;
20
+ return getOrInitGlobalConfig();
15
21
  }
16
22
  exports.getConfig = getConfig;
17
23
  function setFromContext(ctx) {
@@ -114,7 +114,7 @@ class Request {
114
114
  });
115
115
  }
116
116
  static requestWithRetries(resource, params, ctx) {
117
- var _a;
117
+ var _a, _b;
118
118
  return __awaiter(this, void 0, void 0, function* () {
119
119
  const userCtx = ctx || (0, config_1.getGlobalContext)();
120
120
  const start = new Date();
@@ -122,12 +122,13 @@ class Request {
122
122
  const url = API_GATEWAY + resource;
123
123
  const method = (params === null || params === void 0 ? void 0 : params.method) ? params.method.toUpperCase() : 'GET';
124
124
  const fullResource = `${method} ${url.split('/')[3]}${resource}`;
125
+ const ignore404 = (_a = params === null || params === void 0 ? void 0 : params.ignore404) !== null && _a !== void 0 ? _a : false;
125
126
  let res;
126
127
  let attempt = 0;
127
128
  while (attempt <= this.MAX_RETRIES) {
128
129
  attempt++;
129
130
  try {
130
- if ((_a = userCtx === null || userCtx === void 0 ? void 0 : userCtx.requestOptions) === null || _a === void 0 ? void 0 : _a.useNativeFetch) {
131
+ if ((_b = userCtx === null || userCtx === void 0 ? void 0 : userCtx.requestOptions) === null || _b === void 0 ? void 0 : _b.useNativeFetch) {
131
132
  res = yield globalThis.fetch(url, params);
132
133
  }
133
134
  else {
@@ -160,6 +161,9 @@ class Request {
160
161
  else {
161
162
  const error = yield res.text();
162
163
  const errorJson = this.tryParseStringIntoObject(error);
164
+ if (ignore404 && res.status === 404) {
165
+ return null;
166
+ }
163
167
  const isTokenExpired = errorJson && typeof errorJson === 'object' && errorJson.errorCode === 'TOKEN_EXPIRED';
164
168
  if (isTokenExpired) {
165
169
  throw new ApiError('Token expired', errorJson, 'TOKEN_EXPIRED');
@@ -37,6 +37,7 @@ export declare abstract class EntitiesClientGetOptions {
37
37
  suffix?: string;
38
38
  skipHydrateRelationships?: boolean;
39
39
  customParams?: Record<string, string | number | boolean>;
40
+ ignore404?: boolean;
40
41
  }
41
42
  export declare abstract class EntitiesClientCreateOptions {
42
43
  entityName: string;
@@ -78,6 +79,7 @@ export declare abstract class EntitiesClientDeleteOptions {
78
79
  relationId?: string;
79
80
  apiVersion?: API_VERSION;
80
81
  suffix?: string;
82
+ ignore404?: boolean;
81
83
  }
82
84
  export declare abstract class EntitiesClientBatchDeleteOptions {
83
85
  entityName?: string;
@@ -134,7 +134,7 @@ class Entities {
134
134
  resource += `ids=${options.federatedIds.map((id) => encodeURIComponent(id.replace(/,/g, '_COMMA_'))).join(',')}&`;
135
135
  }
136
136
  if (options.criteria) {
137
- resource += 'criteria=' + JSURL.stringify(options.criteria);
137
+ resource += 'criteria=' + JSURL.stringify(options.criteria) + '&';
138
138
  }
139
139
  if (options.customParams) {
140
140
  const buildQueryParam = (key, value) => {
@@ -154,6 +154,7 @@ class Entities {
154
154
  }
155
155
  return yield request_1.Request.request(resource, {
156
156
  headers: Object.assign({}, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
157
+ ignore404: options.ignore404,
157
158
  }, this.ctx);
158
159
  });
159
160
  }
@@ -269,6 +270,7 @@ class Entities {
269
270
  return yield request_1.Request.request(resource, {
270
271
  method: 'DELETE',
271
272
  headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
273
+ ignore404: options.ignore404,
272
274
  }, this.ctx);
273
275
  });
274
276
  }
@@ -56,3 +56,4 @@ EntityResourceRegistry.registerEntityResourceName('project-configurator', 'proje
56
56
  EntityResourceRegistry.registerEntityResourceName('identity', 'identities');
57
57
  EntityResourceRegistry.registerEntityResourceName('entity-policy', 'entity-policies');
58
58
  EntityResourceRegistry.registerEntityResourceName('measurement-spec-entry', 'measurement-spec-entries');
59
+ EntityResourceRegistry.registerEntityResourceName('image-search', 'image-search');
@@ -0,0 +1,34 @@
1
+ import { InvocationContext } from '../config';
2
+ export declare type ImageSearchSource = {
3
+ contentId: string;
4
+ } | {
5
+ fileId: string;
6
+ } | {
7
+ imageBase64: string;
8
+ };
9
+ export interface ImageSearchOptions {
10
+ limit?: number;
11
+ minScore?: number;
12
+ hydrate?: boolean;
13
+ filterContentIds?: string[];
14
+ }
15
+ export interface ImageSearchResult {
16
+ contentId: string;
17
+ fileId: string;
18
+ contentHolderReference: string;
19
+ fileName: string;
20
+ contentType: string;
21
+ primaryFileUrl: string;
22
+ score: number;
23
+ contentHolder?: Record<string, unknown>;
24
+ }
25
+ export interface ImageSearchResponse {
26
+ results: ImageSearchResult[];
27
+ }
28
+ export declare class ImageSearch {
29
+ private ctx;
30
+ constructor(ctx?: InvocationContext);
31
+ searchByText(query: string, options?: ImageSearchOptions): Promise<ImageSearchResponse>;
32
+ searchSimilar(source: ImageSearchSource, options?: ImageSearchOptions): Promise<ImageSearchResponse>;
33
+ private post;
34
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ImageSearch = void 0;
13
+ const request_1 = require("../core/request");
14
+ const SEARCH_RESOURCE = '/image-search/search';
15
+ const SEARCH_BY_IMAGE_RESOURCE = '/image-search/search-by-image';
16
+ class ImageSearch {
17
+ constructor(ctx) {
18
+ this.ctx = ctx;
19
+ }
20
+ searchByText(query, options = {}) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ return this.post(SEARCH_RESOURCE, Object.assign({ query }, options));
23
+ });
24
+ }
25
+ searchSimilar(source, options = {}) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this.post(SEARCH_BY_IMAGE_RESOURCE, Object.assign(Object.assign({}, source), options));
28
+ });
29
+ }
30
+ post(resource, body) {
31
+ var _a;
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const response = (yield request_1.Request.request(resource, {
34
+ method: 'POST',
35
+ body: JSON.stringify(body),
36
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
37
+ }, this.ctx));
38
+ return { results: (_a = response === null || response === void 0 ? void 0 : response.results) !== null && _a !== void 0 ? _a : [] };
39
+ });
40
+ }
41
+ }
42
+ exports.ImageSearch = ImageSearch;
@@ -0,0 +1 @@
1
+ export * from './image-search';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./image-search"), exports);
@@ -8,3 +8,4 @@ export * from './auth';
8
8
  export * from './policies';
9
9
  export * from './assets';
10
10
  export * from './notifications';
11
+ export * from './image-search';
@@ -24,3 +24,4 @@ __exportStar(require("./auth"), exports);
24
24
  __exportStar(require("./policies"), exports);
25
25
  __exportStar(require("./assets"), exports);
26
26
  __exportStar(require("./notifications"), exports);
27
+ __exportStar(require("./image-search"), exports);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/sdk",
3
- "version": "1.5.13",
3
+ "version": "1.6.0",
4
4
  "description": "Client library for interfacing with contrail services.",
5
5
  "homepage": "https://archergreysorg.github.io/contrail-lib/",
6
6
  "publishConfig": {
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Replication script for ENGINE-92:
3
+ * Auth credentials set on one @contrail/sdk instance don't propagate to a second instance
4
+ * loaded in the same process (npm link / prerelease version scenarios).
5
+ *
6
+ * Run: node scripts/replicate-bug.js
7
+ */
8
+
9
+ const path = require('path');
10
+
11
+ const libDir = path.resolve(__dirname, '../lib');
12
+ const indexModulePath = path.join(libDir, 'index.js');
13
+
14
+ // ---------- Helper: load a fresh module instance ----------
15
+ function loadFreshInstance() {
16
+ // Clear all sdk lib modules from the require cache to simulate a second npm installation.
17
+ // Match on the resolved absolute lib path so this works regardless of directory name or OS path separator.
18
+ Object.keys(require.cache).forEach((key) => {
19
+ if (key.startsWith(libDir)) {
20
+ delete require.cache[key];
21
+ }
22
+ });
23
+ return require(indexModulePath);
24
+ }
25
+
26
+ // ----------------------------------------------------------------
27
+ // SIMULATE the bug
28
+ // ----------------------------------------------------------------
29
+
30
+ console.log('\n======= ENGINE-92 Replication Script =======\n');
31
+
32
+ // Instance A = what @contrail/app-framework loads
33
+ const instanceA = loadFreshInstance();
34
+
35
+ // Instance B = what the app itself loads (separate npm copy)
36
+ const instanceB = loadFreshInstance();
37
+
38
+ const TEST_API_KEY = 'app:test-api-key-12345';
39
+ const TEST_ORG_SLUG = 'test-org';
40
+
41
+ // Step 1: App-framework calls setAppCredentials on its own SDK instance (A)
42
+ instanceA.setAppCredentials(TEST_API_KEY, TEST_ORG_SLUG);
43
+
44
+ // Step 2: App's own SDK reads config — this is what Request.getHeaders() does
45
+ const configFromB = instanceB.getConfig();
46
+
47
+ console.log('Credentials set via instance A (app-framework):');
48
+ console.log(' apiUserToken :', TEST_API_KEY);
49
+ console.log(' orgSlug :', TEST_ORG_SLUG);
50
+ console.log('');
51
+ console.log("Config read from instance B (app's SDK calls):");
52
+ console.log(' apiUserToken :', configFromB.apiUserToken ?? '(undefined)');
53
+ console.log(' orgSlug :', configFromB.orgSlug ?? '(undefined)');
54
+ console.log('');
55
+
56
+ const bugReproduced = configFromB.apiUserToken !== TEST_API_KEY;
57
+
58
+ if (bugReproduced) {
59
+ console.log('RESULT: BUG REPRODUCED ❌');
60
+ console.log(' Instance B cannot see credentials set by instance A.');
61
+ console.log(' This is why SDK calls fail with auth errors in event workflows.');
62
+ } else {
63
+ console.log('RESULT: Bug NOT reproduced — credentials ARE shared across instances ✅');
64
+ console.log(' (Either the fix is already applied, or the two instances resolved to the same module path.)');
65
+ }
66
+
67
+ console.log('\n============================================\n');
68
+
69
+ process.exit(bugReproduced ? 1 : 0);