@salesforce/b2c-tooling-sdk 0.0.0-nightly.20260121201541 → 0.0.0-nightly.20260122144746
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/cjs/cli/mrt-command.d.ts +2 -1
- package/dist/cjs/cli/mrt-command.js +3 -2
- package/dist/cjs/cli/mrt-command.js.map +1 -1
- package/dist/cjs/clients/cdn-zones.d.ts +154 -0
- package/dist/cjs/clients/cdn-zones.generated.d.ts +8330 -0
- package/dist/cjs/clients/cdn-zones.generated.js +6 -0
- package/dist/cjs/clients/cdn-zones.generated.js.map +1 -0
- package/dist/cjs/clients/cdn-zones.js +100 -0
- package/dist/cjs/clients/cdn-zones.js.map +1 -0
- package/dist/cjs/clients/error-utils.d.ts +35 -0
- package/dist/cjs/clients/error-utils.js +69 -0
- package/dist/cjs/clients/error-utils.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +5 -0
- package/dist/cjs/clients/index.js +3 -0
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/middleware-registry.d.ts +1 -1
- package/dist/cjs/clients/middleware-registry.js.map +1 -1
- package/dist/cjs/clients/mrt-b2c.d.ts +114 -0
- package/dist/cjs/clients/mrt-b2c.generated.d.ts +176 -0
- package/dist/cjs/clients/mrt-b2c.generated.js +6 -0
- package/dist/cjs/clients/mrt-b2c.generated.js.map +1 -0
- package/dist/cjs/clients/mrt-b2c.js +86 -0
- package/dist/cjs/clients/mrt-b2c.js.map +1 -0
- package/dist/cjs/config/dw-json.d.ts +4 -0
- package/dist/cjs/config/dw-json.js.map +1 -1
- package/dist/cjs/config/mapping.js +1 -0
- package/dist/cjs/config/mapping.js.map +1 -1
- package/dist/cjs/config/resolver.js +3 -0
- package/dist/cjs/config/resolver.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/operations/code/deploy.js +9 -3
- package/dist/cjs/operations/code/deploy.js.map +1 -1
- package/dist/cjs/operations/mrt/access-control.d.ts +192 -0
- package/dist/cjs/operations/mrt/access-control.js +152 -0
- package/dist/cjs/operations/mrt/access-control.js.map +1 -0
- package/dist/cjs/operations/mrt/b2c-config.d.ts +201 -0
- package/dist/cjs/operations/mrt/b2c-config.js +195 -0
- package/dist/cjs/operations/mrt/b2c-config.js.map +1 -0
- package/dist/cjs/operations/mrt/cache.d.ts +80 -0
- package/dist/cjs/operations/mrt/cache.js +65 -0
- package/dist/cjs/operations/mrt/cache.js.map +1 -0
- package/dist/cjs/operations/mrt/deployment.d.ts +157 -0
- package/dist/cjs/operations/mrt/deployment.js +109 -0
- package/dist/cjs/operations/mrt/deployment.js.map +1 -0
- package/dist/cjs/operations/mrt/env.d.ts +141 -0
- package/dist/cjs/operations/mrt/env.js +119 -0
- package/dist/cjs/operations/mrt/env.js.map +1 -1
- package/dist/cjs/operations/mrt/index.d.ts +24 -4
- package/dist/cjs/operations/mrt/index.js +23 -3
- package/dist/cjs/operations/mrt/index.js.map +1 -1
- package/dist/cjs/operations/mrt/member.d.ts +281 -0
- package/dist/cjs/operations/mrt/member.js +244 -0
- package/dist/cjs/operations/mrt/member.js.map +1 -0
- package/dist/cjs/operations/mrt/notification.d.ts +252 -0
- package/dist/cjs/operations/mrt/notification.js +206 -0
- package/dist/cjs/operations/mrt/notification.js.map +1 -0
- package/dist/cjs/operations/mrt/organization.d.ts +80 -0
- package/dist/cjs/operations/mrt/organization.js +53 -0
- package/dist/cjs/operations/mrt/organization.js.map +1 -0
- package/dist/cjs/operations/mrt/project.d.ts +261 -0
- package/dist/cjs/operations/mrt/project.js +232 -0
- package/dist/cjs/operations/mrt/project.js.map +1 -0
- package/dist/cjs/operations/mrt/push.d.ts +122 -8
- package/dist/cjs/operations/mrt/push.js +83 -10
- package/dist/cjs/operations/mrt/push.js.map +1 -1
- package/dist/cjs/operations/mrt/redirect.d.ts +337 -0
- package/dist/cjs/operations/mrt/redirect.js +256 -0
- package/dist/cjs/operations/mrt/redirect.js.map +1 -0
- package/dist/cjs/operations/mrt/user.d.ts +135 -0
- package/dist/cjs/operations/mrt/user.js +153 -0
- package/dist/cjs/operations/mrt/user.js.map +1 -0
- package/dist/esm/cli/mrt-command.d.ts +2 -1
- package/dist/esm/cli/mrt-command.js +3 -2
- package/dist/esm/cli/mrt-command.js.map +1 -1
- package/dist/esm/clients/cdn-zones.d.ts +154 -0
- package/dist/esm/clients/cdn-zones.generated.d.ts +8330 -0
- package/dist/esm/clients/cdn-zones.generated.js +6 -0
- package/dist/esm/clients/cdn-zones.generated.js.map +1 -0
- package/dist/esm/clients/cdn-zones.js +100 -0
- package/dist/esm/clients/cdn-zones.js.map +1 -0
- package/dist/esm/clients/error-utils.d.ts +35 -0
- package/dist/esm/clients/error-utils.js +69 -0
- package/dist/esm/clients/error-utils.js.map +1 -0
- package/dist/esm/clients/index.d.ts +5 -0
- package/dist/esm/clients/index.js +3 -0
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/middleware-registry.d.ts +1 -1
- package/dist/esm/clients/middleware-registry.js.map +1 -1
- package/dist/esm/clients/mrt-b2c.d.ts +114 -0
- package/dist/esm/clients/mrt-b2c.generated.d.ts +176 -0
- package/dist/esm/clients/mrt-b2c.generated.js +6 -0
- package/dist/esm/clients/mrt-b2c.generated.js.map +1 -0
- package/dist/esm/clients/mrt-b2c.js +86 -0
- package/dist/esm/clients/mrt-b2c.js.map +1 -0
- package/dist/esm/config/dw-json.d.ts +4 -0
- package/dist/esm/config/dw-json.js.map +1 -1
- package/dist/esm/config/mapping.js +1 -0
- package/dist/esm/config/mapping.js.map +1 -1
- package/dist/esm/config/resolver.js +3 -0
- package/dist/esm/config/resolver.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operations/code/deploy.js +9 -3
- package/dist/esm/operations/code/deploy.js.map +1 -1
- package/dist/esm/operations/mrt/access-control.d.ts +192 -0
- package/dist/esm/operations/mrt/access-control.js +152 -0
- package/dist/esm/operations/mrt/access-control.js.map +1 -0
- package/dist/esm/operations/mrt/b2c-config.d.ts +201 -0
- package/dist/esm/operations/mrt/b2c-config.js +195 -0
- package/dist/esm/operations/mrt/b2c-config.js.map +1 -0
- package/dist/esm/operations/mrt/cache.d.ts +80 -0
- package/dist/esm/operations/mrt/cache.js +65 -0
- package/dist/esm/operations/mrt/cache.js.map +1 -0
- package/dist/esm/operations/mrt/deployment.d.ts +157 -0
- package/dist/esm/operations/mrt/deployment.js +109 -0
- package/dist/esm/operations/mrt/deployment.js.map +1 -0
- package/dist/esm/operations/mrt/env.d.ts +141 -0
- package/dist/esm/operations/mrt/env.js +119 -0
- package/dist/esm/operations/mrt/env.js.map +1 -1
- package/dist/esm/operations/mrt/index.d.ts +24 -4
- package/dist/esm/operations/mrt/index.js +23 -3
- package/dist/esm/operations/mrt/index.js.map +1 -1
- package/dist/esm/operations/mrt/member.d.ts +281 -0
- package/dist/esm/operations/mrt/member.js +244 -0
- package/dist/esm/operations/mrt/member.js.map +1 -0
- package/dist/esm/operations/mrt/notification.d.ts +252 -0
- package/dist/esm/operations/mrt/notification.js +206 -0
- package/dist/esm/operations/mrt/notification.js.map +1 -0
- package/dist/esm/operations/mrt/organization.d.ts +80 -0
- package/dist/esm/operations/mrt/organization.js +53 -0
- package/dist/esm/operations/mrt/organization.js.map +1 -0
- package/dist/esm/operations/mrt/project.d.ts +261 -0
- package/dist/esm/operations/mrt/project.js +232 -0
- package/dist/esm/operations/mrt/project.js.map +1 -0
- package/dist/esm/operations/mrt/push.d.ts +122 -8
- package/dist/esm/operations/mrt/push.js +83 -10
- package/dist/esm/operations/mrt/push.js.map +1 -1
- package/dist/esm/operations/mrt/redirect.d.ts +337 -0
- package/dist/esm/operations/mrt/redirect.js +256 -0
- package/dist/esm/operations/mrt/redirect.js.map +1 -0
- package/dist/esm/operations/mrt/user.d.ts +135 -0
- package/dist/esm/operations/mrt/user.js +153 -0
- package/dist/esm/operations/mrt/user.js.map +1 -0
- package/package.json +2 -2
- package/specs/cdn-zones-v1.yaml +9324 -0
- package/specs/mrt-b2c.json +384 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdn-zones.generated.js","sourceRoot":"","sources":["../../../src/clients/cdn-zones.generated.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
* CDN Zones API client for B2C Commerce.
|
|
8
|
+
*
|
|
9
|
+
* Provides a fully typed client for CDN Zones API operations using
|
|
10
|
+
* openapi-fetch with OAuth authentication middleware. Used for managing
|
|
11
|
+
* eCDN configurations including zones, certificates, WAF, rate limiting,
|
|
12
|
+
* cache purge, and other CDN settings.
|
|
13
|
+
*
|
|
14
|
+
* @module clients/cdn-zones
|
|
15
|
+
*/
|
|
16
|
+
import createClient from 'openapi-fetch';
|
|
17
|
+
import { OAuthStrategy } from '../auth/oauth.js';
|
|
18
|
+
import { createAuthMiddleware, createLoggingMiddleware } from './middleware.js';
|
|
19
|
+
import { globalMiddlewareRegistry } from './middleware-registry.js';
|
|
20
|
+
import { toOrganizationId, toTenantId, buildTenantScope } from './custom-apis.js';
|
|
21
|
+
/**
|
|
22
|
+
* Re-export organization/tenant utilities for convenience.
|
|
23
|
+
*/
|
|
24
|
+
export { toOrganizationId, toTenantId, buildTenantScope };
|
|
25
|
+
/** Default OAuth scopes required for CDN Zones (read-only) */
|
|
26
|
+
export const CDN_ZONES_READ_SCOPES = ['sfcc.cdn-zones'];
|
|
27
|
+
/** OAuth scopes required for CDN Zones (read-write) */
|
|
28
|
+
export const CDN_ZONES_RW_SCOPES = ['sfcc.cdn-zones.rw'];
|
|
29
|
+
/**
|
|
30
|
+
* Creates a typed CDN Zones API client.
|
|
31
|
+
*
|
|
32
|
+
* Returns the openapi-fetch client directly, with authentication
|
|
33
|
+
* handled via middleware. This gives full access to all openapi-fetch
|
|
34
|
+
* features with type-safe paths, parameters, and responses.
|
|
35
|
+
*
|
|
36
|
+
* The client automatically handles OAuth scope requirements:
|
|
37
|
+
* - Domain scope: `sfcc.cdn-zones` (read) or `sfcc.cdn-zones.rw` (read-write)
|
|
38
|
+
* - Tenant scope: `SALESFORCE_COMMERCE_API:{tenantId}`
|
|
39
|
+
*
|
|
40
|
+
* @param config - CDN Zones client configuration including shortCode and tenantId
|
|
41
|
+
* @param auth - Authentication strategy (typically OAuth)
|
|
42
|
+
* @param options - Optional settings like readWrite scope
|
|
43
|
+
* @returns Typed openapi-fetch client
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Create CDN Zones client for read-only operations
|
|
47
|
+
* const oauthStrategy = new OAuthStrategy({
|
|
48
|
+
* clientId: 'your-client-id',
|
|
49
|
+
* clientSecret: 'your-client-secret',
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* const client = createCdnZonesClient(
|
|
53
|
+
* { shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' },
|
|
54
|
+
* oauthStrategy
|
|
55
|
+
* );
|
|
56
|
+
*
|
|
57
|
+
* // List all zones
|
|
58
|
+
* const { data, error } = await client.GET('/organizations/{organizationId}/zones/info', {
|
|
59
|
+
* params: {
|
|
60
|
+
* path: { organizationId: toOrganizationId('zzxy_prd') }
|
|
61
|
+
* }
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Create CDN Zones client for read-write operations (e.g., cache purge)
|
|
66
|
+
* const rwClient = createCdnZonesClient(
|
|
67
|
+
* { shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' },
|
|
68
|
+
* oauthStrategy,
|
|
69
|
+
* { readWrite: true }
|
|
70
|
+
* );
|
|
71
|
+
*
|
|
72
|
+
* // Purge cache
|
|
73
|
+
* const { data } = await rwClient.POST('/organizations/{organizationId}/zones/{zoneId}/cachepurge', {
|
|
74
|
+
* params: {
|
|
75
|
+
* path: { organizationId: toOrganizationId('zzxy_prd'), zoneId: 'zone-id' }
|
|
76
|
+
* },
|
|
77
|
+
* body: { path: ['/some/path'] }
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
export function createCdnZonesClient(config, auth, options) {
|
|
81
|
+
const registry = config.middlewareRegistry ?? globalMiddlewareRegistry;
|
|
82
|
+
const client = createClient({
|
|
83
|
+
baseUrl: `https://${config.shortCode}.api.commercecloud.salesforce.com/cdn/zones/v1`,
|
|
84
|
+
});
|
|
85
|
+
// Build required scopes: domain scope + tenant-specific scope
|
|
86
|
+
const domainScopes = options?.readWrite ? CDN_ZONES_RW_SCOPES : CDN_ZONES_READ_SCOPES;
|
|
87
|
+
const requiredScopes = config.scopes ?? [...domainScopes, buildTenantScope(config.tenantId)];
|
|
88
|
+
// If OAuth strategy, add required scopes; otherwise use as-is
|
|
89
|
+
const scopedAuth = auth instanceof OAuthStrategy ? auth.withAdditionalScopes(requiredScopes) : auth;
|
|
90
|
+
// Core middleware: auth first
|
|
91
|
+
client.use(createAuthMiddleware(scopedAuth));
|
|
92
|
+
// Plugin middleware from registry
|
|
93
|
+
for (const middleware of registry.getMiddleware('cdn-zones')) {
|
|
94
|
+
client.use(middleware);
|
|
95
|
+
}
|
|
96
|
+
// Logging middleware last (sees complete request with all modifications)
|
|
97
|
+
client.use(createLoggingMiddleware('CDN-ZONES'));
|
|
98
|
+
return client;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=cdn-zones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdn-zones.js","sourceRoot":"","sources":["../../../src/clients/cdn-zones.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;GASG;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;AA4CxD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAExD,uDAAuD;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,mBAAmB,CAAC,CAAC;AA4CzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA4B,EAC5B,IAAkB,EAClB,OAA+B;IAE/B,MAAM,QAAQ,GAAG,MAAM,CAAC,kBAAkB,IAAI,wBAAwB,CAAC;IAEvE,MAAM,MAAM,GAAG,YAAY,CAAQ;QACjC,OAAO,EAAE,WAAW,MAAM,CAAC,SAAS,gDAAgD;KACrF,CAAC,CAAC;IAEH,8DAA8D;IAC9D,MAAM,YAAY,GAAG,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,qBAAqB,CAAC;IACtF,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,YAAY,EAAE,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE7F,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,WAAW,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAED,yEAAyE;IACzE,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,CAAC;IAEjD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for extracting error messages from API responses.
|
|
3
|
+
*
|
|
4
|
+
* @module clients/error-utils
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Extract a clean error message from an API error response.
|
|
8
|
+
*
|
|
9
|
+
* Handles multiple API error patterns and falls back to HTTP status.
|
|
10
|
+
* This ensures that HTML response bodies (like error pages) are never
|
|
11
|
+
* included in user-facing error messages.
|
|
12
|
+
*
|
|
13
|
+
* Supported error patterns:
|
|
14
|
+
* - ODS/SLAS: `{ error: { message: '...' } }`
|
|
15
|
+
* - OCAPI: `{ fault: { message: '...' } }`
|
|
16
|
+
* - SCAPI/Problem+JSON: `{ detail: '...', title: '...' }`
|
|
17
|
+
* - Standard Error: `{ message: '...' }`
|
|
18
|
+
*
|
|
19
|
+
* @param error - The error object from an API response
|
|
20
|
+
* @param response - The HTTP response (for status code fallback)
|
|
21
|
+
* @returns A clean, human-readable error message
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const {data, error, response} = await client.GET('/sites', {...});
|
|
26
|
+
* if (error) {
|
|
27
|
+
* const message = getApiErrorMessage(error, response);
|
|
28
|
+
* // Returns structured error message or "HTTP 521 Web Server Is Down"
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function getApiErrorMessage(error: unknown, response: Response | {
|
|
33
|
+
status: number;
|
|
34
|
+
statusText: string;
|
|
35
|
+
}): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
* Utilities for extracting error messages from API responses.
|
|
8
|
+
*
|
|
9
|
+
* @module clients/error-utils
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Extract a clean error message from an API error response.
|
|
13
|
+
*
|
|
14
|
+
* Handles multiple API error patterns and falls back to HTTP status.
|
|
15
|
+
* This ensures that HTML response bodies (like error pages) are never
|
|
16
|
+
* included in user-facing error messages.
|
|
17
|
+
*
|
|
18
|
+
* Supported error patterns:
|
|
19
|
+
* - ODS/SLAS: `{ error: { message: '...' } }`
|
|
20
|
+
* - OCAPI: `{ fault: { message: '...' } }`
|
|
21
|
+
* - SCAPI/Problem+JSON: `{ detail: '...', title: '...' }`
|
|
22
|
+
* - Standard Error: `{ message: '...' }`
|
|
23
|
+
*
|
|
24
|
+
* @param error - The error object from an API response
|
|
25
|
+
* @param response - The HTTP response (for status code fallback)
|
|
26
|
+
* @returns A clean, human-readable error message
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const {data, error, response} = await client.GET('/sites', {...});
|
|
31
|
+
* if (error) {
|
|
32
|
+
* const message = getApiErrorMessage(error, response);
|
|
33
|
+
* // Returns structured error message or "HTTP 521 Web Server Is Down"
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function getApiErrorMessage(error, response) {
|
|
38
|
+
if (error && typeof error === 'object') {
|
|
39
|
+
const err = error;
|
|
40
|
+
// ODS/SLAS pattern: { error: { message: '...' } }
|
|
41
|
+
if (err.error && typeof err.error === 'object') {
|
|
42
|
+
const nested = err.error;
|
|
43
|
+
if (typeof nested.message === 'string' && nested.message) {
|
|
44
|
+
return nested.message;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// OCAPI fault pattern: { fault: { message: '...' } }
|
|
48
|
+
if (err.fault && typeof err.fault === 'object') {
|
|
49
|
+
const fault = err.fault;
|
|
50
|
+
if (typeof fault.message === 'string' && fault.message) {
|
|
51
|
+
return fault.message;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// SCAPI/Problem+JSON pattern: { detail: '...', title: '...' }
|
|
55
|
+
if (typeof err.detail === 'string' && err.detail) {
|
|
56
|
+
return err.detail;
|
|
57
|
+
}
|
|
58
|
+
if (typeof err.title === 'string' && err.title) {
|
|
59
|
+
return err.title;
|
|
60
|
+
}
|
|
61
|
+
// Standard Error pattern: { message: '...' }
|
|
62
|
+
if (typeof err.message === 'string' && err.message) {
|
|
63
|
+
return err.message;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Fallback to HTTP status
|
|
67
|
+
return `HTTP ${response.status} ${response.statusText}`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=error-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.js","sourceRoot":"","sources":["../../../src/clients/error-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc,EAAE,QAAyD;IAC1G,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,KAAgC,CAAC;QAE7C,kDAAkD;QAClD,IAAI,GAAG,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAgC,CAAC;YACpD,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACzD,OAAO,MAAM,CAAC,OAAO,CAAC;YACxB,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,IAAI,GAAG,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAgC,CAAC;YACnD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBACvD,OAAO,KAAK,CAAC,OAAO,CAAC;YACvB,CAAC;QACH,CAAC;QAED,8DAA8D;QAC9D,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACjD,OAAO,GAAG,CAAC,MAAM,CAAC;QACpB,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YAC/C,OAAO,GAAG,CAAC,KAAK,CAAC;QACnB,CAAC;QAED,6CAA6C;QAC7C,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACnD,OAAO,GAAG,CAAC,OAAO,CAAC;QACrB,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,OAAO,QAAQ,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -128,3 +128,8 @@ export { createCustomApisClient, toOrganizationId, toTenantId, buildTenantScope,
|
|
|
128
128
|
export type { CustomApisClient, CustomApisClientConfig, CustomApisError, CustomApisResponse, paths as CustomApisPaths, components as CustomApisComponents, } from './custom-apis.js';
|
|
129
129
|
export { createScapiSchemasClient, SCAPI_SCHEMAS_DEFAULT_SCOPES } from './scapi-schemas.js';
|
|
130
130
|
export type { ScapiSchemasClient, ScapiSchemasClientConfig, ScapiSchemasError, ScapiSchemasResponse, SchemaListItem, SchemaListResult, OpenApiSchema, paths as ScapiSchemasPaths, components as ScapiSchemasComponents, } from './scapi-schemas.js';
|
|
131
|
+
export { createCdnZonesClient, CDN_ZONES_READ_SCOPES, CDN_ZONES_RW_SCOPES } from './cdn-zones.js';
|
|
132
|
+
export type { CdnZonesClient, CdnZonesClientConfig, CdnZonesClientOptions, CdnZonesError, CdnZonesResponse, Zone, ZonesEnvelope, Certificate, SecuritySetting, SpeedSetting, paths as CdnZonesPaths, components as CdnZonesComponents, } from './cdn-zones.js';
|
|
133
|
+
export { createMrtB2CClient, DEFAULT_MRT_B2C_ORIGIN } from './mrt-b2c.js';
|
|
134
|
+
export type { MrtB2CClient, MrtB2CClientConfig, MrtB2CError, MrtB2CResponse, B2COrgInfo, B2CTargetInfo, PatchedB2CTargetInfo, paths as MrtB2CPaths, components as MrtB2CComponents, } from './mrt-b2c.js';
|
|
135
|
+
export { getApiErrorMessage } from './error-utils.js';
|
|
@@ -124,4 +124,7 @@ export { createOdsClient } from './ods.js';
|
|
|
124
124
|
export { createMrtClient, DEFAULT_MRT_ORIGIN } from './mrt.js';
|
|
125
125
|
export { createCustomApisClient, toOrganizationId, toTenantId, buildTenantScope, ORGANIZATION_ID_PREFIX, SCAPI_TENANT_SCOPE_PREFIX, CUSTOM_APIS_DEFAULT_SCOPES, } from './custom-apis.js';
|
|
126
126
|
export { createScapiSchemasClient, SCAPI_SCHEMAS_DEFAULT_SCOPES } from './scapi-schemas.js';
|
|
127
|
+
export { createCdnZonesClient, CDN_ZONES_READ_SCOPES, CDN_ZONES_RW_SCOPES } from './cdn-zones.js';
|
|
128
|
+
export { createMrtB2CClient, DEFAULT_MRT_B2C_ORIGIN } from './mrt-b2c.js';
|
|
129
|
+
export { getApiErrorMessage } from './error-utils.js';
|
|
127
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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;AAa1F,OAAO,EAAC,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAgBhG,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,cAAc,CAAC;AAaxE,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,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' | 'scapi-schemas' | 'webdav';
|
|
41
|
+
export type HttpClientType = 'ocapi' | 'slas' | 'ods' | 'mrt' | 'mrt-b2c' | 'custom-apis' | 'scapi-schemas' | 'cdn-zones' | 'webdav';
|
|
42
42
|
/**
|
|
43
43
|
* Middleware interface compatible with openapi-fetch.
|
|
44
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-registry.js","sourceRoot":"","sources":["../../../src/clients/middleware-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware-registry.js","sourceRoot":"","sources":["../../../src/clients/middleware-registry.ts"],"names":[],"mappings":"AA4HA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,kBAAkB;IACrB,SAAS,GAA6B,EAAE,CAAC;IAEjD;;;;;;OAMG;IACH,QAAQ,CAAC,QAAgC;QACvC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,IAAY;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAC/D,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,UAA0B;QACtC,MAAM,UAAU,GAAwB,EAAE,CAAC;QAE3C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI,CAAC,EAAE,CAAC;gBACN,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed Runtime B2C Commerce API client.
|
|
3
|
+
*
|
|
4
|
+
* Provides a typed client for the MRT B2C Commerce integration API,
|
|
5
|
+
* which manages the connection between MRT targets and B2C Commerce instances.
|
|
6
|
+
*
|
|
7
|
+
* @module clients/mrt-b2c
|
|
8
|
+
*/
|
|
9
|
+
import { type Client } from 'openapi-fetch';
|
|
10
|
+
import type { AuthStrategy } from '../auth/types.js';
|
|
11
|
+
import type { paths, components } from './mrt-b2c.generated.js';
|
|
12
|
+
import { type MiddlewareRegistry } from './middleware-registry.js';
|
|
13
|
+
/**
|
|
14
|
+
* Re-export generated types for external use.
|
|
15
|
+
*/
|
|
16
|
+
export type { paths, components };
|
|
17
|
+
/**
|
|
18
|
+
* The typed MRT B2C client - openapi-fetch Client with full type safety.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link createMrtB2CClient} for instantiation
|
|
21
|
+
*/
|
|
22
|
+
export type MrtB2CClient = Client<paths>;
|
|
23
|
+
/**
|
|
24
|
+
* Helper type to extract response data from an operation.
|
|
25
|
+
*/
|
|
26
|
+
export type MrtB2CResponse<T> = T extends {
|
|
27
|
+
content: {
|
|
28
|
+
'application/json': infer R;
|
|
29
|
+
};
|
|
30
|
+
} ? R : never;
|
|
31
|
+
/**
|
|
32
|
+
* B2C organization info from MRT.
|
|
33
|
+
*/
|
|
34
|
+
export type B2COrgInfo = components['schemas']['APIB2COrgInfo'];
|
|
35
|
+
/**
|
|
36
|
+
* B2C target info - connection between MRT target and B2C instance.
|
|
37
|
+
*/
|
|
38
|
+
export type B2CTargetInfo = components['schemas']['APIB2CTargetInfo'];
|
|
39
|
+
/**
|
|
40
|
+
* Partial B2C target info for updates.
|
|
41
|
+
*/
|
|
42
|
+
export type PatchedB2CTargetInfo = components['schemas']['PatchedAPIB2CTargetInfo'];
|
|
43
|
+
/**
|
|
44
|
+
* Standard MRT B2C error response structure.
|
|
45
|
+
*/
|
|
46
|
+
export interface MrtB2CError {
|
|
47
|
+
status: number;
|
|
48
|
+
message: string;
|
|
49
|
+
detail?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for creating an MRT B2C client.
|
|
53
|
+
*/
|
|
54
|
+
export interface MrtB2CClientConfig {
|
|
55
|
+
/**
|
|
56
|
+
* The origin URL for the MRT B2C API.
|
|
57
|
+
* @default "https://cloud.mobify.com/api/cc/b2c"
|
|
58
|
+
* @example "https://cloud.mobify.com/api/cc/b2c"
|
|
59
|
+
*/
|
|
60
|
+
origin?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Middleware registry to use for this client.
|
|
63
|
+
* If not specified, uses the global middleware registry.
|
|
64
|
+
*/
|
|
65
|
+
middlewareRegistry?: MiddlewareRegistry;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Default MRT B2C API origin.
|
|
69
|
+
*/
|
|
70
|
+
export declare const DEFAULT_MRT_B2C_ORIGIN = "https://cloud.mobify.com/api/cc/b2c";
|
|
71
|
+
/**
|
|
72
|
+
* Creates a typed Managed Runtime B2C Commerce API client.
|
|
73
|
+
*
|
|
74
|
+
* This client handles the B2C Commerce integration endpoints, which manage
|
|
75
|
+
* the connection between MRT targets/environments and B2C Commerce instances.
|
|
76
|
+
*
|
|
77
|
+
* @param config - MRT B2C client configuration
|
|
78
|
+
* @param auth - Authentication strategy (typically ApiKeyStrategy)
|
|
79
|
+
* @returns Typed openapi-fetch client
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Create MRT B2C client with API key auth
|
|
83
|
+
* const apiKeyStrategy = new ApiKeyStrategy(apiKey, 'Authorization');
|
|
84
|
+
*
|
|
85
|
+
* const client = createMrtB2CClient({}, apiKeyStrategy);
|
|
86
|
+
*
|
|
87
|
+
* // Get B2C organization info
|
|
88
|
+
* const { data, error } = await client.GET('/b2c-organization-info/{organization_slug}/', {
|
|
89
|
+
* params: {
|
|
90
|
+
* path: { organization_slug: 'my-org' }
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* // Get B2C target info
|
|
96
|
+
* const { data, error } = await client.GET('/projects/{project_slug}/b2c-target-info/{target_slug}/', {
|
|
97
|
+
* params: {
|
|
98
|
+
* path: { project_slug: 'my-project', target_slug: 'staging' }
|
|
99
|
+
* }
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Update B2C target info
|
|
104
|
+
* const { data, error } = await client.PUT('/projects/{project_slug}/b2c-target-info/{target_slug}/', {
|
|
105
|
+
* params: {
|
|
106
|
+
* path: { project_slug: 'my-project', target_slug: 'staging' }
|
|
107
|
+
* },
|
|
108
|
+
* body: {
|
|
109
|
+
* instance_id: 'zzxy_prd',
|
|
110
|
+
* sites: ['RefArch', 'SiteGenesis']
|
|
111
|
+
* }
|
|
112
|
+
* });
|
|
113
|
+
*/
|
|
114
|
+
export declare function createMrtB2CClient(config: MrtB2CClientConfig, auth: AuthStrategy): MrtB2CClient;
|
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
"/b2c-organization-info/{organization_slug}/": {
|
|
7
|
+
parameters: {
|
|
8
|
+
query?: never;
|
|
9
|
+
header?: never;
|
|
10
|
+
path?: never;
|
|
11
|
+
cookie?: never;
|
|
12
|
+
};
|
|
13
|
+
/** @description Get the list of B2C Commerce instances connected to a specified organization. This allows you to track the integrations between your Managed Runtime targets (environments) and Commerce Cloud. */
|
|
14
|
+
get: operations["cc_b2c_organization_info_retrieve"];
|
|
15
|
+
put?: never;
|
|
16
|
+
post?: never;
|
|
17
|
+
delete?: never;
|
|
18
|
+
options?: never;
|
|
19
|
+
head?: never;
|
|
20
|
+
patch?: never;
|
|
21
|
+
trace?: never;
|
|
22
|
+
};
|
|
23
|
+
"/projects/{project_slug}/b2c-target-info/{target_slug}/": {
|
|
24
|
+
parameters: {
|
|
25
|
+
query?: never;
|
|
26
|
+
header?: never;
|
|
27
|
+
path?: never;
|
|
28
|
+
cookie?: never;
|
|
29
|
+
};
|
|
30
|
+
/** @description Get the B2C Commerce instance and sites connected to a specified target (environment). This allows you to track the integrations between your Managed Runtime targets and Commerce Cloud. */
|
|
31
|
+
get: operations["cc_b2c_target_info_retrieve"];
|
|
32
|
+
/** @description Create B2C information for a target. */
|
|
33
|
+
put: operations["cc_b2c_target_info_update"];
|
|
34
|
+
post?: never;
|
|
35
|
+
delete?: never;
|
|
36
|
+
options?: never;
|
|
37
|
+
head?: never;
|
|
38
|
+
/** @description Edit a specified target's (environment's) connection to a B2C Commerce instance. If you pass in a list of site IDs, that list replaces the existing sites connected to the target. */
|
|
39
|
+
patch: operations["cc_b2c_target_info_partial_update"];
|
|
40
|
+
trace?: never;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export type webhooks = Record<string, never>;
|
|
44
|
+
export interface components {
|
|
45
|
+
schemas: {
|
|
46
|
+
APIB2COrgInfo: {
|
|
47
|
+
/** @description Specifies whether the organization is a B2C customer account. Returns true if the organization is a B2C customer account. Returns false if the organization isn't a B2C customer account. */
|
|
48
|
+
is_b2c_customer: boolean;
|
|
49
|
+
instances: string[];
|
|
50
|
+
};
|
|
51
|
+
APIB2CTargetInfo: {
|
|
52
|
+
/** @description ID of the B2C Commerce instance associated with the target */
|
|
53
|
+
instance_id: string;
|
|
54
|
+
sites?: string[] | null;
|
|
55
|
+
};
|
|
56
|
+
PatchedAPIB2CTargetInfo: {
|
|
57
|
+
/** @description ID of the B2C Commerce instance associated with the target */
|
|
58
|
+
instance_id?: string;
|
|
59
|
+
sites?: string[] | null;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
responses: never;
|
|
63
|
+
parameters: never;
|
|
64
|
+
requestBodies: never;
|
|
65
|
+
headers: never;
|
|
66
|
+
pathItems: never;
|
|
67
|
+
}
|
|
68
|
+
export type $defs = Record<string, never>;
|
|
69
|
+
export interface operations {
|
|
70
|
+
cc_b2c_organization_info_retrieve: {
|
|
71
|
+
parameters: {
|
|
72
|
+
query?: never;
|
|
73
|
+
header?: never;
|
|
74
|
+
path: {
|
|
75
|
+
/** @description The organization identifier. */
|
|
76
|
+
organization_slug: string;
|
|
77
|
+
};
|
|
78
|
+
cookie?: never;
|
|
79
|
+
};
|
|
80
|
+
requestBody?: never;
|
|
81
|
+
responses: {
|
|
82
|
+
200: {
|
|
83
|
+
headers: {
|
|
84
|
+
[name: string]: unknown;
|
|
85
|
+
};
|
|
86
|
+
content: {
|
|
87
|
+
"application/json": components["schemas"]["APIB2COrgInfo"];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
cc_b2c_target_info_retrieve: {
|
|
93
|
+
parameters: {
|
|
94
|
+
query?: never;
|
|
95
|
+
header?: never;
|
|
96
|
+
path: {
|
|
97
|
+
/** @description The project identifier. */
|
|
98
|
+
project_slug: string;
|
|
99
|
+
/** @description The target identifier. */
|
|
100
|
+
target_slug: string;
|
|
101
|
+
};
|
|
102
|
+
cookie?: never;
|
|
103
|
+
};
|
|
104
|
+
requestBody?: never;
|
|
105
|
+
responses: {
|
|
106
|
+
200: {
|
|
107
|
+
headers: {
|
|
108
|
+
[name: string]: unknown;
|
|
109
|
+
};
|
|
110
|
+
content: {
|
|
111
|
+
"application/json": components["schemas"]["APIB2CTargetInfo"];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
cc_b2c_target_info_update: {
|
|
117
|
+
parameters: {
|
|
118
|
+
query?: never;
|
|
119
|
+
header?: never;
|
|
120
|
+
path: {
|
|
121
|
+
/** @description The project identifier. */
|
|
122
|
+
project_slug: string;
|
|
123
|
+
/** @description The target identifier. */
|
|
124
|
+
target_slug: string;
|
|
125
|
+
};
|
|
126
|
+
cookie?: never;
|
|
127
|
+
};
|
|
128
|
+
requestBody: {
|
|
129
|
+
content: {
|
|
130
|
+
"application/json": components["schemas"]["APIB2CTargetInfo"];
|
|
131
|
+
"application/x-www-form-urlencoded": components["schemas"]["APIB2CTargetInfo"];
|
|
132
|
+
"multipart/form-data": components["schemas"]["APIB2CTargetInfo"];
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
responses: {
|
|
136
|
+
200: {
|
|
137
|
+
headers: {
|
|
138
|
+
[name: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
content: {
|
|
141
|
+
"application/json": components["schemas"]["APIB2CTargetInfo"];
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
cc_b2c_target_info_partial_update: {
|
|
147
|
+
parameters: {
|
|
148
|
+
query?: never;
|
|
149
|
+
header?: never;
|
|
150
|
+
path: {
|
|
151
|
+
/** @description The project identifier. */
|
|
152
|
+
project_slug: string;
|
|
153
|
+
/** @description The target identifier. */
|
|
154
|
+
target_slug: string;
|
|
155
|
+
};
|
|
156
|
+
cookie?: never;
|
|
157
|
+
};
|
|
158
|
+
requestBody?: {
|
|
159
|
+
content: {
|
|
160
|
+
"application/json": components["schemas"]["PatchedAPIB2CTargetInfo"];
|
|
161
|
+
"application/x-www-form-urlencoded": components["schemas"]["PatchedAPIB2CTargetInfo"];
|
|
162
|
+
"multipart/form-data": components["schemas"]["PatchedAPIB2CTargetInfo"];
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
responses: {
|
|
166
|
+
200: {
|
|
167
|
+
headers: {
|
|
168
|
+
[name: string]: unknown;
|
|
169
|
+
};
|
|
170
|
+
content: {
|
|
171
|
+
"application/json": components["schemas"]["APIB2CTargetInfo"];
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mrt-b2c.generated.js","sourceRoot":"","sources":["../../../src/clients/mrt-b2c.generated.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* Managed Runtime B2C Commerce API client.
|
|
8
|
+
*
|
|
9
|
+
* Provides a typed client for the MRT B2C Commerce integration API,
|
|
10
|
+
* which manages the connection between MRT targets and B2C Commerce instances.
|
|
11
|
+
*
|
|
12
|
+
* @module clients/mrt-b2c
|
|
13
|
+
*/
|
|
14
|
+
import createClient from 'openapi-fetch';
|
|
15
|
+
import { createAuthMiddleware, createLoggingMiddleware } from './middleware.js';
|
|
16
|
+
import { globalMiddlewareRegistry } from './middleware-registry.js';
|
|
17
|
+
/**
|
|
18
|
+
* Default MRT B2C API origin.
|
|
19
|
+
*/
|
|
20
|
+
export const DEFAULT_MRT_B2C_ORIGIN = 'https://cloud.mobify.com/api/cc/b2c';
|
|
21
|
+
/**
|
|
22
|
+
* Creates a typed Managed Runtime B2C Commerce API client.
|
|
23
|
+
*
|
|
24
|
+
* This client handles the B2C Commerce integration endpoints, which manage
|
|
25
|
+
* the connection between MRT targets/environments and B2C Commerce instances.
|
|
26
|
+
*
|
|
27
|
+
* @param config - MRT B2C client configuration
|
|
28
|
+
* @param auth - Authentication strategy (typically ApiKeyStrategy)
|
|
29
|
+
* @returns Typed openapi-fetch client
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Create MRT B2C client with API key auth
|
|
33
|
+
* const apiKeyStrategy = new ApiKeyStrategy(apiKey, 'Authorization');
|
|
34
|
+
*
|
|
35
|
+
* const client = createMrtB2CClient({}, apiKeyStrategy);
|
|
36
|
+
*
|
|
37
|
+
* // Get B2C organization info
|
|
38
|
+
* const { data, error } = await client.GET('/b2c-organization-info/{organization_slug}/', {
|
|
39
|
+
* params: {
|
|
40
|
+
* path: { organization_slug: 'my-org' }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Get B2C target info
|
|
46
|
+
* const { data, error } = await client.GET('/projects/{project_slug}/b2c-target-info/{target_slug}/', {
|
|
47
|
+
* params: {
|
|
48
|
+
* path: { project_slug: 'my-project', target_slug: 'staging' }
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Update B2C target info
|
|
54
|
+
* const { data, error } = await client.PUT('/projects/{project_slug}/b2c-target-info/{target_slug}/', {
|
|
55
|
+
* params: {
|
|
56
|
+
* path: { project_slug: 'my-project', target_slug: 'staging' }
|
|
57
|
+
* },
|
|
58
|
+
* body: {
|
|
59
|
+
* instance_id: 'zzxy_prd',
|
|
60
|
+
* sites: ['RefArch', 'SiteGenesis']
|
|
61
|
+
* }
|
|
62
|
+
* });
|
|
63
|
+
*/
|
|
64
|
+
export function createMrtB2CClient(config, auth) {
|
|
65
|
+
let origin = config.origin || DEFAULT_MRT_B2C_ORIGIN;
|
|
66
|
+
const registry = config.middlewareRegistry ?? globalMiddlewareRegistry;
|
|
67
|
+
// Normalize origin: add https:// if no protocol specified
|
|
68
|
+
if (origin && !origin.startsWith('http://') && !origin.startsWith('https://')) {
|
|
69
|
+
origin = `https://${origin}`;
|
|
70
|
+
}
|
|
71
|
+
const client = createClient({
|
|
72
|
+
baseUrl: origin,
|
|
73
|
+
});
|
|
74
|
+
// Core middleware: auth first
|
|
75
|
+
client.use(createAuthMiddleware(auth));
|
|
76
|
+
// Plugin middleware from registry
|
|
77
|
+
for (const middleware of registry.getMiddleware('mrt-b2c')) {
|
|
78
|
+
client.use(middleware);
|
|
79
|
+
}
|
|
80
|
+
// Logging middleware last (sees complete request with all modifications)
|
|
81
|
+
client.use(createLoggingMiddleware({
|
|
82
|
+
prefix: 'MRT-B2C',
|
|
83
|
+
}));
|
|
84
|
+
return client;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=mrt-b2c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mrt-b2c.js","sourceRoot":"","sources":["../../../src/clients/mrt-b2c.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;GAOG;AACH,OAAO,YAA2B,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAC,oBAAoB,EAAE,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAC,wBAAwB,EAA0B,MAAM,0BAA0B,CAAC;AA6D3F;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,qCAAqC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B,EAAE,IAAkB;IAC/E,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,sBAAsB,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,kBAAkB,IAAI,wBAAwB,CAAC;IAEvE,0DAA0D;IAC1D,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9E,MAAM,GAAG,WAAW,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAQ;QACjC,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;IAEH,8BAA8B;IAC9B,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvC,kCAAkC;IAClC,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAED,yEAAyE;IACzE,MAAM,CAAC,GAAG,CACR,uBAAuB,CAAC;QACtB,MAAM,EAAE,SAAS;KAClB,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|