@fabrika/provider-cloudflare 0.9.0-cloudflare.2 → 0.9.0-cloudflare.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { type AppEnvironment } from '@fabrika/auth-core';
1
+ import { type AppEnvironment, type ApplicationObjects } from '@fabrika/auth-core';
2
2
  import type { ControlProvider, ProviderCodec, ProviderSource, ProviderSourceBinding, ProviderSourceResolution, ProviderSourceResolutionInput, ProviderTerminalOutcome } from '@fabrika/provider-contract';
3
3
  import { z } from 'zod';
4
4
  import { type RunnerApprovedAccess, type RunnerIamReconcile } from './runner-protocol';
@@ -26,6 +26,8 @@ export interface CloudflareRunnerJob {
26
26
  readonly installationApps?: readonly string[];
27
27
  /** What the deployed proxy enforces and the application starts as; every run but a dry one carries it. */
28
28
  readonly approvedAccess?: RunnerApprovedAccess;
29
+ /** The serving object and the listed objects Control records (ADR-0070 §9); absent, the deployer's defaults. */
30
+ readonly applicationObjects?: ApplicationObjects;
29
31
  readonly dryRun?: boolean;
30
32
  /**
31
33
  * Shared secret the runner verifies before it touches D1 or the container; the binding alone proves
@@ -104,6 +106,19 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
104
106
  contract?: unknown;
105
107
  framework?: string | undefined;
106
108
  }>>;
109
+ applicationObjects: z.ZodOptional<z.ZodEffects<z.ZodObject<{
110
+ object: z.ZodString;
111
+ objects: z.ZodArray<z.ZodString, "many">;
112
+ }, "strict", z.ZodTypeAny, {
113
+ object: string;
114
+ objects: string[];
115
+ }, {
116
+ object: string;
117
+ objects: string[];
118
+ }>, ApplicationObjects, {
119
+ object: string;
120
+ objects: string[];
121
+ }>>;
107
122
  dryRun: z.ZodOptional<z.ZodBoolean>;
108
123
  secrets: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">, {
109
124
  [k: string]: string;
@@ -164,15 +179,16 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
164
179
  crossOrigins?: string[] | undefined;
165
180
  dryRun?: boolean | undefined;
166
181
  domain?: string | undefined;
167
- installationApps?: string[] | undefined;
168
- stateNamespace?: string | undefined;
182
+ managedEnvironment?: {
183
+ [k: string]: string;
184
+ } | undefined;
185
+ applicationObjects?: ApplicationObjects | undefined;
169
186
  configPath?: string | undefined;
187
+ stateNamespace?: string | undefined;
188
+ installationApps?: string[] | undefined;
170
189
  runnerKey?: string | undefined;
171
190
  workerDir?: string | undefined;
172
191
  approvedAccess?: RunnerApprovedAccess | undefined;
173
- managedEnvironment?: {
174
- [k: string]: string;
175
- } | undefined;
176
192
  artifactUpload?: {
177
193
  url: string;
178
194
  environment: string;
@@ -197,9 +213,14 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
197
213
  crossOrigins?: string[] | undefined;
198
214
  dryRun?: boolean | undefined;
199
215
  domain?: string | undefined;
200
- installationApps?: string[] | undefined;
201
- stateNamespace?: string | undefined;
216
+ managedEnvironment?: unknown;
217
+ applicationObjects?: {
218
+ object: string;
219
+ objects: string[];
220
+ } | undefined;
202
221
  configPath?: string | undefined;
222
+ stateNamespace?: string | undefined;
223
+ installationApps?: string[] | undefined;
203
224
  runnerKey?: string | undefined;
204
225
  workerDir?: string | undefined;
205
226
  approvedAccess?: {
@@ -208,7 +229,6 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
208
229
  contract?: unknown;
209
230
  framework?: string | undefined;
210
231
  } | undefined;
211
- managedEnvironment?: unknown;
212
232
  artifactUpload?: {
213
233
  url: string;
214
234
  environment: string;
@@ -237,15 +257,16 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
237
257
  crossOrigins?: string[] | undefined;
238
258
  dryRun?: boolean | undefined;
239
259
  domain?: string | undefined;
240
- installationApps?: string[] | undefined;
241
- stateNamespace?: string | undefined;
260
+ managedEnvironment?: {
261
+ [k: string]: string;
262
+ } | undefined;
263
+ applicationObjects?: ApplicationObjects | undefined;
242
264
  configPath?: string | undefined;
265
+ stateNamespace?: string | undefined;
266
+ installationApps?: string[] | undefined;
243
267
  runnerKey?: string | undefined;
244
268
  workerDir?: string | undefined;
245
269
  approvedAccess?: RunnerApprovedAccess | undefined;
246
- managedEnvironment?: {
247
- [k: string]: string;
248
- } | undefined;
249
270
  artifactUpload?: {
250
271
  url: string;
251
272
  environment: string;
@@ -270,9 +291,14 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
270
291
  crossOrigins?: string[] | undefined;
271
292
  dryRun?: boolean | undefined;
272
293
  domain?: string | undefined;
273
- installationApps?: string[] | undefined;
274
- stateNamespace?: string | undefined;
294
+ managedEnvironment?: unknown;
295
+ applicationObjects?: {
296
+ object: string;
297
+ objects: string[];
298
+ } | undefined;
275
299
  configPath?: string | undefined;
300
+ stateNamespace?: string | undefined;
301
+ installationApps?: string[] | undefined;
276
302
  runnerKey?: string | undefined;
277
303
  workerDir?: string | undefined;
278
304
  approvedAccess?: {
@@ -281,7 +307,6 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
281
307
  contract?: unknown;
282
308
  framework?: string | undefined;
283
309
  } | undefined;
284
- managedEnvironment?: unknown;
285
310
  artifactUpload?: {
286
311
  url: string;
287
312
  environment: string;
@@ -310,15 +335,16 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
310
335
  crossOrigins?: string[] | undefined;
311
336
  dryRun?: boolean | undefined;
312
337
  domain?: string | undefined;
313
- installationApps?: string[] | undefined;
314
- stateNamespace?: string | undefined;
338
+ managedEnvironment?: {
339
+ [k: string]: string;
340
+ } | undefined;
341
+ applicationObjects?: ApplicationObjects | undefined;
315
342
  configPath?: string | undefined;
343
+ stateNamespace?: string | undefined;
344
+ installationApps?: string[] | undefined;
316
345
  runnerKey?: string | undefined;
317
346
  workerDir?: string | undefined;
318
347
  approvedAccess?: RunnerApprovedAccess | undefined;
319
- managedEnvironment?: {
320
- [k: string]: string;
321
- } | undefined;
322
348
  artifactUpload?: {
323
349
  url: string;
324
350
  environment: string;
@@ -343,9 +369,14 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
343
369
  crossOrigins?: string[] | undefined;
344
370
  dryRun?: boolean | undefined;
345
371
  domain?: string | undefined;
346
- installationApps?: string[] | undefined;
347
- stateNamespace?: string | undefined;
372
+ managedEnvironment?: unknown;
373
+ applicationObjects?: {
374
+ object: string;
375
+ objects: string[];
376
+ } | undefined;
348
377
  configPath?: string | undefined;
378
+ stateNamespace?: string | undefined;
379
+ installationApps?: string[] | undefined;
349
380
  runnerKey?: string | undefined;
350
381
  workerDir?: string | undefined;
351
382
  approvedAccess?: {
@@ -354,7 +385,6 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
354
385
  contract?: unknown;
355
386
  framework?: string | undefined;
356
387
  } | undefined;
357
- managedEnvironment?: unknown;
358
388
  artifactUpload?: {
359
389
  url: string;
360
390
  environment: string;
@@ -383,15 +413,16 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
383
413
  crossOrigins?: string[] | undefined;
384
414
  dryRun?: boolean | undefined;
385
415
  domain?: string | undefined;
386
- installationApps?: string[] | undefined;
387
- stateNamespace?: string | undefined;
416
+ managedEnvironment?: {
417
+ [k: string]: string;
418
+ } | undefined;
419
+ applicationObjects?: ApplicationObjects | undefined;
388
420
  configPath?: string | undefined;
421
+ stateNamespace?: string | undefined;
422
+ installationApps?: string[] | undefined;
389
423
  runnerKey?: string | undefined;
390
424
  workerDir?: string | undefined;
391
425
  approvedAccess?: RunnerApprovedAccess | undefined;
392
- managedEnvironment?: {
393
- [k: string]: string;
394
- } | undefined;
395
426
  artifactUpload?: {
396
427
  url: string;
397
428
  environment: string;
@@ -416,9 +447,14 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
416
447
  crossOrigins?: string[] | undefined;
417
448
  dryRun?: boolean | undefined;
418
449
  domain?: string | undefined;
419
- installationApps?: string[] | undefined;
420
- stateNamespace?: string | undefined;
450
+ managedEnvironment?: unknown;
451
+ applicationObjects?: {
452
+ object: string;
453
+ objects: string[];
454
+ } | undefined;
421
455
  configPath?: string | undefined;
456
+ stateNamespace?: string | undefined;
457
+ installationApps?: string[] | undefined;
422
458
  runnerKey?: string | undefined;
423
459
  workerDir?: string | undefined;
424
460
  approvedAccess?: {
@@ -427,7 +463,6 @@ export declare const cloudflareRunnerJobSchema: z.ZodEffects<z.ZodEffects<z.ZodE
427
463
  contract?: unknown;
428
464
  framework?: string | undefined;
429
465
  } | undefined;
430
- managedEnvironment?: unknown;
431
466
  artifactUpload?: {
432
467
  url: string;
433
468
  environment: string;
@@ -0,0 +1,8 @@
1
+ import type { GeneratedConfig } from 'oblaka-iac';
2
+ /**
3
+ * The generated configs in the order `wrangler deploy` can take them: a Worker another generated config binds as a
4
+ * service goes first, because wrangler refuses a service binding to a script with no deployment yet (code 10145) —
5
+ * on a first deploy the proxy would otherwise reach the application Worker before it exists. Configs with no such
6
+ * dependency keep oblaka's order. A cycle has no first deploy, so it is refused.
7
+ */
8
+ export declare const deployOrder: (configs: readonly GeneratedConfig[]) => readonly GeneratedConfig[];
@@ -1,5 +1,5 @@
1
1
  export * from 'oblaka-iac';
2
- export { type CloudflareAppConfig, type CloudflareAppConfigInput, defineApp, isCloudflareAppConfig, type ResourceContext } from './authoring';
2
+ export { type ApplicationWorkerOptions, type CloudflareAppConfig, type CloudflareAppConfigInput, defineApp, isCloudflareAppConfig, type ResourceContext, } from './authoring';
3
3
  export { assertGeneratedConfigs, assertGeneration, generateWranglerConfigs } from './bounds';
4
4
  export type { ConfigGeneration, DeploymentBounds, GeneratedResource } from './bounds';
5
5
  export { parseCloudflareArgs, platformComponents } from './cli-args';
@@ -12,7 +12,7 @@ export { cloudflareStoredTargetCodec, createCloudflareControlProvider } from './
12
12
  export type { CloudflareCloneSource, CloudflareControlOptions, CloudflareRunnerJob, CloudflareStoredTarget } from './control';
13
13
  export { buildPlan, findMigratableDatabases, PLATFORM_RESOURCE_NAMES } from './plan';
14
14
  export type { CloudflareStep, CloudflareStepKind, MigratableDatabase } from './plan';
15
- export { type CloudflareDeployerOptions, type CloudflareDeployResult, type CloudflareDeployRun, createCloudflareDeployer } from './provider';
15
+ export { type CloudflareDeployerOptions, type CloudflareDeployResult, type CloudflareDeployRun, composeLocalApplication, createCloudflareDeployer, type LocalApplicationOptions, type StagedLocalAssets, stageLocalAssets, } from './provider';
16
16
  export { createCloudflareProxyWorker, IAM_APPLICATION_ENTRYPOINT, iamServiceReference, proxyManifestJson } from './proxy';
17
17
  export type { CloudflareProxyWorkerOptions } from './proxy';
18
18
  export { type AppSchemaParse, parseAppSchema } from './schema';
@@ -1,7 +1,10 @@
1
- import { type AppEnvironment } from '@fabrika/auth-core';
1
+ import { type AppEnvironment, type ApplicationObjects, type ContractArtifact } from '@fabrika/auth-core';
2
2
  import { type DeployStepResult, type ProviderManagedEnvironment, type SchemaReconciler } from '@fabrika/provider-contract';
3
+ import { Worker } from 'oblaka-iac';
4
+ import type { CloudflareAppConfig } from './authoring';
3
5
  import { type CloudflareCollaborators } from './collaborators';
4
6
  import type { RunnerApprovedAccess } from './runner-protocol';
7
+ import { type AssetMount } from './spa-assets';
5
8
  export interface CloudflareDeployerOptions {
6
9
  readonly accountId: string;
7
10
  readonly apiToken: string;
@@ -45,6 +48,8 @@ export interface CloudflareDeployRun {
45
48
  readonly approved?: RunnerApprovedAccess;
46
49
  /** Every Cloudflare deployment of the installation in Control's registry; a name of another application is refused. */
47
50
  readonly installationApps?: readonly AppEnvironment[];
51
+ /** The serving object and the listed objects Control records (ADR-0070 §9); absent, `application` and `rehearsal`. */
52
+ readonly applicationObjects?: ApplicationObjects;
48
53
  readonly dryRun: boolean;
49
54
  readonly signal: AbortSignal;
50
55
  readonly log: (line: string) => void;
@@ -56,3 +61,33 @@ export interface CloudflareDeployResult {
56
61
  readonly steps: readonly DeployStepResult[];
57
62
  }
58
63
  export declare const createCloudflareDeployer: (options: CloudflareDeployerOptions) => (run: CloudflareDeployRun) => Promise<CloudflareDeployResult>;
64
+ /** The SPA files `stageLocalAssets` staged for a local run: the mounts it copied, in the order a deploy stages them. */
65
+ export interface StagedLocalAssets {
66
+ readonly mounts: readonly AssetMount[];
67
+ readonly files: number;
68
+ }
69
+ /**
70
+ * Stage the contract's SPA and link mounts for a local run, with the code a deploy stages them with: each mount's
71
+ * built directory under `root` into `root/fabrika/assets`, where the generated `wrangler.jsonc` beside the config points
72
+ * its `ASSETS`. Run it before oblaka generates the config (`await` at the top of `oblaka.ts`) and after the SPA build.
73
+ */
74
+ export declare const stageLocalAssets: (contract: ContractArtifact, root: string) => Promise<StagedLocalAssets>;
75
+ /** What `composeLocalApplication` needs: the config, the contract it serves, and the IAM a local run reaches. */
76
+ export interface LocalApplicationOptions {
77
+ readonly config: CloudflareAppConfig;
78
+ readonly contract: ContractArtifact;
79
+ /** What `stageLocalAssets` staged; required when the contract has an SPA or link mount and the Worker no `assets`. */
80
+ readonly assets?: StagedLocalAssets;
81
+ /** IAM's origin, the issuer of the local run's tokens. */
82
+ readonly iamOrigin: string;
83
+ readonly env: string;
84
+ readonly domain?: string;
85
+ }
86
+ /**
87
+ * The proxy Worker and the application Worker of a local run (`oblaka.ts`, lopata), composed by the code a deploy runs:
88
+ * the platform's proxy over the contract's endpoint table, and the application's object, files bucket and repair tick,
89
+ * as a release that serves alarms gets them. No deploy takes it. With no Control to write them, the framework values
90
+ * come from here, and the proxy secret, which a deploy uploads as a Worker secret, is drawn anew on each call and
91
+ * written as a variable into the ignored `wrangler.jsonc`.
92
+ */
93
+ export declare const composeLocalApplication: (options: LocalApplicationOptions) => Worker;
@@ -26,6 +26,25 @@ export declare const INSTALLATION_APPS_ENV = "FABRIKA_INSTALLATION_APPS";
26
26
  export declare const CROSS_ORIGINS_ENV = "FABRIKA_CROSS_ORIGINS";
27
27
  /** The executor's copy of `CloudflareRunnerJob.operationsOrigin`: the origin of the environment's Operations ingest. */
28
28
  export declare const OPERATIONS_ORIGIN_ENV = "FABRIKA_OPERATIONS_ORIGIN";
29
+ /** The executor's copy of `CloudflareRunnerJob.applicationObjects`: JSON `{ object, objects }`, the pointer Control records. */
30
+ export declare const APPLICATION_OBJECTS_ENV = "FABRIKA_RUNNER_APPLICATION_OBJECTS";
31
+ /**
32
+ * The serving object and the listed objects as the job and the executor carry them: the shape `parseApplicationObjects`
33
+ * accepts, so a pointer the application would refuse never reaches a deploy.
34
+ */
35
+ export declare const applicationObjectsSchema: z.ZodEffects<z.ZodObject<{
36
+ object: z.ZodString;
37
+ objects: z.ZodArray<z.ZodString, "many">;
38
+ }, "strict", z.ZodTypeAny, {
39
+ object: string;
40
+ objects: string[];
41
+ }, {
42
+ object: string;
43
+ objects: string[];
44
+ }>, import("@fabrika/auth-core").ApplicationObjects, {
45
+ object: string;
46
+ objects: string[];
47
+ }>;
29
48
  /**
30
49
  * The access Control approved for a run (ADR-0050): the contract it read at the commit, in this release's model, and
31
50
  * the digest the application's own framework release computes for it. The proxy table and `FABRIKA_CONTRACT_DIGEST`
@@ -37,8 +56,10 @@ export interface RunnerApprovedAccess {
37
56
  readonly contract: ContractArtifact;
38
57
  readonly contractDigest: string;
39
58
  /**
40
- * The framework release whose reader read the application. It picks the Worker's shape: the Durable Object from
41
- * 0.9, the stateless Worker before it. Absent from a Control older than the runner, which deploys the older shape.
59
+ * The framework release the application pins (`applicationRelease`), which every release gate of the deployer reads:
60
+ * the Durable Object from 0.9, the stateless Worker before it. An older Control sends its reader's
61
+ * release here, a newer patch of the same minor. Absent from a Control older than the runner, which deploys the
62
+ * older shape.
42
63
  */
43
64
  readonly framework?: string;
44
65
  }
@@ -19,7 +19,8 @@ export declare const assetMounts: (contract: ContractArtifact) => readonly Asset
19
19
  * Copy each mount's build directory under `root` into `target` at its prefix, after removing whatever `target` held. A
20
20
  * file of a mount that lies under a longer mount's prefix is that mount's path, so it is left out; a source map is never
21
21
  * served (the platform build uploads it to Operations), so it is left out too, and so is Workers Assets' own
22
- * configuration at the root (`ASSET_CONFIG_PATHS`). A mount whose directory is missing, a symbolic link anywhere on
22
+ * configuration at the root (`ASSET_CONFIG_PATHS`), what the mount's `.assetsignore` excludes, and version control
23
+ * metadata (`VCS_NAMES`) at any depth. A mount whose directory is missing, a symbolic link anywhere on
23
24
  * its path or in its tree, or anything but a regular file or a directory is refused: the staged tree is uploaded
24
25
  * publicly, and a link would publish its target. `target` is `SPA_ASSETS_DIRECTORY` under `base`, with no link on the
25
26
  * way either. Returns how many files it staged.