@fabrika/provider-cloudflare 0.9.0-cloudflare.1 → 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.
- package/package.json +11 -10
- package/src/authoring.ts +56 -6
- package/src/bounds.ts +5 -2
- package/src/command.ts +22 -1
- package/src/contract-support.ts +126 -9
- package/src/control.ts +27 -7
- package/src/deploy-order.ts +35 -0
- package/src/index.ts +18 -2
- package/src/installation/templates/platform.yml +3 -0
- package/src/plan.ts +2 -0
- package/src/provider.ts +201 -33
- package/src/runner-protocol.ts +21 -3
- package/src/spa-assets.ts +176 -0
- package/types/src/authoring.d.ts +27 -5
- package/types/src/bounds.d.ts +5 -2
- package/types/src/command.d.ts +6 -1
- package/types/src/contract-support.d.ts +45 -4
- package/types/src/control.d.ts +68 -33
- package/types/src/deploy-order.d.ts +8 -0
- package/types/src/index.d.ts +2 -2
- package/types/src/provider.d.ts +36 -1
- package/types/src/runner-protocol.d.ts +23 -2
- package/types/src/spa-assets.d.ts +28 -0
package/types/src/authoring.d.ts
CHANGED
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
import { type AppConfigBase, type ProviderAuthoredApp } from '@fabrika/provider-contract';
|
|
2
|
-
import
|
|
2
|
+
import { Worker } from 'oblaka-iac';
|
|
3
3
|
/** Inputs used to materialize one environment's Cloudflare resource graph. */
|
|
4
4
|
export interface ResourceContext {
|
|
5
5
|
readonly env: string;
|
|
6
6
|
readonly domain?: string;
|
|
7
7
|
}
|
|
8
|
+
/** What an author may set on the application Worker `defineApp` builds; everything else is fixed by the platform. */
|
|
9
|
+
export interface ApplicationWorkerOptions {
|
|
10
|
+
/** The application's own bindings, beside `IAM`, which is always the platform's. */
|
|
11
|
+
readonly bindings?: Worker['options']['bindings'];
|
|
12
|
+
readonly compatibility_date?: string;
|
|
13
|
+
readonly compatibility_flags?: Worker['options']['compatibility_flags'];
|
|
14
|
+
}
|
|
15
|
+
/** A Cloudflare app config as `fabrika.config.ts` writes it. */
|
|
16
|
+
export type CloudflareAppConfigInput = AppConfigBase & ({
|
|
17
|
+
/**
|
|
18
|
+
* The application Worker, for a config that composes its own. The deployer builds the proxy Worker in front of it
|
|
19
|
+
* from the contract (ADR-0048); never return one.
|
|
20
|
+
*/
|
|
21
|
+
readonly resources: (ctx: ResourceContext) => Worker;
|
|
22
|
+
readonly worker?: never;
|
|
23
|
+
} | {
|
|
24
|
+
readonly resources?: never;
|
|
25
|
+
/** Without `resources`, `defineApp` builds the application Worker from these and the platform's fixed values. */
|
|
26
|
+
readonly worker?: ApplicationWorkerOptions;
|
|
27
|
+
});
|
|
8
28
|
/** A Cloudflare app config loaded from `fabrika.config.ts` inside the runner checkout. */
|
|
9
|
-
export interface
|
|
10
|
-
/** The application Worker. The deployer builds the proxy Worker in front of it from the contract (ADR-0048)
|
|
29
|
+
export interface CloudflareAppConfig extends AppConfigBase, ProviderAuthoredApp<'cloudflare'> {
|
|
30
|
+
/** The application Worker. The deployer builds the proxy Worker in front of it from the contract (ADR-0048). */
|
|
11
31
|
readonly resources: (ctx: ResourceContext) => Worker;
|
|
12
32
|
}
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Validate the app id and fill in the application Worker when the config composes none. The result always carries
|
|
35
|
+
* `resources`, because a runner narrows a loaded config with `isCloudflareAppConfig`, which requires it.
|
|
36
|
+
*/
|
|
15
37
|
export declare function defineApp(config: CloudflareAppConfigInput): CloudflareAppConfig;
|
|
16
38
|
/** Narrow an imported module default without trusting code from the checkout. */
|
|
17
39
|
export declare const isCloudflareAppConfig: (value: unknown) => value is CloudflareAppConfig;
|
package/types/src/bounds.d.ts
CHANGED
|
@@ -34,11 +34,14 @@ export interface DeploymentBounds {
|
|
|
34
34
|
/** What the platform gives a contract application's Worker (ADR-0065), or null outside one. */
|
|
35
35
|
readonly application: ApplicationRuntime | null;
|
|
36
36
|
}
|
|
37
|
-
/** The Durable Object, files bucket and
|
|
37
|
+
/** The Durable Object, files bucket and cron trigger of a contract application's Worker; the application authors none of them. */
|
|
38
38
|
export interface ApplicationRuntime {
|
|
39
39
|
/** The remote name of the environment's files bucket. */
|
|
40
40
|
readonly filesBucket: string;
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The cron triggers the Worker carries when the contract has a job or a file kind, else an empty list: the hourly repair
|
|
43
|
+
* tick of a release that serves alarms, otherwise the minute tick.
|
|
44
|
+
*/
|
|
42
45
|
readonly crons: readonly string[];
|
|
43
46
|
/**
|
|
44
47
|
* The absolute path of the entry the deploy regenerates, which the Worker's `main` must name (`pinsGeneratedEntry`), or
|
package/types/src/command.d.ts
CHANGED
|
@@ -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 { CloudflareAppConfig } from './authoring';
|
|
3
3
|
import { type CloudflareDeployResult, type PlatformIamTarget } from './provider';
|
|
4
4
|
import { type RunnerApprovedAccess } from './runner-protocol';
|
|
@@ -14,6 +14,11 @@ export declare const parseReturnOrigins: (raw: string | undefined) => readonly s
|
|
|
14
14
|
* empty; anything malformed fails the deploy, and the proxy manifest's own parser judges each origin.
|
|
15
15
|
*/
|
|
16
16
|
export declare const parseCrossOrigins: (raw: string | undefined) => readonly string[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Decode `FABRIKA_RUNNER_APPLICATION_OBJECTS`, the pointer Control recorded, as the runner writes it. Undefined when
|
|
19
|
+
* absent, and the deployer writes its defaults; anything malformed fails the deploy rather than move ordinary traffic.
|
|
20
|
+
*/
|
|
21
|
+
export declare const parseApplicationObjectsEnvironment: (raw: string | undefined) => ApplicationObjects | undefined;
|
|
17
22
|
/**
|
|
18
23
|
* Decode `FABRIKA_INSTALLATION_APPS`, the Cloudflare deployments Control registered, as the runner writes it.
|
|
19
24
|
* Undefined when absent; anything malformed fails the deploy rather than dropping the refusal it feeds.
|
|
@@ -5,14 +5,23 @@ import type { ProviderManagedEnvironment } from '@fabrika/provider-contract';
|
|
|
5
5
|
* workerd resets an object whose transaction runs about 30 s (docs/reference/cloudflare-platform.md).
|
|
6
6
|
*/
|
|
7
7
|
export declare const CLOUDFLARE_MAX_HANDLER_MS = 25000;
|
|
8
|
+
/** What the release a caller runs a contract as decides about it; each caller reads them off that release. */
|
|
9
|
+
export interface CloudflareContractGates {
|
|
10
|
+
/** The release caps a job at one segment (`capsJobSegments`). */
|
|
11
|
+
readonly capsSegments: boolean;
|
|
12
|
+
/** The release runs `ctx.sql` on the object's SQLite (`servesRawSql`). */
|
|
13
|
+
readonly servesSql: boolean;
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
16
|
* Refuse what a contract declares that an application on Cloudflare cannot run yet (ADR-0065): a file kind that scans
|
|
10
|
-
* its uploads,
|
|
17
|
+
* its uploads, a handler allowed to outlive the object's transaction limit, and, by the release it runs as, a job longer
|
|
18
|
+
* than one segment and raw SQL (`ctx.sql`).
|
|
11
19
|
*/
|
|
12
|
-
export declare const assertCloudflareContract: (contract: ContractArtifact) => void;
|
|
20
|
+
export declare const assertCloudflareContract: (contract: ContractArtifact, { capsSegments, servesSql }: CloudflareContractGates) => void;
|
|
13
21
|
/**
|
|
14
|
-
* The object runs due jobs and the file sweep of file kinds, a framework job,
|
|
15
|
-
*
|
|
22
|
+
* The object runs due jobs and the file sweep of file kinds, a framework job, from the Worker's cron trigger: the minute
|
|
23
|
+
* tick, or from `servesAlarms` its alarm with an hourly repair tick (ADR-0065 §5). Legacy `files` collections do not
|
|
24
|
+
* count: the object schedules no sweep of theirs.
|
|
16
25
|
*/
|
|
17
26
|
export declare const needsMinuteTick: (contract: ContractArtifact) => boolean;
|
|
18
27
|
/**
|
|
@@ -32,6 +41,38 @@ export declare const runsInObject: (release: string) => boolean;
|
|
|
32
41
|
export declare const pinsGeneratedEntry: (release: string) => boolean;
|
|
33
42
|
/** Whether an environment on release `release` gets the ops row, the ops key digests and the object variables. */
|
|
34
43
|
export declare const servesOps: (release: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether framework release `release` is at or above the exact version `since` in semver's precedence, prerelease
|
|
46
|
+
* included; a release that is not a semver version never is (ADR-0062).
|
|
47
|
+
*/
|
|
48
|
+
export declare const releaseFrom: (release: string, since: string) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The release a gate reads for an approved access: the application's pin, never the reader's `checker`, which is this
|
|
51
|
+
* platform's patch of the pin's minor and so passes a `releaseFrom` gate a prerelease pin does not. An access approved before Control recorded the pin is read as the oldest release of its
|
|
52
|
+
* reader's minor (`<major>.<minor>.0-0`): every `releaseAtLeast` gate answers as for that minor, and every `releaseFrom`
|
|
53
|
+
* gate of a prerelease or a patch fails closed, as for an older application, until a deploy reads its pin.
|
|
54
|
+
*/
|
|
55
|
+
export declare const applicationRelease: (access: {
|
|
56
|
+
readonly checker: string;
|
|
57
|
+
readonly framework?: string;
|
|
58
|
+
}) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the object of release `release` holds the maintenance barrier and serves Control's data operations: the
|
|
61
|
+
* backups, the migration phase and the side restore (ADR-0069 §3, ADR-0070).
|
|
62
|
+
*/
|
|
63
|
+
export declare const servesDataOperations: (release: string) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the Worker of release `release` gets the hourly repair tick instead of the minute tick: an older object runs
|
|
66
|
+
* its jobs only from the minute tick and has no alarm.
|
|
67
|
+
*/
|
|
68
|
+
export declare const servesAlarms: (release: string) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the Cloudflare deploy of release `release` refuses a job whose `timeoutMs` exceeds one segment
|
|
71
|
+
* (`CLOUDFLARE_MAX_JOB_SEGMENT_MS`). An older release deploys as it did (ADR-0062).
|
|
72
|
+
*/
|
|
73
|
+
export declare const capsJobSegments: (release: string) => boolean;
|
|
74
|
+
/** Whether an application on release `release` may declare `sql` on Cloudflare. */
|
|
75
|
+
export declare const servesRawSql: (release: string) => boolean;
|
|
35
76
|
/**
|
|
36
77
|
* Refuse what a stateless Worker of an older release cannot run: a job, a webhook, a public procedure, installation
|
|
37
78
|
* mail and token purposes all need the object's database or a Worker secret it never reads.
|
package/types/src/control.d.ts
CHANGED
|
@@ -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
|
-
|
|
168
|
-
|
|
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
|
-
|
|
201
|
-
|
|
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
|
-
|
|
241
|
-
|
|
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
|
-
|
|
274
|
-
|
|
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
|
-
|
|
314
|
-
|
|
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
|
-
|
|
347
|
-
|
|
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
|
-
|
|
387
|
-
|
|
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
|
-
|
|
420
|
-
|
|
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[];
|
package/types/src/index.d.ts
CHANGED
|
@@ -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';
|
package/types/src/provider.d.ts
CHANGED
|
@@ -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
|
|
41
|
-
* 0.9, the stateless Worker before it.
|
|
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
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContractArtifact } from '@fabrika/auth-core';
|
|
2
|
+
/** Where the deploy stages the mounts' files, beside the generated `wrangler.jsonc` of the application Worker. */
|
|
3
|
+
export declare const SPA_ASSETS_DIRECTORY = "fabrika/assets";
|
|
4
|
+
/** The `assets` the platform writes into an application Worker that declares none and has a mount with files. */
|
|
5
|
+
export declare const SPA_ASSETS: {
|
|
6
|
+
readonly directory: "fabrika/assets";
|
|
7
|
+
readonly binding: "ASSETS";
|
|
8
|
+
readonly run_worker_first: true;
|
|
9
|
+
};
|
|
10
|
+
/** A mount that serves files: its prefix, and its build directory relative to the application's root. */
|
|
11
|
+
export interface AssetMount {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly prefix: string;
|
|
14
|
+
readonly dir: string;
|
|
15
|
+
}
|
|
16
|
+
/** Every SPA and link mount of the contract with the directory its files come from, the most specific prefix first. */
|
|
17
|
+
export declare const assetMounts: (contract: ContractArtifact) => readonly AssetMount[];
|
|
18
|
+
/**
|
|
19
|
+
* Copy each mount's build directory under `root` into `target` at its prefix, after removing whatever `target` held. A
|
|
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
|
+
* 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`), 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
|
|
24
|
+
* its path or in its tree, or anything but a regular file or a directory is refused: the staged tree is uploaded
|
|
25
|
+
* publicly, and a link would publish its target. `target` is `SPA_ASSETS_DIRECTORY` under `base`, with no link on the
|
|
26
|
+
* way either. Returns how many files it staged.
|
|
27
|
+
*/
|
|
28
|
+
export declare const stageSpaAssets: (mounts: readonly AssetMount[], root: string, base: string) => Promise<number>;
|