@rehearsal-db/core 0.1.0-beta.1 → 0.1.0-beta.11

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 (72) hide show
  1. package/CHANGELOG.md +271 -1
  2. package/COMPATIBILITY.md +26 -0
  3. package/README.md +150 -346
  4. package/SECURITY.md +2 -1
  5. package/SUPPORT.md +5 -0
  6. package/docs/README.md +38 -0
  7. package/docs/adapters.md +20 -6
  8. package/docs/architecture.md +58 -0
  9. package/docs/baselines.md +102 -22
  10. package/docs/commands.md +202 -33
  11. package/docs/configuration.md +288 -13
  12. package/docs/getting-started.md +114 -181
  13. package/docs/glossary.md +11 -8
  14. package/docs/index.md +47 -0
  15. package/docs/production-source.md +176 -33
  16. package/docs/releasing.md +28 -38
  17. package/docs/roadmap.md +41 -0
  18. package/docs/runtime-policies.md +253 -0
  19. package/docs/sanitization.md +144 -8
  20. package/docs/security-model.md +34 -9
  21. package/docs/standalone-workflow.md +109 -0
  22. package/docs/troubleshooting.md +127 -2
  23. package/docs/tutorial.md +70 -59
  24. package/package.json +39 -23
  25. package/scripts/install/create_root_config.mjs +36 -0
  26. package/scripts/runtime/manage_database.mjs +18 -0
  27. package/src/README.md +17 -0
  28. package/src/application/session.mjs +435 -0
  29. package/{scripts/lib/rehearsal/baseline_artifact.mjs → src/baseline/artifact.mjs} +142 -17
  30. package/{scripts/lib/rehearsal/baseline_builder.mjs → src/baseline/builder.mjs} +19 -10
  31. package/src/baseline/input_discovery.mjs +155 -0
  32. package/src/baseline/policy_review.mjs +92 -0
  33. package/src/baseline/preparation.mjs +323 -0
  34. package/src/baseline/privacy_engine.mjs +741 -0
  35. package/{scripts/lib/rehearsal → src/baseline}/sanitization_policy.mjs +133 -3
  36. package/{scripts/lib/rehearsal → src/baseline}/schema_snapshot.mjs +1 -1
  37. package/src/cli/arguments.mjs +123 -0
  38. package/src/cli/guided.mjs +812 -0
  39. package/src/cli/init_command.mjs +77 -0
  40. package/src/cli/rehearsal.mjs +952 -0
  41. package/src/cli/renderers.mjs +589 -0
  42. package/src/cli/runtime_commands.mjs +624 -0
  43. package/src/cli/source_commands.mjs +326 -0
  44. package/src/cli/terminal.mjs +275 -0
  45. package/src/identity/claim.mjs +1163 -0
  46. package/src/identity/storage.mjs +165 -0
  47. package/{scripts/lib/rehearsal → src/project}/configuration.d.mts +72 -4
  48. package/src/project/configuration.mjs +1201 -0
  49. package/src/project/install_scaffold.mjs +291 -0
  50. package/src/project/setup.mjs +484 -0
  51. package/src/project/support_report.mjs +105 -0
  52. package/src/runtime/cleanup.mjs +381 -0
  53. package/{scripts/lib/rehearsal → src/runtime}/plan.mjs +118 -20
  54. package/src/runtime/policy.mjs +438 -0
  55. package/{scripts/lib/rehearsal/runtime_restore.mjs → src/runtime/restore.mjs} +46 -27
  56. package/src/runtime/topology.mjs +177 -0
  57. package/{scripts/lib/rehearsal → src/shared}/diagnostics.mjs +10 -3
  58. package/src/shared/human_output.mjs +4 -0
  59. package/src/shared/operation_guard.mjs +162 -0
  60. package/{scripts/lib/rehearsal → src/shared}/process_environment.mjs +5 -1
  61. package/src/source/access.mjs +578 -0
  62. package/src/source/asset_transfer.mjs +177 -0
  63. package/src/source/baseline.mjs +446 -0
  64. package/src/source/postgresql_access.mjs +480 -0
  65. package/src/targets/postgresql.mjs +808 -0
  66. package/{scripts/operations/database/manage_rehearsal_database.mjs → src/targets/supabase.mjs} +66 -20
  67. package/{scripts/lib/environment/local_supabase.mjs → src/targets/supabase_environment.mjs} +60 -28
  68. package/src/targets/target.mjs +66 -0
  69. package/scripts/lib/rehearsal/configuration.mjs +0 -559
  70. package/scripts/operations/rehearsal/rehearsal_cli.mjs +0 -565
  71. /package/{scripts/lib/rehearsal → src/runtime}/migration_history.mjs +0 -0
  72. /package/{scripts/lib/rehearsal → src/runtime}/service_environment.mjs +0 -0
@@ -0,0 +1,77 @@
1
+ /** Preview or create the project-root Rehearsal configuration. */
2
+
3
+ import { writeFile } from "node:fs/promises";
4
+ import { join, relative } from "node:path";
5
+ import {
6
+ findRehearsalConfigPath,
7
+ inspectDetectedProject,
8
+ loadRehearsalConfig,
9
+ renderDetectedConfig,
10
+ renderDetectedPostgresqlConfig,
11
+ } from "../project/configuration.mjs";
12
+
13
+ const findExistingConfig = async ({ projectRoot, configPath }) => {
14
+ try {
15
+ return await findRehearsalConfigPath({ projectRoot, configPath });
16
+ } catch (error) {
17
+ if (
18
+ String(error?.message ?? error).startsWith("No Rehearsal configuration")
19
+ ) {
20
+ return null;
21
+ }
22
+ throw error;
23
+ }
24
+ };
25
+
26
+ export const runRehearsalInit = async ({ projectRoot, flags }) => {
27
+ const detected = await inspectDetectedProject({ projectRoot });
28
+ const destination = join(projectRoot, "rehearsal.config.mjs");
29
+ const existingPath = await findExistingConfig({
30
+ projectRoot,
31
+ configPath: flags.configPath,
32
+ });
33
+ if (existingPath) {
34
+ if (flags.write) {
35
+ throw new Error(
36
+ `A Rehearsal configuration already exists at ${relative(projectRoot, existingPath)}; Rehearsal will not overwrite it.`,
37
+ );
38
+ }
39
+ const loaded = await loadRehearsalConfig({
40
+ projectRoot,
41
+ configPath: flags.configPath,
42
+ });
43
+ const source = loaded.config.supabase
44
+ ? renderDetectedConfig(detected, {
45
+ applicationUrl: loaded.config.runtime.applicationUrl,
46
+ ports: loaded.config.runtime.ports,
47
+ })
48
+ : renderDetectedPostgresqlConfig(detected, {
49
+ applicationUrl: loaded.config.runtime.applicationUrl,
50
+ databasePort: loaded.config.runtime.ports.database,
51
+ });
52
+ return {
53
+ mode: "current-template",
54
+ destination: relative(projectRoot, existingPath),
55
+ detected,
56
+ source,
57
+ nextAction:
58
+ "Your existing configuration was not changed. Compare it with this installed-release template to discover new optional keys.",
59
+ };
60
+ }
61
+
62
+ const source = detected.hasSupabaseConfig
63
+ ? renderDetectedConfig(detected)
64
+ : renderDetectedPostgresqlConfig(detected);
65
+ if (flags.write) {
66
+ await writeFile(destination, source, { flag: "wx", mode: 0o600 });
67
+ }
68
+ return {
69
+ mode: flags.write ? "written" : "preview",
70
+ destination: relative(projectRoot, destination),
71
+ detected,
72
+ source,
73
+ nextAction: flags.write
74
+ ? "Review the generated safety settings and run rehearsal doctor."
75
+ : "Review this preview, then rerun rehearsal init --write to create it.",
76
+ };
77
+ };