@fabrika/app 0.9.0-dev.4 → 0.9.0-dev.6
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 +9 -9
- package/skill/SKILL.md +41 -14
- package/skill/references/app-setup.md +43 -12
- package/skill/references/dev.md +2 -1
- package/skill/references/endpoint.md +30 -24
- package/skill/references/errors.md +40 -35
- package/skill/references/files.md +4 -2
- package/skill/references/jobs.md +21 -4
- package/skill/references/table-and-migration.md +19 -2
- package/skill/references/tests.md +40 -1
- package/skill/references/webhooks-links-connectors.md +1 -1
- package/src/build-recipe.ts +198 -0
- package/src/build.ts +60 -4
- package/src/bun.ts +181 -13
- package/src/cloudflare/application.ts +822 -0
- package/src/cloudflare/bindings.ts +159 -0
- package/src/cloudflare/export.ts +621 -0
- package/src/cloudflare/import.ts +1013 -0
- package/src/cloudflare/maintenance.ts +518 -0
- package/src/cloudflare/names.ts +16 -0
- package/src/cloudflare/ops.ts +375 -0
- package/src/cloudflare/r2-files.ts +172 -0
- package/src/cloudflare/restore.ts +167 -0
- package/src/cloudflare/tracker.ts +192 -0
- package/src/cloudflare.ts +100 -146
- package/src/contract/app-id.ts +5 -0
- package/src/contract/artifact-schema.ts +9 -1
- package/src/contract/build.ts +40 -2
- package/src/contract/compile.ts +1 -0
- package/src/contract/context.ts +35 -9
- package/src/contract/declaration.ts +2 -0
- package/src/contract/defaults.ts +22 -2
- package/src/contract/define.ts +29 -3
- package/src/contract/kit.ts +4 -1
- package/src/contract/platform.ts +3 -2
- package/src/contract/vocabulary.ts +26 -8
- package/src/dev/launcher.ts +50 -4
- package/src/disk-assets.ts +8 -3
- package/src/files/archive.ts +2 -2
- package/src/files/job-names.ts +12 -0
- package/src/files/kinds.ts +73 -31
- package/src/files/scan.ts +3 -4
- package/src/files/streams.ts +3 -1
- package/src/implement/anonymous.ts +12 -11
- package/src/implement/boot.ts +75 -6
- package/src/implement/bounded.ts +21 -2
- package/src/implement/capability.ts +15 -3
- package/src/implement/dispatch.ts +419 -177
- package/src/implement/failures.ts +17 -1
- package/src/implement/faults.ts +1 -0
- package/src/implement/index.ts +1 -0
- package/src/implement/invocation.ts +58 -10
- package/src/implement/principal.ts +25 -2
- package/src/implement/terminals.ts +93 -0
- package/src/implement/workload.ts +42 -16
- package/src/jobs/mail.ts +8 -0
- package/src/jobs/report.ts +5 -1
- package/src/jobs/runner.ts +672 -113
- package/src/jobs/schedule.ts +7 -1
- package/src/jobs/scrub.ts +14 -1
- package/src/jobs/types.ts +6 -0
- package/src/spa-fallback.ts +12 -0
- package/src/testing/endpoint-access.ts +307 -152
- package/src/testing/isolation.ts +8 -1
- package/src/testing/kit.ts +80 -2
- package/src/testing/proxy.ts +15 -10
- package/types/src/build-recipe.d.ts +70 -0
- package/types/src/build.d.ts +19 -1
- package/types/src/bun.d.ts +34 -1
- package/types/src/cloudflare/application.d.ts +73 -0
- package/types/src/cloudflare/bindings.d.ts +33 -0
- package/types/src/cloudflare/export.d.ts +16 -0
- package/types/src/cloudflare/import.d.ts +51 -0
- package/types/src/cloudflare/maintenance.d.ts +117 -0
- package/types/src/cloudflare/names.d.ts +11 -0
- package/types/src/cloudflare/ops.d.ts +81 -0
- package/types/src/cloudflare/r2-files.d.ts +9 -0
- package/types/src/cloudflare/restore.d.ts +9 -0
- package/types/src/cloudflare/tracker.d.ts +29 -0
- package/types/src/cloudflare.d.ts +12 -18
- package/types/src/contract/app-id.d.ts +2 -0
- package/types/src/contract/artifact-schema.d.ts +2 -0
- package/types/src/contract/context.d.ts +35 -11
- package/types/src/contract/declaration.d.ts +4 -0
- package/types/src/contract/defaults.d.ts +19 -1
- package/types/src/contract/define.d.ts +20 -3
- package/types/src/contract/kit.d.ts +2 -1
- package/types/src/contract/platform.d.ts +2 -2
- package/types/src/contract/vocabulary.d.ts +9 -7
- package/types/src/disk-assets.d.ts +4 -1
- package/types/src/files/job-names.d.ts +9 -0
- package/types/src/files/kinds.d.ts +21 -14
- package/types/src/files/scan.d.ts +1 -3
- package/types/src/implement/anonymous.d.ts +2 -4
- package/types/src/implement/boot.d.ts +17 -1
- package/types/src/implement/bounded.d.ts +11 -1
- package/types/src/implement/capability.d.ts +4 -2
- package/types/src/implement/dispatch.d.ts +34 -1
- package/types/src/implement/failures.d.ts +5 -0
- package/types/src/implement/faults.d.ts +1 -0
- package/types/src/implement/index.d.ts +1 -0
- package/types/src/implement/invocation.d.ts +22 -7
- package/types/src/implement/principal.d.ts +6 -1
- package/types/src/implement/terminals.d.ts +33 -0
- package/types/src/implement/workload.d.ts +5 -0
- package/types/src/jobs/runner.d.ts +66 -2
- package/types/src/jobs/schedule.d.ts +2 -0
- package/types/src/jobs/types.d.ts +6 -0
- package/types/src/spa-fallback.d.ts +2 -0
- package/types/src/testing/endpoint-access.d.ts +37 -5
- package/types/src/testing/isolation.d.ts +1 -1
- package/types/src/testing/kit.d.ts +22 -1
- package/types/src/testing/proxy.d.ts +4 -4
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type OpsMaintenance, type OpsMode, type OpsPublishedState, type OpsStateAck } from '@fabrika/auth-core';
|
|
2
|
+
import type { InvocationAdmission, InvocationGate, InvocationKind } from '../implement/dispatch.js';
|
|
3
|
+
export declare const DRAIN_BOUND_MS: number;
|
|
4
|
+
/** The state R2 holds, and its version: the etag a conditional put names. */
|
|
5
|
+
export interface StoredMaintenance {
|
|
6
|
+
readonly state: OpsPublishedState;
|
|
7
|
+
readonly version: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Since which generation the object has written nothing, as of the published generation `generation`: kept only while
|
|
11
|
+
* it is `read-only`, `closed` or `inspect`.
|
|
12
|
+
*/
|
|
13
|
+
export interface FrozenRecord {
|
|
14
|
+
readonly generation: number;
|
|
15
|
+
readonly since: number;
|
|
16
|
+
}
|
|
17
|
+
/** The object's durable copy of its maintenance state. */
|
|
18
|
+
export interface MaintenanceStore {
|
|
19
|
+
/** `null` only for a definite not-found; every other failure throws, and is never read as absence. */
|
|
20
|
+
read(): Promise<StoredMaintenance | null>;
|
|
21
|
+
/** Puts `state` if R2 still holds `version` (`null`: holds nothing); the new version, or `null` when the condition failed. */
|
|
22
|
+
put(state: OpsPublishedState, version: string | null): Promise<string | null>;
|
|
23
|
+
/** The frozen record, `null` when none is stored. A store without these keeps the record in memory only. */
|
|
24
|
+
readFrozen?(): Promise<FrozenRecord | null>;
|
|
25
|
+
putFrozen?(record: FrozenRecord): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/** `__fabrika/ops/<object>.json` in the environment's bucket (`bucket`, an R2 binding). */
|
|
28
|
+
export declare function r2MaintenanceStore(bucket: unknown, object: string): MaintenanceStore;
|
|
29
|
+
export type TransitionResult = {
|
|
30
|
+
readonly kind: 'acknowledged';
|
|
31
|
+
readonly ack: OpsStateAck;
|
|
32
|
+
}
|
|
33
|
+
/** The 409: what R2 holds as far as the object knows, `null` before the first publication. */
|
|
34
|
+
| {
|
|
35
|
+
readonly kind: 'stale';
|
|
36
|
+
readonly published: OpsPublishedState | null;
|
|
37
|
+
}
|
|
38
|
+
/** R2 could not be read or written: the call fails and Control retries. */
|
|
39
|
+
| {
|
|
40
|
+
readonly kind: 'failed';
|
|
41
|
+
}
|
|
42
|
+
/** The caller's `frozen` held the object in `inspect`: nothing changed. */
|
|
43
|
+
| {
|
|
44
|
+
readonly kind: 'frozen';
|
|
45
|
+
};
|
|
46
|
+
export type MigrateResult<T> = {
|
|
47
|
+
readonly kind: 'migrated';
|
|
48
|
+
readonly value: T;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'stale';
|
|
51
|
+
readonly published: OpsPublishedState | null;
|
|
52
|
+
};
|
|
53
|
+
/** What a step run in the barrier's turn answers, and what keeps the turn past the answer (`null`: nothing). */
|
|
54
|
+
export interface TurnStep<T> {
|
|
55
|
+
readonly value: T;
|
|
56
|
+
readonly holdUntil: Promise<void> | null;
|
|
57
|
+
}
|
|
58
|
+
export type StepResult<T> = {
|
|
59
|
+
readonly kind: 'ran';
|
|
60
|
+
readonly value: T;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: 'stale';
|
|
63
|
+
readonly published: OpsPublishedState | null;
|
|
64
|
+
};
|
|
65
|
+
export interface BarrierOptions {
|
|
66
|
+
/** The drain's bound; `DRAIN_BOUND_MS` by default. */
|
|
67
|
+
readonly drainBoundMs?: number;
|
|
68
|
+
}
|
|
69
|
+
export declare class MaintenanceBarrier {
|
|
70
|
+
#private;
|
|
71
|
+
private constructor();
|
|
72
|
+
/** The cold start: an absent state is `open`; a failed read rejects, and the caller retries on its next request. */
|
|
73
|
+
static load(store: MaintenanceStore, options?: BarrierOptions): Promise<MaintenanceBarrier>;
|
|
74
|
+
get mode(): OpsMode;
|
|
75
|
+
view(): OpsMaintenance;
|
|
76
|
+
/** What R2 holds as far as this instance knows, `null` before the first publication: what a stale refusal names. */
|
|
77
|
+
get published(): OpsPublishedState | null;
|
|
78
|
+
/**
|
|
79
|
+
* The generation at which the object entered its current stretch of `read-only`, `closed` and `inspect`, or at which a
|
|
80
|
+
* data step last wrote within it; `null` outside such a stretch. A consistent dump is one state while it holds.
|
|
81
|
+
*/
|
|
82
|
+
get frozenSince(): number | null;
|
|
83
|
+
/**
|
|
84
|
+
* Called in a data step's turn before the step writes while the object writes nothing else (an import step, a
|
|
85
|
+
* restore's `arm`): the stretch starts again at the current generation, durably before the write. A failed put rejects.
|
|
86
|
+
*/
|
|
87
|
+
restrictedWrite(): Promise<void>;
|
|
88
|
+
/** The scope of one invocation, admitted now: the generation and mode it captures, which its writes are fenced on. */
|
|
89
|
+
event(): BarrierEvent;
|
|
90
|
+
/** Whether a write of an invocation admitted at `generation` in `mode` may commit now. */
|
|
91
|
+
writable(generation: number | null, mode: OpsMode): boolean;
|
|
92
|
+
/** Admits an invocation of `kind` captured at `generation`, or `null` when the mode refuses it or a transition followed. */
|
|
93
|
+
admit(kind: InvocationKind, generation: number | null): InvocationAdmission | null;
|
|
94
|
+
/**
|
|
95
|
+
* `POST /__fabrika/ops/state`: the transition of ADR-0069 §3, acknowledged once published and drained. `frozen` is
|
|
96
|
+
* asked in the turn, after every data step before it: while it holds, no transition leaves `inspect`.
|
|
97
|
+
*/
|
|
98
|
+
transition(requested: OpsPublishedState, frozen?: () => boolean): Promise<TransitionResult>;
|
|
99
|
+
/**
|
|
100
|
+
* `POST /__fabrika/ops/migrate`: `work` runs only under the published generation, in a mode that may migrate, and no
|
|
101
|
+
* transition runs meanwhile.
|
|
102
|
+
*/
|
|
103
|
+
migrate<T>(generation: number, work: () => Promise<T>): Promise<MigrateResult<T>>;
|
|
104
|
+
/**
|
|
105
|
+
* A data step of Control's (ADR-0070): `work` runs in the barrier's turn, only under the published `generation`, with
|
|
106
|
+
* the mode it is in. No transition runs until `work` settles, nor, when it answers one, until `holdUntil` settles.
|
|
107
|
+
*/
|
|
108
|
+
step<T>(generation: number, work: (mode: OpsMode) => Promise<TurnStep<T>>): Promise<StepResult<T>>;
|
|
109
|
+
}
|
|
110
|
+
/** One invocation's view of the barrier: the gate that admits and counts its work, and its write fence. */
|
|
111
|
+
export declare class BarrierEvent implements InvocationGate {
|
|
112
|
+
#private;
|
|
113
|
+
constructor(barrier: MaintenanceBarrier, generation: number | null, mode: OpsMode);
|
|
114
|
+
admit(kind: InvocationKind): InvocationAdmission | null;
|
|
115
|
+
/** Whether this invocation may commit a write now: still `open`, at the generation it was admitted under. */
|
|
116
|
+
writable(): boolean;
|
|
117
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The Durable Object class the Cloudflare entry exports: one object per application environment runs it (ADR-0065). */
|
|
2
|
+
export declare const CLOUDFLARE_APPLICATION_CLASS = "FabrikaApplication";
|
|
3
|
+
/** The binding through which the application's Worker reaches its object. */
|
|
4
|
+
export declare const CLOUDFLARE_APPLICATION_BINDING = "FABRIKA_APPLICATION";
|
|
5
|
+
/** The R2 bucket binding of the environment's stored files. */
|
|
6
|
+
export declare const CLOUDFLARE_FILES_BINDING = "FABRIKA_FILES";
|
|
7
|
+
/**
|
|
8
|
+
* The Workers Assets binding the SPA and link mounts serve their files from. Its directory mirrors the request paths:
|
|
9
|
+
* the mount `/admin` serves `<directory>/admin/…`, the root mount `<directory>/…`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CLOUDFLARE_ASSETS_BINDING = "ASSETS";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type ApplicationObjects, type OpsBootFailureContent, type OpsOperation } from '@fabrika/auth-core';
|
|
2
|
+
import type { SqliteCursor, SqliteStorage, SqliteValue } from '@fabrika/db/sqlite';
|
|
3
|
+
import type { SqliteMigrationBundle } from '@fabrika/db/sqlite-migrate';
|
|
4
|
+
import type { MaintenanceBarrier } from './maintenance.js';
|
|
5
|
+
/** What the view reads of the object's storage; workerd's `DurableObjectStorage` has every optional member. */
|
|
6
|
+
export interface OpsStorage {
|
|
7
|
+
readonly sql: {
|
|
8
|
+
exec(query: string, ...bindings: SqliteValue[]): SqliteCursor;
|
|
9
|
+
/** The bun:sqlite test double has no size. */
|
|
10
|
+
readonly databaseSize?: number;
|
|
11
|
+
};
|
|
12
|
+
/** The bun:sqlite test double has no alarm. */
|
|
13
|
+
getAlarm?(): Promise<number | null>;
|
|
14
|
+
/** The object's KV storage, which point-in-time recovery rewinds with its SQLite; the bun:sqlite double has none. */
|
|
15
|
+
get?(key: string): Promise<unknown>;
|
|
16
|
+
put?(key: string, value: unknown): Promise<void>;
|
|
17
|
+
/** The synchronous KV of a SQLite-backed object, in the same database; the bun:sqlite test double has none. */
|
|
18
|
+
readonly kv?: {
|
|
19
|
+
get(key: string): unknown;
|
|
20
|
+
put(key: string, value: unknown): void;
|
|
21
|
+
delete(key: string): boolean;
|
|
22
|
+
};
|
|
23
|
+
/** Wipes the object's database, its KV and its alarm; the bun:sqlite test double has none. */
|
|
24
|
+
deleteAll?(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The object's point-in-time recovery: workerd's storage bookmarks and the abort that resets the object. `null` where the
|
|
28
|
+
* storage has none (the bun:sqlite double, a runtime without PITR).
|
|
29
|
+
*/
|
|
30
|
+
export interface OpsRecovery {
|
|
31
|
+
getCurrentBookmark(): Promise<string>;
|
|
32
|
+
getBookmarkForTime(time: number): Promise<string>;
|
|
33
|
+
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
|
|
34
|
+
abort(reason: string): void;
|
|
35
|
+
}
|
|
36
|
+
/** `X-Fabrika-Endpoint` of the composed ops row, the only value an ops request may carry (ADR-0022 rule 3). */
|
|
37
|
+
export declare const OPS_ENDPOINT: string;
|
|
38
|
+
/** What the platform wrote for the ops channel: the key digests and the objects a request may name. */
|
|
39
|
+
export interface OpsAccess {
|
|
40
|
+
readonly digests: readonly Uint8Array[];
|
|
41
|
+
readonly objects: ApplicationObjects;
|
|
42
|
+
}
|
|
43
|
+
/** The environment's ops access, or `null` (an older deploy, or a malformed value), which refuses every ops request. */
|
|
44
|
+
export declare function opsAccess(env: Readonly<Record<string, unknown>>): OpsAccess | null;
|
|
45
|
+
/** What an ops request reads of the object it reached. */
|
|
46
|
+
export interface OpsTarget {
|
|
47
|
+
readonly storage: OpsStorage & SqliteStorage;
|
|
48
|
+
/** The environment's bucket (the `FABRIKA_FILES` R2 binding), where dumps and the maintenance state live. */
|
|
49
|
+
readonly bucket: unknown;
|
|
50
|
+
readonly recovery: OpsRecovery | null;
|
|
51
|
+
/** The digest of the contract this release was deployed with (`FABRIKA_CONTRACT_DIGEST`); a dump's manifest records it. */
|
|
52
|
+
readonly contractDigest: string | null;
|
|
53
|
+
/** The release's migration bundles in the order the object applies them: the framework's, then the application's. */
|
|
54
|
+
readonly migrations: readonly SqliteMigrationBundle[];
|
|
55
|
+
/**
|
|
56
|
+
* The instance's last failed boot, the application's error text included. Asked only after authentication: it
|
|
57
|
+
* waits for a boot under way and never starts one.
|
|
58
|
+
*/
|
|
59
|
+
bootFailure(): Promise<OpsBootFailureContent | null>;
|
|
60
|
+
/** The barrier of the object named `object`, read from R2 on a cold start; rejects while R2 cannot be read. */
|
|
61
|
+
maintenance(object: string): Promise<MaintenanceBarrier>;
|
|
62
|
+
/** Runs the pending migrations and boots the application; `false` when the boot failed. */
|
|
63
|
+
migrate(): Promise<boolean>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Answers an ops request the Worker forwarded with the proxy secret, which the object checked before. Authentication
|
|
67
|
+
* runs first; an unknown operation, a malformed body and an object name the list lacks are refused after it. Every
|
|
68
|
+
* operation needs the barrier, so while R2 cannot be read each answers 503.
|
|
69
|
+
*/
|
|
70
|
+
export declare function serveOps(request: Request, access: OpsAccess | null, target: OpsTarget): Promise<Response>;
|
|
71
|
+
/** The object an ops request names, read with its operation's strict parser; `null` for a body that does not parse. */
|
|
72
|
+
export declare function objectNamed(operation: OpsOperation, body: unknown): string | null;
|
|
73
|
+
/** The request's body as JSON, or `undefined` when it is none: every parser refuses `undefined`. */
|
|
74
|
+
export declare function jsonBody(request: {
|
|
75
|
+
text(): Promise<string>;
|
|
76
|
+
}): Promise<unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Control's credentials on an ops request: the row's method, its endpoint header, and a key whose digest is one the
|
|
79
|
+
* platform wrote, compared in constant time. The Worker and the object both run it; it reads nothing the body names.
|
|
80
|
+
*/
|
|
81
|
+
export declare function opsAuthenticated(request: Request, access: OpsAccess): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FileObjectStore } from '@fabrika/platform';
|
|
2
|
+
/**
|
|
3
|
+
* R2 stores a stream only when its length is known up front, which an upload's is not. A body up to this size is
|
|
4
|
+
* buffered and written in one conditional put; a longer one goes up in parts of this size, so an object holds at most
|
|
5
|
+
* one part in memory. R2 takes parts of at least 5 MiB, all but the last of one size.
|
|
6
|
+
*/
|
|
7
|
+
export declare const R2_PART_BYTES: number;
|
|
8
|
+
/** `bucket` (an R2 binding) as the files' object store, or `undefined` when the environment binds none. */
|
|
9
|
+
export declare function r2FileObjectStore(bucket: unknown): FileObjectStore | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type OpsRestoreRequest } from '@fabrika/auth-core';
|
|
2
|
+
import type { MaintenanceBarrier } from './maintenance.js';
|
|
3
|
+
import type { OpsTarget } from './ops.js';
|
|
4
|
+
/**
|
|
5
|
+
* One step of the original object's point-in-time restore (ADR-0070 §9 step 6). `prepare` and `arm` run in the
|
|
6
|
+
* barrier's turn, only under the published generation, on an object that is not the one ordinary traffic reaches
|
|
7
|
+
* (`serving`), while it is `inspect`; `verify` writes nothing and runs in any mode.
|
|
8
|
+
*/
|
|
9
|
+
export declare function serveRestore(target: OpsTarget, barrier: MaintenanceBarrier, step: OpsRestoreRequest, serving: boolean): Promise<Response>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type OpsTimersRequest, type OpsTimersView } from '@fabrika/auth-core';
|
|
2
|
+
import { type Scrubber } from '../jobs/scrub.js';
|
|
3
|
+
/** The global timers the tracker wraps while it is on; `globalThis` fits it. */
|
|
4
|
+
export interface TimerScope {
|
|
5
|
+
setTimeout(handler: unknown, delay?: unknown, ...args: unknown[]): unknown;
|
|
6
|
+
setInterval(handler: unknown, delay?: unknown, ...args: unknown[]): unknown;
|
|
7
|
+
clearTimeout(id?: unknown): void;
|
|
8
|
+
clearInterval(id?: unknown): void;
|
|
9
|
+
}
|
|
10
|
+
export interface TimerTracker {
|
|
11
|
+
/** Switches tracking on (wrapping the scope's timers) or off (restoring them and forgetting every record). */
|
|
12
|
+
track(on: boolean): void;
|
|
13
|
+
/**
|
|
14
|
+
* While tracking is on, records `promise` until it settles and answers a chain that settles as it does, rejection
|
|
15
|
+
* included, so the caller hands the chain to `waitUntil` and an unhandled rejection stays unhandled. Off, `promise`.
|
|
16
|
+
*/
|
|
17
|
+
pending<T>(promise: Promise<T>): Promise<T>;
|
|
18
|
+
/** The live records, oldest first, at most `OPS_TIMERS_CAP` of them. */
|
|
19
|
+
view(): OpsTimersView;
|
|
20
|
+
}
|
|
21
|
+
/** A tracker over `scope`'s timers, off until `track(true)`; each stack is scrubbed by `scrubber`. */
|
|
22
|
+
export declare function timerTracker(scope: TimerScope, now: () => number, scrubber: Scrubber): TimerTracker;
|
|
23
|
+
/**
|
|
24
|
+
* Records a promise an object hands to `waitUntil` while the tracker is on. Hand the answer, not `promise`, to
|
|
25
|
+
* `waitUntil`: it rejects as `promise` does, so an unhandled rejection still reaches the crash reporting.
|
|
26
|
+
*/
|
|
27
|
+
export declare function trackPending<T>(promise: Promise<T>): Promise<T>;
|
|
28
|
+
/** The isolate's live timers and `waitUntil` promises; `track` switches the isolate's tracker on or off first. */
|
|
29
|
+
export declare function serveTimers(request: OpsTimersRequest): Response;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { type ContractWorkerOptions, type ImplementationLoader } from './cloudflare/application.js';
|
|
1
2
|
import type { FetchService, RequestExecutionContext } from './fetch.js';
|
|
2
|
-
import { type CrashEvents } from './implement/crashes.js';
|
|
3
|
-
import type { ContractImplementation } from './implement/implement.js';
|
|
4
3
|
export { markProductionProcess } from '@fabrika/db/production';
|
|
4
|
+
export { type ApplicationMigration, type ApplicationState, type ApplicationStorage, type ContractWorkerOptions, FabrikaApplication, type ImplementationLoader, } from './cloudflare/application.js';
|
|
5
5
|
/** Minimal structural view of a Workers `ExecutionContext`. */
|
|
6
6
|
export interface CloudflareExecutionContext extends RequestExecutionContext {
|
|
7
7
|
passThroughOnException(): void;
|
|
@@ -28,22 +28,16 @@ export interface CloudflareWorker<Env> {
|
|
|
28
28
|
}
|
|
29
29
|
/** Adapt a runtime-neutral `{ fetch }` service to a Workers module export. */
|
|
30
30
|
export declare function createCloudflareWorker<Env>(app: FetchService<Env>, options?: CloudflareWorkerOptions<Env>): CloudflareWorker<Env>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}>;
|
|
35
|
-
export interface ContractWorkerOptions {
|
|
36
|
-
/** Where the isolate hears of an unhandled rejection; the global `unhandledrejection` event by default. */
|
|
37
|
-
readonly rejections?: CrashEvents;
|
|
38
|
-
/** What posts a report to Operations' ingest; `fetch` by default. */
|
|
39
|
-
readonly operationsFetch?: (request: Request) => Promise<Response>;
|
|
31
|
+
export interface ContractWorker {
|
|
32
|
+
fetch(request: Request, env: Readonly<Record<string, unknown>>, exec: CloudflareExecutionContext): Promise<Response>;
|
|
33
|
+
scheduled(controller: CloudflareScheduledController, env: Readonly<Record<string, unknown>>, exec: CloudflareExecutionContext): Promise<void>;
|
|
40
34
|
}
|
|
41
35
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
36
|
+
* The Worker module of a contract application, called only by the generated entrypoint, which also exports
|
|
37
|
+
* `FabrikaApplication`. The application runs in the environment's Durable Object (ADR-0065): `fetch` forwards every
|
|
38
|
+
* request to it with the proxy secret, the proxy's own headers unchanged, and `scheduled` forwards the repair tick: the
|
|
39
|
+
* object's alarm runs the jobs, and the tick repairs its wakes and arms an alarm nothing armed yet.
|
|
40
|
+
* An ops request goes to the object its body names instead (ADR-0069). The object captures the environment, imports
|
|
41
|
+
* the application and boots it.
|
|
46
42
|
*/
|
|
47
|
-
export declare function createContractWorker(load: ImplementationLoader, options?: ContractWorkerOptions):
|
|
48
|
-
fetch(request: Request, env: Readonly<Record<string, unknown>>, exec: CloudflareExecutionContext): Promise<Response>;
|
|
49
|
-
};
|
|
43
|
+
export declare function createContractWorker(load: ImplementationLoader, options?: ContractWorkerOptions): ContractWorker;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ContractArtifact, type OutputShape, type SchemaShape } from '@fabrika/auth-core';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
|
+
/** A file's object key starts with its kind: the framework keeps its own objects in the files bucket under this prefix. */
|
|
4
|
+
export declare const RESERVED_FILE_KIND_PREFIX = "__fabrika";
|
|
3
5
|
/** A `SchemaShape` read back as JSON. */
|
|
4
6
|
export declare const schemaShapeSchema: z.ZodType<SchemaShape>;
|
|
5
7
|
export declare const outputShapeSchema: z.ZodType<OutputShape>;
|
|
@@ -6,6 +6,7 @@ import type { StoredFilesHandle, StoredFilesReadHandle } from '../files/handle';
|
|
|
6
6
|
import type { AppCapability, Ref, Within } from '../implement/capability';
|
|
7
7
|
import type { ApplicationDirectory, LinkIssuing, MemberDirectory, MemberLookup, MemberManagement } from '../implement/membership';
|
|
8
8
|
import type { AppPrincipal, PrincipalOf, PublicPrincipal, ServicePrincipal } from '../implement/principal';
|
|
9
|
+
import type { TerminalIdentification } from '../implement/terminals';
|
|
9
10
|
import type { CapabilityOf, ConnectCall, RequestContext } from '../implement/types';
|
|
10
11
|
import type { WebhookDelivery, WebhookPrincipal } from '../implement/webhook';
|
|
11
12
|
import type { AppMail, JobContext } from '../jobs/types';
|
|
@@ -38,6 +39,8 @@ export interface KitTypes {
|
|
|
38
39
|
readonly manage: string;
|
|
39
40
|
readonly list: string;
|
|
40
41
|
};
|
|
42
|
+
/** Whether the vocabulary declares `terminal: { identify }`, which gives `ctx.terminals`. */
|
|
43
|
+
readonly terminal: boolean;
|
|
41
44
|
readonly index: AnyDbIndex;
|
|
42
45
|
/** The table names of `src/db/tables.ts`. */
|
|
43
46
|
readonly tables: string;
|
|
@@ -88,14 +91,24 @@ export type SqlValue = string | number | boolean | bigint | Date | null | readon
|
|
|
88
91
|
export interface SqlTag<Ix extends AnyDbIndex = AnyDbIndex, M extends SqlMode = SqlMode> {
|
|
89
92
|
<Row extends Schema>(row: Row): (text: TemplateStringsArray, ...values: readonly (SqlValue | SqlScope)[]) => Promise<z.output<Row>[]>;
|
|
90
93
|
/**
|
|
91
|
-
* The capability's whole predicate on `table
|
|
92
|
-
*
|
|
93
|
-
* `
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
94
|
+
* The capability's whole predicate on `table`: the object's key and every link of its chain for a `Ref`, what
|
|
95
|
+
* `ctx.db.within` matches for a `Within`, every row for `ctx.app`. Interpolated as
|
|
96
|
+
* `where ${ctx.sql.scope(ctx.target, 'tasks', { alias: 't' })}`, its values are bound parameters. `alias` is the
|
|
97
|
+
* table's name in the statement (the table's own by default). `use` states what the statement does with the table:
|
|
98
|
+
* `'read'` (the default) needs an action the table reads with, `'update'` or `'delete'` (a `'write'` site only) that
|
|
99
|
+
* operation's action, checked when the fragment is built. The statement is not read for where the fragment stands:
|
|
100
|
+
* using it as stated is the author's and the approver's to check. A table the capability reaches for no use of this
|
|
101
|
+
* site is a type error here.
|
|
97
102
|
*/
|
|
98
|
-
scope<C extends Ref<string, string> | Within<string, string> | AppCapability<string>, T extends FragmentTable<Ix, C, M>>(capability: C, table: T,
|
|
103
|
+
scope<C extends Ref<string, string> | Within<string, string> | AppCapability<string>, T extends FragmentTable<Ix, C, M>>(capability: C, table: T, options?: SqlScopeOptions): SqlScope;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The third argument of `ctx.sql.scope`: the table's alias in the statement, and what the statement does with it. A
|
|
107
|
+
* `'read'` site's `ctx.sql` is refused `'update'` and `'delete'` at run time; a `'write'` site's stays assignable to it.
|
|
108
|
+
*/
|
|
109
|
+
export interface SqlScopeOptions {
|
|
110
|
+
readonly alias?: string;
|
|
111
|
+
readonly use?: 'read' | 'update' | 'delete';
|
|
99
112
|
}
|
|
100
113
|
declare const sqlScope: unique symbol;
|
|
101
114
|
/** What `ctx.sql.scope(…)` builds: only the framework makes one, and only its own tag takes it. */
|
|
@@ -329,8 +342,14 @@ type ConnectContext<K extends KitTypes, Cn extends readonly string[]> = [Cn] ext
|
|
|
329
342
|
readonly [N in Cn[number]]: ConnectorOf<K['imports'][N]>;
|
|
330
343
|
};
|
|
331
344
|
};
|
|
345
|
+
/** `ctx.terminals`, where the vocabulary declares the terminal identification page. */
|
|
346
|
+
type TerminalsContext<K extends KitTypes> = K['terminal'] extends true ? {
|
|
347
|
+
readonly terminals: TerminalIdentification;
|
|
348
|
+
} : {
|
|
349
|
+
readonly terminals: Unavailable<"the application declares no terminal: terminal: { identify: '/identify' } in the vocabulary">;
|
|
350
|
+
};
|
|
332
351
|
/** What the handler of an RPC endpoint receives, for mount callers `Caller`, kind `Kind` and its declaration. */
|
|
333
|
-
export type EndpointContext<K extends KitTypes, Caller extends RpcCaller, Kind extends DataKind, Acc, D extends Declared<SqlMode, unknown, readonly string[], string>> = RequestContext<PrincipalOf<Caller>> & CapabilityContext<Acc> & MembersContext<K, Acc> & LinksContext<Acc, Of<D, 'issues'>> & ConnectContext<K, Of<D, 'connect'>> & SqlContext<Of<D, 'sql'>, K['index']> & FilesContext<K['index'], Kind> & {
|
|
352
|
+
export type EndpointContext<K extends KitTypes, Caller extends RpcCaller, Kind extends DataKind, Acc, D extends Declared<SqlMode, unknown, readonly string[], string>> = RequestContext<PrincipalOf<Caller>> & CapabilityContext<Acc> & MembersContext<K, Acc> & LinksContext<Acc, Of<D, 'issues'>> & ConnectContext<K, Of<D, 'connect'>> & TerminalsContext<K> & SqlContext<Of<D, 'sql'>, K['index']> & FilesContext<K['index'], Kind> & {
|
|
334
353
|
readonly db: DataOf<K['index'], EndpointData<K['index'], Kind, Acc, Of<D, 'unscoped'>>>;
|
|
335
354
|
} & NoMail;
|
|
336
355
|
type PublicOnly = 'a public procedure acts application-wide, as its own workload: ctx.app(<action>) and ctx.db.app(<action>)';
|
|
@@ -350,7 +369,7 @@ export type PublicContext<K extends KitTypes, Kind extends DataKind, Acts extend
|
|
|
350
369
|
/** The stored files: a public mutation puts one, and both open one this request holds. */
|
|
351
370
|
readonly files: Kind extends 'query' ? StoredFilesReadHandle : StoredFilesHandle;
|
|
352
371
|
readonly sql: Unavailable<'a public procedure reaches its actions only: it declares no sql'>;
|
|
353
|
-
} & {
|
|
372
|
+
} & TerminalsContext<K> & {
|
|
354
373
|
readonly db: DataOf<K['index'], {
|
|
355
374
|
app<const A extends Acts>(action: A): PublicApplicationTables<K['index'], A, Kind>;
|
|
356
375
|
readonly target: Unavailable<PublicOnly>;
|
|
@@ -360,13 +379,18 @@ export type PublicContext<K extends KitTypes, Kind extends DataKind, Acts extend
|
|
|
360
379
|
} & NoMail;
|
|
361
380
|
/**
|
|
362
381
|
* `ctx.kick('<job>')` of a site that declares `kicks`: the job runs in the background after the site's transaction
|
|
363
|
-
* committed, once however often it is kicked, and not at all on a rollback.
|
|
382
|
+
* committed, once however often it is kicked, and not at all on a rollback. `ctx.kick('<job>', { at })` runs it at `at`
|
|
383
|
+
* instead. Either way the kick is a durable wake written in the site's transaction, and it carries nothing.
|
|
364
384
|
*/
|
|
365
385
|
export type KickContext<Ks> = [Ks] extends [never] ? {
|
|
366
386
|
readonly kick: Unavailable<"declare kicks: ['<cron job>'] on this site to kick a job after its commit">;
|
|
367
387
|
} : Ks extends readonly (infer N extends string)[] ? {
|
|
368
|
-
kick(job: N): void;
|
|
388
|
+
kick(job: N, options?: KickOptions): void;
|
|
369
389
|
} : never;
|
|
390
|
+
/** When a kicked job runs: at `at`, a `Date`; without options, as soon as the site committed. */
|
|
391
|
+
export interface KickOptions {
|
|
392
|
+
readonly at: Date;
|
|
393
|
+
}
|
|
370
394
|
/** `ctx.tokens.sign('<purpose>', claims, { days })` of a site that declares `signs`: a token of one of those purposes. */
|
|
371
395
|
export type TokensContext<K extends KitTypes, Sg> = [Sg] extends [never] ? {
|
|
372
396
|
readonly tokens: Unavailable<"declare signs: ['<token purpose>'] on this site to sign its tokens">;
|
|
@@ -24,6 +24,10 @@ export interface ContractDeclaration<S> {
|
|
|
24
24
|
};
|
|
25
25
|
/** `'labels'` only; `buildArtifact` refuses another value, and refuses it without `members`. */
|
|
26
26
|
readonly directory?: string;
|
|
27
|
+
/** The identification page of a terminal; `buildArtifact` refuses a path a public SPA mount does not serve. */
|
|
28
|
+
readonly terminal?: {
|
|
29
|
+
readonly identify: string;
|
|
30
|
+
};
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
33
|
* The keys of the object `defineContract`'s callback returns that are sections, not mounts. Every other key is a
|
|
@@ -22,6 +22,16 @@ export declare const PROCEDURE_LIMITS: {
|
|
|
22
22
|
/** The headers of one part of a multipart body, at most. */
|
|
23
23
|
readonly maxPartHeaderBytes: number;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* The slowest body a procedure or a webhook waits for: its deadline is `maxBytes` at `bytesPerSecond`, `minMs` at least.
|
|
27
|
+
* The handler's own `timeoutMs` starts after the last byte, so the approval diff names both.
|
|
28
|
+
*/
|
|
29
|
+
export declare const BODY_DEADLINE: {
|
|
30
|
+
readonly bytesPerSecond: number;
|
|
31
|
+
readonly minMs: 30000;
|
|
32
|
+
};
|
|
33
|
+
/** How long a body of at most `maxBytes` may take to arrive. */
|
|
34
|
+
export declare function bodyDeadlineMs(maxBytes: number): number;
|
|
25
35
|
/**
|
|
26
36
|
* A procedure with file fields is `multipart/form-data`: its JSON input travels in the first part, named `input`, and
|
|
27
37
|
* each file in a part named after its field. A field of several files sends one part per file, under its name.
|
|
@@ -37,7 +47,15 @@ export declare const WEBHOOK_LIMITS: {
|
|
|
37
47
|
readonly maxMaxBytes: number;
|
|
38
48
|
readonly timeoutMs: 10000;
|
|
39
49
|
};
|
|
40
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* The longest job segment on Cloudflare: setup, one attempt and its finish. A framework policy inside the 15 minutes
|
|
52
|
+
* `waitUntil` keeps an object alive, not a platform guarantee; longer work chunks through claims.
|
|
53
|
+
*/
|
|
54
|
+
export declare const CLOUDFLARE_MAX_JOB_SEGMENT_MS: number;
|
|
55
|
+
/**
|
|
56
|
+
* A job attempt's time limit (`limits.timeoutMs`) and its ceiling, which keeps a lease and a timer within a day. The
|
|
57
|
+
* default is one Cloudflare segment, so a job that declares no limit deploys on either provider.
|
|
58
|
+
*/
|
|
41
59
|
export declare const JOB_LIMITS: {
|
|
42
60
|
readonly timeoutMs: number;
|
|
43
61
|
readonly maxTimeoutMs: number;
|
|
@@ -3,7 +3,9 @@ import type { z } from 'zod/v4';
|
|
|
3
3
|
import { type CronDeclaration, type CspDeclaration, type ExportAccessDeclaration, type ExportDeclaration, type FileKindDeclaration, type HealthMountDeclaration, type ImportDeclaration, type LinkAccessDeclaration, type LinkMountDeclaration, type ProcedureDeclaration, type ProcedureTreeDeclaration, type ProcedureType, type RpcMountDeclaration, type SpaAccessDeclaration, type SpaMountDeclaration, type WebhookMountDeclaration } from './declaration';
|
|
4
4
|
import type { TokenPurposes } from './token';
|
|
5
5
|
export type Path = `/${string}`;
|
|
6
|
-
/**
|
|
6
|
+
/** Whether `value` is written as a `Path`; what `buildArtifact` refuses of one is a separate check. */
|
|
7
|
+
export declare function isPath(value: string): value is Path;
|
|
8
|
+
/** A job attempt's time limit: 14 minutes by default, at most a day. A job reads no body, so it has no `maxBytes`. */
|
|
7
9
|
export interface JobLimitsOption {
|
|
8
10
|
readonly timeoutMs?: number;
|
|
9
11
|
}
|
|
@@ -63,7 +65,7 @@ export interface RoleDef<A extends string, D extends string, R extends string> {
|
|
|
63
65
|
*/
|
|
64
66
|
readonly external?: true;
|
|
65
67
|
}
|
|
66
|
-
export interface Vocabulary<A extends string, D extends string, R extends string> extends Presentation, AppPeople<A
|
|
68
|
+
export interface Vocabulary<A extends string, D extends string, R extends string> extends Presentation, AppPeople<A>, AppTerminal {
|
|
67
69
|
readonly app: string;
|
|
68
70
|
readonly dimensions: {
|
|
69
71
|
readonly [K in D]: DimensionDef<A, D, R>;
|
|
@@ -92,6 +94,21 @@ export interface AppPeople<A extends string> {
|
|
|
92
94
|
}
|
|
93
95
|
/** A vocabulary's people fields, copied one by one: each exists only when declared. */
|
|
94
96
|
export declare function peopleOf<A extends string>(vocabulary: AppPeople<A>): AppPeople<A>;
|
|
97
|
+
/** The page that identifies a person at an enrolled terminal (ADR-0067). */
|
|
98
|
+
export interface TerminalDeclaration {
|
|
99
|
+
/** An absolute path on the application's own origin, served by a public SPA mount; IAM appends `?identification=<id>`. */
|
|
100
|
+
readonly identify: Path;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* `terminal: { identify: '/identify' }`: the application identifies a person at an enrolled terminal on that page and
|
|
104
|
+
* asserts who stands there (`ctx.terminals`). IAM sends a terminal's browser there only for an application its
|
|
105
|
+
* administrator lists on the terminal. A reviewed declaration.
|
|
106
|
+
*/
|
|
107
|
+
export interface AppTerminal {
|
|
108
|
+
readonly terminal?: TerminalDeclaration;
|
|
109
|
+
}
|
|
110
|
+
/** A vocabulary's terminal, copied field by field: it exists only when declared. */
|
|
111
|
+
export declare function terminalOf(vocabulary: AppTerminal): AppTerminal;
|
|
95
112
|
/** How IAM names the application to a person: on its sign-in, password and invitation pages, and in its e-mails. */
|
|
96
113
|
export interface Presentation {
|
|
97
114
|
/** The language of those pages and e-mails; absent, the installation's default. */
|
|
@@ -346,7 +363,7 @@ export declare function surfaceKit<A extends string, D extends string, CD extend
|
|
|
346
363
|
*/
|
|
347
364
|
export declare function defineContract<const A extends string, const D extends string, const R extends string, const Dims extends {
|
|
348
365
|
readonly [K in D]: DimensionDef<NoInfer<A>, NoInfer<D>, NoInfer<R>>;
|
|
349
|
-
}, const S extends Surface>(vocabulary: Presentation & AppPeople<NoInfer<A>> & {
|
|
366
|
+
}, const S extends Surface>(vocabulary: Presentation & AppPeople<NoInfer<A>> & AppTerminal & {
|
|
350
367
|
readonly app: string;
|
|
351
368
|
readonly dimensions: Dims & {
|
|
352
369
|
readonly [K in D]: DimensionDef<NoInfer<A>, NoInfer<D>, NoInfer<R>>;
|
|
@@ -12,13 +12,14 @@ type Owned<K extends string> = {
|
|
|
12
12
|
readonly [P in K]?: never;
|
|
13
13
|
};
|
|
14
14
|
/** The kit's types, computed once from the vocabulary, the tables' index, the imports and the token purposes. */
|
|
15
|
-
export type KitOf<V, Ix, Imp extends KitImports, Tk extends TokenPurposes = Record<never, never>> = V extends AppVocabulary<infer A, infer D, infer R, infer Dims, infer M> ? {
|
|
15
|
+
export type KitOf<V, Ix, Imp extends KitImports, Tk extends TokenPurposes = Record<never, never>> = V extends AppVocabulary<infer A, infer D, infer R, infer Dims, infer M, infer T> ? {
|
|
16
16
|
readonly action: A;
|
|
17
17
|
readonly dimension: D;
|
|
18
18
|
readonly creatable: CreatableDimension<Dims>;
|
|
19
19
|
readonly role: R;
|
|
20
20
|
readonly dimensions: Dims;
|
|
21
21
|
readonly members: M;
|
|
22
|
+
readonly terminal: [T] extends [never] ? false : true;
|
|
22
23
|
readonly index: Ix;
|
|
23
24
|
readonly tables: Ix extends {
|
|
24
25
|
readonly tables: infer T;
|
|
@@ -2,8 +2,8 @@ import { type AppSchema, type ContractArtifact } from '@fabrika/auth-core';
|
|
|
2
2
|
/**
|
|
3
3
|
* The IAM vocabulary of a contract application, marked `contract` so IAM refuses every wildcard written for it: the
|
|
4
4
|
* dimensions as scopes with their container, creator role and members actions; the actions; the roles, a membership
|
|
5
|
-
* role with its scope and the roles that may assign it; the link mounts; the delegations; the workloads;
|
|
6
|
-
* display name and e-mail wording IAM names the application with. Every artifact
|
|
5
|
+
* role with its scope and the roles that may assign it; the link mounts; the delegations; the workloads; the locale,
|
|
6
|
+
* display name and e-mail wording IAM names the application with; and its terminal identification page. Every artifact
|
|
7
7
|
* dimension is a scope, a file collection's `file:<name>` included, because access to a file is checked there.
|
|
8
8
|
*/
|
|
9
9
|
export declare function schemaFromContract(artifact: ContractArtifact): AppSchema;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { type AppMembers, type DimensionDef, type Presentation, type RoleDefs, type Vocabulary, type WildcardMessage } from './define';
|
|
1
|
+
import { type AppMembers, type DimensionDef, type Presentation, type RoleDefs, type TerminalDeclaration, type Vocabulary, type WildcardMessage } from './define';
|
|
2
2
|
/**
|
|
3
|
-
* The vocabulary as `defineVocabulary` returned it, with its literal names, dimension definitions
|
|
4
|
-
* people (`M`, `never` when it declares none).
|
|
3
|
+
* The vocabulary as `defineVocabulary` returned it, with its literal names, dimension definitions, the actions of its
|
|
4
|
+
* people (`M`, `never` when it declares none) and its terminal (`T`, `never` when it declares none).
|
|
5
5
|
*/
|
|
6
|
-
export interface AppVocabulary<A extends string, D extends string, R extends string, Dims, M extends AppMembers<A> = never> extends Vocabulary<A, D, R> {
|
|
6
|
+
export interface AppVocabulary<A extends string, D extends string, R extends string, Dims, M extends AppMembers<A> = never, T extends TerminalDeclaration = never> extends Vocabulary<A, D, R> {
|
|
7
7
|
readonly dimensions: Dims & {
|
|
8
8
|
readonly [K in D]: DimensionDef<A, D, R>;
|
|
9
9
|
};
|
|
10
10
|
readonly members?: M;
|
|
11
|
+
readonly terminal?: T;
|
|
11
12
|
}
|
|
12
|
-
export type AnyAppVocabulary = AppVocabulary<string, string, string, unknown, AppMembers<string
|
|
13
|
+
export type AnyAppVocabulary = AppVocabulary<string, string, string, unknown, AppMembers<string>, TerminalDeclaration>;
|
|
13
14
|
/**
|
|
14
15
|
* Declares the dimensions, actions and roles, and how IAM names the application (`locale`, `displayName`). `src/vocabulary.ts` exports it; `defineTables`, `defineApp` and the
|
|
15
16
|
* contract take it, so each name is written once.
|
|
16
17
|
*/
|
|
17
18
|
export declare function defineVocabulary<const A extends string, const D extends string, const R extends string, const Dims extends {
|
|
18
19
|
readonly [K in D]: DimensionDef<NoInfer<A>, NoInfer<D>, NoInfer<R>>;
|
|
19
|
-
}, const M extends AppMembers<NoInfer<A>> = never>(vocabulary: Presentation & {
|
|
20
|
+
}, const M extends AppMembers<NoInfer<A>> = never, const T extends TerminalDeclaration = never>(vocabulary: Presentation & {
|
|
20
21
|
readonly app: string;
|
|
21
22
|
readonly dimensions: Dims & {
|
|
22
23
|
readonly [K in D]: DimensionDef<NoInfer<A>, NoInfer<D>, NoInfer<R>>;
|
|
@@ -27,4 +28,5 @@ export declare function defineVocabulary<const A extends string, const D extends
|
|
|
27
28
|
readonly roles: RoleDefs<NoInfer<A>, NoInfer<D>, R>;
|
|
28
29
|
readonly members?: M;
|
|
29
30
|
readonly directory?: 'labels';
|
|
30
|
-
|
|
31
|
+
readonly terminal?: T;
|
|
32
|
+
}): AppVocabulary<A, D, R, Dims, M, T>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { SpaAssets } from './implement/dispatch.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Serves each SPA mount from its build directory under `root`; a page route that names no file gets the SPA's
|
|
4
|
+
* `index.html` (`isPageRoute`), and a missing asset is 404.
|
|
5
|
+
*/
|
|
3
6
|
export declare function diskAssets(root: string): SpaAssets;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The reserved name of the scan job: a `c.cron` job name cannot contain `-`, so no application job takes it. */
|
|
2
|
+
export declare const FILE_SCAN_JOB = "fabrika-file-scan";
|
|
3
|
+
export declare const FILE_SCAN_SCHEDULE = "* * * * *";
|
|
4
|
+
/**
|
|
5
|
+
* The framework's sweep job: hourly, it deletes the files no declared column references and the pending ones past the
|
|
6
|
+
* grace, so none waits for the next request. A reserved name with `-`, which no `c.cron` name can take.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FILE_SWEEP_JOB = "fabrika-file-sweep";
|
|
9
|
+
export declare const FILE_SWEEP_SCHEDULE = "41 * * * *";
|