@doswiftly/storefront-sdk 14.0.0 → 16.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 +294 -0
- package/README.md +28 -0
- package/dist/core/auth/auth-client.d.ts +13 -1
- package/dist/core/auth/auth-client.d.ts.map +1 -1
- package/dist/core/auth/auth-client.js +16 -1
- package/dist/core/auth/types.d.ts +18 -52
- package/dist/core/auth/types.d.ts.map +1 -1
- package/dist/core/auth/types.js +0 -3
- package/dist/core/cart/cart-client.d.ts +50 -1
- package/dist/core/cart/cart-client.d.ts.map +1 -1
- package/dist/core/cart/cart-client.js +63 -1
- package/dist/core/cart/types.d.ts +75 -391
- package/dist/core/cart/types.d.ts.map +1 -1
- package/dist/core/cart/types.js +0 -8
- package/dist/core/format.d.ts +81 -46
- package/dist/core/format.d.ts.map +1 -1
- package/dist/core/format.js +116 -94
- package/dist/core/generated/operation-types.d.ts +4486 -0
- package/dist/core/generated/operation-types.d.ts.map +1 -0
- package/dist/core/generated/operation-types.js +4 -0
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/operations/auth.d.ts +7 -0
- package/dist/core/operations/auth.d.ts.map +1 -1
- package/dist/core/operations/auth.js +68 -0
- package/dist/core/operations/cart.d.ts +30 -0
- package/dist/core/operations/cart.d.ts.map +1 -1
- package/dist/core/operations/cart.js +158 -0
- package/dist/react/components/Money.d.ts +22 -8
- package/dist/react/components/Money.d.ts.map +1 -1
- package/dist/react/components/Money.js +16 -9
- package/dist/react/hooks/use-cart.d.ts +78 -0
- package/dist/react/hooks/use-cart.d.ts.map +1 -0
- package/dist/react/hooks/use-cart.js +121 -0
- package/dist/react/hooks/use-format.d.ts +85 -0
- package/dist/react/hooks/use-format.d.ts.map +1 -0
- package/dist/react/hooks/use-format.js +141 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -0
- package/package.json +7 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience hooks that pull the active language from `<StorefrontProvider>`
|
|
3
|
+
* and forward it to the core format utilities. Use these inside the provider
|
|
4
|
+
* tree for boilerplate-free locale-aware formatting; outside the provider,
|
|
5
|
+
* fall back to the vanilla `formatPrice` / `formatDate` / etc. from
|
|
6
|
+
* `@doswiftly/storefront-sdk` with an explicit `locale` argument.
|
|
7
|
+
*
|
|
8
|
+
* Each hook returns a memoised function so it's safe to use directly in
|
|
9
|
+
* render. The function accepts an optional final `localeOverride` argument
|
|
10
|
+
* that wins over the store value — handy for per-call overrides (e.g. a
|
|
11
|
+
* "show in US format" toggle on one element while the rest of the UI stays
|
|
12
|
+
* in Polish).
|
|
13
|
+
*
|
|
14
|
+
* Resolution order per call:
|
|
15
|
+
* 1. `localeOverride` argument (highest)
|
|
16
|
+
* 2. `useLanguageStore().language` from `<StorefrontProvider>`
|
|
17
|
+
* 3. Runtime default (`Intl.NumberFormat().resolvedOptions().locale`)
|
|
18
|
+
*/
|
|
19
|
+
'use client';
|
|
20
|
+
import { useCallback } from 'react';
|
|
21
|
+
import { useLanguageStore } from '../stores/store-context';
|
|
22
|
+
import { formatPrice as coreFormatPrice, formatAmount as coreFormatAmount, formatPriceRange as coreFormatPriceRange, formatDate as coreFormatDate, formatDateTime as coreFormatDateTime, formatNumber as coreFormatNumber, getCurrencySymbol as coreGetCurrencySymbol, } from '../../core/format';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Locale resolution
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
let runtimeLocaleCache;
|
|
27
|
+
function getRuntimeLocale() {
|
|
28
|
+
if (runtimeLocaleCache === undefined) {
|
|
29
|
+
runtimeLocaleCache = new Intl.NumberFormat().resolvedOptions().locale;
|
|
30
|
+
}
|
|
31
|
+
return runtimeLocaleCache;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Read the active language from `useLanguageStore` and fall back to the
|
|
35
|
+
* runtime default when the store hasn't been initialised yet (e.g. before the
|
|
36
|
+
* first Shop query has resolved). Internal helper for every convenience hook
|
|
37
|
+
* in this file — the selector-based subscription means consumers only
|
|
38
|
+
* re-render when the language actually changes.
|
|
39
|
+
*/
|
|
40
|
+
function useResolvedLocale() {
|
|
41
|
+
const language = useLanguageStore((s) => s.language);
|
|
42
|
+
return language ?? getRuntimeLocale();
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Price formatters
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Memoised `formatPrice` bound to the active language from `<StorefrontProvider>`.
|
|
49
|
+
* Pass `localeOverride` as the second argument to override the store value for
|
|
50
|
+
* a single call.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const formatPrice = useFormatPrice();
|
|
54
|
+
* return <span>{formatPrice(item.price)}</span>;
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Per-call override:
|
|
58
|
+
* const formatPrice = useFormatPrice();
|
|
59
|
+
* <span>{formatPrice(item.price, 'en-US')}</span>
|
|
60
|
+
*/
|
|
61
|
+
export function useFormatPrice() {
|
|
62
|
+
const locale = useResolvedLocale();
|
|
63
|
+
return useCallback((price, localeOverride) => coreFormatPrice(price, localeOverride ?? locale), [locale]);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Memoised `formatAmount` bound to the active language from `<StorefrontProvider>`.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const formatAmount = useFormatAmount();
|
|
70
|
+
* return <span>{formatAmount(item.totalPrice.amount, item.totalPrice.currencyCode)}</span>;
|
|
71
|
+
*/
|
|
72
|
+
export function useFormatAmount() {
|
|
73
|
+
const locale = useResolvedLocale();
|
|
74
|
+
return useCallback((amount, currencyCode, localeOverride) => coreFormatAmount(amount, currencyCode, localeOverride ?? locale), [locale]);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Memoised `formatPriceRange` bound to the active language from `<StorefrontProvider>`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const formatPriceRange = useFormatPriceRange();
|
|
81
|
+
* return <span>{formatPriceRange(min, max)}</span>;
|
|
82
|
+
*/
|
|
83
|
+
export function useFormatPriceRange() {
|
|
84
|
+
const locale = useResolvedLocale();
|
|
85
|
+
return useCallback((minPrice, maxPrice, localeOverride) => coreFormatPriceRange(minPrice, maxPrice, localeOverride ?? locale), [locale]);
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Date formatters
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* Memoised `formatDate` bound to the active language from `<StorefrontProvider>`.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const formatDate = useFormatDate();
|
|
95
|
+
* return <span>{formatDate(order.processedAt)}</span>;
|
|
96
|
+
*/
|
|
97
|
+
export function useFormatDate() {
|
|
98
|
+
const locale = useResolvedLocale();
|
|
99
|
+
return useCallback((date, localeOverride) => coreFormatDate(date, localeOverride ?? locale), [locale]);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Memoised `formatDateTime` bound to the active language from `<StorefrontProvider>`.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const formatDateTime = useFormatDateTime();
|
|
106
|
+
* return <span>{formatDateTime(event.timestamp)}</span>;
|
|
107
|
+
*/
|
|
108
|
+
export function useFormatDateTime() {
|
|
109
|
+
const locale = useResolvedLocale();
|
|
110
|
+
return useCallback((date, localeOverride) => coreFormatDateTime(date, localeOverride ?? locale), [locale]);
|
|
111
|
+
}
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Number formatters
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
/**
|
|
116
|
+
* Memoised `formatNumber` bound to the active language from `<StorefrontProvider>`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const formatNumber = useFormatNumber();
|
|
120
|
+
* return <span>{formatNumber(points.balance)}</span>;
|
|
121
|
+
*/
|
|
122
|
+
export function useFormatNumber() {
|
|
123
|
+
const locale = useResolvedLocale();
|
|
124
|
+
return useCallback((num, localeOverride) => coreFormatNumber(num, localeOverride ?? locale), [locale]);
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// Currency symbol
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
/**
|
|
130
|
+
* Memoised `getCurrencySymbol` bound to the active language from
|
|
131
|
+
* `<StorefrontProvider>`. The returned symbol is locale-dependent — see
|
|
132
|
+
* `getCurrencySymbol` in core for examples.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const getCurrencySymbol = useGetCurrencySymbol();
|
|
136
|
+
* return <span>{getCurrencySymbol(shop.currencyCode)}</span>;
|
|
137
|
+
*/
|
|
138
|
+
export function useGetCurrencySymbol() {
|
|
139
|
+
const locale = useResolvedLocale();
|
|
140
|
+
return useCallback((code, localeOverride) => coreGetCurrencySymbol(code, localeOverride ?? locale), [locale]);
|
|
141
|
+
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { useLogin, type UseLoginOptions, type UseLoginReturn } from './hooks/use
|
|
|
20
20
|
export { useLogout, type UseLogoutOptions, type UseLogoutReturn } from './hooks/use-logout';
|
|
21
21
|
export { useRefreshToken, type UseRefreshTokenOptions, type UseRefreshTokenReturn } from './hooks/use-refresh-token';
|
|
22
22
|
export { useCartManager, type CartManagerOperation, type CartManagerStatus, type UseCartManagerResult } from './hooks/use-cart-manager';
|
|
23
|
+
export { useCart, type UseCartOptions, type UseCartResult, type ServerCartOperation } from './hooks/use-cart';
|
|
23
24
|
export { useStorefrontClient } from './hooks/use-storefront-client';
|
|
24
25
|
export { useCurrency } from './hooks/use-currency';
|
|
25
26
|
export { useAuthStore, useAuthStoreApi, useAuthHydrated } from './stores/store-context';
|
|
@@ -35,6 +36,7 @@ export { getCookie, setCookie, deleteCookie, getCurrencyFromCookieAsync, getCart
|
|
|
35
36
|
export { useBotProtection } from './hooks/use-bot-protection';
|
|
36
37
|
export { useHydrated } from './hooks/use-hydrated';
|
|
37
38
|
export { useDebouncedValue } from './hooks/use-debounced-value';
|
|
39
|
+
export { useFormatPrice, useFormatAmount, useFormatPriceRange, useFormatDate, useFormatDateTime, useFormatNumber, useGetCurrencySymbol, } from './hooks/use-format';
|
|
38
40
|
export { createCartStore, selectCartId, selectIsCartOpen, selectCartIsLoading, } from './stores/cart.store';
|
|
39
41
|
export type { CartState, CartStoreConfig, CartActions, CartData, CartMutationAction, CartLineInput, CartLineUpdateInput, } from './stores/cart.store';
|
|
40
42
|
export { CartProvider, useCartStore, useCartStoreApi } from './stores/cart.context';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,KAAK,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG7F,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9H,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,SAAS,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,GAC7B,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,SAAS,EACT,eAAe,EACf,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EACL,KAAK,EACL,KAAK,UAAU,EACf,KAAK,EACL,KAAK,mBAAmB,EACxB,SAAS,EACT,KAAK,cAAc,EACnB,eAAe,EACf,KAAK,oBAAoB,EACzB,YAAY,EACZ,KAAK,iBAAiB,EACtB,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { useLogin } from './hooks/use-login';
|
|
|
22
22
|
export { useLogout } from './hooks/use-logout';
|
|
23
23
|
export { useRefreshToken } from './hooks/use-refresh-token';
|
|
24
24
|
export { useCartManager } from './hooks/use-cart-manager';
|
|
25
|
+
export { useCart } from './hooks/use-cart';
|
|
25
26
|
export { useStorefrontClient } from './hooks/use-storefront-client';
|
|
26
27
|
export { useCurrency } from './hooks/use-currency';
|
|
27
28
|
// Store hooks (Context-based)
|
|
@@ -38,6 +39,8 @@ export { useBotProtection } from './hooks/use-bot-protection';
|
|
|
38
39
|
// Generic hooks
|
|
39
40
|
export { useHydrated } from './hooks/use-hydrated';
|
|
40
41
|
export { useDebouncedValue } from './hooks/use-debounced-value';
|
|
42
|
+
// Format hooks (Context-driven — pull locale from `useLanguageStore`)
|
|
43
|
+
export { useFormatPrice, useFormatAmount, useFormatPriceRange, useFormatDate, useFormatDateTime, useFormatNumber, useGetCurrencySymbol, } from './hooks/use-format';
|
|
41
44
|
// Cart store (DI-based)
|
|
42
45
|
export { createCartStore, selectCartId, selectIsCartOpen, selectCartIsLoading, } from './stores/cart.store';
|
|
43
46
|
export { CartProvider, useCartStore, useCartStoreApi } from './stores/cart.context';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doswiftly/storefront-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Storefront runtime SDK for DoSwiftly Commerce — layered transport, middleware pipeline, React providers, Zustand stores, cache strategies. 0 runtime dependencies in core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,16 +41,21 @@
|
|
|
41
41
|
"author": "DoSwiftly Team",
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@graphql-codegen/cli": "^5.0.0",
|
|
45
|
+
"@graphql-codegen/typescript": "^4.0.0",
|
|
46
|
+
"@graphql-codegen/typescript-operations": "^4.0.0",
|
|
44
47
|
"@testing-library/react": "^16.1.0",
|
|
45
48
|
"@types/node": "^22.10.2",
|
|
46
49
|
"@types/react": "^18.3.0 || ^19.0.0",
|
|
47
50
|
"@types/react-dom": "^19.0.0",
|
|
48
51
|
"@vitest/coverage-v8": "^4.1.0",
|
|
49
52
|
"fast-check": "^3.23.2",
|
|
53
|
+
"graphql": "^16.13.2",
|
|
50
54
|
"jsdom": "^25.0.1",
|
|
51
55
|
"next": "^16.2.3",
|
|
52
56
|
"react": "^19.0.0",
|
|
53
57
|
"react-dom": "^19.0.0",
|
|
58
|
+
"tsx": "^4.0.0",
|
|
54
59
|
"typescript": "^5.7.2",
|
|
55
60
|
"vitest": "^4.1.0",
|
|
56
61
|
"zustand": "^5.0.2"
|
|
@@ -70,6 +75,7 @@
|
|
|
70
75
|
"scripts": {
|
|
71
76
|
"build": "tsc",
|
|
72
77
|
"build:only": "tsc",
|
|
78
|
+
"codegen": "tsx scripts/codegen.mts",
|
|
73
79
|
"dev": "tsc --watch",
|
|
74
80
|
"clean": "rm -rf dist",
|
|
75
81
|
"test": "vitest run",
|