@contrail/cli 3.6.0-alpha-8-alpha.694fd70 → 3.6.0-alpha.aae3e70

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 (163) hide show
  1. package/README.md +45 -151
  2. package/dist/api/feature-flags.d.ts +3 -0
  3. package/dist/api/feature-flags.js +29 -0
  4. package/dist/api/types.d.ts +0 -35
  5. package/dist/api/types.js +1 -49
  6. package/dist/api/users.d.ts +1 -0
  7. package/dist/api/users.js +10 -1
  8. package/dist/auth/login.d.ts +4 -0
  9. package/dist/auth/login.js +167 -93
  10. package/dist/auth/login.spec.js +305 -0
  11. package/dist/auth/sso.d.ts +36 -0
  12. package/dist/auth/sso.js +164 -0
  13. package/dist/auth/sso.spec.js +119 -0
  14. package/dist/basecommand.d.ts +1 -3
  15. package/dist/basecommand.js +2 -2
  16. package/dist/commands/app/getApiKey.js +2 -2
  17. package/dist/commands/config/set.js +1 -1
  18. package/dist/commands/feature-flags/export.d.ts +19 -0
  19. package/dist/commands/feature-flags/export.js +66 -0
  20. package/dist/commands/feature-flags/export.spec.js +109 -0
  21. package/dist/commands/feature-flags/import.d.ts +42 -0
  22. package/dist/commands/feature-flags/import.js +191 -0
  23. package/dist/commands/feature-flags/import.spec.js +194 -0
  24. package/dist/commands/instance/export.d.ts +9 -0
  25. package/dist/commands/instance/export.js +18 -3
  26. package/dist/commands/instance/export.spec.js +32 -0
  27. package/dist/commands/instance/import.d.ts +3 -0
  28. package/dist/commands/instance/import.js +5 -0
  29. package/dist/commands/instance/import.spec.js +4 -0
  30. package/dist/commands/login.d.ts +12 -0
  31. package/dist/commands/login.js +25 -0
  32. package/dist/common.d.ts +1 -3
  33. package/dist/common.js +1 -13
  34. package/dist/helpers/config/config.d.ts +5 -4
  35. package/dist/helpers/config/config.js +10 -12
  36. package/dist/helpers/file-helpers.d.ts +0 -1
  37. package/dist/helpers/file-helpers.js +1 -18
  38. package/dist/logger.js +1 -4
  39. package/node_modules/@contrail/entity-compare/package.json +3 -6
  40. package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
  41. package/node_modules/@contrail/loader/lib/constants.d.ts +8 -0
  42. package/node_modules/@contrail/loader/lib/constants.js +9 -1
  43. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +4 -0
  44. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +57 -0
  45. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +492 -34
  46. package/node_modules/@contrail/loader/lib/pipeline/validate.js +2 -52
  47. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +0 -85
  48. package/node_modules/@contrail/loader/package.json +2 -2
  49. package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +4 -1
  50. package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
  51. package/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -3
  52. package/node_modules/@contrail/sdk/lib/config/config.js +7 -13
  53. package/node_modules/@contrail/sdk/lib/core/request.js +2 -6
  54. package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -2
  55. package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -3
  56. package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -1
  57. package/node_modules/@contrail/sdk/package.json +1 -1
  58. package/oclif.manifest.json +75 -365
  59. package/package.json +15 -5
  60. package/dist/commands/entities/create.d.ts +0 -48
  61. package/dist/commands/entities/create.js +0 -639
  62. package/dist/commands/entities/create.spec.js +0 -541
  63. package/dist/commands/entities/delete.d.ts +0 -19
  64. package/dist/commands/entities/delete.js +0 -134
  65. package/dist/commands/entities/get.d.ts +0 -24
  66. package/dist/commands/entities/get.js +0 -273
  67. package/dist/commands/entities/grammar.spec.js +0 -80
  68. package/dist/commands/entities/output.spec.js +0 -72
  69. package/dist/commands/entities/update.d.ts +0 -31
  70. package/dist/commands/entities/update.js +0 -157
  71. package/dist/helpers/entities/assortment-items.d.ts +0 -10
  72. package/dist/helpers/entities/assortment-items.js +0 -84
  73. package/dist/helpers/entities/batchFetch.d.ts +0 -8
  74. package/dist/helpers/entities/batchFetch.js +0 -49
  75. package/dist/helpers/entities/index.d.ts +0 -3
  76. package/dist/helpers/entities/index.js +0 -6
  77. package/dist/helpers/entities/items.d.ts +0 -10
  78. package/dist/helpers/entities/items.js +0 -102
  79. package/dist/helpers/entities/project-items.d.ts +0 -3
  80. package/dist/helpers/entities/project-items.js +0 -65
  81. package/dist/helpers/propertySpecifications/dateRanges.d.ts +0 -38
  82. package/dist/helpers/propertySpecifications/dateRanges.js +0 -89
  83. package/dist/helpers/propertySpecifications/dateRanges.spec.js +0 -95
  84. package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -40
  85. package/dist/helpers/propertySpecifications/propertySpecifications.js +0 -109
  86. package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +0 -1
  87. package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +0 -373
  88. package/dist/logger.spec.d.ts +0 -1
  89. package/dist/logger.spec.js +0 -12
  90. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/pull_request_template.md +0 -31
  91. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/check-code-formatting.yml +0 -34
  92. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/empty.yml +0 -10
  93. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/generate-sdk-docs.yml +0 -32
  94. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +0 -117
  95. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/sdk-lib.yml +0 -27
  96. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.prettierrc.yaml +0 -2
  97. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/README.md +0 -72
  98. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/home-hero.svg +0 -11
  99. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.d.ts +0 -9
  100. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.js +0 -54
  101. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.d.ts +0 -1
  102. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.js +0 -17
  103. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.d.ts +0 -10
  104. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.js +0 -6
  105. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.d.ts +0 -2
  106. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.js +0 -18
  107. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.d.ts +0 -10
  108. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.js +0 -209
  109. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -48
  110. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.js +0 -42
  111. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.d.ts +0 -1
  112. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.js +0 -17
  113. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.d.ts +0 -12
  114. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.js +0 -70
  115. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.d.ts +0 -1
  116. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.js +0 -17
  117. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.d.ts +0 -1
  118. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.js +0 -17
  119. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.d.ts +0 -15
  120. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.js +0 -241
  121. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -101
  122. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.js +0 -306
  123. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.d.ts +0 -9
  124. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.js +0 -86
  125. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.d.ts +0 -6
  126. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.js +0 -19
  127. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.d.ts +0 -5
  128. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -59
  129. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.d.ts +0 -3
  130. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.js +0 -19
  131. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.d.ts +0 -3
  132. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.js +0 -24
  133. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.d.ts +0 -19
  134. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.js +0 -151
  135. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.d.ts +0 -1
  136. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.js +0 -17
  137. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +0 -10
  138. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +0 -26
  139. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.d.ts +0 -1
  140. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.js +0 -17
  141. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.d.ts +0 -16
  142. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.js +0 -37
  143. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.d.ts +0 -1
  144. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.js +0 -17
  145. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.d.ts +0 -12
  146. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.js +0 -55
  147. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.d.ts +0 -9
  148. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.js +0 -74
  149. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.d.ts +0 -2
  150. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.js +0 -18
  151. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.d.ts +0 -18
  152. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.js +0 -98
  153. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.d.ts +0 -19
  154. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.js +0 -73
  155. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.d.ts +0 -42
  156. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.js +0 -217
  157. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +0 -64
  158. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
  159. package/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
  160. /package/dist/{commands/entities/create.spec.d.ts → auth/sso.spec.d.ts} +0 -0
  161. /package/dist/commands/{entities/grammar.spec.d.ts → feature-flags/export.spec.d.ts} +0 -0
  162. /package/dist/commands/{entities/output.spec.d.ts → feature-flags/import.spec.d.ts} +0 -0
  163. /package/dist/{helpers/propertySpecifications/dateRanges.spec.d.ts → commands/instance/export.spec.d.ts} +0 -0
@@ -1,73 +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.TypesCache = void 0;
13
- const config_1 = require("../config");
14
- let LOCAL_CACHE = {};
15
- class TypesCache {
16
- constructor() { }
17
- getType(typeIdentifier, ctx) {
18
- return this.get(typeIdentifier, ctx);
19
- }
20
- setType(typeIdentifier, type, ctx) {
21
- this.setTypePropertyMap(type);
22
- return this.set(typeIdentifier, type, ctx);
23
- }
24
- setTypePropertyMap(type) {
25
- if (!type) {
26
- return;
27
- }
28
- for (const prop of type.typeProperties) {
29
- LOCAL_CACHE[this.getLocalCacheKey(type.id) + '_' + prop.slug] = prop;
30
- }
31
- }
32
- getProperty(params) {
33
- if (!params.typeId || !params.propertySlug) {
34
- return;
35
- }
36
- return LOCAL_CACHE[this.getLocalCacheKey(params.typeId) + '_' + params.propertySlug];
37
- }
38
- clearLocal() {
39
- LOCAL_CACHE = {};
40
- }
41
- getOrgSlug(ctx) {
42
- const config = (0, config_1.getConfig)();
43
- return (ctx === null || ctx === void 0 ? void 0 : ctx.orgSlug) || config.orgSlug;
44
- }
45
- getLocalCacheKey(typeIdentifier, ctx) {
46
- const orgSlug = this.getOrgSlug(ctx);
47
- const typeKey = `org:${orgSlug}|${typeIdentifier}`;
48
- return typeKey;
49
- }
50
- get(typeIdentifier, ctx) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- let type;
53
- const typeKey = this.getLocalCacheKey(typeIdentifier, ctx);
54
- type = LOCAL_CACHE[typeKey];
55
- return type;
56
- });
57
- }
58
- set(typeIdentifier, type, ctx) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- if (typeIdentifier) {
61
- LOCAL_CACHE[this.getLocalCacheKey(typeIdentifier, ctx)] = type;
62
- }
63
- if (type) {
64
- const typeId = type.id;
65
- const typePath = type.typePath;
66
- LOCAL_CACHE[this.getLocalCacheKey(typeId, ctx)] = type;
67
- LOCAL_CACHE[this.getLocalCacheKey(typePath, ctx)] = type;
68
- }
69
- return;
70
- });
71
- }
72
- }
73
- exports.TypesCache = TypesCache;
@@ -1,42 +0,0 @@
1
- import { Type, TypeProperty } from '@contrail/types';
2
- import { InvocationContext } from '../config';
3
- export declare const PATH_REQUIRED_FULL_PATH_ERROR = "Search type by path requires both root and path (e.g. path: \"color:color\")";
4
- export interface TypeClientOptions {
5
- root?: string;
6
- path?: string;
7
- id?: string;
8
- relations?: Array<string>;
9
- criteria?: {
10
- [key: string]: any;
11
- };
12
- includeArchivedTypeProperties?: boolean;
13
- ignoreTypePolicies?: boolean;
14
- }
15
- export declare class Types {
16
- private ctx;
17
- constructor(ctx?: InvocationContext);
18
- static clearTypeCache(): void;
19
- getByRootAndPath(options: TypeClientOptions): Promise<Type>;
20
- getType(options: TypeClientOptions): Promise<Type>;
21
- getAllReferencePropertiesByRootSlug(options: TypeClientOptions): Promise<any[]>;
22
- private requestReferenceProperties;
23
- private requestType;
24
- getProperty(typeId: any, propertySlug: any): Promise<TypeProperty>;
25
- }
26
- export interface AccessManagedType extends Type {
27
- canRead?: boolean;
28
- canCreate?: boolean;
29
- canUpdate?: boolean;
30
- canDelete?: boolean;
31
- restrictedTypePropertySlugs?: Array<string>;
32
- }
33
- export declare function populateTypePolicies(ctx: InvocationContext, type: Type): void;
34
- export interface AccessManagedTypeProperty extends TypeProperty {
35
- canRead?: boolean;
36
- canCreate?: boolean;
37
- canUpdate?: boolean;
38
- canDelete?: boolean;
39
- policiesSet?: Array<any>;
40
- typePropertyPolicyIds?: Array<any>;
41
- }
42
- export declare function populatePropertyPolicies(ctx: InvocationContext, type: Type): void;
@@ -1,217 +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
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.populatePropertyPolicies = exports.populateTypePolicies = exports.Types = exports.PATH_REQUIRED_FULL_PATH_ERROR = void 0;
14
- const request_1 = require("../core/request");
15
- const types_1 = require("@contrail/types");
16
- const types_cache_1 = require("./types-cache");
17
- const policies_1 = require("@contrail/policies");
18
- const policies_client_1 = require("../policies/policies.client");
19
- const config_1 = require("../config");
20
- const IS_JEST = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID;
21
- exports.PATH_REQUIRED_FULL_PATH_ERROR = 'Search type by path requires both root and path (e.g. path: "color:color")';
22
- const CACHE = new types_cache_1.TypesCache();
23
- const PROMISE_MAP = {};
24
- class Types {
25
- constructor(ctx) {
26
- this.ctx = ctx;
27
- }
28
- static clearTypeCache() {
29
- CACHE.clearLocal();
30
- }
31
- getByRootAndPath(options) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return this.getType(options);
34
- });
35
- }
36
- getType(options) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- let resource = '';
39
- if (!options.relations) {
40
- options.relations = ['typeProperties', 'typeInterfaces'];
41
- }
42
- if (!options.relations.includes('typeProperties')) {
43
- options.relations.push('typeProperties');
44
- }
45
- if (!options.relations.includes('typeInterfaces')) {
46
- options.relations.push('typeInterfaces');
47
- }
48
- let typeKey;
49
- if (options.id) {
50
- resource = `/types/${options.id}`;
51
- }
52
- else if (options.root && !options.path) {
53
- resource = `/types/roots/${options.root}/path/${options.root}`;
54
- }
55
- else if (options.path) {
56
- let root;
57
- const path = options.path;
58
- if (path.includes(':')) {
59
- const parts = options.path.split(':');
60
- root = parts[0];
61
- }
62
- else {
63
- root = path;
64
- }
65
- resource = `/types/roots/${root}/path/${path}`;
66
- }
67
- else {
68
- throw Error(`You must specify either an id, or path for a type.`);
69
- }
70
- resource += '?cacheMode=USE&';
71
- if (options.relations) {
72
- resource += `relations=${options.relations.join(',')}&`;
73
- }
74
- if (options.includeArchivedTypeProperties) {
75
- resource += `includeArchivedTypeProperties=true&`;
76
- }
77
- if (options.ignoreTypePolicies) {
78
- resource += `ignoreTypePolicies=true&`;
79
- }
80
- typeKey = resource;
81
- let type;
82
- if (!IS_JEST) {
83
- type = yield CACHE.getType(typeKey, this.ctx);
84
- }
85
- if (type) {
86
- return Promise.resolve(type);
87
- }
88
- const existingPromise = PROMISE_MAP[typeKey];
89
- if (existingPromise) {
90
- return existingPromise;
91
- }
92
- const promise = this.requestType(resource, typeKey, { ignoreTypePolicies: Boolean(options.ignoreTypePolicies) });
93
- PROMISE_MAP[typeKey] = promise;
94
- return yield promise;
95
- });
96
- }
97
- getAllReferencePropertiesByRootSlug(options) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- let resource = '';
100
- let referencePropertiesKey;
101
- if (options.root) {
102
- resource = `/types/roots/${options.root}/referenceProperties`;
103
- }
104
- else {
105
- throw Error(`You must specify a root for a type.`);
106
- }
107
- resource += '?cacheMode=USE&';
108
- referencePropertiesKey = resource;
109
- let referenceProperties;
110
- if (!IS_JEST) {
111
- referenceProperties = yield CACHE.getType(referencePropertiesKey, this.ctx);
112
- }
113
- if (referenceProperties) {
114
- return Promise.resolve(referenceProperties);
115
- }
116
- const existingPromise = PROMISE_MAP[referencePropertiesKey];
117
- if (existingPromise) {
118
- return existingPromise;
119
- }
120
- const promise = this.requestReferenceProperties(resource, referencePropertiesKey);
121
- PROMISE_MAP[referencePropertiesKey] = promise;
122
- return promise;
123
- });
124
- }
125
- requestReferenceProperties(resource, key) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const objectReferences = yield request_1.Request.request(resource, { method: 'GET' }, this.ctx);
128
- delete PROMISE_MAP[key];
129
- return objectReferences;
130
- });
131
- }
132
- requestType(resource, typeKey, options) {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- const type = (yield request_1.Request.request(resource, { method: 'GET' }, this.ctx));
135
- const shouldApplyPolicies = Boolean(!(options === null || options === void 0 ? void 0 : options.ignoreTypePolicies));
136
- if (shouldApplyPolicies) {
137
- populatePropertyPolicies(this.ctx, type);
138
- populateTypePolicies(this.ctx, type);
139
- }
140
- CACHE.setType(resource, type, this.ctx);
141
- delete PROMISE_MAP[typeKey];
142
- return type;
143
- });
144
- }
145
- getProperty(typeId, propertySlug) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- const type = yield this.getType({ id: typeId });
148
- return CACHE.getProperty({ typeId, propertySlug });
149
- });
150
- }
151
- }
152
- exports.Types = Types;
153
- function populateTypePolicies(ctx, type) {
154
- var _a;
155
- const accessControlledType = type;
156
- const userCtx = ctx || (0, config_1.getGlobalContext)();
157
- const policies = (_a = type.typePolicies) === null || _a === void 0 ? void 0 : _a.map((tp) => tp.policy);
158
- if (policies === null || policies === void 0 ? void 0 : policies.length) {
159
- const allowed = (0, policies_1.getPermissionsOnResource)((0, policies_client_1.getPrincipalReferences)(userCtx), policies, '*');
160
- accessControlledType.canRead = allowed.includes(policies_1.Operation.read);
161
- accessControlledType.canUpdate = allowed.includes(policies_1.Operation.update);
162
- accessControlledType.canDelete = allowed.includes(policies_1.Operation.delete);
163
- accessControlledType.canCreate = allowed.includes(policies_1.Operation.create);
164
- }
165
- else {
166
- accessControlledType.canRead = true;
167
- accessControlledType.canUpdate = true;
168
- accessControlledType.canDelete = true;
169
- accessControlledType.canCreate = true;
170
- }
171
- }
172
- exports.populateTypePolicies = populateTypePolicies;
173
- function populatePropertyPolicies(ctx, type) {
174
- var _a;
175
- const typeProperties = type.typeProperties;
176
- const policies = type.typePropertyPolicies;
177
- const userCtx = ctx || (0, config_1.getGlobalContext)();
178
- if (!(policies === null || policies === void 0 ? void 0 : policies.length)) {
179
- return;
180
- }
181
- const validTypeProperties = [];
182
- const restrictedTypePropertySlugs = [];
183
- for (const property of typeProperties) {
184
- if (property.policiesSet) {
185
- return;
186
- }
187
- if (((_a = property === null || property === void 0 ? void 0 : property.typePropertyPolicyIds) === null || _a === void 0 ? void 0 : _a.length) > 0) {
188
- const thisPropertyPolicies = policies
189
- .filter((x) => property.typePropertyPolicyIds.includes(x.id))
190
- .map((x) => x.policy);
191
- const allowed = (0, policies_1.getPermissionsOnResource)((0, policies_client_1.getPrincipalReferences)(userCtx), thisPropertyPolicies, '*');
192
- property.canRead = allowed.includes(policies_1.Operation.read);
193
- property.canUpdate = allowed.includes(policies_1.Operation.update);
194
- property.canDelete = allowed.includes(policies_1.Operation.delete);
195
- property.canCreate = allowed.includes(policies_1.Operation.create);
196
- }
197
- else {
198
- property.canRead = true;
199
- property.canUpdate = true;
200
- property.canDelete = true;
201
- property.canCreate = true;
202
- }
203
- if (property.canRead !== false) {
204
- validTypeProperties.push(property);
205
- }
206
- else {
207
- restrictedTypePropertySlugs.push(property.slug);
208
- if ((0, types_1.isReferencePropertyType)(property.propertyType)) {
209
- restrictedTypePropertySlugs.push(`${property.slug}Id`);
210
- }
211
- }
212
- }
213
- const accessControlledType = type;
214
- accessControlledType.typeProperties = validTypeProperties;
215
- accessControlledType.restrictedTypePropertySlugs = restrictedTypePropertySlugs;
216
- }
217
- exports.populatePropertyPolicies = populatePropertyPolicies;
@@ -1,64 +0,0 @@
1
- {
2
- "name": "@contrail/sdk",
3
- "version": "1.5.18",
4
- "description": "Client library for interfacing with contrail services.",
5
- "homepage": "https://archergreysorg.github.io/contrail-lib/",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "main": "lib/index.js",
10
- "types": "lib/index.d.ts",
11
- "scripts": {
12
- "build": "tsc",
13
- "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\" \"src/**/*.json\" \"src/**/*.yml\"",
14
- "lint": "tslint -p tsconfig.json",
15
- "generate-docs": "npx typedoc src/index.ts --disableSources --excludeInternal --plugin typedoc-plugin-extras --favicon home-hero.svg",
16
- "test": "jest",
17
- "prepare": "husky install",
18
- "lint-staged:check": "lint-staged --config .lintstagedrc-check.json",
19
- "lint-staged:format": "lint-staged --allow-empty --config .lintstagedrc-format.json"
20
- },
21
- "keywords": [],
22
- "author": "",
23
- "license": "ISC",
24
- "dependencies": {
25
- "@contrail/entity-types": "^1.1.50-2",
26
- "@contrail/policies": "^2.0.5",
27
- "@contrail/types": "^3.0.84",
28
- "@contrail/util": "^1.0.19",
29
- "amazon-cognito-identity-js": "^5.2.8",
30
- "es6-promisify": "^6.1.1",
31
- "form-data": "^4.0.0",
32
- "jsurl": "^0.1.5",
33
- "node-fetch": "^2.6.0",
34
- "p-limit": "^3.0.0"
35
- },
36
- "devDependencies": {
37
- "@types/jest": "^29.5.2",
38
- "@types/node": "^14.10.1",
39
- "jest": "^29.5.0",
40
- "prettier": "^3.2.5",
41
- "ts-jest": "^29.1.1",
42
- "tslint": "^5.11.0",
43
- "tslint-config-prettier": "^1.18.0",
44
- "typedoc": "^0.25.7",
45
- "typedoc-plugin-extras": "^3.0.0",
46
- "typescript": "^4.0.0",
47
- "husky": "^9.0.11",
48
- "lint-staged": "^15.2.5"
49
- },
50
- "jest": {
51
- "moduleFileExtensions": [
52
- "js",
53
- "json",
54
- "ts"
55
- ],
56
- "rootDir": "src",
57
- "testRegex": ".spec.ts$",
58
- "transform": {
59
- "^.+\\.(t|j)s$": "ts-jest"
60
- },
61
- "coverageDirectory": "../coverage",
62
- "testEnvironment": "node"
63
- }
64
- }
@@ -1,69 +0,0 @@
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);
@@ -1,69 +0,0 @@
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);