@contrail/cli 3.6.0-alpha-8-alpha.2ab4f80 → 3.6.0-alpha.693d785

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 +169 -94
  10. package/dist/auth/login.spec.js +305 -0
  11. package/dist/auth/sso.d.ts +36 -0
  12. package/dist/auth/sso.js +168 -0
  13. package/dist/auth/sso.spec.js +138 -0
  14. package/dist/basecommand.d.ts +1 -3
  15. package/dist/basecommand.js +4 -4
  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 -4
  33. package/dist/common.js +1 -18
  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 +3 -20
  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 -49
  61. package/dist/commands/entities/create.js +0 -643
  62. package/dist/commands/entities/create.spec.js +0 -545
  63. package/dist/commands/entities/delete.d.ts +0 -20
  64. package/dist/commands/entities/delete.js +0 -137
  65. package/dist/commands/entities/get.d.ts +0 -25
  66. package/dist/commands/entities/get.js +0 -276
  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 -32
  70. package/dist/commands/entities/update.js +0 -160
  71. package/dist/helpers/entities/assortment-items.d.ts +0 -12
  72. package/dist/helpers/entities/assortment-items.js +0 -87
  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,306 +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.Entities = exports.EntitiesClientBatchDeleteOptions = exports.EntitiesClientDeleteOptions = exports.EntitiesClientBatchUpdateOptions = exports.EntitiesClientBatchCreateOptions = exports.EntitiesClientCreateOptions = exports.EntitiesClientGetOptions = exports.DEFAULT_API_VERSION = exports.API_VERSION = exports.SortOrderOptions = void 0;
13
- const request_1 = require("../core/request");
14
- const entity_reference_1 = require("./entity-reference");
15
- const entity_reference_expander_1 = require("./entity-reference-expander");
16
- const entity_resource_registry_1 = require("./entity.resource.registry");
17
- let JSURL = require('jsurl');
18
- var SortOrderOptions;
19
- (function (SortOrderOptions) {
20
- SortOrderOptions["ASC"] = "asc";
21
- SortOrderOptions["DESC"] = "desc";
22
- })(SortOrderOptions = exports.SortOrderOptions || (exports.SortOrderOptions = {}));
23
- var API_VERSION;
24
- (function (API_VERSION) {
25
- API_VERSION["EMPTY"] = "";
26
- API_VERSION["V1"] = "1";
27
- API_VERSION["V2"] = "2";
28
- })(API_VERSION = exports.API_VERSION || (exports.API_VERSION = {}));
29
- exports.DEFAULT_API_VERSION = API_VERSION.EMPTY;
30
- class EntitiesClientGetOptions {
31
- }
32
- exports.EntitiesClientGetOptions = EntitiesClientGetOptions;
33
- class EntitiesClientCreateOptions {
34
- }
35
- exports.EntitiesClientCreateOptions = EntitiesClientCreateOptions;
36
- class EntitiesClientBatchCreateOptions {
37
- }
38
- exports.EntitiesClientBatchCreateOptions = EntitiesClientBatchCreateOptions;
39
- class EntitiesClientUpdateOptions {
40
- }
41
- class EntitiesClientBatchUpdateOptions {
42
- }
43
- exports.EntitiesClientBatchUpdateOptions = EntitiesClientBatchUpdateOptions;
44
- class EntitiesClientDeleteOptions {
45
- }
46
- exports.EntitiesClientDeleteOptions = EntitiesClientDeleteOptions;
47
- class EntitiesClientBatchDeleteOptions {
48
- }
49
- exports.EntitiesClientBatchDeleteOptions = EntitiesClientBatchDeleteOptions;
50
- class Entities {
51
- constructor(ctx, apiVersion = exports.DEFAULT_API_VERSION) {
52
- this.ctx = ctx;
53
- this.apiVersion = apiVersion;
54
- }
55
- getAllReferences(references, relations) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- return entity_reference_expander_1.EntityReferenceExpander.expandEntityReferences(this, references, relations);
58
- });
59
- }
60
- get(options) {
61
- var _a;
62
- return __awaiter(this, void 0, void 0, function* () {
63
- if (options.reference) {
64
- const ref = new entity_reference_1.EntityReference(options.reference);
65
- options.entityName = ref.entityType;
66
- options.id = ref.id;
67
- }
68
- if (!options.entityName) {
69
- throw Error('Missing entityName or valid reference.');
70
- }
71
- let resource = `/${entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName)}`;
72
- if (options.id) {
73
- resource += '/' + options.id;
74
- }
75
- else if (options.federatedId) {
76
- resource += '/federated/' + options.federatedId;
77
- }
78
- else if (options.federatedIds) {
79
- resource += '/federated/batch';
80
- }
81
- if (options.suffix) {
82
- resource += '/' + options.suffix;
83
- }
84
- else if (options.relation) {
85
- resource += '/' + options.relation;
86
- }
87
- const objectKeys = Object.keys(options);
88
- if (options.relations ||
89
- options.federatedIds ||
90
- options.criteria ||
91
- options.cacheMode ||
92
- options.skip ||
93
- options.search ||
94
- objectKeys.includes('useSearch') ||
95
- objectKeys.includes('paginate') ||
96
- options.order ||
97
- options.nextPageKey ||
98
- objectKeys.includes('skipHydrateRelationships') ||
99
- options.take ||
100
- options.customParams) {
101
- resource += '?';
102
- }
103
- if (options.relations) {
104
- resource += `relations=${options.relations.join(',')}&`;
105
- }
106
- if (options.cacheMode) {
107
- resource += `cacheMode=${options.cacheMode}&`;
108
- }
109
- if (options.search) {
110
- resource += `search=${options.search}&`;
111
- }
112
- if (objectKeys.includes('useSearch')) {
113
- resource += `useSearch=${options.useSearch}&`;
114
- }
115
- if (options.order) {
116
- resource += `order=${JSURL.stringify(options.order)}&`;
117
- }
118
- if (options.skip) {
119
- resource += `skip=${options.skip}&`;
120
- }
121
- if (objectKeys.includes('paginate')) {
122
- resource += `paginate=${options.paginate}&`;
123
- }
124
- if (options.take) {
125
- resource += `take=${options.take}&`;
126
- }
127
- if (options.nextPageKey) {
128
- resource += `nextPageKey=${options.nextPageKey}&`;
129
- }
130
- if (objectKeys.includes('skipHydrateRelationships')) {
131
- resource += `skipHydrateRelationships=${options.skipHydrateRelationships}&`;
132
- }
133
- if (options.federatedIds) {
134
- resource += `ids=${options.federatedIds.map((id) => encodeURIComponent(id.replace(/,/g, '_COMMA_'))).join(',')}&`;
135
- }
136
- if (options.criteria) {
137
- resource += 'criteria=' + JSURL.stringify(options.criteria) + '&';
138
- }
139
- if (options.customParams) {
140
- const buildQueryParam = (key, value) => {
141
- if (value === undefined || value === null) {
142
- return '';
143
- }
144
- if (typeof value === 'object') {
145
- throw Error('customParams must be string, number, or boolean.');
146
- }
147
- return `${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`;
148
- };
149
- const combinedCustomParamsString = Object.entries(options.customParams)
150
- .filter(([_key, value]) => value !== undefined && value !== null)
151
- .map(([key, value]) => buildQueryParam(key, value))
152
- .join('&');
153
- resource += combinedCustomParamsString;
154
- }
155
- return yield request_1.Request.request(resource, {
156
- headers: Object.assign({}, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
157
- }, this.ctx);
158
- });
159
- }
160
- create(options) {
161
- var _a;
162
- return __awaiter(this, void 0, void 0, function* () {
163
- let resource = '/' + entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName);
164
- if (options.relation && options.id) {
165
- resource += `/${options.id}/${options.relation}`;
166
- }
167
- else if (options.relation) {
168
- resource += `/${options.relation}`;
169
- }
170
- if (options.suffix) {
171
- resource += '/' + options.suffix;
172
- }
173
- if (options.skipHydrateRelationships) {
174
- resource += '?skipHydrateRelationships=true';
175
- }
176
- return yield request_1.Request.request(resource, {
177
- method: 'POST',
178
- body: JSON.stringify(options.object),
179
- headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
180
- }, this.ctx);
181
- });
182
- }
183
- batchCreate(options) {
184
- var _a;
185
- return __awaiter(this, void 0, void 0, function* () {
186
- let resource = `/${entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName)}/batch`;
187
- if (options.suffix) {
188
- resource += '/' + options.suffix;
189
- }
190
- return yield request_1.Request.request(resource, {
191
- method: 'POST',
192
- body: JSON.stringify(options.objects),
193
- headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
194
- }, this.ctx);
195
- });
196
- }
197
- update(options) {
198
- var _a;
199
- return __awaiter(this, void 0, void 0, function* () {
200
- if (options.reference) {
201
- const ref = new entity_reference_1.EntityReference(options.reference);
202
- options.entityName = ref.entityType;
203
- options.id = ref.id;
204
- }
205
- if (!options.id) {
206
- throw Error(`Must specify id in update.`);
207
- }
208
- if (!options.entityName) {
209
- throw Error('Missing entityName or valid reference.');
210
- }
211
- let resource = `/${entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName)}/${options.id}`;
212
- if (options.relation) {
213
- if (!options.relationId) {
214
- throw Error(`Must specify a relation id when updating a relation.`);
215
- }
216
- resource += `/${options.relation}/${options.relationId}`;
217
- }
218
- if (options.suffix) {
219
- resource += '/' + options.suffix;
220
- }
221
- if (options.skipHydrateRelationships) {
222
- resource += '?skipHydrateRelationships=true';
223
- }
224
- return yield request_1.Request.request(resource, {
225
- method: 'PUT',
226
- body: JSON.stringify(options.object),
227
- headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
228
- }, this.ctx);
229
- });
230
- }
231
- batchUpdate(options) {
232
- var _a;
233
- return __awaiter(this, void 0, void 0, function* () {
234
- let resource = `/${entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName)}/batch`;
235
- if (options.suffix) {
236
- resource += '/' + options.suffix;
237
- }
238
- return yield request_1.Request.request(resource, {
239
- method: 'PUT',
240
- body: JSON.stringify(options.objects),
241
- headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
242
- }, this.ctx);
243
- });
244
- }
245
- delete(options) {
246
- var _a;
247
- return __awaiter(this, void 0, void 0, function* () {
248
- if (options.reference) {
249
- const ref = new entity_reference_1.EntityReference(options.reference);
250
- options.entityName = ref.entityType;
251
- options.id = ref.id;
252
- }
253
- if (!options.id) {
254
- throw Error(`Must specify id in delete.`);
255
- }
256
- if (!options.entityName) {
257
- throw Error('Missing entityName or valid reference.');
258
- }
259
- let resource = `/${entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName)}/${options.id}`;
260
- if (options.relation) {
261
- if (!options.relationId) {
262
- throw Error(`Must specify a relation id when deleting a relation.`);
263
- }
264
- resource += `/${options.relation}/${options.relationId}`;
265
- }
266
- if (options.suffix) {
267
- resource += '/' + options.suffix;
268
- }
269
- return yield request_1.Request.request(resource, {
270
- method: 'DELETE',
271
- headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
272
- }, this.ctx);
273
- });
274
- }
275
- batchDelete(options) {
276
- var _a;
277
- return __awaiter(this, void 0, void 0, function* () {
278
- if (!options.ids) {
279
- throw Error(`Must specify ids in batch delete.`);
280
- }
281
- if (!options.entityName) {
282
- throw Error('Missing entityName');
283
- }
284
- let resource = `/${entity_resource_registry_1.EntityResourceRegistry.getEntityResourceName(options.entityName)}/batch`;
285
- if (options.suffix) {
286
- resource += '/' + options.suffix;
287
- }
288
- return yield request_1.Request.request(resource, {
289
- method: 'DELETE',
290
- body: JSON.stringify({ ids: options.ids }),
291
- headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, getVersionHeader((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion)),
292
- }, this.ctx);
293
- });
294
- }
295
- }
296
- exports.Entities = Entities;
297
- function getVersionHeader(version) {
298
- if (version === API_VERSION.EMPTY) {
299
- return {};
300
- }
301
- else {
302
- return {
303
- 'Api-Version': version,
304
- };
305
- }
306
- }
@@ -1,9 +0,0 @@
1
- import { Entities } from './entities.client';
2
- import { EntityReference } from './entity-reference';
3
- export declare class EntityReferenceExpander {
4
- static expandEntityReferences(entitiesClient: Entities, references: Array<EntityReference>, relations: Array<string>): Promise<Map<string, any>>;
5
- static getEntityTypeMap(references: Array<EntityReference>): Map<any, any>;
6
- private static getEntitiesFromReferences;
7
- static createEntityMapFromTypeBasedResults(typeBasedResults: Map<string, Array<any>>): Map<string, any>;
8
- static splitIntoChunksByLen(arr: any, len: any): any[];
9
- }
@@ -1,86 +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.EntityReferenceExpander = void 0;
13
- const pLimit = require('p-limit');
14
- const limit = pLimit(30);
15
- class EntityReferenceExpander {
16
- static expandEntityReferences(entitiesClient, references, relations) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const entityTypeMap = this.getEntityTypeMap(references);
19
- const typeBasedResults = new Map();
20
- for (const entityType of entityTypeMap.keys()) {
21
- const results = yield this.getEntitiesFromReferences(entitiesClient, entityType, Array.from(entityTypeMap.get(entityType)), relations);
22
- typeBasedResults.set(entityType, results);
23
- }
24
- return this.createEntityMapFromTypeBasedResults(typeBasedResults);
25
- });
26
- }
27
- static getEntityTypeMap(references) {
28
- return references.reduce((map, ref) => {
29
- const set = map.get(ref.entityType) || new Set();
30
- set.add(ref.id);
31
- map.set(ref.entityType, set);
32
- return map;
33
- }, new Map());
34
- }
35
- static getEntitiesFromReferences(entitiesClient, entityType, ids, relations = []) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const chunks = this.splitIntoChunksByLen(ids, 200);
38
- const entities = [];
39
- const promises = [];
40
- for (const chunk of chunks) {
41
- const itemPromise = limit(() => __awaiter(this, void 0, void 0, function* () {
42
- try {
43
- const chunkOfEntities = yield entitiesClient.get({
44
- entityName: entityType,
45
- criteria: { ids: chunk },
46
- relations,
47
- });
48
- if (!chunkOfEntities) {
49
- throw new Error('No entities were returned.');
50
- }
51
- entities.push(...chunkOfEntities);
52
- }
53
- catch (e) {
54
- console.log('Failed to get entities', e);
55
- throw new Error(`'Failed to get entities: ${e}`);
56
- }
57
- }));
58
- promises.push(itemPromise);
59
- }
60
- yield Promise.all(promises);
61
- return entities;
62
- });
63
- }
64
- static createEntityMapFromTypeBasedResults(typeBasedResults) {
65
- const entityMap = new Map();
66
- for (const entityType of typeBasedResults.keys()) {
67
- const entities = typeBasedResults.get(entityType);
68
- entities === null || entities === void 0 ? void 0 : entities.forEach((entity) => {
69
- if (entity) {
70
- const ref = entityType + ':' + entity.id;
71
- entityMap.set(ref, entity);
72
- }
73
- });
74
- }
75
- return entityMap;
76
- }
77
- static splitIntoChunksByLen(arr, len) {
78
- const chunks = [], n = arr === null || arr === void 0 ? void 0 : arr.length;
79
- let i = 0;
80
- while (i < n) {
81
- chunks.push(arr.slice(i, (i += len)));
82
- }
83
- return chunks;
84
- }
85
- }
86
- exports.EntityReferenceExpander = EntityReferenceExpander;
@@ -1,6 +0,0 @@
1
- export declare class EntityReference {
2
- id: string;
3
- entityType: string;
4
- reference: string;
5
- constructor(reference: string);
6
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityReference = void 0;
4
- class EntityReference {
5
- constructor(reference) {
6
- this.reference = reference;
7
- if (!this.reference) {
8
- throw Error('Illegal reference string: ' + reference);
9
- }
10
- const parts = reference.split(':');
11
- if (parts.length < 2) {
12
- throw Error('Illegal reference string: ' + reference);
13
- }
14
- this.entityType = parts[0];
15
- parts.splice(0, 1);
16
- this.id = parts.join(':');
17
- }
18
- }
19
- exports.EntityReference = EntityReference;
@@ -1,5 +0,0 @@
1
- export declare class EntityResourceRegistry {
2
- private static entityRegister;
3
- static registerEntityResourceName(entityName: string, resourceName: string): void;
4
- static getEntityResourceName(entityName: string): string;
5
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityResourceRegistry = void 0;
4
- class EntityResourceRegistry {
5
- static registerEntityResourceName(entityName, resourceName) {
6
- this.entityRegister.set(entityName, resourceName);
7
- }
8
- static getEntityResourceName(entityName) {
9
- const resourceName = this.entityRegister.get(entityName) || `${entityName}s`;
10
- return resourceName;
11
- }
12
- }
13
- exports.EntityResourceRegistry = EntityResourceRegistry;
14
- EntityResourceRegistry.entityRegister = new Map();
15
- EntityResourceRegistry.registerEntityResourceName('access', 'access');
16
- EntityResourceRegistry.registerEntityResourceName('user-access', 'user-access');
17
- EntityResourceRegistry.registerEntityResourceName('user-last-access', 'user-last-access');
18
- EntityResourceRegistry.registerEntityResourceName('action-function-manager', 'action-function-manager');
19
- EntityResourceRegistry.registerEntityResourceName('babylon', 'babylon');
20
- EntityResourceRegistry.registerEntityResourceName('content', 'content');
21
- EntityResourceRegistry.registerEntityResourceName('content-holder-content', 'content-holder-content');
22
- EntityResourceRegistry.registerEntityResourceName('jwk', 'jwk');
23
- EntityResourceRegistry.registerEntityResourceName('auth', 'auth');
24
- EntityResourceRegistry.registerEntityResourceName('search', 'open-search');
25
- EntityResourceRegistry.registerEntityResourceName('type-property', 'type-properties');
26
- EntityResourceRegistry.registerEntityResourceName('policy', 'policies');
27
- EntityResourceRegistry.registerEntityResourceName('plan-summary', 'plan-summaries');
28
- EntityResourceRegistry.registerEntityResourceName('event-workflow-process', 'event-workflow-processes');
29
- EntityResourceRegistry.registerEntityResourceName('email', 'email');
30
- EntityResourceRegistry.registerEntityResourceName('external-event-callback', 'external-events/callback');
31
- EntityResourceRegistry.registerEntityResourceName('event-workflow-request-synchronous', 'event-workflow-requests/synchronous');
32
- EntityResourceRegistry.registerEntityResourceName('loader-process', 'loader-processes');
33
- EntityResourceRegistry.registerEntityResourceName('change-history', 'change-history');
34
- EntityResourceRegistry.registerEntityResourceName('chaos-monkey', 'chaos-monkey');
35
- EntityResourceRegistry.registerEntityResourceName('scheduler', 'scheduler');
36
- EntityResourceRegistry.registerEntityResourceName('scheduled-event', 'scheduler');
37
- EntityResourceRegistry.registerEntityResourceName('ghostscript', 'ghostscript');
38
- EntityResourceRegistry.registerEntityResourceName('imagemagick', 'imagemagick');
39
- EntityResourceRegistry.registerEntityResourceName('assortment-summary', 'assortment-summaries');
40
- EntityResourceRegistry.registerEntityResourceName('composite-plans-summary', 'composite-plans-summaries');
41
- EntityResourceRegistry.registerEntityResourceName('type-property-policy', 'type-property-policies');
42
- EntityResourceRegistry.registerEntityResourceName('type-policy', 'type-policies');
43
- EntityResourceRegistry.registerEntityResourceName('type-property-usage-info', 'type-property-usage-info');
44
- EntityResourceRegistry.registerEntityResourceName('type-override', 'type-overrides');
45
- EntityResourceRegistry.registerEntityResourceName('type-override-copy', 'type-overrides/copy');
46
- EntityResourceRegistry.registerEntityResourceName('option-set-hierarchy', 'option-set-hierarchies');
47
- EntityResourceRegistry.registerEntityResourceName('workspace-entity', 'workspace-entities');
48
- EntityResourceRegistry.registerEntityResourceName('custom-entity', 'custom-entities');
49
- EntityResourceRegistry.registerEntityResourceName('content-holder-content', 'content-holder-content');
50
- EntityResourceRegistry.registerEntityResourceName('service-manager', 'service-manager');
51
- EntityResourceRegistry.registerEntityResourceName('feature-branch', 'feature-branches');
52
- EntityResourceRegistry.registerEntityResourceName('sso-config', 'sso-config');
53
- EntityResourceRegistry.registerEntityResourceName('trash', 'trash');
54
- EntityResourceRegistry.registerEntityResourceName('open-search', 'open-search');
55
- EntityResourceRegistry.registerEntityResourceName('project-configurator', 'project-configurator');
56
- EntityResourceRegistry.registerEntityResourceName('identity', 'identities');
57
- EntityResourceRegistry.registerEntityResourceName('entity-policy', 'entity-policies');
58
- EntityResourceRegistry.registerEntityResourceName('measurement-spec-entry', 'measurement-spec-entries');
59
- EntityResourceRegistry.registerEntityResourceName('image-search', 'image-search');
@@ -1,3 +0,0 @@
1
- export * from './entities.client';
2
- export * from './entity.resource.registry';
3
- export * from './entity-reference';
@@ -1,19 +0,0 @@
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("./entities.client"), exports);
18
- __exportStar(require("./entity.resource.registry"), exports);
19
- __exportStar(require("./entity-reference"), exports);
@@ -1,3 +0,0 @@
1
- export declare class FileTypeHelper {
2
- static getContentType(file: any): any;
3
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileTypeHelper = void 0;
4
- class FileTypeHelper {
5
- static getContentType(file) {
6
- var _a, _b, _c, _d;
7
- if (!file) {
8
- return null;
9
- }
10
- if (file.type) {
11
- return file.type;
12
- }
13
- if (((_a = file.name) === null || _a === void 0 ? void 0 : _a.indexOf('.glb')) > -1) {
14
- return 'model/gltf-binary';
15
- }
16
- else if (((_b = file.name) === null || _b === void 0 ? void 0 : _b.indexOf('.gltf')) > -1) {
17
- return 'model/gltf+json';
18
- }
19
- else if (((_c = file.name) === null || _c === void 0 ? void 0 : _c.endsWith('.psd')) || ((_d = file.name) === null || _d === void 0 ? void 0 : _d.endsWith('.psb'))) {
20
- return 'image/vnd.adobe.photoshop';
21
- }
22
- }
23
- }
24
- exports.FileTypeHelper = FileTypeHelper;
@@ -1,19 +0,0 @@
1
- /// <reference types="node" />
2
- export declare class Files {
3
- private ctx;
4
- constructor(ctx?: any);
5
- createAndUploadFile(file: File, ownedByReference?: string, ttl?: number): Promise<any>;
6
- createAndUploadFileFromBuffer(buffer: Buffer, contentType: string, fileName: string, ownedByReference?: string, ttl?: number): Promise<any>;
7
- uploadFile(uploadPost: {
8
- url: string;
9
- fields: Record<string, string>;
10
- }, file: File): Promise<void>;
11
- uploadFileAsStream(uploadPost: {
12
- url: string;
13
- fields: Record<string, string>;
14
- }, buffer: Buffer | File, options?: {
15
- contentType?: string;
16
- }): Promise<void>;
17
- private withRetry;
18
- private appendUploadHeaders;
19
- }