@contrail/cli 3.6.0-alpha-8-alpha.252e3f3 → 3.6.0-alpha-8-alpha.c613d8e

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 (47) hide show
  1. package/README.md +31 -58
  2. package/dist/auth/login.js +8 -9
  3. package/dist/basecommand.js +2 -2
  4. package/dist/commands/app/getApiKey.js +2 -2
  5. package/dist/commands/entities/create.d.ts +1 -13
  6. package/dist/commands/entities/create.js +31 -98
  7. package/dist/commands/entities/create.spec.js +3 -32
  8. package/dist/commands/entities/delete.d.ts +2 -6
  9. package/dist/commands/entities/delete.js +53 -72
  10. package/dist/commands/entities/get.d.ts +0 -4
  11. package/dist/commands/entities/get.js +15 -66
  12. package/dist/commands/entities/update.d.ts +2 -15
  13. package/dist/commands/entities/update.js +44 -80
  14. package/dist/common.d.ts +0 -3
  15. package/dist/common.js +1 -18
  16. package/dist/helpers/entities/assortment-items.d.ts +2 -4
  17. package/dist/helpers/entities/assortment-items.js +1 -4
  18. package/dist/helpers/file-helpers.js +2 -2
  19. package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -8
  20. package/dist/helpers/propertySpecifications/propertySpecifications.js +9 -21
  21. package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +10 -20
  22. package/dist/logger.js +1 -4
  23. package/node_modules/@contrail/entity-compare/package.json +6 -3
  24. package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
  25. package/node_modules/@contrail/loader/lib/constants.d.ts +0 -8
  26. package/node_modules/@contrail/loader/lib/constants.js +1 -9
  27. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +0 -4
  28. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +0 -57
  29. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +34 -492
  30. package/node_modules/@contrail/loader/lib/pipeline/validate.js +52 -2
  31. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +85 -0
  32. package/node_modules/@contrail/loader/package.json +2 -2
  33. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +0 -1
  34. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +0 -1
  35. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +1 -1
  36. package/oclif.manifest.json +27 -99
  37. package/package.json +1 -1
  38. package/dist/commands/entities/grammar.spec.d.ts +0 -1
  39. package/dist/commands/entities/grammar.spec.js +0 -80
  40. package/dist/commands/entities/output.spec.d.ts +0 -1
  41. package/dist/commands/entities/output.spec.js +0 -72
  42. package/dist/logger.spec.d.ts +0 -1
  43. package/dist/logger.spec.js +0 -12
  44. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +0 -34
  45. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/image-search.js +0 -42
  46. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/index.d.ts +0 -1
  47. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/image-search/index.js +0 -17
@@ -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",
@@ -8,4 +8,3 @@ export * from './auth';
8
8
  export * from './policies';
9
9
  export * from './assets';
10
10
  export * from './notifications';
11
- export * from './image-search';
@@ -24,4 +24,3 @@ __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.19",
3
+ "version": "1.5.18",
4
4
  "description": "Client library for interfacing with contrail services.",
5
5
  "homepage": "https://archergreysorg.github.io/contrail-lib/",
6
6
  "publishConfig": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.252e3f3",
2
+ "version": "3.6.0-alpha-8-alpha.c613d8e",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -675,7 +675,7 @@
675
675
  },
676
676
  "entities:create": {
677
677
  "id": "entities:create",
678
- "description": "Create entities",
678
+ "description": "(BETA) Create entities",
679
679
  "strict": false,
680
680
  "pluginName": "@contrail/cli",
681
681
  "pluginAlias": "@contrail/cli",
@@ -771,28 +771,10 @@
771
771
  "skipHydrateRelationships": {
772
772
  "name": "skipHydrateRelationships",
773
773
  "type": "boolean",
774
- "char": "S",
774
+ "char": "s",
775
775
  "description": "If true, does not hydrate relationships for the created entities",
776
776
  "required": false,
777
777
  "allowNo": false
778
- },
779
- "suffix": {
780
- "name": "suffix",
781
- "type": "option",
782
- "description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
783
- "required": false,
784
- "multiple": false
785
- },
786
- "apiVersion": {
787
- "name": "apiVersion",
788
- "type": "option",
789
- "description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
790
- "required": false,
791
- "multiple": false,
792
- "options": [
793
- "1",
794
- "2"
795
- ]
796
778
  }
797
779
  },
798
780
  "args": {
@@ -805,16 +787,14 @@
805
787
  },
806
788
  "entities:delete": {
807
789
  "id": "entities:delete",
808
- "description": "Delete entities by id",
809
- "strict": false,
790
+ "description": "(BETA) Delete an entity",
791
+ "strict": true,
810
792
  "pluginName": "@contrail/cli",
811
793
  "pluginAlias": "@contrail/cli",
812
794
  "pluginType": "core",
813
795
  "aliases": [],
814
796
  "examples": [
815
- "contrail entities delete color 123",
816
- "contrail entities delete color id1 id2 id3",
817
- "contrail entities delete item -i ids.json"
797
+ "contrail entities delete color 123"
818
798
  ],
819
799
  "flags": {
820
800
  "logLevel": {
@@ -848,35 +828,24 @@
848
828
  "name": "dryRun",
849
829
  "type": "boolean",
850
830
  "char": "d",
851
- "description": "If true, does not delete the entities but simulates the deletion",
831
+ "description": "If true, does not delete the entity but simulates the deletion",
852
832
  "required": false,
853
833
  "allowNo": false
854
834
  },
855
- "inputFile": {
856
- "name": "inputFile",
835
+ "input": {
836
+ "name": "input",
857
837
  "type": "option",
858
838
  "char": "i",
859
- "description": "A file with a JSON array of objects; only each object's id is used. Deletes every entity in the file.",
839
+ "description": "A JSON array of objects where each object is one entity to create. Cannot be used with --count. Unless --precise is specified, any missing values will be populated with random values.",
860
840
  "required": false,
861
841
  "multiple": false
862
842
  },
863
- "suffix": {
864
- "name": "suffix",
843
+ "id": {
844
+ "name": "id",
865
845
  "type": "option",
866
- "description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
846
+ "description": "The unique identifier of the entity",
867
847
  "required": false,
868
848
  "multiple": false
869
- },
870
- "apiVersion": {
871
- "name": "apiVersion",
872
- "type": "option",
873
- "description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
874
- "required": false,
875
- "multiple": false,
876
- "options": [
877
- "1",
878
- "2"
879
- ]
880
849
  }
881
850
  },
882
851
  "args": {
@@ -884,25 +853,18 @@
884
853
  "name": "entityName",
885
854
  "description": "The name of the entity type to delete",
886
855
  "required": true
887
- },
888
- "ids": {
889
- "name": "ids",
890
- "description": "One or more entity ids to delete",
891
- "required": false
892
856
  }
893
857
  }
894
858
  },
895
859
  "entities:get": {
896
860
  "id": "entities:get",
897
- "description": "Get an entity",
861
+ "description": "(BETA) Get an entity",
898
862
  "strict": false,
899
863
  "pluginName": "@contrail/cli",
900
864
  "pluginAlias": "@contrail/cli",
901
865
  "pluginType": "core",
902
866
  "aliases": [],
903
867
  "examples": [
904
- "contrail entities get color 123",
905
- "contrail entities get color id1 id2 id3",
906
868
  "contrail entities get color -- id=123",
907
869
  "contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16",
908
870
  "contrail entities get orders -- updatedAt=2025-09-15T04:00:00Z..",
@@ -991,24 +953,6 @@
991
953
  "description": "Comma-separated list of relations to include in the output",
992
954
  "required": false,
993
955
  "multiple": false
994
- },
995
- "suffix": {
996
- "name": "suffix",
997
- "type": "option",
998
- "description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
999
- "required": false,
1000
- "multiple": false
1001
- },
1002
- "apiVersion": {
1003
- "name": "apiVersion",
1004
- "type": "option",
1005
- "description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
1006
- "required": false,
1007
- "multiple": false,
1008
- "options": [
1009
- "1",
1010
- "2"
1011
- ]
1012
956
  }
1013
957
  },
1014
958
  "args": {
@@ -1016,17 +960,12 @@
1016
960
  "name": "typePath",
1017
961
  "description": "The name of the entity type to fetch",
1018
962
  "required": true
1019
- },
1020
- "ids": {
1021
- "name": "ids",
1022
- "description": "One or more entity ids; shorthand for the id/ids criteria",
1023
- "required": false
1024
963
  }
1025
964
  }
1026
965
  },
1027
966
  "entities:update": {
1028
967
  "id": "entities:update",
1029
- "description": "Update an entity",
968
+ "description": "(BETA) Update an entity",
1030
969
  "strict": false,
1031
970
  "pluginName": "@contrail/cli",
1032
971
  "pluginAlias": "@contrail/cli",
@@ -1034,7 +973,6 @@
1034
973
  "aliases": [],
1035
974
  "examples": [
1036
975
  "contrail entities update color 123 -- name=obsidian hex=000000",
1037
- "contrail entities update item id1 id2 id3 -- status=archived # apply the same change to several entities",
1038
976
  "contrail entities update color 123 -- description= notes='\"\"' # Unset description, set notes to empty string"
1039
977
  ],
1040
978
  "flags": {
@@ -1068,7 +1006,7 @@
1068
1006
  "skipHydrateRelationships": {
1069
1007
  "name": "skipHydrateRelationships",
1070
1008
  "type": "boolean",
1071
- "char": "S",
1009
+ "char": "s",
1072
1010
  "description": "Skip hydrating relationships when updating the entity",
1073
1011
  "required": false,
1074
1012
  "allowNo": false
@@ -1077,7 +1015,7 @@
1077
1015
  "name": "dryRun",
1078
1016
  "type": "boolean",
1079
1017
  "char": "d",
1080
- "description": "If true, does not update the entities but simulates the update",
1018
+ "description": "If true, does not create the entity but simulates the creation",
1081
1019
  "required": false,
1082
1020
  "allowNo": false
1083
1021
  },
@@ -1085,27 +1023,17 @@
1085
1023
  "name": "inputFile",
1086
1024
  "type": "option",
1087
1025
  "char": "i",
1088
- "description": "A file with a JSON array of {id, ...} objects; each object is one entity to update.",
1026
+ "description": "File containing properties to update the entity (optional)",
1089
1027
  "required": false,
1090
1028
  "multiple": false
1091
1029
  },
1092
- "suffix": {
1093
- "name": "suffix",
1094
- "type": "option",
1095
- "description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
1096
- "required": false,
1097
- "multiple": false
1098
- },
1099
- "apiVersion": {
1100
- "name": "apiVersion",
1101
- "type": "option",
1102
- "description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
1030
+ "force": {
1031
+ "name": "force",
1032
+ "type": "boolean",
1033
+ "char": "F",
1034
+ "description": "Force update without validation. Internal use only",
1103
1035
  "required": false,
1104
- "multiple": false,
1105
- "options": [
1106
- "1",
1107
- "2"
1108
- ]
1036
+ "allowNo": false
1109
1037
  }
1110
1038
  },
1111
1039
  "args": {
@@ -1114,9 +1042,9 @@
1114
1042
  "description": "The name of the entity type to update",
1115
1043
  "required": true
1116
1044
  },
1117
- "ids": {
1118
- "name": "ids",
1119
- "description": "One or more entity ids to update",
1045
+ "id": {
1046
+ "name": "id",
1047
+ "description": "The unique identifier of the entity",
1120
1048
  "required": false
1121
1049
  }
1122
1050
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.6.0-alpha-8-alpha.252e3f3",
3
+ "version": "3.6.0-alpha-8-alpha.c613d8e",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",
@@ -1 +0,0 @@
1
- export {};
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const create_1 = tslib_1.__importDefault(require("./create"));
5
- const get_1 = tslib_1.__importDefault(require("./get"));
6
- const update_1 = tslib_1.__importDefault(require("./update"));
7
- const delete_1 = tslib_1.__importDefault(require("./delete"));
8
- const propertySpecifications_1 = require("../../helpers/propertySpecifications/propertySpecifications");
9
- describe('entities command grammar: entities <verb> <typePath> [ID...]', () => {
10
- describe('partitionIdsAndSpecs', () => {
11
- it('should treat tokens without an equals sign as ids', () => {
12
- const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(['id1', 'id2', 'id3']);
13
- expect(ids).toEqual(['id1', 'id2', 'id3']);
14
- expect(specs).toEqual([]);
15
- });
16
- it('should treat slug=value tokens as property specifications', () => {
17
- const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(['name=jet', 'hex=000000']);
18
- expect(ids).toEqual([]);
19
- expect(specs).toEqual(['name=jet', 'hex=000000']);
20
- });
21
- it('should split mixed tokens preserving order within each group', () => {
22
- const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(['id1', 'name=jet', 'id2', 'status=archived']);
23
- expect(ids).toEqual(['id1', 'id2']);
24
- expect(specs).toEqual(['name=jet', 'status=archived']);
25
- });
26
- it('should not classify malformed specs as ids', () => {
27
- const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(['=value']);
28
- expect(ids).toEqual([]);
29
- expect(specs).toEqual([]);
30
- });
31
- it('should handle empty input', () => {
32
- const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)([]);
33
- expect(ids).toEqual([]);
34
- expect(specs).toEqual([]);
35
- });
36
- });
37
- describe('positional id arguments', () => {
38
- it('should accept variadic positional ids on get', () => {
39
- expect(get_1.default.strict).toBe(false);
40
- expect(get_1.default.args.ids).toBeDefined();
41
- });
42
- it('should accept variadic positional ids on update with no single id arg', () => {
43
- expect(update_1.default.strict).toBe(false);
44
- expect(update_1.default.args.ids).toBeDefined();
45
- expect(update_1.default.args.id).toBeUndefined();
46
- });
47
- it('should accept variadic positional ids on delete with no --id flag', () => {
48
- expect(delete_1.default.strict).toBe(false);
49
- expect(delete_1.default.args.ids).toBeDefined();
50
- expect(delete_1.default.flags.id).toBeUndefined();
51
- });
52
- });
53
- describe('flag alignment across verbs', () => {
54
- it('should name the input file -i, --inputFile on every verb that accepts one', () => {
55
- expect(create_1.default.flags.inputFile.char).toBe('i');
56
- expect(update_1.default.flags.inputFile.char).toBe('i');
57
- expect(delete_1.default.flags.inputFile.char).toBe('i');
58
- expect(delete_1.default.flags.input).toBeUndefined();
59
- });
60
- it('should map skipHydrateRelationships to -S on every verb', () => {
61
- expect(create_1.default.flags.skipHydrateRelationships.char).toBe('S');
62
- expect(get_1.default.flags.skipHydrateRelationships.char).toBe('S');
63
- expect(update_1.default.flags.skipHydrateRelationships.char).toBe('S');
64
- });
65
- it('should keep -s for --skip on get', () => {
66
- expect(get_1.default.flags.skip.char).toBe('s');
67
- });
68
- it('should expose --suffix on every verb to reach entity sub-routes', () => {
69
- expect(create_1.default.flags.suffix).toBeDefined();
70
- expect(get_1.default.flags.suffix).toBeDefined();
71
- expect(update_1.default.flags.suffix).toBeDefined();
72
- expect(delete_1.default.flags.suffix).toBeDefined();
73
- });
74
- it('should expose --apiVersion on every verb, constrained to 1 or 2', () => {
75
- for (const command of [create_1.default, get_1.default, update_1.default, delete_1.default]) {
76
- expect(command.flags.apiVersion.options).toEqual(['1', '2']);
77
- }
78
- });
79
- });
80
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const create_1 = require("./create");
4
- const update_1 = require("./update");
5
- const fulfilled = (value) => ({ status: 'fulfilled', value });
6
- const rejected = (message) => ({
7
- status: 'rejected',
8
- reason: new Error(message),
9
- });
10
- describe('mutation output summaries', () => {
11
- describe('summarizeSettledCreates', () => {
12
- it('should put every fulfilled result under created', () => {
13
- const inputs = [{ name: 'a' }, { name: 'b' }];
14
- const summary = (0, create_1.summarizeSettledCreates)(inputs, [
15
- fulfilled({ id: '1', name: 'a' }),
16
- fulfilled({ id: '2', name: 'b' }),
17
- ]);
18
- expect(summary.created).toEqual([
19
- { id: '1', name: 'a' },
20
- { id: '2', name: 'b' },
21
- ]);
22
- expect(summary.failed).toEqual([]);
23
- });
24
- it('should pair each failed input with its error so it can be retried as-is', () => {
25
- const inputs = [{ itemId: 'itm-1' }, { itemId: 'itm-41x' }, { itemId: 'itm-3' }];
26
- const summary = (0, create_1.summarizeSettledCreates)(inputs, [
27
- fulfilled({ id: 'ai-1' }),
28
- rejected('Item with ID itm-41x does not exist'),
29
- fulfilled({ id: 'ai-3' }),
30
- ]);
31
- expect(summary.created).toEqual([{ id: 'ai-1' }, { id: 'ai-3' }]);
32
- expect(summary.failed).toEqual([
33
- { input: { itemId: 'itm-41x' }, error: 'Item with ID itm-41x does not exist' },
34
- ]);
35
- });
36
- it('should fall back to details when the SDK error message is empty', () => {
37
- const sdkError = Object.assign(new Error(''), {
38
- details: '{"message":"Assortment not found.","statusCode":404}',
39
- });
40
- const summary = (0, create_1.summarizeSettledCreates)([{ assortmentId: 'bogus' }], [{ status: 'rejected', reason: sdkError }]);
41
- expect(summary.failed[0].error).toBe('{"message":"Assortment not found.","statusCode":404}');
42
- });
43
- it('should stringify reasons that are not Errors', () => {
44
- const summary = (0, create_1.summarizeSettledCreates)([{ name: 'a' }], [{ status: 'rejected', reason: 'boom' }]);
45
- expect(summary.failed).toEqual([{ input: { name: 'a' }, error: 'boom' }]);
46
- });
47
- it('should handle empty input', () => {
48
- expect((0, create_1.summarizeSettledCreates)([], [])).toEqual({ created: [], failed: [] });
49
- });
50
- });
51
- describe('summarizeSettledUpdates', () => {
52
- it('should report updated, failed, and skipped without stopping on failures', () => {
53
- const inputs = [{ id: 'id1' }, { id: 'id2' }, { id: 'id3' }];
54
- const summary = (0, update_1.summarizeSettledUpdates)(inputs, [
55
- fulfilled({ id: 'id1', status: 'archived' }),
56
- rejected('Entity not found.'),
57
- fulfilled({ id: 'id3', status: 'archived' }),
58
- ], 2);
59
- expect(summary.updated).toEqual([
60
- { id: 'id1', status: 'archived' },
61
- { id: 'id3', status: 'archived' },
62
- ]);
63
- expect(summary.failed).toEqual([{ id: 'id2', error: 'Entity not found.' }]);
64
- expect(summary.skipped).toBe(2);
65
- });
66
- it('should not report a failed id as updated', () => {
67
- const summary = (0, update_1.summarizeSettledUpdates)([{ id: 'id1' }], [rejected('boom')], 0);
68
- expect(summary.updated).toEqual([]);
69
- expect(summary.failed).toEqual([{ id: 'id1', error: 'boom' }]);
70
- });
71
- });
72
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const logger_1 = tslib_1.__importDefault(require("./logger"));
5
- describe('logger', () => {
6
- it('should write every log level to stderr so stdout carries only command output', () => {
7
- const consoleTransport = logger_1.default.transports[0];
8
- for (const level of ['error', 'warn', 'info', 'debug']) {
9
- expect(consoleTransport.stderrLevels[level]).toBe(true);
10
- }
11
- });
12
- });
@@ -1,34 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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;