@commercelayer/cli-plugin-provisioning 2.0.10 → 2.1.0
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.
- package/bin/run.js +3 -3
- package/lib/base.d.ts +8 -8
- package/lib/base.js +224 -165
- package/lib/commands/provisioning/create.d.ts +2 -2
- package/lib/commands/provisioning/create.js +46 -34
- package/lib/commands/provisioning/delete.d.ts +2 -2
- package/lib/commands/provisioning/delete.js +25 -14
- package/lib/commands/provisioning/exec.d.ts +1 -1
- package/lib/commands/provisioning/exec.js +22 -13
- package/lib/commands/provisioning/fetch.d.ts +3 -3
- package/lib/commands/provisioning/fetch.js +25 -17
- package/lib/commands/provisioning/get.d.ts +3 -3
- package/lib/commands/provisioning/get.js +8 -8
- package/lib/commands/provisioning/list.d.ts +3 -3
- package/lib/commands/provisioning/list.js +42 -38
- package/lib/commands/provisioning/noc.d.ts +1 -1
- package/lib/commands/provisioning/noc.js +1 -1
- package/lib/commands/provisioning/relationship.d.ts +3 -3
- package/lib/commands/provisioning/relationship.js +39 -23
- package/lib/commands/provisioning/resources.d.ts +1 -1
- package/lib/commands/provisioning/resources.js +22 -12
- package/lib/commands/provisioning/retrieve.d.ts +2 -2
- package/lib/commands/provisioning/retrieve.js +36 -30
- package/lib/commands/provisioning/update.d.ts +3 -3
- package/lib/commands/provisioning/update.js +60 -41
- package/lib/csv.d.ts +1 -1
- package/lib/csv.js +30 -27
- package/lib/lang/curl.d.ts +2 -2
- package/lib/lang/curl.js +4 -2
- package/lib/lang/index.d.ts +5 -5
- package/lib/lang/index.js +26 -18
- package/lib/lang/node.d.ts +2 -2
- package/lib/lang/node.js +7 -7
- package/lib/lang/request.d.ts +3 -3
- package/lib/lang/request.js +37 -30
- package/lib/lang/ruby.d.ts +2 -2
- package/lib/lang/ruby.js +1 -1
- package/lib/output.d.ts +1 -1
- package/lib/output.js +3 -3
- package/lib/util/resources/available.js +33 -8
- package/lib/util/resources/build.js +35 -19
- package/lib/util/resources/index.d.ts +3 -3
- package/lib/util/resources/index.js +3 -3
- package/lib/util/timezones.js +127 -115
- package/oclif.manifest.json +1 -1
- package/package.json +85 -87
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Command from
|
|
1
|
+
import Command from "../../base";
|
|
2
2
|
export default class ProvisioningCreate extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static aliases: string[];
|
|
@@ -19,7 +19,7 @@ export default class ProvisioningCreate extends Command {
|
|
|
19
19
|
curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
|
|
20
20
|
node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
|
|
21
21
|
headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
22
|
-
|
|
22
|
+
"headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
23
23
|
};
|
|
24
24
|
static args: {
|
|
25
25
|
resource: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -1,51 +1,56 @@
|
|
|
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
4
|
const cli_core_1 = require("@commercelayer/cli-core");
|
|
5
|
+
const base_1 = tslib_1.__importStar(require("../../base"));
|
|
6
6
|
const lang_1 = require("../../lang");
|
|
7
7
|
// import { mergeCommandParams } from '../../commands'
|
|
8
|
-
const OPERATION =
|
|
8
|
+
const OPERATION = "create";
|
|
9
9
|
class ProvisioningCreate extends base_1.default {
|
|
10
|
-
static description =
|
|
11
|
-
static aliases = [
|
|
10
|
+
static description = "create a new resource";
|
|
11
|
+
static aliases = ["prov:create", "pc", "pcreate"];
|
|
12
12
|
static examples = [
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
"$ commercelayer provisioning:create organizations -a name=MyOrg",
|
|
14
|
+
"$ clayer prov:create subscriptions -r plan=plans/<planId>",
|
|
15
15
|
'$ cl prov:create organization -a name=MyOrg -m meta_key="meta value"',
|
|
16
|
-
|
|
16
|
+
"$ cl pc roles -D /path/to/data/file/data.json",
|
|
17
17
|
];
|
|
18
18
|
static flags = {
|
|
19
19
|
...base_1.default.flags,
|
|
20
20
|
attribute: base_1.Flags.string({
|
|
21
|
-
char:
|
|
22
|
-
description:
|
|
21
|
+
char: "a",
|
|
22
|
+
description: "define a resource attribute",
|
|
23
23
|
multiple: true,
|
|
24
24
|
}),
|
|
25
25
|
object: base_1.Flags.string({
|
|
26
|
-
char:
|
|
27
|
-
description:
|
|
26
|
+
char: "O",
|
|
27
|
+
description: "define a resource object attribute",
|
|
28
28
|
multiple: true,
|
|
29
29
|
}),
|
|
30
30
|
relationship: base_1.Flags.string({
|
|
31
|
-
char:
|
|
32
|
-
description:
|
|
31
|
+
char: "r",
|
|
32
|
+
description: "define a relationship with another resource",
|
|
33
33
|
multiple: true,
|
|
34
34
|
}),
|
|
35
35
|
metadata: base_1.Flags.string({
|
|
36
|
-
char:
|
|
37
|
-
description:
|
|
36
|
+
char: "m",
|
|
37
|
+
description: "define a metadata attribute or a set of metadata attributes",
|
|
38
38
|
multiple: true,
|
|
39
39
|
}),
|
|
40
40
|
data: base_1.Flags.string({
|
|
41
|
-
char:
|
|
42
|
-
description:
|
|
41
|
+
char: "D",
|
|
42
|
+
description: "the data file to use as request body",
|
|
43
43
|
multiple: false,
|
|
44
|
-
exclusive: [
|
|
45
|
-
|
|
44
|
+
exclusive: [
|
|
45
|
+
"attribute",
|
|
46
|
+
"relationship",
|
|
47
|
+
"metadata",
|
|
48
|
+
"doc" /* , FLAG_LOAD_PARAMS, FLAG_SAVE_PARAMS */,
|
|
49
|
+
],
|
|
50
|
+
}),
|
|
46
51
|
};
|
|
47
52
|
static args = {
|
|
48
|
-
...base_1.default.args
|
|
53
|
+
...base_1.default.args,
|
|
49
54
|
};
|
|
50
55
|
async run() {
|
|
51
56
|
const { args, flags } = await this.parse(ProvisioningCreate);
|
|
@@ -53,16 +58,21 @@ class ProvisioningCreate extends base_1.default {
|
|
|
53
58
|
// const loadParams = flags[FLAG_LOAD_PARAMS]
|
|
54
59
|
// const saveCmd = flags[FLAG_SAVE_PARAMS]
|
|
55
60
|
// if (saveCmd) this.checkAlias(saveCmd, resource.api, OPERATION, this.config)
|
|
56
|
-
const showHeaders = flags.headers || flags[
|
|
61
|
+
const showHeaders = flags.headers || flags["headers-only"];
|
|
57
62
|
// Raw request
|
|
58
63
|
if (flags.data) {
|
|
59
64
|
try {
|
|
60
|
-
const baseUrl = cli_core_1.clApi.baseURL(
|
|
65
|
+
const baseUrl = cli_core_1.clApi.baseURL("provisioning", undefined, flags.domain);
|
|
61
66
|
const accessToken = flags.accessToken;
|
|
62
|
-
const rawRes = await cli_core_1.clApi.request.raw({
|
|
67
|
+
const rawRes = await cli_core_1.clApi.request.raw({
|
|
68
|
+
operation: cli_core_1.clApi.Operation.Create,
|
|
69
|
+
baseUrl,
|
|
70
|
+
accessToken,
|
|
71
|
+
resource: resource.api,
|
|
72
|
+
}, cli_core_1.clApi.request.readDataFile(flags.data));
|
|
63
73
|
const out = flags.raw ? rawRes : cli_core_1.clApi.response.denormalize(rawRes);
|
|
64
74
|
this.printOutput(out, flags);
|
|
65
|
-
this.log(`\n${cli_core_1.clColor.style.success(
|
|
75
|
+
this.log(`\n${cli_core_1.clColor.style.success("Successfully")} created new resource of type ${cli_core_1.clColor.style.resource(resource.api)} with id ${cli_core_1.clColor.style.id(rawRes.data.id)}\n`);
|
|
66
76
|
return out;
|
|
67
77
|
}
|
|
68
78
|
catch (error) {
|
|
@@ -79,14 +89,14 @@ class ProvisioningCreate extends base_1.default {
|
|
|
79
89
|
// Metadata flags
|
|
80
90
|
const metadata = this.metadataFlag(flags.metadata, { fixTypes: true });
|
|
81
91
|
// Relationships
|
|
82
|
-
if (relationships &&
|
|
92
|
+
if (relationships && Object.keys(relationships).length > 0)
|
|
83
93
|
Object.entries(relationships).forEach(([key, value]) => {
|
|
84
94
|
const relSdk = cl[value.type];
|
|
85
95
|
const rel = relSdk.relationship(value);
|
|
86
96
|
attributes[key] = rel;
|
|
87
97
|
});
|
|
88
98
|
// Objects
|
|
89
|
-
if (objects &&
|
|
99
|
+
if (objects && Object.keys(objects).length > 0) {
|
|
90
100
|
for (const o of Object.keys(objects)) {
|
|
91
101
|
if (Object.keys(attributes).includes(o))
|
|
92
102
|
this.warn(`Object ${o} will overwrite attribute ${o}`);
|
|
@@ -95,24 +105,26 @@ class ProvisioningCreate extends base_1.default {
|
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
107
|
// Metadata
|
|
98
|
-
if (metadata &&
|
|
108
|
+
if (metadata && Object.keys(metadata).length > 0) {
|
|
99
109
|
if (attributes.metadata)
|
|
100
|
-
this.warn(`Attribute ${cli_core_1.clColor.style.attribute(
|
|
110
|
+
this.warn(`Attribute ${cli_core_1.clColor.style.attribute("metadata")} will be overwritten by the content defined with the flag ${cli_core_1.clColor.style.flag("-m")}`);
|
|
101
111
|
attributes.metadata = metadata;
|
|
102
112
|
}
|
|
103
113
|
// Include flags
|
|
104
114
|
const include = this.includeFlag(flags.include, relationships);
|
|
105
115
|
// Fields flags
|
|
106
116
|
const fields = this.fieldsFlag(flags.fields, resource.type);
|
|
107
|
-
const rawReader = flags.raw
|
|
117
|
+
const rawReader = flags.raw
|
|
118
|
+
? cl.addRawResponseReader({ headers: showHeaders })
|
|
119
|
+
: undefined;
|
|
108
120
|
const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
|
|
109
121
|
const params = {};
|
|
110
122
|
try {
|
|
111
123
|
const resSdk = cl[resource.api];
|
|
112
124
|
this.checkOperation(resSdk, OPERATION);
|
|
113
|
-
if (include &&
|
|
125
|
+
if (include && include.length > 0)
|
|
114
126
|
params.include = include;
|
|
115
|
-
if (fields &&
|
|
127
|
+
if (fields && Object.keys(fields).length > 0)
|
|
116
128
|
params.fields = fields;
|
|
117
129
|
// Load saved command arguments
|
|
118
130
|
// if (loadParams) {
|
|
@@ -120,10 +132,10 @@ class ProvisioningCreate extends base_1.default {
|
|
|
120
132
|
// if (savedParams) mergeCommandParams(params, savedParams)
|
|
121
133
|
// }
|
|
122
134
|
const res = await resSdk.create(attributes, params);
|
|
123
|
-
const out =
|
|
135
|
+
const out = flags.raw && rawReader ? rawReader.rawResponse : res;
|
|
124
136
|
this.printHeaders(rawReader?.headers, flags);
|
|
125
137
|
this.printOutput(out, flags);
|
|
126
|
-
this.log(`\n${cli_core_1.clColor.style.success(
|
|
138
|
+
this.log(`\n${cli_core_1.clColor.style.success("Successfully")} created new resource of type ${cli_core_1.clColor.style.resource(resource.type)} with id ${cli_core_1.clColor.style.id(res.id)}\n`);
|
|
127
139
|
// Save command arguments
|
|
128
140
|
// if (saveCmd) this.saveParams(saveCmd, { type: resource.api }, OPERATION, params)
|
|
129
141
|
return out;
|
|
@@ -131,7 +143,7 @@ class ProvisioningCreate extends base_1.default {
|
|
|
131
143
|
catch (error) {
|
|
132
144
|
if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
|
|
133
145
|
await this.showLiveDocumentation(reqReader.request, params, flags);
|
|
134
|
-
cl.removeInterceptor(
|
|
146
|
+
cl.removeInterceptor("request", reqReader.id);
|
|
135
147
|
}
|
|
136
148
|
else
|
|
137
149
|
this.printError(error);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Command from
|
|
1
|
+
import Command from "../../base";
|
|
2
2
|
export default class ProvisioningDelete extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static aliases: string[];
|
|
@@ -14,7 +14,7 @@ export default class ProvisioningDelete extends Command {
|
|
|
14
14
|
curl: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
|
|
15
15
|
node: import("@oclif/core/lib/interfaces").BooleanFlag<string>;
|
|
16
16
|
headers: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
-
|
|
17
|
+
"headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
18
18
|
};
|
|
19
19
|
static args: {
|
|
20
20
|
id: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
@@ -1,36 +1,47 @@
|
|
|
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
|
-
const
|
|
7
|
-
const OPERATION = 'delete';
|
|
7
|
+
const OPERATION = "delete";
|
|
8
8
|
class ProvisioningDelete extends base_1.default {
|
|
9
|
-
static description =
|
|
10
|
-
static aliases = [
|
|
9
|
+
static description = "delete an existing resource";
|
|
10
|
+
static aliases = ["prov:delete", "pd", "pdelete", "pdel"];
|
|
11
11
|
static examples = [
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
"$ commercelayer provisioning:delete api_credentials/<id>",
|
|
13
|
+
"$ cl prov:delete api_credentials <id>",
|
|
14
14
|
];
|
|
15
15
|
static flags = {
|
|
16
|
-
...
|
|
16
|
+
...cli_core_1.clCommand.commandFlags(base_1.default.flags, [
|
|
17
|
+
/* FLAG_SAVE_PARAMS, FLAG_LOAD_PARAMS, */ "fields",
|
|
18
|
+
"include",
|
|
19
|
+
"json",
|
|
20
|
+
"unformatted",
|
|
21
|
+
]),
|
|
17
22
|
};
|
|
18
23
|
static args = {
|
|
19
24
|
...base_1.default.args,
|
|
20
|
-
id: base_1.Args.string({
|
|
25
|
+
id: base_1.Args.string({
|
|
26
|
+
name: "id",
|
|
27
|
+
description: "id of the resource to delete",
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
21
30
|
};
|
|
22
31
|
async run() {
|
|
23
32
|
const { args, flags } = await this.parse(ProvisioningDelete);
|
|
24
|
-
const invalidFlags = [
|
|
25
|
-
invalidFlags.forEach(x => {
|
|
33
|
+
const invalidFlags = ["fields", "include"];
|
|
34
|
+
invalidFlags.forEach((x) => {
|
|
26
35
|
if (flags[x])
|
|
27
36
|
this.error(`Flag not supported in ${cli_core_1.clColor.cli.command(OPERATION)} operation: ${cli_core_1.clColor.style.error(x)}`);
|
|
28
37
|
});
|
|
29
38
|
const { res, id } = this.checkResourceId(args.resource, args.id);
|
|
30
39
|
const resource = this.checkResource(res, { singular: true });
|
|
31
|
-
const showHeaders = flags.headers || flags[
|
|
40
|
+
const showHeaders = flags.headers || flags["headers-only"];
|
|
32
41
|
const cl = this.initCommerceLayer(flags);
|
|
33
|
-
const rawReader =
|
|
42
|
+
const rawReader = flags.raw && showHeaders
|
|
43
|
+
? cl.addRawResponseReader({ headers: showHeaders })
|
|
44
|
+
: undefined;
|
|
34
45
|
const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
|
|
35
46
|
try {
|
|
36
47
|
const resSdk = cl[resource.api];
|
|
@@ -38,12 +49,12 @@ class ProvisioningDelete extends base_1.default {
|
|
|
38
49
|
await resSdk.delete(id);
|
|
39
50
|
if (showHeaders)
|
|
40
51
|
this.printHeaders(rawReader?.headers, flags);
|
|
41
|
-
this.log(`\n${cli_core_1.clColor.style.success(
|
|
52
|
+
this.log(`\n${cli_core_1.clColor.style.success("Successfully")} deleted resource of type ${cli_core_1.clColor.style.resource(resource.type)} with id ${cli_core_1.clColor.style.id(id)}\n`);
|
|
42
53
|
}
|
|
43
54
|
catch (error) {
|
|
44
55
|
if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
|
|
45
56
|
await this.showLiveDocumentation(reqReader.request, undefined, flags);
|
|
46
|
-
cl.removeInterceptor(
|
|
57
|
+
cl.removeInterceptor("request", reqReader.id);
|
|
47
58
|
}
|
|
48
59
|
else
|
|
49
60
|
this.printError(error, flags, args);
|
|
@@ -1,44 +1,53 @@
|
|
|
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
4
|
const cli_core_1 = require("@commercelayer/cli-core");
|
|
5
|
+
const base_1 = tslib_1.__importStar(require("../../base"));
|
|
6
6
|
class ProvisioningExec extends base_1.BaseCommand {
|
|
7
|
-
static description =
|
|
8
|
-
static aliases = [
|
|
7
|
+
static description = "execute an action on a resource";
|
|
8
|
+
static aliases = ["prov:exec", "pe", "pexec"];
|
|
9
9
|
static examples = [
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
"$ commercelayer provisioning:exec organizations <organizationId> transfer_ownership",
|
|
11
|
+
"$ cl prov:exec memberships <membershipId> resend",
|
|
12
12
|
];
|
|
13
13
|
static flags = {
|
|
14
14
|
attribute: base_1.Flags.string({
|
|
15
|
-
char:
|
|
16
|
-
description:
|
|
15
|
+
char: "a",
|
|
16
|
+
description: "define a resource attribute",
|
|
17
17
|
multiple: true,
|
|
18
|
-
})
|
|
18
|
+
}),
|
|
19
19
|
};
|
|
20
20
|
static args = {
|
|
21
21
|
...base_1.default.args,
|
|
22
|
-
id: base_1.Args.string({
|
|
23
|
-
|
|
22
|
+
id: base_1.Args.string({
|
|
23
|
+
name: "id",
|
|
24
|
+
description: "id of the resource on which to execute the action",
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
action: base_1.Args.string({
|
|
28
|
+
name: "action",
|
|
29
|
+
description: "action to execute on resource",
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
24
32
|
};
|
|
25
33
|
async run() {
|
|
26
34
|
const { args, flags } = await this.parse(ProvisioningExec);
|
|
27
35
|
const action = args.action;
|
|
28
36
|
if (!action)
|
|
29
|
-
this.error(
|
|
37
|
+
this.error("Missing action name");
|
|
30
38
|
const { res, id } = this.checkResourceId(args.resource, args.id);
|
|
31
39
|
const resource = this.checkResource(res, { singular: true });
|
|
32
40
|
const clp = this.initCommerceLayer(flags);
|
|
33
41
|
try {
|
|
34
42
|
const resSdk = clp[resource.api];
|
|
35
43
|
this.checkOperation(resSdk, action);
|
|
36
|
-
if (resSdk[action].length > 2) {
|
|
44
|
+
if (resSdk[action].length > 2) {
|
|
45
|
+
// Base action command has two arguments: resource id and request options
|
|
37
46
|
const attributes = this.attributeFlag(flags.attribute);
|
|
38
47
|
await resSdk[action](id, attributes);
|
|
39
48
|
}
|
|
40
49
|
else {
|
|
41
|
-
if (flags.attribute &&
|
|
50
|
+
if (flags.attribute && flags.attribute.length > 0)
|
|
42
51
|
this.warn(`Action ${cli_core_1.clColor.cli.arg(action)} does not require argumemts, all the attributes will be ignored.`);
|
|
43
52
|
await resSdk[action](id);
|
|
44
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseFilterCommand } from
|
|
1
|
+
import { BaseFilterCommand } from "../../base";
|
|
2
2
|
export default class ResourcesFetch extends BaseFilterCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static aliases: string[];
|
|
@@ -10,7 +10,7 @@ export default class ResourcesFetch extends BaseFilterCommand {
|
|
|
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
|
-
|
|
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 ResourcesFetch extends BaseFilterCommand {
|
|
|
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
|
-
|
|
24
|
+
"headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
25
25
|
};
|
|
26
26
|
static args: {
|
|
27
27
|
path: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const base_1 = require("../../base");
|
|
5
|
-
const
|
|
5
|
+
const get_1 = tslib_1.__importDefault(require("./get"));
|
|
6
6
|
const list_1 = tslib_1.__importDefault(require("./list"));
|
|
7
7
|
const relationship_1 = tslib_1.__importDefault(require("./relationship"));
|
|
8
|
-
const
|
|
8
|
+
const retrieve_1 = tslib_1.__importDefault(require("./retrieve"));
|
|
9
9
|
class ResourcesFetch extends base_1.BaseFilterCommand {
|
|
10
|
-
static description =
|
|
11
|
-
static aliases = [
|
|
10
|
+
static description = "retrieve a resource or list a set of resources";
|
|
11
|
+
static aliases = ["prov:fetch", "pf"];
|
|
12
12
|
static examples = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
"$ commercelayer provisioning:fetch roles",
|
|
14
|
+
"$ commercelayer prov:fetch roles",
|
|
15
|
+
"$ clayer prov:fetch roles/<roleId>",
|
|
16
|
+
"$ cl prov:fetch roles/<roleId>/<roleRelationship>",
|
|
17
|
+
"$ cl pf roles/{roleId}/permissions aBcdEkYWx",
|
|
18
18
|
];
|
|
19
19
|
static strict = false;
|
|
20
20
|
static flags = {
|
|
@@ -23,15 +23,23 @@ class ResourcesFetch extends base_1.BaseFilterCommand {
|
|
|
23
23
|
};
|
|
24
24
|
static args = {
|
|
25
25
|
...list_1.default.args,
|
|
26
|
-
path: base_1.Args.string({
|
|
27
|
-
|
|
26
|
+
path: base_1.Args.string({
|
|
27
|
+
name: "path",
|
|
28
|
+
description: "path (or URL) of the resource(s) to fetch",
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
id: base_1.Args.string({
|
|
32
|
+
name: "id",
|
|
33
|
+
description: "resource id",
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
28
36
|
};
|
|
29
37
|
async run() {
|
|
30
38
|
const { args } = await this.parse(ResourcesFetch);
|
|
31
39
|
const path = this.fixPath(args.path, args);
|
|
32
40
|
const id = args.id;
|
|
33
41
|
// If no relationship is defined then run retrieve/list command
|
|
34
|
-
const pathNodes = path.split(
|
|
42
|
+
const pathNodes = path.split("/");
|
|
35
43
|
if (pathNodes.length < 3)
|
|
36
44
|
return await get_1.default.run(this.argv, this.config);
|
|
37
45
|
// Build argv array to pass to Relationship command
|
|
@@ -41,13 +49,13 @@ class ResourcesFetch extends base_1.BaseFilterCommand {
|
|
|
41
49
|
}
|
|
42
50
|
fixPath(path, args, _flags) {
|
|
43
51
|
// Remove base URL
|
|
44
|
-
if (path.startsWith(
|
|
45
|
-
path = path.substring(path.indexOf(
|
|
52
|
+
if (path.startsWith("http"))
|
|
53
|
+
path = path.substring(path.indexOf("/api/") + 4);
|
|
46
54
|
// Remove 'relationships' sub-path (usually part of 'self' link)
|
|
47
|
-
if (path.includes(
|
|
48
|
-
path = path.replace(
|
|
55
|
+
if (path.includes("/relationships/"))
|
|
56
|
+
path = path.replace("/relationships", "");
|
|
49
57
|
// Remove leading slash
|
|
50
|
-
if (path.startsWith(
|
|
58
|
+
if (path.startsWith("/"))
|
|
51
59
|
path = path.substring(1);
|
|
52
60
|
// Replace {resourceId} placeholder with actual resource id
|
|
53
61
|
if (args.id)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Command from
|
|
1
|
+
import Command from "../../base";
|
|
2
2
|
export default class ProvisioningGet extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static aliases: string[];
|
|
@@ -10,7 +10,7 @@ export default class ProvisioningGet 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
|
-
|
|
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 ProvisioningGet 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
|
-
|
|
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 | undefined, Record<string, unknown>>;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
-
const retrieve_1 = tslib_1.__importDefault(require("./retrieve"));
|
|
6
5
|
const list_1 = tslib_1.__importDefault(require("./list"));
|
|
6
|
+
const retrieve_1 = tslib_1.__importDefault(require("./retrieve"));
|
|
7
7
|
class ProvisioningGet extends base_1.default {
|
|
8
|
-
static description =
|
|
9
|
-
static aliases = [
|
|
8
|
+
static description = "retrieve a resource or list a set of resources";
|
|
9
|
+
static aliases = ["prov:get", "pg", "pget"];
|
|
10
10
|
static examples = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
"$ commercelayer provisioning:get roles",
|
|
12
|
+
"$ commercelayer prov:get roles",
|
|
13
|
+
"$ clayer prov:get roles/<roleId>",
|
|
14
|
+
"$ cl prov:get roles <roleId>",
|
|
15
15
|
];
|
|
16
16
|
static strict = false;
|
|
17
17
|
static flags = {
|
|
@@ -24,7 +24,7 @@ class ProvisioningGet extends base_1.default {
|
|
|
24
24
|
async run() {
|
|
25
25
|
const { args } = await this.parse(ProvisioningGet);
|
|
26
26
|
const { id, singleton } = this.checkResourceId(args.resource, args.id, false);
|
|
27
|
-
const command =
|
|
27
|
+
const command = id || singleton ? retrieve_1.default : list_1.default;
|
|
28
28
|
const result = await command.run(this.argv, this.config);
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Command from
|
|
1
|
+
import Command from "../../base";
|
|
2
2
|
export default class ProvisioningList extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static aliases: string[];
|
|
@@ -9,7 +9,7 @@ export default class ProvisioningList extends Command {
|
|
|
9
9
|
pageSize: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
sort: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
11
|
extract: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
-
|
|
12
|
+
"force-include": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
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>;
|
|
15
15
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -20,7 +20,7 @@ export default class ProvisioningList 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
|
-
|
|
23
|
+
"headers-only": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
24
24
|
};
|
|
25
25
|
static args: {
|
|
26
26
|
resource: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|