@fabrika/app 0.9.0-dev.1 → 0.9.0-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -26
- package/skill/SKILL.md +46 -15
- package/skill/references/app-setup.md +43 -12
- package/skill/references/dev.md +5 -2
- package/skill/references/endpoint.md +39 -28
- package/skill/references/errors.md +50 -37
- package/skill/references/files.md +8 -4
- package/skill/references/jobs.md +39 -7
- package/skill/references/table-and-migration.md +47 -3
- package/skill/references/tests.md +73 -16
- 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 +888 -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/capability-cases.ts +30 -0
- package/src/contract/compile.ts +1 -0
- package/src/contract/containers.ts +19 -0
- package/src/contract/context.ts +35 -9
- package/src/contract/declaration.ts +2 -0
- package/src/contract/defaults.ts +27 -4
- package/src/contract/define.ts +29 -3
- package/src/contract/index.ts +1 -0
- package/src/contract/kit.ts +4 -1
- package/src/contract/platform.ts +3 -2
- package/src/contract/vocabulary.ts +26 -8
- package/src/dev/changes.ts +5 -43
- package/src/dev/contract-digest.ts +17 -0
- package/src/dev/index.ts +1 -1
- package/src/dev/launcher.ts +197 -41
- package/src/dev/output.ts +13 -3
- package/src/dev/wire.ts +11 -1
- package/src/disk-assets.ts +8 -3
- package/src/files/archive.ts +2 -2
- package/src/files/handle.ts +2 -1
- package/src/files/job-names.ts +12 -0
- package/src/files/kinds.ts +74 -32
- 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 +84 -27
- package/src/implement/bounded.ts +21 -2
- package/src/implement/capability.ts +16 -4
- package/src/implement/dispatch.ts +423 -178
- package/src/implement/failures.ts +59 -4
- package/src/implement/faults.ts +5 -1
- package/src/implement/index.ts +1 -0
- package/src/implement/invocation.ts +62 -11
- package/src/implement/principal.ts +25 -2
- package/src/implement/terminals.ts +93 -0
- package/src/implement/tokens.ts +4 -2
- package/src/implement/types.ts +22 -4
- 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 +702 -126
- 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 +493 -202
- package/src/testing/index.ts +1 -1
- package/src/testing/isolation.ts +8 -1
- package/src/testing/kit.ts +86 -4
- package/src/testing/policy-isolation.ts +2 -2
- package/src/testing/proxy.ts +15 -10
- package/types/src/agent-skill.d.ts +29 -0
- package/types/src/build-recipe.d.ts +70 -0
- package/types/src/build.d.ts +29 -0
- package/types/src/bun.d.ts +99 -0
- package/types/src/client/caller.d.ts +19 -0
- package/types/src/client/contract.d.ts +131 -0
- package/types/src/client/error-reporting.d.ts +66 -0
- package/types/src/client/index.d.ts +4 -0
- package/types/src/client/rpc.d.ts +14 -0
- package/types/src/client/share.d.ts +2 -0
- package/types/src/client/transport.d.ts +42 -0
- 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 +47 -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 +43 -0
- package/types/src/contract/app-id.d.ts +2 -0
- package/types/src/contract/artifact-schema.d.ts +10 -0
- package/types/src/contract/attachment.d.ts +41 -0
- package/types/src/contract/build.d.ts +12 -0
- package/types/src/contract/capability-cases.d.ts +9 -0
- package/types/src/contract/compile.d.ts +11 -0
- package/types/src/contract/connect.d.ts +51 -0
- package/types/src/contract/containers.d.ts +3 -0
- package/types/src/contract/context.d.ts +525 -0
- package/types/src/contract/declaration.d.ts +307 -0
- package/types/src/contract/defaults.d.ts +228 -0
- package/types/src/contract/define.d.ts +376 -0
- package/types/src/contract/file.d.ts +44 -0
- package/types/src/contract/group.d.ts +274 -0
- package/types/src/contract/handled.d.ts +18 -0
- package/types/src/contract/index.d.ts +20 -0
- package/types/src/contract/kit.d.ts +211 -0
- package/types/src/contract/platform.d.ts +9 -0
- package/types/src/contract/problems.d.ts +14 -0
- package/types/src/contract/redirect.d.ts +25 -0
- package/types/src/contract/schema-from-shape.d.ts +10 -0
- package/types/src/contract/schema-shape.d.ts +5 -0
- package/types/src/contract/snapshot-source.d.ts +15 -0
- package/types/src/contract/token.d.ts +58 -0
- package/types/src/contract/vocabulary.d.ts +32 -0
- package/types/src/contract/webhook-binding.d.ts +24 -0
- package/types/src/contract/webhook-scheme.d.ts +23 -0
- package/types/src/dev/changes.d.ts +7 -0
- package/types/src/dev/contract-digest.d.ts +1 -0
- package/types/src/dev/index.d.ts +2 -0
- package/types/src/dev/launcher.d.ts +32 -0
- package/types/src/dev/output.d.ts +28 -0
- package/types/src/dev/wire.d.ts +126 -0
- package/types/src/disk-assets.d.ts +6 -0
- package/types/src/errors.d.ts +46 -0
- package/types/src/fetch.d.ts +7 -0
- package/types/src/files/archive.d.ts +26 -0
- package/types/src/files/clamscan.d.ts +32 -0
- package/types/src/files/handle.d.ts +107 -0
- package/types/src/files/job-names.d.ts +9 -0
- package/types/src/files/kinds.d.ts +112 -0
- package/types/src/files/scan.d.ts +78 -0
- package/types/src/files/sniff.d.ts +7 -0
- package/types/src/files/streams.d.ts +17 -0
- package/types/src/files/treatment.d.ts +18 -0
- package/types/src/from-row.d.ts +20 -0
- package/types/src/honeypot.d.ts +2 -0
- package/types/src/implement/anonymous.d.ts +24 -0
- package/types/src/implement/attachment.d.ts +14 -0
- package/types/src/implement/boot.d.ts +128 -0
- package/types/src/implement/bounded.d.ts +32 -0
- package/types/src/implement/browser-config.d.ts +19 -0
- package/types/src/implement/capability.d.ts +142 -0
- package/types/src/implement/challenge.d.ts +75 -0
- package/types/src/implement/client-address.d.ts +11 -0
- package/types/src/implement/connect.d.ts +67 -0
- package/types/src/implement/crashes.d.ts +31 -0
- package/types/src/implement/dispatch.d.ts +251 -0
- package/types/src/implement/egress.d.ts +14 -0
- package/types/src/implement/environment.d.ts +14 -0
- package/types/src/implement/failures.d.ts +58 -0
- package/types/src/implement/faults.d.ts +48 -0
- package/types/src/implement/headers.d.ts +7 -0
- package/types/src/implement/implement.d.ts +58 -0
- package/types/src/implement/index.d.ts +25 -0
- package/types/src/implement/invocation.d.ts +136 -0
- package/types/src/implement/membership.d.ts +201 -0
- package/types/src/implement/multipart.d.ts +36 -0
- package/types/src/implement/params.d.ts +7 -0
- package/types/src/implement/principal.d.ts +57 -0
- package/types/src/implement/project.d.ts +11 -0
- package/types/src/implement/public.d.ts +61 -0
- package/types/src/implement/serve.d.ts +25 -0
- package/types/src/implement/terminals.d.ts +33 -0
- package/types/src/implement/tokens.d.ts +49 -0
- package/types/src/implement/types.d.ts +263 -0
- package/types/src/implement/urls.d.ts +15 -0
- package/types/src/implement/verifiers.d.ts +19 -0
- package/types/src/implement/webhook.d.ts +55 -0
- package/types/src/implement/workload.d.ts +61 -0
- package/types/src/implement/xlsx.d.ts +6 -0
- package/types/src/index.d.ts +12 -0
- package/types/src/jobs/exception.d.ts +40 -0
- package/types/src/jobs/mail.d.ts +67 -0
- package/types/src/jobs/report.d.ts +56 -0
- package/types/src/jobs/runner.d.ts +218 -0
- package/types/src/jobs/schedule.d.ts +17 -0
- package/types/src/jobs/scrub.d.ts +12 -0
- package/types/src/jobs/types.d.ts +98 -0
- package/types/src/react/caller.d.ts +30 -0
- package/types/src/react/errors.d.ts +40 -0
- package/types/src/react/hooks.d.ts +110 -0
- package/types/src/react/index.d.ts +5 -0
- package/types/src/react/provider.d.ts +58 -0
- package/types/src/react/store.d.ts +68 -0
- package/types/src/react/testing.d.ts +28 -0
- package/types/src/react/types.d.ts +33 -0
- package/types/src/rpc/builder.d.ts +52 -0
- package/types/src/rpc/contract.d.ts +23 -0
- package/types/src/rpc/dispatcher.d.ts +11 -0
- package/types/src/rpc/types.d.ts +62 -0
- package/types/src/service/define.d.ts +42 -0
- package/types/src/service/index.d.ts +3 -0
- package/types/src/service/serve.d.ts +28 -0
- package/types/src/spa-fallback.d.ts +2 -0
- package/types/src/standard-schema.d.ts +55 -0
- package/types/src/testing/caller.d.ts +95 -0
- package/types/src/testing/challenge.d.ts +11 -0
- package/types/src/testing/dev.d.ts +97 -0
- package/types/src/testing/endpoint-access.d.ts +132 -0
- package/types/src/testing/index.d.ts +12 -0
- package/types/src/testing/isolation.d.ts +3 -0
- package/types/src/testing/kit.d.ts +207 -0
- package/types/src/testing/membership.d.ts +132 -0
- package/types/src/testing/policy-isolation.d.ts +113 -0
- package/types/src/testing/preload.d.ts +1 -0
- package/types/src/testing/proxy.d.ts +40 -0
- package/types/src/testing/runner.d.ts +8 -0
- package/types/src/testing/sample-file.d.ts +5 -0
- package/types/src/testing/status.d.ts +4 -0
- package/types/src/undumpable.d.ts +5 -0
package/src/testing/index.ts
CHANGED
|
@@ -7,8 +7,8 @@ export type { IamMembershipRpc } from '@fabrika/auth-core'
|
|
|
7
7
|
export { type MemoryEmail, MemoryEmailSender, type MemoryHandoff } from '@fabrika/email/memory'
|
|
8
8
|
export type { FileScanner } from '../files/scan'
|
|
9
9
|
export type { ChallengeFetch } from '../implement/challenge'
|
|
10
|
+
export type { HandlerErrorSink } from '../implement/failures'
|
|
10
11
|
export { mailKeyPrefix, type MailKeyScope, transportMailKey } from '../jobs/mail'
|
|
11
|
-
export type { HandlerErrorSink } from '../jobs/runner'
|
|
12
12
|
export type {
|
|
13
13
|
LabelledTestCaller,
|
|
14
14
|
LinkTestCaller,
|
package/src/testing/isolation.ts
CHANGED
|
@@ -6,7 +6,14 @@ import { refuseInProduction } from '@fabrika/db/production'
|
|
|
6
6
|
|
|
7
7
|
refuseInProduction('@fabrika/app/testing/isolation')
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
type DeniedOutcome,
|
|
11
|
+
type EndpointAccessKit,
|
|
12
|
+
endpointAccessKit,
|
|
13
|
+
type EndpointAccessOptions,
|
|
14
|
+
type LeakOutcome,
|
|
15
|
+
type ReachOutcome,
|
|
16
|
+
} from './endpoint-access'
|
|
10
17
|
export {
|
|
11
18
|
type AppCaller,
|
|
12
19
|
type AppCountOutcome,
|
package/src/testing/kit.ts
CHANGED
|
@@ -16,18 +16,22 @@ import {
|
|
|
16
16
|
FABRIKA_IAM_ISSUER,
|
|
17
17
|
FABRIKA_TOKEN_KEYS,
|
|
18
18
|
type IamMembershipRpc,
|
|
19
|
+
type IamTerminalRpc,
|
|
19
20
|
isNormalizedMailbox,
|
|
20
21
|
type Jwks,
|
|
21
22
|
MAX_ACCESS_TOKEN_BYTES,
|
|
23
|
+
MAX_APPLICATION_TOKEN_BYTES,
|
|
22
24
|
normalizeEmailIdentity,
|
|
23
25
|
type PermissionEntry,
|
|
24
26
|
PROXY_TOKEN_HEADER,
|
|
25
27
|
SESSION_COOKIE,
|
|
28
|
+
type TerminalFailure,
|
|
26
29
|
TOKEN_ALG,
|
|
27
30
|
UNTRUSTED_FORWARD_HEADERS,
|
|
28
31
|
workloadKeyVariable,
|
|
29
32
|
} from '@fabrika/auth-core'
|
|
30
33
|
import type { Database } from '@fabrika/db'
|
|
34
|
+
import { frameworkTablesOf, type LeaseFence } from '@fabrika/db/framework'
|
|
31
35
|
import { refuseInProduction } from '@fabrika/db/production'
|
|
32
36
|
import { MemoryEmailSender } from '@fabrika/email/memory'
|
|
33
37
|
import type { FileObjectStore } from '@fabrika/platform'
|
|
@@ -49,11 +53,11 @@ import { boot, type BootOptions, type ContractApp } from '../implement/boot'
|
|
|
49
53
|
import { type ChallengeFetch, MINIMAL_CHALLENGE_WORK } from '../implement/challenge'
|
|
50
54
|
import { type ConnectFetch, connectVariables } from '../implement/connect'
|
|
51
55
|
import type { SpaAssets } from '../implement/dispatch'
|
|
56
|
+
import type { HandlerErrorSink } from '../implement/failures'
|
|
52
57
|
import type { ApplicationEnvironment, ContractImplementation } from '../implement/implement'
|
|
53
58
|
import { readTokenKeys, SignedTokens } from '../implement/tokens'
|
|
54
59
|
import type { WorkloadKindOf, WorkloadTokenSource } from '../implement/workload'
|
|
55
60
|
import type { MailKeyScope } from '../jobs/mail'
|
|
56
|
-
import type { HandlerErrorSink } from '../jobs/runner'
|
|
57
61
|
import type { JobRunOptions, JobRunResult } from '../jobs/runner'
|
|
58
62
|
import {
|
|
59
63
|
type LabelledTestCaller,
|
|
@@ -78,6 +82,14 @@ import {
|
|
|
78
82
|
import { endpointProxy } from './proxy'
|
|
79
83
|
|
|
80
84
|
export const TEST_ISSUER = 'https://iam.test'
|
|
85
|
+
|
|
86
|
+
/** The kit's IAM without a terminal: no identification is open, so every one is `not_found`. */
|
|
87
|
+
const noIdentification = (): Promise<TerminalFailure> => Promise.resolve({ ok: false, reason: 'not_found' })
|
|
88
|
+
const NO_IDENTIFICATIONS: IamTerminalRpc = Object.freeze({
|
|
89
|
+
inspectIdentification: noIdentification,
|
|
90
|
+
assertIdentity: noIdentification,
|
|
91
|
+
cancelIdentification: noIdentification,
|
|
92
|
+
})
|
|
81
93
|
export const TEST_ENVIRONMENT = 'test'
|
|
82
94
|
const KEY_ID = 'test-key'
|
|
83
95
|
const TOKEN_TTL_SECONDS = 300
|
|
@@ -112,6 +124,11 @@ export interface TestKitOptions {
|
|
|
112
124
|
* kit's proxy obtains each delegation grant from it. Without it the kit's IAM answers them under IAM's rules.
|
|
113
125
|
*/
|
|
114
126
|
readonly membership?: IamMembershipRpc
|
|
127
|
+
/**
|
|
128
|
+
* IAM's identifications at a terminal (ADR-0067), for a contract that declares one. Without it the kit's IAM knows no
|
|
129
|
+
* open identification: `inspect` answers null and `assert` `not_found`.
|
|
130
|
+
*/
|
|
131
|
+
readonly terminals?: IamTerminalRpc
|
|
115
132
|
/**
|
|
116
133
|
* Each import's owner, by the import's name: its origin and edge key, which the platform writes as the import's
|
|
117
134
|
* framework variables, and how a request reaches it — usually the owner kit's `fetch`.
|
|
@@ -119,7 +136,11 @@ export interface TestKitOptions {
|
|
|
119
136
|
readonly connect?: Readonly<Record<string, TestConnection>>
|
|
120
137
|
/** What answers a public procedure's challenge verification in place of the provider: a stand-in for its siteverify. */
|
|
121
138
|
readonly challengeFetch?: ChallengeFetch
|
|
122
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Where the author's own run shows what a request's 5xx or a job attempt threw, whole: a handler's own error, or a
|
|
141
|
+
* framework failure (a refused `ctx.sql`, a capability refusal, a `ServerFault`) whose message the log line withholds.
|
|
142
|
+
* `fabrika app dev` sets it; a test passes one to see why a call failed. Off unless passed.
|
|
143
|
+
*/
|
|
123
144
|
readonly revealHandlerErrors?: HandlerErrorSink
|
|
124
145
|
/**
|
|
125
146
|
* The stand-in for every job's mail transport; a new `MemoryEmailSender` by default. Pass one with other capabilities
|
|
@@ -181,6 +202,15 @@ export interface TestKit<C extends AnyContract> {
|
|
|
181
202
|
runJob(name: JobName<C> | typeof FILE_SCAN_JOB | typeof FILE_SWEEP_JOB, options?: JobRunOptions): Promise<JobRunResult>
|
|
182
203
|
/** Waits for the work requests left running: the runs a site's `ctx.kick` sent, a failure's report. */
|
|
183
204
|
drain(): Promise<void>
|
|
205
|
+
/**
|
|
206
|
+
* Runs every job with a wake due now or within `within` ms (0 by default) once, as the Cloudflare object's alarm
|
|
207
|
+
* runs it: the startup repair first (each job's cron wake at its next fire), then each wake ahead moved to now, then
|
|
208
|
+
* each due job under its lease, a failed run's retry moved to its backoff. It first waits for the runs a site's
|
|
209
|
+
* `ctx.kick` sent. Nothing else fires on its own. Handlers keep real time: only the wakes move, never the clock, so
|
|
210
|
+
* a run again schedules its cron fire from now, and a later call skips a cron fire this kit already ran early. Needs
|
|
211
|
+
* the application's data layer.
|
|
212
|
+
*/
|
|
213
|
+
runDueJobs(options?: { readonly within?: number }): Promise<readonly DueJobRun[]>
|
|
184
214
|
/**
|
|
185
215
|
* The stand-in for every job's transport: what reached it (`accepted`, `handoffs`) and its faults (`refuse`,
|
|
186
216
|
* `unavailable`, `unreachable`, `loseAnswers`, `during`, `heal`). Each message carries the transport key,
|
|
@@ -202,6 +232,12 @@ export interface TestKit<C extends AnyContract> {
|
|
|
202
232
|
solveChallenge(procedure: object): Promise<string>
|
|
203
233
|
}
|
|
204
234
|
|
|
235
|
+
/** A job `runDueJobs` ran, and its run's result. */
|
|
236
|
+
export interface DueJobRun {
|
|
237
|
+
readonly job: string
|
|
238
|
+
readonly result: JobRunResult
|
|
239
|
+
}
|
|
240
|
+
|
|
205
241
|
/** The names of the contract's cron jobs. */
|
|
206
242
|
export type JobName<C> = C extends { readonly surface: { readonly jobs: infer J } } ? keyof J & string : never
|
|
207
243
|
|
|
@@ -428,6 +464,7 @@ export function bootTestKit<C extends AnyContract>(
|
|
|
428
464
|
...dev,
|
|
429
465
|
...(options.revealHandlerErrors === undefined ? {} : { revealHandlerErrors: options.revealHandlerErrors }),
|
|
430
466
|
membership,
|
|
467
|
+
terminals: options.terminals ?? (artifact.terminal === undefined ? undefined : NO_IDENTIFICATIONS),
|
|
431
468
|
connectBindings,
|
|
432
469
|
workloadTokens,
|
|
433
470
|
mailStandIn: options.mail === 'none' ? 'none' : mail,
|
|
@@ -523,7 +560,7 @@ export function bootTestKit<C extends AnyContract>(
|
|
|
523
560
|
|
|
524
561
|
const scope = <D extends DimensionOf<C>>(dimension: D, value: string): TestScope<D> => Object.freeze({ type: dimension, value })
|
|
525
562
|
|
|
526
|
-
/** The caller's token, or why IAM signs none: a disabled principal, or a token above
|
|
563
|
+
/** The caller's token, or why IAM signs none: a disabled principal, or a token above IAM's bound for it. */
|
|
527
564
|
async function mint(caller: TestCaller): Promise<{ readonly ok: true; readonly token: string; readonly expiresAt: number } | MintRefusal> {
|
|
528
565
|
if (caller.disabled) return { ok: false, reason: 'disabled' }
|
|
529
566
|
const now = Math.floor(Date.now() / 1000)
|
|
@@ -542,7 +579,8 @@ export function bootTestKit<C extends AnyContract>(
|
|
|
542
579
|
})
|
|
543
580
|
const { privateKey } = await signing
|
|
544
581
|
const token = await new SignJWT({ ...claims }).setProtectedHeader({ alg: TOKEN_ALG, kid: KEY_ID }).sign(privateKey)
|
|
545
|
-
|
|
582
|
+
// IAM bounds a workload's own token as any installation token, and a token the proxy injects at the application's.
|
|
583
|
+
if (token.length > (caller.app === null ? MAX_APPLICATION_TOKEN_BYTES : MAX_ACCESS_TOKEN_BYTES)) return { ok: false, reason: 'token_too_large' }
|
|
546
584
|
byToken.set(token, { caller, expiresAt: claims.exp })
|
|
547
585
|
return { ok: true, token, expiresAt: claims.exp }
|
|
548
586
|
}
|
|
@@ -675,6 +713,49 @@ export function bootTestKit<C extends AnyContract>(
|
|
|
675
713
|
return application.jobs.run(name, runOptions)
|
|
676
714
|
}
|
|
677
715
|
|
|
716
|
+
// The cron fires `runDueJobs` ran early, as `<key>@<due>`: a run schedules the same fire again from the real now.
|
|
717
|
+
const ranEarly = new Set<string>()
|
|
718
|
+
const runDueJobs = async (dueOptions: { readonly within?: number } = {}): Promise<readonly DueJobRun[]> => {
|
|
719
|
+
const within = dueOptions.within ?? 0
|
|
720
|
+
if (!Number.isFinite(within) || within < 0) {
|
|
721
|
+
throw new TypeError('runDueJobs({ within }) takes milliseconds, 0 or more')
|
|
722
|
+
}
|
|
723
|
+
const scheduler = application.jobs.scheduler
|
|
724
|
+
if (scheduler === null || app.database === null) {
|
|
725
|
+
throw new Error(
|
|
726
|
+
"runDueJobs runs the jobs over the application's data layer: serve(contract, { database: scoped(tables) }) and testKit(app, { database })",
|
|
727
|
+
)
|
|
728
|
+
}
|
|
729
|
+
await drain()
|
|
730
|
+
await scheduler.repair()
|
|
731
|
+
const { jobs: leases, wakes } = frameworkTablesOf(app.database)
|
|
732
|
+
const now = (await leases.now()).getTime()
|
|
733
|
+
const ahead: string[] = []
|
|
734
|
+
const fires: string[] = []
|
|
735
|
+
for (const job of scheduler.jobs) {
|
|
736
|
+
for (const wake of await wakes.pending(job)) {
|
|
737
|
+
const due = wake.dueAt.getTime()
|
|
738
|
+
const fire = wake.reason === 'cron' ? `${wake.dedupe}@${due}` : null
|
|
739
|
+
if (due > now && due <= now + within && (fire === null || !ranEarly.has(fire))) {
|
|
740
|
+
ahead.push(wake.id)
|
|
741
|
+
if (fire !== null) fires.push(fire)
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (ahead.length > 0) {
|
|
746
|
+
await wakes.hasten(ahead)
|
|
747
|
+
}
|
|
748
|
+
// Only once the wakes moved: a hasten that failed left them ahead, and the next call moves them again.
|
|
749
|
+
for (const fire of fires) ranEarly.add(fire)
|
|
750
|
+
const taken: { readonly job: string; readonly fence: LeaseFence }[] = []
|
|
751
|
+
for (const job of scheduler.jobs) {
|
|
752
|
+
const { fence, reaped } = await scheduler.take(job)
|
|
753
|
+
if (reaped) await scheduler.crashed(job)
|
|
754
|
+
if (fence !== null) taken.push({ job, fence })
|
|
755
|
+
}
|
|
756
|
+
return await Promise.all(taken.map(async ({ job, fence }) => ({ job, result: await scheduler.run(job, fence) })))
|
|
757
|
+
}
|
|
758
|
+
|
|
678
759
|
const acceptInvitation = (invitationId: string, person?: LabelledTestCaller): LabelledTestCaller => {
|
|
679
760
|
if (standIn === null) {
|
|
680
761
|
throw new Error('this kit was given its own membership transport, so its IAM holds no invitation to accept')
|
|
@@ -707,6 +788,7 @@ export function bootTestKit<C extends AnyContract>(
|
|
|
707
788
|
iam,
|
|
708
789
|
runJob,
|
|
709
790
|
drain,
|
|
791
|
+
runDueJobs,
|
|
710
792
|
acceptInvitation,
|
|
711
793
|
mail,
|
|
712
794
|
mailKeyScope,
|
|
@@ -690,7 +690,7 @@ export function policyIsolationKit<C extends AnyContract, DB, P>(
|
|
|
690
690
|
required('insert')
|
|
691
691
|
const worlds = await seed()
|
|
692
692
|
const api = session(worlds)
|
|
693
|
-
const tag = tagged(await postgres.sampleInsert(tables, table))
|
|
693
|
+
const tag = tagged(await postgres.sampleInsert(tables, table, worlds[into]))
|
|
694
694
|
return wrote(() => api.insert({ scope: worlds[into].scope, tag }))
|
|
695
695
|
},
|
|
696
696
|
async update(row) {
|
|
@@ -801,7 +801,7 @@ export function policyIsolationKit<C extends AnyContract, DB, P>(
|
|
|
801
801
|
required('insert')
|
|
802
802
|
const worlds = await seed()
|
|
803
803
|
const api = session(worlds)
|
|
804
|
-
const tag = tagged(await postgres.sampleInsert(tables, table))
|
|
804
|
+
const tag = tagged(await postgres.sampleInsert(tables, table, worlds[into]))
|
|
805
805
|
const { parent: parentKey } = address(worlds, into)
|
|
806
806
|
return wrote(() => api.insert({ parent: parentKey, tag }))
|
|
807
807
|
},
|
package/src/testing/proxy.ts
CHANGED
|
@@ -19,18 +19,18 @@ import {
|
|
|
19
19
|
type TokenCache,
|
|
20
20
|
} from '@fabrika/proxy-core'
|
|
21
21
|
import { applyCrossOriginHeaders, crossOriginHeaders } from '@fabrika/proxy-core/headers'
|
|
22
|
-
import { contractProxyTable } from '@fabrika/proxy-core/manifest'
|
|
22
|
+
import { contractProxyEntry, contractProxyTable } from '@fabrika/proxy-core/manifest'
|
|
23
23
|
|
|
24
24
|
/** What the proxy did with a request: answered it itself, or forwarded it with what only the proxy may set. */
|
|
25
25
|
export type ProxyOutcome =
|
|
26
26
|
| {
|
|
27
27
|
readonly outcome: 'forward'
|
|
28
|
-
/** Every header only the proxy may assert, with the value the decision gave it. */
|
|
29
|
-
readonly asserted: ReadonlyMap<string, string>
|
|
30
28
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* Every header only the proxy may assert, with the value the decision gave it. A credentialed request that carried
|
|
30
|
+
* `Authorization` has it replaced by the minted token, so the caller's `px_` key never reaches the application.
|
|
33
31
|
*/
|
|
32
|
+
readonly asserted: ReadonlyMap<string, string>
|
|
33
|
+
/** Whether the request's own `Authorization` reaches the application: only on a webhook row the decision marked to pass it on. */
|
|
34
34
|
readonly keepsAuthorization: boolean
|
|
35
35
|
/** What the application's answer is given for an admitted cross-origin request, over its own headers. */
|
|
36
36
|
readonly decorate: (headers: Headers) => void
|
|
@@ -66,14 +66,14 @@ const ASSERTED_HEADERS = [PROXY_TOKEN_HEADER, REQUEST_ID_HEADER, ENDPOINT_HEADER
|
|
|
66
66
|
export function endpointProxy(options: EndpointProxyOptions): TestProxy {
|
|
67
67
|
const verify = createVerifyService({
|
|
68
68
|
manifest: {
|
|
69
|
-
apps: [{
|
|
69
|
+
apps: [contractProxyEntry({
|
|
70
70
|
id: options.appId,
|
|
71
71
|
hosts: [options.host],
|
|
72
72
|
upstream: 'app',
|
|
73
73
|
scheme: 'https',
|
|
74
|
-
|
|
75
|
-
...(options.crossOrigins === undefined
|
|
76
|
-
}],
|
|
74
|
+
table: contractProxyTable(options.artifact),
|
|
75
|
+
...(options.crossOrigins === undefined ? {} : { crossOrigins: options.crossOrigins }),
|
|
76
|
+
})],
|
|
77
77
|
},
|
|
78
78
|
iam: options.iam,
|
|
79
79
|
issuer: options.issuer,
|
|
@@ -105,10 +105,15 @@ export function endpointProxy(options: EndpointProxyOptions): TestProxy {
|
|
|
105
105
|
asserted.set(header, value)
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
const keepsAuthorization = verification.headers.get(FORWARD_AUTHORIZATION_HEADER) === '1'
|
|
109
|
+
const minted = asserted.get(PROXY_TOKEN_HEADER)
|
|
110
|
+
if (!keepsAuthorization && minted !== undefined && request.headers.has('Authorization')) {
|
|
111
|
+
asserted.set('Authorization', `Bearer ${minted}`)
|
|
112
|
+
}
|
|
108
113
|
return {
|
|
109
114
|
outcome: 'forward',
|
|
110
115
|
asserted,
|
|
111
|
-
keepsAuthorization
|
|
116
|
+
keepsAuthorization,
|
|
112
117
|
decorate: (answer) => {
|
|
113
118
|
if (allowOrigin !== null) applyCrossOriginHeaders(answer, crossOriginHeaders(allowOrigin))
|
|
114
119
|
},
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const APP_AGENT_SKILL_NAME = "fabrika-app";
|
|
2
|
+
export interface AppAgentSkillReference {
|
|
3
|
+
/** The file's path in the skill directory, `references/<topic>.md`: the path `SKILL.md` names it by. */
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** The topic `get_app_rules` answers it under: its file name without `.md`. */
|
|
6
|
+
readonly topic: string;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AppAgentSkill {
|
|
10
|
+
/** The `version` of the frontmatter: the version of the `@fabrika/app` that ships it. */
|
|
11
|
+
readonly version: string;
|
|
12
|
+
/** The whole `SKILL.md`, frontmatter included: what a skill directory holds. */
|
|
13
|
+
readonly text: string;
|
|
14
|
+
/** `SKILL.md` without the frontmatter. */
|
|
15
|
+
readonly body: string;
|
|
16
|
+
/** The reference files, by path. */
|
|
17
|
+
readonly references: readonly AppAgentSkillReference[];
|
|
18
|
+
}
|
|
19
|
+
/** The skill of this package. */
|
|
20
|
+
export declare function readAppAgentSkill(): AppAgentSkill;
|
|
21
|
+
/** The skill in `skillDir`, the `skill/` directory of an installed `@fabrika/app`. */
|
|
22
|
+
export declare function readAppAgentSkillAt(skillDir: string): AppAgentSkill;
|
|
23
|
+
/**
|
|
24
|
+
* The skill of the `@fabrika/app` an application installed: the nearest `node_modules/@fabrika/app` from `appRoot`
|
|
25
|
+
* up, as Bun resolves the package. `null` when the application has not installed it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function installedAppAgentSkill(appRoot: string): AppAgentSkill | null;
|
|
28
|
+
/** The `AGENTS.md` of an application repository: the skill's body, then each reference file. */
|
|
29
|
+
export declare function renderAgentsFile(skill: AppAgentSkill): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export { CONTRACT_APP_ID_PATTERN } from './contract/app-id.js';
|
|
2
|
+
export { FILE_SCAN_JOB, FILE_SWEEP_JOB } from './files/job-names.js';
|
|
3
|
+
/** The TypeScript release of the platform's type check; the application's own `typescript` is not run. */
|
|
4
|
+
export declare const PLATFORM_TYPESCRIPT_VERSION = "5.9.3";
|
|
5
|
+
/** A `c.cron` job name, which a crontab line carries unquoted. */
|
|
6
|
+
export declare const CONTRACT_JOB_NAME_PATTERN: RegExp;
|
|
7
|
+
/** Five cron fields of digits and `*`, `/`, `,`, `-` only. */
|
|
8
|
+
export declare const CRON_SCHEDULE_PATTERN: RegExp;
|
|
9
|
+
/** What one contract application's recipe depends on. `contractRecipe` refuses a value that a shell would read as more. */
|
|
10
|
+
export interface ContractRecipeInput {
|
|
11
|
+
readonly appId: string;
|
|
12
|
+
/** The `@fabrika/check` release whose reader read the application (ADR-0062). */
|
|
13
|
+
readonly checkRelease: string;
|
|
14
|
+
/** The absolute directory the build runs in: the checker reads the source there. */
|
|
15
|
+
readonly sourceRoot: string;
|
|
16
|
+
/** The absolute directory the built application runs from: each generated script starts there. */
|
|
17
|
+
readonly runtimeRoot: string;
|
|
18
|
+
/** With a database, every container migrates and checks its schema before the server starts. */
|
|
19
|
+
readonly database: boolean;
|
|
20
|
+
/** Whether the build uploads its source maps, last and never failing the build. */
|
|
21
|
+
readonly sourceMaps: boolean;
|
|
22
|
+
readonly jobs: readonly {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly schedule: string;
|
|
25
|
+
}[];
|
|
26
|
+
/** The contract declares a file collection: the sweep of removed files is scheduled. */
|
|
27
|
+
readonly files: boolean;
|
|
28
|
+
/** A file collection scans its uploads: the scan pass is scheduled. */
|
|
29
|
+
readonly scan: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** One build step: a command run in the source root, or a generated file written there, line by line. */
|
|
32
|
+
export type ContractBuildStep = {
|
|
33
|
+
readonly run: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly write: string;
|
|
36
|
+
readonly lines: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
/** One check of the build: a command run in the source root that fails the build. */
|
|
39
|
+
export interface ContractCheck {
|
|
40
|
+
readonly name: 'tests' | 'tsc' | 'fabrika-check';
|
|
41
|
+
readonly command: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ContractRecipe {
|
|
44
|
+
/** The steps after the authored SPA commands, in order. */
|
|
45
|
+
readonly build: readonly ContractBuildStep[];
|
|
46
|
+
/** The checks among `build`, in its order. */
|
|
47
|
+
readonly checks: readonly ContractCheck[];
|
|
48
|
+
/** The generated scripts every container runs before `start`, in order; any failure stops the activation. */
|
|
49
|
+
readonly init: readonly string[];
|
|
50
|
+
/** The generated script that starts the server, which only `exec`s it. */
|
|
51
|
+
readonly start: string;
|
|
52
|
+
/** The command the start script `exec`s, run from the runtime root. */
|
|
53
|
+
readonly serve: readonly string[];
|
|
54
|
+
/** The command that migrates the application's database, run from the runtime root. */
|
|
55
|
+
readonly migrate: readonly string[];
|
|
56
|
+
/** The jobs to schedule, each on one container; a command runs from the runtime root. */
|
|
57
|
+
readonly jobs: readonly {
|
|
58
|
+
readonly schedule: string;
|
|
59
|
+
readonly command: string;
|
|
60
|
+
}[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The recipe of one contract application. The application's tests run first: they are authored code, so everything
|
|
64
|
+
* after them is reinstalled, regenerated or checked again. They run `--isolate`, as the application skill runs them: a
|
|
65
|
+
* test file's DOM globals otherwise leak into the next file. `tsc` runs before the checker, as in the skill's loop: the
|
|
66
|
+
* usual quick fix of a type error is a cast or an `any`, which only the checker refuses, so the checker is the last word
|
|
67
|
+
* on the code. The build has no database, so the schema checks run as init scripts, after the migrations and before the
|
|
68
|
+
* readiness window opens.
|
|
69
|
+
*/
|
|
70
|
+
export declare function contractRecipe(input: ContractRecipeInput): ContractRecipe;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** An application root with this file is a contract application. The paths equal `@fabrika/check`'s layout. */
|
|
2
|
+
export declare const CONTRACT_FILE = "fabrika.contract.ts";
|
|
3
|
+
/** Relative to the application root. */
|
|
4
|
+
export declare const GENERATED_ENTRY_FILE = "fabrika/entry.generated.ts";
|
|
5
|
+
/** The module whose default export is `serve(contract, …)`, relative to the application root. */
|
|
6
|
+
export declare const IMPLEMENTATION_FILE = "src/app.ts";
|
|
7
|
+
/** The application's migrations as a module, relative to the application root: a Worker reads no file system. */
|
|
8
|
+
export declare const GENERATED_MIGRATIONS_FILE = "fabrika/migrations.generated.ts";
|
|
9
|
+
/** Where an application keeps its migrations, relative to its root; `fabrika db new` writes there. */
|
|
10
|
+
export declare const MIGRATIONS_DIRECTORY = "db/migrations";
|
|
11
|
+
export type EntryRuntime = 'bun' | 'cloudflare';
|
|
12
|
+
export * from './build-recipe.js';
|
|
13
|
+
export { CLOUDFLARE_APPLICATION_BINDING, CLOUDFLARE_APPLICATION_CLASS, CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_FILES_BINDING, } from './cloudflare/names.js';
|
|
14
|
+
/** The entrypoint source for one runtime. */
|
|
15
|
+
export declare function generatedEntry(runtime: EntryRuntime): string;
|
|
16
|
+
/** Writes the entrypoint under `root` and returns its path; the Cloudflare one also writes the migrations module it imports. */
|
|
17
|
+
export declare function writeGeneratedEntry(root: string, runtime: EntryRuntime): Promise<string>;
|
|
18
|
+
/** The application's migrations under `root`, every `.sql` file of `db/migrations` by name; none without the directory. */
|
|
19
|
+
export declare function applicationMigrations(root: string): Promise<readonly {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly sql: string;
|
|
22
|
+
}[]>;
|
|
23
|
+
/** The migrations module source: the files' names and texts, verbatim, so their checksums stay the files'. */
|
|
24
|
+
export declare function generatedMigrations(migrations: readonly {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly sql: string;
|
|
27
|
+
}[]): string;
|
|
28
|
+
/** Writes the migrations module under `root` and returns its path. */
|
|
29
|
+
export declare function writeGeneratedMigrations(root: string): Promise<string>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Session } from '@fabrika/db/framework';
|
|
2
|
+
import type { FileObjectStore } from '@fabrika/platform';
|
|
3
|
+
import type { FetchService, RequestExecutionContext } from './fetch.js';
|
|
4
|
+
import { type IamKeySource } from './implement/boot.js';
|
|
5
|
+
import { type CrashEvents } from './implement/crashes.js';
|
|
6
|
+
import { type ContractImplementation } from './implement/implement.js';
|
|
7
|
+
import { type ContractJobs, type JobRunOptions, type JobRunResult } from './jobs/runner.js';
|
|
8
|
+
export { diskAssets } from './disk-assets.js';
|
|
9
|
+
export { clamscanArguments, type ClamscanOptions, clamscanScanner } from './files/clamscan.js';
|
|
10
|
+
export { markProductionProcess } from '@fabrika/db/production';
|
|
11
|
+
export interface ManagedBunHandlerOptions {
|
|
12
|
+
/** Required sink for rejected background tasks. Do not log raw errors or secret-bearing values. */
|
|
13
|
+
onBackgroundError(error: unknown): void;
|
|
14
|
+
executionContext?: never;
|
|
15
|
+
}
|
|
16
|
+
export interface ExternalBunHandlerOptions {
|
|
17
|
+
/** Existing supervised process context. Its owner remains responsible for draining it. */
|
|
18
|
+
executionContext: RequestExecutionContext;
|
|
19
|
+
onBackgroundError?: never;
|
|
20
|
+
}
|
|
21
|
+
export type BunHandlerOptions = ManagedBunHandlerOptions | ExternalBunHandlerOptions;
|
|
22
|
+
export interface BunHandler {
|
|
23
|
+
fetch(request: Request): Promise<Response>;
|
|
24
|
+
/** Wait until every task registered through `waitUntil()` has settled. */
|
|
25
|
+
drain(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createBunHandler<Env>(app: FetchService<Env>, env: Env, options: BunHandlerOptions): BunHandler;
|
|
28
|
+
/** IAM's public key set at the issuer's `/.well-known/jwks.json`, for a process with no IAM binding. */
|
|
29
|
+
export declare function issuerJwks(issuer: unknown): IamKeySource;
|
|
30
|
+
export interface ContractServer {
|
|
31
|
+
/** The port the server listens on; `PORT=0` picks a free one. */
|
|
32
|
+
readonly port: number;
|
|
33
|
+
/** Stops accepting requests and waits for the ones in flight. */
|
|
34
|
+
stop(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* How long the wake timer waits for a wake that is already due: such a wake's own kick is under way (the post-commit start,
|
|
38
|
+
* or the timer's last one), and looking at once would kick its job a second time before that kick took the lease.
|
|
39
|
+
*/
|
|
40
|
+
export declare const WAKE_RETRY_MS = 1000;
|
|
41
|
+
/**
|
|
42
|
+
* How long after a write projected the timer a refresh that cannot see the projected wake looks again: the write may still
|
|
43
|
+
* be committing, and no transaction that writes a wake outlasts a request's budget.
|
|
44
|
+
*/
|
|
45
|
+
export declare const WAKE_SETTLE_MS: number;
|
|
46
|
+
/**
|
|
47
|
+
* The serving process's one timer to the jobs' next wake, Bun's side of the scheduler (ADR-0065 §5): it kicks each job
|
|
48
|
+
* whose wake came due through the kick path, so the lease admits one container. A write of this process lowers it in
|
|
49
|
+
* that write's transaction (`project`, `BootOptions.projectWakes`), by the delay on the database's clock; a wake another
|
|
50
|
+
* container wrote is found when the serving process refreshes it with its job check. Crontab still runs the schedule.
|
|
51
|
+
*/
|
|
52
|
+
export declare class WakeTimer {
|
|
53
|
+
#private;
|
|
54
|
+
/** `track` holds each kick the timer starts until it ended, for the shutdown drain. */
|
|
55
|
+
constructor(track: (kick: Promise<void>) => void);
|
|
56
|
+
/** The booted application's jobs; until then nothing fires. */
|
|
57
|
+
attach(jobs: ContractJobs): void;
|
|
58
|
+
/**
|
|
59
|
+
* `BootOptions.projectWakes`: never later than the next wake the write leaves, which a rollback only makes early. The
|
|
60
|
+
* timer may fire before the write commits, so the wake stays unseen until a refresh finds it.
|
|
61
|
+
*/
|
|
62
|
+
readonly project: (transaction: Session) => Promise<void>;
|
|
63
|
+
/** Kicks every job whose wake is due and arms the timer at the next one; it never rejects. */
|
|
64
|
+
refresh(): Promise<void>;
|
|
65
|
+
/** Fires no more and refreshes no more; resolves once a refresh under way ended, so it starts no kick after it. */
|
|
66
|
+
stop(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The stored files' object storage (Zerops object storage, path-style), when the platform wrote its variables;
|
|
70
|
+
* a partial set stops the boot. The credentials are never quoted in a message.
|
|
71
|
+
*/
|
|
72
|
+
export declare function openFileStorage(framework: Readonly<Record<string, string>>): FileObjectStore | undefined;
|
|
73
|
+
/** The application module, imported only after the environment was captured: the generated entrypoint's `import()`. */
|
|
74
|
+
export type ImplementationLoader = () => Promise<{
|
|
75
|
+
readonly default: ContractImplementation;
|
|
76
|
+
}>;
|
|
77
|
+
export interface ContractServerOptions {
|
|
78
|
+
/** Where the process hears of an uncaught exception or an unhandled rejection; `process` by default. */
|
|
79
|
+
readonly crashes?: CrashEvents;
|
|
80
|
+
/** What posts a report to Operations' ingest; `fetch` by default. */
|
|
81
|
+
readonly operationsFetch?: (request: Request) => Promise<Response>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Captures the framework's variables and scrubs them from the process, then imports the application, boots it and
|
|
85
|
+
* serves it on `PORT` (default 3000), on every interface: the project's private network is how the proxy reaches
|
|
86
|
+
* it. Called only by the generated entrypoint, with `process.env`. SIGTERM drains. Given the provisioning credential,
|
|
87
|
+
* it is the launcher instead: it never loads the application and re-runs the entrypoint as the runtime role.
|
|
88
|
+
* With an Operations DSN, a startup that throws is reported before it is rethrown, and so is a crash once it serves.
|
|
89
|
+
*/
|
|
90
|
+
export declare function serveContract(load: ImplementationLoader, env: Readonly<Record<string, string | undefined>>, options?: ContractServerOptions): Promise<ContractServer>;
|
|
91
|
+
/** The application module at `path`, imported when the loader runs; its default export must be what `serve` returned. */
|
|
92
|
+
export declare function implementationAt(path: string): ImplementationLoader;
|
|
93
|
+
/**
|
|
94
|
+
* One run of the job `name` (`fabrika job run <name>`, the crontab's command): the framework's variables are captured
|
|
95
|
+
* and scrubbed before the application loads, exactly as `serveContract` does, then `boot` binds the job and the run
|
|
96
|
+
* takes its lease. The connection closes when the run ends. Given the provisioning credential, it re-runs the command
|
|
97
|
+
* as the runtime role, as `serveContract` does.
|
|
98
|
+
*/
|
|
99
|
+
export declare function runContractJob(load: ImplementationLoader, env: Readonly<Record<string, string | undefined>>, name: string, options?: JobRunOptions): Promise<JobRunResult>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
declare const PageCallerSchema: z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
email: z.ZodString;
|
|
5
|
+
actions: z.ZodObject<{
|
|
6
|
+
/** The actions held as a global grant, so in every value. */
|
|
7
|
+
app: z.ZodArray<z.ZodString>;
|
|
8
|
+
/** Each scope value the person holds something in, with those actions; sorted by dimension, then value. */
|
|
9
|
+
scopes: z.ZodArray<z.ZodObject<{
|
|
10
|
+
type: z.ZodString;
|
|
11
|
+
value: z.ZodString;
|
|
12
|
+
actions: z.ZodArray<z.ZodString>;
|
|
13
|
+
}, z.core.$strict>>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export type PageCaller = z.infer<typeof PageCallerSchema>;
|
|
17
|
+
/** The caller document as the framework answers it; throws on any other value. */
|
|
18
|
+
export declare function parsePageCaller(value: unknown): PageCaller;
|
|
19
|
+
export {};
|