@spree/next 0.3.1 → 0.5.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.
@@ -2,14 +2,19 @@ import { StoreCountry } from '@spree/sdk';
2
2
  import { SpreeNextOptions } from '../types.js';
3
3
 
4
4
  /**
5
- * List all available countries.
5
+ * List countries available in the store.
6
+ * Each country includes currency and default_locale derived from its market.
6
7
  */
7
8
  declare function listCountries(options?: SpreeNextOptions): Promise<{
8
9
  data: StoreCountry[];
9
10
  }>;
10
11
  /**
11
- * Get a single country by ISO code.
12
+ * Get a country by ISO code.
13
+ * @param iso - ISO 3166-1 alpha-2 code (e.g., "US", "DE")
14
+ * @param params - Optional params (e.g., { include: 'states' } for address forms)
12
15
  */
13
- declare function getCountry(iso: string, options?: SpreeNextOptions): Promise<StoreCountry>;
16
+ declare function getCountry(iso: string, params?: {
17
+ include?: string;
18
+ }, options?: SpreeNextOptions): Promise<StoreCountry>;
14
19
 
15
20
  export { getCountry, listCountries };
@@ -30,8 +30,8 @@ async function listCountries(options) {
30
30
  currency: options?.currency
31
31
  });
32
32
  }
33
- async function getCountry(iso, options) {
34
- return getClient().store.countries.get(iso, {
33
+ async function getCountry(iso, params, options) {
34
+ return getClient().store.countries.get(iso, params, {
35
35
  locale: options?.locale,
36
36
  currency: options?.currency
37
37
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config.ts","../../src/data/countries.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,gBAAgB,MAAA,CAAO;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,cAAA,GAAiB,QAAQ,GAAA,CAAI,qBAAA;AACnC,IAAA,IAAI,WAAW,cAAA,EAAgB;AAC7B,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,cAAA,EAAgB,CAAA;AAAA,IAC3C,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,cACpB,OAAA,EACmC;AACnC,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,SAAA,CAAU,IAAA,CAAK;AAAA,IACtC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,UAAA,CACpB,KACA,OAAA,EACuB;AACvB,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,SAAA,CAAU,IAAI,GAAA,EAAK;AAAA,IAC1C,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"countries.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_PUBLISHABLE_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n publishableKey: config.publishableKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;\n if (baseUrl && publishableKey) {\n initSpreeNext({ baseUrl, publishableKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreCountry } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List all available countries.\n */\nexport async function listCountries(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCountry[] }> {\n return getClient().store.countries.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single country by ISO code.\n */\nexport async function getCountry(\n iso: string,\n options?: SpreeNextOptions\n): Promise<StoreCountry> {\n return getClient().store.countries.get(iso, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}
1
+ {"version":3,"sources":["../../src/config.ts","../../src/data/countries.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,gBAAgB,MAAA,CAAO;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,cAAA,GAAiB,QAAQ,GAAA,CAAI,qBAAA;AACnC,IAAA,IAAI,WAAW,cAAA,EAAgB;AAC7B,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,cAAA,EAAgB,CAAA;AAAA,IAC3C,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC5BA,eAAsB,cACpB,OAAA,EACmC;AACnC,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,SAAA,CAAU,IAAA,CAAK;AAAA,IACtC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAOA,eAAsB,UAAA,CACpB,GAAA,EACA,MAAA,EACA,OAAA,EACuB;AACvB,EAAA,OAAO,WAAU,CAAE,KAAA,CAAM,SAAA,CAAU,GAAA,CAAI,KAAK,MAAA,EAAQ;AAAA,IAClD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"countries.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_PUBLISHABLE_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n publishableKey: config.publishableKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;\n if (baseUrl && publishableKey) {\n initSpreeNext({ baseUrl, publishableKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreCountry } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List countries available in the store.\n * Each country includes currency and default_locale derived from its market.\n */\nexport async function listCountries(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCountry[] }> {\n return getClient().store.countries.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a country by ISO code.\n * @param iso - ISO 3166-1 alpha-2 code (e.g., \"US\", \"DE\")\n * @param params - Optional params (e.g., { include: 'states' } for address forms)\n */\nexport async function getCountry(\n iso: string,\n params?: { include?: string },\n options?: SpreeNextOptions\n): Promise<StoreCountry> {\n return getClient().store.countries.get(iso, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { StoreCurrency } from '@spree/sdk';
2
+ import { SpreeNextOptions } from '../types.js';
3
+
4
+ /**
5
+ * List currencies supported by the store (derived from markets).
6
+ */
7
+ declare function listCurrencies(options?: SpreeNextOptions): Promise<{
8
+ data: StoreCurrency[];
9
+ }>;
10
+
11
+ export { listCurrencies };
@@ -0,0 +1,36 @@
1
+ import { createSpreeClient } from '@spree/sdk';
2
+
3
+ // src/config.ts
4
+ var _client = null;
5
+ function initSpreeNext(config) {
6
+ _client = createSpreeClient({
7
+ baseUrl: config.baseUrl,
8
+ publishableKey: config.publishableKey
9
+ });
10
+ }
11
+ function getClient() {
12
+ if (!_client) {
13
+ const baseUrl = process.env.SPREE_API_URL;
14
+ const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;
15
+ if (baseUrl && publishableKey) {
16
+ initSpreeNext({ baseUrl, publishableKey });
17
+ } else {
18
+ throw new Error(
19
+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables."
20
+ );
21
+ }
22
+ }
23
+ return _client;
24
+ }
25
+
26
+ // src/data/currencies.ts
27
+ async function listCurrencies(options) {
28
+ return getClient().store.currencies.list({
29
+ locale: options?.locale,
30
+ currency: options?.currency
31
+ });
32
+ }
33
+
34
+ export { listCurrencies };
35
+ //# sourceMappingURL=currencies.js.map
36
+ //# sourceMappingURL=currencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config.ts","../../src/data/currencies.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,gBAAgB,MAAA,CAAO;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,cAAA,GAAiB,QAAQ,GAAA,CAAI,qBAAA;AACnC,IAAA,IAAI,WAAW,cAAA,EAAgB;AAC7B,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,cAAA,EAAgB,CAAA;AAAA,IAC3C,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,eACpB,OAAA,EACoC;AACpC,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,UAAA,CAAW,IAAA,CAAK;AAAA,IACvC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"currencies.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_PUBLISHABLE_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n publishableKey: config.publishableKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;\n if (baseUrl && publishableKey) {\n initSpreeNext({ baseUrl, publishableKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreCurrency } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List currencies supported by the store (derived from markets).\n */\nexport async function listCurrencies(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCurrency[] }> {\n return getClient().store.currencies.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { StoreLocale } from '@spree/sdk';
2
+ import { SpreeNextOptions } from '../types.js';
3
+
4
+ /**
5
+ * List locales supported by the store (derived from markets).
6
+ */
7
+ declare function listLocales(options?: SpreeNextOptions): Promise<{
8
+ data: StoreLocale[];
9
+ }>;
10
+
11
+ export { listLocales };
@@ -0,0 +1,36 @@
1
+ import { createSpreeClient } from '@spree/sdk';
2
+
3
+ // src/config.ts
4
+ var _client = null;
5
+ function initSpreeNext(config) {
6
+ _client = createSpreeClient({
7
+ baseUrl: config.baseUrl,
8
+ publishableKey: config.publishableKey
9
+ });
10
+ }
11
+ function getClient() {
12
+ if (!_client) {
13
+ const baseUrl = process.env.SPREE_API_URL;
14
+ const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;
15
+ if (baseUrl && publishableKey) {
16
+ initSpreeNext({ baseUrl, publishableKey });
17
+ } else {
18
+ throw new Error(
19
+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables."
20
+ );
21
+ }
22
+ }
23
+ return _client;
24
+ }
25
+
26
+ // src/data/locales.ts
27
+ async function listLocales(options) {
28
+ return getClient().store.locales.list({
29
+ locale: options?.locale,
30
+ currency: options?.currency
31
+ });
32
+ }
33
+
34
+ export { listLocales };
35
+ //# sourceMappingURL=locales.js.map
36
+ //# sourceMappingURL=locales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config.ts","../../src/data/locales.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAQ3B,SAAS,cAAc,MAAA,EAA+B;AAE3D,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,gBAAgB,MAAA,CAAO;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,cAAA,GAAiB,QAAQ,GAAA,CAAI,qBAAA;AACnC,IAAA,IAAI,WAAW,cAAA,EAAgB;AAC7B,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,cAAA,EAAgB,CAAA;AAAA,IAC3C,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,YACpB,OAAA,EACkC;AAClC,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK;AAAA,IACpC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"locales.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_PUBLISHABLE_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n publishableKey: config.publishableKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;\n if (baseUrl && publishableKey) {\n initSpreeNext({ baseUrl, publishableKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreLocale } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List locales supported by the store (derived from markets).\n */\nexport async function listLocales(\n options?: SpreeNextOptions\n): Promise<{ data: StoreLocale[] }> {\n return getClient().store.locales.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -5,8 +5,10 @@ export { getTaxon, listTaxonProducts, listTaxons } from './data/taxons.js';
5
5
  export { getTaxonomy, listTaxonomies } from './data/taxonomies.js';
6
6
  export { getStore } from './data/store.js';
7
7
  export { getCountry, listCountries } from './data/countries.js';
8
+ export { listCurrencies } from './data/currencies.js';
9
+ export { listLocales } from './data/locales.js';
8
10
  import { StoreOrder, StoreShipment, AddressParams, StoreCustomer, StoreAddress, PaginatedResponse, StoreCreditCard, StoreGiftCard, CompletePaymentSessionParams, StorePaymentSession, CreatePaymentSessionParams, UpdatePaymentSessionParams, CompletePaymentSetupSessionParams, StorePaymentSetupSession, CreatePaymentSetupSessionParams } from '@spree/sdk';
9
- export { AddressParams, CompletePaymentSessionParams, CompletePaymentSetupSessionParams, CreatePaymentSessionParams, CreatePaymentSetupSessionParams, PaginatedResponse, ProductFiltersResponse, SpreeError, StoreAddress, StoreCountry, StoreCreditCard, StoreCustomer, StoreDigitalLink, StoreGiftCard, StoreImage, StoreLineItem, StoreOptionType, StoreOptionValue, StoreOrder, StoreOrderPromotion, StorePayment, StorePaymentMethod, StorePaymentSession, StorePaymentSetupSession, StorePrice, StoreProduct, StoreShipment, StoreShippingRate, StoreStore, StoreTaxon, StoreTaxonomy, StoreVariant, UpdatePaymentSessionParams } from '@spree/sdk';
11
+ export { AddressParams, CompletePaymentSessionParams, CompletePaymentSetupSessionParams, CreatePaymentSessionParams, CreatePaymentSetupSessionParams, PaginatedResponse, ProductFiltersResponse, SpreeError, StoreAddress, StoreCountry, StoreCreditCard, StoreCurrency, StoreCustomer, StoreDigitalLink, StoreGiftCard, StoreImage, StoreLineItem, StoreLocale, StoreOptionType, StoreOptionValue, StoreOrder, StoreOrderPromotion, StorePayment, StorePaymentMethod, StorePaymentSession, StorePaymentSetupSession, StorePrice, StoreProduct, StoreShipment, StoreShippingRate, StoreStore, StoreTaxon, StoreTaxonomy, StoreVariant, UpdatePaymentSessionParams } from '@spree/sdk';
10
12
 
11
13
  /**
12
14
  * Get the current cart. Returns null if no cart exists.
package/dist/index.js CHANGED
@@ -102,8 +102,24 @@ async function listCountries(options) {
102
102
  currency: options?.currency
103
103
  });
104
104
  }
105
- async function getCountry(iso, options) {
106
- return getClient().store.countries.get(iso, {
105
+ async function getCountry(iso, params, options) {
106
+ return getClient().store.countries.get(iso, params, {
107
+ locale: options?.locale,
108
+ currency: options?.currency
109
+ });
110
+ }
111
+
112
+ // src/data/currencies.ts
113
+ async function listCurrencies(options) {
114
+ return getClient().store.currencies.list({
115
+ locale: options?.locale,
116
+ currency: options?.currency
117
+ });
118
+ }
119
+
120
+ // src/data/locales.ts
121
+ async function listLocales(options) {
122
+ return getClient().store.locales.list({
107
123
  locale: options?.locale,
108
124
  currency: options?.currency
109
125
  });
@@ -549,6 +565,6 @@ async function completePaymentSetupSession(id, params) {
549
565
  });
550
566
  }
551
567
 
552
- export { addItem, advance, applyCoupon, associateCart, clearCart, complete, completePaymentSession, completePaymentSetupSession, createAddress, createPaymentSession, createPaymentSetupSession, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getClient, getCountry, getCustomer, getGiftCard, getOrCreateCart, getOrder, getPaymentSession, getPaymentSetupSession, getProduct, getProductFilters, getShipments, getStore, getTaxon, getTaxonomy, initSpreeNext, listAddresses, listCountries, listCreditCards, listGiftCards, listOrders, listProducts, listTaxonProducts, listTaxonomies, listTaxons, login, logout, next, register, removeCoupon, removeItem, selectShippingRate, updateAddress, updateAddresses, updateCustomer, updateItem, updatePaymentSession };
568
+ export { addItem, advance, applyCoupon, associateCart, clearCart, complete, completePaymentSession, completePaymentSetupSession, createAddress, createPaymentSession, createPaymentSetupSession, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getClient, getCountry, getCustomer, getGiftCard, getOrCreateCart, getOrder, getPaymentSession, getPaymentSetupSession, getProduct, getProductFilters, getShipments, getStore, getTaxon, getTaxonomy, initSpreeNext, listAddresses, listCountries, listCreditCards, listCurrencies, listGiftCards, listLocales, listOrders, listProducts, listTaxonProducts, listTaxonomies, listTaxons, login, logout, next, register, removeCoupon, removeItem, selectShippingRate, updateAddress, updateAddresses, updateCustomer, updateItem, updatePaymentSession };
553
569
  //# sourceMappingURL=index.js.map
554
570
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/data/products.ts","../src/data/taxons.ts","../src/data/taxonomies.ts","../src/data/store.ts","../src/data/countries.ts","../src/cookies.ts","../src/actions/cart.ts","../src/actions/checkout.ts","../src/auth-helpers.ts","../src/actions/auth.ts","../src/actions/addresses.ts","../src/actions/orders.ts","../src/actions/credit-cards.ts","../src/actions/gift-cards.ts","../src/actions/payment-sessions.ts","../src/actions/payment-setup-sessions.ts"],"names":["revalidateTag","getCheckoutOptions"],"mappings":";;;;;AAGA,IAAI,OAAA,GAA8B,IAAA;AAClC,IAAI,OAAA,GAAkC,IAAA;AAO/B,SAAS,cAAc,MAAA,EAA+B;AAC3D,EAAA,OAAA,GAAU,MAAA;AACV,EAAA,OAAA,GAAU,iBAAA,CAAkB;AAAA,IAC1B,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,gBAAgB,MAAA,CAAO;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,cAAA,GAAiB,QAAQ,GAAA,CAAI,qBAAA;AACnC,IAAA,IAAI,WAAW,cAAA,EAAgB;AAC7B,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,cAAA,EAAgB,CAAA;AAAA,IAC3C,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAA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AO,eAAA,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,WAAU,CAAE,KAAA,CAAM,SAAS,oBAAA,CAAqB,MAAA,CAAO,QAAQ,OAAO,CAAA;AAAA,EAC/E,CAAC,CAAA;AACH;AAKA,eAAsB,uBACpB,EAAA,EACmC;AACnC,EAAA,OAAO,eAAA,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,WAAU,CAAE,KAAA,CAAM,SAAS,oBAAA,CAAqB,GAAA,CAAI,IAAI,OAAO,CAAA;AAAA,EACxE,CAAC,CAAA;AACH;AAMA,eAAsB,2BAAA,CACpB,IACA,MAAA,EACmC;AACnC,EAAA,OAAO,eAAA,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,SAAA,GAAY,KAAA,CAAM,QAAA,CAAS,qBAAqB,QAAA,CAAS,EAAA,EAAI,QAAQ,OAAO,CAAA;AAAA,EACrF,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_PUBLISHABLE_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n publishableKey: config.publishableKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;\n if (baseUrl && publishableKey) {\n initSpreeNext({ baseUrl, publishableKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreProduct, PaginatedResponse, ProductFiltersResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List products with optional filtering, sorting, and pagination.\n */\nexport async function listProducts(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().store.products.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single product by slug or ID.\n */\nexport async function getProduct(\n slugOrId: string,\n params?: { includes?: string },\n options?: SpreeNextOptions\n): Promise<StoreProduct> {\n return getClient().store.products.get(slugOrId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get available product filters (price ranges, option values, etc.).\n */\nexport async function getProductFilters(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<ProductFiltersResponse> {\n return getClient().store.products.filters(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreTaxon, StoreProduct, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxons (categories) with optional filtering and pagination.\n */\nexport async function listTaxons(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxon>> {\n return getClient().store.taxons.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxon by ID or permalink.\n */\nexport async function getTaxon(\n idOrPermalink: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxon> {\n return getClient().store.taxons.get(idOrPermalink, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * List products within a taxon.\n */\nexport async function listTaxonProducts(\n taxonId: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().store.taxons.products.list(taxonId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreTaxonomy, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxonomies with optional filtering and pagination.\n */\nexport async function listTaxonomies(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxonomy>> {\n return getClient().store.taxonomies.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxonomy by ID.\n */\nexport async function getTaxonomy(\n id: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxonomy> {\n return getClient().store.taxonomies.get(id, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreStore } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * Get the current store configuration.\n */\nexport async function getStore(options?: SpreeNextOptions): Promise<StoreStore> {\n return getClient().store.store.get({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreCountry } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List all available countries.\n */\nexport async function listCountries(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCountry[] }> {\n return getClient().store.countries.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single country by ISO code.\n */\nexport async function getCountry(\n iso: string,\n options?: SpreeNextOptions\n): Promise<StoreCountry> {\n return getClient().store.countries.get(iso, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, setCartToken, clearCartToken, getAccessToken } from '../cookies';\n\n/**\n * Get the current cart. Returns null if no cart exists.\n */\nexport async function getCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) return null;\n\n try {\n return await getClient().store.cart.get({ orderToken, token });\n } catch {\n // Cart not found (e.g., order was completed) — clear stale token\n if (orderToken) {\n await clearCartToken();\n }\n return null;\n }\n}\n\n/**\n * Get existing cart or create a new one.\n */\nexport async function getOrCreateCart(): Promise<StoreOrder & { token: string }> {\n const existing = await getCart();\n if (existing) return existing;\n\n const token = await getAccessToken();\n const cart = await getClient().store.cart.create(token ? { token } : undefined);\n\n if (cart.token) {\n await setCartToken(cart.token);\n }\n\n revalidateTag('cart');\n return cart;\n}\n\n/**\n * Add an item to the cart. Creates a cart if none exists.\n * Returns the updated order with recalculated totals.\n */\nexport async function addItem(\n variantId: string,\n quantity: number = 1\n): Promise<StoreOrder> {\n const cart = await getOrCreateCart();\n const orderToken = cart.token;\n const token = await getAccessToken();\n\n const order = await getClient().store.orders.lineItems.create(\n cart.id,\n { variant_id: variantId, quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return order;\n}\n\n/**\n * Update a line item quantity in the cart.\n * Returns the updated order with recalculated totals.\n */\nexport async function updateItem(\n lineItemId: string,\n quantity: number\n): Promise<StoreOrder> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().store.cart.get({ orderToken, token });\n\n const order = await getClient().store.orders.lineItems.update(\n cart.id,\n lineItemId,\n { quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return order;\n}\n\n/**\n * Remove a line item from the cart.\n * Returns the updated order with recalculated totals.\n */\nexport async function removeItem(lineItemId: string): Promise<StoreOrder> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().store.cart.get({ orderToken, token });\n\n const order = await getClient().store.orders.lineItems.delete(cart.id, lineItemId, {\n orderToken,\n token,\n });\n\n revalidateTag('cart');\n return order;\n}\n\n/**\n * Clear the cart (abandons the current cart).\n */\nexport async function clearCart(): Promise<void> {\n await clearCartToken();\n revalidateTag('cart');\n}\n\n/**\n * Associate a guest cart with the currently authenticated user.\n * Call this after login/register when the user has an existing guest cart.\n */\nexport async function associateCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken || !token) return null;\n\n try {\n const result = await getClient().store.cart.associate({ orderToken, token });\n revalidateTag('cart');\n return result;\n } catch {\n // Cart might already belong to another user — clear it\n await clearCartToken();\n revalidateTag('cart');\n return null;\n }\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder, StoreShipment, AddressParams } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, getAccessToken } from '../cookies';\n\nasync function getCheckoutOptions() {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n return { orderToken, token };\n}\n\n/**\n * Get the current checkout order state.\n * Includes line_items, shipments, and addresses by default.\n */\nexport async function getCheckout(\n orderId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n return getClient().store.orders.get(\n orderId,\n { includes: 'line_items,shipments,ship_address,bill_address' },\n options\n );\n}\n\n/**\n * Update shipping and/or billing addresses on the order.\n */\nexport async function updateAddresses(\n orderId: string,\n params: {\n email?: string;\n ship_address?: AddressParams;\n bill_address?: AddressParams;\n ship_address_id?: string;\n bill_address_id?: string;\n }\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.update(orderId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Advance the checkout to the next step.\n */\nexport async function advance(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.advance(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Move the checkout to the next step (alias for advance).\n */\nexport async function next(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.next(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Get shipments for the order (includes available shipping rates).\n */\nexport async function getShipments(\n orderId: string\n): Promise<{ data: StoreShipment[] }> {\n const options = await getCheckoutOptions();\n return getClient().store.orders.shipments.list(orderId, options);\n}\n\n/**\n * Select a shipping rate for a shipment.\n * Returns the updated order with recalculated totals.\n */\nexport async function selectShippingRate(\n orderId: string,\n shipmentId: string,\n shippingRateId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.shipments.update(\n orderId,\n shipmentId,\n { selected_shipping_rate_id: shippingRateId },\n options\n );\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Apply a coupon code to the order.\n */\nexport async function applyCoupon(\n orderId: string,\n code: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.couponCodes.apply(orderId, code, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Remove a coupon/promotion from the order.\n */\nexport async function removeCoupon(\n orderId: string,\n promotionId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.couponCodes.remove(orderId, promotionId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Complete the checkout and place the order.\n */\nexport async function complete(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.complete(orderId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n","import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().store.auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().store.auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreCustomer } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { setAccessToken, clearAccessToken, getAccessToken, getCartToken } from '../cookies';\nimport { withAuthRefresh } from '../auth-helpers';\n\n/**\n * Login with email and password.\n * Automatically associates any guest cart with the authenticated user.\n */\nexport async function login(\n email: string,\n password: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().store.auth.login({ email, password });\n await setAccessToken(result.token);\n\n // Associate guest cart if one exists\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().store.cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Cart association failure is non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Invalid email or password',\n };\n }\n}\n\n/**\n * Register a new customer account.\n * Automatically associates any guest cart with the new account.\n */\nexport async function register(\n email: string,\n password: string,\n passwordConfirmation: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().store.auth.register({\n email,\n password,\n password_confirmation: passwordConfirmation,\n });\n await setAccessToken(result.token);\n\n // Associate guest cart\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().store.cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Registration failed',\n };\n }\n}\n\n/**\n * Logout the current user.\n */\nexport async function logout(): Promise<void> {\n await clearAccessToken();\n revalidateTag('customer');\n revalidateTag('cart');\n revalidateTag('addresses');\n revalidateTag('credit-cards');\n}\n\n/**\n * Get the currently authenticated customer. Returns null if not logged in.\n */\nexport async function getCustomer(): Promise<StoreCustomer | null> {\n const token = await getAccessToken();\n if (!token) return null;\n\n try {\n return await withAuthRefresh(async (options) => {\n return getClient().store.customer.get(options);\n });\n } catch {\n await clearAccessToken();\n return null;\n }\n}\n\n/**\n * Update the current customer's profile.\n */\nexport async function updateCustomer(\n data: { first_name?: string; last_name?: string; email?: string }\n): Promise<StoreCustomer> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().store.customer.update(data, options);\n });\n revalidateTag('customer');\n return result;\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreAddress, AddressParams } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's addresses.\n */\nexport async function listAddresses(): Promise<{ data: StoreAddress[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.list(undefined, options);\n });\n}\n\n/**\n * Get a single address by ID.\n */\nexport async function getAddress(id: string): Promise<StoreAddress> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.get(id, options);\n });\n}\n\n/**\n * Create a new address for the customer.\n */\nexport async function createAddress(params: AddressParams): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.create(params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Update an existing address.\n */\nexport async function updateAddress(\n id: string,\n params: Partial<AddressParams>\n): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.update(id, params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Delete an address.\n */\nexport async function deleteAddress(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.delete(id, options);\n });\n revalidateTag('addresses');\n}\n","'use server';\n\nimport type { StoreOrder, PaginatedResponse } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's orders.\n */\nexport async function listOrders(\n params?: Record<string, unknown>\n): Promise<PaginatedResponse<StoreOrder>> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.orders.list(params, options);\n });\n}\n\n/**\n * Get a single order by ID or number.\n */\nexport async function getOrder(\n idOrNumber: string,\n params?: Record<string, unknown>\n): Promise<StoreOrder> {\n return withAuthRefresh(async (options) => {\n return getClient().store.orders.get(idOrNumber, params, options);\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreCreditCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's credit cards.\n */\nexport async function listCreditCards(): Promise<{ data: StoreCreditCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.creditCards.list(undefined, options);\n });\n}\n\n/**\n * Delete a credit card.\n */\nexport async function deleteCreditCard(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().store.customer.creditCards.delete(id, options);\n });\n revalidateTag('credit-cards');\n}\n","'use server';\n\nimport type { StoreGiftCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's gift cards.\n */\nexport async function listGiftCards(): Promise<{ data: StoreGiftCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.giftCards.list(undefined, options);\n });\n}\n\n/**\n * Get a single gift card by ID.\n */\nexport async function getGiftCard(id: string): Promise<StoreGiftCard> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.giftCards.get(id, options);\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type {\n StorePaymentSession,\n CreatePaymentSessionParams,\n UpdatePaymentSessionParams,\n CompletePaymentSessionParams,\n} from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, getAccessToken } from '../cookies';\n\nasync function getCheckoutOptions() {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n return { orderToken, token };\n}\n\n/**\n * Create a payment session for an order.\n * Delegates to the payment gateway to initialize a provider-specific session.\n */\nexport async function createPaymentSession(\n orderId: string,\n params: CreatePaymentSessionParams\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.paymentSessions.create(orderId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Get a payment session by ID.\n */\nexport async function getPaymentSession(\n orderId: string,\n sessionId: string\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n return getClient().store.orders.paymentSessions.get(orderId, sessionId, options);\n}\n\n/**\n * Update a payment session.\n * Delegates to the payment gateway to sync changes with the provider.\n */\nexport async function updatePaymentSession(\n orderId: string,\n sessionId: string,\n params: UpdatePaymentSessionParams\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.paymentSessions.update(orderId, sessionId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Complete a payment session.\n * Confirms the payment with the provider, triggering capture/authorization.\n */\nexport async function completePaymentSession(\n orderId: string,\n sessionId: string,\n params?: CompletePaymentSessionParams\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.paymentSessions.complete(orderId, sessionId, params, options);\n revalidateTag('checkout');\n return result;\n}\n","'use server';\n\nimport type {\n StorePaymentSetupSession,\n CreatePaymentSetupSessionParams,\n CompletePaymentSetupSessionParams,\n} from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * Create a payment setup session for saving a payment method.\n * Delegates to the payment gateway to initialize a setup flow.\n */\nexport async function createPaymentSetupSession(\n params: CreatePaymentSetupSessionParams\n): Promise<StorePaymentSetupSession> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.paymentSetupSessions.create(params, options);\n });\n}\n\n/**\n * Get a payment setup session by ID.\n */\nexport async function getPaymentSetupSession(\n id: string\n): Promise<StorePaymentSetupSession> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.paymentSetupSessions.get(id, options);\n });\n}\n\n/**\n * Complete a payment setup session.\n * Confirms the setup with the provider, resulting in a saved payment method.\n */\nexport async function completePaymentSetupSession(\n id: string,\n params?: CompletePaymentSetupSessionParams\n): Promise<StorePaymentSetupSession> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.paymentSetupSessions.complete(id, params, options);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/config.ts","../src/data/products.ts","../src/data/taxons.ts","../src/data/taxonomies.ts","../src/data/store.ts","../src/data/countries.ts","../src/data/currencies.ts","../src/data/locales.ts","../src/cookies.ts","../src/actions/cart.ts","../src/actions/checkout.ts","../src/auth-helpers.ts","../src/actions/auth.ts","../src/actions/addresses.ts","../src/actions/orders.ts","../src/actions/credit-cards.ts","../src/actions/gift-cards.ts","../src/actions/payment-s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,QAAQ,OAAO,CAAA;AAAA,EAC/E,CAAC,CAAA;AACH;AAKA,eAAsB,uBACpB,EAAA,EACmC;AACnC,EAAA,OAAO,eAAA,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,WAAU,CAAE,KAAA,CAAM,SAAS,oBAAA,CAAqB,GAAA,CAAI,IAAI,OAAO,CAAA;AAAA,EACxE,CAAC,CAAA;AACH;AAMA,eAAsB,2BAAA,CACpB,IACA,MAAA,EACmC;AACnC,EAAA,OAAO,eAAA,CAAgB,OAAO,OAAA,KAAY;AACxC,IAAA,OAAO,SAAA,GAAY,KAAA,CAAM,QAAA,CAAS,qBAAqB,QAAA,CAAS,EAAA,EAAI,QAAQ,OAAO,CAAA;AAAA,EACrF,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["import { createSpreeClient, type SpreeClient } from '@spree/sdk';\nimport type { SpreeNextConfig } from './types';\n\nlet _client: SpreeClient | null = null;\nlet _config: SpreeNextConfig | null = null;\n\n/**\n * Initialize the Spree Next.js integration.\n * Call this once in your app (e.g., in `lib/storefront.ts`).\n * If not called, the client will auto-initialize from SPREE_API_URL and SPREE_PUBLISHABLE_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n publishableKey: config.publishableKey,\n });\n}\n\n/**\n * Get the SpreeClient instance. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getClient(): SpreeClient {\n if (!_client) {\n const baseUrl = process.env.SPREE_API_URL;\n const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;\n if (baseUrl && publishableKey) {\n initSpreeNext({ baseUrl, publishableKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables.'\n );\n }\n }\n return _client!;\n}\n\n/**\n * Get the current config. Auto-initializes from env vars if needed.\n * @internal\n */\nexport function getConfig(): SpreeNextConfig {\n if (!_config) {\n getClient(); // triggers auto-init\n }\n return _config!;\n}\n\n/**\n * Reset the client (useful for testing).\n * @internal\n */\nexport function resetClient(): void {\n _client = null;\n _config = null;\n}\n","import type { StoreProduct, PaginatedResponse, ProductFiltersResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List products with optional filtering, sorting, and pagination.\n */\nexport async function listProducts(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().store.products.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single product by slug or ID.\n */\nexport async function getProduct(\n slugOrId: string,\n params?: { includes?: string },\n options?: SpreeNextOptions\n): Promise<StoreProduct> {\n return getClient().store.products.get(slugOrId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get available product filters (price ranges, option values, etc.).\n */\nexport async function getProductFilters(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<ProductFiltersResponse> {\n return getClient().store.products.filters(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreTaxon, StoreProduct, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxons (categories) with optional filtering and pagination.\n */\nexport async function listTaxons(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxon>> {\n return getClient().store.taxons.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxon by ID or permalink.\n */\nexport async function getTaxon(\n idOrPermalink: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxon> {\n return getClient().store.taxons.get(idOrPermalink, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * List products within a taxon.\n */\nexport async function listTaxonProducts(\n taxonId: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreProduct>> {\n return getClient().store.taxons.products.list(taxonId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreTaxonomy, PaginatedResponse } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List taxonomies with optional filtering and pagination.\n */\nexport async function listTaxonomies(\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<PaginatedResponse<StoreTaxonomy>> {\n return getClient().store.taxonomies.list(params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a single taxonomy by ID.\n */\nexport async function getTaxonomy(\n id: string,\n params?: Record<string, unknown>,\n options?: SpreeNextOptions\n): Promise<StoreTaxonomy> {\n return getClient().store.taxonomies.get(id, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreStore } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * Get the current store configuration.\n */\nexport async function getStore(options?: SpreeNextOptions): Promise<StoreStore> {\n return getClient().store.store.get({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreCountry } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List countries available in the store.\n * Each country includes currency and default_locale derived from its market.\n */\nexport async function listCountries(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCountry[] }> {\n return getClient().store.countries.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n\n/**\n * Get a country by ISO code.\n * @param iso - ISO 3166-1 alpha-2 code (e.g., \"US\", \"DE\")\n * @param params - Optional params (e.g., { include: 'states' } for address forms)\n */\nexport async function getCountry(\n iso: string,\n params?: { include?: string },\n options?: SpreeNextOptions\n): Promise<StoreCountry> {\n return getClient().store.countries.get(iso, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreCurrency } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List currencies supported by the store (derived from markets).\n */\nexport async function listCurrencies(\n options?: SpreeNextOptions\n): Promise<{ data: StoreCurrency[] }> {\n return getClient().store.currencies.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import type { StoreLocale } from '@spree/sdk';\nimport { getClient } from '../config';\nimport type { SpreeNextOptions } from '../types';\n\n/**\n * List locales supported by the store (derived from markets).\n */\nexport async function listLocales(\n options?: SpreeNextOptions\n): Promise<{ data: StoreLocale[] }> {\n return getClient().store.locales.list({\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n","import { cookies } from 'next/headers';\nimport { getConfig } from './config';\n\nconst DEFAULT_CART_COOKIE = '_spree_cart_token';\nconst DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';\nconst CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 days\nconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days\n\nfunction getCartCookieName(): string {\n try {\n return getConfig().cartCookieName ?? DEFAULT_CART_COOKIE;\n } catch {\n return DEFAULT_CART_COOKIE;\n }\n}\n\nfunction getAccessTokenCookieName(): string {\n try {\n return getConfig().accessTokenCookieName ?? DEFAULT_ACCESS_TOKEN_COOKIE;\n } catch {\n return DEFAULT_ACCESS_TOKEN_COOKIE;\n }\n}\n\n// --- Cart Token ---\n\nexport async function getCartToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getCartCookieName())?.value;\n}\n\nexport async function setCartToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: CART_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearCartToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getCartCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n\n// --- Access Token (JWT) ---\n\nexport async function getAccessToken(): Promise<string | undefined> {\n const cookieStore = await cookies();\n return cookieStore.get(getAccessTokenCookieName())?.value;\n}\n\nexport async function setAccessToken(token: string): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'lax',\n path: '/',\n maxAge: ACCESS_TOKEN_MAX_AGE,\n });\n}\n\nexport async function clearAccessToken(): Promise<void> {\n const cookieStore = await cookies();\n cookieStore.set(getAccessTokenCookieName(), '', {\n maxAge: -1,\n path: '/',\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, setCartToken, clearCartToken, getAccessToken } from '../cookies';\n\n/**\n * Get the current cart. Returns null if no cart exists.\n */\nexport async function getCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) return null;\n\n try {\n return await getClient().store.cart.get({ orderToken, token });\n } catch {\n // Cart not found (e.g., order was completed) — clear stale token\n if (orderToken) {\n await clearCartToken();\n }\n return null;\n }\n}\n\n/**\n * Get existing cart or create a new one.\n */\nexport async function getOrCreateCart(): Promise<StoreOrder & { token: string }> {\n const existing = await getCart();\n if (existing) return existing;\n\n const token = await getAccessToken();\n const cart = await getClient().store.cart.create(token ? { token } : undefined);\n\n if (cart.token) {\n await setCartToken(cart.token);\n }\n\n revalidateTag('cart');\n return cart;\n}\n\n/**\n * Add an item to the cart. Creates a cart if none exists.\n * Returns the updated order with recalculated totals.\n */\nexport async function addItem(\n variantId: string,\n quantity: number = 1\n): Promise<StoreOrder> {\n const cart = await getOrCreateCart();\n const orderToken = cart.token;\n const token = await getAccessToken();\n\n const order = await getClient().store.orders.lineItems.create(\n cart.id,\n { variant_id: variantId, quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return order;\n}\n\n/**\n * Update a line item quantity in the cart.\n * Returns the updated order with recalculated totals.\n */\nexport async function updateItem(\n lineItemId: string,\n quantity: number\n): Promise<StoreOrder> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().store.cart.get({ orderToken, token });\n\n const order = await getClient().store.orders.lineItems.update(\n cart.id,\n lineItemId,\n { quantity },\n { orderToken, token }\n );\n\n revalidateTag('cart');\n return order;\n}\n\n/**\n * Remove a line item from the cart.\n * Returns the updated order with recalculated totals.\n */\nexport async function removeItem(lineItemId: string): Promise<StoreOrder> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken && !token) throw new Error('No cart found');\n\n const cart = await getClient().store.cart.get({ orderToken, token });\n\n const order = await getClient().store.orders.lineItems.delete(cart.id, lineItemId, {\n orderToken,\n token,\n });\n\n revalidateTag('cart');\n return order;\n}\n\n/**\n * Clear the cart (abandons the current cart).\n */\nexport async function clearCart(): Promise<void> {\n await clearCartToken();\n revalidateTag('cart');\n}\n\n/**\n * Associate a guest cart with the currently authenticated user.\n * Call this after login/register when the user has an existing guest cart.\n */\nexport async function associateCart(): Promise<(StoreOrder & { token: string }) | null> {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n if (!orderToken || !token) return null;\n\n try {\n const result = await getClient().store.cart.associate({ orderToken, token });\n revalidateTag('cart');\n return result;\n } catch {\n // Cart might already belong to another user — clear it\n await clearCartToken();\n revalidateTag('cart');\n return null;\n }\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreOrder, StoreShipment, AddressParams } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, getAccessToken } from '../cookies';\n\nasync function getCheckoutOptions() {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n return { orderToken, token };\n}\n\n/**\n * Get the current checkout order state.\n * Includes line_items, shipments, and addresses by default.\n */\nexport async function getCheckout(\n orderId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n return getClient().store.orders.get(\n orderId,\n { includes: 'line_items,shipments,ship_address,bill_address' },\n options\n );\n}\n\n/**\n * Update shipping and/or billing addresses on the order.\n */\nexport async function updateAddresses(\n orderId: string,\n params: {\n email?: string;\n ship_address?: AddressParams;\n bill_address?: AddressParams;\n ship_address_id?: string;\n bill_address_id?: string;\n }\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.update(orderId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Advance the checkout to the next step.\n */\nexport async function advance(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.advance(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Move the checkout to the next step (alias for advance).\n */\nexport async function next(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.next(orderId, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Get shipments for the order (includes available shipping rates).\n */\nexport async function getShipments(\n orderId: string\n): Promise<{ data: StoreShipment[] }> {\n const options = await getCheckoutOptions();\n return getClient().store.orders.shipments.list(orderId, options);\n}\n\n/**\n * Select a shipping rate for a shipment.\n * Returns the updated order with recalculated totals.\n */\nexport async function selectShippingRate(\n orderId: string,\n shipmentId: string,\n shippingRateId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.shipments.update(\n orderId,\n shipmentId,\n { selected_shipping_rate_id: shippingRateId },\n options\n );\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Apply a coupon code to the order.\n */\nexport async function applyCoupon(\n orderId: string,\n code: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.couponCodes.apply(orderId, code, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Remove a coupon/promotion from the order.\n */\nexport async function removeCoupon(\n orderId: string,\n promotionId: string\n): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.couponCodes.remove(orderId, promotionId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n\n/**\n * Complete the checkout and place the order.\n */\nexport async function complete(orderId: string): Promise<StoreOrder> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.complete(orderId, options);\n revalidateTag('checkout');\n revalidateTag('cart');\n return result;\n}\n","import { SpreeError } from '@spree/sdk';\nimport type { RequestOptions } from '@spree/sdk';\nimport { getClient } from './config';\nimport { getAccessToken, setAccessToken, clearAccessToken } from './cookies';\n\n/**\n * Get auth request options from the current JWT token.\n * Proactively refreshes the token if it expires within 1 hour.\n */\nexport async function getAuthOptions(): Promise<RequestOptions> {\n const token = await getAccessToken();\n if (!token) {\n return {};\n }\n\n // Check if token is close to expiry by decoding JWT payload\n try {\n const payload = JSON.parse(atob(token.split('.')[1]));\n const exp = payload.exp;\n const now = Math.floor(Date.now() / 1000);\n\n // Refresh if token expires in less than 1 hour\n if (exp && exp - now < 3600) {\n try {\n const refreshed = await getClient().store.auth.refresh({ token });\n await setAccessToken(refreshed.token);\n return { token: refreshed.token };\n } catch {\n // Refresh failed — use existing token, it might still work\n }\n }\n } catch {\n // Can't decode JWT — use it as-is, the server will reject if invalid\n }\n\n return { token };\n}\n\n/**\n * Execute an authenticated request with automatic token refresh on 401.\n * @param fn - Function that takes RequestOptions and returns a promise\n * @returns The result of the function\n * @throws SpreeError if auth fails after refresh attempt\n */\nexport async function withAuthRefresh<T>(\n fn: (options: RequestOptions) => Promise<T>\n): Promise<T> {\n const options = await getAuthOptions();\n\n if (!options.token) {\n throw new Error('Not authenticated');\n }\n\n try {\n return await fn(options);\n } catch (error: unknown) {\n // If 401, try refreshing the token once\n if (error instanceof SpreeError && error.status === 401) {\n try {\n const refreshed = await getClient().store.auth.refresh({ token: options.token });\n await setAccessToken(refreshed.token);\n return await fn({ token: refreshed.token });\n } catch {\n // Refresh failed — clear token and rethrow\n await clearAccessToken();\n throw error;\n }\n }\n throw error;\n }\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreCustomer } from '@spree/sdk';\nimport { getClient } from '../config';\nimport { setAccessToken, clearAccessToken, getAccessToken, getCartToken } from '../cookies';\nimport { withAuthRefresh } from '../auth-helpers';\n\n/**\n * Login with email and password.\n * Automatically associates any guest cart with the authenticated user.\n */\nexport async function login(\n email: string,\n password: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().store.auth.login({ email, password });\n await setAccessToken(result.token);\n\n // Associate guest cart if one exists\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().store.cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Cart association failure is non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Invalid email or password',\n };\n }\n}\n\n/**\n * Register a new customer account.\n * Automatically associates any guest cart with the new account.\n */\nexport async function register(\n email: string,\n password: string,\n passwordConfirmation: string\n): Promise<{ success: boolean; user?: { id: string; email: string; first_name?: string | null; last_name?: string | null }; error?: string }> {\n try {\n const result = await getClient().store.auth.register({\n email,\n password,\n password_confirmation: passwordConfirmation,\n });\n await setAccessToken(result.token);\n\n // Associate guest cart\n const cartToken = await getCartToken();\n if (cartToken) {\n try {\n await getClient().store.cart.associate({\n token: result.token,\n orderToken: cartToken,\n });\n } catch {\n // Non-fatal\n }\n }\n\n revalidateTag('customer');\n revalidateTag('cart');\n return { success: true, user: result.user };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Registration failed',\n };\n }\n}\n\n/**\n * Logout the current user.\n */\nexport async function logout(): Promise<void> {\n await clearAccessToken();\n revalidateTag('customer');\n revalidateTag('cart');\n revalidateTag('addresses');\n revalidateTag('credit-cards');\n}\n\n/**\n * Get the currently authenticated customer. Returns null if not logged in.\n */\nexport async function getCustomer(): Promise<StoreCustomer | null> {\n const token = await getAccessToken();\n if (!token) return null;\n\n try {\n return await withAuthRefresh(async (options) => {\n return getClient().store.customer.get(options);\n });\n } catch {\n await clearAccessToken();\n return null;\n }\n}\n\n/**\n * Update the current customer's profile.\n */\nexport async function updateCustomer(\n data: { first_name?: string; last_name?: string; email?: string }\n): Promise<StoreCustomer> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().store.customer.update(data, options);\n });\n revalidateTag('customer');\n return result;\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreAddress, AddressParams } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's addresses.\n */\nexport async function listAddresses(): Promise<{ data: StoreAddress[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.list(undefined, options);\n });\n}\n\n/**\n * Get a single address by ID.\n */\nexport async function getAddress(id: string): Promise<StoreAddress> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.get(id, options);\n });\n}\n\n/**\n * Create a new address for the customer.\n */\nexport async function createAddress(params: AddressParams): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.create(params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Update an existing address.\n */\nexport async function updateAddress(\n id: string,\n params: Partial<AddressParams>\n): Promise<StoreAddress> {\n const result = await withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.update(id, params, options);\n });\n revalidateTag('addresses');\n return result;\n}\n\n/**\n * Delete an address.\n */\nexport async function deleteAddress(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().store.customer.addresses.delete(id, options);\n });\n revalidateTag('addresses');\n}\n","'use server';\n\nimport type { StoreOrder, PaginatedResponse } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's orders.\n */\nexport async function listOrders(\n params?: Record<string, unknown>\n): Promise<PaginatedResponse<StoreOrder>> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.orders.list(params, options);\n });\n}\n\n/**\n * Get a single order by ID or number.\n */\nexport async function getOrder(\n idOrNumber: string,\n params?: Record<string, unknown>\n): Promise<StoreOrder> {\n return withAuthRefresh(async (options) => {\n return getClient().store.orders.get(idOrNumber, params, options);\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type { StoreCreditCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's credit cards.\n */\nexport async function listCreditCards(): Promise<{ data: StoreCreditCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.creditCards.list(undefined, options);\n });\n}\n\n/**\n * Delete a credit card.\n */\nexport async function deleteCreditCard(id: string): Promise<void> {\n await withAuthRefresh(async (options) => {\n return getClient().store.customer.creditCards.delete(id, options);\n });\n revalidateTag('credit-cards');\n}\n","'use server';\n\nimport type { StoreGiftCard } from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * List the authenticated customer's gift cards.\n */\nexport async function listGiftCards(): Promise<{ data: StoreGiftCard[] }> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.giftCards.list(undefined, options);\n });\n}\n\n/**\n * Get a single gift card by ID.\n */\nexport async function getGiftCard(id: string): Promise<StoreGiftCard> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.giftCards.get(id, options);\n });\n}\n","'use server';\n\nimport { revalidateTag } from 'next/cache';\nimport type {\n StorePaymentSession,\n CreatePaymentSessionParams,\n UpdatePaymentSessionParams,\n CompletePaymentSessionParams,\n} from '@spree/sdk';\nimport { getClient } from '../config';\nimport { getCartToken, getAccessToken } from '../cookies';\n\nasync function getCheckoutOptions() {\n const orderToken = await getCartToken();\n const token = await getAccessToken();\n return { orderToken, token };\n}\n\n/**\n * Create a payment session for an order.\n * Delegates to the payment gateway to initialize a provider-specific session.\n */\nexport async function createPaymentSession(\n orderId: string,\n params: CreatePaymentSessionParams\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.paymentSessions.create(orderId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Get a payment session by ID.\n */\nexport async function getPaymentSession(\n orderId: string,\n sessionId: string\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n return getClient().store.orders.paymentSessions.get(orderId, sessionId, options);\n}\n\n/**\n * Update a payment session.\n * Delegates to the payment gateway to sync changes with the provider.\n */\nexport async function updatePaymentSession(\n orderId: string,\n sessionId: string,\n params: UpdatePaymentSessionParams\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.paymentSessions.update(orderId, sessionId, params, options);\n revalidateTag('checkout');\n return result;\n}\n\n/**\n * Complete a payment session.\n * Confirms the payment with the provider, triggering capture/authorization.\n */\nexport async function completePaymentSession(\n orderId: string,\n sessionId: string,\n params?: CompletePaymentSessionParams\n): Promise<StorePaymentSession> {\n const options = await getCheckoutOptions();\n const result = await getClient().store.orders.paymentSessions.complete(orderId, sessionId, params, options);\n revalidateTag('checkout');\n return result;\n}\n","'use server';\n\nimport type {\n StorePaymentSetupSession,\n CreatePaymentSetupSessionParams,\n CompletePaymentSetupSessionParams,\n} from '@spree/sdk';\nimport { withAuthRefresh } from '../auth-helpers';\nimport { getClient } from '../config';\n\n/**\n * Create a payment setup session for saving a payment method.\n * Delegates to the payment gateway to initialize a setup flow.\n */\nexport async function createPaymentSetupSession(\n params: CreatePaymentSetupSessionParams\n): Promise<StorePaymentSetupSession> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.paymentSetupSessions.create(params, options);\n });\n}\n\n/**\n * Get a payment setup session by ID.\n */\nexport async function getPaymentSetupSession(\n id: string\n): Promise<StorePaymentSetupSession> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.paymentSetupSessions.get(id, options);\n });\n}\n\n/**\n * Complete a payment setup session.\n * Confirms the setup with the provider, resulting in a saved payment method.\n */\nexport async function completePaymentSetupSession(\n id: string,\n params?: CompletePaymentSetupSessionParams\n): Promise<StorePaymentSetupSession> {\n return withAuthRefresh(async (options) => {\n return getClient().store.customer.paymentSetupSessions.complete(id, params, options);\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/next",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Next.js integration for Spree Commerce — server actions, caching, and cookie-based auth",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -55,7 +55,7 @@
55
55
  "url": "https://github.com/spree/spree/issues"
56
56
  },
57
57
  "peerDependencies": {
58
- "@spree/sdk": ">=0.3.0",
58
+ "@spree/sdk": ">=0.5.0",
59
59
  "next": ">=15.0.0",
60
60
  "react": ">=19.0.0"
61
61
  },