@concavejs/docstore-cf-do 0.0.1-alpha.5 → 0.0.1-alpha.7

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 (2) hide show
  1. package/dist/index.js +271 -574
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -11,212 +11,173 @@ var __export = (target, all) => {
11
11
  };
12
12
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
13
13
 
14
- // ../core/dist/utils/utils.js
15
- function hexToArrayBuffer(hex) {
16
- if (hex === "") {
17
- return new Uint8Array(0).buffer;
18
- }
19
- const matches = hex.match(/.{1,2}/g);
20
- if (!matches) {
21
- throw new Error(`Invalid hex string: ${hex}`);
22
- }
23
- return new Uint8Array(matches.map((byte) => parseInt(byte, 16))).buffer;
24
- }
25
- function arrayBufferToHex(buffer) {
26
- return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
27
- }
28
- function stringToHex(s) {
29
- const buffer = new TextEncoder().encode(s);
30
- return arrayBufferToHex(buffer.buffer);
31
- }
32
- function hexToString(hex) {
33
- const buffer = hexToArrayBuffer(hex);
34
- return new TextDecoder().decode(buffer);
35
- }
36
- function serializeDeveloperId(tableHex, internalIdHex) {
37
- return `${tableHex}${DOC_ID_SEPARATOR}${internalIdHex}`;
38
- }
39
- function deserializeDeveloperId(developerId) {
40
- if (!developerId) {
41
- return null;
42
- }
43
- for (const separator of [DOC_ID_SEPARATOR, LEGACY_DOC_ID_SEPARATOR]) {
44
- const parts = developerId.split(separator);
45
- if (parts.length === 2 && parts[0] && parts[1]) {
46
- return { table: parts[0], internalId: parts[1] };
47
- }
48
- }
49
- return null;
50
- }
51
- var DOC_ID_SEPARATOR = ":", LEGACY_DOC_ID_SEPARATOR = ";";
52
-
53
- // ../core/node_modules/convex/dist/esm/values/base64.js
54
- function getLens2(b64) {
55
- var len3 = b64.length;
56
- if (len3 % 4 > 0) {
14
+ // ../../node_modules/convex/dist/esm/values/base64.js
15
+ function getLens(b64) {
16
+ var len2 = b64.length;
17
+ if (len2 % 4 > 0) {
57
18
  throw new Error("Invalid string. Length must be a multiple of 4");
58
19
  }
59
20
  var validLen = b64.indexOf("=");
60
21
  if (validLen === -1)
61
- validLen = len3;
62
- var placeHoldersLen = validLen === len3 ? 0 : 4 - validLen % 4;
22
+ validLen = len2;
23
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
63
24
  return [validLen, placeHoldersLen];
64
25
  }
65
- function _byteLength2(_b64, validLen, placeHoldersLen) {
26
+ function _byteLength(_b64, validLen, placeHoldersLen) {
66
27
  return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
67
28
  }
68
- function toByteArray2(b64) {
29
+ function toByteArray(b64) {
69
30
  var tmp;
70
- var lens = getLens2(b64);
31
+ var lens = getLens(b64);
71
32
  var validLen = lens[0];
72
33
  var placeHoldersLen = lens[1];
73
- var arr = new Arr2(_byteLength2(b64, validLen, placeHoldersLen));
34
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
74
35
  var curByte = 0;
75
- var len3 = placeHoldersLen > 0 ? validLen - 4 : validLen;
76
- var i3;
77
- for (i3 = 0;i3 < len3; i3 += 4) {
78
- tmp = revLookup2[b64.charCodeAt(i3)] << 18 | revLookup2[b64.charCodeAt(i3 + 1)] << 12 | revLookup2[b64.charCodeAt(i3 + 2)] << 6 | revLookup2[b64.charCodeAt(i3 + 3)];
36
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
37
+ var i2;
38
+ for (i2 = 0;i2 < len2; i2 += 4) {
39
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
79
40
  arr[curByte++] = tmp >> 16 & 255;
80
41
  arr[curByte++] = tmp >> 8 & 255;
81
42
  arr[curByte++] = tmp & 255;
82
43
  }
83
44
  if (placeHoldersLen === 2) {
84
- tmp = revLookup2[b64.charCodeAt(i3)] << 2 | revLookup2[b64.charCodeAt(i3 + 1)] >> 4;
45
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
85
46
  arr[curByte++] = tmp & 255;
86
47
  }
87
48
  if (placeHoldersLen === 1) {
88
- tmp = revLookup2[b64.charCodeAt(i3)] << 10 | revLookup2[b64.charCodeAt(i3 + 1)] << 4 | revLookup2[b64.charCodeAt(i3 + 2)] >> 2;
49
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
89
50
  arr[curByte++] = tmp >> 8 & 255;
90
51
  arr[curByte++] = tmp & 255;
91
52
  }
92
53
  return arr;
93
54
  }
94
- function tripletToBase642(num) {
95
- return lookup2[num >> 18 & 63] + lookup2[num >> 12 & 63] + lookup2[num >> 6 & 63] + lookup2[num & 63];
55
+ function tripletToBase64(num) {
56
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
96
57
  }
97
- function encodeChunk2(uint8, start, end) {
58
+ function encodeChunk(uint8, start, end) {
98
59
  var tmp;
99
60
  var output = [];
100
- for (var i3 = start;i3 < end; i3 += 3) {
101
- tmp = (uint8[i3] << 16 & 16711680) + (uint8[i3 + 1] << 8 & 65280) + (uint8[i3 + 2] & 255);
102
- output.push(tripletToBase642(tmp));
61
+ for (var i2 = start;i2 < end; i2 += 3) {
62
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
63
+ output.push(tripletToBase64(tmp));
103
64
  }
104
65
  return output.join("");
105
66
  }
106
- function fromByteArray2(uint8) {
67
+ function fromByteArray(uint8) {
107
68
  var tmp;
108
- var len3 = uint8.length;
109
- var extraBytes = len3 % 3;
69
+ var len2 = uint8.length;
70
+ var extraBytes = len2 % 3;
110
71
  var parts = [];
111
72
  var maxChunkLength = 16383;
112
- for (var i3 = 0, len22 = len3 - extraBytes;i3 < len22; i3 += maxChunkLength) {
113
- parts.push(encodeChunk2(uint8, i3, i3 + maxChunkLength > len22 ? len22 : i3 + maxChunkLength));
73
+ for (var i2 = 0, len22 = len2 - extraBytes;i2 < len22; i2 += maxChunkLength) {
74
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
114
75
  }
115
76
  if (extraBytes === 1) {
116
- tmp = uint8[len3 - 1];
117
- parts.push(lookup2[tmp >> 2] + lookup2[tmp << 4 & 63] + "==");
77
+ tmp = uint8[len2 - 1];
78
+ parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
118
79
  } else if (extraBytes === 2) {
119
- tmp = (uint8[len3 - 2] << 8) + uint8[len3 - 1];
120
- parts.push(lookup2[tmp >> 10] + lookup2[tmp >> 4 & 63] + lookup2[tmp << 2 & 63] + "=");
80
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
81
+ parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
121
82
  }
122
83
  return parts.join("");
123
84
  }
124
- var lookup2, revLookup2, Arr2, code2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i2, len2;
85
+ var lookup, revLookup, Arr, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i, len;
125
86
  var init_base64 = __esm(() => {
126
- lookup2 = [];
127
- revLookup2 = [];
128
- Arr2 = Uint8Array;
129
- for (i2 = 0, len2 = code2.length;i2 < len2; ++i2) {
130
- lookup2[i2] = code2[i2];
131
- revLookup2[code2.charCodeAt(i2)] = i2;
132
- }
133
- revLookup2[45] = 62;
134
- revLookup2[95] = 63;
87
+ lookup = [];
88
+ revLookup = [];
89
+ Arr = Uint8Array;
90
+ for (i = 0, len = code.length;i < len; ++i) {
91
+ lookup[i] = code[i];
92
+ revLookup[code.charCodeAt(i)] = i;
93
+ }
94
+ revLookup[45] = 62;
95
+ revLookup[95] = 63;
135
96
  });
136
97
 
137
- // ../core/node_modules/convex/dist/esm/common/index.js
98
+ // ../../node_modules/convex/dist/esm/common/index.js
138
99
  function parseArgs(args) {
139
100
  if (args === undefined) {
140
101
  return {};
141
102
  }
142
- if (!isSimpleObject2(args)) {
103
+ if (!isSimpleObject(args)) {
143
104
  throw new Error(`The arguments to a Convex function must be an object. Received: ${args}`);
144
105
  }
145
106
  return args;
146
107
  }
147
- function isSimpleObject2(value) {
108
+ function isSimpleObject(value) {
148
109
  const isObject = typeof value === "object";
149
110
  const prototype = Object.getPrototypeOf(value);
150
111
  const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
151
112
  return isObject && isSimple;
152
113
  }
153
114
 
154
- // ../core/node_modules/convex/dist/esm/values/value.js
155
- function isSpecial2(n) {
115
+ // ../../node_modules/convex/dist/esm/values/value.js
116
+ function isSpecial(n) {
156
117
  return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
157
118
  }
158
- function slowBigIntToBase642(value) {
159
- if (value < ZERO2) {
160
- value -= MIN_INT642 + MIN_INT642;
119
+ function slowBigIntToBase64(value) {
120
+ if (value < ZERO) {
121
+ value -= MIN_INT64 + MIN_INT64;
161
122
  }
162
123
  let hex = value.toString(16);
163
124
  if (hex.length % 2 === 1)
164
125
  hex = "0" + hex;
165
126
  const bytes = new Uint8Array(new ArrayBuffer(8));
166
- let i3 = 0;
127
+ let i2 = 0;
167
128
  for (const hexByte of hex.match(/.{2}/g).reverse()) {
168
- bytes.set([parseInt(hexByte, 16)], i3++);
169
- value >>= EIGHT2;
129
+ bytes.set([parseInt(hexByte, 16)], i2++);
130
+ value >>= EIGHT;
170
131
  }
171
- return fromByteArray2(bytes);
132
+ return fromByteArray(bytes);
172
133
  }
173
- function slowBase64ToBigInt2(encoded) {
174
- const integerBytes = toByteArray2(encoded);
134
+ function slowBase64ToBigInt(encoded) {
135
+ const integerBytes = toByteArray(encoded);
175
136
  if (integerBytes.byteLength !== 8) {
176
137
  throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
177
138
  }
178
- let value = ZERO2;
179
- let power = ZERO2;
139
+ let value = ZERO;
140
+ let power = ZERO;
180
141
  for (const byte of integerBytes) {
181
- value += BigInt(byte) * TWOFIFTYSIX2 ** power;
142
+ value += BigInt(byte) * TWOFIFTYSIX ** power;
182
143
  power++;
183
144
  }
184
- if (value > MAX_INT642) {
185
- value += MIN_INT642 + MIN_INT642;
145
+ if (value > MAX_INT64) {
146
+ value += MIN_INT64 + MIN_INT64;
186
147
  }
187
148
  return value;
188
149
  }
189
- function modernBigIntToBase642(value) {
190
- if (value < MIN_INT642 || MAX_INT642 < value) {
150
+ function modernBigIntToBase64(value) {
151
+ if (value < MIN_INT64 || MAX_INT64 < value) {
191
152
  throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
192
153
  }
193
154
  const buffer = new ArrayBuffer(8);
194
155
  new DataView(buffer).setBigInt64(0, value, true);
195
- return fromByteArray2(new Uint8Array(buffer));
156
+ return fromByteArray(new Uint8Array(buffer));
196
157
  }
197
- function modernBase64ToBigInt2(encoded) {
198
- const integerBytes = toByteArray2(encoded);
158
+ function modernBase64ToBigInt(encoded) {
159
+ const integerBytes = toByteArray(encoded);
199
160
  if (integerBytes.byteLength !== 8) {
200
161
  throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
201
162
  }
202
163
  const intBytesView = new DataView(integerBytes.buffer);
203
164
  return intBytesView.getBigInt64(0, true);
204
165
  }
205
- function validateObjectField2(k) {
206
- if (k.length > MAX_IDENTIFIER_LEN2) {
207
- throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN2}.`);
166
+ function validateObjectField(k) {
167
+ if (k.length > MAX_IDENTIFIER_LEN) {
168
+ throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN}.`);
208
169
  }
209
170
  if (k.startsWith("$")) {
210
171
  throw new Error(`Field name ${k} starts with a '$', which is reserved.`);
211
172
  }
212
- for (let i3 = 0;i3 < k.length; i3 += 1) {
213
- const charCode = k.charCodeAt(i3);
173
+ for (let i2 = 0;i2 < k.length; i2 += 1) {
174
+ const charCode = k.charCodeAt(i2);
214
175
  if (charCode < 32 || charCode >= 127) {
215
- throw new Error(`Field name ${k} has invalid character '${k[i3]}': Field names can only contain non-control ASCII characters`);
176
+ throw new Error(`Field name ${k} has invalid character '${k[i2]}': Field names can only contain non-control ASCII characters`);
216
177
  }
217
178
  }
218
179
  }
219
- function jsonToConvex2(value) {
180
+ function jsonToConvex(value) {
220
181
  if (value === null) {
221
182
  return value;
222
183
  }
@@ -230,7 +191,7 @@ function jsonToConvex2(value) {
230
191
  return value;
231
192
  }
232
193
  if (Array.isArray(value)) {
233
- return value.map((value2) => jsonToConvex2(value2));
194
+ return value.map((value2) => jsonToConvex(value2));
234
195
  }
235
196
  if (typeof value !== "object") {
236
197
  throw new Error(`Unexpected type of ${value}`);
@@ -242,25 +203,25 @@ function jsonToConvex2(value) {
242
203
  if (typeof value.$bytes !== "string") {
243
204
  throw new Error(`Malformed $bytes field on ${value}`);
244
205
  }
245
- return toByteArray2(value.$bytes).buffer;
206
+ return toByteArray(value.$bytes).buffer;
246
207
  }
247
208
  if (key === "$integer") {
248
209
  if (typeof value.$integer !== "string") {
249
210
  throw new Error(`Malformed $integer field on ${value}`);
250
211
  }
251
- return base64ToBigInt2(value.$integer);
212
+ return base64ToBigInt(value.$integer);
252
213
  }
253
214
  if (key === "$float") {
254
215
  if (typeof value.$float !== "string") {
255
216
  throw new Error(`Malformed $float field on ${value}`);
256
217
  }
257
- const floatBytes = toByteArray2(value.$float);
218
+ const floatBytes = toByteArray(value.$float);
258
219
  if (floatBytes.byteLength !== 8) {
259
220
  throw new Error(`Received ${floatBytes.byteLength} bytes, expected 8 for $float`);
260
221
  }
261
222
  const floatBytesView = new DataView(floatBytes.buffer);
262
- const float = floatBytesView.getFloat64(0, LITTLE_ENDIAN2);
263
- if (!isSpecial2(float)) {
223
+ const float = floatBytesView.getFloat64(0, LITTLE_ENDIAN);
224
+ if (!isSpecial(float)) {
264
225
  throw new Error(`Float ${float} should be encoded as a number`);
265
226
  }
266
227
  return float;
@@ -274,12 +235,12 @@ function jsonToConvex2(value) {
274
235
  }
275
236
  const out = {};
276
237
  for (const [k, v] of Object.entries(value)) {
277
- validateObjectField2(k);
278
- out[k] = jsonToConvex2(v);
238
+ validateObjectField(k);
239
+ out[k] = jsonToConvex(v);
279
240
  }
280
241
  return out;
281
242
  }
282
- function stringifyValueForError2(value) {
243
+ function stringifyValueForError(value) {
283
244
  const str = JSON.stringify(value, (_key, value2) => {
284
245
  if (value2 === undefined) {
285
246
  return "undefined";
@@ -300,25 +261,25 @@ function stringifyValueForError2(value) {
300
261
  }
301
262
  return str;
302
263
  }
303
- function convexToJsonInternal2(value, originalValue, context, includeTopLevelUndefined) {
264
+ function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
304
265
  if (value === undefined) {
305
- const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError2(originalValue)})`;
266
+ const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError(originalValue)})`;
306
267
  throw new Error(`undefined is not a valid Convex value${contextText}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
307
268
  }
308
269
  if (value === null) {
309
270
  return value;
310
271
  }
311
272
  if (typeof value === "bigint") {
312
- if (value < MIN_INT642 || MAX_INT642 < value) {
273
+ if (value < MIN_INT64 || MAX_INT64 < value) {
313
274
  throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
314
275
  }
315
- return { $integer: bigIntToBase642(value) };
276
+ return { $integer: bigIntToBase64(value) };
316
277
  }
317
278
  if (typeof value === "number") {
318
- if (isSpecial2(value)) {
279
+ if (isSpecial(value)) {
319
280
  const buffer = new ArrayBuffer(8);
320
- new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN2);
321
- return { $float: fromByteArray2(new Uint8Array(buffer)) };
281
+ new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN);
282
+ return { $float: fromByteArray(new Uint8Array(buffer)) };
322
283
  } else {
323
284
  return value;
324
285
  }
@@ -330,75 +291,75 @@ function convexToJsonInternal2(value, originalValue, context, includeTopLevelUnd
330
291
  return value;
331
292
  }
332
293
  if (value instanceof ArrayBuffer) {
333
- return { $bytes: fromByteArray2(new Uint8Array(value)) };
294
+ return { $bytes: fromByteArray(new Uint8Array(value)) };
334
295
  }
335
296
  if (Array.isArray(value)) {
336
- return value.map((value2, i3) => convexToJsonInternal2(value2, originalValue, context + `[${i3}]`, false));
297
+ return value.map((value2, i2) => convexToJsonInternal(value2, originalValue, context + `[${i2}]`, false));
337
298
  }
338
299
  if (value instanceof Set) {
339
- throw new Error(errorMessageForUnsupportedType2(context, "Set", [...value], originalValue));
300
+ throw new Error(errorMessageForUnsupportedType(context, "Set", [...value], originalValue));
340
301
  }
341
302
  if (value instanceof Map) {
342
- throw new Error(errorMessageForUnsupportedType2(context, "Map", [...value], originalValue));
303
+ throw new Error(errorMessageForUnsupportedType(context, "Map", [...value], originalValue));
343
304
  }
344
- if (!isSimpleObject2(value)) {
305
+ if (!isSimpleObject(value)) {
345
306
  const theType = value?.constructor?.name;
346
307
  const typeName = theType ? `${theType} ` : "";
347
- throw new Error(errorMessageForUnsupportedType2(context, typeName, value, originalValue));
308
+ throw new Error(errorMessageForUnsupportedType(context, typeName, value, originalValue));
348
309
  }
349
310
  const out = {};
350
311
  const entries = Object.entries(value);
351
312
  entries.sort(([k1, _v1], [k2, _v2]) => k1 === k2 ? 0 : k1 < k2 ? -1 : 1);
352
313
  for (const [k, v] of entries) {
353
314
  if (v !== undefined) {
354
- validateObjectField2(k);
355
- out[k] = convexToJsonInternal2(v, originalValue, context + `.${k}`, false);
315
+ validateObjectField(k);
316
+ out[k] = convexToJsonInternal(v, originalValue, context + `.${k}`, false);
356
317
  } else if (includeTopLevelUndefined) {
357
- validateObjectField2(k);
358
- out[k] = convexOrUndefinedToJsonInternal2(v, originalValue, context + `.${k}`);
318
+ validateObjectField(k);
319
+ out[k] = convexOrUndefinedToJsonInternal(v, originalValue, context + `.${k}`);
359
320
  }
360
321
  }
361
322
  return out;
362
323
  }
363
- function errorMessageForUnsupportedType2(context, typeName, value, originalValue) {
324
+ function errorMessageForUnsupportedType(context, typeName, value, originalValue) {
364
325
  if (context) {
365
- return `${typeName}${stringifyValueForError2(value)} is not a supported Convex type (present at path ${context} in original object ${stringifyValueForError2(originalValue)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`;
326
+ return `${typeName}${stringifyValueForError(value)} is not a supported Convex type (present at path ${context} in original object ${stringifyValueForError(originalValue)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`;
366
327
  } else {
367
- return `${typeName}${stringifyValueForError2(value)} is not a supported Convex type.`;
328
+ return `${typeName}${stringifyValueForError(value)} is not a supported Convex type.`;
368
329
  }
369
330
  }
370
- function convexOrUndefinedToJsonInternal2(value, originalValue, context) {
331
+ function convexOrUndefinedToJsonInternal(value, originalValue, context) {
371
332
  if (value === undefined) {
372
333
  return { $undefined: null };
373
334
  } else {
374
335
  if (originalValue === undefined) {
375
- throw new Error(`Programming error. Current value is ${stringifyValueForError2(value)} but original value is undefined`);
336
+ throw new Error(`Programming error. Current value is ${stringifyValueForError(value)} but original value is undefined`);
376
337
  }
377
- return convexToJsonInternal2(value, originalValue, context, false);
338
+ return convexToJsonInternal(value, originalValue, context, false);
378
339
  }
379
340
  }
380
- function convexToJson2(value) {
381
- return convexToJsonInternal2(value, value, "", false);
341
+ function convexToJson(value) {
342
+ return convexToJsonInternal(value, value, "", false);
382
343
  }
383
344
  function convexOrUndefinedToJson(value) {
384
- return convexOrUndefinedToJsonInternal2(value, value, "");
345
+ return convexOrUndefinedToJsonInternal(value, value, "");
385
346
  }
386
347
  function patchValueToJson(value) {
387
- return convexToJsonInternal2(value, value, "", true);
348
+ return convexToJsonInternal(value, value, "", true);
388
349
  }
389
- var LITTLE_ENDIAN2 = true, MIN_INT642, MAX_INT642, ZERO2, EIGHT2, TWOFIFTYSIX2, bigIntToBase642, base64ToBigInt2, MAX_IDENTIFIER_LEN2 = 1024, MAX_VALUE_FOR_ERROR_LEN = 16384;
350
+ var LITTLE_ENDIAN = true, MIN_INT64, MAX_INT64, ZERO, EIGHT, TWOFIFTYSIX, bigIntToBase64, base64ToBigInt, MAX_IDENTIFIER_LEN = 1024, MAX_VALUE_FOR_ERROR_LEN = 16384;
390
351
  var init_value = __esm(() => {
391
352
  init_base64();
392
- MIN_INT642 = BigInt("-9223372036854775808");
393
- MAX_INT642 = BigInt("9223372036854775807");
394
- ZERO2 = BigInt("0");
395
- EIGHT2 = BigInt("8");
396
- TWOFIFTYSIX2 = BigInt("256");
397
- bigIntToBase642 = DataView.prototype.setBigInt64 ? modernBigIntToBase642 : slowBigIntToBase642;
398
- base64ToBigInt2 = DataView.prototype.getBigInt64 ? modernBase64ToBigInt2 : slowBase64ToBigInt2;
353
+ MIN_INT64 = BigInt("-9223372036854775808");
354
+ MAX_INT64 = BigInt("9223372036854775807");
355
+ ZERO = BigInt("0");
356
+ EIGHT = BigInt("8");
357
+ TWOFIFTYSIX = BigInt("256");
358
+ bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
359
+ base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
399
360
  });
400
361
 
401
- // ../core/node_modules/convex/dist/esm/values/validators.js
362
+ // ../../node_modules/convex/dist/esm/values/validators.js
402
363
  function throwUndefinedValidatorError(context, fieldName) {
403
364
  const fieldInfo = fieldName !== undefined ? ` for field "${fieldName}"` : "";
404
365
  throw new Error(`A validator is undefined${fieldInfo} in ${context}. This is often caused by circular imports. See ${UNDEFINED_VALIDATOR_ERROR_URL} for details.`);
@@ -621,7 +582,7 @@ var init_validators = __esm(() => {
621
582
  get json() {
622
583
  return {
623
584
  type: this.kind,
624
- value: convexToJson2(this.value)
585
+ value: convexToJson(this.value)
625
586
  };
626
587
  }
627
588
  asOptional() {
@@ -733,7 +694,7 @@ var init_validators = __esm(() => {
733
694
  };
734
695
  });
735
696
 
736
- // ../core/node_modules/convex/dist/esm/values/validator.js
697
+ // ../../node_modules/convex/dist/esm/values/validator.js
737
698
  function isValidator(v2) {
738
699
  return !!v2.isConvexValidator;
739
700
  }
@@ -812,7 +773,7 @@ var init_validator = __esm(() => {
812
773
  };
813
774
  });
814
775
 
815
- // ../core/node_modules/convex/dist/esm/values/errors.js
776
+ // ../../node_modules/convex/dist/esm/values/errors.js
816
777
  var __defProp3, __defNormalProp2 = (obj, key, value) => (key in obj) ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value), _a, _b, IDENTIFYING_FIELD, ConvexError;
817
778
  var init_errors = __esm(() => {
818
779
  init_value();
@@ -820,7 +781,7 @@ var init_errors = __esm(() => {
820
781
  IDENTIFYING_FIELD = Symbol.for("ConvexError");
821
782
  ConvexError = class ConvexError extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
822
783
  constructor(data) {
823
- super(typeof data === "string" ? data : stringifyValueForError2(data));
784
+ super(typeof data === "string" ? data : stringifyValueForError(data));
824
785
  __publicField2(this, "name", "ConvexError");
825
786
  __publicField2(this, "data");
826
787
  __publicField2(this, _a, true);
@@ -829,13 +790,52 @@ var init_errors = __esm(() => {
829
790
  };
830
791
  });
831
792
 
832
- // ../core/node_modules/convex/dist/esm/values/index.js
793
+ // ../../node_modules/convex/dist/esm/values/index.js
833
794
  var init_values = __esm(() => {
834
795
  init_value();
835
796
  init_validator();
836
797
  init_errors();
837
798
  });
838
799
 
800
+ // ../core/dist/utils/utils.js
801
+ function hexToArrayBuffer(hex) {
802
+ if (hex === "") {
803
+ return new Uint8Array(0).buffer;
804
+ }
805
+ const matches = hex.match(/.{1,2}/g);
806
+ if (!matches) {
807
+ throw new Error(`Invalid hex string: ${hex}`);
808
+ }
809
+ return new Uint8Array(matches.map((byte) => parseInt(byte, 16))).buffer;
810
+ }
811
+ function arrayBufferToHex(buffer) {
812
+ return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
813
+ }
814
+ function stringToHex(s) {
815
+ const buffer = new TextEncoder().encode(s);
816
+ return arrayBufferToHex(buffer.buffer);
817
+ }
818
+ function hexToString(hex) {
819
+ const buffer = hexToArrayBuffer(hex);
820
+ return new TextDecoder().decode(buffer);
821
+ }
822
+ function serializeDeveloperId(tableHex, internalIdHex) {
823
+ return `${tableHex}${DOC_ID_SEPARATOR}${internalIdHex}`;
824
+ }
825
+ function deserializeDeveloperId(developerId) {
826
+ if (!developerId) {
827
+ return null;
828
+ }
829
+ for (const separator of [DOC_ID_SEPARATOR, LEGACY_DOC_ID_SEPARATOR]) {
830
+ const parts = developerId.split(separator);
831
+ if (parts.length === 2 && parts[0] && parts[1]) {
832
+ return { table: parts[0], internalId: parts[1] };
833
+ }
834
+ }
835
+ return null;
836
+ }
837
+ var DOC_ID_SEPARATOR = ":", LEGACY_DOC_ID_SEPARATOR = ";";
838
+
839
839
  // ../core/dist/queryengine/indexing/index-key-codec.js
840
840
  function encodeNumber(n) {
841
841
  const buffer = new ArrayBuffer(8);
@@ -845,8 +845,8 @@ function encodeNumber(n) {
845
845
  if (n >= 0) {
846
846
  bytes[0] ^= 128;
847
847
  } else {
848
- for (let i3 = 0;i3 < 8; i3++) {
849
- bytes[i3] ^= 255;
848
+ for (let i2 = 0;i2 < 8; i2++) {
849
+ bytes[i2] ^= 255;
850
850
  }
851
851
  }
852
852
  return bytes;
@@ -959,10 +959,10 @@ function compareIndexKeys(a, b) {
959
959
  const viewA = new Uint8Array(a);
960
960
  const viewB = new Uint8Array(b);
961
961
  const minLen = Math.min(viewA.length, viewB.length);
962
- for (let i3 = 0;i3 < minLen; i3++) {
963
- if (viewA[i3] < viewB[i3])
962
+ for (let i2 = 0;i2 < minLen; i2++) {
963
+ if (viewA[i2] < viewB[i2])
964
964
  return -1;
965
- if (viewA[i3] > viewB[i3])
965
+ if (viewA[i2] > viewB[i2])
966
966
  return 1;
967
967
  }
968
968
  if (viewA.length < viewB.length)
@@ -1097,10 +1097,10 @@ var init_interface = __esm(() => {
1097
1097
  };
1098
1098
  });
1099
1099
 
1100
- // ../core/node_modules/convex/dist/esm/index.js
1100
+ // ../../node_modules/convex/dist/esm/index.js
1101
1101
  var version = "1.31.7";
1102
1102
 
1103
- // ../core/node_modules/convex/dist/esm/server/impl/syscall.js
1103
+ // ../../node_modules/convex/dist/esm/server/impl/syscall.js
1104
1104
  function performSyscall(op, arg) {
1105
1105
  if (typeof Convex === "undefined" || Convex.syscall === undefined) {
1106
1106
  throw new Error("The Convex database and auth objects are being used outside of a Convex backend. Did you mean to use `useQuery` or `useMutation` to call a Convex function?");
@@ -1118,7 +1118,7 @@ async function performAsyncSyscall(op, arg) {
1118
1118
  } catch (e) {
1119
1119
  if (e.data !== undefined) {
1120
1120
  const rethrown = new ConvexError(e.message);
1121
- rethrown.data = jsonToConvex2(e.data);
1121
+ rethrown.data = jsonToConvex(e.data);
1122
1122
  throw rethrown;
1123
1123
  }
1124
1124
  throw new Error(e.message);
@@ -1130,13 +1130,13 @@ var init_syscall = __esm(() => {
1130
1130
  init_value();
1131
1131
  });
1132
1132
 
1133
- // ../core/node_modules/convex/dist/esm/server/functionName.js
1133
+ // ../../node_modules/convex/dist/esm/server/functionName.js
1134
1134
  var functionName;
1135
1135
  var init_functionName = __esm(() => {
1136
1136
  functionName = Symbol.for("functionName");
1137
1137
  });
1138
1138
 
1139
- // ../core/node_modules/convex/dist/esm/server/components/paths.js
1139
+ // ../../node_modules/convex/dist/esm/server/components/paths.js
1140
1140
  function extractReferencePath(reference) {
1141
1141
  return reference[toReferencePath] ?? null;
1142
1142
  }
@@ -1168,7 +1168,7 @@ var init_paths = __esm(() => {
1168
1168
  toReferencePath = Symbol.for("toReferencePath");
1169
1169
  });
1170
1170
 
1171
- // ../core/node_modules/convex/dist/esm/server/impl/validate.js
1171
+ // ../../node_modules/convex/dist/esm/server/impl/validate.js
1172
1172
  function validateArg(arg, idx, method, argName) {
1173
1173
  if (arg === undefined) {
1174
1174
  throw new TypeError(`Must provide arg ${idx} \`${argName}\` to \`${method}\``);
@@ -1180,7 +1180,7 @@ function validateArgIsNonNegativeInteger(arg, idx, method, argName) {
1180
1180
  }
1181
1181
  }
1182
1182
 
1183
- // ../core/node_modules/convex/dist/esm/server/impl/authentication_impl.js
1183
+ // ../../node_modules/convex/dist/esm/server/impl/authentication_impl.js
1184
1184
  function setupAuth(requestId) {
1185
1185
  return {
1186
1186
  getUserIdentity: async () => {
@@ -1194,7 +1194,7 @@ var init_authentication_impl = __esm(() => {
1194
1194
  init_syscall();
1195
1195
  });
1196
1196
 
1197
- // ../core/node_modules/convex/dist/esm/server/filter_builder.js
1197
+ // ../../node_modules/convex/dist/esm/server/filter_builder.js
1198
1198
  class Expression {
1199
1199
  constructor() {
1200
1200
  __publicField3(this, "_isExpression");
@@ -1206,7 +1206,7 @@ var init_filter_builder = __esm(() => {
1206
1206
  __defProp4 = Object.defineProperty;
1207
1207
  });
1208
1208
 
1209
- // ../core/node_modules/convex/dist/esm/server/impl/filter_builder_impl.js
1209
+ // ../../node_modules/convex/dist/esm/server/impl/filter_builder_impl.js
1210
1210
  function serializeExpression(expr) {
1211
1211
  if (expr instanceof ExpressionImpl) {
1212
1212
  return expr.serialize();
@@ -1303,7 +1303,7 @@ var init_filter_builder_impl = __esm(() => {
1303
1303
  };
1304
1304
  });
1305
1305
 
1306
- // ../core/node_modules/convex/dist/esm/server/index_range_builder.js
1306
+ // ../../node_modules/convex/dist/esm/server/index_range_builder.js
1307
1307
  class IndexRange {
1308
1308
  constructor() {
1309
1309
  __publicField5(this, "_isIndexRange");
@@ -1314,7 +1314,7 @@ var init_index_range_builder = __esm(() => {
1314
1314
  __defProp6 = Object.defineProperty;
1315
1315
  });
1316
1316
 
1317
- // ../core/node_modules/convex/dist/esm/server/impl/index_range_builder_impl.js
1317
+ // ../../node_modules/convex/dist/esm/server/impl/index_range_builder_impl.js
1318
1318
  var __defProp7, __defNormalProp6 = (obj, key, value) => (key in obj) ? __defProp7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField6 = (obj, key, value) => __defNormalProp6(obj, typeof key !== "symbol" ? key + "" : key, value), IndexRangeBuilderImpl;
1319
1319
  var init_index_range_builder_impl = __esm(() => {
1320
1320
  init_value();
@@ -1384,7 +1384,7 @@ var init_index_range_builder_impl = __esm(() => {
1384
1384
  };
1385
1385
  });
1386
1386
 
1387
- // ../core/node_modules/convex/dist/esm/server/search_filter_builder.js
1387
+ // ../../node_modules/convex/dist/esm/server/search_filter_builder.js
1388
1388
  class SearchFilter {
1389
1389
  constructor() {
1390
1390
  __publicField7(this, "_isSearchFilter");
@@ -1395,7 +1395,7 @@ var init_search_filter_builder = __esm(() => {
1395
1395
  __defProp8 = Object.defineProperty;
1396
1396
  });
1397
1397
 
1398
- // ../core/node_modules/convex/dist/esm/server/impl/search_filter_builder_impl.js
1398
+ // ../../node_modules/convex/dist/esm/server/impl/search_filter_builder_impl.js
1399
1399
  var __defProp9, __defNormalProp8 = (obj, key, value) => (key in obj) ? __defProp9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField8 = (obj, key, value) => __defNormalProp8(obj, typeof key !== "symbol" ? key + "" : key, value), SearchFilterBuilderImpl;
1400
1400
  var init_search_filter_builder_impl = __esm(() => {
1401
1401
  init_value();
@@ -1447,7 +1447,7 @@ var init_search_filter_builder_impl = __esm(() => {
1447
1447
  };
1448
1448
  });
1449
1449
 
1450
- // ../core/node_modules/convex/dist/esm/server/impl/query_impl.js
1450
+ // ../../node_modules/convex/dist/esm/server/impl/query_impl.js
1451
1451
  function throwClosedError(type) {
1452
1452
  throw new Error(type === "consumed" ? "This query is closed and can't emit any more values." : "This query has been chained with another operator and can't be reused.");
1453
1453
  }
@@ -1510,7 +1510,7 @@ var init_query_impl = __esm(() => {
1510
1510
  const syscallJSON = await performAsyncSyscall("1.0/count", {
1511
1511
  table: this.tableName
1512
1512
  });
1513
- const syscallResult = jsonToConvex2(syscallJSON);
1513
+ const syscallResult = jsonToConvex(syscallJSON);
1514
1514
  return syscallResult;
1515
1515
  }
1516
1516
  filter(predicate) {
@@ -1620,7 +1620,7 @@ var init_query_impl = __esm(() => {
1620
1620
  if (done) {
1621
1621
  this.closeQuery();
1622
1622
  }
1623
- const convexValue = jsonToConvex2(value);
1623
+ const convexValue = jsonToConvex(value);
1624
1624
  return { value: convexValue, done };
1625
1625
  }
1626
1626
  return() {
@@ -1647,7 +1647,7 @@ var init_query_impl = __esm(() => {
1647
1647
  version
1648
1648
  });
1649
1649
  return {
1650
- page: page.map((json) => jsonToConvex2(json)),
1650
+ page: page.map((json) => jsonToConvex(json)),
1651
1651
  isDone,
1652
1652
  continueCursor,
1653
1653
  splitCursor,
@@ -1684,20 +1684,20 @@ var init_query_impl = __esm(() => {
1684
1684
  };
1685
1685
  });
1686
1686
 
1687
- // ../core/node_modules/convex/dist/esm/server/impl/database_impl.js
1687
+ // ../../node_modules/convex/dist/esm/server/impl/database_impl.js
1688
1688
  async function get(table, id, isSystem) {
1689
1689
  validateArg(id, 1, "get", "id");
1690
1690
  if (typeof id !== "string") {
1691
1691
  throw new Error(`Invalid argument \`id\` for \`db.get\`, expected string but got '${typeof id}': ${id}`);
1692
1692
  }
1693
1693
  const args = {
1694
- id: convexToJson2(id),
1694
+ id: convexToJson(id),
1695
1695
  isSystem,
1696
1696
  version,
1697
1697
  table
1698
1698
  };
1699
1699
  const syscallJSON = await performAsyncSyscall("1.0/get", args);
1700
- return jsonToConvex2(syscallJSON);
1700
+ return jsonToConvex(syscallJSON);
1701
1701
  }
1702
1702
  function setupReader() {
1703
1703
  const reader = (isSystem = false) => {
@@ -1719,7 +1719,7 @@ function setupReader() {
1719
1719
  table: tableName,
1720
1720
  idString: id
1721
1721
  });
1722
- const syscallResult = jsonToConvex2(syscallJSON);
1722
+ const syscallResult = jsonToConvex(syscallJSON);
1723
1723
  return syscallResult.id;
1724
1724
  },
1725
1725
  system: null,
@@ -1741,16 +1741,16 @@ async function insert(tableName, value) {
1741
1741
  validateArg(value, 2, "insert", "value");
1742
1742
  const syscallJSON = await performAsyncSyscall("1.0/insert", {
1743
1743
  table: tableName,
1744
- value: convexToJson2(value)
1744
+ value: convexToJson(value)
1745
1745
  });
1746
- const syscallResult = jsonToConvex2(syscallJSON);
1746
+ const syscallResult = jsonToConvex(syscallJSON);
1747
1747
  return syscallResult._id;
1748
1748
  }
1749
1749
  async function patch(table, id, value) {
1750
1750
  validateArg(id, 1, "patch", "id");
1751
1751
  validateArg(value, 2, "patch", "value");
1752
1752
  await performAsyncSyscall("1.0/shallowMerge", {
1753
- id: convexToJson2(id),
1753
+ id: convexToJson(id),
1754
1754
  value: patchValueToJson(value),
1755
1755
  table
1756
1756
  });
@@ -1759,15 +1759,15 @@ async function replace(table, id, value) {
1759
1759
  validateArg(id, 1, "replace", "id");
1760
1760
  validateArg(value, 2, "replace", "value");
1761
1761
  await performAsyncSyscall("1.0/replace", {
1762
- id: convexToJson2(id),
1763
- value: convexToJson2(value),
1762
+ id: convexToJson(id),
1763
+ value: convexToJson(value),
1764
1764
  table
1765
1765
  });
1766
1766
  }
1767
1767
  async function delete_(table, id) {
1768
1768
  validateArg(id, 1, "delete", "id");
1769
1769
  await performAsyncSyscall("1.0/remove", {
1770
- id: convexToJson2(id),
1770
+ id: convexToJson(id),
1771
1771
  table
1772
1772
  });
1773
1773
  }
@@ -1834,7 +1834,7 @@ var init_database_impl = __esm(() => {
1834
1834
  };
1835
1835
  });
1836
1836
 
1837
- // ../core/node_modules/convex/dist/esm/server/impl/scheduler_impl.js
1837
+ // ../../node_modules/convex/dist/esm/server/impl/scheduler_impl.js
1838
1838
  function setupMutationScheduler() {
1839
1839
  return {
1840
1840
  runAfter: async (delayMs, functionReference, args) => {
@@ -1847,7 +1847,7 @@ function setupMutationScheduler() {
1847
1847
  },
1848
1848
  cancel: async (id) => {
1849
1849
  validateArg(id, 1, "cancel", "id");
1850
- const args = { id: convexToJson2(id) };
1850
+ const args = { id: convexToJson(id) };
1851
1851
  await performAsyncSyscall("1.0/cancel_job", args);
1852
1852
  }
1853
1853
  };
@@ -1868,7 +1868,7 @@ function runAfterSyscallArgs(delayMs, functionReference, args) {
1868
1868
  return {
1869
1869
  ...address,
1870
1870
  ts,
1871
- args: convexToJson2(functionArgs),
1871
+ args: convexToJson(functionArgs),
1872
1872
  version
1873
1873
  };
1874
1874
  }
@@ -1886,7 +1886,7 @@ function runAtSyscallArgs(ms_since_epoch_or_date, functionReference, args) {
1886
1886
  return {
1887
1887
  ...address,
1888
1888
  ts,
1889
- args: convexToJson2(functionArgs),
1889
+ args: convexToJson(functionArgs),
1890
1890
  version
1891
1891
  };
1892
1892
  }
@@ -1896,7 +1896,7 @@ var init_scheduler_impl = __esm(() => {
1896
1896
  init_paths();
1897
1897
  });
1898
1898
 
1899
- // ../core/node_modules/convex/dist/esm/server/impl/storage_impl.js
1899
+ // ../../node_modules/convex/dist/esm/server/impl/storage_impl.js
1900
1900
  function setupStorageReader(requestId) {
1901
1901
  return {
1902
1902
  getUrl: async (storageId) => {
@@ -1940,10 +1940,10 @@ var init_storage_impl = __esm(() => {
1940
1940
  init_syscall();
1941
1941
  });
1942
1942
 
1943
- // ../core/node_modules/convex/dist/esm/server/impl/registration_impl.js
1943
+ // ../../node_modules/convex/dist/esm/server/impl/registration_impl.js
1944
1944
  async function invokeMutation(func, argsStr) {
1945
1945
  const requestId = "";
1946
- const args = jsonToConvex2(JSON.parse(argsStr));
1946
+ const args = jsonToConvex(JSON.parse(argsStr));
1947
1947
  const mutationCtx = {
1948
1948
  db: setupWriter(),
1949
1949
  auth: setupAuth(requestId),
@@ -1954,7 +1954,7 @@ async function invokeMutation(func, argsStr) {
1954
1954
  };
1955
1955
  const result = await invokeFunction(func, mutationCtx, args);
1956
1956
  validateReturnValue(result);
1957
- return JSON.stringify(convexToJson2(result === undefined ? null : result));
1957
+ return JSON.stringify(convexToJson(result === undefined ? null : result));
1958
1958
  }
1959
1959
  function validateReturnValue(v2) {
1960
1960
  if (v2 instanceof QueryInitializerImpl || v2 instanceof QueryImpl) {
@@ -1979,7 +1979,7 @@ function dontCallDirectly(funcType, handler) {
1979
1979
  function serializeConvexErrorData(thrown) {
1980
1980
  if (typeof thrown === "object" && thrown !== null && Symbol.for("ConvexError") in thrown) {
1981
1981
  const error = thrown;
1982
- error.data = JSON.stringify(convexToJson2(error.data === undefined ? null : error.data));
1982
+ error.data = JSON.stringify(convexToJson(error.data === undefined ? null : error.data));
1983
1983
  error.ConvexErrorSymbol = Symbol.for("ConvexError");
1984
1984
  return error;
1985
1985
  } else {
@@ -2021,7 +2021,7 @@ function exportReturns(functionDefinition) {
2021
2021
  }
2022
2022
  async function invokeQuery(func, argsStr) {
2023
2023
  const requestId = "";
2024
- const args = jsonToConvex2(JSON.parse(argsStr));
2024
+ const args = jsonToConvex(JSON.parse(argsStr));
2025
2025
  const queryCtx = {
2026
2026
  db: setupReader(),
2027
2027
  auth: setupAuth(requestId),
@@ -2030,17 +2030,17 @@ async function invokeQuery(func, argsStr) {
2030
2030
  };
2031
2031
  const result = await invokeFunction(func, queryCtx, args);
2032
2032
  validateReturnValue(result);
2033
- return JSON.stringify(convexToJson2(result === undefined ? null : result));
2033
+ return JSON.stringify(convexToJson(result === undefined ? null : result));
2034
2034
  }
2035
2035
  async function runUdf(udfType, f, args) {
2036
2036
  const queryArgs = parseArgs(args);
2037
2037
  const syscallArgs = {
2038
2038
  udfType,
2039
- args: convexToJson2(queryArgs),
2039
+ args: convexToJson(queryArgs),
2040
2040
  ...getFunctionAddress(f)
2041
2041
  };
2042
2042
  const result = await performAsyncSyscall("1.0/runUdf", syscallArgs);
2043
- return jsonToConvex2(result);
2043
+ return jsonToConvex(result);
2044
2044
  }
2045
2045
  var mutationGeneric = (functionDefinition) => {
2046
2046
  const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
@@ -2077,7 +2077,7 @@ var init_registration_impl = __esm(() => {
2077
2077
  init_paths();
2078
2078
  });
2079
2079
 
2080
- // ../core/node_modules/convex/dist/esm/server/pagination.js
2080
+ // ../../node_modules/convex/dist/esm/server/pagination.js
2081
2081
  var paginationOptsValidator;
2082
2082
  var init_pagination = __esm(() => {
2083
2083
  init_validator();
@@ -2091,7 +2091,7 @@ var init_pagination = __esm(() => {
2091
2091
  });
2092
2092
  });
2093
2093
 
2094
- // ../core/node_modules/convex/dist/esm/server/index.js
2094
+ // ../../node_modules/convex/dist/esm/server/index.js
2095
2095
  var init_server = __esm(() => {
2096
2096
  init_registration_impl();
2097
2097
  init_pagination();
@@ -2323,9 +2323,9 @@ async function listSystemFunctions(options = {}) {
2323
2323
  });
2324
2324
  const analysisResults = await pooledMap(filteredListings, (listing) => analyzeModule(listing, componentPath), 20);
2325
2325
  const results = [];
2326
- for (let i3 = 0;i3 < filteredListings.length; i3++) {
2327
- const listing = filteredListings[i3];
2328
- const result = analysisResults[i3];
2326
+ for (let i2 = 0;i2 < filteredListings.length; i2++) {
2327
+ const listing = filteredListings[i2];
2328
+ const result = analysisResults[i2];
2329
2329
  if (result.status === "rejected") {
2330
2330
  if (!isNpmPackageError(result.reason)) {
2331
2331
  console.warn(`Failed to analyze module "${listing.path}":`, result.reason);
@@ -3199,7 +3199,7 @@ class ModuleRegistry {
3199
3199
  }
3200
3200
  async load(request) {
3201
3201
  const scopes = expandComponentScopes(request.componentPath);
3202
- const errors3 = [];
3202
+ const errors2 = [];
3203
3203
  let attempted = false;
3204
3204
  for (const scope of scopes) {
3205
3205
  const loaders = this.scopedLoaders.get(scope);
@@ -3214,7 +3214,7 @@ class ModuleRegistry {
3214
3214
  return result;
3215
3215
  }
3216
3216
  } catch (error2) {
3217
- errors3.push(error2);
3217
+ errors2.push(error2);
3218
3218
  }
3219
3219
  }
3220
3220
  }
@@ -3223,8 +3223,8 @@ class ModuleRegistry {
3223
3223
  throw new Error(`Unable to resolve ${description}. No module loaders are registered${request.componentPath ? ` for component "${request.componentPath}"` : ""}. Register a loader with runtime worker options (\`moduleLoader\`, \`moduleLoaders\`, or \`configureModuleLoaders\`).`);
3224
3224
  }
3225
3225
  const error = new Error(`Unable to resolve ${description}`);
3226
- if (errors3.length > 0) {
3227
- error.causes = errors3;
3226
+ if (errors2.length > 0) {
3227
+ error.causes = errors2;
3228
3228
  }
3229
3229
  throw error;
3230
3230
  }
@@ -3448,8 +3448,8 @@ function expandComponentScopes(componentPath) {
3448
3448
  if (componentPath) {
3449
3449
  const normalized = normalizeComponentPath(componentPath);
3450
3450
  const segments = normalized.split("/").filter(Boolean);
3451
- for (let i3 = segments.length;i3 > 0; i3--) {
3452
- scopes.push(segments.slice(0, i3).join("/"));
3451
+ for (let i2 = segments.length;i2 > 0; i2--) {
3452
+ scopes.push(segments.slice(0, i2).join("/"));
3453
3453
  }
3454
3454
  }
3455
3455
  scopes.push("");
@@ -3723,8 +3723,8 @@ Path: ${formatPath(path)}
3723
3723
  Value: ${formatValue(value)}
3724
3724
  Validator: v.array(...)`);
3725
3725
  }
3726
- for (let i3 = 0;i3 < value.length; i3++) {
3727
- validateValidator(validator2.value, value[i3], `${path}[${i3}]`, options);
3726
+ for (let i2 = 0;i2 < value.length; i2++) {
3727
+ validateValidator(validator2.value, value[i2], `${path}[${i2}]`, options);
3728
3728
  }
3729
3729
  return;
3730
3730
  }
@@ -3752,7 +3752,7 @@ Path: ${formatPath(path)}
3752
3752
  Value: ${formatValue(value)}
3753
3753
  Validator: v.object({...})`);
3754
3754
  }
3755
- if (!isSimpleObject3(value)) {
3755
+ if (!isSimpleObject2(value)) {
3756
3756
  throw new Error(`Value does not match validator.
3757
3757
  Path: ${formatPath(path)}
3758
3758
  Value: ${formatValue(value)}
@@ -3802,7 +3802,7 @@ function isMatchingValidatorTable(idTableName, validatorTableName, componentPath
3802
3802
  }
3803
3803
  return idBareName === validatorBareName;
3804
3804
  }
3805
- function isSimpleObject3(value) {
3805
+ function isSimpleObject2(value) {
3806
3806
  const isObject = typeof value === "object";
3807
3807
  const prototype = Object.getPrototypeOf(value);
3808
3808
  const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
@@ -4034,9 +4034,9 @@ function isValidBase32(str) {
4034
4034
  var ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz", ALPHABET_MAP;
4035
4035
  var init_base32 = __esm(() => {
4036
4036
  ALPHABET_MAP = new Map;
4037
- for (let i3 = 0;i3 < ALPHABET.length; i3++) {
4038
- ALPHABET_MAP.set(ALPHABET[i3], i3);
4039
- ALPHABET_MAP.set(ALPHABET[i3].toUpperCase(), i3);
4037
+ for (let i2 = 0;i2 < ALPHABET.length; i2++) {
4038
+ ALPHABET_MAP.set(ALPHABET[i2], i2);
4039
+ ALPHABET_MAP.set(ALPHABET[i2].toUpperCase(), i2);
4040
4040
  }
4041
4041
  ALPHABET_MAP.set("i", 1);
4042
4042
  ALPHABET_MAP.set("I", 1);
@@ -4193,8 +4193,8 @@ function isValidDocumentId(encoded) {
4193
4193
  }
4194
4194
  function internalIdToHex(internalId) {
4195
4195
  let hex = "";
4196
- for (let i3 = 0;i3 < internalId.length; i3++) {
4197
- hex += internalId[i3].toString(16).padStart(2, "0");
4196
+ for (let i2 = 0;i2 < internalId.length; i2++) {
4197
+ hex += internalId[i2].toString(16).padStart(2, "0");
4198
4198
  }
4199
4199
  return hex;
4200
4200
  }
@@ -4204,326 +4204,9 @@ var init_document_id = __esm(() => {
4204
4204
  cryptoGetRandomValues = crypto.getRandomValues.bind(crypto);
4205
4205
  });
4206
4206
 
4207
- // ../../node_modules/.bun/convex@1.28.0/node_modules/convex/dist/esm/values/base64.js
4208
- var lookup = [];
4209
- var revLookup = [];
4210
- var Arr = Uint8Array;
4211
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4212
- for (i = 0, len = code.length;i < len; ++i) {
4213
- lookup[i] = code[i];
4214
- revLookup[code.charCodeAt(i)] = i;
4215
- }
4216
- var i;
4217
- var len;
4218
- revLookup[45] = 62;
4219
- revLookup[95] = 63;
4220
- function getLens(b64) {
4221
- var len2 = b64.length;
4222
- if (len2 % 4 > 0) {
4223
- throw new Error("Invalid string. Length must be a multiple of 4");
4224
- }
4225
- var validLen = b64.indexOf("=");
4226
- if (validLen === -1)
4227
- validLen = len2;
4228
- var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
4229
- return [validLen, placeHoldersLen];
4230
- }
4231
- function _byteLength(_b64, validLen, placeHoldersLen) {
4232
- return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
4233
- }
4234
- function toByteArray(b64) {
4235
- var tmp;
4236
- var lens = getLens(b64);
4237
- var validLen = lens[0];
4238
- var placeHoldersLen = lens[1];
4239
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
4240
- var curByte = 0;
4241
- var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
4242
- var i2;
4243
- for (i2 = 0;i2 < len2; i2 += 4) {
4244
- tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
4245
- arr[curByte++] = tmp >> 16 & 255;
4246
- arr[curByte++] = tmp >> 8 & 255;
4247
- arr[curByte++] = tmp & 255;
4248
- }
4249
- if (placeHoldersLen === 2) {
4250
- tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
4251
- arr[curByte++] = tmp & 255;
4252
- }
4253
- if (placeHoldersLen === 1) {
4254
- tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
4255
- arr[curByte++] = tmp >> 8 & 255;
4256
- arr[curByte++] = tmp & 255;
4257
- }
4258
- return arr;
4259
- }
4260
- function tripletToBase64(num) {
4261
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
4262
- }
4263
- function encodeChunk(uint8, start, end) {
4264
- var tmp;
4265
- var output = [];
4266
- for (var i2 = start;i2 < end; i2 += 3) {
4267
- tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
4268
- output.push(tripletToBase64(tmp));
4269
- }
4270
- return output.join("");
4271
- }
4272
- function fromByteArray(uint8) {
4273
- var tmp;
4274
- var len2 = uint8.length;
4275
- var extraBytes = len2 % 3;
4276
- var parts = [];
4277
- var maxChunkLength = 16383;
4278
- for (var i2 = 0, len22 = len2 - extraBytes;i2 < len22; i2 += maxChunkLength) {
4279
- parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
4280
- }
4281
- if (extraBytes === 1) {
4282
- tmp = uint8[len2 - 1];
4283
- parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
4284
- } else if (extraBytes === 2) {
4285
- tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
4286
- parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
4287
- }
4288
- return parts.join("");
4289
- }
4290
-
4291
- // ../../node_modules/.bun/convex@1.28.0/node_modules/convex/dist/esm/common/index.js
4292
- function isSimpleObject(value) {
4293
- const isObject = typeof value === "object";
4294
- const prototype = Object.getPrototypeOf(value);
4295
- const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
4296
- return isObject && isSimple;
4297
- }
4207
+ // src/do-docstore.ts
4208
+ init_values();
4298
4209
 
4299
- // ../../node_modules/.bun/convex@1.28.0/node_modules/convex/dist/esm/values/value.js
4300
- var LITTLE_ENDIAN = true;
4301
- var MIN_INT64 = BigInt("-9223372036854775808");
4302
- var MAX_INT64 = BigInt("9223372036854775807");
4303
- var ZERO = BigInt("0");
4304
- var EIGHT = BigInt("8");
4305
- var TWOFIFTYSIX = BigInt("256");
4306
- function isSpecial(n) {
4307
- return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
4308
- }
4309
- function slowBigIntToBase64(value) {
4310
- if (value < ZERO) {
4311
- value -= MIN_INT64 + MIN_INT64;
4312
- }
4313
- let hex = value.toString(16);
4314
- if (hex.length % 2 === 1)
4315
- hex = "0" + hex;
4316
- const bytes = new Uint8Array(new ArrayBuffer(8));
4317
- let i2 = 0;
4318
- for (const hexByte of hex.match(/.{2}/g).reverse()) {
4319
- bytes.set([parseInt(hexByte, 16)], i2++);
4320
- value >>= EIGHT;
4321
- }
4322
- return fromByteArray(bytes);
4323
- }
4324
- function slowBase64ToBigInt(encoded) {
4325
- const integerBytes = toByteArray(encoded);
4326
- if (integerBytes.byteLength !== 8) {
4327
- throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
4328
- }
4329
- let value = ZERO;
4330
- let power = ZERO;
4331
- for (const byte of integerBytes) {
4332
- value += BigInt(byte) * TWOFIFTYSIX ** power;
4333
- power++;
4334
- }
4335
- if (value > MAX_INT64) {
4336
- value += MIN_INT64 + MIN_INT64;
4337
- }
4338
- return value;
4339
- }
4340
- function modernBigIntToBase64(value) {
4341
- if (value < MIN_INT64 || MAX_INT64 < value) {
4342
- throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
4343
- }
4344
- const buffer = new ArrayBuffer(8);
4345
- new DataView(buffer).setBigInt64(0, value, true);
4346
- return fromByteArray(new Uint8Array(buffer));
4347
- }
4348
- function modernBase64ToBigInt(encoded) {
4349
- const integerBytes = toByteArray(encoded);
4350
- if (integerBytes.byteLength !== 8) {
4351
- throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
4352
- }
4353
- const intBytesView = new DataView(integerBytes.buffer);
4354
- return intBytesView.getBigInt64(0, true);
4355
- }
4356
- var bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
4357
- var base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
4358
- var MAX_IDENTIFIER_LEN = 1024;
4359
- function validateObjectField(k) {
4360
- if (k.length > MAX_IDENTIFIER_LEN) {
4361
- throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN}.`);
4362
- }
4363
- if (k.startsWith("$")) {
4364
- throw new Error(`Field name ${k} starts with a '$', which is reserved.`);
4365
- }
4366
- for (let i2 = 0;i2 < k.length; i2 += 1) {
4367
- const charCode = k.charCodeAt(i2);
4368
- if (charCode < 32 || charCode >= 127) {
4369
- throw new Error(`Field name ${k} has invalid character '${k[i2]}': Field names can only contain non-control ASCII characters`);
4370
- }
4371
- }
4372
- }
4373
- function jsonToConvex(value) {
4374
- if (value === null) {
4375
- return value;
4376
- }
4377
- if (typeof value === "boolean") {
4378
- return value;
4379
- }
4380
- if (typeof value === "number") {
4381
- return value;
4382
- }
4383
- if (typeof value === "string") {
4384
- return value;
4385
- }
4386
- if (Array.isArray(value)) {
4387
- return value.map((value2) => jsonToConvex(value2));
4388
- }
4389
- if (typeof value !== "object") {
4390
- throw new Error(`Unexpected type of ${value}`);
4391
- }
4392
- const entries = Object.entries(value);
4393
- if (entries.length === 1) {
4394
- const key = entries[0][0];
4395
- if (key === "$bytes") {
4396
- if (typeof value.$bytes !== "string") {
4397
- throw new Error(`Malformed $bytes field on ${value}`);
4398
- }
4399
- return toByteArray(value.$bytes).buffer;
4400
- }
4401
- if (key === "$integer") {
4402
- if (typeof value.$integer !== "string") {
4403
- throw new Error(`Malformed $integer field on ${value}`);
4404
- }
4405
- return base64ToBigInt(value.$integer);
4406
- }
4407
- if (key === "$float") {
4408
- if (typeof value.$float !== "string") {
4409
- throw new Error(`Malformed $float field on ${value}`);
4410
- }
4411
- const floatBytes = toByteArray(value.$float);
4412
- if (floatBytes.byteLength !== 8) {
4413
- throw new Error(`Received ${floatBytes.byteLength} bytes, expected 8 for $float`);
4414
- }
4415
- const floatBytesView = new DataView(floatBytes.buffer);
4416
- const float = floatBytesView.getFloat64(0, LITTLE_ENDIAN);
4417
- if (!isSpecial(float)) {
4418
- throw new Error(`Float ${float} should be encoded as a number`);
4419
- }
4420
- return float;
4421
- }
4422
- if (key === "$set") {
4423
- throw new Error(`Received a Set which is no longer supported as a Convex type.`);
4424
- }
4425
- if (key === "$map") {
4426
- throw new Error(`Received a Map which is no longer supported as a Convex type.`);
4427
- }
4428
- }
4429
- const out = {};
4430
- for (const [k, v] of Object.entries(value)) {
4431
- validateObjectField(k);
4432
- out[k] = jsonToConvex(v);
4433
- }
4434
- return out;
4435
- }
4436
- function stringifyValueForError(value) {
4437
- return JSON.stringify(value, (_key, value2) => {
4438
- if (value2 === undefined) {
4439
- return "undefined";
4440
- }
4441
- if (typeof value2 === "bigint") {
4442
- return `${value2.toString()}n`;
4443
- }
4444
- return value2;
4445
- });
4446
- }
4447
- function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
4448
- if (value === undefined) {
4449
- const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError(originalValue)})`;
4450
- throw new Error(`undefined is not a valid Convex value${contextText}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
4451
- }
4452
- if (value === null) {
4453
- return value;
4454
- }
4455
- if (typeof value === "bigint") {
4456
- if (value < MIN_INT64 || MAX_INT64 < value) {
4457
- throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
4458
- }
4459
- return { $integer: bigIntToBase64(value) };
4460
- }
4461
- if (typeof value === "number") {
4462
- if (isSpecial(value)) {
4463
- const buffer = new ArrayBuffer(8);
4464
- new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN);
4465
- return { $float: fromByteArray(new Uint8Array(buffer)) };
4466
- } else {
4467
- return value;
4468
- }
4469
- }
4470
- if (typeof value === "boolean") {
4471
- return value;
4472
- }
4473
- if (typeof value === "string") {
4474
- return value;
4475
- }
4476
- if (value instanceof ArrayBuffer) {
4477
- return { $bytes: fromByteArray(new Uint8Array(value)) };
4478
- }
4479
- if (Array.isArray(value)) {
4480
- return value.map((value2, i2) => convexToJsonInternal(value2, originalValue, context + `[${i2}]`, false));
4481
- }
4482
- if (value instanceof Set) {
4483
- throw new Error(errorMessageForUnsupportedType(context, "Set", [...value], originalValue));
4484
- }
4485
- if (value instanceof Map) {
4486
- throw new Error(errorMessageForUnsupportedType(context, "Map", [...value], originalValue));
4487
- }
4488
- if (!isSimpleObject(value)) {
4489
- const theType = value?.constructor?.name;
4490
- const typeName = theType ? `${theType} ` : "";
4491
- throw new Error(errorMessageForUnsupportedType(context, typeName, value, originalValue));
4492
- }
4493
- const out = {};
4494
- const entries = Object.entries(value);
4495
- entries.sort(([k1, _v1], [k2, _v2]) => k1 === k2 ? 0 : k1 < k2 ? -1 : 1);
4496
- for (const [k, v] of entries) {
4497
- if (v !== undefined) {
4498
- validateObjectField(k);
4499
- out[k] = convexToJsonInternal(v, originalValue, context + `.${k}`, false);
4500
- } else if (includeTopLevelUndefined) {
4501
- validateObjectField(k);
4502
- out[k] = convexOrUndefinedToJsonInternal(v, originalValue, context + `.${k}`);
4503
- }
4504
- }
4505
- return out;
4506
- }
4507
- function errorMessageForUnsupportedType(context, typeName, value, originalValue) {
4508
- if (context) {
4509
- return `${typeName}${stringifyValueForError(value)} is not a supported Convex type (present at path ${context} in original object ${stringifyValueForError(originalValue)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`;
4510
- } else {
4511
- return `${typeName}${stringifyValueForError(value)} is not a supported Convex type.`;
4512
- }
4513
- }
4514
- function convexOrUndefinedToJsonInternal(value, originalValue, context) {
4515
- if (value === undefined) {
4516
- return { $undefined: null };
4517
- } else {
4518
- if (originalValue === undefined) {
4519
- throw new Error(`Programming error. Current value is ${stringifyValueForError(value)} but original value is undefined`);
4520
- }
4521
- return convexToJsonInternal(value, originalValue, context, false);
4522
- }
4523
- }
4524
- function convexToJson(value) {
4525
- return convexToJsonInternal(value, value, "", false);
4526
- }
4527
4210
  // ../core/dist/docstore/interface.js
4528
4211
  function documentIdKey(id) {
4529
4212
  return `${id.table}:${id.internalId}`;
@@ -4745,7 +4428,7 @@ init_schema_service();
4745
4428
  init_index_key_codec();
4746
4429
 
4747
4430
  // ../core/dist/queryengine/filters.js
4748
- function isSimpleObject4(value) {
4431
+ function isSimpleObject3(value) {
4749
4432
  const isObject = typeof value === "object" && value !== null;
4750
4433
  if (!isObject)
4751
4434
  return false;
@@ -4759,7 +4442,7 @@ function evaluateFieldPath(fieldPath, document) {
4759
4442
  for (const part of parts) {
4760
4443
  if (current == null)
4761
4444
  return;
4762
- if (!isSimpleObject4(current))
4445
+ if (!isSimpleObject3(current))
4763
4446
  return;
4764
4447
  current = current[part];
4765
4448
  }
@@ -4789,6 +4472,19 @@ function parseDeveloperId(developerId) {
4789
4472
  }
4790
4473
  return { table: parts.table, internalId: parts.internalId };
4791
4474
  }
4475
+ function parseStorageId(storageId) {
4476
+ const parsed = parseDeveloperId(storageId);
4477
+ if (parsed) {
4478
+ return parsed;
4479
+ }
4480
+ if (storageId.length === INTERNAL_ID_LENGTH * 2 && /^[0-9a-fA-F]+$/.test(storageId)) {
4481
+ return {
4482
+ table: stringToHex("_storage"),
4483
+ internalId: storageId.toLowerCase()
4484
+ };
4485
+ }
4486
+ return null;
4487
+ }
4792
4488
  function isTablePlaceholder(table) {
4793
4489
  return table.startsWith("#");
4794
4490
  }
@@ -5242,19 +4938,19 @@ class BlobStoreGateway {
5242
4938
  if (!this.storage) {
5243
4939
  return null;
5244
4940
  }
5245
- const docId = parseDeveloperId(storageId);
4941
+ const docId = parseStorageId(storageId);
5246
4942
  if (!docId) {
5247
- console.error(`[BlobStoreGateway] Failed to parse storage ID: ${storageId}`);
4943
+ console.debug(`[BlobStoreGateway] Failed to parse storage ID: ${storageId}`);
5248
4944
  return null;
5249
4945
  }
5250
4946
  const docValue = await this.queryRuntime.getVisibleDocumentById(storageId, docId);
5251
4947
  if (!docValue) {
5252
- console.error(`[BlobStoreGateway] Document not found for storage ID: ${storageId} (table: ${docId.table}, internalId: ${docId.internalId})`);
4948
+ console.debug(`[BlobStoreGateway] Document not found for storage ID: ${storageId} (table: ${docId.table}, internalId: ${docId.internalId}, ts: ${this.context.snapshotTimestamp})`);
5253
4949
  return null;
5254
4950
  }
5255
4951
  const storedBlob = await this.storage.get(docId.internalId);
5256
4952
  if (!storedBlob) {
5257
- console.error(`[BlobStoreGateway] Blob not found in storage: ${docId.internalId}`);
4953
+ console.debug(`[BlobStoreGateway] Blob not found in storage: ${docId.internalId}`);
5258
4954
  return null;
5259
4955
  }
5260
4956
  return storedBlob instanceof Blob ? storedBlob : new Blob([storedBlob]);
@@ -5263,7 +4959,7 @@ class BlobStoreGateway {
5263
4959
  if (!this.storage) {
5264
4960
  return null;
5265
4961
  }
5266
- const docId = parseDeveloperId(storageId);
4962
+ const docId = parseStorageId(storageId);
5267
4963
  if (!docId) {
5268
4964
  return null;
5269
4965
  }
@@ -5276,7 +4972,7 @@ class BlobStoreGateway {
5276
4972
  }
5277
4973
  async delete(storageId) {
5278
4974
  const storage2 = this.requireStorage();
5279
- const docId = parseDeveloperId(storageId);
4975
+ const docId = parseStorageId(storageId);
5280
4976
  if (!docId) {
5281
4977
  return;
5282
4978
  }
@@ -5338,8 +5034,9 @@ function resolveFunctionTarget(callArgs, currentComponentPath) {
5338
5034
  return parseFunctionHandleTarget(callArgs.functionHandle);
5339
5035
  }
5340
5036
  if (callArgs && typeof callArgs.functionHandle === "object" && callArgs.functionHandle !== null) {
5341
- if (typeof callArgs.functionHandle.handle === "string") {
5342
- return parseFunctionHandleTarget(callArgs.functionHandle.handle);
5037
+ const handle = callArgs.functionHandle;
5038
+ if (typeof handle.handle === "string") {
5039
+ return parseFunctionHandleTarget(handle.handle);
5343
5040
  }
5344
5041
  }
5345
5042
  if (callArgs && typeof callArgs.reference === "string") {
@@ -5434,7 +5131,7 @@ function evaluatePatchValue(value) {
5434
5131
  if (typeof value === "object" && value !== null && "$undefined" in value) {
5435
5132
  return;
5436
5133
  }
5437
- return jsonToConvex2(value);
5134
+ return jsonToConvex(value);
5438
5135
  }
5439
5136
 
5440
5137
  // ../core/dist/kernel/scheduler-gateway.js
@@ -5456,7 +5153,7 @@ class SchedulerGateway {
5456
5153
  const docId = { table: tableHex, internalId: internalIdHex, tableNumber };
5457
5154
  const developerId = this.context.useConvexIdFormat ? encodeDocumentId(tableNumber, internalIdBytes) : serializeDeveloperId(tableHex, internalIdHex);
5458
5155
  const timestamp2 = this.docStore.allocateTimestamp();
5459
- const argsValue = jsonToConvex2(convexToJson2(fnArgs));
5156
+ const argsValue = jsonToConvex(convexToJson(fnArgs));
5460
5157
  const formattedName = name.replace(/\.(js|ts|mjs|mts|cjs|cts):/g, ":");
5461
5158
  const docToInsert = {
5462
5159
  name: formattedName,
@@ -5585,17 +5282,15 @@ class ActionSyscalls {
5585
5282
  const type = args.udfType ?? args.type ?? "mutation";
5586
5283
  return await this.invocationManager.execute(target.udfPath, udfArguments, type, target.componentPath);
5587
5284
  }
5588
- handleCreateFunctionHandle(args) {
5285
+ async handleCreateFunctionHandle(args) {
5589
5286
  const target = resolveFunctionTarget(args, this.context.componentPath);
5590
5287
  return formatFunctionHandle(target.componentPath ?? "", target.udfPath);
5591
5288
  }
5592
5289
  async handleVectorSearch(args) {
5593
- const { query: vectorQuery } = args;
5594
- return this.queryRuntime.runVectorSearchAction(vectorQuery);
5290
+ return this.queryRuntime.runVectorSearchAction(args.query);
5595
5291
  }
5596
5292
  async handleSearchAction(args) {
5597
- const { query: searchQuery } = args;
5598
- return this.queryRuntime.runSearchAction(searchQuery);
5293
+ return this.queryRuntime.runSearchAction(args.query);
5599
5294
  }
5600
5295
  }
5601
5296
 
@@ -5658,7 +5353,7 @@ class DatabaseSyscalls {
5658
5353
  if (typeof table !== "string") {
5659
5354
  throw new Error("`table` argument for `insert` must be a string.");
5660
5355
  }
5661
- const convexValue = jsonToConvex2(value);
5356
+ const convexValue = jsonToConvex(value);
5662
5357
  if (typeof convexValue !== "object" || convexValue === null || Array.isArray(convexValue)) {
5663
5358
  throw new Error("The document value for `insert` must be an object.");
5664
5359
  }
@@ -5803,7 +5498,7 @@ class DatabaseSyscalls {
5803
5498
  }
5804
5499
  const fullTableName = await resolveTableName(docId, this.context.tableRegistry);
5805
5500
  const { tableName: bareTableName } = parseFullTableName(fullTableName);
5806
- const replaceValue = jsonToConvex2(value);
5501
+ const replaceValue = jsonToConvex(value);
5807
5502
  if (typeof replaceValue !== "object" || replaceValue === null || Array.isArray(replaceValue)) {
5808
5503
  throw new Error("The replacement value for `replace` must be an object.");
5809
5504
  }
@@ -5907,6 +5602,8 @@ function decodeJwtClaimsToken(token) {
5907
5602
  return null;
5908
5603
  }
5909
5604
  }
5605
+ var DEFAULT_JWKS_CACHE_TTL_MS = 5 * 60 * 1000;
5606
+ var MAX_JWKS_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
5910
5607
  var JWKS_CACHE = new Map;
5911
5608
  function decodeJwtUnsafe(token) {
5912
5609
  if (!token)
@@ -5990,13 +5687,13 @@ class QuerySyscalls {
5990
5687
  return { queryId };
5991
5688
  }
5992
5689
  handleQueryCleanup(args) {
5993
- const { queryId } = args;
5690
+ const queryId = args.queryId;
5994
5691
  delete this.pendingQueries[queryId];
5995
5692
  delete this.queryResults[queryId];
5996
5693
  return {};
5997
5694
  }
5998
5695
  async handleQueryStreamNext(args) {
5999
- const { queryId } = args;
5696
+ const queryId = args.queryId;
6000
5697
  if (this.pendingQueries[queryId]) {
6001
5698
  const query = this.pendingQueries[queryId];
6002
5699
  delete this.pendingQueries[queryId];
@@ -6168,9 +5865,9 @@ class SyscallRouter {
6168
5865
  throw new Error(`Unknown async syscall: ${op}`);
6169
5866
  }
6170
5867
  const parsedArgs = JSON.parse(jsonArgs);
6171
- const args = entry.argsFormat === "convex" ? jsonToConvex2(parsedArgs) : parsedArgs;
5868
+ const args = entry.argsFormat === "convex" ? jsonToConvex(parsedArgs) : parsedArgs;
6172
5869
  const result = await entry.handler(args);
6173
- return JSON.stringify(convexToJson2(result));
5870
+ return JSON.stringify(convexToJson(result));
6174
5871
  }
6175
5872
  }
6176
5873
 
@@ -6421,7 +6118,7 @@ class DODocStore {
6421
6118
  value
6422
6119
  };
6423
6120
  yield [
6424
- row.key,
6121
+ row.key.buffer,
6425
6122
  {
6426
6123
  ts: BigInt(row.ts),
6427
6124
  value: document,
@@ -6763,9 +6460,9 @@ class DODocStore {
6763
6460
  let dot = 0;
6764
6461
  let queryMagnitude = 0;
6765
6462
  let docMagnitude = 0;
6766
- for (let i3 = 0;i3 < vector.length; i3++) {
6767
- const q = vector[i3];
6768
- const d = embedding[i3];
6463
+ for (let i2 = 0;i2 < vector.length; i2++) {
6464
+ const q = vector[i2];
6465
+ const d = embedding[i2];
6769
6466
  dot += q * d;
6770
6467
  queryMagnitude += q * q;
6771
6468
  docMagnitude += d * d;
@@ -6789,8 +6486,8 @@ class DODocStore {
6789
6486
  }
6790
6487
  function hexToArrayBuffer3(hex) {
6791
6488
  const bytes = new Uint8Array(hex.length / 2);
6792
- for (let i3 = 0;i3 < hex.length; i3 += 2) {
6793
- bytes[i3 / 2] = parseInt(hex.substring(i3, i3 + 2), 16);
6489
+ for (let i2 = 0;i2 < hex.length; i2 += 2) {
6490
+ bytes[i2 / 2] = parseInt(hex.substring(i2, i2 + 2), 16);
6794
6491
  }
6795
6492
  return bytes;
6796
6493
  }