@concavejs/docstore-bun-sqlite 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.
- package/dist/index.js +257 -568
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16,211 +16,173 @@ var __export = (target, all) => {
|
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const matches = hex.match(/.{1,2}/g);
|
|
24
|
-
if (!matches) {
|
|
25
|
-
throw new Error(`Invalid hex string: ${hex}`);
|
|
26
|
-
}
|
|
27
|
-
return new Uint8Array(matches.map((byte) => parseInt(byte, 16))).buffer;
|
|
28
|
-
}
|
|
29
|
-
function arrayBufferToHex(buffer) {
|
|
30
|
-
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
31
|
-
}
|
|
32
|
-
function stringToHex(s) {
|
|
33
|
-
const buffer = new TextEncoder().encode(s);
|
|
34
|
-
return arrayBufferToHex(buffer.buffer);
|
|
35
|
-
}
|
|
36
|
-
function hexToString(hex) {
|
|
37
|
-
const buffer = hexToArrayBuffer(hex);
|
|
38
|
-
return new TextDecoder().decode(buffer);
|
|
39
|
-
}
|
|
40
|
-
function serializeDeveloperId(tableHex, internalIdHex) {
|
|
41
|
-
return `${tableHex}${DOC_ID_SEPARATOR}${internalIdHex}`;
|
|
42
|
-
}
|
|
43
|
-
function deserializeDeveloperId(developerId) {
|
|
44
|
-
if (!developerId) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
for (const separator of [DOC_ID_SEPARATOR, LEGACY_DOC_ID_SEPARATOR]) {
|
|
48
|
-
const parts = developerId.split(separator);
|
|
49
|
-
if (parts.length === 2 && parts[0] && parts[1]) {
|
|
50
|
-
return { table: parts[0], internalId: parts[1] };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
var DOC_ID_SEPARATOR = ":";
|
|
56
|
-
var LEGACY_DOC_ID_SEPARATOR = ";";
|
|
57
|
-
function getLens2(b64) {
|
|
58
|
-
var len3 = b64.length;
|
|
59
|
-
if (len3 % 4 > 0) {
|
|
19
|
+
function getLens(b64) {
|
|
20
|
+
var len2 = b64.length;
|
|
21
|
+
if (len2 % 4 > 0) {
|
|
60
22
|
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
61
23
|
}
|
|
62
24
|
var validLen = b64.indexOf("=");
|
|
63
25
|
if (validLen === -1)
|
|
64
|
-
validLen =
|
|
65
|
-
var placeHoldersLen = validLen ===
|
|
26
|
+
validLen = len2;
|
|
27
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
66
28
|
return [validLen, placeHoldersLen];
|
|
67
29
|
}
|
|
68
|
-
function
|
|
30
|
+
function _byteLength(_b64, validLen, placeHoldersLen) {
|
|
69
31
|
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
70
32
|
}
|
|
71
|
-
function
|
|
33
|
+
function toByteArray(b64) {
|
|
72
34
|
var tmp;
|
|
73
|
-
var lens =
|
|
35
|
+
var lens = getLens(b64);
|
|
74
36
|
var validLen = lens[0];
|
|
75
37
|
var placeHoldersLen = lens[1];
|
|
76
|
-
var arr = new
|
|
38
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
77
39
|
var curByte = 0;
|
|
78
|
-
var
|
|
79
|
-
var
|
|
80
|
-
for (
|
|
81
|
-
tmp =
|
|
40
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
41
|
+
var i2;
|
|
42
|
+
for (i2 = 0;i2 < len2; i2 += 4) {
|
|
43
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
82
44
|
arr[curByte++] = tmp >> 16 & 255;
|
|
83
45
|
arr[curByte++] = tmp >> 8 & 255;
|
|
84
46
|
arr[curByte++] = tmp & 255;
|
|
85
47
|
}
|
|
86
48
|
if (placeHoldersLen === 2) {
|
|
87
|
-
tmp =
|
|
49
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
88
50
|
arr[curByte++] = tmp & 255;
|
|
89
51
|
}
|
|
90
52
|
if (placeHoldersLen === 1) {
|
|
91
|
-
tmp =
|
|
53
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
92
54
|
arr[curByte++] = tmp >> 8 & 255;
|
|
93
55
|
arr[curByte++] = tmp & 255;
|
|
94
56
|
}
|
|
95
57
|
return arr;
|
|
96
58
|
}
|
|
97
|
-
function
|
|
98
|
-
return
|
|
59
|
+
function tripletToBase64(num) {
|
|
60
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
99
61
|
}
|
|
100
|
-
function
|
|
62
|
+
function encodeChunk(uint8, start, end) {
|
|
101
63
|
var tmp;
|
|
102
64
|
var output = [];
|
|
103
|
-
for (var
|
|
104
|
-
tmp = (uint8[
|
|
105
|
-
output.push(
|
|
65
|
+
for (var i2 = start;i2 < end; i2 += 3) {
|
|
66
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
67
|
+
output.push(tripletToBase64(tmp));
|
|
106
68
|
}
|
|
107
69
|
return output.join("");
|
|
108
70
|
}
|
|
109
|
-
function
|
|
71
|
+
function fromByteArray(uint8) {
|
|
110
72
|
var tmp;
|
|
111
|
-
var
|
|
112
|
-
var extraBytes =
|
|
73
|
+
var len2 = uint8.length;
|
|
74
|
+
var extraBytes = len2 % 3;
|
|
113
75
|
var parts = [];
|
|
114
76
|
var maxChunkLength = 16383;
|
|
115
|
-
for (var
|
|
116
|
-
parts.push(
|
|
77
|
+
for (var i2 = 0, len22 = len2 - extraBytes;i2 < len22; i2 += maxChunkLength) {
|
|
78
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
117
79
|
}
|
|
118
80
|
if (extraBytes === 1) {
|
|
119
|
-
tmp = uint8[
|
|
120
|
-
parts.push(
|
|
81
|
+
tmp = uint8[len2 - 1];
|
|
82
|
+
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
|
|
121
83
|
} else if (extraBytes === 2) {
|
|
122
|
-
tmp = (uint8[
|
|
123
|
-
parts.push(
|
|
84
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
85
|
+
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
|
|
124
86
|
}
|
|
125
87
|
return parts.join("");
|
|
126
88
|
}
|
|
127
|
-
var
|
|
128
|
-
var
|
|
129
|
-
var
|
|
130
|
-
var
|
|
131
|
-
var
|
|
132
|
-
var
|
|
89
|
+
var lookup;
|
|
90
|
+
var revLookup;
|
|
91
|
+
var Arr;
|
|
92
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
93
|
+
var i;
|
|
94
|
+
var len;
|
|
133
95
|
var init_base64 = __esm(() => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
for (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
96
|
+
lookup = [];
|
|
97
|
+
revLookup = [];
|
|
98
|
+
Arr = Uint8Array;
|
|
99
|
+
for (i = 0, len = code.length;i < len; ++i) {
|
|
100
|
+
lookup[i] = code[i];
|
|
101
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
102
|
+
}
|
|
103
|
+
revLookup[45] = 62;
|
|
104
|
+
revLookup[95] = 63;
|
|
143
105
|
});
|
|
144
106
|
function parseArgs(args) {
|
|
145
107
|
if (args === undefined) {
|
|
146
108
|
return {};
|
|
147
109
|
}
|
|
148
|
-
if (!
|
|
110
|
+
if (!isSimpleObject(args)) {
|
|
149
111
|
throw new Error(`The arguments to a Convex function must be an object. Received: ${args}`);
|
|
150
112
|
}
|
|
151
113
|
return args;
|
|
152
114
|
}
|
|
153
|
-
function
|
|
115
|
+
function isSimpleObject(value) {
|
|
154
116
|
const isObject = typeof value === "object";
|
|
155
117
|
const prototype = Object.getPrototypeOf(value);
|
|
156
118
|
const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
|
|
157
119
|
return isObject && isSimple;
|
|
158
120
|
}
|
|
159
|
-
function
|
|
121
|
+
function isSpecial(n) {
|
|
160
122
|
return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
|
|
161
123
|
}
|
|
162
|
-
function
|
|
163
|
-
if (value <
|
|
164
|
-
value -=
|
|
124
|
+
function slowBigIntToBase64(value) {
|
|
125
|
+
if (value < ZERO) {
|
|
126
|
+
value -= MIN_INT64 + MIN_INT64;
|
|
165
127
|
}
|
|
166
128
|
let hex = value.toString(16);
|
|
167
129
|
if (hex.length % 2 === 1)
|
|
168
130
|
hex = "0" + hex;
|
|
169
131
|
const bytes = new Uint8Array(new ArrayBuffer(8));
|
|
170
|
-
let
|
|
132
|
+
let i2 = 0;
|
|
171
133
|
for (const hexByte of hex.match(/.{2}/g).reverse()) {
|
|
172
|
-
bytes.set([parseInt(hexByte, 16)],
|
|
173
|
-
value >>=
|
|
134
|
+
bytes.set([parseInt(hexByte, 16)], i2++);
|
|
135
|
+
value >>= EIGHT;
|
|
174
136
|
}
|
|
175
|
-
return
|
|
137
|
+
return fromByteArray(bytes);
|
|
176
138
|
}
|
|
177
|
-
function
|
|
178
|
-
const integerBytes =
|
|
139
|
+
function slowBase64ToBigInt(encoded) {
|
|
140
|
+
const integerBytes = toByteArray(encoded);
|
|
179
141
|
if (integerBytes.byteLength !== 8) {
|
|
180
142
|
throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
181
143
|
}
|
|
182
|
-
let value =
|
|
183
|
-
let power =
|
|
144
|
+
let value = ZERO;
|
|
145
|
+
let power = ZERO;
|
|
184
146
|
for (const byte of integerBytes) {
|
|
185
|
-
value += BigInt(byte) *
|
|
147
|
+
value += BigInt(byte) * TWOFIFTYSIX ** power;
|
|
186
148
|
power++;
|
|
187
149
|
}
|
|
188
|
-
if (value >
|
|
189
|
-
value +=
|
|
150
|
+
if (value > MAX_INT64) {
|
|
151
|
+
value += MIN_INT64 + MIN_INT64;
|
|
190
152
|
}
|
|
191
153
|
return value;
|
|
192
154
|
}
|
|
193
|
-
function
|
|
194
|
-
if (value <
|
|
155
|
+
function modernBigIntToBase64(value) {
|
|
156
|
+
if (value < MIN_INT64 || MAX_INT64 < value) {
|
|
195
157
|
throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
196
158
|
}
|
|
197
159
|
const buffer = new ArrayBuffer(8);
|
|
198
160
|
new DataView(buffer).setBigInt64(0, value, true);
|
|
199
|
-
return
|
|
161
|
+
return fromByteArray(new Uint8Array(buffer));
|
|
200
162
|
}
|
|
201
|
-
function
|
|
202
|
-
const integerBytes =
|
|
163
|
+
function modernBase64ToBigInt(encoded) {
|
|
164
|
+
const integerBytes = toByteArray(encoded);
|
|
203
165
|
if (integerBytes.byteLength !== 8) {
|
|
204
166
|
throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
205
167
|
}
|
|
206
168
|
const intBytesView = new DataView(integerBytes.buffer);
|
|
207
169
|
return intBytesView.getBigInt64(0, true);
|
|
208
170
|
}
|
|
209
|
-
function
|
|
210
|
-
if (k.length >
|
|
211
|
-
throw new Error(`Field name ${k} exceeds maximum field name length ${
|
|
171
|
+
function validateObjectField(k) {
|
|
172
|
+
if (k.length > MAX_IDENTIFIER_LEN) {
|
|
173
|
+
throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN}.`);
|
|
212
174
|
}
|
|
213
175
|
if (k.startsWith("$")) {
|
|
214
176
|
throw new Error(`Field name ${k} starts with a '$', which is reserved.`);
|
|
215
177
|
}
|
|
216
|
-
for (let
|
|
217
|
-
const charCode = k.charCodeAt(
|
|
178
|
+
for (let i2 = 0;i2 < k.length; i2 += 1) {
|
|
179
|
+
const charCode = k.charCodeAt(i2);
|
|
218
180
|
if (charCode < 32 || charCode >= 127) {
|
|
219
|
-
throw new Error(`Field name ${k} has invalid character '${k[
|
|
181
|
+
throw new Error(`Field name ${k} has invalid character '${k[i2]}': Field names can only contain non-control ASCII characters`);
|
|
220
182
|
}
|
|
221
183
|
}
|
|
222
184
|
}
|
|
223
|
-
function
|
|
185
|
+
function jsonToConvex(value) {
|
|
224
186
|
if (value === null) {
|
|
225
187
|
return value;
|
|
226
188
|
}
|
|
@@ -234,7 +196,7 @@ function jsonToConvex2(value) {
|
|
|
234
196
|
return value;
|
|
235
197
|
}
|
|
236
198
|
if (Array.isArray(value)) {
|
|
237
|
-
return value.map((value2) =>
|
|
199
|
+
return value.map((value2) => jsonToConvex(value2));
|
|
238
200
|
}
|
|
239
201
|
if (typeof value !== "object") {
|
|
240
202
|
throw new Error(`Unexpected type of ${value}`);
|
|
@@ -246,25 +208,25 @@ function jsonToConvex2(value) {
|
|
|
246
208
|
if (typeof value.$bytes !== "string") {
|
|
247
209
|
throw new Error(`Malformed $bytes field on ${value}`);
|
|
248
210
|
}
|
|
249
|
-
return
|
|
211
|
+
return toByteArray(value.$bytes).buffer;
|
|
250
212
|
}
|
|
251
213
|
if (key === "$integer") {
|
|
252
214
|
if (typeof value.$integer !== "string") {
|
|
253
215
|
throw new Error(`Malformed $integer field on ${value}`);
|
|
254
216
|
}
|
|
255
|
-
return
|
|
217
|
+
return base64ToBigInt(value.$integer);
|
|
256
218
|
}
|
|
257
219
|
if (key === "$float") {
|
|
258
220
|
if (typeof value.$float !== "string") {
|
|
259
221
|
throw new Error(`Malformed $float field on ${value}`);
|
|
260
222
|
}
|
|
261
|
-
const floatBytes =
|
|
223
|
+
const floatBytes = toByteArray(value.$float);
|
|
262
224
|
if (floatBytes.byteLength !== 8) {
|
|
263
225
|
throw new Error(`Received ${floatBytes.byteLength} bytes, expected 8 for $float`);
|
|
264
226
|
}
|
|
265
227
|
const floatBytesView = new DataView(floatBytes.buffer);
|
|
266
|
-
const float = floatBytesView.getFloat64(0,
|
|
267
|
-
if (!
|
|
228
|
+
const float = floatBytesView.getFloat64(0, LITTLE_ENDIAN);
|
|
229
|
+
if (!isSpecial(float)) {
|
|
268
230
|
throw new Error(`Float ${float} should be encoded as a number`);
|
|
269
231
|
}
|
|
270
232
|
return float;
|
|
@@ -278,12 +240,12 @@ function jsonToConvex2(value) {
|
|
|
278
240
|
}
|
|
279
241
|
const out = {};
|
|
280
242
|
for (const [k, v] of Object.entries(value)) {
|
|
281
|
-
|
|
282
|
-
out[k] =
|
|
243
|
+
validateObjectField(k);
|
|
244
|
+
out[k] = jsonToConvex(v);
|
|
283
245
|
}
|
|
284
246
|
return out;
|
|
285
247
|
}
|
|
286
|
-
function
|
|
248
|
+
function stringifyValueForError(value) {
|
|
287
249
|
const str = JSON.stringify(value, (_key, value2) => {
|
|
288
250
|
if (value2 === undefined) {
|
|
289
251
|
return "undefined";
|
|
@@ -293,9 +255,9 @@ function stringifyValueForError2(value) {
|
|
|
293
255
|
}
|
|
294
256
|
return value2;
|
|
295
257
|
});
|
|
296
|
-
if (str.length >
|
|
258
|
+
if (str.length > MAX_VALUE_FOR_ERROR_LEN) {
|
|
297
259
|
const rest = "[...truncated]";
|
|
298
|
-
let truncateAt =
|
|
260
|
+
let truncateAt = MAX_VALUE_FOR_ERROR_LEN - rest.length;
|
|
299
261
|
const codePoint = str.codePointAt(truncateAt - 1);
|
|
300
262
|
if (codePoint !== undefined && codePoint > 65535) {
|
|
301
263
|
truncateAt -= 1;
|
|
@@ -304,25 +266,25 @@ function stringifyValueForError2(value) {
|
|
|
304
266
|
}
|
|
305
267
|
return str;
|
|
306
268
|
}
|
|
307
|
-
function
|
|
269
|
+
function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
|
|
308
270
|
if (value === undefined) {
|
|
309
|
-
const contextText = context && ` (present at path ${context} in original object ${
|
|
271
|
+
const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError(originalValue)})`;
|
|
310
272
|
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.`);
|
|
311
273
|
}
|
|
312
274
|
if (value === null) {
|
|
313
275
|
return value;
|
|
314
276
|
}
|
|
315
277
|
if (typeof value === "bigint") {
|
|
316
|
-
if (value <
|
|
278
|
+
if (value < MIN_INT64 || MAX_INT64 < value) {
|
|
317
279
|
throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
318
280
|
}
|
|
319
|
-
return { $integer:
|
|
281
|
+
return { $integer: bigIntToBase64(value) };
|
|
320
282
|
}
|
|
321
283
|
if (typeof value === "number") {
|
|
322
|
-
if (
|
|
284
|
+
if (isSpecial(value)) {
|
|
323
285
|
const buffer = new ArrayBuffer(8);
|
|
324
|
-
new DataView(buffer).setFloat64(0, value,
|
|
325
|
-
return { $float:
|
|
286
|
+
new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN);
|
|
287
|
+
return { $float: fromByteArray(new Uint8Array(buffer)) };
|
|
326
288
|
} else {
|
|
327
289
|
return value;
|
|
328
290
|
}
|
|
@@ -334,81 +296,81 @@ function convexToJsonInternal2(value, originalValue, context, includeTopLevelUnd
|
|
|
334
296
|
return value;
|
|
335
297
|
}
|
|
336
298
|
if (value instanceof ArrayBuffer) {
|
|
337
|
-
return { $bytes:
|
|
299
|
+
return { $bytes: fromByteArray(new Uint8Array(value)) };
|
|
338
300
|
}
|
|
339
301
|
if (Array.isArray(value)) {
|
|
340
|
-
return value.map((value2,
|
|
302
|
+
return value.map((value2, i2) => convexToJsonInternal(value2, originalValue, context + `[${i2}]`, false));
|
|
341
303
|
}
|
|
342
304
|
if (value instanceof Set) {
|
|
343
|
-
throw new Error(
|
|
305
|
+
throw new Error(errorMessageForUnsupportedType(context, "Set", [...value], originalValue));
|
|
344
306
|
}
|
|
345
307
|
if (value instanceof Map) {
|
|
346
|
-
throw new Error(
|
|
308
|
+
throw new Error(errorMessageForUnsupportedType(context, "Map", [...value], originalValue));
|
|
347
309
|
}
|
|
348
|
-
if (!
|
|
310
|
+
if (!isSimpleObject(value)) {
|
|
349
311
|
const theType = value?.constructor?.name;
|
|
350
312
|
const typeName = theType ? `${theType} ` : "";
|
|
351
|
-
throw new Error(
|
|
313
|
+
throw new Error(errorMessageForUnsupportedType(context, typeName, value, originalValue));
|
|
352
314
|
}
|
|
353
315
|
const out = {};
|
|
354
316
|
const entries = Object.entries(value);
|
|
355
317
|
entries.sort(([k1, _v1], [k2, _v2]) => k1 === k2 ? 0 : k1 < k2 ? -1 : 1);
|
|
356
318
|
for (const [k, v] of entries) {
|
|
357
319
|
if (v !== undefined) {
|
|
358
|
-
|
|
359
|
-
out[k] =
|
|
320
|
+
validateObjectField(k);
|
|
321
|
+
out[k] = convexToJsonInternal(v, originalValue, context + `.${k}`, false);
|
|
360
322
|
} else if (includeTopLevelUndefined) {
|
|
361
|
-
|
|
362
|
-
out[k] =
|
|
323
|
+
validateObjectField(k);
|
|
324
|
+
out[k] = convexOrUndefinedToJsonInternal(v, originalValue, context + `.${k}`);
|
|
363
325
|
}
|
|
364
326
|
}
|
|
365
327
|
return out;
|
|
366
328
|
}
|
|
367
|
-
function
|
|
329
|
+
function errorMessageForUnsupportedType(context, typeName, value, originalValue) {
|
|
368
330
|
if (context) {
|
|
369
|
-
return `${typeName}${
|
|
331
|
+
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.`;
|
|
370
332
|
} else {
|
|
371
|
-
return `${typeName}${
|
|
333
|
+
return `${typeName}${stringifyValueForError(value)} is not a supported Convex type.`;
|
|
372
334
|
}
|
|
373
335
|
}
|
|
374
|
-
function
|
|
336
|
+
function convexOrUndefinedToJsonInternal(value, originalValue, context) {
|
|
375
337
|
if (value === undefined) {
|
|
376
338
|
return { $undefined: null };
|
|
377
339
|
} else {
|
|
378
340
|
if (originalValue === undefined) {
|
|
379
|
-
throw new Error(`Programming error. Current value is ${
|
|
341
|
+
throw new Error(`Programming error. Current value is ${stringifyValueForError(value)} but original value is undefined`);
|
|
380
342
|
}
|
|
381
|
-
return
|
|
343
|
+
return convexToJsonInternal(value, originalValue, context, false);
|
|
382
344
|
}
|
|
383
345
|
}
|
|
384
|
-
function
|
|
385
|
-
return
|
|
346
|
+
function convexToJson(value) {
|
|
347
|
+
return convexToJsonInternal(value, value, "", false);
|
|
386
348
|
}
|
|
387
349
|
function convexOrUndefinedToJson(value) {
|
|
388
|
-
return
|
|
350
|
+
return convexOrUndefinedToJsonInternal(value, value, "");
|
|
389
351
|
}
|
|
390
352
|
function patchValueToJson(value) {
|
|
391
|
-
return
|
|
392
|
-
}
|
|
393
|
-
var
|
|
394
|
-
var
|
|
395
|
-
var
|
|
396
|
-
var
|
|
397
|
-
var
|
|
398
|
-
var
|
|
399
|
-
var
|
|
400
|
-
var
|
|
401
|
-
var
|
|
402
|
-
var
|
|
353
|
+
return convexToJsonInternal(value, value, "", true);
|
|
354
|
+
}
|
|
355
|
+
var LITTLE_ENDIAN = true;
|
|
356
|
+
var MIN_INT64;
|
|
357
|
+
var MAX_INT64;
|
|
358
|
+
var ZERO;
|
|
359
|
+
var EIGHT;
|
|
360
|
+
var TWOFIFTYSIX;
|
|
361
|
+
var bigIntToBase64;
|
|
362
|
+
var base64ToBigInt;
|
|
363
|
+
var MAX_IDENTIFIER_LEN = 1024;
|
|
364
|
+
var MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
403
365
|
var init_value = __esm(() => {
|
|
404
366
|
init_base64();
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
367
|
+
MIN_INT64 = BigInt("-9223372036854775808");
|
|
368
|
+
MAX_INT64 = BigInt("9223372036854775807");
|
|
369
|
+
ZERO = BigInt("0");
|
|
370
|
+
EIGHT = BigInt("8");
|
|
371
|
+
TWOFIFTYSIX = BigInt("256");
|
|
372
|
+
bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
|
|
373
|
+
base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
|
|
412
374
|
});
|
|
413
375
|
function throwUndefinedValidatorError(context, fieldName) {
|
|
414
376
|
const fieldInfo = fieldName !== undefined ? ` for field "${fieldName}"` : "";
|
|
@@ -648,7 +610,7 @@ var init_validators = __esm(() => {
|
|
|
648
610
|
get json() {
|
|
649
611
|
return {
|
|
650
612
|
type: this.kind,
|
|
651
|
-
value:
|
|
613
|
+
value: convexToJson(this.value)
|
|
652
614
|
};
|
|
653
615
|
}
|
|
654
616
|
asOptional() {
|
|
@@ -849,7 +811,7 @@ var init_errors = __esm(() => {
|
|
|
849
811
|
IDENTIFYING_FIELD = Symbol.for("ConvexError");
|
|
850
812
|
ConvexError = class ConvexError2 extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
|
|
851
813
|
constructor(data) {
|
|
852
|
-
super(typeof data === "string" ? data :
|
|
814
|
+
super(typeof data === "string" ? data : stringifyValueForError(data));
|
|
853
815
|
__publicField2(this, "name", "ConvexError");
|
|
854
816
|
__publicField2(this, "data");
|
|
855
817
|
__publicField2(this, _a, true);
|
|
@@ -862,6 +824,44 @@ var init_values = __esm(() => {
|
|
|
862
824
|
init_validator();
|
|
863
825
|
init_errors();
|
|
864
826
|
});
|
|
827
|
+
function hexToArrayBuffer(hex) {
|
|
828
|
+
if (hex === "") {
|
|
829
|
+
return new Uint8Array(0).buffer;
|
|
830
|
+
}
|
|
831
|
+
const matches = hex.match(/.{1,2}/g);
|
|
832
|
+
if (!matches) {
|
|
833
|
+
throw new Error(`Invalid hex string: ${hex}`);
|
|
834
|
+
}
|
|
835
|
+
return new Uint8Array(matches.map((byte) => parseInt(byte, 16))).buffer;
|
|
836
|
+
}
|
|
837
|
+
function arrayBufferToHex(buffer) {
|
|
838
|
+
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
839
|
+
}
|
|
840
|
+
function stringToHex(s) {
|
|
841
|
+
const buffer = new TextEncoder().encode(s);
|
|
842
|
+
return arrayBufferToHex(buffer.buffer);
|
|
843
|
+
}
|
|
844
|
+
function hexToString(hex) {
|
|
845
|
+
const buffer = hexToArrayBuffer(hex);
|
|
846
|
+
return new TextDecoder().decode(buffer);
|
|
847
|
+
}
|
|
848
|
+
function serializeDeveloperId(tableHex, internalIdHex) {
|
|
849
|
+
return `${tableHex}${DOC_ID_SEPARATOR}${internalIdHex}`;
|
|
850
|
+
}
|
|
851
|
+
function deserializeDeveloperId(developerId) {
|
|
852
|
+
if (!developerId) {
|
|
853
|
+
return null;
|
|
854
|
+
}
|
|
855
|
+
for (const separator of [DOC_ID_SEPARATOR, LEGACY_DOC_ID_SEPARATOR]) {
|
|
856
|
+
const parts = developerId.split(separator);
|
|
857
|
+
if (parts.length === 2 && parts[0] && parts[1]) {
|
|
858
|
+
return { table: parts[0], internalId: parts[1] };
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
863
|
+
var DOC_ID_SEPARATOR = ":";
|
|
864
|
+
var LEGACY_DOC_ID_SEPARATOR = ";";
|
|
865
865
|
function encodeNumber(n) {
|
|
866
866
|
const buffer = new ArrayBuffer(8);
|
|
867
867
|
const view = new DataView(buffer);
|
|
@@ -870,8 +870,8 @@ function encodeNumber(n) {
|
|
|
870
870
|
if (n >= 0) {
|
|
871
871
|
bytes[0] ^= 128;
|
|
872
872
|
} else {
|
|
873
|
-
for (let
|
|
874
|
-
bytes[
|
|
873
|
+
for (let i2 = 0;i2 < 8; i2++) {
|
|
874
|
+
bytes[i2] ^= 255;
|
|
875
875
|
}
|
|
876
876
|
}
|
|
877
877
|
return bytes;
|
|
@@ -984,10 +984,10 @@ function compareIndexKeys(a, b) {
|
|
|
984
984
|
const viewA = new Uint8Array(a);
|
|
985
985
|
const viewB = new Uint8Array(b);
|
|
986
986
|
const minLen = Math.min(viewA.length, viewB.length);
|
|
987
|
-
for (let
|
|
988
|
-
if (viewA[
|
|
987
|
+
for (let i2 = 0;i2 < minLen; i2++) {
|
|
988
|
+
if (viewA[i2] < viewB[i2])
|
|
989
989
|
return -1;
|
|
990
|
-
if (viewA[
|
|
990
|
+
if (viewA[i2] > viewB[i2])
|
|
991
991
|
return 1;
|
|
992
992
|
}
|
|
993
993
|
if (viewA.length < viewB.length)
|
|
@@ -1136,7 +1136,7 @@ async function performAsyncSyscall(op, arg) {
|
|
|
1136
1136
|
} catch (e) {
|
|
1137
1137
|
if (e.data !== undefined) {
|
|
1138
1138
|
const rethrown = new ConvexError(e.message);
|
|
1139
|
-
rethrown.data =
|
|
1139
|
+
rethrown.data = jsonToConvex(e.data);
|
|
1140
1140
|
throw rethrown;
|
|
1141
1141
|
}
|
|
1142
1142
|
throw new Error(e.message);
|
|
@@ -1530,7 +1530,7 @@ var init_query_impl = __esm(() => {
|
|
|
1530
1530
|
const syscallJSON = await performAsyncSyscall("1.0/count", {
|
|
1531
1531
|
table: this.tableName
|
|
1532
1532
|
});
|
|
1533
|
-
const syscallResult =
|
|
1533
|
+
const syscallResult = jsonToConvex(syscallJSON);
|
|
1534
1534
|
return syscallResult;
|
|
1535
1535
|
}
|
|
1536
1536
|
filter(predicate) {
|
|
@@ -1640,7 +1640,7 @@ var init_query_impl = __esm(() => {
|
|
|
1640
1640
|
if (done) {
|
|
1641
1641
|
this.closeQuery();
|
|
1642
1642
|
}
|
|
1643
|
-
const convexValue =
|
|
1643
|
+
const convexValue = jsonToConvex(value);
|
|
1644
1644
|
return { value: convexValue, done };
|
|
1645
1645
|
}
|
|
1646
1646
|
return() {
|
|
@@ -1667,7 +1667,7 @@ var init_query_impl = __esm(() => {
|
|
|
1667
1667
|
version
|
|
1668
1668
|
});
|
|
1669
1669
|
return {
|
|
1670
|
-
page: page.map((json) =>
|
|
1670
|
+
page: page.map((json) => jsonToConvex(json)),
|
|
1671
1671
|
isDone,
|
|
1672
1672
|
continueCursor,
|
|
1673
1673
|
splitCursor,
|
|
@@ -1709,13 +1709,13 @@ async function get(table, id, isSystem) {
|
|
|
1709
1709
|
throw new Error(`Invalid argument \`id\` for \`db.get\`, expected string but got '${typeof id}': ${id}`);
|
|
1710
1710
|
}
|
|
1711
1711
|
const args = {
|
|
1712
|
-
id:
|
|
1712
|
+
id: convexToJson(id),
|
|
1713
1713
|
isSystem,
|
|
1714
1714
|
version,
|
|
1715
1715
|
table
|
|
1716
1716
|
};
|
|
1717
1717
|
const syscallJSON = await performAsyncSyscall("1.0/get", args);
|
|
1718
|
-
return
|
|
1718
|
+
return jsonToConvex(syscallJSON);
|
|
1719
1719
|
}
|
|
1720
1720
|
function setupReader() {
|
|
1721
1721
|
const reader = (isSystem = false) => {
|
|
@@ -1737,7 +1737,7 @@ function setupReader() {
|
|
|
1737
1737
|
table: tableName,
|
|
1738
1738
|
idString: id
|
|
1739
1739
|
});
|
|
1740
|
-
const syscallResult =
|
|
1740
|
+
const syscallResult = jsonToConvex(syscallJSON);
|
|
1741
1741
|
return syscallResult.id;
|
|
1742
1742
|
},
|
|
1743
1743
|
system: null,
|
|
@@ -1759,16 +1759,16 @@ async function insert(tableName, value) {
|
|
|
1759
1759
|
validateArg(value, 2, "insert", "value");
|
|
1760
1760
|
const syscallJSON = await performAsyncSyscall("1.0/insert", {
|
|
1761
1761
|
table: tableName,
|
|
1762
|
-
value:
|
|
1762
|
+
value: convexToJson(value)
|
|
1763
1763
|
});
|
|
1764
|
-
const syscallResult =
|
|
1764
|
+
const syscallResult = jsonToConvex(syscallJSON);
|
|
1765
1765
|
return syscallResult._id;
|
|
1766
1766
|
}
|
|
1767
1767
|
async function patch(table, id, value) {
|
|
1768
1768
|
validateArg(id, 1, "patch", "id");
|
|
1769
1769
|
validateArg(value, 2, "patch", "value");
|
|
1770
1770
|
await performAsyncSyscall("1.0/shallowMerge", {
|
|
1771
|
-
id:
|
|
1771
|
+
id: convexToJson(id),
|
|
1772
1772
|
value: patchValueToJson(value),
|
|
1773
1773
|
table
|
|
1774
1774
|
});
|
|
@@ -1777,15 +1777,15 @@ async function replace(table, id, value) {
|
|
|
1777
1777
|
validateArg(id, 1, "replace", "id");
|
|
1778
1778
|
validateArg(value, 2, "replace", "value");
|
|
1779
1779
|
await performAsyncSyscall("1.0/replace", {
|
|
1780
|
-
id:
|
|
1781
|
-
value:
|
|
1780
|
+
id: convexToJson(id),
|
|
1781
|
+
value: convexToJson(value),
|
|
1782
1782
|
table
|
|
1783
1783
|
});
|
|
1784
1784
|
}
|
|
1785
1785
|
async function delete_(table, id) {
|
|
1786
1786
|
validateArg(id, 1, "delete", "id");
|
|
1787
1787
|
await performAsyncSyscall("1.0/remove", {
|
|
1788
|
-
id:
|
|
1788
|
+
id: convexToJson(id),
|
|
1789
1789
|
table
|
|
1790
1790
|
});
|
|
1791
1791
|
}
|
|
@@ -1863,7 +1863,7 @@ function setupMutationScheduler() {
|
|
|
1863
1863
|
},
|
|
1864
1864
|
cancel: async (id) => {
|
|
1865
1865
|
validateArg(id, 1, "cancel", "id");
|
|
1866
|
-
const args = { id:
|
|
1866
|
+
const args = { id: convexToJson(id) };
|
|
1867
1867
|
await performAsyncSyscall("1.0/cancel_job", args);
|
|
1868
1868
|
}
|
|
1869
1869
|
};
|
|
@@ -1884,7 +1884,7 @@ function runAfterSyscallArgs(delayMs, functionReference, args) {
|
|
|
1884
1884
|
return {
|
|
1885
1885
|
...address,
|
|
1886
1886
|
ts,
|
|
1887
|
-
args:
|
|
1887
|
+
args: convexToJson(functionArgs),
|
|
1888
1888
|
version
|
|
1889
1889
|
};
|
|
1890
1890
|
}
|
|
@@ -1902,7 +1902,7 @@ function runAtSyscallArgs(ms_since_epoch_or_date, functionReference, args) {
|
|
|
1902
1902
|
return {
|
|
1903
1903
|
...address,
|
|
1904
1904
|
ts,
|
|
1905
|
-
args:
|
|
1905
|
+
args: convexToJson(functionArgs),
|
|
1906
1906
|
version
|
|
1907
1907
|
};
|
|
1908
1908
|
}
|
|
@@ -1955,7 +1955,7 @@ var init_storage_impl = __esm(() => {
|
|
|
1955
1955
|
});
|
|
1956
1956
|
async function invokeMutation(func, argsStr) {
|
|
1957
1957
|
const requestId = "";
|
|
1958
|
-
const args =
|
|
1958
|
+
const args = jsonToConvex(JSON.parse(argsStr));
|
|
1959
1959
|
const mutationCtx = {
|
|
1960
1960
|
db: setupWriter(),
|
|
1961
1961
|
auth: setupAuth(requestId),
|
|
@@ -1966,7 +1966,7 @@ async function invokeMutation(func, argsStr) {
|
|
|
1966
1966
|
};
|
|
1967
1967
|
const result = await invokeFunction(func, mutationCtx, args);
|
|
1968
1968
|
validateReturnValue(result);
|
|
1969
|
-
return JSON.stringify(
|
|
1969
|
+
return JSON.stringify(convexToJson(result === undefined ? null : result));
|
|
1970
1970
|
}
|
|
1971
1971
|
function validateReturnValue(v2) {
|
|
1972
1972
|
if (v2 instanceof QueryInitializerImpl || v2 instanceof QueryImpl) {
|
|
@@ -1991,7 +1991,7 @@ function dontCallDirectly(funcType, handler) {
|
|
|
1991
1991
|
function serializeConvexErrorData(thrown) {
|
|
1992
1992
|
if (typeof thrown === "object" && thrown !== null && Symbol.for("ConvexError") in thrown) {
|
|
1993
1993
|
const error = thrown;
|
|
1994
|
-
error.data = JSON.stringify(
|
|
1994
|
+
error.data = JSON.stringify(convexToJson(error.data === undefined ? null : error.data));
|
|
1995
1995
|
error.ConvexErrorSymbol = Symbol.for("ConvexError");
|
|
1996
1996
|
return error;
|
|
1997
1997
|
} else {
|
|
@@ -2033,7 +2033,7 @@ function exportReturns(functionDefinition) {
|
|
|
2033
2033
|
}
|
|
2034
2034
|
async function invokeQuery(func, argsStr) {
|
|
2035
2035
|
const requestId = "";
|
|
2036
|
-
const args =
|
|
2036
|
+
const args = jsonToConvex(JSON.parse(argsStr));
|
|
2037
2037
|
const queryCtx = {
|
|
2038
2038
|
db: setupReader(),
|
|
2039
2039
|
auth: setupAuth(requestId),
|
|
@@ -2042,17 +2042,17 @@ async function invokeQuery(func, argsStr) {
|
|
|
2042
2042
|
};
|
|
2043
2043
|
const result = await invokeFunction(func, queryCtx, args);
|
|
2044
2044
|
validateReturnValue(result);
|
|
2045
|
-
return JSON.stringify(
|
|
2045
|
+
return JSON.stringify(convexToJson(result === undefined ? null : result));
|
|
2046
2046
|
}
|
|
2047
2047
|
async function runUdf(udfType, f, args) {
|
|
2048
2048
|
const queryArgs = parseArgs(args);
|
|
2049
2049
|
const syscallArgs = {
|
|
2050
2050
|
udfType,
|
|
2051
|
-
args:
|
|
2051
|
+
args: convexToJson(queryArgs),
|
|
2052
2052
|
...getFunctionAddress(f)
|
|
2053
2053
|
};
|
|
2054
2054
|
const result = await performAsyncSyscall("1.0/runUdf", syscallArgs);
|
|
2055
|
-
return
|
|
2055
|
+
return jsonToConvex(result);
|
|
2056
2056
|
}
|
|
2057
2057
|
var mutationGeneric = (functionDefinition) => {
|
|
2058
2058
|
const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
|
|
@@ -2326,9 +2326,9 @@ async function listSystemFunctions(options = {}) {
|
|
|
2326
2326
|
});
|
|
2327
2327
|
const analysisResults = await pooledMap(filteredListings, (listing) => analyzeModule(listing, componentPath), 20);
|
|
2328
2328
|
const results = [];
|
|
2329
|
-
for (let
|
|
2330
|
-
const listing = filteredListings[
|
|
2331
|
-
const result = analysisResults[
|
|
2329
|
+
for (let i2 = 0;i2 < filteredListings.length; i2++) {
|
|
2330
|
+
const listing = filteredListings[i2];
|
|
2331
|
+
const result = analysisResults[i2];
|
|
2332
2332
|
if (result.status === "rejected") {
|
|
2333
2333
|
if (!isNpmPackageError(result.reason)) {
|
|
2334
2334
|
console.warn(`Failed to analyze module "${listing.path}":`, result.reason);
|
|
@@ -3197,7 +3197,7 @@ class ModuleRegistry {
|
|
|
3197
3197
|
}
|
|
3198
3198
|
async load(request) {
|
|
3199
3199
|
const scopes = expandComponentScopes(request.componentPath);
|
|
3200
|
-
const
|
|
3200
|
+
const errors2 = [];
|
|
3201
3201
|
let attempted = false;
|
|
3202
3202
|
for (const scope of scopes) {
|
|
3203
3203
|
const loaders = this.scopedLoaders.get(scope);
|
|
@@ -3212,7 +3212,7 @@ class ModuleRegistry {
|
|
|
3212
3212
|
return result;
|
|
3213
3213
|
}
|
|
3214
3214
|
} catch (error2) {
|
|
3215
|
-
|
|
3215
|
+
errors2.push(error2);
|
|
3216
3216
|
}
|
|
3217
3217
|
}
|
|
3218
3218
|
}
|
|
@@ -3221,8 +3221,8 @@ class ModuleRegistry {
|
|
|
3221
3221
|
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\`).`);
|
|
3222
3222
|
}
|
|
3223
3223
|
const error = new Error(`Unable to resolve ${description}`);
|
|
3224
|
-
if (
|
|
3225
|
-
error.causes =
|
|
3224
|
+
if (errors2.length > 0) {
|
|
3225
|
+
error.causes = errors2;
|
|
3226
3226
|
}
|
|
3227
3227
|
throw error;
|
|
3228
3228
|
}
|
|
@@ -3446,8 +3446,8 @@ function expandComponentScopes(componentPath) {
|
|
|
3446
3446
|
if (componentPath) {
|
|
3447
3447
|
const normalized = normalizeComponentPath(componentPath);
|
|
3448
3448
|
const segments = normalized.split("/").filter(Boolean);
|
|
3449
|
-
for (let
|
|
3450
|
-
scopes.push(segments.slice(0,
|
|
3449
|
+
for (let i2 = segments.length;i2 > 0; i2--) {
|
|
3450
|
+
scopes.push(segments.slice(0, i2).join("/"));
|
|
3451
3451
|
}
|
|
3452
3452
|
}
|
|
3453
3453
|
scopes.push("");
|
|
@@ -3722,8 +3722,8 @@ Path: ${formatPath(path)}
|
|
|
3722
3722
|
Value: ${formatValue(value)}
|
|
3723
3723
|
Validator: v.array(...)`);
|
|
3724
3724
|
}
|
|
3725
|
-
for (let
|
|
3726
|
-
validateValidator(validator2.value, value[
|
|
3725
|
+
for (let i2 = 0;i2 < value.length; i2++) {
|
|
3726
|
+
validateValidator(validator2.value, value[i2], `${path}[${i2}]`, options);
|
|
3727
3727
|
}
|
|
3728
3728
|
return;
|
|
3729
3729
|
}
|
|
@@ -3751,7 +3751,7 @@ Path: ${formatPath(path)}
|
|
|
3751
3751
|
Value: ${formatValue(value)}
|
|
3752
3752
|
Validator: v.object({...})`);
|
|
3753
3753
|
}
|
|
3754
|
-
if (!
|
|
3754
|
+
if (!isSimpleObject2(value)) {
|
|
3755
3755
|
throw new Error(`Value does not match validator.
|
|
3756
3756
|
Path: ${formatPath(path)}
|
|
3757
3757
|
Value: ${formatValue(value)}
|
|
@@ -3801,7 +3801,7 @@ function isMatchingValidatorTable(idTableName, validatorTableName, componentPath
|
|
|
3801
3801
|
}
|
|
3802
3802
|
return idBareName === validatorBareName;
|
|
3803
3803
|
}
|
|
3804
|
-
function
|
|
3804
|
+
function isSimpleObject2(value) {
|
|
3805
3805
|
const isObject = typeof value === "object";
|
|
3806
3806
|
const prototype = Object.getPrototypeOf(value);
|
|
3807
3807
|
const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
|
|
@@ -4031,9 +4031,9 @@ var ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
|
4031
4031
|
var ALPHABET_MAP;
|
|
4032
4032
|
var init_base32 = __esm(() => {
|
|
4033
4033
|
ALPHABET_MAP = new Map;
|
|
4034
|
-
for (let
|
|
4035
|
-
ALPHABET_MAP.set(ALPHABET[
|
|
4036
|
-
ALPHABET_MAP.set(ALPHABET[
|
|
4034
|
+
for (let i2 = 0;i2 < ALPHABET.length; i2++) {
|
|
4035
|
+
ALPHABET_MAP.set(ALPHABET[i2], i2);
|
|
4036
|
+
ALPHABET_MAP.set(ALPHABET[i2].toUpperCase(), i2);
|
|
4037
4037
|
}
|
|
4038
4038
|
ALPHABET_MAP.set("i", 1);
|
|
4039
4039
|
ALPHABET_MAP.set("I", 1);
|
|
@@ -4184,8 +4184,8 @@ function isValidDocumentId(encoded) {
|
|
|
4184
4184
|
}
|
|
4185
4185
|
function internalIdToHex(internalId) {
|
|
4186
4186
|
let hex = "";
|
|
4187
|
-
for (let
|
|
4188
|
-
hex += internalId[
|
|
4187
|
+
for (let i2 = 0;i2 < internalId.length; i2++) {
|
|
4188
|
+
hex += internalId[i2].toString(16).padStart(2, "0");
|
|
4189
4189
|
}
|
|
4190
4190
|
return hex;
|
|
4191
4191
|
}
|
|
@@ -4197,332 +4197,7 @@ var init_document_id = __esm(() => {
|
|
|
4197
4197
|
init_base32();
|
|
4198
4198
|
cryptoGetRandomValues = crypto.getRandomValues.bind(crypto);
|
|
4199
4199
|
});
|
|
4200
|
-
|
|
4201
|
-
var revLookup = [];
|
|
4202
|
-
var Arr = Uint8Array;
|
|
4203
|
-
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4204
|
-
for (i = 0, len = code.length;i < len; ++i) {
|
|
4205
|
-
lookup[i] = code[i];
|
|
4206
|
-
revLookup[code.charCodeAt(i)] = i;
|
|
4207
|
-
}
|
|
4208
|
-
var i;
|
|
4209
|
-
var len;
|
|
4210
|
-
revLookup[45] = 62;
|
|
4211
|
-
revLookup[95] = 63;
|
|
4212
|
-
function getLens(b64) {
|
|
4213
|
-
var len22 = b64.length;
|
|
4214
|
-
if (len22 % 4 > 0) {
|
|
4215
|
-
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
4216
|
-
}
|
|
4217
|
-
var validLen = b64.indexOf("=");
|
|
4218
|
-
if (validLen === -1)
|
|
4219
|
-
validLen = len22;
|
|
4220
|
-
var placeHoldersLen = validLen === len22 ? 0 : 4 - validLen % 4;
|
|
4221
|
-
return [validLen, placeHoldersLen];
|
|
4222
|
-
}
|
|
4223
|
-
function _byteLength(_b64, validLen, placeHoldersLen) {
|
|
4224
|
-
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
4225
|
-
}
|
|
4226
|
-
function toByteArray(b64) {
|
|
4227
|
-
var tmp;
|
|
4228
|
-
var lens = getLens(b64);
|
|
4229
|
-
var validLen = lens[0];
|
|
4230
|
-
var placeHoldersLen = lens[1];
|
|
4231
|
-
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
4232
|
-
var curByte = 0;
|
|
4233
|
-
var len22 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
4234
|
-
var i22;
|
|
4235
|
-
for (i22 = 0;i22 < len22; i22 += 4) {
|
|
4236
|
-
tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)];
|
|
4237
|
-
arr[curByte++] = tmp >> 16 & 255;
|
|
4238
|
-
arr[curByte++] = tmp >> 8 & 255;
|
|
4239
|
-
arr[curByte++] = tmp & 255;
|
|
4240
|
-
}
|
|
4241
|
-
if (placeHoldersLen === 2) {
|
|
4242
|
-
tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4;
|
|
4243
|
-
arr[curByte++] = tmp & 255;
|
|
4244
|
-
}
|
|
4245
|
-
if (placeHoldersLen === 1) {
|
|
4246
|
-
tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2;
|
|
4247
|
-
arr[curByte++] = tmp >> 8 & 255;
|
|
4248
|
-
arr[curByte++] = tmp & 255;
|
|
4249
|
-
}
|
|
4250
|
-
return arr;
|
|
4251
|
-
}
|
|
4252
|
-
function tripletToBase64(num) {
|
|
4253
|
-
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
4254
|
-
}
|
|
4255
|
-
function encodeChunk(uint8, start, end) {
|
|
4256
|
-
var tmp;
|
|
4257
|
-
var output = [];
|
|
4258
|
-
for (var i22 = start;i22 < end; i22 += 3) {
|
|
4259
|
-
tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255);
|
|
4260
|
-
output.push(tripletToBase64(tmp));
|
|
4261
|
-
}
|
|
4262
|
-
return output.join("");
|
|
4263
|
-
}
|
|
4264
|
-
function fromByteArray(uint8) {
|
|
4265
|
-
var tmp;
|
|
4266
|
-
var len22 = uint8.length;
|
|
4267
|
-
var extraBytes = len22 % 3;
|
|
4268
|
-
var parts = [];
|
|
4269
|
-
var maxChunkLength = 16383;
|
|
4270
|
-
for (var i22 = 0, len222 = len22 - extraBytes;i22 < len222; i22 += maxChunkLength) {
|
|
4271
|
-
parts.push(encodeChunk(uint8, i22, i22 + maxChunkLength > len222 ? len222 : i22 + maxChunkLength));
|
|
4272
|
-
}
|
|
4273
|
-
if (extraBytes === 1) {
|
|
4274
|
-
tmp = uint8[len22 - 1];
|
|
4275
|
-
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
|
|
4276
|
-
} else if (extraBytes === 2) {
|
|
4277
|
-
tmp = (uint8[len22 - 2] << 8) + uint8[len22 - 1];
|
|
4278
|
-
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
|
|
4279
|
-
}
|
|
4280
|
-
return parts.join("");
|
|
4281
|
-
}
|
|
4282
|
-
function isSimpleObject(value) {
|
|
4283
|
-
const isObject = typeof value === "object";
|
|
4284
|
-
const prototype = Object.getPrototypeOf(value);
|
|
4285
|
-
const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
|
|
4286
|
-
return isObject && isSimple;
|
|
4287
|
-
}
|
|
4288
|
-
var LITTLE_ENDIAN = true;
|
|
4289
|
-
var MIN_INT64 = BigInt("-9223372036854775808");
|
|
4290
|
-
var MAX_INT64 = BigInt("9223372036854775807");
|
|
4291
|
-
var ZERO = BigInt("0");
|
|
4292
|
-
var EIGHT = BigInt("8");
|
|
4293
|
-
var TWOFIFTYSIX = BigInt("256");
|
|
4294
|
-
function isSpecial(n) {
|
|
4295
|
-
return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
|
|
4296
|
-
}
|
|
4297
|
-
function slowBigIntToBase64(value) {
|
|
4298
|
-
if (value < ZERO) {
|
|
4299
|
-
value -= MIN_INT64 + MIN_INT64;
|
|
4300
|
-
}
|
|
4301
|
-
let hex = value.toString(16);
|
|
4302
|
-
if (hex.length % 2 === 1)
|
|
4303
|
-
hex = "0" + hex;
|
|
4304
|
-
const bytes = new Uint8Array(new ArrayBuffer(8));
|
|
4305
|
-
let i22 = 0;
|
|
4306
|
-
for (const hexByte of hex.match(/.{2}/g).reverse()) {
|
|
4307
|
-
bytes.set([parseInt(hexByte, 16)], i22++);
|
|
4308
|
-
value >>= EIGHT;
|
|
4309
|
-
}
|
|
4310
|
-
return fromByteArray(bytes);
|
|
4311
|
-
}
|
|
4312
|
-
function slowBase64ToBigInt(encoded) {
|
|
4313
|
-
const integerBytes = toByteArray(encoded);
|
|
4314
|
-
if (integerBytes.byteLength !== 8) {
|
|
4315
|
-
throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
4316
|
-
}
|
|
4317
|
-
let value = ZERO;
|
|
4318
|
-
let power = ZERO;
|
|
4319
|
-
for (const byte of integerBytes) {
|
|
4320
|
-
value += BigInt(byte) * TWOFIFTYSIX ** power;
|
|
4321
|
-
power++;
|
|
4322
|
-
}
|
|
4323
|
-
if (value > MAX_INT64) {
|
|
4324
|
-
value += MIN_INT64 + MIN_INT64;
|
|
4325
|
-
}
|
|
4326
|
-
return value;
|
|
4327
|
-
}
|
|
4328
|
-
function modernBigIntToBase64(value) {
|
|
4329
|
-
if (value < MIN_INT64 || MAX_INT64 < value) {
|
|
4330
|
-
throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
4331
|
-
}
|
|
4332
|
-
const buffer = new ArrayBuffer(8);
|
|
4333
|
-
new DataView(buffer).setBigInt64(0, value, true);
|
|
4334
|
-
return fromByteArray(new Uint8Array(buffer));
|
|
4335
|
-
}
|
|
4336
|
-
function modernBase64ToBigInt(encoded) {
|
|
4337
|
-
const integerBytes = toByteArray(encoded);
|
|
4338
|
-
if (integerBytes.byteLength !== 8) {
|
|
4339
|
-
throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
4340
|
-
}
|
|
4341
|
-
const intBytesView = new DataView(integerBytes.buffer);
|
|
4342
|
-
return intBytesView.getBigInt64(0, true);
|
|
4343
|
-
}
|
|
4344
|
-
var bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
|
|
4345
|
-
var base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
|
|
4346
|
-
var MAX_IDENTIFIER_LEN = 1024;
|
|
4347
|
-
function validateObjectField(k) {
|
|
4348
|
-
if (k.length > MAX_IDENTIFIER_LEN) {
|
|
4349
|
-
throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN}.`);
|
|
4350
|
-
}
|
|
4351
|
-
if (k.startsWith("$")) {
|
|
4352
|
-
throw new Error(`Field name ${k} starts with a '$', which is reserved.`);
|
|
4353
|
-
}
|
|
4354
|
-
for (let i22 = 0;i22 < k.length; i22 += 1) {
|
|
4355
|
-
const charCode = k.charCodeAt(i22);
|
|
4356
|
-
if (charCode < 32 || charCode >= 127) {
|
|
4357
|
-
throw new Error(`Field name ${k} has invalid character '${k[i22]}': Field names can only contain non-control ASCII characters`);
|
|
4358
|
-
}
|
|
4359
|
-
}
|
|
4360
|
-
}
|
|
4361
|
-
function jsonToConvex(value) {
|
|
4362
|
-
if (value === null) {
|
|
4363
|
-
return value;
|
|
4364
|
-
}
|
|
4365
|
-
if (typeof value === "boolean") {
|
|
4366
|
-
return value;
|
|
4367
|
-
}
|
|
4368
|
-
if (typeof value === "number") {
|
|
4369
|
-
return value;
|
|
4370
|
-
}
|
|
4371
|
-
if (typeof value === "string") {
|
|
4372
|
-
return value;
|
|
4373
|
-
}
|
|
4374
|
-
if (Array.isArray(value)) {
|
|
4375
|
-
return value.map((value2) => jsonToConvex(value2));
|
|
4376
|
-
}
|
|
4377
|
-
if (typeof value !== "object") {
|
|
4378
|
-
throw new Error(`Unexpected type of ${value}`);
|
|
4379
|
-
}
|
|
4380
|
-
const entries = Object.entries(value);
|
|
4381
|
-
if (entries.length === 1) {
|
|
4382
|
-
const key = entries[0][0];
|
|
4383
|
-
if (key === "$bytes") {
|
|
4384
|
-
if (typeof value.$bytes !== "string") {
|
|
4385
|
-
throw new Error(`Malformed $bytes field on ${value}`);
|
|
4386
|
-
}
|
|
4387
|
-
return toByteArray(value.$bytes).buffer;
|
|
4388
|
-
}
|
|
4389
|
-
if (key === "$integer") {
|
|
4390
|
-
if (typeof value.$integer !== "string") {
|
|
4391
|
-
throw new Error(`Malformed $integer field on ${value}`);
|
|
4392
|
-
}
|
|
4393
|
-
return base64ToBigInt(value.$integer);
|
|
4394
|
-
}
|
|
4395
|
-
if (key === "$float") {
|
|
4396
|
-
if (typeof value.$float !== "string") {
|
|
4397
|
-
throw new Error(`Malformed $float field on ${value}`);
|
|
4398
|
-
}
|
|
4399
|
-
const floatBytes = toByteArray(value.$float);
|
|
4400
|
-
if (floatBytes.byteLength !== 8) {
|
|
4401
|
-
throw new Error(`Received ${floatBytes.byteLength} bytes, expected 8 for $float`);
|
|
4402
|
-
}
|
|
4403
|
-
const floatBytesView = new DataView(floatBytes.buffer);
|
|
4404
|
-
const float = floatBytesView.getFloat64(0, LITTLE_ENDIAN);
|
|
4405
|
-
if (!isSpecial(float)) {
|
|
4406
|
-
throw new Error(`Float ${float} should be encoded as a number`);
|
|
4407
|
-
}
|
|
4408
|
-
return float;
|
|
4409
|
-
}
|
|
4410
|
-
if (key === "$set") {
|
|
4411
|
-
throw new Error(`Received a Set which is no longer supported as a Convex type.`);
|
|
4412
|
-
}
|
|
4413
|
-
if (key === "$map") {
|
|
4414
|
-
throw new Error(`Received a Map which is no longer supported as a Convex type.`);
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
const out = {};
|
|
4418
|
-
for (const [k, v2] of Object.entries(value)) {
|
|
4419
|
-
validateObjectField(k);
|
|
4420
|
-
out[k] = jsonToConvex(v2);
|
|
4421
|
-
}
|
|
4422
|
-
return out;
|
|
4423
|
-
}
|
|
4424
|
-
var MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
4425
|
-
function stringifyValueForError(value) {
|
|
4426
|
-
const str = JSON.stringify(value, (_key, value2) => {
|
|
4427
|
-
if (value2 === undefined) {
|
|
4428
|
-
return "undefined";
|
|
4429
|
-
}
|
|
4430
|
-
if (typeof value2 === "bigint") {
|
|
4431
|
-
return `${value2.toString()}n`;
|
|
4432
|
-
}
|
|
4433
|
-
return value2;
|
|
4434
|
-
});
|
|
4435
|
-
if (str.length > MAX_VALUE_FOR_ERROR_LEN) {
|
|
4436
|
-
const rest = "[...truncated]";
|
|
4437
|
-
let truncateAt = MAX_VALUE_FOR_ERROR_LEN - rest.length;
|
|
4438
|
-
const codePoint = str.codePointAt(truncateAt - 1);
|
|
4439
|
-
if (codePoint !== undefined && codePoint > 65535) {
|
|
4440
|
-
truncateAt -= 1;
|
|
4441
|
-
}
|
|
4442
|
-
return str.substring(0, truncateAt) + rest;
|
|
4443
|
-
}
|
|
4444
|
-
return str;
|
|
4445
|
-
}
|
|
4446
|
-
function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
|
|
4447
|
-
if (value === undefined) {
|
|
4448
|
-
const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError(originalValue)})`;
|
|
4449
|
-
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.`);
|
|
4450
|
-
}
|
|
4451
|
-
if (value === null) {
|
|
4452
|
-
return value;
|
|
4453
|
-
}
|
|
4454
|
-
if (typeof value === "bigint") {
|
|
4455
|
-
if (value < MIN_INT64 || MAX_INT64 < value) {
|
|
4456
|
-
throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
4457
|
-
}
|
|
4458
|
-
return { $integer: bigIntToBase64(value) };
|
|
4459
|
-
}
|
|
4460
|
-
if (typeof value === "number") {
|
|
4461
|
-
if (isSpecial(value)) {
|
|
4462
|
-
const buffer = new ArrayBuffer(8);
|
|
4463
|
-
new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN);
|
|
4464
|
-
return { $float: fromByteArray(new Uint8Array(buffer)) };
|
|
4465
|
-
} else {
|
|
4466
|
-
return value;
|
|
4467
|
-
}
|
|
4468
|
-
}
|
|
4469
|
-
if (typeof value === "boolean") {
|
|
4470
|
-
return value;
|
|
4471
|
-
}
|
|
4472
|
-
if (typeof value === "string") {
|
|
4473
|
-
return value;
|
|
4474
|
-
}
|
|
4475
|
-
if (value instanceof ArrayBuffer) {
|
|
4476
|
-
return { $bytes: fromByteArray(new Uint8Array(value)) };
|
|
4477
|
-
}
|
|
4478
|
-
if (Array.isArray(value)) {
|
|
4479
|
-
return value.map((value2, i22) => convexToJsonInternal(value2, originalValue, context + `[${i22}]`, false));
|
|
4480
|
-
}
|
|
4481
|
-
if (value instanceof Set) {
|
|
4482
|
-
throw new Error(errorMessageForUnsupportedType(context, "Set", [...value], originalValue));
|
|
4483
|
-
}
|
|
4484
|
-
if (value instanceof Map) {
|
|
4485
|
-
throw new Error(errorMessageForUnsupportedType(context, "Map", [...value], originalValue));
|
|
4486
|
-
}
|
|
4487
|
-
if (!isSimpleObject(value)) {
|
|
4488
|
-
const theType = value?.constructor?.name;
|
|
4489
|
-
const typeName = theType ? `${theType} ` : "";
|
|
4490
|
-
throw new Error(errorMessageForUnsupportedType(context, typeName, value, originalValue));
|
|
4491
|
-
}
|
|
4492
|
-
const out = {};
|
|
4493
|
-
const entries = Object.entries(value);
|
|
4494
|
-
entries.sort(([k1, _v1], [k2, _v2]) => k1 === k2 ? 0 : k1 < k2 ? -1 : 1);
|
|
4495
|
-
for (const [k, v2] of entries) {
|
|
4496
|
-
if (v2 !== undefined) {
|
|
4497
|
-
validateObjectField(k);
|
|
4498
|
-
out[k] = convexToJsonInternal(v2, originalValue, context + `.${k}`, false);
|
|
4499
|
-
} else if (includeTopLevelUndefined) {
|
|
4500
|
-
validateObjectField(k);
|
|
4501
|
-
out[k] = convexOrUndefinedToJsonInternal(v2, originalValue, context + `.${k}`);
|
|
4502
|
-
}
|
|
4503
|
-
}
|
|
4504
|
-
return out;
|
|
4505
|
-
}
|
|
4506
|
-
function errorMessageForUnsupportedType(context, typeName, value, originalValue) {
|
|
4507
|
-
if (context) {
|
|
4508
|
-
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.`;
|
|
4509
|
-
} else {
|
|
4510
|
-
return `${typeName}${stringifyValueForError(value)} is not a supported Convex type.`;
|
|
4511
|
-
}
|
|
4512
|
-
}
|
|
4513
|
-
function convexOrUndefinedToJsonInternal(value, originalValue, context) {
|
|
4514
|
-
if (value === undefined) {
|
|
4515
|
-
return { $undefined: null };
|
|
4516
|
-
} else {
|
|
4517
|
-
if (originalValue === undefined) {
|
|
4518
|
-
throw new Error(`Programming error. Current value is ${stringifyValueForError(value)} but original value is undefined`);
|
|
4519
|
-
}
|
|
4520
|
-
return convexToJsonInternal(value, originalValue, context, false);
|
|
4521
|
-
}
|
|
4522
|
-
}
|
|
4523
|
-
function convexToJson(value) {
|
|
4524
|
-
return convexToJsonInternal(value, value, "", false);
|
|
4525
|
-
}
|
|
4200
|
+
init_values();
|
|
4526
4201
|
function documentIdKey(id) {
|
|
4527
4202
|
return `${id.table}:${id.internalId}`;
|
|
4528
4203
|
}
|
|
@@ -4768,7 +4443,7 @@ function decodeIndexId(indexId) {
|
|
|
4768
4443
|
}
|
|
4769
4444
|
init_schema_service();
|
|
4770
4445
|
init_index_key_codec();
|
|
4771
|
-
function
|
|
4446
|
+
function isSimpleObject3(value) {
|
|
4772
4447
|
const isObject = typeof value === "object" && value !== null;
|
|
4773
4448
|
if (!isObject)
|
|
4774
4449
|
return false;
|
|
@@ -4782,7 +4457,7 @@ function evaluateFieldPath(fieldPath, document) {
|
|
|
4782
4457
|
for (const part of parts) {
|
|
4783
4458
|
if (current == null)
|
|
4784
4459
|
return;
|
|
4785
|
-
if (!
|
|
4460
|
+
if (!isSimpleObject3(current))
|
|
4786
4461
|
return;
|
|
4787
4462
|
current = current[part];
|
|
4788
4463
|
}
|
|
@@ -4808,6 +4483,19 @@ function parseDeveloperId(developerId) {
|
|
|
4808
4483
|
}
|
|
4809
4484
|
return { table: parts.table, internalId: parts.internalId };
|
|
4810
4485
|
}
|
|
4486
|
+
function parseStorageId(storageId) {
|
|
4487
|
+
const parsed = parseDeveloperId(storageId);
|
|
4488
|
+
if (parsed) {
|
|
4489
|
+
return parsed;
|
|
4490
|
+
}
|
|
4491
|
+
if (storageId.length === INTERNAL_ID_LENGTH * 2 && /^[0-9a-fA-F]+$/.test(storageId)) {
|
|
4492
|
+
return {
|
|
4493
|
+
table: stringToHex("_storage"),
|
|
4494
|
+
internalId: storageId.toLowerCase()
|
|
4495
|
+
};
|
|
4496
|
+
}
|
|
4497
|
+
return null;
|
|
4498
|
+
}
|
|
4811
4499
|
function isTablePlaceholder(table) {
|
|
4812
4500
|
return table.startsWith("#");
|
|
4813
4501
|
}
|
|
@@ -5250,19 +4938,19 @@ class BlobStoreGateway {
|
|
|
5250
4938
|
if (!this.storage) {
|
|
5251
4939
|
return null;
|
|
5252
4940
|
}
|
|
5253
|
-
const docId =
|
|
4941
|
+
const docId = parseStorageId(storageId);
|
|
5254
4942
|
if (!docId) {
|
|
5255
|
-
console.
|
|
4943
|
+
console.debug(`[BlobStoreGateway] Failed to parse storage ID: ${storageId}`);
|
|
5256
4944
|
return null;
|
|
5257
4945
|
}
|
|
5258
4946
|
const docValue = await this.queryRuntime.getVisibleDocumentById(storageId, docId);
|
|
5259
4947
|
if (!docValue) {
|
|
5260
|
-
console.
|
|
4948
|
+
console.debug(`[BlobStoreGateway] Document not found for storage ID: ${storageId} (table: ${docId.table}, internalId: ${docId.internalId}, ts: ${this.context.snapshotTimestamp})`);
|
|
5261
4949
|
return null;
|
|
5262
4950
|
}
|
|
5263
4951
|
const storedBlob = await this.storage.get(docId.internalId);
|
|
5264
4952
|
if (!storedBlob) {
|
|
5265
|
-
console.
|
|
4953
|
+
console.debug(`[BlobStoreGateway] Blob not found in storage: ${docId.internalId}`);
|
|
5266
4954
|
return null;
|
|
5267
4955
|
}
|
|
5268
4956
|
return storedBlob instanceof Blob ? storedBlob : new Blob([storedBlob]);
|
|
@@ -5271,7 +4959,7 @@ class BlobStoreGateway {
|
|
|
5271
4959
|
if (!this.storage) {
|
|
5272
4960
|
return null;
|
|
5273
4961
|
}
|
|
5274
|
-
const docId =
|
|
4962
|
+
const docId = parseStorageId(storageId);
|
|
5275
4963
|
if (!docId) {
|
|
5276
4964
|
return null;
|
|
5277
4965
|
}
|
|
@@ -5284,7 +4972,7 @@ class BlobStoreGateway {
|
|
|
5284
4972
|
}
|
|
5285
4973
|
async delete(storageId) {
|
|
5286
4974
|
const storage2 = this.requireStorage();
|
|
5287
|
-
const docId =
|
|
4975
|
+
const docId = parseStorageId(storageId);
|
|
5288
4976
|
if (!docId) {
|
|
5289
4977
|
return;
|
|
5290
4978
|
}
|
|
@@ -5343,8 +5031,9 @@ function resolveFunctionTarget(callArgs, currentComponentPath) {
|
|
|
5343
5031
|
return parseFunctionHandleTarget(callArgs.functionHandle);
|
|
5344
5032
|
}
|
|
5345
5033
|
if (callArgs && typeof callArgs.functionHandle === "object" && callArgs.functionHandle !== null) {
|
|
5346
|
-
|
|
5347
|
-
|
|
5034
|
+
const handle = callArgs.functionHandle;
|
|
5035
|
+
if (typeof handle.handle === "string") {
|
|
5036
|
+
return parseFunctionHandleTarget(handle.handle);
|
|
5348
5037
|
}
|
|
5349
5038
|
}
|
|
5350
5039
|
if (callArgs && typeof callArgs.reference === "string") {
|
|
@@ -5439,7 +5128,7 @@ function evaluatePatchValue(value) {
|
|
|
5439
5128
|
if (typeof value === "object" && value !== null && "$undefined" in value) {
|
|
5440
5129
|
return;
|
|
5441
5130
|
}
|
|
5442
|
-
return
|
|
5131
|
+
return jsonToConvex(value);
|
|
5443
5132
|
}
|
|
5444
5133
|
|
|
5445
5134
|
class SchedulerGateway {
|
|
@@ -5460,7 +5149,7 @@ class SchedulerGateway {
|
|
|
5460
5149
|
const docId = { table: tableHex, internalId: internalIdHex, tableNumber };
|
|
5461
5150
|
const developerId = this.context.useConvexIdFormat ? encodeDocumentId(tableNumber, internalIdBytes) : serializeDeveloperId(tableHex, internalIdHex);
|
|
5462
5151
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5463
|
-
const argsValue =
|
|
5152
|
+
const argsValue = jsonToConvex(convexToJson(fnArgs));
|
|
5464
5153
|
const formattedName = name.replace(/\.(js|ts|mjs|mts|cjs|cts):/g, ":");
|
|
5465
5154
|
const docToInsert = {
|
|
5466
5155
|
name: formattedName,
|
|
@@ -5584,17 +5273,15 @@ class ActionSyscalls {
|
|
|
5584
5273
|
const type = args.udfType ?? args.type ?? "mutation";
|
|
5585
5274
|
return await this.invocationManager.execute(target.udfPath, udfArguments, type, target.componentPath);
|
|
5586
5275
|
}
|
|
5587
|
-
handleCreateFunctionHandle(args) {
|
|
5276
|
+
async handleCreateFunctionHandle(args) {
|
|
5588
5277
|
const target = resolveFunctionTarget(args, this.context.componentPath);
|
|
5589
5278
|
return formatFunctionHandle(target.componentPath ?? "", target.udfPath);
|
|
5590
5279
|
}
|
|
5591
5280
|
async handleVectorSearch(args) {
|
|
5592
|
-
|
|
5593
|
-
return this.queryRuntime.runVectorSearchAction(vectorQuery);
|
|
5281
|
+
return this.queryRuntime.runVectorSearchAction(args.query);
|
|
5594
5282
|
}
|
|
5595
5283
|
async handleSearchAction(args) {
|
|
5596
|
-
|
|
5597
|
-
return this.queryRuntime.runSearchAction(searchQuery);
|
|
5284
|
+
return this.queryRuntime.runSearchAction(args.query);
|
|
5598
5285
|
}
|
|
5599
5286
|
}
|
|
5600
5287
|
init_values();
|
|
@@ -5655,7 +5342,7 @@ class DatabaseSyscalls {
|
|
|
5655
5342
|
if (typeof table !== "string") {
|
|
5656
5343
|
throw new Error("`table` argument for `insert` must be a string.");
|
|
5657
5344
|
}
|
|
5658
|
-
const convexValue =
|
|
5345
|
+
const convexValue = jsonToConvex(value);
|
|
5659
5346
|
if (typeof convexValue !== "object" || convexValue === null || Array.isArray(convexValue)) {
|
|
5660
5347
|
throw new Error("The document value for `insert` must be an object.");
|
|
5661
5348
|
}
|
|
@@ -5800,7 +5487,7 @@ class DatabaseSyscalls {
|
|
|
5800
5487
|
}
|
|
5801
5488
|
const fullTableName = await resolveTableName(docId, this.context.tableRegistry);
|
|
5802
5489
|
const { tableName: bareTableName } = parseFullTableName(fullTableName);
|
|
5803
|
-
const replaceValue =
|
|
5490
|
+
const replaceValue = jsonToConvex(value);
|
|
5804
5491
|
if (typeof replaceValue !== "object" || replaceValue === null || Array.isArray(replaceValue)) {
|
|
5805
5492
|
throw new Error("The replacement value for `replace` must be an object.");
|
|
5806
5493
|
}
|
|
@@ -5902,6 +5589,8 @@ function decodeJwtClaimsToken(token) {
|
|
|
5902
5589
|
return null;
|
|
5903
5590
|
}
|
|
5904
5591
|
}
|
|
5592
|
+
var DEFAULT_JWKS_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
5593
|
+
var MAX_JWKS_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
5905
5594
|
var JWKS_CACHE = new Map;
|
|
5906
5595
|
function decodeJwtUnsafe(token) {
|
|
5907
5596
|
if (!token)
|
|
@@ -5982,13 +5671,13 @@ class QuerySyscalls {
|
|
|
5982
5671
|
return { queryId };
|
|
5983
5672
|
}
|
|
5984
5673
|
handleQueryCleanup(args) {
|
|
5985
|
-
const
|
|
5674
|
+
const queryId = args.queryId;
|
|
5986
5675
|
delete this.pendingQueries[queryId];
|
|
5987
5676
|
delete this.queryResults[queryId];
|
|
5988
5677
|
return {};
|
|
5989
5678
|
}
|
|
5990
5679
|
async handleQueryStreamNext(args) {
|
|
5991
|
-
const
|
|
5680
|
+
const queryId = args.queryId;
|
|
5992
5681
|
if (this.pendingQueries[queryId]) {
|
|
5993
5682
|
const query = this.pendingQueries[queryId];
|
|
5994
5683
|
delete this.pendingQueries[queryId];
|
|
@@ -6156,9 +5845,9 @@ class SyscallRouter {
|
|
|
6156
5845
|
throw new Error(`Unknown async syscall: ${op}`);
|
|
6157
5846
|
}
|
|
6158
5847
|
const parsedArgs = JSON.parse(jsonArgs);
|
|
6159
|
-
const args = entry.argsFormat === "convex" ?
|
|
5848
|
+
const args = entry.argsFormat === "convex" ? jsonToConvex(parsedArgs) : parsedArgs;
|
|
6160
5849
|
const result = await entry.handler(args);
|
|
6161
|
-
return JSON.stringify(
|
|
5850
|
+
return JSON.stringify(convexToJson(result));
|
|
6162
5851
|
}
|
|
6163
5852
|
}
|
|
6164
5853
|
|
|
@@ -6714,9 +6403,9 @@ class BaseSqliteDocStore {
|
|
|
6714
6403
|
let dot = 0;
|
|
6715
6404
|
let queryMagnitude = 0;
|
|
6716
6405
|
let docMagnitude = 0;
|
|
6717
|
-
for (let
|
|
6718
|
-
const q = vector[
|
|
6719
|
-
const d = embedding[
|
|
6406
|
+
for (let i2 = 0;i2 < vector.length; i2++) {
|
|
6407
|
+
const q = vector[i2];
|
|
6408
|
+
const d = embedding[i2];
|
|
6720
6409
|
dot += q * d;
|
|
6721
6410
|
queryMagnitude += q * q;
|
|
6722
6411
|
docMagnitude += d * d;
|