@everystack/cli 0.4.60 → 0.4.64

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.
Files changed (116) hide show
  1. package/package.json +19 -2
  2. package/src/backfill.ts +3 -3
  3. package/src/cli/alter-type-dependents.ts +1 -1
  4. package/src/cli/apply-authority.ts +1 -1
  5. package/src/cli/apply-execute.ts +10 -10
  6. package/src/cli/audit-api.ts +4 -4
  7. package/src/cli/audit-source-api.ts +2 -2
  8. package/src/cli/authz-adoption-class.ts +4 -4
  9. package/src/cli/authz-baseline.ts +2 -2
  10. package/src/cli/authz-canonical.ts +2 -2
  11. package/src/cli/authz-compile.ts +3 -3
  12. package/src/cli/authz-contract-io.ts +2 -2
  13. package/src/cli/authz-contract.ts +4 -4
  14. package/src/cli/authz-derive.ts +2 -2
  15. package/src/cli/authz-identity.ts +1 -1
  16. package/src/cli/authz-ownership.ts +1 -1
  17. package/src/cli/authz-reconcile.ts +4 -4
  18. package/src/cli/authz-redteam.ts +1 -1
  19. package/src/cli/authz-render.ts +2 -2
  20. package/src/cli/aws.ts +57 -4
  21. package/src/cli/backfill.ts +3 -3
  22. package/src/cli/branch-db.ts +5 -5
  23. package/src/cli/bundle-weight.ts +2 -2
  24. package/src/cli/commands/analyze.ts +2 -2
  25. package/src/cli/commands/audit.ts +10 -10
  26. package/src/cli/commands/bundle.ts +6 -6
  27. package/src/cli/commands/cache.ts +75 -3
  28. package/src/cli/commands/console.ts +6 -6
  29. package/src/cli/commands/db-apply.ts +25 -25
  30. package/src/cli/commands/db-approvers.ts +4 -4
  31. package/src/cli/commands/db-authz.ts +15 -15
  32. package/src/cli/commands/db-backfill.ts +10 -10
  33. package/src/cli/commands/db-backup.ts +7 -7
  34. package/src/cli/commands/db-branch.ts +8 -8
  35. package/src/cli/commands/db-build.ts +7 -7
  36. package/src/cli/commands/db-check.ts +16 -16
  37. package/src/cli/commands/db-diff.ts +6 -6
  38. package/src/cli/commands/db-exec.ts +8 -8
  39. package/src/cli/commands/db-export.ts +10 -10
  40. package/src/cli/commands/db-fingerprint.ts +14 -14
  41. package/src/cli/commands/db-fork.ts +6 -6
  42. package/src/cli/commands/db-generate.ts +19 -19
  43. package/src/cli/commands/db-plan.ts +25 -25
  44. package/src/cli/commands/db-pull.ts +18 -18
  45. package/src/cli/commands/db-reconcile.ts +14 -14
  46. package/src/cli/commands/db-refresh.ts +7 -7
  47. package/src/cli/commands/db-snapshot.ts +5 -5
  48. package/src/cli/commands/db-swap.ts +26 -26
  49. package/src/cli/commands/db-sync.ts +18 -18
  50. package/src/cli/commands/db.ts +283 -18
  51. package/src/cli/commands/deploy.ts +39 -5
  52. package/src/cli/commands/diag.ts +10 -10
  53. package/src/cli/commands/lighthouse.ts +3 -3
  54. package/src/cli/commands/logs.ts +5 -5
  55. package/src/cli/commands/pipeline-run.ts +7 -7
  56. package/src/cli/commands/runbook.ts +5 -5
  57. package/src/cli/commands/secrets.ts +5 -5
  58. package/src/cli/commands/security-probe.ts +4 -4
  59. package/src/cli/commands/security.ts +6 -6
  60. package/src/cli/commands/status.ts +3 -3
  61. package/src/cli/commands/task-probe.ts +4 -4
  62. package/src/cli/commands/ui-audit.ts +5 -5
  63. package/src/cli/commands/update.ts +64 -8
  64. package/src/cli/component-audit.ts +5 -5
  65. package/src/cli/config.ts +2 -2
  66. package/src/cli/db-build.ts +6 -6
  67. package/src/cli/db-source.ts +2 -2
  68. package/src/cli/declared-derived.ts +5 -5
  69. package/src/cli/declared-diff.ts +5 -5
  70. package/src/cli/deploy-probe.ts +3 -3
  71. package/src/cli/derived-apply.ts +5 -5
  72. package/src/cli/derived-compile.ts +4 -4
  73. package/src/cli/derived-grants.ts +1 -1
  74. package/src/cli/derived-introspect.ts +3 -3
  75. package/src/cli/derived-lint.ts +2 -2
  76. package/src/cli/derived-plan.ts +5 -5
  77. package/src/cli/derived-render.ts +6 -6
  78. package/src/cli/direct-venue.ts +2 -2
  79. package/src/cli/discover.ts +2 -2
  80. package/src/cli/edge-plan.ts +8 -8
  81. package/src/cli/exec-digest.ts +1 -1
  82. package/src/cli/exec-execute.ts +1 -1
  83. package/src/cli/exec-log.ts +1 -1
  84. package/src/cli/exec-run.ts +2 -2
  85. package/src/cli/git-descent.ts +5 -5
  86. package/src/cli/index.ts +48 -47
  87. package/src/cli/migration-compile.ts +7 -7
  88. package/src/cli/migration-generate.ts +6 -6
  89. package/src/cli/model-api.ts +16 -16
  90. package/src/cli/model-render.ts +6 -6
  91. package/src/cli/mutation-lease.ts +1 -1
  92. package/src/cli/observability.ts +1 -1
  93. package/src/cli/refresh-execute.ts +2 -2
  94. package/src/cli/runbook/generate.ts +3 -3
  95. package/src/cli/runbook/index.ts +7 -7
  96. package/src/cli/runbook/sections.ts +2 -2
  97. package/src/cli/schema-compile.ts +4 -4
  98. package/src/cli/schema-diff.ts +1 -1
  99. package/src/cli/schema-fingerprint.ts +7 -7
  100. package/src/cli/schema-introspect.ts +3 -3
  101. package/src/cli/schema-source.ts +1 -1
  102. package/src/cli/schema-swap.ts +4 -4
  103. package/src/cli/security-catalog.ts +1 -1
  104. package/src/cli/stage-backup.ts +3 -3
  105. package/src/cli/stage-read-consistency.ts +6 -6
  106. package/src/cli/state-apply.ts +7 -7
  107. package/src/cli/swap-execute.ts +3 -3
  108. package/src/cli/swap-heartbeat.ts +1 -1
  109. package/src/cli/swap-pair.ts +7 -7
  110. package/src/cli/task-poll.ts +2 -2
  111. package/src/cli/ui-bloat.ts +1 -1
  112. package/src/cli/utils/secrets.ts +1 -1
  113. package/src/exec.ts +7 -7
  114. package/src/reconcile.ts +2 -2
  115. package/src/refresh.ts +2 -2
  116. package/src/sst.ts +1 -1
@@ -9,9 +9,9 @@
9
9
  * Writes directly to CloudFront KVS — no Lambda invoke.
10
10
  */
11
11
 
12
- import { resolveConfig } from '../config.js';
13
- import { putKvsKey, createInvalidation } from '../aws.js';
14
- import { step, success, warn, fail, info } from '../output.js';
12
+ import { resolveConfig } from '../config';
13
+ import { putKvsKey, createInvalidation, getDistributionStatus, getFromS3 } from '../aws';
14
+ import { step, success, warn, fail, info } from '../output';
15
15
 
16
16
  const VALID_ORIGINS = ['api', 'media', 'web'] as const;
17
17
  type CacheOrigin = typeof VALID_ORIGINS[number];
@@ -32,6 +32,19 @@ export async function cachePurgeCommand(flags: Record<string, string>): Promise<
32
32
  process.exit(1);
33
33
  }
34
34
 
35
+ const force = flags.force === 'true';
36
+
37
+ // Safety gate: verify the origin is serving the expected release and the distribution is stable.
38
+ if (!force) {
39
+ const channel = flags.channel || flags.stage || 'production';
40
+ const blocked = await preflight(config.region, config.baseUrl, config.updatesBucket, channel, config.distributionId);
41
+ if (blocked) {
42
+ fail(blocked);
43
+ info('Pass --force to override this check.');
44
+ process.exit(1);
45
+ }
46
+ }
47
+
35
48
  // Key resolution: --path wins > --origin > global
36
49
  let key: string;
37
50
  if (flags.path) {
@@ -91,3 +104,62 @@ export async function cachePurgeCommand(flags: Record<string, string>): Promise<
91
104
  }
92
105
  }
93
106
  }
107
+
108
+ /**
109
+ * Pre-purge safety checks. Returns an error message if blocked, null if clear.
110
+ * @internal Exported for testing.
111
+ */
112
+ export async function preflight(
113
+ region: string,
114
+ baseUrl: string,
115
+ updatesBucket: string,
116
+ channel: string,
117
+ distributionId?: string,
118
+ ): Promise<string | null> {
119
+ // 1. Read the channel pointer to get the expected updateId.
120
+ const pointerKey = `${channel}/web/manifest.json`;
121
+ const pointerData = await getFromS3(region, updatesBucket, pointerKey);
122
+ if (!pointerData) {
123
+ return `No release manifest found for channel "${channel}". Run \`everystack update\` first.`;
124
+ }
125
+ let expectedUpdateId: string;
126
+ try {
127
+ const pointer = JSON.parse(pointerData.toString('utf8'));
128
+ expectedUpdateId = pointer.updateId;
129
+ } catch {
130
+ return `Channel manifest for "${channel}" is malformed.`;
131
+ }
132
+ if (!expectedUpdateId) {
133
+ return `Channel manifest for "${channel}" has no updateId.`;
134
+ }
135
+
136
+ // 2. Probe the origin for the serving release.
137
+ try {
138
+ const probe = `${baseUrl}?_probe=${Date.now()}`;
139
+ const res = await fetch(probe, { redirect: 'follow' });
140
+ const serving = res.headers.get('x-everystack-release');
141
+ if (serving !== expectedUpdateId) {
142
+ return (
143
+ `Origin is serving release ${serving ? serving.slice(0, 12) + '...' : '(none)'} ` +
144
+ `but the channel pointer is ${expectedUpdateId.slice(0, 12)}.... ` +
145
+ `Purging now would expose stale containers to uncached traffic.`
146
+ );
147
+ }
148
+ } catch (err: any) {
149
+ return `Could not reach origin at ${baseUrl}: ${err.message}`;
150
+ }
151
+
152
+ // 3. Check distribution status (if discoverable).
153
+ if (distributionId) {
154
+ try {
155
+ const status = await getDistributionStatus(region, distributionId);
156
+ if (status !== 'Deployed') {
157
+ return `CloudFront distribution is "${status}" (not Deployed). Wait for propagation to finish.`;
158
+ }
159
+ } catch {
160
+ // Best-effort — missing permission is not a blocker.
161
+ }
162
+ }
163
+
164
+ return null;
165
+ }
@@ -15,12 +15,12 @@ import * as readline from 'node:readline';
15
15
  import * as fs from 'node:fs';
16
16
  import * as path from 'node:path';
17
17
  import * as os from 'node:os';
18
- import { resolveConfig, opsFunction, type CliConfig } from '../config.js';
19
- import { invokeAction } from '../aws.js';
20
- import { success, fail, info } from '../output.js';
21
- import { formatResult } from '../utils/table.js';
22
- import { isComplete } from '../utils/bracket-counter.js';
23
- import { createCompleter } from '../utils/completer.js';
18
+ import { resolveConfig, opsFunction, type CliConfig } from '../config';
19
+ import { invokeAction } from '../aws';
20
+ import { success, fail, info } from '../output';
21
+ import { formatResult } from '../utils/table';
22
+ import { isComplete } from '../utils/bracket-counter';
23
+ import { createCompleter } from '../utils/completer';
24
24
 
25
25
  const HISTORY_DIR = path.join(os.homedir(), '.everystack');
26
26
  const HISTORY_FILE = path.join(HISTORY_DIR, 'console_history');
@@ -30,33 +30,33 @@
30
30
  */
31
31
 
32
32
  import fs from 'node:fs/promises';
33
- import { type QueryRunner } from '../authz-contract.js';
34
- import { currentGitRef } from '../state-apply.js';
35
- import { planHash, PLAN_VERSION, type EdgePlan } from '../edge-plan.js';
36
- import { verifyDescent, type DescentVerdict, type LiveState } from '../git-descent.js';
37
- import { checkDestructiveAuthority, readApproverParam, resolveCallerIdentity, type AuthorityVerdict } from '../apply-authority.js';
38
- import { resolveModelsPath } from '../models-path.js';
39
- import { loadModels } from './db-generate.js';
40
- import { loadDeclaredDerived } from '../declared-derived.js';
41
- import { compileTableContract } from '../authz-compile.js';
42
- import { governedRoleSet, ungovernedGrants } from '../authz-reconcile.js';
43
- import { readBaselineFile, checkAgainstBaseline, baselineRefusal } from '../authz-baseline.js';
44
- import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source.js';
45
- import { borrowedSessionRunner, type SessionRunner } from '../session.js';
46
- import { resolveConfig, opsFunction } from '../config.js';
47
- import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws.js';
48
- import { executeApplyPlan, type ApplyPlanResult } from '../apply-execute.js';
49
- import { estimateOpsRuntimeFit } from '../ops-fit.js';
50
- import { resolveOperatorUrlViaStage } from '../direct-venue.js';
51
- import { withMutationLease, MutationLeaseError } from '../mutation-lease.js';
52
- import { readStageStateTwice, stageDestructiveRefusal } from '../stage-read-consistency.js';
53
- import { step, success, fail, info, warn } from '../output.js';
33
+ import { type QueryRunner } from '../authz-contract';
34
+ import { currentGitRef } from '../state-apply';
35
+ import { planHash, PLAN_VERSION, type EdgePlan } from '../edge-plan';
36
+ import { verifyDescent, type DescentVerdict, type LiveState } from '../git-descent';
37
+ import { checkDestructiveAuthority, readApproverParam, resolveCallerIdentity, type AuthorityVerdict } from '../apply-authority';
38
+ import { resolveModelsPath } from '../models-path';
39
+ import { loadModels } from './db-generate';
40
+ import { loadDeclaredDerived } from '../declared-derived';
41
+ import { compileTableContract } from '../authz-compile';
42
+ import { governedRoleSet, ungovernedGrants } from '../authz-reconcile';
43
+ import { readBaselineFile, checkAgainstBaseline, baselineRefusal } from '../authz-baseline';
44
+ import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source';
45
+ import { borrowedSessionRunner, type SessionRunner } from '../session';
46
+ import { resolveConfig, opsFunction } from '../config';
47
+ import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws';
48
+ import { executeApplyPlan, type ApplyPlanResult } from '../apply-execute';
49
+ import { estimateOpsRuntimeFit } from '../ops-fit';
50
+ import { resolveOperatorUrlViaStage } from '../direct-venue';
51
+ import { withMutationLease, MutationLeaseError } from '../mutation-lease';
52
+ import { readStageStateTwice, stageDestructiveRefusal } from '../stage-read-consistency';
53
+ import { step, success, fail, info, warn } from '../output';
54
54
 
55
55
  // The apply core lives in apply-execute.ts (shared with the ops Lambda's
56
56
  // db:apply action). Re-exported so the existing integration suites — and any
57
57
  // other in-repo caller — keep importing it from this command module.
58
- export { executeApplyPlan } from '../apply-execute.js';
59
- export type { ApplyPlanOptions, ApplyPlanResult } from '../apply-execute.js';
58
+ export { executeApplyPlan } from '../apply-execute';
59
+ export type { ApplyPlanOptions, ApplyPlanResult } from '../apply-execute';
60
60
 
61
61
  // ---------------------------------------------------------------------------
62
62
  // The CLI shell.
@@ -210,7 +210,7 @@ async function applyPlanViaStage(
210
210
  process.exit(1);
211
211
  }
212
212
  step(`Destructive authority: checking the approver set for stage ${flags.stage}...`);
213
- const { parseAppName } = await import('../discover.js');
213
+ const { parseAppName } = await import('../discover');
214
214
  const appName = await parseAppName();
215
215
  const approvers = await readApproverParam(region, appName, flags.stage);
216
216
  const identity = approvers === null ? null : await resolveCallerIdentity(region);
@@ -368,7 +368,7 @@ export async function dbApplyCommand(flags: Record<string, string>): Promise<voi
368
368
  }
369
369
  if (flags.stage) {
370
370
  const config = await resolveConfig(flags.stage);
371
- const { parseAppName } = await import('../discover.js');
371
+ const { parseAppName } = await import('../discover');
372
372
  const appName = await parseAppName();
373
373
  verifyAuthority = async () => {
374
374
  step(`Destructive authority: checking the approver set for stage ${flags.stage}...`);
@@ -14,15 +14,15 @@
14
14
  * path segments (`ty` matches `user/ty` and an assumed-role session `ty`).
15
15
  */
16
16
 
17
- import { resolveConfig } from '../config.js';
17
+ import { resolveConfig } from '../config';
18
18
  import {
19
19
  approverParamName,
20
20
  parseApproverValue,
21
21
  readApproverParam,
22
22
  writeApproverParam,
23
23
  removeApproverParam,
24
- } from '../apply-authority.js';
25
- import { step, success, fail, info, warn } from '../output.js';
24
+ } from '../apply-authority';
25
+ import { step, success, fail, info, warn } from '../output';
26
26
 
27
27
  export async function dbApproversCommand(flags: Record<string, string>): Promise<void> {
28
28
  if (!flags.stage) {
@@ -32,7 +32,7 @@ export async function dbApproversCommand(flags: Record<string, string>): Promise
32
32
 
33
33
  step('Resolving deployed config...');
34
34
  const config = await resolveConfig(flags.stage);
35
- const { parseAppName } = await import('../discover.js');
35
+ const { parseAppName } = await import('../discover');
36
36
  const appName = await parseAppName();
37
37
  const paramName = approverParamName(appName, flags.stage);
38
38
 
@@ -31,7 +31,7 @@ import {
31
31
  diffContracts,
32
32
  type QueryRunner,
33
33
  type AuthzContract,
34
- } from '../authz-contract.js';
34
+ } from '../authz-contract';
35
35
  import {
36
36
  buildProbeSql,
37
37
  PROBE_SELECT_SQL,
@@ -42,26 +42,26 @@ import {
42
42
  toGrantGap,
43
43
  buildInheritedPrivilegeSql,
44
44
  toInheritedGrant,
45
- } from '../authz-redteam.js';
45
+ } from '../authz-redteam';
46
46
  import {
47
47
  buildOwnerProbeSql,
48
48
  OWNER_PROBE_SELECT_SQL,
49
49
  toOwnerProbeResult,
50
50
  evaluateOwnerProbe,
51
51
  type OwnerProbe,
52
- } from '../authz-owner-probe.js';
53
- import { modelOwner } from '../authz-compile.js';
54
- import { writeContract, loadContract } from '../authz-contract-io.js';
55
- import { renderContractMarkdown } from '../authz-render.js';
56
- import { FUNCTIONS_SQL, contractFunctionRow } from '../security-catalog.js';
57
- import { resolveConfig, opsFunction } from '../config.js';
58
- import { resolveModelsPath } from '../models-path.js';
59
- import { resolveDbSource, connectingVia, createUrlProbeRunner } from '../db-source.js';
60
- import { borrowedSessionRunner, type SessionRunner } from '../session.js';
61
- import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws.js';
62
- import { step, success, fail, info, warn } from '../output.js';
63
- import { opsAdviceLines, IAM_ADVICE } from '../ops-advice.js';
64
- import { loadModels } from './db-generate.js';
52
+ } from '../authz-owner-probe';
53
+ import { modelOwner } from '../authz-compile';
54
+ import { writeContract, loadContract } from '../authz-contract-io';
55
+ import { renderContractMarkdown } from '../authz-render';
56
+ import { FUNCTIONS_SQL, contractFunctionRow } from '../security-catalog';
57
+ import { resolveConfig, opsFunction } from '../config';
58
+ import { resolveModelsPath } from '../models-path';
59
+ import { resolveDbSource, connectingVia, createUrlProbeRunner } from '../db-source';
60
+ import { borrowedSessionRunner, type SessionRunner } from '../session';
61
+ import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws';
62
+ import { step, success, fail, info, warn } from '../output';
63
+ import { opsAdviceLines, IAM_ADVICE } from '../ops-advice';
64
+ import { loadModels } from './db-generate';
65
65
 
66
66
  const DEFAULT_DIR = 'authz';
67
67
 
@@ -18,22 +18,22 @@
18
18
  * reads and writes its own per-database record.
19
19
  */
20
20
 
21
- import type { QueryRunner } from '../authz-contract.js';
21
+ import type { QueryRunner } from '../authz-contract';
22
22
  import {
23
23
  planBackfills,
24
24
  readBackfillLog,
25
25
  executeBackfills,
26
26
  markBackfillApplied,
27
27
  type BackfillPlan,
28
- } from '../backfill.js';
29
- import { currentGitRef } from '../state-apply.js';
30
- import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source.js';
31
- import { resolveOperatorUrlViaStage } from '../direct-venue.js';
32
- import { withMutationLease, MutationLeaseError } from '../mutation-lease.js';
33
- import { resolveConfig, opsFunction } from '../config.js';
34
- import { invokeAction } from '../aws.js';
35
- import { readSqlDirIfPresent } from './db-sync.js';
36
- import { step, success, fail, info, warn } from '../output.js';
28
+ } from '../backfill';
29
+ import { currentGitRef } from '../state-apply';
30
+ import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source';
31
+ import { resolveOperatorUrlViaStage } from '../direct-venue';
32
+ import { withMutationLease, MutationLeaseError } from '../mutation-lease';
33
+ import { resolveConfig, opsFunction } from '../config';
34
+ import { invokeAction } from '../aws';
35
+ import { readSqlDirIfPresent } from './db-sync';
36
+ import { step, success, fail, info, warn } from '../output';
37
37
 
38
38
  const DEFAULT_DIR = 'db/backfills';
39
39
 
@@ -19,16 +19,16 @@ import { spawn } from 'node:child_process';
19
19
  import { createGzip } from 'node:zlib';
20
20
  import { pipeline } from 'node:stream/promises';
21
21
  import { randomBytes } from 'node:crypto';
22
- import { resolveConfig, opsFunction, type CliConfig } from '../config.js';
23
- import { invokeAction, presignGet, getS3 } from '../aws.js';
24
- import { runStageBackup, stageBackupDeps } from '../stage-backup.js';
22
+ import { resolveConfig, opsFunction, type CliConfig } from '../config';
23
+ import { invokeAction, presignGet, getS3 } from '../aws';
24
+ import { runStageBackup, stageBackupDeps } from '../stage-backup';
25
25
  import {
26
26
  parseBackupRef, keyForId, crossStageGuard, restoreTargetGuard,
27
27
  backupKey, backupId, metaKey, utcStamp,
28
- } from '../backup.js';
29
- import { pgEnvFromUrl, pgKeepaliveConninfo } from './db.js';
30
- import { pollTaskUntilStopped } from '../task-poll.js';
31
- import { step, success, fail, info, warn } from '../output.js';
28
+ } from '../backup';
29
+ import { pgEnvFromUrl, pgKeepaliveConninfo } from './db';
30
+ import { pollTaskUntilStopped } from '../task-poll';
31
+ import { step, success, fail, info, warn } from '../output';
32
32
 
33
33
  /** Which database db:backup dumps. LOCAL requires a target --stage (its bucket receives the upload
34
34
  * AND names the backup id). Note this DIVERGES from db:export, where --database-url and --stage are
@@ -34,14 +34,14 @@ import {
34
34
  templateName,
35
35
  currentBranch,
36
36
  localBranches,
37
- } from '../branch-db.js';
38
- import { currentGitRef } from '../state-apply.js';
39
- import { fingerprintModels } from '../schema-fingerprint.js';
40
- import { resolveDbSource, type DbSource } from '../db-source.js';
41
- import { resolveModelsPath } from '../models-path.js';
42
- import { loadDeclaredDerived, retiredSqlDirAnywhere, retiredSqlDirFlagRefusal, type DeclaredDerived } from '../declared-derived.js';
43
- import { loadModels } from './db-generate.js';
44
- import { step, success, fail, info, warn } from '../output.js';
37
+ } from '../branch-db';
38
+ import { currentGitRef } from '../state-apply';
39
+ import { fingerprintModels } from '../schema-fingerprint';
40
+ import { resolveDbSource, type DbSource } from '../db-source';
41
+ import { resolveModelsPath } from '../models-path';
42
+ import { loadDeclaredDerived, retiredSqlDirAnywhere, retiredSqlDirFlagRefusal, type DeclaredDerived } from '../declared-derived';
43
+ import { loadModels } from './db-generate';
44
+ import { step, success, fail, info, warn } from '../output';
45
45
 
46
46
  function requireUrl(flags: Record<string, string>, verb: string): string {
47
47
  let dbSource: DbSource;
@@ -25,13 +25,13 @@
25
25
  */
26
26
 
27
27
  import type { ModelDescriptor } from '@everystack/model';
28
- import { buildIntoDatabase } from '../db-build.js';
29
- import { createUrlRunner } from '../db-source.js';
30
- import { resolveModelsPath } from '../models-path.js';
31
- import { loadDeclaredDerived, retiredSqlDirAnywhere, retiredSqlDirFlagRefusal, type DeclaredDerived } from '../declared-derived.js';
32
- import { loadModels } from './db-generate.js';
33
- import { currentGitRef } from '../state-apply.js';
34
- import { step, info, success, fail, warn } from '../output.js';
28
+ import { buildIntoDatabase } from '../db-build';
29
+ import { createUrlRunner } from '../db-source';
30
+ import { resolveModelsPath } from '../models-path';
31
+ import { loadDeclaredDerived, retiredSqlDirAnywhere, retiredSqlDirFlagRefusal, type DeclaredDerived } from '../declared-derived';
32
+ import { loadModels } from './db-generate';
33
+ import { currentGitRef } from '../state-apply';
34
+ import { step, info, success, fail, warn } from '../output';
35
35
 
36
36
  /** Tables already in the target, outside the schemas PostgreSQL owns. */
37
37
  const OCCUPANCY_SQL = `
@@ -31,29 +31,29 @@
31
31
  import fs from 'node:fs/promises';
32
32
  import path from 'node:path';
33
33
  import type { ModelDescriptor, DerivedDescriptor } from '@everystack/model';
34
- import { compileDeclaredState } from '../declared-diff.js';
35
- import { compileMigration } from '../migration-compile.js';
36
- import { compileDrizzleSource } from '../schema-source.js';
37
- import { currentGitRef } from '../state-apply.js';
38
- import { createDatabase, dropDatabase, buildIntoDatabase, withDatabase } from '../db-build.js';
39
- import { resolveModelsPath } from '../models-path.js';
40
- import { loadModels, loadModules, readJournal, DEFAULT_MIGRATIONS } from './db-generate.js';
41
- import { resolveSchemaOut } from '../migration-generate.js';
42
- import { findUnexportedModels, scanModelDirectory, type ModelFileScan } from '../model-barrel-lint.js';
43
- import { loadDeclaredDerived, retiredSqlDirAnywhere, retiredSqlDirFlagRefusal, type DeclaredDerived } from '../declared-derived.js';
34
+ import { compileDeclaredState } from '../declared-diff';
35
+ import { compileMigration } from '../migration-compile';
36
+ import { compileDrizzleSource } from '../schema-source';
37
+ import { currentGitRef } from '../state-apply';
38
+ import { createDatabase, dropDatabase, buildIntoDatabase, withDatabase } from '../db-build';
39
+ import { resolveModelsPath } from '../models-path';
40
+ import { loadModels, loadModules, readJournal, DEFAULT_MIGRATIONS } from './db-generate';
41
+ import { resolveSchemaOut } from '../migration-generate';
42
+ import { findUnexportedModels, scanModelDirectory, type ModelFileScan } from '../model-barrel-lint';
43
+ import { loadDeclaredDerived, retiredSqlDirAnywhere, retiredSqlDirFlagRefusal, type DeclaredDerived } from '../declared-derived';
44
44
  import type { SequenceDescriptor } from '@everystack/model';
45
- import type { SourceObject } from '../derived-source.js';
46
- import { findReadAuthzGaps, findNakedGrants } from '../authz-lint.js';
47
- import { parseBaseline, renderBaseline, BASELINE_FILE } from '../authz-baseline.js';
45
+ import type { SourceObject } from '../derived-source';
46
+ import { findReadAuthzGaps, findNakedGrants } from '../authz-lint';
47
+ import { parseBaseline, renderBaseline, BASELINE_FILE } from '../authz-baseline';
48
48
  import {
49
49
  findDerivedReadGaps, findSecdefExecuteGaps, findMatviewSnapshotWarnings, findPublicExecutableSecdef,
50
50
  findUnpinnedDefiners,
51
- } from '../derived-lint.js';
52
- import { step, success, fail, info, warn } from '../output.js';
51
+ } from '../derived-lint';
52
+ import { step, success, fail, info, warn } from '../output';
53
53
 
54
54
  // The role derivation moved to the shared builder (db-build) with brick
55
55
  // 5-remainder; re-exported here because db:check is where it grew up.
56
- export { rolesFromContract } from '../db-build.js';
56
+ export { rolesFromContract } from '../db-build';
57
57
 
58
58
  const DEFAULT_SCHEMA_OUT = 'db/schema.generated.ts';
59
59
 
@@ -24,12 +24,12 @@
24
24
  */
25
25
 
26
26
  import type { ModelDescriptor } from '@everystack/model';
27
- import { diffDeclaredStates } from '../declared-diff.js';
28
- import { classifyGeneratedStatements } from '../state-apply.js';
29
- import { fingerprintModels } from '../schema-fingerprint.js';
30
- import { resolveModelsPath } from '../models-path.js';
31
- import { loadModels } from './db-generate.js';
32
- import { step, success, fail, info, warn } from '../output.js';
27
+ import { diffDeclaredStates } from '../declared-diff';
28
+ import { classifyGeneratedStatements } from '../state-apply';
29
+ import { fingerprintModels } from '../schema-fingerprint';
30
+ import { resolveModelsPath } from '../models-path';
31
+ import { loadModels } from './db-generate';
32
+ import { step, success, fail, info, warn } from '../output';
33
33
 
34
34
  export async function dbDiffCommand(flags: Record<string, string>): Promise<void> {
35
35
  const fromPath = flags['from-models'];
@@ -16,14 +16,14 @@
16
16
  */
17
17
 
18
18
  import fs from 'node:fs/promises';
19
- import { resolveDbSource, sslDefaults } from '../db-source.js';
20
- import { resolveConfig, opsFunction } from '../config.js';
21
- import { invokeAction } from '../aws.js';
22
- import { isProductionTier } from '../backup.js';
23
- import { executeExec, assertNoTxnControl } from '../exec-execute.js';
24
- import { runExecInTx } from '../exec-run.js';
25
- import { ENSURE_EXEC_LOG_SQL, renderExecIntentInsert, renderExecOutcomeUpdate } from '../exec-log.js';
26
- import { step, success, fail, info } from '../output.js';
19
+ import { resolveDbSource, sslDefaults } from '../db-source';
20
+ import { resolveConfig, opsFunction } from '../config';
21
+ import { invokeAction } from '../aws';
22
+ import { isProductionTier } from '../backup';
23
+ import { executeExec, assertNoTxnControl } from '../exec-execute';
24
+ import { runExecInTx } from '../exec-run';
25
+ import { ENSURE_EXEC_LOG_SQL, renderExecIntentInsert, renderExecOutcomeUpdate } from '../exec-log';
26
+ import { step, success, fail, info } from '../output';
27
27
 
28
28
  async function readStdin(): Promise<string> {
29
29
  const chunks: Buffer[] = [];
@@ -20,16 +20,16 @@ import path from 'node:path';
20
20
  import { randomBytes } from 'node:crypto';
21
21
  import { spawn } from 'node:child_process';
22
22
  import type { ModelDescriptor } from '@everystack/model';
23
- import { resolveConfig, opsFunction, type CliConfig } from '../config.js';
24
- import { invokeAction } from '../aws.js';
25
- import { fingerprintModels } from '../schema-fingerprint.js';
26
- import { resolveModelsPath } from '../models-path.js';
27
- import { loadModels } from './db-generate.js';
28
- import { loadDeclaredDerived } from '../declared-derived.js';
29
- import { pgEnvFromUrl, pgKeepaliveConninfo } from './db.js';
30
- import { utcStamp } from '../backup.js';
31
- import { pollTaskUntilStopped } from '../task-poll.js';
32
- import { step, success, fail, info } from '../output.js';
23
+ import { resolveConfig, opsFunction, type CliConfig } from '../config';
24
+ import { invokeAction } from '../aws';
25
+ import { fingerprintModels } from '../schema-fingerprint';
26
+ import { resolveModelsPath } from '../models-path';
27
+ import { loadModels } from './db-generate';
28
+ import { loadDeclaredDerived } from '../declared-derived';
29
+ import { pgEnvFromUrl, pgKeepaliveConninfo } from './db';
30
+ import { utcStamp } from '../backup';
31
+ import { pollTaskUntilStopped } from '../task-poll';
32
+ import { step, success, fail, info } from '../output';
33
33
 
34
34
  const fmtBytes = (b?: number): string =>
35
35
  b == null ? '?' : b >= 1024 ** 3 ? `${(b / 1024 ** 3).toFixed(1)} GB` : b >= 1024 ** 2 ? `${(b / 1024 ** 2).toFixed(1)} MB` : `${(b / 1024).toFixed(0)} KB`;
@@ -14,10 +14,10 @@
14
14
 
15
15
  import { existsSync } from 'node:fs';
16
16
  import type { ModelDescriptor } from '@everystack/model';
17
- import type { QueryRunner } from '../authz-contract.js';
18
- import { introspectSchema } from '../schema-introspect.js';
19
- import { introspectContract } from '../authz-contract.js';
20
- import { FUNCTIONS_SQL, contractFunctionRow } from '../security-catalog.js';
17
+ import type { QueryRunner } from '../authz-contract';
18
+ import { introspectSchema } from '../schema-introspect';
19
+ import { introspectContract } from '../authz-contract';
20
+ import { FUNCTIONS_SQL, contractFunctionRow } from '../security-catalog';
21
21
  import {
22
22
  fingerprintLive,
23
23
  fingerprintModels,
@@ -25,16 +25,16 @@ import {
25
25
  mapUnfingerprintedRows,
26
26
  UNFINGERPRINTED_SQL,
27
27
  type UnfingerprintedObject,
28
- } from '../schema-fingerprint.js';
29
- import { predictLiveFingerprint, governedLiveFingerprint } from '../edge-plan.js';
30
- import { resolveModelsPath } from '../models-path.js';
31
- import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source.js';
32
- import { borrowedSessionRunner, INTROSPECTION_SESSION, type SessionRunner } from '../session.js';
33
- import { resolveConfig, opsFunction } from '../config.js';
34
- import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws.js';
35
- import { step, success, fail, info, warn } from '../output.js';
36
- import { loadModels } from './db-generate.js';
37
- import { loadDeclaredDerived } from '../declared-derived.js';
28
+ } from '../schema-fingerprint';
29
+ import { predictLiveFingerprint, governedLiveFingerprint } from '../edge-plan';
30
+ import { resolveModelsPath } from '../models-path';
31
+ import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source';
32
+ import { borrowedSessionRunner, INTROSPECTION_SESSION, type SessionRunner } from '../session';
33
+ import { resolveConfig, opsFunction } from '../config';
34
+ import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws';
35
+ import { step, success, fail, info, warn } from '../output';
36
+ import { loadModels } from './db-generate';
37
+ import { loadDeclaredDerived } from '../declared-derived';
38
38
  import type { SequenceDescriptor } from '@everystack/model';
39
39
 
40
40
  export interface FingerprintStatus {
@@ -19,12 +19,12 @@
19
19
  * data-governance warning. Teardown is the stage's own: `sst remove`.
20
20
  */
21
21
 
22
- import { resolveConfig, opsFunction, type CliConfig } from '../config.js';
23
- import { invokeAction, presignGet } from '../aws.js';
24
- import { keyForId, parseBackupRef, isProductionTier, crossStageGuard } from '../backup.js';
25
- import { pollTaskUntilStopped } from '../task-poll.js';
26
- import { runStageBackup, stageBackupDeps } from '../stage-backup.js';
27
- import { step, success, fail, info, warn } from '../output.js';
22
+ import { resolveConfig, opsFunction, type CliConfig } from '../config';
23
+ import { invokeAction, presignGet } from '../aws';
24
+ import { keyForId, parseBackupRef, isProductionTier, crossStageGuard } from '../backup';
25
+ import { pollTaskUntilStopped } from '../task-poll';
26
+ import { runStageBackup, stageBackupDeps } from '../stage-backup';
27
+ import { step, success, fail, info, warn } from '../output';
28
28
 
29
29
  export type ForkGuardVerdict =
30
30
  | { ok: true; piiWarning: string | null }
@@ -23,25 +23,25 @@ import fs from 'node:fs/promises';
23
23
  import path from 'node:path';
24
24
  import { pathToFileURL } from 'node:url';
25
25
  import type { ModelDescriptor, Module } from '@everystack/model';
26
- import { introspectSchema } from '../schema-introspect.js';
27
- import { compileDrizzleSource } from '../schema-source.js';
28
- import { compileModuleMigration } from '../migration-compile.js';
29
- import { generateMigrationSql, unmodeledTables, formatMigrationFile, planMigrationFile, resolveSchemaOut, HELD_DROP_PREFIX, type Journal } from '../migration-generate.js';
30
- import { introspectContract, type QueryRunner, type AuthzContract } from '../authz-contract.js';
31
- import { compileTableContract } from '../authz-compile.js';
32
- import { governedRoleSet, ungovernedGrants, renderGrantExemptions } from '../authz-reconcile.js';
33
- import { classifyAdoption, renderAdoptionReport } from '../authz-adoption-class.js';
34
- import { introspectTableOwners, buildOwnershipReport, renderOwnershipReport, type TableOwner } from '../authz-ownership.js';
35
- import { FUNCTIONS_SQL, contractFunctionRow } from '../security-catalog.js';
36
- import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source.js';
37
- import { borrowedSessionRunner, type SessionRunner } from '../session.js';
38
- import { resolveModelsPath } from '../models-path.js';
39
- import { loadDeclaredDerived, assertNoHoles, type DeclaredDerived } from '../declared-derived.js';
40
- import { asModelComposeError, opsAdviceLines } from '../ops-advice.js';
41
- import { applyStateAndVerify, classifyGeneratedStatements, renderStatementHistogram, currentGitRef, type StateSyncOutcome } from '../state-apply.js';
42
- import { resolveConfig, opsFunction } from '../config.js';
43
- import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws.js';
44
- import { step, success, fail, info, warn } from '../output.js';
26
+ import { introspectSchema } from '../schema-introspect';
27
+ import { compileDrizzleSource } from '../schema-source';
28
+ import { compileModuleMigration } from '../migration-compile';
29
+ import { generateMigrationSql, unmodeledTables, formatMigrationFile, planMigrationFile, resolveSchemaOut, HELD_DROP_PREFIX, type Journal } from '../migration-generate';
30
+ import { introspectContract, type QueryRunner, type AuthzContract } from '../authz-contract';
31
+ import { compileTableContract } from '../authz-compile';
32
+ import { governedRoleSet, ungovernedGrants, renderGrantExemptions } from '../authz-reconcile';
33
+ import { classifyAdoption, renderAdoptionReport } from '../authz-adoption-class';
34
+ import { introspectTableOwners, buildOwnershipReport, renderOwnershipReport, type TableOwner } from '../authz-ownership';
35
+ import { FUNCTIONS_SQL, contractFunctionRow } from '../security-catalog';
36
+ import { resolveDbSource, createUrlRunner, connectingVia, type DbSource } from '../db-source';
37
+ import { borrowedSessionRunner, type SessionRunner } from '../session';
38
+ import { resolveModelsPath } from '../models-path';
39
+ import { loadDeclaredDerived, assertNoHoles, type DeclaredDerived } from '../declared-derived';
40
+ import { asModelComposeError, opsAdviceLines } from '../ops-advice';
41
+ import { applyStateAndVerify, classifyGeneratedStatements, renderStatementHistogram, currentGitRef, type StateSyncOutcome } from '../state-apply';
42
+ import { resolveConfig, opsFunction } from '../config';
43
+ import { invokeAction, lambdaQueryRunner, lambdaSessionRunner } from '../aws';
44
+ import { step, success, fail, info, warn } from '../output';
45
45
 
46
46
  export const DEFAULT_MIGRATIONS = 'drizzle';
47
47
  const DEFAULT_SCHEMA_OUT = 'db/schema.generated.ts';