@contrail/cli 1.0.62 → 1.0.63

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.
@@ -152,10 +152,10 @@ async function getFolderPrincipals(folder) {
152
152
  });
153
153
  for (const workspacePrincipal of workspacePrincipals) {
154
154
  if (workspacePrincipal.principal.email) {
155
- principals.push(workspacePrincipal.principal.email);
155
+ principals.push(workspacePrincipal.principal.email + '|' + workspacePrincipal.role);
156
156
  }
157
157
  else {
158
- principals.push(workspacePrincipal.principal.name);
158
+ principals.push(workspacePrincipal.principal.name + '|' + workspacePrincipal.role);
159
159
  }
160
160
  }
161
161
  return principals;
@@ -8,20 +8,49 @@ export interface DataHolder {
8
8
  typePropertyPolicies: any[];
9
9
  typePropertyPolicyLinks: any[];
10
10
  }
11
- export interface ReducedDataHolder {
12
- reducedTypes: any[];
13
- reducedOptionSets: any[];
14
- reducedOptionSetHierarchies: any[];
15
- reducedRuleSets: any[];
16
- reducedRuleSetLinks: any[];
17
- reducedUsageInfo: any[];
18
- reducedTypePropertyPolicies: any[];
19
- reducedTypePropertyPolicyLinks: any[];
20
- }
21
11
  export declare function getAll(args: any): Promise<void>;
22
12
  /**
23
13
  * stores reduced option sets and returns full option sets */
24
14
  export declare function getOptionSets(): Promise<any>;
25
15
  export declare function getTypes(): Promise<any[]>;
26
16
  export declare function reduceTypes(dataHolder: DataHolder): any[];
27
- export declare function reduceData(data: DataHolder): ReducedDataHolder;
17
+ export declare function reduceData(data: DataHolder): {
18
+ reducedTypes: any[];
19
+ reducedOptionSets: {
20
+ name: any;
21
+ isArchived: any;
22
+ optionSet: any;
23
+ }[];
24
+ reducedOptionSetHierarchies: {
25
+ hierarchy: any;
26
+ options: any;
27
+ name: any;
28
+ }[];
29
+ reducedRuleSets: {
30
+ ruleSet: any;
31
+ name: any;
32
+ }[];
33
+ reducedRuleSetLinks: any[];
34
+ reducedUsageInfo: {
35
+ used: any;
36
+ editable: any;
37
+ formulaFunction: any;
38
+ validationFunction: any;
39
+ numberFormat: any;
40
+ defaultValue: any;
41
+ label: any;
42
+ typeSlug: any;
43
+ typePropertySlug: any;
44
+ }[];
45
+ reducedTypePropertyPolicies: {
46
+ label: any;
47
+ policy: {
48
+ version: any;
49
+ statements: any;
50
+ };
51
+ }[];
52
+ reducedTypePropertyPolicyLinks: {
53
+ typePropertySlug: any;
54
+ typePropertyPolicyLabel: any;
55
+ }[];
56
+ };
@@ -247,38 +247,9 @@ export function reduceData(data) {
247
247
  reducedTypePropertyPolicyLinks: reduceTypePropertyPolicyLinks(data),
248
248
  };
249
249
  }
250
- const saveTypesFunction = function (data, dir) {
251
- const roots = {};
252
- for (const type of data.reducedTypes) {
253
- const typePathParts = type.typePath.split(':');
254
- if (!typePathParts) {
255
- console.warn('skipping bad type with no path', type);
256
- }
257
- const root = typePathParts[0];
258
- if (roots[root]) {
259
- roots[root].push(type);
260
- }
261
- else {
262
- roots[root] = [type];
263
- }
264
- }
265
- for (const [root, types] of Object.entries(roots)) {
266
- const CURRENT_DIR = process.cwd();
267
- const subDir = path.join(CURRENT_DIR, dir, 'types');
268
- if (!fs.existsSync(subDir)) {
269
- fs.mkdirSync(subDir);
270
- }
271
- const yamlStr = yaml.dump(types);
272
- const fileLabel = root;
273
- if (!fileLabel) {
274
- console.warn('skipping bad type root:', root);
275
- }
276
- fs.writeFileSync(path.join(subDir, `${removeSlash(fileLabel)}.yml`), yamlStr, 'utf8');
277
- }
278
- };
279
250
  function saveData(reducedData, dir) {
280
251
  const propertyToFolderMap = {
281
- reducedTypes: { filename: 'types', split: false, fileLabel: 'slug', saveFunction: saveTypesFunction },
252
+ reducedTypes: { filename: 'types', split: true, fileLabel: 'slug' },
282
253
  reducedOptionSets: { filename: 'option-sets', split: true, fileLabel: 'name' },
283
254
  reducedOptionSetHierarchies: { filename: 'option-set-hierarchies', split: true, fileLabel: 'name' },
284
255
  reducedRuleSets: { filename: 'rule-sets', split: true, fileLabel: 'name' },
@@ -289,10 +260,7 @@ function saveData(reducedData, dir) {
289
260
  };
290
261
  for (const [key, folder] of Object.entries(propertyToFolderMap)) {
291
262
  const CURRENT_DIR = process.cwd();
292
- if (folder['saveFunction']) {
293
- folder['saveFunction'](reducedData, dir);
294
- }
295
- else if (folder.split) {
263
+ if (folder.split) {
296
264
  const subDir = path.join(CURRENT_DIR, dir, folder.filename);
297
265
  if (!fs.existsSync(subDir)) {
298
266
  fs.mkdirSync(subDir);
@@ -25,7 +25,7 @@ function loadReducedTypes() {
25
25
  const files = fs.readdirSync(path.join(TARGET_DIR, 'types'));
26
26
  const types = [];
27
27
  for (const file of files) {
28
- types.push(...yaml.load(fs.readFileSync(path.join(TARGET_DIR, 'types', file), 'utf8')));
28
+ types.push(yaml.load(fs.readFileSync(path.join(TARGET_DIR, 'types', file), 'utf8')));
29
29
  }
30
30
  return types;
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -187,10 +187,10 @@ async function getFolderPrincipals(folder) {
187
187
  for (const workspacePrincipal of workspacePrincipals) {
188
188
 
189
189
  if (workspacePrincipal.principal.email) {
190
- principals.push(workspacePrincipal.principal.email);
190
+ principals.push(workspacePrincipal.principal.email + '|' + workspacePrincipal.role);
191
191
  }
192
192
  else {
193
- principals.push(workspacePrincipal.principal.name);
193
+ principals.push(workspacePrincipal.principal.name + '|' + workspacePrincipal.role);
194
194
  }
195
195
  }
196
196
 
@@ -8,10 +8,6 @@ import pLimit from 'p-limit';
8
8
  const limit = pLimit(30);
9
9
 
10
10
  const yaml = require('js-yaml');
11
- interface StoreFunction
12
- {
13
- (data: ReducedDataHolder, dir: string): void;
14
- }
15
11
 
16
12
  export interface DataHolder {
17
13
  types: any[],
@@ -24,17 +20,6 @@ export interface DataHolder {
24
20
  typePropertyPolicyLinks: any[],
25
21
  }
26
22
 
27
- export interface ReducedDataHolder {
28
- reducedTypes: any[],
29
- reducedOptionSets: any[],
30
- reducedOptionSetHierarchies: any[],
31
- reducedRuleSets: any[],
32
- reducedRuleSetLinks: any[],
33
- reducedUsageInfo: any[],
34
- reducedTypePropertyPolicies: any[],
35
- reducedTypePropertyPolicyLinks: any[],
36
- }
37
-
38
23
  export async function getAll(args) {
39
24
  try {
40
25
  const userConfig = await authUser();
@@ -283,7 +268,7 @@ export function reduceTypes(dataHolder: DataHolder) {
283
268
  return reducedTypes;
284
269
  }
285
270
 
286
- export function reduceData(data: DataHolder): ReducedDataHolder {
271
+ export function reduceData(data: DataHolder) {
287
272
  return {
288
273
  reducedTypes: reduceTypes(data),
289
274
  reducedOptionSets: reduceOptionSets(data),
@@ -296,40 +281,10 @@ export function reduceData(data: DataHolder): ReducedDataHolder {
296
281
  };
297
282
  }
298
283
 
299
- const saveTypesFunction: StoreFunction = function (data: ReducedDataHolder, dir: string) {
300
- const roots = {};
301
- for(const type of data.reducedTypes) {
302
- const typePathParts = type.typePath.split(':');
303
- if(!typePathParts) {
304
- console.warn('skipping bad type with no path', type);
305
- }
306
- const root = typePathParts[0];
307
- if(roots[root]) {
308
- roots[root].push(type);
309
- } else {
310
- roots[root] = [type];
311
- }
312
- }
313
- for(const [root, types] of Object.entries(roots)) {
314
- const CURRENT_DIR = process.cwd();
315
- const subDir = path.join(CURRENT_DIR, dir, 'types');
316
- if(!fs.existsSync(subDir)) {
317
- fs.mkdirSync(subDir);
318
- }
319
- const yamlStr = yaml.dump(types);
320
- const fileLabel = root;
321
- if(!fileLabel) {
322
- console.warn('skipping bad type root:', root);
323
- }
324
- fs.writeFileSync(path.join(subDir, `${removeSlash(fileLabel)}.yml`), yamlStr, 'utf8');
325
- }
326
-
327
- };
328
-
329
284
  function saveData(reducedData, dir: string) {
330
285
 
331
286
  const propertyToFolderMap = {
332
- reducedTypes: { filename: 'types', split: false, fileLabel: 'slug', saveFunction: saveTypesFunction},
287
+ reducedTypes: { filename: 'types', split: true, fileLabel: 'slug' },
333
288
  reducedOptionSets: { filename: 'option-sets', split: true, fileLabel: 'name' },
334
289
  reducedOptionSetHierarchies: { filename: 'option-set-hierarchies', split: true, fileLabel: 'name' },
335
290
  reducedRuleSets: { filename: 'rule-sets', split: true, fileLabel: 'name' },
@@ -340,9 +295,7 @@ function saveData(reducedData, dir: string) {
340
295
  };
341
296
  for(const [key, folder] of Object.entries(propertyToFolderMap)) {
342
297
  const CURRENT_DIR = process.cwd();
343
- if(folder['saveFunction']) {
344
- folder['saveFunction'](reducedData, dir);
345
- } else if(folder.split) {
298
+ if(folder.split) {
346
299
  const subDir = path.join(CURRENT_DIR, dir, folder.filename);
347
300
  if(!fs.existsSync(subDir)) {
348
301
  fs.mkdirSync(subDir);
@@ -32,7 +32,7 @@ function loadReducedTypes(){
32
32
  const files = fs.readdirSync(path.join(TARGET_DIR, 'types'));
33
33
  const types = [];
34
34
  for(const file of files) {
35
- types.push(...yaml.load(fs.readFileSync(path.join(TARGET_DIR, 'types', file), 'utf8')));
35
+ types.push(yaml.load(fs.readFileSync(path.join(TARGET_DIR, 'types', file), 'utf8')));
36
36
  }
37
37
  return types;
38
38
  } catch (e) {