@sequenceholdings/orm 2.11.0 → 2.11.1
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 -4
- package/dist/authoring.d.cts +1 -1
- package/dist/authoring.d.ts +1 -1
- package/dist/canonical.d.cts +43 -43
- package/dist/canonical.d.ts +43 -43
- package/dist/cli.cjs +147 -195
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +148 -196
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +5 -10
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -13
- package/dist/client.d.ts +2 -13
- package/dist/client.js +6 -10
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +14 -67
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +6 -17
- package/dist/compiler.d.ts +6 -17
- package/dist/compiler.js +16 -66
- package/dist/compiler.js.map +1 -1
- package/dist/index.cjs +242 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +541 -36
- package/dist/index.d.ts +541 -36
- package/dist/index.js +237 -189
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +6 -11
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +61 -64
- package/dist/ir.d.ts +61 -64
- package/dist/ir.js +6 -11
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +3 -8
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.js +3 -8
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +4 -11
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +1 -5
- package/dist/sdl.d.ts +1 -5
- package/dist/sdl.js +4 -11
- package/dist/sdl.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen-gql/server-fns.cjs +1 -1
- package/dist/{definition-CevES7lM.d.cts → definition-B99BsOAO.d.cts} +2 -2
- package/dist/{definition-CevES7lM.d.ts → definition-B99BsOAO.d.ts} +2 -2
package/dist/compiler.cjs
CHANGED
|
@@ -2137,9 +2137,6 @@ function normalizeCanonical(definition) {
|
|
|
2137
2137
|
return normalized;
|
|
2138
2138
|
}
|
|
2139
2139
|
|
|
2140
|
-
// src/client/sql.ts
|
|
2141
|
-
var BUILTIN_SQL_READ_HASH = "sha256:a50c477c952a5e0fe68ed158a4530e4aab573c09bcbb1a8ac454dc88a39a6258";
|
|
2142
|
-
|
|
2143
2140
|
// src/ir/index.ts
|
|
2144
2141
|
var IR_VERSION = 6;
|
|
2145
2142
|
var LEGACY_IR_VERSION = 1;
|
|
@@ -2468,8 +2465,7 @@ var compiledOperationSchema = zod.z.object({
|
|
|
2468
2465
|
maxRows: zod.z.number().int().min(1).max(1e4)
|
|
2469
2466
|
}).strict().optional(),
|
|
2470
2467
|
irVersion: irVersionSchema,
|
|
2471
|
-
name: zod.z.string(),
|
|
2472
|
-
opHash: zod.z.string().regex(/^sha256:[0-9a-f]{64}$/),
|
|
2468
|
+
name: zod.z.string().regex(/^[_A-Za-z][_0-9A-Za-z]{0,254}$/),
|
|
2473
2469
|
kind: zod.z.enum(["query", "mutation"]),
|
|
2474
2470
|
requires: zod.z.object({
|
|
2475
2471
|
capability: zod.z.string().optional(),
|
|
@@ -2485,7 +2481,7 @@ var compiledOperationSchema = zod.z.object({
|
|
|
2485
2481
|
}
|
|
2486
2482
|
if (operation.language === "sql") {
|
|
2487
2483
|
const validPlan = operation.sqlQuery ? !operation.sql && operation.irVersion === RUNTIME_SQL_IR_VERSION : !!operation.sql && operation.irVersion === SQL_IR_VERSION;
|
|
2488
|
-
const builtin = operation.name === "BuiltinSqlRead" && operation.
|
|
2484
|
+
const builtin = operation.name === "BuiltinSqlRead" && operation.requires === null;
|
|
2489
2485
|
if (!validPlan || operation.kind !== "query" || operation.roots.length !== 0 || !builtin && !operation.requires?.capability) {
|
|
2490
2486
|
ctx.addIssue({ code: "custom", message: "SQL operations require a query-only v4 plan or v5 runtime contract, capability, and no GraphQL roots" });
|
|
2491
2487
|
}
|
|
@@ -2500,7 +2496,7 @@ var compiledOperationSchema = zod.z.object({
|
|
|
2500
2496
|
}
|
|
2501
2497
|
});
|
|
2502
2498
|
var resolvedSourceIrSchema = zod.z.object({
|
|
2503
|
-
name: zod.z.string(),
|
|
2499
|
+
name: zod.z.string().regex(/^[_A-Za-z][_0-9A-Za-z]{0,254}$/),
|
|
2504
2500
|
kind: zod.z.enum(["manual", "etl", "prefetch"]),
|
|
2505
2501
|
/** Logical table key of the backing relation. */
|
|
2506
2502
|
table: zod.z.string(),
|
|
@@ -2614,7 +2610,6 @@ var compiledArtifactSchema = zod.z.object({
|
|
|
2614
2610
|
ownSchemaHash: zod.z.string().optional(),
|
|
2615
2611
|
dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
2616
2612
|
readPolicies: zod.z.record(zod.z.string(), predIrSchema).optional(),
|
|
2617
|
-
opsHash: zod.z.string(),
|
|
2618
2613
|
/** Apply-observed synced objects without a serving backing; not part of the authored schema hash. */
|
|
2619
2614
|
unbackedTables: zod.z.array(zod.z.string()).optional(),
|
|
2620
2615
|
tables: zod.z.record(zod.z.string(), tableMetaIrSchema),
|
|
@@ -4319,24 +4314,6 @@ function flattenOperation({
|
|
|
4319
4314
|
}) {
|
|
4320
4315
|
return { ...operation, selectionSet: flattenSelectionSet(operation.selectionSet, fragments, []) };
|
|
4321
4316
|
}
|
|
4322
|
-
var COMPILER_MAJOR = 1;
|
|
4323
|
-
var OP_HASH_DOMAIN = "sequence-orm-op\0";
|
|
4324
|
-
var OPS_HASH_DOMAIN = "sequence-orm-opset\0";
|
|
4325
|
-
function canonicalOperationText(definition) {
|
|
4326
|
-
const document2 = { kind: graphql.Kind.DOCUMENT, definitions: [definition] };
|
|
4327
|
-
return graphql.print(document2);
|
|
4328
|
-
}
|
|
4329
|
-
function computeOpHash({
|
|
4330
|
-
definition,
|
|
4331
|
-
schemaHash
|
|
4332
|
-
}) {
|
|
4333
|
-
const digest2 = crypto.createHash("sha256").update(OP_HASH_DOMAIN).update(`${COMPILER_MAJOR}\0${schemaHash}\0`).update(canonicalOperationText(definition)).digest("hex");
|
|
4334
|
-
return `sha256:${digest2}`;
|
|
4335
|
-
}
|
|
4336
|
-
function computeOpsHash(opHashes) {
|
|
4337
|
-
const digest2 = crypto.createHash("sha256").update(OPS_HASH_DOMAIN).update([...opHashes].sort().join("\n")).digest("hex");
|
|
4338
|
-
return `sha256:${digest2}`;
|
|
4339
|
-
}
|
|
4340
4317
|
var SOURCE_DIRECTIVES = /* @__PURE__ */ new Set(["prefetch", "writeback", "localOnly"]);
|
|
4341
4318
|
var fail = (message, code) => {
|
|
4342
4319
|
throw new DocumentCompileError(message, code);
|
|
@@ -5832,7 +5809,6 @@ function compileNamespace({ canonical, sdl, documents }) {
|
|
|
5832
5809
|
operations[restricted.name] = {
|
|
5833
5810
|
irVersion: usesServicePrincipal(roots) ? SERVICE_PRINCIPAL_IR_VERSION : canonical.imports?.length ? COMPOSED_IR_VERSION : roots.some((root) => root.kind === "mutation" && root.assertAffectedRows !== void 0) ? GUARDED_IR_VERSION : LEGACY_IR_VERSION,
|
|
5834
5811
|
name: restricted.name,
|
|
5835
|
-
opHash: computeOpHash({ definition: flattened, schemaHash }),
|
|
5836
5812
|
kind: restricted.kind,
|
|
5837
5813
|
requires: restricted.requires,
|
|
5838
5814
|
variables: restricted.variables,
|
|
@@ -5865,7 +5841,6 @@ function compileNamespace({ canonical, sdl, documents }) {
|
|
|
5865
5841
|
dependencies: Object.fromEntries(canonical.imports.map((owner) => [owner.namespace, computeSchemaHash(localContract(owner))]))
|
|
5866
5842
|
} : {},
|
|
5867
5843
|
readPolicies: Object.fromEntries(ctx.readPolicies),
|
|
5868
|
-
opsHash: computeOpsHash(Object.values(operations).map((op) => op.opHash)),
|
|
5869
5844
|
tables: ctx.tables,
|
|
5870
5845
|
operations
|
|
5871
5846
|
};
|
|
@@ -5873,11 +5848,10 @@ function compileNamespace({ canonical, sdl, documents }) {
|
|
|
5873
5848
|
const manifest = {
|
|
5874
5849
|
namespace: ctx.namespace,
|
|
5875
5850
|
schemaHash,
|
|
5876
|
-
opsHash: normalized.opsHash,
|
|
5877
5851
|
operations: Object.fromEntries(
|
|
5878
5852
|
Object.values(normalized.operations).map((op) => [
|
|
5879
5853
|
op.name,
|
|
5880
|
-
|
|
5854
|
+
op
|
|
5881
5855
|
])
|
|
5882
5856
|
)
|
|
5883
5857
|
};
|
|
@@ -6273,6 +6247,10 @@ function validateOnConflictInput({
|
|
|
6273
6247
|
}
|
|
6274
6248
|
return finish(collector, { constraint, updateColumns });
|
|
6275
6249
|
}
|
|
6250
|
+
function canonicalOperationText(definition) {
|
|
6251
|
+
const document2 = { kind: graphql.Kind.DOCUMENT, definitions: [definition] };
|
|
6252
|
+
return graphql.print(document2);
|
|
6253
|
+
}
|
|
6276
6254
|
|
|
6277
6255
|
// src/sdl/generate.ts
|
|
6278
6256
|
var SdlGenerationError = class extends Error {
|
|
@@ -7251,7 +7229,6 @@ function createSqlCatalog({ canonical, publishedObjects, executionTarget }) {
|
|
|
7251
7229
|
}
|
|
7252
7230
|
function createSqlCatalogFromContext({ canonical, publishedObjects, executionTarget, ctx, identity: suppliedIdentity }) {
|
|
7253
7231
|
if (!publishedObjects.length || new Set(publishedObjects).size !== publishedObjects.length) throw new Error("SQL objects must be explicitly declared and unique");
|
|
7254
|
-
const identity = suppliedIdentity ?? sqlHash(`ontology-sql-v1\0${computeSchemaHash(canonical)}\0${executionTarget}`);
|
|
7255
7232
|
const logicalNames = new Map(Object.entries(ctx.tables).map(([key, meta]) => [meta, key]));
|
|
7256
7233
|
const refOf = (meta) => `${meta.namespace ?? canonical.namespace}/${logicalNames.get(meta)}`;
|
|
7257
7234
|
const definitions = [canonical, ...canonical.imports ?? []];
|
|
@@ -7276,7 +7253,7 @@ function createSqlCatalogFromContext({ canonical, publishedObjects, executionTar
|
|
|
7276
7253
|
const scan = `SELECT ${projection} FROM ${quoteIdentifier(meta.schema)}.${quoteIdentifier(meta.table)} AS ${quoteIdentifier("p0")} WHERE ${compileStaticPolicySql({ table: meta, predicate: policy, tables: ctx.tables, namespace: canonical.namespace, alias: "p0", onRead: (target) => reads.add(refOf(target)) })}`;
|
|
7277
7254
|
return { ref, table: meta.table, columns, scan, read: [...reads].sort() };
|
|
7278
7255
|
});
|
|
7279
|
-
return { identity, objects };
|
|
7256
|
+
return { identity: suppliedIdentity ?? sqlHash(JSON.stringify(["ontology-sql-catalog-v2", executionTarget, objects])), objects };
|
|
7280
7257
|
}
|
|
7281
7258
|
|
|
7282
7259
|
// src/sql/ast.ts
|
|
@@ -7830,20 +7807,10 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7830
7807
|
const catalog = createSqlCatalog({ canonical: input.canonical, publishedObjects: read, executionTarget: "registered-operation" });
|
|
7831
7808
|
if ("mode" in definition) {
|
|
7832
7809
|
if (catalog.objects.some((object) => object.read.some((ref) => !read.includes(ref)))) throw new Error("SQL policy accesses an undeclared ontology object");
|
|
7833
|
-
const opHash2 = sqlHash(JSON.stringify([
|
|
7834
|
-
"sequence-runtime-sql-operation-v1",
|
|
7835
|
-
definition.name,
|
|
7836
|
-
definition.namespace,
|
|
7837
|
-
definition.requires.capability,
|
|
7838
|
-
read,
|
|
7839
|
-
catalog.identity,
|
|
7840
|
-
definition.maxRows
|
|
7841
|
-
]));
|
|
7842
7810
|
result.artifact.operations[definition.name] = compiledOperationSchema.parse({
|
|
7843
7811
|
irVersion: RUNTIME_SQL_IR_VERSION,
|
|
7844
7812
|
language: "sql",
|
|
7845
7813
|
name: definition.name,
|
|
7846
|
-
opHash: opHash2,
|
|
7847
7814
|
kind: "query",
|
|
7848
7815
|
requires: definition.requires,
|
|
7849
7816
|
variables: [
|
|
@@ -7854,7 +7821,7 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7854
7821
|
tableSet: read.map((ref) => ref.split("/")[1]).sort(),
|
|
7855
7822
|
sqlQuery: { catalog, read, maxRows: definition.maxRows }
|
|
7856
7823
|
});
|
|
7857
|
-
result.manifest.operations[definition.name] =
|
|
7824
|
+
result.manifest.operations[definition.name] = result.artifact.operations[definition.name];
|
|
7858
7825
|
continue;
|
|
7859
7826
|
}
|
|
7860
7827
|
const names = Object.keys(definition.parameters).sort();
|
|
@@ -7872,20 +7839,10 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7872
7839
|
nullable: !definition.parameters[name2].required,
|
|
7873
7840
|
list: false
|
|
7874
7841
|
}));
|
|
7875
|
-
const opHash = sqlHash(JSON.stringify([
|
|
7876
|
-
"sequence-sql-operation-v1",
|
|
7877
|
-
definition.name,
|
|
7878
|
-
definition.namespace,
|
|
7879
|
-
definition.requires.capability,
|
|
7880
|
-
read,
|
|
7881
|
-
variables,
|
|
7882
|
-
plan.queryHash
|
|
7883
|
-
]));
|
|
7884
7842
|
const operation = compiledOperationSchema.parse({
|
|
7885
7843
|
irVersion: SQL_IR_VERSION,
|
|
7886
7844
|
language: "sql",
|
|
7887
7845
|
name: definition.name,
|
|
7888
|
-
opHash,
|
|
7889
7846
|
kind: "query",
|
|
7890
7847
|
requires: definition.requires,
|
|
7891
7848
|
variables,
|
|
@@ -7894,7 +7851,7 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7894
7851
|
sql: { text: plan.text, columns: plan.columns, parameters: names, read, maxRows: plan.maxRows }
|
|
7895
7852
|
});
|
|
7896
7853
|
result.artifact.operations[definition.name] = operation;
|
|
7897
|
-
result.manifest.operations[definition.name] =
|
|
7854
|
+
result.manifest.operations[definition.name] = result.artifact.operations[definition.name];
|
|
7898
7855
|
} catch (error) {
|
|
7899
7856
|
return { ok: false, diagnostics: [...result.diagnostics, {
|
|
7900
7857
|
severity: "error",
|
|
@@ -7906,8 +7863,6 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7906
7863
|
}
|
|
7907
7864
|
const required = requiredArtifactIrVersion(Object.values(result.artifact.operations));
|
|
7908
7865
|
if (required > result.artifact.irVersion) result.artifact.irVersion = required;
|
|
7909
|
-
result.artifact.opsHash = computeOpsHash(Object.values(result.artifact.operations).map((op) => op.opHash));
|
|
7910
|
-
result.manifest.opsHash = result.artifact.opsHash;
|
|
7911
7866
|
return { ...result, artifact: normalizeIr(result.artifact) };
|
|
7912
7867
|
}
|
|
7913
7868
|
async function managedViewDiagnostics(canonical) {
|
|
@@ -8006,14 +7961,13 @@ function compileBuiltinSqlArtifact({ namespace, definitions, read, unbackedObjec
|
|
|
8006
7961
|
namespace,
|
|
8007
7962
|
executionTarget,
|
|
8008
7963
|
read,
|
|
8009
|
-
|
|
7964
|
+
objects
|
|
8010
7965
|
])) };
|
|
8011
7966
|
return normalizeIr({
|
|
8012
7967
|
irVersion: usesServicePrincipal(policies) ? SERVICE_PRINCIPAL_IR_VERSION : RUNTIME_SQL_IR_VERSION,
|
|
8013
7968
|
namespace,
|
|
8014
7969
|
schemaHash: catalog.identity,
|
|
8015
7970
|
ownSchemaHash: localHash(anchor),
|
|
8016
|
-
opsHash: BUILTIN_SQL_READ_HASH,
|
|
8017
7971
|
dependencies: Object.fromEntries(definitions.filter((definition) => definition.namespace !== namespace).map((definition) => [definition.namespace, localHash(definition)])),
|
|
8018
7972
|
tables,
|
|
8019
7973
|
readPolicies: policies,
|
|
@@ -8021,7 +7975,6 @@ function compileBuiltinSqlArtifact({ namespace, definitions, read, unbackedObjec
|
|
|
8021
7975
|
operations: { BuiltinSqlRead: {
|
|
8022
7976
|
irVersion: RUNTIME_SQL_IR_VERSION,
|
|
8023
7977
|
name: "BuiltinSqlRead",
|
|
8024
|
-
opHash: BUILTIN_SQL_READ_HASH,
|
|
8025
7978
|
language: "sql",
|
|
8026
7979
|
kind: "query",
|
|
8027
7980
|
requires: null,
|
|
@@ -8186,13 +8139,11 @@ function composeObjectSqlArtifact({ namespace, bundles }) {
|
|
|
8186
8139
|
irVersion: usesServicePrincipal(readPolicies) ? SERVICE_PRINCIPAL_IR_VERSION : RUNTIME_SQL_IR_VERSION,
|
|
8187
8140
|
namespace,
|
|
8188
8141
|
schemaHash: identity,
|
|
8189
|
-
opsHash: BUILTIN_SQL_READ_HASH,
|
|
8190
8142
|
tables,
|
|
8191
8143
|
readPolicies,
|
|
8192
8144
|
operations: { BuiltinSqlRead: {
|
|
8193
8145
|
irVersion: RUNTIME_SQL_IR_VERSION,
|
|
8194
8146
|
name: "BuiltinSqlRead",
|
|
8195
|
-
opHash: BUILTIN_SQL_READ_HASH,
|
|
8196
8147
|
language: "sql",
|
|
8197
8148
|
kind: "query",
|
|
8198
8149
|
requires: null,
|
|
@@ -8206,12 +8157,13 @@ function composeObjectSqlArtifact({ namespace, bundles }) {
|
|
|
8206
8157
|
} }
|
|
8207
8158
|
});
|
|
8208
8159
|
}
|
|
8160
|
+
|
|
8161
|
+
// src/compiler-gql/dataset-previews.ts
|
|
8209
8162
|
var DATASET_PREVIEW_LIMIT = 100;
|
|
8210
8163
|
function compileDatasetPreviews(input) {
|
|
8211
8164
|
const canonical = normalizeCanonical(input);
|
|
8212
8165
|
const { ctx, diagnostics } = buildCompileContext(canonical);
|
|
8213
8166
|
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) throw new NamespaceCompileError(diagnostics);
|
|
8214
|
-
const schemaHash = computeSchemaHash(canonical);
|
|
8215
8167
|
const operations = {};
|
|
8216
8168
|
for (const relation of canonicalRelations(canonical)) {
|
|
8217
8169
|
if (relation.internal || relation.source !== void 0) continue;
|
|
@@ -8236,11 +8188,9 @@ function compileDatasetPreviews(input) {
|
|
|
8236
8188
|
throw new DocumentCompileError(`object '${meta.namespace}/${table}' is not exported for reads`, "unexported-object");
|
|
8237
8189
|
}
|
|
8238
8190
|
}
|
|
8239
|
-
const hash = crypto.createHash("sha256").update("sequence-orm-dataset-preview-v1\0").update(stableJson({ schemaHash, roots, tableSet })).digest("hex");
|
|
8240
8191
|
operations[relation.table] = compiledOperationSchema.parse({
|
|
8241
8192
|
irVersion: usesServicePrincipal(roots) ? SERVICE_PRINCIPAL_IR_VERSION : canonical.imports?.length ? COMPOSED_IR_VERSION : LEGACY_IR_VERSION,
|
|
8242
8193
|
name: `DatasetPreview_${relation.table}`,
|
|
8243
|
-
opHash: `sha256:${hash}`,
|
|
8244
8194
|
kind: "query",
|
|
8245
8195
|
requires: null,
|
|
8246
8196
|
variables: [],
|
|
@@ -8309,7 +8259,6 @@ function projectOperationMetadata({ artifact, operation }) {
|
|
|
8309
8259
|
});
|
|
8310
8260
|
}
|
|
8311
8261
|
|
|
8312
|
-
exports.COMPILER_MAJOR = COMPILER_MAJOR;
|
|
8313
8262
|
exports.CONST_TRUE = CONST_TRUE;
|
|
8314
8263
|
exports.DATASET_PREVIEW_LIMIT = DATASET_PREVIEW_LIMIT;
|
|
8315
8264
|
exports.DEFAULT_LIMIT = DEFAULT_LIMIT;
|
|
@@ -8347,8 +8296,6 @@ exports.compilePolicy = compilePolicy;
|
|
|
8347
8296
|
exports.compilePredicateV2 = compilePredicateV2;
|
|
8348
8297
|
exports.compileRuntimeSql = compileRuntimeSql;
|
|
8349
8298
|
exports.composeObjectSqlArtifact = composeObjectSqlArtifact;
|
|
8350
|
-
exports.computeOpHash = computeOpHash;
|
|
8351
|
-
exports.computeOpsHash = computeOpsHash;
|
|
8352
8299
|
exports.computePinnedColumnsByTable = computePinnedColumnsByTable;
|
|
8353
8300
|
exports.computeSchemaHash = computeSchemaHash;
|
|
8354
8301
|
exports.defineOperation = defineOperation;
|