@cimplify/sdk 0.51.1 → 0.52.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.
Files changed (51) hide show
  1. package/dist/advanced.d.mts +1 -1
  2. package/dist/advanced.d.ts +1 -1
  3. package/dist/advanced.js +23 -22
  4. package/dist/advanced.mjs +4 -3
  5. package/dist/chunk-3G6RQLXK.mjs +21 -0
  6. package/dist/{chunk-GUZXQSGI.mjs → chunk-4QDCMYYB.mjs} +10 -21
  7. package/dist/{chunk-CAG3TEXO.js → chunk-7A3D3LFI.js} +4 -4
  8. package/dist/{chunk-6RP6OPYO.js → chunk-7Y2O3E4D.js} +3 -3
  9. package/dist/{chunk-Z2AYLZDF.mjs → chunk-AMZXALF6.mjs} +1 -21
  10. package/dist/{chunk-VOWMB2KR.js → chunk-EQLT46ZR.js} +75 -78
  11. package/dist/{chunk-FXACV333.mjs → chunk-GLAVTDDE.mjs} +55 -58
  12. package/dist/chunk-OWW5GUSB.js +28 -0
  13. package/dist/{chunk-GEWFWQYK.js → chunk-Q5VGDCQF.js} +235 -234
  14. package/dist/{chunk-632JEJUS.mjs → chunk-R3F55BRN.mjs} +2 -1
  15. package/dist/{chunk-QCS6D4XW.mjs → chunk-RDORJT7Y.mjs} +2 -2
  16. package/dist/{chunk-XY2DFX5K.mjs → chunk-TD3AY34U.mjs} +1 -1
  17. package/dist/{chunk-FJQC4VSN.js → chunk-W6CCBNGL.js} +68 -79
  18. package/dist/{chunk-TKOTACKZ.js → chunk-XA3ZNR75.js} +0 -26
  19. package/dist/{client-CF2pmEE9.d.mts → client-C6J_RGlr.d.mts} +27 -45
  20. package/dist/{client-B6x53-Al.d.ts → client-CX7IFIkL.d.ts} +27 -45
  21. package/dist/{client-BbrCopIS.d.mts → client-DdefKjcs.d.mts} +1 -1
  22. package/dist/{client-BvEjhvwq.d.ts → client-Lt7uGLmT.d.ts} +1 -1
  23. package/dist/index.d.mts +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +110 -109
  26. package/dist/index.mjs +5 -4
  27. package/dist/react.d.mts +1 -1
  28. package/dist/react.d.ts +1 -1
  29. package/dist/react.js +86 -85
  30. package/dist/react.mjs +5 -4
  31. package/dist/server/evict.d.mts +31 -0
  32. package/dist/server/evict.d.ts +31 -0
  33. package/dist/server/evict.js +75 -0
  34. package/dist/server/evict.mjs +73 -0
  35. package/dist/server.d.mts +11 -48
  36. package/dist/server.d.ts +11 -48
  37. package/dist/server.js +7 -76
  38. package/dist/server.mjs +6 -74
  39. package/dist/testing/msw.js +4 -3
  40. package/dist/testing/msw.mjs +3 -2
  41. package/dist/testing/suite.d.mts +2 -2
  42. package/dist/testing/suite.d.ts +2 -2
  43. package/dist/testing/suite.js +26 -25
  44. package/dist/testing/suite.mjs +7 -6
  45. package/dist/testing.d.mts +2 -2
  46. package/dist/testing.d.ts +2 -2
  47. package/dist/testing.js +82 -81
  48. package/dist/testing.mjs +8 -7
  49. package/dist/utils.js +30 -29
  50. package/dist/utils.mjs +3 -2
  51. package/package.json +7 -1
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ require('../chunk-OWW5GUSB.js');
4
+ var internal = require('@opennextjs/cloudflare/overrides/internal');
5
+ var cloudflareContext = require('@opennextjs/cloudflare/cloudflare-context');
6
+
7
+ var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
8
+ var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
9
+ var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
10
+ var CIMPLIFY_TAG_PREFIX = "cimplify:";
11
+ function r2Key(env, key, cacheType) {
12
+ return internal.computeCacheKey(key, {
13
+ prefix: env[R2_PREFIX_ENV],
14
+ buildId: globalThis.process?.env?.OPEN_NEXT_BUILD_ID,
15
+ cacheType
16
+ });
17
+ }
18
+ function cimplifyTags(value) {
19
+ return (value?.tags ?? []).filter((t) => t.startsWith(CIMPLIFY_TAG_PREFIX));
20
+ }
21
+ function pathIndexFor(env) {
22
+ const ns = env[PATH_INDEX_BINDING];
23
+ const prefix = env[R2_PREFIX_ENV];
24
+ if (!ns || !prefix) return null;
25
+ return ns.get(ns.idFromName(prefix));
26
+ }
27
+ var evictIncrementalCache = {
28
+ name: "cimplify-evict-r2-cache",
29
+ async get(key, cacheType) {
30
+ const env = cloudflareContext.getCloudflareContext().env;
31
+ const r2 = env[R2_BUCKET_BINDING];
32
+ if (!r2) return null;
33
+ try {
34
+ const obj = await r2.get(r2Key(env, key, cacheType));
35
+ if (!obj) return null;
36
+ return {
37
+ value: await obj.json(),
38
+ lastModified: obj.uploaded.getTime()
39
+ };
40
+ } catch {
41
+ return null;
42
+ }
43
+ },
44
+ async set(key, value, cacheType) {
45
+ const env = cloudflareContext.getCloudflareContext().env;
46
+ const r2 = env[R2_BUCKET_BINDING];
47
+ if (!r2) return;
48
+ const k = r2Key(env, key, cacheType);
49
+ try {
50
+ await r2.put(k, JSON.stringify(value));
51
+ } catch {
52
+ return;
53
+ }
54
+ const tags = cimplifyTags(value);
55
+ if (tags.length === 0) return;
56
+ const index = pathIndexFor(env);
57
+ if (!index) return;
58
+ try {
59
+ await index.indexAdd(key, k, tags, cacheType === "fetch");
60
+ } catch {
61
+ }
62
+ },
63
+ async delete(key) {
64
+ const env = cloudflareContext.getCloudflareContext().env;
65
+ const r2 = env[R2_BUCKET_BINDING];
66
+ if (!r2) return;
67
+ try {
68
+ await r2.delete(r2Key(env, key));
69
+ } catch {
70
+ }
71
+ }
72
+ };
73
+ var evict_incremental_cache_default = evictIncrementalCache;
74
+
75
+ exports.evictIncrementalCache = evict_incremental_cache_default;
@@ -0,0 +1,73 @@
1
+ import '../chunk-3G6RQLXK.mjs';
2
+ import { computeCacheKey } from '@opennextjs/cloudflare/overrides/internal';
3
+ import { getCloudflareContext } from '@opennextjs/cloudflare/cloudflare-context';
4
+
5
+ var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
6
+ var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
7
+ var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
8
+ var CIMPLIFY_TAG_PREFIX = "cimplify:";
9
+ function r2Key(env, key, cacheType) {
10
+ return computeCacheKey(key, {
11
+ prefix: env[R2_PREFIX_ENV],
12
+ buildId: globalThis.process?.env?.OPEN_NEXT_BUILD_ID,
13
+ cacheType
14
+ });
15
+ }
16
+ function cimplifyTags(value) {
17
+ return (value?.tags ?? []).filter((t) => t.startsWith(CIMPLIFY_TAG_PREFIX));
18
+ }
19
+ function pathIndexFor(env) {
20
+ const ns = env[PATH_INDEX_BINDING];
21
+ const prefix = env[R2_PREFIX_ENV];
22
+ if (!ns || !prefix) return null;
23
+ return ns.get(ns.idFromName(prefix));
24
+ }
25
+ var evictIncrementalCache = {
26
+ name: "cimplify-evict-r2-cache",
27
+ async get(key, cacheType) {
28
+ const env = getCloudflareContext().env;
29
+ const r2 = env[R2_BUCKET_BINDING];
30
+ if (!r2) return null;
31
+ try {
32
+ const obj = await r2.get(r2Key(env, key, cacheType));
33
+ if (!obj) return null;
34
+ return {
35
+ value: await obj.json(),
36
+ lastModified: obj.uploaded.getTime()
37
+ };
38
+ } catch {
39
+ return null;
40
+ }
41
+ },
42
+ async set(key, value, cacheType) {
43
+ const env = getCloudflareContext().env;
44
+ const r2 = env[R2_BUCKET_BINDING];
45
+ if (!r2) return;
46
+ const k = r2Key(env, key, cacheType);
47
+ try {
48
+ await r2.put(k, JSON.stringify(value));
49
+ } catch {
50
+ return;
51
+ }
52
+ const tags = cimplifyTags(value);
53
+ if (tags.length === 0) return;
54
+ const index = pathIndexFor(env);
55
+ if (!index) return;
56
+ try {
57
+ await index.indexAdd(key, k, tags, cacheType === "fetch");
58
+ } catch {
59
+ }
60
+ },
61
+ async delete(key) {
62
+ const env = getCloudflareContext().env;
63
+ const r2 = env[R2_BUCKET_BINDING];
64
+ if (!r2) return;
65
+ try {
66
+ await r2.delete(r2Key(env, key));
67
+ } catch {
68
+ }
69
+ }
70
+ };
71
+ var evict_incremental_cache_default = evictIncrementalCache;
72
+
73
+ export { evict_incremental_cache_default as evictIncrementalCache };
package/dist/server.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { C as CimplifyClient } from './client-CF2pmEE9.mjs';
2
- export { d as CacheOptions, b as ReadRequestOptions, aQ as Result } from './client-CF2pmEE9.mjs';
3
- import { IncrementalCache } from '@opennextjs/aws/types/overrides';
1
+ import { C as CimplifyClient } from './client-C6J_RGlr.mjs';
2
+ export { aO as Result } from './client-C6J_RGlr.mjs';
4
3
  export { ap as Category, h as CimplifyError, ar as Collection, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.mjs';
5
4
  import './payment-9L_-GWqQ.mjs';
6
5
 
@@ -28,17 +27,9 @@ interface ServerClientOptions {
28
27
  *
29
28
  * The returned client is the exact same surface the browser uses — every
30
29
  * resource (catalogue, cart, checkout, …) and every method works identically.
31
- *
32
- * Caching is Next.js's responsibility. Pass `cacheOptions` per read method
33
- * (`{ revalidate, tags }`); the SDK forwards them as `next: { revalidate, tags }`
34
- * on the underlying fetch — Next 16's documented ISR API. Invalidate via the
35
- * `revalidate*` helpers (also exported from this entry) or the bare
36
- * `revalidateTag` / `revalidatePath` from `next/cache`.
37
- *
38
- * If you have `cacheComponents: true` in `next.config.ts` (Next 16 PPR-style
39
- * caching), the `'use cache'` + `cacheTag` / `cacheLife` directives work too —
40
- * but they require a Node-compatible runtime and won't function on Cloudflare
41
- * Workers. For Workers / WfP storefronts, stay on the ISR (`cacheOptions`) path.
30
+ * Caching is Next.js's responsibility: wrap your composed reads with
31
+ * `'use cache'` + `cacheTag` (using the tag builders from `@cimplify/sdk/server`),
32
+ * or set `next: { revalidate, tags }` on individual fetches.
42
33
  *
43
34
  * Errors continue to flow through `Result<T, CimplifyError>`. Use the SDK's
44
35
  * `unwrap()` helper, or `if (!result.ok) notFound()` — whichever is
@@ -46,13 +37,13 @@ interface ServerClientOptions {
46
37
  *
47
38
  * @example
48
39
  * import { getServerClient, tags } from "@cimplify/sdk/server";
49
- *
50
- * export const revalidate = 3600;
40
+ * import { cacheTag, cacheLife } from "next/cache";
51
41
  *
52
42
  * async function getProduct(slug: string) {
53
- * const r = await getServerClient().catalogue.getProductBySlug(slug, {
54
- * cacheOptions: { revalidate: 3600, tags: [tags.product(slug)] },
55
- * });
43
+ * "use cache";
44
+ * cacheTag(tags.product(slug));
45
+ * cacheLife("hours");
46
+ * const r = await getServerClient().catalogue.getProductBySlug(slug);
56
47
  * if (!r.ok) throw new Error(r.error.message);
57
48
  * return r.value;
58
49
  * }
@@ -145,34 +136,6 @@ type CacheLifeDefault = typeof CACHE_LIFE_DEFAULT;
145
136
  /** The TS type of {@link CACHE_LIFE_PROBE} — the `"seconds"` literal. */
146
137
  type CacheLifeProbe = typeof CACHE_LIFE_PROBE;
147
138
 
148
- /**
149
- * Cimplify incremental-cache override for Workers for Platforms storefronts.
150
- *
151
- * Replaces opennext's stale-while-revalidate model with an evict-on-invalidate
152
- * model that fits Cimplify's event-driven domain:
153
- *
154
- * - `get`: standard R2 fetch. Returns the cached value or null.
155
- * - `set`: writes to R2 AND emits a tag→cache_key index update to the shared
156
- * `CIMPLIFY_PATH_INDEX` Durable Object (hosted in cimplify-tag-cache).
157
- * - `delete`: standard R2 delete (called by opennext on explicit invalidate;
158
- * also called by us from the Rust EvictionDispatcher path on tag events).
159
- *
160
- * The Rust EvictionDispatcher reads the index on bus events, deletes the
161
- * matching R2 entries directly, and prunes the index — there is no SWR
162
- * "background refresh" path. opennext's queue and `isStale` checks become
163
- * no-ops; cached entries are by definition fresh (existed at write time and
164
- * haven't been evicted), and absence means the next request synchronously
165
- * re-renders.
166
- *
167
- * Why this exists: WfP user workers cannot have `WORKER_SELF_REFERENCE`,
168
- * which is the binding every built-in opennext queue requires. Rather than
169
- * recreate SWR via self-fetch tricks, we drop SWR for our domain — Cimplify
170
- * always knows when data changes (every catalog mutation flows through the
171
- * bus), so timer-based refresh adds no value.
172
- */
173
-
174
- declare const evictIncrementalCache: IncrementalCache;
175
-
176
139
  /** Next 16 cacheLife profile — a built-in name (`'max'`/`'hours'`/…) or `{expire: secs}`. */
177
140
  type RevalidateProfile$1 = string | {
178
141
  expire: number;
@@ -230,4 +193,4 @@ interface RevalidateRouteOptions {
230
193
  }
231
194
  declare function revalidateRouteHandler(req: Request, options?: RevalidateRouteOptions): Promise<Response>;
232
195
 
233
- export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, evictIncrementalCache, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
196
+ export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
package/dist/server.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { C as CimplifyClient } from './client-B6x53-Al.js';
2
- export { d as CacheOptions, b as ReadRequestOptions, aQ as Result } from './client-B6x53-Al.js';
3
- import { IncrementalCache } from '@opennextjs/aws/types/overrides';
1
+ import { C as CimplifyClient } from './client-CX7IFIkL.js';
2
+ export { aO as Result } from './client-CX7IFIkL.js';
4
3
  export { ap as Category, h as CimplifyError, ar as Collection, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.js';
5
4
  import './payment-_e99nSRj.js';
6
5
 
@@ -28,17 +27,9 @@ interface ServerClientOptions {
28
27
  *
29
28
  * The returned client is the exact same surface the browser uses — every
30
29
  * resource (catalogue, cart, checkout, …) and every method works identically.
31
- *
32
- * Caching is Next.js's responsibility. Pass `cacheOptions` per read method
33
- * (`{ revalidate, tags }`); the SDK forwards them as `next: { revalidate, tags }`
34
- * on the underlying fetch — Next 16's documented ISR API. Invalidate via the
35
- * `revalidate*` helpers (also exported from this entry) or the bare
36
- * `revalidateTag` / `revalidatePath` from `next/cache`.
37
- *
38
- * If you have `cacheComponents: true` in `next.config.ts` (Next 16 PPR-style
39
- * caching), the `'use cache'` + `cacheTag` / `cacheLife` directives work too —
40
- * but they require a Node-compatible runtime and won't function on Cloudflare
41
- * Workers. For Workers / WfP storefronts, stay on the ISR (`cacheOptions`) path.
30
+ * Caching is Next.js's responsibility: wrap your composed reads with
31
+ * `'use cache'` + `cacheTag` (using the tag builders from `@cimplify/sdk/server`),
32
+ * or set `next: { revalidate, tags }` on individual fetches.
42
33
  *
43
34
  * Errors continue to flow through `Result<T, CimplifyError>`. Use the SDK's
44
35
  * `unwrap()` helper, or `if (!result.ok) notFound()` — whichever is
@@ -46,13 +37,13 @@ interface ServerClientOptions {
46
37
  *
47
38
  * @example
48
39
  * import { getServerClient, tags } from "@cimplify/sdk/server";
49
- *
50
- * export const revalidate = 3600;
40
+ * import { cacheTag, cacheLife } from "next/cache";
51
41
  *
52
42
  * async function getProduct(slug: string) {
53
- * const r = await getServerClient().catalogue.getProductBySlug(slug, {
54
- * cacheOptions: { revalidate: 3600, tags: [tags.product(slug)] },
55
- * });
43
+ * "use cache";
44
+ * cacheTag(tags.product(slug));
45
+ * cacheLife("hours");
46
+ * const r = await getServerClient().catalogue.getProductBySlug(slug);
56
47
  * if (!r.ok) throw new Error(r.error.message);
57
48
  * return r.value;
58
49
  * }
@@ -145,34 +136,6 @@ type CacheLifeDefault = typeof CACHE_LIFE_DEFAULT;
145
136
  /** The TS type of {@link CACHE_LIFE_PROBE} — the `"seconds"` literal. */
146
137
  type CacheLifeProbe = typeof CACHE_LIFE_PROBE;
147
138
 
148
- /**
149
- * Cimplify incremental-cache override for Workers for Platforms storefronts.
150
- *
151
- * Replaces opennext's stale-while-revalidate model with an evict-on-invalidate
152
- * model that fits Cimplify's event-driven domain:
153
- *
154
- * - `get`: standard R2 fetch. Returns the cached value or null.
155
- * - `set`: writes to R2 AND emits a tag→cache_key index update to the shared
156
- * `CIMPLIFY_PATH_INDEX` Durable Object (hosted in cimplify-tag-cache).
157
- * - `delete`: standard R2 delete (called by opennext on explicit invalidate;
158
- * also called by us from the Rust EvictionDispatcher path on tag events).
159
- *
160
- * The Rust EvictionDispatcher reads the index on bus events, deletes the
161
- * matching R2 entries directly, and prunes the index — there is no SWR
162
- * "background refresh" path. opennext's queue and `isStale` checks become
163
- * no-ops; cached entries are by definition fresh (existed at write time and
164
- * haven't been evicted), and absence means the next request synchronously
165
- * re-renders.
166
- *
167
- * Why this exists: WfP user workers cannot have `WORKER_SELF_REFERENCE`,
168
- * which is the binding every built-in opennext queue requires. Rather than
169
- * recreate SWR via self-fetch tricks, we drop SWR for our domain — Cimplify
170
- * always knows when data changes (every catalog mutation flows through the
171
- * bus), so timer-based refresh adds no value.
172
- */
173
-
174
- declare const evictIncrementalCache: IncrementalCache;
175
-
176
139
  /** Next 16 cacheLife profile — a built-in name (`'max'`/`'hours'`/…) or `{expire: secs}`. */
177
140
  type RevalidateProfile$1 = string | {
178
141
  expire: number;
@@ -230,4 +193,4 @@ interface RevalidateRouteOptions {
230
193
  }
231
194
  declare function revalidateRouteHandler(req: Request, options?: RevalidateRouteOptions): Promise<Response>;
232
195
 
233
- export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, evictIncrementalCache, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
196
+ export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
package/dist/server.js CHANGED
@@ -1,12 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkFJQC4VSN_js = require('./chunk-FJQC4VSN.js');
4
- require('./chunk-VOWMB2KR.js');
5
- require('./chunk-6RP6OPYO.js');
6
- var chunkTKOTACKZ_js = require('./chunk-TKOTACKZ.js');
3
+ var chunkW6CCBNGL_js = require('./chunk-W6CCBNGL.js');
4
+ require('./chunk-EQLT46ZR.js');
5
+ require('./chunk-7Y2O3E4D.js');
6
+ var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
7
+ require('./chunk-OWW5GUSB.js');
7
8
  var react = require('react');
8
- var internal = require('@opennextjs/cloudflare/overrides/internal');
9
- var cloudflareContext = require('@opennextjs/cloudflare/cloudflare-context');
10
9
 
11
10
  var DEFAULT_PROD_URL = "https://storefronts.cimplify.io";
12
11
  var DEFAULT_DEV_URL = "http://127.0.0.1:8787";
@@ -26,7 +25,7 @@ function readEnv(...keys) {
26
25
  var getServerClient = react.cache((opts = {}) => {
27
26
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
28
27
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
29
- const client = chunkFJQC4VSN_js.createCimplifyClient({
28
+ const client = chunkW6CCBNGL_js.createCimplifyClient({
30
29
  baseUrl,
31
30
  publicKey,
32
31
  suppressPublicKeyWarning: true
@@ -68,73 +67,6 @@ var tags = {
68
67
  // src/server/cache-life.ts
69
68
  var CACHE_LIFE_DEFAULT = "max";
70
69
  var CACHE_LIFE_PROBE = "seconds";
71
- var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
72
- var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
73
- var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
74
- var CIMPLIFY_TAG_PREFIX = "cimplify:";
75
- function r2Key(env, key, cacheType) {
76
- return internal.computeCacheKey(key, {
77
- prefix: env[R2_PREFIX_ENV],
78
- buildId: globalThis.process?.env?.OPEN_NEXT_BUILD_ID,
79
- cacheType
80
- });
81
- }
82
- function cimplifyTags(value) {
83
- return (value?.tags ?? []).filter((t) => t.startsWith(CIMPLIFY_TAG_PREFIX));
84
- }
85
- function pathIndexFor(env) {
86
- const ns = env[PATH_INDEX_BINDING];
87
- const prefix = env[R2_PREFIX_ENV];
88
- if (!ns || !prefix) return null;
89
- return ns.get(ns.idFromName(prefix));
90
- }
91
- var evictIncrementalCache = {
92
- name: "cimplify-evict-r2-cache",
93
- async get(key, cacheType) {
94
- const env = cloudflareContext.getCloudflareContext().env;
95
- const r2 = env[R2_BUCKET_BINDING];
96
- if (!r2) return null;
97
- try {
98
- const obj = await r2.get(r2Key(env, key, cacheType));
99
- if (!obj) return null;
100
- return {
101
- value: await obj.json(),
102
- lastModified: obj.uploaded.getTime()
103
- };
104
- } catch {
105
- return null;
106
- }
107
- },
108
- async set(key, value, cacheType) {
109
- const env = cloudflareContext.getCloudflareContext().env;
110
- const r2 = env[R2_BUCKET_BINDING];
111
- if (!r2) return;
112
- const k = r2Key(env, key, cacheType);
113
- try {
114
- await r2.put(k, JSON.stringify(value));
115
- } catch {
116
- return;
117
- }
118
- const tags2 = cimplifyTags(value);
119
- if (tags2.length === 0) return;
120
- const index = pathIndexFor(env);
121
- if (!index) return;
122
- try {
123
- await index.indexAdd(key, k, tags2, cacheType === "fetch");
124
- } catch {
125
- }
126
- },
127
- async delete(key) {
128
- const env = cloudflareContext.getCloudflareContext().env;
129
- const r2 = env[R2_BUCKET_BINDING];
130
- if (!r2) return;
131
- try {
132
- await r2.delete(r2Key(env, key));
133
- } catch {
134
- }
135
- }
136
- };
137
- var evict_incremental_cache_default = evictIncrementalCache;
138
70
 
139
71
  // src/server/revalidate.ts
140
72
  var DEFAULT_PROFILE = CACHE_LIFE_DEFAULT;
@@ -389,11 +321,10 @@ function text(message, status) {
389
321
 
390
322
  Object.defineProperty(exports, "CimplifyError", {
391
323
  enumerable: true,
392
- get: function () { return chunkTKOTACKZ_js.CimplifyError; }
324
+ get: function () { return chunkXA3ZNR75_js.CimplifyError; }
393
325
  });
394
326
  exports.CACHE_LIFE_DEFAULT = CACHE_LIFE_DEFAULT;
395
327
  exports.CACHE_LIFE_PROBE = CACHE_LIFE_PROBE;
396
- exports.evictIncrementalCache = evict_incremental_cache_default;
397
328
  exports.getServerClient = getServerClient;
398
329
  exports.refreshPage = refreshPage;
399
330
  exports.revalidateAddOn = revalidateAddOn;
package/dist/server.mjs CHANGED
@@ -1,10 +1,9 @@
1
- import { createCimplifyClient } from './chunk-GUZXQSGI.mjs';
2
- import './chunk-FXACV333.mjs';
3
- import './chunk-XY2DFX5K.mjs';
4
- export { CimplifyError } from './chunk-Z2AYLZDF.mjs';
1
+ import { createCimplifyClient } from './chunk-4QDCMYYB.mjs';
2
+ import './chunk-GLAVTDDE.mjs';
3
+ import './chunk-TD3AY34U.mjs';
4
+ export { CimplifyError } from './chunk-AMZXALF6.mjs';
5
+ import './chunk-3G6RQLXK.mjs';
5
6
  import { cache } from 'react';
6
- import { computeCacheKey } from '@opennextjs/cloudflare/overrides/internal';
7
- import { getCloudflareContext } from '@opennextjs/cloudflare/cloudflare-context';
8
7
 
9
8
  var DEFAULT_PROD_URL = "https://storefronts.cimplify.io";
10
9
  var DEFAULT_DEV_URL = "http://127.0.0.1:8787";
@@ -66,73 +65,6 @@ var tags = {
66
65
  // src/server/cache-life.ts
67
66
  var CACHE_LIFE_DEFAULT = "max";
68
67
  var CACHE_LIFE_PROBE = "seconds";
69
- var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
70
- var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
71
- var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
72
- var CIMPLIFY_TAG_PREFIX = "cimplify:";
73
- function r2Key(env, key, cacheType) {
74
- return computeCacheKey(key, {
75
- prefix: env[R2_PREFIX_ENV],
76
- buildId: globalThis.process?.env?.OPEN_NEXT_BUILD_ID,
77
- cacheType
78
- });
79
- }
80
- function cimplifyTags(value) {
81
- return (value?.tags ?? []).filter((t) => t.startsWith(CIMPLIFY_TAG_PREFIX));
82
- }
83
- function pathIndexFor(env) {
84
- const ns = env[PATH_INDEX_BINDING];
85
- const prefix = env[R2_PREFIX_ENV];
86
- if (!ns || !prefix) return null;
87
- return ns.get(ns.idFromName(prefix));
88
- }
89
- var evictIncrementalCache = {
90
- name: "cimplify-evict-r2-cache",
91
- async get(key, cacheType) {
92
- const env = getCloudflareContext().env;
93
- const r2 = env[R2_BUCKET_BINDING];
94
- if (!r2) return null;
95
- try {
96
- const obj = await r2.get(r2Key(env, key, cacheType));
97
- if (!obj) return null;
98
- return {
99
- value: await obj.json(),
100
- lastModified: obj.uploaded.getTime()
101
- };
102
- } catch {
103
- return null;
104
- }
105
- },
106
- async set(key, value, cacheType) {
107
- const env = getCloudflareContext().env;
108
- const r2 = env[R2_BUCKET_BINDING];
109
- if (!r2) return;
110
- const k = r2Key(env, key, cacheType);
111
- try {
112
- await r2.put(k, JSON.stringify(value));
113
- } catch {
114
- return;
115
- }
116
- const tags2 = cimplifyTags(value);
117
- if (tags2.length === 0) return;
118
- const index = pathIndexFor(env);
119
- if (!index) return;
120
- try {
121
- await index.indexAdd(key, k, tags2, cacheType === "fetch");
122
- } catch {
123
- }
124
- },
125
- async delete(key) {
126
- const env = getCloudflareContext().env;
127
- const r2 = env[R2_BUCKET_BINDING];
128
- if (!r2) return;
129
- try {
130
- await r2.delete(r2Key(env, key));
131
- } catch {
132
- }
133
- }
134
- };
135
- var evict_incremental_cache_default = evictIncrementalCache;
136
68
 
137
69
  // src/server/revalidate.ts
138
70
  var DEFAULT_PROFILE = CACHE_LIFE_DEFAULT;
@@ -385,4 +317,4 @@ function text(message, status) {
385
317
  return new Response(message, { status, headers: { "content-type": "text/plain" } });
386
318
  }
387
319
 
388
- export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, evict_incremental_cache_default as evictIncrementalCache, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
320
+ export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkGEWFWQYK_js = require('../chunk-GEWFWQYK.js');
4
- require('../chunk-TKOTACKZ.js');
3
+ var chunkQ5VGDCQF_js = require('../chunk-Q5VGDCQF.js');
4
+ require('../chunk-XA3ZNR75.js');
5
+ require('../chunk-OWW5GUSB.js');
5
6
 
6
7
  // src/mock/msw.ts
7
8
  async function createMswHandlers(options = {}) {
8
9
  const baseUrl = options.baseUrl ?? "http://localhost:8787";
9
- const handle = chunkGEWFWQYK_js.createMockApp(options);
10
+ const handle = chunkQ5VGDCQF_js.createMockApp(options);
10
11
  const msw = await import('msw').catch(() => {
11
12
  throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
12
13
  });
@@ -1,5 +1,6 @@
1
- import { createMockApp } from '../chunk-632JEJUS.mjs';
2
- import '../chunk-Z2AYLZDF.mjs';
1
+ import { createMockApp } from '../chunk-R3F55BRN.mjs';
2
+ import '../chunk-AMZXALF6.mjs';
3
+ import '../chunk-3G6RQLXK.mjs';
3
4
 
4
5
  // src/mock/msw.ts
5
6
  async function createMswHandlers(options = {}) {
@@ -1,8 +1,8 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-BbrCopIS.mjs';
2
+ import { T as TestClientHandle } from '../client-DdefKjcs.mjs';
3
3
  import { C as CreateAppOptions } from '../server-BgccqOLT.mjs';
4
4
  export { S as SeedName } from '../server-BgccqOLT.mjs';
5
- import '../client-CF2pmEE9.mjs';
5
+ import '../client-C6J_RGlr.mjs';
6
6
  import '../product-C-xLzh7Q.mjs';
7
7
  import '../payment-9L_-GWqQ.mjs';
8
8
  import 'hono';
@@ -1,8 +1,8 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-BvEjhvwq.js';
2
+ import { T as TestClientHandle } from '../client-Lt7uGLmT.js';
3
3
  import { C as CreateAppOptions } from '../server-72rzvJ4Y.js';
4
4
  export { S as SeedName } from '../server-72rzvJ4Y.js';
5
- import '../client-B6x53-Al.js';
5
+ import '../client-CX7IFIkL.js';
6
6
  import '../product-C-xLzh7Q.js';
7
7
  import '../payment-_e99nSRj.js';
8
8
  import 'hono';