@doswiftly/storefront-sdk 16.1.0 → 18.0.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/CHANGELOG.md +1255 -0
- package/README.md +16 -4
- package/dist/core/auth/auth-client.d.ts +39 -3
- package/dist/core/auth/auth-client.d.ts.map +1 -1
- package/dist/core/auth/auth-client.js +51 -3
- package/dist/core/auth/cookie-config.d.ts +52 -3
- package/dist/core/auth/cookie-config.d.ts.map +1 -1
- package/dist/core/auth/cookie-config.js +60 -6
- package/dist/core/auth/handlers.d.ts +46 -0
- package/dist/core/auth/handlers.d.ts.map +1 -1
- package/dist/core/auth/handlers.js +9 -2
- package/dist/core/auth/session-events.d.ts +38 -0
- package/dist/core/auth/session-events.d.ts.map +1 -0
- package/dist/core/auth/session-events.js +35 -0
- package/dist/core/cart/cart-client.d.ts +10 -1
- package/dist/core/cart/cart-client.d.ts.map +1 -1
- package/dist/core/cart/cart-client.js +17 -1
- package/dist/core/cart/cart-recovery.d.ts +23 -0
- package/dist/core/cart/cart-recovery.d.ts.map +1 -1
- package/dist/core/cart/cart-recovery.js +20 -3
- package/dist/core/cart/types.d.ts +2 -1
- package/dist/core/cart/types.d.ts.map +1 -1
- package/dist/core/cart/types.js +7 -1
- package/dist/core/client/create-client.d.ts.map +1 -1
- package/dist/core/client/create-client.js +7 -3
- package/dist/core/client/execute.d.ts +29 -3
- package/dist/core/client/execute.d.ts.map +1 -1
- package/dist/core/client/execute.js +174 -3
- package/dist/core/client/types.d.ts +50 -2
- package/dist/core/client/types.d.ts.map +1 -1
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +6 -0
- package/dist/core/generated/operation-types.d.ts +937 -182
- package/dist/core/generated/operation-types.d.ts.map +1 -1
- package/dist/core/generated/operation-types.js +560 -1
- package/dist/core/index.d.ts +6 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +12 -2
- package/dist/core/middleware/session-retry.d.ts +47 -0
- package/dist/core/middleware/session-retry.d.ts.map +1 -0
- package/dist/core/middleware/session-retry.js +71 -0
- package/dist/core/operations/auth.d.ts.map +1 -1
- package/dist/core/operations/auth.js +1 -0
- package/dist/core/operations/cart.d.ts +7 -0
- package/dist/core/operations/cart.d.ts.map +1 -1
- package/dist/core/operations/cart.js +54 -3
- package/dist/react/components/PaymentInstrumentSection.d.ts +56 -0
- package/dist/react/components/PaymentInstrumentSection.d.ts.map +1 -0
- package/dist/react/components/PaymentInstrumentSection.js +89 -0
- package/dist/react/components/PaymentInstrumentTile.d.ts +56 -0
- package/dist/react/components/PaymentInstrumentTile.d.ts.map +1 -0
- package/dist/react/components/PaymentInstrumentTile.js +41 -0
- package/dist/react/components/index.d.ts +2 -0
- package/dist/react/components/index.d.ts.map +1 -1
- package/dist/react/components/index.js +2 -0
- package/dist/react/helpers/browser-data.d.ts +89 -0
- package/dist/react/helpers/browser-data.d.ts.map +1 -0
- package/dist/react/helpers/browser-data.js +84 -0
- package/dist/react/hooks/use-cart-manager.d.ts +104 -13
- package/dist/react/hooks/use-cart-manager.d.ts.map +1 -1
- package/dist/react/hooks/use-cart-manager.js +144 -12
- package/dist/react/hooks/use-login.d.ts.map +1 -1
- package/dist/react/hooks/use-login.js +3 -3
- package/dist/react/hooks/use-refresh-token.d.ts.map +1 -1
- package/dist/react/hooks/use-refresh-token.js +6 -4
- package/dist/react/hooks/use-session-expired.d.ts +16 -0
- package/dist/react/hooks/use-session-expired.d.ts.map +1 -0
- package/dist/react/hooks/use-session-expired.js +26 -0
- package/dist/react/hooks/use-session-refresh.d.ts +32 -0
- package/dist/react/hooks/use-session-refresh.d.ts.map +1 -0
- package/dist/react/hooks/use-session-refresh.js +147 -0
- package/dist/react/index.d.ts +5 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -1
- package/dist/react/providers/storefront-client-provider.d.ts +10 -1
- package/dist/react/providers/storefront-client-provider.d.ts.map +1 -1
- package/dist/react/providers/storefront-client-provider.js +38 -3
- package/dist/react/providers/storefront-provider.d.ts +51 -3
- package/dist/react/providers/storefront-provider.d.ts.map +1 -1
- package/dist/react/providers/storefront-provider.js +22 -5
- package/dist/react/server/create-storefront-auth-route.d.ts +63 -0
- package/dist/react/server/create-storefront-auth-route.d.ts.map +1 -0
- package/dist/react/server/create-storefront-auth-route.js +239 -0
- package/dist/react/server/get-initial-auth.d.ts +57 -0
- package/dist/react/server/get-initial-auth.d.ts.map +1 -0
- package/dist/react/server/get-initial-auth.js +55 -0
- package/dist/react/server/index.d.ts +3 -0
- package/dist/react/server/index.d.ts.map +1 -1
- package/dist/react/server/index.js +6 -0
- package/dist/react/stores/auth.store.d.ts +46 -2
- package/dist/react/stores/auth.store.d.ts.map +1 -1
- package/dist/react/stores/auth.store.js +19 -7
- package/package.json +4 -2
|
@@ -156,11 +156,20 @@ async function acquireCartId(coord, factory) {
|
|
|
156
156
|
* consumers can wire this directly without the runner factory.
|
|
157
157
|
*/
|
|
158
158
|
export async function executeWithCartRecovery(opts) {
|
|
159
|
-
const { cartClient, cookieStore, operation, ensureCart, cookieMaxAge, onExpired, onSessionExpired } = opts;
|
|
159
|
+
const { cartClient, cookieStore, operation, ensureCart, cookieMaxAge, onExpired, onSessionExpired, initialCartId, } = opts;
|
|
160
160
|
const coord = opts.recoveryCoordinator ?? createCoordinator();
|
|
161
161
|
const opName = operation.name ?? 'unknown';
|
|
162
162
|
// Phase 0 — ensure cart exists (cookie may be empty on first interaction).
|
|
163
|
+
// Priority: cookie wins (cross-tab canonical state) → initialCartId seed
|
|
164
|
+
// (server-known via env / SSO / magic-link / iframe / customer service) →
|
|
165
|
+
// auto-create fallback through the coordinator. The seed is eagerly written
|
|
166
|
+
// to the cookie so subsequent reads see a canonical value and the recovery
|
|
167
|
+
// path (Phase 2a/2b) operates on a known cookie when the seed turns out stale.
|
|
163
168
|
let cartId = cookieStore.get();
|
|
169
|
+
if (!cartId && initialCartId) {
|
|
170
|
+
cookieStore.set(initialCartId, cookieMaxAge !== undefined ? { maxAge: cookieMaxAge } : undefined);
|
|
171
|
+
cartId = initialCartId;
|
|
172
|
+
}
|
|
164
173
|
if (!cartId) {
|
|
165
174
|
cartId = await acquireCartId(coord, async () => {
|
|
166
175
|
const created = ensureCart ? await ensureCart() : (await cartClient.create()).cart;
|
|
@@ -237,7 +246,7 @@ export async function executeWithCartRecovery(opts) {
|
|
|
237
246
|
* concurrent operations and exposes an `onExpired` listener pattern.
|
|
238
247
|
*/
|
|
239
248
|
export function createCartRecoveryRunner(options) {
|
|
240
|
-
const { cartClient, cookieStore, ensureCart, cookieMaxAge } = options;
|
|
249
|
+
const { cartClient, cookieStore, ensureCart, cookieMaxAge, initialCartId } = options;
|
|
241
250
|
const coordinator = createCoordinator();
|
|
242
251
|
const expiredListeners = new Set();
|
|
243
252
|
const sessionListeners = new Set();
|
|
@@ -271,6 +280,7 @@ export function createCartRecoveryRunner(options) {
|
|
|
271
280
|
operation,
|
|
272
281
|
ensureCart,
|
|
273
282
|
cookieMaxAge,
|
|
283
|
+
initialCartId,
|
|
274
284
|
recoveryCoordinator: coordinator,
|
|
275
285
|
onExpired: emitExpired,
|
|
276
286
|
onSessionExpired: emitSessionExpired,
|
|
@@ -278,7 +288,14 @@ export function createCartRecoveryRunner(options) {
|
|
|
278
288
|
return executeWithCartRecovery(internalOpts);
|
|
279
289
|
},
|
|
280
290
|
async getCart() {
|
|
281
|
-
|
|
291
|
+
// Symmetric with Phase 0 of `execute` — cookie wins, seed fills the gap
|
|
292
|
+
// and is eagerly promoted to the cookie so the next mutation picks it up
|
|
293
|
+
// from the canonical source without re-reading the seed.
|
|
294
|
+
let cartId = cookieStore.get();
|
|
295
|
+
if (!cartId && initialCartId) {
|
|
296
|
+
cookieStore.set(initialCartId, cookieMaxAge !== undefined ? { maxAge: cookieMaxAge } : undefined);
|
|
297
|
+
cartId = initialCartId;
|
|
298
|
+
}
|
|
282
299
|
if (!cartId)
|
|
283
300
|
return null;
|
|
284
301
|
try {
|
|
@@ -93,7 +93,8 @@ export type PaymentSession = PaymentSessionFragment;
|
|
|
93
93
|
export type DiscountValidationResult = CartValidateDiscountCodeQuery['cartValidateDiscountCode'];
|
|
94
94
|
export type DiscountInfo = NonNullable<DiscountValidationResult['discount']>;
|
|
95
95
|
export type DiscountValidationError = NonNullable<DiscountValidationResult['error']>;
|
|
96
|
-
export type { CartCreateInput, CartLineInput, CartLineUpdateInput, CartBuyerIdentityInput, CartAddressInput, CartAttributeInput, CartCompleteInput, CartApplyGiftCardInput, CartRemoveGiftCardInput, CartSelectPaymentMethodInput, CartSelectShippingMethodInput, CartSetBillingAddressInput, CartSetShippingAddressInput, CartUpdateGiftCardRecipientInput, PaymentCreateInput, ShippingAddressInput, PickupPointInput,
|
|
96
|
+
export type { CartCreateInput, CartLineInput, CartLineUpdateInput, CartBuyerIdentityInput, CartAddressInput, CartAttributeInput, CartCompleteInput, CartApplyGiftCardInput, CartRemoveGiftCardInput, CartSelectPaymentMethodInput, CartClearPaymentSelectionInput, CartSelectShippingMethodInput, CartSetBillingAddressInput, CartSetShippingAddressInput, CartUpdateGiftCardRecipientInput, PaymentCreateInput, ShippingAddressInput, PickupPointInput, DeliveryEstimate, ShippingCarrier, FreeShippingProgress, PickupPoint, AttributeSelectionInput as CartAttributeSelectionInput, } from '../generated/operation-types';
|
|
97
|
+
export { DeliveryType, PaymentMethodType, PaymentInitiationFlow, DiscountApplicationType, DiscountErrorCode, CurrencyCode, CountryCode, LanguageCode, ProductTypeEnum, WeightUnit, CartWarningCode, AttributeType, AttributeFillingMode, AttributeBillingMode, AttributeOptionSurchargeType, StorefrontOrderStatus, OrderPaymentStatus, OrderFulfillmentStatus, PaymentProvider, PaymentInstrumentType, PaymentInstrumentDisplayHint, PaymentMethodUnavailableReason, } from '../generated/operation-types';
|
|
97
98
|
/**
|
|
98
99
|
* Machine-readable error code surfaced when `createPayment` fails. The call
|
|
99
100
|
* throws a `StorefrontError` on `userErrors` — read `.userErrors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B,gCAAgC,EAChC,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAIhB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EAEpB,WAAW,EAEX,uBAAuB,IAAI,2BAA2B,GACvD,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC;AAMtC;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,oBAAoB,GACpB,mBAAmB,GACnB,iCAAiC,GACjC,oBAAoB,GACpB,mBAAmB,GACnB,gBAAgB,CAAC"}
|
package/dist/core/cart/types.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Schema enums — re-exported as VALUES (runtime const + type alias). Storefront
|
|
2
|
+
// devs can `z.enum(Object.values(PaymentMethodType))`, `Object.values(...)`,
|
|
3
|
+
// `Object.keys(...)` for runtime validation, while `import type { X }` still
|
|
4
|
+
// works because the codegen emits a sibling type alias under the same name
|
|
5
|
+
// (`enumsAsConst`). Promoting these from `export type` to plain `export` is
|
|
6
|
+
// strictly additive — no breaking change for existing `import type` consumers.
|
|
7
|
+
export { DeliveryType, PaymentMethodType, PaymentInitiationFlow, DiscountApplicationType, DiscountErrorCode, CurrencyCode, CountryCode, LanguageCode, ProductTypeEnum, WeightUnit, CartWarningCode, AttributeType, AttributeFillingMode, AttributeBillingMode, AttributeOptionSurchargeType, StorefrontOrderStatus, OrderPaymentStatus, OrderFulfillmentStatus, PaymentProvider, PaymentInstrumentType, PaymentInstrumentDisplayHint, PaymentMethodUnavailableReason, } from '../generated/operation-types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-client.d.ts","sourceRoot":"","sources":["../../../src/core/client/create-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAKjB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"create-client.d.ts","sourceRoot":"","sources":["../../../src/core/client/create-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAKjB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,gBAAgB,CA0GvF"}
|
|
@@ -10,19 +10,23 @@
|
|
|
10
10
|
*
|
|
11
11
|
* 0 runtime dependencies.
|
|
12
12
|
*/
|
|
13
|
-
import { createExecute } from './execute';
|
|
13
|
+
import { createExecute, resolveDebugOptions } from './execute';
|
|
14
14
|
import { compose } from './compose';
|
|
15
15
|
import { dedupe } from './dedupe';
|
|
16
16
|
import { hashQuery } from './hash';
|
|
17
17
|
import { getOperationName } from './operation-name';
|
|
18
18
|
export function createStorefrontClient(config) {
|
|
19
|
-
const { apiUrl, shopSlug, defaultHeaders = {}, middleware: initialMiddleware = [], fetch: customFetch = globalThis.fetch, debug
|
|
19
|
+
const { apiUrl, shopSlug, defaultHeaders = {}, middleware: initialMiddleware = [], fetch: customFetch = globalThis.fetch, debug, } = config;
|
|
20
20
|
const endpoint = `${apiUrl.replace(/\/$/, '')}/storefront/graphql`;
|
|
21
21
|
// Mutable middleware list — use() adds to it, invalidates compiled pipeline
|
|
22
22
|
const middlewares = [...initialMiddleware];
|
|
23
23
|
let compiledPipeline = null;
|
|
24
|
+
// Normalise the public `boolean | 'verbose' | DebugOptions` union into the
|
|
25
|
+
// canonical ResolvedDebugOptions shape (or null = no logging). Env var
|
|
26
|
+
// fallback (`DOSWIFTLY_SDK_DEBUG`) applies only when `debug` is undefined.
|
|
27
|
+
const resolvedDebug = resolveDebugOptions(debug);
|
|
24
28
|
// Create the innermost execute function (native fetch)
|
|
25
|
-
const innerExecute = createExecute({ endpoint, fetch: customFetch, debug });
|
|
29
|
+
const innerExecute = createExecute({ endpoint, fetch: customFetch, debug: resolvedDebug });
|
|
26
30
|
/**
|
|
27
31
|
* Get or build the compiled middleware pipeline (lazy).
|
|
28
32
|
* Rebuilt on first call and after use() is called.
|
|
@@ -4,15 +4,41 @@
|
|
|
4
4
|
* Sends GraphQL POST request, parses response, returns typed GraphQLResponse.
|
|
5
5
|
* Error normalization is handled by error middleware, NOT here.
|
|
6
6
|
*/
|
|
7
|
-
import type { GraphQLRequest, GraphQLResponse } from './types';
|
|
7
|
+
import type { DebugEvent, DebugOptions, GraphQLRequest, GraphQLResponse } from './types';
|
|
8
8
|
export interface ExecuteConfig {
|
|
9
9
|
/** GraphQL endpoint URL */
|
|
10
10
|
endpoint: string;
|
|
11
11
|
/** Custom fetch implementation */
|
|
12
12
|
fetch: typeof globalThis.fetch;
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolved debug options (null = no logging). Caller is responsible for
|
|
15
|
+
* normalising the public `boolean | 'verbose' | DebugOptions` config into
|
|
16
|
+
* this canonical shape via `resolveDebugOptions`.
|
|
17
|
+
*/
|
|
18
|
+
debug: ResolvedDebugOptions | null;
|
|
15
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Internal canonical form of `DebugOptions` — every flag explicit, `log` always set.
|
|
22
|
+
* Produced by `resolveDebugOptions` from the public union type.
|
|
23
|
+
*/
|
|
24
|
+
export interface ResolvedDebugOptions {
|
|
25
|
+
request: boolean;
|
|
26
|
+
response: boolean;
|
|
27
|
+
headers: boolean;
|
|
28
|
+
timing: boolean;
|
|
29
|
+
userErrors: boolean;
|
|
30
|
+
log: (event: DebugEvent) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Normalise the public `debug` config (`boolean | 'verbose' | DebugOptions`)
|
|
34
|
+
* into a canonical `ResolvedDebugOptions`. `null` means "no logging".
|
|
35
|
+
*
|
|
36
|
+
* Env var fallback (`DOSWIFTLY_SDK_DEBUG`) is applied **only** when `input`
|
|
37
|
+
* is `undefined` — explicit `false` from the consumer wins. Production
|
|
38
|
+
* fallback is no-op to prevent accidental PII logging through environment
|
|
39
|
+
* leakage; explicit programmatic `debug` is honoured regardless of env.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveDebugOptions(input: boolean | 'verbose' | DebugOptions | undefined): ResolvedDebugOptions | null;
|
|
16
42
|
/**
|
|
17
43
|
* Create the innermost execute function for the middleware pipeline.
|
|
18
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/core/client/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/core/client/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EAEZ,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B;;;;OAIG;IACH,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAClC;AAsCD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GACpD,oBAAoB,GAAG,IAAI,CAiB7B;AAwFD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,IAGnB,SAAS,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC,CAyEjF"}
|
|
@@ -4,6 +4,153 @@
|
|
|
4
4
|
* Sends GraphQL POST request, parses response, returns typed GraphQLResponse.
|
|
5
5
|
* Error normalization is handled by error middleware, NOT here.
|
|
6
6
|
*/
|
|
7
|
+
const DEFAULT_LOG = (event) => {
|
|
8
|
+
// Header on a separate line so the data dump below renders untruncated in
|
|
9
|
+
// both terminals and DevTools.
|
|
10
|
+
// eslint-disable-next-line no-console
|
|
11
|
+
console.log('[StorefrontSDK]', event.phase, event.operationName ?? 'anonymous');
|
|
12
|
+
// `console.dir(obj, { depth: null })` is the cross-runtime escape hatch for
|
|
13
|
+
// Node's default `util.inspect` depth of 2 — without it, `shippingAddress:
|
|
14
|
+
// [Object]` and `data: { cart: [Object] }` swallow exactly the payload the
|
|
15
|
+
// developer turned `verbose` on to see. Browser DevTools ignores the 2nd
|
|
16
|
+
// argument and renders an interactive drill-down (no `[Object]` problem
|
|
17
|
+
// there); the options apply where they matter (Node terminal, CI logs).
|
|
18
|
+
// `colors: false` suppresses ANSI escape codes so log files and CI output
|
|
19
|
+
// stay grep-friendly. Consumers wiring `pino`/`winston` through
|
|
20
|
+
// `DebugOptions.log` skip this path entirely and use their own serialiser.
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.dir(event.data, { depth: null, colors: false });
|
|
23
|
+
};
|
|
24
|
+
const MINIMAL_DEBUG = {
|
|
25
|
+
request: false,
|
|
26
|
+
response: false,
|
|
27
|
+
headers: false,
|
|
28
|
+
timing: false,
|
|
29
|
+
userErrors: true,
|
|
30
|
+
log: DEFAULT_LOG,
|
|
31
|
+
};
|
|
32
|
+
const VERBOSE_DEBUG = {
|
|
33
|
+
request: true,
|
|
34
|
+
response: true,
|
|
35
|
+
headers: true,
|
|
36
|
+
timing: true,
|
|
37
|
+
userErrors: true,
|
|
38
|
+
log: DEFAULT_LOG,
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Normalise the public `debug` config (`boolean | 'verbose' | DebugOptions`)
|
|
42
|
+
* into a canonical `ResolvedDebugOptions`. `null` means "no logging".
|
|
43
|
+
*
|
|
44
|
+
* Env var fallback (`DOSWIFTLY_SDK_DEBUG`) is applied **only** when `input`
|
|
45
|
+
* is `undefined` — explicit `false` from the consumer wins. Production
|
|
46
|
+
* fallback is no-op to prevent accidental PII logging through environment
|
|
47
|
+
* leakage; explicit programmatic `debug` is honoured regardless of env.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveDebugOptions(input) {
|
|
50
|
+
if (input === undefined) {
|
|
51
|
+
const env = readEnvDebug();
|
|
52
|
+
if (env === null)
|
|
53
|
+
return null;
|
|
54
|
+
return env === 'verbose' ? VERBOSE_DEBUG : MINIMAL_DEBUG;
|
|
55
|
+
}
|
|
56
|
+
if (input === false)
|
|
57
|
+
return null;
|
|
58
|
+
if (input === true)
|
|
59
|
+
return MINIMAL_DEBUG;
|
|
60
|
+
if (input === 'verbose')
|
|
61
|
+
return VERBOSE_DEBUG;
|
|
62
|
+
return {
|
|
63
|
+
request: input.request ?? false,
|
|
64
|
+
response: input.response ?? false,
|
|
65
|
+
headers: input.headers ?? false,
|
|
66
|
+
timing: input.timing ?? false,
|
|
67
|
+
userErrors: input.userErrors ?? true,
|
|
68
|
+
log: input.log ?? DEFAULT_LOG,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Read `process.env.DOSWIFTLY_SDK_DEBUG` once per resolve call. Returns
|
|
73
|
+
* `'verbose'`, `'minimal'`, or `null`. Production environments are no-op —
|
|
74
|
+
* env-driven debug mode is dev/test only; programmatic `debug` is the
|
|
75
|
+
* escape hatch when an operator genuinely needs production traces.
|
|
76
|
+
*/
|
|
77
|
+
function readEnvDebug() {
|
|
78
|
+
// `process` may be undefined in non-Node runtimes (Cloudflare Workers,
|
|
79
|
+
// some Edge environments) — guard before access.
|
|
80
|
+
if (typeof process === 'undefined' || !process.env)
|
|
81
|
+
return null;
|
|
82
|
+
if (process.env.NODE_ENV === 'production')
|
|
83
|
+
return null;
|
|
84
|
+
const raw = process.env.DOSWIFTLY_SDK_DEBUG;
|
|
85
|
+
if (!raw)
|
|
86
|
+
return null;
|
|
87
|
+
const normalized = raw.trim().toLowerCase();
|
|
88
|
+
if (normalized === 'verbose')
|
|
89
|
+
return 'verbose';
|
|
90
|
+
if (normalized === 'true' || normalized === '1' || normalized === 'minimal')
|
|
91
|
+
return 'minimal';
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Mask `Bearer <token>` payloads inline so logged headers never carry a usable
|
|
96
|
+
* credential. Preserves the prefix + last-4 to make the diagnostic useful
|
|
97
|
+
* (token rotation, scope mismatch) without leaking the full value.
|
|
98
|
+
*/
|
|
99
|
+
function redactBearer(value) {
|
|
100
|
+
return value.replace(/Bearer\s+(\S+)/gi, (_match, token) => `Bearer ***${token.slice(-4)}`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Mask known auth cookies (`customerAccessToken`) inside a cookie string —
|
|
104
|
+
* applies to both `Cookie` request headers and `Set-Cookie` response headers.
|
|
105
|
+
*/
|
|
106
|
+
function redactCookies(value) {
|
|
107
|
+
return value.replace(/(customerAccessToken)=([^;]+)/gi, (_match, name, token) => `${name}=***${token.slice(-4)}`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Apply both bearer + cookie redaction to a single header value. Other
|
|
111
|
+
* sensitive headers can be added here when new platform contracts emerge.
|
|
112
|
+
*/
|
|
113
|
+
function redactHeaderValue(name, value) {
|
|
114
|
+
const lower = name.toLowerCase();
|
|
115
|
+
if (lower === 'authorization')
|
|
116
|
+
return redactBearer(value);
|
|
117
|
+
if (lower === 'cookie' || lower === 'set-cookie')
|
|
118
|
+
return redactCookies(value);
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
function redactRequestHeaders(headers) {
|
|
122
|
+
const out = {};
|
|
123
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
124
|
+
out[name] = redactHeaderValue(name, value);
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
function redactResponseHeaders(headers) {
|
|
129
|
+
const out = {};
|
|
130
|
+
headers.forEach((value, name) => {
|
|
131
|
+
out[name] = redactHeaderValue(name, value);
|
|
132
|
+
});
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Flatten every `userErrors[]` array from top-level mutation payloads into a
|
|
137
|
+
* single array — the single most useful diagnostic when a mutation throws.
|
|
138
|
+
* Returns `[]` when the response has no userErrors anywhere.
|
|
139
|
+
*/
|
|
140
|
+
function extractUserErrors(data) {
|
|
141
|
+
if (!data || typeof data !== 'object')
|
|
142
|
+
return [];
|
|
143
|
+
const flat = [];
|
|
144
|
+
for (const value of Object.values(data)) {
|
|
145
|
+
if (value && typeof value === 'object') {
|
|
146
|
+
const candidate = value.userErrors;
|
|
147
|
+
if (Array.isArray(candidate) && candidate.length > 0) {
|
|
148
|
+
flat.push(...candidate);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return flat;
|
|
153
|
+
}
|
|
7
154
|
/**
|
|
8
155
|
* Create the innermost execute function for the middleware pipeline.
|
|
9
156
|
*/
|
|
@@ -11,8 +158,14 @@ export function createExecute(config) {
|
|
|
11
158
|
const { endpoint, fetch: fetchFn, debug } = config;
|
|
12
159
|
return async function execute(request) {
|
|
13
160
|
const { query, variables, headers, signal, operationName } = request;
|
|
161
|
+
const startedAt = debug?.timing ? Date.now() : 0;
|
|
14
162
|
if (debug) {
|
|
15
|
-
|
|
163
|
+
const requestData = { variables };
|
|
164
|
+
if (debug.request)
|
|
165
|
+
requestData.query = query;
|
|
166
|
+
if (debug.headers)
|
|
167
|
+
requestData.headers = redactRequestHeaders(headers);
|
|
168
|
+
debug.log({ phase: 'request', operationName, data: requestData });
|
|
16
169
|
}
|
|
17
170
|
const body = { query };
|
|
18
171
|
if (variables && Object.keys(variables).length > 0) {
|
|
@@ -39,10 +192,28 @@ export function createExecute(config) {
|
|
|
39
192
|
});
|
|
40
193
|
const json = await response.json();
|
|
41
194
|
if (debug) {
|
|
42
|
-
|
|
195
|
+
const responseData = {
|
|
43
196
|
status: response.status,
|
|
44
197
|
hasErrors: !!json.errors?.length,
|
|
45
|
-
}
|
|
198
|
+
};
|
|
199
|
+
if (debug.response) {
|
|
200
|
+
responseData.data = json.data;
|
|
201
|
+
responseData.errors = json.errors;
|
|
202
|
+
if (json.extensions)
|
|
203
|
+
responseData.extensions = json.extensions;
|
|
204
|
+
}
|
|
205
|
+
if (debug.userErrors) {
|
|
206
|
+
const flat = extractUserErrors(json.data);
|
|
207
|
+
if (flat.length > 0)
|
|
208
|
+
responseData.userErrors = flat;
|
|
209
|
+
}
|
|
210
|
+
if (debug.headers) {
|
|
211
|
+
responseData.headers = redactResponseHeaders(response.headers);
|
|
212
|
+
}
|
|
213
|
+
if (debug.timing) {
|
|
214
|
+
responseData.durationMs = Date.now() - startedAt;
|
|
215
|
+
}
|
|
216
|
+
debug.log({ phase: 'response', operationName, data: responseData });
|
|
46
217
|
}
|
|
47
218
|
return {
|
|
48
219
|
data: json.data,
|
|
@@ -89,6 +89,38 @@ export interface CacheOptions {
|
|
|
89
89
|
tags?: string[];
|
|
90
90
|
}
|
|
91
91
|
export type CacheStrategy = CacheOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Granular debug controls. Defaults are minimal so opting into a single
|
|
94
|
+
* dimension does not flood the console — pass `'verbose'` (or set
|
|
95
|
+
* `process.env.DOSWIFTLY_SDK_DEBUG=verbose`) to switch every dimension on.
|
|
96
|
+
*
|
|
97
|
+
* The shape is intentionally a plain object — no enum / class — so future
|
|
98
|
+
* additions stay additive (`bodyMaxBytes`, `redact`, `pretty`, …).
|
|
99
|
+
*/
|
|
100
|
+
export interface DebugOptions {
|
|
101
|
+
/** Log the full GraphQL query document on every request. Default `false` — variables are always logged. */
|
|
102
|
+
request?: boolean;
|
|
103
|
+
/** Log the full response body (`data` + `errors` + `extensions`) on every response. Default `false`. */
|
|
104
|
+
response?: boolean;
|
|
105
|
+
/** Log request headers (sent) and response headers (received). `Authorization` and `customerAccessToken` are auto-redacted to `***<last4>`. Default `false`. */
|
|
106
|
+
headers?: boolean;
|
|
107
|
+
/** Log request duration (`durationMs`) on every response. Default `false`. */
|
|
108
|
+
timing?: boolean;
|
|
109
|
+
/** Surface `userErrors[]` from mutation payloads as a flat array on the response log. Default `true` — the most common diagnostic. */
|
|
110
|
+
userErrors?: boolean;
|
|
111
|
+
/** Custom logger sink. Default `console.log('[StorefrontSDK]', event.phase, event.operationName, event.data)`. Use for routing into `pino` / `winston`. */
|
|
112
|
+
log?: (event: DebugEvent) => void;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Structured event handed to a custom `DebugOptions.log` sink. Stable contract:
|
|
116
|
+
* `phase` and `operationName` are always present; `data` carries the merged
|
|
117
|
+
* payload selected by `DebugOptions` flags.
|
|
118
|
+
*/
|
|
119
|
+
export interface DebugEvent {
|
|
120
|
+
phase: 'request' | 'response';
|
|
121
|
+
operationName: string | undefined;
|
|
122
|
+
data: Record<string, unknown>;
|
|
123
|
+
}
|
|
92
124
|
export interface StorefrontClientConfig {
|
|
93
125
|
/** GraphQL API URL (e.g. 'https://api.doswiftly.pl') */
|
|
94
126
|
apiUrl: string;
|
|
@@ -100,8 +132,24 @@ export interface StorefrontClientConfig {
|
|
|
100
132
|
middleware?: Middleware[];
|
|
101
133
|
/** Custom fetch implementation (polyfill, test mocks, edge) */
|
|
102
134
|
fetch?: typeof globalThis.fetch;
|
|
103
|
-
/**
|
|
104
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Enable debug logging (request/response in dev).
|
|
137
|
+
*
|
|
138
|
+
* Tagged union (backward-compatible):
|
|
139
|
+
* - `false` / omitted — no logging.
|
|
140
|
+
* - `true` — minimal logs: operationName + variables on request, status + hasErrors + userErrors on response.
|
|
141
|
+
* The exact output is preserved from the v17.1.0 minimal mode.
|
|
142
|
+
* - `'verbose'` — every dimension on: full query + variables + headers + response body + userErrors + timing.
|
|
143
|
+
* - `DebugOptions` — granular opt-in per dimension.
|
|
144
|
+
*
|
|
145
|
+
* Falls back to `process.env.DOSWIFTLY_SDK_DEBUG` (`'verbose'` / `'true'` / `'1'`) when this prop is
|
|
146
|
+
* omitted. `NODE_ENV=production` requires an explicit `debug` setting — env-driven verbose mode is
|
|
147
|
+
* no-op in production to prevent accidental logging of customer PII.
|
|
148
|
+
*
|
|
149
|
+
* `Authorization: Bearer …` and `customerAccessToken=…` cookie values are unconditionally redacted
|
|
150
|
+
* to `***<last4>` whenever headers are logged, regardless of mode.
|
|
151
|
+
*/
|
|
152
|
+
debug?: boolean | 'verbose' | DebugOptions;
|
|
105
153
|
}
|
|
106
154
|
export interface StorefrontClient {
|
|
107
155
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/client/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;GAKG;AACH,qBAAa,mBAAmB,CAAC,OAAO,GAAG,OAAO,EAAE,UAAU,GAAG,OAAO,CAAE,SAAQ,MAAM;IAIpD,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAH7D,+CAA+C;IAC/C,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,KAA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IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,0BAA0B;IAC1B,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,CAAC;CAC5C;AAMD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5C,QAAQ,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,EAC5C,SAAS,CAAC,EAAE,CAAC,EACb,KAAK,CAAC,EAAE,aAAa,GACpB,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd;;;;OAIG;IACH,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,QAAQ,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,EAC5C,SAAS,CAAC,EAAE,CAAC,GACZ,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;CACnC"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -39,5 +39,11 @@ export declare const ErrorCodes: {
|
|
|
39
39
|
readonly GRAPHQL_ERROR: "GRAPHQL_ERROR";
|
|
40
40
|
readonly USER_ERROR: "USER_ERROR";
|
|
41
41
|
readonly NO_DATA: "NO_DATA";
|
|
42
|
+
/**
|
|
43
|
+
* The customer session expired and could not be renewed (proactive refresh
|
|
44
|
+
* failed on tab wake, or a reactive refresh after a 401 also failed). Surfaced
|
|
45
|
+
* to the consumer so the storefront can prompt re-authentication.
|
|
46
|
+
*/
|
|
47
|
+
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
42
48
|
};
|
|
43
49
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,0DAA0D;IAC1D,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,mCAAmC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC;gBAErB,OAAO,EAAE,sBAAsB;IAS3C,uEAAuE;IACvE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,yDAAyD;IACzD,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,oCAAoC;IACpC,IAAI,SAAS,IAAI,OAAO,CAEvB;CACF;AAMD,eAAO,MAAM,UAAU;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,0DAA0D;IAC1D,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,mCAAmC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC;gBAErB,OAAO,EAAE,sBAAsB;IAS3C,uEAAuE;IACvE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,yDAAyD;IACzD,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,oCAAoC;IACpC,IAAI,SAAS,IAAI,OAAO,CAEvB;CACF;AAMD,eAAO,MAAM,UAAU;;;;;;;IAOrB;;;;OAIG;;CAEK,CAAC"}
|
package/dist/core/errors.js
CHANGED
|
@@ -40,4 +40,10 @@ export const ErrorCodes = {
|
|
|
40
40
|
GRAPHQL_ERROR: 'GRAPHQL_ERROR',
|
|
41
41
|
USER_ERROR: 'USER_ERROR',
|
|
42
42
|
NO_DATA: 'NO_DATA',
|
|
43
|
+
/**
|
|
44
|
+
* The customer session expired and could not be renewed (proactive refresh
|
|
45
|
+
* failed on tab wake, or a reactive refresh after a 401 also failed). Surfaced
|
|
46
|
+
* to the consumer so the storefront can prompt re-authentication.
|
|
47
|
+
*/
|
|
48
|
+
SESSION_EXPIRED: 'SESSION_EXPIRED',
|
|
43
49
|
};
|