@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.
@@ -0,0 +1,40 @@
1
+ import { Command } from '@oclif/core';
2
+ import { OAuthCommand } from '@salesforce/b2c-tooling-sdk/cli';
3
+ import { type ScapiSchemasClient } from '@salesforce/b2c-tooling-sdk/clients';
4
+ /**
5
+ * Format API error for display.
6
+ */
7
+ export declare function formatApiError(error: unknown): string;
8
+ /**
9
+ * Base command for SCAPI Schemas operations.
10
+ * Provides common flags and helper methods for interacting with the SCAPI Schemas API.
11
+ */
12
+ export declare abstract class ScapiSchemasCommand<T extends typeof Command> extends OAuthCommand<T> {
13
+ static baseFlags: {
14
+ 'tenant-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'client-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'client-secret': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ scope: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
+ lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
+ instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
+ 'working-directory': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
+ 'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
+ 'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
+ 'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
31
+ };
32
+ /**
33
+ * Get the organization ID from the tenant-id flag.
34
+ */
35
+ protected getOrganizationId(): string;
36
+ /**
37
+ * Get the SCAPI Schemas client, ensuring short code is configured.
38
+ */
39
+ protected getSchemasClient(): ScapiSchemasClient;
40
+ }
@@ -0,0 +1,49 @@
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 { Command, Flags } from '@oclif/core';
7
+ import { OAuthCommand } from '@salesforce/b2c-tooling-sdk/cli';
8
+ import { createScapiSchemasClient, toOrganizationId } from '@salesforce/b2c-tooling-sdk/clients';
9
+ import { t } from '../../i18n/index.js';
10
+ /**
11
+ * Format API error for display.
12
+ */
13
+ export function formatApiError(error) {
14
+ return typeof error === 'object' ? JSON.stringify(error) : String(error);
15
+ }
16
+ /**
17
+ * Base command for SCAPI Schemas operations.
18
+ * Provides common flags and helper methods for interacting with the SCAPI Schemas API.
19
+ */
20
+ export class ScapiSchemasCommand extends OAuthCommand {
21
+ static baseFlags = {
22
+ ...OAuthCommand.baseFlags,
23
+ 'tenant-id': Flags.string({
24
+ description: t('flags.tenantId.description', 'Organization/tenant ID'),
25
+ env: 'SFCC_TENANT_ID',
26
+ required: true,
27
+ }),
28
+ };
29
+ /**
30
+ * Get the organization ID from the tenant-id flag.
31
+ */
32
+ getOrganizationId() {
33
+ const tenantId = this.flags['tenant-id'];
34
+ return toOrganizationId(tenantId);
35
+ }
36
+ /**
37
+ * Get the SCAPI Schemas client, ensuring short code is configured.
38
+ */
39
+ getSchemasClient() {
40
+ const { shortCode } = this.resolvedConfig.values;
41
+ const tenantId = this.flags['tenant-id'];
42
+ if (!shortCode) {
43
+ this.error(t('error.shortCodeRequired', 'SCAPI short code required. Provide --short-code, set SFCC_SHORTCODE, or configure short-code in dw.json.'));
44
+ }
45
+ const oauthStrategy = this.getOAuthStrategy();
46
+ return createScapiSchemasClient({ shortCode, tenantId }, oauthStrategy);
47
+ }
48
+ }
49
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/utils/scapi/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAC,wBAAwB,EAAE,gBAAgB,EAA0B,MAAM,qCAAqC,CAAC;AACxH,OAAO,EAAC,CAAC,EAAC,MAAM,qBAAqB,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,OAAgB,mBAA8C,SAAQ,YAAe;IACzF,MAAM,CAAC,SAAS,GAAG;QACjB,GAAG,YAAY,CAAC,SAAS;QACzB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,CAAC,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