@rehearsal-db/core 0.1.0-beta.9 → 0.1.0-rc.2
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 +319 -1
- package/COMPATIBILITY.md +15 -0
- package/README.md +73 -16
- package/dist/package.json +100 -0
- package/dist/scripts/install/create_root_config.d.mts +3 -0
- package/dist/scripts/install/create_root_config.mjs +13 -0
- package/dist/scripts/runtime/manage_database.d.mts +6 -0
- package/{scripts → dist/scripts}/runtime/manage_database.mjs +6 -8
- package/dist/src/application/interactive_task.d.mts +30 -0
- package/dist/src/application/interactive_task.mjs +83 -0
- package/dist/src/application/session.d.mts +97 -0
- package/dist/src/application/session.mjs +380 -0
- package/dist/src/baseline/artifact.d.mts +119 -0
- package/dist/src/baseline/artifact.mjs +522 -0
- package/dist/src/baseline/builder.d.mts +19 -0
- package/dist/src/baseline/builder.mjs +142 -0
- package/dist/src/baseline/input_discovery.d.mts +13 -0
- package/dist/src/baseline/input_discovery.mjs +149 -0
- package/dist/src/baseline/policy_review.d.mts +56 -0
- package/dist/src/baseline/policy_review.mjs +73 -0
- package/dist/src/baseline/preparation.d.mts +63 -0
- package/dist/src/baseline/preparation.mjs +295 -0
- package/dist/src/baseline/privacy_contract.d.mts +147 -0
- package/dist/src/baseline/privacy_contract.mjs +2 -0
- package/dist/src/baseline/privacy_dependency_graph.d.mts +7 -0
- package/dist/src/baseline/privacy_dependency_graph.mjs +110 -0
- package/dist/src/baseline/privacy_engine.d.mts +5 -0
- package/dist/src/baseline/privacy_engine.mjs +4 -0
- package/dist/src/baseline/privacy_key.d.mts +7 -0
- package/dist/src/baseline/privacy_key.mjs +42 -0
- package/dist/src/baseline/privacy_pipeline.d.mts +7 -0
- package/dist/src/baseline/privacy_pipeline.mjs +127 -0
- package/dist/src/baseline/privacy_policy.d.mts +6 -0
- package/dist/src/baseline/privacy_policy.mjs +237 -0
- package/dist/src/baseline/privacy_recipe_validation.d.mts +5 -0
- package/dist/src/baseline/privacy_recipe_validation.mjs +289 -0
- package/dist/src/baseline/privacy_rule_registry.d.mts +18 -0
- package/dist/src/baseline/privacy_rule_registry.mjs +143 -0
- package/dist/src/baseline/privacy_structured_json.d.mts +66 -0
- package/dist/src/baseline/privacy_structured_json.mjs +464 -0
- package/dist/src/baseline/privacy_transforms.d.mts +18 -0
- package/dist/src/baseline/privacy_transforms.mjs +142 -0
- package/dist/src/baseline/privacy_validation_shared.d.mts +31 -0
- package/dist/src/baseline/privacy_validation_shared.mjs +127 -0
- package/dist/src/baseline/sanitization_policy.d.mts +69 -0
- package/dist/src/baseline/sanitization_policy.mjs +227 -0
- package/dist/src/baseline/schema_snapshot.d.mts +19 -0
- package/dist/src/baseline/schema_snapshot.mjs +79 -0
- package/dist/src/cli/application_command_handlers.d.mts +8 -0
- package/dist/src/cli/application_command_handlers.mjs +52 -0
- package/dist/src/cli/arguments.d.mts +38 -0
- package/dist/src/cli/arguments.mjs +130 -0
- package/dist/src/cli/basic_command_handlers.d.mts +4 -0
- package/dist/src/cli/basic_command_handlers.mjs +57 -0
- package/dist/src/cli/cli_commands.d.mts +14 -0
- package/dist/src/cli/cli_commands.mjs +34 -0
- package/dist/src/cli/command_contract.d.mts +57 -0
- package/dist/src/cli/command_contract.mjs +39 -0
- package/dist/src/cli/command_output.d.mts +12 -0
- package/dist/src/cli/command_output.mjs +20 -0
- package/dist/src/cli/command_registry.d.mts +7 -0
- package/dist/src/cli/command_registry.mjs +14 -0
- package/dist/src/cli/guided.d.mts +53 -0
- package/dist/src/cli/guided.mjs +727 -0
- package/dist/src/cli/identity_command_handlers.d.mts +12 -0
- package/dist/src/cli/identity_command_handlers.mjs +239 -0
- package/dist/src/cli/identity_renderer.d.mts +8 -0
- package/dist/src/cli/identity_renderer.mjs +33 -0
- package/dist/src/cli/init_command.d.mts +21 -0
- package/dist/src/cli/init_command.mjs +90 -0
- package/dist/src/cli/inspection_command_handlers.d.mts +3 -0
- package/dist/src/cli/inspection_command_handlers.mjs +79 -0
- package/dist/src/cli/project_command_handlers.d.mts +11 -0
- package/dist/src/cli/project_command_handlers.mjs +92 -0
- package/dist/src/cli/project_commands.d.mts +283 -0
- package/dist/src/cli/project_commands.mjs +192 -0
- package/dist/src/cli/rehearsal.d.mts +7 -0
- package/dist/src/cli/rehearsal.mjs +190 -0
- package/dist/src/cli/renderers.d.mts +299 -0
- package/dist/src/cli/renderers.mjs +554 -0
- package/dist/src/cli/runtime_action_handlers.d.mts +12 -0
- package/dist/src/cli/runtime_action_handlers.mjs +201 -0
- package/dist/src/cli/runtime_commands.d.mts +294 -0
- package/dist/src/cli/runtime_commands.mjs +619 -0
- package/dist/src/cli/source_command_handlers.d.mts +8 -0
- package/dist/src/cli/source_command_handlers.mjs +62 -0
- package/dist/src/cli/source_commands.d.mts +436 -0
- package/dist/src/cli/source_commands.mjs +301 -0
- package/dist/src/cli/terminal.d.mts +59 -0
- package/dist/src/cli/terminal.mjs +230 -0
- package/dist/src/identity/claim.d.mts +5 -0
- package/dist/src/identity/claim.mjs +4 -0
- package/dist/src/identity/claim_contract.d.mts +135 -0
- package/dist/src/identity/claim_contract.mjs +6 -0
- package/dist/src/identity/claim_executor.d.mts +10 -0
- package/dist/src/identity/claim_executor.mjs +358 -0
- package/dist/src/identity/claim_identity_lookup.d.mts +23 -0
- package/dist/src/identity/claim_identity_lookup.mjs +134 -0
- package/dist/src/identity/claim_plan.d.mts +8 -0
- package/dist/src/identity/claim_plan.mjs +61 -0
- package/dist/src/identity/claim_policy.d.mts +3 -0
- package/dist/src/identity/claim_policy.mjs +377 -0
- package/dist/src/identity/claim_sql.d.mts +10 -0
- package/dist/src/identity/claim_sql.mjs +46 -0
- package/dist/src/identity/claim_verification.d.mts +13 -0
- package/dist/src/identity/claim_verification.mjs +35 -0
- package/dist/src/identity/connect.d.mts +30 -0
- package/dist/src/identity/connect.mjs +111 -0
- package/dist/src/identity/provider_configuration.d.mts +37 -0
- package/dist/src/identity/provider_configuration.mjs +132 -0
- package/dist/src/identity/storage.d.mts +21 -0
- package/dist/src/identity/storage.mjs +122 -0
- package/dist/src/index.d.mts +4 -0
- package/dist/src/index.mjs +3 -0
- package/dist/src/project/configuration.d.mts +13 -0
- package/dist/src/project/configuration.mjs +9 -0
- package/dist/src/project/configuration_contract.d.mts +125 -0
- package/dist/src/project/configuration_contract.mjs +27 -0
- package/dist/src/project/configuration_discovery.d.mts +7 -0
- package/dist/src/project/configuration_discovery.mjs +37 -0
- package/dist/src/project/configuration_normalization.d.mts +107 -0
- package/dist/src/project/configuration_normalization.mjs +302 -0
- package/dist/src/project/configuration_rendering.d.mts +14 -0
- package/dist/src/project/configuration_rendering.mjs +228 -0
- package/dist/src/project/configuration_resolution.d.mts +125 -0
- package/dist/src/project/configuration_resolution.mjs +81 -0
- package/dist/src/project/configuration_schema.d.mts +22 -0
- package/dist/src/project/configuration_schema.mjs +160 -0
- package/dist/src/project/configuration_validation.d.mts +22 -0
- package/dist/src/project/configuration_validation.mjs +136 -0
- package/dist/src/project/install_scaffold.d.mts +42 -0
- package/dist/src/project/install_scaffold.mjs +263 -0
- package/dist/src/project/project_detection.d.mts +14 -0
- package/dist/src/project/project_detection.mjs +47 -0
- package/dist/src/project/setup.d.mts +87 -0
- package/dist/src/project/setup.mjs +414 -0
- package/dist/src/project/support_report.d.mts +88 -0
- package/dist/src/project/support_report.mjs +83 -0
- package/dist/src/runtime/cleanup.d.mts +85 -0
- package/dist/src/runtime/cleanup.mjs +311 -0
- package/dist/src/runtime/lifecycle_engine.d.mts +63 -0
- package/dist/src/runtime/lifecycle_engine.mjs +114 -0
- package/dist/src/runtime/migration_history.d.mts +51 -0
- package/dist/src/runtime/migration_history.mjs +170 -0
- package/dist/src/runtime/plan.d.mts +134 -0
- package/dist/src/runtime/plan.mjs +640 -0
- package/dist/src/runtime/policy.d.mts +66 -0
- package/dist/src/runtime/policy.mjs +369 -0
- package/dist/src/runtime/restore.d.mts +22 -0
- package/dist/src/runtime/restore.mjs +276 -0
- package/dist/src/runtime/service_environment.d.mts +11 -0
- package/dist/src/runtime/service_environment.mjs +58 -0
- package/dist/src/runtime/topology.d.mts +51 -0
- package/dist/src/runtime/topology.mjs +128 -0
- package/dist/src/shared/diagnostics.d.mts +97 -0
- package/dist/src/shared/diagnostics.mjs +170 -0
- package/dist/src/shared/human_output.d.mts +2 -0
- package/{src → dist/src}/shared/human_output.mjs +1 -3
- package/dist/src/shared/node_runtime.d.mts +14 -0
- package/dist/src/shared/node_runtime.mjs +25 -0
- package/dist/src/shared/operation_guard.d.mts +22 -0
- package/dist/src/shared/operation_guard.mjs +150 -0
- package/dist/src/shared/process_environment.d.mts +15 -0
- package/dist/src/shared/process_environment.mjs +50 -0
- package/dist/src/source/access.d.mts +165 -0
- package/dist/src/source/access.mjs +602 -0
- package/dist/src/source/asset_transfer.d.mts +27 -0
- package/dist/src/source/asset_transfer.mjs +202 -0
- package/dist/src/source/baseline.d.mts +66 -0
- package/dist/src/source/baseline.mjs +372 -0
- package/dist/src/source/external_reader.d.mts +42 -0
- package/dist/src/source/external_reader.mjs +278 -0
- package/dist/src/source/postgresql_access.d.mts +86 -0
- package/dist/src/source/postgresql_access.mjs +454 -0
- package/dist/src/source/privacy_paths.d.mts +10 -0
- package/dist/src/source/privacy_paths.mjs +27 -0
- package/dist/src/targets/driver.d.mts +2 -0
- package/dist/src/targets/driver.mjs +13 -0
- package/dist/src/targets/postgresql.d.mts +5 -0
- package/dist/src/targets/postgresql.mjs +620 -0
- package/dist/src/targets/supabase.d.mts +8 -0
- package/dist/src/targets/supabase.mjs +629 -0
- package/dist/src/targets/supabase_environment.d.mts +54 -0
- package/dist/src/targets/supabase_environment.mjs +184 -0
- package/dist/src/targets/target.d.mts +33 -0
- package/dist/src/targets/target.mjs +39 -0
- package/docs/README.md +35 -16
- package/docs/architecture.md +135 -10
- package/docs/commands.md +53 -15
- package/docs/configuration.md +186 -31
- package/docs/getting-started.md +66 -9
- package/docs/index.md +67 -0
- package/docs/production-source.md +175 -17
- package/docs/releasing.md +24 -12
- package/docs/roadmap.md +3 -2
- package/docs/runtime-lifecycle.md +99 -0
- package/docs/runtime-policies.md +80 -7
- package/docs/sanitization.md +572 -4
- package/docs/security-model.md +8 -0
- package/docs/stability.md +70 -0
- package/docs/standalone-workflow.md +36 -13
- package/docs/troubleshooting.md +82 -10
- package/docs/tutorial.md +7 -1
- package/docs/typescript.md +134 -0
- package/package.json +44 -29
- package/types/configuration.d.mts +5 -0
- package/src/README.md +0 -17
- package/src/application/session.mjs +0 -313
- package/src/baseline/artifact.mjs +0 -661
- package/src/baseline/builder.mjs +0 -164
- package/src/baseline/input_discovery.mjs +0 -155
- package/src/baseline/policy_review.mjs +0 -92
- package/src/baseline/preparation.mjs +0 -323
- package/src/baseline/privacy_engine.mjs +0 -413
- package/src/baseline/sanitization_policy.mjs +0 -299
- package/src/baseline/schema_snapshot.mjs +0 -113
- package/src/cli/arguments.mjs +0 -120
- package/src/cli/guided.mjs +0 -807
- package/src/cli/rehearsal.mjs +0 -933
- package/src/cli/renderers.mjs +0 -584
- package/src/cli/runtime_commands.mjs +0 -553
- package/src/cli/source_commands.mjs +0 -326
- package/src/cli/terminal.mjs +0 -275
- package/src/identity/claim.mjs +0 -975
- package/src/identity/storage.mjs +0 -165
- package/src/project/configuration.d.mts +0 -153
- package/src/project/configuration.mjs +0 -1197
- package/src/project/setup.mjs +0 -379
- package/src/project/support_report.mjs +0 -105
- package/src/runtime/cleanup.mjs +0 -381
- package/src/runtime/migration_history.mjs +0 -220
- package/src/runtime/plan.mjs +0 -685
- package/src/runtime/policy.mjs +0 -438
- package/src/runtime/restore.mjs +0 -329
- package/src/runtime/service_environment.mjs +0 -82
- package/src/runtime/topology.mjs +0 -177
- package/src/shared/diagnostics.mjs +0 -199
- package/src/shared/operation_guard.mjs +0 -162
- package/src/shared/process_environment.mjs +0 -68
- package/src/source/access.mjs +0 -578
- package/src/source/asset_transfer.mjs +0 -177
- package/src/source/baseline.mjs +0 -446
- package/src/source/postgresql_access.mjs +0 -480
- package/src/targets/postgresql.mjs +0 -808
- package/src/targets/supabase.mjs +0 -830
- package/src/targets/supabase_environment.mjs +0 -229
- package/src/targets/target.mjs +0 -66
package/docs/configuration.md
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
# Configuration reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An ordinary npm application install creates this file in the application root when the
|
|
4
|
+
root can be identified safely:
|
|
4
5
|
|
|
5
6
|
```bash
|
|
6
|
-
|
|
7
|
+
npm install --save-dev @rehearsal-db/core
|
|
7
8
|
```
|
|
8
9
|
|
|
9
|
-
The
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
The install hook detects the database type, project name, migration folder,
|
|
11
|
+
package-manager commands, and free local ports. It also creates the dedicated local
|
|
12
|
+
runtime config and appends the two Rehearsal local-artifact entries to `.gitignore`.
|
|
13
|
+
Existing configs and existing ignore content are never rewritten.
|
|
14
|
+
|
|
15
|
+
When lifecycle scripts are disabled or the application root is not provable, run
|
|
16
|
+
`npx rehearsal` inside the application. The guide provides the same setup with a preview
|
|
17
|
+
and confirmation. Automatic root generation is tested with npm. pnpm and Yarn users
|
|
18
|
+
should use this guided fallback because their lifecycle and workspace layouts vary.
|
|
13
19
|
|
|
14
20
|
Review lines marked `CHECK`, especially the application proof command. Optional settings
|
|
15
21
|
are present as commented examples, and secrets never belong in this file. Rehearsal will
|
|
@@ -19,6 +25,11 @@ Use this page when changing the generated file. The schema is strict: misspelled
|
|
|
19
25
|
unknown fields, and unsupported versions are errors. The `.mjs` extension works in both
|
|
20
26
|
CommonJS and ESM projects.
|
|
21
27
|
|
|
28
|
+
The generated file also receives editor and compiler checking through the package's
|
|
29
|
+
public TypeScript declarations. See [TypeScript](typescript.md) for the supported type
|
|
30
|
+
surface and checked examples. Keep the runnable configuration as `.mjs`; a project does
|
|
31
|
+
not need to rename it to `.ts`.
|
|
32
|
+
|
|
22
33
|
```ts
|
|
23
34
|
// @ts-check
|
|
24
35
|
import { defineRehearsalConfig } from "@rehearsal-db/core";
|
|
@@ -36,9 +47,21 @@ export default defineRehearsalConfig({
|
|
|
36
47
|
rehearsalConfig: "infrastructure/rehearsal/supabase/config.toml",
|
|
37
48
|
runtimeWorkdir: ".rehearsal/runtime",
|
|
38
49
|
|
|
39
|
-
// Optional
|
|
40
|
-
//
|
|
41
|
-
//
|
|
50
|
+
// Optional local OAuth connection. Secrets stay in the ignored owner-only file.
|
|
51
|
+
// Register http://127.0.0.1:58321/auth/v1/callback with the provider.
|
|
52
|
+
// authentication: {
|
|
53
|
+
// enableLocalSignup: true,
|
|
54
|
+
// environmentFile: ".env.rehearsal-service.local",
|
|
55
|
+
// providers: [
|
|
56
|
+
// {
|
|
57
|
+
// name: "google",
|
|
58
|
+
// clientIdEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_ID",
|
|
59
|
+
// clientSecretEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_SECRET",
|
|
60
|
+
// skipNonceCheck: false,
|
|
61
|
+
// emailOptional: false,
|
|
62
|
+
// },
|
|
63
|
+
// ],
|
|
64
|
+
// },
|
|
42
65
|
},
|
|
43
66
|
baseline: {
|
|
44
67
|
artifactDirectory: ".rehearsal",
|
|
@@ -54,10 +77,12 @@ export default defineRehearsalConfig({
|
|
|
54
77
|
// diskHeadroomBytes: 67108864,
|
|
55
78
|
// },
|
|
56
79
|
// runtimePolicy: "infrastructure/rehearsal/runtime-policy.json",
|
|
57
|
-
// Optional
|
|
80
|
+
// Optional copied-account association. The JSON stores reviewed matcher hashes only;
|
|
81
|
+
// raw emails/subjects and provider credentials stay in ignored environment files.
|
|
82
|
+
// After setup, run: npx rehearsal identity connect
|
|
58
83
|
// identityPolicy: "infrastructure/rehearsal/identity-policy.json",
|
|
59
84
|
containerRuntime: {
|
|
60
|
-
autoStartColima:
|
|
85
|
+
autoStartColima: false,
|
|
61
86
|
},
|
|
62
87
|
cleanup: {
|
|
63
88
|
retainBaselineGenerations: 2,
|
|
@@ -111,8 +136,64 @@ All paths resolve inside the consuming project. The artifact directory must be n
|
|
|
111
136
|
`.rehearsal`; this is an intentional deletion guard. `runtimeWorkdir` must be its
|
|
112
137
|
`runtime` child, and the generated application environment file must remain inside it.
|
|
113
138
|
|
|
114
|
-
Rehearsal never overwrites this config.
|
|
115
|
-
|
|
139
|
+
Rehearsal never overwrites this config. Do not move it merely to inspect a newer template.
|
|
140
|
+
After upgrading, run `npx rehearsal init` to print the current release's generated
|
|
141
|
+
template beside the path of your existing config. This comparison is read-only; adding a
|
|
142
|
+
new optional key remains your decision. `npx rehearsal init --write` still refuses to
|
|
143
|
+
replace an existing config. Rehearsal lists important optional settings that are
|
|
144
|
+
available but not enabled before printing the template, so they are easier to find.
|
|
145
|
+
|
|
146
|
+
If setup was interrupted after creating only some files, rerun
|
|
147
|
+
`npx rehearsal setup --write`. It recreates missing generated files while preserving every
|
|
148
|
+
existing config and local runtime file. When a config itself is invalid, keep it as a
|
|
149
|
+
backup, generate a fresh file, and manually carry over only reviewed settings. See
|
|
150
|
+
[Getting started](getting-started.md#if-setup-or-an-upgrade-is-interrupted) for the short
|
|
151
|
+
recovery table.
|
|
152
|
+
|
|
153
|
+
### Workspaces and custom paths
|
|
154
|
+
|
|
155
|
+
For an npm workspace, automatic creation proceeds only when exactly one application
|
|
156
|
+
package already declares `@rehearsal-db/core` in the manifest or lockfile visible to the
|
|
157
|
+
install hook. npm can save a new `--workspace` dependency after that hook runs, so a
|
|
158
|
+
first workspace install may safely skip creation. If several applications declare it,
|
|
159
|
+
Rehearsal also refuses to choose. Run `npx rehearsal` inside each intended application.
|
|
160
|
+
Global installs, package caches, temporary `npx` installs, and Rehearsal's own source
|
|
161
|
+
checkout never receive project files.
|
|
162
|
+
|
|
163
|
+
Supported existing config paths—including
|
|
164
|
+
`infrastructure/rehearsal/rehearsal.config.mjs`—are preserved, and a second root config
|
|
165
|
+
is not created. The install hook reports the exact active path when npm displays lifecycle
|
|
166
|
+
output, and setup always prints it. `npx rehearsal init --json` is the package-manager-
|
|
167
|
+
independent way to check the `destination`. Rehearsal checks the supported root filenames
|
|
168
|
+
first and then the supported nested filenames; finding any one of them prevents automatic
|
|
169
|
+
creation of another. Use
|
|
170
|
+
`--config=<project-relative-path>` for other explicit paths when running commands.
|
|
171
|
+
|
|
172
|
+
### Move an existing config to the project root
|
|
173
|
+
|
|
174
|
+
Relocation is deliberately manual because the config may contain reviewed settings and
|
|
175
|
+
JavaScript imports. Rehearsal will never move it or create a competing root file.
|
|
176
|
+
|
|
177
|
+
From the directory containing `package.json`:
|
|
178
|
+
|
|
179
|
+
1. Stop active Rehearsal commands and confirm the current path with
|
|
180
|
+
`npx rehearsal init --json`.
|
|
181
|
+
2. Make a backup outside every supported discovery path, such as
|
|
182
|
+
`.rehearsal/config-backups/rehearsal.config.mjs`.
|
|
183
|
+
3. Move—do not copy—the active file to `./rehearsal.config.mjs`. Use `git mv` when it is
|
|
184
|
+
tracked so review history remains clear.
|
|
185
|
+
4. Update relative JavaScript `import` specifiers inside the moved file. Imports resolve
|
|
186
|
+
from the config file's own folder, so a nested `../../something.mjs` import usually
|
|
187
|
+
changes after moving to the root.
|
|
188
|
+
5. Leave config values such as `migrationDirectory`, `sanitizationPolicy`,
|
|
189
|
+
`runtimePolicy`, `identityPolicy`, and `dependentTargets[].configPath` unchanged unless
|
|
190
|
+
the referenced project file also moved. Rehearsal resolves those values from the
|
|
191
|
+
project root, not from the config file's folder.
|
|
192
|
+
6. Run `npx rehearsal init --json`, confirm its `destination` is
|
|
193
|
+
`rehearsal.config.mjs`, then run `npx rehearsal doctor` and review the Git diff.
|
|
194
|
+
|
|
195
|
+
If validation fails, restore the backup to its original path. Do not run setup while the
|
|
196
|
+
move is half-finished; setup may correctly conclude that no supported config exists.
|
|
116
197
|
|
|
117
198
|
`preparation.privacyKey` must stay inside `.rehearsal`; it is ignored and owner-readable
|
|
118
199
|
only. Source, runtime, and identity policy files are declarations that may be reviewed in
|
|
@@ -135,15 +216,18 @@ approval sequence.
|
|
|
135
216
|
|
|
136
217
|
`runtimePolicy` replaces common restore adapters with reviewed schemas, allowlisted
|
|
137
218
|
extensions, managed triggers, local-only singleton rows, and structural expectations.
|
|
138
|
-
`identityPolicy` declares a hashed verified
|
|
139
|
-
defaults, required role/reference transfers, Storage path
|
|
219
|
+
`identityPolicy` declares a hashed verified-email or provider-subject matcher, copied
|
|
220
|
+
placeholder, safe signup defaults, required role/reference transfers, Storage path
|
|
221
|
+
rewrites, and token checks. Provider credentials stay in the local Supabase runtime
|
|
222
|
+
environment; association values stay in named environment variables and only their
|
|
223
|
+
SHA-256 receipts are tracked. See
|
|
140
224
|
[Runtime and identity policies](runtime-policies.md).
|
|
141
225
|
|
|
142
226
|
## Container runtime and cleanup
|
|
143
227
|
|
|
144
228
|
```ts
|
|
145
229
|
containerRuntime: {
|
|
146
|
-
autoStartColima:
|
|
230
|
+
autoStartColima: false,
|
|
147
231
|
},
|
|
148
232
|
cleanup: {
|
|
149
233
|
retainBaselineGenerations: 2,
|
|
@@ -151,9 +235,17 @@ cleanup: {
|
|
|
151
235
|
```
|
|
152
236
|
|
|
153
237
|
Rehearsal uses whichever Docker-compatible engine already answers `docker info`. If none
|
|
154
|
-
is running and `autoStartColima` is `true`, Rehearsal may run `colima start`.
|
|
155
|
-
|
|
156
|
-
|
|
238
|
+
is running and `autoStartColima` is `true`, Rehearsal may run `colima start`. This is an
|
|
239
|
+
explicit opt-in because starting a shared Docker engine can also restart unrelated
|
|
240
|
+
containers whose restart policy is `always` or `unless-stopped`. Rehearsal respects the
|
|
241
|
+
user's Colima CPU, memory, and disk settings and never changes them. The generated default
|
|
242
|
+
is `false`: start Docker or Colima yourself before a mutating command. Rehearsal never
|
|
243
|
+
stops a shared container engine automatically.
|
|
244
|
+
|
|
245
|
+
After each Supabase start, Rehearsal changes only the exact target's containers to
|
|
246
|
+
Docker's `no` restart policy. Its database and Storage volumes remain intact,
|
|
247
|
+
`rehearsal start` can resume it, and restarting Docker does not silently wake stopped
|
|
248
|
+
Rehearsal stacks.
|
|
157
249
|
|
|
158
250
|
`retainBaselineGenerations` controls how many immutable baseline generations survive an
|
|
159
251
|
approved `rehearsal refresh` or `rehearsal cleanup`; it must be at least 1. Refresh shows
|
|
@@ -217,19 +309,72 @@ negative controls, such as unauthorized, malformed, withheld, or missing records
|
|
|
217
309
|
response that merely avoids a server error does not prove that eligible data was
|
|
218
310
|
published or can be found.
|
|
219
311
|
|
|
220
|
-
## Supabase
|
|
312
|
+
## Supabase authentication
|
|
221
313
|
|
|
222
|
-
|
|
223
|
-
|
|
314
|
+
Rehearsal can configure a Google or GitHub OAuth connection in its disposable local
|
|
315
|
+
Supabase runtime. Declare the provider and the names of its credential variables:
|
|
224
316
|
|
|
225
317
|
```ts
|
|
226
|
-
|
|
227
|
-
|
|
318
|
+
authentication: {
|
|
319
|
+
enableLocalSignup: true,
|
|
320
|
+
environmentFile: ".env.rehearsal-service.local",
|
|
321
|
+
providers: [
|
|
322
|
+
{
|
|
323
|
+
name: "google",
|
|
324
|
+
clientIdEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_ID",
|
|
325
|
+
clientSecretEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_SECRET",
|
|
326
|
+
skipNonceCheck: false,
|
|
327
|
+
emailOptional: false,
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
},
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Create the ignored file, add the values, then restrict it to your account:
|
|
334
|
+
|
|
335
|
+
```dotenv
|
|
336
|
+
REHEARSAL_GOOGLE_CLIENT_ID=your-local-oauth-client-id
|
|
337
|
+
REHEARSAL_GOOGLE_CLIENT_SECRET=your-local-oauth-client-secret
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
chmod 600 .env.rehearsal-service.local
|
|
228
342
|
```
|
|
229
343
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
344
|
+
Register `http://127.0.0.1:<apiPort>/auth/v1/callback` with the provider, using the
|
|
345
|
+
`runtime.apiPort` value from this config. `rehearsal explain` also prints the exact URL.
|
|
346
|
+
Rehearsal writes that callback and `env(...)` references into the disposable runtime; it
|
|
347
|
+
never copies credential values into tracked configuration. Use `name: "github"` and
|
|
348
|
+
distinct GitHub variable names for GitHub. Duplicate providers, reused variable names,
|
|
349
|
+
unsupported providers, extra keys, and a template that already owns the same provider
|
|
350
|
+
are refused. This follows Supabase's documented
|
|
351
|
+
[`env()` configuration pattern](https://supabase.com/docs/guides/local-development/managing-config).
|
|
352
|
+
|
|
353
|
+
`enableLocalSignup: true` explicitly acknowledges that disposable local Auth may create
|
|
354
|
+
the temporary user returned by OAuth. Rehearsal changes the generated runtime copy only;
|
|
355
|
+
the tracked Supabase template and every hosted project remain unchanged.
|
|
356
|
+
|
|
357
|
+
The older `serviceEnvironmentFile`, `serviceEnvironmentVariables`, and
|
|
358
|
+
`safety.authenticationProviders` fields remain compatible for projects that manually
|
|
359
|
+
own their Supabase provider TOML. Do not combine those fields with the declarative
|
|
360
|
+
`authentication` block.
|
|
361
|
+
|
|
362
|
+
To migrate a manual Google or GitHub setup, replace those three legacy config fields
|
|
363
|
+
with the `authentication` block together. The tracked Supabase template may keep its
|
|
364
|
+
existing provider section: Rehearsal replaces a compatible legacy section only in the
|
|
365
|
+
generated disposable runtime copy. The section may contain `enabled`, `client_id`,
|
|
366
|
+
`secret`, `redirect_uri`, `skip_nonce_check`, and `email_optional`. The latter two must
|
|
367
|
+
match the explicit `skipNonceCheck` and `emailOptional` declarations, which default to
|
|
368
|
+
`false`. Keep them false unless the provider integration has a reviewed need; Supabase
|
|
369
|
+
warns in its [CLI configuration reference](https://supabase.com/docs/guides/local-development/cli/config#auth.external.provider.skip_nonce_check)
|
|
370
|
+
that skipping nonce validation reduces replay protection. Unknown settings,
|
|
371
|
+
duplicate sections, nested provider tables, or mismatched options fail
|
|
372
|
+
`rehearsal doctor` before reset. Rehearsal never edits the tracked template during this
|
|
373
|
+
transition.
|
|
374
|
+
|
|
375
|
+
Provider connection and copied-account association are separate. This block lets the
|
|
376
|
+
ordinary application sign-in reach local Auth. An optional `identityPolicy` decides
|
|
377
|
+
whether that verified local identity may claim a reviewed copied account.
|
|
233
378
|
|
|
234
379
|
## Safety fields
|
|
235
380
|
|
|
@@ -281,7 +426,7 @@ Declarative runtime policies are preferred for supported schema prerequisites an
|
|
|
281
426
|
checks. Existing project-owned adapters remain compatible but do not replace the
|
|
282
427
|
database driver.
|
|
283
428
|
|
|
284
|
-
## Application proof
|
|
429
|
+
## Application proof and hands-on sessions
|
|
285
430
|
|
|
286
431
|
`startCommand` is the ordinary application command. When `readiness` is present,
|
|
287
432
|
`rehearsal run` launches it with a minimal environment, waits for the exact local status,
|
|
@@ -306,6 +451,15 @@ package-owned checks and must include real positive and negative expectations. A
|
|
|
306
451
|
404, 401, empty result, or non-5xx response is not a positive unless it matches the
|
|
307
452
|
declared status and body assertion.
|
|
308
453
|
|
|
454
|
+
After a successful rehearsal, `rehearsal open` uses the same `startCommand`, readiness
|
|
455
|
+
check, and environment mappings for a hands-on session. It starts and verifies every
|
|
456
|
+
configured database target but does not reset them. The app remains available until
|
|
457
|
+
`Ctrl+C` or `Ctrl+Z`; Rehearsal then stops only its application process group. Database
|
|
458
|
+
and Storage changes remain for the next `open`, `verify`, or `start` command.
|
|
459
|
+
|
|
460
|
+
`application.readiness` is required for `open`. Point it at a route that returns the
|
|
461
|
+
configured status only when the local app is ready. Keep the URL on a loopback host.
|
|
462
|
+
|
|
309
463
|
## Runtime adapters
|
|
310
464
|
|
|
311
465
|
Existing adapters remain compatible, but new projects should first use `runtimePolicy`,
|
|
@@ -326,9 +480,10 @@ may use these explicit subpaths:
|
|
|
326
480
|
- `@rehearsal-db/core/service-environment`
|
|
327
481
|
- `@rehearsal-db/core/source-access`
|
|
328
482
|
|
|
329
|
-
These advanced entry points
|
|
330
|
-
configuration and sanitization
|
|
331
|
-
|
|
483
|
+
These advanced entry points ship as ordinary ESM JavaScript with generated TypeScript
|
|
484
|
+
declarations. The root configuration and sanitization contract remains the explicitly
|
|
485
|
+
reviewed public type surface. The exact current boundary is documented in
|
|
486
|
+
[TypeScript](typescript.md).
|
|
332
487
|
|
|
333
488
|
Undocumented files under `scripts/` are package internals and are not compatibility
|
|
334
489
|
contracts.
|
package/docs/getting-started.md
CHANGED
|
@@ -7,7 +7,8 @@ Want to experiment first? Use the [safe hands-on tutorial](tutorial.md).
|
|
|
7
7
|
|
|
8
8
|
## 1. Check the required tools
|
|
9
9
|
|
|
10
|
-
You need Node.js 24, npm, and a running Docker-compatible engine
|
|
10
|
+
You need Node.js 22, 24, or 26, npm, and a running Docker-compatible engine. Node.js 24
|
|
11
|
+
LTS is the recommended default:
|
|
11
12
|
|
|
12
13
|
```bash
|
|
13
14
|
node --version
|
|
@@ -15,8 +16,8 @@ npm --version
|
|
|
15
16
|
docker info
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
`node --version` must begin with `v24`. If `docker info` fails, start
|
|
19
|
-
Colima, or your usual Docker engine.
|
|
19
|
+
`node --version` must begin with `v22`, `v24`, or `v26`. If `docker info` fails, start
|
|
20
|
+
Docker Desktop, Colima, or your usual Docker engine.
|
|
20
21
|
|
|
21
22
|
Choose the extra requirement for your project:
|
|
22
23
|
|
|
@@ -34,22 +35,39 @@ Rehearsal will use that image with downloads disabled.
|
|
|
34
35
|
Run these commands from the directory containing your project's `package.json`:
|
|
35
36
|
|
|
36
37
|
```bash
|
|
37
|
-
npm install --save-dev @rehearsal-db/core
|
|
38
|
+
npm install --save-dev @rehearsal-db/core
|
|
38
39
|
npx rehearsal
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
With npm, a normal application install creates `rehearsal.config.mjs`, the dedicated
|
|
43
|
+
local runtime config, and the required `.gitignore` entries when Rehearsal can prove the
|
|
44
|
+
application root. It never replaces an existing file. Review the generated config,
|
|
45
|
+
especially:
|
|
45
46
|
|
|
46
47
|
- the migration directory;
|
|
47
48
|
- the application start and proof commands;
|
|
48
49
|
- the local ports.
|
|
49
50
|
|
|
51
|
+
If a supported configuration already exists elsewhere—such as
|
|
52
|
+
`infrastructure/rehearsal/rehearsal.config.mjs`—the installer reports that exact active
|
|
53
|
+
path and does not generate a competing root file. Keep using it, or follow the explicit
|
|
54
|
+
[root relocation guide](configuration.md#move-an-existing-config-to-the-project-root).
|
|
55
|
+
|
|
56
|
+
If lifecycle scripts were disabled, a global/cache install was used, or a workspace has
|
|
57
|
+
more than one possible application, no project files are created automatically. Run
|
|
58
|
+
`npx rehearsal` inside the intended application, choose **Set the stage**, select
|
|
59
|
+
Supabase or PostgreSQL, and approve the same safe setup preview.
|
|
60
|
+
|
|
50
61
|
The proof command should check behavior changed by the migration. A test that only checks
|
|
51
62
|
whether the home page loads is usually too weak.
|
|
52
63
|
|
|
64
|
+
If the sandbox needs Google or GitHub sign-in, uncomment
|
|
65
|
+
`supabase.authentication` in `rehearsal.config.mjs`. Add the named credentials to
|
|
66
|
+
`.env.rehearsal-service.local`, run `chmod 600 .env.rehearsal-service.local`, and
|
|
67
|
+
register the local callback printed in the config. See
|
|
68
|
+
[Supabase authentication](configuration.md#supabase-authentication). Rehearsal keeps the
|
|
69
|
+
values out of tracked files and generates the disposable provider configuration for you.
|
|
70
|
+
|
|
53
71
|
## 3. Prepare safe baseline inputs
|
|
54
72
|
|
|
55
73
|
A **baseline** is the locked starting point restored before each rehearsal. Start with a
|
|
@@ -125,7 +143,17 @@ Once temporary source access is ready, `npx rehearsal refresh` previews the safe
|
|
|
125
143
|
replacement workflow. It means “get a newly verified copy.” By contrast, `reset` means
|
|
126
144
|
“discard local edits and restore the copy I already have.”
|
|
127
145
|
|
|
128
|
-
## 6.
|
|
146
|
+
## 6. Use the sandbox and clean up
|
|
147
|
+
|
|
148
|
+
Choose **Open the sandbox app**, or run:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npx rehearsal open
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Open the local URL printed by Rehearsal. The app stays available for hands-on testing
|
|
155
|
+
until you press `Ctrl+C`. Only the app stops; your local database and Storage changes are
|
|
156
|
+
kept. Run `npx rehearsal open` again to continue where you left off.
|
|
129
157
|
|
|
130
158
|
Use the guide for normal runtime tasks:
|
|
131
159
|
|
|
@@ -151,6 +179,35 @@ npx rehearsal run --confirm-candidates=PASTE_DIGEST_HERE
|
|
|
151
179
|
Replace `postgresql` with `supabase` when needed. See [CLI commands](commands.md) for the
|
|
152
180
|
complete reference and [Troubleshooting](troubleshooting.md) when a check fails.
|
|
153
181
|
|
|
182
|
+
Running setup again is safe: existing configuration and runtime files are reported as
|
|
183
|
+
unchanged. Rehearsal only adds missing ignore entries. It never refreshes an existing
|
|
184
|
+
config during an upgrade. After upgrading, run `npx rehearsal init` to see important
|
|
185
|
+
optional settings you have not enabled and compare your file with the installed
|
|
186
|
+
release's current template.
|
|
187
|
+
|
|
188
|
+
### If setup or an upgrade is interrupted
|
|
189
|
+
|
|
190
|
+
Do not delete `.rehearsal/` or your existing config. Start with:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npx rehearsal doctor
|
|
194
|
+
npx rehearsal init
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Use the reported problem to choose the smallest recovery:
|
|
198
|
+
|
|
199
|
+
| Problem | Safe recovery |
|
|
200
|
+
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
201
|
+
| A generated runtime file is missing | Run `npx rehearsal setup --write`. Existing files stay unchanged; only missing files are created. |
|
|
202
|
+
| A port is already in use | Stop the conflicting local process or choose new dedicated ports, then rerun setup. |
|
|
203
|
+
| The config is malformed | Move it to a backup name, run `npx rehearsal setup --write`, then copy reviewed choices into the new file. |
|
|
204
|
+
| OAuth credentials are missing | Create the ignored file named by `supabase.authentication.environmentFile`, add only the declared keys, and run `chmod 600` on it. Ambient shell credentials are not used. |
|
|
205
|
+
| An npm upgrade fails | Keep the existing config, baseline, and lockfile. Restore dependencies with your package manager, then run `npx rehearsal init` before retrying. |
|
|
206
|
+
| Docker storage is low | Run `npx rehearsal cleanup` for an exact preview. Rehearsal never performs a global Docker prune or silently removes volumes. |
|
|
207
|
+
|
|
208
|
+
`setup --write` and package installation never replace a config. If an existing file is
|
|
209
|
+
invalid, Rehearsal fails closed and leaves it available for comparison.
|
|
210
|
+
|
|
154
211
|
## Files Rehearsal creates
|
|
155
212
|
|
|
156
213
|
- `rehearsal.config.mjs` — reviewed project configuration
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Rehearsal documentation
|
|
2
|
+
|
|
3
|
+
## Why an empty database is not enough
|
|
4
|
+
|
|
5
|
+
Most migration tests start with an empty database. Production does not.
|
|
6
|
+
|
|
7
|
+
Existing rows, relationships, authentication identities, stored files, and migration
|
|
8
|
+
history are where risky changes break. A migration can build successfully and still fail
|
|
9
|
+
against the data and application behavior you actually have.
|
|
10
|
+
|
|
11
|
+
Rehearsal catches those problems before deployment. It restores a reviewed, sanitized
|
|
12
|
+
baseline into a disposable local PostgreSQL or Supabase environment, applies only the
|
|
13
|
+
exact migrations you approve, and runs your application's own proof.
|
|
14
|
+
|
|
15
|
+
| Empty-database tests miss… | Rehearsal exercises… |
|
|
16
|
+
| ------------------------------------------------- | --------------------------------------------------------- |
|
|
17
|
+
| old rows and edge cases | a reviewed, production-shaped baseline |
|
|
18
|
+
| relationships between data, identities, and files | database, Auth, and Storage in one local sandbox |
|
|
19
|
+
| whether the product still behaves correctly | your automated proof and hands-on application walkthrough |
|
|
20
|
+
|
|
21
|
+
## Pick the path that fits today
|
|
22
|
+
|
|
23
|
+
You do not need to read everything before your first rehearsal. Start with the outcome
|
|
24
|
+
you want, then follow the links when a term or safety check is new.
|
|
25
|
+
|
|
26
|
+
| I want to… | Go here |
|
|
27
|
+
| --------------------------------------- | ----------------------------------------------------------------- |
|
|
28
|
+
| Set up my own project | [Getting started](getting-started.md) |
|
|
29
|
+
| Try Rehearsal without touching my app | [Hands-on tutorial](tutorial.md) |
|
|
30
|
+
| Understand what makes a copy safe | [Baselines](baselines.md) and [Sanitization](sanitization.md) |
|
|
31
|
+
| Look up a command or setting | [CLI commands](commands.md) and [Configuration](configuration.md) |
|
|
32
|
+
| Reduce Docker and Supabase resource use | [Container runtime lifecycle](runtime-lifecycle.md) |
|
|
33
|
+
| Add editor and compiler type checks | [TypeScript](typescript.md) |
|
|
34
|
+
| Fix something that did not work | [Troubleshooting](troubleshooting.md) |
|
|
35
|
+
|
|
36
|
+
## The short version
|
|
37
|
+
|
|
38
|
+
Rehearsal restores an approved local baseline, applies only the migration files you
|
|
39
|
+
reviewed, and runs the application checks your project owns. The normal workflow stays
|
|
40
|
+
on your computer and does not deploy anything.
|
|
41
|
+
|
|
42
|
+
1. **Prepare** a safe baseline.
|
|
43
|
+
2. **Review** the exact candidate migrations.
|
|
44
|
+
3. **Run** them in a disposable local database.
|
|
45
|
+
4. **Prove** the application behavior that matters.
|
|
46
|
+
5. **Open** the sandbox for hands-on testing.
|
|
47
|
+
|
|
48
|
+
## Safety is part of the workflow
|
|
49
|
+
|
|
50
|
+
Rehearsal does not ask you to trust one giant switch. Baseline checksums, local-only
|
|
51
|
+
networking, exact confirmation digests, project-owned proofs, and narrowly owned cleanup
|
|
52
|
+
each protect a different boundary.
|
|
53
|
+
|
|
54
|
+
Start with synthetic data when you can. If a project needs a production-shaped copy,
|
|
55
|
+
read [Production-shaped preparation](production-source.md) before providing any source
|
|
56
|
+
access.
|
|
57
|
+
|
|
58
|
+
## Still unsure where to begin?
|
|
59
|
+
|
|
60
|
+
Run the interactive guide from the project you want to test:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx rehearsal
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
It reads the project state, explains the next safe step, and keeps the full command
|
|
67
|
+
reference available when you need it.
|