@sequenceholdings/orm 2.9.0 → 2.10.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/dist/cli.cjs +30 -16
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +10 -1
- package/dist/cli.d.ts +10 -1
- package/dist/cli.js +29 -17
- package/dist/cli.js.map +1 -1
- package/dist/compiler.cjs +258 -17
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +181 -1
- package/dist/compiler.d.ts +181 -1
- package/dist/compiler.js +253 -18
- package/dist/compiler.js.map +1 -1
- package/dist/index.cjs +9 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +9 -7
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +12 -1
- package/dist/ir.d.ts +12 -1
- package/dist/ir.js +9 -8
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +9 -7
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +2 -0
- package/dist/predicate-v2.d.ts +2 -0
- package/dist/predicate-v2.js +9 -7
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +8 -7
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.js +8 -7
- package/dist/sdl.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.cts
CHANGED
|
@@ -5,6 +5,13 @@ declare const TOKEN_ENV = "SEQUENCE_ORM_TOKEN";
|
|
|
5
5
|
declare const SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
6
6
|
/** Namespace-admin override reason for an apply whose source does not verify; set by `seq-studio orm apply --unverified-source`. */
|
|
7
7
|
declare const UNVERIFIED_SOURCE_REASON_ENV = "SEQUENCE_ORM_UNVERIFIED_SOURCE_REASON";
|
|
8
|
+
/**
|
|
9
|
+
* The caller's token for the source claim's `source_environment`; set by `seq-studio orm apply --source-env`.
|
|
10
|
+
* Only the apply request carries it (as `x-sequence-source-authorization`), so Atlas can read the source there.
|
|
11
|
+
*/
|
|
12
|
+
declare const SOURCE_AUTHORIZATION_ENV = "SEQUENCE_ORM_SOURCE_AUTHORIZATION";
|
|
13
|
+
/** The apply request's source environment credential header, when the delegate supplied one. */
|
|
14
|
+
declare function applySourceHeaders(env?: NodeJS.ProcessEnv): Record<string, string>;
|
|
8
15
|
/** The apply body's `source` claim, when the delegate supplied one. Atlas verifies it; it never authorizes anything. */
|
|
9
16
|
declare function applySourceFromEnv(env?: NodeJS.ProcessEnv): {
|
|
10
17
|
source?: Record<string, unknown>;
|
|
@@ -39,6 +46,8 @@ declare function errorDetail(payload: unknown): string | null;
|
|
|
39
46
|
interface RegistryActivation {
|
|
40
47
|
id: string;
|
|
41
48
|
provenance_class: string;
|
|
49
|
+
/** Absent on an older Atlas; null for this deployment's own Git Service. */
|
|
50
|
+
source_environment?: string | null;
|
|
42
51
|
source_commit: string | null;
|
|
43
52
|
source_branch: string | null;
|
|
44
53
|
source_path: string | null;
|
|
@@ -47,4 +56,4 @@ interface RegistryActivation {
|
|
|
47
56
|
activated_at: string;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, type RegistryActivation, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
59
|
+
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, type RegistryActivation, SOURCE_AUTHORIZATION_ENV, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, applySourceHeaders, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
package/dist/cli.d.ts
CHANGED
|
@@ -5,6 +5,13 @@ declare const TOKEN_ENV = "SEQUENCE_ORM_TOKEN";
|
|
|
5
5
|
declare const SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
6
6
|
/** Namespace-admin override reason for an apply whose source does not verify; set by `seq-studio orm apply --unverified-source`. */
|
|
7
7
|
declare const UNVERIFIED_SOURCE_REASON_ENV = "SEQUENCE_ORM_UNVERIFIED_SOURCE_REASON";
|
|
8
|
+
/**
|
|
9
|
+
* The caller's token for the source claim's `source_environment`; set by `seq-studio orm apply --source-env`.
|
|
10
|
+
* Only the apply request carries it (as `x-sequence-source-authorization`), so Atlas can read the source there.
|
|
11
|
+
*/
|
|
12
|
+
declare const SOURCE_AUTHORIZATION_ENV = "SEQUENCE_ORM_SOURCE_AUTHORIZATION";
|
|
13
|
+
/** The apply request's source environment credential header, when the delegate supplied one. */
|
|
14
|
+
declare function applySourceHeaders(env?: NodeJS.ProcessEnv): Record<string, string>;
|
|
8
15
|
/** The apply body's `source` claim, when the delegate supplied one. Atlas verifies it; it never authorizes anything. */
|
|
9
16
|
declare function applySourceFromEnv(env?: NodeJS.ProcessEnv): {
|
|
10
17
|
source?: Record<string, unknown>;
|
|
@@ -39,6 +46,8 @@ declare function errorDetail(payload: unknown): string | null;
|
|
|
39
46
|
interface RegistryActivation {
|
|
40
47
|
id: string;
|
|
41
48
|
provenance_class: string;
|
|
49
|
+
/** Absent on an older Atlas; null for this deployment's own Git Service. */
|
|
50
|
+
source_environment?: string | null;
|
|
42
51
|
source_commit: string | null;
|
|
43
52
|
source_branch: string | null;
|
|
44
53
|
source_path: string | null;
|
|
@@ -47,4 +56,4 @@ interface RegistryActivation {
|
|
|
47
56
|
activated_at: string;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, type RegistryActivation, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
59
|
+
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, type RegistryActivation, SOURCE_AUTHORIZATION_ENV, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, applySourceHeaders, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
package/dist/cli.js
CHANGED
|
@@ -1813,19 +1813,20 @@ var variableIrSchema = z.object({
|
|
|
1813
1813
|
defaultValue: variableDefaultIrSchema.optional()
|
|
1814
1814
|
});
|
|
1815
1815
|
var sqlColumnSchema = z.object({ name: z.string(), type: z.enum(["text", "boolean", "integer", "bigint", "numeric", "double", "uuid", "date", "timestamptz", "jsonb"]), nullable: z.boolean() });
|
|
1816
|
+
var sqlObjectIrSchema = z.object({
|
|
1817
|
+
ref: z.string(),
|
|
1818
|
+
table: z.string(),
|
|
1819
|
+
columns: z.array(sqlColumnSchema.extend({ type: z.string() })).min(1),
|
|
1820
|
+
scan: z.string().min(1),
|
|
1821
|
+
read: z.array(z.string()).min(1)
|
|
1822
|
+
}).strict();
|
|
1816
1823
|
var compiledOperationSchema = z.object({
|
|
1817
1824
|
language: z.literal("sql").optional(),
|
|
1818
1825
|
/** Server-compiled object catalog and permission ceiling, never caller SQL. */
|
|
1819
1826
|
sqlQuery: z.object({
|
|
1820
1827
|
catalog: z.object({
|
|
1821
1828
|
identity: z.string(),
|
|
1822
|
-
objects: z.array(
|
|
1823
|
-
ref: z.string(),
|
|
1824
|
-
table: z.string(),
|
|
1825
|
-
columns: z.array(sqlColumnSchema.extend({ type: z.string() })).min(1),
|
|
1826
|
-
scan: z.string().min(1),
|
|
1827
|
-
read: z.array(z.string()).min(1)
|
|
1828
|
-
}).strict()).min(1).max(256)
|
|
1829
|
+
objects: z.array(sqlObjectIrSchema).min(1).max(256)
|
|
1829
1830
|
}).strict(),
|
|
1830
1831
|
read: z.array(z.string()).min(1).max(256),
|
|
1831
1832
|
maxRows: z.number().int().min(1).max(1e4)
|
|
@@ -2485,6 +2486,7 @@ var FLIPPED = {
|
|
|
2485
2486
|
">=": "<="
|
|
2486
2487
|
};
|
|
2487
2488
|
function resolveTable(resolver, table) {
|
|
2489
|
+
resolver.onTable?.(table);
|
|
2488
2490
|
const info = resolver.tables[table];
|
|
2489
2491
|
if (!info) {
|
|
2490
2492
|
throw new PolicyCompileError(`unknown table '${table}'`, "unknown-table", Object.keys(resolver.tables));
|
|
@@ -5400,10 +5402,13 @@ function sqlHash(value) {
|
|
|
5400
5402
|
return `sha256:${createHash("sha256").update(value).digest("hex")}`;
|
|
5401
5403
|
}
|
|
5402
5404
|
function createSqlCatalog({ canonical, publishedObjects, executionTarget }) {
|
|
5403
|
-
if (!publishedObjects.length || new Set(publishedObjects).size !== publishedObjects.length) throw new Error("SQL objects must be explicitly declared and unique");
|
|
5404
5405
|
const { ctx, diagnostics } = buildCompileContext(canonical);
|
|
5405
5406
|
if (diagnostics.some((d) => d.severity === "error")) throw new Error(diagnostics.map((d) => d.message).join("; "));
|
|
5406
|
-
|
|
5407
|
+
return createSqlCatalogFromContext({ canonical, publishedObjects, executionTarget, ctx });
|
|
5408
|
+
}
|
|
5409
|
+
function createSqlCatalogFromContext({ canonical, publishedObjects, executionTarget, ctx, identity: suppliedIdentity }) {
|
|
5410
|
+
if (!publishedObjects.length || new Set(publishedObjects).size !== publishedObjects.length) throw new Error("SQL objects must be explicitly declared and unique");
|
|
5411
|
+
const identity = suppliedIdentity ?? sqlHash(`ontology-sql-v1\0${computeSchemaHash(canonical)}\0${executionTarget}`);
|
|
5407
5412
|
const logicalNames = new Map(Object.entries(ctx.tables).map(([key, meta]) => [meta, key]));
|
|
5408
5413
|
const refOf = (meta) => `${meta.namespace ?? canonical.namespace}/${logicalNames.get(meta)}`;
|
|
5409
5414
|
const definitions = [canonical, ...canonical.imports ?? []];
|
|
@@ -5514,9 +5519,10 @@ var SqlEmitter = class {
|
|
|
5514
5519
|
only(cte, ["ctename", "ctequery", "ctematerialized", "location"]);
|
|
5515
5520
|
const name2 = str(cte.ctename);
|
|
5516
5521
|
if (scope.ctes.has(name2)) fail3("duplicate CTE");
|
|
5522
|
+
const materialization = cte.ctematerialized === "CTEMaterializeAlways" ? "MATERIALIZED " : cte.ctematerialized === "CTEMaterializeNever" ? "NOT MATERIALIZED " : cte.ctematerialized === "CTEMaterializeDefault" ? "" : fail3("unsupported CTE materialization");
|
|
5517
5523
|
const result2 = this.select(obj(cte.ctequery), { ...parent, ctes: scope.ctes });
|
|
5518
5524
|
scope.ctes.set(name2, result2);
|
|
5519
|
-
ctes.push(`${quoteIdentifier(name2)} AS (${result2.text})`);
|
|
5525
|
+
ctes.push(`${quoteIdentifier(name2)} AS ${materialization}(${result2.text})`);
|
|
5520
5526
|
}
|
|
5521
5527
|
}
|
|
5522
5528
|
const result = node.op === "SETOP_UNION" ? this.union(node, scope) : this.projection(node, scope);
|
|
@@ -11425,6 +11431,11 @@ var BASE_URL_ENV = "SEQUENCE_ORM_BASE_URL";
|
|
|
11425
11431
|
var TOKEN_ENV = "SEQUENCE_ORM_TOKEN";
|
|
11426
11432
|
var SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
11427
11433
|
var UNVERIFIED_SOURCE_REASON_ENV = "SEQUENCE_ORM_UNVERIFIED_SOURCE_REASON";
|
|
11434
|
+
var SOURCE_AUTHORIZATION_ENV = "SEQUENCE_ORM_SOURCE_AUTHORIZATION";
|
|
11435
|
+
function applySourceHeaders(env = process.env) {
|
|
11436
|
+
const token = env[SOURCE_AUTHORIZATION_ENV]?.trim();
|
|
11437
|
+
return token ? { "x-sequence-source-authorization": `Bearer ${token}` } : {};
|
|
11438
|
+
}
|
|
11428
11439
|
function applySourceFromEnv(env = process.env) {
|
|
11429
11440
|
const reason = env[UNVERIFIED_SOURCE_REASON_ENV]?.trim();
|
|
11430
11441
|
const override = reason ? { unverified_source_reason: reason } : {};
|
|
@@ -11984,7 +11995,8 @@ function describeActivation(activation) {
|
|
|
11984
11995
|
const by = `by ${activation.actor_sub.replace(/^google-apps\|/, "")}`;
|
|
11985
11996
|
if (activation.source_commit && activation.source_branch) {
|
|
11986
11997
|
const at = activation.source_path ? ` at ${activation.source_path}` : "";
|
|
11987
|
-
|
|
11998
|
+
const branch = activation.source_environment ? `${activation.source_environment}:${activation.source_branch}` : activation.source_branch;
|
|
11999
|
+
return `${since} from ${activation.source_commit.slice(0, 12)} on ${branch}${at} (${activation.provenance_class}) ${by}`;
|
|
11988
12000
|
}
|
|
11989
12001
|
const failure = activation.reported_source?.verification_failure;
|
|
11990
12002
|
const why = typeof failure === "string" ? `: ${failure}` : "";
|
|
@@ -12196,7 +12208,7 @@ async function applyV2Command(rest, dir) {
|
|
|
12196
12208
|
...allowDestructive ? { allow_destructive: true } : {},
|
|
12197
12209
|
...schemaAlreadyActive && registered.operation_set_id ? { operation_set_id: registered.operation_set_id } : {},
|
|
12198
12210
|
...applySourceFromEnv()
|
|
12199
|
-
});
|
|
12211
|
+
}, applySourceHeaders());
|
|
12200
12212
|
const live = { namespace, contentHash: registered.content_hash };
|
|
12201
12213
|
if ("ops_only" in applied) {
|
|
12202
12214
|
console.log(
|
|
@@ -12654,7 +12666,7 @@ async function applyCommand(rest) {
|
|
|
12654
12666
|
version_id: registered.version_id,
|
|
12655
12667
|
...allowDestructive ? { allow_destructive: true } : {},
|
|
12656
12668
|
...applySourceFromEnv()
|
|
12657
|
-
});
|
|
12669
|
+
}, applySourceHeaders());
|
|
12658
12670
|
if ("status" in applied) {
|
|
12659
12671
|
const verdict = await awaitQueuedApply({ dir, namespace, contentHash: registered.content_hash, runId: applied.run_id, applyWait });
|
|
12660
12672
|
return verdict === "live" ? writeGeneratedTypes(dir, loaded) : verdict;
|
|
@@ -12799,7 +12811,7 @@ async function apiRequest(method, path, body, options) {
|
|
|
12799
12811
|
if (!token) throw new Error("not authenticated \u2014 run: seq-studio login");
|
|
12800
12812
|
const response = await fetch(`${baseUrl}${path}`, {
|
|
12801
12813
|
method,
|
|
12802
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
12814
|
+
headers: { ...options?.headers, Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
12803
12815
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
12804
12816
|
});
|
|
12805
12817
|
if (response.status === 404 && options?.allow404) return null;
|
|
@@ -12826,8 +12838,8 @@ function errorDetail(payload) {
|
|
|
12826
12838
|
const fields = details && typeof details === "object" ? Object.entries(details).filter(([, value]) => typeof value === "string").map(([key, value]) => `${key}: ${String(value)}`) : [];
|
|
12827
12839
|
return `${String(first.message)}${code ? ` (${code})` : ""}${fields.length ? ` [${fields.join(", ")}]` : ""}`;
|
|
12828
12840
|
}
|
|
12829
|
-
async function apiRequestStrict(method, path, body) {
|
|
12830
|
-
const result = await apiRequest(method, path, body);
|
|
12841
|
+
async function apiRequestStrict(method, path, body, headers) {
|
|
12842
|
+
const result = await apiRequest(method, path, body, { headers });
|
|
12831
12843
|
if (result === null) throw new Error(`${method} ${path} returned no payload`);
|
|
12832
12844
|
return result;
|
|
12833
12845
|
}
|
|
@@ -12854,6 +12866,6 @@ function positional(rest) {
|
|
|
12854
12866
|
}
|
|
12855
12867
|
var firstLine2 = (sql4) => sql4.split("\n")[0] ?? sql4;
|
|
12856
12868
|
|
|
12857
|
-
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
12869
|
+
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, SOURCE_AUTHORIZATION_ENV, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, applySourceHeaders, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
12858
12870
|
//# sourceMappingURL=cli.js.map
|
|
12859
12871
|
//# sourceMappingURL=cli.js.map
|