@sequenceholdings/orm 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/authoring.cjs +284 -99
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +31 -8
- package/dist/authoring.d.ts +31 -8
- package/dist/authoring.js +282 -100
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs +51 -3
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +838 -12
- package/dist/canonical.d.ts +838 -12
- package/dist/canonical.js +47 -4
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +5838 -4197
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5838 -4197
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +49 -32
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +49 -6
- package/dist/client.d.ts +49 -6
- package/dist/client.js +49 -32
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +1237 -263
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +57 -3
- package/dist/compiler.d.ts +57 -3
- package/dist/compiler.js +1230 -264
- package/dist/compiler.js.map +1 -1
- package/dist/{constants-YoFGjIBM.d.cts → constants-C6EG6Wq7.d.cts} +1 -1
- package/dist/{constants-YoFGjIBM.d.ts → constants-C6EG6Wq7.d.ts} +1 -1
- package/dist/definition-DjfC7Lll.d.cts +91 -0
- package/dist/definition-DjfC7Lll.d.ts +91 -0
- package/dist/dynamic-input.cjs +2 -1
- package/dist/dynamic-input.cjs.map +1 -1
- package/dist/dynamic-input.d.cts +9 -2
- package/dist/dynamic-input.d.ts +9 -2
- package/dist/dynamic-input.js +2 -1
- package/dist/dynamic-input.js.map +1 -1
- package/dist/index.cjs +1094 -321
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +479 -19
- package/dist/index.d.ts +479 -19
- package/dist/index.js +1083 -322
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +84 -10
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +138 -13
- package/dist/ir.d.ts +138 -13
- package/dist/ir.js +81 -11
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +78 -9
- 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 +78 -9
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +156 -21
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +8 -1
- package/dist/sdl.d.ts +8 -1
- package/dist/sdl.js +156 -21
- package/dist/sdl.js.map +1 -1
- package/package.json +5 -4
- package/src/codegen-gql/server-fns.cjs +2 -2
- package/templates/orm-namespace/AGENTS.md +10 -0
- package/templates/orm-namespace/CLAUDE.md +1 -84
- package/templates/orm-namespace/package.json +1 -1
package/dist/canonical.cjs
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
5
|
// src/canonical/v2.ts
|
|
6
|
+
var objectRef = zod.z.string().max(255).regex(/^[a-z][a-z0-9_]{0,40}\/[A-Za-z_][A-Za-z0-9_]*$/, "Expected an explicit namespace/object reference (no wildcards)");
|
|
7
|
+
var functionRef = zod.z.string().max(255).regex(/^[a-z][a-z0-9-]*$/, "Expected a function slug");
|
|
8
|
+
var refs = (schema) => zod.z.array(schema).max(256).refine(
|
|
9
|
+
(values) => new Set(values).size === values.length,
|
|
10
|
+
"Duplicate dependency reference"
|
|
11
|
+
).default([]);
|
|
12
|
+
var ontologyContractSchema = zod.z.strictObject({
|
|
13
|
+
version: zod.z.literal(1),
|
|
14
|
+
read: refs(objectRef),
|
|
15
|
+
write: refs(objectRef),
|
|
16
|
+
produce: refs(objectRef),
|
|
17
|
+
invoke: refs(functionRef)
|
|
18
|
+
}).refine((contract) => JSON.stringify(contract).length <= 4096, "Ontology contract exceeds the 4 KiB signed-context budget");
|
|
19
|
+
function readOntologyContract(manifest) {
|
|
20
|
+
if (!manifest || typeof manifest !== "object" || !("ontology" in manifest) || manifest.ontology === void 0) return void 0;
|
|
21
|
+
return ontologyContractSchema.parse(manifest.ontology);
|
|
22
|
+
}
|
|
6
23
|
var quoteIdentifier = (name) => `"${name.replaceAll('"', '""')}"`;
|
|
7
24
|
var quoteLiteral = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
8
25
|
|
|
@@ -205,6 +222,7 @@ function compileCheckExpression(source, columns) {
|
|
|
205
222
|
// src/constants.ts
|
|
206
223
|
var COLUMN_IDENTIFIER_PATTERN = /^_?[a-z][a-z0-9_]*$/;
|
|
207
224
|
var MAX_IDENTIFIER_LENGTH = 63;
|
|
225
|
+
var QUALIFIED_TABLE_PATTERN = /^[a-z][a-z0-9_]{0,62}\.[a-z][a-z0-9_]{0,62}$/;
|
|
208
226
|
var CELL_PARTS = ["at", "by", "rev", "source", "conflicts"];
|
|
209
227
|
var CELL_PART_SUFFIX = {
|
|
210
228
|
at: "__at",
|
|
@@ -545,6 +563,8 @@ var canonicalLinkSchema = zod.z.object({
|
|
|
545
563
|
kind: zod.z.enum(["toOne", "toMany", "toPlatformUser"]),
|
|
546
564
|
/** Target table name (namespace-local). Absent for toPlatformUser. */
|
|
547
565
|
target: identifier2.optional(),
|
|
566
|
+
/** Owning namespace of an imported target; omitted for local links. */
|
|
567
|
+
namespace: identifier2.max(41).optional(),
|
|
548
568
|
/** FK column on the owning side (toOne/toPlatformUser: on this table; toMany: on the target). */
|
|
549
569
|
on: columnIdentifier,
|
|
550
570
|
/** Referenced column on the target (default: target's PK / platform user `sub`). */
|
|
@@ -803,11 +823,12 @@ var canonicalForeignKeySchema = zod.z.object({
|
|
|
803
823
|
}).strict();
|
|
804
824
|
var canonicalTableSchema = zod.z.object({
|
|
805
825
|
table: identifier2,
|
|
826
|
+
displayName: zod.z.string().trim().min(1).max(120).optional(),
|
|
806
827
|
description: zod.z.string().max(2e3).optional(),
|
|
807
828
|
/** Table-level rename hint (new in v2). */
|
|
808
829
|
renamedFrom: identifier2.optional(),
|
|
809
|
-
/** Synced/reflected read-only tables (`source:
|
|
810
|
-
source: zod.z.string().regex(
|
|
830
|
+
/** Synced/reflected read-only tables (`source: schema.table`) — v1 semantics. */
|
|
831
|
+
source: zod.z.string().regex(QUALIFIED_TABLE_PATTERN).optional(),
|
|
811
832
|
columns: zod.z.array(canonicalColumnSchema).default([]),
|
|
812
833
|
primaryKey: zod.z.array(columnIdentifier).min(1).max(8).optional(),
|
|
813
834
|
links: zod.z.array(canonicalLinkSchema).default([]),
|
|
@@ -960,7 +981,9 @@ function validateCellMetadata(table, index, ctx) {
|
|
|
960
981
|
}
|
|
961
982
|
}
|
|
962
983
|
}
|
|
963
|
-
var
|
|
984
|
+
var exportGateSchema = zod.z.union([zod.z.literal(true), zod.z.object({ capability: zod.z.string().min(1) }).strict(), zod.z.object({ role: zod.z.string().min(1) }).strict()]);
|
|
985
|
+
var relationExportSchema = zod.z.object({ read: exportGateSchema, write: exportGateSchema.optional() }).strict();
|
|
986
|
+
var localDefinitionSchema = zod.z.object({
|
|
964
987
|
definition_format: zod.z.literal(CANONICAL_FORMAT),
|
|
965
988
|
namespace: identifier2.max(41),
|
|
966
989
|
description: zod.z.string().max(2e3).optional(),
|
|
@@ -968,6 +991,8 @@ var canonicalDefinitionSchema = zod.z.object({
|
|
|
968
991
|
tables: zod.z.array(canonicalTableSchema).min(0).max(500),
|
|
969
992
|
/** Optional to preserve byte-identical hashes for pre-view canonical v2 documents. */
|
|
970
993
|
views: zod.z.array(canonicalViewSchema).max(500).optional(),
|
|
994
|
+
/** Target-owned cross-namespace access contract, using existing namespace grants. */
|
|
995
|
+
exports: zod.z.record(identifier2, relationExportSchema).optional(),
|
|
971
996
|
/** Verbatim custom-roles grammar (@sequenceholdings/custom-roles-manifest). */
|
|
972
997
|
capabilities: zod.z.object({
|
|
973
998
|
roles: zod.z.unknown().optional(),
|
|
@@ -994,7 +1019,16 @@ var canonicalDefinitionSchema = zod.z.object({
|
|
|
994
1019
|
}
|
|
995
1020
|
}
|
|
996
1021
|
const fkTables = new Map(definition.tables.map((table) => [table.table, table]));
|
|
1022
|
+
const relations = /* @__PURE__ */ new Set([...fkTables.keys(), ...(definition.views ?? []).map((view) => view.view)]);
|
|
1023
|
+
for (const name of Object.keys(definition.exports ?? {})) {
|
|
1024
|
+
if (!relations.has(name)) ctx.addIssue({ code: "custom", path: ["exports", name], message: `export '${name}' is not a local object` });
|
|
1025
|
+
}
|
|
997
1026
|
for (const [tableIndex, table] of definition.tables.entries()) {
|
|
1027
|
+
for (const [linkIndex, link] of table.links.entries()) {
|
|
1028
|
+
if (link.enforce && link.namespace !== void 0 && link.namespace !== definition.namespace) {
|
|
1029
|
+
ctx.addIssue({ code: "custom", path: ["tables", tableIndex, "links", linkIndex], message: "physical foreign keys require a local target; use an ORM link without enforce" });
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
998
1032
|
const names = /* @__PURE__ */ new Set([
|
|
999
1033
|
...table.primaryKey?.length ? [`${table.table}_pkey`] : [],
|
|
1000
1034
|
...table.columns.filter((column) => column.unique && !(table.primaryKey?.length === 1 && table.primaryKey[0] === column.columnName)).map((column) => `${table.table}_${column.columnName}_unique`),
|
|
@@ -1164,6 +1198,10 @@ var canonicalDefinitionSchema = zod.z.object({
|
|
|
1164
1198
|
};
|
|
1165
1199
|
for (const view of views) visit(view.view, []);
|
|
1166
1200
|
});
|
|
1201
|
+
var canonicalDefinitionSchema = localDefinitionSchema.safeExtend({
|
|
1202
|
+
/** Flattened, pinned snapshots. Imported relations never participate in this namespace's DDL. */
|
|
1203
|
+
imports: zod.z.array(localDefinitionSchema).max(32).optional()
|
|
1204
|
+
});
|
|
1167
1205
|
function canonicalRelations(definition) {
|
|
1168
1206
|
const views = (definition.views ?? []).map((view) => ({
|
|
1169
1207
|
table: view.view,
|
|
@@ -1207,6 +1245,11 @@ function normalizeCanonical(definition) {
|
|
|
1207
1245
|
dependencies: [...view.dependencies].sort()
|
|
1208
1246
|
}));
|
|
1209
1247
|
}
|
|
1248
|
+
if (definition.imports?.length) {
|
|
1249
|
+
normalized.imports = definition.imports.map(normalizeCanonical).sort((a, b) => a.namespace.localeCompare(b.namespace));
|
|
1250
|
+
} else {
|
|
1251
|
+
delete normalized.imports;
|
|
1252
|
+
}
|
|
1210
1253
|
return normalized;
|
|
1211
1254
|
}
|
|
1212
1255
|
|
|
@@ -1239,11 +1282,16 @@ exports.canonicalResolvedSchema = canonicalResolvedSchema;
|
|
|
1239
1282
|
exports.canonicalResolvedSourceSchema = canonicalResolvedSourceSchema;
|
|
1240
1283
|
exports.canonicalTableSchema = canonicalTableSchema;
|
|
1241
1284
|
exports.canonicalViewSchema = canonicalViewSchema;
|
|
1285
|
+
exports.exportGateSchema = exportGateSchema;
|
|
1242
1286
|
exports.isSingleViewQuerySql = isSingleViewQuerySql;
|
|
1287
|
+
exports.localDefinitionSchema = localDefinitionSchema;
|
|
1243
1288
|
exports.normalizeCanonical = normalizeCanonical;
|
|
1289
|
+
exports.ontologyContractSchema = ontologyContractSchema;
|
|
1244
1290
|
exports.parseDurationMs = parseDurationMs;
|
|
1245
1291
|
exports.policyExpressionSchema = policyExpressionSchema;
|
|
1246
1292
|
exports.policyVariantSchema = policyVariantSchema;
|
|
1293
|
+
exports.readOntologyContract = readOntologyContract;
|
|
1294
|
+
exports.relationExportSchema = relationExportSchema;
|
|
1247
1295
|
exports.trackedCellColumns = trackedCellColumns;
|
|
1248
1296
|
exports.validateResolvedView = validateResolvedView;
|
|
1249
1297
|
//# sourceMappingURL=canonical.cjs.map
|