@eidos.space/eidos-file 2.2.0 → 3.1.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.
- package/FIELD-CONVERSION.md +40 -19
- package/dist/adapter-contract-SrPzXysz.d.mts +281 -0
- package/dist/adapter-contract-SrPzXysz.d.mts.map +1 -0
- package/dist/better-sqlite3.d.mts +2 -2
- package/dist/better-sqlite3.mjs +1 -1
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +2 -2
- package/dist/{csv-BVaUkU1o.mjs → csv-NK8Rti5O.mjs} +38 -7
- package/dist/csv-NK8Rti5O.mjs.map +1 -0
- package/dist/csv.d.mts +1 -1
- package/dist/csv.d.mts.map +1 -1
- package/dist/csv.mjs +1 -1
- package/dist/index.d.mts +57 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +66 -499
- package/dist/index.mjs.map +1 -1
- package/dist/node-sqlite.d.mts +3 -3
- package/dist/node-sqlite.d.mts.map +1 -1
- package/dist/node-sqlite.mjs +10 -4
- package/dist/node-sqlite.mjs.map +1 -1
- package/dist/runtime-CUCgAnbo.d.mts +1682 -0
- package/dist/runtime-CUCgAnbo.d.mts.map +1 -0
- package/dist/{runtime-D9Vp-lxn.mjs → runtime-CrsC-uwG.mjs} +1390 -293
- package/dist/runtime-CrsC-uwG.mjs.map +1 -0
- package/dist/{sqlite-wasm-DzuW0TZZ.mjs → sqlite-wasm-BQqcna0d.mjs} +9 -2
- package/dist/sqlite-wasm-BQqcna0d.mjs.map +1 -0
- package/dist/{system-metadata-merge-DeHwokcY.d.mts → system-metadata-merge-BY7ebqnp.d.mts} +2 -2
- package/dist/{system-metadata-merge-DeHwokcY.d.mts.map → system-metadata-merge-BY7ebqnp.d.mts.map} +1 -1
- package/dist/{system-metadata-merge-DJ9yCprr.mjs → system-metadata-merge-CVa87L1C.mjs} +2 -2
- package/dist/{system-metadata-merge-DJ9yCprr.mjs.map → system-metadata-merge-CVa87L1C.mjs.map} +1 -1
- package/dist/{temporal-CnuhXeP8.d.mts → temporal-BMFnxGcx.d.mts} +6 -3
- package/dist/temporal-BMFnxGcx.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/adapter-contract-CNigdeQ7.d.mts +0 -1137
- package/dist/adapter-contract-CNigdeQ7.d.mts.map +0 -1
- package/dist/csv-BVaUkU1o.mjs.map +0 -1
- package/dist/runtime-BSYpcOBe.d.mts +0 -801
- package/dist/runtime-BSYpcOBe.d.mts.map +0 -1
- package/dist/runtime-D9Vp-lxn.mjs.map +0 -1
- package/dist/sqlite-wasm-DzuW0TZZ.mjs.map +0 -1
- 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-
|
|
3
|
-
import { $ as
|
|
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-
|
|
5
|
-
import { n as mergeEidosSystemMetadata, t as EIDOS_SYSTEM_METADATA_TABLES } from "./system-metadata-merge-
|
|
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-BQqcna0d.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-CrsC-uwG.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-CVa87L1C.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
|
-
"
|
|
425
|
-
"datetime",
|
|
426
|
-
"file",
|
|
13
|
+
"select",
|
|
427
14
|
"multi-select",
|
|
428
15
|
"rating",
|
|
429
|
-
"
|
|
430
|
-
"
|
|
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");
|
|
@@ -1026,7 +618,7 @@ var EidosRuntimeService = class {
|
|
|
1026
618
|
const field = fields.get(fieldId);
|
|
1027
619
|
if (!field) throw runtimeError("not-found", "Mutation Field not found", { fieldId });
|
|
1028
620
|
if (!fieldWritable(field)) throw runtimeError("forbidden", "Mutation Field is read-only", { fieldId });
|
|
1029
|
-
const type =
|
|
621
|
+
const type = eidosFileFieldValueType(field);
|
|
1030
622
|
assertJcsBytes(value, EIDOS_RUNTIME_LIMITS.logicalValueBytesMax, "Logical value");
|
|
1031
623
|
if (value === null) {
|
|
1032
624
|
if (!field.nullable) throw runtimeError("constraint", "Field is not nullable", { fieldId });
|
|
@@ -1039,6 +631,7 @@ var EidosRuntimeService = class {
|
|
|
1039
631
|
if (Array.isArray(value) && value.length > EIDOS_RUNTIME_LIMITS.listElementsMax) throw runtimeError("resource-limit", "List exceeds listElementsMax", { fieldId });
|
|
1040
632
|
if (type === "date" && !isCanonicalEidosFileDate(value)) throw runtimeError("invalid-value", "Date is not canonical", { fieldId });
|
|
1041
633
|
if (type === "datetime" && !isCanonicalEidosFileInstant(value)) throw runtimeError("invalid-value", "Datetime is not canonical", { fieldId });
|
|
634
|
+
if (type === "url" && !isEidosFileUriReference(value)) throw runtimeError("invalid-value", "Invalid URI-reference", { fieldId });
|
|
1042
635
|
if (type === "integer") normalized[fieldId] = parseSignedInt64(value, "Integer value");
|
|
1043
636
|
else normalized[fieldId] = value;
|
|
1044
637
|
}
|
|
@@ -1467,7 +1060,8 @@ var EidosRuntimeService = class {
|
|
|
1467
1060
|
position: String(table.position ?? 0),
|
|
1468
1061
|
settings: objectValue({
|
|
1469
1062
|
...table.icon === null ? {} : { icon: table.icon },
|
|
1470
|
-
...table.description === null ? {} : { description: table.description }
|
|
1063
|
+
...table.description === null ? {} : { description: table.description },
|
|
1064
|
+
...table.contentFieldId === null ? {} : { contentFieldId: table.contentFieldId }
|
|
1471
1065
|
})
|
|
1472
1066
|
};
|
|
1473
1067
|
});
|
|
@@ -1508,7 +1102,7 @@ var EidosRuntimeService = class {
|
|
|
1508
1102
|
return {
|
|
1509
1103
|
fieldId,
|
|
1510
1104
|
name: field.name,
|
|
1511
|
-
valueType:
|
|
1105
|
+
valueType: eidosFileFieldValueType(field),
|
|
1512
1106
|
source: field.type === "formula" ? "formula" : field.type === "lookup" ? "lookup" : field.type === "relation" && relation?.direction === "inverse" ? "inverse-relation" : "stored",
|
|
1513
1107
|
writable: fieldWritable(field)
|
|
1514
1108
|
};
|
|
@@ -1529,15 +1123,22 @@ var EidosRuntimeService = class {
|
|
|
1529
1123
|
if (!field || !definition) return [];
|
|
1530
1124
|
const labelField = this.core.listFields(definition.targetTableId).find((entry) => entry.isRecordLabel);
|
|
1531
1125
|
if (!labelField?.id) return [];
|
|
1126
|
+
const resolved = new Map((row.resolved?.[fieldId] ?? []).map((item) => [item.id, item]));
|
|
1532
1127
|
return [{
|
|
1533
1128
|
column,
|
|
1534
|
-
items: (row.
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1129
|
+
items: (Array.isArray(row.fields[fieldId]) ? row.fields[fieldId].filter((value) => typeof value === "string") : []).map((id) => {
|
|
1130
|
+
const item = resolved.get(id);
|
|
1131
|
+
return item ? {
|
|
1132
|
+
id,
|
|
1133
|
+
state: "resolved",
|
|
1134
|
+
labelFieldId: labelField.id,
|
|
1135
|
+
labelType: eidosFileFieldValueType(labelField),
|
|
1136
|
+
label: item.label
|
|
1137
|
+
} : {
|
|
1138
|
+
id,
|
|
1139
|
+
state: "unresolved"
|
|
1140
|
+
};
|
|
1141
|
+
})
|
|
1541
1142
|
}];
|
|
1542
1143
|
});
|
|
1543
1144
|
if (resolvedRelations.length > 0) projected.resolvedRelations = resolvedRelations;
|
|
@@ -1614,7 +1215,7 @@ var EidosRuntimeService = class {
|
|
|
1614
1215
|
key: item.key,
|
|
1615
1216
|
value: String(rows.length)
|
|
1616
1217
|
};
|
|
1617
|
-
return aggregateItemResult(item,
|
|
1218
|
+
return aggregateItemResult(item, eidosFileFieldValueType(fieldsById.get(item.fieldId)), rows.map((row) => row.fields[item.fieldId] ?? null));
|
|
1618
1219
|
});
|
|
1619
1220
|
const metadata = this.core.info();
|
|
1620
1221
|
return {
|
|
@@ -1638,8 +1239,8 @@ var EidosRuntimeService = class {
|
|
|
1638
1239
|
const fieldsById = new Map(fields.map((field) => [field.id, field]));
|
|
1639
1240
|
const groupTypes = request.groupBy.map((fieldId) => {
|
|
1640
1241
|
const field = fieldsById.get(fieldId);
|
|
1641
|
-
const type = field ?
|
|
1642
|
-
if (!field ||
|
|
1242
|
+
const type = field ? eidosFileFieldValueType(field) : void 0;
|
|
1243
|
+
if (!field || !type || !eidosFileTypeRefQueryCapabilities(type).groupable) throw runtimeError("invalid-query", "Group Field is not groupable", { fieldId });
|
|
1643
1244
|
return type;
|
|
1644
1245
|
});
|
|
1645
1246
|
assertAggregateItems(request.aggregates, fieldsById);
|
|
@@ -1879,6 +1480,7 @@ var EidosRuntimeService = class {
|
|
|
1879
1480
|
property: field.property ? { ...field.property } : null
|
|
1880
1481
|
}]));
|
|
1881
1482
|
const tableNames = new Map(this.core.listTables().map((table) => [table.id, table.name]));
|
|
1483
|
+
const proposedContentFields = new Map(this.core.listTables().map((table) => [table.id, table.contentFieldId ?? null]));
|
|
1882
1484
|
let syntheticField = 0;
|
|
1883
1485
|
let rewrittenFormulaSources = 0;
|
|
1884
1486
|
for (const leaf of leaves) switch (leaf.kind) {
|
|
@@ -1895,6 +1497,7 @@ var EidosRuntimeService = class {
|
|
|
1895
1497
|
case "delete-table":
|
|
1896
1498
|
for (const [id, field] of proposedFields) if (field.tableId === leaf.tableId) proposedFields.delete(id);
|
|
1897
1499
|
tableNames.delete(leaf.tableId);
|
|
1500
|
+
proposedContentFields.delete(leaf.tableId);
|
|
1898
1501
|
break;
|
|
1899
1502
|
case "create-field": {
|
|
1900
1503
|
const candidate = simulatedNewField(leaf.tableId, tableNames.get(leaf.tableId) ?? leaf.tableId, leaf.field, ++syntheticField);
|
|
@@ -2065,10 +1668,17 @@ var EidosRuntimeService = class {
|
|
|
2065
1668
|
});
|
|
2066
1669
|
break;
|
|
2067
1670
|
case "rename-table":
|
|
2068
|
-
case "set-table-settings":
|
|
2069
1671
|
case "set-table-position":
|
|
2070
1672
|
if (!tableIds.has(leaf.tableId)) forbid("dependency-blocked", "Table does not exist", { tableId: leaf.tableId });
|
|
2071
1673
|
break;
|
|
1674
|
+
case "set-table-settings":
|
|
1675
|
+
if (!tableIds.has(leaf.tableId)) forbid("dependency-blocked", "Table does not exist", { tableId: leaf.tableId });
|
|
1676
|
+
else {
|
|
1677
|
+
const contentFieldId = leaf.settings.contentFieldId;
|
|
1678
|
+
proposedContentFields.set(leaf.tableId, contentFieldId === void 0 ? null : String(contentFieldId));
|
|
1679
|
+
if (contentFieldId !== void 0 && typeof contentFieldId !== "string") forbid("dependency-blocked", "Content Field ID must be a string", { tableId: leaf.tableId });
|
|
1680
|
+
}
|
|
1681
|
+
break;
|
|
2072
1682
|
case "create-field":
|
|
2073
1683
|
if (!tableIds.has(leaf.tableId)) forbid("dependency-blocked", "Owning Table does not exist", { tableId: leaf.tableId });
|
|
2074
1684
|
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 +1881,14 @@ var EidosRuntimeService = class {
|
|
|
2271
1881
|
}
|
|
2272
1882
|
}
|
|
2273
1883
|
}
|
|
1884
|
+
for (const [tableId, contentFieldId] of proposedContentFields) {
|
|
1885
|
+
if (contentFieldId === null) continue;
|
|
1886
|
+
const field = proposedFields.get(contentFieldId);
|
|
1887
|
+
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", {
|
|
1888
|
+
tableId,
|
|
1889
|
+
fieldId: contentFieldId
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
2274
1892
|
const orderedDependencies = Array.from(dependencies.values()).sort((left, right) => {
|
|
2275
1893
|
const order = {
|
|
2276
1894
|
table: 0,
|
|
@@ -2698,7 +2316,7 @@ function fieldDescriptor(field) {
|
|
|
2698
2316
|
tableId: field.tableId,
|
|
2699
2317
|
name: field.name,
|
|
2700
2318
|
kind: field.type === "created-time" || field.type === "last-edited-time" ? "datetime" : field.type === "row-id" ? "text" : field.type,
|
|
2701
|
-
valueType:
|
|
2319
|
+
valueType: eidosFileFieldValueType(field),
|
|
2702
2320
|
systemRole: field.systemRole ?? null,
|
|
2703
2321
|
nullable: field.nullable ?? false,
|
|
2704
2322
|
position: String(field.position ?? 0),
|
|
@@ -2707,28 +2325,12 @@ function fieldDescriptor(field) {
|
|
|
2707
2325
|
...definition ? { definition } : {}
|
|
2708
2326
|
};
|
|
2709
2327
|
}
|
|
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
2328
|
function csvImportFieldType(field) {
|
|
2728
2329
|
if (field.isRecordLabel) return "record-label";
|
|
2729
2330
|
return [
|
|
2730
2331
|
"text",
|
|
2731
2332
|
"number",
|
|
2333
|
+
"integer",
|
|
2732
2334
|
"checkbox",
|
|
2733
2335
|
"date",
|
|
2734
2336
|
"datetime",
|
|
@@ -2843,31 +2445,16 @@ function assertRuntimeRowQuery(fields, query) {
|
|
|
2843
2445
|
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
2446
|
for (const fieldId of query.search.fields) {
|
|
2845
2447
|
const field = byId.get(fieldId);
|
|
2846
|
-
|
|
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 });
|
|
2448
|
+
if (!field || !eidosFileFieldQueryCapabilities(field).searchable) throw runtimeError("invalid-query", "Search Field is not searchable", { fieldId });
|
|
2853
2449
|
}
|
|
2854
2450
|
}
|
|
2855
2451
|
if (query.sort !== void 0) {
|
|
2856
2452
|
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
2453
|
query.sort.forEach((sort, index) => {
|
|
2858
2454
|
const field = byId.get(sort.fieldId);
|
|
2859
|
-
const type = field ?
|
|
2860
|
-
|
|
2861
|
-
|
|
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 });
|
|
2455
|
+
const type = field ? eidosFileFieldValueType(field) : void 0;
|
|
2456
|
+
const capabilities = type ? eidosFileTypeRefQueryCapabilities(type) : null;
|
|
2457
|
+
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
2458
|
});
|
|
2872
2459
|
}
|
|
2873
2460
|
let nodes = 0;
|
|
@@ -2887,7 +2474,7 @@ function assertRuntimeRowQuery(fields, query) {
|
|
|
2887
2474
|
if (!("fieldId" in node)) throw runtimeError("invalid-query", "Filter Field is required");
|
|
2888
2475
|
const field = byId.get(node.fieldId);
|
|
2889
2476
|
if (!field) throw runtimeError("invalid-query", "Filter Field does not exist", { fieldId: node.fieldId });
|
|
2890
|
-
const type =
|
|
2477
|
+
const type = eidosFileFieldValueType(field);
|
|
2891
2478
|
if (node.op === "is-null" || node.op === "is-not-null") return;
|
|
2892
2479
|
if (node.op === "relative-date") {
|
|
2893
2480
|
if (type !== "date" && type !== "datetime") throw runtimeError("invalid-query", "Relative date Filter requires Date or Datetime");
|
|
@@ -2931,7 +2518,7 @@ function assertRuntimeRowQuery(fields, query) {
|
|
|
2931
2518
|
return;
|
|
2932
2519
|
}
|
|
2933
2520
|
if (node.op === "between") {
|
|
2934
|
-
if (
|
|
2521
|
+
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
2522
|
return;
|
|
2936
2523
|
}
|
|
2937
2524
|
if (!("value" in node) || node.value === null || !filterValueMatchesType(node.value, type) || [
|
|
@@ -2939,7 +2526,7 @@ function assertRuntimeRowQuery(fields, query) {
|
|
|
2939
2526
|
"lte",
|
|
2940
2527
|
"gt",
|
|
2941
2528
|
"gte"
|
|
2942
|
-
].includes(node.op) &&
|
|
2529
|
+
].includes(node.op) && !eidosFileTypeRefQueryCapabilities(type).ordered) throw runtimeError("invalid-query", "Filter operand type is invalid");
|
|
2943
2530
|
};
|
|
2944
2531
|
if (query.filter) visit(query.filter, 1);
|
|
2945
2532
|
}
|
|
@@ -2947,19 +2534,6 @@ function filterValueMatchesType(value, type) {
|
|
|
2947
2534
|
if (type === "row-id") return typeof value === "string";
|
|
2948
2535
|
return logicalValueMatchesType(value, type);
|
|
2949
2536
|
}
|
|
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
2537
|
function logicalValueMatchesType(value, type) {
|
|
2964
2538
|
if (typeof type === "object") return Array.isArray(value) && value.every((entry) => entry !== null && logicalValueMatchesType(entry, type.element));
|
|
2965
2539
|
switch (type) {
|
|
@@ -2993,13 +2567,6 @@ function logicalValueMatchesType(value, type) {
|
|
|
2993
2567
|
} catch {
|
|
2994
2568
|
return false;
|
|
2995
2569
|
}
|
|
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
2570
|
}
|
|
3004
2571
|
}
|
|
3005
2572
|
function runtimeFilterToCompatibility(node) {
|
|
@@ -3096,7 +2663,7 @@ function compatibilityFilterToRuntime(group, fields = []) {
|
|
|
3096
2663
|
}
|
|
3097
2664
|
function compatibilityFilterRuleToRuntime(rule, fields) {
|
|
3098
2665
|
const field = fields.find((candidate) => candidate.id === rule.field);
|
|
3099
|
-
const type = field ?
|
|
2666
|
+
const type = field ? eidosFileFieldValueType(field) : void 0;
|
|
3100
2667
|
const list = type !== void 0 && runtimeListElementType(type) !== void 0;
|
|
3101
2668
|
const values = Array.isArray(rule.value) ? rule.value : [rule.value ?? null];
|
|
3102
2669
|
const scalarValue = values[0] ?? null;
|
|
@@ -3692,7 +3259,7 @@ function aggregateResultsForRows(items, fieldsById, rows) {
|
|
|
3692
3259
|
key: item.key,
|
|
3693
3260
|
value: String(rows.length)
|
|
3694
3261
|
};
|
|
3695
|
-
return aggregateItemResult(item,
|
|
3262
|
+
return aggregateItemResult(item, eidosFileFieldValueType(fieldsById.get(item.fieldId)), rowIdOrder.map((row) => row.fields[item.fieldId] ?? null));
|
|
3696
3263
|
});
|
|
3697
3264
|
}
|
|
3698
3265
|
function groupIdentity(values, types) {
|
|
@@ -3774,7 +3341,7 @@ function aggregateItemResult(item, valueType, values) {
|
|
|
3774
3341
|
truncated: ordered.length > item.limit
|
|
3775
3342
|
};
|
|
3776
3343
|
}
|
|
3777
|
-
const sortable =
|
|
3344
|
+
const sortable = eidosFileTypeRefQueryCapabilities(valueType).sortable;
|
|
3778
3345
|
const numeric = valueType === "integer" || valueType === "number";
|
|
3779
3346
|
if ((item.op === "sum" || item.op === "average") && !numeric) throw runtimeError("invalid-request", `${item.op} requires an Integer or Number Field`, { fieldId: item.fieldId });
|
|
3780
3347
|
if ((item.op === "min" || item.op === "max") && !sortable) throw runtimeError("invalid-request", `${item.op} requires a sortable scalar Field`, { fieldId: item.fieldId });
|
|
@@ -3931,6 +3498,6 @@ function jcsByteLength(value) {
|
|
|
3931
3498
|
return new TextEncoder().encode(canonicalizeEidosFileJson(value)).byteLength;
|
|
3932
3499
|
}
|
|
3933
3500
|
//#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_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, 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 };
|
|
3501
|
+
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
3502
|
|
|
3936
3503
|
//# sourceMappingURL=index.mjs.map
|