@astrale-os/adapter-astrale 0.5.0-beta.167 → 0.5.0-beta.168

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
@@ -19,30 +19,34 @@ export default defineProject({
19
19
  deployment: astrale({ secrets: '.env.dev' }),
20
20
  },
21
21
  production: {
22
- deployment: astrale({ organization: '<Identity id>', secrets: '.env.production' }),
22
+ deployment: astrale({ secrets: '.env.production' }),
23
23
  },
24
24
  },
25
25
  })
26
26
  ```
27
27
 
28
28
  `astrale-domain deploy <environment>` builds the release locally and makes one immutable
29
- deployment of it on Admin's Services: its own Worker script at its own URL,
30
- `https://<line>-<content>.<routingDomain>`. The line comes from the Domain's origin and the
31
- Environment name, and is opaque (a fingerprint). The content covers the build and the frozen
29
+ deployment of it on Admin's Services, as a version of the Service of the Domain's origin and the
30
+ Environment: its own Worker script at its own URL, `https://<line>-<content>.<routingDomain>`. The
31
+ line comes from the Domain's origin and the Environment name, is opaque (a fingerprint), and names
32
+ the Service, whose stable URL `https://<line>.<routingDomain>` serves its current deployment. The
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
32
35
  configuration (variables, execution settings, durable options, the Workers runtime and the names of
33
36
  the declared secrets, never their values), so one URL serves one release and a changed variable gives another
34
37
  URL. The commit the deploy runs from is recorded but never part of the label: the same release
35
38
  deployed from a later commit, or from a dirty or clean working tree, reuses its deployment, whose
36
39
  record keeps the commit of the deploy that created it. Each deployment is its own issuer, with a signing
37
40
  key Services generates for it: there is no key file to keep or distribute. Deploying a new release
38
- leaves earlier deployments served at their own URLs.
41
+ leaves earlier deployments served at their own URLs; Services keeps each one until it is retired,
42
+ with no preview, expiry or retention to manage.
39
43
 
40
- `organization` names the Identity on the Admin instance (a User, or a Shell Group whose members and
41
- CI act for it through `extends_with`) that holds the Environment's deployment line. Services
42
- registers the line to it on the first deploy and refuses the line to anyone else. Every
43
- Environment but `development` must name one; a `development` Environment without one deploys on a
44
- line of the deploying identity. `admin` names the Admin bookmark of the astrale CLI to deploy
45
- through; by default the CLI's configured Admin target.
44
+ Every Environment deploys as the authenticated Astrale CLI identity, selected with `--as` when
45
+ needed. The adapter names no `owner`, so a Service its first deploy creates is owned by that
46
+ identity; a Service owned by another Identity, which the caller neither is nor acts as, is refused
47
+ as `service-owned-elsewhere`. Give a Service to another owner with its `transfer` Method.
48
+ `admin` names the Admin bookmark of the astrale CLI to deploy through; by default the CLI's
49
+ configured Admin target.
46
50
 
47
51
  `durable` declares what a Domain serving durable Workflows tells the workflow engine (run
48
52
  retention, retry before pausing, the deadline of each Step). The options are frozen into the
@@ -50,42 +54,42 @@ deployment's configuration (`settings.durableOptions`), so another value is anot
50
54
  and a durable run stays on the deployment that started it. A hosted deployment binds no service,
51
55
  no dispatch namespace and no router.
52
56
 
53
- The adapter calls Admin's Services with `astrale call --admin` (astrale CLI 1.0.0-beta.126 or
54
- newer): `CloudflareDeployment.hosting` to read the routing domain, then
55
- `CloudflareDeployment.deploy`, a non-durable Action, with the request on stdin; `list` calls
56
- `CloudflareDeployment.list`, then `CloudflareDeployment.lastCalls`. It never calls an
57
- instance and never installs the Domain: install the URL the deploy prints with
58
- `astrale domain install <url> --direct -i <instance>`.
57
+ The adapter calls the static Methods of `CloudflareService` on Admin's Services with
58
+ `astrale call --admin` (astrale CLI 1.0.0-beta.126 or newer): `CloudflareService.hosting` to read
59
+ 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
61
+ Domain: install the URL the deploy prints with `astrale domain install <url> --direct -i <instance>`.
59
62
 
60
63
  Secrets come from the file `secrets` names. A new deployment binds the file's current values. A
61
64
  redeploy of the same release (same label) reuses its deployment and rewrites that deployment's
62
65
  secrets in place when they changed (`Secrets: updated`); the new values are served once
63
66
  propagated, which is eventually consistent (about 4 s). No other deployment's secrets are ever
64
- written. A secret name added or removed changes the configuration, so it is a new deployment. To
65
- rotate a secret of one deployment without redeploying, call its `setSecret` Method on Admin's
66
- Services with the call target `astrale-domain list --json` gives that deployment:
67
- `astrale call "<callTarget.path>.method.setSecret" --admin -d @file` (`--admin=<callTarget.admin>`
68
- when it names a bookmark).
67
+ written. A secret name added or removed changes the configuration, so it is a new deployment.
69
68
 
70
69
  `astrale-domain list [--environment <name>] [--json]` lists, Environment by Environment, the
71
- deployments Services keeps on the lines the caller holds or acts for (`CloudflareDeployment.list`,
70
+ deployments of the Services the caller owns or acts as the owner of (`CloudflareService.list`,
72
71
  which changes nothing): each one's release, its name computed from its record
73
- (`1.4.2 + 7 commits · a1b2c3d · staging`), its state, last call and expiry, its URL, and its call
74
- target, `@<id>::services.astrale.ai:class.CloudflareDeployment` on the Admin instance.
72
+ (`1.4.2 + 7 commits · a1b2c3d · staging`), its state, `active (current)` for the one its Service
73
+ serves (`current` in `--json`), its URL, and its call target on the Admin instance. A Services
74
+ 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.
75
77
 
76
- Services records a deployment's last call, and a preview's expiry, only when it activates it and at
77
- each expiry pass. The listing therefore also reads `CloudflareDeployment.lastCalls` for the active
78
- deployments, at most 100 labels per call: the last call shown is the later of the one the dispatcher
79
- counted and the one Services recorded, and a preview expires 30 days after its activation or that
80
- call, whichever is later. An Environment whose last calls cannot be read is not listed, rather than
81
- listed with a stale last call. Admin's Services fails its whole `list` on a stored deployment record
82
- its own SDK no longer admits (until the Services follow-up SV4b); the listing tolerates a record only
83
- this SDK refuses.
78
+ The call target names two nodes. `callTarget.service`,
79
+ `@<serviceId>::services.astrale.ai:class.CloudflareService`, takes the Service's Methods, which
80
+ act on the Service and the deployment it currently serves: `promote` (`{ "label": "<label>" }`,
81
+ to roll back or forward to one of its active deployments), `setSecret` (`{ "name", "value" }`, to
82
+ rewrite one secret of the current deployment in place without redeploying), `secrets`,
83
+ `setSchedule` and `schedules` (UTC crons run on the current deployment), `logs`, `transfer`
84
+ (`{ "owner" }`) and `delete`. `callTarget.path`, `@<id>::services.astrale.ai:class.CloudflareDeployment`,
85
+ takes `retire` (`{}`), the emergency stop of that deployment alone. Call them with
86
+ `astrale call "<node>.method.<method>" --admin -d @file` (`--admin=<callTarget.admin>` when it
87
+ names a bookmark).
84
88
 
85
89
  The deploy is ready once the deployment URL serves exactly the sealed release: its `release.json`
86
90
  (release digest and build digest), its Bundle and its issuer documents. Readiness is cancellable
87
91
  and bounded to two minutes; certificate verification is never disabled. Services refusals are
88
- reported with their reason (`line-owned-elsewhere`, `deployment-conflict`, ...). A validation or
92
+ reported with their reason (`service-owned-elsewhere`, `deployment-conflict`, ...). A validation or
89
93
  ownership refusal changes nothing. `service-unavailable` waited on, or lost to, another operation on
90
94
  the deployment and may follow effects: a creation that lost its lease after uploading, or an
91
95
  in-place secret rewrite that wrote part of the values. Rerunning the same deploy converges on the
package/dist/admit.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import type { AdapterEnvironmentContext } from '@astrale-os/sdk/deployment/adapter';
2
2
  import type { AstraleParams } from './params.js';
3
- /** The one Environment that deploys on a line of the deploying identity without naming one (AM-7). */
4
- export declare const DEVELOPMENT = "development";
5
3
  /**
6
4
  * Refuse, when the Project loads, an Environment this adapter cannot deploy: an unknown or removed
7
- * parameter, an Environment other than `development` that names no organisation, or a malformed
8
- * organisation or Admin bookmark.
5
+ * parameter or a malformed Admin bookmark.
9
6
  *
10
7
  * An Environment of the removed instance mode (`instance`, `signingIdentity`) is left to the deploy
11
8
  * mode selection, which refuses it when it deploys with the configuration to write instead; loading
package/dist/admit.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /** The parameters an Environment of this adapter declares. */
2
2
  const PARAMETERS = Object.freeze([
3
- 'organization',
4
3
  'admin',
5
4
  'secrets',
6
5
  'vars',
@@ -15,14 +14,11 @@ const PARAMETERS = Object.freeze([
15
14
  const INSTANCE_MODE = Object.freeze(['instance', 'signingIdentity']);
16
15
  /** The parameters that named the stable Service of the removed instance mode. */
17
16
  const INSTANCE_SERVICE = Object.freeze(['serviceKey', 'name']);
18
- /** The one Environment that deploys on a line of the deploying identity without naming one (AM-7). */
19
- export const DEVELOPMENT = 'development';
20
- /** The longest organisation Identity id or Admin bookmark name an Environment may name. */
17
+ /** The longest Admin bookmark name an Environment may name. */
21
18
  const MAXIMUM_NAME_LENGTH = 256;
22
19
  /**
23
20
  * Refuse, when the Project loads, an Environment this adapter cannot deploy: an unknown or removed
24
- * parameter, an Environment other than `development` that names no organisation, or a malformed
25
- * organisation or Admin bookmark.
21
+ * parameter or a malformed Admin bookmark.
26
22
  *
27
23
  * An Environment of the removed instance mode (`instance`, `signingIdentity`) is left to the deploy
28
24
  * mode selection, which refuses it when it deploys with the configuration to write instead; loading
@@ -45,17 +41,6 @@ export function admitAstraleParameters(parameters, context) {
45
41
  if (unknown.length > 0) {
46
42
  throw new TypeError(`${environment} declares unknown parameters ${names(unknown)}.`);
47
43
  }
48
- if (parameters.organization === undefined) {
49
- if (context.environment !== DEVELOPMENT) {
50
- throw new TypeError(`${environment} requires astrale({ organization }): the Identity on the Admin instance ` +
51
- `that holds its deployment line. Only ${DEVELOPMENT} deploys on a line of the ` +
52
- 'deploying identity without naming one.');
53
- }
54
- }
55
- else if (!stable(parameters.organization, MAXIMUM_NAME_LENGTH)) {
56
- throw new TypeError(`${environment} names an invalid organization: an Identity id on the Admin instance, at ` +
57
- `most ${MAXIMUM_NAME_LENGTH} characters, without whitespace.`);
58
- }
59
44
  if (parameters.admin !== undefined &&
60
45
  (!stable(parameters.admin, MAXIMUM_NAME_LENGTH) ||
61
46
  parameters.admin.startsWith('-') ||
@@ -14,20 +14,21 @@ export interface AstraleDependencies {
14
14
  }
15
15
  /**
16
16
  * Where Admin's Services places this Environment's deployments: under the routing domain its
17
- * `hosting` answers, on an opaque line. Lines of this adapter are tenant lines: the readable form
18
- * is the platform organisation's, whose Domains deploy into the platform namespace instead (D12).
19
- * Reading `hosting` changes nothing at the host.
17
+ * `hosting` answers, on the opaque line that names the Service of the Domain's origin and the
18
+ * Environment. The readable form is the platform organisation's, whose Domains deploy into the
19
+ * platform namespace instead (D12). Reading `hosting` changes nothing at the host.
20
20
  */
21
21
  export declare function placeAstrale(parameters: AstraleParams, context: PlacementContext, dependencies: AstraleDependencies): Promise<Placement>;
22
22
  /**
23
23
  * Create, or reuse, the immutable deployment of one sealed release on Admin's Services.
24
24
  *
25
- * One non-durable `CloudflareDeployment.deploy` call carries the release's address, its record,
26
- * its Worker upload and the Environment's current secrets, which are never journaled. A new
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
27
+ * the Service of the origin and Environment on its first deploy, owned by the caller. A new
27
28
  * deployment binds those secrets and a key Services generates for it; a deployment of the same
28
29
  * release (same label) is reused and has its own declared secrets rewritten in place when they
29
- * changed. No other deployment is ever written (AM-4'). The deployment is then ready once its URL
30
- * serves exactly the sealed release.
30
+ * changed. No other deployment is ever written (AM-4'), and the Service's stable URL then serves
31
+ * this one. The deployment is ready once its own URL serves exactly the sealed release.
31
32
  */
32
33
  export declare function deployAstraleRelease(parameters: AstraleParams, context: ReleaseDeployContext, dependencies: AstraleDependencies): Promise<ReleaseDeployResult>;
33
34
  /** Resolve the astrale CLI once per operation and require the release that serves `call --admin`. */
@@ -5,9 +5,9 @@ import { deploymentRequest } from '../services/request.js';
5
5
  import { decodeDeploymentResponse, decodeHosting } from '../services/response.js';
6
6
  /**
7
7
  * Where Admin's Services places this Environment's deployments: under the routing domain its
8
- * `hosting` answers, on an opaque line. Lines of this adapter are tenant lines: the readable form
9
- * is the platform organisation's, whose Domains deploy into the platform namespace instead (D12).
10
- * Reading `hosting` changes nothing at the host.
8
+ * `hosting` answers, on the opaque line that names the Service of the Domain's origin and the
9
+ * Environment. The readable form is the platform organisation's, whose Domains deploy into the
10
+ * platform namespace instead (D12). Reading `hosting` changes nothing at the host.
11
11
  */
12
12
  export async function placeAstrale(parameters, context, dependencies) {
13
13
  // `astrale-domain` runs in its Project directory.
@@ -28,12 +28,13 @@ export async function placeAstrale(parameters, context, dependencies) {
28
28
  /**
29
29
  * Create, or reuse, the immutable deployment of one sealed release on Admin's Services.
30
30
  *
31
- * One non-durable `CloudflareDeployment.deploy` call carries the release's address, its record,
32
- * its Worker upload and the Environment's current secrets, which are never journaled. A new
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
+ * the Service of the origin and Environment on its first deploy, owned by the caller. A new
33
34
  * deployment binds those secrets and a key Services generates for it; a deployment of the same
34
35
  * release (same label) is reused and has its own declared secrets rewritten in place when they
35
- * changed. No other deployment is ever written (AM-4'). The deployment is then ready once its URL
36
- * serves exactly the sealed release.
36
+ * changed. No other deployment is ever written (AM-4'), and the Service's stable URL then serves
37
+ * this one. The deployment is ready once its own URL serves exactly the sealed release.
37
38
  */
38
39
  export async function deployAstraleRelease(parameters, context, dependencies) {
39
40
  let executable;
@@ -46,7 +47,7 @@ export async function deployAstraleRelease(parameters, context, dependencies) {
46
47
  ? {}
47
48
  : { identity: context.identity }),
48
49
  });
49
- request = deploymentRequest(parameters, context);
50
+ request = deploymentRequest(context);
50
51
  executable = await requireAstraleCli(context.projectDir, context.signal, dependencies);
51
52
  }
52
53
  catch (cause) {
@@ -2,21 +2,20 @@ import type { ListContext, ListedDeployment } from '@astrale-os/sdk/deployment/a
2
2
  import type { AstraleParams } from '../params.js';
3
3
  import type { AstraleDependencies } from './deploy-release.js';
4
4
  /**
5
- * The deployments of one Environment that Admin's Services keeps on the lines the caller holds, or
6
- * acts for through `extends_with`, in Services' order: what Services knows of each one, its record
7
- * as Services stores it, and where it is called on Admin's Kernel. Nothing changes: one
8
- * `CloudflareDeployment.list` call, then one `CloudflareDeployment.lastCalls` call for every
9
- * `LAST_CALL_LABELS` active deployments, both through `astrale call --admin`.
5
+ * The deployments of one Environment's Service that Admin's Services keeps for the caller, who
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`.
10
10
  *
11
- * Services records a deployment's last call and a preview's expiry only at its activation and at
12
- * each expiry pass, so the listing asks `lastCalls` for what the dispatcher counted since: each
13
- * active deployment's last call is the later of the two, and a preview's expiry moves to 30 days
14
- * after that call when it is later than the recorded one, as Services' next pass would record it
15
- * (AM-123). A host whose last calls cannot be read is not listed: the listing never prints a last
16
- * call or an expiry it knows to be stale.
11
+ * Services keeps every deployment until it is retired and counts no call, so each one is listed as
12
+ * `published`, without a last call or an expiry, and a retiring or retired one as `withdrawn`: a
13
+ * retirement is always an operator's. Its Service's name is the line of its label.
17
14
  *
18
- * Each deployment is called by its node on the Admin instance this adapter deploys through, the
19
- * `admin` bookmark when it names one: `astrale call "<path>.method.setSecret" --admin` rotates one
20
- * of its secrets in place on that deployment alone (AM-4').
15
+ * Each deployment and its Service are called by their nodes on the Admin instance this adapter
16
+ * deploys through, the `admin` bookmark when it names one: `astrale call
17
+ * "<callTarget.service>.method.setSecret" --admin` rewrites one secret of the deployment the
18
+ * Service serves, and `astrale call "<callTarget.path>.method.retire" --admin` retires this
19
+ * deployment alone.
21
20
  */
22
21
  export declare function listAstraleDeployments(parameters: AstraleParams, context: ListContext, dependencies: AstraleDependencies): Promise<readonly ListedDeployment[]>;
@@ -1,85 +1,61 @@
1
1
  import { authorityArguments } from '../cli/identity.js';
2
- import { deploymentCallPath, LAST_CALL_LABELS, PREVIEW_RETENTION_MILLISECONDS, SERVICES_METHODS, } from '../services/api.js';
3
- import { decodeDeploymentList, decodeLastCalls } from '../services/response.js';
2
+ import { deploymentCallPath, SERVICES_METHODS, serviceCallPath } from '../services/api.js';
3
+ import { decodeDeploymentList } from '../services/response.js';
4
4
  import { requireAstraleCli } from './deploy-release.js';
5
5
  /**
6
- * The deployments of one Environment that Admin's Services keeps on the lines the caller holds, or
7
- * acts for through `extends_with`, in Services' order: what Services knows of each one, its record
8
- * as Services stores it, and where it is called on Admin's Kernel. Nothing changes: one
9
- * `CloudflareDeployment.list` call, then one `CloudflareDeployment.lastCalls` call for every
10
- * `LAST_CALL_LABELS` active deployments, both through `astrale call --admin`.
6
+ * The deployments of one Environment's Service that Admin's Services keeps for the caller, who
7
+ * 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`.
11
11
  *
12
- * Services records a deployment's last call and a preview's expiry only at its activation and at
13
- * each expiry pass, so the listing asks `lastCalls` for what the dispatcher counted since: each
14
- * active deployment's last call is the later of the two, and a preview's expiry moves to 30 days
15
- * after that call when it is later than the recorded one, as Services' next pass would record it
16
- * (AM-123). A host whose last calls cannot be read is not listed: the listing never prints a last
17
- * call or an expiry it knows to be stale.
12
+ * Services keeps every deployment until it is retired and counts no call, so each one is listed as
13
+ * `published`, without a last call or an expiry, and a retiring or retired one as `withdrawn`: a
14
+ * retirement is always an operator's. Its Service's name is the line of its label.
18
15
  *
19
- * Each deployment is called by its node on the Admin instance this adapter deploys through, the
20
- * `admin` bookmark when it names one: `astrale call "<path>.method.setSecret" --admin` rotates one
21
- * of its secrets in place on that deployment alone (AM-4').
16
+ * Each deployment and its Service are called by their nodes on the Admin instance this adapter
17
+ * deploys through, the `admin` bookmark when it names one: `astrale call
18
+ * "<callTarget.service>.method.setSecret" --admin` rewrites one secret of the deployment the
19
+ * Service serves, and `astrale call "<callTarget.path>.method.retire" --admin` retires this
20
+ * deployment alone.
22
21
  */
23
22
  export async function listAstraleDeployments(parameters, context, dependencies) {
24
23
  // `astrale-domain` runs in its Project directory.
25
24
  const projectDir = process.cwd();
26
25
  const executable = await requireAstraleCli(projectDir, context.signal, dependencies);
27
- const call = (path, data) => dependencies.callAdmin({
26
+ const hosted = decodeDeploymentList(await dependencies.callAdmin({
28
27
  executable,
29
28
  projectDir,
30
29
  ...(parameters.admin === undefined ? {} : { admin: parameters.admin }),
31
- path,
30
+ path: SERVICES_METHODS.list,
32
31
  authority: authorityArguments(context.identity === undefined ? {} : { identity: context.identity }),
33
- data,
32
+ data: { origin: context.origin, environment: context.environment },
34
33
  signal: context.signal,
35
- });
36
- const hosted = decodeDeploymentList(await call(SERVICES_METHODS.list, {
37
- origin: context.origin,
38
- environment: context.environment,
39
34
  }));
40
- const served = [
41
- ...new Set(hosted
42
- .filter((deployment) => deployment.state === 'active')
43
- .map((deployment) => deployment.label)),
44
- ].sort();
45
- const lastCalls = new Map();
46
- for (let start = 0; start < served.length; start += LAST_CALL_LABELS) {
47
- const labels = served.slice(start, start + LAST_CALL_LABELS);
48
- const answer = decodeLastCalls(await call(SERVICES_METHODS.lastCalls, { labels }), labels);
49
- for (const label of labels)
50
- lastCalls.set(label, answer[label]);
51
- }
52
- return Object.freeze(hosted.map((deployment) => Object.freeze({
53
- ...called(deployment, lastCalls.get(deployment.label)),
35
+ return Object.freeze(hosted.map((deployment) => listed(deployment, parameters.admin)));
36
+ }
37
+ /** One deployment Services lists, as an adapter lists it (`ListedDeployment`). */
38
+ function listed(deployment, admin) {
39
+ const withdrawn = deployment.state === 'retiring' || deployment.state === 'retired';
40
+ return Object.freeze({
41
+ id: deployment.id,
42
+ url: deployment.url,
43
+ label: deployment.label,
44
+ line: deployment.service,
45
+ owner: deployment.owner,
46
+ state: deployment.state,
47
+ retention: 'published',
48
+ createdAt: deployment.createdAt,
49
+ ...(deployment.retiredAt === undefined ? {} : { retiredAt: deployment.retiredAt }),
50
+ ...(withdrawn ? { retirement: 'withdrawn' } : {}),
51
+ signingKeyId: deployment.signingKeyId,
52
+ record: deployment.record,
53
+ current: deployment.current,
54
54
  callTarget: Object.freeze({
55
55
  kind: 'services',
56
56
  path: deploymentCallPath(deployment.id),
57
- ...(parameters.admin === undefined ? {} : { admin: parameters.admin }),
57
+ service: serviceCallPath(deployment.serviceId),
58
+ ...(admin === undefined ? {} : { admin }),
58
59
  }),
59
- })));
60
- }
61
- /**
62
- * One deployment with the last call `lastCalls` read for it: the later of that call and the one
63
- * Services recorded, and, for a preview whose expiry Services recorded, the later of that expiry
64
- * and 30 days after the call. A deployment `lastCalls` was not asked for keeps what Services
65
- * recorded: it does not serve, so no call was counted since.
66
- */
67
- function called(deployment, lastCall) {
68
- if (lastCall === undefined)
69
- return deployment;
70
- const lastCallAt = later(lastCall, deployment.lastCallAt);
71
- if (lastCallAt === undefined)
72
- return deployment;
73
- const expiresAt = deployment.retention === 'preview' && deployment.expiresAt !== undefined
74
- ? later(deployment.expiresAt, new Date(Date.parse(lastCallAt) + PREVIEW_RETENTION_MILLISECONDS).toISOString())
75
- : deployment.expiresAt;
76
- return { ...deployment, lastCallAt, ...(expiresAt === undefined ? {} : { expiresAt }) };
77
- }
78
- /** The later of two instants, as given; `undefined` when neither is. */
79
- function later(left, right) {
80
- if (left === null || left === undefined)
81
- return right;
82
- if (right === undefined)
83
- return left;
84
- return Date.parse(left) >= Date.parse(right) ? left : right;
60
+ });
85
61
  }
package/dist/index.d.ts CHANGED
@@ -8,17 +8,18 @@
8
8
  * environments: {
9
9
  * development: { deployment: astrale({ secrets: '.env.dev' }) },
10
10
  * production: {
11
- * deployment: astrale({ organization: '<Identity id>', secrets: '.env.production' }),
11
+ * deployment: astrale({ secrets: '.env.production' }),
12
12
  * },
13
13
  * }
14
14
  *
15
15
  * `astrale-domain deploy <environment>` builds locally and makes one immutable deployment per
16
- * release: its own script at its own URL, `https://<line>-<content>.<routingDomain>`, on the
17
- * deployment line of the Domain's origin and the Environment, held by `organization` on the Admin
18
- * instance. It calls Admin's Services with `astrale call --admin`, never an instance, and never
19
- * installs the Domain: `astrale domain install <url> --direct -i <instance>` installs the URL it
20
- * prints. A redeploy of the same release reuses its deployment and rewrites its secrets in place
21
- * when the secrets file changed; no other deployment is ever touched.
16
+ * release of the Service of the Domain's origin and the Environment: its own script at its own
17
+ * URL, `https://<line>-<content>.<routingDomain>`, while the Service's stable URL,
18
+ * `https://<line>.<routingDomain>`, serves the deployment last promoted, by default the latest. It
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>`
21
+ * installs the URL it prints. A redeploy of the same release reuses its deployment and rewrites
22
+ * its secrets in place when the secrets file changed; no other deployment is ever touched.
22
23
  *
23
24
  * It builds the SAME Cloudflare Workers bundle the `cloudflare` adapter ships
24
25
  * (via `@astrale-os/adapter-cloudflare/build`). For deploying to YOUR OWN Cloudflare account
package/dist/index.js CHANGED
@@ -8,17 +8,18 @@
8
8
  * environments: {
9
9
  * development: { deployment: astrale({ secrets: '.env.dev' }) },
10
10
  * production: {
11
- * deployment: astrale({ organization: '<Identity id>', secrets: '.env.production' }),
11
+ * deployment: astrale({ secrets: '.env.production' }),
12
12
  * },
13
13
  * }
14
14
  *
15
15
  * `astrale-domain deploy <environment>` builds locally and makes one immutable deployment per
16
- * release: its own script at its own URL, `https://<line>-<content>.<routingDomain>`, on the
17
- * deployment line of the Domain's origin and the Environment, held by `organization` on the Admin
18
- * instance. It calls Admin's Services with `astrale call --admin`, never an instance, and never
19
- * installs the Domain: `astrale domain install <url> --direct -i <instance>` installs the URL it
20
- * prints. A redeploy of the same release reuses its deployment and rewrites its secrets in place
21
- * when the secrets file changed; no other deployment is ever touched.
16
+ * release of the Service of the Domain's origin and the Environment: its own script at its own
17
+ * URL, `https://<line>-<content>.<routingDomain>`, while the Service's stable URL,
18
+ * `https://<line>.<routingDomain>`, serves the deployment last promoted, by default the latest. It
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>`
21
+ * installs the URL it prints. A redeploy of the same release reuses its deployment and rewrites
22
+ * its secrets in place when the secrets file changed; no other deployment is ever touched.
22
23
  *
23
24
  * It builds the SAME Cloudflare Workers bundle the `cloudflare` adapter ships
24
25
  * (via `@astrale-os/adapter-cloudflare/build`). For deploying to YOUR OWN Cloudflare account
package/dist/params.d.ts CHANGED
@@ -4,20 +4,13 @@ import type { ExchangeOptions } from '@astrale-os/sdk/execution';
4
4
  * `AstraleParams` — the provider-typed config for the Astrale-managed adapter.
5
5
  *
6
6
  * One value configures one Project Environment. `deploy` makes one immutable deployment per
7
- * release on Admin's Services, on the deployment line of the Environment's origin and name, and
7
+ * release of the Service of the Environment's origin and name on Admin's Services, and
8
8
  * never installs the Domain: `astrale domain install <url>` installs the URL it prints. Each
9
9
  * deployment is its own issuer at its own URL, with a signing key Services generates for it; there
10
10
  * is no key file to keep. Frontend source, routes, and build ownership live on the authored
11
11
  * Domain; adapter environments select delivery only.
12
12
  */
13
13
  export interface AstraleParams {
14
- /**
15
- * The Identity on the Admin instance, a User or a Shell Group, that holds this Environment's
16
- * deployment line; its members and its CI deploy for it through `extends_with`. Required for
17
- * every Environment but `development`, which deploys on a line of the deploying identity when it
18
- * names none (AM-7).
19
- */
20
- readonly organization?: string;
21
14
  /**
22
15
  * The Admin bookmark `astrale call --admin` reaches Admin's Services through. Default: the Admin
23
16
  * target the astrale CLI is configured with.
@@ -1,67 +1,100 @@
1
- import type { DeploymentCommitV1, DeploymentSummaryV1, FrozenConfigurationV1, LineAddressing } from '@astrale-os/sdk/deployment/address';
1
+ import type { DeploymentCommitV1, DeploymentRecordV1, FrozenConfigurationV1 } from '@astrale-os/sdk/deployment/address';
2
2
  import type { DeploymentContent } from './content.js';
3
3
  /** The Services Domain origin, as Admin's Kernel names its installation (not a network host). */
4
4
  export declare const SERVICES_ORIGIN = "services.astrale.ai";
5
- /** The Services class whose nodes are the deployments Admin's Services hosts. */
5
+ /**
6
+ * The Services class whose nodes are the Services Admin's Services hosts: one per origin and
7
+ * environment, named by the opaque line of the two, whose stable URL serves its current deployment.
8
+ */
9
+ export declare const SERVICE_CLASS = "services.astrale.ai:class.CloudflareService";
10
+ /** The Services class whose nodes are the immutable deployments of those Services. */
6
11
  export declare const DEPLOYMENT_CLASS = "services.astrale.ai:class.CloudflareDeployment";
7
12
  /**
8
- * The static `CloudflareDeployment` Methods of Admin's Services this adapter calls (CT19):
9
- * `hosting` reads where deployments are addressed, `deploy` creates or reuses one deployment,
10
- * `list` reads the deployments of the lines the caller holds, and `lastCalls` reads when each of
11
- * them was last called. They run on Admin's Kernel through `astrale call --admin` (CT21).
13
+ * The static `CloudflareService` Methods of Admin's Services this adapter calls: `hosting` reads
14
+ * where Services and deployments are addressed, `deploy` creates or reuses one deployment of the
15
+ * Service of its origin and environment (creating that Service on its first deploy), and `list`
16
+ * reads the deployments of the Services the caller owns. They run on Admin's Kernel through
17
+ * `astrale call --admin` (CT21).
12
18
  */
13
19
  export declare const SERVICES_METHODS: Readonly<{
14
- hosting: "/:services.astrale.ai:class.CloudflareDeployment:hosting";
15
- deploy: "/:services.astrale.ai:class.CloudflareDeployment:deploy";
16
- list: "/:services.astrale.ai:class.CloudflareDeployment:list";
17
- lastCalls: "/:services.astrale.ai:class.CloudflareDeployment:lastCalls";
20
+ hosting: "/:services.astrale.ai:class.CloudflareService:hosting";
21
+ deploy: "/:services.astrale.ai:class.CloudflareService:deploy";
22
+ list: "/:services.astrale.ai:class.CloudflareService:list";
18
23
  }>;
19
- /** The most labels one `CloudflareDeployment.lastCalls` reads (Services' `lastCallsInput`). */
20
- export declare const LAST_CALL_LABELS = 100;
21
24
  /**
22
- * How long Admin's Services keeps serving a preview after its activation or its last call,
23
- * whichever is later (D6, AM-123): its `PREVIEW_RETENTION_MILLISECONDS`. `expiresAt` as Services
24
- * records it already follows this rule for the calls Services has recorded.
25
+ * Where one hosted Service is called on Admin's Kernel: its node, `@<serviceId>`, qualified by its
26
+ * class. Its instance Methods act on the Service and its current deployment:
27
+ * `astrale call "<path>.method.setSecret" --admin` rewrites one secret of the deployment the
28
+ * Service serves, and `promote`, `transfer`, `secrets`, `setSchedule`, `schedules`, `logs` and
29
+ * `delete` are called the same way.
25
30
  */
26
- export declare const PREVIEW_RETENTION_MILLISECONDS: number;
31
+ export declare function serviceCallPath(serviceId: string): string;
27
32
  /**
28
33
  * Where one hosted deployment is called on Admin's Kernel: its node, `@<id>`, qualified by its
29
- * class, so that `astrale call "<path>.method.setSecret" --admin` rotates one of its secrets in
30
- * place on that deployment alone (AM-4').
34
+ * class, whose only instance Method is `retire`, the emergency stop of that deployment alone.
31
35
  */
32
36
  export declare function deploymentCallPath(id: string): string;
33
- /** `CloudflareDeployment.list` input: the deployments of one origin's line for one environment. */
37
+ /** `CloudflareService.list` input: the deployments of one origin's Service for one environment. */
34
38
  export interface DeploymentListRequestV1 {
35
39
  readonly origin: string;
36
40
  readonly environment: string;
37
41
  }
38
42
  /**
39
- * `CloudflareDeployment.lastCalls` input: 1 to `LAST_CALL_LABELS` labels of deployments on lines
40
- * the caller holds. Its answer maps each label to the instant of its last call, the later of what
41
- * the dispatcher counted and what Services recorded, or `null` when there is none.
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.
42
46
  */
43
- export interface DeploymentLastCallsRequestV1 {
44
- readonly labels: readonly string[];
45
- }
46
- /** `CloudflareDeployment.hosting`: the routing domain of deployments and how the caller's lines read. */
47
47
  export interface DeploymentHostingV1 {
48
48
  readonly routingDomain: string;
49
- readonly addressing: LineAddressing;
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;
50
78
  }
51
79
  /**
52
- * `DeploymentRequestV1` (CT19): one release to host on the line of its origin and environment.
53
- * Services recomputes the label and the build digest from what it receives and refuses a request
54
- * that states another; its `secrets` are the Environment's current values, exactly the names the
55
- * frozen configuration declares. A non-durable Action receives it: it is never journaled.
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.
56
85
  */
57
86
  export interface DeploymentRequestV1 {
58
87
  readonly format: 'astrale.services.deployment-request';
59
88
  readonly version: 1;
60
- /** The Identity of the Admin instance the deploy acts for; the exact caller when absent. */
61
- readonly organization?: string;
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;
62
94
  readonly origin: string;
63
95
  readonly environment: string;
64
- readonly addressing: LineAddressing;
96
+ /** Services are named by their fingerprint alone. */
97
+ readonly addressing: 'opaque';
65
98
  readonly label: string;
66
99
  readonly buildDigest: string;
67
100
  readonly configuration: FrozenConfigurationV1;
@@ -90,12 +123,17 @@ export interface DeploymentRequestV1 {
90
123
  };
91
124
  };
92
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;
93
131
  }
94
- /** Why Services refused to host one release (CT19). */
95
- export type DeploymentRejectionReason = 'invalid-deployment' | 'address-mismatch' | 'build-mismatch' | 'line-owned-elsewhere' | 'deployment-conflict' | 'deployment-retired' | 'hosting-unavailable' | 'service-unavailable';
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';
96
134
  /**
97
- * `DeploymentResponseV1` (CT19, AM-4'): a deployment `created` with the request's secrets `bound`
98
- * to it, or `reused` with its own declared secrets `updated` in place or left `unchanged`, or a
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
99
137
  * refusal. A refusal changed nothing, except that a `service-unavailable` in-place rewrite may
100
138
  * have written part of the values; rerunning the same deploy converges.
101
139
  */
@@ -105,7 +143,7 @@ export type DeploymentResponseV1 = {
105
143
  readonly secrets: {
106
144
  readonly state: 'bound' | 'updated' | 'unchanged';
107
145
  };
108
- readonly deployment: DeploymentSummaryV1;
146
+ readonly deployment: ServiceDeploymentSummaryV1;
109
147
  } | {
110
148
  readonly kind: 'rejected';
111
149
  readonly reason: DeploymentRejectionReason;
@@ -1,31 +1,37 @@
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
- /** The Services class whose nodes are the deployments Admin's Services hosts. */
3
+ /**
4
+ * The Services class whose nodes are the Services Admin's Services hosts: one per origin and
5
+ * environment, named by the opaque line of the two, whose stable URL serves its current deployment.
6
+ */
7
+ export const SERVICE_CLASS = `${SERVICES_ORIGIN}:class.CloudflareService`;
8
+ /** The Services class whose nodes are the immutable deployments of those Services. */
4
9
  export const DEPLOYMENT_CLASS = `${SERVICES_ORIGIN}:class.CloudflareDeployment`;
5
10
  /**
6
- * The static `CloudflareDeployment` Methods of Admin's Services this adapter calls (CT19):
7
- * `hosting` reads where deployments are addressed, `deploy` creates or reuses one deployment,
8
- * `list` reads the deployments of the lines the caller holds, and `lastCalls` reads when each of
9
- * them was last called. They run on Admin's Kernel through `astrale call --admin` (CT21).
11
+ * The static `CloudflareService` Methods of Admin's Services this adapter calls: `hosting` reads
12
+ * where Services and deployments are addressed, `deploy` creates or reuses one deployment of the
13
+ * Service of its origin and environment (creating that Service on its first deploy), and `list`
14
+ * reads the deployments of the Services the caller owns. They run on Admin's Kernel through
15
+ * `astrale call --admin` (CT21).
10
16
  */
11
17
  export const SERVICES_METHODS = Object.freeze({
12
- hosting: `/:${DEPLOYMENT_CLASS}:hosting`,
13
- deploy: `/:${DEPLOYMENT_CLASS}:deploy`,
14
- list: `/:${DEPLOYMENT_CLASS}:list`,
15
- lastCalls: `/:${DEPLOYMENT_CLASS}:lastCalls`,
18
+ hosting: `/:${SERVICE_CLASS}:hosting`,
19
+ deploy: `/:${SERVICE_CLASS}:deploy`,
20
+ list: `/:${SERVICE_CLASS}:list`,
16
21
  });
17
- /** The most labels one `CloudflareDeployment.lastCalls` reads (Services' `lastCallsInput`). */
18
- export const LAST_CALL_LABELS = 100;
19
22
  /**
20
- * How long Admin's Services keeps serving a preview after its activation or its last call,
21
- * whichever is later (D6, AM-123): its `PREVIEW_RETENTION_MILLISECONDS`. `expiresAt` as Services
22
- * records it already follows this rule for the calls Services has recorded.
23
+ * Where one hosted Service is called on Admin's Kernel: its node, `@<serviceId>`, qualified by its
24
+ * class. Its instance Methods act on the Service and its current deployment:
25
+ * `astrale call "<path>.method.setSecret" --admin` rewrites one secret of the deployment the
26
+ * Service serves, and `promote`, `transfer`, `secrets`, `setSchedule`, `schedules`, `logs` and
27
+ * `delete` are called the same way.
23
28
  */
24
- export const PREVIEW_RETENTION_MILLISECONDS = 30 * 24 * 60 * 60 * 1_000;
29
+ export function serviceCallPath(serviceId) {
30
+ return `@${serviceId}::${SERVICE_CLASS}`;
31
+ }
25
32
  /**
26
33
  * Where one hosted deployment is called on Admin's Kernel: its node, `@<id>`, qualified by its
27
- * class, so that `astrale call "<path>.method.setSecret" --admin` rotates one of its secrets in
28
- * place on that deployment alone (AM-4').
34
+ * class, whose only instance Method is `retire`, the emergency stop of that deployment alone.
29
35
  */
30
36
  export function deploymentCallPath(id) {
31
37
  return `@${id}::${DEPLOYMENT_CLASS}`;
@@ -1,19 +1,20 @@
1
1
  import type { BundleUpload } from '@astrale-os/adapter-cloudflare/build';
2
2
  import type { ReleaseDeployContext } from '@astrale-os/sdk/deployment/adapter';
3
- import type { AstraleParams } from '../params.js';
4
3
  import type { DeploymentRequestV1 } from './api.js';
5
4
  /** What of one deploy the request to Admin's Services carries. */
6
5
  export type DeploymentRequestContext = Pick<ReleaseDeployContext, 'environment' | 'secrets' | 'bundle' | 'configuration' | 'placement' | 'label' | 'release' | 'commit'>;
7
6
  /**
8
- * The `DeploymentRequestV1` of one sealed release: the address the SDK derived (line addressing,
7
+ * The `DeploymentRequestV1` of one sealed release: the address the SDK derived (opaque line,
9
8
  * label, build digest, frozen configuration), the facts its deployment record declares, the
10
- * Worker upload of its Bundle, and the Environment's current secrets.
9
+ * Worker upload of its Bundle, and the Environment's current secrets. It names no `owner`, so a
10
+ * Service its first deploy creates is the caller's, and asks no `promote`, so the Service serves
11
+ * the deployment once it is active.
11
12
  *
12
13
  * The upload reproduces the Bundle's build digest, which Services recomputes from these bytes, and
13
14
  * the secrets are exactly the names the configuration declares, which Services requires: a request
14
15
  * Services would refuse for either is refused here, before any call.
15
16
  */
16
- export declare function deploymentRequest(parameters: Pick<AstraleParams, 'organization'>, context: DeploymentRequestContext): DeploymentRequestV1;
17
+ export declare function deploymentRequest(context: DeploymentRequestContext): DeploymentRequestV1;
17
18
  /**
18
19
  * One Worker upload on the wire: each module and asset in the Services content envelope (gzip when
19
20
  * that is smaller, identity otherwise, over portable Base64), and the assets served
@@ -1,29 +1,34 @@
1
1
  import { bundleUpload } from '@astrale-os/adapter-cloudflare/build';
2
2
  import { deploymentContent } from './content.js';
3
3
  /**
4
- * The `DeploymentRequestV1` of one sealed release: the address the SDK derived (line addressing,
4
+ * The `DeploymentRequestV1` of one sealed release: the address the SDK derived (opaque line,
5
5
  * label, build digest, frozen configuration), the facts its deployment record declares, the
6
- * Worker upload of its Bundle, and the Environment's current secrets.
6
+ * Worker upload of its Bundle, and the Environment's current secrets. It names no `owner`, so a
7
+ * Service its first deploy creates is the caller's, and asks no `promote`, so the Service serves
8
+ * the deployment once it is active.
7
9
  *
8
10
  * The upload reproduces the Bundle's build digest, which Services recomputes from these bytes, and
9
11
  * the secrets are exactly the names the configuration declares, which Services requires: a request
10
12
  * Services would refuse for either is refused here, before any call.
11
13
  */
12
- export function deploymentRequest(parameters, context) {
14
+ export function deploymentRequest(context) {
13
15
  const declared = context.configuration.bindings.secrets;
14
16
  const supplied = Object.keys(context.secrets).sort();
15
17
  if (supplied.length !== declared.length || supplied.some((name, at) => name !== declared[at])) {
16
18
  throw new TypeError('The deploy secrets differ from the secret names its configuration declares.');
17
19
  }
20
+ // Services names every Service by its opaque line; placement never places another.
21
+ if (context.placement.addressing !== 'opaque') {
22
+ throw new TypeError('Admin Services hosts deployments on opaque lines only.');
23
+ }
18
24
  const upload = bundleUpload(context.bundle);
19
25
  const { document } = context.release;
20
26
  return Object.freeze({
21
27
  format: 'astrale.services.deployment-request',
22
28
  version: 1,
23
- ...(parameters.organization === undefined ? {} : { organization: parameters.organization }),
24
29
  origin: document.origin,
25
30
  environment: context.environment,
26
- addressing: context.placement.addressing,
31
+ addressing: 'opaque',
27
32
  label: context.label,
28
33
  buildDigest: context.bundle.digest,
29
34
  configuration: context.configuration,
@@ -1,24 +1,18 @@
1
- import type { DeploymentSummaryV1 } from '@astrale-os/sdk/deployment/address';
2
- import type { DeploymentHostingV1, DeploymentResponseV1 } from './api.js';
3
- /** Admit the answer of `CloudflareDeployment.hosting`. */
1
+ import type { DeploymentHostingV1, DeploymentResponseV1, ServiceDeploymentSummaryV1 } from './api.js';
2
+ /** One deployment as Services lists it, its record not yet admitted. */
3
+ export type ListedServiceDeploymentV1 = Omit<ServiceDeploymentSummaryV1, 'record'> & {
4
+ readonly record: unknown;
5
+ };
6
+ /** Admit the answer of `CloudflareService.hosting`: a routing domain, and opaque Service names. */
4
7
  export declare function decodeHosting(input: unknown): DeploymentHostingV1;
5
8
  /**
6
- * Admit the answer of `CloudflareDeployment.deploy` exactly: a deployment whose state reports the
9
+ * Admit the answer of `CloudflareService.deploy` exactly: a deployment whose state reports the
7
10
  * secret state CT19 pairs with it and whose record admits, or a refusal Services can give.
8
11
  */
9
12
  export declare function decodeDeploymentResponse(input: unknown): DeploymentResponseV1;
10
13
  /**
11
- * Admit the answer of `CloudflareDeployment.list`: what Services knows of each deployment of the
12
- * lines the caller holds, exactly, each with the record Services stores, unadmitted. The listing
14
+ * Admit the answer of `CloudflareService.list`: what Services knows of each deployment of the
15
+ * Services the caller owns, exactly, each with the record Services stores, unadmitted. The listing
13
16
  * admits each record itself and lists a deployment whose record it refuses from these facts.
14
17
  */
15
- export declare function decodeDeploymentList(input: unknown): readonly (Omit<DeploymentSummaryV1, 'record'> & {
16
- readonly record: unknown;
17
- })[];
18
- /**
19
- * Admit the answer of `CloudflareDeployment.lastCalls` for the labels asked, exactly: one entry per
20
- * label, the instant of its last call or `null` when none was ever counted or recorded. Services
21
- * refuses the whole call when the caller does not hold one of the labels, so an answer never
22
- * leaves a label out.
23
- */
24
- export declare function decodeLastCalls(input: unknown, labels: readonly string[]): Readonly<Record<string, string | null>>;
18
+ export declare function decodeDeploymentList(input: unknown): readonly ListedServiceDeploymentV1[];
@@ -4,7 +4,7 @@ const REJECTIONS = Object.freeze([
4
4
  'invalid-deployment',
5
5
  'address-mismatch',
6
6
  'build-mismatch',
7
- 'line-owned-elsewhere',
7
+ 'service-owned-elsewhere',
8
8
  'deployment-conflict',
9
9
  'deployment-retired',
10
10
  'hosting-unavailable',
@@ -22,20 +22,19 @@ const SECRETS_BY_STATE = Object.freeze({
22
22
  created: Object.freeze(['bound']),
23
23
  reused: Object.freeze(['updated', 'unchanged']),
24
24
  });
25
- /** Admit the answer of `CloudflareDeployment.hosting`. */
25
+ /** Admit the answer of `CloudflareService.hosting`: a routing domain, and opaque Service names. */
26
26
  export function decodeHosting(input) {
27
27
  const value = object(input, 'hosting');
28
28
  exact(value, ['routingDomain', 'addressing'], [], 'hosting');
29
29
  if (typeof value.routingDomain !== 'string' || !isDnsName(value.routingDomain)) {
30
30
  invalid('hosting', 'routingDomain');
31
31
  }
32
- if (value.addressing !== 'readable' && value.addressing !== 'opaque') {
32
+ if (value.addressing !== 'opaque')
33
33
  invalid('hosting', 'addressing');
34
- }
35
- return Object.freeze({ routingDomain: value.routingDomain, addressing: value.addressing });
34
+ return Object.freeze({ routingDomain: value.routingDomain, addressing: 'opaque' });
36
35
  }
37
36
  /**
38
- * Admit the answer of `CloudflareDeployment.deploy` exactly: a deployment whose state reports the
37
+ * Admit the answer of `CloudflareService.deploy` exactly: a deployment whose state reports the
39
38
  * secret state CT19 pairs with it and whose record admits, or a refusal Services can give.
40
39
  */
41
40
  export function decodeDeploymentResponse(input) {
@@ -79,8 +78,8 @@ export function decodeDeploymentResponse(input) {
79
78
  });
80
79
  }
81
80
  /**
82
- * Admit the answer of `CloudflareDeployment.list`: what Services knows of each deployment of the
83
- * lines the caller holds, exactly, each with the record Services stores, unadmitted. The listing
81
+ * Admit the answer of `CloudflareService.list`: what Services knows of each deployment of the
82
+ * Services the caller owns, exactly, each with the record Services stores, unadmitted. The listing
84
83
  * admits each record itself and lists a deployment whose record it refuses from these facts.
85
84
  */
86
85
  export function decodeDeploymentList(input) {
@@ -90,25 +89,7 @@ export function decodeDeploymentList(input) {
90
89
  invalid('list', 'deployments');
91
90
  return Object.freeze(value.deployments.map((deployment) => hostedDeployment(deployment)));
92
91
  }
93
- /**
94
- * Admit the answer of `CloudflareDeployment.lastCalls` for the labels asked, exactly: one entry per
95
- * label, the instant of its last call or `null` when none was ever counted or recorded. Services
96
- * refuses the whole call when the caller does not hold one of the labels, so an answer never
97
- * leaves a label out.
98
- */
99
- export function decodeLastCalls(input, labels) {
100
- const value = object(input, 'lastCalls');
101
- exact(value, labels, [], 'lastCalls');
102
- const calls = {};
103
- for (const label of labels) {
104
- const instant = value[label];
105
- if (instant !== null && !isInstant(instant))
106
- invalid('lastCalls', label);
107
- calls[label] = instant;
108
- }
109
- return Object.freeze(calls);
110
- }
111
- /** `DeploymentSummaryV1` as Services returns it, its record admitted: never a provider version id. */
92
+ /** Services' `DeploymentSummaryV1`, its record admitted: never a provider version id. */
112
93
  function decodeSummary(input) {
113
94
  const summary = hostedDeployment(input);
114
95
  let record;
@@ -123,9 +104,10 @@ function decodeSummary(input) {
123
104
  return Object.freeze({ ...summary, record });
124
105
  }
125
106
  /**
126
- * The facts Services owns about one deployment, exactly as `DeploymentSummaryV1` names them, and
127
- * the record it stores beside them, not yet admitted. Its id is a Kernel node id, and its label,
128
- * line and URL are one deployment's: a listing prints them and calls the deployment by its id.
107
+ * The facts Services owns about one deployment, exactly as its `DeploymentSummaryV1` names them,
108
+ * and the record it stores beside them, not yet admitted. Its id and its Service's id are Kernel
109
+ * node ids, its Service is the line of its label, and its label and URL are one deployment's: a
110
+ * listing prints them and calls the deployment and its Service by their ids.
129
111
  */
130
112
  function hostedDeployment(input) {
131
113
  const value = object(input, 'deployment');
@@ -133,22 +115,24 @@ function hostedDeployment(input) {
133
115
  'id',
134
116
  'url',
135
117
  'label',
136
- 'line',
118
+ 'serviceId',
119
+ 'service',
137
120
  'owner',
138
121
  'state',
139
- 'retention',
122
+ 'current',
140
123
  'createdAt',
141
124
  'signingKeyId',
142
125
  'record',
143
126
  ];
144
- const optional = ['lastCallAt', 'expiresAt', 'retiredAt', 'retirement'];
145
- exact(value, required, optional, 'deployment');
146
- for (const key of ['id', 'url', 'label', 'line', 'owner', 'signingKeyId']) {
127
+ exact(value, required, ['retiredAt'], 'deployment');
128
+ for (const key of ['id', 'url', 'label', 'serviceId', 'service', 'owner', 'signingKeyId']) {
147
129
  if (typeof value[key] !== 'string' || !isPrintable(value[key]))
148
130
  invalid('deployment', key);
149
131
  }
150
132
  if (!isNodeId(value.id))
151
133
  invalid('deployment', 'id');
134
+ if (!isNodeId(value.serviceId))
135
+ invalid('deployment', 'serviceId');
152
136
  let line;
153
137
  try {
154
138
  line = parseDeploymentLabel(value.label).line;
@@ -156,27 +140,24 @@ function hostedDeployment(input) {
156
140
  catch {
157
141
  invalid('deployment', 'label');
158
142
  }
159
- if (value.line !== line)
160
- invalid('deployment', 'line');
143
+ if (value.service !== line)
144
+ invalid('deployment', 'service');
161
145
  if (!isDeploymentUrl(value.url, value.label))
162
146
  invalid('deployment', 'url');
163
147
  if (!DEPLOYMENT_STATES.includes(value.state)) {
164
148
  invalid('deployment', 'state');
165
149
  }
166
- if (value.retention !== 'preview' && value.retention !== 'published') {
167
- invalid('deployment', 'retention');
168
- }
169
- for (const key of ['createdAt', 'lastCallAt', 'expiresAt', 'retiredAt']) {
150
+ if (typeof value.current !== 'boolean')
151
+ invalid('deployment', 'current');
152
+ for (const key of ['createdAt', 'retiredAt']) {
170
153
  if ((key === 'createdAt' || value[key] !== undefined) && !isInstant(value[key])) {
171
154
  invalid('deployment', key);
172
155
  }
173
156
  }
174
- if (value.retirement !== undefined &&
175
- value.retirement !== 'expired' &&
176
- value.retirement !== 'withdrawn') {
177
- invalid('deployment', 'retirement');
178
- }
179
- return Object.freeze({ ...value, record: value.record });
157
+ return Object.freeze({
158
+ ...value,
159
+ record: value.record,
160
+ });
180
161
  }
181
162
  /** `https://<label>.<routing domain>`, nothing more: the URL a deployment is installed by. */
182
163
  function isDeploymentUrl(url, label) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/adapter-astrale",
3
- "version": "0.5.0-beta.167",
3
+ "version": "0.5.0-beta.168",
4
4
  "description": "Deploy an Astrale domain as a managed service through the Astrale platform",
5
5
  "keywords": [
6
6
  "adapter",
@@ -37,8 +37,8 @@
37
37
  "registry": "https://registry.npmjs.org/"
38
38
  },
39
39
  "dependencies": {
40
- "@astrale-os/adapter-cloudflare": "0.5.0-beta.174",
41
- "@astrale-os/sdk": "0.6.0-beta.19"
40
+ "@astrale-os/adapter-cloudflare": "0.5.0-beta.175",
41
+ "@astrale-os/sdk": "0.6.0-beta.20"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@astrale-os/ox": "0.1.4",
@@ -8,8 +8,7 @@
8
8
  * Redeploying the same release reuses its deployment; a changed secrets file is
9
9
  * then rewritten in place on that deployment only.
10
10
  *
11
- * `development` deploys on a line of the identity that deploys it. Every other
12
- * Environment names the organisation that holds its deployment line.
11
+ * Every Environment deploys through the Astrale CLI's authenticated identity.
13
12
  */
14
13
  import { astrale } from '@astrale-os/adapter-astrale'
15
14
  import { defineProject } from '@astrale-os/sdk/project'
@@ -17,14 +16,6 @@ import { dataset, tests } from '@astrale-os/sdk/testing'
17
16
 
18
17
  import { domain } from './domain.js'
19
18
 
20
- /**
21
- * The organisation that holds the deployment line of every Environment but
22
- * `development`: the id of an Identity on the Admin instance, a User or a Shell
23
- * Group, whose members and CI deploy for it. Replace this placeholder with that
24
- * Identity id before deploying `production`.
25
- */
26
- const organization = 'your-organization-identity-id'
27
-
28
19
  export default defineProject({
29
20
  domain,
30
21
 
@@ -34,7 +25,7 @@ export default defineProject({
34
25
  },
35
26
 
36
27
  production: {
37
- deployment: astrale({ organization }),
28
+ deployment: astrale(),
38
29
  },
39
30
  },
40
31