@eidos.space/eidos-file 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-contract-CPhqAl4b.d.mts → adapter-contract-CkvahNz_.d.mts} +7 -2
- package/dist/adapter-contract-CkvahNz_.d.mts.map +1 -0
- package/dist/better-sqlite3.d.mts +2 -2
- package/dist/better-sqlite3.mjs +2 -2
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +3 -3
- package/dist/{csv-CvzHNNGW.mjs → csv-BVaUkU1o.mjs} +2 -2
- package/dist/{csv-CvzHNNGW.mjs.map → csv-BVaUkU1o.mjs.map} +1 -1
- package/dist/csv.d.mts +1 -1
- package/dist/csv.mjs +1 -1
- package/dist/index.d.mts +17 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +73 -15
- package/dist/index.mjs.map +1 -1
- package/dist/node-sqlite.d.mts +3 -3
- package/dist/node-sqlite.mjs +3 -3
- package/dist/{runtime-CkL1OOJT.d.mts → runtime-DLuj4nKL.d.mts} +14 -5
- package/dist/runtime-DLuj4nKL.d.mts.map +1 -0
- package/dist/{runtime-qbuZMbV4.mjs → runtime-P50mnJpM.mjs} +215 -37
- package/dist/runtime-P50mnJpM.mjs.map +1 -0
- package/dist/{select-options-Dr8XCYOS.mjs → select-options-DSzDn3qm.mjs} +21 -2
- package/dist/{select-options-Dr8XCYOS.mjs.map → select-options-DSzDn3qm.mjs.map} +1 -1
- package/dist/{sqlite-wasm-fT8Z-5Ww.mjs → sqlite-wasm-DBAIvsId.mjs} +3 -3
- package/dist/{sqlite-wasm-fT8Z-5Ww.mjs.map → sqlite-wasm-DBAIvsId.mjs.map} +1 -1
- package/dist/{system-metadata-merge-CjTqAwCi.mjs → system-metadata-merge-1qWkqwQz.mjs} +3 -3
- package/dist/{system-metadata-merge-CjTqAwCi.mjs.map → system-metadata-merge-1qWkqwQz.mjs.map} +1 -1
- package/dist/{system-metadata-merge-BaX38cp-.d.mts → system-metadata-merge-EzBzKRJS.d.mts} +2 -2
- package/dist/{system-metadata-merge-BaX38cp-.d.mts.map → system-metadata-merge-EzBzKRJS.d.mts.map} +1 -1
- package/dist/{temporal-ysCLNSub.d.mts → temporal-QVadI6iZ.d.mts} +3 -3
- package/dist/{temporal-ysCLNSub.d.mts.map → temporal-QVadI6iZ.d.mts.map} +1 -1
- package/package.json +1 -1
- package/dist/adapter-contract-CPhqAl4b.d.mts.map +0 -1
- package/dist/runtime-CkL1OOJT.d.mts.map +0 -1
- package/dist/runtime-qbuZMbV4.mjs.map +0 -1
package/dist/node-sqlite.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as ScalarDefinition, S as RunResult, T as SqlValue, a as ConnectionCapabilities, o as ConnectionPort, s as ConnectionSnapshot, w as SnapshotContext, x as QueryResult } from "./adapter-contract-
|
|
3
|
-
import { c as EidosSystemMergeResult } from "./system-metadata-merge-
|
|
1
|
+
import { Ct as EidosFileValidationResult, Gt as EidosFileRunResult, Kt as EidosFileSqlParams, Ut as EidosFileConnection, a as CreateEidosFileOptions, qt as EidosFileSqlPrimitive, t as EidosFileRuntime } from "./runtime-DLuj4nKL.mjs";
|
|
2
|
+
import { C as ScalarDefinition, S as RunResult, T as SqlValue, a as ConnectionCapabilities, o as ConnectionPort, s as ConnectionSnapshot, w as SnapshotContext, x as QueryResult } from "./adapter-contract-CkvahNz_.mjs";
|
|
3
|
+
import { c as EidosSystemMergeResult } from "./system-metadata-merge-EzBzKRJS.mjs";
|
|
4
4
|
import { DatabaseSync } from "node:sqlite";
|
|
5
5
|
|
|
6
6
|
//#region src/node-sqlite.d.ts
|
package/dist/node-sqlite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { H as EIDOS_FILE_EXTENSION, ct as EidosAdapterError, ft as exactConnectionBindingCount, g as parseNonNegativeInt64, l as initializeEidosFileSchema, lt as assertExactConnectionBindings, m as MemoryByteSource, mt as sqlValueToNative, n as validateEidosFile, pt as nativeToSqlValue, rt as SQLITE_HEADER, t as EidosFileRuntime } from "./runtime-
|
|
3
|
-
import { n as mergeEidosSystemMetadata } from "./system-metadata-merge-
|
|
1
|
+
import { F as EidosFileError } from "./select-options-DSzDn3qm.mjs";
|
|
2
|
+
import { H as EIDOS_FILE_EXTENSION, ct as EidosAdapterError, ft as exactConnectionBindingCount, g as parseNonNegativeInt64, l as initializeEidosFileSchema, lt as assertExactConnectionBindings, m as MemoryByteSource, mt as sqlValueToNative, n as validateEidosFile, pt as nativeToSqlValue, rt as SQLITE_HEADER, t as EidosFileRuntime } from "./runtime-P50mnJpM.mjs";
|
|
3
|
+
import { n as mergeEidosSystemMetadata } from "./system-metadata-merge-1qWkqwQz.mjs";
|
|
4
4
|
import { closeSync, existsSync, openSync, readSync, statSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { DatabaseSync, constants } from "node:sqlite";
|
|
@@ -284,6 +284,8 @@ interface EidosFileFormulaPreviewInput {
|
|
|
284
284
|
columnName: string;
|
|
285
285
|
formula: string;
|
|
286
286
|
displayType: EidosFileFormulaResultType;
|
|
287
|
+
/** Restrict preview samples to these records, preserving UI context. */
|
|
288
|
+
rowIds?: string[];
|
|
287
289
|
}
|
|
288
290
|
interface EidosFileFormulaPreviewDependency {
|
|
289
291
|
name: string;
|
|
@@ -449,13 +451,20 @@ interface EidosFileSort {
|
|
|
449
451
|
direction: EidosFileSortDirection;
|
|
450
452
|
nulls?: "first" | "last";
|
|
451
453
|
}
|
|
452
|
-
type EidosFileFilterOperator = "equals" | "not-equals" | "contains" | "not-contains" | "starts-with" | "ends-with" | "greater-than" | "greater-than-or-equal" | "less-than" | "less-than-or-equal" | "is-empty" | "is-not-empty" | "is-any-of" | "is-all-of" | "is-none-of";
|
|
454
|
+
type EidosFileFilterOperator = "equals" | "not-equals" | "contains" | "not-contains" | "starts-with" | "ends-with" | "greater-than" | "greater-than-or-equal" | "less-than" | "less-than-or-equal" | "is-empty" | "is-not-empty" | "is-any-of" | "is-all-of" | "is-none-of" | "is-between" | "is-relative-to-today";
|
|
453
455
|
type EidosFileFilterValue = string | number | boolean | null;
|
|
456
|
+
type EidosFileRelativeDateDirection = "past" | "next" | "this";
|
|
457
|
+
type EidosFileRelativeDateUnit = "day" | "week" | "month" | "year";
|
|
458
|
+
interface EidosFileRelativeDateValue {
|
|
459
|
+
direction: EidosFileRelativeDateDirection;
|
|
460
|
+
unit: EidosFileRelativeDateUnit;
|
|
461
|
+
}
|
|
462
|
+
type EidosFileFilterRuleValue = EidosFileFilterValue | EidosFileFilterValue[] | EidosFileRelativeDateValue;
|
|
454
463
|
interface EidosFileFilterRule {
|
|
455
464
|
type: "rule";
|
|
456
465
|
field: string;
|
|
457
466
|
operator: EidosFileFilterOperator;
|
|
458
|
-
value?:
|
|
467
|
+
value?: EidosFileFilterRuleValue;
|
|
459
468
|
}
|
|
460
469
|
interface EidosFileFilterGroup {
|
|
461
470
|
type: "group";
|
|
@@ -704,7 +713,7 @@ declare class EidosFileRuntime {
|
|
|
704
713
|
runtimeScanLogicalRows(tableId: string, fieldIds: string[], query: EidosFileRowQuery): EidosFileLogicalRow[];
|
|
705
714
|
/** @internal Builds the keyset boundary used by the exact Runtime service. */
|
|
706
715
|
createRowCursor(tableId: string, query: EidosFileRowQuery, row: EidosFileLogicalRow): string;
|
|
707
|
-
countRows(tableId: string, query?: EidosFileRowQuery): number;
|
|
716
|
+
countRows(tableId: string, query?: EidosFileRowQuery, referenceInstant?: string): number;
|
|
708
717
|
countRowsByField(tableId: string, fieldKey: string, query?: EidosFileRowQuery): EidosFileRowGroupCount[];
|
|
709
718
|
calculateColumnStats(tableId: string, configs: EidosFileColumnStatConfig[], query?: EidosFileRowQuery): EidosFileColumnStatResult[];
|
|
710
719
|
aggregate(tableId: string, configs: EidosFileColumnStatConfig[], query?: EidosFileRowQuery): EidosFileColumnStatResult[];
|
|
@@ -786,5 +795,5 @@ declare class EidosFileRuntime {
|
|
|
786
795
|
};
|
|
787
796
|
}
|
|
788
797
|
//#endregion
|
|
789
|
-
export {
|
|
790
|
-
//# sourceMappingURL=runtime-
|
|
798
|
+
export { EidosFileRow as $, EidosFileFilterRuleValue as A, ByteSource as At, EidosFileLogicalRowDraft as B, RequestContext as Bt, EidosFileFieldInfo as C, EidosFileValidationResult as Ct, EidosFileFilterGroup as D, UpdateEidosFileFieldInput as Dt, EidosFileFileValue as E, ImportEidosFileFieldInput as Et, EidosFileFormulaPreviewInput as F, JsonObject as Ft, EidosFileMetadata as G, EidosFileRunResult as Gt, EidosFileLogicalValue as H, parseNonNegativeInt64 as Ht, EidosFileFormulaPreviewSample as I, JsonValue as It, EidosFileRelationValue as J, EidosFileOptionValueChange as K, EidosFileSqlParams as Kt, EidosFileFormulaProperty as L, MemoryByteSource as Lt, EidosFileFormulaDisplayType as M, CancellationSignal as Mt, EidosFileFormulaPreview as N, ClockPort as Nt, EidosFileFilterOperator as O, UpdateEidosFileTableInput as Ot, EidosFileFormulaPreviewDependency as P, EntropyPort as Pt, EidosFileResolvedRelationValue as Q, EidosFileFormulaResultType as R, OwnedBytes as Rt, EidosFileCsvImportResult as S, EidosFileValidationIssue as St, EidosFileFieldType as T, EidosFileViewInfo as Tt, EidosFileLookupAggregate as U, EidosFileConnection as Ut, EidosFileLogicalRowUpdate as V, cancellationPortFromSignal as Vt, EidosFileLookupProperty as W, EidosFileConnectionCapabilities as Wt, EidosFileRelativeDateUnit as X, EidosFileRelativeDateDirection as Y, EidosFileRelativeDateValue as Z, EidosFileCsvFieldType as _, EidosFileSortDirection as _t, CreateEidosFileOptions as a, EidosFileRowQuery as at, EidosFileCsvImportOptions as b, EidosFileTableInfo as bt, CreateEidosFileTableInput as c, EidosFileRowValue as ct, EidosFileColumnStatResult as d, EidosFileRowsMutationResult as dt, EidosFileRowGroupCount as et, EidosFileColumnStatType as f, EidosFileRowsUndoResult as ft, EidosFileCsvExportResult as g, EidosFileSort as gt, EidosFileCsvExportOptions as h, EidosFileSnapshot as ht, CreateEidosFileLookupFieldInput as i, EidosFileRowPageProjection as it, EidosFileFilterValue as j, CancellationPort as jt, EidosFileFilterRule as k, UpdateEidosFileViewInput as kt, CreateEidosFileViewInput as l, EidosFileRowsDeleteResult as lt, EidosFileCsvExportColumn as m, EidosFileSelectOption as mt, CreateEidosFileFieldInput as n, EidosFileRowPage as nt, CreateEidosFileRelationFieldInput as o, EidosFileRowRange as ot, EidosFileCsvColumnOverride as p, EidosFileSchemaMutation as pt, EidosFileRelationProperty as q, EidosFileSqlPrimitive as qt, CreateEidosFileFormulaFieldInput as r, EidosFileRowPageOptions as rt, CreateEidosFileSourceFieldInput as s, EidosFileRowUpdate as st, EidosFileRuntime as t, EidosFileRowMutationResult as tt, EidosFileColumnStatConfig as u, EidosFileRowsMutation as ut, EidosFileCsvImportColumn as v, EidosFileSourceFieldType as vt, EidosFileFieldPlacement as w, EidosFileValueKind as wt, EidosFileCsvImportPlan as x, EidosFileTableSnapshot as xt, EidosFileCsvImportIssue as y, EidosFileStorageCodec as yt, EidosFileLogicalRow as z, PublicationContext as zt };
|
|
799
|
+
//# sourceMappingURL=runtime-DLuj4nKL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-DLuj4nKL.d.mts","names":[],"sources":["../src/connection.ts","../src/protocol-types.ts","../src/types.ts","../src/runtime.ts"],"mappings":";KAAY,qBAAA,qCAA0D,UAAA;AAAA,KAC1D,kBAAA,YAA8B,qBAAA;AAAA,UAEzB,kBAAA;EACf,OAAA;EACA,eAAA;AAAA;AAAA,UAGe,+BAAA;EAPa;EAS5B,KAAA;EATwC;EAWxC,KAAA;EATe;EAWf,SAAA;;EAEA,SAAA;EAXe;EAaf,eAAA;AAAA;AAAA,UAGe,mBAAA;EAAA,SACN,YAAA,EAAc,+BAAA;EACvB,IAAA,CAAK,GAAA;EACL,KAAA,mBAAwB,GAAA,UAAa,MAAA,GA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EAAO,qBAAA;IAChB,QAAA;IACA,IAAA,EAAM,mBAAA;IACN,OAAA,YFv2JC;IEy2JD,QAAA,GAAW,KAAA;MAAQ,OAAA;MAAiB,KAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as isEidosFileUuid, C as assertEidosFileDisplayName, E as assertEidosFileUuid, F as EidosFileError, M as canonicalizeEidosFileJson, N as isCanonicalEidosFileJson, O as createEidosFileUuid, P as parseEidosFileJson, T as assertEidosFileTableName, c as eidosFileInstantSqlCheck, d as normalizeEidosFileDate, f as normalizeEidosFileInstant, h as decodeEidosFileValues, i as parseEidosFileSelectDefaultOption, j as quoteIdentifier, k as isEidosFileReservedTableName, l as isCanonicalEidosFileDate, n as assertEidosFileSelectDefaultOption, o as currentEidosFileInstant, p as assertEidosFileValues, r as assertEidosFileSelectOptions, s as eidosFileDateSqlCheck, t as assertEidosFileMultiSelectHasNoDefaultOption, u as isCanonicalEidosFileInstant } from "./select-options-DSzDn3qm.mjs";
|
|
2
2
|
//#region src/connection-port.ts
|
|
3
3
|
const INT64_MIN$2 = -9223372036854775808n;
|
|
4
4
|
const INT64_MAX$2 = 9223372036854775807n;
|
|
@@ -1329,7 +1329,9 @@ const FILTER_OPERATORS$1 = new Set([
|
|
|
1329
1329
|
"is-not-empty",
|
|
1330
1330
|
"is-any-of",
|
|
1331
1331
|
"is-all-of",
|
|
1332
|
-
"is-none-of"
|
|
1332
|
+
"is-none-of",
|
|
1333
|
+
"is-between",
|
|
1334
|
+
"is-relative-to-today"
|
|
1333
1335
|
]);
|
|
1334
1336
|
const MAX_QUERY_DEPTH = 8;
|
|
1335
1337
|
const MAX_QUERY_FILTER_NODES = 100;
|
|
@@ -1356,20 +1358,42 @@ function assertEidosFileRowQuery(value) {
|
|
|
1356
1358
|
return;
|
|
1357
1359
|
}
|
|
1358
1360
|
if (filter.type !== "rule" || typeof filter.field !== "string" || !FILTER_OPERATORS$1.has(filter.operator)) throw new EidosFileError("invalid-query", "Invalid filter rule");
|
|
1361
|
+
if (filter.operator === "is-relative-to-today") {
|
|
1362
|
+
if (!isRelativeDateValue(filter.value)) throw new EidosFileError("invalid-query", "Relative date filter value is invalid");
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1359
1365
|
const values = Array.isArray(filter.value) ? filter.value : [filter.value];
|
|
1360
1366
|
if (values.length > 500 || values.some((entry) => entry !== void 0 && entry !== null && typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean")) throw new EidosFileError("query-limit", "Filter values exceed the query limit");
|
|
1367
|
+
if (filter.operator === "is-between" && values.length !== 2) throw new EidosFileError("invalid-query", "Between filter requires exactly two values");
|
|
1361
1368
|
};
|
|
1362
1369
|
if (query.filter !== void 0 && query.filter !== null) visit(query.filter, 0);
|
|
1363
1370
|
}
|
|
1364
1371
|
function filterValue(value) {
|
|
1365
1372
|
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : void 0;
|
|
1366
1373
|
}
|
|
1374
|
+
function isRelativeDateValue(value) {
|
|
1375
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1376
|
+
const candidate = value;
|
|
1377
|
+
return [
|
|
1378
|
+
"past",
|
|
1379
|
+
"next",
|
|
1380
|
+
"this"
|
|
1381
|
+
].includes(String(candidate.direction)) && [
|
|
1382
|
+
"day",
|
|
1383
|
+
"week",
|
|
1384
|
+
"month",
|
|
1385
|
+
"year"
|
|
1386
|
+
].includes(String(candidate.unit));
|
|
1387
|
+
}
|
|
1367
1388
|
function normalizeFilterNode(value, depth) {
|
|
1368
1389
|
if (depth > MAX_QUERY_DEPTH || typeof value !== "object" || value === null) return null;
|
|
1369
1390
|
const candidate = value;
|
|
1370
1391
|
if (candidate.type === "rule") {
|
|
1371
1392
|
if (typeof candidate.field !== "string" || !FILTER_OPERATORS$1.has(candidate.operator)) return null;
|
|
1372
|
-
const values =
|
|
1393
|
+
const values = candidate.operator === "is-relative-to-today" && isRelativeDateValue(candidate.value) ? {
|
|
1394
|
+
direction: candidate.value.direction,
|
|
1395
|
+
unit: candidate.value.unit
|
|
1396
|
+
} : Array.isArray(candidate.value) ? candidate.value.flatMap((entry) => {
|
|
1373
1397
|
const normalized = filterValue(entry);
|
|
1374
1398
|
return normalized === void 0 ? [] : [normalized];
|
|
1375
1399
|
}) : filterValue(candidate.value);
|
|
@@ -1526,6 +1550,65 @@ function sqlFieldValue(field, value) {
|
|
|
1526
1550
|
}
|
|
1527
1551
|
return sqlValue(value);
|
|
1528
1552
|
}
|
|
1553
|
+
function temporalFieldType(field) {
|
|
1554
|
+
const type = (field.type === "formula" || field.type === "lookup") && typeof field.property?.displayType === "string" ? field.property.displayType : field.type;
|
|
1555
|
+
if (type === "date") return "date";
|
|
1556
|
+
if (type === "datetime" || type === "created-time" || type === "last-edited-time") return "datetime";
|
|
1557
|
+
return null;
|
|
1558
|
+
}
|
|
1559
|
+
function shiftUtcMonth(instant, amount) {
|
|
1560
|
+
const result = new Date(instant.getTime());
|
|
1561
|
+
const day = result.getUTCDate();
|
|
1562
|
+
result.setUTCDate(1);
|
|
1563
|
+
result.setUTCMonth(result.getUTCMonth() + amount);
|
|
1564
|
+
const endOfTargetMonth = new Date(Date.UTC(result.getUTCFullYear(), result.getUTCMonth() + 1, 0)).getUTCDate();
|
|
1565
|
+
result.setUTCDate(Math.min(day, endOfTargetMonth));
|
|
1566
|
+
return result;
|
|
1567
|
+
}
|
|
1568
|
+
function shiftUtcYear(instant, amount) {
|
|
1569
|
+
const result = new Date(instant.getTime());
|
|
1570
|
+
const month = result.getUTCMonth();
|
|
1571
|
+
const day = result.getUTCDate();
|
|
1572
|
+
result.setUTCDate(1);
|
|
1573
|
+
result.setUTCFullYear(result.getUTCFullYear() + amount);
|
|
1574
|
+
result.setUTCMonth(month);
|
|
1575
|
+
const endOfTargetMonth = new Date(Date.UTC(result.getUTCFullYear(), month + 1, 0)).getUTCDate();
|
|
1576
|
+
result.setUTCDate(Math.min(day, endOfTargetMonth));
|
|
1577
|
+
return result;
|
|
1578
|
+
}
|
|
1579
|
+
function shiftUtcUnit(instant, unit, amount) {
|
|
1580
|
+
if (unit === "day" || unit === "week") {
|
|
1581
|
+
const days = unit === "day" ? 1 : 7;
|
|
1582
|
+
return new Date(instant.getTime() + amount * days * 864e5);
|
|
1583
|
+
}
|
|
1584
|
+
return unit === "month" ? shiftUtcMonth(instant, amount) : shiftUtcYear(instant, amount);
|
|
1585
|
+
}
|
|
1586
|
+
function utcPeriodStart(instant, unit) {
|
|
1587
|
+
const year = instant.getUTCFullYear();
|
|
1588
|
+
const month = instant.getUTCMonth();
|
|
1589
|
+
const day = instant.getUTCDate();
|
|
1590
|
+
if (unit === "year") return new Date(Date.UTC(year, 0, 1));
|
|
1591
|
+
if (unit === "month") return new Date(Date.UTC(year, month, 1));
|
|
1592
|
+
const start = new Date(Date.UTC(year, month, day));
|
|
1593
|
+
if (unit === "week") {
|
|
1594
|
+
const daysSinceMonday = (start.getUTCDay() + 6) % 7;
|
|
1595
|
+
start.setUTCDate(start.getUTCDate() - daysSinceMonday);
|
|
1596
|
+
}
|
|
1597
|
+
return start;
|
|
1598
|
+
}
|
|
1599
|
+
function relativeTemporalBounds(relative, referenceInstant, type) {
|
|
1600
|
+
const reference = new Date(normalizeEidosFileInstant(referenceInstant, "Relative filter reference"));
|
|
1601
|
+
return (() => {
|
|
1602
|
+
if (relative.direction === "this") {
|
|
1603
|
+
const start = utcPeriodStart(reference, relative.unit);
|
|
1604
|
+
const nextStart = relative.unit === "day" || relative.unit === "week" ? new Date(start.getTime() + (relative.unit === "day" ? 1 : 7) * 864e5) : shiftUtcUnit(start, relative.unit, 1);
|
|
1605
|
+
return [start, /* @__PURE__ */ new Date(nextStart.getTime() - 1)];
|
|
1606
|
+
}
|
|
1607
|
+
const past = relative.direction === "past";
|
|
1608
|
+
const boundary = shiftUtcUnit(reference, relative.unit, past ? -1 : 1);
|
|
1609
|
+
return past ? [boundary, reference] : [reference, boundary];
|
|
1610
|
+
})().map((value) => type === "date" ? value.toISOString().slice(0, 10) : value.toISOString());
|
|
1611
|
+
}
|
|
1529
1612
|
function likeExpression(field, operator, value, params) {
|
|
1530
1613
|
const column = quoteIdentifier(field.tableColumnName);
|
|
1531
1614
|
const escaped = escapeLike(value);
|
|
@@ -1552,13 +1635,28 @@ function likeExpression(field, operator, value, params) {
|
|
|
1552
1635
|
)` : `COALESCE(${caseInsensitiveLike(column, pattern, value, params)}, 0)`;
|
|
1553
1636
|
return operator === "not-contains" ? `NOT (${expression})` : expression;
|
|
1554
1637
|
}
|
|
1555
|
-
function compileRule(rule, fields, params) {
|
|
1638
|
+
function compileRule(rule, fields, params, referenceInstant) {
|
|
1556
1639
|
const field = requireField(fields, rule.field);
|
|
1557
1640
|
const column = quoteIdentifier(field.tableColumnName);
|
|
1558
1641
|
const arrayCodec = field.storageCodec === "json_array" || field.storageCodec === "relation";
|
|
1559
1642
|
const empty = arrayCodec ? `(${column} IS NULL OR (json_valid(${column}) AND json_type(${column}) = 'array' AND json_array_length(${column}) = 0))` : `(${column} IS NULL)`;
|
|
1560
1643
|
if (rule.operator === "is-empty") return empty;
|
|
1561
1644
|
if (rule.operator === "is-not-empty") return `NOT ${empty}`;
|
|
1645
|
+
if (rule.operator === "is-relative-to-today") {
|
|
1646
|
+
const type = temporalFieldType(field);
|
|
1647
|
+
if (!type) throw new EidosFileError("invalid-query", `${field.name} does not support relative date filters`);
|
|
1648
|
+
if (!isRelativeDateValue(rule.value)) throw new EidosFileError("invalid-query", `${field.name} relative date filter is invalid`);
|
|
1649
|
+
const [lower, upper] = relativeTemporalBounds(rule.value, referenceInstant, type);
|
|
1650
|
+
params.push(lower, upper);
|
|
1651
|
+
return `COALESCE(${column} >= ? AND ${column} <= ?, 0)`;
|
|
1652
|
+
}
|
|
1653
|
+
if (rule.operator === "is-between") {
|
|
1654
|
+
if (!Array.isArray(rule.value) || rule.value.length !== 2) throw new EidosFileError("invalid-query", `${field.name} between filter requires two values`);
|
|
1655
|
+
const [lower, upper] = rule.value;
|
|
1656
|
+
if (lower === null || upper === null) throw new EidosFileError("invalid-query", `${field.name} between filter values cannot be null`);
|
|
1657
|
+
params.push(sqlFieldValue(field, lower), sqlFieldValue(field, upper));
|
|
1658
|
+
return `COALESCE(${column} >= ? AND ${column} <= ?, 0)`;
|
|
1659
|
+
}
|
|
1562
1660
|
if (rule.operator === "is-any-of" || rule.operator === "is-all-of" || rule.operator === "is-none-of") {
|
|
1563
1661
|
const values = Array.isArray(rule.value) ? rule.value : [];
|
|
1564
1662
|
if (values.length === 0) return rule.operator === "is-any-of" ? "0" : "1";
|
|
@@ -1585,6 +1683,7 @@ function compileRule(rule, fields, params) {
|
|
|
1585
1683
|
return rule.operator === "is-none-of" ? `NOT (${expression})` : expression;
|
|
1586
1684
|
}
|
|
1587
1685
|
const value = Array.isArray(rule.value) ? rule.value[0] : rule.value;
|
|
1686
|
+
if (value !== null && typeof value === "object") throw new EidosFileError("invalid-query", `${field.name} filter has an invalid structured operand`);
|
|
1588
1687
|
if (rule.operator === "equals" || rule.operator === "not-equals") {
|
|
1589
1688
|
if (arrayCodec && Array.isArray(rule.value)) {
|
|
1590
1689
|
params.push(canonicalizeEidosFileJson(rule.value));
|
|
@@ -1606,8 +1705,8 @@ function compileRule(rule, fields, params) {
|
|
|
1606
1705
|
params.push(sqlFieldValue(field, value));
|
|
1607
1706
|
return `COALESCE(${column} ${comparison} ?, 0)`;
|
|
1608
1707
|
}
|
|
1609
|
-
function compileGroup(group, fields, params) {
|
|
1610
|
-
const children = group.children.map((child) => child.type === "group" ? compileGroup(child, fields, params) : compileRule(child, fields, params));
|
|
1708
|
+
function compileGroup(group, fields, params, referenceInstant) {
|
|
1709
|
+
const children = group.children.map((child) => child.type === "group" ? compileGroup(child, fields, params, referenceInstant) : compileRule(child, fields, params, referenceInstant));
|
|
1611
1710
|
const expression = children.length === 0 ? group.conjunction === "or" ? "0" : "1" : `(${children.join(group.conjunction === "or" ? " OR " : " AND ")})`;
|
|
1612
1711
|
return group.negated ? `NOT (${expression})` : expression;
|
|
1613
1712
|
}
|
|
@@ -1629,7 +1728,7 @@ function compileSorts(sorts, fields) {
|
|
|
1629
1728
|
clauses.push("\"__base_rowid\" ASC");
|
|
1630
1729
|
return `ORDER BY ${clauses.join(", ")}`;
|
|
1631
1730
|
}
|
|
1632
|
-
function compileEidosFileRowQuery(fields, query = {}) {
|
|
1731
|
+
function compileEidosFileRowQuery(fields, query = {}, context = {}) {
|
|
1633
1732
|
query = normalizeEidosFileRowQuery(query);
|
|
1634
1733
|
const byColumn = new Map(fields.map((field) => [field.tableColumnName, field]));
|
|
1635
1734
|
const params = [];
|
|
@@ -1640,7 +1739,7 @@ function compileEidosFileRowQuery(fields, query = {}) {
|
|
|
1640
1739
|
const searchClauses = searchableFields(fields, query.searchFields).map((field) => caseInsensitiveLike(quoteIdentifier(field.tableColumnName), pattern, search, params));
|
|
1641
1740
|
if (searchClauses.length > 0) where.push(`(${searchClauses.join(" OR ")})`);
|
|
1642
1741
|
}
|
|
1643
|
-
if (query.filter) where.push(compileGroup(query.filter, byColumn, params));
|
|
1742
|
+
if (query.filter) where.push(compileGroup(query.filter, byColumn, params, context.referenceInstant ?? currentEidosFileInstant()));
|
|
1644
1743
|
return {
|
|
1645
1744
|
whereSql: where.length > 0 ? `WHERE ${where.join(" AND ")}` : "",
|
|
1646
1745
|
orderSql: compileSorts(query.sorts, byColumn),
|
|
@@ -2629,7 +2728,10 @@ const FILTER_OPERATORS = new Set([
|
|
|
2629
2728
|
"is-empty",
|
|
2630
2729
|
"is-not-empty",
|
|
2631
2730
|
"is-any-of",
|
|
2632
|
-
"is-
|
|
2731
|
+
"is-all-of",
|
|
2732
|
+
"is-none-of",
|
|
2733
|
+
"is-between",
|
|
2734
|
+
"is-relative-to-today"
|
|
2633
2735
|
]);
|
|
2634
2736
|
const LEVELS = {
|
|
2635
2737
|
identity: 0,
|
|
@@ -2847,6 +2949,8 @@ function validateEidosFile(connection, options = {}) {
|
|
|
2847
2949
|
}
|
|
2848
2950
|
if (row.type === "select" || row.type === "multi-select") try {
|
|
2849
2951
|
assertEidosFileSelectOptions(settings);
|
|
2952
|
+
if (row.type === "select") assertEidosFileSelectDefaultOption(settings);
|
|
2953
|
+
else assertEidosFileMultiSelectHasNoDefaultOption(settings);
|
|
2850
2954
|
} catch (error) {
|
|
2851
2955
|
add(errors, "invalid-schema", error instanceof Error ? error.message : "Invalid Select catalog");
|
|
2852
2956
|
}
|
|
@@ -3171,6 +3275,23 @@ function validateEidosFile(connection, options = {}) {
|
|
|
3171
3275
|
if (field.type === "relation" && "value" in node) {
|
|
3172
3276
|
if (!(Array.isArray(node.value) ? node.value : [node.value]).every((entry) => entry === null || isEidosFileUuid(entry))) throw new Error("View Relation filter values must be canonical Row IDs");
|
|
3173
3277
|
}
|
|
3278
|
+
if (node.op === "is-between") {
|
|
3279
|
+
if (!Array.isArray(node.value) || node.value.length !== 2) throw new Error("View between filter must contain exactly two values");
|
|
3280
|
+
}
|
|
3281
|
+
if (node.op === "is-relative-to-today") {
|
|
3282
|
+
if (field.type !== "date" && field.type !== "datetime" && field.type !== "created-time" && field.type !== "last-edited-time") throw new Error("View relative filter requires a Date or Datetime Field");
|
|
3283
|
+
const relative = node.value;
|
|
3284
|
+
if (!relative || typeof relative !== "object" || Array.isArray(relative) || ![
|
|
3285
|
+
"past",
|
|
3286
|
+
"next",
|
|
3287
|
+
"this"
|
|
3288
|
+
].includes(String(relative.direction)) || ![
|
|
3289
|
+
"day",
|
|
3290
|
+
"week",
|
|
3291
|
+
"month",
|
|
3292
|
+
"year"
|
|
3293
|
+
].includes(String(relative.unit))) throw new Error("View relative filter value is invalid");
|
|
3294
|
+
}
|
|
3174
3295
|
};
|
|
3175
3296
|
if ("filter" in query) checkFilter(query.filter);
|
|
3176
3297
|
if ("sort" in query) {
|
|
@@ -3185,7 +3306,11 @@ function validateEidosFile(connection, options = {}) {
|
|
|
3185
3306
|
const value = layout[key];
|
|
3186
3307
|
if (value !== void 0 && (!Array.isArray(value) || !value.every((fieldId) => typeof fieldId === "string" && fieldIds.has(fieldId)))) throw new Error(`View ${key} must contain Field IDs from its Table`);
|
|
3187
3308
|
}
|
|
3188
|
-
for (const key of [
|
|
3309
|
+
for (const key of [
|
|
3310
|
+
"coverField",
|
|
3311
|
+
"groupField",
|
|
3312
|
+
"dateField"
|
|
3313
|
+
]) {
|
|
3189
3314
|
const value = layout[key];
|
|
3190
3315
|
if (value !== void 0 && value !== null && (typeof value !== "string" || !fieldIds.has(value))) throw new Error(`View ${key} must be null or a Field ID from its Table`);
|
|
3191
3316
|
}
|
|
@@ -3387,10 +3512,17 @@ function presentationSettingsObject(source) {
|
|
|
3387
3512
|
}
|
|
3388
3513
|
function presentationSettings(input) {
|
|
3389
3514
|
const property = presentationSettingsObject("property" in input ? input.property : void 0);
|
|
3390
|
-
if (input.type === "select" || input.type === "multi-select")
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3515
|
+
if (input.type === "select" || input.type === "multi-select") {
|
|
3516
|
+
property.options = assertEidosFileSelectOptions("property" in input ? input.property : void 0).map((option) => ({
|
|
3517
|
+
color: option.color,
|
|
3518
|
+
name: option.name
|
|
3519
|
+
}));
|
|
3520
|
+
if (input.type === "select") {
|
|
3521
|
+
const defaultOption = assertEidosFileSelectDefaultOption(property);
|
|
3522
|
+
if (defaultOption === null) delete property.defaultOption;
|
|
3523
|
+
else property.defaultOption = defaultOption;
|
|
3524
|
+
} else assertEidosFileMultiSelectHasNoDefaultOption(property);
|
|
3525
|
+
}
|
|
3394
3526
|
return property;
|
|
3395
3527
|
}
|
|
3396
3528
|
function transformOptionValue(value, fieldId, changes) {
|
|
@@ -4266,12 +4398,34 @@ var EidosFileRuntime = class {
|
|
|
4266
4398
|
}
|
|
4267
4399
|
let settings = field.settings ?? {};
|
|
4268
4400
|
if (changes.property !== void 0) settings = presentationSettingsObject(changes.property);
|
|
4269
|
-
if (field.type === "select" || field.type === "multi-select") settings.options = assertEidosFileSelectOptions(settings).map((option) => ({
|
|
4270
|
-
color: option.color,
|
|
4271
|
-
name: option.name
|
|
4272
|
-
}));
|
|
4273
4401
|
if (changes.optionValueChanges && changes.optionValueChanges.length > 0) {
|
|
4274
4402
|
if (field.type !== "select" && field.type !== "multi-select") throw new EidosFileError("invalid-schema", "Only Select Fields have option values");
|
|
4403
|
+
const replacements = new Map(changes.optionValueChanges.map((change) => [change.from, change.to]));
|
|
4404
|
+
const options = assertEidosFileSelectOptions(settings);
|
|
4405
|
+
const existingNames = new Set(options.map((option) => option.name));
|
|
4406
|
+
settings.options = options.flatMap((option) => {
|
|
4407
|
+
const replacement = replacements.get(option.name);
|
|
4408
|
+
if (replacement === void 0) return [option];
|
|
4409
|
+
if (existingNames.has(replacement)) return [];
|
|
4410
|
+
return [{
|
|
4411
|
+
...option,
|
|
4412
|
+
name: replacement
|
|
4413
|
+
}];
|
|
4414
|
+
});
|
|
4415
|
+
if (field.type === "select" && typeof settings.defaultOption === "string") settings.defaultOption = replacements.get(settings.defaultOption) ?? settings.defaultOption;
|
|
4416
|
+
}
|
|
4417
|
+
if (field.type === "select" || field.type === "multi-select") {
|
|
4418
|
+
settings.options = assertEidosFileSelectOptions(settings).map((option) => ({
|
|
4419
|
+
color: option.color,
|
|
4420
|
+
name: option.name
|
|
4421
|
+
}));
|
|
4422
|
+
if (field.type === "select") {
|
|
4423
|
+
const defaultOption = assertEidosFileSelectDefaultOption(settings);
|
|
4424
|
+
if (defaultOption === null) delete settings.defaultOption;
|
|
4425
|
+
else settings.defaultOption = defaultOption;
|
|
4426
|
+
} else assertEidosFileMultiSelectHasNoDefaultOption(settings);
|
|
4427
|
+
}
|
|
4428
|
+
if (changes.optionValueChanges && changes.optionValueChanges.length > 0) {
|
|
4275
4429
|
const replacements = new Map(changes.optionValueChanges.map((change) => [change.from, change.to]));
|
|
4276
4430
|
for (const [from, to] of replacements) if (field.type === "select") this.connection.run(`UPDATE ${quoteIdentifier(table.physicalName ?? table.rawTableName)}
|
|
4277
4431
|
SET ${quoteIdentifier(field.physicalName)} = ?, "_updated_at" = ?
|
|
@@ -4556,7 +4710,11 @@ var EidosFileRuntime = class {
|
|
|
4556
4710
|
"fieldOrder",
|
|
4557
4711
|
"hiddenFields"
|
|
4558
4712
|
]) if (Array.isArray(layout[key])) layout[key] = layout[key].filter((value) => value !== fieldId);
|
|
4559
|
-
for (const key of [
|
|
4713
|
+
for (const key of [
|
|
4714
|
+
"coverField",
|
|
4715
|
+
"groupField",
|
|
4716
|
+
"dateField"
|
|
4717
|
+
]) if (layout[key] === fieldId) layout[key] = null;
|
|
4560
4718
|
if (layout.fieldWidths && typeof layout.fieldWidths === "object" && !Array.isArray(layout.fieldWidths)) {
|
|
4561
4719
|
const fieldWidths = { ...layout.fieldWidths };
|
|
4562
4720
|
delete fieldWidths[fieldId];
|
|
@@ -4688,6 +4846,7 @@ var EidosFileRuntime = class {
|
|
|
4688
4846
|
...properties,
|
|
4689
4847
|
cardFields: mapFieldList(properties.cardFields),
|
|
4690
4848
|
coverField: mappedLayoutField(properties.coverField),
|
|
4849
|
+
dateField: mappedLayoutField(properties.dateField),
|
|
4691
4850
|
fieldOrder,
|
|
4692
4851
|
fieldWidths,
|
|
4693
4852
|
groupField: mappedLayoutField(properties.groupField),
|
|
@@ -4975,23 +5134,25 @@ var EidosFileRuntime = class {
|
|
|
4975
5134
|
...this.requiredQueryFieldKeys(fields, compatibleQuery)
|
|
4976
5135
|
]) : void 0;
|
|
4977
5136
|
const source = this.logicalSource(tableId, requested, projection?.includeRecordLabel !== false, projection?.includeRelationDisplays !== false);
|
|
4978
|
-
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery);
|
|
4979
5137
|
const querySignature = canonicalizeEidosFileJson(compatibleQuery);
|
|
4980
5138
|
const sorts = uniqueSortFields(source.fields, compatibleQuery.sorts);
|
|
4981
5139
|
const revision = String(this.info().revision ?? 0);
|
|
4982
5140
|
let effectiveOffset = offset;
|
|
4983
5141
|
let cursorWhere = "";
|
|
4984
5142
|
let cursorParams = [];
|
|
5143
|
+
let referenceInstant = this.nowInstant();
|
|
4985
5144
|
if (cursor) try {
|
|
4986
5145
|
const payload = JSON.parse(decodeURIComponent(cursor));
|
|
4987
5146
|
if (payload.version !== 1 || payload.direction !== "forward" || payload.revision !== revision || payload.tableId !== tableId || payload.query !== querySignature || !Array.isArray(payload.values)) throw new Error("cursor binding mismatch");
|
|
4988
5147
|
effectiveOffset = payload.offset;
|
|
5148
|
+
if (payload.referenceInstant !== void 0) referenceInstant = normalizeEidosFileInstant(payload.referenceInstant, "Cursor reference instant");
|
|
4989
5149
|
const keyset = compileKeysetAfter(sorts, payload.values.map(decodeCursorSqlValue), payload.lastId);
|
|
4990
5150
|
cursorWhere = keyset.sql;
|
|
4991
5151
|
cursorParams = keyset.params;
|
|
4992
5152
|
} catch {
|
|
4993
5153
|
throw new EidosFileError("invalid-query", "Invalid or stale Eidos File cursor");
|
|
4994
5154
|
}
|
|
5155
|
+
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant });
|
|
4995
5156
|
const whereSql = cursorWhere ? compiled.whereSql ? `${compiled.whereSql} AND ${cursorWhere}` : `WHERE ${cursorWhere}` : compiled.whereSql;
|
|
4996
5157
|
const rawRows = this.connection.query(`WITH logical AS (${source.sql})
|
|
4997
5158
|
SELECT * FROM logical ${whereSql} ${compiled.orderSql}
|
|
@@ -5022,7 +5183,7 @@ var EidosFileRuntime = class {
|
|
|
5022
5183
|
}
|
|
5023
5184
|
return Object.fromEntries(Object.entries(mapped).filter(([key]) => selected.has(key)));
|
|
5024
5185
|
});
|
|
5025
|
-
const total = totalHint ?? this.countRows(tableId, query);
|
|
5186
|
+
const total = totalHint ?? this.countRows(tableId, query, referenceInstant);
|
|
5026
5187
|
const nextOffset = effectiveOffset + rawRows.length;
|
|
5027
5188
|
const lastRawRow = rawRows.at(-1);
|
|
5028
5189
|
const nextCursor = lastRawRow && rawRows.length === limit && nextOffset < total ? encodeURIComponent(JSON.stringify({
|
|
@@ -5033,7 +5194,8 @@ var EidosFileRuntime = class {
|
|
|
5033
5194
|
offset: nextOffset,
|
|
5034
5195
|
values: sorts.map(({ field }) => encodeCursorSqlValue(cursorSortValue(lastRawRow, field))),
|
|
5035
5196
|
lastId: String(lastRawRow.__base_rowid),
|
|
5036
|
-
direction: "forward"
|
|
5197
|
+
direction: "forward",
|
|
5198
|
+
referenceInstant
|
|
5037
5199
|
})) : void 0;
|
|
5038
5200
|
return {
|
|
5039
5201
|
tableId,
|
|
@@ -5050,7 +5212,7 @@ var EidosFileRuntime = class {
|
|
|
5050
5212
|
const compatibleQuery = this.compatibilityQuery(tableId, query);
|
|
5051
5213
|
const fields = this.listFields(tableId);
|
|
5052
5214
|
const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false);
|
|
5053
|
-
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery);
|
|
5215
|
+
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
|
|
5054
5216
|
const sorts = uniqueSortFields(source.fields, compatibleQuery.sorts);
|
|
5055
5217
|
const targetWhere = compiled.whereSql ? `${compiled.whereSql} AND "__base_rowid" = ?` : "WHERE \"__base_rowid\" = ?";
|
|
5056
5218
|
const target = this.connection.get(`WITH logical AS (${source.sql})
|
|
@@ -5144,7 +5306,7 @@ var EidosFileRuntime = class {
|
|
|
5144
5306
|
runtimeScanLogicalRows(tableId, fieldIds, query) {
|
|
5145
5307
|
const compatibleQuery = this.compatibilityQuery(tableId, query);
|
|
5146
5308
|
const source = this.logicalSource(tableId, fieldIds, false, false);
|
|
5147
|
-
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery);
|
|
5309
|
+
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
|
|
5148
5310
|
const selectedFields = fieldIds.map((fieldId) => this.fieldByKey(tableId, fieldId));
|
|
5149
5311
|
const encodedValues = selectedFields.map((field) => {
|
|
5150
5312
|
const column = quoteIdentifier(field.tableColumnName);
|
|
@@ -5214,14 +5376,15 @@ var EidosFileRuntime = class {
|
|
|
5214
5376
|
offset: 0,
|
|
5215
5377
|
values: values.map((value) => encodeCursorSqlValue(value)),
|
|
5216
5378
|
lastId: row.id,
|
|
5217
|
-
direction: "forward"
|
|
5379
|
+
direction: "forward",
|
|
5380
|
+
referenceInstant: this.nowInstant()
|
|
5218
5381
|
}));
|
|
5219
5382
|
}
|
|
5220
|
-
countRows(tableId, query = {}) {
|
|
5383
|
+
countRows(tableId, query = {}, referenceInstant = this.nowInstant()) {
|
|
5221
5384
|
const compatibleQuery = this.compatibilityQuery(tableId, query);
|
|
5222
5385
|
const fields = this.listFields(tableId);
|
|
5223
5386
|
const source = this.logicalSource(tableId, this.requiredQueryFieldKeys(fields, compatibleQuery), false, false);
|
|
5224
|
-
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery);
|
|
5387
|
+
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant });
|
|
5225
5388
|
return this.connection.get(`WITH logical AS (${source.sql}) SELECT count(*) AS count FROM logical ${compiled.whereSql}`, compiled.params)?.count ?? 0;
|
|
5226
5389
|
}
|
|
5227
5390
|
countRowsByField(tableId, fieldKey, query = {}) {
|
|
@@ -5229,7 +5392,7 @@ var EidosFileRuntime = class {
|
|
|
5229
5392
|
const compatibleQuery = this.compatibilityQuery(tableId, query);
|
|
5230
5393
|
const fields = this.listFields(tableId);
|
|
5231
5394
|
const source = this.logicalSource(tableId, [field.id, ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false);
|
|
5232
|
-
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery);
|
|
5395
|
+
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
|
|
5233
5396
|
const column = quoteIdentifier(field.tableColumnName);
|
|
5234
5397
|
if (field.storageCodec === "json_array" || field.storageCodec === "relation") return this.connection.query(`WITH logical AS (${source.sql}), filtered AS (
|
|
5235
5398
|
SELECT * FROM logical ${compiled.whereSql}
|
|
@@ -5246,7 +5409,7 @@ var EidosFileRuntime = class {
|
|
|
5246
5409
|
const fields = this.listFields(tableId);
|
|
5247
5410
|
configs = normalizeEidosFileColumnStatConfigs(configs, fields);
|
|
5248
5411
|
const source = this.logicalSource(tableId, [...configs.map((config) => config.fieldId), ...this.requiredQueryFieldKeys(fields, compatibleQuery)], false, false);
|
|
5249
|
-
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery);
|
|
5412
|
+
const compiled = compileEidosFileRowQuery(source.fields, compatibleQuery, { referenceInstant: this.nowInstant() });
|
|
5250
5413
|
return configs.map((config) => {
|
|
5251
5414
|
const field = this.fieldByKey(tableId, config.fieldId);
|
|
5252
5415
|
const column = quoteIdentifier(field.tableColumnName);
|
|
@@ -5342,7 +5505,7 @@ var EidosFileRuntime = class {
|
|
|
5342
5505
|
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") return value;
|
|
5343
5506
|
throw new EidosFileError("invalid-value", `Unsupported value for ${field.name}`);
|
|
5344
5507
|
}
|
|
5345
|
-
rowChanges(tableId, row, allowUnresolvedRelations) {
|
|
5508
|
+
rowChanges(tableId, row, allowUnresolvedRelations, applyCreateDefaults = false) {
|
|
5346
5509
|
const changes = [];
|
|
5347
5510
|
for (const [key, value] of Object.entries(row)) {
|
|
5348
5511
|
if (key === "_id" || key === "id" || key.endsWith("__display")) continue;
|
|
@@ -5353,14 +5516,26 @@ var EidosFileRuntime = class {
|
|
|
5353
5516
|
value: this.normalizeStoredValue(field, value, allowUnresolvedRelations)
|
|
5354
5517
|
});
|
|
5355
5518
|
}
|
|
5519
|
+
if (applyCreateDefaults) {
|
|
5520
|
+
const suppliedFieldIds = new Set(changes.map((change) => change.field.id));
|
|
5521
|
+
for (const field of this.listFields(tableId)) {
|
|
5522
|
+
if (field.type !== "select" || !field.id || !field.physicalName || suppliedFieldIds.has(field.id)) continue;
|
|
5523
|
+
const defaultOption = parseEidosFileSelectDefaultOption(field.settings);
|
|
5524
|
+
if (defaultOption === null) continue;
|
|
5525
|
+
changes.push({
|
|
5526
|
+
field,
|
|
5527
|
+
value: this.normalizeStoredValue(field, defaultOption, allowUnresolvedRelations)
|
|
5528
|
+
});
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5356
5531
|
return changes;
|
|
5357
5532
|
}
|
|
5358
|
-
insertRowInTransaction(tableId, row, allowUnresolvedRelations) {
|
|
5533
|
+
insertRowInTransaction(tableId, row, allowUnresolvedRelations, applyCreateDefaults) {
|
|
5359
5534
|
const table = this.getTable(tableId);
|
|
5360
5535
|
const requestedId = row._id ?? row.id;
|
|
5361
5536
|
const rowId = typeof requestedId === "string" ? assertEidosFileUuid(requestedId, "Row ID") : this.allocateId();
|
|
5362
5537
|
const now = this.operationInstant();
|
|
5363
|
-
const changes = this.rowChanges(tableId, row, allowUnresolvedRelations);
|
|
5538
|
+
const changes = this.rowChanges(tableId, row, allowUnresolvedRelations, applyCreateDefaults);
|
|
5364
5539
|
const columns = [
|
|
5365
5540
|
"_id",
|
|
5366
5541
|
"_created_at",
|
|
@@ -5435,11 +5610,11 @@ var EidosFileRuntime = class {
|
|
|
5435
5610
|
return ids;
|
|
5436
5611
|
}
|
|
5437
5612
|
insertRow(tableId, row) {
|
|
5438
|
-
const id = this.mutate(() => this.insertRowInTransaction(tableId, row, true));
|
|
5613
|
+
const id = this.mutate(() => this.insertRowInTransaction(tableId, row, true, true));
|
|
5439
5614
|
return this.getRow(tableId, id);
|
|
5440
5615
|
}
|
|
5441
5616
|
insertImportedRow(tableId, row) {
|
|
5442
|
-
const id = this.mutate(() => this.insertRowInTransaction(tableId, row, true));
|
|
5617
|
+
const id = this.mutate(() => this.insertRowInTransaction(tableId, row, true, false));
|
|
5443
5618
|
return this.getRow(tableId, id);
|
|
5444
5619
|
}
|
|
5445
5620
|
insertImportedRows(tableId, rows) {
|
|
@@ -5752,11 +5927,14 @@ var EidosFileRuntime = class {
|
|
|
5752
5927
|
const sampleExpression = canonicalTemporalProjection(expression, input.displayType);
|
|
5753
5928
|
const table = this.getTable(tableId);
|
|
5754
5929
|
const label = fields.find((field) => field.isRecordLabel);
|
|
5930
|
+
const previewRowIds = input.rowIds === void 0 ? void 0 : Array.from(new Set(input.rowIds.map((rowId) => assertEidosFileUuid(rowId, "Formula preview Row ID")))).slice(0, 100);
|
|
5931
|
+
const rowFilter = previewRowIds === void 0 ? "" : previewRowIds.length === 0 ? "WHERE 0" : `WHERE base."_id" IN (${previewRowIds.map(() => "?").join(", ")})`;
|
|
5755
5932
|
const samples = this.connection.query(`SELECT base."_id" AS row_id,
|
|
5756
5933
|
${this.fieldExpression(label, "base", schema)} AS title,
|
|
5757
5934
|
${sampleExpression} AS value
|
|
5758
5935
|
FROM ${quoteIdentifier(table.physicalName ?? table.rawTableName)} base
|
|
5759
|
-
|
|
5936
|
+
${rowFilter}
|
|
5937
|
+
ORDER BY base."_id" LIMIT ${previewRowIds?.length || 5}`, previewRowIds ?? []);
|
|
5760
5938
|
return {
|
|
5761
5939
|
expression,
|
|
5762
5940
|
dependencies: compiled.dependencyFieldIds.map((id) => {
|
|
@@ -5863,7 +6041,7 @@ var EidosFileRuntime = class {
|
|
|
5863
6041
|
}
|
|
5864
6042
|
}
|
|
5865
6043
|
}
|
|
5866
|
-
const inserted = (input.insert ?? []).map((row) => this.insertRowInTransaction(input.tableId, this.logicalMutationFields(input.tableId, row.fields, row.id), false));
|
|
6044
|
+
const inserted = (input.insert ?? []).map((row) => this.insertRowInTransaction(input.tableId, this.logicalMutationFields(input.tableId, row.fields, row.id), false, true));
|
|
5867
6045
|
const changedUpdates = [];
|
|
5868
6046
|
for (const { rowId, changes } of preparedUpdates) {
|
|
5869
6047
|
if (changes.length === 0) continue;
|
|
@@ -5949,4 +6127,4 @@ function fieldValueTypeForScan(field) {
|
|
|
5949
6127
|
//#endregion
|
|
5950
6128
|
export { EIDOS_FILE_SCHEMA_VERSION as $, eidosFileLookupStorageCodec as A, rewriteEidosFileFormulaFieldReferences as B, normalizeEidosFileRowQuery as C, eidosFileLookupAggregateSupportsTarget as D, eidosFileFieldStoresJsonArray as E, EIDOS_FILE_FORMULA_FUNCTION_NAMES as F, EIDOS_FILE_FORMAT as G, EIDOS_FILE_EXTENSION as H, compileEidosFileFormula as I, EIDOS_FILE_LOOKUP_FIELDS_TABLE as J, EIDOS_FILE_FORMAT_VERSION as K, compileEidosFileFormulaFields as L, eidosFileLookupTargetValueType as M, eidosFileLookupValueType as N, eidosFileLookupDisplayType as O, EIDOS_FILE_FORMULA_FIELD_FUNCTION_NAMES as P, EIDOS_FILE_REQUIRED_TABLES as Q, compileEidosFileFormulaSource as R, normalizeEidosFileFilter as S, removeEidosFileFilterField as T, EIDOS_FILE_FEATURES_TABLE as U, EIDOS_FILE_APPLICATION_ID as V, EIDOS_FILE_FIELDS_TABLE as W, EIDOS_FILE_MIME_TYPE as X, EIDOS_FILE_META_TABLE as Y, EIDOS_FILE_RELATION_FIELDS_TABLE as Z, assertEidosFileRowQuery as _, EIDOS_FILE_FORMAT_VERSION_TEXT as a, eidosFileColumnStatLabel as at, eidosFileRowQueryPredicateColumns as b, incrementEidosFileRevision as c, EidosAdapterError as ct, decodeEidosFileRelationDisplay as d, assertUnicodeString as dt, EIDOS_FILE_SYSTEM_COLUMNS as et, decodeEidosFileRelationIds as f, exactConnectionBindingCount as ft, parseNonNegativeInt64 as g, cancellationPortFromSignal as h, scanStableRowPages as i, hasEidosFileSqliteHeader as it, eidosFileLookupTargetDisplayType as j, eidosFileLookupElementType as k, initializeEidosFileSchema as l, assertExactConnectionBindings as lt, MemoryByteSource as m, sqlValueToNative as mt, validateEidosFile as n, EIDOS_FILE_VIEWS_TABLE as nt, EIDOS_FILE_SCHEMA_SQL as o, eidosFileColumnStatTypesForField as ot, encodeEidosFileRelationIds as p, nativeToSqlValue as pt, EIDOS_FILE_FORMULA_FIELDS_TABLE as q, smallestDependencyCycle as r, SQLITE_HEADER as rt, configureEidosFileConnection as s, ConnectionPortEidosFileConnection as st, EidosFileRuntime as t, EIDOS_FILE_TABLES_TABLE as tt, setEidosFileMetadata as u, assertInt64Decimal as ut, compileEidosFileRowQuery as v, normalizeEidosFileSorts as w, eidosFileSortExpression as x, eidosFileRowQueryAffectedByFieldChanges as y, eidosFileFormulaReferences as z };
|
|
5951
6129
|
|
|
5952
|
-
//# sourceMappingURL=runtime-
|
|
6130
|
+
//# sourceMappingURL=runtime-P50mnJpM.mjs.map
|