@sequenceholdings/orm 2.3.0 → 2.5.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/dist/authoring.cjs +53 -7
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +11 -7
- package/dist/authoring.d.ts +11 -7
- package/dist/authoring.js +53 -7
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs +48 -2
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +72 -72
- package/dist/canonical.d.ts +72 -72
- package/dist/canonical.js +48 -2
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +337 -86
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +337 -86
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +493 -52
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +22 -7
- package/dist/compiler.d.ts +22 -7
- package/dist/compiler.js +493 -53
- package/dist/compiler.js.map +1 -1
- package/dist/{constants-C6EG6Wq7.d.cts → constants-Dou1RkTo.d.cts} +7 -2
- package/dist/{constants-C6EG6Wq7.d.ts → constants-Dou1RkTo.d.ts} +7 -2
- package/dist/dynamic-input.d.cts +1 -1
- package/dist/dynamic-input.d.ts +1 -1
- package/dist/index.cjs +329 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -58
- package/dist/index.d.ts +66 -58
- package/dist/index.js +329 -131
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +50 -3
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +71 -71
- package/dist/ir.d.ts +71 -71
- package/dist/ir.js +50 -3
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +145 -22
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +41 -4
- package/dist/predicate-v2.d.ts +41 -4
- package/dist/predicate-v2.js +145 -22
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +53 -3
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +3 -1
- package/dist/sdl.d.ts +3 -1
- package/dist/sdl.js +53 -3
- package/dist/sdl.js.map +1 -1
- package/package.json +1 -1
- package/dist/{definition-DjfC7Lll.d.cts → definition-B99BsOAO.d.cts} +4 -4
- package/dist/{definition-DjfC7Lll.d.ts → definition-B99BsOAO.d.ts} +4 -4
package/dist/ir.js
CHANGED
|
@@ -201,8 +201,10 @@ function compileCheckExpression(source, columns) {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
// src/constants.ts
|
|
204
|
+
var NAMESPACE_PATTERN = /^(?!(?:events|native_sources)$)[a-z][a-z0-9_]{0,40}$/;
|
|
204
205
|
var COLUMN_IDENTIFIER_PATTERN = /^_?[a-z][a-z0-9_]*$/;
|
|
205
206
|
var MAX_IDENTIFIER_LENGTH = 63;
|
|
207
|
+
var MAX_PERSISTED_READ_ROWS = 50001;
|
|
206
208
|
var QUALIFIED_TABLE_PATTERN = /^[a-z][a-z0-9_]{0,62}\.[a-z][a-z0-9_]{0,62}$/;
|
|
207
209
|
var CELL_PARTS = ["at", "by", "rev", "source", "conflicts"];
|
|
208
210
|
var CELL_PART_SUFFIX = {
|
|
@@ -355,6 +357,7 @@ function validateResolvedView({ view, tables, views = [] }) {
|
|
|
355
357
|
function validateSource({ scope, source, table }) {
|
|
356
358
|
const { fail } = scope;
|
|
357
359
|
if (source.kind === "etl" && table.source === void 0) fail(`etl source '${source.name}' must reference a synced table`);
|
|
360
|
+
if (source.kind === "etl" && table.primaryKey?.length === 0) fail(`etl source '${source.name}' cannot use an unkeyed synced table for resolved row identity`);
|
|
358
361
|
if (source.kind !== "etl" && (table.internal !== true || table.cellMetadata !== true)) {
|
|
359
362
|
fail(`${source.kind} source '${source.name}' must reference an internal table with cell metadata`);
|
|
360
363
|
}
|
|
@@ -646,7 +649,7 @@ var canonicalTableSchema = z.object({
|
|
|
646
649
|
/** Synced/reflected read-only tables (`source: schema.table`) — v1 semantics. */
|
|
647
650
|
source: z.string().regex(QUALIFIED_TABLE_PATTERN).optional(),
|
|
648
651
|
columns: z.array(canonicalColumnSchema).default([]),
|
|
649
|
-
primaryKey: z.array(columnIdentifier).
|
|
652
|
+
primaryKey: z.array(columnIdentifier).max(8).optional(),
|
|
650
653
|
links: z.array(canonicalLinkSchema).default([]),
|
|
651
654
|
indexes: z.array(canonicalIndexSchema).default([]),
|
|
652
655
|
/** Omitted by old definitions, preserving their existing content hashes. */
|
|
@@ -682,6 +685,29 @@ var canonicalTableSchema = z.object({
|
|
|
682
685
|
* data plane. Omitted otherwise.
|
|
683
686
|
*/
|
|
684
687
|
materializes: identifier2.optional()
|
|
688
|
+
}).superRefine((table, ctx) => {
|
|
689
|
+
if (table.primaryKey?.length !== 0) return;
|
|
690
|
+
const fail = (message, path = ["primaryKey"]) => ctx.addIssue({ code: "custom", path, message: `unkeyed table '${table.table}' ${message}` });
|
|
691
|
+
if (table.source === void 0 || table.columns.length === 0) {
|
|
692
|
+
fail("requires a typed synced source");
|
|
693
|
+
}
|
|
694
|
+
if ([table.policies.write, table.policies.insert, table.policies.update].some((policy) => policy !== void 0)) {
|
|
695
|
+
fail("is read-only and cannot declare write policies", ["policies"]);
|
|
696
|
+
}
|
|
697
|
+
const ownedCollections = [table.indexes, table.actions, table.checks, table.foreignKeys, table.cowMutations];
|
|
698
|
+
const ownedMetadata = [table.cellMetadata, table.internal, table.materializes, table.renamedFrom];
|
|
699
|
+
if (ownedCollections.some((items) => items !== void 0 && items.length > 0) || ownedMetadata.some((value) => value !== void 0)) {
|
|
700
|
+
fail("cannot declare owned storage, constraints or identity operations");
|
|
701
|
+
}
|
|
702
|
+
for (const [index, column] of table.columns.entries()) {
|
|
703
|
+
const ownedColumnMetadata = [column.default, column.defaultFn, column.onUpdateFn, column.renamedFrom, column.cast, column.cell];
|
|
704
|
+
if (column.unique || ownedColumnMetadata.some((value) => value !== void 0)) {
|
|
705
|
+
fail("cannot declare column uniqueness, mutation defaults or migration metadata", ["columns", index]);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
for (const [index, link] of table.links.entries()) {
|
|
709
|
+
if (link.enforce || link.kind === "toMany") fail("cannot provide an identity for this link", ["links", index]);
|
|
710
|
+
}
|
|
685
711
|
});
|
|
686
712
|
var MAX_VIEW_QUERY = 1e5;
|
|
687
713
|
var MAX_RESOLVED_VIEW_QUERY = 5e6;
|
|
@@ -738,6 +764,26 @@ var canonicalViewSchema = z.object({
|
|
|
738
764
|
}
|
|
739
765
|
}
|
|
740
766
|
});
|
|
767
|
+
function validateUnkeyedLinkIdentities({ definition, ctx }) {
|
|
768
|
+
const tables = new Map(definition.tables.map((table) => [table.table, table]));
|
|
769
|
+
const relations = [
|
|
770
|
+
...definition.tables.map((table, index) => ({ kind: "tables", index, links: table.links })),
|
|
771
|
+
...(definition.views ?? []).map((view, index) => ({ kind: "views", index, links: view.links }))
|
|
772
|
+
];
|
|
773
|
+
for (const relation of relations) {
|
|
774
|
+
for (const [linkIndex, link] of relation.links.entries()) {
|
|
775
|
+
if (link.kind !== "toOne" || link.namespace !== void 0 && link.namespace !== definition.namespace) continue;
|
|
776
|
+
const target = link.target === void 0 ? void 0 : tables.get(link.target);
|
|
777
|
+
if (target?.source !== void 0 && target.primaryKey?.length === 0) {
|
|
778
|
+
ctx.addIssue({
|
|
779
|
+
code: "custom",
|
|
780
|
+
path: [relation.kind, relation.index, "links", linkIndex],
|
|
781
|
+
message: `link '${link.name}' cannot use unkeyed table '${target.table}' as a to-one identity`
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
741
787
|
var CELL_PART_TYPES = {
|
|
742
788
|
at: "timestamptz",
|
|
743
789
|
by: "text",
|
|
@@ -801,7 +847,7 @@ var exportGateSchema = z.union([z.literal(true), z.object({ capability: z.string
|
|
|
801
847
|
var relationExportSchema = z.object({ read: exportGateSchema, write: exportGateSchema.optional() }).strict();
|
|
802
848
|
var localDefinitionSchema = z.object({
|
|
803
849
|
definition_format: z.literal(CANONICAL_FORMAT),
|
|
804
|
-
namespace: identifier2.max(41),
|
|
850
|
+
namespace: identifier2.max(41).regex(NAMESPACE_PATTERN, "invalid or reserved ORM namespace"),
|
|
805
851
|
description: z.string().max(2e3).optional(),
|
|
806
852
|
enums: z.array(canonicalEnumSchema).default([]),
|
|
807
853
|
tables: z.array(canonicalTableSchema).min(0).max(500),
|
|
@@ -835,6 +881,7 @@ var localDefinitionSchema = z.object({
|
|
|
835
881
|
}
|
|
836
882
|
}
|
|
837
883
|
const fkTables = new Map(definition.tables.map((table) => [table.table, table]));
|
|
884
|
+
validateUnkeyedLinkIdentities({ definition, ctx });
|
|
838
885
|
const relations = /* @__PURE__ */ new Set([...fkTables.keys(), ...(definition.views ?? []).map((view) => view.view)]);
|
|
839
886
|
for (const name of Object.keys(definition.exports ?? {})) {
|
|
840
887
|
if (!relations.has(name)) ctx.addIssue({ code: "custom", path: ["exports", name], message: `export '${name}' is not a local object` });
|
|
@@ -1107,7 +1154,7 @@ var limitIrSchema = z.object({
|
|
|
1107
1154
|
variable: z.string().optional(),
|
|
1108
1155
|
value: z.number().int().positive().optional(),
|
|
1109
1156
|
default: z.number().int().positive(),
|
|
1110
|
-
max: z.number().int().positive()
|
|
1157
|
+
max: z.number().int().positive().max(MAX_PERSISTED_READ_ROWS)
|
|
1111
1158
|
});
|
|
1112
1159
|
var selectionIrSchema = z.lazy(
|
|
1113
1160
|
() => z.object({
|