@spree/next 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +261 -0
- package/dist/actions/addresses.js +12 -12
- package/dist/actions/addresses.js.map +1 -1
- package/dist/actions/auth.d.ts +3 -3
- package/dist/actions/auth.js +13 -13
- package/dist/actions/auth.js.map +1 -1
- package/dist/actions/cart.js +13 -13
- package/dist/actions/cart.js.map +1 -1
- package/dist/actions/checkout.js +14 -14
- package/dist/actions/checkout.js.map +1 -1
- package/dist/actions/credit-cards.js +9 -9
- package/dist/actions/credit-cards.js.map +1 -1
- package/dist/actions/gift-cards.js +9 -9
- package/dist/actions/gift-cards.js.map +1 -1
- package/dist/actions/orders.js +9 -9
- package/dist/actions/orders.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +5 -5
- package/dist/config.js.map +1 -1
- package/dist/data/countries.js +7 -7
- package/dist/data/countries.js.map +1 -1
- package/dist/data/products.js +8 -8
- package/dist/data/products.js.map +1 -1
- package/dist/data/store.js +6 -6
- package/dist/data/store.js.map +1 -1
- package/dist/data/taxonomies.js +7 -7
- package/dist/data/taxonomies.js.map +1 -1
- package/dist/data/taxons.js +8 -8
- package/dist/data/taxons.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +52 -52
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +17 -16
- package/LICENSE +0 -58
|
@@ -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,
|
|
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"]}
|
package/dist/data/products.js
CHANGED
|
@@ -5,18 +5,18 @@ var _client = null;
|
|
|
5
5
|
function initSpreeNext(config) {
|
|
6
6
|
_client = createSpreeClient({
|
|
7
7
|
baseUrl: config.baseUrl,
|
|
8
|
-
|
|
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
|
|
15
|
-
if (baseUrl &&
|
|
16
|
-
initSpreeNext({ baseUrl,
|
|
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
|
|
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/products.ts
|
|
27
27
|
async function listProducts(params, options) {
|
|
28
|
-
return getClient().products.list(params, {
|
|
28
|
+
return getClient().store.products.list(params, {
|
|
29
29
|
locale: options?.locale,
|
|
30
30
|
currency: options?.currency
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async function getProduct(slugOrId, params, options) {
|
|
34
|
-
return getClient().products.get(slugOrId, params, {
|
|
34
|
+
return getClient().store.products.get(slugOrId, params, {
|
|
35
35
|
locale: options?.locale,
|
|
36
36
|
currency: options?.currency
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
async function getProductFilters(params, options) {
|
|
40
|
-
return getClient().products.filters(params, {
|
|
40
|
+
return getClient().store.products.filters(params, {
|
|
41
41
|
locale: options?.locale,
|
|
42
42
|
currency: options?.currency
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts","../../src/data/products.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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AAA,EAAQ;AAAA,IAChD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"products.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"]}
|
package/dist/data/store.js
CHANGED
|
@@ -5,18 +5,18 @@ var _client = null;
|
|
|
5
5
|
function initSpreeNext(config) {
|
|
6
6
|
_client = createSpreeClient({
|
|
7
7
|
baseUrl: config.baseUrl,
|
|
8
|
-
|
|
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
|
|
15
|
-
if (baseUrl &&
|
|
16
|
-
initSpreeNext({ baseUrl,
|
|
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
|
|
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,7 +25,7 @@ function getClient() {
|
|
|
25
25
|
|
|
26
26
|
// src/data/store.ts
|
|
27
27
|
async function getStore(options) {
|
|
28
|
-
return getClient().store.get({
|
|
28
|
+
return getClient().store.store.get({
|
|
29
29
|
locale: options?.locale,
|
|
30
30
|
currency: options?.currency
|
|
31
31
|
});
|
package/dist/data/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts","../../src/data/store.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,
|
|
1
|
+
{"version":3,"sources":["../../src/config.ts","../../src/data/store.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,SAAS,OAAA,EAAiD;AAC9E,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,KAAA,CAAM,GAAA,CAAI;AAAA,IACjC,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"store.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 { 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"]}
|
package/dist/data/taxonomies.js
CHANGED
|
@@ -5,18 +5,18 @@ var _client = null;
|
|
|
5
5
|
function initSpreeNext(config) {
|
|
6
6
|
_client = createSpreeClient({
|
|
7
7
|
baseUrl: config.baseUrl,
|
|
8
|
-
|
|
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
|
|
15
|
-
if (baseUrl &&
|
|
16
|
-
initSpreeNext({ baseUrl,
|
|
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
|
|
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,13 +25,13 @@ function getClient() {
|
|
|
25
25
|
|
|
26
26
|
// src/data/taxonomies.ts
|
|
27
27
|
async function listTaxonomies(params, options) {
|
|
28
|
-
return getClient().taxonomies.list(params, {
|
|
28
|
+
return getClient().store.taxonomies.list(params, {
|
|
29
29
|
locale: options?.locale,
|
|
30
30
|
currency: options?.currency
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async function getTaxonomy(id, params, options) {
|
|
34
|
-
return getClient().taxonomies.get(id, params, {
|
|
34
|
+
return getClient().store.taxonomies.get(id, params, {
|
|
35
35
|
locale: options?.locale,
|
|
36
36
|
currency: options?.currency
|
|
37
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts","../../src/data/taxonomies.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,
|
|
1
|
+
{"version":3,"sources":["../../src/config.ts","../../src/data/taxonomies.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,cAAA,CACpB,QACA,OAAA,EAC2C;AAC3C,EAAA,OAAO,SAAA,EAAU,CAAE,KAAA,CAAM,UAAA,CAAW,KAAK,MAAA,EAAQ;AAAA,IAC/C,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH;AAKA,eAAsB,WAAA,CACpB,EAAA,EACA,MAAA,EACA,OAAA,EACwB;AACxB,EAAA,OAAO,WAAU,CAAE,KAAA,CAAM,UAAA,CAAW,GAAA,CAAI,IAAI,MAAA,EAAQ;AAAA,IAClD,QAAQ,OAAA,EAAS,MAAA;AAAA,IACjB,UAAU,OAAA,EAAS;AAAA,GACpB,CAAA;AACH","file":"taxonomies.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 { 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"]}
|
package/dist/data/taxons.js
CHANGED
|
@@ -5,18 +5,18 @@ var _client = null;
|
|
|
5
5
|
function initSpreeNext(config) {
|
|
6
6
|
_client = createSpreeClient({
|
|
7
7
|
baseUrl: config.baseUrl,
|
|
8
|
-
|
|
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
|
|
15
|
-
if (baseUrl &&
|
|
16
|
-
initSpreeNext({ baseUrl,
|
|
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
|
|
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
|
});
|
package/dist/data/taxons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts","../../src/data/taxons.ts"],"names":[],"mappings":";;;AAGA,IAAI,OAA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S;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,
|
|
9
|
-
export { AddressParams, PaginatedResponse, ProductFiltersResponse, SpreeError, StoreAddress, StoreCountry, StoreCreditCard, StoreGiftCard, StoreImage, StoreLineItem, StoreOptionType, StoreOptionValue, StoreOrder, StoreOrderPromotion, StorePayment, StorePaymentMethod, StorePrice, StoreProduct, StoreShipment, StoreShippingRate, StoreStore, StoreTaxon, StoreTaxonomy,
|
|
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';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Get the current cart. Returns null if no cart exists.
|
|
@@ -125,7 +125,7 @@ declare function logout(): Promise<void>;
|
|
|
125
125
|
/**
|
|
126
126
|
* Get the currently authenticated customer. Returns null if not logged in.
|
|
127
127
|
*/
|
|
128
|
-
declare function getCustomer(): Promise<
|
|
128
|
+
declare function getCustomer(): Promise<StoreCustomer | null>;
|
|
129
129
|
/**
|
|
130
130
|
* Update the current customer's profile.
|
|
131
131
|
*/
|
|
@@ -133,7 +133,7 @@ declare function updateCustomer(data: {
|
|
|
133
133
|
first_name?: string;
|
|
134
134
|
last_name?: string;
|
|
135
135
|
email?: string;
|
|
136
|
-
}): Promise<
|
|
136
|
+
}): Promise<StoreCustomer>;
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* List the authenticated customer's addresses.
|