@salesforce/b2c-tooling-sdk 0.0.7 → 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.
Files changed (34) hide show
  1. package/dist/cjs/clients/index.d.ts +3 -0
  2. package/dist/cjs/clients/index.js +2 -0
  3. package/dist/cjs/clients/index.js.map +1 -1
  4. package/dist/cjs/clients/middleware-registry.d.ts +1 -1
  5. package/dist/cjs/clients/scapi-schemas.d.ts +132 -0
  6. package/dist/cjs/clients/scapi-schemas.generated.d.ts +328 -0
  7. package/dist/cjs/clients/scapi-schemas.generated.js +6 -0
  8. package/dist/cjs/clients/scapi-schemas.generated.js.map +1 -0
  9. package/dist/cjs/clients/scapi-schemas.js +95 -0
  10. package/dist/cjs/clients/scapi-schemas.js.map +1 -0
  11. package/dist/cjs/operations/scapi-schemas/collapse.d.ts +150 -0
  12. package/dist/cjs/operations/scapi-schemas/collapse.js +180 -0
  13. package/dist/cjs/operations/scapi-schemas/collapse.js.map +1 -0
  14. package/dist/cjs/operations/scapi-schemas/index.d.ts +53 -0
  15. package/dist/cjs/operations/scapi-schemas/index.js +59 -0
  16. package/dist/cjs/operations/scapi-schemas/index.js.map +1 -0
  17. package/dist/esm/clients/index.d.ts +3 -0
  18. package/dist/esm/clients/index.js +2 -0
  19. package/dist/esm/clients/index.js.map +1 -1
  20. package/dist/esm/clients/middleware-registry.d.ts +1 -1
  21. package/dist/esm/clients/scapi-schemas.d.ts +132 -0
  22. package/dist/esm/clients/scapi-schemas.generated.d.ts +328 -0
  23. package/dist/esm/clients/scapi-schemas.generated.js +6 -0
  24. package/dist/esm/clients/scapi-schemas.generated.js.map +1 -0
  25. package/dist/esm/clients/scapi-schemas.js +95 -0
  26. package/dist/esm/clients/scapi-schemas.js.map +1 -0
  27. package/dist/esm/operations/scapi-schemas/collapse.d.ts +150 -0
  28. package/dist/esm/operations/scapi-schemas/collapse.js +180 -0
  29. package/dist/esm/operations/scapi-schemas/collapse.js.map +1 -0
  30. package/dist/esm/operations/scapi-schemas/index.d.ts +53 -0
  31. package/dist/esm/operations/scapi-schemas/index.js +59 -0
  32. package/dist/esm/operations/scapi-schemas/index.js.map +1 -0
  33. package/package.json +13 -2
  34. package/specs/scapi-schemas-v1.yaml +341 -0
@@ -11,6 +11,7 @@
11
11
  * - {@link SlasClient} - SLAS Admin API for managing tenants and clients
12
12
  * - {@link OdsClient} - On-Demand Sandbox API for managing developer sandboxes
13
13
  * - {@link CustomApisClient} - Custom APIs DX API for retrieving endpoint status
14
+ * - {@link ScapiSchemasClient} - SCAPI Schemas API for discovering and retrieving OpenAPI schemas
14
15
  *
15
16
  * ## Usage
16
17
  *
@@ -125,3 +126,5 @@ export { createMrtClient, DEFAULT_MRT_ORIGIN } from './mrt.js';
125
126
  export type { MrtClient, MrtClientConfig, MrtError, MrtResponse, BuildPushResponse, paths as MrtPaths, components as MrtComponents, } from './mrt.js';
126
127
  export { createCustomApisClient, toOrganizationId, toTenantId, buildTenantScope, ORGANIZATION_ID_PREFIX, SCAPI_TENANT_SCOPE_PREFIX, CUSTOM_APIS_DEFAULT_SCOPES, } from './custom-apis.js';
127
128
  export type { CustomApisClient, CustomApisClientConfig, CustomApisError, CustomApisResponse, paths as CustomApisPaths, components as CustomApisComponents, } from './custom-apis.js';
129
+ export { createScapiSchemasClient, SCAPI_SCHEMAS_DEFAULT_SCOPES } from './scapi-schemas.js';
130
+ export type { ScapiSchemasClient, ScapiSchemasClientConfig, ScapiSchemasError, ScapiSchemasResponse, SchemaListItem, SchemaListResult, OpenApiSchema, paths as ScapiSchemasPaths, components as ScapiSchemasComponents, } from './scapi-schemas.js';
@@ -16,6 +16,7 @@
16
16
  * - {@link SlasClient} - SLAS Admin API for managing tenants and clients
17
17
  * - {@link OdsClient} - On-Demand Sandbox API for managing developer sandboxes
18
18
  * - {@link CustomApisClient} - Custom APIs DX API for retrieving endpoint status
19
+ * - {@link ScapiSchemasClient} - SCAPI Schemas API for discovering and retrieving OpenAPI schemas
19
20
  *
20
21
  * ## Usage
21
22
  *
@@ -122,4 +123,5 @@ export { createSlasClient } from './slas-admin.js';
122
123
  export { createOdsClient } from './ods.js';
123
124
  export { createMrtClient, DEFAULT_MRT_ORIGIN } from './mrt.js';
124
125
  export { createCustomApisClient, toOrganizationId, toTenantId, buildTenantScope, ORGANIZATION_ID_PREFIX, SCAPI_TENANT_SCOPE_PREFIX, CUSTOM_APIS_DEFAULT_SCOPES, } from './custom-apis.js';
126
+ export { createScapiSchemasClient, SCAPI_SCHEMAS_DEFAULT_SCOPES } from './scapi-schemas.js';
125
127
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GG;AACH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,2BAA2B,EAAC,MAAM,iBAAiB,CAAC;AAG3G,OAAO,EAAC,kBAAkB,EAAE,wBAAwB,EAAC,MAAM,0BAA0B,CAAC;AAGtF,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAU7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAUjD,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAUzC,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAW7D,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+GG;AACH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,2BAA2B,EAAC,MAAM,iBAAiB,CAAC;AAG3G,OAAO,EAAC,kBAAkB,EAAE,wBAAwB,EAAC,MAAM,0BAA0B,CAAC;AAGtF,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAU7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAUjD,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAUzC,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAW7D,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAU1B,OAAO,EAAC,wBAAwB,EAAE,4BAA4B,EAAC,MAAM,oBAAoB,CAAC"}
@@ -38,7 +38,7 @@ import type { Middleware } from 'openapi-fetch';
38
38
  /**
39
39
  * Types of HTTP clients that can receive middleware.
40
40
  */
41
- export type HttpClientType = 'ocapi' | 'slas' | 'ods' | 'mrt' | 'custom-apis' | 'webdav';
41
+ export type HttpClientType = 'ocapi' | 'slas' | 'ods' | 'mrt' | 'custom-apis' | 'scapi-schemas' | 'webdav';
42
42
  /**
43
43
  * Middleware interface compatible with openapi-fetch.
44
44
  *
@@ -0,0 +1,132 @@
1
+ /**
2
+ * SCAPI Schemas API client for B2C Commerce.
3
+ *
4
+ * Provides a fully typed client for SCAPI Schemas API operations using
5
+ * openapi-fetch with OAuth authentication middleware. Used for discovering
6
+ * and retrieving OpenAPI schema specifications for SCAPI APIs.
7
+ *
8
+ * @module clients/scapi-schemas
9
+ */
10
+ import { type Client } from 'openapi-fetch';
11
+ import type { AuthStrategy } from '../auth/types.js';
12
+ import type { paths, components } from './scapi-schemas.generated.js';
13
+ import { type MiddlewareRegistry } from './middleware-registry.js';
14
+ import { toOrganizationId, toTenantId, buildTenantScope } from './custom-apis.js';
15
+ /**
16
+ * Re-export generated types for external use.
17
+ */
18
+ export type { paths, components };
19
+ /**
20
+ * Re-export organization/tenant utilities for convenience.
21
+ */
22
+ export { toOrganizationId, toTenantId, buildTenantScope };
23
+ /**
24
+ * The typed SCAPI Schemas client - this is the openapi-fetch Client with full type safety.
25
+ *
26
+ * @see {@link createScapiSchemasClient} for instantiation
27
+ */
28
+ export type ScapiSchemasClient = Client<paths>;
29
+ /**
30
+ * Helper type to extract response data from an operation.
31
+ */
32
+ export type ScapiSchemasResponse<T> = T extends {
33
+ content: {
34
+ 'application/json': infer R;
35
+ };
36
+ } ? R : never;
37
+ /**
38
+ * Standard SCAPI Schemas error response structure.
39
+ */
40
+ export type ScapiSchemasError = components['schemas']['ErrorResponse'];
41
+ /**
42
+ * Schema list item from the list endpoint.
43
+ */
44
+ export type SchemaListItem = components['schemas']['SchemaListItem'];
45
+ /**
46
+ * Schema list result from the list endpoint.
47
+ */
48
+ export type SchemaListResult = components['schemas']['SchemaListResult'];
49
+ /**
50
+ * OpenAPI schema structure returned by the get endpoint.
51
+ */
52
+ export type OpenApiSchema = components['schemas']['OpenApiSchema'];
53
+ /** Default OAuth scopes required for SCAPI Schemas (read-only) */
54
+ export declare const SCAPI_SCHEMAS_DEFAULT_SCOPES: string[];
55
+ /**
56
+ * Configuration for creating a SCAPI Schemas client.
57
+ */
58
+ export interface ScapiSchemasClientConfig {
59
+ /**
60
+ * The short code for the SCAPI instance.
61
+ * This is typically a 4-8 character alphanumeric code.
62
+ * @example "kv7kzm78"
63
+ */
64
+ shortCode: string;
65
+ /**
66
+ * The tenant ID (with or without f_ecom_ prefix).
67
+ * Used to build the organizationId path parameter and tenant-specific OAuth scope.
68
+ * @example "zzxy_prd" or "f_ecom_zzxy_prd"
69
+ */
70
+ tenantId: string;
71
+ /**
72
+ * Optional scope override. If not provided, defaults to domain scope
73
+ * (sfcc.scapi-schemas) plus tenant-specific scope (SALESFORCE_COMMERCE_API:{tenant}).
74
+ */
75
+ scopes?: string[];
76
+ /**
77
+ * Middleware registry to use for this client.
78
+ * If not specified, uses the global middleware registry.
79
+ */
80
+ middlewareRegistry?: MiddlewareRegistry;
81
+ }
82
+ /**
83
+ * Creates a typed SCAPI Schemas API client.
84
+ *
85
+ * Returns the openapi-fetch client directly, with authentication
86
+ * handled via middleware. This gives full access to all openapi-fetch
87
+ * features with type-safe paths, parameters, and responses.
88
+ *
89
+ * The client automatically handles OAuth scope requirements:
90
+ * - Domain scope: `sfcc.scapi-schemas` (or custom via config.scopes)
91
+ * - Tenant scope: `SALESFORCE_COMMERCE_API:{tenantId}`
92
+ *
93
+ * @param config - SCAPI Schemas client configuration including shortCode and tenantId
94
+ * @param auth - Authentication strategy (typically OAuth)
95
+ * @returns Typed openapi-fetch client
96
+ *
97
+ * @example
98
+ * // Create SCAPI Schemas client - scopes are handled automatically
99
+ * const oauthStrategy = new OAuthStrategy({
100
+ * clientId: 'your-client-id',
101
+ * clientSecret: 'your-client-secret',
102
+ * });
103
+ *
104
+ * const client = createScapiSchemasClient(
105
+ * { shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' },
106
+ * oauthStrategy
107
+ * );
108
+ *
109
+ * // List available SCAPI schemas
110
+ * const { data, error } = await client.GET('/organizations/{organizationId}/schemas', {
111
+ * params: {
112
+ * path: { organizationId: toOrganizationId('zzxy_prd') }
113
+ * }
114
+ * });
115
+ *
116
+ * // Get a specific schema
117
+ * const { data: schema } = await client.GET(
118
+ * '/organizations/{organizationId}/schemas/{apiFamily}/{apiName}/{apiVersion}',
119
+ * {
120
+ * params: {
121
+ * path: {
122
+ * organizationId: toOrganizationId('zzxy_prd'),
123
+ * apiFamily: 'shopper',
124
+ * apiName: 'products',
125
+ * apiVersion: 'v1'
126
+ * },
127
+ * query: { expand: 'custom_properties' }
128
+ * }
129
+ * }
130
+ * );
131
+ */
132
+ export declare function createScapiSchemasClient(config: ScapiSchemasClientConfig, auth: AuthStrategy): ScapiSchemasClient;
@@ -0,0 +1,328 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+ export interface paths {
6
+ "/organizations/{organizationId}/schemas": {
7
+ parameters: {
8
+ query?: never;
9
+ header?: never;
10
+ path?: never;
11
+ cookie?: never;
12
+ };
13
+ /**
14
+ * Get a list of available SCAPI schemas.
15
+ * @description List available SCAPI schema definitions with optional filtering by API family, name, version, or status.
16
+ */
17
+ get: operations["getSchemas"];
18
+ put?: never;
19
+ post?: never;
20
+ delete?: never;
21
+ options?: never;
22
+ head?: never;
23
+ patch?: never;
24
+ trace?: never;
25
+ };
26
+ "/organizations/{organizationId}/schemas/{apiFamily}/{apiName}/{apiVersion}": {
27
+ parameters: {
28
+ query?: never;
29
+ header?: never;
30
+ path?: never;
31
+ cookie?: never;
32
+ };
33
+ /**
34
+ * Get a specific SCAPI schema.
35
+ * @description Retrieve the detailed OpenAPI schema specification for a specific SCAPI API.
36
+ */
37
+ get: operations["getSchema"];
38
+ put?: never;
39
+ post?: never;
40
+ delete?: never;
41
+ options?: never;
42
+ head?: never;
43
+ patch?: never;
44
+ trace?: never;
45
+ };
46
+ }
47
+ export type webhooks = Record<string, never>;
48
+ export interface components {
49
+ schemas: {
50
+ /**
51
+ * @description An identifier for the organization the request is being made by
52
+ * @example f_ecom_zzxy_prd
53
+ */
54
+ OrganizationId: string;
55
+ /**
56
+ * @example current
57
+ * @enum {string}
58
+ */
59
+ SchemaStatus: "current" | "deprecated";
60
+ /**
61
+ * Format: int32
62
+ * @description Maximum records to retrieve per request, not to exceed the maximum defined. A limit must be at least 1 so at least one record is returned (if any match the criteria).
63
+ * @default 10
64
+ * @example 10
65
+ */
66
+ Limit: number;
67
+ /**
68
+ * Format: int32
69
+ * @description The total number of hits that match the search's criteria. This can be greater than the number of results returned as search results are paginated.
70
+ * @default 0
71
+ * @example 10
72
+ */
73
+ Total: number;
74
+ /** @description Schema defining generic list result. Each response schema of a resource requiring a list response should extend this schema. */
75
+ ResultBase: {
76
+ limit: components["schemas"]["Limit"];
77
+ total: components["schemas"]["Total"];
78
+ };
79
+ SchemaListFilter: {
80
+ /** @example shopper */
81
+ apiFamily?: string;
82
+ /** @example products */
83
+ apiName?: string;
84
+ /** @example v1 */
85
+ apiVersion?: string;
86
+ status?: components["schemas"]["SchemaStatus"];
87
+ };
88
+ SchemaListItem: {
89
+ /**
90
+ * @description Semantic version of the schema (e.g., "1.0.0")
91
+ * @example 1.0.0
92
+ */
93
+ schemaVersion?: string;
94
+ /**
95
+ * @description The API family (e.g., shopper, admin)
96
+ * @example shopper
97
+ */
98
+ apiFamily?: string;
99
+ /**
100
+ * @description The API name (e.g., products, orders)
101
+ * @example products
102
+ */
103
+ apiName?: string;
104
+ /**
105
+ * @description The API version (e.g., v1)
106
+ * @example v1
107
+ */
108
+ apiVersion?: string;
109
+ status?: components["schemas"]["SchemaStatus"];
110
+ /**
111
+ * @description URL to the schema detail endpoint
112
+ * @example /organizations/f_ecom_zzxy_prd/schemas/shopper/products/v1
113
+ */
114
+ link?: string;
115
+ };
116
+ SchemaListResult: {
117
+ filter?: components["schemas"]["SchemaListFilter"];
118
+ data?: components["schemas"]["SchemaListItem"][];
119
+ } & components["schemas"]["ResultBase"];
120
+ /** @description An OpenAPI 3.0 schema specification */
121
+ OpenApiSchema: {
122
+ /**
123
+ * @description OpenAPI version
124
+ * @example 3.0.3
125
+ */
126
+ openapi?: string;
127
+ info?: {
128
+ title?: string;
129
+ version?: string;
130
+ description?: string;
131
+ } & {
132
+ [key: string]: unknown;
133
+ };
134
+ paths?: {
135
+ [key: string]: unknown;
136
+ };
137
+ components?: {
138
+ [key: string]: unknown;
139
+ };
140
+ } & {
141
+ [key: string]: unknown;
142
+ };
143
+ ErrorResponse: {
144
+ /**
145
+ * @description A short, human-readable summary of the problem type.
146
+ * @example Bad Request
147
+ */
148
+ title: string;
149
+ /**
150
+ * @description A URI reference that identifies the problem type.
151
+ * @example https://api.commercecloud.salesforce.com/documentation/error/v1/errors/bad-request
152
+ */
153
+ type: string;
154
+ /**
155
+ * @description A human-readable explanation specific to this occurrence of the problem.
156
+ * @example Invalid value for filter parameter.
157
+ */
158
+ detail: string;
159
+ /** @description A URI reference that identifies the specific occurrence of the problem. */
160
+ instance?: string;
161
+ } & {
162
+ [key: string]: unknown;
163
+ };
164
+ };
165
+ responses: never;
166
+ parameters: {
167
+ /**
168
+ * @description An identifier for the organization the request is being made by
169
+ * @example f_ecom_zzxy_prd
170
+ */
171
+ organizationId: components["schemas"]["OrganizationId"];
172
+ /** @description Filter by API family (e.g., shopper, admin) */
173
+ apiFamily: string;
174
+ /** @description Filter by API name (e.g., products, orders) */
175
+ apiName: string;
176
+ /** @description Filter by API version (e.g., v1) */
177
+ apiVersion: string;
178
+ /** @description Filter by schema status */
179
+ status: components["schemas"]["SchemaStatus"];
180
+ /** @description The API family (e.g., shopper, admin) */
181
+ apiFamilyPath: string;
182
+ /** @description The API name (e.g., products, orders) */
183
+ apiNamePath: string;
184
+ /** @description The API version (e.g., v1) */
185
+ apiVersionPath: string;
186
+ /** @description Comma-separated list of sections to expand (e.g., "custom_properties") */
187
+ expand: string;
188
+ };
189
+ requestBodies: never;
190
+ headers: never;
191
+ pathItems: never;
192
+ }
193
+ export type $defs = Record<string, never>;
194
+ export interface operations {
195
+ getSchemas: {
196
+ parameters: {
197
+ query?: {
198
+ /** @description Filter by API family (e.g., shopper, admin) */
199
+ apiFamily?: components["parameters"]["apiFamily"];
200
+ /** @description Filter by API name (e.g., products, orders) */
201
+ apiName?: components["parameters"]["apiName"];
202
+ /** @description Filter by API version (e.g., v1) */
203
+ apiVersion?: components["parameters"]["apiVersion"];
204
+ /** @description Filter by schema status */
205
+ status?: components["parameters"]["status"];
206
+ };
207
+ header?: never;
208
+ path: {
209
+ /**
210
+ * @description An identifier for the organization the request is being made by
211
+ * @example f_ecom_zzxy_prd
212
+ */
213
+ organizationId: components["parameters"]["organizationId"];
214
+ };
215
+ cookie?: never;
216
+ };
217
+ requestBody?: never;
218
+ responses: {
219
+ /** @description Successful operation */
220
+ 200: {
221
+ headers: {
222
+ [name: string]: unknown;
223
+ };
224
+ content: {
225
+ "application/json": components["schemas"]["SchemaListResult"];
226
+ };
227
+ };
228
+ /** @description Invalid or malformed filter parameter */
229
+ 400: {
230
+ headers: {
231
+ [name: string]: unknown;
232
+ };
233
+ content: {
234
+ "application/problem+json": components["schemas"]["ErrorResponse"];
235
+ };
236
+ };
237
+ /** @description Unauthorized - invalid or missing authentication */
238
+ 401: {
239
+ headers: {
240
+ [name: string]: unknown;
241
+ };
242
+ content: {
243
+ "application/problem+json": components["schemas"]["ErrorResponse"];
244
+ };
245
+ };
246
+ /** @description Forbidden - insufficient permissions */
247
+ 403: {
248
+ headers: {
249
+ [name: string]: unknown;
250
+ };
251
+ content: {
252
+ "application/problem+json": components["schemas"]["ErrorResponse"];
253
+ };
254
+ };
255
+ };
256
+ };
257
+ getSchema: {
258
+ parameters: {
259
+ query?: {
260
+ /** @description Comma-separated list of sections to expand (e.g., "custom_properties") */
261
+ expand?: components["parameters"]["expand"];
262
+ };
263
+ header?: never;
264
+ path: {
265
+ /**
266
+ * @description An identifier for the organization the request is being made by
267
+ * @example f_ecom_zzxy_prd
268
+ */
269
+ organizationId: components["parameters"]["organizationId"];
270
+ /** @description The API family (e.g., shopper, admin) */
271
+ apiFamily: components["parameters"]["apiFamilyPath"];
272
+ /** @description The API name (e.g., products, orders) */
273
+ apiName: components["parameters"]["apiNamePath"];
274
+ /** @description The API version (e.g., v1) */
275
+ apiVersion: components["parameters"]["apiVersionPath"];
276
+ };
277
+ cookie?: never;
278
+ };
279
+ requestBody?: never;
280
+ responses: {
281
+ /** @description Successful operation - returns OpenAPI schema */
282
+ 200: {
283
+ headers: {
284
+ [name: string]: unknown;
285
+ };
286
+ content: {
287
+ "application/json": components["schemas"]["OpenApiSchema"];
288
+ };
289
+ };
290
+ /** @description Invalid parameter value */
291
+ 400: {
292
+ headers: {
293
+ [name: string]: unknown;
294
+ };
295
+ content: {
296
+ "application/problem+json": components["schemas"]["ErrorResponse"];
297
+ };
298
+ };
299
+ /** @description Unauthorized - invalid or missing authentication */
300
+ 401: {
301
+ headers: {
302
+ [name: string]: unknown;
303
+ };
304
+ content: {
305
+ "application/problem+json": components["schemas"]["ErrorResponse"];
306
+ };
307
+ };
308
+ /** @description Forbidden - insufficient permissions */
309
+ 403: {
310
+ headers: {
311
+ [name: string]: unknown;
312
+ };
313
+ content: {
314
+ "application/problem+json": components["schemas"]["ErrorResponse"];
315
+ };
316
+ };
317
+ /** @description Schema not found */
318
+ 404: {
319
+ headers: {
320
+ [name: string]: unknown;
321
+ };
322
+ content: {
323
+ "application/problem+json": components["schemas"]["ErrorResponse"];
324
+ };
325
+ };
326
+ };
327
+ };
328
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=scapi-schemas.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scapi-schemas.generated.js","sourceRoot":"","sources":["../../../src/clients/scapi-schemas.generated.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,95 @@
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
+ /**
7
+ * SCAPI Schemas API client for B2C Commerce.
8
+ *
9
+ * Provides a fully typed client for SCAPI Schemas API operations using
10
+ * openapi-fetch with OAuth authentication middleware. Used for discovering
11
+ * and retrieving OpenAPI schema specifications for SCAPI APIs.
12
+ *
13
+ * @module clients/scapi-schemas
14
+ */
15
+ import createClient from 'openapi-fetch';
16
+ import { OAuthStrategy } from '../auth/oauth.js';
17
+ import { createAuthMiddleware, createLoggingMiddleware } from './middleware.js';
18
+ import { globalMiddlewareRegistry } from './middleware-registry.js';
19
+ import { toOrganizationId, toTenantId, buildTenantScope } from './custom-apis.js';
20
+ /**
21
+ * Re-export organization/tenant utilities for convenience.
22
+ */
23
+ export { toOrganizationId, toTenantId, buildTenantScope };
24
+ /** Default OAuth scopes required for SCAPI Schemas (read-only) */
25
+ export const SCAPI_SCHEMAS_DEFAULT_SCOPES = ['sfcc.scapi-schemas'];
26
+ /**
27
+ * Creates a typed SCAPI Schemas API client.
28
+ *
29
+ * Returns the openapi-fetch client directly, with authentication
30
+ * handled via middleware. This gives full access to all openapi-fetch
31
+ * features with type-safe paths, parameters, and responses.
32
+ *
33
+ * The client automatically handles OAuth scope requirements:
34
+ * - Domain scope: `sfcc.scapi-schemas` (or custom via config.scopes)
35
+ * - Tenant scope: `SALESFORCE_COMMERCE_API:{tenantId}`
36
+ *
37
+ * @param config - SCAPI Schemas client configuration including shortCode and tenantId
38
+ * @param auth - Authentication strategy (typically OAuth)
39
+ * @returns Typed openapi-fetch client
40
+ *
41
+ * @example
42
+ * // Create SCAPI Schemas client - scopes are handled automatically
43
+ * const oauthStrategy = new OAuthStrategy({
44
+ * clientId: 'your-client-id',
45
+ * clientSecret: 'your-client-secret',
46
+ * });
47
+ *
48
+ * const client = createScapiSchemasClient(
49
+ * { shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' },
50
+ * oauthStrategy
51
+ * );
52
+ *
53
+ * // List available SCAPI schemas
54
+ * const { data, error } = await client.GET('/organizations/{organizationId}/schemas', {
55
+ * params: {
56
+ * path: { organizationId: toOrganizationId('zzxy_prd') }
57
+ * }
58
+ * });
59
+ *
60
+ * // Get a specific schema
61
+ * const { data: schema } = await client.GET(
62
+ * '/organizations/{organizationId}/schemas/{apiFamily}/{apiName}/{apiVersion}',
63
+ * {
64
+ * params: {
65
+ * path: {
66
+ * organizationId: toOrganizationId('zzxy_prd'),
67
+ * apiFamily: 'shopper',
68
+ * apiName: 'products',
69
+ * apiVersion: 'v1'
70
+ * },
71
+ * query: { expand: 'custom_properties' }
72
+ * }
73
+ * }
74
+ * );
75
+ */
76
+ export function createScapiSchemasClient(config, auth) {
77
+ const registry = config.middlewareRegistry ?? globalMiddlewareRegistry;
78
+ const client = createClient({
79
+ baseUrl: `https://${config.shortCode}.api.commercecloud.salesforce.com/dx/scapi-schemas/v1`,
80
+ });
81
+ // Build required scopes: domain scope + tenant-specific scope
82
+ const requiredScopes = config.scopes ?? [...SCAPI_SCHEMAS_DEFAULT_SCOPES, buildTenantScope(config.tenantId)];
83
+ // If OAuth strategy, add required scopes; otherwise use as-is
84
+ const scopedAuth = auth instanceof OAuthStrategy ? auth.withAdditionalScopes(requiredScopes) : auth;
85
+ // Core middleware: auth first
86
+ client.use(createAuthMiddleware(scopedAuth));
87
+ // Plugin middleware from registry
88
+ for (const middleware of registry.getMiddleware('scapi-schemas')) {
89
+ client.use(middleware);
90
+ }
91
+ // Logging middleware last (sees complete request with all modifications)
92
+ client.use(createLoggingMiddleware('SCAPI-SCHEMAS'));
93
+ return client;
94
+ }
95
+ //# sourceMappingURL=scapi-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scapi-schemas.js","sourceRoot":"","sources":["../../../src/clients/scapi-schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;GAQG;AACH,OAAO,YAA2B,MAAM,eAAe,CAAC;AAExD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAC,oBAAoB,EAAE,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAC,wBAAwB,EAA0B,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAC,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAOhF;;GAEG;AACH,OAAO,EAAC,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAC,CAAC;AAkCxD,kEAAkE;AAClE,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAiCnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAgC,EAAE,IAAkB;IAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,kBAAkB,IAAI,wBAAwB,CAAC;IAEvE,MAAM,MAAM,GAAG,YAAY,CAAQ;QACjC,OAAO,EAAE,WAAW,MAAM,CAAC,SAAS,uDAAuD;KAC5F,CAAC,CAAC;IAEH,8DAA8D;IAC9D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,4BAA4B,EAAE,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE7G,8DAA8D;IAC9D,MAAM,UAAU,GAAG,IAAI,YAAY,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpG,8BAA8B;IAC9B,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;IAE7C,kCAAkC;IAClC,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,CAAC;QACjE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAED,yEAAyE;IACzE,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC"}