@astrale-os/adapter-astrale 0.5.0-beta.170 → 0.5.0-beta.172

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 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
- configuration (variables, execution settings, durable options, the Workers runtime and the names of
36
- the declared secrets, never their values), so one URL serves one release and a changed variable gives another
37
- URL. The commit the deploy runs from is recorded but never part of the label: the same release
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`. It never calls an instance and never installs the
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. A deployment whose stored record Services' SDK no longer
76
- admits is listed with the record as stored; the listing names it from its host's facts.
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/admit.d.ts CHANGED
@@ -3,9 +3,5 @@ import type { AstraleParams } from './params.js';
3
3
  /**
4
4
  * Refuse, when the Project loads, an Environment this adapter cannot deploy: an unknown or removed
5
5
  * parameter or a malformed Admin bookmark.
6
- *
7
- * An Environment of the removed instance mode (`instance`, `signingIdentity`) is left to the deploy
8
- * mode selection, which refuses it when it deploys with the configuration to write instead; loading
9
- * it to build or test it has no effect.
10
6
  */
11
7
  export declare function admitAstraleParameters(parameters: AstraleParams, context: AdapterEnvironmentContext): void;
package/dist/admit.js CHANGED
@@ -7,36 +7,17 @@ const PARAMETERS = Object.freeze([
7
7
  'tokenExchange',
8
8
  'durable',
9
9
  ]);
10
- /**
11
- * The parameters of the removed instance mode. `astrale-domain deploy` refuses them before any
12
- * effect, with the configuration to write instead (CT33, AM-72).
13
- */
14
- const INSTANCE_MODE = Object.freeze(['instance', 'signingIdentity']);
15
- /** The parameters that named the stable Service of the removed instance mode. */
16
- const INSTANCE_SERVICE = Object.freeze(['serviceKey', 'name']);
17
10
  /** The longest Admin bookmark name an Environment may name. */
18
11
  const MAXIMUM_NAME_LENGTH = 256;
19
12
  /**
20
13
  * Refuse, when the Project loads, an Environment this adapter cannot deploy: an unknown or removed
21
14
  * parameter or a malformed Admin bookmark.
22
- *
23
- * An Environment of the removed instance mode (`instance`, `signingIdentity`) is left to the deploy
24
- * mode selection, which refuses it when it deploys with the configuration to write instead; loading
25
- * it to build or test it has no effect.
26
15
  */
27
16
  export function admitAstraleParameters(parameters, context) {
28
17
  const values = parameters;
29
18
  // A parameter is declared when its value is not `undefined`, as optional parameters read.
30
19
  const declared = Reflect.ownKeys(values).filter((key) => values[key] !== undefined);
31
20
  const environment = `Astrale Environment ${context.environment}`;
32
- if (declared.some((key) => isOneOf(key, INSTANCE_MODE)))
33
- return;
34
- const service = declared.filter((key) => isOneOf(key, INSTANCE_SERVICE));
35
- if (service.length > 0) {
36
- throw new TypeError(`${environment} declares ${names(service)}, which named the stable Service of the removed ` +
37
- `instance mode. Remove ${service.length === 1 ? 'it' : 'them'}: each immutable ` +
38
- 'deployment is named by its own label.');
39
- }
40
21
  const unknown = declared.filter((key) => !isOneOf(key, PARAMETERS));
41
22
  if (unknown.length > 0) {
42
23
  throw new TypeError(`${environment} declares unknown parameters ${names(unknown)}.`);
@@ -1,14 +1,17 @@
1
1
  import type { ConfigureContext } from '@astrale-os/sdk/deployment/adapter';
2
- import type { FrozenConfigurationV1 } from '@astrale-os/sdk/deployment/address';
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: the author's variables, the
6
- * execution settings the generated Worker runs under, defaults resolved, its durable options when
7
- * the Environment declares them (AM-175), the Workers runtime every generated Worker runs on, and
8
- * the names of the Environment's secrets. A deployment on Admin's Services binds no service, no
9
- * dispatch namespace and no router (AM-174): it reaches its Kernel through its public issuer.
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): FrozenConfigurationV1;
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 { frozenConfiguration } from '@astrale-os/sdk/deployment/address';
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: the author's variables, the
5
- * execution settings the generated Worker runs under, defaults resolved, its durable options when
6
- * the Environment declares them (AM-175), the Workers runtime every generated Worker runs on, and
7
- * the names of the Environment's secrets. A deployment on Admin's Services binds no service, no
8
- * dispatch namespace and no router (AM-174): it reaches its Kernel through its public issuer.
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 frozenConfiguration({
28
- vars,
29
- settings: {
30
- maximumRequestBytes: settings.maximumRequestBytes,
31
- invocationTimeoutMs: settings.invocationTimeoutMs,
32
- tokenExchange: settings.tokenExchange,
33
- ...(settings.durableOptions === undefined ? {} : { durableOptions: settings.durableOptions }),
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's address, its record, its
26
- * Worker upload and the Environment's current secrets, which are never journaled. Services creates
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 { deploymentRequest } from '../services/request.js';
5
- import { decodeDeploymentResponse, decodeHosting } from '../services/response.js';
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 = decodeHosting(answer);
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's address, its record, its
32
- * Worker upload and the Environment's current secrets, which are never journaled. Services creates
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 = deploymentRequest(context);
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 = decodeDeploymentResponse(answer);
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 declaring exactly the sealed release.
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 { deployment } = response;
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) {
@@ -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, its record as Services stores it, whether the Service serves it, and where it
8
- * and its Service are called on Admin's Kernel. Nothing changes: one `CloudflareService.list` call
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
@@ -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 { decodeDeploymentList } from '../services/response.js';
4
- import { requireAstraleCli } from './deploy-release.js';
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, its record as Services stores it, whether the Service serves it, and where it
9
- * and its Service are called on Admin's Kernel. Nothing changes: one `CloudflareService.list` call
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 = decodeDeploymentList(await dependencies.callAdmin({
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: { origin: context.origin, environment: context.environment },
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
- record: deployment.record,
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
@@ -17,13 +17,15 @@
17
17
  * URL, `https://<line>-<content>.<routingDomain>`, while the Service's stable URL,
18
18
  * `https://<line>.<routingDomain>`, serves the deployment last promoted, by default the latest. It
19
19
  * calls Admin's Services with `astrale call --admin` as the authenticated identity, never an
20
- * instance, and never installs the Domain: `astrale domain install <url> --direct -i <instance>`
20
+ * instance, and never installs the Domain: `astrale domain install <url> -i <instance>`
21
21
  * installs the URL it prints. A redeploy of the same release reuses its deployment and rewrites
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`). For deploying to YOUR OWN Cloudflare account
26
- * instead, use `@astrale-os/adapter-cloudflare`.
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
@@ -17,12 +17,14 @@
17
17
  * URL, `https://<line>-<content>.<routingDomain>`, while the Service's stable URL,
18
18
  * `https://<line>.<routingDomain>`, serves the deployment last promoted, by default the latest. It
19
19
  * calls Admin's Services with `astrale call --admin` as the authenticated identity, never an
20
- * instance, and never installs the Domain: `astrale domain install <url> --direct -i <instance>`
20
+ * instance, and never installs the Domain: `astrale domain install <url> -i <instance>`
21
21
  * installs the URL it prints. A redeploy of the same release reuses its deployment and rewrites
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`). For deploying to YOUR OWN Cloudflare account
26
- * instead, use `@astrale-os/adapter-cloudflare`.
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';