@astrale-domains/services 0.5.1 → 0.7.0
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/README.md +115 -51
- package/dist/scaffold/create-service.mjs +94 -0
- package/dist/scaffold/template/.env.example +4 -0
- package/dist/scaffold/template/README.md +75 -0
- package/dist/scaffold/template/gitignore +6 -0
- package/dist/scaffold/template/scripts/build.mjs +20 -0
- package/dist/scaffold/template/scripts/deploy.mjs +65 -0
- package/dist/scaffold/template/scripts/service.mjs +69 -0
- package/dist/scaffold/template/src/account.js +31 -0
- package/dist/scaffold/template/src/index.js +50 -0
- package/dist/scaffold/template/src/job.js +22 -0
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/modules/deployment/classes/cloudflare-deployment.d.ts +15 -56
- package/dist/schema/modules/deployment/classes/deployment.d.ts +24 -61
- package/dist/schema/modules/deployment/classes/deployment.js +16 -9
- package/dist/schema/modules/deployment/index.d.ts +2 -2
- package/dist/schema/modules/deployment/index.js +1 -1
- package/dist/schema/modules/deployment/types/deployment-hosting.d.ts +19 -49
- package/dist/schema/modules/deployment/types/deployment-hosting.js +10 -10
- package/dist/schema/modules/deployment/types/deployment-request.d.ts +45 -93
- package/dist/schema/modules/deployment/types/deployment-request.js +60 -30
- package/dist/schema/modules/deployment/types/deployment-response.d.ts +14 -22
- package/dist/schema/modules/deployment/types/deployment-response.js +5 -2
- package/dist/schema/modules/deployment/types/deployment-secret.d.ts +2 -2
- package/dist/schema/modules/deployment/types/deployment-secret.js +2 -2
- package/dist/schema/modules/deployment/types/deployment-summary.d.ts +13 -112
- package/dist/schema/modules/deployment/types/deployment-summary.js +16 -18
- package/dist/schema/modules/deployment/types/index.d.ts +6 -12
- package/dist/schema/modules/deployment/types/index.js +3 -6
- package/dist/schema/modules/deployment/types/worker-configuration.d.ts +21 -0
- package/dist/schema/modules/deployment/types/worker-configuration.js +21 -0
- package/dist/schema/modules/deployment/types/worker-record.d.ts +12 -0
- package/dist/schema/modules/deployment/types/worker-record.js +15 -0
- package/dist/schema/modules/service/classes/cloudflare-service.d.ts +56 -135
- package/dist/schema/modules/service/classes/cloudflare-service.js +4 -1
- package/dist/schema/modules/service/classes/service.d.ts +8 -7
- package/dist/schema/modules/service/classes/service.js +8 -7
- package/dist/schema/modules/service/functions/deploy-service.d.ts +44 -100
- package/dist/schema/modules/service/functions/deploy-service.js +6 -5
- package/dist/schema/modules/service/functions/describe-hosting.d.ts +0 -1
- package/dist/schema/modules/service/functions/list-service-deployments.d.ts +12 -36
- package/dist/schema/schema.d.ts +83 -247
- package/package.json +11 -7
- package/dist/schema/modules/deployment/types/content/index.d.ts +0 -1
- package/dist/schema/modules/deployment/types/content/index.js +0 -1
- package/dist/schema/modules/deployment/types/content/limits.d.ts +0 -7
- package/dist/schema/modules/deployment/types/content/limits.js +0 -7
- package/dist/schema/modules/deployment/types/deployment-record.d.ts +0 -35
- package/dist/schema/modules/deployment/types/deployment-record.js +0 -31
- package/dist/schema/modules/deployment/types/frozen-configuration.d.ts +0 -52
- package/dist/schema/modules/deployment/types/frozen-configuration.js +0 -55
- package/dist/schema/modules/deployment/types/service-deployment-artifact-module.d.ts +0 -26
- package/dist/schema/modules/deployment/types/service-deployment-artifact-module.js +0 -10
- package/dist/schema/modules/deployment/types/service-deployment-assets.d.ts +0 -49
- package/dist/schema/modules/deployment/types/service-deployment-assets.js +0 -16
- package/dist/schema/modules/deployment/types/service-deployment-content.d.ts +0 -19
- package/dist/schema/modules/deployment/types/service-deployment-content.js +0 -24
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { runJob } from './job.js'
|
|
2
|
+
|
|
3
|
+
/** The call budget of one scheduled run, under the dispatcher's 10 s deadline. */
|
|
4
|
+
const JOB_BUDGET_MS = 9_000
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
/**
|
|
8
|
+
* Admin's Services serves this Worker at its deployment URL and at its Service's URL. A cron of
|
|
9
|
+
* the Service reaches it as `POST /__scheduled` from the Services dispatcher alone, with the cron
|
|
10
|
+
* in `x-astrale-cron` and the dispatcher's scheduled time (epoch ms, not rounded to the minute) in
|
|
11
|
+
* `x-astrale-scheduled-time`: the dispatcher refuses that path to the public, in every spelling.
|
|
12
|
+
*/
|
|
13
|
+
async fetch(request, env) {
|
|
14
|
+
const path = new URL(request.url).pathname
|
|
15
|
+
if (path === '/health' && request.method === 'GET') {
|
|
16
|
+
return new Response('ok', {
|
|
17
|
+
headers: { 'x-astrale-worker-version': env.ASTRALE_VERSION_METADATA?.id ?? '' },
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
if (path === '/__scheduled' && request.method === 'POST') return scheduled(request, env)
|
|
21
|
+
return new Response(null, { status: 404 })
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function scheduled(request, env) {
|
|
26
|
+
const cron = request.headers.get('x-astrale-cron')
|
|
27
|
+
const scheduledAt = Number(request.headers.get('x-astrale-scheduled-time'))
|
|
28
|
+
if (cron === null || !Number.isSafeInteger(scheduledAt) || scheduledAt <= 0) {
|
|
29
|
+
return new Response(null, { status: 400 })
|
|
30
|
+
}
|
|
31
|
+
const started = Date.now()
|
|
32
|
+
try {
|
|
33
|
+
await runJob({ cron, scheduledAt, env, signal: AbortSignal.timeout(JOB_BUDGET_MS) })
|
|
34
|
+
console.log(
|
|
35
|
+
JSON.stringify({ event: 'job.completed', cron, scheduledAt, ms: Date.now() - started }),
|
|
36
|
+
)
|
|
37
|
+
return Response.json({ status: 'completed' })
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Never log a credential, a provider envelope or a business value: only the error's code.
|
|
40
|
+
console.error(
|
|
41
|
+
JSON.stringify({
|
|
42
|
+
event: 'job.failed',
|
|
43
|
+
cron,
|
|
44
|
+
scheduledAt,
|
|
45
|
+
code: typeof error?.code === 'number' ? error.code : undefined,
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
return Response.json({ status: 'failed' }, { status: 503 })
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path'
|
|
2
|
+
|
|
3
|
+
import { openAccount } from './account.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The job one cron runs: call one callable of an Astrale Kernel as this Service's own account.
|
|
7
|
+
* Adapt its input to the target's contract; a repeated or uncertain run is the target's to absorb.
|
|
8
|
+
*/
|
|
9
|
+
export async function runJob({ cron, scheduledAt, env, signal }) {
|
|
10
|
+
if (!env.KERNEL || !env.TARGET || !env.ACCOUNT_PRIVATE_JWK) {
|
|
11
|
+
throw new Error('Configure KERNEL, TARGET and the ACCOUNT_PRIVATE_JWK secret.')
|
|
12
|
+
}
|
|
13
|
+
const session = openAccount(env.KERNEL, JSON.parse(env.ACCOUNT_PRIVATE_JWK))
|
|
14
|
+
try {
|
|
15
|
+
return await session.call(
|
|
16
|
+
{ target: Path.parse(env.TARGET), input: { cron, scheduledAt } },
|
|
17
|
+
{ signal },
|
|
18
|
+
)
|
|
19
|
+
} finally {
|
|
20
|
+
session.close()
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { schema } from './schema.js';
|
|
|
2
2
|
export type { ServicesDomain, ServicesSchema } from './schema.js';
|
|
3
3
|
export { ActAs, CloudflareService, OwnService, Service, TraverseOwnedService, serviceLifecycle, service_owned_by, } from './modules/service/index.js';
|
|
4
4
|
export type { ServiceLifecycle, ServiceLifecycleEvent } from './modules/service/index.js';
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
5
|
+
export { CloudflareDeployment, Deployment, OwnDeployment, TraverseOwnedServiceDeployment, current_deployment, deployment_of, deploymentHosting, deploymentLifecycle, deploymentRejection, deploymentRequest, deploymentResponse, deploymentSecretDigests, deploymentSecretRejection, deploymentSummary, retireDeploymentOutput, workerConfiguration, workerRecord, } from './modules/deployment/index.js';
|
|
6
|
+
export type { DeploymentHosting, DeploymentLifecycle, DeploymentLifecycleEvent, DeploymentRejection, DeploymentRejectionReason, DeploymentRequest, DeploymentResponse, DeploymentSecretDigest, DeploymentSecretRejection, DeploymentSummary, RetireDeploymentResult, WorkerConfiguration, WorkerRecordWire, } from './modules/deployment/index.js';
|
package/dist/schema/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { schema } from './schema.js';
|
|
2
2
|
export { ActAs, CloudflareService, OwnService, Service, TraverseOwnedService, serviceLifecycle, service_owned_by, } from './modules/service/index.js';
|
|
3
|
-
export {
|
|
3
|
+
export { CloudflareDeployment, Deployment, OwnDeployment, TraverseOwnedServiceDeployment, current_deployment, deployment_of, deploymentHosting, deploymentLifecycle, deploymentRejection, deploymentRequest, deploymentResponse, deploymentSecretDigests, deploymentSecretRejection, deploymentSummary, retireDeploymentOutput, workerConfiguration, workerRecord, } from './modules/deployment/index.js';
|
|
@@ -29,66 +29,25 @@ export declare const CloudflareDeployment: import("@astrale-os/sdk/schema").Auth
|
|
|
29
29
|
required?: boolean;
|
|
30
30
|
description?: string;
|
|
31
31
|
}>;
|
|
32
|
-
|
|
33
|
-
format: import("zod").ZodLiteral<"astrale.deployment-record">;
|
|
34
|
-
version: import("zod").ZodLiteral<1>;
|
|
35
|
-
origin: import("zod").ZodString;
|
|
36
|
-
environment: import("zod").ZodString;
|
|
37
|
-
releaseDigest: import("zod").ZodString;
|
|
38
|
-
buildDigest: import("zod").ZodString;
|
|
39
|
-
schemaRevision: import("zod").ZodString;
|
|
40
|
-
configuration: import("zod").ZodString;
|
|
41
|
-
providerScript: import("zod").ZodString;
|
|
42
|
-
commit: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
43
|
-
sha: import("zod").ZodString;
|
|
44
|
-
dirty: import("zod").ZodBoolean;
|
|
45
|
-
base: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
46
|
-
version: import("zod").ZodString;
|
|
47
|
-
distance: import("zod").ZodNumber;
|
|
48
|
-
}, import("zod/v4/core").$strict>>;
|
|
49
|
-
}, import("zod/v4/core").$strict>>;
|
|
50
|
-
}, import("zod/v4/core").$strict>;
|
|
32
|
+
buildDigest: import("zod").ZodString;
|
|
51
33
|
configuration: import("zod").ZodObject<{
|
|
52
|
-
format: import("zod").ZodLiteral<"astrale.
|
|
34
|
+
format: import("zod").ZodLiteral<"astrale.worker.configuration">;
|
|
53
35
|
version: import("zod").ZodLiteral<1>;
|
|
36
|
+
compatibilityDate: import("zod").ZodString;
|
|
37
|
+
compatibilityFlags: import("zod").ZodArray<import("zod").ZodString>;
|
|
54
38
|
vars: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
maximumLifetimeSeconds: import("zod").ZodNumber;
|
|
60
|
-
}, import("zod/v4/core").$strict>]>;
|
|
61
|
-
durableOptions: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
62
|
-
retentionMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
63
|
-
retry: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
64
|
-
initialIntervalMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
65
|
-
maxAttempts: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
66
|
-
maxIntervalMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
67
|
-
}, import("zod/v4/core").$strict>>;
|
|
68
|
-
stepTimeoutMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
69
|
-
}, import("zod/v4/core").$strict>>;
|
|
70
|
-
}, import("zod/v4/core").$strict>;
|
|
71
|
-
runtime: import("zod").ZodObject<{
|
|
72
|
-
compatibilityDate: import("zod").ZodString;
|
|
73
|
-
compatibilityFlags: import("zod").ZodArray<import("zod").ZodString>;
|
|
74
|
-
}, import("zod/v4/core").$strict>;
|
|
75
|
-
bindings: import("zod").ZodObject<{
|
|
76
|
-
services: import("zod").ZodArray<import("zod").ZodObject<{
|
|
77
|
-
name: import("zod").ZodString;
|
|
78
|
-
service: import("zod").ZodString;
|
|
79
|
-
}, import("zod/v4/core").$strict>>;
|
|
80
|
-
dispatchNamespaces: import("zod").ZodArray<import("zod").ZodObject<{
|
|
81
|
-
name: import("zod").ZodString;
|
|
82
|
-
namespace: import("zod").ZodString;
|
|
83
|
-
}, import("zod/v4/core").$strict>>;
|
|
84
|
-
secrets: import("zod").ZodArray<import("zod").ZodString>;
|
|
85
|
-
}, import("zod/v4/core").$strict>;
|
|
86
|
-
router: import("zod").ZodUnion<readonly [import("zod").ZodLiteral<false>, import("zod").ZodObject<{
|
|
87
|
-
service: import("zod").ZodString;
|
|
88
|
-
hostSuffix: import("zod").ZodString;
|
|
89
|
-
minLabels: import("zod").ZodNumber;
|
|
90
|
-
}, import("zod/v4/core").$strict>]>;
|
|
39
|
+
secrets: import("zod").ZodArray<import("zod").ZodString>;
|
|
40
|
+
record: import("zod").ZodBoolean;
|
|
41
|
+
signingIdentity: import("zod").ZodBoolean;
|
|
42
|
+
router: import("zod").ZodBoolean;
|
|
91
43
|
}, import("zod/v4/core").$strict>;
|
|
44
|
+
configurationDigest: import("zod").ZodString;
|
|
45
|
+
record: import("@astrale-os/sdk/schema").AuthoredProperty<import("zod").ZodObject<{
|
|
46
|
+
contentType: import("zod").ZodString;
|
|
47
|
+
contentBase64: import("zod").ZodString;
|
|
48
|
+
}, import("zod/v4/core").$strict>, {
|
|
49
|
+
readonly required: false;
|
|
50
|
+
}>;
|
|
92
51
|
secretDigests: import("@astrale-os/sdk/schema").AuthoredProperty<import("zod").ZodArray<import("zod").ZodObject<{
|
|
93
52
|
name: import("zod").ZodString;
|
|
94
53
|
digest: import("zod").ZodString;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
* One immutable deployment of one Service: one build
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* One immutable deployment of one Service: one Worker build with its configuration, served by one
|
|
4
|
+
* script at its own URL. It never changes code; a new release is a new deployment of the
|
|
5
|
+
* same Service. Only its secrets rotate in place, under the names its configuration declares.
|
|
6
|
+
* Services knows nothing of what the Worker serves: the record it publishes is opaque bytes.
|
|
7
7
|
*/
|
|
8
8
|
export declare const Deployment: import("@astrale-os/sdk/schema").AuthoredNodeClass<{
|
|
9
9
|
readonly abstract: true;
|
|
@@ -34,67 +34,29 @@ export declare const Deployment: import("@astrale-os/sdk/schema").AuthoredNodeCl
|
|
|
34
34
|
required?: boolean;
|
|
35
35
|
description?: string;
|
|
36
36
|
}>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
origin: z.ZodString;
|
|
41
|
-
environment: z.ZodString;
|
|
42
|
-
releaseDigest: z.ZodString;
|
|
43
|
-
buildDigest: z.ZodString;
|
|
44
|
-
schemaRevision: z.ZodString;
|
|
45
|
-
configuration: z.ZodString;
|
|
46
|
-
providerScript: z.ZodString;
|
|
47
|
-
commit: z.ZodNullable<z.ZodObject<{
|
|
48
|
-
sha: z.ZodString;
|
|
49
|
-
dirty: z.ZodBoolean;
|
|
50
|
-
base: z.ZodOptional<z.ZodObject<{
|
|
51
|
-
version: z.ZodString;
|
|
52
|
-
distance: z.ZodNumber;
|
|
53
|
-
}, z.core.$strict>>;
|
|
54
|
-
}, z.core.$strict>>;
|
|
55
|
-
}, z.core.$strict>;
|
|
56
|
-
/** The configuration frozen into this deployment; its digest is `record.configuration`. */
|
|
37
|
+
/** The build digest of the uploaded Worker, bound as `ASTRALE_BUILD_DIGEST`. */
|
|
38
|
+
buildDigest: z.ZodString;
|
|
39
|
+
/** The configuration frozen into this deployment. */
|
|
57
40
|
configuration: z.ZodObject<{
|
|
58
|
-
format: z.ZodLiteral<"astrale.
|
|
41
|
+
format: z.ZodLiteral<"astrale.worker.configuration">;
|
|
59
42
|
version: z.ZodLiteral<1>;
|
|
43
|
+
compatibilityDate: z.ZodString;
|
|
44
|
+
compatibilityFlags: z.ZodArray<z.ZodString>;
|
|
60
45
|
vars: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
maximumLifetimeSeconds: z.ZodNumber;
|
|
66
|
-
}, z.core.$strict>]>;
|
|
67
|
-
durableOptions: z.ZodOptional<z.ZodObject<{
|
|
68
|
-
retentionMs: z.ZodOptional<z.ZodNumber>;
|
|
69
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
70
|
-
initialIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
71
|
-
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
72
|
-
maxIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
73
|
-
}, z.core.$strict>>;
|
|
74
|
-
stepTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
75
|
-
}, z.core.$strict>>;
|
|
76
|
-
}, z.core.$strict>;
|
|
77
|
-
runtime: z.ZodObject<{
|
|
78
|
-
compatibilityDate: z.ZodString;
|
|
79
|
-
compatibilityFlags: z.ZodArray<z.ZodString>;
|
|
80
|
-
}, z.core.$strict>;
|
|
81
|
-
bindings: z.ZodObject<{
|
|
82
|
-
services: z.ZodArray<z.ZodObject<{
|
|
83
|
-
name: z.ZodString;
|
|
84
|
-
service: z.ZodString;
|
|
85
|
-
}, z.core.$strict>>;
|
|
86
|
-
dispatchNamespaces: z.ZodArray<z.ZodObject<{
|
|
87
|
-
name: z.ZodString;
|
|
88
|
-
namespace: z.ZodString;
|
|
89
|
-
}, z.core.$strict>>;
|
|
90
|
-
secrets: z.ZodArray<z.ZodString>;
|
|
91
|
-
}, z.core.$strict>;
|
|
92
|
-
router: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
|
|
93
|
-
service: z.ZodString;
|
|
94
|
-
hostSuffix: z.ZodString;
|
|
95
|
-
minLabels: z.ZodNumber;
|
|
96
|
-
}, z.core.$strict>]>;
|
|
46
|
+
secrets: z.ZodArray<z.ZodString>;
|
|
47
|
+
record: z.ZodBoolean;
|
|
48
|
+
signingIdentity: z.ZodBoolean;
|
|
49
|
+
router: z.ZodBoolean;
|
|
97
50
|
}, z.core.$strict>;
|
|
51
|
+
/** The digest of `configuration` (`workerConfigurationDigest`). */
|
|
52
|
+
configurationDigest: z.ZodString;
|
|
53
|
+
/** The record the deployment publishes, when its configuration asks for one. */
|
|
54
|
+
record: import("@astrale-os/sdk/schema").AuthoredProperty<z.ZodObject<{
|
|
55
|
+
contentType: z.ZodString;
|
|
56
|
+
contentBase64: z.ZodString;
|
|
57
|
+
}, z.core.$strict>, {
|
|
58
|
+
readonly required: false;
|
|
59
|
+
}>;
|
|
98
60
|
/** The keyed digest of each secret bound to this deployment, never a value. */
|
|
99
61
|
secretDigests: import("@astrale-os/sdk/schema").AuthoredProperty<z.ZodArray<z.ZodObject<{
|
|
100
62
|
name: z.ZodString;
|
|
@@ -109,6 +71,7 @@ export declare const Deployment: import("@astrale-os/sdk/schema").AuthoredNodeCl
|
|
|
109
71
|
scriptEtag: import("@astrale-os/sdk/schema").AuthoredProperty<z.ZodString, {
|
|
110
72
|
readonly required: false;
|
|
111
73
|
}>;
|
|
74
|
+
/** The thumbprint of the deployment's own key, when its configuration asks for one. */
|
|
112
75
|
signingKeyId: import("@astrale-os/sdk/schema").AuthoredProperty<z.ZodString, {
|
|
113
76
|
readonly required: false;
|
|
114
77
|
}>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { classIcon, K, nodeClass, property, schema as valueSchema, stateProperty, } from '@astrale-os/sdk/schema';
|
|
1
|
+
import { classIcon, fullMatch, K, nodeClass, property, schema as valueSchema, stateProperty, } from '@astrale-os/sdk/schema';
|
|
2
2
|
import { Rocket } from '@astrale-os/sdk/schema/icons';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { deploymentLifecycle } from '../states/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { deploymentSecretDigests, workerConfiguration, workerRecord } from '../types/index.js';
|
|
6
|
+
const digest = z.string().check(fullMatch('sha256:[0-9a-f]{64}'));
|
|
6
7
|
/**
|
|
7
|
-
* One immutable deployment of one Service: one build
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* One immutable deployment of one Service: one Worker build with its configuration, served by one
|
|
9
|
+
* script at its own URL. It never changes code; a new release is a new deployment of the
|
|
10
|
+
* same Service. Only its secrets rotate in place, under the names its configuration declares.
|
|
11
|
+
* Services knows nothing of what the Worker serves: the record it publishes is opaque bytes.
|
|
11
12
|
*/
|
|
12
13
|
export const Deployment = nodeClass({
|
|
13
14
|
abstract: true,
|
|
@@ -19,9 +20,14 @@ export const Deployment = nodeClass({
|
|
|
19
20
|
label: z.string().min(33).max(57),
|
|
20
21
|
url: z.string().min(1).max(2_048),
|
|
21
22
|
state: stateProperty(deploymentLifecycle),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
configuration
|
|
23
|
+
/** The build digest of the uploaded Worker, bound as `ASTRALE_BUILD_DIGEST`. */
|
|
24
|
+
buildDigest: digest,
|
|
25
|
+
/** The configuration frozen into this deployment. */
|
|
26
|
+
configuration: workerConfiguration,
|
|
27
|
+
/** The digest of `configuration` (`workerConfigurationDigest`). */
|
|
28
|
+
configurationDigest: digest,
|
|
29
|
+
/** The record the deployment publishes, when its configuration asks for one. */
|
|
30
|
+
record: property(workerRecord, { required: false }),
|
|
25
31
|
/** The keyed digest of each secret bound to this deployment, never a value. */
|
|
26
32
|
secretDigests: property(deploymentSecretDigests, { required: false }),
|
|
27
33
|
/**
|
|
@@ -29,6 +35,7 @@ export const Deployment = nodeClass({
|
|
|
29
35
|
* identifies the deployment; a secret rewritten in place keeps it, unlike a provider version.
|
|
30
36
|
*/
|
|
31
37
|
scriptEtag: property(z.string().min(1).max(128), { required: false }),
|
|
38
|
+
/** The thumbprint of the deployment's own key, when its configuration asks for one. */
|
|
32
39
|
signingKeyId: property(z.string().min(1).max(128), { required: false }),
|
|
33
40
|
activatedAt: property(valueSchema.values.instant, { required: false }),
|
|
34
41
|
retiredAt: property(valueSchema.values.instant, { required: false }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { deploymentHosting, deploymentRejection, deploymentRejectionReason, deploymentRequest, deploymentResponse, deploymentSecretDigest, deploymentSecretDigests, deploymentSecretRejection, deploymentSummary, listDeploymentsInput, listDeploymentsOutput, retireDeploymentInput, retireDeploymentOutput, workerConfiguration, workerRecord, } from './types/index.js';
|
|
2
|
+
export type { DeploymentHosting, DeploymentRejection, DeploymentRejectionReason, DeploymentRequest, DeploymentResponse, DeploymentSecretDigest, DeploymentSecretRejection, DeploymentSummary, RetireDeploymentResult, WorkerConfiguration, WorkerRecordWire, } from './types/index.js';
|
|
3
3
|
export { CloudflareDeployment, Deployment, current_deployment, deployment_of, } from './classes/index.js';
|
|
4
4
|
export { deploymentHostingUnavailable, deploymentNotFound } from './errors/index.js';
|
|
5
5
|
export { retireDeployment } from './functions/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Types first: the service module's Methods read them while this module's classes, which refer
|
|
2
2
|
// to the Service class, are still evaluating.
|
|
3
|
-
export {
|
|
3
|
+
export { deploymentHosting, deploymentRejection, deploymentRejectionReason, deploymentRequest, deploymentResponse, deploymentSecretDigest, deploymentSecretDigests, deploymentSecretRejection, deploymentSummary, listDeploymentsInput, listDeploymentsOutput, retireDeploymentInput, retireDeploymentOutput, workerConfiguration, workerRecord, } from './types/index.js';
|
|
4
4
|
export { CloudflareDeployment, Deployment, current_deployment, deployment_of, } from './classes/index.js';
|
|
5
5
|
export { deploymentHostingUnavailable, deploymentNotFound } from './errors/index.js';
|
|
6
6
|
export { retireDeployment } from './functions/index.js';
|
|
@@ -1,62 +1,27 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* `WorkerHostingV1`: the routing domain Services and deployments are addressed under. Every name is
|
|
4
|
+
* opaque: `https://<service>.<routing domain>` serves a Service, `https://<label>.<routing domain>`
|
|
5
|
+
* one deployment.
|
|
6
|
+
*/
|
|
3
7
|
export declare const deploymentHosting: z.ZodObject<{
|
|
4
8
|
routingDomain: z.ZodString;
|
|
5
|
-
addressing: z.ZodLiteral<"opaque">;
|
|
6
9
|
}, z.core.$strict>;
|
|
10
|
+
/** `WorkerDeploymentListRequestV1`: the caller's deployments, of one project or environment. */
|
|
7
11
|
export declare const listDeploymentsInput: z.ZodObject<{
|
|
8
|
-
|
|
12
|
+
project: z.ZodOptional<z.ZodString>;
|
|
9
13
|
environment: z.ZodOptional<z.ZodString>;
|
|
10
14
|
}, z.core.$strict>;
|
|
11
|
-
/**
|
|
12
|
-
* The deployments of the caller's Services. A deployment whose stored record or configuration this
|
|
13
|
-
* Services SDK no longer admits is listed from its facts with its record as stored, never dropped,
|
|
14
|
-
* and never fails the listing.
|
|
15
|
-
*/
|
|
15
|
+
/** The deployments of the caller's Services, by creation then label. */
|
|
16
16
|
export declare const listDeploymentsOutput: z.ZodObject<{
|
|
17
|
-
deployments: z.ZodArray<z.
|
|
18
|
-
id: z.ZodString;
|
|
19
|
-
url: z.ZodString;
|
|
20
|
-
label: z.ZodString;
|
|
21
|
-
serviceId: z.ZodString;
|
|
22
|
-
service: z.ZodString;
|
|
23
|
-
owner: z.ZodString;
|
|
24
|
-
state: z.ZodEnum<{
|
|
25
|
-
active: "active";
|
|
26
|
-
deploying: "deploying";
|
|
27
|
-
failed: "failed";
|
|
28
|
-
retired: "retired";
|
|
29
|
-
retiring: "retiring";
|
|
30
|
-
}>;
|
|
31
|
-
current: z.ZodBoolean;
|
|
32
|
-
createdAt: z.ZodString;
|
|
33
|
-
retiredAt: z.ZodOptional<z.ZodString>;
|
|
34
|
-
signingKeyId: z.ZodString;
|
|
35
|
-
record: z.ZodObject<{
|
|
36
|
-
format: z.ZodLiteral<"astrale.deployment-record">;
|
|
37
|
-
version: z.ZodLiteral<1>;
|
|
38
|
-
origin: z.ZodString;
|
|
39
|
-
environment: z.ZodString;
|
|
40
|
-
releaseDigest: z.ZodString;
|
|
41
|
-
buildDigest: z.ZodString;
|
|
42
|
-
schemaRevision: z.ZodString;
|
|
43
|
-
configuration: z.ZodString;
|
|
44
|
-
providerScript: z.ZodString;
|
|
45
|
-
commit: z.ZodNullable<z.ZodObject<{
|
|
46
|
-
sha: z.ZodString;
|
|
47
|
-
dirty: z.ZodBoolean;
|
|
48
|
-
base: z.ZodOptional<z.ZodObject<{
|
|
49
|
-
version: z.ZodString;
|
|
50
|
-
distance: z.ZodNumber;
|
|
51
|
-
}, z.core.$strict>>;
|
|
52
|
-
}, z.core.$strict>>;
|
|
53
|
-
}, z.core.$strict>;
|
|
54
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
17
|
+
deployments: z.ZodArray<z.ZodObject<{
|
|
55
18
|
id: z.ZodString;
|
|
56
19
|
url: z.ZodString;
|
|
57
20
|
label: z.ZodString;
|
|
58
21
|
serviceId: z.ZodString;
|
|
59
22
|
service: z.ZodString;
|
|
23
|
+
project: z.ZodString;
|
|
24
|
+
environment: z.ZodString;
|
|
60
25
|
owner: z.ZodString;
|
|
61
26
|
state: z.ZodEnum<{
|
|
62
27
|
active: "active";
|
|
@@ -68,8 +33,13 @@ export declare const listDeploymentsOutput: z.ZodObject<{
|
|
|
68
33
|
current: z.ZodBoolean;
|
|
69
34
|
createdAt: z.ZodString;
|
|
70
35
|
retiredAt: z.ZodOptional<z.ZodString>;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
36
|
+
buildDigest: z.ZodString;
|
|
37
|
+
configuration: z.ZodString;
|
|
38
|
+
signingKeyId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
record: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
contentType: z.ZodString;
|
|
41
|
+
contentBase64: z.ZodString;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
}, z.core.$strict>>;
|
|
74
44
|
}, z.core.$strict>;
|
|
75
45
|
export type DeploymentHosting = z.output<typeof deploymentHosting>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
2
|
+
import { deploymentSummary } from './deployment-summary.js';
|
|
3
|
+
/**
|
|
4
|
+
* `WorkerHostingV1`: the routing domain Services and deployments are addressed under. Every name is
|
|
5
|
+
* opaque: `https://<service>.<routing domain>` serves a Service, `https://<label>.<routing domain>`
|
|
6
|
+
* one deployment.
|
|
7
|
+
*/
|
|
4
8
|
export const deploymentHosting = z.strictObject({
|
|
5
9
|
routingDomain: z.string().min(1).max(253),
|
|
6
|
-
addressing: z.literal('opaque'),
|
|
7
10
|
});
|
|
11
|
+
/** `WorkerDeploymentListRequestV1`: the caller's deployments, of one project or environment. */
|
|
8
12
|
export const listDeploymentsInput = z.strictObject({
|
|
9
|
-
|
|
13
|
+
project: z.string().min(1).max(253).optional(),
|
|
10
14
|
environment: z.string().min(1).max(63).optional(),
|
|
11
15
|
});
|
|
12
|
-
/**
|
|
13
|
-
* The deployments of the caller's Services. A deployment whose stored record or configuration this
|
|
14
|
-
* Services SDK no longer admits is listed from its facts with its record as stored, never dropped,
|
|
15
|
-
* and never fails the listing.
|
|
16
|
-
*/
|
|
16
|
+
/** The deployments of the caller's Services, by creation then label. */
|
|
17
17
|
export const listDeploymentsOutput = z.strictObject({
|
|
18
|
-
deployments: z.array(
|
|
18
|
+
deployments: z.array(deploymentSummary),
|
|
19
19
|
});
|