@sequenceholdings/orm 2.7.1 → 2.8.2
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 +18 -4
- package/dist/authoring.cjs +21 -0
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.js +21 -0
- package/dist/authoring.js.map +1 -1
- package/dist/cli.cjs +3461 -3357
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +13 -1
- package/dist/cli.d.ts +13 -1
- package/dist/cli.js +3460 -3358
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +66 -52
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +35 -11
- package/dist/client.d.ts +35 -11
- package/dist/client.js +66 -53
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +844 -15
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +11 -1
- package/dist/compiler.d.ts +11 -1
- package/dist/compiler.js +844 -17
- package/dist/compiler.js.map +1 -1
- package/dist/index.cjs +21 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +8 -20
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +11 -10
- package/dist/sdl.d.ts +11 -10
- package/dist/sdl.js +8 -20
- package/dist/sdl.js.map +1 -1
- package/package.json +2 -1
- package/templates/orm-namespace/graphql/example/queries.ts +52 -5
- package/templates/orm-namespace/schema/tables.ts +5 -2
- package/templates/orm-namespace/sequence.config.ts +6 -4
package/dist/sdl.d.cts
CHANGED
|
@@ -20,6 +20,8 @@ declare class SdlGenerationError extends Error {
|
|
|
20
20
|
constructor(message: string);
|
|
21
21
|
}
|
|
22
22
|
interface GenerateSdlOptions {
|
|
23
|
+
/** Expose keyed synced relations as read roots for synthesized defaults. */
|
|
24
|
+
includeSyncedReads?: boolean;
|
|
23
25
|
/**
|
|
24
26
|
* Server-pinned columns per table (computed by the compiler from write
|
|
25
27
|
* policies — a column referenced via claim comparison, e.g.
|
|
@@ -44,13 +46,14 @@ declare function generateSdl(canonical: CanonicalDefinition, options?: GenerateS
|
|
|
44
46
|
/** Columns a resolved-table mutation may write: authored data columns, never the view's system columns. */
|
|
45
47
|
declare function resolvedWritableColumns(table: CanonicalRelation): CanonicalColumn[];
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
/** Client registry keyed by persistent operation names. Compilation digests stay server-side. */
|
|
50
|
+
|
|
51
|
+
declare const MANIFEST_VERSION: 2;
|
|
48
52
|
declare const manifestRequiresSchema: z.ZodNullable<z.ZodObject<{
|
|
49
53
|
capability: z.ZodOptional<z.ZodString>;
|
|
50
54
|
role: z.ZodOptional<z.ZodString>;
|
|
51
55
|
}, z.core.$strip>>;
|
|
52
56
|
declare const manifestOperationSchema: z.ZodObject<{
|
|
53
|
-
hash: z.ZodString;
|
|
54
57
|
kind: z.ZodEnum<{
|
|
55
58
|
query: "query";
|
|
56
59
|
mutation: "mutation";
|
|
@@ -61,11 +64,8 @@ declare const manifestOperationSchema: z.ZodObject<{
|
|
|
61
64
|
}, z.core.$strip>>;
|
|
62
65
|
}, z.core.$strip>;
|
|
63
66
|
declare const operationsManifestSchema: z.ZodObject<{
|
|
64
|
-
manifestVersion: z.ZodLiteral<1>;
|
|
65
|
-
schemaHash: z.ZodString;
|
|
66
|
-
opsHash: z.ZodString;
|
|
67
|
+
manifestVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
67
68
|
operations: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
68
|
-
hash: z.ZodString;
|
|
69
69
|
kind: z.ZodEnum<{
|
|
70
70
|
query: "query";
|
|
71
71
|
mutation: "mutation";
|
|
@@ -81,8 +81,8 @@ type ManifestOperation = z.infer<typeof manifestOperationSchema>;
|
|
|
81
81
|
interface ManifestOperationInput {
|
|
82
82
|
/** Operation name as authored in the document (the registry identity). */
|
|
83
83
|
name: string;
|
|
84
|
-
/**
|
|
85
|
-
hash
|
|
84
|
+
/** Legacy generator input; ignored in the client registry. */
|
|
85
|
+
hash?: string;
|
|
86
86
|
kind: 'query' | 'mutation';
|
|
87
87
|
/** `@requires` gate; absent/empty normalizes to null. */
|
|
88
88
|
requires?: {
|
|
@@ -90,8 +90,9 @@ interface ManifestOperationInput {
|
|
|
90
90
|
role?: string;
|
|
91
91
|
} | null;
|
|
92
92
|
}
|
|
93
|
-
declare function buildOperationsManifest({
|
|
94
|
-
|
|
93
|
+
declare function buildOperationsManifest({ operations, }: {
|
|
94
|
+
/** Accepted from older generator callers, never emitted. */
|
|
95
|
+
schemaHash?: string;
|
|
95
96
|
operations: ManifestOperationInput[];
|
|
96
97
|
}): OperationsManifest;
|
|
97
98
|
|
package/dist/sdl.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ declare class SdlGenerationError extends Error {
|
|
|
20
20
|
constructor(message: string);
|
|
21
21
|
}
|
|
22
22
|
interface GenerateSdlOptions {
|
|
23
|
+
/** Expose keyed synced relations as read roots for synthesized defaults. */
|
|
24
|
+
includeSyncedReads?: boolean;
|
|
23
25
|
/**
|
|
24
26
|
* Server-pinned columns per table (computed by the compiler from write
|
|
25
27
|
* policies — a column referenced via claim comparison, e.g.
|
|
@@ -44,13 +46,14 @@ declare function generateSdl(canonical: CanonicalDefinition, options?: GenerateS
|
|
|
44
46
|
/** Columns a resolved-table mutation may write: authored data columns, never the view's system columns. */
|
|
45
47
|
declare function resolvedWritableColumns(table: CanonicalRelation): CanonicalColumn[];
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
/** Client registry keyed by persistent operation names. Compilation digests stay server-side. */
|
|
50
|
+
|
|
51
|
+
declare const MANIFEST_VERSION: 2;
|
|
48
52
|
declare const manifestRequiresSchema: z.ZodNullable<z.ZodObject<{
|
|
49
53
|
capability: z.ZodOptional<z.ZodString>;
|
|
50
54
|
role: z.ZodOptional<z.ZodString>;
|
|
51
55
|
}, z.core.$strip>>;
|
|
52
56
|
declare const manifestOperationSchema: z.ZodObject<{
|
|
53
|
-
hash: z.ZodString;
|
|
54
57
|
kind: z.ZodEnum<{
|
|
55
58
|
query: "query";
|
|
56
59
|
mutation: "mutation";
|
|
@@ -61,11 +64,8 @@ declare const manifestOperationSchema: z.ZodObject<{
|
|
|
61
64
|
}, z.core.$strip>>;
|
|
62
65
|
}, z.core.$strip>;
|
|
63
66
|
declare const operationsManifestSchema: z.ZodObject<{
|
|
64
|
-
manifestVersion: z.ZodLiteral<1>;
|
|
65
|
-
schemaHash: z.ZodString;
|
|
66
|
-
opsHash: z.ZodString;
|
|
67
|
+
manifestVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
67
68
|
operations: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
68
|
-
hash: z.ZodString;
|
|
69
69
|
kind: z.ZodEnum<{
|
|
70
70
|
query: "query";
|
|
71
71
|
mutation: "mutation";
|
|
@@ -81,8 +81,8 @@ type ManifestOperation = z.infer<typeof manifestOperationSchema>;
|
|
|
81
81
|
interface ManifestOperationInput {
|
|
82
82
|
/** Operation name as authored in the document (the registry identity). */
|
|
83
83
|
name: string;
|
|
84
|
-
/**
|
|
85
|
-
hash
|
|
84
|
+
/** Legacy generator input; ignored in the client registry. */
|
|
85
|
+
hash?: string;
|
|
86
86
|
kind: 'query' | 'mutation';
|
|
87
87
|
/** `@requires` gate; absent/empty normalizes to null. */
|
|
88
88
|
requires?: {
|
|
@@ -90,8 +90,9 @@ interface ManifestOperationInput {
|
|
|
90
90
|
role?: string;
|
|
91
91
|
} | null;
|
|
92
92
|
}
|
|
93
|
-
declare function buildOperationsManifest({
|
|
94
|
-
|
|
93
|
+
declare function buildOperationsManifest({ operations, }: {
|
|
94
|
+
/** Accepted from older generator callers, never emitted. */
|
|
95
|
+
schemaHash?: string;
|
|
95
96
|
operations: ManifestOperationInput[];
|
|
96
97
|
}): OperationsManifest;
|
|
97
98
|
|
package/dist/sdl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
2
|
+
import 'crypto';
|
|
3
3
|
|
|
4
4
|
// src/canonical/v2.ts
|
|
5
5
|
var quoteIdentifier = (name) => `"${name.replaceAll('"', '""')}"`;
|
|
@@ -1800,7 +1800,7 @@ var PLATFORM_USER_FIELDS = [
|
|
|
1800
1800
|
];
|
|
1801
1801
|
function generateSdl(canonical, options = {}) {
|
|
1802
1802
|
const def = composeNamespace(normalizeCanonical(canonicalDefinitionSchema.parse(canonical))).definition;
|
|
1803
|
-
const exposed = canonicalRelations(def).filter((table) => table.source === void 0 && table.
|
|
1803
|
+
const exposed = canonicalRelations(def).filter((table) => table.internal !== true && (table.source === void 0 || options.includeSyncedReads === true && (table.primaryKey?.length ?? 0) > 0));
|
|
1804
1804
|
const cellsByTable = new Map(exposed.map((table) => [table.table, trackedCells(table)]));
|
|
1805
1805
|
const tables = exposed.map((table) => ({ ...table, columns: table.columns.filter((column) => column.cell === void 0) }));
|
|
1806
1806
|
if (tables.length === 0) {
|
|
@@ -2110,10 +2110,10 @@ function renderResolvedMutationFields(table, names) {
|
|
|
2110
2110
|
return lines;
|
|
2111
2111
|
}
|
|
2112
2112
|
function allowsInsert(table) {
|
|
2113
|
-
return table.policies.write !== void 0 || table.policies.insert !== void 0;
|
|
2113
|
+
return table.source === void 0 && (table.policies.write !== void 0 || table.policies.insert !== void 0);
|
|
2114
2114
|
}
|
|
2115
2115
|
function allowsUpdate(table) {
|
|
2116
|
-
return table.policies.write !== void 0 || table.policies.update !== void 0;
|
|
2116
|
+
return table.source === void 0 && (table.policies.write !== void 0 || table.policies.update !== void 0);
|
|
2117
2117
|
}
|
|
2118
2118
|
function allowsOnConflict(table) {
|
|
2119
2119
|
if (!allowsInsert(table) || !allowsUpdate(table)) return false;
|
|
@@ -2457,29 +2457,23 @@ var CodegenGqlError = class extends Error {
|
|
|
2457
2457
|
};
|
|
2458
2458
|
|
|
2459
2459
|
// src/codegen-gql/manifest.ts
|
|
2460
|
-
var MANIFEST_VERSION =
|
|
2461
|
-
var OP_HASH_RE = /^sha256:[0-9a-f]{64}$/;
|
|
2460
|
+
var MANIFEST_VERSION = 2;
|
|
2462
2461
|
var GRAPHQL_NAME_RE2 = /^[_A-Za-z][_0-9A-Za-z]*$/;
|
|
2463
2462
|
var manifestRequiresSchema = z.object({
|
|
2464
2463
|
capability: z.string().min(1).optional(),
|
|
2465
2464
|
role: z.string().min(1).optional()
|
|
2466
2465
|
}).nullable();
|
|
2467
2466
|
var manifestOperationSchema = z.object({
|
|
2468
|
-
hash: z.string().regex(OP_HASH_RE),
|
|
2469
2467
|
kind: z.enum(["query", "mutation"]),
|
|
2470
2468
|
requires: manifestRequiresSchema
|
|
2471
2469
|
});
|
|
2472
2470
|
var operationsManifestSchema = z.object({
|
|
2473
|
-
manifestVersion: z.literal(MANIFEST_VERSION),
|
|
2474
|
-
schemaHash: z.string().min(1),
|
|
2475
|
-
opsHash: z.string().regex(OP_HASH_RE),
|
|
2471
|
+
manifestVersion: z.union([z.literal(1), z.literal(MANIFEST_VERSION)]),
|
|
2476
2472
|
operations: z.record(z.string().regex(GRAPHQL_NAME_RE2), manifestOperationSchema)
|
|
2477
2473
|
});
|
|
2478
2474
|
function buildOperationsManifest({
|
|
2479
|
-
schemaHash,
|
|
2480
2475
|
operations
|
|
2481
2476
|
}) {
|
|
2482
|
-
if (schemaHash.length === 0) throw new CodegenGqlError("schemaHash must be a non-empty string.");
|
|
2483
2477
|
const sorted = [...operations].sort((a, b) => a.name.localeCompare(b.name));
|
|
2484
2478
|
const seen = /* @__PURE__ */ new Set();
|
|
2485
2479
|
const entries = sorted.map((op) => {
|
|
@@ -2490,20 +2484,14 @@ function buildOperationsManifest({
|
|
|
2490
2484
|
throw new CodegenGqlError(`Duplicate operation name "${op.name}" \u2014 operation names must be unique per namespace.`);
|
|
2491
2485
|
}
|
|
2492
2486
|
seen.add(op.name);
|
|
2493
|
-
|
|
2494
|
-
throw new CodegenGqlError(`Operation "${op.name}" has malformed hash "${op.hash}" (expected sha256:<64 hex>).`);
|
|
2495
|
-
}
|
|
2496
|
-
return { name: op.name, hash: op.hash, kind: op.kind, requires: normalizeRequires(op.requires) };
|
|
2487
|
+
return { name: op.name, kind: op.kind, requires: normalizeRequires(op.requires) };
|
|
2497
2488
|
});
|
|
2498
|
-
const opsHash = `sha256:${createHash("sha256").update(stableJson(entries)).digest("hex")}`;
|
|
2499
2489
|
const operationsRecord = {};
|
|
2500
2490
|
for (const entry of entries) {
|
|
2501
|
-
operationsRecord[entry.name] = {
|
|
2491
|
+
operationsRecord[entry.name] = { kind: entry.kind, requires: entry.requires };
|
|
2502
2492
|
}
|
|
2503
2493
|
return {
|
|
2504
2494
|
manifestVersion: MANIFEST_VERSION,
|
|
2505
|
-
schemaHash,
|
|
2506
|
-
opsHash,
|
|
2507
2495
|
operations: operationsRecord
|
|
2508
2496
|
};
|
|
2509
2497
|
}
|