ddd-ts-kit 0.23.0 → 0.24.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/CHANGELOG.md +59 -0
- package/README.fr.md +42 -7
- package/README.md +38 -6
- package/dist/check/canonical/stray-entry.d.ts +8 -0
- package/dist/check/canonical/stray-entry.d.ts.map +1 -0
- package/dist/check/canonical/stray-entry.js +75 -0
- package/dist/check/canonical/stray-entry.js.map +1 -0
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/default-severities.d.ts.map +1 -1
- package/dist/check/catalogue/default-severities.js +1 -0
- package/dist/check/catalogue/default-severities.js.map +1 -1
- package/dist/check/explain/clean-docs.js +1 -1
- package/dist/check/explain/clean-docs.js.map +1 -1
- package/dist/check/explain/persistence-docs.js +1 -1
- package/dist/check/explain/persistence-docs.js.map +1 -1
- package/dist/check/explain/tree-docs.d.ts.map +1 -1
- package/dist/check/explain/tree-docs.js +5 -0
- package/dist/check/explain/tree-docs.js.map +1 -1
- package/dist/check/fixtures/clean-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/clean-fixtures.js +16 -0
- package/dist/check/fixtures/clean-fixtures.js.map +1 -1
- package/dist/check/fixtures/tree-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tree-fixtures.js +17 -0
- package/dist/check/fixtures/tree-fixtures.js.map +1 -1
- package/dist/check/migrations/drizzle-history-findings.js +1 -1
- package/dist/check/migrations/drizzle-history-findings.js.map +1 -1
- package/dist/check/rules/clean-function-size.js +10 -2
- package/dist/check/rules/clean-function-size.js.map +1 -1
- package/dist/check/rules/tree-closed.d.ts.map +1 -1
- package/dist/check/rules/tree-closed.js +4 -68
- package/dist/check/rules/tree-closed.js.map +1 -1
- package/dist/check/rules/tree-documented-paths.d.ts +3 -0
- package/dist/check/rules/tree-documented-paths.d.ts.map +1 -0
- package/dist/check/rules/tree-documented-paths.js +54 -0
- package/dist/check/rules/tree-documented-paths.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +15 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/drizzle-generate.d.ts +6 -1
- package/dist/commands/drizzle-generate.d.ts.map +1 -1
- package/dist/commands/drizzle-generate.js +39 -6
- package/dist/commands/drizzle-generate.js.map +1 -1
- package/dist/commands/plan-waves.d.ts +9 -0
- package/dist/commands/plan-waves.d.ts.map +1 -0
- package/dist/commands/plan-waves.js +36 -0
- package/dist/commands/plan-waves.js.map +1 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/doctor/diagnose.d.ts +9 -0
- package/dist/doctor/diagnose.d.ts.map +1 -0
- package/dist/doctor/diagnose.js +34 -0
- package/dist/doctor/diagnose.js.map +1 -0
- package/dist/doctor/doctor-finding.d.ts +11 -0
- package/dist/doctor/doctor-finding.d.ts.map +1 -0
- package/dist/doctor/doctor-finding.js +2 -0
- package/dist/doctor/doctor-finding.js.map +1 -0
- package/dist/doctor/format-diagnosis.d.ts +4 -0
- package/dist/doctor/format-diagnosis.d.ts.map +1 -0
- package/dist/doctor/format-diagnosis.js +25 -0
- package/dist/doctor/format-diagnosis.js.map +1 -0
- package/dist/doctor/package-findings.d.ts +8 -0
- package/dist/doctor/package-findings.d.ts.map +1 -0
- package/dist/doctor/package-findings.js +21 -0
- package/dist/doctor/package-findings.js.map +1 -0
- package/dist/doctor/permission-findings.d.ts +5 -0
- package/dist/doctor/permission-findings.d.ts.map +1 -0
- package/dist/doctor/permission-findings.js +16 -0
- package/dist/doctor/permission-findings.js.map +1 -0
- package/dist/doctor/script-findings.d.ts +5 -0
- package/dist/doctor/script-findings.d.ts.map +1 -0
- package/dist/doctor/script-findings.js +12 -0
- package/dist/doctor/script-findings.js.map +1 -0
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +25 -4
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +3 -0
- package/dist/help/usage.js.map +1 -1
- package/dist/init/agent-permissions.d.ts +8 -0
- package/dist/init/agent-permissions.d.ts.map +1 -0
- package/dist/init/agent-permissions.js +55 -0
- package/dist/init/agent-permissions.js.map +1 -0
- package/dist/init/files/persistence-files.d.ts.map +1 -1
- package/dist/init/files/persistence-files.js +7 -1
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/write-agent-settings.d.ts.map +1 -1
- package/dist/init/write-agent-settings.js +1 -54
- package/dist/init/write-agent-settings.js.map +1 -1
- package/dist/migration/branch-migration.d.ts +9 -0
- package/dist/migration/branch-migration.d.ts.map +1 -0
- package/dist/migration/branch-migration.js +2 -0
- package/dist/migration/branch-migration.js.map +1 -0
- package/dist/migration/branch-migrations.d.ts +16 -0
- package/dist/migration/branch-migrations.d.ts.map +1 -0
- package/dist/migration/branch-migrations.js +48 -0
- package/dist/migration/branch-migrations.js.map +1 -0
- package/dist/migration/delete-branch-migrations.d.ts +9 -0
- package/dist/migration/delete-branch-migrations.d.ts.map +1 -0
- package/dist/migration/delete-branch-migrations.js +23 -0
- package/dist/migration/delete-branch-migrations.js.map +1 -0
- package/dist/migration/drizzle-run.d.ts +7 -0
- package/dist/migration/drizzle-run.d.ts.map +1 -0
- package/dist/migration/drizzle-run.js +2 -0
- package/dist/migration/drizzle-run.js.map +1 -0
- package/dist/migration/drizzle-silent-failures.js +1 -1
- package/dist/migration/drizzle-silent-failures.js.map +1 -1
- package/dist/migration/find-project-formatter.d.ts +8 -0
- package/dist/migration/find-project-formatter.d.ts.map +1 -0
- package/dist/migration/find-project-formatter.js +52 -0
- package/dist/migration/find-project-formatter.js.map +1 -0
- package/dist/migration/format-written-files.d.ts +9 -0
- package/dist/migration/format-written-files.d.ts.map +1 -0
- package/dist/migration/format-written-files.js +32 -0
- package/dist/migration/format-written-files.js.map +1 -0
- package/dist/migration/generate-and-read.d.ts +6 -0
- package/dist/migration/generate-and-read.d.ts.map +1 -0
- package/dist/migration/generate-and-read.js +14 -0
- package/dist/migration/generate-and-read.js.map +1 -0
- package/dist/migration/index.d.ts +4 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +4 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/known-primary-keys.d.ts +3 -0
- package/dist/migration/known-primary-keys.d.ts.map +1 -0
- package/dist/migration/known-primary-keys.js +2 -0
- package/dist/migration/known-primary-keys.js.map +1 -0
- package/dist/migration/migration-files.d.ts +7 -0
- package/dist/migration/migration-files.d.ts.map +1 -0
- package/dist/migration/migration-files.js +29 -0
- package/dist/migration/migration-files.js.map +1 -0
- package/dist/migration/plan-replay.d.ts +9 -0
- package/dist/migration/plan-replay.d.ts.map +1 -0
- package/dist/migration/plan-replay.js +68 -0
- package/dist/migration/plan-replay.js.map +1 -0
- package/dist/migration/previous-primary-keys.d.ts +9 -0
- package/dist/migration/previous-primary-keys.d.ts.map +1 -0
- package/dist/migration/previous-primary-keys.js +55 -0
- package/dist/migration/previous-primary-keys.js.map +1 -0
- package/dist/migration/primary-key-order-finding.d.ts +12 -0
- package/dist/migration/primary-key-order-finding.d.ts.map +1 -0
- package/dist/migration/primary-key-order-finding.js +2 -0
- package/dist/migration/primary-key-order-finding.js.map +1 -0
- package/dist/migration/primary-key-order-findings.d.ts +12 -0
- package/dist/migration/primary-key-order-findings.d.ts.map +1 -0
- package/dist/migration/primary-key-order-findings.js +55 -0
- package/dist/migration/primary-key-order-findings.js.map +1 -0
- package/dist/migration/project-formatter.d.ts +9 -0
- package/dist/migration/project-formatter.d.ts.map +1 -0
- package/dist/migration/project-formatter.js +2 -0
- package/dist/migration/project-formatter.js.map +1 -0
- package/dist/migration/replay-drizzle-migrations.d.ts +15 -0
- package/dist/migration/replay-drizzle-migrations.d.ts.map +1 -0
- package/dist/migration/replay-drizzle-migrations.js +63 -0
- package/dist/migration/replay-drizzle-migrations.js.map +1 -0
- package/dist/migration/replay-plan.d.ts +11 -0
- package/dist/migration/replay-plan.d.ts.map +1 -0
- package/dist/migration/replay-plan.js +2 -0
- package/dist/migration/replay-plan.js.map +1 -0
- package/dist/migration/replayed-name.d.ts +7 -0
- package/dist/migration/replayed-name.d.ts.map +1 -0
- package/dist/migration/replayed-name.js +12 -0
- package/dist/migration/replayed-name.js.map +1 -0
- package/dist/migration/sql-statement.d.ts +6 -0
- package/dist/migration/sql-statement.d.ts.map +1 -0
- package/dist/migration/sql-statement.js +2 -0
- package/dist/migration/sql-statement.js.map +1 -0
- package/dist/migration/sql-statements.d.ts +4 -0
- package/dist/migration/sql-statements.d.ts.map +1 -0
- package/dist/migration/sql-statements.js +36 -0
- package/dist/migration/sql-statements.js.map +1 -0
- package/dist/migration/table-change.d.ts +12 -0
- package/dist/migration/table-change.d.ts.map +1 -0
- package/dist/migration/table-change.js +2 -0
- package/dist/migration/table-change.js.map +1 -0
- package/dist/migration/table-changes.d.ts +9 -0
- package/dist/migration/table-changes.d.ts.map +1 -0
- package/dist/migration/table-changes.js +55 -0
- package/dist/migration/table-changes.js.map +1 -0
- package/dist/migration/tidy-written-migration.d.ts +5 -0
- package/dist/migration/tidy-written-migration.d.ts.map +1 -0
- package/dist/migration/tidy-written-migration.js +8 -0
- package/dist/migration/tidy-written-migration.js.map +1 -0
- package/dist/migration/wait-for-next-second.d.ts +6 -0
- package/dist/migration/wait-for-next-second.d.ts.map +1 -0
- package/dist/migration/wait-for-next-second.js +11 -0
- package/dist/migration/wait-for-next-second.js.map +1 -0
- package/dist/migration/warn-primary-key-order.d.ts +5 -0
- package/dist/migration/warn-primary-key-order.d.ts.map +1 -0
- package/dist/migration/warn-primary-key-order.js +16 -0
- package/dist/migration/warn-primary-key-order.js.map +1 -0
- package/dist/migration/written-migration.d.ts +9 -0
- package/dist/migration/written-migration.d.ts.map +1 -0
- package/dist/migration/written-migration.js +2 -0
- package/dist/migration/written-migration.js.map +1 -0
- package/dist/migration/written-paths.d.ts +3 -0
- package/dist/migration/written-paths.d.ts.map +1 -0
- package/dist/migration/written-paths.js +5 -0
- package/dist/migration/written-paths.js.map +1 -0
- package/dist/plan/aggregates-of.d.ts +6 -0
- package/dist/plan/aggregates-of.d.ts.map +1 -0
- package/dist/plan/aggregates-of.js +13 -0
- package/dist/plan/aggregates-of.js.map +1 -0
- package/dist/plan/batched-waves.d.ts +18 -0
- package/dist/plan/batched-waves.d.ts.map +1 -0
- package/dist/plan/batched-waves.js +73 -0
- package/dist/plan/batched-waves.js.map +1 -0
- package/dist/plan/cycles-of.d.ts +8 -0
- package/dist/plan/cycles-of.d.ts.map +1 -0
- package/dist/plan/cycles-of.js +30 -0
- package/dist/plan/cycles-of.js.map +1 -0
- package/dist/plan/format-plan.d.ts +4 -0
- package/dist/plan/format-plan.d.ts.map +1 -0
- package/dist/plan/format-plan.js +53 -0
- package/dist/plan/format-plan.js.map +1 -0
- package/dist/plan/merge-order.d.ts +8 -0
- package/dist/plan/merge-order.d.ts.map +1 -0
- package/dist/plan/merge-order.js +32 -0
- package/dist/plan/merge-order.js.map +1 -0
- package/dist/plan/plan-problems.d.ts +8 -0
- package/dist/plan/plan-problems.d.ts.map +1 -0
- package/dist/plan/plan-problems.js +57 -0
- package/dist/plan/plan-problems.js.map +1 -0
- package/dist/plan/plan-waves.d.ts +16 -0
- package/dist/plan/plan-waves.d.ts.map +1 -0
- package/dist/plan/plan-waves.js +23 -0
- package/dist/plan/plan-waves.js.map +1 -0
- package/dist/plan/rows-to-plan.d.ts +7 -0
- package/dist/plan/rows-to-plan.d.ts.map +1 -0
- package/dist/plan/rows-to-plan.js +19 -0
- package/dist/plan/rows-to-plan.js.map +1 -0
- package/dist/plan/wave-numbers.d.ts +8 -0
- package/dist/plan/wave-numbers.d.ts.map +1 -0
- package/dist/plan/wave-numbers.js +27 -0
- package/dist/plan/wave-numbers.js.map +1 -0
- package/dist/plan/wave-plan.d.ts +48 -0
- package/dist/plan/wave-plan.d.ts.map +1 -0
- package/dist/plan/wave-plan.js +2 -0
- package/dist/plan/wave-plan.js.map +1 -0
- package/dist/progress/format-progress.d.ts.map +1 -1
- package/dist/progress/format-progress.js +16 -1
- package/dist/progress/format-progress.js.map +1 -1
- package/dist/progress/progress.d.ts +11 -1
- package/dist/progress/progress.d.ts.map +1 -1
- package/dist/progress/read-progress.d.ts +6 -2
- package/dist/progress/read-progress.d.ts.map +1 -1
- package/dist/progress/read-progress.js +10 -5
- package/dist/progress/read-progress.js.map +1 -1
- package/dist/progress/status-row-of.d.ts +16 -0
- package/dist/progress/status-row-of.d.ts.map +1 -0
- package/dist/progress/status-row-of.js +23 -0
- package/dist/progress/status-row-of.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -0
- package/dist/run.js.map +1 -1
- package/dist/slice/changed-entries.d.ts +7 -0
- package/dist/slice/changed-entries.d.ts.map +1 -0
- package/dist/slice/changed-entries.js +20 -0
- package/dist/slice/changed-entries.js.map +1 -0
- package/dist/slice/changed-entry.d.ts +6 -0
- package/dist/slice/changed-entry.d.ts.map +1 -0
- package/dist/slice/changed-entry.js +2 -0
- package/dist/slice/changed-entry.js.map +1 -0
- package/dist/slice/format-slice-verification.d.ts.map +1 -1
- package/dist/slice/format-slice-verification.js +10 -0
- package/dist/slice/format-slice-verification.js.map +1 -1
- package/dist/slice/plan-staging.d.ts +13 -0
- package/dist/slice/plan-staging.d.ts.map +1 -0
- package/dist/slice/plan-staging.js +52 -0
- package/dist/slice/plan-staging.js.map +1 -0
- package/dist/slice/slice-verification.d.ts +3 -0
- package/dist/slice/slice-verification.d.ts.map +1 -1
- package/dist/slice/staging-plan.d.ts +6 -0
- package/dist/slice/staging-plan.d.ts.map +1 -0
- package/dist/slice/staging-plan.js +2 -0
- package/dist/slice/staging-plan.js.map +1 -0
- package/dist/slice/verify-slice.d.ts.map +1 -1
- package/dist/slice/verify-slice.js +3 -2
- package/dist/slice/verify-slice.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/briefing-of.js +1 -1
- package/dist/worker/briefing-of.js.map +1 -1
- package/dist/worker/rows-on-branches.d.ts +8 -0
- package/dist/worker/rows-on-branches.d.ts.map +1 -0
- package/dist/worker/rows-on-branches.js +9 -0
- package/dist/worker/rows-on-branches.js.map +1 -0
- package/package.json +2 -2
- package/templates/e2e/e2e.spec.ts.tpl +2 -2
- package/templates/init/e2e/start-application.database.ts.tpl +30 -1
- package/templates/init/e2e/start-application.memory.ts.tpl +30 -1
- package/templates/init/e2e/vitest.e2e.config.ts.tpl +4 -0
- package/templates/init/platform/database/open-test-database.drizzle.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.knex.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.prisma.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +18 -1
- package/templates/init/platform/database/test-database-template.ts.tpl +23 -0
- package/templates/init/rules/tests.md.tpl +1 -1
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/pipeline/vitest.config.ts.tpl +6 -0
- package/dist/slice/paths-to-stage.d.ts +0 -6
- package/dist/slice/paths-to-stage.d.ts.map +0 -1
- package/dist/slice/paths-to-stage.js +0 -13
- package/dist/slice/paths-to-stage.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { sqlStatements } from './sql-statements.js';
|
|
2
|
+
import { tableChanges } from './table-changes.js';
|
|
3
|
+
/** PostgreSQL names a key `<table>_pkey`; drizzle-kit names a composite one `<table>_<column>_<column>_pk`. */
|
|
4
|
+
const KEY_NAME = /_(?:pkey|pk)$/;
|
|
5
|
+
const CUSTOM = 'or write the migration yourself (`npm run db:generate -- <name> --custom`)';
|
|
6
|
+
/**
|
|
7
|
+
* The changes of a primary key that a migration of drizzle-kit writes in an order PostgreSQL
|
|
8
|
+
* refuses: the new key of a table added before its old one is dropped (a table has one primary
|
|
9
|
+
* key), and a column dropped before the key that holds it (the column takes the key with it, and
|
|
10
|
+
* the later `DROP CONSTRAINT` finds none). A dropped constraint is a primary key when `known` says
|
|
11
|
+
* so (the snapshot before the migration) or its name ends in `_pkey` or `_pk`; the columns of a
|
|
12
|
+
* key come from `known`, else from the name drizzle-kit gives a composite key.
|
|
13
|
+
*/
|
|
14
|
+
export function primaryKeyOrderFindings(sql, known = new Map()) {
|
|
15
|
+
const changes = tableChanges(sqlStatements(sql));
|
|
16
|
+
const drops = changes.filter((change) => change.kind === 'drop-constraint' && isKey(change.name, known));
|
|
17
|
+
return changes.flatMap((early) => {
|
|
18
|
+
const condition = mustFollow(early, known);
|
|
19
|
+
const drop = drops.find((key) => key.table === early.table && key.position > early.position && condition?.(key) === true);
|
|
20
|
+
return drop === undefined ? [] : [finding(early, drop)];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Which later drop of a key the change has to follow: any key of its table for an added key, the key holding it for a dropped column. */
|
|
24
|
+
function mustFollow(early, known) {
|
|
25
|
+
if (early.kind === 'add-key') {
|
|
26
|
+
return () => true;
|
|
27
|
+
}
|
|
28
|
+
return early.kind === 'drop-column' ? (key) => holdsColumn(key, early.name, known) : undefined;
|
|
29
|
+
}
|
|
30
|
+
function finding(early, drop) {
|
|
31
|
+
const { table } = early;
|
|
32
|
+
const words = early.kind === 'add-key'
|
|
33
|
+
? {
|
|
34
|
+
message: `The new primary key of "${table}" is added before its old one, "${drop.name}", is dropped: PostgreSQL refuses a second primary key on a table, and the migration fails.`,
|
|
35
|
+
fix: `Drop the old key first: move the DROP CONSTRAINT above the ADD of the new key in this migration, still unapplied, ${CUSTOM}.`,
|
|
36
|
+
}
|
|
37
|
+
: {
|
|
38
|
+
message: `The column "${early.name}" of "${table}" is dropped before the primary key "${drop.name}" that holds it: the column takes the key with it, and the later DROP CONSTRAINT fails.`,
|
|
39
|
+
fix: `Drop the key first: move the DROP CONSTRAINT above the DROP COLUMN in this migration, still unapplied, ${CUSTOM}.`,
|
|
40
|
+
};
|
|
41
|
+
return { table, early: early.statement, drop: drop.statement, ...words };
|
|
42
|
+
}
|
|
43
|
+
function isKey(constraint, known) {
|
|
44
|
+
return known.has(constraint) || KEY_NAME.test(constraint);
|
|
45
|
+
}
|
|
46
|
+
function holdsColumn(key, column, known) {
|
|
47
|
+
const columns = known.get(key.name);
|
|
48
|
+
if (columns !== undefined) {
|
|
49
|
+
return columns.includes(column);
|
|
50
|
+
}
|
|
51
|
+
const prefix = `${key.table}_`;
|
|
52
|
+
const named = key.name.startsWith(prefix) && key.name.endsWith('_pk') ? key.name.slice(prefix.length, -3) : '';
|
|
53
|
+
return named !== '' && `_${named}_`.includes(`_${column}_`);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=primary-key-order-findings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primary-key-order-findings.js","sourceRoot":"","sources":["../../src/migration/primary-key-order-findings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,+GAA+G;AAC/G,MAAM,QAAQ,GAAG,eAAe,CAAC;AAEjC,MAAM,MAAM,GAAG,4EAA4E,CAAC;AAE5F;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW,EAAE,KAAK,GAAqB,IAAI,GAAG,EAAE;IACtF,MAAM,OAAO,GAAG,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAA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AS,KAAK,wCAAwC,IAAI,CAAC,IAAI,yFAAyF;YAC1L,GAAG,EAAE,0GAA0G,MAAM,GAAG;SACzH,CAAC;IAER,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,KAAK,CAAC,UAAkB,EAAE,KAAuB;IACxD,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,WAAW,CAAC,GAAgB,EAAE,MAAc,EAAE,KAAuB;IAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC;IAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE/G,OAAO,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The formatter the `format` script of a project runs, found installed, run on given paths by the same node. */
|
|
2
|
+
export interface ProjectFormatter {
|
|
3
|
+
readonly name: 'Biome' | 'Prettier';
|
|
4
|
+
/** The entry file of its command line, under node_modules. */
|
|
5
|
+
readonly bin: string;
|
|
6
|
+
/** What precedes the paths: write in place, and pass over a path its configuration ignores. */
|
|
7
|
+
readonly args: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=project-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-formatter.d.ts","sourceRoot":"","sources":["../../src/migration/project-formatter.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-formatter.js","sourceRoot":"","sources":["../../src/migration/project-formatter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Io } from '../commands/io.js';
|
|
2
|
+
export interface DrizzleReplay {
|
|
3
|
+
readonly root: string;
|
|
4
|
+
/** The trunk the branch merged: its migrations are kept, the others generated again on top. */
|
|
5
|
+
readonly base: string;
|
|
6
|
+
readonly interactive: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `drizzle-generate --replay`, after merging the trunk into a branch when both added migrations:
|
|
10
|
+
* deletes the migrations of the branch the base does not have (with their snapshots and journal
|
|
11
|
+
* entries), then generates them again on top of the base, one per deleted one, in their order and
|
|
12
|
+
* under their names. A custom migration gets its statements back.
|
|
13
|
+
*/
|
|
14
|
+
export declare function replayDrizzleMigrations(replay: DrizzleReplay, io: Io): number;
|
|
15
|
+
//# sourceMappingURL=replay-drizzle-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-drizzle-migrations.d.ts","sourceRoot":"","sources":["../../src/migration/replay-drizzle-migrations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAY5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+FAA+F;IAC/F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,GAAG,MAAM,CAyC7E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { WORKER_SCOPE_FILE } from '../commit/worker-scope-file.js';
|
|
4
|
+
import { deleteBranchMigrations } from './delete-branch-migrations.js';
|
|
5
|
+
import { generateAndRead } from './generate-and-read.js';
|
|
6
|
+
import { migrationFiles } from './migration-files.js';
|
|
7
|
+
import { planReplay } from './plan-replay.js';
|
|
8
|
+
import { replayedName } from './replayed-name.js';
|
|
9
|
+
import { tidyWrittenMigration } from './tidy-written-migration.js';
|
|
10
|
+
import { waitForNextSecond } from './wait-for-next-second.js';
|
|
11
|
+
/**
|
|
12
|
+
* `drizzle-generate --replay`, after merging the trunk into a branch when both added migrations:
|
|
13
|
+
* deletes the migrations of the branch the base does not have (with their snapshots and journal
|
|
14
|
+
* entries), then generates them again on top of the base, one per deleted one, in their order and
|
|
15
|
+
* under their names. A custom migration gets its statements back.
|
|
16
|
+
*/
|
|
17
|
+
export function replayDrizzleMigrations(replay, io) {
|
|
18
|
+
const plan = planReplay(replay);
|
|
19
|
+
if (plan.migrations.length === 0) {
|
|
20
|
+
io.out(`No migration of this branch is missing from ${plan.base}: nothing to replay.`);
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
deleteBranchMigrations(plan);
|
|
24
|
+
io.out(`Deleted, with their snapshots and journal entries: ${plan.migrations.map((migration) => migration.tag).join(', ')}.`);
|
|
25
|
+
const written = new Set();
|
|
26
|
+
const inWorker = fs.existsSync(path.join(replay.root, WORKER_SCOPE_FILE));
|
|
27
|
+
let since = 0;
|
|
28
|
+
for (const migration of plan.migrations) {
|
|
29
|
+
waitForNextSecond(since);
|
|
30
|
+
const code = generateAgain({ plan, migration, name: replayedName(migration.tag, inWorker) }, replay, io);
|
|
31
|
+
if (typeof code === 'number') {
|
|
32
|
+
return code;
|
|
33
|
+
}
|
|
34
|
+
for (const file of code) {
|
|
35
|
+
written.add(file);
|
|
36
|
+
}
|
|
37
|
+
since = Date.now();
|
|
38
|
+
}
|
|
39
|
+
const files = migrationFiles(replay.root, plan.folder);
|
|
40
|
+
tidyWrittenMigration({ root: replay.root, paths: [...written], files }, io);
|
|
41
|
+
io.out(`Stage ${plan.folder}/, then run \`npm run check:arch\`.`);
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
/** Generates one migration again: what it wrote, or the exit code of drizzle-kit when it failed. */
|
|
45
|
+
function generateAgain({ plan, migration, name }, replay, io) {
|
|
46
|
+
const { root, interactive } = replay;
|
|
47
|
+
const { code, written } = generateAndRead({ root, name, custom: migration.custom, interactive }, io);
|
|
48
|
+
const sql = written.paths.find((file) => file.endsWith('.sql') && path.posix.dirname(file) === plan.folder);
|
|
49
|
+
if (code !== 0) {
|
|
50
|
+
io.err(`drizzle-kit failed on ${name}: the migrations generated above are written, the others stay deleted. Delete what this run generated, restore ${plan.folder}/ as the merge left it (\`git checkout HEAD -- ${plan.folder}\`), fix the cause above and run the replay again.`);
|
|
51
|
+
return code;
|
|
52
|
+
}
|
|
53
|
+
if (sql === undefined) {
|
|
54
|
+
io.err(`Warning: drizzle-kit wrote nothing for ${migration.tag}: ${plan.base} already holds its change.`);
|
|
55
|
+
return written.paths;
|
|
56
|
+
}
|
|
57
|
+
if (migration.custom) {
|
|
58
|
+
fs.writeFileSync(path.join(root, sql), migration.sql);
|
|
59
|
+
}
|
|
60
|
+
io.out(`Generated ${path.posix.basename(sql, '.sql')} in place of ${migration.tag}.`);
|
|
61
|
+
return written.paths;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=replay-drizzle-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-drizzle-migrations.js","sourceRoot":"","sources":["../../src/migration/replay-drizzle-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAS9D;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAqB,EAAE,EAAM;IACnE,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAEhC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,EAAE,CAAC,GAAG,CAAC,+CAA+C,IAAI,CAAC,IAAI,sBAAsB,CAAC,CAAC;QAEvF,OAAO,CAAC,CAAC;IACX,CAAC;IAED,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,EAAE,CAAC,GAAG,CACJ,sDAAsD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC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|
+
import type { BranchMigration } from './branch-migration.js';
|
|
2
|
+
/** What a replay deletes and generates again, read before anything is touched. */
|
|
3
|
+
export interface ReplayPlan {
|
|
4
|
+
readonly root: string;
|
|
5
|
+
readonly base: string;
|
|
6
|
+
/** The migrations folder, relative to the project root. */
|
|
7
|
+
readonly folder: string;
|
|
8
|
+
/** In their order. */
|
|
9
|
+
readonly migrations: readonly BranchMigration[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=replay-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-plan.d.ts","sourceRoot":"","sources":["../../src/migration/replay-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sBAAsB;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;CACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-plan.js","sourceRoot":"","sources":["../../src/migration/replay-plan.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name a migration of the branch is generated again with: what follows its number. In the
|
|
3
|
+
* worktree of a worker it stays a working migration; elsewhere (the conductor, a branch of its
|
|
4
|
+
* own) it becomes the real one, without the `working-` prefix.
|
|
5
|
+
*/
|
|
6
|
+
export declare function replayedName(tag: string, inWorker: boolean): string;
|
|
7
|
+
//# sourceMappingURL=replayed-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replayed-name.d.ts","sourceRoot":"","sources":["../../src/migration/replayed-name.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAKnE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const WORKING = 'working-';
|
|
2
|
+
/**
|
|
3
|
+
* The name a migration of the branch is generated again with: what follows its number. In the
|
|
4
|
+
* worktree of a worker it stays a working migration; elsewhere (the conductor, a branch of its
|
|
5
|
+
* own) it becomes the real one, without the `working-` prefix.
|
|
6
|
+
*/
|
|
7
|
+
export function replayedName(tag, inWorker) {
|
|
8
|
+
const at = tag.indexOf('_');
|
|
9
|
+
const name = at === -1 ? tag : tag.slice(at + 1);
|
|
10
|
+
return inWorker || !name.startsWith(WORKING) || name === WORKING ? name : name.slice(WORKING.length);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=replayed-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replayed-name.js","sourceRoot":"","sources":["../../src/migration/replayed-name.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,QAAiB;IACzD,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjD,OAAO,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-statement.d.ts","sourceRoot":"","sources":["../../src/migration/sql-statement.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-statement.js","sourceRoot":"","sources":["../../src/migration/sql-statement.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SqlStatement } from './sql-statement.js';
|
|
2
|
+
/** The statements of a SQL file in their order, as PostgreSQL runs them; `--> statement-breakpoint` of drizzle-kit is a comment. */
|
|
3
|
+
export declare function sqlStatements(sql: string): SqlStatement[];
|
|
4
|
+
//# sourceMappingURL=sql-statements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-statements.d.ts","sourceRoot":"","sources":["../../src/migration/sql-statements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAUvD,oIAAoI;AACpI,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,EAAE,CAqBzD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A comment, a string, a quoted name, a dollar-quoted body (a `DO $$ .. $$` block keeps its own
|
|
3
|
+
* semicolons), the semicolon that ends a statement, or anything else. An unterminated one runs to
|
|
4
|
+
* the end of the file.
|
|
5
|
+
*/
|
|
6
|
+
const TOKENS = /--[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|'(?:[^']|'')*'?|"(?:[^"]|"")*"?|\$(\w*)\$[\s\S]*?(?:\$\1\$|$)|;|[^-/'"$;]+|[\s\S]/g;
|
|
7
|
+
/** The statements of a SQL file in their order, as PostgreSQL runs them; `--> statement-breakpoint` of drizzle-kit is a comment. */
|
|
8
|
+
export function sqlStatements(sql) {
|
|
9
|
+
const statements = [];
|
|
10
|
+
let text = '';
|
|
11
|
+
let start = 1;
|
|
12
|
+
let line = 1;
|
|
13
|
+
for (const [token] of sql.matchAll(TOKENS)) {
|
|
14
|
+
if (token === ';') {
|
|
15
|
+
statements.push(...folded(text, start));
|
|
16
|
+
text = '';
|
|
17
|
+
}
|
|
18
|
+
else if (token.startsWith('--') || token.startsWith('/*')) {
|
|
19
|
+
text += ' ';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
start = text.trim() === '' && token.trim() !== '' ? line + newlines(token.slice(0, token.search(/\S/))) : start;
|
|
23
|
+
text += token;
|
|
24
|
+
}
|
|
25
|
+
line += newlines(token);
|
|
26
|
+
}
|
|
27
|
+
return [...statements, ...folded(text, start)];
|
|
28
|
+
}
|
|
29
|
+
function folded(text, line) {
|
|
30
|
+
const statement = text.replace(/\s+/g, ' ').trim();
|
|
31
|
+
return statement === '' ? [] : [{ text: statement, line }];
|
|
32
|
+
}
|
|
33
|
+
function newlines(text) {
|
|
34
|
+
return text.split('\n').length - 1;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=sql-statements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-statements.js","sourceRoot":"","sources":["../../src/migration/sql-statements.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,GACV,oHAAoH,CAAC;AAEvH,oIAAoI;AACpI,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,UAAU,GAAmB,EAAE,CAAC;IACtC,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3C,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAClB,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACxC,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;aAAM,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,IAAI,IAAI,GAAG,CAAC;QACd,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAChH,IAAI,IAAI,KAAK,CAAC;QAChB,CAAC;QAED,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,IAAY;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAEnD,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SqlStatement } from './sql-statement.js';
|
|
2
|
+
/** One action of an `ALTER TABLE` that bears on a primary key, with the position of its statement in the file. */
|
|
3
|
+
export interface TableChange {
|
|
4
|
+
readonly kind: 'add-key' | 'drop-constraint' | 'drop-column';
|
|
5
|
+
/** Unquoted, without its schema; lower case unless it was quoted, as PostgreSQL reads it. */
|
|
6
|
+
readonly table: string;
|
|
7
|
+
/** The dropped constraint or column; empty for an added key. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly position: number;
|
|
10
|
+
readonly statement: SqlStatement;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=table-change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-change.d.ts","sourceRoot":"","sources":["../../src/migration/table-change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,kHAAkH;AAClH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,iBAAiB,GAAG,aAAa,CAAC;IAC7D,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-change.js","sourceRoot":"","sources":["../../src/migration/table-change.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SqlStatement } from './sql-statement.js';
|
|
2
|
+
import type { TableChange } from './table-change.js';
|
|
3
|
+
/**
|
|
4
|
+
* The actions of the `ALTER TABLE` statements of a migration that add a primary key, drop a
|
|
5
|
+
* constraint or drop a column, in the order of the statements. The actions of one statement share
|
|
6
|
+
* its position: PostgreSQL drops before it adds within a statement.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tableChanges(statements: readonly SqlStatement[]): TableChange[];
|
|
9
|
+
//# sourceMappingURL=table-changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-changes.d.ts","sourceRoot":"","sources":["../../src/migration/table-changes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBrD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,GAAG,WAAW,EAAE,CAc/E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const NAME = String.raw `(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`;
|
|
2
|
+
const ALTER_TABLE = new RegExp(String.raw `^ALTER TABLE (?:IF EXISTS )?(?:ONLY )?(?:${NAME} ?\. ?)?(${NAME}) (.+)$`, 'i');
|
|
3
|
+
const ADD_KEY = new RegExp(String.raw `^ADD (?:CONSTRAINT ${NAME} )?PRIMARY KEY\b`, 'i');
|
|
4
|
+
const DROP_CONSTRAINT = new RegExp(String.raw `^DROP CONSTRAINT (?:IF EXISTS )?(${NAME})`, 'i');
|
|
5
|
+
const DROP_COLUMN = new RegExp(String.raw `^DROP COLUMN (?:IF EXISTS )?(${NAME})`, 'i');
|
|
6
|
+
/** A quoted name, a string, a parenthesis, a comma, or anything else: the actions of one ALTER TABLE are split on the commas outside parentheses. */
|
|
7
|
+
const PIECES = /"(?:[^"]|"")*"|'(?:[^']|'')*'|[(),]|[^"'(),]+/g;
|
|
8
|
+
/**
|
|
9
|
+
* The actions of the `ALTER TABLE` statements of a migration that add a primary key, drop a
|
|
10
|
+
* constraint or drop a column, in the order of the statements. The actions of one statement share
|
|
11
|
+
* its position: PostgreSQL drops before it adds within a statement.
|
|
12
|
+
*/
|
|
13
|
+
export function tableChanges(statements) {
|
|
14
|
+
return statements.flatMap((statement, position) => {
|
|
15
|
+
const [, table, actions] = ALTER_TABLE.exec(statement.text) ?? [];
|
|
16
|
+
if (table === undefined || actions === undefined) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return actionsOf(actions).flatMap((action) => {
|
|
20
|
+
const change = changeOf(action);
|
|
21
|
+
return change === undefined ? [] : [{ ...change, table: unquoted(table), position, statement }];
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function changeOf(action) {
|
|
26
|
+
const constraint = DROP_CONSTRAINT.exec(action)?.[1];
|
|
27
|
+
const column = DROP_COLUMN.exec(action)?.[1];
|
|
28
|
+
if (constraint !== undefined) {
|
|
29
|
+
return { kind: 'drop-constraint', name: unquoted(constraint) };
|
|
30
|
+
}
|
|
31
|
+
if (column !== undefined) {
|
|
32
|
+
return { kind: 'drop-column', name: unquoted(column) };
|
|
33
|
+
}
|
|
34
|
+
return ADD_KEY.test(action) ? { kind: 'add-key', name: '' } : undefined;
|
|
35
|
+
}
|
|
36
|
+
function actionsOf(text) {
|
|
37
|
+
const actions = [];
|
|
38
|
+
let action = '';
|
|
39
|
+
let depth = 0;
|
|
40
|
+
for (const [piece] of text.matchAll(PIECES)) {
|
|
41
|
+
depth += piece === '(' ? 1 : piece === ')' ? -1 : 0;
|
|
42
|
+
if (piece === ',' && depth === 0) {
|
|
43
|
+
actions.push(action.trim());
|
|
44
|
+
action = '';
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
action += piece;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return [...actions, action.trim()];
|
|
51
|
+
}
|
|
52
|
+
function unquoted(name) {
|
|
53
|
+
return name.startsWith('"') ? name.slice(1, -1).replaceAll('""', '"') : name.toLowerCase();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=table-changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-changes.js","sourceRoot":"","sources":["../../src/migration/table-changes.ts"],"names":[],"mappings":"AAGA,MAAM,IAAI,GAAG,MAAM,CAAC,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5B,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Io } from '../commands/io.js';
|
|
2
|
+
import type { WrittenMigration } from './written-migration.js';
|
|
3
|
+
/** What follows a migration drizzle-kit wrote: its snapshot and journal formatted as the project formats its files, then the warnings on its SQL. */
|
|
4
|
+
export declare function tidyWrittenMigration(written: WrittenMigration, io: Io): void;
|
|
5
|
+
//# sourceMappingURL=tidy-written-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tidy-written-migration.d.ts","sourceRoot":"","sources":["../../src/migration/tidy-written-migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,qJAAqJ;AACrJ,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAG5E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { formatWrittenFiles } from './format-written-files.js';
|
|
2
|
+
import { warnPrimaryKeyOrder } from './warn-primary-key-order.js';
|
|
3
|
+
/** What follows a migration drizzle-kit wrote: its snapshot and journal formatted as the project formats its files, then the warnings on its SQL. */
|
|
4
|
+
export function tidyWrittenMigration(written, io) {
|
|
5
|
+
formatWrittenFiles(written, io);
|
|
6
|
+
warnPrimaryKeyOrder(written, io);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=tidy-written-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tidy-written-migration.js","sourceRoot":"","sources":["../../src/migration/tidy-written-migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,qJAAqJ;AACrJ,MAAM,UAAU,oBAAoB,CAAC,OAAyB,EAAE,EAAM;IACpE,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blocks until the second after `since` has begun: drizzle-kit numbers a migration with the time to
|
|
3
|
+
* the second (`prefix: 'timestamp'`), so two generated within one second would share a snapshot file.
|
|
4
|
+
*/
|
|
5
|
+
export declare function waitForNextSecond(since: number): void;
|
|
6
|
+
//# sourceMappingURL=wait-for-next-second.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-for-next-second.d.ts","sourceRoot":"","sources":["../../src/migration/wait-for-next-second.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMrD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blocks until the second after `since` has begun: drizzle-kit numbers a migration with the time to
|
|
3
|
+
* the second (`prefix: 'timestamp'`), so two generated within one second would share a snapshot file.
|
|
4
|
+
*/
|
|
5
|
+
export function waitForNextSecond(since) {
|
|
6
|
+
const left = (Math.floor(since / 1000) + 1) * 1000 - Date.now();
|
|
7
|
+
if (left > 0) {
|
|
8
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, left);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=wait-for-next-second.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-for-next-second.js","sourceRoot":"","sources":["../../src/migration/wait-for-next-second.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEhE,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Io } from '../commands/io.js';
|
|
2
|
+
import type { WrittenMigration } from './written-migration.js';
|
|
3
|
+
/** Warns, without changing the exit code, about each SQL file just written that changes a primary key in an order that fails. */
|
|
4
|
+
export declare function warnPrimaryKeyOrder({ paths, files }: WrittenMigration, io: Io): void;
|
|
5
|
+
//# sourceMappingURL=warn-primary-key-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn-primary-key-order.d.ts","sourceRoot":"","sources":["../../src/migration/warn-primary-key-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,iIAAiI;AACjI,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAapF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { previousPrimaryKeys } from './previous-primary-keys.js';
|
|
2
|
+
import { primaryKeyOrderFindings } from './primary-key-order-findings.js';
|
|
3
|
+
/** Warns, without changing the exit code, about each SQL file just written that changes a primary key in an order that fails. */
|
|
4
|
+
export function warnPrimaryKeyOrder({ paths, files }, io) {
|
|
5
|
+
for (const file of paths.filter((written) => written.endsWith('.sql'))) {
|
|
6
|
+
for (const finding of primaryKeyOrderFindings(files.get(file) ?? '', previousPrimaryKeys(files, file))) {
|
|
7
|
+
io.err([
|
|
8
|
+
`Warning: ${file}: ${finding.message}`,
|
|
9
|
+
` line ${finding.early.line}: ${finding.early.text}`,
|
|
10
|
+
` line ${finding.drop.line}: ${finding.drop.text}`,
|
|
11
|
+
` Fix: ${finding.fix}`,
|
|
12
|
+
].join('\n'));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=warn-primary-key-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn-primary-key-order.js","sourceRoot":"","sources":["../../src/migration/warn-primary-key-order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAG1E,iIAAiI;AACjI,MAAM,UAAU,mBAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAoB,EAAE,EAAM;IAC5E,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACvE,KAAK,MAAM,OAAO,IAAI,uBAAuB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;YACvG,EAAE,CAAC,GAAG,CACJ;gBACE,YAAY,IAAI,KAAK,OAAO,CAAC,OAAO,EAAE;gBACtC,UAAU,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;gBACrD,UAAU,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE;gBACnD,UAAU,OAAO,CAAC,GAAG,EAAE;aACxB,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What one run of drizzle-kit, or a replay, wrote under the migrations folder of a project. */
|
|
2
|
+
export interface WrittenMigration {
|
|
3
|
+
readonly root: string;
|
|
4
|
+
/** Relative to the project root, POSIX separators. */
|
|
5
|
+
readonly paths: readonly string[];
|
|
6
|
+
/** Every file of the migrations folder and of its `meta/` once written, by path: the snapshots a SQL file follows. */
|
|
7
|
+
readonly files: ReadonlyMap<string, string>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=written-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-migration.d.ts","sourceRoot":"","sources":["../../src/migration/written-migration.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,sHAAsH;IACtH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-migration.js","sourceRoot":"","sources":["../../src/migration/written-migration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-paths.d.ts","sourceRoot":"","sources":["../../src/migration/written-paths.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAE9G"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The paths that are new or changed between two readings of a migrations folder, in order. */
|
|
2
|
+
export function writtenPaths(before, after) {
|
|
3
|
+
return [...after.entries()].filter(([file, content]) => before.get(file) !== content).map(([file]) => file);
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=written-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-paths.js","sourceRoot":"","sources":["../../src/migration/written-paths.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,MAAM,UAAU,YAAY,CAAC,MAAmC,EAAE,KAAkC;IAClG,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAC9G,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The aggregates the generator commands of a `Start with` cell name, sorted, each once. Empty when
|
|
3
|
+
* the cell names none: the files the row touches are then unknown, not shared with nobody.
|
|
4
|
+
*/
|
|
5
|
+
export declare function aggregatesOf(startWith: string): string[];
|
|
6
|
+
//# sourceMappingURL=aggregates-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregates-of.d.ts","sourceRoot":"","sources":["../../src/plan/aggregates-of.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** `--aggregate Invoice`, the aggregate a command or a query works on. */
|
|
2
|
+
const OPTION = /--aggregate[ =]+([A-Za-z][\w]*)/g;
|
|
3
|
+
/** `aggregate billing Invoice`, `repository billing Invoice`: the generators of an aggregate and of its repository. */
|
|
4
|
+
const GENERATOR = /(?<![-\w])(?:aggregate|repository)\s+[a-z][\w-]*\s+([A-Z]\w*)/g;
|
|
5
|
+
/**
|
|
6
|
+
* The aggregates the generator commands of a `Start with` cell name, sorted, each once. Empty when
|
|
7
|
+
* the cell names none: the files the row touches are then unknown, not shared with nobody.
|
|
8
|
+
*/
|
|
9
|
+
export function aggregatesOf(startWith) {
|
|
10
|
+
const named = [...startWith.matchAll(OPTION), ...startWith.matchAll(GENERATOR)].flatMap((match) => match[1] === undefined ? [] : [match[1]]);
|
|
11
|
+
return [...new Set(named)].sort();
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=aggregates-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregates-of.js","sourceRoot":"","sources":["../../src/plan/aggregates-of.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,MAAM,GAAG,kCAAkC,CAAC;AAElD,uHAAuH;AACvH,MAAM,SAAS,GAAG,gEAAgE,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAChG,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACzC,CAAC;IAEF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Slice } from '../progress/slice.js';
|
|
2
|
+
import type { Wave } from './wave-plan.js';
|
|
3
|
+
/** What `batchedWaves` cuts. */
|
|
4
|
+
export interface WaveRows {
|
|
5
|
+
/** The rows to show, in the order of the file. */
|
|
6
|
+
readonly rows: readonly Slice[];
|
|
7
|
+
/** The wave of every planned row, by id: a dependency it does not hold is done. */
|
|
8
|
+
readonly numbers: ReadonlyMap<string, number>;
|
|
9
|
+
/** The name of the project directory, which `worker-scope` names the worktrees after. */
|
|
10
|
+
readonly project: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The rows in their waves, each wave cut into batches: one owner and one context per batch, two
|
|
14
|
+
* rows at most, and two rows together only when their `Start with` names the same aggregate. A
|
|
15
|
+
* row never waits for a row of its own wave: what it depends on is in an earlier one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function batchedWaves(input: WaveRows): Wave[];
|
|
18
|
+
//# sourceMappingURL=batched-waves.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batched-waves.d.ts","sourceRoot":"","sources":["../../src/plan/batched-waves.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,KAAK,EAAS,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAKlD,gCAAgC;AAChC,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,CAAC;IAChC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAUD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,CAQpD"}
|