@astrale-os/adapter-astrale 0.5.0-beta.156 → 0.5.0-beta.158

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.
@@ -0,0 +1,7 @@
1
+ import { type PortableBase64 } from './base64.js';
2
+ export type DeploymentContent = {
3
+ readonly encoding: 'identity' | 'gzip';
4
+ readonly decodedSize: number;
5
+ } & PortableBase64;
6
+ /** Compression is transport-only and must never expand the request or change release identity. */
7
+ export declare function deploymentContent(bytes: Uint8Array): DeploymentContent;
@@ -0,0 +1,13 @@
1
+ import { gzipSync } from 'node:zlib';
2
+ import { portableBase64 } from './base64.js';
3
+ /** Compression is transport-only and must never expand the request or change release identity. */
4
+ export function deploymentContent(bytes) {
5
+ // A gzip header/trailer costs twenty bytes; tiny files cannot justify compression work.
6
+ const compressed = bytes.byteLength < 64 ? undefined : gzipSync(bytes, { level: 9 });
7
+ const gzip = compressed !== undefined && compressed.byteLength < bytes.byteLength;
8
+ return Object.freeze({
9
+ encoding: gzip ? 'gzip' : 'identity',
10
+ decodedSize: bytes.byteLength,
11
+ ...portableBase64(gzip ? compressed : bytes),
12
+ });
13
+ }
@@ -1,5 +1,5 @@
1
1
  import type { PreparedArtifact } from '@astrale-os/sdk/deployment/adapter';
2
- import { type PortableBase64 } from './base64.js';
2
+ import { type DeploymentContent } from './content.js';
3
3
  export interface DeploymentRequestInput {
4
4
  readonly origin: string;
5
5
  readonly serviceKey: string;
@@ -9,7 +9,8 @@ export interface DeploymentRequestInput {
9
9
  type EncodedModule = {
10
10
  readonly name: string;
11
11
  readonly kind: 'esm' | 'wasm' | 'text' | 'data';
12
- } & PortableBase64;
12
+ readonly content: DeploymentContent;
13
+ };
13
14
  interface EncodedArtifact {
14
15
  readonly entry: string;
15
16
  readonly modules: readonly EncodedModule[];
@@ -34,10 +35,11 @@ export interface DeploymentRequest {
34
35
  readonly vars?: Readonly<Record<string, string>>;
35
36
  readonly secrets: Readonly<Record<string, string>>;
36
37
  readonly assets?: {
37
- readonly files: readonly ({
38
+ readonly files: readonly {
38
39
  readonly path: string;
39
40
  readonly contentType?: string;
40
- } & PortableBase64)[];
41
+ readonly content: DeploymentContent;
42
+ }[];
41
43
  readonly notFound: 'none' | '404-page' | 'single-page-application';
42
44
  readonly runWorkerFirst: boolean;
43
45
  readonly htmlHandling?: 'none';
@@ -1,5 +1,5 @@
1
- import { loadWorkerArtifact } from '@astrale-os/adapter-cloudflare/build';
2
- import { portableBase64 } from './base64.js';
1
+ import { isAdapterVar, loadWorkerArtifact, } from '@astrale-os/adapter-cloudflare/build';
2
+ import { deploymentContent } from './content.js';
3
3
  export function deploymentRequest(artifact, input) {
4
4
  const worker = loadWorkerArtifact(artifact);
5
5
  if (worker.origin !== input.origin) {
@@ -10,7 +10,9 @@ export function deploymentRequest(artifact, input) {
10
10
  ...worker.bindings.services.map((binding) => binding.name),
11
11
  ]);
12
12
  for (const name of Object.keys(input.secrets)) {
13
- if (!/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/u.test(name) || occupied.has(name)) {
13
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/u.test(name) ||
14
+ occupied.has(name) ||
15
+ isAdapterVar(name)) {
14
16
  throw new TypeError(`Managed Worker secret ${name} is invalid or collides with a binding.`);
15
17
  }
16
18
  occupied.add(name);
@@ -41,7 +43,7 @@ export function deploymentRequest(artifact, input) {
41
43
  assets: Object.freeze({
42
44
  files: Object.freeze(worker.assets.files.map((file) => Object.freeze({
43
45
  path: file.path,
44
- ...portableBase64(file.bytes()),
46
+ content: deploymentContent(file.bytes()),
45
47
  ...(file.contentType === undefined ? {} : { contentType: file.contentType }),
46
48
  }))),
47
49
  notFound: worker.assets.notFound,
@@ -59,7 +61,7 @@ function executable(executable) {
59
61
  modules: Object.freeze(executable.modules.map((module) => Object.freeze({
60
62
  name: module.path,
61
63
  kind: module.kind,
62
- ...portableBase64(module.bytes()),
64
+ content: deploymentContent(module.bytes()),
63
65
  }))),
64
66
  });
65
67
  }
package/dist/params.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { DurableWorkerOptions } from '@astrale-os/adapter-cloudflare';
1
2
  import type { ExchangeOptions } from '@astrale-os/sdk/execution';
2
3
  /**
3
4
  * `AstraleParams` — the provider-typed config for the Astrale-managed adapter.
@@ -33,4 +34,11 @@ export interface AstraleParams {
33
34
  * The default maximum is 30 minutes; production and CI environments may select a shorter bound.
34
35
  */
35
36
  readonly tokenExchange?: ExchangeOptions | false;
37
+ /**
38
+ * What a Worker serving durable Workflows declares to the workflow engine: run retention, retry
39
+ * before pausing and the deadline of each Step. Canonical callbacks discover engine keys from
40
+ * their Kernel. The deprecated `ASTRALE_RESTATE_IDENTITY_KEYS` var admits retained legacy
41
+ * callbacks only.
42
+ */
43
+ readonly durable?: DurableWorkerOptions;
36
44
  }
@@ -3,5 +3,6 @@ export declare function cloudflareParameters(parameters: AstraleParams): Readonl
3
3
  vars?: Readonly<Record<string, string>> | undefined;
4
4
  maximumRequestBytes?: number | undefined;
5
5
  tokenExchange?: false | import("../../../src/execution/index.js").ExchangeOptions | undefined;
6
+ durable?: import("@astrale-os/adapter-cloudflare").DurableWorkerOptions | undefined;
6
7
  signingIdentity?: string | undefined;
7
8
  }>;
@@ -5,6 +5,7 @@ export function cloudflareParameters(parameters) {
5
5
  ? {}
6
6
  : { maximumRequestBytes: parameters.maximumRequestBytes }),
7
7
  ...(parameters.tokenExchange === undefined ? {} : { tokenExchange: parameters.tokenExchange }),
8
+ ...(parameters.durable === undefined ? {} : { durable: parameters.durable }),
8
9
  ...(parameters.signingIdentity === undefined
9
10
  ? {}
10
11
  : { signingIdentity: parameters.signingIdentity }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/adapter-astrale",
3
- "version": "0.5.0-beta.156",
3
+ "version": "0.5.0-beta.158",
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.163",
41
- "@astrale-os/sdk": "0.6.0-beta.8"
40
+ "@astrale-os/adapter-cloudflare": "0.5.0-beta.165",
41
+ "@astrale-os/sdk": "0.6.0-beta.10"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@astrale-os/ox": "0.1.4",