@bevel-software/platform-core-backend 0.8.0 → 0.9.1
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/dist/core/core-ports.d.ts +7 -0
- package/dist/core/core-ports.d.ts.map +1 -1
- package/dist/core/core-ports.js.map +1 -1
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +24 -11
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +7 -2
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +39 -18
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts +3 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +4 -2
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/render-roles-yaml.d.ts +22 -0
- package/dist/modules/access/render-roles-yaml.d.ts.map +1 -0
- package/dist/modules/access/render-roles-yaml.js +56 -0
- package/dist/modules/access/render-roles-yaml.js.map +1 -0
- package/dist/modules/access/roles-admin.service.d.ts +15 -1
- package/dist/modules/access/roles-admin.service.d.ts.map +1 -1
- package/dist/modules/access/roles-admin.service.js +30 -15
- package/dist/modules/access/roles-admin.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts +10 -1
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +111 -6
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/workspace/startup/kb-git.d.ts +23 -0
- package/dist/modules/workspace/startup/kb-git.d.ts.map +1 -0
- package/dist/modules/workspace/startup/kb-git.js +86 -0
- package/dist/modules/workspace/startup/kb-git.js.map +1 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +74 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -0
- package/dist/modules/workspace/startup/kb-startup-runner.js +528 -0
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -0
- package/dist/modules/workspace/startup/on-server-start.d.ts +105 -0
- package/dist/modules/workspace/startup/on-server-start.d.ts.map +1 -0
- package/dist/modules/workspace/startup/on-server-start.js +21 -0
- package/dist/modules/workspace/startup/on-server-start.js.map +1 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts +46 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +492 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.d.ts +23 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.js +69 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.js.map +1 -0
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts +17 -0
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/seed-tree.js +109 -0
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -0
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts +103 -0
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/template-files.step.js +337 -0
- package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -0
- package/dist/modules/workspace/workspace.service.d.ts +0 -35
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +2 -101
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/kb-template/AGENTS.md +11 -5
- package/kb-template/access.md +40 -30
- package/kb-template/gitignore.template +16 -0
- package/package.json +3 -3
- package/src/core/core-ports.ts +7 -0
- package/src/core/create-core-server.ts +30 -11
- package/src/core/create-core-services.ts +43 -22
- package/src/modules/access/__tests__/roles-admin.service.test.ts +24 -2
- package/src/modules/access/access.routes.ts +3 -0
- package/src/modules/access/render-roles-yaml.ts +65 -0
- package/src/modules/access/roles-admin.service.ts +32 -14
- package/src/modules/settings/__tests__/setup.routes.test.ts +124 -3
- package/src/modules/settings/setup.routes.ts +112 -5
- package/src/modules/workspace/__tests__/workspace.service.test.ts +5 -94
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +495 -0
- package/src/modules/workspace/startup/kb-git.ts +94 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +597 -0
- package/src/modules/workspace/startup/on-server-start.ts +97 -0
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +636 -0
- package/src/modules/workspace/{plugins-migration.ts → startup/steps/groups-to-plugins.step.ts} +342 -260
- package/src/modules/workspace/startup/steps/roles-yaml.step.ts +71 -0
- package/src/modules/workspace/startup/steps/seed-tree.ts +115 -0
- package/src/modules/workspace/startup/steps/template-files.step.ts +360 -0
- package/src/modules/workspace/workspace.service.ts +2 -106
- package/src/modules/workspace/__tests__/kb-seed.service.test.ts +0 -512
- package/src/modules/workspace/__tests__/plugins-migration.test.ts +0 -427
- package/src/modules/workspace/kb-seed.interface.ts +0 -36
- package/src/modules/workspace/kb-seed.service.ts +0 -584
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The KB startup contract: every migration and scaffolding concern runs here,
|
|
3
|
+
* at the deployment's quiet moments, and nowhere else.
|
|
4
|
+
*
|
|
5
|
+
* There are exactly two occasions, both provably quiet (no user holds a lock,
|
|
6
|
+
* no edit is mid-flight): SERVER BOOT, before routes mount; and FIRST-TIME
|
|
7
|
+
* SETUP COMPLETION, when the branch model is configured through the setup
|
|
8
|
+
* screen — the app is gated shut until exactly that moment. Any later re-run
|
|
9
|
+
* would race live sessions on the very working clones it maintains, which is
|
|
10
|
+
* why there is no retry tick, no lazy per-branch trigger, and no maintenance
|
|
11
|
+
* on runtime branch opens, ever. A failed boot is retried by the container's
|
|
12
|
+
* restart policy — each attempt at boot time, on quiet trees.
|
|
13
|
+
*
|
|
14
|
+
* Failure model, fully fail-closed: the server either completes the phase or
|
|
15
|
+
* does not serve. An UNHANDLED throw from a step stops the boot — the same
|
|
16
|
+
* contract a DB migration has. A failure the author knows is survivable must
|
|
17
|
+
* be DECLARED via the result. `KB_SAFE_BOOT=1` is the break-glass demotion
|
|
18
|
+
* (see the runner).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export interface OnServerStart {
|
|
22
|
+
/** Shown in logs and error messages: "groups-to-plugins", "template-files", … */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
run(ctx: ServerStartContext): Promise<StepResult>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* What the runner should do next. Every declared outcome asserts "the tree is
|
|
29
|
+
* in a state later steps can safely run against".
|
|
30
|
+
*/
|
|
31
|
+
export type StepResult =
|
|
32
|
+
/** Fully done; declared ops apply. "Nothing to do" is `ok` with no ops. */
|
|
33
|
+
| { outcome: 'ok' }
|
|
34
|
+
/**
|
|
35
|
+
* Incomplete but VALID: declared ops still apply; the remainder is named
|
|
36
|
+
* and logged. The migration's refused conversions are exactly this.
|
|
37
|
+
*/
|
|
38
|
+
| { outcome: 'partial'; reason: string }
|
|
39
|
+
/**
|
|
40
|
+
* Did not complete: declared ops are discarded UNAPPLIED — the tree is
|
|
41
|
+
* untouched by construction, not by revert — and later steps continue.
|
|
42
|
+
*/
|
|
43
|
+
| { outcome: 'skipped'; reason: string }
|
|
44
|
+
/** Serving would be worse than being down. The deliberate kill switch. */
|
|
45
|
+
| { outcome: 'stopBoot'; message: string };
|
|
46
|
+
|
|
47
|
+
export interface ServerStartContext {
|
|
48
|
+
/** The resolved template directory this build ships. */
|
|
49
|
+
readonly templateDir: string;
|
|
50
|
+
/** Handles are lazy — the clone happens on first `repoDir()`. */
|
|
51
|
+
defaultBranch(): Promise<KbBranch>;
|
|
52
|
+
protectedBranches(): Promise<KbBranch[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Every branch on the remote, drafts included — and WRITABLE like any
|
|
55
|
+
* other: with maintenance applied uniformly at the quiet moment, migrating
|
|
56
|
+
* a draft alongside its target is what keeps its change-request diff down
|
|
57
|
+
* to the user's own changes. (The lazy era's read-only rule guarded
|
|
58
|
+
* against ASYMMETRIC application; uniform application inverts it — a
|
|
59
|
+
* stale draft against a migrated target diffs by the whole rename.)
|
|
60
|
+
*/
|
|
61
|
+
allBranches(): Promise<KbBranch[]>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* One branch's working copy, with buffered writes. Steps never touch the
|
|
66
|
+
* disk: they READ via `repoDir()` and DECLARE operations, which the runner —
|
|
67
|
+
* the only writer — applies when the step returns `ok`/`partial` (so the next
|
|
68
|
+
* step sees the real, updated tree) and discards on `skipped`. The applier
|
|
69
|
+
* enforces the write layer's containment contract once — repo-relative
|
|
70
|
+
* paths, no escapes, no symlinks — instead of every step getting raw fs
|
|
71
|
+
* right.
|
|
72
|
+
*/
|
|
73
|
+
export interface KbBranch {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly isProtected: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Absolute path of the checked-out clone; clone-if-absent happens here.
|
|
78
|
+
* This is the READ seam: writing through the returned path is a contract
|
|
79
|
+
* violation by the step — steps are first-party trusted code, and the
|
|
80
|
+
* buffered-ops contract is a convention the runner enforces structurally,
|
|
81
|
+
* not a sandbox it defends.
|
|
82
|
+
*/
|
|
83
|
+
repoDir(): Promise<string>;
|
|
84
|
+
/** Declare a file's full content at a repo-relative path. */
|
|
85
|
+
write(path: string, content: string | Uint8Array): void;
|
|
86
|
+
/** Declare a relocation — file or whole directory (the Groups→Plugins rename is one op). */
|
|
87
|
+
move(from: string, to: string): void;
|
|
88
|
+
/** Declare a file's removal. */
|
|
89
|
+
remove(path: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* One honest line per logical change — the branch's commit message is built
|
|
92
|
+
* from these. Notes ride WITH the step's ops: kept when the step's outcome
|
|
93
|
+
* applies them (`ok`/`partial`), discarded together with them on `skipped` —
|
|
94
|
+
* a skipped step must not caption a commit made of other steps' changes.
|
|
95
|
+
*/
|
|
96
|
+
note(line: string): void;
|
|
97
|
+
}
|