@commercelayer/cli-plugin-provisioning 2.0.10 → 2.1.1

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 (46) hide show
  1. package/bin/run.js +3 -3
  2. package/lib/base.d.ts +8 -8
  3. package/lib/base.js +224 -165
  4. package/lib/commands/provisioning/create.d.ts +2 -2
  5. package/lib/commands/provisioning/create.js +46 -34
  6. package/lib/commands/provisioning/delete.d.ts +2 -2
  7. package/lib/commands/provisioning/delete.js +25 -14
  8. package/lib/commands/provisioning/exec.d.ts +1 -1
  9. package/lib/commands/provisioning/exec.js +22 -13
  10. package/lib/commands/provisioning/fetch.d.ts +3 -3
  11. package/lib/commands/provisioning/fetch.js +25 -17
  12. package/lib/commands/provisioning/get.d.ts +3 -3
  13. package/lib/commands/provisioning/get.js +8 -8
  14. package/lib/commands/provisioning/list.d.ts +3 -3
  15. package/lib/commands/provisioning/list.js +42 -38
  16. package/lib/commands/provisioning/noc.d.ts +1 -1
  17. package/lib/commands/provisioning/noc.js +1 -1
  18. package/lib/commands/provisioning/relationship.d.ts +3 -3
  19. package/lib/commands/provisioning/relationship.js +39 -23
  20. package/lib/commands/provisioning/resources.d.ts +1 -1
  21. package/lib/commands/provisioning/resources.js +22 -12
  22. package/lib/commands/provisioning/retrieve.d.ts +2 -2
  23. package/lib/commands/provisioning/retrieve.js +36 -30
  24. package/lib/commands/provisioning/update.d.ts +3 -3
  25. package/lib/commands/provisioning/update.js +60 -41
  26. package/lib/csv.d.ts +1 -1
  27. package/lib/csv.js +30 -27
  28. package/lib/lang/curl.d.ts +2 -2
  29. package/lib/lang/curl.js +4 -2
  30. package/lib/lang/index.d.ts +5 -5
  31. package/lib/lang/index.js +26 -18
  32. package/lib/lang/node.d.ts +2 -2
  33. package/lib/lang/node.js +7 -7
  34. package/lib/lang/request.d.ts +3 -3
  35. package/lib/lang/request.js +37 -30
  36. package/lib/lang/ruby.d.ts +2 -2
  37. package/lib/lang/ruby.js +1 -1
  38. package/lib/output.d.ts +1 -1
  39. package/lib/output.js +3 -3
  40. package/lib/util/resources/available.js +33 -8
  41. package/lib/util/resources/build.js +35 -19
  42. package/lib/util/resources/index.d.ts +3 -3
  43. package/lib/util/resources/index.js +3 -3
  44. package/lib/util/timezones.js +127 -115
  45. package/oclif.manifest.json +1 -1
  46. package/package.json +85 -87
@@ -1,37 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const base_1 = tslib_1.__importStar(require("../../base"));
5
- const lang_1 = require("../../lang");
6
4
  // import { mergeCommandParams } from '../../commands'
7
5
  const cli_core_1 = require("@commercelayer/cli-core");
8
- const OPERATION = 'list';
6
+ const base_1 = tslib_1.__importStar(require("../../base"));
7
+ const lang_1 = require("../../lang");
8
+ const OPERATION = "list";
9
9
  class ProvisioningList extends base_1.default {
10
- static description = 'fetch a collection of resources';
11
- static aliases = ['pl', 'prov:list', 'plist', 'pls'];
10
+ static description = "fetch a collection of resources";
11
+ static aliases = ["pl", "prov:list", "plist", "pls"];
12
12
  static examples = [
13
- '$ commercelayer provisioning:list roles -f id,name -i organization -s updated_at',
13
+ "$ commercelayer provisioning:list roles -f id,name -i organization -s updated_at",
14
14
  '$ cl prov:list roles -i organization -f name -f organizations/name -w organization_name_eq="ORG NAME"',
15
- '$ cl prov:list roles -p 5 -n 10 -s -created_at --raw',
15
+ "$ cl prov:list roles -p 5 -n 10 -s -created_at --raw",
16
16
  ];
17
17
  static flags = {
18
18
  ...base_1.default.flags,
19
19
  where: base_1.Flags.string({
20
- char: 'w',
20
+ char: "w",
21
21
  multiple: true,
22
- description: 'comma separated list of query filters',
22
+ description: "comma separated list of query filters",
23
23
  }),
24
24
  page: base_1.Flags.integer({
25
- char: 'p',
26
- description: 'page number',
25
+ char: "p",
26
+ description: "page number",
27
27
  }),
28
28
  pageSize: base_1.Flags.integer({
29
- char: 'n',
30
- description: 'number of elements per page',
29
+ char: "n",
30
+ description: "number of elements per page",
31
31
  }),
32
32
  sort: base_1.Flags.string({
33
- char: 's',
34
- description: 'define results ordering',
33
+ char: "s",
34
+ description: "define results ordering",
35
35
  multiple: true,
36
36
  }),
37
37
  /*
@@ -49,20 +49,20 @@ class ProvisioningList extends base_1.default {
49
49
  }),
50
50
  */
51
51
  extract: base_1.Flags.string({
52
- char: 'e',
53
- description: 'extract subfields from object attributes',
52
+ char: "e",
53
+ description: "extract subfields from object attributes",
54
54
  multiple: true,
55
- exclusive: ['raw'],
55
+ exclusive: ["raw"],
56
56
  }),
57
- 'force-include': base_1.Flags.boolean({
58
- char: 'I',
59
- description: 'force resources inclusion beyond the 3rd level',
60
- dependsOn: ['include'],
57
+ "force-include": base_1.Flags.boolean({
58
+ char: "I",
59
+ description: "force resources inclusion beyond the 3rd level",
60
+ dependsOn: ["include"],
61
61
  hidden: true,
62
62
  }),
63
63
  };
64
64
  static args = {
65
- ...base_1.default.args
65
+ ...base_1.default.args,
66
66
  };
67
67
  async run() {
68
68
  const { args, flags } = await this.parse(ProvisioningList);
@@ -70,9 +70,9 @@ class ProvisioningList extends base_1.default {
70
70
  // const loadParams = flags[FLAG_LOAD_PARAMS]
71
71
  // const saveCmd = flags[FLAG_SAVE_PARAMS]
72
72
  // if (saveCmd) this.checkAlias(saveCmd, resource.api, OPERATION, this.config)
73
- const showHeaders = flags.headers || flags['headers-only'];
73
+ const showHeaders = flags.headers || flags["headers-only"];
74
74
  // Include flags
75
- const include = this.includeFlag(flags.include, undefined, flags['force-include']);
75
+ const include = this.includeFlag(flags.include, undefined, flags["force-include"]);
76
76
  // Fields flags
77
77
  const fields = this.fieldsFlag(flags.fields, resource.type);
78
78
  // Where flags
@@ -82,23 +82,25 @@ class ProvisioningList extends base_1.default {
82
82
  const page = flags.page;
83
83
  const perPage = flags.pageSize;
84
84
  const cl = this.initCommerceLayer(flags);
85
- const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
85
+ const rawReader = flags.raw
86
+ ? cl.addRawResponseReader({ headers: showHeaders })
87
+ : undefined;
86
88
  const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
87
89
  const params = {};
88
90
  try {
89
91
  const resSdk = cl[resource.api];
90
92
  this.checkOperation(resSdk, OPERATION);
91
- if (include && (include.length > 0))
93
+ if (include && include.length > 0)
92
94
  params.include = include;
93
- if (fields && (Object.keys(fields).length > 0))
95
+ if (fields && Object.keys(fields).length > 0)
94
96
  params.fields = fields;
95
- if (wheres && (Object.keys(wheres).length > 0))
97
+ if (wheres && Object.keys(wheres).length > 0)
96
98
  params.filters = wheres;
97
- if (sort && (Object.keys(sort).length > 0))
99
+ if (sort && Object.keys(sort).length > 0)
98
100
  params.sort = sort;
99
- if (perPage && (perPage > 0))
101
+ if (perPage && perPage > 0)
100
102
  params.pageSize = perPage;
101
- if (page && (page > 0))
103
+ if (page && page > 0)
102
104
  params.pageNumber = page;
103
105
  // Load saved command arguments
104
106
  // if (loadParams) {
@@ -108,22 +110,24 @@ class ProvisioningList extends base_1.default {
108
110
  // if (!flags.doc) cliux.action.start(`Fetching ${resource.api.replace(/_/g, ' ')}`)
109
111
  const res = await resSdk.list(params);
110
112
  base_1.cliux.action.stop();
111
- const out = (flags.raw && rawReader) ? rawReader.rawResponse : [...res];
113
+ const out = flags.raw && rawReader ? rawReader.rawResponse : [...res];
112
114
  const meta = res.meta;
113
- if (res && (res.length > 0)) {
115
+ if (res && res.length > 0) {
114
116
  if (flags.extract && Array.isArray(out)) {
115
117
  const ext = this.extractFlag(flags.extract);
116
- out.forEach(o => { this.extractObjectFields(ext, o); });
118
+ out.forEach((o) => {
119
+ this.extractObjectFields(ext, o);
120
+ });
117
121
  }
118
122
  this.printHeaders(rawReader?.headers, flags);
119
123
  this.printOutput(out, flags);
120
- if (!flags['headers-only'])
124
+ if (!flags["headers-only"])
121
125
  this.log(`\nRecords: ${cli_core_1.clColor.blueBright(res.length)} of ${meta.recordCount} | Page: ${cli_core_1.clColor.blueBright(String(flags.page || 1))} of ${meta.pageCount}\n`);
122
126
  // Save command output
123
127
  // if (flags.save || flags['save-path']) this.saveOutput(out, flags)
124
128
  }
125
129
  else
126
- this.log(cli_core_1.clColor.italic('\nNo records found\n'));
130
+ this.log(cli_core_1.clColor.italic("\nNo records found\n"));
127
131
  // Save command arguments
128
132
  // if (saveCmd) this.saveParams(saveCmd, { type: resource.api }, OPERATION, params)
129
133
  return out;
@@ -131,7 +135,7 @@ class ProvisioningList extends base_1.default {
131
135
  catch (error) {
132
136
  if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
133
137
  await this.showLiveDocumentation(reqReader.request, params, flags);
134
- cl.removeInterceptor('request', reqReader.id);
138
+ cl.removeInterceptor("request", reqReader.id);
135
139
  }
136
140
  else
137
141
  this.printError(error, flags, args);
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Noc extends Command {
3
3
  static hidden: boolean;
4
4
  static flags: {};
@@ -5,7 +5,7 @@ class Noc extends core_1.Command {
5
5
  static hidden = true;
6
6
  static flags = {};
7
7
  async run() {
8
- const output = '-= NoC =-';
8
+ const output = "-= NoC =-";
9
9
  this.log(output);
10
10
  return output;
11
11
  }
@@ -1,4 +1,4 @@
1
- import Command from '../../base';
1
+ import Command from "../../base";
2
2
  export default class ResourcesRelationship extends Command {
3
3
  static description: string;
4
4
  static aliases: string[];
@@ -10,7 +10,7 @@ export default class ResourcesRelationship extends Command {
10
10
  pageSize: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
11
  sort: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  extract: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
- 'force-include': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ "force-include": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
14
  include: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
15
  fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
16
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -21,7 +21,7 @@ export default class ResourcesRelationship extends Command {
21
21
  curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
22
22
  node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
23
23
  headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
- 'headers-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
+ "headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
25
25
  };
26
26
  static args: {
27
27
  id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
@@ -1,28 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const cli_core_1 = require("@commercelayer/cli-core");
4
5
  const base_1 = tslib_1.__importStar(require("../../base"));
5
6
  const lang_1 = require("../../lang");
6
7
  // import { mergeCommandParams } from '../../commands'
7
8
  const list_1 = tslib_1.__importDefault(require("./list"));
8
- const cli_core_1 = require("@commercelayer/cli-core");
9
9
  // const OPERATION = 'relationship'
10
10
  class ResourcesRelationship extends base_1.default {
11
- static description = 'fetch a resource relationship';
12
- static aliases = ['provisioning:rel', 'prov:rel', 'prov:relationship'];
11
+ static description = "fetch a resource relationship";
12
+ static aliases = ["provisioning:rel", "prov:rel", "prov:relationship"];
13
13
  static hidden = true;
14
14
  static examples = [
15
- '$ commercelayer provisioning:relationship roles <roleId> organization',
16
- '$ clayer prov:relationship roles <roleId> permissions',
17
- '$ cl prov:rel roles <roleId> permisions -w subject_eq=testsub'
15
+ "$ commercelayer provisioning:relationship roles <roleId> organization",
16
+ "$ clayer prov:relationship roles <roleId> permissions",
17
+ "$ cl prov:rel roles <roleId> permisions -w subject_eq=testsub",
18
18
  ];
19
19
  static flags = {
20
20
  ...list_1.default.flags,
21
21
  };
22
22
  static args = {
23
23
  ...list_1.default.args,
24
- id: base_1.Args.string({ name: 'id', description: 'id of the resource to retrieve', required: true }),
25
- relationship: base_1.Args.string({ name: 'relationship', description: 'name of the relationship field', required: true }),
24
+ id: base_1.Args.string({
25
+ name: "id",
26
+ description: "id of the resource to retrieve",
27
+ required: true,
28
+ }),
29
+ relationship: base_1.Args.string({
30
+ name: "relationship",
31
+ description: "name of the relationship field",
32
+ required: true,
33
+ }),
26
34
  };
27
35
  async run() {
28
36
  const { args, flags } = await this.parse(ResourcesRelationship);
@@ -30,7 +38,7 @@ class ResourcesRelationship extends base_1.default {
30
38
  const resource = this.checkResource(resName, { singular: true });
31
39
  const relationship = args.relationship;
32
40
  const multiRel = this.isRelationship1N(relationship);
33
- const showHeaders = flags.headers || flags['headers-only'];
41
+ const showHeaders = flags.headers || flags["headers-only"];
34
42
  const cl = this.initCommerceLayer(flags);
35
43
  const resSdk = cl[resource.api];
36
44
  this.checkRelationship(resSdk, relationship);
@@ -48,21 +56,23 @@ class ResourcesRelationship extends base_1.default {
48
56
  const sort = this.sortFlag(flags.sort);
49
57
  const page = flags.page;
50
58
  const perPage = flags.pageSize;
51
- const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
59
+ const rawReader = flags.raw
60
+ ? cl.addRawResponseReader({ headers: showHeaders })
61
+ : undefined;
52
62
  const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
53
63
  const params = {};
54
64
  try {
55
- if (include && (include.length > 0))
65
+ if (include && include.length > 0)
56
66
  params.include = include;
57
- if (fields && (Object.keys(fields).length > 0))
67
+ if (fields && Object.keys(fields).length > 0)
58
68
  params.fields = fields;
59
- if (wheres && (Object.keys(wheres).length > 0))
69
+ if (wheres && Object.keys(wheres).length > 0)
60
70
  params.filters = wheres;
61
- if (sort && (Object.keys(sort).length > 0))
71
+ if (sort && Object.keys(sort).length > 0)
62
72
  params.sort = sort;
63
- if (perPage && (perPage > 0))
73
+ if (perPage && perPage > 0)
64
74
  params.pageSize = perPage;
65
- if (page && (page > 0))
75
+ if (page && page > 0)
66
76
  params.pageNumber = page;
67
77
  // Load saved command arguments
68
78
  // if (loadParams) {
@@ -70,24 +80,30 @@ class ResourcesRelationship extends base_1.default {
70
80
  // if (savedParams) mergeCommandParams(params, savedParams)
71
81
  // }
72
82
  if (!flags.doc && multiRel)
73
- base_1.cliux.action.start(`Fetching ${resource.api.replace(/_/g, ' ')}.${relationship} for id ${id}`);
83
+ base_1.cliux.action.start(`Fetching ${resource.api.replace(/_/g, " ")}.${relationship} for id ${id}`);
74
84
  const res = await resSdk[relationship](id, params);
75
85
  if (multiRel)
76
86
  base_1.cliux.action.stop();
77
- const out = (flags.raw && rawReader) ? rawReader.rawResponse : (multiRel ? [...res] : res);
87
+ const out = flags.raw && rawReader
88
+ ? rawReader.rawResponse
89
+ : multiRel
90
+ ? [...res]
91
+ : res;
78
92
  if (out && flags.extract) {
79
93
  const ext = this.extractFlag(flags.extract);
80
94
  if (Array.isArray(out))
81
- out.forEach(o => { this.extractObjectFields(ext, o); });
95
+ out.forEach((o) => {
96
+ this.extractObjectFields(ext, o);
97
+ });
82
98
  else
83
99
  this.extractObjectFields(ext, out);
84
100
  }
85
- if (!out || (out.length === 0))
101
+ if (!out || out.length === 0)
86
102
  this.log(cli_core_1.clColor.italic(`\nRelationship ${cli_core_1.clColor.api.resource(`${resName}.${relationship}`)} is empty\n`));
87
103
  else {
88
104
  this.printHeaders(rawReader?.headers, flags);
89
105
  this.printOutput(out, flags);
90
- if (multiRel && !flags['headers-only'])
106
+ if (multiRel && !flags["headers-only"])
91
107
  this.log(`\nRecords: ${cli_core_1.clColor.blueBright(out.length)} of ${res.meta.recordCount} | Page: ${cli_core_1.clColor.blueBright(String(flags.page || 1))} of ${res.meta.pageCount}\n`);
92
108
  // Save command output
93
109
  // if (flags.save || flags['save-path']) this.saveOutput(out, flags)
@@ -99,7 +115,7 @@ class ResourcesRelationship extends base_1.default {
99
115
  catch (error) {
100
116
  if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
101
117
  await this.showLiveDocumentation(reqReader.request, params, flags);
102
- cl.removeInterceptor('request', reqReader.id);
118
+ cl.removeInterceptor("request", reqReader.id);
103
119
  }
104
120
  else
105
121
  this.printError(error, flags, args);
@@ -111,7 +127,7 @@ class ResourcesRelationship extends base_1.default {
111
127
  return true;
112
128
  }
113
129
  isRelationship1N(name) {
114
- return (name === cli_core_1.clText.pluralize(name));
130
+ return name === cli_core_1.clText.pluralize(name);
115
131
  }
116
132
  }
117
133
  exports.default = ResourcesRelationship;
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class ProvisioningResources extends Command {
3
3
  static description: string;
4
4
  static aliases: string[];
@@ -1,34 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_core_1 = require("@commercelayer/cli-core");
3
4
  const core_1 = require("@oclif/core");
4
5
  const resources_1 = require("../../util/resources");
5
- const cli_core_1 = require("@commercelayer/cli-core");
6
6
  class ProvisioningResources extends core_1.Command {
7
- static description = 'list all the available Provisioning API resources';
8
- static aliases = ['prov:resources', 'pres'];
7
+ static description = "list all the available Provisioning API resources";
8
+ static aliases = ["prov:resources", "pres"];
9
9
  static examples = [
10
- '$ commercelayer provisioning:resources',
11
- '$ cl prov:resources',
10
+ "$ commercelayer provisioning:resources",
11
+ "$ cl prov:resources",
12
12
  ];
13
13
  static flags = {
14
- help: core_1.Flags.help({ char: 'h' }),
14
+ help: core_1.Flags.help({ char: "h" }),
15
15
  };
16
16
  async run() {
17
17
  await this.parse(ProvisioningResources);
18
- this.log(cli_core_1.clColor.style.title('\n-= Provisioning API available resources =-\n'));
19
- const resourceArray = (0, resources_1.resourceList)('api').map(r => {
20
- return { name: r, url: `${cli_core_1.clConfig.doc.provisioning_api_reference}/${r}` };
18
+ this.log(cli_core_1.clColor.style.title("\n-= Provisioning API available resources =-\n"));
19
+ const resourceArray = (0, resources_1.resourceList)("api").map((r) => {
20
+ return {
21
+ name: r,
22
+ url: `${cli_core_1.clConfig.doc.provisioning_api_reference}/${r}`,
23
+ };
21
24
  });
22
25
  core_1.ux.Table.table(resourceArray, {
23
- key: { header: 'NAME', minWidth: 35, get: row => cli_core_1.clColor.blueBright(row.name) },
24
- description: { header: 'ONLINE DOCUMENTATION URL', get: row => row.url },
26
+ key: {
27
+ header: "NAME",
28
+ minWidth: 35,
29
+ get: (row) => cli_core_1.clColor.blueBright(row.name),
30
+ },
31
+ description: {
32
+ header: "ONLINE DOCUMENTATION URL",
33
+ get: (row) => row.url,
34
+ },
25
35
  }, {
26
36
  printLine: cli_core_1.clUtil.log,
27
37
  });
28
38
  this.log();
29
39
  }
30
40
  async catch(error) {
31
- if ((error.code === 'EEXIT') && (error.message === 'EEXIT: 0'))
41
+ if (error.code === "EEXIT" && error.message === "EEXIT: 0")
32
42
  return;
33
43
  return await super.catch(error);
34
44
  }
@@ -1,4 +1,4 @@
1
- import Command from '../../base';
1
+ import Command from "../../base";
2
2
  export default class ProvisioningRetrieve extends Command {
3
3
  static description: string;
4
4
  static aliases: string[];
@@ -15,7 +15,7 @@ export default class ProvisioningRetrieve extends Command {
15
15
  curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
16
16
  node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
17
17
  headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
- 'headers-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
+ "headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
19
19
  };
20
20
  static args: {
21
21
  id: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
@@ -4,42 +4,46 @@ const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importStar(require("../../base"));
5
5
  const lang_1 = require("../../lang");
6
6
  // import { mergeCommandParams } from '../../commands'
7
- const OPERATION = 'retrieve';
7
+ const OPERATION = "retrieve";
8
8
  class ProvisioningRetrieve extends base_1.default {
9
- static description = 'fetch a single resource';
10
- static aliases = ['prov:retrieve', 'pr', 'pretrieve'];
9
+ static description = "fetch a single resource";
10
+ static aliases = ["prov:retrieve", "pr", "pretrieve"];
11
11
  static examples = [
12
- '$ commercelayer provisioning:retrieve roles/<roleId>',
13
- '$ commercelayer prov:retrieve roles <roleId>',
14
- '$ cl prov:retrieve roles <roleId>',
15
- '$ clayer pr roles/<roleId>',
12
+ "$ commercelayer provisioning:retrieve roles/<roleId>",
13
+ "$ commercelayer prov:retrieve roles <roleId>",
14
+ "$ cl prov:retrieve roles <roleId>",
15
+ "$ clayer pr roles/<roleId>",
16
16
  ];
17
17
  static flags = {
18
18
  ...base_1.default.flags,
19
19
  /*
20
- save: Flags.string({
21
- char: 'x',
22
- description: 'save command output to file',
23
- multiple: false,
24
- exclusive: ['save-path'],
25
- }),
26
- 'save-path': Flags.string({
27
- char: 'X',
28
- description: 'save command output to file and create missing path directories',
29
- multiple: false,
30
- exclusive: ['save'],
31
- }),
32
- */
20
+ save: Flags.string({
21
+ char: 'x',
22
+ description: 'save command output to file',
23
+ multiple: false,
24
+ exclusive: ['save-path'],
25
+ }),
26
+ 'save-path': Flags.string({
27
+ char: 'X',
28
+ description: 'save command output to file and create missing path directories',
29
+ multiple: false,
30
+ exclusive: ['save'],
31
+ }),
32
+ */
33
33
  extract: base_1.Flags.string({
34
- char: 'e',
35
- description: 'extract subfields from object attributes',
34
+ char: "e",
35
+ description: "extract subfields from object attributes",
36
36
  multiple: true,
37
- exclusive: ['raw'],
37
+ exclusive: ["raw"],
38
38
  }),
39
39
  };
40
40
  static args = {
41
41
  ...base_1.default.args,
42
- id: base_1.Args.string({ name: 'id', description: 'id of the resource to retrieve', required: false }),
42
+ id: base_1.Args.string({
43
+ name: "id",
44
+ description: "id of the resource to retrieve",
45
+ required: false,
46
+ }),
43
47
  };
44
48
  async run() {
45
49
  const { args, flags } = await this.parse(ProvisioningRetrieve);
@@ -48,21 +52,23 @@ class ProvisioningRetrieve extends base_1.default {
48
52
  // const loadParams = flags[FLAG_LOAD_PARAMS]
49
53
  // const saveCmd = flags[FLAG_SAVE_PARAMS]
50
54
  // if (saveCmd) this.checkAlias(saveCmd, resource.api, OPERATION, this.config)
51
- const showHeaders = flags.headers || flags['headers-only'];
55
+ const showHeaders = flags.headers || flags["headers-only"];
52
56
  // Include flags
53
57
  const include = this.includeFlag(flags.include);
54
58
  // Fields flags
55
59
  const fields = this.fieldsFlag(flags.fields, resource.type);
56
60
  const cl = this.initCommerceLayer(flags);
57
- const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
61
+ const rawReader = flags.raw
62
+ ? cl.addRawResponseReader({ headers: showHeaders })
63
+ : undefined;
58
64
  const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
59
65
  const params = {};
60
66
  try {
61
67
  const resSdk = cl[resource.api];
62
68
  this.checkOperation(resSdk, OPERATION);
63
- if (include && (include.length > 0))
69
+ if (include && include.length > 0)
64
70
  params.include = include;
65
- if (fields && (Object.keys(fields).length > 0))
71
+ if (fields && Object.keys(fields).length > 0)
66
72
  params.fields = fields;
67
73
  // Load saved command arguments
68
74
  // if (loadParams) {
@@ -70,7 +76,7 @@ class ProvisioningRetrieve extends base_1.default {
70
76
  // if (savedParams) mergeCommandParams(params, savedParams)
71
77
  // }
72
78
  const res = await resSdk.retrieve(id, params);
73
- const out = (flags.raw && rawReader) ? rawReader.rawResponse : res;
79
+ const out = flags.raw && rawReader ? rawReader.rawResponse : res;
74
80
  if (flags.extract) {
75
81
  const ext = this.extractFlag(flags.extract);
76
82
  this.extractObjectFields(ext, out);
@@ -86,7 +92,7 @@ class ProvisioningRetrieve extends base_1.default {
86
92
  catch (error) {
87
93
  if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
88
94
  await this.showLiveDocumentation(reqReader.request, params, flags);
89
- cl.removeInterceptor('request', reqReader.id);
95
+ cl.removeInterceptor("request", reqReader.id);
90
96
  }
91
97
  else
92
98
  this.printError(error, flags, args);
@@ -1,4 +1,4 @@
1
- import Command from '../../base';
1
+ import Command from "../../base";
2
2
  export default class ProvisioningUpdate extends Command {
3
3
  static description: string;
4
4
  static aliases: string[];
@@ -8,7 +8,7 @@ export default class ProvisioningUpdate extends Command {
8
8
  object: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
9
  relationship: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
10
  metadata: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
- 'metadata-replace': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ "metadata-replace": import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  data: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
13
  include: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  fields: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -20,7 +20,7 @@ export default class ProvisioningUpdate extends Command {
20
20
  curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
21
21
  node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
22
22
  headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
23
- 'headers-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
23
+ "headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
24
24
  };
25
25
  static args: {
26
26
  id: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;