@astrale-os/adapter-astrale 0.5.0-beta.170 → 0.5.0-beta.171
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 +63 -7
- package/dist/configure.d.ts +10 -7
- package/dist/configure.js +19 -21
- package/dist/deploy/deploy-release.d.ts +6 -11
- package/dist/deploy/deploy-release.js +33 -18
- package/dist/deploy/list.d.ts +4 -3
- package/dist/deploy/list.js +12 -10
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/services/api.d.ts +7 -124
- package/dist/services/api.js +7 -6
- package/dist/services/client.d.ts +93 -0
- package/dist/services/client.js +116 -0
- package/dist/services/directory.d.ts +16 -0
- package/dist/services/directory.js +78 -0
- package/dist/services/index.d.ts +44 -0
- package/dist/services/index.js +27 -0
- package/dist/services/request.d.ts +19 -18
- package/dist/services/request.js +53 -57
- package/package.json +8 -4
- package/dist/services/base64.d.ts +0 -8
- package/dist/services/base64.js +0 -13
- package/dist/services/content.d.ts +0 -7
- package/dist/services/content.js +0 -13
- package/dist/services/response.d.ts +0 -18
- package/dist/services/response.js +0 -206
package/README.md
CHANGED
|
@@ -31,10 +31,23 @@ Environment: its own Worker script at its own URL, `https://<line>-<content>.<ro
|
|
|
31
31
|
line comes from the Domain's origin and the Environment name, is opaque (a fingerprint), and names
|
|
32
32
|
the Service, whose stable URL `https://<line>.<routingDomain>` serves its current deployment. The
|
|
33
33
|
first deploy creates the Service, and every deploy makes the Service serve the deployment it
|
|
34
|
-
created or reused. The content covers the build and the frozen
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
created or reused. The content covers the build and the frozen Worker configuration
|
|
35
|
+
(`WorkerConfigurationV1`: variables, the execution settings and durable options the generated
|
|
36
|
+
Worker reads from `ASTRALE_SETTINGS`, the Workers runtime, the names of the declared secrets, never
|
|
37
|
+
their values, and what the Domain asks of Services: its record and a key of its own), so one URL
|
|
38
|
+
serves one release and a changed variable gives another URL.
|
|
39
|
+
|
|
40
|
+
Admin's Services knows nothing of Domains: it hosts any Cloudflare Worker from a
|
|
41
|
+
`WorkerDeploymentRequestV1` (`@astrale-os/sdk/deployment/worker`). The adapter builds every Domain
|
|
42
|
+
fact itself: the project is the Domain's origin, so its Service keeps the name of the Domain's
|
|
43
|
+
line; the build manifest members are the Bundle's own, so Services binds the release's build digest
|
|
44
|
+
as `ASTRALE_BUILD_DIGEST`; the record is the Domain's `DeploymentRecordV1` document (media type
|
|
45
|
+
`application/vnd.astrale.deployment-record+json;v=1`), which Services serves byte for byte at
|
|
46
|
+
`/.well-known/astrale/deployment.json`; and Services probes the release's `release.json`, Bundle and
|
|
47
|
+
issuer documents before it activates the deployment. Since the configuration digest is the Worker
|
|
48
|
+
configuration's, the label of a release deployed before this contract is not the label of the same
|
|
49
|
+
release deployed now: the first deploy after an upgrade creates a new deployment at a new URL, and
|
|
50
|
+
the earlier one keeps serving its own until it is retired. The commit the deploy runs from is recorded but never part of the label: the same release
|
|
38
51
|
deployed from a later commit, or from a dirty or clean working tree, reuses its deployment, whose
|
|
39
52
|
record keeps the commit of the deploy that created it. Each deployment is its own issuer, with a signing
|
|
40
53
|
key Services generates for it: there is no key file to keep or distribute. Deploying a new release
|
|
@@ -57,7 +70,7 @@ no dispatch namespace and no router.
|
|
|
57
70
|
The adapter calls the static Methods of `CloudflareService` on Admin's Services with
|
|
58
71
|
`astrale call --admin` (astrale CLI 1.0.0-beta.126 or newer): `CloudflareService.hosting` to read
|
|
59
72
|
the routing domain, then `CloudflareService.deploy`, a non-durable Action, with the request on
|
|
60
|
-
stdin; `list` calls `CloudflareService.list
|
|
73
|
+
stdin; `list` calls `CloudflareService.list` for the project of the Domain's origin. It never calls an instance and never installs the
|
|
61
74
|
Domain: install the URL the deploy prints with `astrale domain install <url> --direct -i <instance>`.
|
|
62
75
|
|
|
63
76
|
Secrets come from the file `secrets` names. A new deployment binds the file's current values. A
|
|
@@ -72,8 +85,8 @@ which changes nothing): each one's release, its name computed from its record
|
|
|
72
85
|
(`1.4.2 + 7 commits · a1b2c3d · staging`), its state, `active (current)` for the one its Service
|
|
73
86
|
serves (`current` in `--json`), its URL, and its call target on the Admin instance. A Services
|
|
74
87
|
deployment is listed `published` until it is retired (`withdrawn` once retiring), with no last
|
|
75
|
-
call or expiry: Services counts neither.
|
|
76
|
-
|
|
88
|
+
call or expiry: Services counts neither. Each row carries the record its deployment published,
|
|
89
|
+
unadmitted; a record this SDK refuses is listed from its host's facts.
|
|
77
90
|
|
|
78
91
|
The call target names two nodes. `callTarget.service`,
|
|
79
92
|
`@<serviceId>::services.astrale.ai:class.CloudflareService`, takes the Service's Methods, which
|
|
@@ -109,3 +122,46 @@ starting with `_worker.js`, in that exact case, such as a Cloudflare Pages `_wor
|
|
|
109
122
|
directory: Services would publish that possible server-side code, whereas Wrangler refuses to
|
|
110
123
|
upload it. Vite copies its public directory (`public/` by default) to that root, so remove or
|
|
111
124
|
rename them there. The same names below the root remain ordinary files.
|
|
125
|
+
|
|
126
|
+
## Any Cloudflare Worker
|
|
127
|
+
|
|
128
|
+
`@astrale-os/adapter-astrale/services` deploys any Worker on Admin's Services, the same way and
|
|
129
|
+
with the same session: a cron job, an API or a scaffolded Service, with no Cloudflare account.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { callService, deployWorker, readWorkerDirectory } from '@astrale-os/adapter-astrale/services'
|
|
133
|
+
|
|
134
|
+
const worker = await readWorkerDirectory('.dist', { mainModule: 'worker.mjs' })
|
|
135
|
+
const { state, deployment } = await deployWorker({
|
|
136
|
+
project: 'nightly-report',
|
|
137
|
+
environment: 'production',
|
|
138
|
+
worker,
|
|
139
|
+
configuration: { compatibilityDate: '2026-09-01', vars: { KERNEL: 'https://…' } },
|
|
140
|
+
secrets: { ACCOUNT_PRIVATE_JWK: process.env.ACCOUNT_PRIVATE_JWK! },
|
|
141
|
+
readiness: ['/health'],
|
|
142
|
+
})
|
|
143
|
+
await callService(deployment.serviceId, 'setSchedule', { crons: ['*/5 * * * *'] })
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- `readWorkerDirectory(directory, { mainModule, assets? })` reads a built Worker: every file is a
|
|
147
|
+
module loaded by its extension (`.js`/`.mjs` ES modules, `.wasm`, `.txt`/`.html`/`.sql` text,
|
|
148
|
+
`.bin` data; source maps left out), and every file of `assets` a static asset.
|
|
149
|
+
- `deployWorker(input, options?)` deploys it as a deployment of the Service of `project` and
|
|
150
|
+
`environment`, created on the first deploy and owned by the caller; the configuration may be the
|
|
151
|
+
input of `workerConfiguration` (`@astrale-os/sdk/deployment/worker`), whose secret names default
|
|
152
|
+
to those of `secrets`. The same code and configuration reuse their deployment and rewrite its
|
|
153
|
+
secrets in place. It answers the deployment (`created` or `reused`), or throws a
|
|
154
|
+
`ServicesRefusal` with Services' reason.
|
|
155
|
+
- `readiness` paths must answer 200 with `x-astrale-worker-version` set to the `id` of the
|
|
156
|
+
`ASTRALE_VERSION_METADATA` binding before Services activates the deployment. Services binds
|
|
157
|
+
`WORKER_URL`, `ASTRALE_BUILD_DIGEST` and `ASTRALE_VERSION_METADATA` on every deployment, a key as
|
|
158
|
+
`ASTRALE_SIGNING_IDENTITY` when the configuration asks `signingIdentity`, and serves the given
|
|
159
|
+
`record` at `/.well-known/astrale/deployment.json`.
|
|
160
|
+
- `listWorkerDeployments({ project?, environment? })`, `servicesHosting()` and
|
|
161
|
+
`callService(serviceId, method, data)` (`promote`, `setSecret`, `setSchedule`, `schedules`,
|
|
162
|
+
`logs`, `transfer`, `delete`) read and act on the caller's Services. A scheduled Service is called
|
|
163
|
+
`POST /__scheduled` on its current deployment, with `x-astrale-cron` and
|
|
164
|
+
`x-astrale-scheduled-time`; the public never reaches that path.
|
|
165
|
+
|
|
166
|
+
Each call runs `astrale call --admin` as the CLI's identity; `options` names an Admin bookmark
|
|
167
|
+
(`admin`), an identity to act as (`identity`) or a credential (`credential`).
|
package/dist/configure.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { ConfigureContext } from '@astrale-os/sdk/deployment/adapter';
|
|
2
|
-
import type {
|
|
2
|
+
import type { WorkerConfigurationV1 } from '@astrale-os/sdk/deployment/worker';
|
|
3
3
|
import type { AstraleParams } from './params.js';
|
|
4
4
|
/**
|
|
5
|
-
* What one deployment of this Environment freezes beside its build
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* What one deployment of this Environment freezes beside its build, as the Worker configuration
|
|
6
|
+
* Admin's Services hosts: the Workers runtime every generated Worker runs on, the author's
|
|
7
|
+
* variables and the execution settings the generated Worker runs under (defaults resolved, its
|
|
8
|
+
* durable options when the Environment declares them, AM-175) bound as `ASTRALE_SETTINGS`, the
|
|
9
|
+
* names of the Environment's secrets, and what a Domain asks of its host: the record it publishes
|
|
10
|
+
* at `/.well-known/astrale/deployment.json` and a signing key of its own. A deployment on Admin's
|
|
11
|
+
* Services binds no service, no dispatch namespace and no router (AM-174): it reaches its Kernel
|
|
12
|
+
* through its public issuer, so its settings name no router either.
|
|
10
13
|
*
|
|
11
14
|
* Pure: the same parameters and secret names give the same configuration, so the same release
|
|
12
15
|
* gives the same deployment address on every run.
|
|
13
16
|
*/
|
|
14
|
-
export declare function configureAstrale(parameters: AstraleParams, context: ConfigureContext):
|
|
17
|
+
export declare function configureAstrale(parameters: AstraleParams, context: ConfigureContext): WorkerConfigurationV1;
|
package/dist/configure.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { GENERATED_WORKER_RUNTIME, isAdapterVar, workerSettings, } from '@astrale-os/adapter-cloudflare/build';
|
|
2
|
-
import {
|
|
1
|
+
import { encodeWorkerSettings, GENERATED_WORKER_RUNTIME, isAdapterVar, SETTINGS_BINDING, workerSettings, } from '@astrale-os/adapter-cloudflare/build';
|
|
2
|
+
import { WORKER_HOST_BINDINGS, workerConfiguration } from '@astrale-os/sdk/deployment/worker';
|
|
3
3
|
/**
|
|
4
|
-
* What one deployment of this Environment freezes beside its build
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* What one deployment of this Environment freezes beside its build, as the Worker configuration
|
|
5
|
+
* Admin's Services hosts: the Workers runtime every generated Worker runs on, the author's
|
|
6
|
+
* variables and the execution settings the generated Worker runs under (defaults resolved, its
|
|
7
|
+
* durable options when the Environment declares them, AM-175) bound as `ASTRALE_SETTINGS`, the
|
|
8
|
+
* names of the Environment's secrets, and what a Domain asks of its host: the record it publishes
|
|
9
|
+
* at `/.well-known/astrale/deployment.json` and a signing key of its own. A deployment on Admin's
|
|
10
|
+
* Services binds no service, no dispatch namespace and no router (AM-174): it reaches its Kernel
|
|
11
|
+
* through its public issuer, so its settings name no router either.
|
|
9
12
|
*
|
|
10
13
|
* Pure: the same parameters and secret names give the same configuration, so the same release
|
|
11
14
|
* gives the same deployment address on every run.
|
|
12
15
|
*/
|
|
13
16
|
export function configureAstrale(parameters, context) {
|
|
14
17
|
const vars = parameters.vars ?? {};
|
|
15
|
-
const owned = [...Object.keys(vars), ...context.secrets].filter(isAdapterVar);
|
|
18
|
+
const owned = [...Object.keys(vars), ...context.secrets].filter((name) => isAdapterVar(name) || WORKER_HOST_BINDINGS.includes(name));
|
|
16
19
|
if (owned.length > 0) {
|
|
17
20
|
throw new TypeError(`Astrale Environment ${context.environment} binds ${owned.join(', ')}, which the deployment ` +
|
|
18
21
|
'binds itself; rename the variable or secret.');
|
|
@@ -24,19 +27,14 @@ export function configureAstrale(parameters, context) {
|
|
|
24
27
|
...(parameters.tokenExchange === undefined ? {} : { tokenExchange: parameters.tokenExchange }),
|
|
25
28
|
...(parameters.durable === undefined ? {} : { durable: parameters.durable }),
|
|
26
29
|
});
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
runtime: {
|
|
36
|
-
compatibilityDate: GENERATED_WORKER_RUNTIME.compatibilityDate,
|
|
37
|
-
compatibilityFlags: GENERATED_WORKER_RUNTIME.compatibilityFlags,
|
|
38
|
-
},
|
|
39
|
-
bindings: { services: [], dispatchNamespaces: [], secrets: context.secrets },
|
|
30
|
+
return workerConfiguration({
|
|
31
|
+
compatibilityDate: GENERATED_WORKER_RUNTIME.compatibilityDate,
|
|
32
|
+
compatibilityFlags: GENERATED_WORKER_RUNTIME.compatibilityFlags,
|
|
33
|
+
vars: { ...vars, [SETTINGS_BINDING]: encodeWorkerSettings({ ...settings, router: false }) },
|
|
34
|
+
secrets: context.secrets,
|
|
35
|
+
record: true,
|
|
36
|
+
signingIdentity: true,
|
|
37
|
+
// An Admin-hosted Domain reaches its Kernel through its public issuer, never a router.
|
|
40
38
|
router: false,
|
|
41
39
|
});
|
|
42
40
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import type { Placement, PlacementContext, ReleaseDeployContext, ReleaseDeployResult } from '@astrale-os/sdk/deployment/adapter';
|
|
2
2
|
import type { Release } from '@astrale-os/sdk/deployment/release';
|
|
3
|
-
import type { callAdmin } from '../cli/commands/call.js';
|
|
4
|
-
import type { requireCliVersion } from '../cli/commands/version.js';
|
|
5
|
-
import type { resolveCliExecutable } from '../cli/executable.js';
|
|
6
3
|
import type { AstraleParams } from '../params.js';
|
|
4
|
+
import type { ServicesDependencies } from '../services/client.js';
|
|
7
5
|
/** The effects this adapter has, replaceable in tests. */
|
|
8
|
-
export interface AstraleDependencies {
|
|
9
|
-
readonly resolveCliExecutable: typeof resolveCliExecutable;
|
|
10
|
-
readonly requireCliVersion: typeof requireCliVersion;
|
|
11
|
-
readonly callAdmin: typeof callAdmin;
|
|
6
|
+
export interface AstraleDependencies extends ServicesDependencies {
|
|
12
7
|
/** Wait until the deployment serves its sealed release at its URL. */
|
|
13
8
|
readonly waitForReadiness: (release: Release, signal: AbortSignal) => Promise<void>;
|
|
14
9
|
}
|
|
@@ -22,8 +17,10 @@ export declare function placeAstrale(parameters: AstraleParams, context: Placeme
|
|
|
22
17
|
/**
|
|
23
18
|
* Create, or reuse, the immutable deployment of one sealed release on Admin's Services.
|
|
24
19
|
*
|
|
25
|
-
* One non-durable `CloudflareService.deploy` call carries the release
|
|
26
|
-
*
|
|
20
|
+
* One non-durable `CloudflareService.deploy` call carries the release as the Worker deployment
|
|
21
|
+
* Services hosts for any Worker (`WorkerDeploymentRequestV1`): its address, its Worker upload, its
|
|
22
|
+
* configuration, its `DeploymentRecordV1` document, the paths of its release to probe before
|
|
23
|
+
* activation and the Environment's current secrets, which are never journaled. Services creates
|
|
27
24
|
* the Service of the origin and Environment on its first deploy, owned by the caller. A new
|
|
28
25
|
* deployment binds those secrets and a key Services generates for it; a deployment of the same
|
|
29
26
|
* release (same label) is reused and has its own declared secrets rewritten in place when they
|
|
@@ -31,5 +28,3 @@ export declare function placeAstrale(parameters: AstraleParams, context: Placeme
|
|
|
31
28
|
* this one. The deployment is ready once its own URL serves exactly the sealed release.
|
|
32
29
|
*/
|
|
33
30
|
export declare function deployAstraleRelease(parameters: AstraleParams, context: ReleaseDeployContext, dependencies: AstraleDependencies): Promise<ReleaseDeployResult>;
|
|
34
|
-
/** Resolve the astrale CLI once per operation and require the release that serves `call --admin`. */
|
|
35
|
-
export declare function requireAstraleCli(projectDir: string, signal: AbortSignal, dependencies: AstraleDependencies): Promise<string>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { decodeDeploymentRecord } from '@astrale-os/sdk/deployment/address';
|
|
1
2
|
import { addressing } from '@astrale-os/sdk/deployment/release';
|
|
3
|
+
import { decodeWorkerDeploymentResponse, decodeWorkerHosting, encodeWorkerDeploymentRequest, workerConfigurationDigest, } from '@astrale-os/sdk/deployment/worker';
|
|
2
4
|
import { authorityArguments } from '../cli/identity.js';
|
|
3
5
|
import { SERVICES_METHODS } from '../services/api.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import { requireAstraleCli, servicesSummary } from '../services/client.js';
|
|
7
|
+
import { domainWorkerDeployment } from '../services/request.js';
|
|
6
8
|
/**
|
|
7
9
|
* Where Admin's Services places this Environment's deployments: under the routing domain its
|
|
8
10
|
* `hosting` answers, on the opaque line that names the Service of the Domain's origin and the
|
|
@@ -22,14 +24,16 @@ export async function placeAstrale(parameters, context, dependencies) {
|
|
|
22
24
|
data: {},
|
|
23
25
|
signal: context.signal,
|
|
24
26
|
});
|
|
25
|
-
const hosting =
|
|
27
|
+
const hosting = decodeWorkerHosting(answer);
|
|
26
28
|
return Object.freeze({ addressing: 'opaque', routingDomain: hosting.routingDomain });
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* Create, or reuse, the immutable deployment of one sealed release on Admin's Services.
|
|
30
32
|
*
|
|
31
|
-
* One non-durable `CloudflareService.deploy` call carries the release
|
|
32
|
-
*
|
|
33
|
+
* One non-durable `CloudflareService.deploy` call carries the release as the Worker deployment
|
|
34
|
+
* Services hosts for any Worker (`WorkerDeploymentRequestV1`): its address, its Worker upload, its
|
|
35
|
+
* configuration, its `DeploymentRecordV1` document, the paths of its release to probe before
|
|
36
|
+
* activation and the Environment's current secrets, which are never journaled. Services creates
|
|
33
37
|
* the Service of the origin and Environment on its first deploy, owned by the caller. A new
|
|
34
38
|
* deployment binds those secrets and a key Services generates for it; a deployment of the same
|
|
35
39
|
* release (same label) is reused and has its own declared secrets rewritten in place when they
|
|
@@ -47,7 +51,11 @@ export async function deployAstraleRelease(parameters, context, dependencies) {
|
|
|
47
51
|
? {}
|
|
48
52
|
: { identity: context.identity }),
|
|
49
53
|
});
|
|
50
|
-
request =
|
|
54
|
+
request = await encodeWorkerDeploymentRequest(domainWorkerDeployment(context));
|
|
55
|
+
// The build Services binds is the release's, at the label the SDK sealed it under.
|
|
56
|
+
if (request.buildDigest !== context.bundle.digest || request.label !== context.label) {
|
|
57
|
+
throw new TypeError('The Worker deployment of the release names another build or label.');
|
|
58
|
+
}
|
|
51
59
|
executable = await requireAstraleCli(context.projectDir, context.signal, dependencies);
|
|
52
60
|
}
|
|
53
61
|
catch (cause) {
|
|
@@ -72,7 +80,7 @@ export async function deployAstraleRelease(parameters, context, dependencies) {
|
|
|
72
80
|
let response;
|
|
73
81
|
let record;
|
|
74
82
|
try {
|
|
75
|
-
response =
|
|
83
|
+
response = decodeWorkerDeploymentResponse(answer);
|
|
76
84
|
if (response.kind === 'rejected') {
|
|
77
85
|
return failed('provider',
|
|
78
86
|
// A validation or ownership refusal changed nothing. `service-unavailable` waited on, or
|
|
@@ -82,7 +90,7 @@ export async function deployAstraleRelease(parameters, context, dependencies) {
|
|
|
82
90
|
response.reason === 'service-unavailable' ? UNKNOWN : NONE, new Error(`Admin Services refused the deployment (${response.reason}): ${response.message}` +
|
|
83
91
|
(response.retryAfter === undefined ? '' : ` Retry after ${response.retryAfter}.`)));
|
|
84
92
|
}
|
|
85
|
-
record = expectDeployment(response, context);
|
|
93
|
+
record = expectDeployment(response, context, request);
|
|
86
94
|
}
|
|
87
95
|
catch (cause) {
|
|
88
96
|
return failed('provider', UNKNOWN, cause);
|
|
@@ -107,7 +115,7 @@ export async function deployAstraleRelease(parameters, context, dependencies) {
|
|
|
107
115
|
}
|
|
108
116
|
/**
|
|
109
117
|
* The deployment Services answered with is the one this deploy addressed: its label and URL, active,
|
|
110
|
-
* and a record
|
|
118
|
+
* of this build and configuration, publishing a record that declares exactly the sealed release.
|
|
111
119
|
*
|
|
112
120
|
* The record's commit is not compared. A label is the release (line, build, configuration), never
|
|
113
121
|
* the commit it was built from, and a deployment keeps the record it was created with: Services
|
|
@@ -115,13 +123,26 @@ export async function deployAstraleRelease(parameters, context, dependencies) {
|
|
|
115
123
|
* a sibling Domain's commit in a monorepo), and resumes a failed creation with its first record.
|
|
116
124
|
* The commit a deployment declares is that of the deploy that created it.
|
|
117
125
|
*/
|
|
118
|
-
function expectDeployment(response, context) {
|
|
119
|
-
const
|
|
120
|
-
const { record } = deployment;
|
|
126
|
+
function expectDeployment(response, context, request) {
|
|
127
|
+
const deployment = servicesSummary(response.deployment);
|
|
121
128
|
const { document } = context.release;
|
|
122
129
|
expect('label', deployment.label, context.label);
|
|
123
130
|
expect('URL', addressing(deployment.url).issuer, context.release.url);
|
|
124
131
|
expect('state', deployment.state, 'active');
|
|
132
|
+
expect('project', deployment.project, document.origin);
|
|
133
|
+
expect('build digest', deployment.buildDigest, context.bundle.digest);
|
|
134
|
+
expect('configuration', deployment.configuration, workerConfigurationDigest(request.configuration));
|
|
135
|
+
let record;
|
|
136
|
+
try {
|
|
137
|
+
if (deployment.record === undefined)
|
|
138
|
+
throw new TypeError('The deployment publishes no record.');
|
|
139
|
+
record = decodeDeploymentRecord(deployment.record);
|
|
140
|
+
}
|
|
141
|
+
catch (cause) {
|
|
142
|
+
throw new TypeError('Admin Services returned a deployment record that does not admit.', {
|
|
143
|
+
cause,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
125
146
|
expect('origin', record.origin, document.origin);
|
|
126
147
|
expect('environment', record.environment, context.environment);
|
|
127
148
|
expect('release digest', record.releaseDigest, document.digest);
|
|
@@ -130,12 +151,6 @@ function expectDeployment(response, context) {
|
|
|
130
151
|
expect('provider script', record.providerScript, context.label);
|
|
131
152
|
return record;
|
|
132
153
|
}
|
|
133
|
-
/** Resolve the astrale CLI once per operation and require the release that serves `call --admin`. */
|
|
134
|
-
export async function requireAstraleCli(projectDir, signal, dependencies) {
|
|
135
|
-
const executable = await dependencies.resolveCliExecutable();
|
|
136
|
-
await dependencies.requireCliVersion({ executable, projectDir, signal });
|
|
137
|
-
return executable;
|
|
138
|
-
}
|
|
139
154
|
const NONE = Object.freeze({ kind: 'none' });
|
|
140
155
|
const UNKNOWN = Object.freeze({ kind: 'unknown' });
|
|
141
156
|
function failed(phase, provider, cause) {
|
package/dist/deploy/list.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ import type { AstraleDependencies } from './deploy-release.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* The deployments of one Environment's Service that Admin's Services keeps for the caller, who
|
|
6
6
|
* owns that Service or acts as its owner through `extends_with`, in Services' order: what Services
|
|
7
|
-
* knows of each one,
|
|
8
|
-
* and its Service are called on Admin's Kernel. Nothing changes:
|
|
9
|
-
* through `astrale call --admin
|
|
7
|
+
* knows of each one, the record it publishes (unadmitted: the listing admits it), whether the
|
|
8
|
+
* Service serves it, and where it and its Service are called on Admin's Kernel. Nothing changes:
|
|
9
|
+
* one `CloudflareService.list` call through `astrale call --admin`, for the project of the
|
|
10
|
+
* Domain's origin.
|
|
10
11
|
*
|
|
11
12
|
* Services keeps every deployment until it is retired and counts no call, so each one is listed as
|
|
12
13
|
* `published`, without a last call or an expiry, and a retiring or retired one as `withdrawn`: a
|
package/dist/deploy/list.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { decodeWorkerDeploymentList } from '@astrale-os/sdk/deployment/worker';
|
|
1
2
|
import { authorityArguments } from '../cli/identity.js';
|
|
2
3
|
import { deploymentCallPath, SERVICES_METHODS, serviceCallPath } from '../services/api.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { requireAstraleCli, servicesSummary } from '../services/client.js';
|
|
5
|
+
import { listedRecord } from '../services/request.js';
|
|
5
6
|
/**
|
|
6
7
|
* The deployments of one Environment's Service that Admin's Services keeps for the caller, who
|
|
7
8
|
* owns that Service or acts as its owner through `extends_with`, in Services' order: what Services
|
|
8
|
-
* knows of each one,
|
|
9
|
-
* and its Service are called on Admin's Kernel. Nothing changes:
|
|
10
|
-
* through `astrale call --admin
|
|
9
|
+
* knows of each one, the record it publishes (unadmitted: the listing admits it), whether the
|
|
10
|
+
* Service serves it, and where it and its Service are called on Admin's Kernel. Nothing changes:
|
|
11
|
+
* one `CloudflareService.list` call through `astrale call --admin`, for the project of the
|
|
12
|
+
* Domain's origin.
|
|
11
13
|
*
|
|
12
14
|
* Services keeps every deployment until it is retired and counts no call, so each one is listed as
|
|
13
15
|
* `published`, without a last call or an expiry, and a retiring or retired one as `withdrawn`: a
|
|
@@ -23,16 +25,16 @@ export async function listAstraleDeployments(parameters, context, dependencies)
|
|
|
23
25
|
// `astrale-domain` runs in its Project directory.
|
|
24
26
|
const projectDir = process.cwd();
|
|
25
27
|
const executable = await requireAstraleCli(projectDir, context.signal, dependencies);
|
|
26
|
-
const hosted =
|
|
28
|
+
const hosted = decodeWorkerDeploymentList(await dependencies.callAdmin({
|
|
27
29
|
executable,
|
|
28
30
|
projectDir,
|
|
29
31
|
...(parameters.admin === undefined ? {} : { admin: parameters.admin }),
|
|
30
32
|
path: SERVICES_METHODS.list,
|
|
31
33
|
authority: authorityArguments(context.identity === undefined ? {} : { identity: context.identity }),
|
|
32
|
-
data: {
|
|
34
|
+
data: { project: context.origin, environment: context.environment },
|
|
33
35
|
signal: context.signal,
|
|
34
36
|
}));
|
|
35
|
-
return Object.freeze(hosted.map((deployment) => listed(deployment, parameters.admin)));
|
|
37
|
+
return Object.freeze(hosted.map((deployment) => listed(servicesSummary(deployment), parameters.admin)));
|
|
36
38
|
}
|
|
37
39
|
/** One deployment Services lists, as an adapter lists it (`ListedDeployment`). */
|
|
38
40
|
function listed(deployment, admin) {
|
|
@@ -48,8 +50,8 @@ function listed(deployment, admin) {
|
|
|
48
50
|
createdAt: deployment.createdAt,
|
|
49
51
|
...(deployment.retiredAt === undefined ? {} : { retiredAt: deployment.retiredAt }),
|
|
50
52
|
...(withdrawn ? { retirement: 'withdrawn' } : {}),
|
|
51
|
-
signingKeyId: deployment.signingKeyId,
|
|
52
|
-
|
|
53
|
+
...(deployment.signingKeyId === undefined ? {} : { signingKeyId: deployment.signingKeyId }),
|
|
54
|
+
...listedRecord(deployment.record),
|
|
53
55
|
current: deployment.current,
|
|
54
56
|
callTarget: Object.freeze({
|
|
55
57
|
kind: 'services',
|
package/dist/index.d.ts
CHANGED
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
* its secrets in place when the secrets file changed; no other deployment is ever touched.
|
|
23
23
|
*
|
|
24
24
|
* It builds the SAME Cloudflare Workers bundle the `cloudflare` adapter ships
|
|
25
|
-
* (via `@astrale-os/adapter-cloudflare/build`)
|
|
26
|
-
*
|
|
25
|
+
* (via `@astrale-os/adapter-cloudflare/build`) and deploys it as Services deploys any Worker
|
|
26
|
+
* (`@astrale-os/sdk/deployment/worker`); `@astrale-os/adapter-astrale/services` deploys any other
|
|
27
|
+
* Worker the same way. For deploying to YOUR OWN Cloudflare account instead, use
|
|
28
|
+
* `@astrale-os/adapter-cloudflare`.
|
|
27
29
|
*/
|
|
28
30
|
export { astrale } from './adapter.js';
|
|
29
31
|
export type { AstraleParams } from './params.js';
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* its secrets in place when the secrets file changed; no other deployment is ever touched.
|
|
23
23
|
*
|
|
24
24
|
* It builds the SAME Cloudflare Workers bundle the `cloudflare` adapter ships
|
|
25
|
-
* (via `@astrale-os/adapter-cloudflare/build`)
|
|
26
|
-
*
|
|
25
|
+
* (via `@astrale-os/adapter-cloudflare/build`) and deploys it as Services deploys any Worker
|
|
26
|
+
* (`@astrale-os/sdk/deployment/worker`); `@astrale-os/adapter-astrale/services` deploys any other
|
|
27
|
+
* Worker the same way. For deploying to YOUR OWN Cloudflare account instead, use
|
|
28
|
+
* `@astrale-os/adapter-cloudflare`.
|
|
27
29
|
*/
|
|
28
30
|
export { astrale } from './adapter.js';
|
package/dist/services/api.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import type { DeploymentCommitV1, DeploymentRecordV1, FrozenConfigurationV1 } from '@astrale-os/sdk/deployment/address';
|
|
2
|
-
import type { DeploymentContent } from './content.js';
|
|
3
1
|
/** The Services Domain origin, as Admin's Kernel names its installation (not a network host). */
|
|
4
2
|
export declare const SERVICES_ORIGIN = "services.astrale.ai";
|
|
5
3
|
/**
|
|
6
|
-
* The Services class whose nodes are the Services Admin's Services hosts: one per
|
|
7
|
-
* environment, named by the opaque
|
|
4
|
+
* The Services class whose nodes are the Services Admin's Services hosts: one per project and
|
|
5
|
+
* environment, named by the opaque fingerprint of the two, whose stable URL serves its current
|
|
6
|
+
* deployment. A Domain's project is its origin.
|
|
8
7
|
*/
|
|
9
8
|
export declare const SERVICE_CLASS = "services.astrale.ai:class.CloudflareService";
|
|
10
9
|
/** The Services class whose nodes are the immutable deployments of those Services. */
|
|
11
10
|
export declare const DEPLOYMENT_CLASS = "services.astrale.ai:class.CloudflareDeployment";
|
|
12
11
|
/**
|
|
13
|
-
* The static `CloudflareService` Methods of Admin's Services this
|
|
12
|
+
* The static `CloudflareService` Methods of Admin's Services this package calls: `hosting` reads
|
|
14
13
|
* where Services and deployments are addressed, `deploy` creates or reuses one deployment of the
|
|
15
|
-
* Service of its
|
|
16
|
-
* reads the deployments of the Services the caller owns.
|
|
17
|
-
* `astrale call --admin` (CT21).
|
|
14
|
+
* Service of its project and environment (creating that Service on its first deploy) from a
|
|
15
|
+
* `WorkerDeploymentRequestV1`, and `list` reads the deployments of the Services the caller owns.
|
|
16
|
+
* They run on Admin's Kernel through `astrale call --admin` (CT21).
|
|
18
17
|
*/
|
|
19
18
|
export declare const SERVICES_METHODS: Readonly<{
|
|
20
19
|
hosting: "/:services.astrale.ai:class.CloudflareService:hosting";
|
|
@@ -34,119 +33,3 @@ export declare function serviceCallPath(serviceId: string): string;
|
|
|
34
33
|
* class, whose only instance Method is `retire`, the emergency stop of that deployment alone.
|
|
35
34
|
*/
|
|
36
35
|
export declare function deploymentCallPath(id: string): string;
|
|
37
|
-
/** `CloudflareService.list` input: the deployments of one origin's Service for one environment. */
|
|
38
|
-
export interface DeploymentListRequestV1 {
|
|
39
|
-
readonly origin: string;
|
|
40
|
-
readonly environment: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* `CloudflareService.hosting`: the routing domain of Services and deployments. Every Service is
|
|
44
|
-
* named by its opaque line: `https://<line>.<routingDomain>` serves its current deployment, and
|
|
45
|
-
* `https://<label>.<routingDomain>` each deployment.
|
|
46
|
-
*/
|
|
47
|
-
export interface DeploymentHostingV1 {
|
|
48
|
-
readonly routingDomain: string;
|
|
49
|
-
readonly addressing: 'opaque';
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* What Services knows of one deployment beside the record its deployer declared (Services'
|
|
53
|
-
* `DeploymentSummaryV1`): where it answers, the Service it is a version of (`service` is that
|
|
54
|
-
* Service's name, the opaque line its label begins with), the Service's owner, its lifecycle, and
|
|
55
|
-
* whether the Service's stable URL serves it (`current`). It names a deployment by its label and
|
|
56
|
-
* URL, never by a provider version id. Services keeps every deployment until it is retired: it has
|
|
57
|
-
* no preview, expiry or last call.
|
|
58
|
-
*/
|
|
59
|
-
export interface ServiceDeploymentSummaryV1 {
|
|
60
|
-
/** The deployment's node id on Admin's Services. */
|
|
61
|
-
readonly id: string;
|
|
62
|
-
readonly url: string;
|
|
63
|
-
readonly label: string;
|
|
64
|
-
/** The node id of the Service this deployment is a version of. */
|
|
65
|
-
readonly serviceId: string;
|
|
66
|
-
/** The name of that Service: the line of the deployment's label. */
|
|
67
|
-
readonly service: string;
|
|
68
|
-
/** The Identity owning the Service, as a node path on Admin's Services. */
|
|
69
|
-
readonly owner: string;
|
|
70
|
-
readonly state: 'deploying' | 'active' | 'retiring' | 'retired' | 'failed';
|
|
71
|
-
/** Whether the Service's stable URL serves this deployment. */
|
|
72
|
-
readonly current: boolean;
|
|
73
|
-
readonly createdAt: string;
|
|
74
|
-
/** When its retirement began; present once it is `retiring`. */
|
|
75
|
-
readonly retiredAt?: string;
|
|
76
|
-
readonly signingKeyId: string;
|
|
77
|
-
readonly record: DeploymentRecordV1;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* `DeploymentRequestV1`: one release to host as a deployment of the Service of its origin and
|
|
81
|
-
* environment. Services recomputes the label and the build digest from what it receives and
|
|
82
|
-
* refuses a request that states another; its `secrets` are the Environment's current values,
|
|
83
|
-
* exactly the names the frozen configuration declares. A non-durable Action receives it: it is
|
|
84
|
-
* never journaled.
|
|
85
|
-
*/
|
|
86
|
-
export interface DeploymentRequestV1 {
|
|
87
|
-
readonly format: 'astrale.services.deployment-request';
|
|
88
|
-
readonly version: 1;
|
|
89
|
-
/**
|
|
90
|
-
* The Identity that owns the Service when this deploy creates it: the caller, or one it acts as.
|
|
91
|
-
* The exact caller when absent; an existing Service keeps its owner. This adapter sends none.
|
|
92
|
-
*/
|
|
93
|
-
readonly owner?: string;
|
|
94
|
-
readonly origin: string;
|
|
95
|
-
readonly environment: string;
|
|
96
|
-
/** Services are named by their fingerprint alone. */
|
|
97
|
-
readonly addressing: 'opaque';
|
|
98
|
-
readonly label: string;
|
|
99
|
-
readonly buildDigest: string;
|
|
100
|
-
readonly configuration: FrozenConfigurationV1;
|
|
101
|
-
readonly record: {
|
|
102
|
-
readonly releaseDigest: string;
|
|
103
|
-
readonly schemaRevision: string;
|
|
104
|
-
readonly schemaBundle: string;
|
|
105
|
-
readonly commit: DeploymentCommitV1 | null;
|
|
106
|
-
};
|
|
107
|
-
readonly bundle: {
|
|
108
|
-
readonly entrypoint: string;
|
|
109
|
-
readonly modules: readonly {
|
|
110
|
-
readonly name: string;
|
|
111
|
-
readonly kind: 'esm' | 'wasm';
|
|
112
|
-
readonly content: DeploymentContent;
|
|
113
|
-
}[];
|
|
114
|
-
readonly assets?: {
|
|
115
|
-
readonly files: readonly {
|
|
116
|
-
readonly path: string;
|
|
117
|
-
readonly contentType?: string;
|
|
118
|
-
readonly content: DeploymentContent;
|
|
119
|
-
}[];
|
|
120
|
-
readonly notFound: 'none';
|
|
121
|
-
readonly runWorkerFirst: true;
|
|
122
|
-
readonly htmlHandling: 'none';
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
readonly secrets: Readonly<Record<string, string>>;
|
|
126
|
-
/**
|
|
127
|
-
* Whether the Service serves this deployment once it is active; `true` when absent. This adapter
|
|
128
|
-
* sends none: every deploy is promoted.
|
|
129
|
-
*/
|
|
130
|
-
readonly promote?: boolean;
|
|
131
|
-
}
|
|
132
|
-
/** Why Services refused to host one release. */
|
|
133
|
-
export type DeploymentRejectionReason = 'invalid-deployment' | 'address-mismatch' | 'build-mismatch' | 'service-owned-elsewhere' | 'deployment-conflict' | 'deployment-retired' | 'hosting-unavailable' | 'service-unavailable';
|
|
134
|
-
/**
|
|
135
|
-
* `DeploymentResponseV1` (AM-4'): a deployment `created` with the request's secrets `bound` to
|
|
136
|
-
* it, or `reused` with its own declared secrets `updated` in place or left `unchanged`, or a
|
|
137
|
-
* refusal. A refusal changed nothing, except that a `service-unavailable` in-place rewrite may
|
|
138
|
-
* have written part of the values; rerunning the same deploy converges.
|
|
139
|
-
*/
|
|
140
|
-
export type DeploymentResponseV1 = {
|
|
141
|
-
readonly kind: 'deployed';
|
|
142
|
-
readonly state: 'created' | 'reused';
|
|
143
|
-
readonly secrets: {
|
|
144
|
-
readonly state: 'bound' | 'updated' | 'unchanged';
|
|
145
|
-
};
|
|
146
|
-
readonly deployment: ServiceDeploymentSummaryV1;
|
|
147
|
-
} | {
|
|
148
|
-
readonly kind: 'rejected';
|
|
149
|
-
readonly reason: DeploymentRejectionReason;
|
|
150
|
-
readonly message: string;
|
|
151
|
-
readonly retryAfter?: string;
|
|
152
|
-
};
|
package/dist/services/api.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/** The Services Domain origin, as Admin's Kernel names its installation (not a network host). */
|
|
2
2
|
export const SERVICES_ORIGIN = 'services.astrale.ai';
|
|
3
3
|
/**
|
|
4
|
-
* The Services class whose nodes are the Services Admin's Services hosts: one per
|
|
5
|
-
* environment, named by the opaque
|
|
4
|
+
* The Services class whose nodes are the Services Admin's Services hosts: one per project and
|
|
5
|
+
* environment, named by the opaque fingerprint of the two, whose stable URL serves its current
|
|
6
|
+
* deployment. A Domain's project is its origin.
|
|
6
7
|
*/
|
|
7
8
|
export const SERVICE_CLASS = `${SERVICES_ORIGIN}:class.CloudflareService`;
|
|
8
9
|
/** The Services class whose nodes are the immutable deployments of those Services. */
|
|
9
10
|
export const DEPLOYMENT_CLASS = `${SERVICES_ORIGIN}:class.CloudflareDeployment`;
|
|
10
11
|
/**
|
|
11
|
-
* The static `CloudflareService` Methods of Admin's Services this
|
|
12
|
+
* The static `CloudflareService` Methods of Admin's Services this package calls: `hosting` reads
|
|
12
13
|
* where Services and deployments are addressed, `deploy` creates or reuses one deployment of the
|
|
13
|
-
* Service of its
|
|
14
|
-
* reads the deployments of the Services the caller owns.
|
|
15
|
-
* `astrale call --admin` (CT21).
|
|
14
|
+
* Service of its project and environment (creating that Service on its first deploy) from a
|
|
15
|
+
* `WorkerDeploymentRequestV1`, and `list` reads the deployments of the Services the caller owns.
|
|
16
|
+
* They run on Admin's Kernel through `astrale call --admin` (CT21).
|
|
16
17
|
*/
|
|
17
18
|
export const SERVICES_METHODS = Object.freeze({
|
|
18
19
|
hosting: `/:${SERVICE_CLASS}:hosting`,
|