@rehearsal-db/core 0.1.0-beta.12 → 0.1.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/COMPATIBILITY.md +6 -0
  3. package/README.md +5 -3
  4. package/docs/commands.md +15 -11
  5. package/docs/configuration.md +40 -5
  6. package/docs/getting-started.md +32 -3
  7. package/docs/production-source.md +175 -17
  8. package/docs/releasing.md +5 -3
  9. package/docs/roadmap.md +3 -2
  10. package/docs/sanitization.md +479 -12
  11. package/docs/security-model.md +8 -0
  12. package/docs/standalone-workflow.md +34 -13
  13. package/docs/troubleshooting.md +17 -6
  14. package/docs/tutorial.md +7 -1
  15. package/package.json +2 -2
  16. package/scripts/install/create_root_config.mjs +5 -22
  17. package/src/baseline/artifact.mjs +27 -4
  18. package/src/baseline/privacy_engine.mjs +865 -207
  19. package/src/baseline/privacy_structured_json.mjs +554 -0
  20. package/src/cli/arguments.mjs +3 -0
  21. package/src/cli/guided.mjs +8 -6
  22. package/src/cli/rehearsal.mjs +23 -3
  23. package/src/cli/renderers.mjs +29 -4
  24. package/src/cli/runtime_commands.mjs +92 -9
  25. package/src/cli/source_commands.mjs +37 -8
  26. package/src/identity/claim.mjs +23 -21
  27. package/src/project/install_scaffold.mjs +35 -1
  28. package/src/project/setup.mjs +14 -24
  29. package/src/runtime/plan.mjs +7 -3
  30. package/src/runtime/restore.mjs +13 -5
  31. package/src/shared/diagnostics.mjs +7 -0
  32. package/src/shared/node_runtime.mjs +31 -0
  33. package/src/source/access.mjs +271 -51
  34. package/src/source/asset_transfer.mjs +156 -74
  35. package/src/source/baseline.mjs +42 -6
  36. package/src/source/external_reader.mjs +368 -0
  37. package/src/source/postgresql_access.mjs +213 -55
  38. package/src/source/privacy_paths.mjs +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rehearsal-db/core",
3
- "version": "0.1.0-beta.12",
3
+ "version": "0.1.0-beta.14",
4
4
  "private": false,
5
5
  "description": "Safely rehearse PostgreSQL and Supabase migrations against sanitized, production-shaped data.",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "type": "module",
20
20
  "engines": {
21
- "node": ">=24 <25"
21
+ "node": "^22.0.0 || ^24.0.0 || ^26.0.0"
22
22
  },
23
23
  "bin": {
24
24
  "rehearsal": "src/cli/rehearsal.mjs"
@@ -2,33 +2,16 @@
2
2
  /** Create safe project-root Rehearsal scaffolding during a local install. */
3
3
 
4
4
  import { fileURLToPath } from "node:url";
5
- import { createInstalledRehearsalScaffold } from "../../src/project/install_scaffold.mjs";
5
+ import {
6
+ createInstalledRehearsalScaffold,
7
+ renderInstalledRehearsalScaffold,
8
+ } from "../../src/project/install_scaffold.mjs";
6
9
 
7
10
  const packageRoot = fileURLToPath(new URL("../..", import.meta.url));
8
11
 
9
12
  try {
10
13
  const result = await createInstalledRehearsalScaffold({ packageRoot });
11
- if (result.status === "ready") {
12
- const changed = result.files.filter((file) => file.action !== "unchanged");
13
- console.log(
14
- [
15
- "Rehearsal is ready in this project.",
16
- ...(changed.length
17
- ? [
18
- ...changed.map(
19
- (file) =>
20
- ` ${file.action === "create" ? "+" : "~"} ${file.path}`,
21
- ),
22
- ]
23
- : [" Existing Rehearsal configuration preserved."]),
24
- "Next: review rehearsal.config.mjs, then run npx rehearsal.",
25
- ].join("\n"),
26
- );
27
- } else {
28
- console.log(
29
- `Rehearsal did not create project files: ${result.reason}.\nNext: run npx rehearsal from the application directory.`,
30
- );
31
- }
14
+ console.log(renderInstalledRehearsalScaffold(result));
32
15
  } catch (error) {
33
16
  console.warn(
34
17
  `Rehearsal could not safely create project files during installation: ${String(error?.message ?? error)}\nNext: run npx rehearsal from the application directory.`,
@@ -372,12 +372,35 @@ export const createAndActivateBaseline = async ({
372
372
  }
373
373
  return manifest;
374
374
  } catch (error) {
375
+ let cleanupFailure;
375
376
  if (dataHandle) await dataHandle.close().catch(() => undefined);
376
- await chmod(buildDirectory, 0o700).catch(() => undefined);
377
- await rm(buildDirectory, { recursive: true, force: true });
377
+ await makeArtifactTreeWritable(buildDirectory).catch(() => undefined);
378
+ await rm(buildDirectory, { recursive: true, force: true }).catch(
379
+ (cleanupError) => {
380
+ cleanupFailure = cleanupError;
381
+ },
382
+ );
378
383
  if (finalCreated) {
379
- await chmod(finalDirectory, 0o700).catch(() => undefined);
380
- await rm(finalDirectory, { recursive: true, force: true });
384
+ await makeArtifactTreeWritable(finalDirectory).catch(() => undefined);
385
+ await rm(finalDirectory, { recursive: true, force: true }).catch(
386
+ (cleanupError) => {
387
+ cleanupFailure ??= cleanupError;
388
+ },
389
+ );
390
+ }
391
+ if (
392
+ cleanupFailure &&
393
+ error &&
394
+ (typeof error === "object" || typeof error === "function")
395
+ ) {
396
+ try {
397
+ Object.defineProperty(error, "cleanupError", {
398
+ value: cleanupFailure,
399
+ enumerable: false,
400
+ });
401
+ } catch {
402
+ // Preserve the preparation failure even when its Error is immutable.
403
+ }
381
404
  }
382
405
  throw error;
383
406
  }