@fabrika/provider-cloudflare 0.8.2 → 0.9.0-cloudflare.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +16 -15
  2. package/src/bounds.ts +142 -4
  3. package/src/cli.ts +14 -0
  4. package/src/command.ts +8 -4
  5. package/src/contract-support.ts +118 -0
  6. package/src/control.ts +37 -119
  7. package/src/index.ts +1 -1
  8. package/src/installation/init.ts +11 -18
  9. package/src/installation/templates/README.md +21 -4
  10. package/src/installation/templates/platform.yml +6 -0
  11. package/src/managed-secrets.ts +61 -0
  12. package/src/plan.ts +11 -3
  13. package/src/provider.ts +277 -54
  14. package/src/proxy-worker.ts +33 -13
  15. package/src/proxy.ts +48 -16
  16. package/src/runner-protocol.ts +16 -1
  17. package/types/src/assets.d.ts +8 -0
  18. package/types/src/authoring.d.ts +17 -0
  19. package/types/src/bounds.d.ts +81 -0
  20. package/types/src/checkout.d.ts +7 -0
  21. package/types/src/cli-args.d.ts +25 -0
  22. package/types/src/cli.d.ts +8 -0
  23. package/types/src/codec.d.ts +8 -0
  24. package/types/src/collaborators.d.ts +52 -0
  25. package/types/src/command.d.ts +49 -0
  26. package/types/src/config-schema.d.ts +9 -0
  27. package/types/src/contract-support.d.ts +39 -0
  28. package/types/src/control.d.ts +468 -0
  29. package/types/src/index.d.ts +18 -0
  30. package/types/src/installation/cloudflare.d.ts +40 -0
  31. package/types/src/installation/envfile.d.ts +39 -0
  32. package/types/src/installation/index.d.ts +2 -0
  33. package/types/src/installation/init-options.d.ts +59 -0
  34. package/types/src/installation/init.d.ts +114 -0
  35. package/types/src/installation/installation.d.ts +2 -0
  36. package/types/src/installation/scaffold.d.ts +39 -0
  37. package/types/src/managed-secrets.d.ts +19 -0
  38. package/types/src/plan.d.ts +21 -0
  39. package/types/src/provider.d.ts +58 -0
  40. package/types/src/proxy-worker.d.ts +15 -0
  41. package/types/src/proxy.d.ts +72 -0
  42. package/types/src/runner-protocol.d.ts +121 -0
  43. package/types/src/schema.d.ts +17 -0
package/src/proxy.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ contractProxyEntry,
2
3
  type ContractProxyTable,
3
4
  encodeProxyManifestJson,
4
5
  type InstallationProxyTable,
@@ -7,6 +8,9 @@ import {
7
8
  } from '@fabrika/proxy-core/manifest'
8
9
  import { ServiceReference, Worker } from 'oblaka-iac'
9
10
 
11
+ /** A binding as oblaka configures it into a Worker's generated config. */
12
+ type Binding = Pick<ServiceReference, 'configureBinding'>
13
+
10
14
  interface CloudflareProxyWorkerBase {
11
15
  /** Name of the proxy Worker before the environment prefix is applied by oblaka. */
12
16
  readonly name: string
@@ -47,6 +51,20 @@ export type CloudflareProxyWorkerOptions =
47
51
  export const CLOUDFLARE_PROXY_WORKER_DIR: string = import.meta.dir
48
52
  export const CLOUDFLARE_PROXY_WORKER_MAIN = './proxy-worker.ts'
49
53
 
54
+ /**
55
+ * The identifier the proxy Worker's bundle reads its manifest from. The generated config's `define` replaces it with
56
+ * the manifest as a string literal when wrangler bundles the Worker, so the table has no Worker variable's 5 KB cap.
57
+ */
58
+ export const PROXY_MANIFEST_DEFINE = '__FABRIKA_PROXY_MANIFEST__'
59
+
60
+ /** The manifest JSON a proxy Worker built here carries, or null for any other Worker. */
61
+ export const proxyManifestJson = (worker: Worker): string | null => {
62
+ const literal = worker.options.define?.[PROXY_MANIFEST_DEFINE]
63
+ if (literal === undefined) return null
64
+ const value: unknown = JSON.parse(literal)
65
+ return typeof value === 'string' ? value : null
66
+ }
67
+
50
68
  /** IAM's Worker: the one platform service an application binds, and only through the entrypoint below. */
51
69
  export const IAM_SERVICE = 'propustka-worker'
52
70
 
@@ -56,6 +74,25 @@ export const IAM_APPLICATION_ENTRYPOINT = 'PropustkaApplication'
56
74
  /** The `IAM` binding of an application Worker; a generated config that binds IAM any other way is refused. */
57
75
  export const iamServiceReference = (): ServiceReference => new ServiceReference(IAM_SERVICE, IAM_APPLICATION_ENTRYPOINT)
58
76
 
77
+ /**
78
+ * The deployer's `IAM` binding: what the Worker declared, with the IAM service entry's `props` naming the deployment's
79
+ * IAM application id. IAM reads it as `ctx.props.app`, the transport identity of a call over the binding, as the
80
+ * membership transport key is over HTTP (ADR-0067 §3). An application cannot choose it: the deployer writes it, and the
81
+ * bounds refuse an IAM binding that names any other application.
82
+ */
83
+ export class IamApplicationReference implements Binding {
84
+ constructor(
85
+ private readonly app: string,
86
+ private readonly declared: Binding = iamServiceReference(),
87
+ ) {}
88
+
89
+ configureBinding(args: Parameters<Binding['configureBinding']>[0]): ReturnType<Binding['configureBinding']> {
90
+ const config = this.declared.configureBinding(args)
91
+ const services = (config.services ?? []).map((entry) => entry.binding === args.binding ? { ...entry, props: { app: this.app } } : entry)
92
+ return { ...config, services }
93
+ }
94
+ }
95
+
59
96
  /**
60
97
  * Build the Cloudflare side of the accepted proxy topology: the public Worker owns the route and
61
98
  * binds the private application Worker. IAM remains a global service binding.
@@ -83,6 +120,9 @@ export function createCloudflareProxyWorker(options: CloudflareProxyWorkerOption
83
120
  const manifest: ProxyManifest = { apps: [proxyApp(placement, options)] }
84
121
  const domain = options.domain?.trim()
85
122
 
123
+ const iam = new ServiceReference(options.iamService ?? IAM_SERVICE, IAM_APPLICATION_ENTRYPOINT)
124
+ // An application's proxy names its application to IAM, as the application Worker's binding does; a platform
125
+ // service's proxy is trusted composition and calls no operation that is pinned to an application.
86
126
  return new Worker({
87
127
  dir: CLOUDFLARE_PROXY_WORKER_DIR,
88
128
  name: options.name,
@@ -91,12 +131,10 @@ export function createCloudflareProxyWorker(options: CloudflareProxyWorkerOption
91
131
  compatibility_date: '2025-05-25',
92
132
  routes: domain === undefined || domain === '' ? [] : [{ pattern: domain, custom_domain: true }],
93
133
  observability: { logs: { enabled: true, invocation_logs: false } },
94
- vars: {
95
- FABRIKA_PROXY_MANIFEST_JSON: encodeProxyManifestJson(manifest),
96
- FABRIKA_IAM_ISSUER: options.iamUrl ?? '',
97
- },
134
+ define: { [PROXY_MANIFEST_DEFINE]: JSON.stringify(encodeProxyManifestJson(manifest)) },
135
+ vars: { FABRIKA_IAM_ISSUER: options.iamUrl ?? '' },
98
136
  bindings: {
99
- IAM: new ServiceReference(options.iamService ?? IAM_SERVICE, IAM_APPLICATION_ENTRYPOINT),
137
+ IAM: options.installation === undefined ? new IamApplicationReference(options.appId, iam) : iam,
100
138
  APP: options.app,
101
139
  },
102
140
  })
@@ -110,16 +148,10 @@ function proxyApp(placement: Pick<ProxyApp, 'id' | 'hosts' | 'upstream' | 'schem
110
148
  const { installation, endpoints, reservedPrefixes } = options.installation
111
149
  return { ...placement, installation, endpoints, reservedPrefixes }
112
150
  }
113
- const { endpoints, reservedPrefixes, snapshot, csp } = options.endpoints
114
- const operationsOrigin = options.operationsOrigin
115
- const crossOrigins = options.crossOrigins ?? []
116
- return {
151
+ return contractProxyEntry({
117
152
  ...placement,
118
- endpoints,
119
- reservedPrefixes,
120
- snapshot,
121
- csp,
122
- ...(operationsOrigin === undefined ? {} : { operationsOrigin }),
123
- ...(crossOrigins.length === 0 ? {} : { crossOrigins: [...crossOrigins] }),
124
- }
153
+ table: options.endpoints,
154
+ ...(options.operationsOrigin === undefined ? {} : { operationsOrigin: options.operationsOrigin }),
155
+ ...(options.crossOrigins === undefined ? {} : { crossOrigins: options.crossOrigins }),
156
+ })
125
157
  }
@@ -1,5 +1,6 @@
1
1
  import { contractArtifactSchema } from '@fabrika/app/contract'
2
2
  import { type ContractArtifact, isDigest } from '@fabrika/auth-core'
3
+ import { FRAMEWORK_RELEASE_PATTERN } from '@fabrika/provider-contract'
3
4
  import { z } from 'zod'
4
5
 
5
6
  export const runnerStateSchema = z.enum(['pending', 'cloning', 'installing', 'deploying', 'succeeded', 'failed'])
@@ -25,6 +26,9 @@ export const INSTALLATION_APPS_ENV = 'FABRIKA_INSTALLATION_APPS'
25
26
  /** The executor's copy of `CloudflareRunnerJob.crossOrigins`: a JSON array of the environment's exact origins. */
26
27
  export const CROSS_ORIGINS_ENV = 'FABRIKA_CROSS_ORIGINS'
27
28
 
29
+ /** The executor's copy of `CloudflareRunnerJob.operationsOrigin`: the origin of the environment's Operations ingest. */
30
+ export const OPERATIONS_ORIGIN_ENV = 'FABRIKA_OPERATIONS_ORIGIN'
31
+
28
32
  /**
29
33
  * The access Control approved for a run (ADR-0050): the contract it read at the commit, in this release's model, and
30
34
  * the digest the application's own framework release computes for it. The proxy table and `FABRIKA_CONTRACT_DIGEST`
@@ -35,12 +39,18 @@ export interface RunnerApprovedAccess {
35
39
  readonly kind: 'contract'
36
40
  readonly contract: ContractArtifact
37
41
  readonly contractDigest: string
42
+ /**
43
+ * The framework release whose reader read the application. It picks the Worker's shape: the Durable Object from
44
+ * 0.9, the stateless Worker before it. Absent from a Control older than the runner, which deploys the older shape.
45
+ */
46
+ readonly framework?: string
38
47
  }
39
48
 
40
49
  export const runnerApprovedAccessSchema = z.object({
41
50
  kind: z.literal('contract'),
42
51
  contract: z.unknown(),
43
52
  contractDigest: z.string().refine(isDigest),
53
+ framework: z.string().regex(FRAMEWORK_RELEASE_PATTERN).optional(),
44
54
  })
45
55
  .strict()
46
56
  .transform((access, context): RunnerApprovedAccess => {
@@ -49,7 +59,12 @@ export const runnerApprovedAccessSchema = z.object({
49
59
  context.addIssue({ code: z.ZodIssueCode.custom, message: 'not a contract artifact' })
50
60
  return z.NEVER
51
61
  }
52
- return { kind: 'contract', contract: contract.data, contractDigest: access.contractDigest }
62
+ return {
63
+ kind: 'contract',
64
+ contract: contract.data,
65
+ contractDigest: access.contractDigest,
66
+ ...(access.framework === undefined ? {} : { framework: access.framework }),
67
+ }
53
68
  })
54
69
 
55
70
  /** Where the runner leaves the job's `RunnerApprovedAccess` as JSON for the executor — beside the checkout, never inside it. */
@@ -0,0 +1,8 @@
1
+ import type { GeneratedConfig } from 'oblaka-iac';
2
+ /**
3
+ * wrangler `stat`s each asset rather than `lstat`ing it, so a committed symlink to `/proc/self/environ`
4
+ * (the deploy's own environment holds the account token) or to `.git/config` uploads publicly. Call this
5
+ * per `wrangler deploy` spawn, for the config that spawn reads: the checkout's own build step runs between
6
+ * `open()` and the deploy, so that spawn is the only moment the tree is final.
7
+ */
8
+ export declare const assertLiteralAssets: (generated: GeneratedConfig, configDir: string) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { type AppConfigBase, type ProviderAuthoredApp } from '@fabrika/provider-contract';
2
+ import type { Worker } from 'oblaka-iac';
3
+ /** Inputs used to materialize one environment's Cloudflare resource graph. */
4
+ export interface ResourceContext {
5
+ readonly env: string;
6
+ readonly domain?: string;
7
+ }
8
+ /** A Cloudflare app config loaded from `fabrika.config.ts` inside the runner checkout. */
9
+ export interface CloudflareAppConfigInput extends AppConfigBase {
10
+ /** The application Worker. The deployer builds the proxy Worker in front of it from the contract (ADR-0048); never return one. */
11
+ readonly resources: (ctx: ResourceContext) => Worker;
12
+ }
13
+ export type CloudflareAppConfig = CloudflareAppConfigInput & ProviderAuthoredApp<'cloudflare'>;
14
+ /** Preserve literal inference while validating the provider's required app id. */
15
+ export declare function defineApp(config: CloudflareAppConfigInput): CloudflareAppConfig;
16
+ /** Narrow an imported module default without trusting code from the checkout. */
17
+ export declare const isCloudflareAppConfig: (value: unknown) => value is CloudflareAppConfig;
@@ -0,0 +1,81 @@
1
+ import { type AppEnvironment } from '@fabrika/auth-core';
2
+ import type { GeneratedConfig, Worker } from 'oblaka-iac';
3
+ /** What a deployment may claim on the account. The generated wrangler configs are checked against it. */
4
+ export interface DeploymentBounds {
5
+ /** The environment oblaka provisions into. Every remote name is `${env}-${name}`. */
6
+ readonly env: string;
7
+ /** The one hostname this environment may route; a route on any other host belongs to another app. */
8
+ readonly domain?: string;
9
+ /** The directory a generated config's relative `path` is resolved against: the deploy's worker directory. */
10
+ readonly cwd: string;
11
+ /** Fabrika deploying its own components is the one caller allowed to name a platform resource. */
12
+ readonly platformResources: 'refuse' | 'allow';
13
+ /** The IAM application id `<app>@<env>` of the deployment. */
14
+ readonly iamAppId: string;
15
+ /** Every Cloudflare deployment of the installation in Control's registry; their names are refused. Empty outside a run. */
16
+ readonly installation: readonly AppEnvironment[];
17
+ /** The remote name of the proxy Worker the deployer built, or null when it built none. */
18
+ readonly proxy: string | null;
19
+ /**
20
+ * The service binding the deployer wrote for each connector import (`FABRIKA_CONNECT_<IMPORT>`), by binding name, to
21
+ * the remote name of the owner's proxy Worker. These are the only bindings to another application's Worker.
22
+ */
23
+ readonly connectors: Readonly<Record<string, string>>;
24
+ /**
25
+ * The value of every framework variable the platform wrote into each Worker; a generated config must carry exactly
26
+ * these. `proxy` is null when the deployer built no proxy.
27
+ */
28
+ readonly frameworkVariables: {
29
+ readonly application: Readonly<Record<string, string>>;
30
+ readonly proxy: Readonly<Record<string, string>> | null;
31
+ };
32
+ /** The `define` literal of the manifest the deployer baked into its proxy Worker, or null when it built none. */
33
+ readonly proxyManifest: string | null;
34
+ /** What the platform gives a contract application's Worker (ADR-0065), or null outside one. */
35
+ readonly application: ApplicationRuntime | null;
36
+ }
37
+ /** The Durable Object, files bucket and minute tick of a contract application's Worker; the application authors none of them. */
38
+ export interface ApplicationRuntime {
39
+ /** The remote name of the environment's files bucket. */
40
+ readonly filesBucket: string;
41
+ /** The cron triggers the Worker carries: the minute tick when the contract has a job or a file kind, else an empty list. */
42
+ readonly crons: readonly string[];
43
+ /**
44
+ * The absolute path of the entry the deploy regenerates, which the Worker's `main` must name (`pinsGeneratedEntry`), or
45
+ * null for a release whose Worker keeps its authored `main`.
46
+ */
47
+ readonly entry: string | null;
48
+ }
49
+ /** The framework variables among a Worker's `vars`, as the deployer wrote them. */
50
+ export declare const frameworkValues: (vars: Readonly<Record<string, unknown>> | undefined) => Record<string, string>;
51
+ /** One resource oblaka would apply: the name it was declared under, the remote name it adopts, and its generated id. */
52
+ export interface GeneratedResource {
53
+ readonly kind: string;
54
+ readonly name: string;
55
+ readonly remote: string;
56
+ readonly id: string | null;
57
+ }
58
+ export interface ConfigGeneration {
59
+ readonly configs: readonly GeneratedConfig[];
60
+ readonly resources: readonly GeneratedResource[];
61
+ }
62
+ /**
63
+ * Generate the wrangler configs of a graph with oblaka's own processor, before any Cloudflare call: every resource is
64
+ * applied in dry-run mode with a client that refuses to authenticate, and nothing is written to disk.
65
+ */
66
+ export declare const generateWranglerConfigs: (definition: Worker, env: string) => Promise<ConfigGeneration>;
67
+ /**
68
+ * Check the wrangler configs oblaka generated — what `wrangler deploy` reads, whatever objects emitted them — before
69
+ * provisioning and again before the deploy. Only the proxy Worker the deployer built is routed; every other config is
70
+ * an application Worker, and there is exactly one of those.
71
+ */
72
+ export declare const assertGeneratedConfigs: (configs: readonly GeneratedConfig[], bounds: DeploymentBounds) => void;
73
+ /**
74
+ * The generation run's checks: every generated config, every resource oblaka would apply by the remote name it adopts
75
+ * (a KV namespace's config carries only its id), and every id-bound binding against the ids the run handed out.
76
+ */
77
+ export declare const assertGeneration: (generation: ConfigGeneration, bounds: DeploymentBounds) => void;
78
+ /** The KV namespace oblaka keeps deploy state in is the ONE name it uses verbatim (`KVStateStorage`): no env prefix. */
79
+ export declare const assertStateNamespace: (stateNamespace: string, platformResources: "refuse" | "allow") => void;
80
+ /** The `assets.directory` of a generated config, relative to the config's own directory, once it has been bounded. */
81
+ export declare const assetDirectory: (generated: GeneratedConfig) => string | null;
@@ -0,0 +1,7 @@
1
+ import { Worker } from 'oblaka-iac';
2
+ /**
3
+ * Rebuild the Worker graph a checkout's config returned out of this package's own `Worker` class, so oblaka's
4
+ * processor and the deployer see one class whichever `oblaka-iac` the checkout installed. Every option is carried
5
+ * over as it is; the generated configs are what is checked. Other bindings stay the checkout's objects.
6
+ */
7
+ export declare const runnerWorkerGraph: (value: unknown, path?: readonly unknown[]) => Worker;
@@ -0,0 +1,25 @@
1
+ export interface ParsedCloudflareArgs {
2
+ readonly command: string | undefined;
3
+ readonly subcommand: string | undefined;
4
+ readonly env: string | undefined;
5
+ readonly config: string;
6
+ readonly runnerConfig: string | undefined;
7
+ readonly workerConfig: string | undefined;
8
+ /** The single-component form of `platform deploy|plan`: deploy exactly this one platform config. */
9
+ readonly componentConfig: string | undefined;
10
+ readonly managedVarNames: readonly string[];
11
+ readonly dryRun: boolean;
12
+ readonly help: boolean;
13
+ }
14
+ export declare const parseCloudflareArgs: (argv: readonly string[]) => ParsedCloudflareArgs;
15
+ export interface PlatformComponent {
16
+ readonly label: string;
17
+ readonly configPath: string;
18
+ }
19
+ /** What `platformComponents` needs off a parsed command line. */
20
+ export type PlatformComponentSelection = Pick<ParsedCloudflareArgs, 'runnerConfig' | 'workerConfig' | 'componentConfig'>;
21
+ /**
22
+ * One config (`--component-config`) or the executor-then-control pair, never mixed. Both run with
23
+ * `platformResources: 'allow'`, which is why the single form lives here and not on `app deploy`.
24
+ */
25
+ export declare const platformComponents: (selection: PlatformComponentSelection) => readonly PlatformComponent[];
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bun
2
+ import type { AppCli } from '@fabrika/provider-contract/app-cli';
3
+ export declare const runCloudflareCli: (argv: readonly string[]) => Promise<void>;
4
+ /**
5
+ * What `fabrika app build` and `app deploy` run for an application on Cloudflare. A contract application's build is its
6
+ * generated Worker entry, which the `fabrika` command writes; there is nothing else to build.
7
+ */
8
+ export declare const appCli: AppCli;
@@ -0,0 +1,8 @@
1
+ import type { ProviderCodec } from '@fabrika/provider-contract';
2
+ /** A checkout recipe. The Oblaka graph stays executable code in the referenced config module. */
3
+ export interface CloudflareArtifact {
4
+ readonly configPath: string;
5
+ }
6
+ export declare const cloudflareArtifactCodec: ProviderCodec<CloudflareArtifact>;
7
+ /** Build the default checkout recipe used by the Cloudflare runner. */
8
+ export declare const cloudflareArtifact: (configPath?: string) => CloudflareArtifact;
@@ -0,0 +1,52 @@
1
+ import type { ContractArtifact } from '@fabrika/auth-core';
2
+ import type { SchemaReconciler } from '@fabrika/provider-contract';
3
+ import { type Definition, type DeployResult as OblakaDeployResult } from 'oblaka-iac';
4
+ import { type CloudflareAppConfig } from './authoring';
5
+ import { type RunnerOutcomeFile } from './runner-protocol';
6
+ export interface CommandSpec {
7
+ readonly command: string;
8
+ readonly args: string[];
9
+ readonly cwd: string;
10
+ readonly env?: Record<string, string>;
11
+ /** Names dropped from the INHERITED environment: a child that runs checkout code gets no platform credential. */
12
+ readonly omitEnv?: readonly string[];
13
+ readonly stdin?: string;
14
+ readonly signal?: AbortSignal;
15
+ }
16
+ export interface CommandResult {
17
+ readonly exitCode: number;
18
+ readonly stdout: string;
19
+ readonly stderr: string;
20
+ }
21
+ export type CommandRunner = (spec: CommandSpec) => Promise<CommandResult>;
22
+ export interface ProvisionInput {
23
+ readonly definition: Definition;
24
+ readonly accountId: string;
25
+ readonly apiToken: string;
26
+ readonly env: string;
27
+ readonly cwd: string;
28
+ readonly stateNamespace: string;
29
+ readonly dryRun: boolean;
30
+ }
31
+ export type OblakaProvisioner = (input: ProvisionInput) => Promise<OblakaDeployResult>;
32
+ /** Hand the run's outcome back to the runner, which folds it into the terminal status the control plane reads. */
33
+ export type OutcomeWriter = (outcome: RunnerOutcomeFile) => Promise<void>;
34
+ export interface LoadedCloudflareConfig {
35
+ readonly config: CloudflareAppConfig;
36
+ readonly cwd: string;
37
+ }
38
+ export type CloudflareConfigLoader = (cwd: string, configPath: string) => Promise<LoadedCloudflareConfig>;
39
+ /** The contract an application root declares, or null when it has no `fabrika.contract.ts`. */
40
+ export type ContractReader = (root: string) => Promise<ContractArtifact | null>;
41
+ export interface CloudflareCollaborators {
42
+ readonly loadConfig: CloudflareConfigLoader;
43
+ readonly readContract: ContractReader;
44
+ readonly runCommand: CommandRunner;
45
+ readonly provision: OblakaProvisioner;
46
+ readonly writeOutcome: OutcomeWriter;
47
+ }
48
+ export declare const loadCloudflareConfig: (cwd: string, configPath: string) => Promise<LoadedCloudflareConfig & {
49
+ readonly absolutePath: string;
50
+ }>;
51
+ export declare const defaultCloudflareCollaborators: CloudflareCollaborators;
52
+ export type { SchemaReconciler };
@@ -0,0 +1,49 @@
1
+ import { type AppEnvironment } from '@fabrika/auth-core';
2
+ import type { CloudflareAppConfig } from './authoring';
3
+ import { type CloudflareDeployResult, type PlatformIamTarget } from './provider';
4
+ import { type RunnerApprovedAccess } from './runner-protocol';
5
+ /**
6
+ * Decode `FABRIKA_IAM_RETURN_ORIGINS`, the comma-separated set the installation's workflow hands the
7
+ * platform's own deploy (ADR-0022). Undefined for an absent or empty value, so a deploy with nothing to
8
+ * project leaves IAM's registry alone rather than clearing it. Part of the executor's environment
9
+ * contract, exported for the test that pins it; not part of the package's public surface.
10
+ */
11
+ export declare const parseReturnOrigins: (raw: string | undefined) => readonly string[] | undefined;
12
+ /**
13
+ * Decode `FABRIKA_CROSS_ORIGINS`, the environment's cross-origin list as the runner writes it. Undefined when absent or
14
+ * empty; anything malformed fails the deploy, and the proxy manifest's own parser judges each origin.
15
+ */
16
+ export declare const parseCrossOrigins: (raw: string | undefined) => readonly string[] | undefined;
17
+ /**
18
+ * Decode `FABRIKA_INSTALLATION_APPS`, the Cloudflare deployments Control registered, as the runner writes it.
19
+ * Undefined when absent; anything malformed fails the deploy rather than dropping the refusal it feeds.
20
+ */
21
+ export declare const parseInstallationApps: (raw: string | undefined) => readonly AppEnvironment[] | undefined;
22
+ /**
23
+ * Read the access Control approved for this run from the file at `FABRIKA_APPROVED_ACCESS_FILE`, as the runner
24
+ * writes it. Undefined when no runner set it (a local deploy); a file that is unreadable or malformed fails the deploy
25
+ * rather than falling back to the checkout.
26
+ */
27
+ export declare const readApprovedAccess: (path: string | undefined) => Promise<RunnerApprovedAccess | undefined>;
28
+ export interface LoadedCloudflareCommandConfig {
29
+ readonly config: CloudflareAppConfig;
30
+ readonly absolutePath: string;
31
+ readonly cwd: string;
32
+ }
33
+ export declare const loadCloudflareCommandConfig: (configPath: string, cwd: string) => Promise<LoadedCloudflareCommandConfig>;
34
+ export interface CloudflareCommandDeployOptions {
35
+ readonly env: string;
36
+ readonly configPath?: string;
37
+ readonly cwd?: string;
38
+ readonly dryRun?: boolean;
39
+ readonly stateNamespace?: string;
40
+ readonly managedVarNames?: readonly string[];
41
+ /** Defaults to `refuse`: only fabrika deploying its own components may name a platform resource. */
42
+ readonly platformResources?: 'refuse' | 'allow';
43
+ /** Where a platform deploy registers a component's schema (ADR-0058); only the installation sets it. */
44
+ readonly platformIam?: PlatformIamTarget;
45
+ readonly signal?: AbortSignal;
46
+ readonly log?: (line: string) => void;
47
+ }
48
+ /** Deploy one config with the account credentials, declared secrets and vars read from the environment. */
49
+ export declare const deployCloudflareConfig: (options: CloudflareCommandDeployOptions) => Promise<CloudflareDeployResult>;
@@ -0,0 +1,9 @@
1
+ import type { AppSchema } from '@fabrika/auth-core';
2
+ /**
3
+ * A config's IAM schema, parsed and deep-frozen. A config that still declares `gates` is refused: an application is
4
+ * protected by the endpoint table of its `fabrika.contract.ts`, and the platform's own services by theirs.
5
+ */
6
+ export declare const configSchema: (config: {
7
+ readonly gates?: unknown;
8
+ readonly schema?: unknown;
9
+ }) => AppSchema | null;
@@ -0,0 +1,39 @@
1
+ import { type ContractArtifact } from '@fabrika/auth-core';
2
+ import type { ProviderManagedEnvironment } from '@fabrika/provider-contract';
3
+ /**
4
+ * The longest a procedure's or a webhook's handler may run on Cloudflare. It runs inside the object's transaction, and
5
+ * workerd resets an object whose transaction runs about 30 s (docs/reference/cloudflare-platform.md).
6
+ */
7
+ export declare const CLOUDFLARE_MAX_HANDLER_MS = 25000;
8
+ /**
9
+ * Refuse what a contract declares that an application on Cloudflare cannot run yet (ADR-0065): a file kind that scans
10
+ * its uploads, raw SQL (`ctx.sql`), and a handler allowed to outlive the object's transaction limit.
11
+ */
12
+ export declare const assertCloudflareContract: (contract: ContractArtifact) => void;
13
+ /**
14
+ * The object runs due jobs and the file sweep of file kinds, a framework job, on the Worker's minute tick (ADR-0065 §5).
15
+ * Legacy `files` collections do not count: the object schedules no sweep of theirs.
16
+ */
17
+ export declare const needsMinuteTick: (contract: ContractArtifact) => boolean;
18
+ /**
19
+ * Whether framework release `release` is at least `since`. A prerelease counts as its `major.minor`; a release that
20
+ * does not start with `<major>.<minor>.` is never at least anything (ADR-0062).
21
+ */
22
+ export declare const releaseAtLeast: (release: string, since: {
23
+ readonly major: number;
24
+ readonly minor: number;
25
+ }) => boolean;
26
+ /**
27
+ * Whether an application on framework release `release` runs in its Durable Object. An older release's entry is a
28
+ * stateless Worker, which the platform keeps deploying in its old shape (ADR-0062).
29
+ */
30
+ export declare const runsInObject: (release: string) => boolean;
31
+ /** Whether the Cloudflare deploy of release `release` accepts only the generated entry and regenerates it. */
32
+ export declare const pinsGeneratedEntry: (release: string) => boolean;
33
+ /** Whether an environment on release `release` gets the ops row, the ops key digests and the object variables. */
34
+ export declare const servesOps: (release: string) => boolean;
35
+ /**
36
+ * Refuse what a stateless Worker of an older release cannot run: a job, a webhook, a public procedure, installation
37
+ * mail and token purposes all need the object's database or a Worker secret it never reads.
38
+ */
39
+ export declare const assertStatelessEnvironment: (managed: ProviderManagedEnvironment, release: string) => void;