@spree/next 0.1.2 → 0.2.1

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.
@@ -5,18 +5,18 @@ var _client = null;
5
5
  function initSpreeNext(config) {
6
6
  _client = createSpreeClient({
7
7
  baseUrl: config.baseUrl,
8
- apiKey: config.apiKey
8
+ publishableKey: config.publishableKey
9
9
  });
10
10
  }
11
11
  function getClient() {
12
12
  if (!_client) {
13
13
  const baseUrl = process.env.SPREE_API_URL;
14
- const apiKey = process.env.SPREE_API_KEY;
15
- if (baseUrl && apiKey) {
16
- initSpreeNext({ baseUrl, apiKey });
14
+ const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;
15
+ if (baseUrl && publishableKey) {
16
+ initSpreeNext({ baseUrl, publishableKey });
17
17
  } else {
18
18
  throw new Error(
19
- "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."
19
+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables."
20
20
  );
21
21
  }
22
22
  }
@@ -25,19 +25,19 @@ function getClient() {
25
25
 
26
26
  // src/data/taxons.ts
27
27
  async function listTaxons(params, options) {
28
- return getClient().taxons.list(params, {
28
+ return getClient().store.taxons.list(params, {
29
29
  locale: options?.locale,
30
30
  currency: options?.currency
31
31
  });
32
32
  }
33
33
  async function getTaxon(idOrPermalink, params, options) {
34
- return getClient().taxons.get(idOrPermalink, params, {
34
+ return getClient().store.taxons.get(idOrPermalink, params, {
35
35
  locale: options?.locale,
36
36
  currency: options?.currency
37
37
  });
38
38
  }
39
39
  async function listTaxonProducts(taxonId, params, options) {
40
- return getClient().taxons.products.list(taxonId, params, {
40
+ return getClient().store.taxons.products.list(taxonId, params, {
41
41
  locale: options?.locale,
42
42
  currency: options?.currency
43
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config.ts","../../src/data/taxons.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,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAMO,SAAS,SAAA,GAAyB;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,OAAA,GAAU,QAAQ,GAAA,CAAI,aAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,aAAA;AAC3B,IAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,MAAA,aAAA,CAAc,EAAE,OAAA,EAAS,MAAA,EAAQ,CAAA;AAAA,IACnC,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC7BA,eAAsB,UAAA,CACpB,QACA,OAAA,EACwC;AACxC,EAAA,OAAO,SAAA,EAAU,CAAE,MAAA,CAAO,IAAA,CAAK,MAAA,EAAQ;AAAA,IACrC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,QAAA,CACpB,aAAA,EACA,MAAA,EACA,OAAA,EACqB;AACrB,EAAA,OAAO,SAAA,EAAU,CAAE,MAAA,CAAO,GAAA,CAAI,eAAe,MAAA,EAAQ;AAAA,IACnD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,iBAAA,CACpB,OAAA,EACA,MAAA,EACA,OAAA,EAC0C;AAC1C,EAAA,OAAO,WAAU,CAAE,MAAA,CAAO,QAAA,CAAS,IAAA,CAAK,SAAS,MAAA,EAAQ;AAAA,IACvD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"taxons.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_API_KEY env vars.\n */\nexport function initSpreeNext(config: SpreeNextConfig): void {\n _config = config;\n _client = createSpreeClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\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 apiKey = process.env.SPREE_API_KEY;\n if (baseUrl && apiKey) {\n initSpreeNext({ baseUrl, apiKey });\n } else {\n throw new Error(\n '@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_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 { 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().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().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().taxons.products.list(taxonId, params, {\n locale: options?.locale,\n currency: options?.currency,\n });\n}\n"]}
1
+ {"version":3,"sources":["../../src/config.ts","../../src/data/taxons.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,UAAA,CACpB,QACA,OAAA,EACwC;AACxC,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,MAAA,CAAO,KAAK,MAAA,EAAQ;AAAA,IAC3C,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,QAAA,CACpB,aAAA,EACA,MAAA,EACA,OAAA,EACqB;AACrB,EAAA,OAAO,WAAU,CAAE,KAAA,CAAM,MAAA,CAAO,GAAA,CAAI,eAAe,MAAA,EAAQ;AAAA,IACzD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,iBAAA,CACpB,OAAA,EACA,MAAA,EACA,OAAA,EAC0C;AAC1C,EAAA,OAAO,WAAU,CAAE,KAAA,CAAM,OAAO,QAAA,CAAS,IAAA,CAAK,SAAS,MAAA,EAAQ;AAAA,IAC7D,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"taxons.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 { 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"]}
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ 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
- import { StoreLineItem, StoreOrder, StoreShipment, AddressParams, StoreCustomer, StoreAddress, PaginatedResponse, StoreCreditCard, StoreGiftCard } from '@spree/sdk';
9
- export { AddressParams, PaginatedResponse, ProductFiltersResponse, SpreeError, StoreAddress, StoreCountry, StoreCreditCard, StoreCustomer, StoreGiftCard, StoreImage, StoreLineItem, StoreOptionType, StoreOptionValue, StoreOrder, StoreOrderPromotion, StorePayment, StorePaymentMethod, StorePrice, StoreProduct, StoreShipment, StoreShippingRate, StoreStore, StoreTaxon, StoreTaxonomy, StoreVariant } from '@spree/sdk';
8
+ import { StoreLineItem, StoreOrder, StoreShipment, AddressParams, StoreCustomer, StoreAddress, PaginatedResponse, StoreCreditCard, StoreGiftCard, CompletePaymentSessionParams, StorePaymentSession, CreatePaymentSessionParams, UpdatePaymentSessionParams } from '@spree/sdk';
9
+ export { AddressParams, CompletePaymentSessionParams, CreatePaymentSessionParams, PaginatedResponse, ProductFiltersResponse, SpreeError, StoreAddress, StoreCountry, StoreCreditCard, StoreCustomer, StoreGiftCard, StoreImage, StoreLineItem, StoreOptionType, StoreOptionValue, StoreOrder, StoreOrderPromotion, StorePayment, StorePaymentMethod, StorePaymentSession, StorePrice, StoreProduct, StoreShipment, StoreShippingRate, StoreStore, StoreTaxon, StoreTaxonomy, StoreVariant, UpdatePaymentSessionParams } from '@spree/sdk';
10
10
 
11
11
  /**
12
12
  * Get the current cart. Returns null if no cart exists.
@@ -189,4 +189,24 @@ declare function listGiftCards(): Promise<{
189
189
  */
190
190
  declare function getGiftCard(id: string): Promise<StoreGiftCard>;
191
191
 
192
- export { addItem, advance, applyCoupon, associateCart, clearCart, complete, createAddress, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getCustomer, getGiftCard, getOrCreateCart, getOrder, getShipments, listAddresses, listCreditCards, listGiftCards, listOrders, login, logout, next, register, removeCoupon, removeItem, selectShippingRate, updateAddress, updateAddresses, updateCustomer, updateItem };
192
+ /**
193
+ * Create a payment session for an order.
194
+ * Delegates to the payment gateway to initialize a provider-specific session.
195
+ */
196
+ declare function createPaymentSession(orderId: string, params: CreatePaymentSessionParams): Promise<StorePaymentSession>;
197
+ /**
198
+ * Get a payment session by ID.
199
+ */
200
+ declare function getPaymentSession(orderId: string, sessionId: string): Promise<StorePaymentSession>;
201
+ /**
202
+ * Update a payment session.
203
+ * Delegates to the payment gateway to sync changes with the provider.
204
+ */
205
+ declare function updatePaymentSession(orderId: string, sessionId: string, params: UpdatePaymentSessionParams): Promise<StorePaymentSession>;
206
+ /**
207
+ * Complete a payment session.
208
+ * Confirms the payment with the provider, triggering capture/authorization.
209
+ */
210
+ declare function completePaymentSession(orderId: string, sessionId: string, params?: CompletePaymentSessionParams): Promise<StorePaymentSession>;
211
+
212
+ export { addItem, advance, applyCoupon, associateCart, clearCart, complete, completePaymentSession, createAddress, createPaymentSession, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getCustomer, getGiftCard, getOrCreateCart, getOrder, getPaymentSession, getShipments, listAddresses, listCreditCards, listGiftCards, listOrders, login, logout, next, register, removeCoupon, removeItem, selectShippingRate, updateAddress, updateAddresses, updateCustomer, updateItem, updatePaymentSession };
package/dist/index.js CHANGED
@@ -9,18 +9,18 @@ function initSpreeNext(config) {
9
9
  _config = config;
10
10
  _client = createSpreeClient({
11
11
  baseUrl: config.baseUrl,
12
- apiKey: config.apiKey
12
+ publishableKey: config.publishableKey
13
13
  });
14
14
  }
15
15
  function getClient() {
16
16
  if (!_client) {
17
17
  const baseUrl = process.env.SPREE_API_URL;
18
- const apiKey = process.env.SPREE_API_KEY;
19
- if (baseUrl && apiKey) {
20
- initSpreeNext({ baseUrl, apiKey });
18
+ const publishableKey = process.env.SPREE_PUBLISHABLE_KEY;
19
+ if (baseUrl && publishableKey) {
20
+ initSpreeNext({ baseUrl, publishableKey });
21
21
  } else {
22
22
  throw new Error(
23
- "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_API_KEY environment variables."
23
+ "@spree/next is not configured. Either call initSpreeNext() or set SPREE_API_URL and SPREE_PUBLISHABLE_KEY environment variables."
24
24
  );
25
25
  }
26
26
  }
@@ -35,19 +35,19 @@ function getConfig() {
35
35
 
36
36
  // src/data/products.ts
37
37
  async function listProducts(params, options) {
38
- return getClient().products.list(params, {
38
+ return getClient().store.products.list(params, {
39
39
  locale: options?.locale,
40
40
  currency: options?.currency
41
41
  });
42
42
  }
43
43
  async function getProduct(slugOrId, params, options) {
44
- return getClient().products.get(slugOrId, params, {
44
+ return getClient().store.products.get(slugOrId, params, {
45
45
  locale: options?.locale,
46
46
  currency: options?.currency
47
47
  });
48
48
  }
49
49
  async function getProductFilters(params, options) {
50
- return getClient().products.filters(params, {
50
+ return getClient().store.products.filters(params, {
51
51
  locale: options?.locale,
52
52
  currency: options?.currency
53
53
  });
@@ -55,19 +55,19 @@ async function getProductFilters(params, options) {
55
55
 
56
56
  // src/data/taxons.ts
57
57
  async function listTaxons(params, options) {
58
- return getClient().taxons.list(params, {
58
+ return getClient().store.taxons.list(params, {
59
59
  locale: options?.locale,
60
60
  currency: options?.currency
61
61
  });
62
62
  }
63
63
  async function getTaxon(idOrPermalink, params, options) {
64
- return getClient().taxons.get(idOrPermalink, params, {
64
+ return getClient().store.taxons.get(idOrPermalink, params, {
65
65
  locale: options?.locale,
66
66
  currency: options?.currency
67
67
  });
68
68
  }
69
69
  async function listTaxonProducts(taxonId, params, options) {
70
- return getClient().taxons.products.list(taxonId, params, {
70
+ return getClient().store.taxons.products.list(taxonId, params, {
71
71
  locale: options?.locale,
72
72
  currency: options?.currency
73
73
  });
@@ -75,13 +75,13 @@ async function listTaxonProducts(taxonId, params, options) {
75
75
 
76
76
  // src/data/taxonomies.ts
77
77
  async function listTaxonomies(params, options) {
78
- return getClient().taxonomies.list(params, {
78
+ return getClient().store.taxonomies.list(params, {
79
79
  locale: options?.locale,
80
80
  currency: options?.currency
81
81
  });
82
82
  }
83
83
  async function getTaxonomy(id, params, options) {
84
- return getClient().taxonomies.get(id, params, {
84
+ return getClient().store.taxonomies.get(id, params, {
85
85
  locale: options?.locale,
86
86
  currency: options?.currency
87
87
  });
@@ -89,7 +89,7 @@ async function getTaxonomy(id, params, options) {
89
89
 
90
90
  // src/data/store.ts
91
91
  async function getStore(options) {
92
- return getClient().store.get({
92
+ return getClient().store.store.get({
93
93
  locale: options?.locale,
94
94
  currency: options?.currency
95
95
  });
@@ -97,13 +97,13 @@ async function getStore(options) {
97
97
 
98
98
  // src/data/countries.ts
99
99
  async function listCountries(options) {
100
- return getClient().countries.list({
100
+ return getClient().store.countries.list({
101
101
  locale: options?.locale,
102
102
  currency: options?.currency
103
103
  });
104
104
  }
105
105
  async function getCountry(iso, options) {
106
- return getClient().countries.get(iso, {
106
+ return getClient().store.countries.get(iso, {
107
107
  locale: options?.locale,
108
108
  currency: options?.currency
109
109
  });
@@ -175,7 +175,7 @@ async function getCart() {
175
175
  const token = await getAccessToken();
176
176
  if (!orderToken && !token) return null;
177
177
  try {
178
- return await getClient().cart.get({ orderToken, token });
178
+ return await getClient().store.cart.get({ orderToken, token });
179
179
  } catch {
180
180
  return null;
181
181
  }
@@ -184,7 +184,7 @@ async function getOrCreateCart() {
184
184
  const existing = await getCart();
185
185
  if (existing) return existing;
186
186
  const token = await getAccessToken();
187
- const cart = await getClient().cart.create(token ? { token } : void 0);
187
+ const cart = await getClient().store.cart.create(token ? { token } : void 0);
188
188
  if (cart.token) {
189
189
  await setCartToken(cart.token);
190
190
  }
@@ -195,7 +195,7 @@ async function addItem(variantId, quantity = 1) {
195
195
  const cart = await getOrCreateCart();
196
196
  const orderToken = cart.token;
197
197
  const token = await getAccessToken();
198
- const lineItem = await getClient().orders.lineItems.create(
198
+ const lineItem = await getClient().store.orders.lineItems.create(
199
199
  cart.id,
200
200
  { variant_id: variantId, quantity },
201
201
  { orderToken, token }
@@ -207,8 +207,8 @@ async function updateItem(lineItemId, quantity) {
207
207
  const orderToken = await getCartToken();
208
208
  const token = await getAccessToken();
209
209
  if (!orderToken && !token) throw new Error("No cart found");
210
- const cart = await getClient().cart.get({ orderToken, token });
211
- const lineItem = await getClient().orders.lineItems.update(
210
+ const cart = await getClient().store.cart.get({ orderToken, token });
211
+ const lineItem = await getClient().store.orders.lineItems.update(
212
212
  cart.id,
213
213
  lineItemId,
214
214
  { quantity },
@@ -221,8 +221,8 @@ async function removeItem(lineItemId) {
221
221
  const orderToken = await getCartToken();
222
222
  const token = await getAccessToken();
223
223
  if (!orderToken && !token) throw new Error("No cart found");
224
- const cart = await getClient().cart.get({ orderToken, token });
225
- await getClient().orders.lineItems.delete(cart.id, lineItemId, {
224
+ const cart = await getClient().store.cart.get({ orderToken, token });
225
+ await getClient().store.orders.lineItems.delete(cart.id, lineItemId, {
226
226
  orderToken,
227
227
  token
228
228
  });
@@ -237,7 +237,7 @@ async function associateCart() {
237
237
  const token = await getAccessToken();
238
238
  if (!orderToken || !token) return null;
239
239
  try {
240
- const result = await getClient().cart.associate({ orderToken, token });
240
+ const result = await getClient().store.cart.associate({ orderToken, token });
241
241
  revalidateTag("cart");
242
242
  return result;
243
243
  } catch {
@@ -253,7 +253,7 @@ async function getCheckoutOptions() {
253
253
  }
254
254
  async function getCheckout(orderId) {
255
255
  const options = await getCheckoutOptions();
256
- return getClient().orders.get(
256
+ return getClient().store.orders.get(
257
257
  orderId,
258
258
  { includes: "line_items,shipments,ship_address,bill_address" },
259
259
  options
@@ -261,29 +261,29 @@ async function getCheckout(orderId) {
261
261
  }
262
262
  async function updateAddresses(orderId, params) {
263
263
  const options = await getCheckoutOptions();
264
- const result = await getClient().orders.update(orderId, params, options);
264
+ const result = await getClient().store.orders.update(orderId, params, options);
265
265
  revalidateTag("checkout");
266
266
  return result;
267
267
  }
268
268
  async function advance(orderId) {
269
269
  const options = await getCheckoutOptions();
270
- const result = await getClient().orders.advance(orderId, options);
270
+ const result = await getClient().store.orders.advance(orderId, options);
271
271
  revalidateTag("checkout");
272
272
  return result;
273
273
  }
274
274
  async function next(orderId) {
275
275
  const options = await getCheckoutOptions();
276
- const result = await getClient().orders.next(orderId, options);
276
+ const result = await getClient().store.orders.next(orderId, options);
277
277
  revalidateTag("checkout");
278
278
  return result;
279
279
  }
280
280
  async function getShipments(orderId) {
281
281
  const options = await getCheckoutOptions();
282
- return getClient().orders.shipments.list(orderId, options);
282
+ return getClient().store.orders.shipments.list(orderId, options);
283
283
  }
284
284
  async function selectShippingRate(orderId, shipmentId, shippingRateId) {
285
285
  const options = await getCheckoutOptions();
286
- const result = await getClient().orders.shipments.update(
286
+ const result = await getClient().store.orders.shipments.update(
287
287
  orderId,
288
288
  shipmentId,
289
289
  { selected_shipping_rate_id: shippingRateId },
@@ -294,21 +294,21 @@ async function selectShippingRate(orderId, shipmentId, shippingRateId) {
294
294
  }
295
295
  async function applyCoupon(orderId, code) {
296
296
  const options = await getCheckoutOptions();
297
- const result = await getClient().orders.couponCodes.apply(orderId, code, options);
297
+ const result = await getClient().store.orders.couponCodes.apply(orderId, code, options);
298
298
  revalidateTag("checkout");
299
299
  revalidateTag("cart");
300
300
  return result;
301
301
  }
302
302
  async function removeCoupon(orderId, promotionId) {
303
303
  const options = await getCheckoutOptions();
304
- const result = await getClient().orders.couponCodes.remove(orderId, promotionId, options);
304
+ const result = await getClient().store.orders.couponCodes.remove(orderId, promotionId, options);
305
305
  revalidateTag("checkout");
306
306
  revalidateTag("cart");
307
307
  return result;
308
308
  }
309
309
  async function complete(orderId) {
310
310
  const options = await getCheckoutOptions();
311
- const result = await getClient().orders.complete(orderId, options);
311
+ const result = await getClient().store.orders.complete(orderId, options);
312
312
  revalidateTag("checkout");
313
313
  revalidateTag("cart");
314
314
  return result;
@@ -324,7 +324,7 @@ async function getAuthOptions() {
324
324
  const now = Math.floor(Date.now() / 1e3);
325
325
  if (exp && exp - now < 3600) {
326
326
  try {
327
- const refreshed = await getClient().auth.refresh({ token });
327
+ const refreshed = await getClient().store.auth.refresh({ token });
328
328
  await setAccessToken(refreshed.token);
329
329
  return { token: refreshed.token };
330
330
  } catch {
@@ -344,7 +344,7 @@ async function withAuthRefresh(fn) {
344
344
  } catch (error) {
345
345
  if (error instanceof SpreeError && error.status === 401) {
346
346
  try {
347
- const refreshed = await getClient().auth.refresh({ token: options.token });
347
+ const refreshed = await getClient().store.auth.refresh({ token: options.token });
348
348
  await setAccessToken(refreshed.token);
349
349
  return await fn({ token: refreshed.token });
350
350
  } catch {
@@ -359,12 +359,12 @@ async function withAuthRefresh(fn) {
359
359
  // src/actions/auth.ts
360
360
  async function login(email, password) {
361
361
  try {
362
- const result = await getClient().auth.login({ email, password });
362
+ const result = await getClient().store.auth.login({ email, password });
363
363
  await setAccessToken(result.token);
364
364
  const cartToken = await getCartToken();
365
365
  if (cartToken) {
366
366
  try {
367
- await getClient().cart.associate({
367
+ await getClient().store.cart.associate({
368
368
  token: result.token,
369
369
  orderToken: cartToken
370
370
  });
@@ -383,7 +383,7 @@ async function login(email, password) {
383
383
  }
384
384
  async function register(email, password, passwordConfirmation) {
385
385
  try {
386
- const result = await getClient().auth.register({
386
+ const result = await getClient().store.auth.register({
387
387
  email,
388
388
  password,
389
389
  password_confirmation: passwordConfirmation
@@ -392,7 +392,7 @@ async function register(email, password, passwordConfirmation) {
392
392
  const cartToken = await getCartToken();
393
393
  if (cartToken) {
394
394
  try {
395
- await getClient().cart.associate({
395
+ await getClient().store.cart.associate({
396
396
  token: result.token,
397
397
  orderToken: cartToken
398
398
  });
@@ -421,7 +421,7 @@ async function getCustomer() {
421
421
  if (!token) return null;
422
422
  try {
423
423
  return await withAuthRefresh(async (options) => {
424
- return getClient().customer.get(options);
424
+ return getClient().store.customer.get(options);
425
425
  });
426
426
  } catch {
427
427
  await clearAccessToken();
@@ -430,38 +430,38 @@ async function getCustomer() {
430
430
  }
431
431
  async function updateCustomer(data) {
432
432
  const result = await withAuthRefresh(async (options) => {
433
- return getClient().customer.update(data, options);
433
+ return getClient().store.customer.update(data, options);
434
434
  });
435
435
  revalidateTag("customer");
436
436
  return result;
437
437
  }
438
438
  async function listAddresses() {
439
439
  return withAuthRefresh(async (options) => {
440
- return getClient().customer.addresses.list(void 0, options);
440
+ return getClient().store.customer.addresses.list(void 0, options);
441
441
  });
442
442
  }
443
443
  async function getAddress(id) {
444
444
  return withAuthRefresh(async (options) => {
445
- return getClient().customer.addresses.get(id, options);
445
+ return getClient().store.customer.addresses.get(id, options);
446
446
  });
447
447
  }
448
448
  async function createAddress(params) {
449
449
  const result = await withAuthRefresh(async (options) => {
450
- return getClient().customer.addresses.create(params, options);
450
+ return getClient().store.customer.addresses.create(params, options);
451
451
  });
452
452
  revalidateTag("addresses");
453
453
  return result;
454
454
  }
455
455
  async function updateAddress(id, params) {
456
456
  const result = await withAuthRefresh(async (options) => {
457
- return getClient().customer.addresses.update(id, params, options);
457
+ return getClient().store.customer.addresses.update(id, params, options);
458
458
  });
459
459
  revalidateTag("addresses");
460
460
  return result;
461
461
  }
462
462
  async function deleteAddress(id) {
463
463
  await withAuthRefresh(async (options) => {
464
- return getClient().customer.addresses.delete(id, options);
464
+ return getClient().store.customer.addresses.delete(id, options);
465
465
  });
466
466
  revalidateTag("addresses");
467
467
  }
@@ -469,22 +469,22 @@ async function deleteAddress(id) {
469
469
  // src/actions/orders.ts
470
470
  async function listOrders(params) {
471
471
  return withAuthRefresh(async (options) => {
472
- return getClient().orders.list(params, options);
472
+ return getClient().store.orders.list(params, options);
473
473
  });
474
474
  }
475
475
  async function getOrder(idOrNumber, params) {
476
476
  return withAuthRefresh(async (options) => {
477
- return getClient().orders.get(idOrNumber, params, options);
477
+ return getClient().store.orders.get(idOrNumber, params, options);
478
478
  });
479
479
  }
480
480
  async function listCreditCards() {
481
481
  return withAuthRefresh(async (options) => {
482
- return getClient().customer.creditCards.list(void 0, options);
482
+ return getClient().store.customer.creditCards.list(void 0, options);
483
483
  });
484
484
  }
485
485
  async function deleteCreditCard(id) {
486
486
  await withAuthRefresh(async (options) => {
487
- return getClient().customer.creditCards.delete(id, options);
487
+ return getClient().store.customer.creditCards.delete(id, options);
488
488
  });
489
489
  revalidateTag("credit-cards");
490
490
  }
@@ -492,15 +492,42 @@ async function deleteCreditCard(id) {
492
492
  // src/actions/gift-cards.ts
493
493
  async function listGiftCards() {
494
494
  return withAuthRefresh(async (options) => {
495
- return getClient().customer.giftCards.list(void 0, options);
495
+ return getClient().store.customer.giftCards.list(void 0, options);
496
496
  });
497
497
  }
498
498
  async function getGiftCard(id) {
499
499
  return withAuthRefresh(async (options) => {
500
- return getClient().customer.giftCards.get(id, options);
500
+ return getClient().store.customer.giftCards.get(id, options);
501
501
  });
502
502
  }
503
+ async function getCheckoutOptions2() {
504
+ const orderToken = await getCartToken();
505
+ const token = await getAccessToken();
506
+ return { orderToken, token };
507
+ }
508
+ async function createPaymentSession(orderId, params) {
509
+ const options = await getCheckoutOptions2();
510
+ const result = await getClient().store.orders.paymentSessions.create(orderId, params, options);
511
+ revalidateTag("checkout");
512
+ return result;
513
+ }
514
+ async function getPaymentSession(orderId, sessionId) {
515
+ const options = await getCheckoutOptions2();
516
+ return getClient().store.orders.paymentSessions.get(orderId, sessionId, options);
517
+ }
518
+ async function updatePaymentSession(orderId, sessionId, params) {
519
+ const options = await getCheckoutOptions2();
520
+ const result = await getClient().store.orders.paymentSessions.update(orderId, sessionId, params, options);
521
+ revalidateTag("checkout");
522
+ return result;
523
+ }
524
+ async function completePaymentSession(orderId, sessionId, params) {
525
+ const options = await getCheckoutOptions2();
526
+ const result = await getClient().store.orders.paymentSessions.complete(orderId, sessionId, params, options);
527
+ revalidateTag("checkout");
528
+ return result;
529
+ }
503
530
 
504
- export { addItem, advance, applyCoupon, associateCart, clearCart, complete, createAddress, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getClient, getCountry, getCustomer, getGiftCard, getOrCreateCart, getOrder, 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 };
531
+ export { addItem, advance, applyCoupon, associateCart, clearCart, complete, completePaymentSession, createAddress, createPaymentSession, deleteAddress, deleteCreditCard, getAddress, getCart, getCheckout, getClient, getCountry, getCustomer, getGiftCard, getOrCreateCart, getOrder, getPaymentSession, 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 };
505
532
  //# sourceMappingURL=index.js.map
506
533
  //# sourceMappingURL=index.js.map