@fabrika/cli 0.9.0-dev.5 → 0.9.0-dev.50
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 +16 -13
- package/src/app-dev-seed.ts +2 -6
- package/src/app-dev-ui.ts +155 -24
- package/src/app-dev.ts +65 -24
- package/src/connect.ts +24 -8
- package/src/control-oauth.ts +463 -0
- package/src/control.ts +899 -105
- package/src/credential-origin.ts +54 -0
- package/src/data.ts +61 -24
- package/src/db.ts +35 -212
- package/src/index.ts +21 -5
- package/src/job.ts +2 -2
- package/src/operations.ts +737 -0
- package/types/src/app-dev-seed.d.ts +0 -2
- package/types/src/app-dev-ui.d.ts +22 -8
- package/types/src/connect.d.ts +4 -1
- package/types/src/control-oauth.d.ts +56 -0
- package/types/src/control.d.ts +86 -14
- package/types/src/credential-origin.d.ts +14 -0
- package/types/src/data.d.ts +3 -1
- package/types/src/db.d.ts +1 -3
- package/types/src/job.d.ts +1 -1
- package/types/src/operations.d.ts +23 -0
- package/src/junit.ts +0 -37
- package/types/src/junit.d.ts +0 -10
|
@@ -27,8 +27,6 @@ export declare const NOTHING_SEEDED: Seeded;
|
|
|
27
27
|
export declare class SeedProblem extends Error {
|
|
28
28
|
readonly name = "SeedProblem";
|
|
29
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
30
|
/** The seed module's path: `--seed`, relative to the root, or `dev/seed.ts` when it exists; `null` for none. */
|
|
33
31
|
export declare function seedPath(root: string, given: string | null): string | null;
|
|
34
32
|
/** The seed's default export, a function of the kit and the dev outbox. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DevMail, SentInvitation } from '@fabrika/app/testing';
|
|
2
|
-
import type { Locale } from '@fabrika/auth-core';
|
|
2
|
+
import type { Locale, RenderedMessage } from '@fabrika/auth-core';
|
|
3
3
|
/** A label beside a caller: a role it holds (with the scope value it holds it in), or that it is external. */
|
|
4
4
|
export interface Badge {
|
|
5
5
|
readonly text: string;
|
|
@@ -44,9 +44,19 @@ export interface LinkView {
|
|
|
44
44
|
}
|
|
45
45
|
/** An invitation's state, or how a job's message ended: `sent` when the transport accepted it. */
|
|
46
46
|
export type MailStatus = SentInvitation['status'] | 'sent' | 'not_sent' | 'unknown';
|
|
47
|
+
/** A link a row offers: accept an invitation, continue as its invitee, open a message. */
|
|
48
|
+
export interface MailAction {
|
|
49
|
+
readonly label: string;
|
|
50
|
+
readonly href: string;
|
|
51
|
+
}
|
|
47
52
|
export interface MailView {
|
|
48
53
|
readonly to: string;
|
|
54
|
+
/** The subject the addressee reads: an invitation's in the language IAM writes it in. */
|
|
49
55
|
readonly subject: string;
|
|
56
|
+
/** The language the subject is written in when it is not the page's (an invitation's `mailLocale`); otherwise `null`. */
|
|
57
|
+
readonly subjectLocale: Locale | null;
|
|
58
|
+
/** One more line of what it is: an invitation's role, scope value and language; `null` for a job's message. */
|
|
59
|
+
readonly note: string | null;
|
|
50
60
|
/** When it was sent, in ms: an invitation's latest send, or a job's handoff. */
|
|
51
61
|
readonly at: number;
|
|
52
62
|
/** The key the job passed; `null` for an invitation. */
|
|
@@ -54,10 +64,8 @@ export interface MailView {
|
|
|
54
64
|
readonly status: MailStatus;
|
|
55
65
|
/** The transport's refusal code (`provider_rejected`) when it did not accept; otherwise `null`. */
|
|
56
66
|
readonly answer: string | null;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
readonly href: string;
|
|
60
|
-
} | null;
|
|
67
|
+
/** The row's links, the main one first: the toolbar offers that one only. */
|
|
68
|
+
readonly actions: readonly MailAction[];
|
|
61
69
|
}
|
|
62
70
|
/** A request the application sent to the dev outbox. */
|
|
63
71
|
export interface OutboxView {
|
|
@@ -114,6 +122,8 @@ interface Strings {
|
|
|
114
122
|
readonly key: string;
|
|
115
123
|
readonly transportKey: string;
|
|
116
124
|
readonly sentAt: string;
|
|
125
|
+
readonly language: string;
|
|
126
|
+
readonly state: string;
|
|
117
127
|
readonly answer: string;
|
|
118
128
|
readonly fromName: string;
|
|
119
129
|
readonly replyTo: string;
|
|
@@ -132,11 +142,15 @@ export declare const stringsOf: (locale: Locale) => Strings;
|
|
|
132
142
|
export declare function pickerPage(view: DevView): string;
|
|
133
143
|
/** A refusal of a dev route, with the way back to the picker. */
|
|
134
144
|
export declare function noticePage(view: Pick<DevView, 'locale' | 'title' | 'current' | 'pickerHref'>, heading: string, message: string): string;
|
|
145
|
+
/** One message a job handed to the mail stand-in. */
|
|
146
|
+
export declare function mailPage(view: Pick<DevView, 'locale' | 'title' | 'current' | 'pickerHref'>, mail: DevMail): string;
|
|
135
147
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
148
|
+
* The e-mail the stand-in IAM would have sent for an invitation, as IAM writes it: in the language it chose
|
|
149
|
+
* (`mailLocale`), from the application's template of that language or IAM's own wording. The page around it speaks the
|
|
150
|
+
* application's language; only the message is the invitee's. `actions` are what its row offers (accept it, continue as
|
|
151
|
+
* its invitee).
|
|
138
152
|
*/
|
|
139
|
-
export declare function
|
|
153
|
+
export declare function invitationMailPage(view: Pick<DevView, 'locale' | 'title' | 'current' | 'pickerHref'>, invitation: SentInvitation, mail: RenderedMessage, actions?: readonly MailAction[]): string;
|
|
140
154
|
/** What the toolbar renders: its labels and the view, with every caller already put into words. */
|
|
141
155
|
export declare function toolbarState(view: DevView): unknown;
|
|
142
156
|
/** The toolbar: a pill in the bottom corner, in a shadow root so neither the page's styles nor its layout meet it. */
|
package/types/src/connect.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ControlOAuthDependencies } from './control-oauth.js';
|
|
2
|
+
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, or with the grant `fabrika control auth device` stored through\nFABRIKA_CONTROL_CREDENTIAL_HELPER. 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
3
|
export interface ConnectCommandDependencies {
|
|
3
4
|
/** The application root. */
|
|
4
5
|
readonly cwd: string;
|
|
@@ -8,6 +9,8 @@ export interface ConnectCommandDependencies {
|
|
|
8
9
|
readonly write: (line: string) => void;
|
|
9
10
|
/** Guidance for the person running it. */
|
|
10
11
|
readonly note: (line: string) => void;
|
|
12
|
+
/** Replaces the credential helper, its lock and the clock; only a test passes it. */
|
|
13
|
+
readonly oauth?: ControlOAuthDependencies;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Every line and error leaves with the Control key cut out. No diagnostic quotes the answer; this is defence in depth
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { RpcFetch } from '@fabrika/app';
|
|
2
|
+
import { type ControlCliPreset } from '@fabrika/control-contract';
|
|
3
|
+
export declare const CREDENTIAL_HELPER_VARIABLE = "FABRIKA_CONTROL_CREDENTIAL_HELPER";
|
|
4
|
+
/** Where the refresh token lives between runs: a command with `get` and `store`, in the style of a git credential helper. */
|
|
5
|
+
export interface CredentialHelper {
|
|
6
|
+
/** The refresh token stored for `origin`, or null when none is. */
|
|
7
|
+
get(origin: string): Promise<string | null>;
|
|
8
|
+
store(origin: string, refreshToken: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/** Takes the one lock that serializes refresh-token rotation for `origin` on this machine; resolves to its release. */
|
|
11
|
+
export type CredentialLock = (origin: string) => Promise<() => Promise<void>>;
|
|
12
|
+
export interface ControlOAuthDependencies {
|
|
13
|
+
readonly fetch: RpcFetch;
|
|
14
|
+
readonly helper: CredentialHelper;
|
|
15
|
+
readonly lock: CredentialLock;
|
|
16
|
+
/** Milliseconds. */
|
|
17
|
+
readonly now: () => number;
|
|
18
|
+
readonly sleep: (ms: number) => Promise<void>;
|
|
19
|
+
/** Guidance for the person running the command; it goes to stderr. */
|
|
20
|
+
readonly note: (line: string) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `command` run by the shell with the action as its one argument, as git runs a credential helper. Its stdin carries
|
|
24
|
+
* `origin=<origin>` and, for `store`, `refresh_token=<token>`; `get` prints `refresh_token=<token>`, or nothing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function commandCredentialHelper(command: string): CredentialHelper;
|
|
27
|
+
/**
|
|
28
|
+
* An exclusive lock file per origin under `directory`, created whole by `link` so it never exists empty, and naming its
|
|
29
|
+
* holder. A dead holder's file is taken over; release removes only this holding's own file.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fileCredentialLock(directory: string, waitMs?: number): CredentialLock;
|
|
32
|
+
/** The helper `command` names, the lock under the user's cache directory, and the real clock. */
|
|
33
|
+
export declare function defaultControlOAuthDependencies(command: string, env: Readonly<Record<string, string | undefined>>, send: RpcFetch): ControlOAuthDependencies;
|
|
34
|
+
export interface DeviceGrantRequest {
|
|
35
|
+
/** Control's origin, already checked. */
|
|
36
|
+
readonly origin: string;
|
|
37
|
+
readonly preset: ControlCliPreset;
|
|
38
|
+
/** The application every preset but `create` holds its actions at. */
|
|
39
|
+
readonly app?: string;
|
|
40
|
+
}
|
|
41
|
+
/** The preset `raw` names, or null. */
|
|
42
|
+
export declare const parseControlCliPreset: (raw: string) => ControlCliPreset | null;
|
|
43
|
+
/**
|
|
44
|
+
* The device grant: start it for the preset's resources, tell the person where to approve it, poll until they do, and
|
|
45
|
+
* store the refresh token through the helper. The access token of the first resource is dropped; a call refreshes its own.
|
|
46
|
+
*/
|
|
47
|
+
export declare function authorizeDevice(request: DeviceGrantRequest, deps: ControlOAuthDependencies): Promise<void>;
|
|
48
|
+
/** A current access token for one of the console's resources. */
|
|
49
|
+
export type ControlBearer = (resource: string) => Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Access tokens for `origin`'s resources, refreshed through the helper's grant as a call needs them and kept in this
|
|
52
|
+
* process's memory only. Concurrent calls for one resource share one refresh.
|
|
53
|
+
*/
|
|
54
|
+
export declare function controlOAuthBearer(origin: string, deps: ControlOAuthDependencies): ControlBearer;
|
|
55
|
+
/** The console resource a request needs: the Operations RPC, or Control's own. A bearer never leaves Control's origin. */
|
|
56
|
+
export declare function controlResourceFor(origin: string, input: RequestInfo | URL): string;
|
package/types/src/control.d.ts
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
import { type InferRpcClient } from '@fabrika/app';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { type InferRpcClient, type RpcFetch } from '@fabrika/app';
|
|
2
|
+
import { type ApprovalRequestDto } from '@fabrika/control-contract';
|
|
3
|
+
import type { AppEnvDto, ControlRpcContract, DeploymentNamespaceDto, JsonValue, PlanDeploymentNamespaceResponse, RunDto } from '@fabrika/control-contract';
|
|
4
|
+
import { type ExternalAppDto, type IamAdminRpcContract, type PutExternalAppRequest, type PutOAuthClientRequest } from '@fabrika/iam-contract';
|
|
5
|
+
import { type ControlOAuthDependencies } from './control-oauth.js';
|
|
6
|
+
declare const USAGE = "fabrika control \u2014 operate the Delivery control plane\n\nUsage:\n fabrika control auth device --preset=<read|deploy|operate|create> [--app=<id>]\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] [--wait]\n fabrika control apps environments suspend --app=<id> --env=<name> [--wait]\n fabrika control apps environments resume --app=<id> --env=<name> [--wait]\n fabrika control apps variables list --app=<id>\n fabrika control apps variables put --app=<id> --name=<name> --value=<text> [--env=<name>] [--not-secret] [--request] [--wait]\n fabrika control apps variables delete --app=<id> --name=<name> [--env=<name>] [--request] [--wait]\n fabrika control apps secrets list --app=<id>\n fabrika control apps secrets put --app=<id> --name=<name> [--env=<name>] [--request] [--wait] (the value on stdin)\n fabrika control apps secrets delete --app=<id> --name=<name> [--env=<name>] [--request] [--wait]\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 namespaces release-claims --namespace=<id> --app=<id> --env=<name>\n fabrika control deploy --app=<id> --env=<name> [--ref=<ref>] [--wait]\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 fabrika control requests get <id> [--wait]\n fabrika control access request-grant --app=<id> --env=<name> --principal=<id> --role=<role>\n [--scope=<dimension>:<value>] --expires-in=<seconds> [--wait]\n fabrika control access request-key --app=<id> --action=<action> [--action=<action>\u2026] --label=<text>\n --expires-in=<seconds> --wait\n fabrika control external-apps list | get <app> | put --file=<app.json> | delete <app> [--iam-url=<origin>]\n fabrika control oauth-clients list | put --file=<client.json> | delete <client id> [--iam-url=<origin>]\n\n`register` CREATES an app and refuses a second one with the same id. Re-registering a changed\nmanifest \u2014 a new import document, or a new `zerops.yaml` of an app without a contract \u2014 is\n`apps environments put`, which replaces one environment's envelopes and leaves the app row alone. A\ncontract app's deploy registers the `zerops.yaml` of its commit itself.\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\n`apps environments suspend` takes an environment offline in an incident, such as a compromised or leaked application.\nBehind a Zerops namespace proxy every request to it answers 503 once the republished proxy is live, which takes the\nminutes of a proxy build; `namespaces get` follows it. A namespace pinned to an older proxy source is refused with the\nre-pin to run first. On Cloudflare the environment's object goes into maintenance `closed`. `resume` restores the\nrouting it had, or on Cloudflare the maintenance mode it was in. Neither stops the application's service, nor\nrevokes a key. Repeating either is a retry.\n\nA variable's value is stored and printed in clear, so `apps variables put` refuses one that looks like a\ncredential (by its name, such as `*_TOKEN` or `*_PASSWORD`, or by its value) and names `apps secrets put` instead.\n`--not-secret` stores it anyway, for a value you have checked is not one. 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 repository owner'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. Branches named `fabrika/\u2026` are reserved for MCP\nworkspaces and are never a trigger ref.\n\n`deploy` of a protected environment with `FABRIKA_CONTROL_KEY` or a device grant is a request a person approves:\n`--ref` names a 40-character commit SHA, by default one merged into the environment's trigger ref (or the default\nbranch), and stderr prints the console link the person opens. `--wait` follows the run until it succeeds or\nfails, approval being one step on the way, and prints its final row; a refusal or an expiry says so on stderr.\n\n`requests get` reads one approval request: a change an agent or a key asked a person to approve, by the id its\ncreation answered. stderr prints the console link while it waits, and why it did not run once it failed, went stale or\nexpired. `--wait` reads it again until it is refused, expired, executed, failed or stale, and prints its final row;\nonce a person decided it, it stops with an error after 15 minutes without an outcome.\n\n`--request` on `apps secrets put|delete` and `apps variables put|delete` does not make the change: it asks a person\nto approve it. Every other verb refuses it. Control stores the request, inert, and stderr prints the console link the person opens; for a secret it\nalso prints the value's fingerprint (the first 8 hex characters of its SHA-256, computed here), which the page shows\nbeside the value's length, so the person can tell it is the value you sent; when Control's answer names another\nfingerprint, the command fails and says to refuse the request. Control seals the value and stores only that. stdout\nprints the request's id, state and link; `--wait` follows it as `requests get --wait` does. Without `--env` the request\nis for every environment of the app, and every protected one judges it. A secret the provider keeps (a Zerops\nenvironment) is requested for one `--env`.\n\n`access request-grant` asks a person to give a principal (this agent's own, or another) one role of an application\nenvironment. It needs `access.request` at the app, the role must be one the environment's approved contract declares,\na membership role takes `--scope` with a value of its dimension, and `--expires-in` is at most 30 days. An IAM\nadministrator of the application approves it at the console link stderr prints; the grant is then theirs, and where\nthe application's grants wait for approval, IAM holds it for a second administrator. An environment that does not gate\nan agent's grants (not protected, or `agent-grants` off) refuses it: there is nothing to approve there. stdout prints\nthe request's id, state and link; `--wait` follows it as `requests get --wait` does.\n\nWithout `--request`, a write by `FABRIKA_CONTROL_KEY` or a device grant on a protected environment meets that\nenvironment's approval policy (ADR-0083): `apps secrets` and `apps variables` are `secrets` and `variables` writes,\n`apps environments put` is a `registry` write, and `apps environments suspend|resume` are `data` writes.\nA category set to `off` applies the write; `refuse` refuses it; `person` does not make the change but stores it as a\nrequest, exactly as `--request` does: stdout prints its id, state and link, stderr the fingerprint of a secret, and the\ncommand exits 75. Hand the person the link; nothing changes until they approve it. `--wait` follows the request\ninstead, and succeeds only when it executed.\n\n`access request-key` asks a person for a key holding exact Control actions at one application (each `--action`, no\nwildcard), for someone other than this agent, expiring in at most 30 days. It needs `access.request` at the app, and\nthe protected environments' `credentialCeiling` decides whether the key may hold actions this agent does not. It\nmakes a key pair in memory, sends only the public key, and prints on stderr the console link and the public key's\nthumbprint, which the page shows: an IAM installation administrator checks it there and approves with a passkey. IAM\nencrypts the key to that public key, and Control hands it out once. `--wait` is required: the private key never leaves\nthis process, so the key cannot be fetched later; the command waits for the decision, fetches the key, decrypts it, and\nprints it once on stdout. A request that issues no key (refused, expired, failed) fails with why.\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 --postgres-type=<type> the `cheap` preset's shared PostgreSQL; on Zerops postgresql:single@18\n (default) or postgresql:ha@18, which keeps its data through a node loss.\n Fixed once created\n --postgres-profile=<profile> its profile, given together with --postgres-type: oltp-hobby for single,\n oltp-staging (about $11) or oltp-production (about $72) for HA\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\n`namespaces release-claims` frees the resource names one app environment holds in a placement, which an\nenvironment or app delete otherwise refuses over. Delete those resources at the provider first: the release\nreads each one back and refuses, naming it, while any still exists. It prints one released key per line.\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. One of:\n\n FABRIKA_CONTROL_KEY a machine `px_` credential for the control app; it wins when both are set\n FABRIKA_CONTROL_CREDENTIAL_HELPER a command with `get` and `store` that holds the refresh token of a\n `control auth device` grant (below)\n\n`auth device` asks IAM for a grant a person approves in the browser (RFC 8628). It prints the page and the\ncode on stderr and waits; the person signs in, checks the code, and picks how long the grant lasts (an hour, a\nday or a week). The grant holds the preset's actions at one application, never more than that person may:\n\n read deploy.read, data.read, operations.read\n deploy read, and deploy.trigger\n operate deploy, secret.manage, app.manage and operations.triage\n create app.manage wherever the person holds it, with no --app: it also changes and deletes apps\n\nThe refresh token goes to the helper and nowhere else: the helper runs as `sh -c '<helper> get|store'`,\nreads `origin=<console origin>` (and, for `store`, `refresh_token=<token>`) on stdin, and `get` prints\n`refresh_token=<token>`, or nothing. Every call then trades it for a short-lived access token, and IAM\nrotates it each time; a lock under $XDG_CACHE_HOME/fabrika (~/.cache/fabrika when unset) serializes that\nbetween processes on this machine. If a refresh's answer is lost, the stored token is spent and the next\ncall says to run `auth device` again.\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\n`external-apps` and `oauth-clients` manage the OAuth clients IAM serves (ADR-0089). They call IAM's admin API\nwith two of the variables `key issue` reads, and nothing else: FABRIKA_IAM_RPC_URL (or --iam-url), IAM's PUBLIC origin,\nand FABRIKA_IAM_PROVISIONING_KEY, the bearer. An external application is an application outside this installation that\nsigns people in through IAM; `put` replaces it whole from a file (record, roles and clients) and is idempotent:\n\n {\n \"app\": \"ops-tool\",\n \"name\": \"Ops tool\",\n \"resource\": \"https://ops.example.com\",\n \"roles\": [{ \"key\": \"viewer\", \"name\": \"Viewer\" }],\n \"clients\": [{ \"clientId\": \"https://ops.example.com/oauth/client.json\",\n \"redirectUris\": [\"https://ops.example.com/oauth/callback\"], \"metadataUrl\": null }]\n }\n\n`roles` null or left out: every active user of the installation signs in. `get` prints the same file, ready to edit\nand put back. Removing a client, changing the resource or deleting the application revokes the sign-ins through it.\n`oauth-clients put` writes an MCP authoring client, whose tokens reach the console's /mcp:\n\n { \"clientId\": \"https://claude.ai/oauth/mcp-oauth-client-metadata\", \"label\": \"claude\",\n \"redirectUris\": [\"https://claude.ai/api/mcp/auth_callback\"] }\n\n`label` is claude, chatgpt or external. A client of an external application is written only through\n`external-apps put`, and `oauth-clients` refuses it. `put` checks the file before anything is sent.\nThe console registers external applications too, under Access \u2192 External applications.\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";
|
|
4
7
|
interface Flags {
|
|
5
8
|
readonly values: ReadonlyMap<string, string>;
|
|
6
9
|
/** Every value of every option, in order; `values` keeps the last. Only a repeatable option reads it. */
|
|
7
10
|
readonly repeated: ReadonlyMap<string, readonly string[]>;
|
|
8
11
|
readonly json: boolean;
|
|
12
|
+
/** `--not-secret`: `apps variables put` stores a value that looks like a credential. */
|
|
13
|
+
readonly notSecret: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* `--wait`: `deploy` follows the run until it succeeds or fails; `requests get`, `--request` and a write Control stores as
|
|
16
|
+
* a request follow the request until it settles.
|
|
17
|
+
*/
|
|
18
|
+
readonly wait: boolean;
|
|
19
|
+
/** `--request`: a secret or variable write asks a person to approve it instead of making it (ADR-0083 §8). */
|
|
20
|
+
readonly request: boolean;
|
|
9
21
|
readonly positional: readonly string[];
|
|
10
22
|
}
|
|
11
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Split `--key=value` options from positional words; `--json` is the one flag every verb shares, `--not-secret`, `--wait`
|
|
25
|
+
* and `--request` the other bare ones.
|
|
26
|
+
*/
|
|
12
27
|
export declare const parseControlFlags: (argv: readonly string[]) => Flags;
|
|
13
28
|
/** The console's client with a bearer instead of a cookie, and no SSO bounce: there is no browser to send. */
|
|
14
29
|
export type ControlClient = InferRpcClient<ControlRpcContract>;
|
|
15
|
-
/**
|
|
16
|
-
* Control's origin, checked before the key is sent anywhere: https, or http to a loopback host for local development,
|
|
17
|
-
* and nothing but scheme, host and port. A refusal never repeats the value, which may hold userinfo.
|
|
18
|
-
*/
|
|
19
|
-
export declare const controlOrigin: (raw: string | undefined) => string;
|
|
20
30
|
/** `text` with the control key cut out: every diagnostic of an area that holds the key passes through it. */
|
|
21
31
|
export declare const withoutControlKey: (text: string, env: Readonly<Record<string, string | undefined>>) => string;
|
|
32
|
+
/** Control's origin and the fetch that carries the Control credential to it. */
|
|
33
|
+
export interface ControlTransport {
|
|
34
|
+
readonly origin: string;
|
|
35
|
+
readonly fetch: RpcFetch;
|
|
36
|
+
/** The credential is a person's device grant, not FABRIKA_CONTROL_KEY. */
|
|
37
|
+
readonly grant: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Neither credential is set; both are read from the environment only. */
|
|
40
|
+
export declare const MISSING_CONTROL_CREDENTIAL: string;
|
|
22
41
|
/**
|
|
23
|
-
* The
|
|
24
|
-
*
|
|
42
|
+
* The origin from `url` or FABRIKA_CONTROL_URL, the credential from the environment only, no redirect followed. Every
|
|
43
|
+
* client of the console's origin is built on it.
|
|
25
44
|
*/
|
|
26
|
-
export declare const
|
|
45
|
+
export declare const controlTransport: (url: string | undefined, env: Readonly<Record<string, string | undefined>>, send?: RpcFetch, oauth?: ControlOAuthDependencies) => ControlTransport;
|
|
46
|
+
/** The one client of Control that `fabrika control`, `fabrika env` and `fabrika operations` share. */
|
|
47
|
+
export declare const connectControl: (url: string | undefined, env: Readonly<Record<string, string | undefined>>, oauth?: ControlOAuthDependencies) => ControlClient;
|
|
27
48
|
/** The exact text `app build` would write, and the provider whose envelope carries it. */
|
|
28
49
|
export interface CompiledManifest {
|
|
29
50
|
readonly provider: string;
|
|
@@ -47,9 +68,60 @@ export interface SecretValueInput {
|
|
|
47
68
|
/** Also `fabrika namespace`'s row, which reads only these fields of Control's answer. */
|
|
48
69
|
export declare const namespaceLine: (namespace: Pick<DeploymentNamespaceDto, "id" | "env" | "state" | "exclusiveAppId">) => string;
|
|
49
70
|
export declare const namespacePlanLines: (plan: PlanDeploymentNamespaceResponse) => string[];
|
|
71
|
+
export type IamAdminClient = InferRpcClient<IamAdminRpcContract>;
|
|
72
|
+
/** IAM's admin RPC at its public origin, with the provisioning key from the environment only and no redirect followed. */
|
|
73
|
+
export declare const iamAdminClient: (url: string | undefined, env: Readonly<Record<string, string | undefined>>, send?: RpcFetch) => IamAdminClient;
|
|
74
|
+
/** An `externalApps.put` request from a file, checked against the contract before it is sent; IAM checks it again. */
|
|
75
|
+
export declare const parseExternalAppFile: (value: JsonValue, path: string) => PutExternalAppRequest;
|
|
76
|
+
/** An `oauthClients.put` request (an MCP authoring client) from a file, checked against the contract before it is sent. */
|
|
77
|
+
export declare const parseOAuthClientFile: (value: JsonValue, path: string) => PutOAuthClientRequest;
|
|
78
|
+
/** What `external-apps get` prints: the file `external-apps put` takes back, so a record can be kept and edited as a file. */
|
|
79
|
+
export declare const externalAppFile: (app: ExternalAppDto) => PutExternalAppRequest;
|
|
80
|
+
/**
|
|
81
|
+
* What stderr says about a run beside its row: the link a person approves it at, or why it failed. A non-person's
|
|
82
|
+
* deploy of a protected environment carries the link from its creation (ADR-0050 §4).
|
|
83
|
+
*/
|
|
84
|
+
export declare const runHint: (run: RunDto) => string | null;
|
|
85
|
+
/**
|
|
86
|
+
* Follow a run until it succeeds or fails, saying on stderr when it starts to wait for a person and where. Approval is
|
|
87
|
+
* only a step: an approved run deploys, and its outcome is what this answers.
|
|
88
|
+
*/
|
|
89
|
+
export declare const followRun: (read: (runId: string) => Promise<RunDto>, created: RunDto, options: {
|
|
90
|
+
readonly intervalMs: number;
|
|
91
|
+
}) => Promise<RunDto>;
|
|
92
|
+
/**
|
|
93
|
+
* The exit code of a write that did not apply because it waits for a person (ADR-0083 §3): neither done nor failed.
|
|
94
|
+
* sysexits' EX_TEMPFAIL, "not done now; it may be later".
|
|
95
|
+
*/
|
|
96
|
+
export declare const APPROVAL_PENDING_EXIT_CODE = 75;
|
|
97
|
+
/** A write Control stored as a request for a person instead of making it; the process exits with `APPROVAL_PENDING_EXIT_CODE`. */
|
|
98
|
+
export declare class ApprovalPendingError extends Error {
|
|
99
|
+
readonly exitCode = 75;
|
|
100
|
+
}
|
|
101
|
+
/** What printing and following a request takes from a command's flags. */
|
|
102
|
+
export interface RequestOutput {
|
|
103
|
+
readonly json: boolean;
|
|
104
|
+
readonly wait: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Make a write; when Control stores it as a request for a person instead (D8, a protected environment), print the
|
|
108
|
+
* request as `--request` does and, without `--wait`, fail with `ApprovalPendingError`. With `--wait` the request is
|
|
109
|
+
* followed: an executed one answers null, anything else fails. `secretValue` is the value a secret write sent, whose
|
|
110
|
+
* fingerprint is computed here.
|
|
111
|
+
*/
|
|
112
|
+
export declare const directWrite: <T>(client: ControlClient, output: RequestOutput, write: () => Promise<T>, secretValue?: string) => Promise<T | null>;
|
|
113
|
+
/** What stderr says about a request beside its row: where a person decides it, or why it did not run. */
|
|
114
|
+
export declare const requestHint: (request: ApprovalRequestDto) => string | null;
|
|
50
115
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
116
|
+
* Follow a request until it settles, saying each stage once on stderr; what it ended as is what this answers. Once it is
|
|
117
|
+
* no longer pending, it stops with an error after `settleTimeoutMs`, which `unsettled` words. A read that fails on the way
|
|
118
|
+
* or with a 5xx is repeated at the next interval while the wait lasts: until the deadline of a pending request, and
|
|
119
|
+
* until `settleTimeoutMs` of a decided one.
|
|
53
120
|
*/
|
|
121
|
+
export declare const followRequest: (read: (id: string) => Promise<ApprovalRequestDto>, first: ApprovalRequestDto, options: {
|
|
122
|
+
readonly intervalMs: number;
|
|
123
|
+
readonly settleTimeoutMs: number;
|
|
124
|
+
readonly unsettled?: (request: ApprovalRequestDto, minutes: number) => string;
|
|
125
|
+
}) => Promise<ApprovalRequestDto>;
|
|
54
126
|
export declare const runControlCli: (command: string | undefined, argv: readonly string[], provider?: string, env?: Readonly<Record<string, string | undefined>>, input?: SecretValueInput) => Promise<void>;
|
|
55
127
|
export { USAGE as CONTROL_USAGE };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Which origin a check reads, so its refusals name the right flag and variable. `hint` follows a refusal of the value. */
|
|
2
|
+
export interface OriginSource {
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly flag: string;
|
|
5
|
+
readonly variable: string;
|
|
6
|
+
readonly hint?: string;
|
|
7
|
+
}
|
|
8
|
+
/** The origin of a value another party published (an authorization server), or null when no credential may go there. */
|
|
9
|
+
export declare const credentialOriginOf: (raw: string) => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* An origin a credential is sent to, checked before the credential goes anywhere. A refusal never repeats the value,
|
|
12
|
+
* which may hold userinfo.
|
|
13
|
+
*/
|
|
14
|
+
export declare const credentialOrigin: (raw: string | undefined, source: OriginSource) => string;
|
package/types/src/data.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
declare const USAGE = "fabrika env \u2014 an application environment's data, through the control plane\n\nUsage:\n fabrika env inspect <app> <env> [--content] [--json]\n fabrika env maintenance <app> <env> <open|read-only|closed> [--json]\n fabrika env operations <app> <env> [--json]\n fabrika env recover <app> <env> <operationId> <resume|open> [--json]\n fabrika env backups <app> <env> [--json]\n fabrika env backups schedule <app> <env> [on|off] [--json]\n fabrika env restore <app> <env> --at=<time> [--json]\n\n`inspect` prints the environment's data view: the object's maintenance mode and generation, the database size and\neach table's row count (a count at 100000 reads `100000+`: it is capped), the applied migrations,\nthe scheduler's alarm, each job's last run, file and webhook counts, and when the application last failed to boot.\nIt needs `data.read`. `--content` adds the boot failure's message and stack, which are the application's own text,\nand needs `data.content.read` granted globally.\n\n`maintenance` puts the environment into a mode: `read-only` refuses writes, `closed` refuses every request, and\n`open` serves again. It starts a data operation and prints it; `operations` follows it. It needs `data.manage`.\n\n`operations` lists the environment's data operations, newest first, one row each:\n<id> <kind> <state> <step> <target mode> <generation> <error code> <created at>.\n\n`recover` fences an environment whose operation is stuck in `closed` at a fresh generation, then `resume`s that\noperation from its recorded step, or `open`s the environment. A failed operation can only be opened past. It needs
|
|
1
|
+
declare const USAGE = "fabrika env \u2014 an application environment's data, through the control plane\n\nUsage:\n fabrika env inspect <app> <env> [--content] [--json]\n fabrika env maintenance <app> <env> <open|read-only|closed> [--wait] [--json]\n fabrika env operations <app> <env> [--json]\n fabrika env recover <app> <env> <operationId> <resume|open|rollback> [--wait] [--json]\n fabrika env backups <app> <env> [--json]\n fabrika env backups schedule <app> <env> [on|off] [--wait] [--json]\n fabrika env restore <app> <env> --at=<time> [--wait] [--json]\n\n`inspect` prints the environment's data view: the object's maintenance mode and generation, the database size and\neach table's row count (a count at 100000 reads `100000+`: it is capped), the applied migrations,\nthe scheduler's alarm, each job's last run, file and webhook counts, and when the application last failed to boot.\nIt needs `data.read`. `--content` adds the boot failure's message and stack, which are the application's own text,\nand needs `data.content.read` granted globally.\n\n`maintenance` puts the environment into a mode: `read-only` refuses writes, `closed` refuses every request, and\n`open` serves again. It starts a data operation and prints it; `operations` follows it. It needs `data.manage`.\n\n`operations` lists the environment's data operations, newest first, one row each:\n<id> <kind> <state> <step> <target mode> <generation> <error code> <created at>.\n\n`recover` fences an environment whose operation is stuck in `closed` at a fresh generation, then `resume`s that\noperation from its recorded step, or `open`s the environment. A failed operation can only be opened past, or, for a\nfailed migration whose data holds nothing of it (`rollbackAndOpen` in `--json`), rolled back: `rollback` fences\nit in `inspect`, deploys the last succeeded commit again as a new run, waits until the failed version is gone and\nopens it. It needs `data.manage`.\n\n`backups` lists the environment's consistent backups, newest first, one row each:\n<id> <object> <state> <created at> <size bytes> <parts> <tables> <rehearsal> <rehearsal code> <error code> <expired>\n<pre-migration>.\nA backup counts as `succeeded` only once its rehearsal, an import into a scratch object, passed. One older than 30\ndays is `expired` and never offered for a restore. The last column is `pre-migration` for the backup a migration\ntakes before its deploy, and `-` for any other, such as a daily backup or a restore's. It needs `data.read`.\n\n`backups schedule` prints whether the environment takes a daily backup; `on` or `off` sets it, which needs\n`data.manage`. Turning it off stops the daily backup only: the backup before a migration still runs.\n\n`restore` brings back the environment's data as it was at `--at`, an ISO 8601 time with an offset in the past. It\nis a side restore: the serving object is frozen read-only and backed up, the backup is imported into a new clone\nobject, ordinary traffic is pointed at the clone, which serves the current data from then on, and the original is\nrewound to that time and kept in `inspect`, serving nothing, for inspection. It starts a data operation and prints\nit; `operations` follows it. It needs `data.manage`.\n\nOn a protected environment whose `data` category waits for a person (ADR-0083), a write by a key or an agent does not\napply: Control stores it as an approval request, the request's `<id> <state> <url>` goes to stdout, and the command\nexits 75. Hand the person the link. `--wait` follows the request to its end instead and succeeds only when it executed.\n\nA release of the control plane that does not offer a command answers that it is not available; retrying does not\nchange that. An environment the caller may not see answers `not_found`, as one that does not exist.\n\nstdout carries data only; progress and follow-up commands go to stderr. `--json` prints the result as JSON.\n\nThe control origin takes either form:\n\n --url=<origin> FABRIKA_CONTROL_URL\n\nThe credential is read from the ENVIRONMENT ONLY and has no flag; one of:\n\n FABRIKA_CONTROL_KEY a machine `px_` credential for the control app\n FABRIKA_CONTROL_CREDENTIAL_HELPER the helper a `fabrika control auth device` grant is stored through\n";
|
|
2
2
|
type Environment = Readonly<Record<string, string | undefined>>;
|
|
3
|
+
/** Every control character but tab and line feed: an answer must not drive the operator's terminal. */
|
|
4
|
+
export declare const printable: (text: string) => string;
|
|
3
5
|
export declare const runEnvCli: (command: string | undefined, argv: readonly string[], env?: Environment) => Promise<void>;
|
|
4
6
|
export { USAGE as ENV_USAGE };
|
package/types/src/db.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const DB_USAGE = "fabrika db \u2014 an application's database schema: Postgres, or SQLite on Cloudflare\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]
|
|
1
|
+
export declare const DB_USAGE = "fabrika db \u2014 an application's database schema: Postgres, or SQLite on Cloudflare\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] [--config=<path>] Write src/db/schema.generated.ts from the migrated schema; --verify only fails when it is stale.\n\nRun from the application root. `--config` names the application's config, fabrika.config.ts by default, as `fabrika app\nbuild` takes it: its provider decides the dialect. `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\nAn application whose fabrika.config.ts default-exports @fabrika/provider-cloudflare's defineApp runs on SQLite in its\nDurable Object, which applies the migrations itself when it boots: `migrate` refuses, `codegen` applies them to an\nin-memory database; neither needs a database URL.\n";
|
|
2
2
|
export interface DbCommandDependencies {
|
|
3
3
|
/** The application root. */
|
|
4
4
|
readonly cwd: string;
|
|
@@ -6,7 +6,5 @@ export interface DbCommandDependencies {
|
|
|
6
6
|
readonly now: () => Date;
|
|
7
7
|
readonly write: (line: string) => void;
|
|
8
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
9
|
export declare const runDbCommand: (command: string | undefined, argv: readonly string[], deps: DbCommandDependencies) => Promise<void>;
|
|
12
10
|
export declare const runDbCli: (command: string | undefined, argv: readonly string[]) => Promise<void>;
|
package/types/src/job.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ImplementationLoader } from '@fabrika/app/bun';
|
|
2
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,\
|
|
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,\nframework_fault, unavailable, driver_failed, crashed, unauthorized, iam_unavailable, boot_failed), never by the\napplication's error; a framework failure adds its catalog reason (query_refused: undeclared_reach).\n";
|
|
4
4
|
export interface JobCommandDependencies {
|
|
5
5
|
/** The application root. */
|
|
6
6
|
readonly cwd: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RpcFetch } from '@fabrika/app';
|
|
2
|
+
import { type ControlOAuthDependencies } from './control-oauth.js';
|
|
3
|
+
declare const USAGE = "fabrika operations \u2014 read Operations (errors, releases, health) from the command line\n\nUsage:\n fabrika operations issues [--app=<id>] [--env=<env>] [--service=<key>] [--status=<open|resolved|ignored>]\n [--level=<fatal|error|warning|info>] [--since=<24h|7d|30d|all>] [--search=<text>]\n [--sort=<recent|new|frequency>] [--limit=<1-100>] [--cursor=<cursor>] [--json]\n fabrika operations issue <issueId> [--event=<occurrenceId>] [--json]\n fabrika operations releases [--app=<id>] [--env=<env>] [--service=<key>] [--limit=<1-100>] [--cursor=<cursor>] [--json]\n fabrika operations health [--app=<id>] [--env=<env>] [--service=<key>] [--json]\n\nEvery command is read-only. It reads what the console's Operations pages show, through the same API, with the\nkey's rights: a source (one service of an application environment) the key may not read is not listed, and an\nissue of one answers `not_found`.\n\n`issues` lists issues, the most recently seen first (`--sort` changes that), one row each:\n<id> <status> <level> <events> <last seen> <app> <env> <service> <title>.\nstderr carries the selection's counts by status (whatever `--status` says) and, when more issues match, the\n`--cursor` that reads the next page with the same options.\n\n`issue` prints one issue: its fields, its activity, its recent events (`occurrence` rows), and the latest\nevent in full: request, user, tags, each exception with its stack frames, and the breadcrumbs. `--event` shows\nthe event of another occurrence instead. The raw event is in `--json` only.\n\n`releases` lists releases, newest first, one row each:\n<id> <state> <artifacts> <release> <commit> <created at> <finished at> <new issues> <regressions> <app> <env> <service>.\n\n`health` prints each source's telemetry health and its HTTP checks:\nsource <app> <env> <service> <telemetry state>\ncheck <app> <env> <service> <path> <state> <observed at> <latency ms> <detail code> <consecutive failures>\n\n`--app`, `--env` and `--service` select sources. On `issues` and `releases` they must select exactly one;\nwhen they match several, the error lists them. Without them every source the key may read is included.\n\nIssue titles, exception messages, breadcrumbs, tags and the raw event are text the application's users and code\nwrote. They are printed as data with control characters removed; `--json` escapes them, C1 controls included,\nas JSON strings.\n\nstdout carries data only; notes and errors go to stderr. Times are ISO 8601 UTC, except a breadcrumb time the event\nwrote as text. `--json` prints the parsed answer: of the procedure, or for `issue` `{ issue, event }`, the\nissue and the event shown (`null` when none is stored).\n\nExit codes:\n 0 the answer was printed (an empty list included)\n 1 the call failed: Control or Operations unreachable, a server error, an unreadable answer, or a procedure this\n installation's release does not offer\n 2 usage: an unknown command or option, a bad value, or a selection that matches several sources\n 3 the credential: neither FABRIKA_CONTROL_KEY nor FABRIKA_CONTROL_CREDENTIAL_HELPER is set, or it was refused,\n or it does not hold `operations.read`\n 4 not found: no such issue, event or source, or one the key may not read\n\nThe console origin takes either form:\n\n --url=<origin> FABRIKA_CONTROL_URL\n\nThe credential is read from the ENVIRONMENT ONLY and has no flag; one of:\n\n FABRIKA_CONTROL_KEY a `px_` key of the console app holding `operations.read`\n FABRIKA_CONTROL_CREDENTIAL_HELPER the helper a `fabrika control auth device` grant is stored through\n (any preset but `create` reads Operations; a list is empty where the\n person who approved it holds no `operations.read`)\n\nMint a key narrowed to `operations.read` alone, with a short expiry: docs/reference/operations-errors.md,\n\"Reading Operations from the command line\".\n";
|
|
4
|
+
export declare const OPERATIONS_EXIT: {
|
|
5
|
+
readonly ok: 0;
|
|
6
|
+
readonly failed: 1;
|
|
7
|
+
readonly usage: 2;
|
|
8
|
+
readonly credential: 3;
|
|
9
|
+
readonly notFound: 4;
|
|
10
|
+
};
|
|
11
|
+
type Environment = Readonly<Record<string, string | undefined>>;
|
|
12
|
+
/** What the area reads and writes: the environment, the network, stdout and stderr. */
|
|
13
|
+
export interface OperationsIo {
|
|
14
|
+
readonly env: Environment;
|
|
15
|
+
readonly fetch: RpcFetch;
|
|
16
|
+
/** Replaces the credential helper, its lock and the clock; only a test passes it. */
|
|
17
|
+
readonly oauth?: ControlOAuthDependencies;
|
|
18
|
+
readonly out: (text: string) => void;
|
|
19
|
+
readonly err: (text: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/** Runs one command and returns its exit code; every diagnostic goes to stderr with the key cut out. */
|
|
22
|
+
export declare const runOperationsCli: (command: string | undefined, argv: readonly string[], io?: OperationsIo) => Promise<number>;
|
|
23
|
+
export { USAGE as OPERATIONS_USAGE };
|
package/src/junit.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// The test cases of a `bun test --reporter=junit` report: which ran, and how each ended. Only what `fabrika db
|
|
2
|
-
// test-isolation` needs to tell a passed case from a skipped, failed or missing one.
|
|
3
|
-
|
|
4
|
-
export type CaseOutcome = 'passed' | 'failed' | 'skipped'
|
|
5
|
-
|
|
6
|
-
export interface ReportedCase {
|
|
7
|
-
/** The test file, relative to the directory `bun test` ran in. */
|
|
8
|
-
readonly file: string
|
|
9
|
-
readonly name: string
|
|
10
|
-
readonly outcome: CaseOutcome
|
|
11
|
-
/** The `expect` calls the case ran, as Bun reports them; `null` when the report does not say. */
|
|
12
|
-
readonly assertions: number | null
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const ENTITIES: Readonly<Record<string, string>> = { quot: '"', apos: "'", lt: '<', gt: '>', amp: '&' }
|
|
16
|
-
|
|
17
|
-
const unescape = (text: string): string => text.replace(/&(quot|apos|lt|gt|amp);/g, (_, name: string) => ENTITIES[name] ?? '')
|
|
18
|
-
|
|
19
|
-
const attribute = (attributes: string, name: string): string | undefined => {
|
|
20
|
-
const match = new RegExp(`\\s${name}="([^"]*)"`).exec(attributes)
|
|
21
|
-
return match?.[1] === undefined ? undefined : unescape(match[1])
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function readJunitCases(xml: string): ReportedCase[] {
|
|
25
|
-
const cases: ReportedCase[] = []
|
|
26
|
-
for (const match of xml.matchAll(/<testcase\b([^>]*?)(\/>|>([\s\S]*?)<\/testcase>)/g)) {
|
|
27
|
-
const attributes = match[1] ?? ''
|
|
28
|
-
const content = match[3] ?? ''
|
|
29
|
-
const file = attribute(attributes, 'file')
|
|
30
|
-
const name = attribute(attributes, 'name')
|
|
31
|
-
if (file === undefined || name === undefined) continue
|
|
32
|
-
const outcome: CaseOutcome = /<(failure|error)\b/.test(content) ? 'failed' : /<skipped\b/.test(content) ? 'skipped' : 'passed'
|
|
33
|
-
const assertions = attribute(attributes, 'assertions')
|
|
34
|
-
cases.push({ file: file.replace(/^\.\//, ''), name, outcome, assertions: assertions === undefined ? null : Number(assertions) })
|
|
35
|
-
}
|
|
36
|
-
return cases
|
|
37
|
-
}
|
package/types/src/junit.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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[];
|