@eidos.space/eidos-file 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/FIELD-CONVERSION.md +40 -19
  2. package/dist/adapter-contract-vfw3_C3w.d.mts +281 -0
  3. package/dist/adapter-contract-vfw3_C3w.d.mts.map +1 -0
  4. package/dist/better-sqlite3.d.mts +2 -2
  5. package/dist/better-sqlite3.mjs +1 -1
  6. package/dist/browser.d.mts +4 -4
  7. package/dist/browser.mjs +2 -2
  8. package/dist/{csv-BVaUkU1o.mjs → csv-NK8Rti5O.mjs} +38 -7
  9. package/dist/csv-NK8Rti5O.mjs.map +1 -0
  10. package/dist/csv.d.mts +1 -1
  11. package/dist/csv.d.mts.map +1 -1
  12. package/dist/csv.mjs +1 -1
  13. package/dist/index.d.mts +54 -8
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +69 -499
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/node-sqlite.d.mts +3 -3
  18. package/dist/node-sqlite.d.mts.map +1 -1
  19. package/dist/node-sqlite.mjs +10 -4
  20. package/dist/node-sqlite.mjs.map +1 -1
  21. package/dist/runtime-CtP7-fVC.d.mts +1705 -0
  22. package/dist/runtime-CtP7-fVC.d.mts.map +1 -0
  23. package/dist/{runtime-BLZqiCnB.mjs → runtime-mvRkk__c.mjs} +1100 -53
  24. package/dist/runtime-mvRkk__c.mjs.map +1 -0
  25. package/dist/{sqlite-wasm-C_MX7-tl.mjs → sqlite-wasm-BhRD8n56.mjs} +12 -2
  26. package/dist/sqlite-wasm-BhRD8n56.mjs.map +1 -0
  27. package/dist/{system-metadata-merge-DeHwokcY.d.mts → system-metadata-merge-CKMMBV4p.d.mts} +2 -2
  28. package/dist/{system-metadata-merge-DeHwokcY.d.mts.map → system-metadata-merge-CKMMBV4p.d.mts.map} +1 -1
  29. package/dist/{system-metadata-merge-Cxv30SkG.mjs → system-metadata-merge-CickEFxi.mjs} +2 -2
  30. package/dist/{system-metadata-merge-Cxv30SkG.mjs.map → system-metadata-merge-CickEFxi.mjs.map} +1 -1
  31. package/dist/{temporal-CnuhXeP8.d.mts → temporal-DS4fCGpj.d.mts} +8 -3
  32. package/dist/temporal-DS4fCGpj.d.mts.map +1 -0
  33. package/package.json +3 -3
  34. package/dist/adapter-contract-CNigdeQ7.d.mts +0 -1137
  35. package/dist/adapter-contract-CNigdeQ7.d.mts.map +0 -1
  36. package/dist/csv-BVaUkU1o.mjs.map +0 -1
  37. package/dist/runtime-BLZqiCnB.mjs.map +0 -1
  38. package/dist/runtime-BSYpcOBe.d.mts +0 -801
  39. package/dist/runtime-BSYpcOBe.d.mts.map +0 -1
  40. package/dist/sqlite-wasm-C_MX7-tl.mjs.map +0 -1
  41. package/dist/temporal-CnuhXeP8.d.mts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { A as isEidosFileUuid, C as assertEidosFileDisplayName, E as assertEidosFileUuid, F as EidosFileError, M as canonicalizeEidosFileJson, N as isCanonicalEidosFileJson, O as createEidosFileUuid, P as parseEidosFileJson, T as assertEidosFileTableName, c as eidosFileInstantSqlCheck, d as normalizeEidosFileDate, f as normalizeEidosFileInstant, h as decodeEidosFileValues, i as parseEidosFileSelectDefaultOption, j as quoteIdentifier, k as isEidosFileReservedTableName, l as isCanonicalEidosFileDate, n as assertEidosFileSelectDefaultOption, o as currentEidosFileInstant, p as assertEidosFileValues, r as assertEidosFileSelectOptions, s as eidosFileDateSqlCheck, t as assertEidosFileMultiSelectHasNoDefaultOption, u as isCanonicalEidosFileInstant } from "./select-options-DSzDn3qm.mjs";
2
2
  //#region src/connection-port.ts
3
- const INT64_MIN$2 = -9223372036854775808n;
4
- const INT64_MAX$2 = 9223372036854775807n;
3
+ const INT64_MIN$3 = -9223372036854775808n;
4
+ const INT64_MAX$3 = 9223372036854775807n;
5
5
  /** Validates the exact `?1` through `?N` EA-Connection binding grammar. */
6
6
  function exactConnectionBindingCount(sql) {
7
7
  const occurrences = /* @__PURE__ */ new Map();
@@ -119,7 +119,7 @@ var EidosAdapterError = class extends Error {
119
119
  function assertInt64Decimal(value) {
120
120
  if (!/^(?:0|-[1-9][0-9]*|[1-9][0-9]*)$/.test(value) || value === "-0") throw new EidosAdapterError("invalid-sql-value", "INTEGER must use canonical signed int64 decimal text");
121
121
  const parsed = BigInt(value);
122
- if (parsed < INT64_MIN$2 || parsed > INT64_MAX$2) throw new EidosAdapterError("invalid-sql-value", "INTEGER is outside signed int64 range");
122
+ if (parsed < INT64_MIN$3 || parsed > INT64_MAX$3) throw new EidosAdapterError("invalid-sql-value", "INTEGER is outside signed int64 range");
123
123
  return parsed;
124
124
  }
125
125
  function assertUnicodeString(value, label = "TEXT") {
@@ -140,7 +140,7 @@ function sqlValueToNative(value) {
140
140
  function nativeToSqlValue(value) {
141
141
  if (value === null) return { tag: "null" };
142
142
  if (typeof value === "bigint") {
143
- if (value < INT64_MIN$2 || value > INT64_MAX$2) throw new EidosAdapterError("invalid-sql-value", "SQLite returned an INTEGER outside signed int64 range", false, true);
143
+ if (value < INT64_MIN$3 || value > INT64_MAX$3) throw new EidosAdapterError("invalid-sql-value", "SQLite returned an INTEGER outside signed int64 range", false, true);
144
144
  return {
145
145
  tag: "integer",
146
146
  value: String(value)
@@ -251,7 +251,7 @@ function nativeParameterToSqlValue(value) {
251
251
  };
252
252
  if (typeof value === "number") {
253
253
  if (!Number.isFinite(value)) throw new EidosAdapterError("invalid-sql-value", "SQL number must be finite");
254
- return Number.isInteger(value) ? {
254
+ return Number.isSafeInteger(value) ? {
255
255
  tag: "integer",
256
256
  value: String(value)
257
257
  } : {
@@ -281,6 +281,438 @@ function sqlValueToLegacy(value) {
281
281
  }
282
282
  }
283
283
  //#endregion
284
+ //#region src/canonical-conversion.ts
285
+ /**
286
+ * Product defaults for conversions requested by the Eidos File editor.
287
+ *
288
+ * These policies are intentionally explicit: the Runtime still reports an
289
+ * `explicit-lossy` preflight and requires confirmation whenever the values in
290
+ * the current Field would actually lose information.
291
+ */
292
+ function recommendedEidosFileConversionPolicies(from, to) {
293
+ const policies = [];
294
+ if (from === "integer" && to === "number") policies.push("round-binary64");
295
+ if (from === "number" && to === "integer") policies.push("round-ties-even");
296
+ if ((from === "integer" || from === "number") && to === "checkbox") policies.push("zero-false-nonzero-true");
297
+ if (from === "datetime" && to === "date") policies.push("utc-date");
298
+ if (from === "multi-select" && to === "select") policies.push("first");
299
+ if (!LIST_TYPES.has(from) && LIST_TYPES.has(to)) policies.push("null-to-empty-list");
300
+ return policies;
301
+ }
302
+ /** Returns the nullable shape used by editor-initiated conversions. */
303
+ function eidosFileConversionTargetNullable(from, to, sourceNullable) {
304
+ if (LIST_TYPES.has(to)) return false;
305
+ if (LIST_TYPES.has(from)) return true;
306
+ return sourceNullable;
307
+ }
308
+ /**
309
+ * Splits a Text value into Multi-select option names using the Runtime rule.
310
+ *
311
+ * A JSON array of strings is read as its ordered choice names; any other text
312
+ * (including malformed JSON, non-string arrays, or commas) is one choice. The
313
+ * Editor reuses this so inferred Field options match converted cell values.
314
+ */
315
+ function eidosFileTextMultiSelectChoices(text) {
316
+ try {
317
+ const parsed = JSON.parse(text);
318
+ if (Array.isArray(parsed) && parsed.every((item) => typeof item === "string")) return parsed;
319
+ } catch {}
320
+ return [text];
321
+ }
322
+ const INT64_MIN$2 = -9223372036854775808n;
323
+ const INT64_MAX$2 = 9223372036854775807n;
324
+ const INT64 = /^(?:0|-[1-9][0-9]*|[1-9][0-9]*)$/u;
325
+ const LIST_TYPES = new Set([
326
+ "multi-select",
327
+ "file",
328
+ "relation"
329
+ ]);
330
+ const TEXT_TYPES = new Set([
331
+ "text",
332
+ "date",
333
+ "datetime",
334
+ "url",
335
+ "select"
336
+ ]);
337
+ const SHARED_TEXT_COLUMN_TYPES = new Set([
338
+ "text",
339
+ "select",
340
+ "url"
341
+ ]);
342
+ /** True when a conversion can retain the exact nullable SQLite column DDL. */
343
+ function eidosFileConversionCanReusePhysicalColumn(from, to, sourceNullable, targetNullable) {
344
+ return sourceNullable === targetNullable && SHARED_TEXT_COLUMN_TYPES.has(from) && SHARED_TEXT_COLUMN_TYPES.has(to);
345
+ }
346
+ function planCanonicalFieldConversion(input) {
347
+ const policies = new Set(input.policies ?? []);
348
+ const sourceHasEmptyList = input.rows.some((row) => {
349
+ if (row.value === null || typeof row.value !== "string") return false;
350
+ return row.value === "[]";
351
+ });
352
+ const changes = /* @__PURE__ */ new Map();
353
+ const rows = [];
354
+ let severity = 0;
355
+ let error;
356
+ for (const row of input.rows) try {
357
+ let converted;
358
+ if (row.value === null) converted = convertNull(input, policies, sourceHasEmptyList);
359
+ else converted = convertNonNull(input, row.value, policies);
360
+ if (converted.value === null && !input.toNullable && !LIST_TYPES.has(input.to)) throw new Error("Destination non-nullability rejects SQL NULL");
361
+ validateDestination(input, converted.value);
362
+ const changed = storageClass(input.from) !== storageClass(input.to) || !sameStorageValue(row.value, converted.value);
363
+ rows.push({
364
+ id: row.id,
365
+ value: converted.value,
366
+ changed
367
+ });
368
+ if (changed) {
369
+ severity = Math.max(severity, converted.class);
370
+ changes.set("value-reencoded", (changes.get("value-reencoded") ?? 0) + 1);
371
+ if (converted.code) changes.set(converted.code, (changes.get(converted.code) ?? 0) + 1);
372
+ }
373
+ } catch (cause) {
374
+ severity = 3;
375
+ error = cause instanceof Error ? cause.message : "Conversion is forbidden";
376
+ break;
377
+ }
378
+ if (severity === 3) return {
379
+ classification: "forbidden",
380
+ rows: [],
381
+ affectedRows: "0",
382
+ valueChanges: [],
383
+ error
384
+ };
385
+ const affectedRows = rows.filter((row) => row.changed).length;
386
+ return {
387
+ classification: severity === 2 ? "explicit-lossy" : severity === 1 ? "lossless-rewrite" : "metadata-only",
388
+ rows,
389
+ affectedRows: String(affectedRows),
390
+ valueChanges: Array.from(changes, ([code, count]) => ({
391
+ code,
392
+ rows: String(count)
393
+ }))
394
+ };
395
+ }
396
+ function convertNull(input, policies, sourceHasEmptyList) {
397
+ if (LIST_TYPES.has(input.to)) {
398
+ if (!policies.has("null-to-empty-list")) throw new Error("SQL NULL requires null-to-empty-list for a list destination");
399
+ return {
400
+ value: "[]",
401
+ class: sourceHasEmptyList ? 2 : 1,
402
+ code: "null-to-empty-list"
403
+ };
404
+ }
405
+ if (!input.toNullable) throw new Error("Destination non-nullability rejects SQL NULL");
406
+ return {
407
+ value: null,
408
+ class: 0
409
+ };
410
+ }
411
+ function convertNonNull(input, value, policies) {
412
+ const { from, to } = input;
413
+ if (from === to) return {
414
+ value,
415
+ class: 0
416
+ };
417
+ if (TEXT_TYPES.has(from) && TEXT_TYPES.has(to)) {
418
+ if (to === "datetime" && from === "date") return {
419
+ value: `${asText(value)}T00:00:00.000Z`,
420
+ class: 1
421
+ };
422
+ if (to === "date" && from === "datetime") {
423
+ const text = asText(value);
424
+ if (text.endsWith("T00:00:00.000Z")) return {
425
+ value: text.slice(0, 10),
426
+ class: 1
427
+ };
428
+ if (!policies.has("utc-date")) throw new Error("Datetime with a time component requires utc-date");
429
+ return {
430
+ value: text.slice(0, 10),
431
+ class: 2,
432
+ code: "datetime-to-date"
433
+ };
434
+ }
435
+ return {
436
+ value: asText(value),
437
+ class: 0
438
+ };
439
+ }
440
+ if (to === "text") {
441
+ if (from === "number") return {
442
+ value: canonicalNumber(asNumber$1(value)),
443
+ class: 1
444
+ };
445
+ if (from === "integer") return {
446
+ value: String(asInteger$1(value)),
447
+ class: 1
448
+ };
449
+ if (from === "checkbox") return {
450
+ value: asCheckbox(value) ? "true" : "false",
451
+ class: 1
452
+ };
453
+ if (LIST_TYPES.has(from)) return {
454
+ value: asText(value),
455
+ class: 0
456
+ };
457
+ }
458
+ if (to === "select") {
459
+ if (from === "number") return {
460
+ value: canonicalNumber(asNumber$1(value)),
461
+ class: 1
462
+ };
463
+ if (from === "integer") return {
464
+ value: String(asInteger$1(value)),
465
+ class: 1
466
+ };
467
+ if (from === "checkbox") return {
468
+ value: asCheckbox(value) ? "true" : "false",
469
+ class: 1
470
+ };
471
+ if (from === "multi-select") {
472
+ const list = parseStringList(value);
473
+ if (list.length === 1) return {
474
+ value: list[0],
475
+ class: 1
476
+ };
477
+ if (!policies.has("first")) throw new Error("Multi-select to Select requires a singleton or first");
478
+ if (list.length === 0) {
479
+ if (!input.toNullable) throw new Error("Empty list requires nullable Select");
480
+ return {
481
+ value: null,
482
+ class: 1,
483
+ code: "list-empty-to-null"
484
+ };
485
+ }
486
+ return {
487
+ value: list[0],
488
+ class: 2,
489
+ code: "list-tail-dropped"
490
+ };
491
+ }
492
+ }
493
+ if (to === "number") {
494
+ if (from === "integer") {
495
+ const integer = asInteger$1(value);
496
+ const number = Number(integer);
497
+ if (Number.isInteger(number) && BigInt(number) === integer) return {
498
+ value: number,
499
+ class: 1
500
+ };
501
+ if (!policies.has("round-binary64") || !Number.isFinite(number)) throw new Error("Integer is not exactly representable as binary64");
502
+ return {
503
+ value: number,
504
+ class: 2,
505
+ code: "binary64-rounded"
506
+ };
507
+ }
508
+ if (from === "checkbox") return {
509
+ value: asCheckbox(value) ? 1 : 0,
510
+ class: 1
511
+ };
512
+ if (from === "text" || from === "select") {
513
+ const text = asText(value);
514
+ const number = Number(text);
515
+ if (!Number.isFinite(number) || canonicalNumber(number) !== text) throw new Error("Text is not the exact inverse binary64 spelling");
516
+ return {
517
+ value: number,
518
+ class: 1
519
+ };
520
+ }
521
+ }
522
+ if (to === "integer") {
523
+ if (from === "checkbox") return {
524
+ value: asCheckbox(value) ? 1n : 0n,
525
+ class: 0
526
+ };
527
+ if (from === "text" || from === "select") return {
528
+ value: parseInt64(asText(value)),
529
+ class: 1
530
+ };
531
+ if (from === "number") return numberToInteger(asNumber$1(value), policies);
532
+ }
533
+ if (to === "checkbox") {
534
+ if (from === "text" || from === "select") {
535
+ const text = asText(value);
536
+ if (text === "true") return {
537
+ value: 1n,
538
+ class: 1
539
+ };
540
+ if (text === "false") return {
541
+ value: 0n,
542
+ class: 1
543
+ };
544
+ throw new Error("Text is not lowercase true or false");
545
+ }
546
+ if (from === "integer") {
547
+ const integer = asInteger$1(value);
548
+ if (integer === 0n || integer === 1n) return {
549
+ value: integer,
550
+ class: 0
551
+ };
552
+ if (!policies.has("zero-false-nonzero-true")) throw new Error("Integer Checkbox conversion requires exact 0/1");
553
+ return {
554
+ value: integer === 0n ? 0n : 1n,
555
+ class: 2,
556
+ code: "numeric-to-checkbox"
557
+ };
558
+ }
559
+ if (from === "number") {
560
+ const number = asNumber$1(value);
561
+ if (number === 0 || number === 1) return {
562
+ value: BigInt(number),
563
+ class: 1
564
+ };
565
+ if (!policies.has("zero-false-nonzero-true")) throw new Error("Number Checkbox conversion requires exact 0.0/1.0");
566
+ return {
567
+ value: number === 0 ? 0n : 1n,
568
+ class: 2,
569
+ code: "numeric-to-checkbox"
570
+ };
571
+ }
572
+ }
573
+ if (LIST_TYPES.has(to)) {
574
+ if (from === "select" && to === "multi-select") return {
575
+ value: canonicalizeEidosFileJson([asText(value)]),
576
+ class: 1
577
+ };
578
+ if (from === "text" && to === "multi-select") {
579
+ const text = asText(value);
580
+ const encoded = canonicalizeEidosFileJson(eidosFileTextMultiSelectChoices(text));
581
+ return {
582
+ value: encoded,
583
+ class: encoded === text ? 0 : 1
584
+ };
585
+ }
586
+ if (from === "multi-select" && to === "relation" || from === "relation" && to === "multi-select" || from === to) return {
587
+ value: asText(value),
588
+ class: 0
589
+ };
590
+ }
591
+ throw new Error(`Conversion from ${from} to ${to} is forbidden`);
592
+ }
593
+ function numberToInteger(number, policies) {
594
+ let result = number;
595
+ let code;
596
+ let classification = 1;
597
+ if (!Number.isInteger(result)) {
598
+ if (policies.has("truncate-toward-zero")) {
599
+ result = Math.trunc(result);
600
+ code = "fraction-truncated";
601
+ } else if (policies.has("round-ties-even")) {
602
+ result = roundTiesEven(result);
603
+ code = "integer-rounded";
604
+ } else throw new Error("Fractional Number requires an Integer rounding policy");
605
+ classification = 2;
606
+ }
607
+ if (!Number.isInteger(result)) throw new Error("Integer result is not integral");
608
+ const integer = BigInt(result);
609
+ if (integer < INT64_MIN$2 || integer > INT64_MAX$2) throw new Error("Integer result is outside signed int64");
610
+ return {
611
+ value: integer,
612
+ class: classification,
613
+ ...code ? { code } : {}
614
+ };
615
+ }
616
+ function validateDestination(input, value) {
617
+ if (value === null) return;
618
+ switch (input.to) {
619
+ case "number":
620
+ asNumber$1(value);
621
+ return;
622
+ case "integer":
623
+ asInteger$1(value);
624
+ return;
625
+ case "checkbox":
626
+ asCheckbox(value);
627
+ return;
628
+ case "date":
629
+ if (!isCanonicalEidosFileDate(value)) throw new Error("Invalid Date value");
630
+ return;
631
+ case "datetime":
632
+ if (!isCanonicalEidosFileInstant(value)) throw new Error("Invalid Datetime value");
633
+ return;
634
+ case "url":
635
+ if (!isEidosFileUriReference(asText(value))) throw new Error("Invalid URI-reference");
636
+ return;
637
+ case "multi-select":
638
+ parseStringList(value);
639
+ return;
640
+ case "file":
641
+ decodeEidosFileValues(asText(value));
642
+ return;
643
+ case "relation": {
644
+ const ids = parseStringList(value);
645
+ if (!ids.every(isEidosFileUuid)) throw new Error("Invalid Relation Row ID");
646
+ if (input.relationCardinality === "one" && ids.length > 1) throw new Error("One-cardinality Relation contains more than one Row ID");
647
+ if (input.relationIdValid && !ids.every(input.relationIdValid)) throw new Error("Relation Row ID does not resolve in the target Table");
648
+ return;
649
+ }
650
+ case "text":
651
+ case "select":
652
+ asText(value);
653
+ return;
654
+ }
655
+ }
656
+ function parseStringList(value) {
657
+ const text = asText(value);
658
+ if (!isCanonicalEidosFileJson(text)) throw new Error("List is not canonical JSON");
659
+ const parsed = parseEidosFileJson(text);
660
+ if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) throw new Error("List must contain only strings");
661
+ if (new Set(parsed).size !== parsed.length) throw new Error("List values must be unique");
662
+ return parsed;
663
+ }
664
+ function asText(value) {
665
+ if (typeof value !== "string") throw new Error("Expected TEXT storage");
666
+ return value;
667
+ }
668
+ function asNumber$1(value) {
669
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error("Expected finite REAL storage");
670
+ return Object.is(value, -0) ? 0 : value;
671
+ }
672
+ function asInteger$1(value) {
673
+ if (typeof value === "bigint") {
674
+ if (value < INT64_MIN$2 || value > INT64_MAX$2) throw new Error("INTEGER outside int64");
675
+ return value;
676
+ }
677
+ if (typeof value !== "number" || !Number.isSafeInteger(value)) throw new Error("Expected exact INTEGER storage");
678
+ return BigInt(value);
679
+ }
680
+ function asCheckbox(value) {
681
+ const integer = asInteger$1(value);
682
+ if (integer !== 0n && integer !== 1n) throw new Error("Checkbox must be 0 or 1");
683
+ return integer === 1n;
684
+ }
685
+ function parseInt64(value) {
686
+ if (!INT64.test(value) || value === "-0") throw new Error("Invalid int64 spelling");
687
+ const integer = BigInt(value);
688
+ if (integer < INT64_MIN$2 || integer > INT64_MAX$2) throw new Error("INTEGER outside int64");
689
+ return integer;
690
+ }
691
+ function canonicalNumber(value) {
692
+ return canonicalizeEidosFileJson(value);
693
+ }
694
+ function roundTiesEven(value) {
695
+ const floor = Math.floor(value);
696
+ const fraction = value - floor;
697
+ if (fraction < .5) return floor;
698
+ if (fraction > .5) return floor + 1;
699
+ return floor % 2 === 0 ? floor : floor + 1;
700
+ }
701
+ /** RFC 3986 URI-reference lexical validation shared by writes and conversions. */
702
+ function isEidosFileUriReference(value) {
703
+ return typeof value === "string" && /^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@/?#\[\]]|%[0-9A-Fa-f]{2})*$/u.test(value);
704
+ }
705
+ function sameStorageValue(left, right) {
706
+ if (left instanceof Uint8Array || right instanceof Uint8Array) return left instanceof Uint8Array && right instanceof Uint8Array && left.byteLength === right.byteLength && left.every((byte, index) => byte === right[index]);
707
+ if ((typeof left === "bigint" || typeof left === "number" && Number.isSafeInteger(left)) && (typeof right === "bigint" || typeof right === "number" && Number.isSafeInteger(right))) return BigInt(left) === BigInt(right);
708
+ return typeof left === typeof right && Object.is(left, right);
709
+ }
710
+ function storageClass(type) {
711
+ if (type === "integer" || type === "checkbox") return "integer";
712
+ if (type === "number") return "real";
713
+ return "text";
714
+ }
715
+ //#endregion
284
716
  //#region src/column-stats.ts
285
717
  const COMMON_STATS = [
286
718
  "count-all",
@@ -333,7 +765,7 @@ function displayType(field) {
333
765
  }
334
766
  function eidosFileColumnStatTypesForField(field) {
335
767
  const type = displayType(field);
336
- if (type === "number" || type === "rating") return NUMERIC_STATS;
768
+ if (type === "number" || type === "integer" || type === "rating") return NUMERIC_STATS;
337
769
  if (type === "date" || type === "datetime" || type === "created-time" || type === "last-edited-time") return DATE_STATS;
338
770
  if (type === "checkbox") return CHECKBOX_STATS;
339
771
  if (type === "relation") return RELATION_STATS;
@@ -399,6 +831,170 @@ const EIDOS_FILE_SYSTEM_COLUMNS = [
399
831
  "_updated_at"
400
832
  ];
401
833
  //#endregion
834
+ //#region src/field-query-capabilities.ts
835
+ const EMPTY_OPERATORS = ["is-empty", "is-not-empty"];
836
+ const EQUALITY_OPERATORS = ["equals", "not-equals"];
837
+ const STRING_OPERATORS = [
838
+ ...EQUALITY_OPERATORS,
839
+ "contains",
840
+ "not-contains",
841
+ "starts-with",
842
+ "ends-with",
843
+ ...EMPTY_OPERATORS
844
+ ];
845
+ const ORDERED_OPERATORS = [
846
+ ...EQUALITY_OPERATORS,
847
+ "greater-than",
848
+ "greater-than-or-equal",
849
+ "less-than",
850
+ "less-than-or-equal",
851
+ ...EMPTY_OPERATORS
852
+ ];
853
+ const TEMPORAL_OPERATORS = [
854
+ ...ORDERED_OPERATORS,
855
+ "is-between",
856
+ "is-relative-to-today"
857
+ ];
858
+ const LIST_OPERATORS = [
859
+ "contains",
860
+ "not-contains",
861
+ "is-any-of",
862
+ "is-all-of",
863
+ "is-none-of",
864
+ ...EMPTY_OPERATORS
865
+ ];
866
+ const CHECKBOX_OPERATORS = [...EQUALITY_OPERATORS, ...EMPTY_OPERATORS];
867
+ const FILE_OPERATORS = [...EMPTY_OPERATORS];
868
+ const TYPE_REF_ATOMS = new Set([
869
+ "text",
870
+ "number",
871
+ "integer",
872
+ "checkbox",
873
+ "date",
874
+ "datetime",
875
+ "url",
876
+ "select",
877
+ "multi-select",
878
+ "file",
879
+ "relation",
880
+ "row-id",
881
+ "file-entry"
882
+ ]);
883
+ const LIST_ATOMS = new Set([
884
+ "text",
885
+ "number",
886
+ "integer",
887
+ "checkbox",
888
+ "date",
889
+ "datetime",
890
+ "url",
891
+ "select",
892
+ "row-id",
893
+ "file-entry"
894
+ ]);
895
+ function configuredTypeRef(value) {
896
+ if (typeof value === "string" && TYPE_REF_ATOMS.has(value)) return value;
897
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && value.kind === "list" && typeof value.element === "string" && LIST_ATOMS.has(value.element)) return {
898
+ kind: "list",
899
+ element: value.element
900
+ };
901
+ return null;
902
+ }
903
+ /** Resolve the public logical TypeRef represented by an editor/runtime Field. */
904
+ function eidosFileFieldValueType(field) {
905
+ if (field.systemRole === "row-id" || field.type === "row-id") return "row-id";
906
+ if (field.systemRole === "created-time" || field.systemRole === "updated-time" || field.type === "created-time" || field.type === "last-edited-time") return "datetime";
907
+ if (field.type === "rating") return "integer";
908
+ if (field.type === "formula" || field.type === "lookup") {
909
+ const generated = configuredTypeRef(field.property?.valueType);
910
+ if (generated) return generated;
911
+ const legacyFileEntry = field.type === "lookup" && field.property?.displayType === "json";
912
+ const display = configuredTypeRef(field.property?.displayType) ?? "text";
913
+ if (field.type === "lookup" && field.property?.aggregate === "values") return {
914
+ kind: "list",
915
+ element: display === "file" || legacyFileEntry ? "file-entry" : display === "relation" ? "row-id" : display === "multi-select" ? "select" : typeof display === "object" ? display.element : display
916
+ };
917
+ if (legacyFileEntry) return "file-entry";
918
+ return display;
919
+ }
920
+ if (field.type === "relation") return "relation";
921
+ if (field.type === "multi-select") return "multi-select";
922
+ if (field.type === "file") return "file";
923
+ return configuredTypeRef(field.type) ?? "text";
924
+ }
925
+ /**
926
+ * Canonical query capability policy for Runtime validation and UI affordances.
927
+ * It intentionally describes implemented behavior, not SQLite storage classes.
928
+ */
929
+ function eidosFileTypeRefQueryCapabilities(type, context = {}) {
930
+ const listElement = typeof type === "object" ? type.element : type === "multi-select" ? "select" : type === "relation" ? "row-id" : type === "file" ? "file-entry" : null;
931
+ const list = listElement !== null;
932
+ const fileValue = type === "file-entry" || listElement === "file-entry";
933
+ const ordered = typeof type === "string" && [
934
+ "text",
935
+ "number",
936
+ "integer",
937
+ "checkbox",
938
+ "date",
939
+ "datetime",
940
+ "url",
941
+ "select",
942
+ "row-id"
943
+ ].includes(type);
944
+ const stringMatch = typeof type === "string" && [
945
+ "text",
946
+ "url",
947
+ "select",
948
+ "row-id"
949
+ ].includes(type);
950
+ const searchableList = listElement !== null && [
951
+ "text",
952
+ "url",
953
+ "select",
954
+ "file-entry"
955
+ ].includes(listElement);
956
+ const recordLabelSearchable = context.isRecordLabel === true && typeof type === "string" && [
957
+ "text",
958
+ "url",
959
+ "select",
960
+ "number",
961
+ "integer",
962
+ "checkbox",
963
+ "date",
964
+ "datetime",
965
+ "row-id"
966
+ ].includes(type);
967
+ const contextualRowId = context.contextualRowId === true && typeof type === "object" && type.element === "row-id";
968
+ const searchable = stringMatch || searchableList || type === "file-entry" || type === "relation" || recordLabelSearchable || contextualRowId;
969
+ const sortPosition = !ordered ? null : type === "row-id" ? "last" : "any";
970
+ let filterOperators;
971
+ if (fileValue) filterOperators = FILE_OPERATORS;
972
+ else if (list) filterOperators = LIST_OPERATORS;
973
+ else if (type === "checkbox") filterOperators = CHECKBOX_OPERATORS;
974
+ else if (type === "date" || type === "datetime") filterOperators = TEMPORAL_OPERATORS;
975
+ else if (type === "number" || type === "integer") filterOperators = ORDERED_OPERATORS;
976
+ else if (stringMatch) filterOperators = STRING_OPERATORS;
977
+ else filterOperators = EMPTY_OPERATORS;
978
+ return {
979
+ filterOperators,
980
+ ordered,
981
+ membership: list,
982
+ stringMatch,
983
+ searchable,
984
+ sortable: sortPosition !== null,
985
+ sortPosition,
986
+ groupable: ordered
987
+ };
988
+ }
989
+ function eidosFileFieldQueryCapabilities(field) {
990
+ const type = eidosFileFieldValueType(field);
991
+ const contextualRowIdLookup = field.type === "lookup" && typeof type === "object" && type.element === "row-id" && typeof field.property?.relationField === "string";
992
+ return eidosFileTypeRefQueryCapabilities(type, {
993
+ isRecordLabel: field.isRecordLabel,
994
+ contextualRowId: contextualRowIdLookup
995
+ });
996
+ }
997
+ //#endregion
402
998
  //#region src/formula.ts
403
999
  /** Eidos File 1.0 has no prop()/props() reference syntax. */
404
1000
  const EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES = [];
@@ -918,8 +1514,7 @@ function formulaOperandType(field) {
918
1514
  "checkbox",
919
1515
  "date",
920
1516
  "datetime",
921
- "url",
922
- "json"
1517
+ "url"
923
1518
  ].includes(String(type))) throw new EidosFileError("invalid-schema", `Field “${field.name}” is not a Formula scalar operand`);
924
1519
  return type;
925
1520
  }
@@ -1028,7 +1623,7 @@ function exactFormulaType(node, fields, numbers, expected) {
1028
1623
  ">="
1029
1624
  ].includes(op)) {
1030
1625
  const pair = inferFormulaPair(node.left, node.right, fields, numbers);
1031
- if (!pair.left || !pair.right || !formulaTypesComparable(pair.left, pair.right, op === "==" ? "=" : op === "<>" ? "!=" : op)) throw new EidosFileError("invalid-schema", `${op} operands have incompatible types`);
1626
+ if (!pair.left || !pair.right || !formulaTypesComparable(pair.left, pair.right)) throw new EidosFileError("invalid-schema", `${op} operands have incompatible types`);
1032
1627
  return setFormulaType(node, "checkbox");
1033
1628
  }
1034
1629
  throw new EidosFileError("invalid-schema", `Unsupported Formula operator: ${op}`);
@@ -1054,7 +1649,7 @@ function exactFormulaType(node, fields, numbers, expected) {
1054
1649
  if (name === "nullif") {
1055
1650
  arity(2);
1056
1651
  const pair = inferFormulaPair(args[0], args[1], fields, numbers, expected);
1057
- if (!pair.left || !pair.right || !formulaTypesComparable(pair.left, pair.right, "=")) throw new EidosFileError("invalid-schema", "NULLIF arguments have incompatible types");
1652
+ if (!pair.left || !pair.right || !formulaTypesComparable(pair.left, pair.right)) throw new EidosFileError("invalid-schema", "NULLIF arguments have incompatible types");
1058
1653
  return setFormulaType(node, pair.left);
1059
1654
  }
1060
1655
  if ([
@@ -1081,9 +1676,7 @@ function exactFormulaType(node, fields, numbers, expected) {
1081
1676
  }
1082
1677
  if (name === "min" || name === "max") {
1083
1678
  arity(2, 16);
1084
- const type = inferFormulaSequence(args, fields, numbers, expected);
1085
- if (type === "json") throw new EidosFileError("invalid-formula", `${name} requires sortable arguments`);
1086
- return setFormulaType(node, type);
1679
+ return setFormulaType(node, inferFormulaSequence(args, fields, numbers, expected));
1087
1680
  }
1088
1681
  if (name === "concat") {
1089
1682
  arity(1, 16);
@@ -1282,10 +1875,10 @@ function requireFormulaType(actual, expected, operation) {
1282
1875
  function isNumericFormulaType(type) {
1283
1876
  return type === "integer" || type === "number";
1284
1877
  }
1285
- function formulaTypesComparable(left, right, operator) {
1878
+ function formulaTypesComparable(left, right) {
1286
1879
  if (isNumericFormulaType(left) && isNumericFormulaType(right)) return true;
1287
1880
  if (left !== right) return false;
1288
- return operator === "=" || operator === "!=" || left !== "json";
1881
+ return true;
1289
1882
  }
1290
1883
  function compileExactFormulaNode(node, fields, resolve) {
1291
1884
  const compile = (child) => compileExactFormulaNode(child, fields, resolve);
@@ -1537,7 +2130,11 @@ function eidosFileLookupTargetValueType(target) {
1537
2130
  const type = typeof target === "string" ? target : target.type;
1538
2131
  const generated = typeof target === "string" ? void 0 : target.property?.valueType;
1539
2132
  const generatedObject = generated && typeof generated === "object" ? generated : void 0;
1540
- if (typeof generated === "string" || generatedObject?.kind === "list" && typeof generatedObject.element === "string") return generated;
2133
+ if (typeof generated === "string") {
2134
+ if (generated === "json") return type === "lookup" ? "file-entry" : "text";
2135
+ return generated;
2136
+ }
2137
+ if (generatedObject?.kind === "list" && typeof generatedObject.element === "string") return generated;
1541
2138
  if (type === "row-id") return "row-id";
1542
2139
  if (type === "created-time" || type === "last-edited-time") return "datetime";
1543
2140
  if (type === "multi-select") return "multi-select";
@@ -1545,7 +2142,10 @@ function eidosFileLookupTargetValueType(target) {
1545
2142
  if (type === "relation") return "relation";
1546
2143
  if (type === "select") return "select";
1547
2144
  if (type === "rating") return "number";
1548
- if (type === "formula" || type === "lookup") return eidosFileLookupTargetDisplayType(target);
2145
+ if (type === "formula" || type === "lookup") {
2146
+ if (type === "lookup" && typeof target !== "string" && target.property?.displayType === "json") return "file-entry";
2147
+ return eidosFileLookupTargetDisplayType(target);
2148
+ }
1549
2149
  return type;
1550
2150
  }
1551
2151
  function eidosFileLookupElementType(target) {
@@ -1570,21 +2170,21 @@ function eidosFileLookupValueType(aggregate, target) {
1570
2170
  function eidosFileLookupTargetDisplayType(target) {
1571
2171
  const type = typeof target === "string" ? target : target.type;
1572
2172
  const configuredDisplayType = typeof target === "string" ? void 0 : target.property?.displayType;
1573
- if ((type === "formula" || type === "lookup") && (configuredDisplayType === "text" || configuredDisplayType === "number" || configuredDisplayType === "integer" || configuredDisplayType === "checkbox" || configuredDisplayType === "date" || configuredDisplayType === "datetime" || configuredDisplayType === "url" || configuredDisplayType === "json")) return configuredDisplayType;
2173
+ if ((type === "formula" || type === "lookup") && (configuredDisplayType === "text" || configuredDisplayType === "number" || configuredDisplayType === "integer" || configuredDisplayType === "checkbox" || configuredDisplayType === "date" || configuredDisplayType === "datetime" || configuredDisplayType === "url")) return configuredDisplayType;
1574
2174
  if (type === "number" || type === "rating") return "number";
1575
2175
  if (type === "integer") return "integer";
1576
2176
  if (type === "checkbox") return "checkbox";
1577
2177
  if (type === "date") return "date";
1578
2178
  if (type === "datetime") return "datetime";
1579
2179
  if (type === "url") return "url";
1580
- if (type === "file") return "json";
2180
+ if (type === "file") return "text";
1581
2181
  return "text";
1582
2182
  }
1583
2183
  function eidosFileLookupDisplayType(aggregate, target) {
1584
2184
  const valueType = eidosFileLookupValueType(aggregate, target);
1585
2185
  const atom = typeof valueType === "object" ? valueType.element : valueType;
1586
2186
  if (atom === "row-id" || atom === "select") return "text";
1587
- if (atom === "file-entry") return "json";
2187
+ if (atom === "file-entry") return "text";
1588
2188
  return atom;
1589
2189
  }
1590
2190
  function eidosFileFieldStoresJsonArray(field) {
@@ -1751,9 +2351,60 @@ function caseInsensitiveLike(expression, pattern, searchText, params) {
1751
2351
  LIKE eidos_casefold(?) ESCAPE '\\'` : `COALESCE(CAST(${expression} AS TEXT), '')
1752
2352
  LIKE ? COLLATE NOCASE ESCAPE '\\'`;
1753
2353
  }
2354
+ function searchExpression(field, pattern, searchText, params) {
2355
+ const column = quoteIdentifier(field.tableColumnName);
2356
+ const type = eidosFileFieldValueType(field);
2357
+ if (field.isRecordLabel && typeof type === "string") return caseInsensitiveLike(type === "checkbox" ? `CASE ${column} WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE NULL END` : type === "number" ? `eidos_canonical_number(${column})` : column, pattern, searchText, params);
2358
+ const contextualRowIdLookup = field.type === "lookup" && typeof type === "object" && type.element === "row-id" && typeof field.property?.relationField === "string";
2359
+ if (type === "relation" || contextualRowIdLookup) {
2360
+ const fragments = quoteIdentifier(`${field.tableColumnName}__search`);
2361
+ return `EXISTS (
2362
+ SELECT 1
2363
+ FROM json_each(
2364
+ CASE
2365
+ WHEN json_valid(${fragments}) AND json_type(${fragments}) = 'array'
2366
+ THEN ${fragments}
2367
+ ELSE '[]'
2368
+ END
2369
+ ) item
2370
+ WHERE ${caseInsensitiveLike("item.value", pattern, searchText, params)}
2371
+ )`;
2372
+ }
2373
+ const listElement = typeof type === "object" ? type.element : type === "multi-select" ? "select" : type === "file" ? "file-entry" : null;
2374
+ const fileEntryPredicate = (entry) => {
2375
+ const name = `json_extract(${entry}, '$.name')`;
2376
+ const mediaType = `json_extract(${entry}, '$.mediaType')`;
2377
+ const uri = `json_extract(${entry}, '$.uri')`;
2378
+ return `(
2379
+ ${caseInsensitiveLike(name, pattern, searchText, params)}
2380
+ OR ${caseInsensitiveLike(mediaType, pattern, searchText, params)}
2381
+ OR (
2382
+ lower(COALESCE(CAST(${uri} AS TEXT), '')) NOT LIKE 'data:%'
2383
+ AND ${caseInsensitiveLike(uri, pattern, searchText, params)}
2384
+ )
2385
+ )`;
2386
+ };
2387
+ if (type === "file-entry") return fileEntryPredicate(`CASE WHEN json_valid(${column}) THEN ${column} ELSE '{}' END`);
2388
+ if (listElement === null) return caseInsensitiveLike(column, pattern, searchText, params);
2389
+ return `EXISTS (
2390
+ SELECT 1
2391
+ FROM json_each(
2392
+ CASE
2393
+ WHEN json_valid(${column}) AND json_type(${column}) = 'array'
2394
+ THEN ${column}
2395
+ ELSE '[]'
2396
+ END
2397
+ ) item
2398
+ WHERE ${listElement === "file-entry" ? fileEntryPredicate("CASE WHEN item.type = 'object' THEN item.value ELSE '{}' END") : caseInsensitiveLike("item.value", pattern, searchText, params)}
2399
+ )`;
2400
+ }
1754
2401
  function searchableFields(fields, selected) {
1755
2402
  const selection = selected ? new Set(selected) : null;
1756
- return fields.filter((field) => (!selection || !!field.id && selection.has(field.id)) && !field.isHidden && (field.isRecordLabel || field.valueKind === "source" || field.valueKind === "materialized" || field.valueKind === "derived"));
2403
+ return fields.filter((field) => (!selection || !!field.id && selection.has(field.id)) && (!field.isHidden || selection !== null) && eidosFileFieldQueryCapabilities(field).searchable && (field.isRecordLabel || field.valueKind === "source" || field.valueKind === "materialized" || field.valueKind === "derived" || field.valueKind === "relation" || selection !== null && field.valueKind === "system"));
2404
+ }
2405
+ function eidosFileRowQuerySearchFields(fields, query) {
2406
+ const normalized = normalizeEidosFileRowQuery(query);
2407
+ return normalized.search === void 0 || normalized.search === "" ? [] : searchableFields(fields, normalized.searchFields);
1757
2408
  }
1758
2409
  function collectFilterFields(filter, target) {
1759
2410
  if (!filter) return;
@@ -1993,17 +2644,21 @@ function compileGroup(group, fields, params, referenceInstant) {
1993
2644
  return group.negated ? `NOT (${expression})` : expression;
1994
2645
  }
1995
2646
  function eidosFileSortExpression(field) {
1996
- const column = quoteIdentifier(field.tableColumnName);
1997
- return field.storageCodec === "json_array" || field.storageCodec === "relation" ? `(SELECT item.value FROM json_each(${column}) item
1998
- WHERE item.value IS NOT NULL ORDER BY CAST(item.key AS INTEGER) LIMIT 1)` : column;
2647
+ if (!eidosFileFieldQueryCapabilities(field).sortable) throw new EidosFileError("invalid-query", `${field.name} does not support sorting`);
2648
+ return quoteIdentifier(field.tableColumnName);
1999
2649
  }
2000
2650
  function compileSorts(sorts, fields) {
2001
2651
  const seen = /* @__PURE__ */ new Set();
2002
2652
  const clauses = [];
2003
- for (const sort of sorts ?? []) {
2004
- if (seen.has(sort.field)) continue;
2005
- const field = requireField(fields, sort.field);
2653
+ const uniqueSorts = (sorts ?? []).filter((sort) => {
2654
+ if (seen.has(sort.field)) return false;
2006
2655
  seen.add(sort.field);
2656
+ return true;
2657
+ });
2658
+ for (const [index, sort] of uniqueSorts.entries()) {
2659
+ const field = requireField(fields, sort.field);
2660
+ const capabilities = eidosFileFieldQueryCapabilities(field);
2661
+ if (!capabilities.sortable || capabilities.sortPosition === "last" && index < uniqueSorts.length - 1) throw new EidosFileError("invalid-query", `${field.name} does not support this sort position`);
2007
2662
  const expression = eidosFileSortExpression(field);
2008
2663
  clauses.push(`${expression} ${sort.direction === "desc" ? "DESC" : "ASC"} NULLS ${sort.nulls === "first" ? "FIRST" : "LAST"}`);
2009
2664
  }
@@ -2018,7 +2673,7 @@ function compileEidosFileRowQuery(fields, query = {}, context = {}) {
2018
2673
  const search = query.search;
2019
2674
  if (search !== void 0 && search !== "") {
2020
2675
  const pattern = `%${escapeLike(search)}%`;
2021
- const searchClauses = searchableFields(fields, query.searchFields).map((field) => caseInsensitiveLike(quoteIdentifier(field.tableColumnName), pattern, search, params));
2676
+ const searchClauses = eidosFileRowQuerySearchFields(fields, query).map((field) => searchExpression(field, pattern, search, params));
2022
2677
  if (searchClauses.length > 0) where.push(`(${searchClauses.join(" OR ")})`);
2023
2678
  }
2024
2679
  if (query.filter) where.push(compileGroup(query.filter, byColumn, params, context.referenceInstant ?? currentEidosFileInstant()));
@@ -2459,7 +3114,7 @@ CREATE TABLE eidos__fields(
2459
3114
  AND instr(physical_name,char(0))=0
2460
3115
  AND physical_name COLLATE BINARY = name COLLATE BINARY)),
2461
3116
  type TEXT NOT NULL CHECK(type IN (
2462
- 'text','number','integer','checkbox','date','datetime','url','json',
3117
+ 'text','number','integer','checkbox','date','datetime','url',
2463
3118
  'select','multi-select','file','relation','formula','lookup'
2464
3119
  )),
2465
3120
  system_role TEXT CHECK(system_role IN ('row-id','created-time','updated-time')),
@@ -2569,7 +3224,7 @@ CREATE TABLE eidos__formula_fields(
2569
3224
  source_text TEXT NOT NULL
2570
3225
  CHECK(length(CAST(source_text AS BLOB)) BETWEEN 1 AND 4096),
2571
3226
  result_type TEXT NOT NULL
2572
- CHECK(result_type IN ('text','number','integer','checkbox','date','datetime','url','json'))
3227
+ CHECK(result_type IN ('text','number','integer','checkbox','date','datetime','url'))
2573
3228
  ) STRICT, WITHOUT ROWID;
2574
3229
 
2575
3230
  CREATE TABLE eidos__lookup_fields(
@@ -2830,6 +3485,7 @@ const ID_COLUMNS = {
2830
3485
  const REQUIRED_INDEXES = new Set(["eidos__fields_one_system_role", "eidos__relation_one_inverse"]);
2831
3486
  const REQUIRED_TRIGGERS = new Set(["eidos__meta_no_delete", "eidos__meta_no_key_update"]);
2832
3487
  const DYNAMIC_TRIGGER_NAME = /^eidos__(?:row_id_immutable|relation_(?:validate_(?:insert|update)|restrict|detach))__[0-9a-f]{32}$/;
3488
+ const DYNAMIC_FIELD_INDEX_NAME = /^eidos__index__([0-9a-f]{32})$/;
2833
3489
  const FIELD_TYPES = new Set([
2834
3490
  "text",
2835
3491
  "number",
@@ -2865,6 +3521,16 @@ const FORMULA_RESULT_TYPES = new Set([
2865
3521
  "url"
2866
3522
  ]);
2867
3523
  const NUMERIC_LOOKUP_TYPES = new Set(["number", "integer"]);
3524
+ const INDEXABLE_FIELD_TYPES = new Set([
3525
+ "text",
3526
+ "number",
3527
+ "integer",
3528
+ "checkbox",
3529
+ "date",
3530
+ "datetime",
3531
+ "url",
3532
+ "select"
3533
+ ]);
2868
3534
  const FILTER_OPERATORS = new Set([
2869
3535
  "equals",
2870
3536
  "not-equals",
@@ -2959,6 +3625,144 @@ function declaresBinaryText(sql, column) {
2959
3625
  const identifier = `(?:"${escaped}"|\\[${escaped}\\]|\`${escaped}\`|${escaped})`;
2960
3626
  return new RegExp(`(?:\\(|,)\\s*${identifier}\\s+TEXT\\b[^,)]*\\bCOLLATE\\s+BINARY\\b`, "i").test(sql);
2961
3627
  }
3628
+ function readSqliteIdentifier(source, offset = 0) {
3629
+ let start = offset;
3630
+ while (/\s/.test(source[start] ?? "")) start += 1;
3631
+ const opener = source[start];
3632
+ const closer = opener === "[" ? "]" : opener;
3633
+ if (opener === "\"" || opener === "`" || opener === "[") {
3634
+ let value = "";
3635
+ for (let index = start + 1; index < source.length; index += 1) {
3636
+ const character = source[index];
3637
+ if (character !== closer) {
3638
+ value += character;
3639
+ continue;
3640
+ }
3641
+ if (closer !== "]" && source[index + 1] === closer) {
3642
+ value += closer;
3643
+ index += 1;
3644
+ continue;
3645
+ }
3646
+ return {
3647
+ value,
3648
+ end: index + 1
3649
+ };
3650
+ }
3651
+ return null;
3652
+ }
3653
+ let end = start;
3654
+ while (end < source.length && !/[\s(),]/.test(source[end])) end += 1;
3655
+ return end === start ? null : {
3656
+ value: source.slice(start, end),
3657
+ end
3658
+ };
3659
+ }
3660
+ function sqliteTableDefinitions(sql) {
3661
+ let quote = null;
3662
+ let open = -1;
3663
+ for (let index = 0; index < sql.length; index += 1) {
3664
+ const character = sql[index];
3665
+ if (quote) {
3666
+ if (character !== quote) continue;
3667
+ if (quote !== "]" && sql[index + 1] === quote) index += 1;
3668
+ else quote = null;
3669
+ continue;
3670
+ }
3671
+ if (character === "\"" || character === "'" || character === "`") {
3672
+ quote = character;
3673
+ continue;
3674
+ }
3675
+ if (character === "[") {
3676
+ quote = "]";
3677
+ continue;
3678
+ }
3679
+ if (character === "(") {
3680
+ open = index;
3681
+ break;
3682
+ }
3683
+ }
3684
+ if (open === -1) return [];
3685
+ const definitions = [];
3686
+ let depth = 1;
3687
+ let start = open + 1;
3688
+ quote = null;
3689
+ for (let index = start; index < sql.length; index += 1) {
3690
+ const character = sql[index];
3691
+ if (quote) {
3692
+ if (character !== quote) continue;
3693
+ if (quote !== "]" && sql[index + 1] === quote) index += 1;
3694
+ else quote = null;
3695
+ continue;
3696
+ }
3697
+ if (character === "\"" || character === "'" || character === "`") {
3698
+ quote = character;
3699
+ continue;
3700
+ }
3701
+ if (character === "[") {
3702
+ quote = "]";
3703
+ continue;
3704
+ }
3705
+ if (character === "(") {
3706
+ depth += 1;
3707
+ continue;
3708
+ }
3709
+ if (character === ")") {
3710
+ depth -= 1;
3711
+ if (depth === 0) {
3712
+ definitions.push(sql.slice(start, index).trim());
3713
+ break;
3714
+ }
3715
+ continue;
3716
+ }
3717
+ if (character === "," && depth === 1) {
3718
+ definitions.push(sql.slice(start, index).trim());
3719
+ start = index + 1;
3720
+ }
3721
+ }
3722
+ return definitions;
3723
+ }
3724
+ function declaredColumnCollation(tableSql, column) {
3725
+ if (!tableSql) return null;
3726
+ const definition = sqliteTableDefinitions(tableSql).find((candidate) => readSqliteIdentifier(candidate)?.value === column);
3727
+ if (!definition) return null;
3728
+ const leading = readSqliteIdentifier(definition);
3729
+ let depth = 0;
3730
+ let quote = null;
3731
+ for (let index = leading.end; index < definition.length; index += 1) {
3732
+ const character = definition[index];
3733
+ if (quote) {
3734
+ if (character !== quote) continue;
3735
+ if (quote !== "]" && definition[index + 1] === quote) index += 1;
3736
+ else quote = null;
3737
+ continue;
3738
+ }
3739
+ if (character === "\"" || character === "'" || character === "`") {
3740
+ quote = character;
3741
+ continue;
3742
+ }
3743
+ if (character === "[") {
3744
+ quote = "]";
3745
+ continue;
3746
+ }
3747
+ if (character === "(") {
3748
+ depth += 1;
3749
+ continue;
3750
+ }
3751
+ if (character === ")") {
3752
+ depth -= 1;
3753
+ continue;
3754
+ }
3755
+ if (depth !== 0 || !/[A-Za-z_]/.test(character)) continue;
3756
+ let end = index + 1;
3757
+ while (/[A-Za-z0-9_$]/.test(definition[end] ?? "")) end += 1;
3758
+ if (definition.slice(index, end).toLowerCase() !== "collate") {
3759
+ index = end - 1;
3760
+ continue;
3761
+ }
3762
+ return readSqliteIdentifier(definition, end)?.value ?? null;
3763
+ }
3764
+ return "BINARY";
3765
+ }
2962
3766
  function validateEidosFile(connection, options = {}) {
2963
3767
  const level = options.level ?? "full";
2964
3768
  const errors = [];
@@ -2982,7 +3786,7 @@ function validateEidosFile(connection, options = {}) {
2982
3786
  ...REQUIRED_INDEXES,
2983
3787
  ...REQUIRED_TRIGGERS
2984
3788
  ]);
2985
- for (const object of sqliteObjects) if (object.name.replace(/[A-Z]/g, (character) => character.toLowerCase()).startsWith("eidos__") && !allowedStaticObjects.has(object.name) && !DYNAMIC_TRIGGER_NAME.test(object.name)) add(errors, "invalid-schema", `Undeclared reserved SQLite object: ${object.type} ${object.name}`, object.name);
3789
+ for (const object of sqliteObjects) if (object.name.replace(/[A-Z]/g, (character) => character.toLowerCase()).startsWith("eidos__") && !allowedStaticObjects.has(object.name) && !DYNAMIC_TRIGGER_NAME.test(object.name) && !(object.type === "index" && DYNAMIC_FIELD_INDEX_NAME.test(object.name))) add(errors, "invalid-schema", `Undeclared reserved SQLite object: ${object.type} ${object.name}`, object.name);
2986
3790
  const indexes = new Set(sqliteObjects.filter((object) => object.type === "index").map((object) => object.name));
2987
3791
  for (const indexName of REQUIRED_INDEXES) if (!indexes.has(indexName)) add(errors, "invalid-schema", `Missing required metadata index: ${indexName}`);
2988
3792
  const triggers = new Set(sqliteObjects.filter((object) => object.type === "trigger").map((object) => object.name));
@@ -3058,12 +3862,15 @@ function validateEidosFile(connection, options = {}) {
3058
3862
  const tableRows = sqliteTables.has("eidos__tables") ? connection.query(`SELECT * FROM ${EIDOS_FILE_TABLES_TABLE} ORDER BY position, id`) : [];
3059
3863
  const tables = [];
3060
3864
  const tableRowsById = /* @__PURE__ */ new Map();
3865
+ const tableSettingsById = /* @__PURE__ */ new Map();
3061
3866
  const tableNames = /* @__PURE__ */ new Set();
3062
3867
  for (const row of tableRows) try {
3063
3868
  const id = uuid$1(row.id, "Table ID");
3064
3869
  tableRowsById.set(id, row);
3065
3870
  const tableSettings = isCanonicalEidosFileJson(row.settings_json) ? parseEidosFileJson(row.settings_json) : null;
3066
3871
  const settings = tableSettings && !Array.isArray(tableSettings) && typeof tableSettings === "object" ? tableSettings : {};
3872
+ tableSettingsById.set(id, settings);
3873
+ if (settings.contentFieldId !== void 0 && typeof settings.contentFieldId !== "string") add(errors, "invalid-schema", `Table ${row.name} contentFieldId must be a Field ID string`, row.physical_name);
3067
3874
  tables.push({
3068
3875
  id,
3069
3876
  name: row.name,
@@ -3072,6 +3879,7 @@ function validateEidosFile(connection, options = {}) {
3072
3879
  position: row.position,
3073
3880
  icon: typeof settings.icon === "string" ? settings.icon : null,
3074
3881
  description: typeof settings.description === "string" ? settings.description : null,
3882
+ contentFieldId: typeof settings.contentFieldId === "string" ? settings.contentFieldId : null,
3075
3883
  createdAt: row.created_at,
3076
3884
  updatedAt: row.updated_at
3077
3885
  });
@@ -3096,12 +3904,14 @@ function validateEidosFile(connection, options = {}) {
3096
3904
  const lookups = subtypeMap(lookupRows);
3097
3905
  const fieldRows = sqliteTables.has("eidos__fields") ? connection.query(`SELECT * FROM ${EIDOS_FILE_FIELDS_TABLE} ORDER BY table_id, position, id`) : [];
3098
3906
  const fieldRowsById = /* @__PURE__ */ new Map();
3907
+ const fieldRowsByHexId = /* @__PURE__ */ new Map();
3099
3908
  const fieldsByTable = /* @__PURE__ */ new Map();
3100
3909
  for (const row of fieldRows) try {
3101
3910
  const id = uuid$1(row.id, "Field ID");
3102
3911
  const tableId = uuid$1(row.table_id, "Field Table ID");
3103
3912
  const table = tableRowsById.get(tableId);
3104
3913
  fieldRowsById.set(id, row);
3914
+ fieldRowsByHexId.set(id.replace(/-/g, ""), row);
3105
3915
  if (!table) {
3106
3916
  add(errors, "invalid-schema", `Field ${id} references an unknown Table`);
3107
3917
  continue;
@@ -3141,7 +3951,7 @@ function validateEidosFile(connection, options = {}) {
3141
3951
  relationField: uuid$1(lookup.relation_field_id, "Lookup Relation Field ID"),
3142
3952
  targetField: uuid$1(lookup.target_field_id, "Lookup Target Field ID"),
3143
3953
  aggregate: lookup.aggregate,
3144
- displayType: lookup.aggregate === "values" ? "json" : "text"
3954
+ displayType: "text"
3145
3955
  } : relation ? {
3146
3956
  targetTableId: uuid$1(relation.target_table_id, "Relation Target Table ID"),
3147
3957
  direction: relation.direction,
@@ -3176,6 +3986,28 @@ function validateEidosFile(connection, options = {}) {
3176
3986
  } catch (error) {
3177
3987
  add(errors, "invalid-schema", error instanceof Error ? error.message : "Invalid Field metadata");
3178
3988
  }
3989
+ for (const indexObject of sqliteObjects.filter((object) => object.type === "index" && DYNAMIC_FIELD_INDEX_NAME.test(object.name))) {
3990
+ const fieldHex = DYNAMIC_FIELD_INDEX_NAME.exec(indexObject.name)[1];
3991
+ const field = fieldRowsByHexId.get(fieldHex);
3992
+ if (!field) {
3993
+ add(errors, "invalid-schema", `Reserved Field index ${indexObject.name} references an unknown Field`, indexObject.name);
3994
+ continue;
3995
+ }
3996
+ if (!field.physical_name || !INDEXABLE_FIELD_TYPES.has(field.type)) {
3997
+ add(errors, "invalid-schema", `Reserved Field index ${indexObject.name} must reference a stored scalar Field`, indexObject.name);
3998
+ continue;
3999
+ }
4000
+ const table = tableRowsById.get(field.table_id);
4001
+ if (!table || indexObject.tbl_name !== table.physical_name) {
4002
+ add(errors, "invalid-schema", `Reserved Field index ${indexObject.name} is attached to the wrong Table`, indexObject.name);
4003
+ continue;
4004
+ }
4005
+ const listedIndex = connection.query(`PRAGMA index_list(${quoteIdentifier(table.physical_name)})`).find((index) => index.name === indexObject.name);
4006
+ const keyColumns = connection.query(`PRAGMA index_xinfo(${quoteIdentifier(indexObject.name)})`).filter((column) => column.key === 1);
4007
+ const keyColumn = keyColumns[0];
4008
+ const declaredCollation = declaredColumnCollation(sqliteTables.get(table.physical_name)?.sql ?? null, field.physical_name);
4009
+ if (!listedIndex || listedIndex.unique !== 0 || listedIndex.partial !== 0 || listedIndex.origin !== "c" || indexObject.sql === null || keyColumns.length !== 1 || !keyColumn || keyColumn.cid < 0 || keyColumn.name !== field.physical_name || !declaredCollation || keyColumn.coll?.toLowerCase() !== declaredCollation.toLowerCase()) add(errors, "invalid-schema", `Reserved Field index ${indexObject.name} has an invalid definition`, indexObject.name);
4010
+ }
3179
4011
  for (const [tableId, fields] of fieldsByTable) {
3180
4012
  const table = tableRowsById.get(tableId);
3181
4013
  if (!table) continue;
@@ -3311,10 +4143,15 @@ function validateEidosFile(connection, options = {}) {
3311
4143
  element: valueType.slice(5)
3312
4144
  } : valueType;
3313
4145
  const atom = valueType.startsWith("list:") ? valueType.slice(5) : valueType;
3314
- field.property.displayType = atom === "row-id" || atom === "select" ? "text" : atom === "file-entry" ? "json" : atom;
4146
+ field.property.displayType = atom === "row-id" || atom === "select" ? "text" : atom === "file-entry" ? "text" : atom;
3315
4147
  }
3316
4148
  for (const [tableId, fields] of fieldsByTable) {
3317
4149
  const table = tableRowsById.get(tableId);
4150
+ const contentFieldId = tableSettingsById.get(tableId)?.contentFieldId;
4151
+ if (typeof contentFieldId === "string") {
4152
+ const contentField = fields.find((field) => field.id === contentFieldId);
4153
+ if (!contentField || contentField.type !== "text" || contentField.valueKind !== "source" || contentField.systemRole != null || !contentField.physicalName) add(errors, "invalid-schema", `Table ${table.name} Content Field must reference an ordinary Text Field in the same Table`);
4154
+ }
3318
4155
  const labels = fields.filter((field) => field.isRecordLabel);
3319
4156
  if (labels.length !== 1) add(errors, "invalid-schema", `Table ${table.name} must have exactly one Record Label Field`);
3320
4157
  for (const label of labels) {
@@ -3637,6 +4474,7 @@ function validateEidosFile(connection, options = {}) {
3637
4474
  if (field.type === "number" && (typeof value !== "number" || !Number.isFinite(value))) add(errors, "invalid-value", `${table.name}.${field.name} must be finite REAL`);
3638
4475
  if (field.type === "checkbox" && value !== 0 && value !== 1) add(errors, "invalid-value", `${table.name}.${field.name} must be 0, 1, or NULL`);
3639
4476
  if (field.type === "date" && !isCanonicalEidosFileDate(value)) add(errors, "invalid-value", `${table.name}.${field.name} must be canonical YYYY-MM-DD text`);
4477
+ if (field.type === "url" && !isEidosFileUriReference(value)) add(errors, "invalid-value", `${table.name}.${field.name} must be a valid URI-reference`);
3640
4478
  if ([
3641
4479
  "datetime",
3642
4480
  "created-time",
@@ -4397,6 +5235,11 @@ var EidosFileRuntime = class {
4397
5235
  this.allocateId = environment.allocateId ?? (() => createEidosFileUuid());
4398
5236
  connection.exec("PRAGMA foreign_keys = ON; PRAGMA trusted_schema = OFF;");
4399
5237
  connection.registerFunction("eidos_casefold", (value) => value === null ? null : String(value).toUpperCase().toLowerCase());
5238
+ connection.registerFunction("eidos_canonical_number", (value) => {
5239
+ if (value === null) return null;
5240
+ const number = Number(value);
5241
+ return Number.isFinite(number) ? canonicalizeEidosFileJson(Object.is(number, -0) ? 0 : number) : null;
5242
+ }, 1);
4400
5243
  registerEidosFormulaFunctions(connection);
4401
5244
  assertEidosFileFormulaProfile(connection);
4402
5245
  registerEidosLookupFunctions(connection);
@@ -4550,7 +5393,8 @@ var EidosFileRuntime = class {
4550
5393
  const settings = jsonObject(row.settings_json);
4551
5394
  return {
4552
5395
  icon: typeof settings.icon === "string" ? settings.icon : null,
4553
- description: typeof settings.description === "string" ? settings.description : null
5396
+ description: typeof settings.description === "string" ? settings.description : null,
5397
+ contentFieldId: typeof settings.contentFieldId === "string" ? settings.contentFieldId : null
4554
5398
  };
4555
5399
  })(),
4556
5400
  id: uuid(row.id),
@@ -4573,6 +5417,7 @@ var EidosFileRuntime = class {
4573
5417
  position: row.position,
4574
5418
  icon: typeof settings.icon === "string" ? settings.icon : null,
4575
5419
  description: typeof settings.description === "string" ? settings.description : null,
5420
+ contentFieldId: typeof settings.contentFieldId === "string" ? settings.contentFieldId : null,
4576
5421
  createdAt: row.created_at,
4577
5422
  updatedAt: row.updated_at
4578
5423
  };
@@ -4764,6 +5609,7 @@ var EidosFileRuntime = class {
4764
5609
  position,
4765
5610
  icon: input.icon ?? null,
4766
5611
  description: input.description ?? null,
5612
+ contentFieldId: null,
4767
5613
  createdAt: now,
4768
5614
  updatedAt: now
4769
5615
  };
@@ -4912,6 +5758,7 @@ var EidosFileRuntime = class {
4912
5758
  }
4913
5759
  updateTable(tableId, changes) {
4914
5760
  const table = this.getTable(tableId);
5761
+ const persistedSettings = jsonObject(this.tableRow(tableId).settings_json);
4915
5762
  return this.mutateSchemaState(() => {
4916
5763
  let name = table.name;
4917
5764
  let physicalName = table.physicalName ?? table.rawTableName;
@@ -4936,15 +5783,30 @@ var EidosFileRuntime = class {
4936
5783
  }
4937
5784
  }
4938
5785
  const now = this.operationInstant();
4939
- const settings = canonicalizeEidosFileJson({
4940
- ...changes.icon === void 0 ? table.icon === null ? {} : { icon: table.icon } : changes.icon === null ? {} : { icon: changes.icon },
4941
- ...changes.description === void 0 ? table.description === null ? {} : { description: table.description } : changes.description === null ? {} : { description: changes.description }
4942
- });
5786
+ const nextSettings = { ...persistedSettings };
5787
+ if (changes.icon !== void 0) if (changes.icon === null) delete nextSettings.icon;
5788
+ else nextSettings.icon = changes.icon;
5789
+ if (changes.description !== void 0) if (changes.description === null) delete nextSettings.description;
5790
+ else nextSettings.description = changes.description;
5791
+ if (changes.contentFieldId !== void 0) if (changes.contentFieldId === null) delete nextSettings.contentFieldId;
5792
+ else {
5793
+ const contentField = this.fieldByKey(tableId, changes.contentFieldId);
5794
+ if (contentField.type !== "text" || contentField.valueKind !== "source" || contentField.systemRole != null || !contentField.physicalName) throw new EidosFileError("invalid-schema", "The Content Field must be an ordinary Text Field in the same Table");
5795
+ nextSettings.contentFieldId = contentField.id;
5796
+ }
5797
+ let recordLabelFieldId = this.tableRow(tableId).label_field_id;
5798
+ if (changes.recordLabelFieldId !== void 0) {
5799
+ const labelField = this.fieldByKey(tableId, changes.recordLabelFieldId);
5800
+ if (labelField.type === "lookup" || !LABEL_TYPES.has(labelField.type)) throw new EidosFileError("invalid-schema", "The Record Label Field must be a scalar Field in the same Table");
5801
+ recordLabelFieldId = labelField.id;
5802
+ }
5803
+ const settings = canonicalizeEidosFileJson(nextSettings);
4943
5804
  this.connection.run(`UPDATE ${EIDOS_FILE_TABLES_TABLE}
4944
- SET name = ?, physical_name = ?, settings_json = ?, updated_at = ?
5805
+ SET name = ?, physical_name = ?, label_field_id = ?, settings_json = ?, updated_at = ?
4945
5806
  WHERE id = ?`, [
4946
5807
  name,
4947
5808
  physicalName,
5809
+ recordLabelFieldId,
4948
5810
  settings,
4949
5811
  now,
4950
5812
  tableId
@@ -5389,6 +6251,16 @@ var EidosFileRuntime = class {
5389
6251
  const replacement = replacementRecordLabelFieldId ? this.fieldByKey(tableId, replacementRecordLabelFieldId) : void 0;
5390
6252
  if (replacement?.id === field.id) throw new EidosFileError("constraint-conflict", "The replacement Record Label Field must be a different Field");
5391
6253
  return this.mutateSchemaState(() => {
6254
+ if (table.contentFieldId === field.id) {
6255
+ const settings = jsonObject(this.tableRow(tableId).settings_json);
6256
+ delete settings.contentFieldId;
6257
+ this.connection.run(`UPDATE ${EIDOS_FILE_TABLES_TABLE}
6258
+ SET settings_json = ?, updated_at = ? WHERE id = ?`, [
6259
+ canonicalizeEidosFileJson(settings),
6260
+ this.operationInstant(),
6261
+ tableId
6262
+ ]);
6263
+ }
5392
6264
  if (field.isRecordLabel && replacement?.id) this.connection.run(`UPDATE ${EIDOS_FILE_TABLES_TABLE}
5393
6265
  SET label_field_id = ?, updated_at = ? WHERE id = ?`, [
5394
6266
  replacement.id,
@@ -5692,6 +6564,52 @@ var EidosFileRuntime = class {
5692
6564
  )
5693
6565
  ), '[]')`;
5694
6566
  }
6567
+ rowIdSearchTargetTableId(field, schema, visiting = /* @__PURE__ */ new Set()) {
6568
+ if (!field.id || visiting.has(field.id)) return null;
6569
+ const nextVisiting = new Set(visiting);
6570
+ nextVisiting.add(field.id);
6571
+ if (field.type === "row-id") return field.tableId ?? null;
6572
+ const relation = schema.relations.get(field.id);
6573
+ if (relation) return uuid(relation.target_table_id);
6574
+ const lookup = schema.lookups.get(field.id);
6575
+ if (!lookup) return null;
6576
+ const target = schema.fields.get(uuid(lookup.target_field_id));
6577
+ return target ? this.rowIdSearchTargetTableId(target, schema, nextVisiting) : null;
6578
+ }
6579
+ recordLabelSearchExpression(field, rowAlias, schema) {
6580
+ const expression = this.fieldExpression(field, rowAlias, schema);
6581
+ const type = eidosFileFieldValueType(field);
6582
+ if (typeof type !== "string") return "NULL";
6583
+ if (type === "checkbox") return `CASE ${expression} WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE NULL END`;
6584
+ if (type === "number") return `eidos_canonical_number(${expression})`;
6585
+ return `CAST(${expression} AS TEXT)`;
6586
+ }
6587
+ rowIdSearchFragmentsExpression(field, rowAlias, schema) {
6588
+ const targetTableId = this.rowIdSearchTargetTableId(field, schema);
6589
+ if (!targetTableId) return null;
6590
+ const targetTable = schema.tables.get(targetTableId);
6591
+ const label = (schema.fieldsByTable.get(targetTableId) ?? []).find((candidate) => candidate.isRecordLabel);
6592
+ if (!targetTable || !label) return null;
6593
+ const ids = this.fieldExpression(field, rowAlias, schema);
6594
+ return `coalesce((
6595
+ SELECT json_group_array(fragment) FROM (
6596
+ SELECT CASE
6597
+ WHEN search_target."_id" IS NULL THEN CAST(item.value AS TEXT)
6598
+ ELSE ${this.recordLabelSearchExpression(label, "search_target", schema)}
6599
+ END AS fragment
6600
+ FROM json_each(${ids}) item
6601
+ LEFT JOIN ${quoteIdentifier(targetTable.physical_name)} search_target
6602
+ ON item.value = search_target."_id"
6603
+ ORDER BY CAST(item.key AS INTEGER)
6604
+ )
6605
+ ), '[]')`;
6606
+ }
6607
+ querySearchFragmentFieldIds(fields, query) {
6608
+ return new Set(eidosFileRowQuerySearchFields(fields, query).flatMap((field) => {
6609
+ const type = eidosFileFieldValueType(field);
6610
+ return field.id && (type === "relation" || field.type === "lookup" && typeof type === "object" && type.element === "row-id") ? [field.id] : [];
6611
+ }));
6612
+ }
5695
6613
  requiredQueryFieldKeys(fields, query) {
5696
6614
  const required = /* @__PURE__ */ new Set();
5697
6615
  const collectFilter = (group) => {
@@ -5701,12 +6619,10 @@ var EidosFileRuntime = class {
5701
6619
  };
5702
6620
  collectFilter(query.filter);
5703
6621
  for (const sort of query.sorts ?? []) required.add(sort.field);
5704
- if (query.search?.trim()) {
5705
- for (const field of fields) if (!field.isHidden && (field.isRecordLabel || field.valueKind === "source" || field.valueKind === "relation" || field.valueKind === "derived")) required.add(field.id);
5706
- }
6622
+ for (const field of eidosFileRowQuerySearchFields(fields, query)) if (field.id) required.add(field.id);
5707
6623
  return required;
5708
6624
  }
5709
- logicalSource(tableId, requestedKeys, includeRecordLabel = true, includeRelationDisplays = true) {
6625
+ logicalSource(tableId, requestedKeys, includeRecordLabel = true, includeRelationDisplays = true, searchFragmentFieldIds = /* @__PURE__ */ new Set()) {
5710
6626
  const schema = this.allSchema();
5711
6627
  const table = schema.tables.get(tableId);
5712
6628
  if (!table) throw new EidosFileError("table-not-found", `Table not found: ${tableId}`);
@@ -5729,6 +6645,10 @@ var EidosFileRuntime = class {
5729
6645
  sql: `SELECT base."_id" AS "__base_rowid", ${fields.filter((field) => projected.has(field.id)).flatMap((field) => {
5730
6646
  const result = [`${this.fieldExpression(field, "base", schema)} AS ${quoteIdentifier(field.tableColumnName)}`];
5731
6647
  if (includeRelationDisplays && field.type === "relation") result.push(`${this.relationDisplayExpression(field, "base", schema)} AS ${quoteIdentifier(`${field.tableColumnName}__display`)}`);
6648
+ if (searchFragmentFieldIds.has(field.id)) {
6649
+ const fragments = this.rowIdSearchFragmentsExpression(field, "base", schema);
6650
+ if (fragments) result.push(`${fragments} AS ${quoteIdentifier(`${field.tableColumnName}__search`)}`);
6651
+ }
5732
6652
  return result;
5733
6653
  }).join(", ")}
5734
6654
  FROM ${quoteIdentifier(table.physical_name)} base`,
@@ -5793,7 +6713,7 @@ var EidosFileRuntime = class {
5793
6713
  ...projection.preservedColumns ?? [],
5794
6714
  ...this.requiredQueryFieldKeys(fields, compatibleQuery)
5795
6715
  ]) : void 0;
5796
- const source = this.logicalSource(tableId, requested, projection?.includeRecordLabel !== false, projection?.includeRelationDisplays !== false);
6716
+ const source = this.logicalSource(tableId, requested, projection?.includeRecordLabel !== false, projection?.includeRelationDisplays !== false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
5797
6717
  const querySignature = canonicalizeEidosFileJson(compatibleQuery);
5798
6718
  const sorts = uniqueSortFields(source.fields, compatibleQuery.sorts);
5799
6719
  const revision = String(this.info().revision ?? 0);
@@ -5871,7 +6791,7 @@ var EidosFileRuntime = class {
5871
6791
  const id = assertEidosFileUuid(rowId, "Row ID");
5872
6792
  const compatibleQuery = this.compatibilityQuery(tableId, query);
5873
6793
  const fields = this.listFields(tableId);
5874
- const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false);
6794
+ const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
5875
6795
  const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
5876
6796
  const sorts = uniqueSortFields(source.fields, compatibleQuery.sorts);
5877
6797
  const targetWhere = compiled.whereSql ? `${compiled.whereSql} AND "__base_rowid" = ?` : "WHERE \"__base_rowid\" = ?";
@@ -5884,6 +6804,29 @@ var EidosFileRuntime = class {
5884
6804
  SELECT COUNT(*) AS count FROM logical ${beforeWhere}`, [...compiled.params, ...before.params]);
5885
6805
  return Number(result?.count ?? 0);
5886
6806
  }
6807
+ getRecordNeighbors(tableId, rowId, query = {}) {
6808
+ const id = assertEidosFileUuid(rowId, "Row ID");
6809
+ const compatibleQuery = this.compatibilityQuery(tableId, query);
6810
+ const fields = this.listFields(tableId);
6811
+ const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
6812
+ const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
6813
+ const targetWhere = compiled.whereSql ? `${compiled.whereSql} AND "__base_rowid" = ?` : "WHERE \"__base_rowid\" = ?";
6814
+ const target = this.connection.get(`WITH logical AS (${source.sql}) SELECT * FROM logical ${targetWhere} LIMIT 1`, [...compiled.params, id]);
6815
+ if (!target) return { found: false };
6816
+ const sorts = uniqueSortFields(source.fields, compatibleQuery.sorts);
6817
+ const values = sorts.map(({ field }) => cursorSortValue(target, field));
6818
+ const reverseOrder = [...sorts.map(({ field, sort }) => `${eidosFileSortExpression(field)} ${sort.direction === "desc" ? "ASC" : "DESC"} NULLS ${sort.nulls === "first" ? "LAST" : "FIRST"}`), "\"__base_rowid\" DESC"].join(", ");
6819
+ const neighbor = (previous) => {
6820
+ const boundary = (previous ? compileKeysetBefore : compileKeysetAfter)(sorts, values, id);
6821
+ const where = compiled.whereSql ? `${compiled.whereSql} AND ${boundary.sql}` : `WHERE ${boundary.sql}`;
6822
+ return this.connection.get(`WITH logical AS (${source.sql}) SELECT "__base_rowid" AS id FROM logical ${where} ${previous ? `ORDER BY ${reverseOrder}` : compiled.orderSql} LIMIT 1`, [...compiled.params, ...boundary.params])?.id ?? null;
6823
+ };
6824
+ return {
6825
+ found: true,
6826
+ previousId: neighbor(true),
6827
+ nextId: neighbor(false)
6828
+ };
6829
+ }
5887
6830
  getRow(tableId, rowId) {
5888
6831
  const source = this.logicalSource(tableId);
5889
6832
  const row = this.connection.get(`WITH logical AS (${source.sql}) SELECT * FROM logical WHERE "__base_rowid" = ?`, [assertEidosFileUuid(rowId, "Row ID")]);
@@ -5965,7 +6908,8 @@ var EidosFileRuntime = class {
5965
6908
  */
5966
6909
  runtimeScanLogicalRows(tableId, fieldIds, query) {
5967
6910
  const compatibleQuery = this.compatibilityQuery(tableId, query);
5968
- const source = this.logicalSource(tableId, fieldIds, false, false);
6911
+ const fields = this.listFields(tableId);
6912
+ const source = this.logicalSource(tableId, [...fieldIds, ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
5969
6913
  const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
5970
6914
  const selectedFields = fieldIds.map((fieldId) => this.fieldByKey(tableId, fieldId));
5971
6915
  const encodedValues = selectedFields.map((field) => {
@@ -6012,7 +6956,7 @@ var EidosFileRuntime = class {
6012
6956
  if (storage === "real") return [field.id, Number(value)];
6013
6957
  if (storage === "text") {
6014
6958
  const logicalType = fieldValueTypeForScan(field);
6015
- if (logicalType === "json" || logicalType === "file" || logicalType === "multi-select" || logicalType === "relation" || logicalType === "file-entry" || typeof logicalType === "object") return [field.id, parseEidosFileJson(String(value))];
6959
+ if (logicalType === "file" || logicalType === "multi-select" || logicalType === "relation" || logicalType === "file-entry" || typeof logicalType === "object") return [field.id, parseEidosFileJson(String(value))];
6016
6960
  return [field.id, String(value)];
6017
6961
  }
6018
6962
  throw new EidosFileError("invalid-value", "Logical aggregate scan returned an unsupported storage class");
@@ -6043,7 +6987,7 @@ var EidosFileRuntime = class {
6043
6987
  countRows(tableId, query = {}, referenceInstant = this.nowInstant()) {
6044
6988
  const compatibleQuery = this.compatibilityQuery(tableId, query);
6045
6989
  const fields = this.listFields(tableId);
6046
- const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false);
6990
+ const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
6047
6991
  const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant });
6048
6992
  return this.connection.get(`WITH logical AS (${source.sql}) SELECT count(*) AS count FROM logical ${compiled.whereSql}`, compiled.params)?.count ?? 0;
6049
6993
  }
@@ -6051,7 +6995,7 @@ var EidosFileRuntime = class {
6051
6995
  const field = this.fieldByKey(tableId, fieldKey);
6052
6996
  const compatibleQuery = this.compatibilityQuery(tableId, query);
6053
6997
  const fields = this.listFields(tableId);
6054
- const source = this.logicalSource(tableId, [field.id, ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false);
6998
+ const source = this.logicalSource(tableId, [field.id, ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
6055
6999
  const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
6056
7000
  const column = quoteIdentifier(field.tableColumnName);
6057
7001
  if (field.storageCodec === "json_array" || field.storageCodec === "relation") return this.connection.query(`WITH logical AS (${source.sql}), filtered AS (
@@ -6068,7 +7012,7 @@ var EidosFileRuntime = class {
6068
7012
  const compatibleQuery = this.compatibilityQuery(tableId, query);
6069
7013
  const fields = this.listFields(tableId);
6070
7014
  configs = normalizeEidosFileColumnStatConfigs(configs, fields);
6071
- const source = this.logicalSource(tableId, [...configs.map((config) => config.fieldId), ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false);
7015
+ const source = this.logicalSource(tableId, [...configs.map((config) => config.fieldId), ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
6072
7016
  const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
6073
7017
  return configs.map((config) => {
6074
7018
  const field = this.fieldByKey(tableId, config.fieldId);
@@ -6094,9 +7038,11 @@ var EidosFileRuntime = class {
6094
7038
  "relation-distinct-target-count": `(SELECT count(DISTINCT value) FROM ${flattened} WHERE value_type = 'text')`
6095
7039
  }[config.type];
6096
7040
  if (!expression) throw new EidosFileError("invalid-query", `Unsupported statistic: ${config.type}`);
6097
- const value = this.connection.get(`WITH logical AS (${source.sql}), filtered AS (
7041
+ const rawValue = this.connection.get(`WITH logical AS (${source.sql}), filtered AS (
6098
7042
  SELECT * FROM logical ${compiled.whereSql}
6099
7043
  ) SELECT ${expression} AS value FROM filtered`, compiled.params)?.value ?? null;
7044
+ const value = typeof rawValue === "bigint" ? String(rawValue) : rawValue;
7045
+ if (value instanceof Uint8Array) throw new EidosFileError("invalid-query", `Statistic ${config.type} returned an invalid binary value`);
6100
7046
  return {
6101
7047
  ...config,
6102
7048
  value
@@ -6106,6 +7052,104 @@ var EidosFileRuntime = class {
6106
7052
  aggregate(tableId, configs, query = {}) {
6107
7053
  return this.calculateColumnStats(tableId, configs, query);
6108
7054
  }
7055
+ aggregateTable(tableId, options, query = {}) {
7056
+ const compatibleQuery = this.compatibilityQuery(tableId, query);
7057
+ const fields = this.listFields(tableId);
7058
+ const groupByField = options.groupBy?.fieldId ? this.fieldByKey(tableId, options.groupBy.fieldId) : void 0;
7059
+ const metricField = options.metric.fieldId ? this.fieldByKey(tableId, options.metric.fieldId) : void 0;
7060
+ const requiredFieldIds = [
7061
+ ...groupByField ? [groupByField.id] : [],
7062
+ ...metricField ? [metricField.id] : [],
7063
+ ...this.requiredQueryFieldKeys(fields, compatibleQuery)
7064
+ ];
7065
+ const source = this.logicalSource(tableId, requiredFieldIds, false, false, this.querySearchFragmentFieldIds(fields, compatibleQuery));
7066
+ const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
7067
+ let metricSql = "count(*)";
7068
+ if (options.metric.op === "count") metricSql = metricField ? `count(${quoteIdentifier(metricField.tableColumnName)})` : "count(*)";
7069
+ else if (metricField) {
7070
+ const col = quoteIdentifier(metricField.tableColumnName);
7071
+ switch (options.metric.op) {
7072
+ case "sum":
7073
+ metricSql = `coalesce(sum(${col}), 0)`;
7074
+ break;
7075
+ case "average":
7076
+ metricSql = `coalesce(avg(${col}), 0)`;
7077
+ break;
7078
+ case "min":
7079
+ metricSql = `min(${col})`;
7080
+ break;
7081
+ case "max":
7082
+ metricSql = `max(${col})`;
7083
+ break;
7084
+ }
7085
+ }
7086
+ const countRow = this.connection.query(`WITH logical AS (${source.sql})
7087
+ SELECT count(*) AS total FROM logical ${compiled.whereSql}`, compiled.params)[0];
7088
+ const totalRecords = Number(countRow?.total ?? 0);
7089
+ if (!groupByField) {
7090
+ const row = this.connection.query(`WITH logical AS (${source.sql})
7091
+ SELECT ${metricSql} AS val FROM logical ${compiled.whereSql}`, compiled.params)[0];
7092
+ return {
7093
+ items: [{
7094
+ key: null,
7095
+ label: "Total",
7096
+ value: row?.val !== null && row?.val !== void 0 ? Number(row.val) : 0
7097
+ }],
7098
+ totalRecords
7099
+ };
7100
+ }
7101
+ const groupCol = quoteIdentifier(groupByField.tableColumnName);
7102
+ let groupKeyExpr = groupCol;
7103
+ if (groupByField.type === "date") switch (options.groupBy?.dateInterval) {
7104
+ case "year":
7105
+ groupKeyExpr = `strftime('%Y', ${groupCol})`;
7106
+ break;
7107
+ case "month":
7108
+ groupKeyExpr = `strftime('%Y-%m', ${groupCol})`;
7109
+ break;
7110
+ case "day":
7111
+ groupKeyExpr = `strftime('%Y-%m-%d', ${groupCol})`;
7112
+ break;
7113
+ default:
7114
+ groupKeyExpr = groupCol;
7115
+ break;
7116
+ }
7117
+ let orderClause = "ORDER BY group_key ASC";
7118
+ if (options.sort === "value-desc") orderClause = "ORDER BY metric_value DESC, group_key ASC";
7119
+ else if (options.sort === "value-asc") orderClause = "ORDER BY metric_value ASC, group_key ASC";
7120
+ const isList = groupByField.storageCodec === "json_array" || groupByField.storageCodec === "relation";
7121
+ let rows = [];
7122
+ if (isList) rows = this.connection.query(`WITH logical AS (${source.sql}), filtered AS (
7123
+ SELECT * FROM logical ${compiled.whereSql}
7124
+ )
7125
+ SELECT item.value AS group_key, ${metricSql} AS metric_value
7126
+ FROM filtered, json_each(filtered.${groupCol}) item
7127
+ GROUP BY item.value
7128
+ ${orderClause}`, compiled.params);
7129
+ else rows = this.connection.query(`WITH logical AS (${source.sql})
7130
+ SELECT ${groupKeyExpr} AS group_key, ${metricSql} AS metric_value
7131
+ FROM logical ${compiled.whereSql}
7132
+ GROUP BY ${groupKeyExpr}
7133
+ ${orderClause}`, compiled.params);
7134
+ const optionsMap = /* @__PURE__ */ new Map();
7135
+ if ((groupByField.type === "select" || groupByField.type === "multi-select") && Array.isArray(groupByField.property?.options)) for (const opt of groupByField.property.options) optionsMap.set(opt.id, opt.name);
7136
+ return {
7137
+ items: rows.map((r) => {
7138
+ const key = r.group_key;
7139
+ let label = "";
7140
+ if (key === null || key === void 0 || key === "") label = "(Empty)";
7141
+ else if (groupByField.type === "checkbox") label = Number(key) === 1 ? "Checked" : "Unchecked";
7142
+ else if (typeof key === "string" && optionsMap.has(key)) label = optionsMap.get(key);
7143
+ else label = String(key);
7144
+ return {
7145
+ key,
7146
+ label,
7147
+ value: r.metric_value !== null && r.metric_value !== void 0 ? Number(r.metric_value) : 0
7148
+ };
7149
+ }),
7150
+ totalRecords
7151
+ };
7152
+ }
6109
7153
  normalizeStoredValue(field, value, allowUnresolvedRelations) {
6110
7154
  if (value === null || value === void 0) {
6111
7155
  if (field.type === "file" || field.type === "multi-select" || field.type === "relation") return "[]";
@@ -6139,6 +7183,7 @@ var EidosFileRuntime = class {
6139
7183
  }
6140
7184
  if (field.type === "select" || field.type === "text" || field.type === "url") {
6141
7185
  if (typeof value !== "string") throw new EidosFileError("invalid-value", `${field.name} must be text or NULL`);
7186
+ if (field.type === "url" && !isEidosFileUriReference(value)) throw new EidosFileError("invalid-value", `${field.name} contains an invalid URI-reference`);
6142
7187
  return value;
6143
7188
  }
6144
7189
  if (field.type === "multi-select") {
@@ -6793,6 +7838,8 @@ var EidosFileRuntime = class {
6793
7838
  function fieldValueTypeForScan(field) {
6794
7839
  if (field.systemRole === "row-id") return "row-id";
6795
7840
  if (field.systemRole === "created-time" || field.systemRole === "updated-time") return "datetime";
7841
+ const configured = configuredTypeRef(field.property?.valueType);
7842
+ if (configured) return configured;
6796
7843
  if (field.type === "lookup" && field.property?.aggregate === "values") {
6797
7844
  const display = String(field.property?.displayType ?? "text");
6798
7845
  return {
@@ -6807,6 +7854,6 @@ function fieldValueTypeForScan(field) {
6807
7854
  return field.type;
6808
7855
  }
6809
7856
  //#endregion
6810
- export { EIDOS_FILE_MIME_TYPE as $, eidosFileLookupElementType as A, compileEidosFileFormulaFields as B, normalizeEidosFileFilter as C, eidosFileFieldStoresJsonArray as D, removeEidosFileFilterField as E, EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES as F, EIDOS_FILE_EXTENSION as G, eidosFileFormulaReferences as H, EIDOS_FILE_FORMULA_FUNCTION_NAMES as I, EIDOS_FILE_FORMAT as J, EIDOS_FILE_FEATURES_TABLE as K, EIDOS_FILE_FORMULA_PROFILE as L, eidosFileLookupTargetDisplayType as M, eidosFileLookupTargetValueType as N, eidosFileLookupAggregateSupportsTarget as O, eidosFileLookupValueType as P, EIDOS_FILE_META_TABLE as Q, assertEidosFileFormulaProfile as R, isEidosFileFilterOperator as S, normalizeEidosFileSorts as T, rewriteEidosFileFormulaFieldReferences as U, compileEidosFileFormulaSource as V, EIDOS_FILE_APPLICATION_ID as W, EIDOS_FILE_FORMULA_FIELDS_TABLE as X, EIDOS_FILE_FORMAT_VERSION as Y, EIDOS_FILE_LOOKUP_FIELDS_TABLE as Z, assertEidosFileRowQuery as _, sqlValueToNative as _t, EIDOS_FILE_FORMAT_VERSION_TEXT as a, EIDOS_FILE_VIEWS_TABLE as at, eidosFileRowQueryPredicateColumns as b, incrementEidosFileRevision as c, eidosFileColumnStatLabel as ct, decodeEidosFileRelationDisplay as d, EidosAdapterError as dt, EIDOS_FILE_RELATION_FIELDS_TABLE as et, decodeEidosFileRelationIds as f, assertExactConnectionBindings as ft, parseNonNegativeInt64 as g, nativeToSqlValue as gt, cancellationPortFromSignal as h, exactConnectionBindingCount as ht, scanStableRowPages as i, EIDOS_FILE_TABLES_TABLE as it, eidosFileLookupStorageCodec as j, eidosFileLookupDisplayType as k, initializeEidosFileSchema as l, eidosFileColumnStatTypesForField as lt, MemoryByteSource as m, assertUnicodeString as mt, validateEidosFile as n, EIDOS_FILE_SCHEMA_VERSION as nt, EIDOS_FILE_SCHEMA_SQL as o, SQLITE_HEADER as ot, encodeEidosFileRelationIds as p, assertInt64Decimal as pt, EIDOS_FILE_FIELDS_TABLE as q, smallestDependencyCycle as r, EIDOS_FILE_SYSTEM_COLUMNS as rt, configureEidosFileConnection as s, hasEidosFileSqliteHeader as st, EidosFileRuntime as t, EIDOS_FILE_REQUIRED_TABLES as tt, setEidosFileMetadata as u, ConnectionPortEidosFileConnection as ut, compileEidosFileRowQuery as v, normalizeEidosFileRowQuery as w, eidosFileSortExpression as x, eidosFileRowQueryAffectedByFieldChanges as y, compileEidosFileFormula as z };
7857
+ export { EIDOS_FILE_FORMAT as $, eidosFileLookupDisplayType as A, compileEidosFileFormula as B, isEidosFileFilterOperator as C, assertExactConnectionBindings as Ct, removeEidosFileFilterField as D, nativeToSqlValue as Dt, normalizeEidosFileSorts as E, exactConnectionBindingCount as Et, eidosFileLookupValueType as F, configuredTypeRef as G, compileEidosFileFormulaSource as H, EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES as I, eidosFileTypeRefQueryCapabilities as J, eidosFileFieldQueryCapabilities as K, EIDOS_FILE_FORMULA_FUNCTION_NAMES as L, eidosFileLookupStorageCodec as M, eidosFileLookupTargetDisplayType as N, eidosFileFieldStoresJsonArray as O, sqlValueToNative as Ot, eidosFileLookupTargetValueType as P, EIDOS_FILE_FIELDS_TABLE as Q, EIDOS_FILE_FORMULA_PROFILE as R, eidosFileSortExpression as S, EidosAdapterError as St, normalizeEidosFileRowQuery as T, assertUnicodeString as Tt, eidosFileFormulaReferences as U, compileEidosFileFormulaFields as V, rewriteEidosFileFormulaFieldReferences as W, EIDOS_FILE_EXTENSION as X, EIDOS_FILE_APPLICATION_ID as Y, EIDOS_FILE_FEATURES_TABLE as Z, assertEidosFileRowQuery as _, eidosFileTextMultiSelectChoices as _t, EIDOS_FILE_FORMAT_VERSION_TEXT as a, EIDOS_FILE_RELATION_FIELDS_TABLE as at, eidosFileRowQueryPredicateColumns as b, recommendedEidosFileConversionPolicies as bt, incrementEidosFileRevision as c, EIDOS_FILE_SYSTEM_COLUMNS as ct, decodeEidosFileRelationDisplay as d, SQLITE_HEADER as dt, EIDOS_FILE_FORMAT_VERSION as et, decodeEidosFileRelationIds as f, hasEidosFileSqliteHeader as ft, parseNonNegativeInt64 as g, eidosFileConversionTargetNullable as gt, cancellationPortFromSignal as h, eidosFileConversionCanReusePhysicalColumn as ht, scanStableRowPages as i, EIDOS_FILE_MIME_TYPE as it, eidosFileLookupElementType as j, eidosFileLookupAggregateSupportsTarget as k, initializeEidosFileSchema as l, EIDOS_FILE_TABLES_TABLE as lt, MemoryByteSource as m, eidosFileColumnStatTypesForField as mt, validateEidosFile as n, EIDOS_FILE_LOOKUP_FIELDS_TABLE as nt, EIDOS_FILE_SCHEMA_SQL as o, EIDOS_FILE_REQUIRED_TABLES as ot, encodeEidosFileRelationIds as p, eidosFileColumnStatLabel as pt, eidosFileFieldValueType as q, smallestDependencyCycle as r, EIDOS_FILE_META_TABLE as rt, configureEidosFileConnection as s, EIDOS_FILE_SCHEMA_VERSION as st, EidosFileRuntime as t, EIDOS_FILE_FORMULA_FIELDS_TABLE as tt, setEidosFileMetadata as u, EIDOS_FILE_VIEWS_TABLE as ut, compileEidosFileRowQuery as v, isEidosFileUriReference as vt, normalizeEidosFileFilter as w, assertInt64Decimal as wt, eidosFileRowQuerySearchFields as x, ConnectionPortEidosFileConnection as xt, eidosFileRowQueryAffectedByFieldChanges as y, planCanonicalFieldConversion as yt, assertEidosFileFormulaProfile as z };
6811
7858
 
6812
- //# sourceMappingURL=runtime-BLZqiCnB.mjs.map
7859
+ //# sourceMappingURL=runtime-mvRkk__c.mjs.map