@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,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The `WorkerConfigurationV1` (`@astrale-os/sdk/deployment/worker`) one deployment freezes beside
|
|
4
|
+
* its build: the Workers runtime it runs on, its plain variables, the names of its secrets (never
|
|
5
|
+
* their values) and what it asks of its host: the record it publishes, a signing identity of its
|
|
6
|
+
* own, the router. Its digest and the build digest make the deployment's label. This shape only
|
|
7
|
+
* bounds what a request and the graph carry; the SDK's `acceptWorkerConfiguration` admits its
|
|
8
|
+
* exact canonical form.
|
|
9
|
+
*/
|
|
10
|
+
export declare const workerConfiguration: z.ZodObject<{
|
|
11
|
+
format: z.ZodLiteral<"astrale.worker.configuration">;
|
|
12
|
+
version: z.ZodLiteral<1>;
|
|
13
|
+
compatibilityDate: z.ZodString;
|
|
14
|
+
compatibilityFlags: z.ZodArray<z.ZodString>;
|
|
15
|
+
vars: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
16
|
+
secrets: z.ZodArray<z.ZodString>;
|
|
17
|
+
record: z.ZodBoolean;
|
|
18
|
+
signingIdentity: z.ZodBoolean;
|
|
19
|
+
router: z.ZodBoolean;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
export type WorkerConfiguration = z.output<typeof workerConfiguration>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const name = z.string().min(1).max(128);
|
|
3
|
+
/**
|
|
4
|
+
* The `WorkerConfigurationV1` (`@astrale-os/sdk/deployment/worker`) one deployment freezes beside
|
|
5
|
+
* its build: the Workers runtime it runs on, its plain variables, the names of its secrets (never
|
|
6
|
+
* their values) and what it asks of its host: the record it publishes, a signing identity of its
|
|
7
|
+
* own, the router. Its digest and the build digest make the deployment's label. This shape only
|
|
8
|
+
* bounds what a request and the graph carry; the SDK's `acceptWorkerConfiguration` admits its
|
|
9
|
+
* exact canonical form.
|
|
10
|
+
*/
|
|
11
|
+
export const workerConfiguration = z.strictObject({
|
|
12
|
+
format: z.literal('astrale.worker.configuration'),
|
|
13
|
+
version: z.literal(1),
|
|
14
|
+
compatibilityDate: z.string().min(10).max(10),
|
|
15
|
+
compatibilityFlags: z.array(name).max(64),
|
|
16
|
+
vars: z.record(name, z.string().max(64 * 1024)),
|
|
17
|
+
secrets: z.array(name).max(64),
|
|
18
|
+
record: z.boolean(),
|
|
19
|
+
signingIdentity: z.boolean(),
|
|
20
|
+
router: z.boolean(),
|
|
21
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The record one deployment publishes (`WorkerRecordWireV1`): opaque bytes, as canonical Base64,
|
|
4
|
+
* and the media type the dispatcher serves them with at `/.well-known/astrale/deployment.json`.
|
|
5
|
+
* Services never reads it: it is the deployer's, and a deployment keeps the record it was created
|
|
6
|
+
* with. The SDK's `decodeWorkerRecord` admits it exactly.
|
|
7
|
+
*/
|
|
8
|
+
export declare const workerRecord: z.ZodObject<{
|
|
9
|
+
contentType: z.ZodString;
|
|
10
|
+
contentBase64: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type WorkerRecordWire = z.output<typeof workerRecord>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WORKER_DEPLOYMENT_LIMITS } from '@astrale-os/sdk/deployment/worker';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* The record one deployment publishes (`WorkerRecordWireV1`): opaque bytes, as canonical Base64,
|
|
5
|
+
* and the media type the dispatcher serves them with at `/.well-known/astrale/deployment.json`.
|
|
6
|
+
* Services never reads it: it is the deployer's, and a deployment keeps the record it was created
|
|
7
|
+
* with. The SDK's `decodeWorkerRecord` admits it exactly.
|
|
8
|
+
*/
|
|
9
|
+
export const workerRecord = z.strictObject({
|
|
10
|
+
contentType: z.string().min(3).max(256),
|
|
11
|
+
contentBase64: z
|
|
12
|
+
.string()
|
|
13
|
+
.min(4)
|
|
14
|
+
.max(Math.ceil(WORKER_DEPLOYMENT_LIMITS.recordSize / 3) * 4),
|
|
15
|
+
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* One Service whose deployments are Cloudflare Workers for Platforms scripts: any Cloudflare
|
|
3
|
+
* Worker, an Astrale Domain release or a generic Worker (an API, a cron job) alike.
|
|
4
|
+
*/
|
|
2
5
|
export declare const CloudflareService: import("@astrale-os/sdk/schema").AuthoredNodeClass<{
|
|
3
6
|
readonly description: "One Service whose deployments are Cloudflare Workers for Platforms scripts.";
|
|
4
7
|
readonly icon: import("@astrale-os/sdk/schema").ClassIcon;
|
|
@@ -8,7 +11,7 @@ export declare const CloudflareService: import("@astrale-os/sdk/schema").Authore
|
|
|
8
11
|
readonly icon: import("@astrale-os/sdk/schema").ClassIcon;
|
|
9
12
|
readonly extends: readonly [import("@astrale-os/sdk/schema").KernelClass<"Named">, import("@astrale-os/sdk/schema").KernelClass<"Timestamped">];
|
|
10
13
|
readonly properties: {
|
|
11
|
-
|
|
14
|
+
project: import("zod").ZodString;
|
|
12
15
|
environment: import("zod").ZodString;
|
|
13
16
|
fingerprint: import("zod").ZodString;
|
|
14
17
|
url: import("zod").ZodString;
|
|
@@ -25,73 +28,30 @@ export declare const CloudflareService: import("@astrale-os/sdk/schema").Authore
|
|
|
25
28
|
}>];
|
|
26
29
|
readonly methods: {
|
|
27
30
|
deploy: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<{
|
|
28
|
-
format: "astrale.
|
|
31
|
+
format: "astrale.worker.deployment-request";
|
|
29
32
|
version: 1;
|
|
30
33
|
owner?: string | undefined;
|
|
31
|
-
|
|
34
|
+
project: string;
|
|
32
35
|
environment: string;
|
|
33
|
-
addressing: "opaque";
|
|
34
36
|
label: string;
|
|
35
37
|
buildDigest: string;
|
|
36
38
|
configuration: {
|
|
37
|
-
format: "astrale.
|
|
39
|
+
format: "astrale.worker.configuration";
|
|
38
40
|
version: 1;
|
|
41
|
+
compatibilityDate: string;
|
|
42
|
+
compatibilityFlags: string[];
|
|
39
43
|
vars: Record<string, string>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
maximumLifetimeSeconds: number;
|
|
45
|
-
};
|
|
46
|
-
durableOptions?: {
|
|
47
|
-
retentionMs?: number | undefined;
|
|
48
|
-
retry?: {
|
|
49
|
-
initialIntervalMs?: number | undefined;
|
|
50
|
-
maxAttempts?: number | undefined;
|
|
51
|
-
maxIntervalMs?: number | undefined;
|
|
52
|
-
} | undefined;
|
|
53
|
-
stepTimeoutMs?: number | undefined;
|
|
54
|
-
} | undefined;
|
|
55
|
-
};
|
|
56
|
-
runtime: {
|
|
57
|
-
compatibilityDate: string;
|
|
58
|
-
compatibilityFlags: string[];
|
|
59
|
-
};
|
|
60
|
-
bindings: {
|
|
61
|
-
services: {
|
|
62
|
-
name: string;
|
|
63
|
-
service: string;
|
|
64
|
-
}[];
|
|
65
|
-
dispatchNamespaces: {
|
|
66
|
-
name: string;
|
|
67
|
-
namespace: string;
|
|
68
|
-
}[];
|
|
69
|
-
secrets: string[];
|
|
70
|
-
};
|
|
71
|
-
router: false | {
|
|
72
|
-
service: string;
|
|
73
|
-
hostSuffix: string;
|
|
74
|
-
minLabels: number;
|
|
75
|
-
};
|
|
44
|
+
secrets: string[];
|
|
45
|
+
record: boolean;
|
|
46
|
+
signingIdentity: boolean;
|
|
47
|
+
router: boolean;
|
|
76
48
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
schemaBundle: string;
|
|
81
|
-
commit: {
|
|
82
|
-
sha: string;
|
|
83
|
-
dirty: boolean;
|
|
84
|
-
base?: {
|
|
85
|
-
version: string;
|
|
86
|
-
distance: number;
|
|
87
|
-
} | undefined;
|
|
88
|
-
} | null;
|
|
89
|
-
};
|
|
90
|
-
bundle: {
|
|
91
|
-
entrypoint: string;
|
|
49
|
+
worker: {
|
|
50
|
+
manifest: Record<string, unknown>;
|
|
51
|
+
mainModule: string;
|
|
92
52
|
modules: {
|
|
93
53
|
name: string;
|
|
94
|
-
kind
|
|
54
|
+
kind: "data" | "esm" | "text" | "wasm";
|
|
95
55
|
content: {
|
|
96
56
|
encoding: "gzip" | "identity";
|
|
97
57
|
decodedSize: number;
|
|
@@ -103,29 +63,26 @@ export declare const CloudflareService: import("@astrale-os/sdk/schema").Authore
|
|
|
103
63
|
};
|
|
104
64
|
}[];
|
|
105
65
|
assets?: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}[];
|
|
119
|
-
notFound?: "404-page" | "none" | "single-page-application" | undefined;
|
|
120
|
-
runWorkerFirst?: boolean | undefined;
|
|
121
|
-
htmlHandling?: "none" | undefined;
|
|
122
|
-
} | undefined;
|
|
66
|
+
path: string;
|
|
67
|
+
contentType?: string | undefined;
|
|
68
|
+
content: {
|
|
69
|
+
encoding: "gzip" | "identity";
|
|
70
|
+
decodedSize: number;
|
|
71
|
+
contentBase64: string;
|
|
72
|
+
} | {
|
|
73
|
+
encoding: "gzip" | "identity";
|
|
74
|
+
decodedSize: number;
|
|
75
|
+
contentBase64Chunks: string[];
|
|
76
|
+
};
|
|
77
|
+
}[] | undefined;
|
|
123
78
|
};
|
|
79
|
+
record?: {
|
|
80
|
+
contentType: string;
|
|
81
|
+
contentBase64: string;
|
|
82
|
+
} | undefined;
|
|
83
|
+
readiness?: string[] | undefined;
|
|
124
84
|
secrets: Record<string, string>;
|
|
125
85
|
promote?: boolean | undefined;
|
|
126
|
-
readiness?: {
|
|
127
|
-
paths: string[];
|
|
128
|
-
} | undefined;
|
|
129
86
|
}, {
|
|
130
87
|
readonly mode: 'value';
|
|
131
88
|
readonly value: {
|
|
@@ -145,31 +102,20 @@ export declare const CloudflareService: import("@astrale-os/sdk/schema").Authore
|
|
|
145
102
|
label: string;
|
|
146
103
|
serviceId: string;
|
|
147
104
|
service: string;
|
|
105
|
+
project: string;
|
|
106
|
+
environment: string;
|
|
148
107
|
owner: string;
|
|
149
108
|
state: "active" | "deploying" | "failed" | "retired" | "retiring";
|
|
150
109
|
current: boolean;
|
|
151
110
|
createdAt: string;
|
|
152
111
|
retiredAt?: string | undefined;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
buildDigest: string;
|
|
161
|
-
schemaRevision: string;
|
|
162
|
-
configuration: string;
|
|
163
|
-
providerScript: string;
|
|
164
|
-
commit: {
|
|
165
|
-
sha: string;
|
|
166
|
-
dirty: boolean;
|
|
167
|
-
base?: {
|
|
168
|
-
version: string;
|
|
169
|
-
distance: number;
|
|
170
|
-
} | undefined;
|
|
171
|
-
} | null;
|
|
172
|
-
};
|
|
112
|
+
buildDigest: string;
|
|
113
|
+
configuration: string;
|
|
114
|
+
signingKeyId?: string | undefined;
|
|
115
|
+
record?: {
|
|
116
|
+
contentType: string;
|
|
117
|
+
contentBase64: string;
|
|
118
|
+
} | undefined;
|
|
173
119
|
};
|
|
174
120
|
};
|
|
175
121
|
}, "authenticated", true, false, undefined>>;
|
|
@@ -177,60 +123,35 @@ export declare const CloudflareService: import("@astrale-os/sdk/schema").Authore
|
|
|
177
123
|
readonly mode: 'value';
|
|
178
124
|
readonly value: {
|
|
179
125
|
routingDomain: string;
|
|
180
|
-
addressing: "opaque";
|
|
181
126
|
};
|
|
182
127
|
}, "authenticated", true, false, undefined>>;
|
|
183
128
|
list: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<{
|
|
184
|
-
|
|
129
|
+
project?: string | undefined;
|
|
185
130
|
environment?: string | undefined;
|
|
186
131
|
}, {
|
|
187
132
|
readonly mode: 'value';
|
|
188
133
|
readonly value: {
|
|
189
|
-
deployments:
|
|
190
|
-
id: string;
|
|
191
|
-
url: string;
|
|
192
|
-
label: string;
|
|
193
|
-
serviceId: string;
|
|
194
|
-
service: string;
|
|
195
|
-
owner: string;
|
|
196
|
-
state: "active" | "deploying" | "failed" | "retired" | "retiring";
|
|
197
|
-
current: boolean;
|
|
198
|
-
createdAt: string;
|
|
199
|
-
retiredAt?: string | undefined;
|
|
200
|
-
signingKeyId: string;
|
|
201
|
-
record: {
|
|
202
|
-
format: "astrale.deployment-record";
|
|
203
|
-
version: 1;
|
|
204
|
-
origin: string;
|
|
205
|
-
environment: string;
|
|
206
|
-
releaseDigest: string;
|
|
207
|
-
buildDigest: string;
|
|
208
|
-
schemaRevision: string;
|
|
209
|
-
configuration: string;
|
|
210
|
-
providerScript: string;
|
|
211
|
-
commit: {
|
|
212
|
-
sha: string;
|
|
213
|
-
dirty: boolean;
|
|
214
|
-
base?: {
|
|
215
|
-
version: string;
|
|
216
|
-
distance: number;
|
|
217
|
-
} | undefined;
|
|
218
|
-
} | null;
|
|
219
|
-
};
|
|
220
|
-
} | {
|
|
134
|
+
deployments: {
|
|
221
135
|
id: string;
|
|
222
136
|
url: string;
|
|
223
137
|
label: string;
|
|
224
138
|
serviceId: string;
|
|
225
139
|
service: string;
|
|
140
|
+
project: string;
|
|
141
|
+
environment: string;
|
|
226
142
|
owner: string;
|
|
227
143
|
state: "active" | "deploying" | "failed" | "retired" | "retiring";
|
|
228
144
|
current: boolean;
|
|
229
145
|
createdAt: string;
|
|
230
146
|
retiredAt?: string | undefined;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
147
|
+
buildDigest: string;
|
|
148
|
+
configuration: string;
|
|
149
|
+
signingKeyId?: string | undefined;
|
|
150
|
+
record?: {
|
|
151
|
+
contentType: string;
|
|
152
|
+
contentBase64: string;
|
|
153
|
+
} | undefined;
|
|
154
|
+
}[];
|
|
234
155
|
};
|
|
235
156
|
}, "authenticated", true, false, undefined>>;
|
|
236
157
|
promote: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<{
|
|
@@ -13,7 +13,10 @@ import { setServiceSecret } from '../functions/set-service-secret.js';
|
|
|
13
13
|
import { transferService } from '../functions/transfer-service.js';
|
|
14
14
|
import { OwnService } from '../policies/own-service.js';
|
|
15
15
|
import { Service } from './service.js';
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* One Service whose deployments are Cloudflare Workers for Platforms scripts: any Cloudflare
|
|
18
|
+
* Worker, an Astrale Domain release or a generic Worker (an API, a cron job) alike.
|
|
19
|
+
*/
|
|
17
20
|
export const CloudflareService = nodeClass({
|
|
18
21
|
description: 'One Service whose deployments are Cloudflare Workers for Platforms scripts.',
|
|
19
22
|
icon: classIcon.lucide(CloudCog),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
* One
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* of the Service and the prefix of each
|
|
7
|
-
* once the Service is deleted.
|
|
3
|
+
* One Service: the stable identity of one project in one environment, owned by one Identity,
|
|
4
|
+
* whatever its Worker serves (an Astrale Domain release, an API, a cron job). Every deploy adds an
|
|
5
|
+
* immutable Deployment of it, and its URL serves the one it currently points at. Its `name` is the
|
|
6
|
+
* SDK's `serviceName(project, environment)`: the DNS label of the Service and the prefix of each
|
|
7
|
+
* deployment's label, unique among Services, and free again once the Service is deleted.
|
|
8
8
|
*/
|
|
9
9
|
export declare const Service: import("@astrale-os/sdk/schema").AuthoredNodeClass<{
|
|
10
10
|
readonly abstract: true;
|
|
@@ -12,9 +12,10 @@ export declare const Service: import("@astrale-os/sdk/schema").AuthoredNodeClass
|
|
|
12
12
|
readonly icon: import("@astrale-os/sdk/schema").ClassIcon;
|
|
13
13
|
readonly extends: readonly [import("@astrale-os/sdk/schema").KernelClass<"Named">, import("@astrale-os/sdk/schema").KernelClass<"Timestamped">];
|
|
14
14
|
readonly properties: {
|
|
15
|
-
origin
|
|
15
|
+
/** Any project name; a Domain deployer names its Domain's origin. */
|
|
16
|
+
project: z.ZodString;
|
|
16
17
|
environment: z.ZodString;
|
|
17
|
-
/**
|
|
18
|
+
/** `serviceName(project, environment)`, 16 characters; it alone identifies the Service. */
|
|
18
19
|
fingerprint: z.ZodString;
|
|
19
20
|
/** `https://<name>.<routing domain>`: always serves the current deployment. */
|
|
20
21
|
url: z.ZodString;
|
|
@@ -3,11 +3,11 @@ import { Server } from '@astrale-os/sdk/schema/icons';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { serviceLifecycle } from '../states/index.js';
|
|
5
5
|
/**
|
|
6
|
-
* One
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* of the Service and the prefix of each
|
|
10
|
-
* once the Service is deleted.
|
|
6
|
+
* One Service: the stable identity of one project in one environment, owned by one Identity,
|
|
7
|
+
* whatever its Worker serves (an Astrale Domain release, an API, a cron job). Every deploy adds an
|
|
8
|
+
* immutable Deployment of it, and its URL serves the one it currently points at. Its `name` is the
|
|
9
|
+
* SDK's `serviceName(project, environment)`: the DNS label of the Service and the prefix of each
|
|
10
|
+
* deployment's label, unique among Services, and free again once the Service is deleted.
|
|
11
11
|
*/
|
|
12
12
|
export const Service = nodeClass({
|
|
13
13
|
abstract: true,
|
|
@@ -15,9 +15,10 @@ export const Service = nodeClass({
|
|
|
15
15
|
icon: classIcon.lucide(Server),
|
|
16
16
|
extends: [K.classes.Named, K.classes.Timestamped],
|
|
17
17
|
properties: {
|
|
18
|
-
origin
|
|
18
|
+
/** Any project name; a Domain deployer names its Domain's origin. */
|
|
19
|
+
project: z.string().min(1).max(253),
|
|
19
20
|
environment: z.string().min(1).max(63),
|
|
20
|
-
/**
|
|
21
|
+
/** `serviceName(project, environment)`, 16 characters; it alone identifies the Service. */
|
|
21
22
|
fingerprint: z.string().check(fullMatch('[a-z2-7]{16}')),
|
|
22
23
|
/** `https://<name>.<routing domain>`: always serves the current deployment. */
|
|
23
24
|
url: z.string().min(1).max(2_048),
|
|
@@ -1,77 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Host one release as an immutable deployment of
|
|
3
|
-
* creating that Service on its first deploy, and by
|
|
4
|
-
*
|
|
5
|
-
* a new one that it is or acts as the owner it
|
|
2
|
+
* Host one Cloudflare Worker release (`WorkerDeploymentRequestV1`) as an immutable deployment of
|
|
3
|
+
* the Service of its project and environment, creating that Service on its first deploy, and by
|
|
4
|
+
* default make it the one the Service serves. Any authenticated identity may ask; the handler
|
|
5
|
+
* proves that the caller owns the Service, or for a new one that it is or acts as the owner it
|
|
6
|
+
* names, before any write.
|
|
6
7
|
*/
|
|
7
8
|
export declare const deployService: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<{
|
|
8
|
-
format: "astrale.
|
|
9
|
+
format: "astrale.worker.deployment-request";
|
|
9
10
|
version: 1;
|
|
10
11
|
owner?: string | undefined;
|
|
11
|
-
|
|
12
|
+
project: string;
|
|
12
13
|
environment: string;
|
|
13
|
-
addressing: "opaque";
|
|
14
14
|
label: string;
|
|
15
15
|
buildDigest: string;
|
|
16
16
|
configuration: {
|
|
17
|
-
format: "astrale.
|
|
17
|
+
format: "astrale.worker.configuration";
|
|
18
18
|
version: 1;
|
|
19
|
+
compatibilityDate: string;
|
|
20
|
+
compatibilityFlags: string[];
|
|
19
21
|
vars: Record<string, string>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
maximumLifetimeSeconds: number;
|
|
25
|
-
};
|
|
26
|
-
durableOptions?: {
|
|
27
|
-
retentionMs?: number | undefined;
|
|
28
|
-
retry?: {
|
|
29
|
-
initialIntervalMs?: number | undefined;
|
|
30
|
-
maxAttempts?: number | undefined;
|
|
31
|
-
maxIntervalMs?: number | undefined;
|
|
32
|
-
} | undefined;
|
|
33
|
-
stepTimeoutMs?: number | undefined;
|
|
34
|
-
} | undefined;
|
|
35
|
-
};
|
|
36
|
-
runtime: {
|
|
37
|
-
compatibilityDate: string;
|
|
38
|
-
compatibilityFlags: string[];
|
|
39
|
-
};
|
|
40
|
-
bindings: {
|
|
41
|
-
services: {
|
|
42
|
-
name: string;
|
|
43
|
-
service: string;
|
|
44
|
-
}[];
|
|
45
|
-
dispatchNamespaces: {
|
|
46
|
-
name: string;
|
|
47
|
-
namespace: string;
|
|
48
|
-
}[];
|
|
49
|
-
secrets: string[];
|
|
50
|
-
};
|
|
51
|
-
router: false | {
|
|
52
|
-
service: string;
|
|
53
|
-
hostSuffix: string;
|
|
54
|
-
minLabels: number;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
record: {
|
|
58
|
-
releaseDigest: string;
|
|
59
|
-
schemaRevision: string;
|
|
60
|
-
schemaBundle: string;
|
|
61
|
-
commit: {
|
|
62
|
-
sha: string;
|
|
63
|
-
dirty: boolean;
|
|
64
|
-
base?: {
|
|
65
|
-
version: string;
|
|
66
|
-
distance: number;
|
|
67
|
-
} | undefined;
|
|
68
|
-
} | null;
|
|
22
|
+
secrets: string[];
|
|
23
|
+
record: boolean;
|
|
24
|
+
signingIdentity: boolean;
|
|
25
|
+
router: boolean;
|
|
69
26
|
};
|
|
70
|
-
|
|
71
|
-
|
|
27
|
+
worker: {
|
|
28
|
+
manifest: Record<string, unknown>;
|
|
29
|
+
mainModule: string;
|
|
72
30
|
modules: {
|
|
73
31
|
name: string;
|
|
74
|
-
kind
|
|
32
|
+
kind: "data" | "esm" | "text" | "wasm";
|
|
75
33
|
content: {
|
|
76
34
|
encoding: "gzip" | "identity";
|
|
77
35
|
decodedSize: number;
|
|
@@ -83,29 +41,26 @@ export declare const deployService: import("@astrale-os/sdk/schema").Method<impo
|
|
|
83
41
|
};
|
|
84
42
|
}[];
|
|
85
43
|
assets?: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}[];
|
|
99
|
-
notFound?: "404-page" | "none" | "single-page-application" | undefined;
|
|
100
|
-
runWorkerFirst?: boolean | undefined;
|
|
101
|
-
htmlHandling?: "none" | undefined;
|
|
102
|
-
} | undefined;
|
|
44
|
+
path: string;
|
|
45
|
+
contentType?: string | undefined;
|
|
46
|
+
content: {
|
|
47
|
+
encoding: "gzip" | "identity";
|
|
48
|
+
decodedSize: number;
|
|
49
|
+
contentBase64: string;
|
|
50
|
+
} | {
|
|
51
|
+
encoding: "gzip" | "identity";
|
|
52
|
+
decodedSize: number;
|
|
53
|
+
contentBase64Chunks: string[];
|
|
54
|
+
};
|
|
55
|
+
}[] | undefined;
|
|
103
56
|
};
|
|
57
|
+
record?: {
|
|
58
|
+
contentType: string;
|
|
59
|
+
contentBase64: string;
|
|
60
|
+
} | undefined;
|
|
61
|
+
readiness?: string[] | undefined;
|
|
104
62
|
secrets: Record<string, string>;
|
|
105
63
|
promote?: boolean | undefined;
|
|
106
|
-
readiness?: {
|
|
107
|
-
paths: string[];
|
|
108
|
-
} | undefined;
|
|
109
64
|
}, {
|
|
110
65
|
readonly mode: 'value';
|
|
111
66
|
readonly value: {
|
|
@@ -125,31 +80,20 @@ export declare const deployService: import("@astrale-os/sdk/schema").Method<impo
|
|
|
125
80
|
label: string;
|
|
126
81
|
serviceId: string;
|
|
127
82
|
service: string;
|
|
83
|
+
project: string;
|
|
84
|
+
environment: string;
|
|
128
85
|
owner: string;
|
|
129
86
|
state: "active" | "deploying" | "failed" | "retired" | "retiring";
|
|
130
87
|
current: boolean;
|
|
131
88
|
createdAt: string;
|
|
132
89
|
retiredAt?: string | undefined;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
buildDigest: string;
|
|
141
|
-
schemaRevision: string;
|
|
142
|
-
configuration: string;
|
|
143
|
-
providerScript: string;
|
|
144
|
-
commit: {
|
|
145
|
-
sha: string;
|
|
146
|
-
dirty: boolean;
|
|
147
|
-
base?: {
|
|
148
|
-
version: string;
|
|
149
|
-
distance: number;
|
|
150
|
-
} | undefined;
|
|
151
|
-
} | null;
|
|
152
|
-
};
|
|
90
|
+
buildDigest: string;
|
|
91
|
+
configuration: string;
|
|
92
|
+
signingKeyId?: string | undefined;
|
|
93
|
+
record?: {
|
|
94
|
+
contentType: string;
|
|
95
|
+
contentBase64: string;
|
|
96
|
+
} | undefined;
|
|
153
97
|
};
|
|
154
98
|
};
|
|
155
99
|
}, "authenticated", true, false, undefined>>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { method } from '@astrale-os/sdk/schema';
|
|
2
2
|
import { deploymentRequest, deploymentResponse } from '../../deployment/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Host one release as an immutable deployment of
|
|
5
|
-
* creating that Service on its first deploy, and by
|
|
6
|
-
*
|
|
7
|
-
* a new one that it is or acts as the owner it
|
|
4
|
+
* Host one Cloudflare Worker release (`WorkerDeploymentRequestV1`) as an immutable deployment of
|
|
5
|
+
* the Service of its project and environment, creating that Service on its first deploy, and by
|
|
6
|
+
* default make it the one the Service serves. Any authenticated identity may ask; the handler
|
|
7
|
+
* proves that the caller owns the Service, or for a new one that it is or acts as the owner it
|
|
8
|
+
* names, before any write.
|
|
8
9
|
*/
|
|
9
10
|
export const deployService = method({
|
|
10
|
-
description: 'Host one release as an immutable deployment of its Service.',
|
|
11
|
+
description: 'Host one Worker release as an immutable deployment of its Service.',
|
|
11
12
|
auth: 'authenticated',
|
|
12
13
|
static: true,
|
|
13
14
|
input: deploymentRequest,
|