@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
package/dist/index.mjs CHANGED
@@ -1,433 +1,22 @@
1
1
  import { A as isEidosFileUuid, C as assertEidosFileDisplayName, D as createEidosFileIdentifier, E as assertEidosFileUuid, F as EidosFileError, M as canonicalizeEidosFileJson, N as isCanonicalEidosFileJson, O as createEidosFileUuid, P as parseEidosFileJson, S as assertEidosFileColumnName, T as assertEidosFileTableName, _ as encodeEidosFileAttachmentPaths, a as parseEidosFileSelectOptions, b as normalizeEidosFileAttachmentPath, d as normalizeEidosFileDate, f as normalizeEidosFileInstant, g as eidosFileUriClass, h as decodeEidosFileValues, i as parseEidosFileSelectDefaultOption, j as quoteIdentifier, k as isEidosFileReservedTableName, l as isCanonicalEidosFileDate, m as decodeEidosFileAttachmentPaths, n as assertEidosFileSelectDefaultOption, o as currentEidosFileInstant, p as assertEidosFileValues, r as assertEidosFileSelectOptions, t as assertEidosFileMultiSelectHasNoDefaultOption, u as isCanonicalEidosFileInstant, v as encodeEidosFileValues, w as assertEidosFileTableId, x as EidosUuidV7Generator, y as isSafeEidosFileUri } from "./select-options-DSzDn3qm.mjs";
2
- import { a as eidosFileTypeHandler, c as AdapterTransportRuntimeClient, d as transportFitsHostLimit, f as validateAdapterCarrier, i as EidosFileSession, l as AdapterTransportServer, n as EidosFileHandlerRegistry, o as EidosFileRuntimeDataSource, p as validateAdapterEnvelope, r as EidosFileHostError, s as eidosFileSnapshot, t as SQLiteWasmConnectionPort, u as EIDOS_ADAPTER_TRANSPORT_LIMITS } from "./sqlite-wasm-C_MX7-tl.mjs";
3
- import { $ as EIDOS_FILE_MIME_TYPE, A as eidosFileLookupElementType, B as compileEidosFileFormulaFields, C as normalizeEidosFileFilter, D as eidosFileFieldStoresJsonArray, E as removeEidosFileFilterField, F as EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES, G as EIDOS_FILE_EXTENSION, H as eidosFileFormulaReferences, I as EIDOS_FILE_FORMULA_FUNCTION_NAMES, J as EIDOS_FILE_FORMAT, K as EIDOS_FILE_FEATURES_TABLE, L as EIDOS_FILE_FORMULA_PROFILE, M as eidosFileLookupTargetDisplayType, N as eidosFileLookupTargetValueType, O as eidosFileLookupAggregateSupportsTarget, P as eidosFileLookupValueType, Q as EIDOS_FILE_META_TABLE, R as assertEidosFileFormulaProfile, S as isEidosFileFilterOperator, T as normalizeEidosFileSorts, U as rewriteEidosFileFormulaFieldReferences, V as compileEidosFileFormulaSource, W as EIDOS_FILE_APPLICATION_ID, X as EIDOS_FILE_FORMULA_FIELDS_TABLE, Y as EIDOS_FILE_FORMAT_VERSION, Z as EIDOS_FILE_LOOKUP_FIELDS_TABLE, _ as assertEidosFileRowQuery, _t as sqlValueToNative, a as EIDOS_FILE_FORMAT_VERSION_TEXT, at as EIDOS_FILE_VIEWS_TABLE, b as eidosFileRowQueryPredicateColumns, c as incrementEidosFileRevision, ct as eidosFileColumnStatLabel, d as decodeEidosFileRelationDisplay, dt as EidosAdapterError, et as EIDOS_FILE_RELATION_FIELDS_TABLE, f as decodeEidosFileRelationIds, g as parseNonNegativeInt64, gt as nativeToSqlValue, h as cancellationPortFromSignal, i as scanStableRowPages, it as EIDOS_FILE_TABLES_TABLE, j as eidosFileLookupStorageCodec, k as eidosFileLookupDisplayType, l as initializeEidosFileSchema, lt as eidosFileColumnStatTypesForField, m as MemoryByteSource, mt as assertUnicodeString, n as validateEidosFile, nt as EIDOS_FILE_SCHEMA_VERSION, o as EIDOS_FILE_SCHEMA_SQL, ot as SQLITE_HEADER, p as encodeEidosFileRelationIds, pt as assertInt64Decimal, q as EIDOS_FILE_FIELDS_TABLE, r as smallestDependencyCycle, rt as EIDOS_FILE_SYSTEM_COLUMNS, s as configureEidosFileConnection, st as hasEidosFileSqliteHeader, t as EidosFileRuntime, tt as EIDOS_FILE_REQUIRED_TABLES, u as setEidosFileMetadata, ut as ConnectionPortEidosFileConnection, v as compileEidosFileRowQuery, w as normalizeEidosFileRowQuery, x as eidosFileSortExpression, y as eidosFileRowQueryAffectedByFieldChanges, z as compileEidosFileFormula } from "./runtime-BLZqiCnB.mjs";
4
- import { _ as isMutableEidosFileFieldType, a as eidosFileCsvExportHeader, b as decodeEidosFileStringArray, c as importEidosFileCsv, d as prepareEidosFileCsvImport, f as MUTABLE_BASE_FIELD_TYPES, g as encodeEidosFileMultiSelectValues, h as eidosFileFieldDisplayValues, i as createEidosFileCsvRowEncoder, l as parseEidosFileCsvRows, m as eidosFileFieldConversionMayRequireLossyConfirmation, n as EIDOS_FILE_CSV_PREVIEW_ROW_COUNT, o as eidosFileCsvRowToEidosFileRow, p as decodeEidosFileMultiSelectValues, r as createEidosFileCsvImportPlan, s as encodeEidosFileCsvRecord, t as EIDOS_FILE_CSV_INFERENCE_ROW_COUNT, u as planEidosFileCsvImport, v as planEidosFileFieldConversion, x as encodeEidosFileJsonArray, y as decodeEidosFileJsonArray } from "./csv-BVaUkU1o.mjs";
5
- import { n as mergeEidosSystemMetadata, t as EIDOS_SYSTEM_METADATA_TABLES } from "./system-metadata-merge-Cxv30SkG.mjs";
6
- //#region src/canonical-conversion.ts
7
- /**
8
- * Product defaults for conversions requested by the Eidos File editor.
9
- *
10
- * These policies are intentionally explicit: the Runtime still reports an
11
- * `explicit-lossy` preflight and requires confirmation whenever the values in
12
- * the current Field would actually lose information.
13
- */
14
- function recommendedEidosFileConversionPolicies(from, to) {
15
- const policies = [];
16
- if (from === "integer" && to === "number") policies.push("round-binary64");
17
- if (from === "number" && to === "integer") policies.push("round-ties-even");
18
- if ((from === "integer" || from === "number") && to === "checkbox") policies.push("zero-false-nonzero-true");
19
- if (from === "datetime" && to === "date") policies.push("utc-date");
20
- if (from === "multi-select" && to === "select") policies.push("first");
21
- if (!LIST_TYPES.has(from) && LIST_TYPES.has(to)) policies.push("null-to-empty-list");
22
- return policies;
23
- }
24
- /** Returns the nullable shape used by editor-initiated conversions. */
25
- function eidosFileConversionTargetNullable(from, to, sourceNullable) {
26
- return sourceNullable || from === "multi-select" && to === "select";
27
- }
28
- const INT64_MIN = -9223372036854775808n;
29
- const INT64_MAX = 9223372036854775807n;
30
- const INT64 = /^(?:0|-[1-9][0-9]*|[1-9][0-9]*)$/u;
31
- const LIST_TYPES = new Set([
32
- "multi-select",
33
- "file",
34
- "relation"
35
- ]);
36
- const TEXT_TYPES = new Set([
37
- "text",
38
- "date",
39
- "datetime",
40
- "url",
41
- "select"
42
- ]);
43
- const SHARED_TEXT_COLUMN_TYPES = new Set([
44
- "text",
45
- "select",
46
- "url"
47
- ]);
48
- /** True when a conversion can retain the exact nullable SQLite column DDL. */
49
- function eidosFileConversionCanReusePhysicalColumn(from, to, sourceNullable, targetNullable) {
50
- return sourceNullable === targetNullable && SHARED_TEXT_COLUMN_TYPES.has(from) && SHARED_TEXT_COLUMN_TYPES.has(to);
51
- }
52
- function planCanonicalFieldConversion(input) {
53
- const policies = new Set(input.policies ?? []);
54
- const sourceHasEmptyList = input.rows.some((row) => {
55
- if (row.value === null || typeof row.value !== "string") return false;
56
- return row.value === "[]";
57
- });
58
- const changes = /* @__PURE__ */ new Map();
59
- const rows = [];
60
- let severity = 0;
61
- let error;
62
- for (const row of input.rows) try {
63
- let converted;
64
- if (row.value === null) converted = convertNull(input, policies, sourceHasEmptyList);
65
- else converted = convertNonNull(input, row.value, policies);
66
- if (converted.value === null && !input.toNullable && !LIST_TYPES.has(input.to)) throw new Error("Destination non-nullability rejects SQL NULL");
67
- validateDestination(input, converted.value);
68
- const changed = storageClass(input.from) !== storageClass(input.to) || !sameStorageValue(row.value, converted.value);
69
- rows.push({
70
- id: row.id,
71
- value: converted.value,
72
- changed
73
- });
74
- if (changed) {
75
- severity = Math.max(severity, converted.class);
76
- changes.set("value-reencoded", (changes.get("value-reencoded") ?? 0) + 1);
77
- if (converted.code) changes.set(converted.code, (changes.get(converted.code) ?? 0) + 1);
78
- }
79
- } catch (cause) {
80
- severity = 3;
81
- error = cause instanceof Error ? cause.message : "Conversion is forbidden";
82
- break;
83
- }
84
- if (severity === 3) return {
85
- classification: "forbidden",
86
- rows: [],
87
- affectedRows: "0",
88
- valueChanges: [],
89
- error
90
- };
91
- const affectedRows = rows.filter((row) => row.changed).length;
92
- return {
93
- classification: severity === 2 ? "explicit-lossy" : severity === 1 ? "lossless-rewrite" : "metadata-only",
94
- rows,
95
- affectedRows: String(affectedRows),
96
- valueChanges: Array.from(changes, ([code, count]) => ({
97
- code,
98
- rows: String(count)
99
- }))
100
- };
101
- }
102
- function convertNull(input, policies, sourceHasEmptyList) {
103
- if (LIST_TYPES.has(input.to)) {
104
- if (!policies.has("null-to-empty-list")) throw new Error("SQL NULL requires null-to-empty-list for a list destination");
105
- return {
106
- value: "[]",
107
- class: sourceHasEmptyList ? 2 : 1,
108
- code: "null-to-empty-list"
109
- };
110
- }
111
- if (!input.toNullable) throw new Error("Destination non-nullability rejects SQL NULL");
112
- return {
113
- value: null,
114
- class: 0
115
- };
116
- }
117
- function convertNonNull(input, value, policies) {
118
- const { from, to } = input;
119
- if (from === to) return {
120
- value,
121
- class: 0
122
- };
123
- if (TEXT_TYPES.has(from) && TEXT_TYPES.has(to)) {
124
- if (to === "datetime" && from === "date") return {
125
- value: `${asText(value)}T00:00:00.000Z`,
126
- class: 1
127
- };
128
- if (to === "date" && from === "datetime") {
129
- const text = asText(value);
130
- if (text.endsWith("T00:00:00.000Z")) return {
131
- value: text.slice(0, 10),
132
- class: 1
133
- };
134
- if (!policies.has("utc-date")) throw new Error("Datetime with a time component requires utc-date");
135
- return {
136
- value: text.slice(0, 10),
137
- class: 2,
138
- code: "datetime-to-date"
139
- };
140
- }
141
- return {
142
- value: asText(value),
143
- class: 0
144
- };
145
- }
146
- if (to === "text") {
147
- if (from === "number") return {
148
- value: canonicalNumber(asNumber(value)),
149
- class: 1
150
- };
151
- if (from === "integer") return {
152
- value: String(asInteger(value)),
153
- class: 1
154
- };
155
- if (from === "checkbox") return {
156
- value: asCheckbox(value) ? "true" : "false",
157
- class: 1
158
- };
159
- if (LIST_TYPES.has(from)) return {
160
- value: asText(value),
161
- class: 0
162
- };
163
- }
164
- if (to === "select") {
165
- if (from === "number") return {
166
- value: canonicalNumber(asNumber(value)),
167
- class: 1
168
- };
169
- if (from === "integer") return {
170
- value: String(asInteger(value)),
171
- class: 1
172
- };
173
- if (from === "checkbox") return {
174
- value: asCheckbox(value) ? "true" : "false",
175
- class: 1
176
- };
177
- if (from === "multi-select") {
178
- const list = parseStringList(value);
179
- if (list.length === 1) return {
180
- value: list[0],
181
- class: 1
182
- };
183
- if (!policies.has("first")) throw new Error("Multi-select to Select requires a singleton or first");
184
- if (list.length === 0) {
185
- if (!input.toNullable) throw new Error("Empty list requires nullable Select");
186
- return {
187
- value: null,
188
- class: 1,
189
- code: "list-empty-to-null"
190
- };
191
- }
192
- return {
193
- value: list[0],
194
- class: 2,
195
- code: "list-tail-dropped"
196
- };
197
- }
198
- }
199
- if (to === "number") {
200
- if (from === "integer") {
201
- const integer = asInteger(value);
202
- const number = Number(integer);
203
- if (Number.isInteger(number) && BigInt(number) === integer) return {
204
- value: number,
205
- class: 1
206
- };
207
- if (!policies.has("round-binary64") || !Number.isFinite(number)) throw new Error("Integer is not exactly representable as binary64");
208
- return {
209
- value: number,
210
- class: 2,
211
- code: "binary64-rounded"
212
- };
213
- }
214
- if (from === "checkbox") return {
215
- value: asCheckbox(value) ? 1 : 0,
216
- class: 1
217
- };
218
- if (from === "text" || from === "select") {
219
- const text = asText(value);
220
- const number = Number(text);
221
- if (!Number.isFinite(number) || canonicalNumber(number) !== text) throw new Error("Text is not the exact inverse binary64 spelling");
222
- return {
223
- value: number,
224
- class: 1
225
- };
226
- }
227
- }
228
- if (to === "integer") {
229
- if (from === "checkbox") return {
230
- value: asCheckbox(value) ? 1n : 0n,
231
- class: 0
232
- };
233
- if (from === "text" || from === "select") return {
234
- value: parseInt64(asText(value)),
235
- class: 1
236
- };
237
- if (from === "number") return numberToInteger(asNumber(value), policies);
238
- }
239
- if (to === "checkbox") {
240
- if (from === "text" || from === "select") {
241
- const text = asText(value);
242
- if (text === "true") return {
243
- value: 1n,
244
- class: 1
245
- };
246
- if (text === "false") return {
247
- value: 0n,
248
- class: 1
249
- };
250
- throw new Error("Text is not lowercase true or false");
251
- }
252
- if (from === "integer") {
253
- const integer = asInteger(value);
254
- if (integer === 0n || integer === 1n) return {
255
- value: integer,
256
- class: 0
257
- };
258
- if (!policies.has("zero-false-nonzero-true")) throw new Error("Integer Checkbox conversion requires exact 0/1");
259
- return {
260
- value: integer === 0n ? 0n : 1n,
261
- class: 2,
262
- code: "numeric-to-checkbox"
263
- };
264
- }
265
- if (from === "number") {
266
- const number = asNumber(value);
267
- if (number === 0 || number === 1) return {
268
- value: BigInt(number),
269
- class: 1
270
- };
271
- if (!policies.has("zero-false-nonzero-true")) throw new Error("Number Checkbox conversion requires exact 0.0/1.0");
272
- return {
273
- value: number === 0 ? 0n : 1n,
274
- class: 2,
275
- code: "numeric-to-checkbox"
276
- };
277
- }
278
- }
279
- if (LIST_TYPES.has(to)) {
280
- if (from === "select" && to === "multi-select") return {
281
- value: canonicalizeEidosFileJson([asText(value)]),
282
- class: 1
283
- };
284
- if (from === "text" && to === "multi-select") return {
285
- value: canonicalizeEidosFileJson([asText(value)]),
286
- class: 1
287
- };
288
- if (from === "multi-select" && to === "relation" || from === "relation" && to === "multi-select" || from === to) return {
289
- value: asText(value),
290
- class: 0
291
- };
292
- }
293
- throw new Error(`Conversion from ${from} to ${to} is forbidden`);
294
- }
295
- function numberToInteger(number, policies) {
296
- let result = number;
297
- let code;
298
- let classification = 1;
299
- if (!Number.isInteger(result)) {
300
- if (policies.has("truncate-toward-zero")) {
301
- result = Math.trunc(result);
302
- code = "fraction-truncated";
303
- } else if (policies.has("round-ties-even")) {
304
- result = roundTiesEven(result);
305
- code = "integer-rounded";
306
- } else throw new Error("Fractional Number requires an Integer rounding policy");
307
- classification = 2;
308
- }
309
- if (!Number.isInteger(result)) throw new Error("Integer result is not integral");
310
- const integer = BigInt(result);
311
- if (integer < INT64_MIN || integer > INT64_MAX) throw new Error("Integer result is outside signed int64");
312
- return {
313
- value: integer,
314
- class: classification,
315
- ...code ? { code } : {}
316
- };
317
- }
318
- function validateDestination(input, value) {
319
- if (value === null) return;
320
- switch (input.to) {
321
- case "number":
322
- asNumber(value);
323
- return;
324
- case "integer":
325
- asInteger(value);
326
- return;
327
- case "checkbox":
328
- asCheckbox(value);
329
- return;
330
- case "date":
331
- if (!isCanonicalEidosFileDate(value)) throw new Error("Invalid Date value");
332
- return;
333
- case "datetime":
334
- if (!isCanonicalEidosFileInstant(value)) throw new Error("Invalid Datetime value");
335
- return;
336
- case "url":
337
- if (!isUriReference(asText(value))) throw new Error("Invalid URI-reference");
338
- return;
339
- case "multi-select":
340
- parseStringList(value);
341
- return;
342
- case "file":
343
- decodeEidosFileValues(asText(value));
344
- return;
345
- case "relation": {
346
- const ids = parseStringList(value);
347
- if (!ids.every(isEidosFileUuid)) throw new Error("Invalid Relation Row ID");
348
- if (input.relationCardinality === "one" && ids.length > 1) throw new Error("One-cardinality Relation contains more than one Row ID");
349
- if (input.relationIdValid && !ids.every(input.relationIdValid)) throw new Error("Relation Row ID does not resolve in the target Table");
350
- return;
351
- }
352
- case "text":
353
- case "select":
354
- asText(value);
355
- return;
356
- }
357
- }
358
- function parseStringList(value) {
359
- const text = asText(value);
360
- if (!isCanonicalEidosFileJson(text)) throw new Error("List is not canonical JSON");
361
- const parsed = parseEidosFileJson(text);
362
- if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) throw new Error("List must contain only strings");
363
- if (new Set(parsed).size !== parsed.length) throw new Error("List values must be unique");
364
- return parsed;
365
- }
366
- function asText(value) {
367
- if (typeof value !== "string") throw new Error("Expected TEXT storage");
368
- return value;
369
- }
370
- function asNumber(value) {
371
- if (typeof value !== "number" || !Number.isFinite(value)) throw new Error("Expected finite REAL storage");
372
- return Object.is(value, -0) ? 0 : value;
373
- }
374
- function asInteger(value) {
375
- if (typeof value === "bigint") {
376
- if (value < INT64_MIN || value > INT64_MAX) throw new Error("INTEGER outside int64");
377
- return value;
378
- }
379
- if (typeof value !== "number" || !Number.isSafeInteger(value)) throw new Error("Expected exact INTEGER storage");
380
- return BigInt(value);
381
- }
382
- function asCheckbox(value) {
383
- const integer = asInteger(value);
384
- if (integer !== 0n && integer !== 1n) throw new Error("Checkbox must be 0 or 1");
385
- return integer === 1n;
386
- }
387
- function parseInt64(value) {
388
- if (!INT64.test(value) || value === "-0") throw new Error("Invalid int64 spelling");
389
- const integer = BigInt(value);
390
- if (integer < INT64_MIN || integer > INT64_MAX) throw new Error("INTEGER outside int64");
391
- return integer;
392
- }
393
- function canonicalNumber(value) {
394
- return canonicalizeEidosFileJson(value);
395
- }
396
- function roundTiesEven(value) {
397
- const floor = Math.floor(value);
398
- const fraction = value - floor;
399
- if (fraction < .5) return floor;
400
- if (fraction > .5) return floor + 1;
401
- return floor % 2 === 0 ? floor : floor + 1;
402
- }
403
- function isUriReference(value) {
404
- return !/[\u0000-\u0020<>"{}|\\^`]/u.test(value) && !/%(?![0-9A-Fa-f]{2})/u.test(value);
405
- }
406
- function sameStorageValue(left, right) {
407
- 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]);
408
- if ((typeof left === "bigint" || typeof left === "number" && Number.isSafeInteger(left)) && (typeof right === "bigint" || typeof right === "number" && Number.isSafeInteger(right))) return BigInt(left) === BigInt(right);
409
- return typeof left === typeof right && Object.is(left, right);
410
- }
411
- function storageClass(type) {
412
- if (type === "integer" || type === "checkbox") return "integer";
413
- if (type === "number") return "real";
414
- return "text";
415
- }
416
- //#endregion
2
+ import { a as eidosFileTypeHandler, c as AdapterTransportRuntimeClient, d as transportFitsHostLimit, f as validateAdapterCarrier, i as EidosFileSession, l as AdapterTransportServer, n as EidosFileHandlerRegistry, o as EidosFileRuntimeDataSource, p as validateAdapterEnvelope, r as EidosFileHostError, s as eidosFileSnapshot, t as SQLiteWasmConnectionPort, u as EIDOS_ADAPTER_TRANSPORT_LIMITS } from "./sqlite-wasm-BhRD8n56.mjs";
3
+ import { $ as EIDOS_FILE_FORMAT, A as eidosFileLookupDisplayType, B as compileEidosFileFormula, C as isEidosFileFilterOperator, D as removeEidosFileFilterField, Dt as nativeToSqlValue, E as normalizeEidosFileSorts, F as eidosFileLookupValueType, G as configuredTypeRef, H as compileEidosFileFormulaSource, I as EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES, J as eidosFileTypeRefQueryCapabilities, K as eidosFileFieldQueryCapabilities, L as EIDOS_FILE_FORMULA_FUNCTION_NAMES, M as eidosFileLookupStorageCodec, N as eidosFileLookupTargetDisplayType, O as eidosFileFieldStoresJsonArray, Ot as sqlValueToNative, P as eidosFileLookupTargetValueType, Q as EIDOS_FILE_FIELDS_TABLE, R as EIDOS_FILE_FORMULA_PROFILE, S as eidosFileSortExpression, St as EidosAdapterError, T as normalizeEidosFileRowQuery, Tt as assertUnicodeString, U as eidosFileFormulaReferences, V as compileEidosFileFormulaFields, W as rewriteEidosFileFormulaFieldReferences, X as EIDOS_FILE_EXTENSION, Y as EIDOS_FILE_APPLICATION_ID, Z as EIDOS_FILE_FEATURES_TABLE, _ as assertEidosFileRowQuery, _t as eidosFileTextMultiSelectChoices, a as EIDOS_FILE_FORMAT_VERSION_TEXT, at as EIDOS_FILE_RELATION_FIELDS_TABLE, b as eidosFileRowQueryPredicateColumns, bt as recommendedEidosFileConversionPolicies, c as incrementEidosFileRevision, ct as EIDOS_FILE_SYSTEM_COLUMNS, d as decodeEidosFileRelationDisplay, dt as SQLITE_HEADER, et as EIDOS_FILE_FORMAT_VERSION, f as decodeEidosFileRelationIds, ft as hasEidosFileSqliteHeader, g as parseNonNegativeInt64, gt as eidosFileConversionTargetNullable, h as cancellationPortFromSignal, ht as eidosFileConversionCanReusePhysicalColumn, i as scanStableRowPages, it as EIDOS_FILE_MIME_TYPE, j as eidosFileLookupElementType, k as eidosFileLookupAggregateSupportsTarget, l as initializeEidosFileSchema, lt as EIDOS_FILE_TABLES_TABLE, m as MemoryByteSource, mt as eidosFileColumnStatTypesForField, n as validateEidosFile, nt as EIDOS_FILE_LOOKUP_FIELDS_TABLE, o as EIDOS_FILE_SCHEMA_SQL, ot as EIDOS_FILE_REQUIRED_TABLES, p as encodeEidosFileRelationIds, pt as eidosFileColumnStatLabel, q as eidosFileFieldValueType, r as smallestDependencyCycle, rt as EIDOS_FILE_META_TABLE, s as configureEidosFileConnection, st as EIDOS_FILE_SCHEMA_VERSION, t as EidosFileRuntime, tt as EIDOS_FILE_FORMULA_FIELDS_TABLE, u as setEidosFileMetadata, ut as EIDOS_FILE_VIEWS_TABLE, v as compileEidosFileRowQuery, vt as isEidosFileUriReference, w as normalizeEidosFileFilter, wt as assertInt64Decimal, x as eidosFileRowQuerySearchFields, xt as ConnectionPortEidosFileConnection, y as eidosFileRowQueryAffectedByFieldChanges, yt as planCanonicalFieldConversion, z as assertEidosFileFormulaProfile } from "./runtime-mvRkk__c.mjs";
4
+ import { _ as isMutableEidosFileFieldType, a as eidosFileCsvExportHeader, b as decodeEidosFileStringArray, c as importEidosFileCsv, d as prepareEidosFileCsvImport, f as MUTABLE_BASE_FIELD_TYPES, g as encodeEidosFileMultiSelectValues, h as eidosFileFieldDisplayValues, i as createEidosFileCsvRowEncoder, l as parseEidosFileCsvRows, m as eidosFileFieldConversionMayRequireLossyConfirmation, n as EIDOS_FILE_CSV_PREVIEW_ROW_COUNT, o as eidosFileCsvRowToEidosFileRow, p as decodeEidosFileMultiSelectValues, r as createEidosFileCsvImportPlan, s as encodeEidosFileCsvRecord, t as EIDOS_FILE_CSV_INFERENCE_ROW_COUNT, u as planEidosFileCsvImport, v as planEidosFileFieldConversion, x as encodeEidosFileJsonArray, y as decodeEidosFileJsonArray } from "./csv-NK8Rti5O.mjs";
5
+ import { n as mergeEidosSystemMetadata, t as EIDOS_SYSTEM_METADATA_TABLES } from "./system-metadata-merge-CickEFxi.mjs";
417
6
  //#region src/form-view.ts
418
7
  const EIDOS_FILE_FORM_VIEW_TYPE = "form";
419
8
  const EIDOS_FILE_FORM_INPUT_FIELD_TYPES = [
420
- "integer",
421
9
  "text",
422
10
  "number",
11
+ "integer",
423
12
  "checkbox",
424
- "date",
425
- "datetime",
426
- "file",
13
+ "select",
427
14
  "multi-select",
428
15
  "rating",
429
- "select",
430
- "url"
16
+ "date",
17
+ "datetime",
18
+ "url",
19
+ "file"
431
20
  ];
432
21
  const INPUT_TYPES = new Set(EIDOS_FILE_FORM_INPUT_FIELD_TYPES);
433
22
  function optionalString(value, maxBytes) {
@@ -770,6 +359,9 @@ var EidosRuntimeService = class {
770
359
  };
771
360
  }), false, request);
772
361
  }
362
+ getRecordNeighbors(request, context) {
363
+ return this.invoke(context, async () => this.read(async () => this.core.getRecordNeighbors(request.tableId, request.rowId, this.compatibilityQuery(request.tableId, request.query))), false, request);
364
+ }
773
365
  getRowsById(request, context) {
774
366
  return this.invoke(context, async () => this.read(async () => {
775
367
  if (request.rowIds.length > EIDOS_RUNTIME_LIMITS.rowsByIdMax || new Set(request.rowIds).size !== request.rowIds.length) throw runtimeError("invalid-request", "rowIds must be unique and within rowsByIdMax");
@@ -781,6 +373,9 @@ var EidosRuntimeService = class {
781
373
  aggregate(request, context) {
782
374
  return this.invoke(context, () => this.read(() => this.aggregateNow(request)), false, request);
783
375
  }
376
+ aggregateTable(tableId, options, query = {}) {
377
+ return this.read(() => this.core.aggregateTable(tableId, options, query));
378
+ }
784
379
  groupRows(request, context) {
785
380
  return this.invoke(context, async () => this.read(async () => this.groupRowsNow(request)), false, request);
786
381
  }
@@ -1026,7 +621,7 @@ var EidosRuntimeService = class {
1026
621
  const field = fields.get(fieldId);
1027
622
  if (!field) throw runtimeError("not-found", "Mutation Field not found", { fieldId });
1028
623
  if (!fieldWritable(field)) throw runtimeError("forbidden", "Mutation Field is read-only", { fieldId });
1029
- const type = fieldValueType(field);
624
+ const type = eidosFileFieldValueType(field);
1030
625
  assertJcsBytes(value, EIDOS_RUNTIME_LIMITS.logicalValueBytesMax, "Logical value");
1031
626
  if (value === null) {
1032
627
  if (!field.nullable) throw runtimeError("constraint", "Field is not nullable", { fieldId });
@@ -1039,6 +634,7 @@ var EidosRuntimeService = class {
1039
634
  if (Array.isArray(value) && value.length > EIDOS_RUNTIME_LIMITS.listElementsMax) throw runtimeError("resource-limit", "List exceeds listElementsMax", { fieldId });
1040
635
  if (type === "date" && !isCanonicalEidosFileDate(value)) throw runtimeError("invalid-value", "Date is not canonical", { fieldId });
1041
636
  if (type === "datetime" && !isCanonicalEidosFileInstant(value)) throw runtimeError("invalid-value", "Datetime is not canonical", { fieldId });
637
+ if (type === "url" && !isEidosFileUriReference(value)) throw runtimeError("invalid-value", "Invalid URI-reference", { fieldId });
1042
638
  if (type === "integer") normalized[fieldId] = parseSignedInt64(value, "Integer value");
1043
639
  else normalized[fieldId] = value;
1044
640
  }
@@ -1467,7 +1063,8 @@ var EidosRuntimeService = class {
1467
1063
  position: String(table.position ?? 0),
1468
1064
  settings: objectValue({
1469
1065
  ...table.icon === null ? {} : { icon: table.icon },
1470
- ...table.description === null ? {} : { description: table.description }
1066
+ ...table.description === null ? {} : { description: table.description },
1067
+ ...table.contentFieldId === null ? {} : { contentFieldId: table.contentFieldId }
1471
1068
  })
1472
1069
  };
1473
1070
  });
@@ -1508,7 +1105,7 @@ var EidosRuntimeService = class {
1508
1105
  return {
1509
1106
  fieldId,
1510
1107
  name: field.name,
1511
- valueType: fieldValueType(field),
1108
+ valueType: eidosFileFieldValueType(field),
1512
1109
  source: field.type === "formula" ? "formula" : field.type === "lookup" ? "lookup" : field.type === "relation" && relation?.direction === "inverse" ? "inverse-relation" : "stored",
1513
1110
  writable: fieldWritable(field)
1514
1111
  };
@@ -1529,15 +1126,22 @@ var EidosRuntimeService = class {
1529
1126
  if (!field || !definition) return [];
1530
1127
  const labelField = this.core.listFields(definition.targetTableId).find((entry) => entry.isRecordLabel);
1531
1128
  if (!labelField?.id) return [];
1129
+ const resolved = new Map((row.resolved?.[fieldId] ?? []).map((item) => [item.id, item]));
1532
1130
  return [{
1533
1131
  column,
1534
- items: (row.resolved?.[fieldId] ?? []).map((item) => ({
1535
- id: item.id,
1536
- state: "resolved",
1537
- labelFieldId: labelField.id,
1538
- labelType: fieldValueType(labelField),
1539
- label: item.label
1540
- }))
1132
+ items: (Array.isArray(row.fields[fieldId]) ? row.fields[fieldId].filter((value) => typeof value === "string") : []).map((id) => {
1133
+ const item = resolved.get(id);
1134
+ return item ? {
1135
+ id,
1136
+ state: "resolved",
1137
+ labelFieldId: labelField.id,
1138
+ labelType: eidosFileFieldValueType(labelField),
1139
+ label: item.label
1140
+ } : {
1141
+ id,
1142
+ state: "unresolved"
1143
+ };
1144
+ })
1541
1145
  }];
1542
1146
  });
1543
1147
  if (resolvedRelations.length > 0) projected.resolvedRelations = resolvedRelations;
@@ -1614,7 +1218,7 @@ var EidosRuntimeService = class {
1614
1218
  key: item.key,
1615
1219
  value: String(rows.length)
1616
1220
  };
1617
- return aggregateItemResult(item, fieldValueType(fieldsById.get(item.fieldId)), rows.map((row) => row.fields[item.fieldId] ?? null));
1221
+ return aggregateItemResult(item, eidosFileFieldValueType(fieldsById.get(item.fieldId)), rows.map((row) => row.fields[item.fieldId] ?? null));
1618
1222
  });
1619
1223
  const metadata = this.core.info();
1620
1224
  return {
@@ -1638,8 +1242,8 @@ var EidosRuntimeService = class {
1638
1242
  const fieldsById = new Map(fields.map((field) => [field.id, field]));
1639
1243
  const groupTypes = request.groupBy.map((fieldId) => {
1640
1244
  const field = fieldsById.get(fieldId);
1641
- const type = field ? fieldValueType(field) : void 0;
1642
- if (!field || typeof type !== "string" || !isSortableType(type)) throw runtimeError("invalid-query", "Group Field is not groupable", { fieldId });
1245
+ const type = field ? eidosFileFieldValueType(field) : void 0;
1246
+ if (!field || !type || !eidosFileTypeRefQueryCapabilities(type).groupable) throw runtimeError("invalid-query", "Group Field is not groupable", { fieldId });
1643
1247
  return type;
1644
1248
  });
1645
1249
  assertAggregateItems(request.aggregates, fieldsById);
@@ -1879,6 +1483,7 @@ var EidosRuntimeService = class {
1879
1483
  property: field.property ? { ...field.property } : null
1880
1484
  }]));
1881
1485
  const tableNames = new Map(this.core.listTables().map((table) => [table.id, table.name]));
1486
+ const proposedContentFields = new Map(this.core.listTables().map((table) => [table.id, table.contentFieldId ?? null]));
1882
1487
  let syntheticField = 0;
1883
1488
  let rewrittenFormulaSources = 0;
1884
1489
  for (const leaf of leaves) switch (leaf.kind) {
@@ -1895,6 +1500,7 @@ var EidosRuntimeService = class {
1895
1500
  case "delete-table":
1896
1501
  for (const [id, field] of proposedFields) if (field.tableId === leaf.tableId) proposedFields.delete(id);
1897
1502
  tableNames.delete(leaf.tableId);
1503
+ proposedContentFields.delete(leaf.tableId);
1898
1504
  break;
1899
1505
  case "create-field": {
1900
1506
  const candidate = simulatedNewField(leaf.tableId, tableNames.get(leaf.tableId) ?? leaf.tableId, leaf.field, ++syntheticField);
@@ -2065,10 +1671,17 @@ var EidosRuntimeService = class {
2065
1671
  });
2066
1672
  break;
2067
1673
  case "rename-table":
2068
- case "set-table-settings":
2069
1674
  case "set-table-position":
2070
1675
  if (!tableIds.has(leaf.tableId)) forbid("dependency-blocked", "Table does not exist", { tableId: leaf.tableId });
2071
1676
  break;
1677
+ case "set-table-settings":
1678
+ if (!tableIds.has(leaf.tableId)) forbid("dependency-blocked", "Table does not exist", { tableId: leaf.tableId });
1679
+ else {
1680
+ const contentFieldId = leaf.settings.contentFieldId;
1681
+ proposedContentFields.set(leaf.tableId, contentFieldId === void 0 ? null : String(contentFieldId));
1682
+ if (contentFieldId !== void 0 && typeof contentFieldId !== "string") forbid("dependency-blocked", "Content Field ID must be a string", { tableId: leaf.tableId });
1683
+ }
1684
+ break;
2072
1685
  case "create-field":
2073
1686
  if (!tableIds.has(leaf.tableId)) forbid("dependency-blocked", "Owning Table does not exist", { tableId: leaf.tableId });
2074
1687
  if (leaf.field.kind !== "formula" && leaf.field.kind !== "lookup" && leaf.field.kind !== "relation" && leaf.field.nullable === false && this.core.countRows(leaf.tableId) > 0) forbid("non-nullability-blocked", "A populated Table cannot add a non-null scalar Field", { tableId: leaf.tableId });
@@ -2271,6 +1884,14 @@ var EidosRuntimeService = class {
2271
1884
  }
2272
1885
  }
2273
1886
  }
1887
+ for (const [tableId, contentFieldId] of proposedContentFields) {
1888
+ if (contentFieldId === null) continue;
1889
+ const field = proposedFields.get(contentFieldId);
1890
+ if (!field || field.tableId !== tableId || field.type !== "text" || field.valueKind !== "source" || field.systemRole != null || !field.physicalName) forbid("dependency-blocked", "The Content Field must be an ordinary Text Field in the same Table", {
1891
+ tableId,
1892
+ fieldId: contentFieldId
1893
+ });
1894
+ }
2274
1895
  const orderedDependencies = Array.from(dependencies.values()).sort((left, right) => {
2275
1896
  const order = {
2276
1897
  table: 0,
@@ -2698,7 +2319,7 @@ function fieldDescriptor(field) {
2698
2319
  tableId: field.tableId,
2699
2320
  name: field.name,
2700
2321
  kind: field.type === "created-time" || field.type === "last-edited-time" ? "datetime" : field.type === "row-id" ? "text" : field.type,
2701
- valueType: fieldValueType(field),
2322
+ valueType: eidosFileFieldValueType(field),
2702
2323
  systemRole: field.systemRole ?? null,
2703
2324
  nullable: field.nullable ?? false,
2704
2325
  position: String(field.position ?? 0),
@@ -2707,28 +2328,12 @@ function fieldDescriptor(field) {
2707
2328
  ...definition ? { definition } : {}
2708
2329
  };
2709
2330
  }
2710
- function fieldValueType(field) {
2711
- if (field.systemRole === "row-id" || field.type === "row-id") return "row-id";
2712
- if (field.systemRole === "created-time" || field.systemRole === "updated-time" || field.type === "created-time" || field.type === "last-edited-time") return "datetime";
2713
- if (field.type === "formula") return String(field.property?.displayType ?? "text");
2714
- if (field.type === "lookup") {
2715
- const generated = field.property?.valueType;
2716
- const generatedObject = generated && typeof generated === "object" ? generated : void 0;
2717
- if (typeof generated === "string" || generatedObject?.kind === "list" && typeof generatedObject.element === "string") return generated;
2718
- const display = String(field.property?.displayType ?? "text");
2719
- if (field.property?.aggregate === "values") return {
2720
- kind: "list",
2721
- element: display === "file" ? "file-entry" : display === "relation" ? "row-id" : display === "multi-select" ? "select" : display
2722
- };
2723
- return display;
2724
- }
2725
- return field.type;
2726
- }
2727
2331
  function csvImportFieldType(field) {
2728
2332
  if (field.isRecordLabel) return "record-label";
2729
2333
  return [
2730
2334
  "text",
2731
2335
  "number",
2336
+ "integer",
2732
2337
  "checkbox",
2733
2338
  "date",
2734
2339
  "datetime",
@@ -2843,31 +2448,16 @@ function assertRuntimeRowQuery(fields, query) {
2843
2448
  if (typeof query.search.text !== "string" || new TextEncoder().encode(query.search.text).byteLength > EIDOS_RUNTIME_LIMITS.searchBytesMax || !Array.isArray(query.search.fields) || query.search.fields.length < 1 || query.search.fields.length > EIDOS_RUNTIME_LIMITS.projectionFieldsMax || new Set(query.search.fields).size !== query.search.fields.length) throw runtimeError("invalid-query", "Search request is invalid");
2844
2449
  for (const fieldId of query.search.fields) {
2845
2450
  const field = byId.get(fieldId);
2846
- const type = field ? fieldValueType(field) : void 0;
2847
- if (!field || typeof type !== "string" || ![
2848
- "text",
2849
- "url",
2850
- "select",
2851
- "row-id"
2852
- ].includes(type)) throw runtimeError("invalid-query", "Search Field is not searchable", { fieldId });
2451
+ if (!field || !eidosFileFieldQueryCapabilities(field).searchable) throw runtimeError("invalid-query", "Search Field is not searchable", { fieldId });
2853
2452
  }
2854
2453
  }
2855
2454
  if (query.sort !== void 0) {
2856
2455
  if (!Array.isArray(query.sort) || query.sort.length > EIDOS_RUNTIME_LIMITS.sortFieldsMax || new Set(query.sort.map((sort) => sort.fieldId)).size !== query.sort.length) throw runtimeError("invalid-query", "Sort list is invalid");
2857
2456
  query.sort.forEach((sort, index) => {
2858
2457
  const field = byId.get(sort.fieldId);
2859
- const type = field ? fieldValueType(field) : void 0;
2860
- if (!field || typeof type !== "string" || ![
2861
- "text",
2862
- "number",
2863
- "integer",
2864
- "checkbox",
2865
- "date",
2866
- "datetime",
2867
- "url",
2868
- "select",
2869
- "row-id"
2870
- ].includes(type) || !["asc", "desc"].includes(sort.direction) || sort.nulls !== void 0 && !["first", "last"].includes(sort.nulls) || type === "row-id" && index !== query.sort.length - 1) throw runtimeError("invalid-query", "Sort Field is invalid", { fieldId: sort.fieldId });
2458
+ const type = field ? eidosFileFieldValueType(field) : void 0;
2459
+ const capabilities = type ? eidosFileTypeRefQueryCapabilities(type) : null;
2460
+ if (!field || !capabilities?.sortable || !["asc", "desc"].includes(sort.direction) || sort.nulls !== void 0 && !["first", "last"].includes(sort.nulls) || capabilities.sortPosition === "last" && index !== query.sort.length - 1) throw runtimeError("invalid-query", "Sort Field is invalid", { fieldId: sort.fieldId });
2871
2461
  });
2872
2462
  }
2873
2463
  let nodes = 0;
@@ -2887,7 +2477,7 @@ function assertRuntimeRowQuery(fields, query) {
2887
2477
  if (!("fieldId" in node)) throw runtimeError("invalid-query", "Filter Field is required");
2888
2478
  const field = byId.get(node.fieldId);
2889
2479
  if (!field) throw runtimeError("invalid-query", "Filter Field does not exist", { fieldId: node.fieldId });
2890
- const type = fieldValueType(field);
2480
+ const type = eidosFileFieldValueType(field);
2891
2481
  if (node.op === "is-null" || node.op === "is-not-null") return;
2892
2482
  if (node.op === "relative-date") {
2893
2483
  if (type !== "date" && type !== "datetime") throw runtimeError("invalid-query", "Relative date Filter requires Date or Datetime");
@@ -2931,7 +2521,7 @@ function assertRuntimeRowQuery(fields, query) {
2931
2521
  return;
2932
2522
  }
2933
2523
  if (node.op === "between") {
2934
- if (typeof type !== "string" || !isSortableType(type) || node.lower === null || node.upper === null || !filterValueMatchesType(node.lower, type) || !filterValueMatchesType(node.upper, type)) throw runtimeError("invalid-query", "between operands are invalid");
2524
+ if (!eidosFileTypeRefQueryCapabilities(type).ordered || node.lower === null || node.upper === null || !filterValueMatchesType(node.lower, type) || !filterValueMatchesType(node.upper, type)) throw runtimeError("invalid-query", "between operands are invalid");
2935
2525
  return;
2936
2526
  }
2937
2527
  if (!("value" in node) || node.value === null || !filterValueMatchesType(node.value, type) || [
@@ -2939,7 +2529,7 @@ function assertRuntimeRowQuery(fields, query) {
2939
2529
  "lte",
2940
2530
  "gt",
2941
2531
  "gte"
2942
- ].includes(node.op) && (typeof type !== "string" || !isSortableType(type))) throw runtimeError("invalid-query", "Filter operand type is invalid");
2532
+ ].includes(node.op) && !eidosFileTypeRefQueryCapabilities(type).ordered) throw runtimeError("invalid-query", "Filter operand type is invalid");
2943
2533
  };
2944
2534
  if (query.filter) visit(query.filter, 1);
2945
2535
  }
@@ -2947,19 +2537,6 @@ function filterValueMatchesType(value, type) {
2947
2537
  if (type === "row-id") return typeof value === "string";
2948
2538
  return logicalValueMatchesType(value, type);
2949
2539
  }
2950
- function isSortableType(type) {
2951
- return [
2952
- "text",
2953
- "number",
2954
- "integer",
2955
- "checkbox",
2956
- "date",
2957
- "datetime",
2958
- "url",
2959
- "select",
2960
- "row-id"
2961
- ].includes(type);
2962
- }
2963
2540
  function logicalValueMatchesType(value, type) {
2964
2541
  if (typeof type === "object") return Array.isArray(value) && value.every((entry) => entry !== null && logicalValueMatchesType(entry, type.element));
2965
2542
  switch (type) {
@@ -2993,13 +2570,6 @@ function logicalValueMatchesType(value, type) {
2993
2570
  } catch {
2994
2571
  return false;
2995
2572
  }
2996
- case "json":
2997
- if (typeof value !== "string") return false;
2998
- try {
2999
- return canonicalizeEidosFileJson(JSON.parse(value)) === value;
3000
- } catch {
3001
- return false;
3002
- }
3003
2573
  }
3004
2574
  }
3005
2575
  function runtimeFilterToCompatibility(node) {
@@ -3096,7 +2666,7 @@ function compatibilityFilterToRuntime(group, fields = []) {
3096
2666
  }
3097
2667
  function compatibilityFilterRuleToRuntime(rule, fields) {
3098
2668
  const field = fields.find((candidate) => candidate.id === rule.field);
3099
- const type = field ? fieldValueType(field) : void 0;
2669
+ const type = field ? eidosFileFieldValueType(field) : void 0;
3100
2670
  const list = type !== void 0 && runtimeListElementType(type) !== void 0;
3101
2671
  const values = Array.isArray(rule.value) ? rule.value : [rule.value ?? null];
3102
2672
  const scalarValue = values[0] ?? null;
@@ -3692,7 +3262,7 @@ function aggregateResultsForRows(items, fieldsById, rows) {
3692
3262
  key: item.key,
3693
3263
  value: String(rows.length)
3694
3264
  };
3695
- return aggregateItemResult(item, fieldValueType(fieldsById.get(item.fieldId)), rowIdOrder.map((row) => row.fields[item.fieldId] ?? null));
3265
+ return aggregateItemResult(item, eidosFileFieldValueType(fieldsById.get(item.fieldId)), rowIdOrder.map((row) => row.fields[item.fieldId] ?? null));
3696
3266
  });
3697
3267
  }
3698
3268
  function groupIdentity(values, types) {
@@ -3774,7 +3344,7 @@ function aggregateItemResult(item, valueType, values) {
3774
3344
  truncated: ordered.length > item.limit
3775
3345
  };
3776
3346
  }
3777
- const sortable = typeof valueType === "string" && isSortableType(valueType);
3347
+ const sortable = eidosFileTypeRefQueryCapabilities(valueType).sortable;
3778
3348
  const numeric = valueType === "integer" || valueType === "number";
3779
3349
  if ((item.op === "sum" || item.op === "average") && !numeric) throw runtimeError("invalid-request", `${item.op} requires an Integer or Number Field`, { fieldId: item.fieldId });
3780
3350
  if ((item.op === "min" || item.op === "max") && !sortable) throw runtimeError("invalid-request", `${item.op} requires a sortable scalar Field`, { fieldId: item.fieldId });
@@ -3931,6 +3501,6 @@ function jcsByteLength(value) {
3931
3501
  return new TextEncoder().encode(canonicalizeEidosFileJson(value)).byteLength;
3932
3502
  }
3933
3503
  //#endregion
3934
- export { AdapterTransportRuntimeClient, AdapterTransportServer, ConnectionPortEidosFileConnection, EIDOS_ADAPTER_TRANSPORT_LIMITS, EIDOS_FILE_APPLICATION_ID, EIDOS_FILE_CSV_INFERENCE_ROW_COUNT, EIDOS_FILE_CSV_PREVIEW_ROW_COUNT, EIDOS_FILE_EXTENSION, EIDOS_FILE_FEATURES_TABLE, EIDOS_FILE_FIELDS_TABLE, EIDOS_FILE_FORMAT, EIDOS_FILE_FORMAT_VERSION, EIDOS_FILE_FORMAT_VERSION_TEXT, EIDOS_FILE_FORMULA_FIELDS_TABLE, EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES, EIDOS_FILE_FORMULA_FUNCTION_NAMES, EIDOS_FILE_FORMULA_PROFILE, EIDOS_FILE_FORM_INPUT_FIELD_TYPES, EIDOS_FILE_FORM_VIEW_TYPE, EIDOS_FILE_LOOKUP_FIELDS_TABLE, EIDOS_FILE_META_TABLE, EIDOS_FILE_MIME_TYPE, EIDOS_FILE_RELATION_FIELDS_TABLE, EIDOS_FILE_REQUIRED_TABLES, EIDOS_FILE_SCHEMA_SQL, EIDOS_FILE_SCHEMA_VERSION, EIDOS_FILE_SYSTEM_COLUMNS, EIDOS_FILE_TABLES_TABLE, EIDOS_FILE_VIEWS_TABLE, EIDOS_RUNTIME_LIMITS, EIDOS_SYSTEM_METADATA_TABLES, EidosAdapterError, EidosFileError, EidosFileHandlerRegistry, EidosFileHostError, EidosFileRuntime, EidosFileRuntimeDataSource, EidosFileSession, EidosRuntimeService, EidosUuidV7Generator, MUTABLE_BASE_FIELD_TYPES, MemoryByteSource, Runtime, SQLITE_HEADER, SQLiteWasmConnectionPort, assertEidosFileColumnName, assertEidosFileDisplayName, assertEidosFileFormulaProfile, assertEidosFileMultiSelectHasNoDefaultOption, assertEidosFileRowQuery, assertEidosFileSelectDefaultOption, assertEidosFileSelectOptions, assertEidosFileTableId, assertEidosFileTableName, assertEidosFileUuid, assertEidosFileValues, assertInt64Decimal, assertUnicodeString, cancellationPortFromSignal, canonicalizeEidosFileJson, compileEidosFileFormula, compileEidosFileFormulaFields, compileEidosFileFormulaSource, compileEidosFileRowQuery, configureEidosFileConnection, createEidosFileCsvImportPlan, createEidosFileCsvRowEncoder, createEidosFileIdentifier, createEidosFileUuid, currentEidosFileInstant, decodeEidosFileAttachmentPaths, decodeEidosFileJsonArray, decodeEidosFileMultiSelectValues, decodeEidosFileRelationDisplay, decodeEidosFileRelationIds, decodeEidosFileStringArray, decodeEidosFileValues, eidosFileColumnStatLabel, eidosFileColumnStatTypesForField, eidosFileConversionCanReusePhysicalColumn, eidosFileConversionTargetNullable, eidosFileCsvExportHeader, eidosFileCsvRowToEidosFileRow, eidosFileFieldConversionMayRequireLossyConfirmation, eidosFileFieldDisplayValues, eidosFileFieldStoresJsonArray, eidosFileFormViewFields, eidosFileFormViewProperties, eidosFileFormulaReferences, eidosFileLookupAggregateSupportsTarget, eidosFileLookupDisplayType, eidosFileLookupElementType, eidosFileLookupStorageCodec, eidosFileLookupTargetDisplayType, eidosFileLookupTargetValueType, eidosFileLookupValueType, eidosFileRowQueryAffectedByFieldChanges, eidosFileRowQueryPredicateColumns, eidosFileSnapshot, eidosFileSortExpression, eidosFileTypeHandler, eidosFileUriClass, encodeEidosFileAttachmentPaths, encodeEidosFileCsvRecord, encodeEidosFileJsonArray, encodeEidosFileMultiSelectValues, encodeEidosFileRelationIds, encodeEidosFileValues, hasEidosFileSqliteHeader, importEidosFileCsv, incrementEidosFileRevision, initializeEidosFileSchema, isCanonicalEidosFileDate, isCanonicalEidosFileInstant, isCanonicalEidosFileJson, isEidosFileFilterOperator, isEidosFileFormInputField, isEidosFileReservedTableName, isEidosFileUuid, isMutableEidosFileFieldType, isSafeEidosFileUri, mergeEidosSystemMetadata, nativeToSqlValue, normalizeEidosFileAttachmentPath, normalizeEidosFileDate, normalizeEidosFileFilter, normalizeEidosFileInstant, normalizeEidosFileRowQuery, normalizeEidosFileSorts, parseEidosFileCsvRows, parseEidosFileJson, parseEidosFileSelectDefaultOption, parseEidosFileSelectOptions, parseNonNegativeInt64, planCanonicalFieldConversion, planEidosFileCsvImport, planEidosFileFieldConversion, prepareEidosFileCsvImport, quoteIdentifier, recommendedEidosFileConversionPolicies, removeEidosFileFilterField, rewriteEidosFileFormulaFieldReferences, setEidosFileMetadata, sqlValueToNative, transportFitsHostLimit, validateAdapterCarrier, validateAdapterEnvelope, validateEidosFile };
3504
+ export { AdapterTransportRuntimeClient, AdapterTransportServer, ConnectionPortEidosFileConnection, EIDOS_ADAPTER_TRANSPORT_LIMITS, EIDOS_FILE_APPLICATION_ID, EIDOS_FILE_CSV_INFERENCE_ROW_COUNT, EIDOS_FILE_CSV_PREVIEW_ROW_COUNT, EIDOS_FILE_EXTENSION, EIDOS_FILE_FEATURES_TABLE, EIDOS_FILE_FIELDS_TABLE, EIDOS_FILE_FORMAT, EIDOS_FILE_FORMAT_VERSION, EIDOS_FILE_FORMAT_VERSION_TEXT, EIDOS_FILE_FORMULA_FIELDS_TABLE, EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES, EIDOS_FILE_FORMULA_FUNCTION_NAMES, EIDOS_FILE_FORMULA_PROFILE, EIDOS_FILE_FORM_INPUT_FIELD_TYPES, EIDOS_FILE_FORM_VIEW_TYPE, EIDOS_FILE_LOOKUP_FIELDS_TABLE, EIDOS_FILE_META_TABLE, EIDOS_FILE_MIME_TYPE, EIDOS_FILE_RELATION_FIELDS_TABLE, EIDOS_FILE_REQUIRED_TABLES, EIDOS_FILE_SCHEMA_SQL, EIDOS_FILE_SCHEMA_VERSION, EIDOS_FILE_SYSTEM_COLUMNS, EIDOS_FILE_TABLES_TABLE, EIDOS_FILE_VIEWS_TABLE, EIDOS_RUNTIME_LIMITS, EIDOS_SYSTEM_METADATA_TABLES, EidosAdapterError, EidosFileError, EidosFileHandlerRegistry, EidosFileHostError, EidosFileRuntime, EidosFileRuntimeDataSource, EidosFileSession, EidosRuntimeService, EidosUuidV7Generator, MUTABLE_BASE_FIELD_TYPES, MemoryByteSource, Runtime, SQLITE_HEADER, SQLiteWasmConnectionPort, assertEidosFileColumnName, assertEidosFileDisplayName, assertEidosFileFormulaProfile, assertEidosFileMultiSelectHasNoDefaultOption, assertEidosFileRowQuery, assertEidosFileSelectDefaultOption, assertEidosFileSelectOptions, assertEidosFileTableId, assertEidosFileTableName, assertEidosFileUuid, assertEidosFileValues, assertInt64Decimal, assertUnicodeString, cancellationPortFromSignal, canonicalizeEidosFileJson, compileEidosFileFormula, compileEidosFileFormulaFields, compileEidosFileFormulaSource, compileEidosFileRowQuery, configureEidosFileConnection, configuredTypeRef, createEidosFileCsvImportPlan, createEidosFileCsvRowEncoder, createEidosFileIdentifier, createEidosFileUuid, currentEidosFileInstant, decodeEidosFileAttachmentPaths, decodeEidosFileJsonArray, decodeEidosFileMultiSelectValues, decodeEidosFileRelationDisplay, decodeEidosFileRelationIds, decodeEidosFileStringArray, decodeEidosFileValues, eidosFileColumnStatLabel, eidosFileColumnStatTypesForField, eidosFileConversionCanReusePhysicalColumn, eidosFileConversionTargetNullable, eidosFileCsvExportHeader, eidosFileCsvRowToEidosFileRow, eidosFileFieldConversionMayRequireLossyConfirmation, eidosFileFieldDisplayValues, eidosFileFieldQueryCapabilities, eidosFileFieldStoresJsonArray, eidosFileFieldValueType, eidosFileFormViewFields, eidosFileFormViewProperties, eidosFileFormulaReferences, eidosFileLookupAggregateSupportsTarget, eidosFileLookupDisplayType, eidosFileLookupElementType, eidosFileLookupStorageCodec, eidosFileLookupTargetDisplayType, eidosFileLookupTargetValueType, eidosFileLookupValueType, eidosFileRowQueryAffectedByFieldChanges, eidosFileRowQueryPredicateColumns, eidosFileRowQuerySearchFields, eidosFileSnapshot, eidosFileSortExpression, eidosFileTextMultiSelectChoices, eidosFileTypeHandler, eidosFileTypeRefQueryCapabilities, eidosFileUriClass, encodeEidosFileAttachmentPaths, encodeEidosFileCsvRecord, encodeEidosFileJsonArray, encodeEidosFileMultiSelectValues, encodeEidosFileRelationIds, encodeEidosFileValues, hasEidosFileSqliteHeader, importEidosFileCsv, incrementEidosFileRevision, initializeEidosFileSchema, isCanonicalEidosFileDate, isCanonicalEidosFileInstant, isCanonicalEidosFileJson, isEidosFileFilterOperator, isEidosFileFormInputField, isEidosFileReservedTableName, isEidosFileUriReference, isEidosFileUuid, isMutableEidosFileFieldType, isSafeEidosFileUri, mergeEidosSystemMetadata, nativeToSqlValue, normalizeEidosFileAttachmentPath, normalizeEidosFileDate, normalizeEidosFileFilter, normalizeEidosFileInstant, normalizeEidosFileRowQuery, normalizeEidosFileSorts, parseEidosFileCsvRows, parseEidosFileJson, parseEidosFileSelectDefaultOption, parseEidosFileSelectOptions, parseNonNegativeInt64, planCanonicalFieldConversion, planEidosFileCsvImport, planEidosFileFieldConversion, prepareEidosFileCsvImport, quoteIdentifier, recommendedEidosFileConversionPolicies, removeEidosFileFilterField, rewriteEidosFileFormulaFieldReferences, setEidosFileMetadata, sqlValueToNative, transportFitsHostLimit, validateAdapterCarrier, validateAdapterEnvelope, validateEidosFile };
3935
3505
 
3936
3506
  //# sourceMappingURL=index.mjs.map