@cimplify/sdk 0.70.2 → 0.71.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.
Files changed (52) hide show
  1. package/dist/advanced.d.mts +1 -1
  2. package/dist/advanced.d.ts +1 -1
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{chunk-M2CXZQHS.mjs → chunk-3BKMNVTR.mjs} +2 -1
  6. package/dist/{chunk-6XXVA3IV.mjs → chunk-BYWJSPT4.mjs} +2 -2
  7. package/dist/{chunk-BCWPRPK7.js → chunk-CV5QMDQS.js} +2 -1
  8. package/dist/{chunk-EAVXSFAB.mjs → chunk-H337NF4O.mjs} +1 -1
  9. package/dist/{chunk-O3ECKVOM.mjs → chunk-J7L5LHGK.mjs} +30 -11
  10. package/dist/{chunk-I4MP2XZS.js → chunk-OGQFDCZM.js} +30 -11
  11. package/dist/{chunk-QZQEGRGB.js → chunk-QS4XDVHI.js} +35 -35
  12. package/dist/{chunk-SC5DUKGD.js → chunk-Y64AIRGW.js} +4 -4
  13. package/dist/{client-Des_GqmQ.d.ts → client-BvqaIlJ0.d.ts} +2 -2
  14. package/dist/{client-DRJvXz54.d.mts → client-C7EMuGoz.d.mts} +9 -7
  15. package/dist/{client-DjQhg6yr.d.ts → client-D6CZ2Ggp.d.ts} +9 -7
  16. package/dist/{client-BRGGjeny.d.mts → client-DWA_XIh3.d.mts} +2 -2
  17. package/dist/index.d.mts +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +68 -68
  20. package/dist/index.mjs +3 -3
  21. package/dist/mock/cli.mjs +30 -11
  22. package/dist/mock/library.js +30 -11
  23. package/dist/mock/library.mjs +30 -11
  24. package/dist/mock/msw.js +30 -11
  25. package/dist/mock/msw.mjs +30 -11
  26. package/dist/react.d.mts +1 -1
  27. package/dist/react.d.ts +1 -1
  28. package/dist/react.js +16 -16
  29. package/dist/react.mjs +2 -2
  30. package/dist/server/tanstack.d.mts +74 -0
  31. package/dist/server/tanstack.d.ts +74 -0
  32. package/dist/server/tanstack.js +291 -0
  33. package/dist/server/tanstack.mjs +279 -0
  34. package/dist/{server-D8rwqZQ6.d.mts → server-DDQ1O3XR.d.mts} +4 -1
  35. package/dist/{server-BQzz921M.d.ts → server-DMvQp27Z.d.ts} +4 -1
  36. package/dist/server.d.mts +2 -2
  37. package/dist/server.d.ts +2 -2
  38. package/dist/server.js +7 -7
  39. package/dist/server.mjs +2 -2
  40. package/dist/testing/msw.d.mts +1 -1
  41. package/dist/testing/msw.d.ts +1 -1
  42. package/dist/testing/msw.js +2 -2
  43. package/dist/testing/msw.mjs +1 -1
  44. package/dist/testing/suite.d.mts +4 -4
  45. package/dist/testing/suite.d.ts +4 -4
  46. package/dist/testing/suite.js +23 -23
  47. package/dist/testing/suite.mjs +4 -4
  48. package/dist/testing.d.mts +18 -18
  49. package/dist/testing.d.ts +18 -18
  50. package/dist/testing.js +79 -79
  51. package/dist/testing.mjs +5 -5
  52. package/package.json +7 -1
@@ -0,0 +1,291 @@
1
+ 'use strict';
2
+
3
+ require('../chunk-OWW5GUSB.js');
4
+
5
+ // src/server/tanstack.ts
6
+ var TANSTACK_R2_BUCKET_BINDING = "CIMPLIFY_CACHE_R2_BUCKET";
7
+ var TANSTACK_R2_PREFIX_ENV = "CIMPLIFY_CACHE_R2_PREFIX";
8
+ var TANSTACK_PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
9
+ var TANSTACK_CACHE_NAMESPACE = "nitro";
10
+ var CIMPLIFY_TAG_PREFIX = "cimplify:";
11
+ var CIMPLIFY_CACHE_META_FIELD = "__cimplifyCache";
12
+ var EMPTY_STORAGE_KEY = "__cimplify_empty_key__";
13
+ function isRecord(value) {
14
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15
+ }
16
+ function stringArray(value) {
17
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
18
+ }
19
+ function metadataFrom(value) {
20
+ if (!isRecord(value)) return void 0;
21
+ const metadata = value[CIMPLIFY_CACHE_META_FIELD];
22
+ return isRecord(metadata) ? metadata : void 0;
23
+ }
24
+ function cimplifyTagsFrom(candidates) {
25
+ const seen = /* @__PURE__ */ new Set();
26
+ for (const candidate of candidates) {
27
+ for (const tag of candidate ?? []) {
28
+ if (!tag.startsWith(CIMPLIFY_TAG_PREFIX) || seen.has(tag)) continue;
29
+ seen.add(tag);
30
+ }
31
+ }
32
+ return [...seen];
33
+ }
34
+ function extractTags(key, value, options, driverOptions) {
35
+ const optionMeta = metadataFrom(options);
36
+ const valueMeta = metadataFrom(value);
37
+ const valueRecord = isRecord(value) ? value : void 0;
38
+ const nestedValue = isRecord(valueRecord?.value) ? valueRecord.value : void 0;
39
+ const configured = typeof driverOptions.tags === "function" ? driverOptions.tags(key, value, options) : driverOptions.tags;
40
+ return cimplifyTagsFrom([
41
+ configured,
42
+ optionMeta?.tags,
43
+ options?.tags,
44
+ options?.cimplifyTags,
45
+ options?.cacheTags,
46
+ valueMeta?.tags,
47
+ stringArray(valueRecord?.tags),
48
+ stringArray(valueRecord?.cimplifyTags),
49
+ stringArray(valueRecord?.cacheTags),
50
+ stringArray(nestedValue?.tags),
51
+ stringArray(nestedValue?.cimplifyTags),
52
+ stringArray(nestedValue?.cacheTags)
53
+ ]);
54
+ }
55
+ function extractCacheKey(key, value, options, driverOptions) {
56
+ const configured = typeof driverOptions.cacheKey === "function" ? driverOptions.cacheKey(key, value, options) : driverOptions.cacheKey;
57
+ if (configured) return configured;
58
+ const optionMeta = metadataFrom(options);
59
+ const valueMeta = metadataFrom(value);
60
+ if (optionMeta?.cacheKey) return optionMeta.cacheKey;
61
+ if (options?.cacheKey) return options.cacheKey;
62
+ if (options?.cimplifyCacheKey) return options.cimplifyCacheKey;
63
+ if (valueMeta?.cacheKey) return valueMeta.cacheKey;
64
+ return key;
65
+ }
66
+ function extractIsFetch(key, value, options, driverOptions) {
67
+ if (typeof driverOptions.isFetch === "function") {
68
+ return driverOptions.isFetch(key, value, options);
69
+ }
70
+ if (typeof driverOptions.isFetch === "boolean") return driverOptions.isFetch;
71
+ const optionMeta = metadataFrom(options);
72
+ const valueMeta = metadataFrom(value);
73
+ return Boolean(
74
+ optionMeta?.isFetch ?? options?.isFetch ?? options?.cimplifyIsFetch ?? valueMeta?.isFetch ?? false
75
+ );
76
+ }
77
+ function valueForStorage(value) {
78
+ if (!isRecord(value) || !(CIMPLIFY_CACHE_META_FIELD in value)) return value;
79
+ const { [CIMPLIFY_CACHE_META_FIELD]: _metadata, ...rest } = value;
80
+ return rest;
81
+ }
82
+ function joinR2Parts(...parts) {
83
+ return parts.map((part) => part.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
84
+ }
85
+ function encodeStorageKey(key) {
86
+ return key === "" ? EMPTY_STORAGE_KEY : encodeURIComponent(key);
87
+ }
88
+ function decodeStorageKey(key) {
89
+ if (key === EMPTY_STORAGE_KEY) return "";
90
+ try {
91
+ return decodeURIComponent(key);
92
+ } catch {
93
+ return key;
94
+ }
95
+ }
96
+ function cimplifyTanstackR2Key(prefix, key, namespace = TANSTACK_CACHE_NAMESPACE) {
97
+ return joinR2Parts(prefix, namespace, encodeStorageKey(key));
98
+ }
99
+ function cimplifyTanstackR2ListPrefix(prefix, base, namespace) {
100
+ if (!base) return `${joinR2Parts(prefix, namespace)}/`;
101
+ return cimplifyTanstackR2Key(prefix, base, namespace);
102
+ }
103
+ function storageKeyFromR2Key(prefix, namespace, key) {
104
+ const base = `${joinR2Parts(prefix, namespace)}/`;
105
+ const encoded = key.startsWith(base) ? key.slice(base.length) : key;
106
+ return decodeStorageKey(encoded);
107
+ }
108
+ function pathIndexFor(env) {
109
+ if (!env.pathIndex) return null;
110
+ return env.pathIndex.get(env.pathIndex.idFromName(env.prefix));
111
+ }
112
+ async function resolveRuntimeEnv(options) {
113
+ const env = await options.getEnv?.() ?? options.env;
114
+ const r2 = env?.[TANSTACK_R2_BUCKET_BINDING];
115
+ const prefix = options.prefix ?? env?.[TANSTACK_R2_PREFIX_ENV];
116
+ if (!r2 || !prefix) return null;
117
+ return {
118
+ r2,
119
+ prefix,
120
+ pathIndex: env?.[TANSTACK_PATH_INDEX_BINDING]
121
+ };
122
+ }
123
+ async function registerIndex(env, cacheKey, r2Key, tags, isFetch) {
124
+ if (tags.length === 0) return;
125
+ const index = pathIndexFor(env);
126
+ if (!index) return;
127
+ try {
128
+ await index.indexAdd(cacheKey, r2Key, tags, isFetch);
129
+ } catch {
130
+ }
131
+ }
132
+ async function listR2Keys(r2, prefix) {
133
+ const keys = [];
134
+ let cursor;
135
+ do {
136
+ const page = await r2.list({ prefix, cursor });
137
+ keys.push(...page.objects.map((object) => object.key));
138
+ cursor = page.truncated ? page.cursor : void 0;
139
+ } while (cursor);
140
+ return keys;
141
+ }
142
+ async function putAndIndex(runtimeEnv, driverOptions, key, storedValue, indexValue, options) {
143
+ const namespace = driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE;
144
+ const r2Key = cimplifyTanstackR2Key(runtimeEnv.prefix, key, namespace);
145
+ try {
146
+ await runtimeEnv.r2.put(r2Key, storedValue);
147
+ } catch {
148
+ return;
149
+ }
150
+ try {
151
+ const tags = extractTags(key, indexValue, options, driverOptions);
152
+ if (tags.length === 0) return;
153
+ await registerIndex(
154
+ runtimeEnv,
155
+ extractCacheKey(key, indexValue, options, driverOptions),
156
+ r2Key,
157
+ tags,
158
+ extractIsFetch(key, indexValue, options, driverOptions)
159
+ );
160
+ } catch {
161
+ }
162
+ }
163
+ async function getRawItem(driverOptions, key) {
164
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
165
+ if (!runtimeEnv) return null;
166
+ try {
167
+ const object = await runtimeEnv.r2.get(
168
+ cimplifyTanstackR2Key(
169
+ runtimeEnv.prefix,
170
+ key,
171
+ driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE
172
+ )
173
+ );
174
+ return object ? await object.text() : null;
175
+ } catch {
176
+ return null;
177
+ }
178
+ }
179
+ function cimplifyTanstackCacheOptions(metadata) {
180
+ return { [CIMPLIFY_CACHE_META_FIELD]: metadata };
181
+ }
182
+ function withCimplifyCacheMetadata(value, metadata) {
183
+ return { ...value, [CIMPLIFY_CACHE_META_FIELD]: metadata };
184
+ }
185
+ function createCimplifyTanstackCacheDriver(options = {}) {
186
+ const driverOptions = { ...options };
187
+ return {
188
+ name: "cimplify-tanstack-r2-cache",
189
+ options: driverOptions,
190
+ async hasItem(key) {
191
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
192
+ if (!runtimeEnv) return false;
193
+ try {
194
+ const object = await runtimeEnv.r2.head(
195
+ cimplifyTanstackR2Key(
196
+ runtimeEnv.prefix,
197
+ key,
198
+ driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE
199
+ )
200
+ );
201
+ return Boolean(object);
202
+ } catch {
203
+ return false;
204
+ }
205
+ },
206
+ async getItem(key) {
207
+ const raw = await getRawItem(driverOptions, key);
208
+ if (raw === null) return null;
209
+ try {
210
+ return JSON.parse(raw);
211
+ } catch {
212
+ return raw;
213
+ }
214
+ },
215
+ async getItemRaw(key) {
216
+ return getRawItem(driverOptions, key);
217
+ },
218
+ async setItem(key, value, options2) {
219
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
220
+ if (!runtimeEnv) return;
221
+ const strippedValue = valueForStorage(value);
222
+ await putAndIndex(
223
+ runtimeEnv,
224
+ driverOptions,
225
+ key,
226
+ JSON.stringify(strippedValue) ?? "null",
227
+ value,
228
+ options2
229
+ );
230
+ },
231
+ async setItemRaw(key, value, options2) {
232
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
233
+ if (!runtimeEnv) return;
234
+ await putAndIndex(runtimeEnv, driverOptions, key, value, value, options2);
235
+ },
236
+ async removeItem(key) {
237
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
238
+ if (!runtimeEnv) return;
239
+ try {
240
+ await runtimeEnv.r2.delete(
241
+ cimplifyTanstackR2Key(
242
+ runtimeEnv.prefix,
243
+ key,
244
+ driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE
245
+ )
246
+ );
247
+ } catch {
248
+ }
249
+ },
250
+ async getKeys(base) {
251
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
252
+ if (!runtimeEnv) return [];
253
+ const namespace = driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE;
254
+ try {
255
+ const keys = await listR2Keys(
256
+ runtimeEnv.r2,
257
+ cimplifyTanstackR2ListPrefix(runtimeEnv.prefix, base, namespace)
258
+ );
259
+ return keys.map((key) => storageKeyFromR2Key(runtimeEnv.prefix, namespace, key));
260
+ } catch {
261
+ return [];
262
+ }
263
+ },
264
+ async clear(base) {
265
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
266
+ if (!runtimeEnv) return;
267
+ const namespace = driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE;
268
+ try {
269
+ const keys = await listR2Keys(
270
+ runtimeEnv.r2,
271
+ cimplifyTanstackR2ListPrefix(runtimeEnv.prefix, base, namespace)
272
+ );
273
+ await Promise.all(keys.map((key) => runtimeEnv.r2.delete(key)));
274
+ } catch {
275
+ }
276
+ }
277
+ };
278
+ }
279
+ var cimplifyTanstackCacheDriver = createCimplifyTanstackCacheDriver;
280
+
281
+ exports.CIMPLIFY_CACHE_META_FIELD = CIMPLIFY_CACHE_META_FIELD;
282
+ exports.CIMPLIFY_TAG_PREFIX = CIMPLIFY_TAG_PREFIX;
283
+ exports.TANSTACK_CACHE_NAMESPACE = TANSTACK_CACHE_NAMESPACE;
284
+ exports.TANSTACK_PATH_INDEX_BINDING = TANSTACK_PATH_INDEX_BINDING;
285
+ exports.TANSTACK_R2_BUCKET_BINDING = TANSTACK_R2_BUCKET_BINDING;
286
+ exports.TANSTACK_R2_PREFIX_ENV = TANSTACK_R2_PREFIX_ENV;
287
+ exports.cimplifyTanstackCacheDriver = cimplifyTanstackCacheDriver;
288
+ exports.cimplifyTanstackCacheOptions = cimplifyTanstackCacheOptions;
289
+ exports.cimplifyTanstackR2Key = cimplifyTanstackR2Key;
290
+ exports.createCimplifyTanstackCacheDriver = createCimplifyTanstackCacheDriver;
291
+ exports.withCimplifyCacheMetadata = withCimplifyCacheMetadata;
@@ -0,0 +1,279 @@
1
+ import '../chunk-3G6RQLXK.mjs';
2
+
3
+ // src/server/tanstack.ts
4
+ var TANSTACK_R2_BUCKET_BINDING = "CIMPLIFY_CACHE_R2_BUCKET";
5
+ var TANSTACK_R2_PREFIX_ENV = "CIMPLIFY_CACHE_R2_PREFIX";
6
+ var TANSTACK_PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
7
+ var TANSTACK_CACHE_NAMESPACE = "nitro";
8
+ var CIMPLIFY_TAG_PREFIX = "cimplify:";
9
+ var CIMPLIFY_CACHE_META_FIELD = "__cimplifyCache";
10
+ var EMPTY_STORAGE_KEY = "__cimplify_empty_key__";
11
+ function isRecord(value) {
12
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13
+ }
14
+ function stringArray(value) {
15
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
16
+ }
17
+ function metadataFrom(value) {
18
+ if (!isRecord(value)) return void 0;
19
+ const metadata = value[CIMPLIFY_CACHE_META_FIELD];
20
+ return isRecord(metadata) ? metadata : void 0;
21
+ }
22
+ function cimplifyTagsFrom(candidates) {
23
+ const seen = /* @__PURE__ */ new Set();
24
+ for (const candidate of candidates) {
25
+ for (const tag of candidate ?? []) {
26
+ if (!tag.startsWith(CIMPLIFY_TAG_PREFIX) || seen.has(tag)) continue;
27
+ seen.add(tag);
28
+ }
29
+ }
30
+ return [...seen];
31
+ }
32
+ function extractTags(key, value, options, driverOptions) {
33
+ const optionMeta = metadataFrom(options);
34
+ const valueMeta = metadataFrom(value);
35
+ const valueRecord = isRecord(value) ? value : void 0;
36
+ const nestedValue = isRecord(valueRecord?.value) ? valueRecord.value : void 0;
37
+ const configured = typeof driverOptions.tags === "function" ? driverOptions.tags(key, value, options) : driverOptions.tags;
38
+ return cimplifyTagsFrom([
39
+ configured,
40
+ optionMeta?.tags,
41
+ options?.tags,
42
+ options?.cimplifyTags,
43
+ options?.cacheTags,
44
+ valueMeta?.tags,
45
+ stringArray(valueRecord?.tags),
46
+ stringArray(valueRecord?.cimplifyTags),
47
+ stringArray(valueRecord?.cacheTags),
48
+ stringArray(nestedValue?.tags),
49
+ stringArray(nestedValue?.cimplifyTags),
50
+ stringArray(nestedValue?.cacheTags)
51
+ ]);
52
+ }
53
+ function extractCacheKey(key, value, options, driverOptions) {
54
+ const configured = typeof driverOptions.cacheKey === "function" ? driverOptions.cacheKey(key, value, options) : driverOptions.cacheKey;
55
+ if (configured) return configured;
56
+ const optionMeta = metadataFrom(options);
57
+ const valueMeta = metadataFrom(value);
58
+ if (optionMeta?.cacheKey) return optionMeta.cacheKey;
59
+ if (options?.cacheKey) return options.cacheKey;
60
+ if (options?.cimplifyCacheKey) return options.cimplifyCacheKey;
61
+ if (valueMeta?.cacheKey) return valueMeta.cacheKey;
62
+ return key;
63
+ }
64
+ function extractIsFetch(key, value, options, driverOptions) {
65
+ if (typeof driverOptions.isFetch === "function") {
66
+ return driverOptions.isFetch(key, value, options);
67
+ }
68
+ if (typeof driverOptions.isFetch === "boolean") return driverOptions.isFetch;
69
+ const optionMeta = metadataFrom(options);
70
+ const valueMeta = metadataFrom(value);
71
+ return Boolean(
72
+ optionMeta?.isFetch ?? options?.isFetch ?? options?.cimplifyIsFetch ?? valueMeta?.isFetch ?? false
73
+ );
74
+ }
75
+ function valueForStorage(value) {
76
+ if (!isRecord(value) || !(CIMPLIFY_CACHE_META_FIELD in value)) return value;
77
+ const { [CIMPLIFY_CACHE_META_FIELD]: _metadata, ...rest } = value;
78
+ return rest;
79
+ }
80
+ function joinR2Parts(...parts) {
81
+ return parts.map((part) => part.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
82
+ }
83
+ function encodeStorageKey(key) {
84
+ return key === "" ? EMPTY_STORAGE_KEY : encodeURIComponent(key);
85
+ }
86
+ function decodeStorageKey(key) {
87
+ if (key === EMPTY_STORAGE_KEY) return "";
88
+ try {
89
+ return decodeURIComponent(key);
90
+ } catch {
91
+ return key;
92
+ }
93
+ }
94
+ function cimplifyTanstackR2Key(prefix, key, namespace = TANSTACK_CACHE_NAMESPACE) {
95
+ return joinR2Parts(prefix, namespace, encodeStorageKey(key));
96
+ }
97
+ function cimplifyTanstackR2ListPrefix(prefix, base, namespace) {
98
+ if (!base) return `${joinR2Parts(prefix, namespace)}/`;
99
+ return cimplifyTanstackR2Key(prefix, base, namespace);
100
+ }
101
+ function storageKeyFromR2Key(prefix, namespace, key) {
102
+ const base = `${joinR2Parts(prefix, namespace)}/`;
103
+ const encoded = key.startsWith(base) ? key.slice(base.length) : key;
104
+ return decodeStorageKey(encoded);
105
+ }
106
+ function pathIndexFor(env) {
107
+ if (!env.pathIndex) return null;
108
+ return env.pathIndex.get(env.pathIndex.idFromName(env.prefix));
109
+ }
110
+ async function resolveRuntimeEnv(options) {
111
+ const env = await options.getEnv?.() ?? options.env;
112
+ const r2 = env?.[TANSTACK_R2_BUCKET_BINDING];
113
+ const prefix = options.prefix ?? env?.[TANSTACK_R2_PREFIX_ENV];
114
+ if (!r2 || !prefix) return null;
115
+ return {
116
+ r2,
117
+ prefix,
118
+ pathIndex: env?.[TANSTACK_PATH_INDEX_BINDING]
119
+ };
120
+ }
121
+ async function registerIndex(env, cacheKey, r2Key, tags, isFetch) {
122
+ if (tags.length === 0) return;
123
+ const index = pathIndexFor(env);
124
+ if (!index) return;
125
+ try {
126
+ await index.indexAdd(cacheKey, r2Key, tags, isFetch);
127
+ } catch {
128
+ }
129
+ }
130
+ async function listR2Keys(r2, prefix) {
131
+ const keys = [];
132
+ let cursor;
133
+ do {
134
+ const page = await r2.list({ prefix, cursor });
135
+ keys.push(...page.objects.map((object) => object.key));
136
+ cursor = page.truncated ? page.cursor : void 0;
137
+ } while (cursor);
138
+ return keys;
139
+ }
140
+ async function putAndIndex(runtimeEnv, driverOptions, key, storedValue, indexValue, options) {
141
+ const namespace = driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE;
142
+ const r2Key = cimplifyTanstackR2Key(runtimeEnv.prefix, key, namespace);
143
+ try {
144
+ await runtimeEnv.r2.put(r2Key, storedValue);
145
+ } catch {
146
+ return;
147
+ }
148
+ try {
149
+ const tags = extractTags(key, indexValue, options, driverOptions);
150
+ if (tags.length === 0) return;
151
+ await registerIndex(
152
+ runtimeEnv,
153
+ extractCacheKey(key, indexValue, options, driverOptions),
154
+ r2Key,
155
+ tags,
156
+ extractIsFetch(key, indexValue, options, driverOptions)
157
+ );
158
+ } catch {
159
+ }
160
+ }
161
+ async function getRawItem(driverOptions, key) {
162
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
163
+ if (!runtimeEnv) return null;
164
+ try {
165
+ const object = await runtimeEnv.r2.get(
166
+ cimplifyTanstackR2Key(
167
+ runtimeEnv.prefix,
168
+ key,
169
+ driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE
170
+ )
171
+ );
172
+ return object ? await object.text() : null;
173
+ } catch {
174
+ return null;
175
+ }
176
+ }
177
+ function cimplifyTanstackCacheOptions(metadata) {
178
+ return { [CIMPLIFY_CACHE_META_FIELD]: metadata };
179
+ }
180
+ function withCimplifyCacheMetadata(value, metadata) {
181
+ return { ...value, [CIMPLIFY_CACHE_META_FIELD]: metadata };
182
+ }
183
+ function createCimplifyTanstackCacheDriver(options = {}) {
184
+ const driverOptions = { ...options };
185
+ return {
186
+ name: "cimplify-tanstack-r2-cache",
187
+ options: driverOptions,
188
+ async hasItem(key) {
189
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
190
+ if (!runtimeEnv) return false;
191
+ try {
192
+ const object = await runtimeEnv.r2.head(
193
+ cimplifyTanstackR2Key(
194
+ runtimeEnv.prefix,
195
+ key,
196
+ driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE
197
+ )
198
+ );
199
+ return Boolean(object);
200
+ } catch {
201
+ return false;
202
+ }
203
+ },
204
+ async getItem(key) {
205
+ const raw = await getRawItem(driverOptions, key);
206
+ if (raw === null) return null;
207
+ try {
208
+ return JSON.parse(raw);
209
+ } catch {
210
+ return raw;
211
+ }
212
+ },
213
+ async getItemRaw(key) {
214
+ return getRawItem(driverOptions, key);
215
+ },
216
+ async setItem(key, value, options2) {
217
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
218
+ if (!runtimeEnv) return;
219
+ const strippedValue = valueForStorage(value);
220
+ await putAndIndex(
221
+ runtimeEnv,
222
+ driverOptions,
223
+ key,
224
+ JSON.stringify(strippedValue) ?? "null",
225
+ value,
226
+ options2
227
+ );
228
+ },
229
+ async setItemRaw(key, value, options2) {
230
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
231
+ if (!runtimeEnv) return;
232
+ await putAndIndex(runtimeEnv, driverOptions, key, value, value, options2);
233
+ },
234
+ async removeItem(key) {
235
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
236
+ if (!runtimeEnv) return;
237
+ try {
238
+ await runtimeEnv.r2.delete(
239
+ cimplifyTanstackR2Key(
240
+ runtimeEnv.prefix,
241
+ key,
242
+ driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE
243
+ )
244
+ );
245
+ } catch {
246
+ }
247
+ },
248
+ async getKeys(base) {
249
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
250
+ if (!runtimeEnv) return [];
251
+ const namespace = driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE;
252
+ try {
253
+ const keys = await listR2Keys(
254
+ runtimeEnv.r2,
255
+ cimplifyTanstackR2ListPrefix(runtimeEnv.prefix, base, namespace)
256
+ );
257
+ return keys.map((key) => storageKeyFromR2Key(runtimeEnv.prefix, namespace, key));
258
+ } catch {
259
+ return [];
260
+ }
261
+ },
262
+ async clear(base) {
263
+ const runtimeEnv = await resolveRuntimeEnv(driverOptions);
264
+ if (!runtimeEnv) return;
265
+ const namespace = driverOptions.namespace ?? TANSTACK_CACHE_NAMESPACE;
266
+ try {
267
+ const keys = await listR2Keys(
268
+ runtimeEnv.r2,
269
+ cimplifyTanstackR2ListPrefix(runtimeEnv.prefix, base, namespace)
270
+ );
271
+ await Promise.all(keys.map((key) => runtimeEnv.r2.delete(key)));
272
+ } catch {
273
+ }
274
+ }
275
+ };
276
+ }
277
+ var cimplifyTanstackCacheDriver = createCimplifyTanstackCacheDriver;
278
+
279
+ export { CIMPLIFY_CACHE_META_FIELD, CIMPLIFY_TAG_PREFIX, TANSTACK_CACHE_NAMESPACE, TANSTACK_PATH_INDEX_BINDING, TANSTACK_R2_BUCKET_BINDING, TANSTACK_R2_PREFIX_ENV, cimplifyTanstackCacheDriver, cimplifyTanstackCacheOptions, cimplifyTanstackR2Key, createCimplifyTanstackCacheDriver, withCimplifyCacheMetadata };
@@ -1010,8 +1010,11 @@ interface MockLinkCustomer {
1010
1010
  email: string | null;
1011
1011
  phone: string | null;
1012
1012
  name: string;
1013
+ delivery_address: string | null;
1013
1014
  created_at: string;
1014
1015
  updated_at: string;
1016
+ metadata: Record<string, unknown> | null;
1017
+ account_id: string | null;
1015
1018
  }
1016
1019
  interface MockLinkSession {
1017
1020
  id: string;
@@ -1019,7 +1022,7 @@ interface MockLinkSession {
1019
1022
  created_at: string;
1020
1023
  last_used_at: string;
1021
1024
  device_type: "mobile" | "desktop" | "tablet" | "unknown";
1022
- ip: string | null;
1025
+ ip_address: string | null;
1023
1026
  user_agent: string | null;
1024
1027
  is_current: boolean;
1025
1028
  }
@@ -1010,8 +1010,11 @@ interface MockLinkCustomer {
1010
1010
  email: string | null;
1011
1011
  phone: string | null;
1012
1012
  name: string;
1013
+ delivery_address: string | null;
1013
1014
  created_at: string;
1014
1015
  updated_at: string;
1016
+ metadata: Record<string, unknown> | null;
1017
+ account_id: string | null;
1015
1018
  }
1016
1019
  interface MockLinkSession {
1017
1020
  id: string;
@@ -1019,7 +1022,7 @@ interface MockLinkSession {
1019
1022
  created_at: string;
1020
1023
  last_used_at: string;
1021
1024
  device_type: "mobile" | "desktop" | "tablet" | "unknown";
1022
- ip: string | null;
1025
+ ip_address: string | null;
1023
1026
  user_agent: string | null;
1024
1027
  is_current: boolean;
1025
1028
  }
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { ad as CimplifyClient } from './client-DRJvXz54.mjs';
2
- export { K as CacheOptions, cq as ReadRequestOptions, cM as Result } from './client-DRJvXz54.mjs';
1
+ import { ad as CimplifyClient } from './client-C7EMuGoz.mjs';
2
+ export { K as CacheOptions, cq as ReadRequestOptions, cM as Result } from './client-C7EMuGoz.mjs';
3
3
  export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.mjs';
4
4
  import { JWTVerifyResult } from 'jose';
5
5
  import './payment-DVS7ZUEp.mjs';
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ad as CimplifyClient } from './client-DjQhg6yr.js';
2
- export { K as CacheOptions, cq as ReadRequestOptions, cM as Result } from './client-DjQhg6yr.js';
1
+ import { ad as CimplifyClient } from './client-D6CZ2Ggp.js';
2
+ export { K as CacheOptions, cq as ReadRequestOptions, cM as Result } from './client-D6CZ2Ggp.js';
3
3
  export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.js';
4
4
  import { JWTVerifyResult } from 'jose';
5
5
  import './payment-sn-yGL7v.js';
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkQZQEGRGB_js = require('./chunk-QZQEGRGB.js');
4
- var chunkBCWPRPK7_js = require('./chunk-BCWPRPK7.js');
3
+ var chunkQS4XDVHI_js = require('./chunk-QS4XDVHI.js');
4
+ var chunkCV5QMDQS_js = require('./chunk-CV5QMDQS.js');
5
5
  require('./chunk-7Y2O3E4D.js');
6
6
  var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
7
7
  require('./chunk-OWW5GUSB.js');
@@ -26,7 +26,7 @@ function readEnv(...keys) {
26
26
  var getServerClient = react.cache((opts = {}) => {
27
27
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
28
28
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
29
- const client = chunkQZQEGRGB_js.createCimplifyClient({
29
+ const client = chunkQS4XDVHI_js.createCimplifyClient({
30
30
  baseUrl,
31
31
  publicKey,
32
32
  suppressPublicKeyWarning: true
@@ -250,7 +250,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
250
250
  var discoveryCache = /* @__PURE__ */ new Map();
251
251
  var jwksCache = /* @__PURE__ */ new Map();
252
252
  function issuerBase(cfg) {
253
- return (cfg.issuer ?? cfg.authUrl ?? chunkBCWPRPK7_js.DEFAULT_ISSUER).replace(/\/$/, "");
253
+ return (cfg.issuer ?? cfg.authUrl ?? chunkCV5QMDQS_js.DEFAULT_ISSUER).replace(/\/$/, "");
254
254
  }
255
255
  function cookieName(cfg) {
256
256
  return cfg.cookieName ?? SESSION_COOKIE;
@@ -465,12 +465,12 @@ async function handleOidcCallback(req, opts) {
465
465
  }
466
466
  function readPkceCookie(cookieHeader) {
467
467
  if (!cookieHeader) return null;
468
- const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkBCWPRPK7_js.PKCE_COOKIE}=`));
468
+ const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkCV5QMDQS_js.PKCE_COOKIE}=`));
469
469
  if (!match) return null;
470
- return chunkBCWPRPK7_js.decodePkceState(match.slice(chunkBCWPRPK7_js.PKCE_COOKIE.length + 1));
470
+ return chunkCV5QMDQS_js.decodePkceState(match.slice(chunkCV5QMDQS_js.PKCE_COOKIE.length + 1));
471
471
  }
472
472
  function buildPkceClearCookie() {
473
- return `${chunkBCWPRPK7_js.PKCE_COOKIE}=; Path=${chunkBCWPRPK7_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
473
+ return `${chunkCV5QMDQS_js.PKCE_COOKIE}=; Path=${chunkCV5QMDQS_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
474
474
  }
475
475
  function safeReturnPath(returnTo, fallback) {
476
476
  if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
package/dist/server.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { createCimplifyClient } from './chunk-EAVXSFAB.mjs';
2
- import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-M2CXZQHS.mjs';
1
+ import { createCimplifyClient } from './chunk-H337NF4O.mjs';
2
+ import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-3BKMNVTR.mjs';
3
3
  import './chunk-TD3AY34U.mjs';
4
4
  export { CimplifyError } from './chunk-AMZXALF6.mjs';
5
5
  import './chunk-3G6RQLXK.mjs';
@@ -1,4 +1,4 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-D8rwqZQ6.mjs';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-DDQ1O3XR.mjs';
2
2
  import 'hono';
3
3
  import '../product-B_kS4Oxa.mjs';
4
4