@astrale-os/adapter-astrale 0.5.0-beta.21 → 0.5.0-beta.210
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 +161 -2
- package/dist/adapter.d.ts +7 -16
- package/dist/adapter.js +27 -266
- package/dist/admit.d.ts +7 -0
- package/dist/admit.js +44 -0
- package/dist/cli/commands/call.d.ts +15 -0
- package/dist/cli/commands/call.js +36 -0
- package/dist/cli/commands/version.d.ts +12 -0
- package/dist/cli/commands/version.js +56 -0
- package/dist/cli/diagnostic.d.ts +6 -0
- package/dist/cli/diagnostic.js +28 -0
- package/dist/cli/error.d.ts +7 -0
- package/dist/cli/error.js +29 -0
- package/dist/cli/executable.d.ts +2 -0
- package/dist/cli/executable.js +54 -0
- package/dist/cli/identity.d.ts +5 -0
- package/dist/cli/identity.js +11 -0
- package/dist/cli/json.d.ts +2 -0
- package/dist/cli/json.js +39 -0
- package/dist/cli/process.d.ts +18 -0
- package/dist/cli/process.js +109 -0
- package/dist/configure.d.ts +17 -0
- package/dist/configure.js +40 -0
- package/dist/deploy/deploy-release.d.ts +30 -0
- package/dist/deploy/deploy-release.js +168 -0
- package/dist/deploy/list.d.ts +22 -0
- package/dist/deploy/list.js +63 -0
- package/dist/deploy/readiness.d.ts +17 -0
- package/dist/deploy/readiness.js +56 -0
- package/dist/index.d.ts +21 -10
- package/dist/index.js +21 -10
- package/dist/params.d.ts +25 -36
- package/dist/services/api.d.ts +35 -0
- package/dist/services/api.js +39 -0
- package/dist/services/client.d.ts +93 -0
- package/dist/services/client.js +116 -0
- package/dist/services/directory.d.ts +16 -0
- package/dist/services/directory.js +78 -0
- package/dist/services/index.d.ts +44 -0
- package/dist/services/index.js +27 -0
- package/dist/services/request.d.ts +25 -0
- package/dist/services/request.js +71 -0
- package/package.json +18 -11
- package/template/astrale.config.ts +27 -38
- package/dist/cli.d.ts +0 -15
- package/dist/cli.js +0 -48
- package/dist/prerequisite.d.ts +0 -19
- package/dist/prerequisite.js +0 -59
- package/dist/service/addressing.d.ts +0 -3
- package/dist/service/addressing.js +0 -16
- package/dist/service/artifact.d.ts +0 -34
- package/dist/service/artifact.js +0 -122
- package/dist/service/readiness.d.ts +0 -3
- package/dist/service/readiness.js +0 -16
package/dist/service/artifact.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { servicePath } from './addressing.js';
|
|
2
|
-
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
3
|
-
export function deploymentPayload(artifact, input) {
|
|
4
|
-
const module = requiredFile(artifact, artifact.entrypoint);
|
|
5
|
-
const configuration = configurationOf(artifact);
|
|
6
|
-
const entry = artifact.entrypoint.split('/').at(-1);
|
|
7
|
-
const assets = artifact.files
|
|
8
|
-
.filter((file) => file.path.startsWith('frontend/'))
|
|
9
|
-
.map((file) => {
|
|
10
|
-
const path = `/${file.path.slice('frontend/'.length)}`;
|
|
11
|
-
const contentType = mediaType(path);
|
|
12
|
-
return Object.freeze({
|
|
13
|
-
path,
|
|
14
|
-
contentBase64: Buffer.from(file.bytes()).toString('base64'),
|
|
15
|
-
...(contentType === undefined ? {} : { contentType }),
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
return Object.freeze({
|
|
19
|
-
path: servicePath(input.origin),
|
|
20
|
-
name: input.name,
|
|
21
|
-
entry,
|
|
22
|
-
...(configuration.compatibilityDate === undefined
|
|
23
|
-
? {}
|
|
24
|
-
: { compatibilityDate: configuration.compatibilityDate }),
|
|
25
|
-
...(configuration.compatibilityFlags.length === 0
|
|
26
|
-
? {}
|
|
27
|
-
: { compatibilityFlags: configuration.compatibilityFlags }),
|
|
28
|
-
...(configuration.serviceBindings.length === 0
|
|
29
|
-
? {}
|
|
30
|
-
: { serviceBindings: configuration.serviceBindings }),
|
|
31
|
-
modules: Object.freeze([
|
|
32
|
-
Object.freeze({
|
|
33
|
-
name: entry,
|
|
34
|
-
kind: 'esm',
|
|
35
|
-
contentBase64: Buffer.from(module.bytes()).toString('base64'),
|
|
36
|
-
}),
|
|
37
|
-
]),
|
|
38
|
-
...(assets.length === 0
|
|
39
|
-
? {}
|
|
40
|
-
: {
|
|
41
|
-
assets: Object.freeze({
|
|
42
|
-
files: Object.freeze(assets),
|
|
43
|
-
notFound: 'none',
|
|
44
|
-
runWorkerFirst: true,
|
|
45
|
-
}),
|
|
46
|
-
}),
|
|
47
|
-
...(input.vars === undefined ? {} : { vars: Object.freeze({ ...input.vars }) }),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function configurationOf(artifact) {
|
|
51
|
-
const file = requiredFile(artifact, 'wrangler.jsonc');
|
|
52
|
-
let parsed;
|
|
53
|
-
try {
|
|
54
|
-
parsed = JSON.parse(decoder.decode(file.bytes()));
|
|
55
|
-
}
|
|
56
|
-
catch (cause) {
|
|
57
|
-
throw new TypeError('Prepared Worker configuration is invalid.', { cause });
|
|
58
|
-
}
|
|
59
|
-
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
60
|
-
invalid();
|
|
61
|
-
const value = parsed;
|
|
62
|
-
const compatibilityDate = value.compatibility_date === undefined
|
|
63
|
-
? undefined
|
|
64
|
-
: typeof value.compatibility_date === 'string'
|
|
65
|
-
? value.compatibility_date
|
|
66
|
-
: invalid();
|
|
67
|
-
const compatibilityFlags = strings(value.compatibility_flags);
|
|
68
|
-
const services = value.services === undefined ? [] : value.services;
|
|
69
|
-
if (!Array.isArray(services))
|
|
70
|
-
invalid();
|
|
71
|
-
const serviceBindings = services.flatMap((service) => {
|
|
72
|
-
if (service === null || typeof service !== 'object' || Array.isArray(service))
|
|
73
|
-
invalid();
|
|
74
|
-
const record = service;
|
|
75
|
-
if (typeof record.binding !== 'string' || typeof record.service !== 'string')
|
|
76
|
-
invalid();
|
|
77
|
-
return record.binding === 'SELF'
|
|
78
|
-
? []
|
|
79
|
-
: [Object.freeze({ name: record.binding, service: record.service })];
|
|
80
|
-
});
|
|
81
|
-
return Object.freeze({
|
|
82
|
-
compatibilityDate,
|
|
83
|
-
compatibilityFlags: Object.freeze(compatibilityFlags),
|
|
84
|
-
serviceBindings: Object.freeze(serviceBindings),
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function requiredFile(artifact, path) {
|
|
88
|
-
const file = artifact.files.find((candidate) => candidate.path === path);
|
|
89
|
-
if (file === undefined)
|
|
90
|
-
throw new TypeError(`Prepared Worker artifact is missing ${path}.`);
|
|
91
|
-
return file;
|
|
92
|
-
}
|
|
93
|
-
function strings(input) {
|
|
94
|
-
if (input === undefined)
|
|
95
|
-
return [];
|
|
96
|
-
if (!Array.isArray(input) || input.some((value) => typeof value !== 'string'))
|
|
97
|
-
invalid();
|
|
98
|
-
return [...input];
|
|
99
|
-
}
|
|
100
|
-
function invalid() {
|
|
101
|
-
throw new TypeError('Prepared Worker configuration is invalid.');
|
|
102
|
-
}
|
|
103
|
-
const TYPES = Object.freeze({
|
|
104
|
-
html: 'text/html; charset=utf-8',
|
|
105
|
-
js: 'text/javascript; charset=utf-8',
|
|
106
|
-
mjs: 'text/javascript; charset=utf-8',
|
|
107
|
-
css: 'text/css; charset=utf-8',
|
|
108
|
-
json: 'application/json; charset=utf-8',
|
|
109
|
-
svg: 'image/svg+xml',
|
|
110
|
-
png: 'image/png',
|
|
111
|
-
jpg: 'image/jpeg',
|
|
112
|
-
jpeg: 'image/jpeg',
|
|
113
|
-
webp: 'image/webp',
|
|
114
|
-
ico: 'image/x-icon',
|
|
115
|
-
woff: 'font/woff',
|
|
116
|
-
woff2: 'font/woff2',
|
|
117
|
-
wasm: 'application/wasm',
|
|
118
|
-
});
|
|
119
|
-
function mediaType(path) {
|
|
120
|
-
const extension = path.split('.').at(-1)?.toLowerCase();
|
|
121
|
-
return extension === undefined ? undefined : TYPES[extension];
|
|
122
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { verifyReadiness } from '@astrale-os/sdk/deployment/verify';
|
|
2
|
-
export async function waitForReadiness(release, verify = verifyReadiness) {
|
|
3
|
-
const deadline = Date.now() + 90_000;
|
|
4
|
-
let last;
|
|
5
|
-
while (Date.now() < deadline) {
|
|
6
|
-
try {
|
|
7
|
-
await verify(release, { signal: AbortSignal.timeout(5_000) });
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
catch (cause) {
|
|
11
|
-
last = cause;
|
|
12
|
-
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
throw last instanceof Error ? last : new Error('Astrale managed Release did not become ready.');
|
|
16
|
-
}
|