@fabrika/cli 0.9.0-dev.1 → 0.9.0-dev.3
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/package.json +15 -14
- package/types/src/app-dev-outside.d.ts +27 -0
- package/types/src/app-dev-seed.d.ts +37 -0
- package/types/src/app-dev-ui.d.ts +146 -0
- package/types/src/app-dev.d.ts +45 -0
- package/types/src/connect.d.ts +17 -0
- package/types/src/control.d.ts +40 -0
- package/types/src/db.d.ts +12 -0
- package/types/src/index.d.ts +13 -0
- package/types/src/job.d.ts +15 -0
- package/types/src/junit.d.ts +10 -0
- package/types/src/namespace.d.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/cli",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"src",
|
|
18
|
-
"!src/**/__tests__/**"
|
|
18
|
+
"!src/**/__tests__/**",
|
|
19
|
+
"types"
|
|
19
20
|
],
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
22
23
|
"bun": "./src/index.ts",
|
|
23
|
-
"types": "./src/index.ts",
|
|
24
|
+
"types": "./types/src/index.d.ts",
|
|
24
25
|
"default": "./src/index.ts"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
@@ -30,19 +31,19 @@
|
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"zod": "^3.25.76",
|
|
33
|
-
"@fabrika/app": "0.9.0-dev.
|
|
34
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
35
|
-
"@fabrika/control-contract": "0.9.0-dev.
|
|
36
|
-
"@fabrika/provider-contract": "0.9.0-dev.
|
|
37
|
-
"@fabrika/db": "0.9.0-dev.
|
|
38
|
-
"@fabrika/platform": "0.9.0-dev.
|
|
39
|
-
"@fabrika/platform-node": "0.9.0-dev.
|
|
40
|
-
"@fabrika/check": "0.9.0-dev.
|
|
34
|
+
"@fabrika/app": "0.9.0-dev.3",
|
|
35
|
+
"@fabrika/auth-core": "0.9.0-dev.3",
|
|
36
|
+
"@fabrika/control-contract": "0.9.0-dev.3",
|
|
37
|
+
"@fabrika/provider-contract": "0.9.0-dev.3",
|
|
38
|
+
"@fabrika/db": "0.9.0-dev.3",
|
|
39
|
+
"@fabrika/platform": "0.9.0-dev.3",
|
|
40
|
+
"@fabrika/platform-node": "0.9.0-dev.3",
|
|
41
|
+
"@fabrika/check": "0.9.0-dev.3"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
|
-
"@fabrika/builder": "0.9.0-dev.
|
|
44
|
-
"@fabrika/provider-cloudflare": "0.9.0-dev.
|
|
45
|
-
"@fabrika/provider-zerops": "0.9.0-dev.
|
|
44
|
+
"@fabrika/builder": "0.9.0-dev.3",
|
|
45
|
+
"@fabrika/provider-cloudflare": "0.9.0-dev.3",
|
|
46
|
+
"@fabrika/provider-zerops": "0.9.0-dev.3"
|
|
46
47
|
},
|
|
47
48
|
"peerDependenciesMeta": {
|
|
48
49
|
"@fabrika/builder": {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type DevOutboxMessage } from '@fabrika/app/testing';
|
|
2
|
+
/** The application's variables for `app dev`, beside the seed. */
|
|
3
|
+
export declare const DEV_ENV_FILE = "dev/dev.env";
|
|
4
|
+
/** A refusal of `dev/dev.env`; it names the line, never a value. */
|
|
5
|
+
export declare class DevEnvProblem extends Error {
|
|
6
|
+
readonly name = "DevEnvProblem";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The variables of `<root>/dev/dev.env`, or none without the file: `NAME=value` lines, `#` comments and blank lines; a
|
|
10
|
+
* value in matching single or double quotes loses them. A framework name (`FABRIKA_*`) is the platform's, not the
|
|
11
|
+
* application's, so it is refused.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readDevEnv(root: string): Readonly<Record<string, string>>;
|
|
14
|
+
export interface DevOutbox {
|
|
15
|
+
/** Every request sent to `DEV_OUTBOX_ORIGIN` so far, oldest first. */
|
|
16
|
+
outbox(): readonly DevOutboxMessage[];
|
|
17
|
+
/** Captures the process's requests to `DEV_OUTBOX_ORIGIN` until the returned function restores `fetch`. */
|
|
18
|
+
install(): () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function devOutbox(): DevOutbox;
|
|
21
|
+
/** A message's body as the dev view shows it: JSON indented, anything else as it came. */
|
|
22
|
+
export declare function shownBody(message: DevOutboxMessage): string;
|
|
23
|
+
/** The recipient and subject a mail provider's JSON body names (`to`, `subject`), else the request's path. */
|
|
24
|
+
export declare function mailHeadOf(message: DevOutboxMessage): {
|
|
25
|
+
readonly to: string;
|
|
26
|
+
readonly subject: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AnyContract } from '@fabrika/app/contract';
|
|
2
|
+
import type { DevKit, PersonTestCaller } from '@fabrika/app/testing';
|
|
3
|
+
/** The seed `app dev` runs when `--seed` names none and the file exists. */
|
|
4
|
+
export declare const DEFAULT_SEED = "dev/seed.ts";
|
|
5
|
+
export interface SeedPersona {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly description: string | null;
|
|
8
|
+
readonly caller: PersonTestCaller;
|
|
9
|
+
}
|
|
10
|
+
export interface SeedLink {
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly description: string | null;
|
|
13
|
+
readonly url: string;
|
|
14
|
+
}
|
|
15
|
+
/** What the seed answered, validated: unique persona names, the kit's own people, local link paths, known dimensions. */
|
|
16
|
+
export interface Seeded {
|
|
17
|
+
readonly personas: readonly SeedPersona[];
|
|
18
|
+
readonly links: readonly SeedLink[];
|
|
19
|
+
/** The labelled values of each dimension, by dimension. */
|
|
20
|
+
readonly scopes: ReadonlyMap<string, readonly {
|
|
21
|
+
readonly value: string;
|
|
22
|
+
readonly label: string;
|
|
23
|
+
}[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare const NOTHING_SEEDED: Seeded;
|
|
26
|
+
/** A refusal of what the seed answered; it names an entry by its position, never by what the seed wrote. */
|
|
27
|
+
export declare class SeedProblem extends Error {
|
|
28
|
+
readonly name = "SeedProblem";
|
|
29
|
+
}
|
|
30
|
+
/** A path of this origin; a link the application issued is one (`/s/#px_…`). */
|
|
31
|
+
export declare function isLocalPath(path: string): boolean;
|
|
32
|
+
/** The seed module's path: `--seed`, relative to the root, or `dev/seed.ts` when it exists; `null` for none. */
|
|
33
|
+
export declare function seedPath(root: string, given: string | null): string | null;
|
|
34
|
+
/** The seed's default export, a function of the kit and the dev outbox. */
|
|
35
|
+
export declare function importSeed(path: string): Promise<(dev: unknown, outside: unknown) => unknown>;
|
|
36
|
+
/** What `answer`, the seed's result, offers the picker, or a `SeedProblem` naming the entry that is wrong. */
|
|
37
|
+
export declare function parseSeeded<C extends AnyContract>(dev: DevKit<C>, answer: unknown): Seeded;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { DevMail, SentInvitation } from '@fabrika/app/testing';
|
|
2
|
+
import type { Locale } from '@fabrika/auth-core';
|
|
3
|
+
/** A label beside a caller: a role it holds (with the scope value it holds it in), or that it is external. */
|
|
4
|
+
export interface Badge {
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly tone: 'role' | 'external';
|
|
7
|
+
}
|
|
8
|
+
/** Who the browser is now, as the picker's header and the toolbar's pill name it. */
|
|
9
|
+
export interface CurrentView {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly badges: readonly Badge[];
|
|
12
|
+
}
|
|
13
|
+
export interface PersonaView {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description: string | null;
|
|
16
|
+
readonly email: string;
|
|
17
|
+
readonly badges: readonly Badge[];
|
|
18
|
+
readonly href: string;
|
|
19
|
+
readonly current: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** A role of the vocabulary: chosen with one link when it is app-wide, or with a scope value of its dimension. */
|
|
22
|
+
export interface RoleView {
|
|
23
|
+
readonly role: string;
|
|
24
|
+
readonly grants: readonly string[];
|
|
25
|
+
readonly external: boolean;
|
|
26
|
+
readonly choose: {
|
|
27
|
+
readonly kind: 'app';
|
|
28
|
+
readonly href: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'member';
|
|
31
|
+
readonly action: string;
|
|
32
|
+
readonly next: string;
|
|
33
|
+
readonly dimension: string;
|
|
34
|
+
readonly values: readonly {
|
|
35
|
+
readonly value: string;
|
|
36
|
+
readonly label: string;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface LinkView {
|
|
41
|
+
readonly title: string;
|
|
42
|
+
readonly description: string | null;
|
|
43
|
+
readonly href: string;
|
|
44
|
+
}
|
|
45
|
+
/** An invitation's state, or how a job's message ended: `sent` when the transport accepted it. */
|
|
46
|
+
export type MailStatus = SentInvitation['status'] | 'sent' | 'not_sent' | 'unknown';
|
|
47
|
+
export interface MailView {
|
|
48
|
+
readonly to: string;
|
|
49
|
+
readonly subject: string;
|
|
50
|
+
/** When it was sent, in ms: an invitation's latest send, or a job's handoff. */
|
|
51
|
+
readonly at: number;
|
|
52
|
+
/** The key the job passed; `null` for an invitation. */
|
|
53
|
+
readonly key: string | null;
|
|
54
|
+
readonly status: MailStatus;
|
|
55
|
+
/** The transport's refusal code (`provider_rejected`) when it did not accept; otherwise `null`. */
|
|
56
|
+
readonly answer: string | null;
|
|
57
|
+
readonly action: {
|
|
58
|
+
readonly label: string;
|
|
59
|
+
readonly href: string;
|
|
60
|
+
} | null;
|
|
61
|
+
}
|
|
62
|
+
/** A request the application sent to the dev outbox. */
|
|
63
|
+
export interface OutboxView {
|
|
64
|
+
readonly to: string;
|
|
65
|
+
readonly subject: string;
|
|
66
|
+
readonly href: string;
|
|
67
|
+
}
|
|
68
|
+
export declare const MAX_MAIL_ROWS = 200;
|
|
69
|
+
/** Newest first, at most `MAX_MAIL_ROWS`. On equal times, the row given later comes first. */
|
|
70
|
+
export declare function newestMail(rows: readonly MailView[]): MailView[];
|
|
71
|
+
export interface DevView {
|
|
72
|
+
readonly locale: Locale;
|
|
73
|
+
/** The application's display name, or its id. */
|
|
74
|
+
readonly title: string;
|
|
75
|
+
readonly current: CurrentView | null;
|
|
76
|
+
readonly personas: readonly PersonaView[];
|
|
77
|
+
readonly roles: readonly RoleView[];
|
|
78
|
+
readonly anonymousHref: string;
|
|
79
|
+
readonly links: readonly LinkView[];
|
|
80
|
+
readonly mail: readonly MailView[];
|
|
81
|
+
readonly outbox: readonly OutboxView[];
|
|
82
|
+
readonly pickerHref: string;
|
|
83
|
+
}
|
|
84
|
+
interface Strings {
|
|
85
|
+
readonly preview: string;
|
|
86
|
+
readonly choose: string;
|
|
87
|
+
readonly lede: string;
|
|
88
|
+
readonly now: string;
|
|
89
|
+
readonly nobody: string;
|
|
90
|
+
readonly personas: string;
|
|
91
|
+
readonly noPersonas: string;
|
|
92
|
+
readonly another: string;
|
|
93
|
+
readonly appWide: string;
|
|
94
|
+
readonly inScope: (dimension: string) => string;
|
|
95
|
+
readonly external: string;
|
|
96
|
+
readonly use: string;
|
|
97
|
+
readonly scopePlaceholder: (dimension: string) => string;
|
|
98
|
+
readonly anonymous: string;
|
|
99
|
+
readonly anonymousText: string;
|
|
100
|
+
readonly anonymousButton: string;
|
|
101
|
+
readonly links: string;
|
|
102
|
+
readonly linksText: string;
|
|
103
|
+
readonly openLink: string;
|
|
104
|
+
readonly mail: string;
|
|
105
|
+
readonly mailText: string;
|
|
106
|
+
readonly noMail: string;
|
|
107
|
+
readonly invitation: (role: string, scope: string) => string;
|
|
108
|
+
readonly accept: string;
|
|
109
|
+
readonly continueAs: string;
|
|
110
|
+
readonly openMessage: string;
|
|
111
|
+
readonly status: Readonly<Record<MailStatus, string>>;
|
|
112
|
+
readonly to: string;
|
|
113
|
+
readonly subject: string;
|
|
114
|
+
readonly key: string;
|
|
115
|
+
readonly transportKey: string;
|
|
116
|
+
readonly sentAt: string;
|
|
117
|
+
readonly answer: string;
|
|
118
|
+
readonly fromName: string;
|
|
119
|
+
readonly replyTo: string;
|
|
120
|
+
readonly text: string;
|
|
121
|
+
readonly html: string;
|
|
122
|
+
readonly noHtml: string;
|
|
123
|
+
readonly outbox: string;
|
|
124
|
+
readonly outboxText: string;
|
|
125
|
+
readonly noOutbox: string;
|
|
126
|
+
readonly picker: string;
|
|
127
|
+
readonly close: string;
|
|
128
|
+
readonly back: string;
|
|
129
|
+
}
|
|
130
|
+
export declare const stringsOf: (locale: Locale) => Strings;
|
|
131
|
+
/** The picker: the personas, another role, anonymous, the link pages, the mail IAM and the jobs sent, and the dev outbox. */
|
|
132
|
+
export declare function pickerPage(view: DevView): string;
|
|
133
|
+
/** A refusal of a dev route, with the way back to the picker. */
|
|
134
|
+
export declare function noticePage(view: Pick<DevView, 'locale' | 'title' | 'current' | 'pickerHref'>, heading: string, message: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* One message a job handed to the mail stand-in: its fields, its text, and its HTML in a frame that runs no script, has no
|
|
137
|
+
* origin and submits nothing. The frame's document inherits the page's policy (`default-src 'none'`), so it loads nothing.
|
|
138
|
+
*/
|
|
139
|
+
export declare function mailPage(view: Pick<DevView, 'locale' | 'title' | 'current' | 'pickerHref'>, mail: DevMail): string;
|
|
140
|
+
/** What the toolbar renders: its labels and the view, with every caller already put into words. */
|
|
141
|
+
export declare function toolbarState(view: DevView): unknown;
|
|
142
|
+
/** The toolbar: a pill in the bottom corner, in a shadow root so neither the page's styles nor its layout meet it. */
|
|
143
|
+
export declare function toolbarScript(statePath: string): string;
|
|
144
|
+
/** `html` with the toolbar's script tag before its `</body>`, or at its end when it has none. */
|
|
145
|
+
export declare function withToolbar(html: string, scriptPath: string): string;
|
|
146
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AnyContract } from '@fabrika/app/contract';
|
|
2
|
+
import { type ContractImplementation } from '@fabrika/app/implement';
|
|
3
|
+
export declare const APP_DEV_USAGE = "fabrika app dev \u2014 the application on a local port, to click through its screens\n\nUsage:\n fabrika app dev [--port=<n>] [--host=<loopback address>] [--seed=<module>]\n\nRun from the application root. It serves src/app.ts through its test kit: the production proxy decision,\nthe kit's stand-in IAM, each SPA from its built directory (run the SPA build first; an unbuilt one is an empty page),\nand a throwaway schema of the database in FABRIKA_TEST_POSTGRES_URL, migrated from db/migrations/ and dropped on exit.\nThe seed module (--seed, or dev/seed.ts when it exists) default-exports a DevSeed of @fabrika/app/testing: it\nreceives the kit, writes through the endpoints, and answers the personas, link pages and scope values to offer.\nPick who the browser is at /__fabrika/dev; every SPA page shows a toolbar that switches the caller and lists the\nmail IAM and the application's jobs sent, and the requests the application sent to https://outbox.invalid, the dev\noutbox. A form's challenge passes. The application's own variables come from dev/dev.env (NAME=value lines)\nover the environment. What the seed or a job's handler throws is printed with its stack. It listens on 127.0.0.1\n(or ::1, localhost) only, port 3000 unless --port says otherwise (0 picks a free one), and prints the address it\nserves.\n";
|
|
4
|
+
/** A refusal of `app dev` itself, whose message names nothing of the environment. */
|
|
5
|
+
export declare class AppDevError extends Error {
|
|
6
|
+
readonly name = "AppDevError";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* What of a startup failure reaches the terminal: the message of `app dev`'s own refusal (the seed's own throw, with its
|
|
10
|
+
* stack, included), of the seed's answer, of `dev/dev.env`, of the framework's boot and of the migration runner;
|
|
11
|
+
* anything else (an application module, a driver, a dependency `deps` built) may carry a credential, so it is a fixed
|
|
12
|
+
* code.
|
|
13
|
+
*/
|
|
14
|
+
export declare function startupFailure(error: unknown): Error;
|
|
15
|
+
export interface AppDevOptions {
|
|
16
|
+
/** The application root. */
|
|
17
|
+
readonly root: string;
|
|
18
|
+
readonly port: number;
|
|
19
|
+
readonly host: string;
|
|
20
|
+
/** The environment: the test database URL, and the application's own variables. */
|
|
21
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
22
|
+
/** The seed module's absolute path, or `null` to serve the empty application. */
|
|
23
|
+
readonly seed: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface AppDevServer {
|
|
26
|
+
/** The address it serves, `http://<host>:<port>/`. */
|
|
27
|
+
readonly url: string;
|
|
28
|
+
/** How many personas and link pages the seed offered. */
|
|
29
|
+
readonly seeded: {
|
|
30
|
+
readonly personas: number;
|
|
31
|
+
readonly links: number;
|
|
32
|
+
};
|
|
33
|
+
/** Stops serving and drops the throwaway schema. */
|
|
34
|
+
stop(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface AppDevArgs {
|
|
37
|
+
readonly port: number;
|
|
38
|
+
readonly host: string;
|
|
39
|
+
readonly seed: string | null;
|
|
40
|
+
}
|
|
41
|
+
export declare function parseAppDevArgs(argv: readonly string[]): AppDevArgs;
|
|
42
|
+
/** Serves `app` through its test kit on a loopback port until `stop`. */
|
|
43
|
+
export declare function startAppDev(app: ContractImplementation<AnyContract>, options: AppDevOptions): Promise<AppDevServer>;
|
|
44
|
+
/** `fabrika app dev`: serves until the process is stopped, then drops the throwaway schema. */
|
|
45
|
+
export declare const runAppDevCli: (argv: readonly string[]) => Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const CONNECT_USAGE = "fabrika connect \u2014 vendor another application's export\n\nUsage:\n fabrika connect add <app>/<export>@<version> --consumer=<this app's id> --env=<env> [--url=<control origin>]\n Write fabrika/connect/<app>.<export>.v<version>.ts.\n fabrika connect pull <app>/<export>@<version> --consumer=<this app's id> --env=<env> [--url=<control origin>]\n Rewrite that snapshot from what the owner's environment approved now.\n\nRun from the application root. Both read the export the owner's environment <env> approved for the consumer from\nControl (FABRIKA_CONTROL_URL or --url), with a machine key that holds deploy.read on the consumer, read from\nFABRIKA_CONTROL_KEY in the environment only. The origin is https; plain http only for localhost. `add` refuses an\nexisting snapshot and prints what to add to src/app-kit.ts and to the endpoints that call it; `pull` refuses a missing one\nand says whether the digest changed. The platform writes each import's address and key when it deploys the consumer.\n";
|
|
2
|
+
export interface ConnectCommandDependencies {
|
|
3
|
+
/** The application root. */
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly source: Readonly<Record<string, string | undefined>>;
|
|
6
|
+
readonly fetch: (request: Request) => Promise<Response>;
|
|
7
|
+
/** Data: the snapshot's path. */
|
|
8
|
+
readonly write: (line: string) => void;
|
|
9
|
+
/** Guidance for the person running it. */
|
|
10
|
+
readonly note: (line: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Every line and error leaves with the Control key cut out. No diagnostic quotes the answer; this is defence in depth
|
|
14
|
+
* against an owner contract that names a procedure after a key.
|
|
15
|
+
*/
|
|
16
|
+
export declare const runConnectCommand: (command: string | undefined, argv: readonly string[], deps: ConnectCommandDependencies) => Promise<void>;
|
|
17
|
+
export declare const runConnectCli: (command: string | undefined, argv: readonly string[]) => Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AppEnvDto, DeploymentNamespaceDto, PlanDeploymentNamespaceResponse } from '@fabrika/control-contract';
|
|
2
|
+
declare const USAGE = "fabrika control \u2014 operate the Delivery control plane\n\nUsage:\n fabrika control key issue --label=<name> --permissions=<a,b,c> --expires-in=<seconds> [--iam-url=<origin>]\n fabrika control apps list\n fabrika control apps get --app=<id>\n fabrika control apps environments list --app=<id>\n fabrika control apps environments put --provider=<name> --app=<id> --env=<name> --manifest=<path>\n [--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>] [--namespace=<id>]\n [--cross-origin=<origin> ...] [--kind=standard|dev]\n fabrika control apps variables list --app=<id>\n fabrika control apps variables put --app=<id> --name=<name> --value=<text> [--env=<name>]\n fabrika control apps variables delete --app=<id> --name=<name> [--env=<name>]\n fabrika control apps secrets list --app=<id>\n fabrika control apps secrets put --app=<id> --name=<name> [--env=<name>] (the value on stdin)\n fabrika control apps secrets delete --app=<id> --name=<name> [--env=<name>]\n fabrika control register --provider=<name> --app=<id> --repo=<url> --env=<name> --manifest=<path>\n [--domain=<host>] [--public-origin=<url>] [--trigger-ref=<ref>]\n [--namespace=<id>] [--installation-id=<n|none>] [--cross-origin=<origin> ...]\n fabrika control namespaces list\n fabrika control namespaces get --namespace=<id>\n fabrika control namespaces plan --namespace=<id> --env=<name> --preset=<cheap|mid|full> [placement]\n fabrika control namespaces create --namespace=<id> --env=<name> --preset=<cheap|mid|full> [placement]\n fabrika control namespaces reconcile --namespace=<id>\n fabrika control namespaces update --namespace=<id> --proxy-source=current\n fabrika control namespaces remove --namespace=<id>\n fabrika control deploy --app=<id> --env=<name> [--ref=<ref>]\n fabrika control runs list [--app=<id>] [--env=<name>] [--limit=<n>]\n fabrika control runs get --run=<id>\n fabrika control runs log --run=<id>\n\n`register` CREATES an app and refuses a second one with the same id. Re-registering a changed\nmanifest \u2014 a new `zerops.yaml`, a new import document \u2014 is `apps environments put`, which replaces\none environment's envelopes and leaves the app row alone.\n\nA manifest that publishes the app through the namespace proxy is routed by HOST, so `--domain` is\nREQUIRED for it \u2014 on `register` and on `apps environments put` alike \u2014 and a registration without one is\nrefused before anything is created. `namespaces get` lists the hosts a `zerops-subdomain` namespace\nserves and which of them are still free; a custom-domain namespace serves the domain you bound to its\nproxy. A manifest with no proxy target needs no domain.\n\nA variable's value is stored and printed in clear. A secret's value is write-only: `apps secrets put`\nreads it from STDIN, never from a flag, so it reaches neither shell history nor a process listing, and\none trailing newline is dropped. No command prints it back; `apps secrets list` shows names, scope and\nstorage only. Generate one in the pipe:\n\n openssl rand -base64 32 | fabrika control apps secrets put --app=<id> --name=<name>\n\n`--public-origin` is where IAM may return a signed-in person: without one, sign-in to the environment is\nrefused. When `register` is given none and the namespace lists `--domain` among its hosts, it sets\n`https://<domain>` and says so on stderr. A custom domain needs the flag.\n\n`--cross-origin` names an origin whose pages may call the environment's cross-origin endpoints (ADR-0022), and\nrepeats: the flags given are the environment's whole list. Each is an exact origin with a literal host\n(`https://app.example.com`; `http://` only for a local one), never the environment's own domain, at most 16.\n`apps environments put` without the flag keeps the stored list, and a lone empty `--cross-origin=` clears it.\nOn Zerops the change reaches the namespace proxy at once; on Cloudflare the next deploy of the environment\napplies it.\n\n`--installation-id` has three states: omitted resolves the installation from the organization's\nconnected GitHub App, `none` registers an anonymous PUBLIC repository source, and a number names one\ninstallation outright. With `none`, control reads the repository once without a token and refuses one\nGitHub hides: a private repository needs the GitHub App connected in the console first.\n\n`--trigger-ref` is the git ref whose push deploys the environment; without it the environment deploys only\non `deploy`. A bare name is a branch: `--trigger-ref=deploy/prod` is stored as `refs/heads/deploy/prod`.\nA full ref is kept as given: `refs/heads/<branch>`, `refs/tags/<tag>`, or a `*` glob such as\n`refs/tags/v*`, which deploys every matching tag. A tag always needs the `refs/tags/` form. Each\nenvironment of an app needs its own trigger ref.\n\nNamespace placement options, each defaulting to what the preset would choose:\n\n --project=<name> the provider project the namespace owns; on Zerops the default is\n fabrika-<env>-<namespace id>, beside the installation's fabrika-<env>\n --core-package=<LIGHT|SERIOUS> defaults to LIGHT on every environment, `prod` included (ADR-0038).\n SERIOUS is a deliberate choice: a project cannot be downgraded again\n --public-access=<custom-domain|zerops-subdomain>\n --exclusive-app=<id> required by, and only by, the `full` preset\n\n`namespaces plan` is a preview and changes nothing. It prints one `<path>\\t<value>` row per field of\nthe plan, keyed by its path in `--json`; a multi-line value such as the proxy's descriptor file is shown\nby size only. `namespaces create` commits that exact plan \u2014 the\nsame two steps the console's form takes \u2014 and returns as soon as the placement is recorded: provisioning\nruns behind the control queue and takes minutes, so the state comes back `pending`. Follow it with\n`namespaces get` or `namespaces list`; nothing needs to stay connected. `namespaces remove` frees the id\nof a placement no application is registered in. It deletes nothing at the provider and prints, on stderr,\nthe provider resources it stopped tracking. `namespaces update --proxy-source=current` re-pins a placement's\nproxy to the source this control plane deploys new placements from \u2014 a placement keeps the one it was created\nwith until you do \u2014 and queues the reconcile that rebuilds the proxy from it; a `failed` placement accepts it.\n\nEvery command accepts --json, which prints the procedure's result verbatim.\n\nThe control origin is not a credential and takes either form:\n\n --url=<origin> FABRIKA_CONTROL_URL\n\nCredentials are read from the ENVIRONMENT ONLY and have no flag, so they cannot reach a CI log or a\nprocess listing:\n\n FABRIKA_CONTROL_KEY required a machine `px_` credential for the control app\n\n`key issue` mints that credential and therefore authenticates differently \u2014 it presents the\ninstallation's IAM RPC key as transport authentication and its provisioning key as the ISSUING\ncredential. Every key expires: `--expires-in` is required and at most 2592000 (30 days). Both\ncredentials are read from the environment only:\n\n FABRIKA_IAM_RPC_URL required IAM's PUBLIC origin, or --iam-url\n FABRIKA_IAM_RPC_KEY required the installation's IAM RPC key\n FABRIKA_IAM_PROVISIONING_KEY required the installation's seeded `px_` provisioning key\n FABRIKA_CONTROL_APP_ID optional the control app's IAM id (default `vozka`)\n\nThe PUBLIC origin is the `https://` address the installation answers on \u2014 the one `platform admin`\nand `platform init` print in their closing block, and the value `FABRIKA_IAM_ISSUER` holds on the\ncontrol service. It is NOT the private hostname the services use between themselves: `http://iam:3000`\nresolves inside the provider's project and nowhere else, so from here it only ever fails to connect.\n\nConnecting a GitHub source is NOT here and will not be: App creation is a browser flow whose\nauthorization requires a human principal (ADR-0029). Use Settings \u2192 Source in the console.\n";
|
|
3
|
+
interface Flags {
|
|
4
|
+
readonly values: ReadonlyMap<string, string>;
|
|
5
|
+
/** Every value of every option, in order; `values` keeps the last. Only a repeatable option reads it. */
|
|
6
|
+
readonly repeated: ReadonlyMap<string, readonly string[]>;
|
|
7
|
+
readonly json: boolean;
|
|
8
|
+
readonly positional: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/** Split `--key=value` options from positional words; `--json` is the one flag every verb shares. */
|
|
11
|
+
export declare const parseControlFlags: (argv: readonly string[]) => Flags;
|
|
12
|
+
/** The exact text `app build` would write, and the provider whose envelope carries it. */
|
|
13
|
+
export interface CompiledManifest {
|
|
14
|
+
readonly provider: string;
|
|
15
|
+
readonly text: string;
|
|
16
|
+
}
|
|
17
|
+
/** Resolves the app's provider and compiles its manifest for one environment; both run the app's own code. */
|
|
18
|
+
export type ManifestTextCompiler = (environment: string) => Promise<CompiledManifest>;
|
|
19
|
+
/**
|
|
20
|
+
* `fabrika app register`: compile in memory, then send the SAME request `control register` sends for
|
|
21
|
+
* that manifest read from disk. Inputs, the control origin and the credential are checked before the
|
|
22
|
+
* compile; nothing is written locally in either phase.
|
|
23
|
+
*/
|
|
24
|
+
export declare const registerCompiledManifest: (argv: readonly string[], compile: ManifestTextCompiler, env?: Readonly<Record<string, string | undefined>>) => Promise<void>;
|
|
25
|
+
/** One environment per line; the cross origins are comma-joined, `-` when it lists none (a Control older than the field included). */
|
|
26
|
+
export declare const environmentLine: (item: Pick<AppEnvDto, "appId" | "env" | "provider" | "domain"> & Partial<Pick<AppEnvDto, "crossOrigins">>) => string;
|
|
27
|
+
/** Where `apps secrets put` reads a secret's value. The CLI reads the process's stdin; a test hands its own. */
|
|
28
|
+
export interface SecretValueInput {
|
|
29
|
+
readonly isTerminal: () => boolean;
|
|
30
|
+
readonly text: () => Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
/** Also `fabrika namespace`'s row, which reads only these fields of Control's answer. */
|
|
33
|
+
export declare const namespaceLine: (namespace: Pick<DeploymentNamespaceDto, "id" | "env" | "state" | "exclusiveAppId">) => string;
|
|
34
|
+
export declare const namespacePlanLines: (plan: PlanDeploymentNamespaceResponse) => string[];
|
|
35
|
+
/**
|
|
36
|
+
* `command` is the group (`key`, `apps`, `runs`, `register`, `deploy`); the verb, where a group has
|
|
37
|
+
* one, is the first positional word after it. `provider` reaches here only to label an envelope.
|
|
38
|
+
*/
|
|
39
|
+
export declare const runControlCli: (command: string | undefined, argv: readonly string[], provider?: string, env?: Readonly<Record<string, string | undefined>>, input?: SecretValueInput) => Promise<void>;
|
|
40
|
+
export { USAGE as CONTROL_USAGE };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DB_USAGE = "fabrika db \u2014 an application's Postgres schema\n\nUsage:\n fabrika db new <slug> Write db/migrations/<UTC YYYYMMDDHHMMSS>_<slug>.sql; the slug is lowercase snake_case.\n fabrika db migrate Apply the framework's tables, then db/migrations, to the application's schema app_<id>.\n fabrika db codegen [--verify] Write src/db/schema.generated.ts from the migrated schema; --verify only fails when it is stale.\n fabrika db test-scaffold Write the generated tests: a policy isolation test per table a store reaches, the endpoint access test.\n fabrika db test-isolation [--verbose] Run the generated tests on a throwaway schema; fail unless every case the scaffold wrote passed.\n\nRun from the application root. `migrate` and `codegen` read FABRIKA_APP_ID and FABRIKA_APP_DATABASE_URL from\nthe environment only. FABRIKA_APP_DATABASE_URL is the provisioning credential: `migrate` uses it only to create\nthe application's roles (app_<id> owns the schema, run_<id> gets DML on its tables) and fails when it cannot create\nroles. It applies the files as app_<id>, holds a lock derived from the application id, runs each file in one\ntransaction with lock_timeout 5000 ms and statement_timeout 60000 ms, and fails when a\nfile that already ran has changed: an applied migration is immutable, so a change is a new file.\n`test-scaffold` reads fabrika.contract.ts and src/db/tables.ts as the checker does, rewrites every generated test and\ndeletes a generated one the scaffold no longer writes, printing each path, or that it wrote none; @fabrika/check refuses\none that is missing, edited or stale.\n`test-isolation` is the platform's run of them: with FABRIKA_APP_DATABASE_URL it creates a throwaway provisioner\n(CREATEROLE, CREATE on the database, nothing of any application) that the tests get instead, ignores the application's\nbunfig.toml, and checks the JUnit report against the case names the scaffold wrote. It first drops the provisioners\nthat killed runs left behind: expired, and without a session of their own or of a role they created. A database at its\nconnection limit (SQLSTATE 53300) is waited for; one that never frees a slot fails the run saying so,\nnever as failed cases.\n";
|
|
2
|
+
export interface DbCommandDependencies {
|
|
3
|
+
/** The application root. */
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly source: Readonly<Record<string, string | undefined>>;
|
|
6
|
+
readonly now: () => Date;
|
|
7
|
+
readonly write: (line: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/** Whether the tests' output reports a connection the database refused for lack of a free slot. */
|
|
10
|
+
export declare const reportsExhaustedConnections: (output: string) => boolean;
|
|
11
|
+
export declare const runDbCommand: (command: string | undefined, argv: readonly string[], deps: DbCommandDependencies) => Promise<void>;
|
|
12
|
+
export declare const runDbCli: (command: string | undefined, argv: readonly string[]) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
export interface ParsedCommand {
|
|
3
|
+
readonly area: string | undefined;
|
|
4
|
+
readonly command: string | undefined;
|
|
5
|
+
readonly provider: string | undefined;
|
|
6
|
+
readonly rest: string[];
|
|
7
|
+
readonly help: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const parseCliArgs: (argv: readonly string[]) => ParsedCommand;
|
|
10
|
+
export declare const providerFromConfig: (argv: readonly string[]) => Promise<string | undefined>;
|
|
11
|
+
export type AppCliRunner = (argv: readonly string[]) => Promise<void>;
|
|
12
|
+
export declare const appCliRunnerFromModule: (loaded: unknown, packageName: string, exportName: string) => AppCliRunner;
|
|
13
|
+
export declare const runCli: (argv: readonly string[]) => Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ImplementationLoader } from '@fabrika/app/bun';
|
|
2
|
+
import { type JobRunResult } from '@fabrika/app/implement';
|
|
3
|
+
export declare const JOB_USAGE = "fabrika job \u2014 an application's c.cron jobs\n\nUsage:\n fabrika job run <name> Run the job <name> of fabrika.contract.ts once: the command every crontab entry runs.\n The framework's own fabrika-file-scan scans the uploads of scan: true file collections,\n and fabrika-file-sweep deletes the objects of removed and orphaned files.\n\nRun from the application root. The job boots like the server: the framework variables (FABRIKA_APP_ID,\nFABRIKA_APP_DATABASE_URL, FABRIKA_IAM_*, FABRIKA_CONTRACT_DIGEST, FABRIKA_PROXY_SECRET, FABRIKA_OPERATIONS_DSN)\ncome from the environment only and leave the process before src/app.ts loads; the run itself happens in a\nprocess started again with the runtime role's credential in place of FABRIKA_APP_DATABASE_URL. A run takes the job's lease\nor does not start. It exits 1 when the job failed, and 0 when it succeeded or a previous run still holds the lease.\nA failure is named by a fixed code (timeout, lease_lost, handler_failed, query_refused, capability_refused,\ndriver_failed, crashed, unauthorized, iam_unavailable, boot_failed), never by the application's error; a refusal adds\nits catalog reason (query_refused: undeclared_reach).\n";
|
|
4
|
+
export interface JobCommandDependencies {
|
|
5
|
+
/** The application root. */
|
|
6
|
+
readonly cwd: string;
|
|
7
|
+
readonly source: Readonly<Record<string, string | undefined>>;
|
|
8
|
+
readonly write: (line: string) => void;
|
|
9
|
+
readonly fileExists: (path: string) => Promise<boolean>;
|
|
10
|
+
readonly run: (load: ImplementationLoader, env: Readonly<Record<string, string | undefined>>, name: string) => Promise<JobRunResult>;
|
|
11
|
+
}
|
|
12
|
+
/** Runs one job and answers the process exit code. */
|
|
13
|
+
export declare const runJobCommand: (command: string | undefined, argv: readonly string[], deps: JobCommandDependencies) => Promise<number>;
|
|
14
|
+
/** The process ends with the run, so nothing a handler left running outlives it. */
|
|
15
|
+
export declare const runJobCli: (command: string | undefined, argv: readonly string[]) => Promise<never>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type CaseOutcome = 'passed' | 'failed' | 'skipped';
|
|
2
|
+
export interface ReportedCase {
|
|
3
|
+
/** The test file, relative to the directory `bun test` ran in. */
|
|
4
|
+
readonly file: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly outcome: CaseOutcome;
|
|
7
|
+
/** The `expect` calls the case ran, as Bun reports them; `null` when the report does not say. */
|
|
8
|
+
readonly assertions: number | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function readJunitCases(xml: string): ReportedCase[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ZeropsCliArgs } from '@fabrika/provider-zerops';
|
|
2
|
+
export declare const NAMESPACE_USAGE = "fabrika namespace \u2014 Zerops deployment namespaces\n\nUsage:\n fabrika namespace plan --provider=zerops --id=<id> --env=<env> --preset=<cheap|mid|full> [namespace options]\n fabrika namespace create --provider=zerops --id=<id> --env=<env> --preset=<cheap|mid|full> [namespace options] [--control-url=<url>]\n fabrika namespace adopt --provider=zerops --id=<id> --env=<env> --preset=<cheap|mid|full> --project-id=<id> [namespace options] [--control-url=<url>]\n fabrika namespace reconcile --provider=zerops --id=<id> [--control-url=<url>]\n\nOptions:\n --id=<id> Namespace id.\n --env=<env> Environment.\n --preset=<cheap|mid|full> Provider-owned namespace preset.\n --exclusive-app=<id> App reserved by a full namespace.\n --project-id=<id> Existing Zerops project id for adoption.\n --project-name=<name> Zerops project name (create: default fabrika-<env>-<id>;\n adopt: the existing project's name, default the namespace id).\n --core-package=<tier> LIGHT or SERIOUS.\n --public-access=<mode> custom-domain or zerops-subdomain.\n --postgres-type=<type> Cheap-tier PostgreSQL type.\n --postgres-profile=<profile> Cheap-tier PostgreSQL profile.\n --control-url=<url> Control origin; or FABRIKA_CONTROL_URL.\n --json Print the result as JSON instead of rows.\n -h, --help Show this help.\n\n`plan` prints one `<path>\\t<value>` row per field of the plan, keyed by its path in --json; a multi-line\nvalue such as the proxy's descriptor file is shown by size only. The other commands print one\n`<id>\\t<env>\\t<state>\\t<exclusive app>` row.\n\nMutating namespace commands read the Bearer credential from FABRIKA_CONTROL_TOKEN.\nPlan/create/adopt require FABRIKA_ZEROPS_PROXY_SOURCE_JSON:\n {\"repository\":{\"owner\":\"...\",\"name\":\"...\"},\"commitSha\":\"...\",\"descriptor\":{\"path\":\"zerops.yaml\",\"contents\":\"...\",\"sha256\":\"...\"}}\nReconcile uses the persisted namespace source.\n";
|
|
3
|
+
export interface ZeropsNamespaceCommand {
|
|
4
|
+
readonly args: ZeropsCliArgs;
|
|
5
|
+
/** The result as JSON; otherwise the rows `fabrika control namespaces` prints. */
|
|
6
|
+
readonly json: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ZeropsNamespaceCommandDependencies {
|
|
9
|
+
readonly source: Readonly<Record<string, string | undefined>>;
|
|
10
|
+
readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
11
|
+
readonly write: (value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/** Execute one namespace command. All command inputs are validated before the first fetch. */
|
|
14
|
+
export declare const runZeropsNamespaceCommand: (command: ZeropsNamespaceCommand, deps: ZeropsNamespaceCommandDependencies) => Promise<void>;
|
|
15
|
+
/** `--json` is this area's own flag, so it is taken out before the provider's parser, which refuses unknown options. */
|
|
16
|
+
export declare const parseZeropsNamespaceCommand: (subcommand: string, argv: readonly string[]) => ZeropsNamespaceCommand;
|
|
17
|
+
export declare const runZeropsNamespaceCli: (subcommand: string, argv: readonly string[]) => Promise<void>;
|