@sequenceholdings/orm 2.4.0 → 2.6.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/README.md +23 -0
- package/dist/authoring.cjs +53 -7
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +10 -6
- package/dist/authoring.d.ts +10 -6
- 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 +1 -1
- package/dist/canonical.d.ts +1 -1
- package/dist/canonical.js +48 -2
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +260 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +260 -31
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +11 -6
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +38 -31
- package/dist/client.d.ts +38 -31
- package/dist/client.js +11 -7
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +513 -23
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +39 -3
- package/dist/compiler.d.ts +39 -3
- package/dist/compiler.js +510 -24
- 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 +461 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.js +460 -141
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +55 -4
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +1 -1
- package/dist/ir.d.ts +1 -1
- package/dist/ir.js +55 -4
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +55 -4
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +1 -1
- package/dist/predicate-v2.d.ts +1 -1
- package/dist/predicate-v2.js +55 -4
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +60 -4
- 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 +60 -4
- package/dist/sdl.js.map +1 -1
- package/package.json +1 -1
package/dist/predicate-v2.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClaimKey, PredIr } from './ir.cjs';
|
|
2
2
|
import { P as PolicyExpression } from './policy-1iZbGnZZ.cjs';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import './constants-
|
|
4
|
+
import './constants-Dou1RkTo.cjs';
|
|
5
5
|
|
|
6
6
|
declare const POLICY_COMPARE_OPS: readonly ["=", "!=", "<", "<=", ">", ">="];
|
|
7
7
|
type PolicyCompareOp = (typeof POLICY_COMPARE_OPS)[number];
|
package/dist/predicate-v2.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClaimKey, PredIr } from './ir.js';
|
|
2
2
|
import { P as PolicyExpression } from './policy-1iZbGnZZ.js';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import './constants-
|
|
4
|
+
import './constants-Dou1RkTo.js';
|
|
5
5
|
|
|
6
6
|
declare const POLICY_COMPARE_OPS: readonly ["=", "!=", "<", "<=", ">", ">="];
|
|
7
7
|
type PolicyCompareOp = (typeof POLICY_COMPARE_OPS)[number];
|
package/dist/predicate-v2.js
CHANGED
|
@@ -29,9 +29,11 @@ var PolicyCompileError = class extends Error {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// src/constants.ts
|
|
32
|
+
var NAMESPACE_PATTERN = /^(?!(?:events|native_sources)$)[a-z][a-z0-9_]{0,40}$/;
|
|
32
33
|
var COLUMN_IDENTIFIER_PATTERN = /^_?[a-z][a-z0-9_]*$/;
|
|
33
34
|
var MAX_IDENTIFIER_LENGTH = 63;
|
|
34
35
|
var CAPABILITY_KEY_PATTERN = /^(?:org\/|app\/[a-z][a-z0-9-]{0,63}\/)?[a-z0-9-]{1,64}$/;
|
|
36
|
+
var MAX_PERSISTED_READ_ROWS = 50001;
|
|
35
37
|
var QUALIFIED_TABLE_PATTERN = /^[a-z][a-z0-9_]{0,62}\.[a-z][a-z0-9_]{0,62}$/;
|
|
36
38
|
var CELL_PARTS = ["at", "by", "rev", "source", "conflicts"];
|
|
37
39
|
var CELL_PART_SUFFIX = {
|
|
@@ -381,6 +383,7 @@ function validateResolvedView({ view, tables, views = [] }) {
|
|
|
381
383
|
function validateSource({ scope, source, table }) {
|
|
382
384
|
const { fail } = scope;
|
|
383
385
|
if (source.kind === "etl" && table.source === void 0) fail(`etl source '${source.name}' must reference a synced table`);
|
|
386
|
+
if (source.kind === "etl" && table.primaryKey?.length === 0) fail(`etl source '${source.name}' cannot use an unkeyed synced table for resolved row identity`);
|
|
384
387
|
if (source.kind !== "etl" && (table.internal !== true || table.cellMetadata !== true)) {
|
|
385
388
|
fail(`${source.kind} source '${source.name}' must reference an internal table with cell metadata`);
|
|
386
389
|
}
|
|
@@ -672,7 +675,7 @@ var canonicalTableSchema = z.object({
|
|
|
672
675
|
/** Synced/reflected read-only tables (`source: schema.table`) — v1 semantics. */
|
|
673
676
|
source: z.string().regex(QUALIFIED_TABLE_PATTERN).optional(),
|
|
674
677
|
columns: z.array(canonicalColumnSchema).default([]),
|
|
675
|
-
primaryKey: z.array(columnIdentifier).
|
|
678
|
+
primaryKey: z.array(columnIdentifier).max(8).optional(),
|
|
676
679
|
links: z.array(canonicalLinkSchema).default([]),
|
|
677
680
|
indexes: z.array(canonicalIndexSchema).default([]),
|
|
678
681
|
/** Omitted by old definitions, preserving their existing content hashes. */
|
|
@@ -708,6 +711,29 @@ var canonicalTableSchema = z.object({
|
|
|
708
711
|
* data plane. Omitted otherwise.
|
|
709
712
|
*/
|
|
710
713
|
materializes: identifier2.optional()
|
|
714
|
+
}).superRefine((table, ctx) => {
|
|
715
|
+
if (table.primaryKey?.length !== 0) return;
|
|
716
|
+
const fail = (message, path = ["primaryKey"]) => ctx.addIssue({ code: "custom", path, message: `unkeyed table '${table.table}' ${message}` });
|
|
717
|
+
if (table.source === void 0 || table.columns.length === 0) {
|
|
718
|
+
fail("requires a typed synced source");
|
|
719
|
+
}
|
|
720
|
+
if ([table.policies.write, table.policies.insert, table.policies.update].some((policy) => policy !== void 0)) {
|
|
721
|
+
fail("is read-only and cannot declare write policies", ["policies"]);
|
|
722
|
+
}
|
|
723
|
+
const ownedCollections = [table.indexes, table.actions, table.checks, table.foreignKeys, table.cowMutations];
|
|
724
|
+
const ownedMetadata = [table.cellMetadata, table.internal, table.materializes, table.renamedFrom];
|
|
725
|
+
if (ownedCollections.some((items) => items !== void 0 && items.length > 0) || ownedMetadata.some((value) => value !== void 0)) {
|
|
726
|
+
fail("cannot declare owned storage, constraints or identity operations");
|
|
727
|
+
}
|
|
728
|
+
for (const [index, column] of table.columns.entries()) {
|
|
729
|
+
const ownedColumnMetadata = [column.default, column.defaultFn, column.onUpdateFn, column.renamedFrom, column.cast, column.cell];
|
|
730
|
+
if (column.unique || ownedColumnMetadata.some((value) => value !== void 0)) {
|
|
731
|
+
fail("cannot declare column uniqueness, mutation defaults or migration metadata", ["columns", index]);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
for (const [index, link] of table.links.entries()) {
|
|
735
|
+
if (link.enforce || link.kind === "toMany") fail("cannot provide an identity for this link", ["links", index]);
|
|
736
|
+
}
|
|
711
737
|
});
|
|
712
738
|
var MAX_VIEW_QUERY = 1e5;
|
|
713
739
|
var MAX_RESOLVED_VIEW_QUERY = 5e6;
|
|
@@ -764,6 +790,26 @@ var canonicalViewSchema = z.object({
|
|
|
764
790
|
}
|
|
765
791
|
}
|
|
766
792
|
});
|
|
793
|
+
function validateUnkeyedLinkIdentities({ definition, ctx }) {
|
|
794
|
+
const tables = new Map(definition.tables.map((table) => [table.table, table]));
|
|
795
|
+
const relations = [
|
|
796
|
+
...definition.tables.map((table, index) => ({ kind: "tables", index, links: table.links })),
|
|
797
|
+
...(definition.views ?? []).map((view, index) => ({ kind: "views", index, links: view.links }))
|
|
798
|
+
];
|
|
799
|
+
for (const relation of relations) {
|
|
800
|
+
for (const [linkIndex, link] of relation.links.entries()) {
|
|
801
|
+
if (link.kind !== "toOne" || link.namespace !== void 0 && link.namespace !== definition.namespace) continue;
|
|
802
|
+
const target = link.target === void 0 ? void 0 : tables.get(link.target);
|
|
803
|
+
if (target?.source !== void 0 && target.primaryKey?.length === 0) {
|
|
804
|
+
ctx.addIssue({
|
|
805
|
+
code: "custom",
|
|
806
|
+
path: [relation.kind, relation.index, "links", linkIndex],
|
|
807
|
+
message: `link '${link.name}' cannot use unkeyed table '${target.table}' as a to-one identity`
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
767
813
|
var CELL_PART_TYPES = {
|
|
768
814
|
at: "timestamptz",
|
|
769
815
|
by: "text",
|
|
@@ -827,7 +873,7 @@ var exportGateSchema = z.union([z.literal(true), z.object({ capability: z.string
|
|
|
827
873
|
var relationExportSchema = z.object({ read: exportGateSchema, write: exportGateSchema.optional() }).strict();
|
|
828
874
|
var localDefinitionSchema = z.object({
|
|
829
875
|
definition_format: z.literal(CANONICAL_FORMAT),
|
|
830
|
-
namespace: identifier2.max(41),
|
|
876
|
+
namespace: identifier2.max(41).regex(NAMESPACE_PATTERN, "invalid or reserved ORM namespace"),
|
|
831
877
|
description: z.string().max(2e3).optional(),
|
|
832
878
|
enums: z.array(canonicalEnumSchema).default([]),
|
|
833
879
|
tables: z.array(canonicalTableSchema).min(0).max(500),
|
|
@@ -861,6 +907,7 @@ var localDefinitionSchema = z.object({
|
|
|
861
907
|
}
|
|
862
908
|
}
|
|
863
909
|
const fkTables = new Map(definition.tables.map((table) => [table.table, table]));
|
|
910
|
+
validateUnkeyedLinkIdentities({ definition, ctx });
|
|
864
911
|
const relations = /* @__PURE__ */ new Set([...fkTables.keys(), ...(definition.views ?? []).map((view) => view.view)]);
|
|
865
912
|
for (const name of Object.keys(definition.exports ?? {})) {
|
|
866
913
|
if (!relations.has(name)) ctx.addIssue({ code: "custom", path: ["exports", name], message: `export '${name}' is not a local object` });
|
|
@@ -1045,6 +1092,9 @@ localDefinitionSchema.safeExtend({
|
|
|
1045
1092
|
imports: z.array(localDefinitionSchema).max(32).optional()
|
|
1046
1093
|
});
|
|
1047
1094
|
|
|
1095
|
+
// src/client/sql.ts
|
|
1096
|
+
var BUILTIN_SQL_READ_HASH = "sha256:a50c477c952a5e0fe68ed158a4530e4aab573c09bcbb1a8ac454dc88a39a6258";
|
|
1097
|
+
|
|
1048
1098
|
// src/ir/index.ts
|
|
1049
1099
|
var LEGACY_IR_VERSION = 1;
|
|
1050
1100
|
var GUARDED_IR_VERSION = 2;
|
|
@@ -1124,7 +1174,7 @@ var limitIrSchema = z.object({
|
|
|
1124
1174
|
variable: z.string().optional(),
|
|
1125
1175
|
value: z.number().int().positive().optional(),
|
|
1126
1176
|
default: z.number().int().positive(),
|
|
1127
|
-
max: z.number().int().positive()
|
|
1177
|
+
max: z.number().int().positive().max(MAX_PERSISTED_READ_ROWS)
|
|
1128
1178
|
});
|
|
1129
1179
|
var selectionIrSchema = z.lazy(
|
|
1130
1180
|
() => z.object({
|
|
@@ -1369,7 +1419,8 @@ var compiledOperationSchema = z.object({
|
|
|
1369
1419
|
}).superRefine((operation, ctx) => {
|
|
1370
1420
|
if (operation.language === "sql") {
|
|
1371
1421
|
const validPlan = operation.sqlQuery ? !operation.sql && operation.irVersion === RUNTIME_SQL_IR_VERSION : !!operation.sql && operation.irVersion === SQL_IR_VERSION;
|
|
1372
|
-
|
|
1422
|
+
const builtin = operation.name === "BuiltinSqlRead" && operation.opHash === BUILTIN_SQL_READ_HASH && operation.requires === null;
|
|
1423
|
+
if (!validPlan || operation.kind !== "query" || operation.roots.length !== 0 || !builtin && !operation.requires?.capability) {
|
|
1373
1424
|
ctx.addIssue({ code: "custom", message: "SQL operations require a query-only v4 plan or v5 runtime contract, capability, and no GraphQL roots" });
|
|
1374
1425
|
}
|
|
1375
1426
|
} else if (operation.sql || operation.sqlQuery || operation.roots.length === 0) {
|