@sequenceholdings/orm 2.8.5 → 2.9.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/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +2 -2
- package/dist/authoring.d.ts +2 -2
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +72 -72
- package/dist/canonical.d.ts +72 -72
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +93 -53
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +23 -1
- package/dist/cli.d.ts +23 -1
- package/dist/cli.js +90 -54
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +1 -1
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +2 -2
- package/dist/compiler.d.ts +2 -2
- package/dist/compiler.js +1 -1
- package/dist/compiler.js.map +1 -1
- package/dist/{constants-Dou1RkTo.d.cts → constants-D2o0vK6U.d.cts} +8 -1
- package/dist/{constants-Dou1RkTo.d.ts → constants-D2o0vK6U.d.ts} +8 -1
- package/dist/dynamic-input.d.cts +1 -1
- package/dist/dynamic-input.d.ts +1 -1
- package/dist/index.cjs +44 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -59
- package/dist/index.d.ts +60 -59
- package/dist/index.js +43 -25
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +73 -73
- package/dist/ir.d.ts +73 -73
- package/dist/ir.js.map +1 -1
- 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.map +1 -1
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +1 -1
- package/dist/sdl.d.ts +1 -1
- package/dist/sdl.js.map +1 -1
- package/package.json +3 -3
- package/templates/orm-namespace/package.json +2 -1
- package/dist/{definition-DjfC7Lll.d.cts → definition-B99BsOAO.d.cts} +4 -4
- package/dist/{definition-DjfC7Lll.d.ts → definition-B99BsOAO.d.ts} +4 -4
package/dist/cli.d.cts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/** Set by the seq-studio delegate; direct users export them. */
|
|
2
2
|
declare const BASE_URL_ENV = "SEQUENCE_ORM_BASE_URL";
|
|
3
3
|
declare const TOKEN_ENV = "SEQUENCE_ORM_TOKEN";
|
|
4
|
+
/** JSON `{repository_id, commit, path, dirty?}` naming the Git Service source of this apply; set by the seq-studio delegate. */
|
|
5
|
+
declare const SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
6
|
+
/** Namespace-admin override reason for an apply whose source does not verify; set by `seq-studio orm apply --unverified-source`. */
|
|
7
|
+
declare const UNVERIFIED_SOURCE_REASON_ENV = "SEQUENCE_ORM_UNVERIFIED_SOURCE_REASON";
|
|
8
|
+
/** The apply body's `source` claim, when the delegate supplied one. Atlas verifies it; it never authorizes anything. */
|
|
9
|
+
declare function applySourceFromEnv(env?: NodeJS.ProcessEnv): {
|
|
10
|
+
source?: Record<string, unknown>;
|
|
11
|
+
unverified_source_reason?: string;
|
|
12
|
+
};
|
|
4
13
|
/**
|
|
5
14
|
* Test/dev hook mirroring `LoadNamespaceOptions.ormModulePath`: when set, bare
|
|
6
15
|
* `'@sequenceholdings/orm'` imports in consumer files resolve to this path
|
|
@@ -12,6 +21,8 @@ type TokenProvider = () => Promise<string | null>;
|
|
|
12
21
|
/** Hand the CLI a refreshing token source (used by the seq-studio delegate). */
|
|
13
22
|
declare function setTokenProvider(provider: TokenProvider): void;
|
|
14
23
|
declare function runCli(argv: readonly string[]): Promise<number>;
|
|
24
|
+
/** Where the live version came from: `live since <time> from <commit> on <branch> at <path> by <actor>`. */
|
|
25
|
+
declare function describeActivation(activation: RegistryActivation): string;
|
|
15
26
|
interface ApplyWait {
|
|
16
27
|
wait: boolean;
|
|
17
28
|
timeoutMs: number;
|
|
@@ -24,5 +35,16 @@ declare function parseApplyWait(rest: readonly string[]): ApplyWait;
|
|
|
24
35
|
* details name the variable, column, constraint, or requirement at fault.
|
|
25
36
|
*/
|
|
26
37
|
declare function errorDetail(payload: unknown): string | null;
|
|
38
|
+
/** One row of the namespace's activation history, as the detail route returns it (absent on older Atlas). */
|
|
39
|
+
interface RegistryActivation {
|
|
40
|
+
id: string;
|
|
41
|
+
provenance_class: string;
|
|
42
|
+
source_commit: string | null;
|
|
43
|
+
source_branch: string | null;
|
|
44
|
+
source_path: string | null;
|
|
45
|
+
reported_source: Record<string, unknown> | null;
|
|
46
|
+
actor_sub: string;
|
|
47
|
+
activated_at: string;
|
|
48
|
+
}
|
|
27
49
|
|
|
28
|
-
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, TOKEN_ENV, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
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 };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/** Set by the seq-studio delegate; direct users export them. */
|
|
2
2
|
declare const BASE_URL_ENV = "SEQUENCE_ORM_BASE_URL";
|
|
3
3
|
declare const TOKEN_ENV = "SEQUENCE_ORM_TOKEN";
|
|
4
|
+
/** JSON `{repository_id, commit, path, dirty?}` naming the Git Service source of this apply; set by the seq-studio delegate. */
|
|
5
|
+
declare const SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
6
|
+
/** Namespace-admin override reason for an apply whose source does not verify; set by `seq-studio orm apply --unverified-source`. */
|
|
7
|
+
declare const UNVERIFIED_SOURCE_REASON_ENV = "SEQUENCE_ORM_UNVERIFIED_SOURCE_REASON";
|
|
8
|
+
/** The apply body's `source` claim, when the delegate supplied one. Atlas verifies it; it never authorizes anything. */
|
|
9
|
+
declare function applySourceFromEnv(env?: NodeJS.ProcessEnv): {
|
|
10
|
+
source?: Record<string, unknown>;
|
|
11
|
+
unverified_source_reason?: string;
|
|
12
|
+
};
|
|
4
13
|
/**
|
|
5
14
|
* Test/dev hook mirroring `LoadNamespaceOptions.ormModulePath`: when set, bare
|
|
6
15
|
* `'@sequenceholdings/orm'` imports in consumer files resolve to this path
|
|
@@ -12,6 +21,8 @@ type TokenProvider = () => Promise<string | null>;
|
|
|
12
21
|
/** Hand the CLI a refreshing token source (used by the seq-studio delegate). */
|
|
13
22
|
declare function setTokenProvider(provider: TokenProvider): void;
|
|
14
23
|
declare function runCli(argv: readonly string[]): Promise<number>;
|
|
24
|
+
/** Where the live version came from: `live since <time> from <commit> on <branch> at <path> by <actor>`. */
|
|
25
|
+
declare function describeActivation(activation: RegistryActivation): string;
|
|
15
26
|
interface ApplyWait {
|
|
16
27
|
wait: boolean;
|
|
17
28
|
timeoutMs: number;
|
|
@@ -24,5 +35,16 @@ declare function parseApplyWait(rest: readonly string[]): ApplyWait;
|
|
|
24
35
|
* details name the variable, column, constraint, or requirement at fault.
|
|
25
36
|
*/
|
|
26
37
|
declare function errorDetail(payload: unknown): string | null;
|
|
38
|
+
/** One row of the namespace's activation history, as the detail route returns it (absent on older Atlas). */
|
|
39
|
+
interface RegistryActivation {
|
|
40
|
+
id: string;
|
|
41
|
+
provenance_class: string;
|
|
42
|
+
source_commit: string | null;
|
|
43
|
+
source_branch: string | null;
|
|
44
|
+
source_path: string | null;
|
|
45
|
+
reported_source: Record<string, unknown> | null;
|
|
46
|
+
actor_sub: string;
|
|
47
|
+
activated_at: string;
|
|
48
|
+
}
|
|
27
49
|
|
|
28
|
-
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, TOKEN_ENV, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
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 };
|
package/dist/cli.js
CHANGED
|
@@ -102,6 +102,8 @@ function materializedRefreshFunctionName(table) {
|
|
|
102
102
|
function materializeLockKey(schema, table) {
|
|
103
103
|
return `orm:materialize:${schema}.${table}`;
|
|
104
104
|
}
|
|
105
|
+
var OPERATION_DOCUMENTS_FILE = "operations.documents.json";
|
|
106
|
+
var OPERATION_DOCUMENTS_VERSION = 1;
|
|
105
107
|
|
|
106
108
|
// src/hash.ts
|
|
107
109
|
function stableJson(value) {
|
|
@@ -10343,6 +10345,42 @@ async function readSnapshot(dir, ordinal) {
|
|
|
10343
10345
|
const path = join(dir, MIGRATIONS_DIRNAME, META_DIRNAME, `${pad(ordinal)}.snapshot.json`);
|
|
10344
10346
|
return parseJson(path, await readSnapshotText(dir, ordinal));
|
|
10345
10347
|
}
|
|
10348
|
+
async function verifyCommittedLedger(dir, entries) {
|
|
10349
|
+
const firstRequiredSnapshot = entries.length - 2;
|
|
10350
|
+
let previousId3;
|
|
10351
|
+
let previousSnapshotPresent = false;
|
|
10352
|
+
let previousHash = null;
|
|
10353
|
+
for (const [index3, entry] of entries.entries()) {
|
|
10354
|
+
const sql4 = await readMigrationSql(dir, entry);
|
|
10355
|
+
if (checksumOf(sql4) !== entry.checksum) {
|
|
10356
|
+
return `${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`;
|
|
10357
|
+
}
|
|
10358
|
+
const snapshotText = index3 >= firstRequiredSnapshot ? await readSnapshotText(dir, entry.ordinal) : await readPrunableSnapshotText(dir, entry.ordinal);
|
|
10359
|
+
if (snapshotText !== void 0) {
|
|
10360
|
+
if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
|
|
10361
|
+
return `the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`;
|
|
10362
|
+
}
|
|
10363
|
+
const snapshot = JSON.parse(snapshotText);
|
|
10364
|
+
if (previousSnapshotPresent && snapshot.prevId !== previousId3) {
|
|
10365
|
+
return `snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``;
|
|
10366
|
+
}
|
|
10367
|
+
previousId3 = snapshot.id;
|
|
10368
|
+
}
|
|
10369
|
+
previousSnapshotPresent = snapshotText !== void 0;
|
|
10370
|
+
if (entry.previous_content_hash !== previousHash) {
|
|
10371
|
+
return `content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``;
|
|
10372
|
+
}
|
|
10373
|
+
previousHash = entry.content_hash;
|
|
10374
|
+
}
|
|
10375
|
+
return void 0;
|
|
10376
|
+
}
|
|
10377
|
+
async function readPrunableSnapshotText(dir, ordinal) {
|
|
10378
|
+
const path = join(dir, MIGRATIONS_DIRNAME, META_DIRNAME, `${pad(ordinal)}.snapshot.json`);
|
|
10379
|
+
return readFile(path, "utf8").catch((error) => {
|
|
10380
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
|
|
10381
|
+
throw error;
|
|
10382
|
+
});
|
|
10383
|
+
}
|
|
10346
10384
|
async function readMigrationSql(dir, entry) {
|
|
10347
10385
|
const path = join(dir, MIGRATIONS_DIRNAME, `${entry.name}.sql`);
|
|
10348
10386
|
return readFile(path, "utf8").catch(() => {
|
|
@@ -10503,30 +10541,10 @@ async function checkWorkspace({
|
|
|
10503
10541
|
log(`no committed migrations for '${loaded.definition.namespace}' \u2014 run \`seq-studio orm diff\` and commit the result`);
|
|
10504
10542
|
return 1;
|
|
10505
10543
|
}
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
if (checksumOf(sql4) !== entry.checksum) {
|
|
10511
|
-
log(`${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`);
|
|
10512
|
-
return 1;
|
|
10513
|
-
}
|
|
10514
|
-
const snapshotText = await readSnapshotText(dir, entry.ordinal);
|
|
10515
|
-
if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
|
|
10516
|
-
log(`the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`);
|
|
10517
|
-
return 1;
|
|
10518
|
-
}
|
|
10519
|
-
const snapshot = JSON.parse(snapshotText);
|
|
10520
|
-
if (entry.ordinal > 1 && snapshot.prevId !== previousId3) {
|
|
10521
|
-
log(`snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``);
|
|
10522
|
-
return 1;
|
|
10523
|
-
}
|
|
10524
|
-
if (entry.previous_content_hash !== previousHash) {
|
|
10525
|
-
log(`content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``);
|
|
10526
|
-
return 1;
|
|
10527
|
-
}
|
|
10528
|
-
previousId3 = snapshot.id;
|
|
10529
|
-
previousHash = entry.content_hash;
|
|
10544
|
+
const broken = await verifyCommittedLedger(dir, workspace.journal.entries);
|
|
10545
|
+
if (broken) {
|
|
10546
|
+
log(broken);
|
|
10547
|
+
return 1;
|
|
10530
10548
|
}
|
|
10531
10549
|
if (tip.content_hash !== loaded.contentHash) {
|
|
10532
10550
|
log(`definitions changed since ${tip.name} \u2014 run \`seq-studio orm diff\` and commit the new migration`);
|
|
@@ -11405,6 +11423,22 @@ function parseArgs(argv) {
|
|
|
11405
11423
|
// src/cli.ts
|
|
11406
11424
|
var BASE_URL_ENV = "SEQUENCE_ORM_BASE_URL";
|
|
11407
11425
|
var TOKEN_ENV = "SEQUENCE_ORM_TOKEN";
|
|
11426
|
+
var SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
11427
|
+
var UNVERIFIED_SOURCE_REASON_ENV = "SEQUENCE_ORM_UNVERIFIED_SOURCE_REASON";
|
|
11428
|
+
function applySourceFromEnv(env = process.env) {
|
|
11429
|
+
const reason = env[UNVERIFIED_SOURCE_REASON_ENV]?.trim();
|
|
11430
|
+
const override = reason ? { unverified_source_reason: reason } : {};
|
|
11431
|
+
const raw = env[SOURCE_ENV];
|
|
11432
|
+
if (!raw) return override;
|
|
11433
|
+
let parsed;
|
|
11434
|
+
try {
|
|
11435
|
+
parsed = JSON.parse(raw);
|
|
11436
|
+
} catch {
|
|
11437
|
+
throw new Error(`${SOURCE_ENV} is not valid JSON`);
|
|
11438
|
+
}
|
|
11439
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${SOURCE_ENV} must be a JSON object`);
|
|
11440
|
+
return { source: Object.fromEntries(Object.entries(parsed)), ...override };
|
|
11441
|
+
}
|
|
11408
11442
|
var ORM_MODULE_PATH_ENV = "SEQUENCE_ORM_MODULE_PATH";
|
|
11409
11443
|
var USAGE = `usage:
|
|
11410
11444
|
seq-studio orm init <dir> scaffold a namespace package (v2: TypeScript schema + persisted operations)
|
|
@@ -11722,15 +11756,21 @@ async function generateCommand(rest) {
|
|
|
11722
11756
|
await writeGenerateOutputs(dir, compiled.project);
|
|
11723
11757
|
const { loaded, manifest } = compiled.project;
|
|
11724
11758
|
console.log(
|
|
11725
|
-
`wrote ${SCHEMA_GRAPHQL_FILE}, ${OPERATIONS_MANIFEST_FILE}, ${TYPE_POLICIES_FILE}, sql-operations.gen.ts, namespace.contract.json (${loaded.canonical.tables.length} table(s), ${loaded.canonical.views?.length ?? 0} view(s), ${Object.keys(manifest.operations).length} operation(s))`
|
|
11759
|
+
`wrote ${SCHEMA_GRAPHQL_FILE}, ${OPERATIONS_MANIFEST_FILE}, ${OPERATION_DOCUMENTS_FILE}, ${TYPE_POLICIES_FILE}, sql-operations.gen.ts, namespace.contract.json (${loaded.canonical.tables.length} table(s), ${loaded.canonical.views?.length ?? 0} view(s), ${Object.keys(manifest.operations).length} operation(s))`
|
|
11726
11760
|
);
|
|
11727
11761
|
return runConsumerCodegen(dir);
|
|
11728
11762
|
}
|
|
11729
11763
|
async function writeGenerateOutputs(dir, project) {
|
|
11730
|
-
const { loaded, sdl, manifest } = project;
|
|
11764
|
+
const { loaded, sdl, manifest, documents } = project;
|
|
11731
11765
|
await writeFile(join(dir, SCHEMA_GRAPHQL_FILE), sdl);
|
|
11732
11766
|
await writeFile(join(dir, "namespace.contract.json"), `${JSON.stringify(loaded.canonical, null, 2)}
|
|
11733
11767
|
`);
|
|
11768
|
+
const sortedDocuments = [...documents].sort((a, b) => a.path.localeCompare(b.path)).map(({ path, contents }) => ({ path, contents }));
|
|
11769
|
+
await writeFile(
|
|
11770
|
+
join(dir, OPERATION_DOCUMENTS_FILE),
|
|
11771
|
+
`${JSON.stringify({ documentsVersion: OPERATION_DOCUMENTS_VERSION, documents: sortedDocuments }, null, 2)}
|
|
11772
|
+
`
|
|
11773
|
+
);
|
|
11734
11774
|
const operations = Object.entries(manifest.operations).map(([name2, op]) => ({
|
|
11735
11775
|
name: name2,
|
|
11736
11776
|
kind: op.kind,
|
|
@@ -11936,8 +11976,20 @@ function reportRegistryState(registry) {
|
|
|
11936
11976
|
if (match && match.id === registry.activeVersionId) console.log("-- registry: this content is the ACTIVE version");
|
|
11937
11977
|
else if (match) console.log(`-- registry: registered (status ${match.status}), not active`);
|
|
11938
11978
|
else console.log(`-- registry: new content (active is ${active ? active.content_hash.slice(0, 12) : "none"})`);
|
|
11979
|
+
if (registry.activeActivation) console.log(`-- registry: ${describeActivation(registry.activeActivation)}`);
|
|
11939
11980
|
return 0;
|
|
11940
11981
|
}
|
|
11982
|
+
function describeActivation(activation) {
|
|
11983
|
+
const since = `live since ${activation.activated_at.slice(0, 16).replace("T", " ")}Z`;
|
|
11984
|
+
const by = `by ${activation.actor_sub.replace(/^google-apps\|/, "")}`;
|
|
11985
|
+
if (activation.source_commit && activation.source_branch) {
|
|
11986
|
+
const at = activation.source_path ? ` at ${activation.source_path}` : "";
|
|
11987
|
+
return `${since} from ${activation.source_commit.slice(0, 12)} on ${activation.source_branch}${at} (${activation.provenance_class}) ${by}`;
|
|
11988
|
+
}
|
|
11989
|
+
const failure = activation.reported_source?.verification_failure;
|
|
11990
|
+
const why = typeof failure === "string" ? `: ${failure}` : "";
|
|
11991
|
+
return `${since} from an untraced source (${activation.provenance_class}${why}) ${by}`;
|
|
11992
|
+
}
|
|
11941
11993
|
var META_DIRNAME2 = "meta";
|
|
11942
11994
|
var JOURNAL_FILENAME2 = "journal.json";
|
|
11943
11995
|
var padOrdinal = (ordinal) => String(ordinal).padStart(4, "0");
|
|
@@ -12025,30 +12077,10 @@ async function checkWorkspaceV2({
|
|
|
12025
12077
|
log(`no committed migrations for '${namespace}' \u2014 run \`seq-studio orm diff\` and commit the result`);
|
|
12026
12078
|
return 1;
|
|
12027
12079
|
}
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
if (checksumOf(sql4) !== entry.checksum) {
|
|
12033
|
-
log(`${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`);
|
|
12034
|
-
return 1;
|
|
12035
|
-
}
|
|
12036
|
-
const snapshotText = await readSnapshotText(dir, entry.ordinal);
|
|
12037
|
-
if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
|
|
12038
|
-
log(`the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`);
|
|
12039
|
-
return 1;
|
|
12040
|
-
}
|
|
12041
|
-
const snapshot = JSON.parse(snapshotText);
|
|
12042
|
-
if (entry.ordinal > 1 && snapshot.prevId !== previousId3) {
|
|
12043
|
-
log(`snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``);
|
|
12044
|
-
return 1;
|
|
12045
|
-
}
|
|
12046
|
-
if (entry.previous_content_hash !== previousHash) {
|
|
12047
|
-
log(`content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``);
|
|
12048
|
-
return 1;
|
|
12049
|
-
}
|
|
12050
|
-
previousId3 = snapshot.id;
|
|
12051
|
-
previousHash = entry.content_hash;
|
|
12080
|
+
const broken = await verifyCommittedLedger(dir, workspace.journal.entries);
|
|
12081
|
+
if (broken) {
|
|
12082
|
+
log(broken);
|
|
12083
|
+
return 1;
|
|
12052
12084
|
}
|
|
12053
12085
|
if (tip.content_hash !== loaded.hash) {
|
|
12054
12086
|
log(`definitions changed since ${tip.name} \u2014 run \`seq-studio orm diff\` and commit the new migration`);
|
|
@@ -12162,7 +12194,8 @@ async function applyV2Command(rest, dir) {
|
|
|
12162
12194
|
const applied = await apiRequestStrict("POST", `/api/orm/namespaces/${namespace}/apply`, {
|
|
12163
12195
|
version_id: registered.version_id,
|
|
12164
12196
|
...allowDestructive ? { allow_destructive: true } : {},
|
|
12165
|
-
...schemaAlreadyActive && registered.operation_set_id ? { operation_set_id: registered.operation_set_id } : {}
|
|
12197
|
+
...schemaAlreadyActive && registered.operation_set_id ? { operation_set_id: registered.operation_set_id } : {},
|
|
12198
|
+
...applySourceFromEnv()
|
|
12166
12199
|
});
|
|
12167
12200
|
const live = { namespace, contentHash: registered.content_hash };
|
|
12168
12201
|
if ("ops_only" in applied) {
|
|
@@ -12619,7 +12652,8 @@ async function applyCommand(rest) {
|
|
|
12619
12652
|
if (dryRun) return dryRunRehearsal({ namespace, versionId: registered.version_id, contentHash: registered.content_hash });
|
|
12620
12653
|
const applied = await apiRequestStrict("POST", `/api/orm/namespaces/${namespace}/apply`, {
|
|
12621
12654
|
version_id: registered.version_id,
|
|
12622
|
-
...allowDestructive ? { allow_destructive: true } : {}
|
|
12655
|
+
...allowDestructive ? { allow_destructive: true } : {},
|
|
12656
|
+
...applySourceFromEnv()
|
|
12623
12657
|
});
|
|
12624
12658
|
if ("status" in applied) {
|
|
12625
12659
|
const verdict = await awaitQueuedApply({ dir, namespace, contentHash: registered.content_hash, runId: applied.run_id, applyWait });
|
|
@@ -12799,11 +12833,13 @@ async function apiRequestStrict(method, path, body) {
|
|
|
12799
12833
|
}
|
|
12800
12834
|
async function fetchRegistryState(namespace, contentHash) {
|
|
12801
12835
|
if (!process.env[BASE_URL_ENV]?.trim() || !await resolveToken()) return { kind: "offline" };
|
|
12802
|
-
const body = await apiRequest("GET", `/api/orm/namespaces/${namespace}?hash=${encodeURIComponent(contentHash)}`, void 0, { allow404: true });
|
|
12836
|
+
const body = await apiRequest("GET", `/api/orm/namespaces/${namespace}?hash=${encodeURIComponent(contentHash)}&activations_limit=1`, void 0, { allow404: true });
|
|
12803
12837
|
if (!body) return { kind: "missing" };
|
|
12838
|
+
const latest = body.activations?.[0];
|
|
12804
12839
|
return {
|
|
12805
12840
|
kind: "found",
|
|
12806
12841
|
activeVersionId: body.namespace.active_version_id,
|
|
12842
|
+
activeActivation: latest && latest.id === body.namespace.active_activation_id ? latest : null,
|
|
12807
12843
|
versions: body.versions,
|
|
12808
12844
|
hashVersion: body.hash_version ?? null
|
|
12809
12845
|
};
|
|
@@ -12818,6 +12854,6 @@ function positional(rest) {
|
|
|
12818
12854
|
}
|
|
12819
12855
|
var firstLine2 = (sql4) => sql4.split("\n")[0] ?? sql4;
|
|
12820
12856
|
|
|
12821
|
-
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, TOKEN_ENV, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
12857
|
+
export { BASE_URL_ENV, ORM_MODULE_PATH_ENV, SOURCE_ENV, TOKEN_ENV, UNVERIFIED_SOURCE_REASON_ENV, applySourceFromEnv, describeActivation, errorDetail, parseApplyWait, runCli, setTokenProvider };
|
|
12822
12858
|
//# sourceMappingURL=cli.js.map
|
|
12823
12859
|
//# sourceMappingURL=cli.js.map
|