@astrale-domains/services 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +149 -51
  2. package/dist/scaffold/create-service.mjs +94 -0
  3. package/dist/scaffold/template/.env.example +4 -0
  4. package/dist/scaffold/template/README.md +75 -0
  5. package/dist/scaffold/template/gitignore +6 -0
  6. package/dist/scaffold/template/scripts/build.mjs +20 -0
  7. package/dist/scaffold/template/scripts/deploy.mjs +65 -0
  8. package/dist/scaffold/template/scripts/service.mjs +69 -0
  9. package/dist/scaffold/template/src/account.js +31 -0
  10. package/dist/scaffold/template/src/index.js +50 -0
  11. package/dist/scaffold/template/src/job.js +22 -0
  12. package/dist/schema/index.d.ts +2 -2
  13. package/dist/schema/index.js +1 -1
  14. package/dist/schema/modules/deployment/classes/cloudflare-deployment.d.ts +41 -20
  15. package/dist/schema/modules/deployment/classes/deployment.d.ts +54 -25
  16. package/dist/schema/modules/deployment/classes/deployment.js +20 -9
  17. package/dist/schema/modules/deployment/functions/retire-deployment.d.ts +5 -5
  18. package/dist/schema/modules/deployment/index.d.ts +2 -2
  19. package/dist/schema/modules/deployment/index.js +1 -1
  20. package/dist/schema/modules/deployment/types/deployment-hosting.d.ts +19 -49
  21. package/dist/schema/modules/deployment/types/deployment-hosting.js +10 -10
  22. package/dist/schema/modules/deployment/types/deployment-request.d.ts +45 -93
  23. package/dist/schema/modules/deployment/types/deployment-request.js +60 -30
  24. package/dist/schema/modules/deployment/types/deployment-response.d.ts +14 -22
  25. package/dist/schema/modules/deployment/types/deployment-response.js +5 -2
  26. package/dist/schema/modules/deployment/types/deployment-secret.d.ts +2 -2
  27. package/dist/schema/modules/deployment/types/deployment-secret.js +2 -2
  28. package/dist/schema/modules/deployment/types/deployment-summary.d.ts +13 -112
  29. package/dist/schema/modules/deployment/types/deployment-summary.js +16 -18
  30. package/dist/schema/modules/deployment/types/index.d.ts +10 -12
  31. package/dist/schema/modules/deployment/types/index.js +5 -6
  32. package/dist/schema/modules/deployment/types/{frozen-configuration.d.ts → legacy-deployment.d.ts} +24 -11
  33. package/dist/schema/modules/deployment/types/{frozen-configuration.js → legacy-deployment.js} +34 -10
  34. package/dist/schema/modules/deployment/types/legacy-migration.d.ts +17 -0
  35. package/dist/schema/modules/deployment/types/legacy-migration.js +17 -0
  36. package/dist/schema/modules/deployment/types/worker-configuration.d.ts +21 -0
  37. package/dist/schema/modules/deployment/types/worker-configuration.js +21 -0
  38. package/dist/schema/modules/deployment/types/worker-record.d.ts +12 -0
  39. package/dist/schema/modules/deployment/types/worker-record.js +15 -0
  40. package/dist/schema/modules/service/classes/cloudflare-service.d.ts +72 -135
  41. package/dist/schema/modules/service/classes/cloudflare-service.js +6 -1
  42. package/dist/schema/modules/service/classes/service.d.ts +17 -7
  43. package/dist/schema/modules/service/classes/service.js +14 -8
  44. package/dist/schema/modules/service/functions/deploy-service.d.ts +44 -100
  45. package/dist/schema/modules/service/functions/deploy-service.js +6 -5
  46. package/dist/schema/modules/service/functions/describe-hosting.d.ts +0 -1
  47. package/dist/schema/modules/service/functions/index.d.ts +1 -0
  48. package/dist/schema/modules/service/functions/index.js +1 -0
  49. package/dist/schema/modules/service/functions/list-service-deployments.d.ts +12 -36
  50. package/dist/schema/modules/service/functions/migrate-legacy-deployments.d.ts +17 -0
  51. package/dist/schema/modules/service/functions/migrate-legacy-deployments.js +15 -0
  52. package/dist/schema/modules/service/functions/promote-service.d.ts +2 -2
  53. package/dist/schema/modules/service/functions/set-service-secret.d.ts +2 -2
  54. package/dist/schema/modules/service/functions/transfer-service.d.ts +2 -2
  55. package/dist/schema/modules/service/index.d.ts +1 -1
  56. package/dist/schema/modules/service/index.js +1 -1
  57. package/dist/schema/schema.d.ts +158 -177
  58. package/package.json +11 -7
  59. package/dist/schema/modules/deployment/types/content/index.d.ts +0 -1
  60. package/dist/schema/modules/deployment/types/content/index.js +0 -1
  61. package/dist/schema/modules/deployment/types/content/limits.d.ts +0 -7
  62. package/dist/schema/modules/deployment/types/content/limits.js +0 -7
  63. package/dist/schema/modules/deployment/types/deployment-record.d.ts +0 -35
  64. package/dist/schema/modules/deployment/types/deployment-record.js +0 -31
  65. package/dist/schema/modules/deployment/types/service-deployment-artifact-module.d.ts +0 -26
  66. package/dist/schema/modules/deployment/types/service-deployment-artifact-module.js +0 -10
  67. package/dist/schema/modules/deployment/types/service-deployment-assets.d.ts +0 -49
  68. package/dist/schema/modules/deployment/types/service-deployment-assets.js +0 -16
  69. package/dist/schema/modules/deployment/types/service-deployment-content.d.ts +0 -19
  70. package/dist/schema/modules/deployment/types/service-deployment-content.js +0 -24
@@ -1,77 +1,35 @@
1
1
  /**
2
- * Host one release as an immutable deployment of the Service of its origin and environment,
3
- * creating that Service on its first deploy, and by default make it the one the Service serves.
4
- * Any authenticated identity may ask; the handler proves that the caller owns the Service, or for
5
- * a new one that it is or acts as the owner it names, before any write.
2
+ * Host one Cloudflare Worker release (`WorkerDeploymentRequestV1`) as an immutable deployment of
3
+ * the Service of its project and environment, creating that Service on its first deploy, and by
4
+ * default make it the one the Service serves. Any authenticated identity may ask; the handler
5
+ * proves that the caller owns the Service, or for a new one that it is or acts as the owner it
6
+ * names, before any write.
6
7
  */
7
8
  export declare const deployService: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<{
8
- format: "astrale.services.deployment-request";
9
+ format: "astrale.worker.deployment-request";
9
10
  version: 1;
10
11
  owner?: string | undefined;
11
- origin: string;
12
+ project: string;
12
13
  environment: string;
13
- addressing: "opaque";
14
14
  label: string;
15
15
  buildDigest: string;
16
16
  configuration: {
17
- format: "astrale.deployment.configuration";
17
+ format: "astrale.worker.configuration";
18
18
  version: 1;
19
+ compatibilityDate: string;
20
+ compatibilityFlags: string[];
19
21
  vars: Record<string, string>;
20
- settings: {
21
- maximumRequestBytes: number;
22
- invocationTimeoutMs: number;
23
- tokenExchange: false | {
24
- maximumLifetimeSeconds: number;
25
- };
26
- durableOptions?: {
27
- retentionMs?: number | undefined;
28
- retry?: {
29
- initialIntervalMs?: number | undefined;
30
- maxAttempts?: number | undefined;
31
- maxIntervalMs?: number | undefined;
32
- } | undefined;
33
- stepTimeoutMs?: number | undefined;
34
- } | undefined;
35
- };
36
- runtime: {
37
- compatibilityDate: string;
38
- compatibilityFlags: string[];
39
- };
40
- bindings: {
41
- services: {
42
- name: string;
43
- service: string;
44
- }[];
45
- dispatchNamespaces: {
46
- name: string;
47
- namespace: string;
48
- }[];
49
- secrets: string[];
50
- };
51
- router: false | {
52
- service: string;
53
- hostSuffix: string;
54
- minLabels: number;
55
- };
56
- };
57
- record: {
58
- releaseDigest: string;
59
- schemaRevision: string;
60
- schemaBundle: string;
61
- commit: {
62
- sha: string;
63
- dirty: boolean;
64
- base?: {
65
- version: string;
66
- distance: number;
67
- } | undefined;
68
- } | null;
22
+ secrets: string[];
23
+ record: boolean;
24
+ signingIdentity: boolean;
25
+ router: boolean;
69
26
  };
70
- bundle: {
71
- entrypoint: string;
27
+ worker: {
28
+ manifest: Record<string, unknown>;
29
+ mainModule: string;
72
30
  modules: {
73
31
  name: string;
74
- kind?: "data" | "esm" | "text" | "wasm" | undefined;
32
+ kind: "data" | "esm" | "text" | "wasm";
75
33
  content: {
76
34
  encoding: "gzip" | "identity";
77
35
  decodedSize: number;
@@ -83,29 +41,26 @@ export declare const deployService: import("@astrale-os/sdk/schema").Method<impo
83
41
  };
84
42
  }[];
85
43
  assets?: {
86
- files: {
87
- path: string;
88
- contentType?: string | undefined;
89
- content: {
90
- encoding: "gzip" | "identity";
91
- decodedSize: number;
92
- contentBase64: string;
93
- } | {
94
- encoding: "gzip" | "identity";
95
- decodedSize: number;
96
- contentBase64Chunks: string[];
97
- };
98
- }[];
99
- notFound?: "404-page" | "none" | "single-page-application" | undefined;
100
- runWorkerFirst?: boolean | undefined;
101
- htmlHandling?: "none" | undefined;
102
- } | undefined;
44
+ path: string;
45
+ contentType?: string | undefined;
46
+ content: {
47
+ encoding: "gzip" | "identity";
48
+ decodedSize: number;
49
+ contentBase64: string;
50
+ } | {
51
+ encoding: "gzip" | "identity";
52
+ decodedSize: number;
53
+ contentBase64Chunks: string[];
54
+ };
55
+ }[] | undefined;
103
56
  };
57
+ record?: {
58
+ contentType: string;
59
+ contentBase64: string;
60
+ } | undefined;
61
+ readiness?: string[] | undefined;
104
62
  secrets: Record<string, string>;
105
63
  promote?: boolean | undefined;
106
- readiness?: {
107
- paths: string[];
108
- } | undefined;
109
64
  }, {
110
65
  readonly mode: 'value';
111
66
  readonly value: {
@@ -125,31 +80,20 @@ export declare const deployService: import("@astrale-os/sdk/schema").Method<impo
125
80
  label: string;
126
81
  serviceId: string;
127
82
  service: string;
83
+ project: string;
84
+ environment: string;
128
85
  owner: string;
129
86
  state: "active" | "deploying" | "failed" | "retired" | "retiring";
130
87
  current: boolean;
131
88
  createdAt: string;
132
89
  retiredAt?: string | undefined;
133
- signingKeyId: string;
134
- record: {
135
- format: "astrale.deployment-record";
136
- version: 1;
137
- origin: string;
138
- environment: string;
139
- releaseDigest: string;
140
- buildDigest: string;
141
- schemaRevision: string;
142
- configuration: string;
143
- providerScript: string;
144
- commit: {
145
- sha: string;
146
- dirty: boolean;
147
- base?: {
148
- version: string;
149
- distance: number;
150
- } | undefined;
151
- } | null;
152
- };
90
+ buildDigest: string;
91
+ configuration: string;
92
+ signingKeyId?: string | undefined;
93
+ record?: {
94
+ contentType: string;
95
+ contentBase64: string;
96
+ } | undefined;
153
97
  };
154
98
  };
155
99
  }, "authenticated", true, false, undefined>>;
@@ -1,13 +1,14 @@
1
1
  import { method } from '@astrale-os/sdk/schema';
2
2
  import { deploymentRequest, deploymentResponse } from '../../deployment/index.js';
3
3
  /**
4
- * Host one release as an immutable deployment of the Service of its origin and environment,
5
- * creating that Service on its first deploy, and by default make it the one the Service serves.
6
- * Any authenticated identity may ask; the handler proves that the caller owns the Service, or for
7
- * a new one that it is or acts as the owner it names, before any write.
4
+ * Host one Cloudflare Worker release (`WorkerDeploymentRequestV1`) as an immutable deployment of
5
+ * the Service of its project and environment, creating that Service on its first deploy, and by
6
+ * default make it the one the Service serves. Any authenticated identity may ask; the handler
7
+ * proves that the caller owns the Service, or for a new one that it is or acts as the owner it
8
+ * names, before any write.
8
9
  */
9
10
  export const deployService = method({
10
- description: 'Host one release as an immutable deployment of its Service.',
11
+ description: 'Host one Worker release as an immutable deployment of its Service.',
11
12
  auth: 'authenticated',
12
13
  static: true,
13
14
  input: deploymentRequest,
@@ -3,6 +3,5 @@ export declare const describeHosting: import("@astrale-os/sdk/schema").Method<im
3
3
  readonly mode: 'value';
4
4
  readonly value: {
5
5
  routingDomain: string;
6
- addressing: "opaque";
7
6
  };
8
7
  }, "authenticated", true, false, undefined>>;
@@ -5,6 +5,7 @@ export { listServiceDeployments } from './list-service-deployments.js';
5
5
  export { listServiceLogs } from './list-service-logs.js';
6
6
  export { listServiceSchedules } from './list-service-schedules.js';
7
7
  export { listServiceSecretNames } from './list-service-secret-names.js';
8
+ export { migrateLegacyDeployments } from './migrate-legacy-deployments.js';
8
9
  export { promoteService } from './promote-service.js';
9
10
  export { replaceServiceSchedules } from './replace-service-schedules.js';
10
11
  export { setServiceSecret } from './set-service-secret.js';
@@ -5,6 +5,7 @@ export { listServiceDeployments } from './list-service-deployments.js';
5
5
  export { listServiceLogs } from './list-service-logs.js';
6
6
  export { listServiceSchedules } from './list-service-schedules.js';
7
7
  export { listServiceSecretNames } from './list-service-secret-names.js';
8
+ export { migrateLegacyDeployments } from './migrate-legacy-deployments.js';
8
9
  export { promoteService } from './promote-service.js';
9
10
  export { replaceServiceSchedules } from './replace-service-schedules.js';
10
11
  export { setServiceSecret } from './set-service-secret.js';
@@ -1,54 +1,30 @@
1
1
  /** The deployments of the Services the caller owns, or acts as the owner of. */
2
2
  export declare const listServiceDeployments: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<{
3
- origin?: string | undefined;
3
+ project?: string | undefined;
4
4
  environment?: string | undefined;
5
5
  }, {
6
6
  readonly mode: 'value';
7
7
  readonly value: {
8
- deployments: ({
8
+ deployments: {
9
9
  id: string;
10
10
  url: string;
11
11
  label: string;
12
12
  serviceId: string;
13
13
  service: string;
14
+ project: string;
15
+ environment: string;
14
16
  owner: string;
15
17
  state: "active" | "deploying" | "failed" | "retired" | "retiring";
16
18
  current: boolean;
17
19
  createdAt: string;
18
20
  retiredAt?: string | undefined;
19
- signingKeyId: string;
20
- record: {
21
- format: "astrale.deployment-record";
22
- version: 1;
23
- origin: string;
24
- environment: string;
25
- releaseDigest: string;
26
- buildDigest: string;
27
- schemaRevision: string;
28
- configuration: string;
29
- providerScript: string;
30
- commit: {
31
- sha: string;
32
- dirty: boolean;
33
- base?: {
34
- version: string;
35
- distance: number;
36
- } | undefined;
37
- } | null;
38
- };
39
- } | {
40
- id: string;
41
- url: string;
42
- label: string;
43
- serviceId: string;
44
- service: string;
45
- owner: string;
46
- state: "active" | "deploying" | "failed" | "retired" | "retiring";
47
- current: boolean;
48
- createdAt: string;
49
- retiredAt?: string | undefined;
50
- signingKeyId: string;
51
- record: unknown;
52
- })[];
21
+ buildDigest: string;
22
+ configuration: string;
23
+ signingKeyId?: string | undefined;
24
+ record?: {
25
+ contentType: string;
26
+ contentBase64: string;
27
+ } | undefined;
28
+ }[];
53
29
  };
54
30
  }, "authenticated", true, false, undefined>>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * LEGACY — rewrite every Service and deployment created before Services hosted any Worker in the
3
+ * agnostic form, once, after this revision is installed and before the next one is. Only the
4
+ * Kernel's Root calls it: an `authorized` Method without a Policy admits no other caller. Removed
5
+ * with the legacy shapes.
6
+ */
7
+ export declare const migrateLegacyDeployments: import("@astrale-os/sdk/schema").Method<import("@astrale-os/sdk/schema").CallableProjection<Record<string, never>, {
8
+ readonly mode: 'value';
9
+ readonly value: {
10
+ services: number;
11
+ deployments: number;
12
+ unconverted: {
13
+ id: string;
14
+ reason: string;
15
+ }[];
16
+ };
17
+ }, "authorized", true, false, undefined>>;
@@ -0,0 +1,15 @@
1
+ import { method } from '@astrale-os/sdk/schema';
2
+ import { migrateLegacyInput, migrateLegacyOutput } from '../../deployment/index.js';
3
+ /**
4
+ * LEGACY — rewrite every Service and deployment created before Services hosted any Worker in the
5
+ * agnostic form, once, after this revision is installed and before the next one is. Only the
6
+ * Kernel's Root calls it: an `authorized` Method without a Policy admits no other caller. Removed
7
+ * with the legacy shapes.
8
+ */
9
+ export const migrateLegacyDeployments = method({
10
+ description: 'Rewrite the legacy Services and deployments in the agnostic Worker form.',
11
+ auth: 'authorized',
12
+ static: true,
13
+ input: migrateLegacyInput,
14
+ output: migrateLegacyOutput,
15
+ });
@@ -4,11 +4,11 @@ export declare const promoteService: import("@astrale-os/sdk/schema").Method<imp
4
4
  }, {
5
5
  readonly mode: 'value';
6
6
  readonly value: {
7
+ current: string;
8
+ } | {
7
9
  kind: "rejected";
8
10
  reason: "address-mismatch" | "build-mismatch" | "deployment-conflict" | "deployment-retired" | "hosting-unavailable" | "invalid-deployment" | "service-owned-elsewhere" | "service-unavailable";
9
11
  message: string;
10
12
  retryAfter?: string | undefined;
11
- } | {
12
- current: string;
13
13
  };
14
14
  }, "authenticated", false, false, undefined>>;
@@ -4,11 +4,11 @@ export declare const setServiceSecret: import("@astrale-os/sdk/schema").Method<i
4
4
  }, {
5
5
  readonly mode: 'value';
6
6
  readonly value: {
7
+ name: string;
8
+ } | {
7
9
  kind: "rejected";
8
10
  reason: "secret-undeclared" | "service-unavailable";
9
11
  message: string;
10
12
  retryAfter?: string | undefined;
11
- } | {
12
- name: string;
13
13
  };
14
14
  }, "authenticated", false, false, undefined>>;
@@ -4,11 +4,11 @@ export declare const transferService: import("@astrale-os/sdk/schema").Method<im
4
4
  }, {
5
5
  readonly mode: 'value';
6
6
  readonly value: {
7
- owner: string;
8
- } | {
9
7
  kind: "rejected";
10
8
  reason: "address-mismatch" | "build-mismatch" | "deployment-conflict" | "deployment-retired" | "hosting-unavailable" | "invalid-deployment" | "service-owned-elsewhere" | "service-unavailable";
11
9
  message: string;
12
10
  retryAfter?: string | undefined;
11
+ } | {
12
+ owner: string;
13
13
  };
14
14
  }, "authenticated", false, false, undefined>>;
@@ -1,5 +1,5 @@
1
1
  export { CloudflareService, Service, service_owned_by } from './classes/index.js';
2
- export { deleteService, deployService, describeHosting, listServiceDeployments, listServiceLogs, listServiceSchedules, listServiceSecretNames, promoteService, replaceServiceSchedules, setServiceSecret, transferService, } from './functions/index.js';
2
+ export { deleteService, deployService, describeHosting, listServiceDeployments, listServiceLogs, listServiceSchedules, listServiceSecretNames, migrateLegacyDeployments, promoteService, replaceServiceSchedules, setServiceSecret, transferService, } from './functions/index.js';
3
3
  export { serviceNotFound } from './errors/index.js';
4
4
  export { ActAs, OwnService, TraverseOwnedService } from './policies/index.js';
5
5
  export { serviceLifecycle } from './states/index.js';
@@ -1,5 +1,5 @@
1
1
  export { CloudflareService, Service, service_owned_by } from './classes/index.js';
2
- export { deleteService, deployService, describeHosting, listServiceDeployments, listServiceLogs, listServiceSchedules, listServiceSecretNames, promoteService, replaceServiceSchedules, setServiceSecret, transferService, } from './functions/index.js';
2
+ export { deleteService, deployService, describeHosting, listServiceDeployments, listServiceLogs, listServiceSchedules, listServiceSecretNames, migrateLegacyDeployments, promoteService, replaceServiceSchedules, setServiceSecret, transferService, } from './functions/index.js';
3
3
  export { serviceNotFound } from './errors/index.js';
4
4
  export { ActAs, OwnService, TraverseOwnedService } from './policies/index.js';
5
5
  export { serviceLifecycle } from './states/index.js';