@salesforce/b2c-cli 0.0.8 → 0.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/dist/commands/scapi/schemas/get.d.ts +86 -0
- package/dist/commands/scapi/schemas/get.js +317 -0
- package/dist/commands/scapi/schemas/get.js.map +1 -0
- package/dist/commands/scapi/schemas/list.d.ts +48 -0
- package/dist/commands/scapi/schemas/list.js +148 -0
- package/dist/commands/scapi/schemas/list.js.map +1 -0
- package/dist/utils/scapi/schemas.d.ts +40 -0
- package/dist/utils/scapi/schemas.js +49 -0
- package/dist/utils/scapi/schemas.js.map +1 -0
- package/oclif.manifest.json +1488 -949
- package/package.json +5 -2
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ScapiSchemasCommand } from '../../../utils/scapi/schemas.js';
|
|
2
|
+
/**
|
|
3
|
+
* Response type for the get command when using --json flag.
|
|
4
|
+
*/
|
|
5
|
+
interface GetOutput {
|
|
6
|
+
apiFamily: string;
|
|
7
|
+
apiName: string;
|
|
8
|
+
apiVersion: string;
|
|
9
|
+
schema: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Command to get a specific SCAPI schema.
|
|
13
|
+
*
|
|
14
|
+
* By default, outputs collapsed schema for context efficiency (ideal for agentic use).
|
|
15
|
+
* Use --expand-* flags to selectively expand specific paths, schemas, or examples.
|
|
16
|
+
* Use --expand-all to get the full, unmodified schema.
|
|
17
|
+
*/
|
|
18
|
+
export default class ScapiSchemasGet extends ScapiSchemasCommand<typeof ScapiSchemasGet> {
|
|
19
|
+
static args: {
|
|
20
|
+
apiFamily: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
21
|
+
apiName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
22
|
+
apiVersion: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
static description: string;
|
|
25
|
+
static enableJsonFlag: boolean;
|
|
26
|
+
static examples: string[];
|
|
27
|
+
static flags: {
|
|
28
|
+
'expand-paths': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
'expand-schemas': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
+
'expand-examples': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
|
+
'expand-custom-properties': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
32
|
+
'expand-all': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
'list-paths': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
34
|
+
'list-schemas': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
35
|
+
'list-examples': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
36
|
+
yaml: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
37
|
+
'tenant-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
38
|
+
'client-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
39
|
+
'client-secret': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
40
|
+
scope: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
41
|
+
'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
42
|
+
'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
43
|
+
'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
44
|
+
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
46
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
47
|
+
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
48
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
49
|
+
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
50
|
+
'working-directory': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
51
|
+
'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
52
|
+
'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
53
|
+
'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
54
|
+
};
|
|
55
|
+
run(): Promise<GetOutput | null | string[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Build expansion info string for the log message.
|
|
58
|
+
*/
|
|
59
|
+
private getExpansionInfo;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a value is a non-empty object (not an array).
|
|
62
|
+
*/
|
|
63
|
+
private isNonEmptyObject;
|
|
64
|
+
/**
|
|
65
|
+
* Output a list of items (paths, schemas, or examples).
|
|
66
|
+
*/
|
|
67
|
+
private outputList;
|
|
68
|
+
/**
|
|
69
|
+
* Serialize object to YAML format.
|
|
70
|
+
* Uses a simple JSON-to-YAML conversion for basic YAML output.
|
|
71
|
+
*/
|
|
72
|
+
private serializeToYaml;
|
|
73
|
+
/**
|
|
74
|
+
* Serialize an array to YAML format.
|
|
75
|
+
*/
|
|
76
|
+
private serializeYamlArray;
|
|
77
|
+
/**
|
|
78
|
+
* Serialize an object to YAML format.
|
|
79
|
+
*/
|
|
80
|
+
private serializeYamlObject;
|
|
81
|
+
/**
|
|
82
|
+
* Serialize a string value to YAML, quoting if necessary.
|
|
83
|
+
*/
|
|
84
|
+
private serializeYamlString;
|
|
85
|
+
}
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Args, Flags } from '@oclif/core';
|
|
7
|
+
import { collapseOpenApiSchema, getPathKeys, getSchemaNames, getExampleNames, } from '@salesforce/b2c-tooling-sdk/operations/scapi-schemas';
|
|
8
|
+
import { ScapiSchemasCommand, formatApiError } from '../../../utils/scapi/schemas.js';
|
|
9
|
+
import { t } from '../../../i18n/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Command to get a specific SCAPI schema.
|
|
12
|
+
*
|
|
13
|
+
* By default, outputs collapsed schema for context efficiency (ideal for agentic use).
|
|
14
|
+
* Use --expand-* flags to selectively expand specific paths, schemas, or examples.
|
|
15
|
+
* Use --expand-all to get the full, unmodified schema.
|
|
16
|
+
*/
|
|
17
|
+
export default class ScapiSchemasGet extends ScapiSchemasCommand {
|
|
18
|
+
static args = {
|
|
19
|
+
apiFamily: Args.string({
|
|
20
|
+
description: t('args.apiFamily.description', 'API family (e.g., shopper, admin)'),
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
apiName: Args.string({
|
|
24
|
+
description: t('args.apiName.description', 'API name (e.g., products, orders)'),
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
apiVersion: Args.string({
|
|
28
|
+
description: t('args.apiVersion.description', 'API version (e.g., v1)'),
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
static description = t('commands.scapi.schemas.get.description', 'Get a specific SCAPI schema with optional selective expansion');
|
|
33
|
+
static enableJsonFlag = true;
|
|
34
|
+
static examples = [
|
|
35
|
+
// Basic usage
|
|
36
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd',
|
|
37
|
+
// Full schema
|
|
38
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --expand-all',
|
|
39
|
+
// Selective expansion
|
|
40
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --expand-paths /products',
|
|
41
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --expand-schemas Product,SearchResult',
|
|
42
|
+
// List available paths/schemas
|
|
43
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --list-paths',
|
|
44
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --list-schemas',
|
|
45
|
+
// YAML output
|
|
46
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --yaml',
|
|
47
|
+
// JSON wrapped output
|
|
48
|
+
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --json',
|
|
49
|
+
];
|
|
50
|
+
static flags = {
|
|
51
|
+
...ScapiSchemasCommand.baseFlags,
|
|
52
|
+
// Selective expansion flags
|
|
53
|
+
'expand-paths': Flags.string({
|
|
54
|
+
description: t('flags.expandPaths.description', 'Paths to fully expand (comma-separated, e.g., /products,/orders)'),
|
|
55
|
+
multiple: false,
|
|
56
|
+
}),
|
|
57
|
+
'expand-schemas': Flags.string({
|
|
58
|
+
description: t('flags.expandSchemas.description', 'Schema names to fully expand (comma-separated)'),
|
|
59
|
+
multiple: false,
|
|
60
|
+
}),
|
|
61
|
+
'expand-examples': Flags.string({
|
|
62
|
+
description: t('flags.expandExamples.description', 'Example names to fully expand (comma-separated)'),
|
|
63
|
+
multiple: false,
|
|
64
|
+
}),
|
|
65
|
+
'expand-custom-properties': Flags.boolean({
|
|
66
|
+
description: t('flags.expandCustomProperties.description', 'Expand custom properties'),
|
|
67
|
+
default: true,
|
|
68
|
+
allowNo: true,
|
|
69
|
+
}),
|
|
70
|
+
'expand-all': Flags.boolean({
|
|
71
|
+
description: t('flags.expandAll.description', 'Return full schema without collapsing (overrides selective expand)'),
|
|
72
|
+
default: false,
|
|
73
|
+
}),
|
|
74
|
+
// List available items flags
|
|
75
|
+
'list-paths': Flags.boolean({
|
|
76
|
+
description: t('flags.listPaths.description', 'List available paths in the schema and exit'),
|
|
77
|
+
default: false,
|
|
78
|
+
exclusive: ['list-schemas', 'list-examples'],
|
|
79
|
+
}),
|
|
80
|
+
'list-schemas': Flags.boolean({
|
|
81
|
+
description: t('flags.listSchemas.description', 'List available schema names and exit'),
|
|
82
|
+
default: false,
|
|
83
|
+
exclusive: ['list-paths', 'list-examples'],
|
|
84
|
+
}),
|
|
85
|
+
'list-examples': Flags.boolean({
|
|
86
|
+
description: t('flags.listExamples.description', 'List available example names and exit'),
|
|
87
|
+
default: false,
|
|
88
|
+
exclusive: ['list-paths', 'list-schemas'],
|
|
89
|
+
}),
|
|
90
|
+
// Output format flags
|
|
91
|
+
yaml: Flags.boolean({
|
|
92
|
+
description: t('flags.yaml.description', 'Output as YAML instead of JSON'),
|
|
93
|
+
default: false,
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
96
|
+
async run() {
|
|
97
|
+
this.requireOAuthCredentials();
|
|
98
|
+
const { apiFamily, apiName, apiVersion } = this.args;
|
|
99
|
+
const { 'expand-paths': expandPathsRaw, 'expand-schemas': expandSchemasRaw, 'expand-examples': expandExamplesRaw, 'expand-custom-properties': expandCustomProperties, 'expand-all': expandAll, 'list-paths': listPaths, 'list-schemas': listSchemas, 'list-examples': listExamples, yaml: outputYaml, } = this.flags;
|
|
100
|
+
// Parse comma-separated values
|
|
101
|
+
const expandPaths = expandPathsRaw ? expandPathsRaw.split(',').map((p) => p.trim()) : [];
|
|
102
|
+
const expandSchemas = expandSchemasRaw ? expandSchemasRaw.split(',').map((s) => s.trim()) : [];
|
|
103
|
+
const expandExamples = expandExamplesRaw ? expandExamplesRaw.split(',').map((e) => e.trim()) : [];
|
|
104
|
+
if (!this.jsonEnabled()) {
|
|
105
|
+
// Build expansion info for the log message
|
|
106
|
+
const expansionInfo = this.getExpansionInfo(expandAll, expandPaths, expandSchemas, expandExamples);
|
|
107
|
+
this.log(t('commands.scapi.schemas.get.fetching', 'Fetching {{apiFamily}}/{{apiName}}/{{apiVersion}} schema{{expansionInfo}}...', {
|
|
108
|
+
apiFamily,
|
|
109
|
+
apiName,
|
|
110
|
+
apiVersion,
|
|
111
|
+
expansionInfo,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
const client = this.getSchemasClient();
|
|
115
|
+
const { data, error } = await client.GET('/organizations/{organizationId}/schemas/{apiFamily}/{apiName}/{apiVersion}', {
|
|
116
|
+
params: {
|
|
117
|
+
path: {
|
|
118
|
+
organizationId: this.getOrganizationId(),
|
|
119
|
+
apiFamily,
|
|
120
|
+
apiName,
|
|
121
|
+
apiVersion,
|
|
122
|
+
},
|
|
123
|
+
query: expandCustomProperties ? { expand: 'custom_properties' } : undefined,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
if (error) {
|
|
127
|
+
this.error(t('commands.scapi.schemas.get.error', 'Failed to fetch schema: {{message}}', {
|
|
128
|
+
message: formatApiError(error),
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
// Handle list-* flags - just output the available items
|
|
132
|
+
if (listPaths || listSchemas || listExamples) {
|
|
133
|
+
const fullSchema = data;
|
|
134
|
+
if (listPaths) {
|
|
135
|
+
const paths = getPathKeys(fullSchema);
|
|
136
|
+
return this.outputList(paths, 'paths');
|
|
137
|
+
}
|
|
138
|
+
if (listSchemas) {
|
|
139
|
+
const schemas = getSchemaNames(fullSchema);
|
|
140
|
+
return this.outputList(schemas, 'schemas');
|
|
141
|
+
}
|
|
142
|
+
if (listExamples) {
|
|
143
|
+
const examples = getExampleNames(fullSchema);
|
|
144
|
+
return this.outputList(examples, 'examples');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Apply collapsing unless --expand-all is set
|
|
148
|
+
let schema;
|
|
149
|
+
if (expandAll) {
|
|
150
|
+
schema = data;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const fullSchema = data;
|
|
154
|
+
schema = collapseOpenApiSchema(fullSchema, {
|
|
155
|
+
expandPaths,
|
|
156
|
+
expandSchemas,
|
|
157
|
+
expandExamples,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const output = { apiFamily, apiName, apiVersion, schema };
|
|
161
|
+
// For --json flag, oclif handles serialization (wrapped output)
|
|
162
|
+
if (this.jsonEnabled()) {
|
|
163
|
+
return output;
|
|
164
|
+
}
|
|
165
|
+
// Output to stdout (raw schema)
|
|
166
|
+
if (outputYaml) {
|
|
167
|
+
process.stdout.write(this.serializeToYaml(schema));
|
|
168
|
+
process.stdout.write('\n');
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
process.stdout.write(JSON.stringify(schema, null, 2));
|
|
172
|
+
process.stdout.write('\n');
|
|
173
|
+
}
|
|
174
|
+
return output;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Build expansion info string for the log message.
|
|
178
|
+
*/
|
|
179
|
+
getExpansionInfo(expandAll, expandPaths, expandSchemas, expandExamples) {
|
|
180
|
+
if (expandAll) {
|
|
181
|
+
return ' (expand=full)';
|
|
182
|
+
}
|
|
183
|
+
const parts = [];
|
|
184
|
+
if (expandPaths.length > 0) {
|
|
185
|
+
parts.push(`paths: ${expandPaths.join(', ')}`);
|
|
186
|
+
}
|
|
187
|
+
if (expandSchemas.length > 0) {
|
|
188
|
+
parts.push(`schemas: ${expandSchemas.join(', ')}`);
|
|
189
|
+
}
|
|
190
|
+
if (expandExamples.length > 0) {
|
|
191
|
+
parts.push(`examples: ${expandExamples.join(', ')}`);
|
|
192
|
+
}
|
|
193
|
+
if (parts.length > 0) {
|
|
194
|
+
return ` (expanding ${parts.join('; ')})`;
|
|
195
|
+
}
|
|
196
|
+
return ' (outline only - use --expand-paths, --expand-schemas, or --expand-all for details)';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if a value is a non-empty object (not an array).
|
|
200
|
+
*/
|
|
201
|
+
isNonEmptyObject(value) {
|
|
202
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) && Object.keys(value).length > 0;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Output a list of items (paths, schemas, or examples).
|
|
206
|
+
*/
|
|
207
|
+
outputList(items, type) {
|
|
208
|
+
if (this.jsonEnabled()) {
|
|
209
|
+
return items;
|
|
210
|
+
}
|
|
211
|
+
if (items.length === 0) {
|
|
212
|
+
this.log(t('commands.scapi.schemas.get.noItems', 'No {{type}} found.', { type }));
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.log(t('commands.scapi.schemas.get.itemCount', 'Found {{count}} {{type}}:', { count: items.length, type }));
|
|
216
|
+
for (const item of items) {
|
|
217
|
+
this.log(` ${item}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return items;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Serialize object to YAML format.
|
|
224
|
+
* Uses a simple JSON-to-YAML conversion for basic YAML output.
|
|
225
|
+
*/
|
|
226
|
+
serializeToYaml(obj, indent = 0) {
|
|
227
|
+
if (obj === null || obj === undefined) {
|
|
228
|
+
return 'null';
|
|
229
|
+
}
|
|
230
|
+
if (typeof obj === 'string') {
|
|
231
|
+
return this.serializeYamlString(obj);
|
|
232
|
+
}
|
|
233
|
+
if (typeof obj === 'number' || typeof obj === 'boolean') {
|
|
234
|
+
return String(obj);
|
|
235
|
+
}
|
|
236
|
+
if (Array.isArray(obj)) {
|
|
237
|
+
return this.serializeYamlArray(obj, indent);
|
|
238
|
+
}
|
|
239
|
+
if (typeof obj === 'object') {
|
|
240
|
+
return this.serializeYamlObject(obj, indent);
|
|
241
|
+
}
|
|
242
|
+
return String(obj);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Serialize an array to YAML format.
|
|
246
|
+
*/
|
|
247
|
+
serializeYamlArray(arr, indent) {
|
|
248
|
+
if (arr.length === 0) {
|
|
249
|
+
return '[]';
|
|
250
|
+
}
|
|
251
|
+
// For arrays of primitives, use inline format
|
|
252
|
+
if (arr.every((item) => typeof item !== 'object' || item === null)) {
|
|
253
|
+
return `[${arr.map((item) => this.serializeToYaml(item, 0)).join(', ')}]`;
|
|
254
|
+
}
|
|
255
|
+
// For arrays of objects, use block format
|
|
256
|
+
const indentStr = ' '.repeat(indent);
|
|
257
|
+
const lines = [];
|
|
258
|
+
for (const item of arr) {
|
|
259
|
+
const serialized = this.serializeToYaml(item, indent + 1);
|
|
260
|
+
if (typeof item === 'object' && item !== null && !Array.isArray(item)) {
|
|
261
|
+
// Object items - first line starts with -, rest are indented
|
|
262
|
+
const objLines = serialized.split('\n');
|
|
263
|
+
lines.push(`${indentStr}- ${objLines[0]}`);
|
|
264
|
+
for (let i = 1; i < objLines.length; i++) {
|
|
265
|
+
lines.push(`${indentStr} ${objLines[i]}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
lines.push(`${indentStr}- ${serialized}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return lines.join('\n');
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Serialize an object to YAML format.
|
|
276
|
+
*/
|
|
277
|
+
serializeYamlObject(obj, indent) {
|
|
278
|
+
const entries = Object.entries(obj);
|
|
279
|
+
if (entries.length === 0) {
|
|
280
|
+
return '{}';
|
|
281
|
+
}
|
|
282
|
+
const indentStr = ' '.repeat(indent);
|
|
283
|
+
const lines = [];
|
|
284
|
+
for (const [key, value] of entries) {
|
|
285
|
+
const serializedValue = this.serializeToYaml(value, indent + 1);
|
|
286
|
+
if (this.isNonEmptyObject(value)) {
|
|
287
|
+
// Nested object - put on next line
|
|
288
|
+
lines.push(`${indentStr}${key}:`);
|
|
289
|
+
for (const line of serializedValue.split('\n')) {
|
|
290
|
+
lines.push(`${indentStr} ${line}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else if (Array.isArray(value) && value.some((item) => typeof item === 'object')) {
|
|
294
|
+
// Array with objects - put on next line
|
|
295
|
+
lines.push(`${indentStr}${key}:`);
|
|
296
|
+
for (const line of serializedValue.split('\n')) {
|
|
297
|
+
lines.push(line);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
// Simple value or empty object/array - inline
|
|
302
|
+
lines.push(`${indentStr}${key}: ${serializedValue}`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return lines.join('\n');
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Serialize a string value to YAML, quoting if necessary.
|
|
309
|
+
*/
|
|
310
|
+
serializeYamlString(str) {
|
|
311
|
+
if (str.includes('\n') || str.includes(':') || str.includes('#') || str === '') {
|
|
312
|
+
return JSON.stringify(str);
|
|
313
|
+
}
|
|
314
|
+
return str;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/commands/scapi/schemas/get.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,eAAe,GAEhB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,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D,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,GAAW;QACrC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;YAC/E,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SchemaListItem } from '@salesforce/b2c-tooling-sdk/clients';
|
|
2
|
+
import { ScapiSchemasCommand } from '../../../utils/scapi/schemas.js';
|
|
3
|
+
/**
|
|
4
|
+
* Response type for the list command.
|
|
5
|
+
*/
|
|
6
|
+
interface ListOutput {
|
|
7
|
+
schemas: SchemaListItem[];
|
|
8
|
+
total: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Command to list available SCAPI schemas.
|
|
12
|
+
*/
|
|
13
|
+
export default class ScapiSchemasList extends ScapiSchemasCommand<typeof ScapiSchemasList> {
|
|
14
|
+
static description: string;
|
|
15
|
+
static enableJsonFlag: boolean;
|
|
16
|
+
static examples: string[];
|
|
17
|
+
static flags: {
|
|
18
|
+
'api-family': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'api-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
status: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
columns: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
extended: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
'tenant-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
'client-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
'client-secret': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
scope: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
+
'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
|
+
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
34
|
+
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
35
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
36
|
+
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
37
|
+
'working-directory': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
38
|
+
'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
39
|
+
'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
40
|
+
'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
41
|
+
};
|
|
42
|
+
run(): Promise<ListOutput>;
|
|
43
|
+
/**
|
|
44
|
+
* Determines which columns to display based on flags.
|
|
45
|
+
*/
|
|
46
|
+
private getSelectedColumns;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Flags } from '@oclif/core';
|
|
7
|
+
import { TableRenderer } from '@salesforce/b2c-tooling-sdk/cli';
|
|
8
|
+
import { ScapiSchemasCommand, formatApiError } from '../../../utils/scapi/schemas.js';
|
|
9
|
+
import { t } from '../../../i18n/index.js';
|
|
10
|
+
const COLUMNS = {
|
|
11
|
+
apiFamily: {
|
|
12
|
+
header: 'API Family',
|
|
13
|
+
get: (s) => s.apiFamily || '-',
|
|
14
|
+
},
|
|
15
|
+
apiName: {
|
|
16
|
+
header: 'API Name',
|
|
17
|
+
get: (s) => s.apiName || '-',
|
|
18
|
+
},
|
|
19
|
+
apiVersion: {
|
|
20
|
+
header: 'Version',
|
|
21
|
+
get: (s) => s.apiVersion || '-',
|
|
22
|
+
},
|
|
23
|
+
status: {
|
|
24
|
+
header: 'Status',
|
|
25
|
+
get: (s) => s.status || '-',
|
|
26
|
+
},
|
|
27
|
+
schemaVersion: {
|
|
28
|
+
header: 'Schema Ver',
|
|
29
|
+
get: (s) => s.schemaVersion || '-',
|
|
30
|
+
extended: true,
|
|
31
|
+
},
|
|
32
|
+
link: {
|
|
33
|
+
header: 'Link',
|
|
34
|
+
get: (s) => s.link || '-',
|
|
35
|
+
extended: true,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
/** Default columns shown without --extended */
|
|
39
|
+
const DEFAULT_COLUMNS = ['apiFamily', 'apiName', 'apiVersion', 'status'];
|
|
40
|
+
const tableRenderer = new TableRenderer(COLUMNS);
|
|
41
|
+
/**
|
|
42
|
+
* Command to list available SCAPI schemas.
|
|
43
|
+
*/
|
|
44
|
+
export default class ScapiSchemasList extends ScapiSchemasCommand {
|
|
45
|
+
static description = t('commands.scapi.schemas.list.description', 'List available SCAPI schemas');
|
|
46
|
+
static enableJsonFlag = true;
|
|
47
|
+
static examples = [
|
|
48
|
+
'<%= config.bin %> <%= command.id %> --tenant-id f_ecom_zzxy_prd',
|
|
49
|
+
'<%= config.bin %> <%= command.id %> --tenant-id f_ecom_zzxy_prd --api-family shopper',
|
|
50
|
+
'<%= config.bin %> <%= command.id %> --tenant-id f_ecom_zzxy_prd --api-name products',
|
|
51
|
+
'<%= config.bin %> <%= command.id %> --tenant-id f_ecom_zzxy_prd --status current',
|
|
52
|
+
'<%= config.bin %> <%= command.id %> --tenant-id f_ecom_zzxy_prd --extended',
|
|
53
|
+
'<%= config.bin %> <%= command.id %> --tenant-id f_ecom_zzxy_prd --json',
|
|
54
|
+
];
|
|
55
|
+
static flags = {
|
|
56
|
+
...ScapiSchemasCommand.baseFlags,
|
|
57
|
+
'api-family': Flags.string({
|
|
58
|
+
description: t('flags.apiFamily.description', 'Filter by API family (e.g., shopper, admin)'),
|
|
59
|
+
}),
|
|
60
|
+
'api-name': Flags.string({
|
|
61
|
+
description: t('flags.apiName.description', 'Filter by API name (e.g., products, orders)'),
|
|
62
|
+
}),
|
|
63
|
+
'api-version': Flags.string({
|
|
64
|
+
description: t('flags.apiVersion.description', 'Filter by API version (e.g., v1)'),
|
|
65
|
+
}),
|
|
66
|
+
status: Flags.string({
|
|
67
|
+
char: 's',
|
|
68
|
+
description: t('flags.status.description', 'Filter by schema status'),
|
|
69
|
+
options: ['current', 'deprecated'],
|
|
70
|
+
}),
|
|
71
|
+
columns: Flags.string({
|
|
72
|
+
char: 'c',
|
|
73
|
+
description: `Columns to display (comma-separated). Available: ${Object.keys(COLUMNS).join(', ')}`,
|
|
74
|
+
}),
|
|
75
|
+
extended: Flags.boolean({
|
|
76
|
+
char: 'x',
|
|
77
|
+
description: t('flags.extended.description', 'Show all columns including extended fields'),
|
|
78
|
+
default: false,
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
async run() {
|
|
82
|
+
this.requireOAuthCredentials();
|
|
83
|
+
const { 'api-family': apiFamily, 'api-name': apiName, 'api-version': apiVersion, status } = this.flags;
|
|
84
|
+
if (!this.jsonEnabled()) {
|
|
85
|
+
this.log(t('commands.scapi.schemas.list.fetching', 'Fetching SCAPI schemas...'));
|
|
86
|
+
}
|
|
87
|
+
const client = this.getSchemasClient();
|
|
88
|
+
const { data, error } = await client.GET('/organizations/{organizationId}/schemas', {
|
|
89
|
+
params: {
|
|
90
|
+
path: { organizationId: this.getOrganizationId() },
|
|
91
|
+
query: {
|
|
92
|
+
apiFamily: apiFamily || undefined,
|
|
93
|
+
apiName: apiName || undefined,
|
|
94
|
+
apiVersion: apiVersion || undefined,
|
|
95
|
+
status: status,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
if (error) {
|
|
100
|
+
this.error(t('commands.scapi.schemas.list.error', 'Failed to fetch SCAPI schemas: {{message}}', {
|
|
101
|
+
message: formatApiError(error),
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
const schemas = data?.data ?? [];
|
|
105
|
+
const output = {
|
|
106
|
+
schemas,
|
|
107
|
+
total: data?.total ?? schemas.length,
|
|
108
|
+
};
|
|
109
|
+
if (this.jsonEnabled()) {
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
if (schemas.length === 0) {
|
|
113
|
+
this.log(t('commands.scapi.schemas.list.noSchemas', 'No schemas found.'));
|
|
114
|
+
return output;
|
|
115
|
+
}
|
|
116
|
+
this.log(t('commands.scapi.schemas.list.count', 'Found {{count}} schema(s):', {
|
|
117
|
+
count: schemas.length,
|
|
118
|
+
}));
|
|
119
|
+
this.log('');
|
|
120
|
+
const columns = this.getSelectedColumns();
|
|
121
|
+
tableRenderer.render(schemas, columns);
|
|
122
|
+
return output;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Determines which columns to display based on flags.
|
|
126
|
+
*/
|
|
127
|
+
getSelectedColumns() {
|
|
128
|
+
const columnsFlag = this.flags.columns;
|
|
129
|
+
const extended = this.flags.extended;
|
|
130
|
+
if (columnsFlag) {
|
|
131
|
+
// User specified explicit columns
|
|
132
|
+
const requested = columnsFlag.split(',').map((c) => c.trim());
|
|
133
|
+
const valid = tableRenderer.validateColumnKeys(requested);
|
|
134
|
+
if (valid.length === 0) {
|
|
135
|
+
this.warn(`No valid columns specified. Available: ${tableRenderer.getColumnKeys().join(', ')}`);
|
|
136
|
+
return DEFAULT_COLUMNS;
|
|
137
|
+
}
|
|
138
|
+
return valid;
|
|
139
|
+
}
|
|
140
|
+
if (extended) {
|
|
141
|
+
// Show all columns
|
|
142
|
+
return tableRenderer.getColumnKeys();
|
|
143
|
+
}
|
|
144
|
+
// Default columns (non-extended)
|
|
145
|
+
return DEFAULT_COLUMNS;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/scapi/schemas/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAClC,OAAO,EAAC,aAAa,EAAiB,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAC,CAAC,EAAC,MAAM,wBAAwB,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