@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.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { DynamicInputIssue, DynamicInputResult, NormalizedBoolExp, NormalizedOnC
|
|
|
5
5
|
export { CompilePolicyInput, CompilePredicateInput, POLICY_COMPARE_OPS, POLICY_MAX_LINK_DEPTH, ParsedPolicy, PolicyAccess, PolicyColumnInfo, PolicyCompareOp, PolicyCompileError, PolicyCompileErrorCode, PolicyLinkInfo, PolicyNode, PolicyOperand, PolicyParseError, PolicyResolver, PolicyTableInfo, assertClaimsOnlyWhen, compilePolicy, compilePredicateV2, parsePolicy, walkPolicy } from './predicate-v2.cjs';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
export { P as PLATFORM_USER_TYPENAME, c as camelCase, g as enumTypeName, p as pascalCase } from './naming-BMZKFO0W.cjs';
|
|
8
|
-
export { S as SqlOperationDefinition, d as defineOperation, s as sqlOperationDefinitionSchema } from './definition-
|
|
8
|
+
export { S as SqlOperationDefinition, d as defineOperation, s as sqlOperationDefinitionSchema } from './definition-B99BsOAO.cjs';
|
|
9
9
|
import './constants-D2o0vK6U.cjs';
|
|
10
10
|
import './policy-1iZbGnZZ.cjs';
|
|
11
11
|
|
|
@@ -238,16 +238,13 @@ declare function parseDocuments({ schema, documents, }: {
|
|
|
238
238
|
|
|
239
239
|
/** Content hash of the canonical definition — the schema identity ops compile against. */
|
|
240
240
|
declare function computeSchemaHash(canonical: CanonicalDefinition): string;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
/** What codegen/the client transport needs: name → hash mapping + set identity. */
|
|
241
|
+
/** Registration tripwire: exact compiled contracts, never selector digests.
|
|
242
|
+
* Public generated client manifests project only kind and capability gates. */
|
|
243
|
+
type ClientManifestOperation = CompiledOperation;
|
|
244
|
+
/** What codegen/the client transport needs: namespace-scoped name, kind and capability contract. */
|
|
247
245
|
interface ClientManifest {
|
|
248
246
|
namespace: string;
|
|
249
247
|
schemaHash: string;
|
|
250
|
-
opsHash: string;
|
|
251
248
|
operations: Record<string, ClientManifestOperation>;
|
|
252
249
|
}
|
|
253
250
|
interface CompileNamespaceInput {
|
|
@@ -287,16 +284,8 @@ declare function flattenOperation({ operation, fragments, }: {
|
|
|
287
284
|
fragments: ReadonlyMap<string, FragmentDefinitionNode>;
|
|
288
285
|
}): OperationDefinitionNode;
|
|
289
286
|
|
|
290
|
-
/** Bump on any change to lowering semantics — invalidates every op hash. */
|
|
291
|
-
declare const COMPILER_MAJOR = 1;
|
|
292
287
|
/** Canonical print of one flattened operation (fragments already inlined). */
|
|
293
288
|
declare function canonicalOperationText(definition: OperationDefinitionNode): string;
|
|
294
|
-
declare function computeOpHash({ definition, schemaHash, }: {
|
|
295
|
-
definition: OperationDefinitionNode;
|
|
296
|
-
schemaHash: string;
|
|
297
|
-
}): string;
|
|
298
|
-
/** Order-independent set hash over the sorted op hashes. */
|
|
299
|
-
declare function computeOpsHash(opHashes: readonly string[]): string;
|
|
300
289
|
|
|
301
290
|
/**
|
|
302
291
|
* Restrict pass — the grammar gate that keeps operations inside the v2.0
|
|
@@ -721,4 +710,4 @@ declare function projectOperationMetadata({ artifact, operation }: {
|
|
|
721
710
|
operation: CompiledOperation;
|
|
722
711
|
}): CompiledArtifact;
|
|
723
712
|
|
|
724
|
-
export { type BuildContextResult,
|
|
713
|
+
export { type BuildContextResult, CONST_TRUE, type ClientManifest, type ClientManifestOperation, type CompileContext, type CompileNamespaceInput, type CompileNamespaceResult, type CompilerDiagnostic, DATASET_PREVIEW_LIMIT, DEFAULT_LIMIT, type DiagnosticSeverity, DocumentCompileError, MAX_LIMIT, type MutationOp, type MutationRootInfo, NamespaceCompileError, OBJECT_METADATA_FORMAT, OPERATION_METADATA_FORMAT, type ObjectMetadataProjection, type ObjectSqlBundle, OperationLowerer, PLATFORM_USER_TABLE, type ParseDocumentsResult, type ParsedDocument, type PinnedColumn, type QueryRootInfo, type RestrictedOperation, type SourceDocument, type SqlQueryInput, andPred, bindNamedParameters, buildCompileContext, canonicalOperationText, classifyInputType, collectPinnedColumns, compileBuiltinSqlArtifact, compileDatasetPreviews, compileDefaultOperations, compileNamespace, compileNamespaceOrThrow, compileObjectMetadata, compileOperationDocuments, compileRuntimeSql, composeObjectSqlArtifact, computePinnedColumnsByTable, computeSchemaHash, flattenOperation, generateDefaultOperations, injectPolicies, inputTypeName, isSqlOperationDocument, lowerOperation, mutationRootNames, objectSqlBundleSchema, parseDocuments, parseSdl, platformUserMeta, predContains, predContainsExists, projectOperationMetadata, queryRootNames, referencedSqlObjects, restrictOperation, sqlQueryInputSchema, typeNameForTable, validateManagedViewQueries, walkPred };
|
package/dist/compiler.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { DynamicInputIssue, DynamicInputResult, NormalizedBoolExp, NormalizedOnC
|
|
|
5
5
|
export { CompilePolicyInput, CompilePredicateInput, POLICY_COMPARE_OPS, POLICY_MAX_LINK_DEPTH, ParsedPolicy, PolicyAccess, PolicyColumnInfo, PolicyCompareOp, PolicyCompileError, PolicyCompileErrorCode, PolicyLinkInfo, PolicyNode, PolicyOperand, PolicyParseError, PolicyResolver, PolicyTableInfo, assertClaimsOnlyWhen, compilePolicy, compilePredicateV2, parsePolicy, walkPolicy } from './predicate-v2.js';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
export { P as PLATFORM_USER_TYPENAME, c as camelCase, g as enumTypeName, p as pascalCase } from './naming-DUk7AcXs.js';
|
|
8
|
-
export { S as SqlOperationDefinition, d as defineOperation, s as sqlOperationDefinitionSchema } from './definition-
|
|
8
|
+
export { S as SqlOperationDefinition, d as defineOperation, s as sqlOperationDefinitionSchema } from './definition-B99BsOAO.js';
|
|
9
9
|
import './constants-D2o0vK6U.js';
|
|
10
10
|
import './policy-1iZbGnZZ.js';
|
|
11
11
|
|
|
@@ -238,16 +238,13 @@ declare function parseDocuments({ schema, documents, }: {
|
|
|
238
238
|
|
|
239
239
|
/** Content hash of the canonical definition — the schema identity ops compile against. */
|
|
240
240
|
declare function computeSchemaHash(canonical: CanonicalDefinition): string;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
/** What codegen/the client transport needs: name → hash mapping + set identity. */
|
|
241
|
+
/** Registration tripwire: exact compiled contracts, never selector digests.
|
|
242
|
+
* Public generated client manifests project only kind and capability gates. */
|
|
243
|
+
type ClientManifestOperation = CompiledOperation;
|
|
244
|
+
/** What codegen/the client transport needs: namespace-scoped name, kind and capability contract. */
|
|
247
245
|
interface ClientManifest {
|
|
248
246
|
namespace: string;
|
|
249
247
|
schemaHash: string;
|
|
250
|
-
opsHash: string;
|
|
251
248
|
operations: Record<string, ClientManifestOperation>;
|
|
252
249
|
}
|
|
253
250
|
interface CompileNamespaceInput {
|
|
@@ -287,16 +284,8 @@ declare function flattenOperation({ operation, fragments, }: {
|
|
|
287
284
|
fragments: ReadonlyMap<string, FragmentDefinitionNode>;
|
|
288
285
|
}): OperationDefinitionNode;
|
|
289
286
|
|
|
290
|
-
/** Bump on any change to lowering semantics — invalidates every op hash. */
|
|
291
|
-
declare const COMPILER_MAJOR = 1;
|
|
292
287
|
/** Canonical print of one flattened operation (fragments already inlined). */
|
|
293
288
|
declare function canonicalOperationText(definition: OperationDefinitionNode): string;
|
|
294
|
-
declare function computeOpHash({ definition, schemaHash, }: {
|
|
295
|
-
definition: OperationDefinitionNode;
|
|
296
|
-
schemaHash: string;
|
|
297
|
-
}): string;
|
|
298
|
-
/** Order-independent set hash over the sorted op hashes. */
|
|
299
|
-
declare function computeOpsHash(opHashes: readonly string[]): string;
|
|
300
289
|
|
|
301
290
|
/**
|
|
302
291
|
* Restrict pass — the grammar gate that keeps operations inside the v2.0
|
|
@@ -721,4 +710,4 @@ declare function projectOperationMetadata({ artifact, operation }: {
|
|
|
721
710
|
operation: CompiledOperation;
|
|
722
711
|
}): CompiledArtifact;
|
|
723
712
|
|
|
724
|
-
export { type BuildContextResult,
|
|
713
|
+
export { type BuildContextResult, CONST_TRUE, type ClientManifest, type ClientManifestOperation, type CompileContext, type CompileNamespaceInput, type CompileNamespaceResult, type CompilerDiagnostic, DATASET_PREVIEW_LIMIT, DEFAULT_LIMIT, type DiagnosticSeverity, DocumentCompileError, MAX_LIMIT, type MutationOp, type MutationRootInfo, NamespaceCompileError, OBJECT_METADATA_FORMAT, OPERATION_METADATA_FORMAT, type ObjectMetadataProjection, type ObjectSqlBundle, OperationLowerer, PLATFORM_USER_TABLE, type ParseDocumentsResult, type ParsedDocument, type PinnedColumn, type QueryRootInfo, type RestrictedOperation, type SourceDocument, type SqlQueryInput, andPred, bindNamedParameters, buildCompileContext, canonicalOperationText, classifyInputType, collectPinnedColumns, compileBuiltinSqlArtifact, compileDatasetPreviews, compileDefaultOperations, compileNamespace, compileNamespaceOrThrow, compileObjectMetadata, compileOperationDocuments, compileRuntimeSql, composeObjectSqlArtifact, computePinnedColumnsByTable, computeSchemaHash, flattenOperation, generateDefaultOperations, injectPolicies, inputTypeName, isSqlOperationDocument, lowerOperation, mutationRootNames, objectSqlBundleSchema, parseDocuments, parseSdl, platformUserMeta, predContains, predContainsExists, projectOperationMetadata, queryRootNames, referencedSqlObjects, restrictOperation, sqlQueryInputSchema, typeNameForTable, validateManagedViewQueries, walkPred };
|
package/dist/compiler.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'crypto';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { Kind,
|
|
3
|
+
import { Kind, visit, buildSchema, parse, validate, print, GraphQLObjectType, valueFromASTUntyped, getNamedType, GraphQLScalarType, GraphQLEnumType, GraphQLInputObjectType, GraphQLNonNull, GraphQLList } from 'graphql';
|
|
4
4
|
import { PgParser } from '@supabase/pg-parser';
|
|
5
5
|
|
|
6
6
|
// src/compiler-gql/artifact.ts
|
|
@@ -2135,9 +2135,6 @@ function normalizeCanonical(definition) {
|
|
|
2135
2135
|
return normalized;
|
|
2136
2136
|
}
|
|
2137
2137
|
|
|
2138
|
-
// src/client/sql.ts
|
|
2139
|
-
var BUILTIN_SQL_READ_HASH = "sha256:a50c477c952a5e0fe68ed158a4530e4aab573c09bcbb1a8ac454dc88a39a6258";
|
|
2140
|
-
|
|
2141
2138
|
// src/ir/index.ts
|
|
2142
2139
|
var IR_VERSION = 6;
|
|
2143
2140
|
var LEGACY_IR_VERSION = 1;
|
|
@@ -2466,8 +2463,7 @@ var compiledOperationSchema = z.object({
|
|
|
2466
2463
|
maxRows: z.number().int().min(1).max(1e4)
|
|
2467
2464
|
}).strict().optional(),
|
|
2468
2465
|
irVersion: irVersionSchema,
|
|
2469
|
-
name: z.string(),
|
|
2470
|
-
opHash: z.string().regex(/^sha256:[0-9a-f]{64}$/),
|
|
2466
|
+
name: z.string().regex(/^[_A-Za-z][_0-9A-Za-z]{0,254}$/),
|
|
2471
2467
|
kind: z.enum(["query", "mutation"]),
|
|
2472
2468
|
requires: z.object({
|
|
2473
2469
|
capability: z.string().optional(),
|
|
@@ -2483,7 +2479,7 @@ var compiledOperationSchema = z.object({
|
|
|
2483
2479
|
}
|
|
2484
2480
|
if (operation.language === "sql") {
|
|
2485
2481
|
const validPlan = operation.sqlQuery ? !operation.sql && operation.irVersion === RUNTIME_SQL_IR_VERSION : !!operation.sql && operation.irVersion === SQL_IR_VERSION;
|
|
2486
|
-
const builtin = operation.name === "BuiltinSqlRead" && operation.
|
|
2482
|
+
const builtin = operation.name === "BuiltinSqlRead" && operation.requires === null;
|
|
2487
2483
|
if (!validPlan || operation.kind !== "query" || operation.roots.length !== 0 || !builtin && !operation.requires?.capability) {
|
|
2488
2484
|
ctx.addIssue({ code: "custom", message: "SQL operations require a query-only v4 plan or v5 runtime contract, capability, and no GraphQL roots" });
|
|
2489
2485
|
}
|
|
@@ -2498,7 +2494,7 @@ var compiledOperationSchema = z.object({
|
|
|
2498
2494
|
}
|
|
2499
2495
|
});
|
|
2500
2496
|
var resolvedSourceIrSchema = z.object({
|
|
2501
|
-
name: z.string(),
|
|
2497
|
+
name: z.string().regex(/^[_A-Za-z][_0-9A-Za-z]{0,254}$/),
|
|
2502
2498
|
kind: z.enum(["manual", "etl", "prefetch"]),
|
|
2503
2499
|
/** Logical table key of the backing relation. */
|
|
2504
2500
|
table: z.string(),
|
|
@@ -2612,7 +2608,6 @@ var compiledArtifactSchema = z.object({
|
|
|
2612
2608
|
ownSchemaHash: z.string().optional(),
|
|
2613
2609
|
dependencies: z.record(z.string(), z.string()).optional(),
|
|
2614
2610
|
readPolicies: z.record(z.string(), predIrSchema).optional(),
|
|
2615
|
-
opsHash: z.string(),
|
|
2616
2611
|
/** Apply-observed synced objects without a serving backing; not part of the authored schema hash. */
|
|
2617
2612
|
unbackedTables: z.array(z.string()).optional(),
|
|
2618
2613
|
tables: z.record(z.string(), tableMetaIrSchema),
|
|
@@ -4317,24 +4312,6 @@ function flattenOperation({
|
|
|
4317
4312
|
}) {
|
|
4318
4313
|
return { ...operation, selectionSet: flattenSelectionSet(operation.selectionSet, fragments, []) };
|
|
4319
4314
|
}
|
|
4320
|
-
var COMPILER_MAJOR = 1;
|
|
4321
|
-
var OP_HASH_DOMAIN = "sequence-orm-op\0";
|
|
4322
|
-
var OPS_HASH_DOMAIN = "sequence-orm-opset\0";
|
|
4323
|
-
function canonicalOperationText(definition) {
|
|
4324
|
-
const document2 = { kind: Kind.DOCUMENT, definitions: [definition] };
|
|
4325
|
-
return print(document2);
|
|
4326
|
-
}
|
|
4327
|
-
function computeOpHash({
|
|
4328
|
-
definition,
|
|
4329
|
-
schemaHash
|
|
4330
|
-
}) {
|
|
4331
|
-
const digest2 = createHash("sha256").update(OP_HASH_DOMAIN).update(`${COMPILER_MAJOR}\0${schemaHash}\0`).update(canonicalOperationText(definition)).digest("hex");
|
|
4332
|
-
return `sha256:${digest2}`;
|
|
4333
|
-
}
|
|
4334
|
-
function computeOpsHash(opHashes) {
|
|
4335
|
-
const digest2 = createHash("sha256").update(OPS_HASH_DOMAIN).update([...opHashes].sort().join("\n")).digest("hex");
|
|
4336
|
-
return `sha256:${digest2}`;
|
|
4337
|
-
}
|
|
4338
4315
|
var SOURCE_DIRECTIVES = /* @__PURE__ */ new Set(["prefetch", "writeback", "localOnly"]);
|
|
4339
4316
|
var fail = (message, code) => {
|
|
4340
4317
|
throw new DocumentCompileError(message, code);
|
|
@@ -5830,7 +5807,6 @@ function compileNamespace({ canonical, sdl, documents }) {
|
|
|
5830
5807
|
operations[restricted.name] = {
|
|
5831
5808
|
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,
|
|
5832
5809
|
name: restricted.name,
|
|
5833
|
-
opHash: computeOpHash({ definition: flattened, schemaHash }),
|
|
5834
5810
|
kind: restricted.kind,
|
|
5835
5811
|
requires: restricted.requires,
|
|
5836
5812
|
variables: restricted.variables,
|
|
@@ -5863,7 +5839,6 @@ function compileNamespace({ canonical, sdl, documents }) {
|
|
|
5863
5839
|
dependencies: Object.fromEntries(canonical.imports.map((owner) => [owner.namespace, computeSchemaHash(localContract(owner))]))
|
|
5864
5840
|
} : {},
|
|
5865
5841
|
readPolicies: Object.fromEntries(ctx.readPolicies),
|
|
5866
|
-
opsHash: computeOpsHash(Object.values(operations).map((op) => op.opHash)),
|
|
5867
5842
|
tables: ctx.tables,
|
|
5868
5843
|
operations
|
|
5869
5844
|
};
|
|
@@ -5871,11 +5846,10 @@ function compileNamespace({ canonical, sdl, documents }) {
|
|
|
5871
5846
|
const manifest = {
|
|
5872
5847
|
namespace: ctx.namespace,
|
|
5873
5848
|
schemaHash,
|
|
5874
|
-
opsHash: normalized.opsHash,
|
|
5875
5849
|
operations: Object.fromEntries(
|
|
5876
5850
|
Object.values(normalized.operations).map((op) => [
|
|
5877
5851
|
op.name,
|
|
5878
|
-
|
|
5852
|
+
op
|
|
5879
5853
|
])
|
|
5880
5854
|
)
|
|
5881
5855
|
};
|
|
@@ -6271,6 +6245,10 @@ function validateOnConflictInput({
|
|
|
6271
6245
|
}
|
|
6272
6246
|
return finish(collector, { constraint, updateColumns });
|
|
6273
6247
|
}
|
|
6248
|
+
function canonicalOperationText(definition) {
|
|
6249
|
+
const document2 = { kind: Kind.DOCUMENT, definitions: [definition] };
|
|
6250
|
+
return print(document2);
|
|
6251
|
+
}
|
|
6274
6252
|
|
|
6275
6253
|
// src/sdl/generate.ts
|
|
6276
6254
|
var SdlGenerationError = class extends Error {
|
|
@@ -7249,7 +7227,6 @@ function createSqlCatalog({ canonical, publishedObjects, executionTarget }) {
|
|
|
7249
7227
|
}
|
|
7250
7228
|
function createSqlCatalogFromContext({ canonical, publishedObjects, executionTarget, ctx, identity: suppliedIdentity }) {
|
|
7251
7229
|
if (!publishedObjects.length || new Set(publishedObjects).size !== publishedObjects.length) throw new Error("SQL objects must be explicitly declared and unique");
|
|
7252
|
-
const identity = suppliedIdentity ?? sqlHash(`ontology-sql-v1\0${computeSchemaHash(canonical)}\0${executionTarget}`);
|
|
7253
7230
|
const logicalNames = new Map(Object.entries(ctx.tables).map(([key, meta]) => [meta, key]));
|
|
7254
7231
|
const refOf = (meta) => `${meta.namespace ?? canonical.namespace}/${logicalNames.get(meta)}`;
|
|
7255
7232
|
const definitions = [canonical, ...canonical.imports ?? []];
|
|
@@ -7274,7 +7251,7 @@ function createSqlCatalogFromContext({ canonical, publishedObjects, executionTar
|
|
|
7274
7251
|
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)) })}`;
|
|
7275
7252
|
return { ref, table: meta.table, columns, scan, read: [...reads].sort() };
|
|
7276
7253
|
});
|
|
7277
|
-
return { identity, objects };
|
|
7254
|
+
return { identity: suppliedIdentity ?? sqlHash(JSON.stringify(["ontology-sql-catalog-v2", executionTarget, objects])), objects };
|
|
7278
7255
|
}
|
|
7279
7256
|
|
|
7280
7257
|
// src/sql/ast.ts
|
|
@@ -7828,20 +7805,10 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7828
7805
|
const catalog = createSqlCatalog({ canonical: input.canonical, publishedObjects: read, executionTarget: "registered-operation" });
|
|
7829
7806
|
if ("mode" in definition) {
|
|
7830
7807
|
if (catalog.objects.some((object) => object.read.some((ref) => !read.includes(ref)))) throw new Error("SQL policy accesses an undeclared ontology object");
|
|
7831
|
-
const opHash2 = sqlHash(JSON.stringify([
|
|
7832
|
-
"sequence-runtime-sql-operation-v1",
|
|
7833
|
-
definition.name,
|
|
7834
|
-
definition.namespace,
|
|
7835
|
-
definition.requires.capability,
|
|
7836
|
-
read,
|
|
7837
|
-
catalog.identity,
|
|
7838
|
-
definition.maxRows
|
|
7839
|
-
]));
|
|
7840
7808
|
result.artifact.operations[definition.name] = compiledOperationSchema.parse({
|
|
7841
7809
|
irVersion: RUNTIME_SQL_IR_VERSION,
|
|
7842
7810
|
language: "sql",
|
|
7843
7811
|
name: definition.name,
|
|
7844
|
-
opHash: opHash2,
|
|
7845
7812
|
kind: "query",
|
|
7846
7813
|
requires: definition.requires,
|
|
7847
7814
|
variables: [
|
|
@@ -7852,7 +7819,7 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7852
7819
|
tableSet: read.map((ref) => ref.split("/")[1]).sort(),
|
|
7853
7820
|
sqlQuery: { catalog, read, maxRows: definition.maxRows }
|
|
7854
7821
|
});
|
|
7855
|
-
result.manifest.operations[definition.name] =
|
|
7822
|
+
result.manifest.operations[definition.name] = result.artifact.operations[definition.name];
|
|
7856
7823
|
continue;
|
|
7857
7824
|
}
|
|
7858
7825
|
const names = Object.keys(definition.parameters).sort();
|
|
@@ -7870,20 +7837,10 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7870
7837
|
nullable: !definition.parameters[name2].required,
|
|
7871
7838
|
list: false
|
|
7872
7839
|
}));
|
|
7873
|
-
const opHash = sqlHash(JSON.stringify([
|
|
7874
|
-
"sequence-sql-operation-v1",
|
|
7875
|
-
definition.name,
|
|
7876
|
-
definition.namespace,
|
|
7877
|
-
definition.requires.capability,
|
|
7878
|
-
read,
|
|
7879
|
-
variables,
|
|
7880
|
-
plan.queryHash
|
|
7881
|
-
]));
|
|
7882
7840
|
const operation = compiledOperationSchema.parse({
|
|
7883
7841
|
irVersion: SQL_IR_VERSION,
|
|
7884
7842
|
language: "sql",
|
|
7885
7843
|
name: definition.name,
|
|
7886
|
-
opHash,
|
|
7887
7844
|
kind: "query",
|
|
7888
7845
|
requires: definition.requires,
|
|
7889
7846
|
variables,
|
|
@@ -7892,7 +7849,7 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7892
7849
|
sql: { text: plan.text, columns: plan.columns, parameters: names, read, maxRows: plan.maxRows }
|
|
7893
7850
|
});
|
|
7894
7851
|
result.artifact.operations[definition.name] = operation;
|
|
7895
|
-
result.manifest.operations[definition.name] =
|
|
7852
|
+
result.manifest.operations[definition.name] = result.artifact.operations[definition.name];
|
|
7896
7853
|
} catch (error) {
|
|
7897
7854
|
return { ok: false, diagnostics: [...result.diagnostics, {
|
|
7898
7855
|
severity: "error",
|
|
@@ -7904,8 +7861,6 @@ async function compileSqlDocuments({ input, result, sqlDocuments }) {
|
|
|
7904
7861
|
}
|
|
7905
7862
|
const required = requiredArtifactIrVersion(Object.values(result.artifact.operations));
|
|
7906
7863
|
if (required > result.artifact.irVersion) result.artifact.irVersion = required;
|
|
7907
|
-
result.artifact.opsHash = computeOpsHash(Object.values(result.artifact.operations).map((op) => op.opHash));
|
|
7908
|
-
result.manifest.opsHash = result.artifact.opsHash;
|
|
7909
7864
|
return { ...result, artifact: normalizeIr(result.artifact) };
|
|
7910
7865
|
}
|
|
7911
7866
|
async function managedViewDiagnostics(canonical) {
|
|
@@ -8004,14 +7959,13 @@ function compileBuiltinSqlArtifact({ namespace, definitions, read, unbackedObjec
|
|
|
8004
7959
|
namespace,
|
|
8005
7960
|
executionTarget,
|
|
8006
7961
|
read,
|
|
8007
|
-
|
|
7962
|
+
objects
|
|
8008
7963
|
])) };
|
|
8009
7964
|
return normalizeIr({
|
|
8010
7965
|
irVersion: usesServicePrincipal(policies) ? SERVICE_PRINCIPAL_IR_VERSION : RUNTIME_SQL_IR_VERSION,
|
|
8011
7966
|
namespace,
|
|
8012
7967
|
schemaHash: catalog.identity,
|
|
8013
7968
|
ownSchemaHash: localHash(anchor),
|
|
8014
|
-
opsHash: BUILTIN_SQL_READ_HASH,
|
|
8015
7969
|
dependencies: Object.fromEntries(definitions.filter((definition) => definition.namespace !== namespace).map((definition) => [definition.namespace, localHash(definition)])),
|
|
8016
7970
|
tables,
|
|
8017
7971
|
readPolicies: policies,
|
|
@@ -8019,7 +7973,6 @@ function compileBuiltinSqlArtifact({ namespace, definitions, read, unbackedObjec
|
|
|
8019
7973
|
operations: { BuiltinSqlRead: {
|
|
8020
7974
|
irVersion: RUNTIME_SQL_IR_VERSION,
|
|
8021
7975
|
name: "BuiltinSqlRead",
|
|
8022
|
-
opHash: BUILTIN_SQL_READ_HASH,
|
|
8023
7976
|
language: "sql",
|
|
8024
7977
|
kind: "query",
|
|
8025
7978
|
requires: null,
|
|
@@ -8184,13 +8137,11 @@ function composeObjectSqlArtifact({ namespace, bundles }) {
|
|
|
8184
8137
|
irVersion: usesServicePrincipal(readPolicies) ? SERVICE_PRINCIPAL_IR_VERSION : RUNTIME_SQL_IR_VERSION,
|
|
8185
8138
|
namespace,
|
|
8186
8139
|
schemaHash: identity,
|
|
8187
|
-
opsHash: BUILTIN_SQL_READ_HASH,
|
|
8188
8140
|
tables,
|
|
8189
8141
|
readPolicies,
|
|
8190
8142
|
operations: { BuiltinSqlRead: {
|
|
8191
8143
|
irVersion: RUNTIME_SQL_IR_VERSION,
|
|
8192
8144
|
name: "BuiltinSqlRead",
|
|
8193
|
-
opHash: BUILTIN_SQL_READ_HASH,
|
|
8194
8145
|
language: "sql",
|
|
8195
8146
|
kind: "query",
|
|
8196
8147
|
requires: null,
|
|
@@ -8204,12 +8155,13 @@ function composeObjectSqlArtifact({ namespace, bundles }) {
|
|
|
8204
8155
|
} }
|
|
8205
8156
|
});
|
|
8206
8157
|
}
|
|
8158
|
+
|
|
8159
|
+
// src/compiler-gql/dataset-previews.ts
|
|
8207
8160
|
var DATASET_PREVIEW_LIMIT = 100;
|
|
8208
8161
|
function compileDatasetPreviews(input) {
|
|
8209
8162
|
const canonical = normalizeCanonical(input);
|
|
8210
8163
|
const { ctx, diagnostics } = buildCompileContext(canonical);
|
|
8211
8164
|
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) throw new NamespaceCompileError(diagnostics);
|
|
8212
|
-
const schemaHash = computeSchemaHash(canonical);
|
|
8213
8165
|
const operations = {};
|
|
8214
8166
|
for (const relation of canonicalRelations(canonical)) {
|
|
8215
8167
|
if (relation.internal || relation.source !== void 0) continue;
|
|
@@ -8234,11 +8186,9 @@ function compileDatasetPreviews(input) {
|
|
|
8234
8186
|
throw new DocumentCompileError(`object '${meta.namespace}/${table}' is not exported for reads`, "unexported-object");
|
|
8235
8187
|
}
|
|
8236
8188
|
}
|
|
8237
|
-
const hash = createHash("sha256").update("sequence-orm-dataset-preview-v1\0").update(stableJson({ schemaHash, roots, tableSet })).digest("hex");
|
|
8238
8189
|
operations[relation.table] = compiledOperationSchema.parse({
|
|
8239
8190
|
irVersion: usesServicePrincipal(roots) ? SERVICE_PRINCIPAL_IR_VERSION : canonical.imports?.length ? COMPOSED_IR_VERSION : LEGACY_IR_VERSION,
|
|
8240
8191
|
name: `DatasetPreview_${relation.table}`,
|
|
8241
|
-
opHash: `sha256:${hash}`,
|
|
8242
8192
|
kind: "query",
|
|
8243
8193
|
requires: null,
|
|
8244
8194
|
variables: [],
|
|
@@ -8307,6 +8257,6 @@ function projectOperationMetadata({ artifact, operation }) {
|
|
|
8307
8257
|
});
|
|
8308
8258
|
}
|
|
8309
8259
|
|
|
8310
|
-
export {
|
|
8260
|
+
export { CONST_TRUE, DATASET_PREVIEW_LIMIT, DEFAULT_LIMIT, DocumentCompileError, MAX_LIMIT, NamespaceCompileError, OBJECT_METADATA_FORMAT, OPERATION_METADATA_FORMAT, ORDER_BY_DIRECTIONS, OperationLowerer, PLATFORM_USER_TABLE, PLATFORM_USER_TYPENAME, POLICY_COMPARE_OPS, POLICY_MAX_LINK_DEPTH, PolicyCompileError, PolicyParseError, allowedBoolExpOperators, allowedOps, andPred, assertClaimsOnlyWhen, bindNamedParameters, buildCompileContext, camelCase, canonicalOperationText, classifyInputType, collectPinnedColumns, compileBuiltinSqlArtifact, compileDatasetPreviews, compileDefaultOperations, compileNamespace, compileNamespaceOrThrow, compileObjectMetadata, compileOperationDocuments, compilePolicy, compilePredicateV2, compileRuntimeSql, composeObjectSqlArtifact, computePinnedColumnsByTable, computeSchemaHash, defineOperation, enumTypeName, flattenOperation, generateDefaultOperations, injectPolicies, inputTypeName, isSqlOperationDocument, lowerOperation, mutationRootNames, objectSqlBundleSchema, parseDocuments, parsePolicy, parseSdl, pascalCase, platformUserMeta, predContains, predContainsExists, projectOperationMetadata, queryRootNames, referencedSqlObjects, restrictOperation, sqlOperationDefinitionSchema, sqlQueryInputSchema, typeNameForTable, validateAppendInput, validateBoolExpInput, validateInsertInput, validateManagedViewQueries, validateOnConflictInput, validateOrderByInput, validateSelectColumns, validateSetInput, walkPolicy, walkPred };
|
|
8311
8261
|
//# sourceMappingURL=compiler.js.map
|
|
8312
8262
|
//# sourceMappingURL=compiler.js.map
|