@eidos.space/eidos-file 1.0.0 → 2.0.2
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/DEVELOPER_PLATFORM.md +17 -11
- package/FIELD-CONVERSION.md +75 -0
- package/README.md +18 -2
- package/dist/{adapter-contract-B3p-48Yb.d.mts → adapter-contract-CPhqAl4b.d.mts} +46 -65
- package/dist/adapter-contract-CPhqAl4b.d.mts.map +1 -0
- package/dist/better-sqlite3.d.mts +2 -2
- package/dist/better-sqlite3.d.mts.map +1 -1
- package/dist/better-sqlite3.mjs +13 -5
- package/dist/better-sqlite3.mjs.map +1 -1
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +3 -3
- package/dist/browser.mjs.map +1 -1
- package/dist/{csv-WEud-i_H.mjs → csv-CvzHNNGW.mjs} +48 -11
- package/dist/csv-CvzHNNGW.mjs.map +1 -0
- package/dist/csv.d.mts +4 -2
- package/dist/csv.d.mts.map +1 -1
- package/dist/csv.mjs +1 -1
- package/dist/index.d.mts +40 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +578 -200
- package/dist/index.mjs.map +1 -1
- package/dist/node-sqlite.d.mts +111 -0
- package/dist/node-sqlite.d.mts.map +1 -0
- package/dist/node-sqlite.mjs +708 -0
- package/dist/node-sqlite.mjs.map +1 -0
- package/dist/{runtime-DCo5E0Kr.d.mts → runtime-CkL1OOJT.d.mts} +129 -7
- package/dist/runtime-CkL1OOJT.d.mts.map +1 -0
- package/dist/{runtime-CMdfE7Gx.mjs → runtime-qbuZMbV4.mjs} +674 -198
- package/dist/runtime-qbuZMbV4.mjs.map +1 -0
- package/dist/{select-options-DihMTuoa.mjs → select-options-Dr8XCYOS.mjs} +145 -80
- package/dist/select-options-Dr8XCYOS.mjs.map +1 -0
- package/dist/{sqlite-wasm-B86yaLG6.mjs → sqlite-wasm-fT8Z-5Ww.mjs} +34 -13
- package/dist/sqlite-wasm-fT8Z-5Ww.mjs.map +1 -0
- package/dist/system-metadata-merge-BaX38cp-.d.mts +77 -0
- package/dist/system-metadata-merge-BaX38cp-.d.mts.map +1 -0
- package/dist/system-metadata-merge-CjTqAwCi.mjs +819 -0
- package/dist/system-metadata-merge-CjTqAwCi.mjs.map +1 -0
- package/dist/{temporal-CVzLU63l.d.mts → temporal-ysCLNSub.d.mts} +8 -3
- package/dist/temporal-ysCLNSub.d.mts.map +1 -0
- package/package.json +10 -2
- package/dist/adapter-contract-B3p-48Yb.d.mts.map +0 -1
- package/dist/csv-WEud-i_H.mjs.map +0 -1
- package/dist/runtime-CMdfE7Gx.mjs.map +0 -1
- package/dist/runtime-DCo5E0Kr.d.mts.map +0 -1
- package/dist/select-options-DihMTuoa.mjs.map +0 -1
- package/dist/sqlite-wasm-B86yaLG6.mjs.map +0 -1
- package/dist/temporal-CVzLU63l.d.mts.map +0 -1
|
@@ -144,17 +144,6 @@ function sqliteNoCase(value) {
|
|
|
144
144
|
function utf8Length(value) {
|
|
145
145
|
return new TextEncoder().encode(value).byteLength;
|
|
146
146
|
}
|
|
147
|
-
function utf8Prefix(value, limit) {
|
|
148
|
-
let result = "";
|
|
149
|
-
let length = 0;
|
|
150
|
-
for (const scalar of value) {
|
|
151
|
-
const scalarLength = utf8Length(scalar);
|
|
152
|
-
if (length + scalarLength > limit) break;
|
|
153
|
-
result += scalar;
|
|
154
|
-
length += scalarLength;
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
147
|
function isEidosFileUuid(value) {
|
|
159
148
|
return typeof value === "string" && UUID_V7.test(value);
|
|
160
149
|
}
|
|
@@ -256,55 +245,14 @@ function assertEidosFileDisplayName(name, label) {
|
|
|
256
245
|
if (name.length === 0 || name.includes("\0") || utf8Length(name) > 1024 || /[\uD800-\uDFFF]/u.test(Array.from(name).filter((scalar) => scalar.length === 1).join(""))) throw new EidosFileError("invalid-identifier", `${label} must be 1..1024 UTF-8 octets, contain Unicode scalar values, and exclude U+0000`);
|
|
257
246
|
return name;
|
|
258
247
|
}
|
|
259
|
-
function
|
|
260
|
-
const folded = sqliteNoCase(
|
|
261
|
-
|
|
262
|
-
"_id",
|
|
263
|
-
"_created_at",
|
|
264
|
-
"_updated_at"
|
|
265
|
-
].includes(folded);
|
|
266
|
-
return [
|
|
267
|
-
"sqlite_",
|
|
268
|
-
"eidos__",
|
|
269
|
-
"x__"
|
|
270
|
-
].some((prefix) => folded.startsWith(prefix));
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Applies the display-first physical naming rule from Eidos File 1.0 §6.
|
|
274
|
-
* `existingNames` is compared using SQLite's ASCII-only NOCASE behavior.
|
|
275
|
-
*/
|
|
276
|
-
function eidosFilePhysicalName(kind, displayName, stableId, existingNames = []) {
|
|
277
|
-
assertEidosFileDisplayName(displayName, kind === "table" ? "Table name" : "Field name");
|
|
278
|
-
const idHex = assertEidosFileUuid(stableId).replace(/-/g, "");
|
|
279
|
-
const existing = new Set(Array.from(existingNames, sqliteNoCase));
|
|
280
|
-
const available = (candidate) => !existing.has(sqliteNoCase(candidate));
|
|
281
|
-
if (kind === "table" && isReservedPhysicalName(kind, displayName)) {
|
|
282
|
-
for (const length of [
|
|
283
|
-
8,
|
|
284
|
-
12,
|
|
285
|
-
32
|
|
286
|
-
]) {
|
|
287
|
-
const prefix = `t__${idHex.slice(0, length)}__`;
|
|
288
|
-
const candidate = `${prefix}${utf8Prefix(displayName, 1024 - utf8Length(prefix))}`;
|
|
289
|
-
if (available(candidate)) return candidate;
|
|
290
|
-
}
|
|
291
|
-
throw new EidosFileError("constraint-conflict", `Unable to allocate a physical ${kind} name for “${displayName}”`);
|
|
292
|
-
}
|
|
293
|
-
if (!isReservedPhysicalName(kind, displayName) && available(displayName)) return displayName;
|
|
294
|
-
for (const length of [
|
|
295
|
-
8,
|
|
296
|
-
12,
|
|
297
|
-
32
|
|
298
|
-
]) {
|
|
299
|
-
const suffix = `__${idHex.slice(0, length)}`;
|
|
300
|
-
const candidate = `${utf8Prefix(displayName, 1024 - utf8Length(suffix))}${suffix}`;
|
|
301
|
-
if (available(candidate)) return candidate;
|
|
302
|
-
}
|
|
303
|
-
throw new EidosFileError("constraint-conflict", `Unable to allocate a physical ${kind} name for “${displayName}”`);
|
|
248
|
+
function isEidosFileReservedTableName(name) {
|
|
249
|
+
const folded = sqliteNoCase(name);
|
|
250
|
+
return folded.startsWith("sqlite_") || folded.startsWith("eidos__");
|
|
304
251
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
252
|
+
function assertEidosFileTableName(name) {
|
|
253
|
+
assertEidosFileDisplayName(name, "Table name");
|
|
254
|
+
if (isEidosFileReservedTableName(name)) throw new EidosFileError("invalid-identifier", "Table name must not begin with sqlite_ or eidos__");
|
|
255
|
+
return name;
|
|
308
256
|
}
|
|
309
257
|
/** @deprecated Field display names are not restricted to bare SQL tokens. */
|
|
310
258
|
function assertEidosFileColumnName(columnName) {
|
|
@@ -317,34 +265,117 @@ function quoteIdentifier(identifier) {
|
|
|
317
265
|
//#endregion
|
|
318
266
|
//#region src/file-values.ts
|
|
319
267
|
const MAX_FILE_VALUES = 1e4;
|
|
268
|
+
const MAX_FILE_JSON_BYTES = 16 * 1024 * 1024;
|
|
269
|
+
const MAX_INLINE_IMAGE_BYTES = 1048576n;
|
|
320
270
|
const NON_NEGATIVE_INT64 = /^(?:0|[1-9][0-9]*)$/u;
|
|
321
|
-
const
|
|
271
|
+
const MEDIA_TYPE_RESTRICTED_NAME = /^[0-9A-Za-z][!#$&+.^_0-9A-Za-z-]{0,126}$/u;
|
|
272
|
+
const URI_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/u;
|
|
273
|
+
const URI_REFERENCE_ASCII = /^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@/?#\[\]]|%[0-9A-Fa-f]{2})*$/u;
|
|
274
|
+
const CANONICAL_BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
|
|
322
275
|
const MAX_SIGNED_INT64 = 9223372036854775807n;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
276
|
+
const encoder = new TextEncoder();
|
|
277
|
+
function hasHttpsAuthorityWithoutUrl(uri) {
|
|
278
|
+
const authorityAndRest = uri.slice(8);
|
|
279
|
+
const authorityEnd = authorityAndRest.search(/[/?#]/u);
|
|
280
|
+
const authority = authorityEnd < 0 ? authorityAndRest : authorityAndRest.slice(0, authorityEnd);
|
|
281
|
+
if (authority.length === 0) return false;
|
|
282
|
+
const hostAndPort = authority.slice(authority.lastIndexOf("@") + 1);
|
|
283
|
+
if (hostAndPort.length === 0) return false;
|
|
284
|
+
if (hostAndPort.startsWith("[")) {
|
|
285
|
+
const closingBracket = hostAndPort.indexOf("]");
|
|
286
|
+
if (closingBracket <= 1) return false;
|
|
287
|
+
const suffix = hostAndPort.slice(closingBracket + 1);
|
|
288
|
+
return suffix === "" || /^:[0-9]+$/u.test(suffix);
|
|
329
289
|
}
|
|
330
|
-
|
|
290
|
+
const separator = hostAndPort.lastIndexOf(":");
|
|
291
|
+
const host = separator < 0 ? hostAndPort : hostAndPort.slice(0, separator);
|
|
292
|
+
const port = separator < 0 ? "" : hostAndPort.slice(separator + 1);
|
|
293
|
+
return host.length > 0 && !host.includes(":") && (separator < 0 || /^[0-9]+$/u.test(port));
|
|
294
|
+
}
|
|
295
|
+
function isEidosFileMediaType(value) {
|
|
296
|
+
const separator = value.indexOf("/");
|
|
297
|
+
return separator > 0 && separator === value.lastIndexOf("/") && MEDIA_TYPE_RESTRICTED_NAME.test(value.slice(0, separator)) && MEDIA_TYPE_RESTRICTED_NAME.test(value.slice(separator + 1));
|
|
298
|
+
}
|
|
299
|
+
function decodedBase64Size(payload) {
|
|
300
|
+
if (payload.length === 0 || payload.length % 4 !== 0 || !CANONICAL_BASE64.test(payload)) return null;
|
|
301
|
+
const padding = payload.endsWith("==") ? 2 : payload.endsWith("=") ? 1 : 0;
|
|
302
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
303
|
+
if (padding === 2) {
|
|
304
|
+
const last = alphabet.indexOf(payload[payload.length - 3] ?? "");
|
|
305
|
+
if (last < 0 || (last & 15) !== 0) return null;
|
|
306
|
+
} else if (padding === 1) {
|
|
307
|
+
const last = alphabet.indexOf(payload[payload.length - 2] ?? "");
|
|
308
|
+
if (last < 0 || (last & 3) !== 0) return null;
|
|
309
|
+
}
|
|
310
|
+
return BigInt(payload.length / 4) * 3n - BigInt(padding);
|
|
311
|
+
}
|
|
312
|
+
function inlineImageDataUrl(uri) {
|
|
313
|
+
if (!uri.startsWith("data:")) return null;
|
|
314
|
+
const marker = ";base64,";
|
|
315
|
+
const markerIndex = uri.indexOf(marker, 5);
|
|
316
|
+
if (markerIndex < 0 || uri.indexOf(marker, markerIndex + 1) >= 0) return null;
|
|
317
|
+
const mediaType = uri.slice(5, markerIndex);
|
|
318
|
+
const payload = uri.slice(markerIndex + 8);
|
|
319
|
+
if (!mediaType.startsWith("image/") || mediaType !== mediaType.toLowerCase() || !isEidosFileMediaType(mediaType)) return null;
|
|
320
|
+
const decodedSize = decodedBase64Size(payload);
|
|
321
|
+
if (decodedSize === null || decodedSize < 1n || decodedSize > MAX_INLINE_IMAGE_BYTES) return null;
|
|
322
|
+
return {
|
|
323
|
+
mediaType,
|
|
324
|
+
decodedSize
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function isContainedRelativeUri(uri) {
|
|
328
|
+
if (!URI_REFERENCE_ASCII.test(uri) || uri.includes("\0") || uri.includes("\\") || uri.startsWith("/") || URI_SCHEME.test(uri)) return false;
|
|
329
|
+
const pathEnd = uri.search(/[?#]/u);
|
|
330
|
+
const path = pathEnd < 0 ? uri : uri.slice(0, pathEnd);
|
|
331
|
+
let decoded;
|
|
331
332
|
try {
|
|
332
|
-
|
|
333
|
-
return !decoded.startsWith("/") && !decoded.includes("\\") && !decoded.split(/[/?#]/u).includes("..");
|
|
333
|
+
decoded = decodeURIComponent(path);
|
|
334
334
|
} catch {
|
|
335
335
|
return false;
|
|
336
336
|
}
|
|
337
|
+
if (decoded.startsWith("/") || decoded.includes("\\")) return false;
|
|
338
|
+
let depth = 0;
|
|
339
|
+
for (const part of decoded.split("/")) {
|
|
340
|
+
if (!part || part === ".") continue;
|
|
341
|
+
if (part === "..") {
|
|
342
|
+
if (depth === 0) return false;
|
|
343
|
+
depth -= 1;
|
|
344
|
+
} else depth += 1;
|
|
345
|
+
}
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
function eidosFileUriClass(uri) {
|
|
349
|
+
if (uri.startsWith("data:")) return inlineImageDataUrl(uri) ? "data" : null;
|
|
350
|
+
if (/^https:\/\//iu.test(uri)) {
|
|
351
|
+
if (!URI_REFERENCE_ASCII.test(uri)) return null;
|
|
352
|
+
if (typeof URL === "undefined") return hasHttpsAuthorityWithoutUrl(uri) ? "https" : null;
|
|
353
|
+
try {
|
|
354
|
+
const parsed = new URL(uri);
|
|
355
|
+
return parsed.protocol === "https:" && parsed.hostname.length > 0 ? "https" : null;
|
|
356
|
+
} catch {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return isContainedRelativeUri(uri) ? "relative" : null;
|
|
361
|
+
}
|
|
362
|
+
function isSafeEidosFileUri(uri) {
|
|
363
|
+
return eidosFileUriClass(uri) !== null;
|
|
337
364
|
}
|
|
338
365
|
function assertEidosFileValues(value) {
|
|
339
366
|
if (!Array.isArray(value)) throw new EidosFileError("invalid-value", "File value must be a JSON array");
|
|
340
367
|
if (value.length > MAX_FILE_VALUES) throw new EidosFileError("resource-limit", "File value contains too many entries");
|
|
341
368
|
const ids = /* @__PURE__ */ new Set();
|
|
342
|
-
|
|
369
|
+
let canonicalBytes = 2;
|
|
370
|
+
return value.map((entry, index) => {
|
|
343
371
|
if (!entry || Array.isArray(entry) || typeof entry !== "object") throw new EidosFileError("invalid-value", "File value contains an invalid entry");
|
|
344
372
|
const candidate = entry;
|
|
345
|
-
if (typeof candidate.id !== "string" || !isEidosFileUuid(candidate.id) || ids.has(candidate.id) || typeof candidate.uri !== "string" ||
|
|
373
|
+
if (typeof candidate.id !== "string" || !isEidosFileUuid(candidate.id) || ids.has(candidate.id) || typeof candidate.uri !== "string" || typeof candidate.name !== "string" || candidate.name.length === 0 || candidate.name.includes("\0") || typeof candidate.mediaType !== "string" || !isEidosFileMediaType(candidate.mediaType) || typeof candidate.size !== "string" || !NON_NEGATIVE_INT64.test(candidate.size) || BigInt(candidate.size) > MAX_SIGNED_INT64) throw new EidosFileError("invalid-value", "File value contains an invalid entry");
|
|
374
|
+
const uriClass = eidosFileUriClass(candidate.uri);
|
|
375
|
+
const inline = uriClass === "data" ? inlineImageDataUrl(candidate.uri) : null;
|
|
376
|
+
if (!uriClass || inline !== null && (inline.mediaType !== candidate.mediaType || inline.decodedSize !== BigInt(candidate.size))) throw new EidosFileError("invalid-value", "File value contains an invalid entry");
|
|
346
377
|
ids.add(candidate.id);
|
|
347
|
-
|
|
378
|
+
const validated = {
|
|
348
379
|
...candidate,
|
|
349
380
|
id: candidate.id,
|
|
350
381
|
uri: candidate.uri,
|
|
@@ -352,12 +383,35 @@ function assertEidosFileValues(value) {
|
|
|
352
383
|
mediaType: candidate.mediaType,
|
|
353
384
|
size: candidate.size
|
|
354
385
|
};
|
|
386
|
+
let entryBytes;
|
|
387
|
+
try {
|
|
388
|
+
entryBytes = encoder.encode(canonicalizeEidosFileJson(validated)).byteLength;
|
|
389
|
+
} catch {
|
|
390
|
+
throw new EidosFileError("invalid-value", "File value contains an invalid entry");
|
|
391
|
+
}
|
|
392
|
+
canonicalBytes += entryBytes + (index === 0 ? 0 : 1);
|
|
393
|
+
if (canonicalBytes > MAX_FILE_JSON_BYTES) throw new EidosFileError("resource-limit", "File value exceeds the 16 MiB canonical JSON limit");
|
|
394
|
+
return validated;
|
|
355
395
|
});
|
|
356
396
|
}
|
|
357
397
|
function decodeEidosFileValues(value) {
|
|
358
|
-
if (value === void 0 || value === null
|
|
398
|
+
if (value === void 0 || value === null) return [];
|
|
359
399
|
if (typeof value !== "string") throw new EidosFileError("invalid-value", "File value must be canonical JSON");
|
|
360
|
-
|
|
400
|
+
if (encoder.encode(value).byteLength > MAX_FILE_JSON_BYTES) throw new EidosFileError("resource-limit", "File value exceeds the 16 MiB canonical JSON limit");
|
|
401
|
+
let parsed;
|
|
402
|
+
try {
|
|
403
|
+
parsed = parseEidosFileJson(value);
|
|
404
|
+
} catch {
|
|
405
|
+
throw new EidosFileError("invalid-value", "File value must be valid JSON");
|
|
406
|
+
}
|
|
407
|
+
let canonical;
|
|
408
|
+
try {
|
|
409
|
+
canonical = canonicalizeEidosFileJson(parsed);
|
|
410
|
+
} catch {
|
|
411
|
+
throw new EidosFileError("invalid-value", "File value must be canonical JSON");
|
|
412
|
+
}
|
|
413
|
+
if (canonical !== value) throw new EidosFileError("invalid-value", "File value must be canonical JSON");
|
|
414
|
+
return assertEidosFileValues(parsed);
|
|
361
415
|
}
|
|
362
416
|
function encodeEidosFileValues(values) {
|
|
363
417
|
return canonicalizeEidosFileJson(assertEidosFileValues([...values]));
|
|
@@ -365,18 +419,25 @@ function encodeEidosFileValues(values) {
|
|
|
365
419
|
function normalizeEidosFileAttachmentPath(value) {
|
|
366
420
|
const trimmed = value.trim();
|
|
367
421
|
if (!trimmed || trimmed.includes("\0")) return null;
|
|
368
|
-
if (
|
|
422
|
+
if (/^https:\/\//iu.test(trimmed)) return isSafeEidosFileUri(trimmed) ? trimmed : null;
|
|
369
423
|
if (/^[a-z][a-z\d+.-]*:/iu.test(trimmed) || trimmed.startsWith("/")) return null;
|
|
370
424
|
const parts = trimmed.replace(/\\/g, "/").split("/");
|
|
371
425
|
const normalized = [];
|
|
372
426
|
for (const part of parts) {
|
|
373
427
|
if (!part || part === ".") continue;
|
|
374
|
-
|
|
428
|
+
let decoded;
|
|
429
|
+
try {
|
|
430
|
+
decoded = decodeURIComponent(part);
|
|
431
|
+
} catch {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
if (decoded === "..") {
|
|
375
435
|
if (normalized.length === 0) return null;
|
|
376
436
|
normalized.pop();
|
|
377
437
|
continue;
|
|
378
438
|
}
|
|
379
|
-
|
|
439
|
+
if (decoded === ".") continue;
|
|
440
|
+
normalized.push(encodeURIComponent(decoded));
|
|
380
441
|
}
|
|
381
442
|
const uri = normalized.join("/");
|
|
382
443
|
return isSafeEidosFileUri(uri) ? uri : null;
|
|
@@ -397,7 +458,11 @@ function encodeEidosFileAttachmentPaths(paths, previousValue) {
|
|
|
397
458
|
seen.add(uri);
|
|
398
459
|
const existing = previous.get(uri);
|
|
399
460
|
if (existing) return [existing];
|
|
400
|
-
const
|
|
461
|
+
const encodedName = uri.split(/[/?#]/u).at(-1);
|
|
462
|
+
let pathName = encodedName;
|
|
463
|
+
try {
|
|
464
|
+
pathName = encodedName ? decodeURIComponent(encodedName) : encodedName;
|
|
465
|
+
} catch {}
|
|
401
466
|
return [{
|
|
402
467
|
id: createEidosFileUuid(),
|
|
403
468
|
uri,
|
|
@@ -513,6 +578,6 @@ function assertEidosFileSelectOptions(property) {
|
|
|
513
578
|
return options;
|
|
514
579
|
}
|
|
515
580
|
//#endregion
|
|
516
|
-
export {
|
|
581
|
+
export { isCanonicalEidosFileJson as A, assertEidosFileUuid as C, isEidosFileUuid as D, isEidosFileReservedTableName as E, EidosFileError as M, quoteIdentifier as O, assertEidosFileTableName as S, createEidosFileUuid as T, normalizeEidosFileAttachmentPath as _, eidosFileInstantSqlCheck as a, assertEidosFileDisplayName as b, normalizeEidosFileDate as c, decodeEidosFileAttachmentPaths as d, decodeEidosFileValues as f, isSafeEidosFileUri as g, encodeEidosFileValues as h, eidosFileDateSqlCheck as i, parseEidosFileJson as j, canonicalizeEidosFileJson as k, normalizeEidosFileInstant as l, encodeEidosFileAttachmentPaths as m, parseEidosFileSelectOptions as n, isCanonicalEidosFileDate as o, eidosFileUriClass as p, currentEidosFileInstant as r, isCanonicalEidosFileInstant as s, assertEidosFileSelectOptions as t, assertEidosFileValues as u, EidosUuidV7Generator as v, createEidosFileIdentifier as w, assertEidosFileTableId as x, assertEidosFileColumnName as y };
|
|
517
582
|
|
|
518
|
-
//# sourceMappingURL=select-options-
|
|
583
|
+
//# sourceMappingURL=select-options-Dr8XCYOS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-options-Dr8XCYOS.mjs","names":[],"sources":["../src/errors.ts","../src/canonical-json.ts","../src/identifiers.ts","../src/file-values.ts","../src/temporal.ts","../src/select-options.ts"],"sourcesContent":["export type EidosFileErrorCode =\n | \"invalid-sqlite\"\n | \"not-eidos-file\"\n | \"unsupported-version\"\n | \"unsupported-feature\"\n | \"invalid-schema\"\n | \"invalid-formula\"\n | \"invalid-value\"\n | \"constraint-conflict\"\n | \"dependency-cycle\"\n | \"stale-revision\"\n | \"file-conflict\"\n | \"permission-denied\"\n | \"query-limit\"\n | \"resource-limit\"\n /** @deprecated Use unsupported-version. */\n | \"unsupported-format\"\n | \"invalid-identifier\"\n | \"invalid-query\"\n | \"invalid-range\"\n | \"invalid-csv\"\n | \"protected-field\"\n | \"protected-view\"\n | \"relation-in-use\"\n | \"formula-in-use\"\n | \"lookup-in-use\"\n | \"table-not-found\"\n | \"row-not-found\"\n | \"field-not-found\"\n | \"view-not-found\"\n | \"file-exists\"\n | \"file-not-found\"\n\nexport class EidosFileError extends Error {\n constructor(\n readonly code: EidosFileErrorCode,\n message: string\n ) {\n super(message)\n this.name = \"EidosFileError\"\n }\n}\n","import { EidosFileError } from \"./errors\"\n\nexport type EidosFileJsonValue =\n | null\n | boolean\n | number\n | string\n | EidosFileJsonValue[]\n | { [key: string]: EidosFileJsonValue }\n\nfunction assertUnicodeScalarString(value: string): void {\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index)\n if (code >= 0xd800 && code <= 0xdbff) {\n const next = value.charCodeAt(index + 1)\n if (!(next >= 0xdc00 && next <= 0xdfff)) {\n throw new EidosFileError(\n \"invalid-value\",\n \"I-JSON strings cannot contain unpaired surrogates\"\n )\n }\n index += 1\n } else if (code >= 0xdc00 && code <= 0xdfff) {\n throw new EidosFileError(\n \"invalid-value\",\n \"I-JSON strings cannot contain unpaired surrogates\"\n )\n }\n }\n}\n\nfunction assertNoDuplicateJsonKeys(text: string): void {\n let index = 0\n const whitespace = (): void => {\n while (/\\s/u.test(text[index] ?? \"\")) index += 1\n }\n const string = (): string => {\n const start = index++\n while (index < text.length) {\n if (text[index] === \"\\\\\") {\n index += 2\n } else if (text[index] === '\"') {\n index += 1\n return JSON.parse(text.slice(start, index)) as string\n } else {\n index += 1\n }\n }\n throw new EidosFileError(\"invalid-value\", \"Value is not valid JSON\")\n }\n const value = (): void => {\n whitespace()\n if (text[index] === '\"') {\n string()\n return\n }\n if (text[index] === \"[\") {\n index += 1\n whitespace()\n if (text[index] === \"]\") {\n index += 1\n return\n }\n while (index < text.length) {\n value()\n whitespace()\n if (text[index] === \"]\") {\n index += 1\n return\n }\n if (text[index++] !== \",\") break\n }\n throw new EidosFileError(\"invalid-value\", \"Value is not valid JSON\")\n }\n if (text[index] === \"{\") {\n index += 1\n const keys = new Set<string>()\n whitespace()\n if (text[index] === \"}\") {\n index += 1\n return\n }\n while (index < text.length) {\n whitespace()\n if (text[index] !== '\"') break\n const key = string()\n if (keys.has(key)) {\n throw new EidosFileError(\n \"invalid-value\",\n `Duplicate I-JSON object key: ${key}`\n )\n }\n keys.add(key)\n whitespace()\n if (text[index++] !== \":\") break\n value()\n whitespace()\n if (text[index] === \"}\") {\n index += 1\n return\n }\n if (text[index++] !== \",\") break\n }\n throw new EidosFileError(\"invalid-value\", \"Value is not valid JSON\")\n }\n while (index < text.length && !/[\\s,\\]}]/u.test(text[index]!)) index += 1\n }\n value()\n whitespace()\n if (index !== text.length) {\n throw new EidosFileError(\"invalid-value\", \"Value is not valid JSON\")\n }\n}\n\nfunction normalize(value: unknown, stack: Set<object>): EidosFileJsonValue {\n if (value === null || typeof value === \"boolean\") {\n return value\n }\n if (typeof value === \"string\") {\n assertUnicodeScalarString(value)\n return value\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new EidosFileError(\n \"invalid-value\",\n \"Canonical JSON numbers must be finite binary64 values\"\n )\n }\n return Object.is(value, -0) ? 0 : value\n }\n if (typeof value !== \"object\" || value === undefined) {\n throw new EidosFileError(\"invalid-value\", \"Value is not valid I-JSON\")\n }\n if (stack.has(value)) {\n throw new EidosFileError(\"invalid-value\", \"Canonical JSON cannot be cyclic\")\n }\n stack.add(value)\n try {\n if (Array.isArray(value)) {\n return value.map((entry) => normalize(entry, stack))\n }\n const normalized: Record<string, EidosFileJsonValue> = {}\n for (const key of Object.keys(value).sort()) {\n assertUnicodeScalarString(key)\n normalized[key] = normalize(\n (value as Record<string, unknown>)[key],\n stack\n )\n }\n return normalized\n } finally {\n stack.delete(value)\n }\n}\n\n/** RFC 8785-compatible canonical serialization for the Eidos JSON subset. */\nexport function canonicalizeEidosFileJson(value: unknown): string {\n return JSON.stringify(normalize(value, new Set()))\n}\n\nexport function parseEidosFileJson(text: string): EidosFileJsonValue {\n let value: unknown\n try {\n assertNoDuplicateJsonKeys(text)\n value = JSON.parse(text)\n } catch (error) {\n if (error instanceof EidosFileError) throw error\n throw new EidosFileError(\"invalid-value\", \"Value is not valid JSON\")\n }\n return normalize(value, new Set())\n}\n\nexport function isCanonicalEidosFileJson(text: string): boolean {\n try {\n return canonicalizeEidosFileJson(parseEidosFileJson(text)) === text\n } catch {\n return false\n }\n}\n","import { EidosFileError } from \"./errors\"\n\nconst UUID_V7 =\n /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/\n\nfunction sqliteNoCase(value: string): string {\n return value.replace(/[A-Z]/g, (character) => character.toLowerCase())\n}\n\nfunction utf8Length(value: string): number {\n return new TextEncoder().encode(value).byteLength\n}\n\nexport function isEidosFileUuid(value: unknown): value is string {\n return typeof value === \"string\" && UUID_V7.test(value)\n}\n\nexport function assertEidosFileUuid(value: string, label = \"ID\"): string {\n if (!isEidosFileUuid(value)) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} must be a lowercase hyphenated UUIDv7`\n )\n }\n return value\n}\n\nfunction bytesToUuid(value: Uint8Array): string {\n const hex = Array.from(value, (byte) =>\n byte.toString(16).padStart(2, \"0\")\n ).join(\"\")\n const uuid = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`\n return assertEidosFileUuid(uuid)\n}\n\nlet lastUuidV7Timestamp = -1\nlet lastUuidV7Bytes: Uint8Array | undefined\n\nfunction incrementUuidV7Random(bytes: Uint8Array): boolean {\n for (let index = 15; index >= 9; index -= 1) {\n if (bytes[index]! < 0xff) {\n bytes[index] = bytes[index]! + 1\n return true\n }\n bytes[index] = 0\n }\n const variantRandom = bytes[8]! & 0x3f\n if (variantRandom < 0x3f) {\n bytes[8] = 0x80 | (variantRandom + 1)\n return true\n }\n bytes[8] = 0x80\n if (bytes[7]! < 0xff) {\n bytes[7] = bytes[7]! + 1\n return true\n }\n bytes[7] = 0\n const versionRandom = bytes[6]! & 0x0f\n if (versionRandom < 0x0f) {\n bytes[6] = 0x70 | (versionRandom + 1)\n return true\n }\n return false\n}\n\n/** Runtime-epoch UUIDv7 allocator with injected time and secure entropy. */\nexport class EidosUuidV7Generator {\n private lastTimestamp: number | undefined\n private lastBytes: Uint8Array | undefined\n\n constructor(\n private readonly nowInstant: () => string,\n private readonly randomBytes: (length: number) => Uint8Array\n ) {}\n\n next(): string {\n const wallInstant = this.nowInstant()\n const wallTimestamp = Date.parse(wallInstant)\n if (\n !Number.isSafeInteger(wallTimestamp) ||\n wallTimestamp < 0 ||\n wallTimestamp > 0xffffffffffff\n ) {\n throw new EidosFileError(\n \"resource-limit\",\n \"Wall clock cannot be encoded as a UUIDv7 timestamp\"\n )\n }\n const timestamp =\n this.lastTimestamp === undefined\n ? wallTimestamp\n : Math.max(wallTimestamp, this.lastTimestamp)\n let bytes: Uint8Array\n if (this.lastBytes && timestamp === this.lastTimestamp) {\n bytes = this.lastBytes.slice()\n if (!incrementUuidV7Random(bytes)) {\n throw new EidosFileError(\n \"resource-limit\",\n \"UUIDv7 monotonic payload was exhausted for one millisecond\"\n )\n }\n } else {\n const supplied = this.randomBytes(16)\n if (!(supplied instanceof Uint8Array) || supplied.byteLength !== 16) {\n throw new EidosFileError(\n \"resource-limit\",\n \"EntropyPort must return exactly the requested owned bytes\"\n )\n }\n bytes = supplied.slice()\n }\n let remaining = timestamp\n for (let index = 5; index >= 0; index -= 1) {\n bytes[index] = remaining % 256\n remaining = Math.floor(remaining / 256)\n }\n bytes[6] = 0x70 | (bytes[6]! & 0x0f)\n bytes[8] = 0x80 | (bytes[8]! & 0x3f)\n this.lastTimestamp = timestamp\n this.lastBytes = bytes.slice()\n return bytesToUuid(bytes)\n }\n}\n\n/** Creates an RFC 9562 UUIDv7 using the current Unix millisecond timestamp. */\nexport function createEidosFileUuid(timestamp = Date.now()): string {\n if (\n !Number.isSafeInteger(timestamp) ||\n timestamp < 0 ||\n timestamp > 0xffffffffffff\n ) {\n throw new EidosFileError(\n \"invalid-value\",\n \"UUIDv7 timestamp is out of range\"\n )\n }\n const bytes =\n timestamp === lastUuidV7Timestamp && lastUuidV7Bytes\n ? new Uint8Array(lastUuidV7Bytes)\n : globalThis.crypto.getRandomValues(new Uint8Array(16))\n if (\n timestamp === lastUuidV7Timestamp &&\n lastUuidV7Bytes &&\n !incrementUuidV7Random(bytes)\n ) {\n throw new EidosFileError(\n \"resource-limit\",\n \"UUIDv7 monotonic random space was exhausted for one millisecond\"\n )\n }\n let time = timestamp\n for (let index = 5; index >= 0; index -= 1) {\n bytes[index] = time % 256\n time = Math.floor(time / 256)\n }\n bytes[6] = 0x70 | (bytes[6]! & 0x0f)\n bytes[8] = 0x80 | (bytes[8]! & 0x3f)\n lastUuidV7Timestamp = timestamp\n lastUuidV7Bytes = new Uint8Array(bytes)\n return bytesToUuid(bytes)\n}\n\n/** @deprecated Use UUID strings as stable public identifiers. */\nexport function createEidosFileIdentifier(): string {\n return createEidosFileUuid()\n}\n\n/** UUIDs are the only valid Table IDs in Eidos File 1.0. */\nexport function assertEidosFileTableId(tableId: string): string {\n return assertEidosFileUuid(tableId, \"Table ID\")\n}\n\nexport function assertEidosFileDisplayName(\n name: string,\n label: string\n): string {\n if (\n name.length === 0 ||\n name.includes(\"\\u0000\") ||\n utf8Length(name) > 1024 ||\n /[\\uD800-\\uDFFF]/u.test(\n Array.from(name)\n .filter((scalar) => scalar.length === 1)\n .join(\"\")\n )\n ) {\n throw new EidosFileError(\n \"invalid-identifier\",\n `${label} must be 1..1024 UTF-8 octets, contain Unicode scalar values, and exclude U+0000`\n )\n }\n return name\n}\n\nexport function isEidosFileReservedTableName(name: string): boolean {\n const folded = sqliteNoCase(name)\n return folded.startsWith(\"sqlite_\") || folded.startsWith(\"eidos__\")\n}\n\nexport function assertEidosFileTableName(name: string): string {\n assertEidosFileDisplayName(name, \"Table name\")\n if (isEidosFileReservedTableName(name)) {\n throw new EidosFileError(\n \"invalid-identifier\",\n \"Table name must not begin with sqlite_ or eidos__\"\n )\n }\n return name\n}\n\n/** @deprecated Field display names are not restricted to bare SQL tokens. */\nexport function assertEidosFileColumnName(columnName: string): string {\n return assertEidosFileDisplayName(columnName, \"Field name\")\n}\n\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.includes(\"\\u0000\")) {\n throw new EidosFileError(\n \"invalid-identifier\",\n \"SQLite identifiers must not contain U+0000\"\n )\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`\n}\n","import { canonicalizeEidosFileJson, parseEidosFileJson } from \"./canonical-json\"\nimport { EidosFileError } from \"./errors\"\nimport { createEidosFileUuid, isEidosFileUuid } from \"./identifiers\"\nimport type { EidosFileFileValue, EidosFileRowValue } from \"./types\"\n\nconst MAX_FILE_VALUES = 10_000\nconst MAX_FILE_JSON_BYTES = 16 * 1_024 * 1_024\nconst MAX_INLINE_IMAGE_BYTES = 1_048_576n\nconst NON_NEGATIVE_INT64 = /^(?:0|[1-9][0-9]*)$/u\nconst MEDIA_TYPE_RESTRICTED_NAME = /^[0-9A-Za-z][!#$&+.^_0-9A-Za-z-]{0,126}$/u\nconst URI_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/u\nconst URI_REFERENCE_ASCII =\n /^(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@/?#\\[\\]]|%[0-9A-Fa-f]{2})*$/u\nconst CANONICAL_BASE64 =\n /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u\nconst MAX_SIGNED_INT64 = 9_223_372_036_854_775_807n\nconst encoder = new TextEncoder()\n\nexport type EidosFileUriClass = \"relative\" | \"https\" | \"data\"\n\nfunction hasHttpsAuthorityWithoutUrl(uri: string): boolean {\n const authorityAndRest = uri.slice(\"https://\".length)\n const authorityEnd = authorityAndRest.search(/[/?#]/u)\n const authority =\n authorityEnd < 0\n ? authorityAndRest\n : authorityAndRest.slice(0, authorityEnd)\n if (authority.length === 0) return false\n\n const hostAndPort = authority.slice(authority.lastIndexOf(\"@\") + 1)\n if (hostAndPort.length === 0) return false\n if (hostAndPort.startsWith(\"[\")) {\n const closingBracket = hostAndPort.indexOf(\"]\")\n if (closingBracket <= 1) return false\n const suffix = hostAndPort.slice(closingBracket + 1)\n return suffix === \"\" || /^:[0-9]+$/u.test(suffix)\n }\n\n const separator = hostAndPort.lastIndexOf(\":\")\n const host = separator < 0 ? hostAndPort : hostAndPort.slice(0, separator)\n const port = separator < 0 ? \"\" : hostAndPort.slice(separator + 1)\n return (\n host.length > 0 &&\n !host.includes(\":\") &&\n (separator < 0 || /^[0-9]+$/u.test(port))\n )\n}\n\nfunction isEidosFileMediaType(value: string): boolean {\n const separator = value.indexOf(\"/\")\n return (\n separator > 0 &&\n separator === value.lastIndexOf(\"/\") &&\n MEDIA_TYPE_RESTRICTED_NAME.test(value.slice(0, separator)) &&\n MEDIA_TYPE_RESTRICTED_NAME.test(value.slice(separator + 1))\n )\n}\n\nfunction decodedBase64Size(payload: string): bigint | null {\n if (\n payload.length === 0 ||\n payload.length % 4 !== 0 ||\n !CANONICAL_BASE64.test(payload)\n ) {\n return null\n }\n const padding = payload.endsWith(\"==\") ? 2 : payload.endsWith(\"=\") ? 1 : 0\n const alphabet =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"\n if (padding === 2) {\n const last = alphabet.indexOf(payload[payload.length - 3] ?? \"\")\n if (last < 0 || (last & 0b1111) !== 0) return null\n } else if (padding === 1) {\n const last = alphabet.indexOf(payload[payload.length - 2] ?? \"\")\n if (last < 0 || (last & 0b11) !== 0) return null\n }\n return BigInt(payload.length / 4) * 3n - BigInt(padding)\n}\n\nfunction inlineImageDataUrl(\n uri: string\n): { mediaType: string; decodedSize: bigint } | null {\n if (!uri.startsWith(\"data:\")) return null\n const marker = \";base64,\"\n const markerIndex = uri.indexOf(marker, 5)\n if (markerIndex < 0 || uri.indexOf(marker, markerIndex + 1) >= 0) return null\n const mediaType = uri.slice(5, markerIndex)\n const payload = uri.slice(markerIndex + marker.length)\n if (\n !mediaType.startsWith(\"image/\") ||\n mediaType !== mediaType.toLowerCase() ||\n !isEidosFileMediaType(mediaType)\n ) {\n return null\n }\n const decodedSize = decodedBase64Size(payload)\n if (\n decodedSize === null ||\n decodedSize < 1n ||\n decodedSize > MAX_INLINE_IMAGE_BYTES\n ) {\n return null\n }\n return { mediaType, decodedSize }\n}\n\nfunction isContainedRelativeUri(uri: string): boolean {\n if (\n !URI_REFERENCE_ASCII.test(uri) ||\n uri.includes(\"\\0\") ||\n uri.includes(\"\\\\\") ||\n uri.startsWith(\"/\") ||\n URI_SCHEME.test(uri)\n ) {\n return false\n }\n const pathEnd = uri.search(/[?#]/u)\n const path = pathEnd < 0 ? uri : uri.slice(0, pathEnd)\n let decoded: string\n try {\n decoded = decodeURIComponent(path)\n } catch {\n return false\n }\n if (decoded.startsWith(\"/\") || decoded.includes(\"\\\\\")) return false\n let depth = 0\n for (const part of decoded.split(\"/\")) {\n if (!part || part === \".\") continue\n if (part === \"..\") {\n if (depth === 0) return false\n depth -= 1\n } else {\n depth += 1\n }\n }\n return true\n}\n\nexport function eidosFileUriClass(uri: string): EidosFileUriClass | null {\n if (uri.startsWith(\"data:\")) return inlineImageDataUrl(uri) ? \"data\" : null\n if (/^https:\\/\\//iu.test(uri)) {\n if (!URI_REFERENCE_ASCII.test(uri)) return null\n if (typeof URL === \"undefined\") {\n return hasHttpsAuthorityWithoutUrl(uri) ? \"https\" : null\n }\n try {\n const parsed = new URL(uri)\n return parsed.protocol === \"https:\" && parsed.hostname.length > 0\n ? \"https\"\n : null\n } catch {\n return null\n }\n }\n return isContainedRelativeUri(uri) ? \"relative\" : null\n}\n\nexport function isSafeEidosFileUri(uri: string): boolean {\n return eidosFileUriClass(uri) !== null\n}\n\nexport function assertEidosFileValues(value: unknown): EidosFileFileValue[] {\n if (!Array.isArray(value)) {\n throw new EidosFileError(\"invalid-value\", \"File value must be a JSON array\")\n }\n if (value.length > MAX_FILE_VALUES) {\n throw new EidosFileError(\n \"resource-limit\",\n \"File value contains too many entries\"\n )\n }\n const ids = new Set<string>()\n let canonicalBytes = 2\n return value.map((entry, index) => {\n if (!entry || Array.isArray(entry) || typeof entry !== \"object\") {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value contains an invalid entry\"\n )\n }\n const candidate = entry as Record<string, unknown>\n if (\n typeof candidate.id !== \"string\" ||\n !isEidosFileUuid(candidate.id) ||\n ids.has(candidate.id) ||\n typeof candidate.uri !== \"string\" ||\n typeof candidate.name !== \"string\" ||\n candidate.name.length === 0 ||\n candidate.name.includes(\"\\u0000\") ||\n typeof candidate.mediaType !== \"string\" ||\n !isEidosFileMediaType(candidate.mediaType) ||\n typeof candidate.size !== \"string\" ||\n !NON_NEGATIVE_INT64.test(candidate.size) ||\n BigInt(candidate.size) > MAX_SIGNED_INT64\n ) {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value contains an invalid entry\"\n )\n }\n const uriClass = eidosFileUriClass(candidate.uri)\n const inline =\n uriClass === \"data\" ? inlineImageDataUrl(candidate.uri) : null\n if (\n !uriClass ||\n (inline !== null &&\n (inline.mediaType !== candidate.mediaType ||\n inline.decodedSize !== BigInt(candidate.size)))\n ) {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value contains an invalid entry\"\n )\n }\n ids.add(candidate.id)\n const validated = {\n ...candidate,\n id: candidate.id,\n uri: candidate.uri,\n name: candidate.name,\n mediaType: candidate.mediaType,\n size: candidate.size,\n } as EidosFileFileValue\n let entryBytes: number\n try {\n entryBytes = encoder.encode(\n canonicalizeEidosFileJson(validated)\n ).byteLength\n } catch {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value contains an invalid entry\"\n )\n }\n canonicalBytes += entryBytes + (index === 0 ? 0 : 1)\n if (canonicalBytes > MAX_FILE_JSON_BYTES) {\n throw new EidosFileError(\n \"resource-limit\",\n \"File value exceeds the 16 MiB canonical JSON limit\"\n )\n }\n return validated\n })\n}\n\nexport function decodeEidosFileValues(\n value: EidosFileRowValue | undefined\n): EidosFileFileValue[] {\n if (value === undefined || value === null) return []\n if (typeof value !== \"string\") {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value must be canonical JSON\"\n )\n }\n if (encoder.encode(value).byteLength > MAX_FILE_JSON_BYTES) {\n throw new EidosFileError(\n \"resource-limit\",\n \"File value exceeds the 16 MiB canonical JSON limit\"\n )\n }\n let parsed: unknown\n try {\n parsed = parseEidosFileJson(value)\n } catch {\n throw new EidosFileError(\"invalid-value\", \"File value must be valid JSON\")\n }\n let canonical: string\n try {\n canonical = canonicalizeEidosFileJson(parsed)\n } catch {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value must be canonical JSON\"\n )\n }\n if (canonical !== value) {\n throw new EidosFileError(\n \"invalid-value\",\n \"File value must be canonical JSON\"\n )\n }\n return assertEidosFileValues(parsed)\n}\n\nexport function encodeEidosFileValues(\n values: readonly EidosFileFileValue[]\n): string {\n return canonicalizeEidosFileJson(assertEidosFileValues([...values]))\n}\n\nexport function normalizeEidosFileAttachmentPath(value: string): string | null {\n const trimmed = value.trim()\n if (!trimmed || trimmed.includes(\"\\0\")) return null\n if (/^https:\\/\\//iu.test(trimmed)) {\n return isSafeEidosFileUri(trimmed) ? trimmed : null\n }\n if (/^[a-z][a-z\\d+.-]*:/iu.test(trimmed) || trimmed.startsWith(\"/\")) {\n return null\n }\n const parts = trimmed.replace(/\\\\/g, \"/\").split(\"/\")\n const normalized: string[] = []\n for (const part of parts) {\n if (!part || part === \".\") continue\n let decoded: string\n try {\n decoded = decodeURIComponent(part)\n } catch {\n return null\n }\n if (decoded === \"..\") {\n if (normalized.length === 0) return null\n normalized.pop()\n continue\n }\n if (decoded === \".\") continue\n normalized.push(encodeURIComponent(decoded))\n }\n const uri = normalized.join(\"/\")\n return isSafeEidosFileUri(uri) ? uri : null\n}\n\nexport function decodeEidosFileAttachmentPaths(\n value: EidosFileRowValue | undefined\n): string[] {\n return decodeEidosFileValues(value).map((file) => file.uri)\n}\n\n/**\n * Compatibility helper for path-oriented host pickers. Existing File IDs are\n * retained by URI; new attachments receive UUIDv7 identities.\n */\nexport function encodeEidosFileAttachmentPaths(\n paths: readonly string[],\n previousValue?: EidosFileRowValue\n): string | null {\n const previous = new Map(\n decodeEidosFileValues(previousValue).map((file) => [file.uri, file])\n )\n const seen = new Set<string>()\n const values = paths.flatMap((path) => {\n const uri = normalizeEidosFileAttachmentPath(path)\n if (!uri || seen.has(uri)) return []\n seen.add(uri)\n const existing = previous.get(uri)\n if (existing) return [existing]\n const encodedName = uri.split(/[/?#]/u).at(-1)\n let pathName = encodedName\n try {\n pathName = encodedName ? decodeURIComponent(encodedName) : encodedName\n } catch {\n // normalizeEidosFileAttachmentPath already validated percent encoding.\n }\n return [\n {\n id: createEidosFileUuid(),\n uri,\n name: pathName || \"attachment\",\n mediaType: \"application/octet-stream\",\n size: \"0\",\n },\n ]\n })\n return values.length > 0 ? encodeEidosFileValues(values) : null\n}\n","import { EidosFileError } from \"./errors\"\n\nconst CANONICAL_DATE = /^\\d{4}-\\d{2}-\\d{2}$/\nconst CANONICAL_INSTANT = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/\nconst RFC3339_INSTANT =\n /^(\\d{4}-\\d{2}-\\d{2})[Tt](\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?([Zz]|([+-])(\\d{2}):(\\d{2}))$/\n\nfunction validCalendarDate(value: string): boolean {\n if (!CANONICAL_DATE.test(value) || value.startsWith(\"0000-\")) return false\n const parsed = new Date(`${value}T00:00:00.000Z`)\n return (\n !Number.isNaN(parsed.getTime()) &&\n parsed.toISOString().slice(0, 10) === value\n )\n}\n\n/** Returns whether a value is the canonical Eidos File calendar date. */\nexport function isCanonicalEidosFileDate(value: unknown): value is string {\n return typeof value === \"string\" && validCalendarDate(value)\n}\n\n/** Returns whether a value is the canonical 24-octet Eidos File instant. */\nexport function isCanonicalEidosFileInstant(value: unknown): value is string {\n if (typeof value !== \"string\" || !CANONICAL_INSTANT.test(value)) return false\n const match = RFC3339_INSTANT.exec(value)\n if (!match || !validCalendarDate(match[1]!)) return false\n const hour = Number(match[2])\n const minute = Number(match[3])\n const second = Number(match[4])\n if (hour > 23 || minute > 59 || second > 59) return false\n const parsed = new Date(value)\n return !Number.isNaN(parsed.getTime()) && parsed.toISOString() === value\n}\n\n/** Validates an exact `YYYY-MM-DD` API/storage value. */\nexport function normalizeEidosFileDate(value: string, label = \"date\"): string {\n if (!isCanonicalEidosFileDate(value)) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} must use canonical YYYY-MM-DD text`\n )\n }\n return value\n}\n\n/**\n * Normalizes RFC 3339 API input to the canonical UTC millisecond form.\n * Precision beyond milliseconds is rejected instead of silently truncated.\n */\nexport function normalizeEidosFileInstant(\n value: string,\n label = \"instant\"\n): string {\n const match = RFC3339_INSTANT.exec(value)\n if (!match || !validCalendarDate(match[1]!)) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} must be an RFC 3339 instant`\n )\n }\n const fraction = match[5] ?? \"\"\n if (fraction.length > 3) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} has sub-millisecond precision; lossy conversion was not requested`\n )\n }\n const hour = Number(match[2])\n const minute = Number(match[3])\n const second = Number(match[4])\n const offsetHour = match[8] === undefined ? 0 : Number(match[8])\n const offsetMinute = match[9] === undefined ? 0 : Number(match[9])\n if (\n hour > 23 ||\n minute > 59 ||\n second > 59 ||\n offsetHour > 23 ||\n offsetMinute > 59\n ) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} must be an RFC 3339 instant`\n )\n }\n const timestamp = Date.parse(value)\n if (!Number.isFinite(timestamp)) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} must be an RFC 3339 instant`\n )\n }\n const canonical = new Date(timestamp).toISOString()\n if (!isCanonicalEidosFileInstant(canonical)) {\n throw new EidosFileError(\n \"invalid-value\",\n `${label} must resolve to a UTC year from 0001 through 9999`\n )\n }\n return canonical\n}\n\n/** Returns the current canonical UTC instant. */\nexport function currentEidosFileInstant(now = new Date()): string {\n const value = now.toISOString()\n if (!isCanonicalEidosFileInstant(value)) {\n throw new EidosFileError(\n \"invalid-value\",\n \"Current time is outside the canonical Eidos File instant range\"\n )\n }\n return value\n}\n\n/** SQLite CHECK body for a nullable canonical date expression. */\nexport function eidosFileDateSqlCheck(expression: string): string {\n return `${expression} IS NULL OR (\n length(CAST(${expression} AS BLOB)) = 10\n AND ${expression} GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'\n AND substr(${expression}, 1, 4) <> '0000'\n AND coalesce(strftime('%Y-%m-%d', ${expression}, '+0 days') = ${expression}, 0)\n )`\n}\n\n/** SQLite CHECK body for a nullable canonical instant expression. */\nexport function eidosFileInstantSqlCheck(expression: string): string {\n return `${expression} IS NULL OR (\n length(CAST(${expression} AS BLOB)) = 24\n AND ${expression} GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]Z'\n AND substr(${expression}, 1, 4) <> '0000'\n AND coalesce(strftime('%Y-%m-%dT%H:%M:%fZ', ${expression}, '+0 seconds') = ${expression}, 0)\n )`\n}\n","import { EidosFileError } from \"./errors\"\nimport type { EidosFileSelectOption } from \"./types\"\n\nexport function parseEidosFileSelectOptions(\n property: Record<string, unknown> | null | undefined\n): EidosFileSelectOption[] {\n const options = property?.options\n if (!Array.isArray(options)) return []\n return options.flatMap((option) => {\n if (typeof option !== \"object\" || option === null) return []\n const name =\n \"name\" in option && typeof option.name === \"string\" ? option.name : null\n if (name === null) return []\n return [\n {\n name,\n color:\n \"color\" in option && typeof option.color === \"string\"\n ? option.color\n : \"default\",\n },\n ]\n })\n}\n\nexport function assertEidosFileSelectOptions(\n property: Record<string, unknown> | null | undefined\n): EidosFileSelectOption[] {\n const rawOptions = property?.options\n if (rawOptions === undefined) return []\n if (!Array.isArray(rawOptions)) {\n throw new EidosFileError(\n \"invalid-schema\",\n \"Select Field settings.options must be an array\"\n )\n }\n const options = parseEidosFileSelectOptions(property)\n if (options.length !== rawOptions.length) {\n throw new EidosFileError(\n \"invalid-schema\",\n \"Every Select option requires a string name\"\n )\n }\n const names = new Set<string>()\n for (const option of options) {\n const name = option.name\n if (names.has(name)) {\n throw new EidosFileError(\n \"constraint-conflict\",\n `Duplicate Select option name: ${name}`\n )\n }\n names.add(name)\n }\n return options\n}\n"],"mappings":";AAiCA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YACE,MACA,SACA;AACA,QAAM,QAAQ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AAS,WAAW,OAAO,OAAO;AACtE,MAAI,SAAS,KAAM,QAAO,EAAE;AAC5B,SAAO,CACL;GACE;GACA,OACE,WAAW,UAAU,OAAO,OAAO,UAAU,WACzC,OAAO,QACP;GACP,CACF;GACD;;AAGJ,SAAgB,6BACd,UACyB;CACzB,MAAM,aAAa,UAAU;AAC7B,KAAI,eAAe,KAAA,EAAW,QAAO,EAAE;AACvC,KAAI,CAAC,MAAM,QAAQ,WAAW,CAC5B,OAAM,IAAI,eACR,kBACA,iDACD;CAEH,MAAM,UAAU,4BAA4B,SAAS;AACrD,KAAI,QAAQ,WAAW,WAAW,OAChC,OAAM,IAAI,eACR,kBACA,6CACD;CAEH,MAAM,wBAAQ,IAAI,KAAa;AAC/B,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,OAAO,OAAO;AACpB,MAAI,MAAM,IAAI,KAAK,CACjB,OAAM,IAAI,eACR,uBACA,iCAAiC,OAClC;AAEH,QAAM,IAAI,KAAK;;AAEjB,QAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { k as canonicalizeEidosFileJson } from "./select-options-Dr8XCYOS.mjs";
|
|
2
|
+
import { G as EIDOS_FILE_FORMAT, H as EIDOS_FILE_EXTENSION, X as EIDOS_FILE_MIME_TYPE, ct as EidosAdapterError, dt as assertUnicodeString, ft as exactConnectionBindingCount, g as parseNonNegativeInt64, lt as assertExactConnectionBindings, m as MemoryByteSource, ut as assertInt64Decimal } from "./runtime-qbuZMbV4.mjs";
|
|
3
3
|
//#region src/adapter-transport.ts
|
|
4
4
|
const EIDOS_ADAPTER_TRANSPORT_LIMITS = Object.freeze({
|
|
5
5
|
maxOutstandingRequests: 32,
|
|
@@ -572,7 +572,6 @@ var AdapterTransportRuntimeClient = class {
|
|
|
572
572
|
if (!this.limits || this.state !== "open") throw runtimeFailure(this.state === "fatal" ? "fatal" : "closed", "Transport is not open");
|
|
573
573
|
if (this.applicationToWire.has(context.requestId)) throw runtimeFailure("invalid-request", "requestId is already unresolved");
|
|
574
574
|
if (this.pending.size >= this.limits.maxOutstandingRequests) throw runtimeFailure("resource-limit", "Transport request limit reached", true);
|
|
575
|
-
if (Array.from(this.pending.values()).some((pending) => PREPARED_OPERATIONS.has(pending.operation))) throw runtimeFailure("resource-limit", "A prepared-capable mutation must settle before another request");
|
|
576
575
|
const attachment = operation === "importCsv" ? extractCsvRequest(logicalRequest) : {
|
|
577
576
|
payload: logicalRequest,
|
|
578
577
|
attachments: []
|
|
@@ -997,6 +996,9 @@ var EidosFileRuntimeDataSource = class {
|
|
|
997
996
|
async getRow(tableId, rowId) {
|
|
998
997
|
return this.runtime.getRow(tableId, rowId);
|
|
999
998
|
}
|
|
999
|
+
async getRowIndex(tableId, rowId, query) {
|
|
1000
|
+
return this.runtime.getRowIndex(tableId, rowId, query);
|
|
1001
|
+
}
|
|
1000
1002
|
async getGroupCounts(tableId, fieldId, query) {
|
|
1001
1003
|
return this.runtime.countRowsByField(tableId, fieldId, query);
|
|
1002
1004
|
}
|
|
@@ -1026,11 +1028,21 @@ var EidosFileRuntimeDataSource = class {
|
|
|
1026
1028
|
})());
|
|
1027
1029
|
}
|
|
1028
1030
|
async deleteRowRanges(tableId, ranges, query) {
|
|
1029
|
-
const
|
|
1030
|
-
return this.deleteResult(tableId,
|
|
1031
|
+
const result = this.runtime.deleteRowRangesReversible(tableId, ranges, query);
|
|
1032
|
+
return this.deleteResult(tableId, result.deleted.length, result.rowCount, result.undoToken);
|
|
1031
1033
|
}
|
|
1032
1034
|
async deleteRows(tableId, rowIds) {
|
|
1033
|
-
|
|
1035
|
+
const result = this.runtime.deleteRowsReversible(tableId, rowIds);
|
|
1036
|
+
return this.deleteResult(tableId, result.deleted.length, result.rowCount, result.undoToken);
|
|
1037
|
+
}
|
|
1038
|
+
async revertRowMutation(tableId, undoToken) {
|
|
1039
|
+
const result = this.runtime.revertRowMutation(undoToken);
|
|
1040
|
+
return {
|
|
1041
|
+
tableId,
|
|
1042
|
+
rowCount: result.rowCount,
|
|
1043
|
+
revision: result.revision,
|
|
1044
|
+
undoToken: result.undoToken
|
|
1045
|
+
};
|
|
1034
1046
|
}
|
|
1035
1047
|
async updateField(tableId, fieldId, changes) {
|
|
1036
1048
|
this.runtime.updateField(tableId, fieldId, changes);
|
|
@@ -1084,12 +1096,13 @@ var EidosFileRuntimeDataSource = class {
|
|
|
1084
1096
|
revision: this.runtime.info().revision
|
|
1085
1097
|
};
|
|
1086
1098
|
}
|
|
1087
|
-
deleteResult(tableId, deletedCount) {
|
|
1099
|
+
deleteResult(tableId, deletedCount, rowCount, undoToken) {
|
|
1088
1100
|
return {
|
|
1089
1101
|
tableId,
|
|
1090
1102
|
deletedCount,
|
|
1091
|
-
rowCount
|
|
1092
|
-
revision: this.runtime.info().revision
|
|
1103
|
+
rowCount,
|
|
1104
|
+
revision: this.runtime.info().revision,
|
|
1105
|
+
...undoToken ? { undoToken } : {}
|
|
1093
1106
|
};
|
|
1094
1107
|
}
|
|
1095
1108
|
};
|
|
@@ -1661,12 +1674,20 @@ var SQLiteWasmConnectionPort = class {
|
|
|
1661
1674
|
const effectiveMode = parent ?? mode;
|
|
1662
1675
|
const savepoint = "eidos_adapter_" + ++this.savepointSequence;
|
|
1663
1676
|
let started = false;
|
|
1677
|
+
const noCallbackFailure = Symbol("no-callback-failure");
|
|
1678
|
+
let callbackFailure = noCallbackFailure;
|
|
1664
1679
|
try {
|
|
1665
1680
|
this.database.exec(outer ? effectiveMode === "write" ? "BEGIN IMMEDIATE" : "BEGIN DEFERRED" : "SAVEPOINT " + savepoint);
|
|
1666
1681
|
started = true;
|
|
1667
1682
|
this.transactionModes.push(effectiveMode);
|
|
1668
1683
|
if (outer) this.mainReadEstablished = false;
|
|
1669
|
-
|
|
1684
|
+
let result;
|
|
1685
|
+
try {
|
|
1686
|
+
result = operation();
|
|
1687
|
+
} catch (error) {
|
|
1688
|
+
callbackFailure = error;
|
|
1689
|
+
throw error;
|
|
1690
|
+
}
|
|
1670
1691
|
if (result instanceof Promise) return result.then((value) => {
|
|
1671
1692
|
try {
|
|
1672
1693
|
this.database.exec(outer ? "COMMIT" : "RELEASE " + savepoint);
|
|
@@ -1682,7 +1703,7 @@ var SQLiteWasmConnectionPort = class {
|
|
|
1682
1703
|
}, (error) => {
|
|
1683
1704
|
try {
|
|
1684
1705
|
this.rollbackTransaction(outer, savepoint);
|
|
1685
|
-
throw
|
|
1706
|
+
throw error;
|
|
1686
1707
|
} finally {
|
|
1687
1708
|
this.transactionModes.pop();
|
|
1688
1709
|
if (outer) this.mainReadEstablished = false;
|
|
@@ -1696,7 +1717,7 @@ var SQLiteWasmConnectionPort = class {
|
|
|
1696
1717
|
} catch (error) {
|
|
1697
1718
|
try {
|
|
1698
1719
|
if (started) this.rollbackTransaction(outer, savepoint);
|
|
1699
|
-
throw this.mapError(error);
|
|
1720
|
+
throw callbackFailure === error && callbackFailure !== noCallbackFailure ? error : this.mapError(error);
|
|
1700
1721
|
} finally {
|
|
1701
1722
|
if (started) this.transactionModes.pop();
|
|
1702
1723
|
if (outer) this.mainReadEstablished = false;
|
|
@@ -1997,4 +2018,4 @@ function measureRow(row) {
|
|
|
1997
2018
|
//#endregion
|
|
1998
2019
|
export { eidosFileTypeHandler as a, AdapterTransportRuntimeClient as c, transportFitsHostLimit as d, validateAdapterCarrier as f, EidosFileSession as i, AdapterTransportServer as l, EidosFileHandlerRegistry as n, EidosFileRuntimeDataSource as o, validateAdapterEnvelope as p, EidosFileHostError as r, eidosFileSnapshot as s, SQLiteWasmConnectionPort as t, EIDOS_ADAPTER_TRANSPORT_LIMITS as u };
|
|
1999
2020
|
|
|
2000
|
-
//# sourceMappingURL=sqlite-wasm-
|
|
2021
|
+
//# sourceMappingURL=sqlite-wasm-fT8Z-5Ww.mjs.map
|