@commercelayer/cli-plugin-provisioning 2.0.2 → 2.0.3
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/lib/commands/provisioning/create.js +2 -2
- package/lib/commands/provisioning/delete.js +1 -1
- package/lib/commands/provisioning/list.js +1 -1
- package/lib/commands/provisioning/relationship.js +1 -1
- package/lib/commands/provisioning/retrieve.js +1 -1
- package/lib/commands/provisioning/update.js +2 -2
- package/lib/util/resources/available.d.ts +8 -0
- package/lib/util/resources/available.js +8 -8
- package/lib/util/resources/build.js +6 -7
- package/lib/util/resources/index.d.ts +5 -4
- package/lib/util/resources/index.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +12 -12
|
@@ -103,7 +103,7 @@ class ProvisioningCreate extends base_1.default {
|
|
|
103
103
|
// Include flags
|
|
104
104
|
const include = this.includeFlag(flags.include, relationships);
|
|
105
105
|
// Fields flags
|
|
106
|
-
const fields = this.fieldsFlag(flags.fields, resource.
|
|
106
|
+
const fields = this.fieldsFlag(flags.fields, resource.type);
|
|
107
107
|
const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
|
|
108
108
|
const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
|
|
109
109
|
const params = {};
|
|
@@ -123,7 +123,7 @@ class ProvisioningCreate extends base_1.default {
|
|
|
123
123
|
const out = (flags.raw && rawReader) ? rawReader.rawResponse : res;
|
|
124
124
|
this.printHeaders(rawReader?.headers, flags);
|
|
125
125
|
this.printOutput(out, flags);
|
|
126
|
-
this.log(`\n${cli_core_1.clColor.style.success('Successfully')} created new resource of type ${cli_core_1.clColor.style.resource(resource.
|
|
126
|
+
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
127
|
// Save command arguments
|
|
128
128
|
// if (saveCmd) this.saveParams(saveCmd, { type: resource.api }, OPERATION, params)
|
|
129
129
|
return out;
|
|
@@ -38,7 +38,7 @@ class ProvisioningDelete extends base_1.default {
|
|
|
38
38
|
await resSdk.delete(id);
|
|
39
39
|
if (showHeaders)
|
|
40
40
|
this.printHeaders(rawReader?.headers, flags);
|
|
41
|
-
this.log(`\n${cli_core_1.clColor.style.success('Successfully')} deleted resource of type ${cli_core_1.clColor.style.resource(resource.
|
|
41
|
+
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
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
44
|
if ((0, lang_1.isRequestInterrupted)(error) && reqReader) {
|
|
@@ -74,7 +74,7 @@ class ProvisioningList extends base_1.default {
|
|
|
74
74
|
// Include flags
|
|
75
75
|
const include = this.includeFlag(flags.include, undefined, flags['force-include']);
|
|
76
76
|
// Fields flags
|
|
77
|
-
const fields = this.fieldsFlag(flags.fields, resource.
|
|
77
|
+
const fields = this.fieldsFlag(flags.fields, resource.type);
|
|
78
78
|
// Where flags
|
|
79
79
|
const wheres = this.whereFlag(flags.where);
|
|
80
80
|
// Sort flags
|
|
@@ -41,7 +41,7 @@ class ResourcesRelationship extends base_1.default {
|
|
|
41
41
|
// Include flags
|
|
42
42
|
const include = this.includeFlag(flags.include);
|
|
43
43
|
// Fields flags
|
|
44
|
-
const fields = this.fieldsFlag(flags.fields, resource.
|
|
44
|
+
const fields = this.fieldsFlag(flags.fields, resource.type);
|
|
45
45
|
// Where flags
|
|
46
46
|
const wheres = this.whereFlag(flags.where);
|
|
47
47
|
// Sort flags
|
|
@@ -52,7 +52,7 @@ class ProvisioningRetrieve extends base_1.default {
|
|
|
52
52
|
// Include flags
|
|
53
53
|
const include = this.includeFlag(flags.include);
|
|
54
54
|
// Fields flags
|
|
55
|
-
const fields = this.fieldsFlag(flags.fields, resource.
|
|
55
|
+
const fields = this.fieldsFlag(flags.fields, resource.type);
|
|
56
56
|
const cl = this.initCommerceLayer(flags);
|
|
57
57
|
const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
|
|
58
58
|
const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
|
|
@@ -112,7 +112,7 @@ class ProvisioningUpdate extends base_1.default {
|
|
|
112
112
|
// Include flags
|
|
113
113
|
const include = this.includeFlag(flags.include, relationships);
|
|
114
114
|
// Fields flags
|
|
115
|
-
const fields = this.fieldsFlag(flags.fields, resource.
|
|
115
|
+
const fields = this.fieldsFlag(flags.fields, resource.type);
|
|
116
116
|
const rawReader = flags.raw ? cl.addRawResponseReader({ headers: showHeaders }) : undefined;
|
|
117
117
|
const reqReader = flags.doc ? (0, lang_1.addRequestReader)(cl) : undefined;
|
|
118
118
|
const params = {};
|
|
@@ -141,7 +141,7 @@ class ProvisioningUpdate extends base_1.default {
|
|
|
141
141
|
const out = (flags.raw && rawReader) ? rawReader.rawResponse : res;
|
|
142
142
|
this.printHeaders(rawReader?.headers, flags);
|
|
143
143
|
this.printOutput(out, flags);
|
|
144
|
-
this.log(`\n${cli_core_1.clColor.style.success('Successfully')} updated resource of type ${cli_core_1.clColor.style.resource(resource.
|
|
144
|
+
this.log(`\n${cli_core_1.clColor.style.success('Successfully')} updated resource of type ${cli_core_1.clColor.style.resource(resource.type)} with id ${cli_core_1.clColor.style.id(res.id)}\n`);
|
|
145
145
|
// Save command arguments
|
|
146
146
|
// if (saveCmd) this.saveParams(saveCmd, { type: resource.api }, OPERATION, params)
|
|
147
147
|
return out;
|
|
@@ -1,34 +1,42 @@
|
|
|
1
1
|
declare const RESOURCES: readonly [{
|
|
2
2
|
readonly name: "api_credential";
|
|
3
|
+
readonly type: "api_credentials";
|
|
3
4
|
readonly api: "api_credentials";
|
|
4
5
|
readonly model: "ApiCredential";
|
|
5
6
|
}, {
|
|
6
7
|
readonly name: "application_membership";
|
|
8
|
+
readonly type: "application_memberships";
|
|
7
9
|
readonly api: "application_memberships";
|
|
8
10
|
readonly model: "ApplicationMembership";
|
|
9
11
|
}, {
|
|
10
12
|
readonly name: "membership";
|
|
13
|
+
readonly type: "memberships";
|
|
11
14
|
readonly api: "memberships";
|
|
12
15
|
readonly model: "Membership";
|
|
13
16
|
}, {
|
|
14
17
|
readonly name: "organization";
|
|
18
|
+
readonly type: "organizations";
|
|
15
19
|
readonly api: "organizations";
|
|
16
20
|
readonly model: "Organization";
|
|
17
21
|
}, {
|
|
18
22
|
readonly name: "permission";
|
|
23
|
+
readonly type: "permissions";
|
|
19
24
|
readonly api: "permissions";
|
|
20
25
|
readonly model: "Permission";
|
|
21
26
|
}, {
|
|
22
27
|
readonly name: "role";
|
|
28
|
+
readonly type: "roles";
|
|
23
29
|
readonly api: "roles";
|
|
24
30
|
readonly model: "Role";
|
|
25
31
|
}, {
|
|
26
32
|
readonly name: "user";
|
|
33
|
+
readonly type: "users";
|
|
27
34
|
readonly api: "user";
|
|
28
35
|
readonly model: "User";
|
|
29
36
|
readonly singleton: true;
|
|
30
37
|
}, {
|
|
31
38
|
readonly name: "version";
|
|
39
|
+
readonly type: "versions";
|
|
32
40
|
readonly api: "versions";
|
|
33
41
|
readonly model: "Version";
|
|
34
42
|
}];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const RESOURCES = [
|
|
4
|
-
{ name: 'api_credential', api: 'api_credentials', model: 'ApiCredential' },
|
|
5
|
-
{ name: 'application_membership', api: 'application_memberships', model: 'ApplicationMembership' },
|
|
6
|
-
{ name: 'membership', api: 'memberships', model: 'Membership' },
|
|
7
|
-
{ name: 'organization', api: 'organizations', model: 'Organization' },
|
|
8
|
-
{ name: 'permission', api: 'permissions', model: 'Permission' },
|
|
9
|
-
{ name: 'role', api: 'roles', model: 'Role' },
|
|
10
|
-
{ name: 'user', api: 'user', model: 'User', singleton: true },
|
|
11
|
-
{ name: 'version', api: 'versions', model: 'Version' },
|
|
4
|
+
{ name: 'api_credential', type: 'api_credentials', api: 'api_credentials', model: 'ApiCredential' },
|
|
5
|
+
{ name: 'application_membership', type: 'application_memberships', api: 'application_memberships', model: 'ApplicationMembership' },
|
|
6
|
+
{ name: 'membership', type: 'memberships', api: 'memberships', model: 'Membership' },
|
|
7
|
+
{ name: 'organization', type: 'organizations', api: 'organizations', model: 'Organization' },
|
|
8
|
+
{ name: 'permission', type: 'permissions', api: 'permissions', model: 'Permission' },
|
|
9
|
+
{ name: 'role', type: 'roles', api: 'roles', model: 'Role' },
|
|
10
|
+
{ name: 'user', type: 'users', api: 'user', model: 'User', singleton: true },
|
|
11
|
+
{ name: 'version', type: 'versions', api: 'versions', model: 'Version' },
|
|
12
12
|
];
|
|
13
13
|
exports.default = RESOURCES;
|
|
@@ -4,17 +4,16 @@ const provisioning_sdk_1 = require("@commercelayer/provisioning-sdk");
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const cli_core_1 = require("@commercelayer/cli-core");
|
|
7
|
-
const isSingleton = (res) => {
|
|
8
|
-
return (cli_core_1.clText.singularize(res) === res);
|
|
9
|
-
};
|
|
10
7
|
const parseResourcesSdk = async () => {
|
|
11
8
|
const resList = provisioning_sdk_1.CommerceLayerProvisioningStatic.resources().map(r => {
|
|
12
|
-
const
|
|
9
|
+
const res = r;
|
|
10
|
+
const singular = cli_core_1.clText.singularize(res);
|
|
13
11
|
const item = {
|
|
14
12
|
name: singular,
|
|
15
|
-
|
|
13
|
+
type: res,
|
|
14
|
+
api: provisioning_sdk_1.CommerceLayerProvisioningStatic.isSingleton(res) ? cli_core_1.clText.singularize(res) : res,
|
|
16
15
|
model: cli_core_1.clText.camelize(singular),
|
|
17
|
-
singleton: isSingleton(
|
|
16
|
+
singleton: provisioning_sdk_1.CommerceLayerProvisioningStatic.isSingleton(res),
|
|
18
17
|
};
|
|
19
18
|
return item;
|
|
20
19
|
});
|
|
@@ -30,7 +29,7 @@ const exportResources = async ({ source = 'sdk', variable = false, name = 'resou
|
|
|
30
29
|
lines.push((variable ? `const ${name} = ` : '') + (array ? '[' : ''));
|
|
31
30
|
const resLines = resources.map(res => {
|
|
32
31
|
let item = `${tab ? '\t' : ''}{ `;
|
|
33
|
-
item += `name: '${res.name}', api: '${res.api}', model: '${res.model}'`;
|
|
32
|
+
item += `name: '${res.name}', type: '${res.type}', api: '${res.api}', model: '${res.model}'`;
|
|
34
33
|
if (res.singleton)
|
|
35
34
|
item += ', singleton: true';
|
|
36
35
|
item += ' },';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ResourceTypeLock } from '@commercelayer/provisioning-sdk';
|
|
2
|
-
interface
|
|
2
|
+
interface ApiResource {
|
|
3
3
|
name: string;
|
|
4
|
-
|
|
4
|
+
type: ResourceTypeLock;
|
|
5
|
+
api: string;
|
|
5
6
|
model: string;
|
|
6
7
|
singleton?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare const findResource: (res: string, { singular }?: {
|
|
9
10
|
singular?: boolean | undefined;
|
|
10
|
-
}) => (
|
|
11
|
+
}) => (ApiResource | undefined);
|
|
11
12
|
declare const resourceList: (field: "name" | "api" | "model") => string[];
|
|
12
|
-
export { findResource, resourceList, type Resource };
|
|
13
|
+
export { findResource, resourceList, type ApiResource as Resource };
|
|
@@ -9,7 +9,7 @@ const findResource = (res, { singular = false } = {}) => {
|
|
|
9
9
|
return undefined;
|
|
10
10
|
const lowRes = res.toLowerCase();
|
|
11
11
|
return resources.find(r => {
|
|
12
|
-
return (lowRes === r.
|
|
12
|
+
return (lowRes === r.type) || (singular && (lowRes === r.name));
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
exports.findResource = findResource;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/cli-plugin-provisioning",
|
|
3
3
|
"description": "Commerce Layer CLI Provisioning plugin",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"author": "Pierluigi Viti <pierluigi@commercelayer.io>",
|
|
6
6
|
"homepage": "https://github.com/commercelayer/commercelayer-cli-plugin-provisioning",
|
|
7
7
|
"repository": "commercelayer/commercelayer-cli-plugin-provisioning",
|
|
@@ -57,30 +57,30 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@commercelayer/cli-dev": "^3.0.6",
|
|
59
59
|
"@commercelayer/eslint-config-ts": "^1.4.5",
|
|
60
|
-
"@oclif/plugin-help": "^6.2.
|
|
60
|
+
"@oclif/plugin-help": "^6.2.18",
|
|
61
61
|
"@oclif/test": "^3.2.15",
|
|
62
62
|
"@semantic-release/changelog": "^6.0.3",
|
|
63
63
|
"@semantic-release/git": "^10.0.1",
|
|
64
64
|
"@types/chai": "^4.3.20",
|
|
65
65
|
"@types/inquirer": "^8.2.10",
|
|
66
|
-
"@types/mocha": "^10.0.
|
|
67
|
-
"@types/node": "^20.
|
|
66
|
+
"@types/mocha": "^10.0.10",
|
|
67
|
+
"@types/node": "^20.17.9",
|
|
68
68
|
"chai": "^4.5.0",
|
|
69
69
|
"eslint": "^8.57.1",
|
|
70
|
-
"mocha": "^10.
|
|
70
|
+
"mocha": "^10.8.2",
|
|
71
71
|
"nyc": "^15.1.0",
|
|
72
|
-
"oclif": "^4.
|
|
72
|
+
"oclif": "^4.16.0",
|
|
73
73
|
"semantic-release": "^23.1.1",
|
|
74
|
-
"tsx": "^4.19.
|
|
75
|
-
"typescript": "^5.
|
|
74
|
+
"tsx": "^4.19.2",
|
|
75
|
+
"typescript": "^5.7.2"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@commercelayer/cli-core": "^5.
|
|
79
|
-
"@commercelayer/provisioning-sdk": "^2.
|
|
78
|
+
"@commercelayer/cli-core": "^5.4.2",
|
|
79
|
+
"@commercelayer/provisioning-sdk": "^2.2.0",
|
|
80
80
|
"@oclif/core": "^3.27.0",
|
|
81
81
|
"inquirer": "^8.2.6",
|
|
82
|
-
"json-2-csv": "^5.5.
|
|
83
|
-
"tslib": "^2.8.
|
|
82
|
+
"json-2-csv": "^5.5.7",
|
|
83
|
+
"tslib": "^2.8.1"
|
|
84
84
|
},
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|