@di-framework/cli-plugin-platform 6.0.3 → 6.0.6
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 +196 -21
- package/dist/args.d.ts +2 -1
- package/dist/args.js +9 -5
- package/dist/assets/http-adapter.js +111 -2
- package/dist/assets/platform/README.md +22 -6
- package/dist/assets/sqlite/BUILD-INFO.txt +1 -1
- package/dist/assets/wit/deps/wasi-clocks-0.2.12/package.wit +43 -0
- package/dist/assets/wit/deps/wasi-filesystem-0.2.12/package.wit +196 -0
- package/dist/assets/wit/deps/wasi-io-0.2.12/package.wit +66 -0
- package/dist/assets/wit/deps/wasi-logging/package.wit +36 -0
- package/dist/build.d.ts +3 -1
- package/dist/build.js +4 -2
- package/dist/command.js +31 -13
- package/dist/console/auth.d.ts +20 -0
- package/dist/console/auth.js +82 -0
- package/dist/console/catalog.d.ts +196 -0
- package/dist/console/catalog.js +821 -0
- package/dist/console/cluster.d.ts +30 -0
- package/dist/console/cluster.js +299 -0
- package/dist/console/errors.d.ts +10 -0
- package/dist/console/errors.js +32 -0
- package/dist/console/run.d.ts +18 -0
- package/dist/console/run.js +102 -0
- package/dist/console/server.d.ts +25 -0
- package/dist/console/server.js +668 -0
- package/dist/console/services.d.ts +47 -0
- package/dist/console/services.js +111 -0
- package/dist/console-ui/app.css +1 -0
- package/dist/console-ui/app.js +260 -0
- package/dist/console-ui/di-framework-mark.png +0 -0
- package/dist/console-ui/index.html +13 -0
- package/dist/deps.d.ts +2 -0
- package/dist/deps.js +5 -3
- package/dist/dev.js +10 -5
- package/dist/egress.d.ts +40 -0
- package/dist/egress.js +214 -0
- package/dist/host-interface.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/manifest.d.ts +7 -0
- package/dist/manifest.js +35 -8
- package/dist/node-compat/console.d.ts +18 -0
- package/dist/node-compat/console.js +42 -0
- package/dist/node-compat/env.js +6 -0
- package/dist/node-compat/events.d.ts +20 -0
- package/dist/node-compat/events.js +55 -0
- package/dist/node-compat/fetch-runtime.d.ts +39 -0
- package/dist/node-compat/fetch-runtime.js +106 -2
- package/dist/node-compat/fs-promises.d.ts +30 -0
- package/dist/node-compat/fs-promises.js +3 -0
- package/dist/node-compat/fs.d.ts +79 -0
- package/dist/node-compat/fs.js +112 -5
- package/dist/node-compat/net.d.ts +2 -1
- package/dist/node-compat/net.js +3 -1
- package/dist/node-compat/storage.d.ts +87 -0
- package/dist/node-compat/storage.js +244 -0
- package/dist/node-compat/stream.d.ts +24 -0
- package/dist/node-compat/stream.js +70 -0
- package/dist/platform.js +2 -4
- package/dist/project.d.ts +5 -0
- package/dist/project.js +4 -0
- package/dist/service.d.ts +21 -2
- package/dist/service.js +71 -5
- package/dist/target.js +6 -1
- package/dist/wit.d.ts +8 -0
- package/dist/wit.js +28 -0
- package/dist/workload.d.ts +45 -0
- package/dist/workload.js +98 -26
- package/package.json +14 -4
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** The wasi:filesystem@0.2.12 descriptor methods the storage backend calls. */
|
|
2
|
+
export type WasiDescriptor = {
|
|
3
|
+
openAt(pathFlags: {
|
|
4
|
+
symlinkFollow?: boolean;
|
|
5
|
+
}, path: string, openFlags: {
|
|
6
|
+
create?: boolean;
|
|
7
|
+
directory?: boolean;
|
|
8
|
+
exclusive?: boolean;
|
|
9
|
+
truncate?: boolean;
|
|
10
|
+
}, flags: {
|
|
11
|
+
read?: boolean;
|
|
12
|
+
write?: boolean;
|
|
13
|
+
mutateDirectory?: boolean;
|
|
14
|
+
}): WasiDescriptor;
|
|
15
|
+
read(length: number, offset: number): [Uint8Array | number[], boolean];
|
|
16
|
+
write(buffer: Uint8Array, offset: number): number;
|
|
17
|
+
setSize(size: number): void;
|
|
18
|
+
stat(): WasiStat;
|
|
19
|
+
statAt(pathFlags: {
|
|
20
|
+
symlinkFollow?: boolean;
|
|
21
|
+
}, path: string): WasiStat;
|
|
22
|
+
createDirectoryAt(path: string): void;
|
|
23
|
+
readDirectory(): {
|
|
24
|
+
readDirectoryEntry(): {
|
|
25
|
+
type: string;
|
|
26
|
+
name: string;
|
|
27
|
+
} | null;
|
|
28
|
+
};
|
|
29
|
+
removeDirectoryAt(path: string): void;
|
|
30
|
+
renameAt(oldPath: string, newDescriptor: WasiDescriptor, newPath: string): void;
|
|
31
|
+
unlinkFileAt(path: string): void;
|
|
32
|
+
};
|
|
33
|
+
type WasiStat = {
|
|
34
|
+
type: string;
|
|
35
|
+
size: number | bigint;
|
|
36
|
+
dataModificationTimestamp?: {
|
|
37
|
+
seconds: number | bigint;
|
|
38
|
+
nanoseconds: number;
|
|
39
|
+
} | null;
|
|
40
|
+
};
|
|
41
|
+
export type Preopen = [WasiDescriptor, string];
|
|
42
|
+
export type StorageStat = {
|
|
43
|
+
directory: boolean;
|
|
44
|
+
size: number;
|
|
45
|
+
mtimeMs: number;
|
|
46
|
+
};
|
|
47
|
+
export type StorageEntry = {
|
|
48
|
+
name: string;
|
|
49
|
+
directory: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type StorageError = Error & {
|
|
52
|
+
code: string;
|
|
53
|
+
errno: number;
|
|
54
|
+
syscall: string;
|
|
55
|
+
path: string;
|
|
56
|
+
};
|
|
57
|
+
/** Map a thrown wasi:filesystem error-code to a Node.js-shaped error. */
|
|
58
|
+
export declare function storageError(error: unknown, syscall: string, path: string): StorageError;
|
|
59
|
+
/** Storage mounts the deploy manifest can request: `/data`, or `DI_STORAGE_DIR` when set. */
|
|
60
|
+
declare function defaultPrefixes(): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Paths under a host-mounted directory (the platform's `/data` preopen) live in
|
|
63
|
+
* wasi:filesystem so every workload member sees them. Only absolute, non-root preopens
|
|
64
|
+
* qualify; every other path stays in the guest's in-memory filesystem. Preopens are
|
|
65
|
+
* read on the first storage path, never at module initialization: only paths under a
|
|
66
|
+
* storage prefix consult them.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createStorage(preopens: () => Preopen[], prefixes?: typeof defaultPrefixes): {
|
|
69
|
+
owns(path: string): boolean;
|
|
70
|
+
readFile(path: string): Uint8Array;
|
|
71
|
+
writeFile(path: string, bytes: Uint8Array): void;
|
|
72
|
+
appendFile(path: string, bytes: Uint8Array): void;
|
|
73
|
+
readAt(path: string, length: number, offset: number): Uint8Array;
|
|
74
|
+
writeAt(path: string, bytes: Uint8Array, offset: number | "end"): number;
|
|
75
|
+
truncate(path: string): void;
|
|
76
|
+
stat: (path: string) => StorageStat;
|
|
77
|
+
exists: (path: string) => boolean;
|
|
78
|
+
readdir: (path: string) => StorageEntry[];
|
|
79
|
+
mkdir: (path: string, recursive: boolean) => void;
|
|
80
|
+
remove: (path: string, recursive: boolean) => void;
|
|
81
|
+
unlink(path: string): void;
|
|
82
|
+
rename(from: string, to: string): void;
|
|
83
|
+
};
|
|
84
|
+
export type Storage = ReturnType<typeof createStorage>;
|
|
85
|
+
/** The guest's storage, backed by the host's preopened directories. */
|
|
86
|
+
export declare const storage: Storage;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { getDirectories } from 'wasi:filesystem/preopens@0.2.12';
|
|
2
|
+
/** Node.js errno for each wasi:filesystem error-code the shim reports. */
|
|
3
|
+
const ERRNO = {
|
|
4
|
+
'no-entry': ['ENOENT', -2],
|
|
5
|
+
exist: ['EEXIST', -17],
|
|
6
|
+
'not-directory': ['ENOTDIR', -20],
|
|
7
|
+
'is-directory': ['EISDIR', -21],
|
|
8
|
+
'not-empty': ['ENOTEMPTY', -39],
|
|
9
|
+
access: ['EACCES', -13],
|
|
10
|
+
'not-permitted': ['EPERM', -1],
|
|
11
|
+
'read-only': ['EROFS', -30],
|
|
12
|
+
'insufficient-space': ['ENOSPC', -28],
|
|
13
|
+
invalid: ['EINVAL', -22],
|
|
14
|
+
'cross-device': ['EXDEV', -18],
|
|
15
|
+
};
|
|
16
|
+
/** Default guest storage mount; see DEFAULT_STORAGE_MOUNT in the deploy manifest. */
|
|
17
|
+
const DEFAULT_MOUNT = '/data';
|
|
18
|
+
const READ_CHUNK = 64 * 1024;
|
|
19
|
+
/** Map a thrown wasi:filesystem error-code to a Node.js-shaped error. */
|
|
20
|
+
export function storageError(error, syscall, path) {
|
|
21
|
+
const payload = typeof error === 'object' && error !== null && 'payload' in error
|
|
22
|
+
? error.payload
|
|
23
|
+
: error;
|
|
24
|
+
const wasiCode = typeof payload === 'string' ? payload : 'io';
|
|
25
|
+
const [code, errno] = ERRNO[wasiCode] ?? ['EIO', -5];
|
|
26
|
+
const result = new Error(`${code}: ${wasiCode}, ${syscall} '${path}'`);
|
|
27
|
+
result.code = code;
|
|
28
|
+
result.errno = errno;
|
|
29
|
+
result.syscall = syscall;
|
|
30
|
+
result.path = path;
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function release(descriptor) {
|
|
34
|
+
const dispose = descriptor[Symbol.dispose];
|
|
35
|
+
if (typeof dispose === 'function')
|
|
36
|
+
dispose.call(descriptor);
|
|
37
|
+
}
|
|
38
|
+
function toNumber(value) {
|
|
39
|
+
return typeof value === 'bigint' ? Number(value) : value;
|
|
40
|
+
}
|
|
41
|
+
function under(path, prefix) {
|
|
42
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
43
|
+
}
|
|
44
|
+
/** Storage mounts the deploy manifest can request: `/data`, or `DI_STORAGE_DIR` when set. */
|
|
45
|
+
function defaultPrefixes() {
|
|
46
|
+
const env = globalThis.process
|
|
47
|
+
?.env;
|
|
48
|
+
const configured = env?.DI_STORAGE_DIR?.replace(/\/+$/, '');
|
|
49
|
+
return configured?.startsWith('/') ? [DEFAULT_MOUNT, configured] : [DEFAULT_MOUNT];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Paths under a host-mounted directory (the platform's `/data` preopen) live in
|
|
53
|
+
* wasi:filesystem so every workload member sees them. Only absolute, non-root preopens
|
|
54
|
+
* qualify; every other path stays in the guest's in-memory filesystem. Preopens are
|
|
55
|
+
* read on the first storage path, never at module initialization: only paths under a
|
|
56
|
+
* storage prefix consult them.
|
|
57
|
+
*/
|
|
58
|
+
export function createStorage(preopens, prefixes = defaultPrefixes) {
|
|
59
|
+
let mounts;
|
|
60
|
+
function list() {
|
|
61
|
+
if (mounts === undefined) {
|
|
62
|
+
mounts = preopens()
|
|
63
|
+
.map(([root, path]) => ({ root, path: path.replace(/\/+$/, '') }))
|
|
64
|
+
.filter((mount) => mount.path.startsWith('/') && mount.path !== '')
|
|
65
|
+
.sort((left, right) => right.path.length - left.path.length);
|
|
66
|
+
}
|
|
67
|
+
return mounts;
|
|
68
|
+
}
|
|
69
|
+
/** The mount holding an absolute, normalized guest path, and the path inside it. */
|
|
70
|
+
function locate(path) {
|
|
71
|
+
for (const mount of list()) {
|
|
72
|
+
if (path === mount.path)
|
|
73
|
+
return { root: mount.root, relative: '.' };
|
|
74
|
+
if (under(path, mount.path)) {
|
|
75
|
+
return { root: mount.root, relative: path.slice(mount.path.length + 1) };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
function at(path, syscall, run) {
|
|
81
|
+
const location = locate(path);
|
|
82
|
+
if (location === undefined)
|
|
83
|
+
throw storageError('no-entry', syscall, path);
|
|
84
|
+
try {
|
|
85
|
+
return run(location.root, location.relative);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw storageError(error, syscall, path);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function withFile(path, syscall, open, access, run) {
|
|
92
|
+
return at(path, syscall, (root, relative) => {
|
|
93
|
+
const file = root.openAt({ symlinkFollow: true }, relative, open, access);
|
|
94
|
+
try {
|
|
95
|
+
return run(file);
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
release(file);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function readAll(file) {
|
|
103
|
+
const chunks = [];
|
|
104
|
+
let offset = 0;
|
|
105
|
+
for (;;) {
|
|
106
|
+
const [data, end] = file.read(READ_CHUNK, offset);
|
|
107
|
+
const chunk = data instanceof Uint8Array ? data : Uint8Array.from(data);
|
|
108
|
+
chunks.push(chunk);
|
|
109
|
+
offset += chunk.byteLength;
|
|
110
|
+
if (end || chunk.byteLength === 0)
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
const result = new Uint8Array(offset);
|
|
114
|
+
let position = 0;
|
|
115
|
+
for (const chunk of chunks) {
|
|
116
|
+
result.set(chunk, position);
|
|
117
|
+
position += chunk.byteLength;
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
function writeAll(file, bytes, offset) {
|
|
122
|
+
let written = 0;
|
|
123
|
+
while (written < bytes.byteLength) {
|
|
124
|
+
const count = toNumber(file.write(bytes.subarray(written), offset + written));
|
|
125
|
+
if (count <= 0)
|
|
126
|
+
throw 'io';
|
|
127
|
+
written += count;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function stat(path) {
|
|
131
|
+
return at(path, 'stat', (root, relative) => {
|
|
132
|
+
const result = relative === '.' ? root.stat() : root.statAt({ symlinkFollow: true }, relative);
|
|
133
|
+
const time = result.dataModificationTimestamp;
|
|
134
|
+
return {
|
|
135
|
+
directory: result.type === 'directory',
|
|
136
|
+
size: toNumber(result.size),
|
|
137
|
+
mtimeMs: time ? toNumber(time.seconds) * 1000 + Math.floor(time.nanoseconds / 1e6) : 0,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function readdir(path) {
|
|
142
|
+
return withFile(path, 'scandir', {}, { read: true }, (directory) => {
|
|
143
|
+
const entries = [];
|
|
144
|
+
const stream = directory.readDirectory();
|
|
145
|
+
for (let entry = stream.readDirectoryEntry(); entry; entry = stream.readDirectoryEntry()) {
|
|
146
|
+
entries.push({ name: entry.name, directory: entry.type === 'directory' });
|
|
147
|
+
}
|
|
148
|
+
return entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function exists(path) {
|
|
152
|
+
try {
|
|
153
|
+
stat(path);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function mkdir(path, recursive) {
|
|
161
|
+
if (!recursive) {
|
|
162
|
+
at(path, 'mkdir', (root, relative) => root.createDirectoryAt(relative));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const location = locate(path);
|
|
166
|
+
if (location === undefined)
|
|
167
|
+
throw storageError('no-entry', 'mkdir', path);
|
|
168
|
+
if (location.relative === '.')
|
|
169
|
+
return;
|
|
170
|
+
let current = '';
|
|
171
|
+
for (const part of location.relative.split('/')) {
|
|
172
|
+
current = current ? `${current}/${part}` : part;
|
|
173
|
+
try {
|
|
174
|
+
location.root.createDirectoryAt(current);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
const failure = storageError(error, 'mkdir', path);
|
|
178
|
+
if (failure.code !== 'EEXIST')
|
|
179
|
+
throw failure;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function remove(path, recursive) {
|
|
184
|
+
if (stat(path).directory) {
|
|
185
|
+
if (recursive) {
|
|
186
|
+
for (const entry of readdir(path))
|
|
187
|
+
remove(`${path}/${entry.name}`, true);
|
|
188
|
+
}
|
|
189
|
+
at(path, 'rmdir', (root, relative) => root.removeDirectoryAt(relative));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
at(path, 'unlink', (root, relative) => root.unlinkFileAt(relative));
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
owns(path) {
|
|
196
|
+
if (!prefixes().some((prefix) => under(path, prefix)))
|
|
197
|
+
return false;
|
|
198
|
+
return locate(path) !== undefined;
|
|
199
|
+
},
|
|
200
|
+
readFile(path) {
|
|
201
|
+
return withFile(path, 'open', {}, { read: true }, readAll);
|
|
202
|
+
},
|
|
203
|
+
writeFile(path, bytes) {
|
|
204
|
+
withFile(path, 'open', { create: true, truncate: true }, { write: true }, (file) => writeAll(file, bytes, 0));
|
|
205
|
+
},
|
|
206
|
+
appendFile(path, bytes) {
|
|
207
|
+
withFile(path, 'open', { create: true }, { write: true }, (file) => writeAll(file, bytes, toNumber(file.stat().size)));
|
|
208
|
+
},
|
|
209
|
+
readAt(path, length, offset) {
|
|
210
|
+
return withFile(path, 'read', {}, { read: true }, (file) => {
|
|
211
|
+
const [data] = file.read(length, offset);
|
|
212
|
+
return data instanceof Uint8Array ? data : Uint8Array.from(data);
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
writeAt(path, bytes, offset) {
|
|
216
|
+
return withFile(path, 'write', { create: true }, { write: true }, (file) => {
|
|
217
|
+
const start = offset === 'end' ? toNumber(file.stat().size) : offset;
|
|
218
|
+
writeAll(file, bytes, start);
|
|
219
|
+
return start + bytes.byteLength;
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
truncate(path) {
|
|
223
|
+
withFile(path, 'open', { create: true, truncate: true }, { write: true }, () => undefined);
|
|
224
|
+
},
|
|
225
|
+
stat,
|
|
226
|
+
exists,
|
|
227
|
+
readdir,
|
|
228
|
+
mkdir,
|
|
229
|
+
remove,
|
|
230
|
+
unlink(path) {
|
|
231
|
+
at(path, 'unlink', (root, relative) => root.unlinkFileAt(relative));
|
|
232
|
+
},
|
|
233
|
+
rename(from, to) {
|
|
234
|
+
const target = locate(to);
|
|
235
|
+
at(from, 'rename', (root, relative) => {
|
|
236
|
+
if (target === undefined || target.root !== root)
|
|
237
|
+
throw 'cross-device';
|
|
238
|
+
root.renameAt(relative, target.root, target.relative);
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/** The guest's storage, backed by the host's preopened directories. */
|
|
244
|
+
export const storage = createStorage(() => getDirectories());
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EventEmitter } from './events.js';
|
|
2
|
+
export * from 'unenv/node/stream';
|
|
3
|
+
type Emitter = InstanceType<typeof EventEmitter>;
|
|
4
|
+
export declare function Stream(this: Emitter, options?: {
|
|
5
|
+
captureRejections?: boolean;
|
|
6
|
+
}): void;
|
|
7
|
+
declare const stream: typeof Stream & typeof import("node:stream") & {
|
|
8
|
+
isDisturbed: any;
|
|
9
|
+
isReadable: any;
|
|
10
|
+
compose: any;
|
|
11
|
+
isErrored: any;
|
|
12
|
+
destroy: any;
|
|
13
|
+
_isUint8Array: any;
|
|
14
|
+
_uint8ArrayToBuffer: any;
|
|
15
|
+
_isArrayBufferView: any;
|
|
16
|
+
duplexPair: any;
|
|
17
|
+
getDefaultHighWaterMark: any;
|
|
18
|
+
isDestroyed: any;
|
|
19
|
+
isWritable: any;
|
|
20
|
+
setDefaultHighWaterMark: any;
|
|
21
|
+
} & {
|
|
22
|
+
Stream: typeof Stream;
|
|
23
|
+
};
|
|
24
|
+
export default stream;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// unenv's `Stream` throws on construction, so packages that subclass Node's legacy
|
|
2
|
+
// stream (`Stream.call(this)` plus `util.inherits(Foo, Stream)`) fail. This is Node's
|
|
3
|
+
// legacy Stream: a callable EventEmitter with the classic `pipe`.
|
|
4
|
+
import unenvStream from 'unenv/node/stream';
|
|
5
|
+
import { EventEmitter } from './events.js';
|
|
6
|
+
export * from 'unenv/node/stream';
|
|
7
|
+
export function Stream(options) {
|
|
8
|
+
EventEmitter.call(this, options);
|
|
9
|
+
}
|
|
10
|
+
Object.setPrototypeOf(Stream.prototype, EventEmitter.prototype);
|
|
11
|
+
Object.setPrototypeOf(Stream, EventEmitter);
|
|
12
|
+
Stream.prototype.pipe = function pipe(dest, options) {
|
|
13
|
+
const source = this;
|
|
14
|
+
function ondata(chunk) {
|
|
15
|
+
if (dest.writable && dest.write(chunk) === false && source.pause)
|
|
16
|
+
source.pause();
|
|
17
|
+
}
|
|
18
|
+
source.on('data', ondata);
|
|
19
|
+
function ondrain() {
|
|
20
|
+
if (source.readable && source.resume)
|
|
21
|
+
source.resume();
|
|
22
|
+
}
|
|
23
|
+
dest.on('drain', ondrain);
|
|
24
|
+
// Without `end: false`, end dest once when source ends or closes.
|
|
25
|
+
if (!dest._isStdio && options?.end !== false) {
|
|
26
|
+
source.on('end', onend);
|
|
27
|
+
source.on('close', onclose);
|
|
28
|
+
}
|
|
29
|
+
let didOnEnd = false;
|
|
30
|
+
function onend() {
|
|
31
|
+
if (didOnEnd)
|
|
32
|
+
return;
|
|
33
|
+
didOnEnd = true;
|
|
34
|
+
dest.end();
|
|
35
|
+
}
|
|
36
|
+
function onclose() {
|
|
37
|
+
if (didOnEnd)
|
|
38
|
+
return;
|
|
39
|
+
didOnEnd = true;
|
|
40
|
+
if (typeof dest.destroy === 'function')
|
|
41
|
+
dest.destroy();
|
|
42
|
+
}
|
|
43
|
+
// Don't leave dangling pipes when there are errors.
|
|
44
|
+
function onerror(error) {
|
|
45
|
+
cleanup();
|
|
46
|
+
if (this.listenerCount('error') === 0)
|
|
47
|
+
this.emit('error', error);
|
|
48
|
+
}
|
|
49
|
+
source.prependListener('error', onerror);
|
|
50
|
+
dest.prependListener('error', onerror);
|
|
51
|
+
function cleanup() {
|
|
52
|
+
source.removeListener('data', ondata);
|
|
53
|
+
dest.removeListener('drain', ondrain);
|
|
54
|
+
source.removeListener('end', onend);
|
|
55
|
+
source.removeListener('close', onclose);
|
|
56
|
+
source.removeListener('error', onerror);
|
|
57
|
+
dest.removeListener('error', onerror);
|
|
58
|
+
source.removeListener('end', cleanup);
|
|
59
|
+
source.removeListener('close', cleanup);
|
|
60
|
+
dest.removeListener('close', cleanup);
|
|
61
|
+
}
|
|
62
|
+
source.on('end', cleanup);
|
|
63
|
+
source.on('close', cleanup);
|
|
64
|
+
dest.on('close', cleanup);
|
|
65
|
+
dest.emit('pipe', source);
|
|
66
|
+
return dest;
|
|
67
|
+
};
|
|
68
|
+
// `require('stream')` in Node is the Stream function carrying the other exports.
|
|
69
|
+
const stream = Object.assign(Stream, unenvStream, { Stream });
|
|
70
|
+
export default stream;
|
package/dist/platform.js
CHANGED
|
@@ -8,6 +8,7 @@ import { isNamespace } from './namespace.js';
|
|
|
8
8
|
import { resolveInsideRoot } from './paths.js';
|
|
9
9
|
import { pulumiEnvironment, runPulumi } from './pulumi.js';
|
|
10
10
|
import { materializeRegistry } from './registry.js';
|
|
11
|
+
import { resolveTarget } from './target.js';
|
|
11
12
|
export const PLATFORM_OUTPUT_SCHEMA_VERSION = 2;
|
|
12
13
|
export async function runWasmcloudPlatformDeploy(args, io, deps = DEFAULT_DEPS) {
|
|
13
14
|
const options = parsePlatformCommandArgs(args, 'platform cluster up');
|
|
@@ -75,10 +76,7 @@ export function resolvePlatformDirectory(target, workspaceRoot, manifestPath) {
|
|
|
75
76
|
}
|
|
76
77
|
function loadManagedPlatform(deps, targetName) {
|
|
77
78
|
const manifest = loadDeployManifest(deps.cwd(), deps.env);
|
|
78
|
-
const target = manifest
|
|
79
|
-
if (target === undefined) {
|
|
80
|
-
throw new CommandFailure('WASMCLOUD_TARGET_NOT_FOUND', `Unknown target "${targetName}". Known targets: ${Object.keys(manifest.targets).join(', ')}`, 2, { target: targetName, targets: Object.keys(manifest.targets), manifestPath: manifest.path });
|
|
81
|
-
}
|
|
79
|
+
const target = resolveTarget(manifest, targetName);
|
|
82
80
|
if (target.kind !== 'managed') {
|
|
83
81
|
throw new CommandFailure('WASMCLOUD_TARGET_INVALID', `Target "${target.name}" is kubeconfig-only and has no managed platform to deploy or destroy.`, 2, { target: target.name });
|
|
84
82
|
}
|
package/dist/project.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export type WasmcloudProject = {
|
|
|
31
31
|
* dedicated hostPath volume (SQLite / migration history).
|
|
32
32
|
*/
|
|
33
33
|
persistentStorage?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* False when `"logs": false` opts out of guest logs: no wasi:logging console and a
|
|
36
|
+
* `di-framework.dev/logs: "false"` WorkloadDeployment annotation. Absent means on.
|
|
37
|
+
*/
|
|
38
|
+
logs?: false;
|
|
34
39
|
};
|
|
35
40
|
export declare function findUp(startDirectory: string, fileName: string): string | undefined;
|
|
36
41
|
/** Paths from the config must stay inside the project root. */
|
package/dist/project.js
CHANGED
|
@@ -75,6 +75,9 @@ export function loadProject(startDirectory) {
|
|
|
75
75
|
/^(?:\*\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i.test(name))))) {
|
|
76
76
|
configInvalid('allowedIpNameLookups must be an array of DNS names, IP addresses, or wildcard suffixes', configPath);
|
|
77
77
|
}
|
|
78
|
+
if (config.logs !== undefined && typeof config.logs !== 'boolean') {
|
|
79
|
+
configInvalid(`${CONFIG_FILE_NAME} "logs" must be a boolean when present`, configPath);
|
|
80
|
+
}
|
|
78
81
|
const witName = asWitIdentifier(config.name);
|
|
79
82
|
const entryPath = resolveInside(projectRoot, config.entry, 'entry', configPath);
|
|
80
83
|
const outputPath = resolveInside(projectRoot, config.output ?? `dist/${witName}.wasm`, 'output', configPath);
|
|
@@ -114,6 +117,7 @@ export function loadProject(startDirectory) {
|
|
|
114
117
|
ingress,
|
|
115
118
|
...(cronMode ? { cronMode } : {}),
|
|
116
119
|
...(persistentStorage ? { persistentStorage: true } : {}),
|
|
120
|
+
...(config.logs === false ? { logs: false } : {}),
|
|
117
121
|
...(config.allowedIpNameLookups === undefined
|
|
118
122
|
? {}
|
|
119
123
|
: { allowedIpNameLookups: config.allowedIpNameLookups }),
|
package/dist/service.d.ts
CHANGED
|
@@ -4,12 +4,21 @@ export declare const BACKING_SERVICE_API_VERSION = "platform.di-framework.dev/v1
|
|
|
4
4
|
export declare const BACKING_SERVICE_KIND = "BackingService";
|
|
5
5
|
export declare const BACKING_SERVICE_RESOURCE = "backingservices.platform.di-framework.dev";
|
|
6
6
|
export declare const BACKING_SERVICE_CLASS_RESOURCE = "backingserviceclasses.platform.di-framework.dev";
|
|
7
|
-
export declare const SERVICE_TYPES: readonly ["keyvalue", "messaging", "postgres"];
|
|
7
|
+
export declare const SERVICE_TYPES: readonly ["keyvalue", "messaging", "blobstore", "postgres", "egress"];
|
|
8
8
|
export type ServiceType = (typeof SERVICE_TYPES)[number];
|
|
9
9
|
export declare const DEFAULT_SERVICE_CLASSES: {
|
|
10
10
|
readonly keyvalue: "keyvalue-redis";
|
|
11
11
|
readonly messaging: "messaging-nats";
|
|
12
|
+
readonly blobstore: "blobstore-nats";
|
|
12
13
|
readonly postgres: "postgres-dedicated";
|
|
14
|
+
readonly egress: "egress-public";
|
|
15
|
+
};
|
|
16
|
+
export declare const DEFAULT_SERVICE_PROVIDERS: {
|
|
17
|
+
readonly keyvalue: "redis";
|
|
18
|
+
readonly messaging: "nats";
|
|
19
|
+
readonly blobstore: "nats";
|
|
20
|
+
readonly postgres: "postgres";
|
|
21
|
+
readonly egress: "platform";
|
|
13
22
|
};
|
|
14
23
|
export declare const DEFAULT_WAIT_TIMEOUT_MS = 120000;
|
|
15
24
|
export declare const WAIT_POLL_INTERVAL_MS = 2000;
|
|
@@ -26,6 +35,8 @@ export type ServiceCreateOptions = {
|
|
|
26
35
|
className?: string;
|
|
27
36
|
parameters?: ServiceSizingParameters;
|
|
28
37
|
deletionPolicy?: DeletionPolicy;
|
|
38
|
+
/** Egress only: hosts the workload may reach. */
|
|
39
|
+
destinations?: string[];
|
|
29
40
|
target?: string;
|
|
30
41
|
namespace?: string;
|
|
31
42
|
context?: string;
|
|
@@ -60,9 +71,11 @@ type BackingServiceDocument = {
|
|
|
60
71
|
className?: string;
|
|
61
72
|
parameters?: ServiceSizingParameters;
|
|
62
73
|
deletionPolicy?: string;
|
|
74
|
+
destinations?: string[];
|
|
63
75
|
};
|
|
64
76
|
status?: {
|
|
65
77
|
conditions?: ReadyCondition[];
|
|
78
|
+
approved?: string[];
|
|
66
79
|
endpoint?: {
|
|
67
80
|
host?: string;
|
|
68
81
|
port?: number;
|
|
@@ -88,8 +101,12 @@ export type ServiceSummary = {
|
|
|
88
101
|
capability: string;
|
|
89
102
|
};
|
|
90
103
|
deletionPolicy?: string;
|
|
104
|
+
destinations?: string[];
|
|
105
|
+
approved?: string[];
|
|
91
106
|
};
|
|
92
107
|
export declare function isServiceType(value: string): value is ServiceType;
|
|
108
|
+
/** An egress destination: `host`, `*.suffix`, `host:port`, or `*.suffix:port`. */
|
|
109
|
+
export declare function isEgressDestination(value: string): boolean;
|
|
93
110
|
/** DNS-label rules aligned with the BackingService CRD metadata.name schema (max 40). */
|
|
94
111
|
export declare function isBackingServiceName(value: string, max?: number): boolean;
|
|
95
112
|
export declare function serviceTypeDiscoveryText(): string;
|
|
@@ -99,6 +116,7 @@ export declare function buildBackingServiceManifest(options: {
|
|
|
99
116
|
className?: string;
|
|
100
117
|
parameters?: ServiceSizingParameters;
|
|
101
118
|
deletionPolicy?: DeletionPolicy;
|
|
119
|
+
destinations?: readonly string[];
|
|
102
120
|
}): Record<string, unknown>;
|
|
103
121
|
export declare function parseServiceCreateArgs(args: readonly string[]): ServiceCreateOptions;
|
|
104
122
|
export declare function parseServiceNameArgs(args: readonly string[], command: string): ServiceNameOptions;
|
|
@@ -117,11 +135,12 @@ export declare function runWasmcloudServiceCreate(args: readonly string[], io: C
|
|
|
117
135
|
} | undefined;
|
|
118
136
|
wait: boolean;
|
|
119
137
|
ready: string;
|
|
138
|
+
destinations?: string[] | undefined;
|
|
120
139
|
deletionPolicy?: "Retain" | "Delete" | undefined;
|
|
121
140
|
parameters?: ServiceSizingParameters | undefined;
|
|
122
141
|
context?: string | undefined;
|
|
123
142
|
name: string;
|
|
124
|
-
type: "messaging" | "
|
|
143
|
+
type: "postgres" | "keyvalue" | "messaging" | "blobstore" | "egress";
|
|
125
144
|
className: string;
|
|
126
145
|
namespace: string;
|
|
127
146
|
target: string;
|