@di-framework/cli-plugin-platform 6.0.2 → 6.0.5
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 +63 -0
- 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 +31 -0
- package/dist/node-compat/fetch-runtime.js +62 -0
- 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,196 @@
|
|
|
1
|
+
package wasi:filesystem@0.2.12;
|
|
2
|
+
interface preopens {
|
|
3
|
+
use types.{descriptor};
|
|
4
|
+
get-directories: func() -> list<tuple<descriptor, string>>;
|
|
5
|
+
}
|
|
6
|
+
interface types {
|
|
7
|
+
use wasi:io/streams@0.2.12.{input-stream, output-stream, error};
|
|
8
|
+
use wasi:clocks/wall-clock@0.2.12.{datetime};
|
|
9
|
+
type filesize = u64;
|
|
10
|
+
enum descriptor-type {
|
|
11
|
+
unknown,
|
|
12
|
+
block-device,
|
|
13
|
+
character-device,
|
|
14
|
+
directory,
|
|
15
|
+
fifo,
|
|
16
|
+
symbolic-link,
|
|
17
|
+
regular-file,
|
|
18
|
+
socket,
|
|
19
|
+
}
|
|
20
|
+
flags descriptor-flags {
|
|
21
|
+
read,
|
|
22
|
+
write,
|
|
23
|
+
file-integrity-sync,
|
|
24
|
+
data-integrity-sync,
|
|
25
|
+
requested-write-sync,
|
|
26
|
+
mutate-directory,
|
|
27
|
+
}
|
|
28
|
+
record descriptor-stat {
|
|
29
|
+
%type: descriptor-type,
|
|
30
|
+
link-count: link-count,
|
|
31
|
+
size: filesize,
|
|
32
|
+
data-access-timestamp: option<datetime>,
|
|
33
|
+
data-modification-timestamp: option<datetime>,
|
|
34
|
+
status-change-timestamp: option<datetime>,
|
|
35
|
+
}
|
|
36
|
+
flags path-flags {
|
|
37
|
+
symlink-follow,
|
|
38
|
+
}
|
|
39
|
+
flags open-flags {
|
|
40
|
+
create,
|
|
41
|
+
directory,
|
|
42
|
+
exclusive,
|
|
43
|
+
truncate,
|
|
44
|
+
}
|
|
45
|
+
type link-count = u64;
|
|
46
|
+
variant new-timestamp {
|
|
47
|
+
no-change,
|
|
48
|
+
now,
|
|
49
|
+
timestamp(datetime),
|
|
50
|
+
}
|
|
51
|
+
record directory-entry {
|
|
52
|
+
%type: descriptor-type,
|
|
53
|
+
name: string,
|
|
54
|
+
}
|
|
55
|
+
enum error-code {
|
|
56
|
+
access,
|
|
57
|
+
would-block,
|
|
58
|
+
already,
|
|
59
|
+
bad-descriptor,
|
|
60
|
+
busy,
|
|
61
|
+
deadlock,
|
|
62
|
+
quota,
|
|
63
|
+
exist,
|
|
64
|
+
file-too-large,
|
|
65
|
+
illegal-byte-sequence,
|
|
66
|
+
in-progress,
|
|
67
|
+
interrupted,
|
|
68
|
+
invalid,
|
|
69
|
+
io,
|
|
70
|
+
is-directory,
|
|
71
|
+
loop,
|
|
72
|
+
too-many-links,
|
|
73
|
+
message-size,
|
|
74
|
+
name-too-long,
|
|
75
|
+
no-device,
|
|
76
|
+
no-entry,
|
|
77
|
+
no-lock,
|
|
78
|
+
insufficient-memory,
|
|
79
|
+
insufficient-space,
|
|
80
|
+
not-directory,
|
|
81
|
+
not-empty,
|
|
82
|
+
not-recoverable,
|
|
83
|
+
unsupported,
|
|
84
|
+
no-tty,
|
|
85
|
+
no-such-device,
|
|
86
|
+
overflow,
|
|
87
|
+
not-permitted,
|
|
88
|
+
pipe,
|
|
89
|
+
read-only,
|
|
90
|
+
invalid-seek,
|
|
91
|
+
text-file-busy,
|
|
92
|
+
cross-device,
|
|
93
|
+
}
|
|
94
|
+
enum advice {
|
|
95
|
+
normal,
|
|
96
|
+
sequential,
|
|
97
|
+
random,
|
|
98
|
+
will-need,
|
|
99
|
+
dont-need,
|
|
100
|
+
no-reuse,
|
|
101
|
+
}
|
|
102
|
+
record metadata-hash-value {
|
|
103
|
+
lower: u64,
|
|
104
|
+
upper: u64,
|
|
105
|
+
}
|
|
106
|
+
resource descriptor {
|
|
107
|
+
read-via-stream: func(
|
|
108
|
+
offset: filesize,
|
|
109
|
+
) -> result<input-stream, error-code>;
|
|
110
|
+
write-via-stream: func(
|
|
111
|
+
offset: filesize,
|
|
112
|
+
) -> result<output-stream, error-code>;
|
|
113
|
+
append-via-stream: func() -> result<output-stream, error-code>;
|
|
114
|
+
advise: func(
|
|
115
|
+
offset: filesize,
|
|
116
|
+
length: filesize,
|
|
117
|
+
advice: advice
|
|
118
|
+
) -> result<_, error-code>;
|
|
119
|
+
sync-data: func() -> result<_, error-code>;
|
|
120
|
+
get-flags: func() -> result<descriptor-flags, error-code>;
|
|
121
|
+
get-type: func() -> result<descriptor-type, error-code>;
|
|
122
|
+
set-size: func(size: filesize) -> result<_, error-code>;
|
|
123
|
+
set-times: func(
|
|
124
|
+
data-access-timestamp: new-timestamp,
|
|
125
|
+
data-modification-timestamp: new-timestamp,
|
|
126
|
+
) -> result<_, error-code>;
|
|
127
|
+
read: func(
|
|
128
|
+
length: filesize,
|
|
129
|
+
offset: filesize,
|
|
130
|
+
) -> result<tuple<list<u8>, bool>, error-code>;
|
|
131
|
+
write: func(
|
|
132
|
+
buffer: list<u8>,
|
|
133
|
+
offset: filesize,
|
|
134
|
+
) -> result<filesize, error-code>;
|
|
135
|
+
read-directory: func() -> result<directory-entry-stream, error-code>;
|
|
136
|
+
sync: func() -> result<_, error-code>;
|
|
137
|
+
create-directory-at: func(
|
|
138
|
+
path: string,
|
|
139
|
+
) -> result<_, error-code>;
|
|
140
|
+
stat: func() -> result<descriptor-stat, error-code>;
|
|
141
|
+
stat-at: func(
|
|
142
|
+
path-flags: path-flags,
|
|
143
|
+
path: string,
|
|
144
|
+
) -> result<descriptor-stat, error-code>;
|
|
145
|
+
set-times-at: func(
|
|
146
|
+
path-flags: path-flags,
|
|
147
|
+
path: string,
|
|
148
|
+
data-access-timestamp: new-timestamp,
|
|
149
|
+
data-modification-timestamp: new-timestamp,
|
|
150
|
+
) -> result<_, error-code>;
|
|
151
|
+
link-at: func(
|
|
152
|
+
old-path-flags: path-flags,
|
|
153
|
+
old-path: string,
|
|
154
|
+
new-descriptor: borrow<descriptor>,
|
|
155
|
+
new-path: string,
|
|
156
|
+
) -> result<_, error-code>;
|
|
157
|
+
open-at: func(
|
|
158
|
+
path-flags: path-flags,
|
|
159
|
+
path: string,
|
|
160
|
+
open-flags: open-flags,
|
|
161
|
+
%flags: descriptor-flags,
|
|
162
|
+
) -> result<descriptor, error-code>;
|
|
163
|
+
readlink-at: func(
|
|
164
|
+
path: string,
|
|
165
|
+
) -> result<string, error-code>;
|
|
166
|
+
remove-directory-at: func(
|
|
167
|
+
path: string,
|
|
168
|
+
) -> result<_, error-code>;
|
|
169
|
+
rename-at: func(
|
|
170
|
+
old-path: string,
|
|
171
|
+
new-descriptor: borrow<descriptor>,
|
|
172
|
+
new-path: string,
|
|
173
|
+
) -> result<_, error-code>;
|
|
174
|
+
symlink-at: func(
|
|
175
|
+
old-path: string,
|
|
176
|
+
new-path: string,
|
|
177
|
+
) -> result<_, error-code>;
|
|
178
|
+
unlink-file-at: func(
|
|
179
|
+
path: string,
|
|
180
|
+
) -> result<_, error-code>;
|
|
181
|
+
is-same-object: func(other: borrow<descriptor>) -> bool;
|
|
182
|
+
metadata-hash: func() -> result<metadata-hash-value, error-code>;
|
|
183
|
+
metadata-hash-at: func(
|
|
184
|
+
path-flags: path-flags,
|
|
185
|
+
path: string,
|
|
186
|
+
) -> result<metadata-hash-value, error-code>;
|
|
187
|
+
}
|
|
188
|
+
resource directory-entry-stream {
|
|
189
|
+
read-directory-entry: func() -> result<option<directory-entry>, error-code>;
|
|
190
|
+
}
|
|
191
|
+
filesystem-error-code: func(err: borrow<error>) -> option<error-code>;
|
|
192
|
+
}
|
|
193
|
+
world imports {
|
|
194
|
+
import types;
|
|
195
|
+
import preopens;
|
|
196
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package wasi:io@0.2.12;
|
|
2
|
+
interface error {
|
|
3
|
+
resource error {
|
|
4
|
+
to-debug-string: func() -> string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
interface poll {
|
|
8
|
+
resource pollable {
|
|
9
|
+
ready: func() -> bool;
|
|
10
|
+
block: func();
|
|
11
|
+
}
|
|
12
|
+
poll: func(in: list<borrow<pollable>>) -> list<u32>;
|
|
13
|
+
}
|
|
14
|
+
interface streams {
|
|
15
|
+
use error.{error};
|
|
16
|
+
use poll.{pollable};
|
|
17
|
+
variant stream-error {
|
|
18
|
+
last-operation-failed(error),
|
|
19
|
+
closed
|
|
20
|
+
}
|
|
21
|
+
resource input-stream {
|
|
22
|
+
read: func(
|
|
23
|
+
len: u64
|
|
24
|
+
) -> result<list<u8>, stream-error>;
|
|
25
|
+
blocking-read: func(
|
|
26
|
+
len: u64
|
|
27
|
+
) -> result<list<u8>, stream-error>;
|
|
28
|
+
skip: func(
|
|
29
|
+
len: u64,
|
|
30
|
+
) -> result<u64, stream-error>;
|
|
31
|
+
blocking-skip: func(
|
|
32
|
+
len: u64,
|
|
33
|
+
) -> result<u64, stream-error>;
|
|
34
|
+
subscribe: func() -> pollable;
|
|
35
|
+
}
|
|
36
|
+
resource output-stream {
|
|
37
|
+
check-write: func() -> result<u64, stream-error>;
|
|
38
|
+
write: func(
|
|
39
|
+
contents: list<u8>
|
|
40
|
+
) -> result<_, stream-error>;
|
|
41
|
+
blocking-write-and-flush: func(
|
|
42
|
+
contents: list<u8>
|
|
43
|
+
) -> result<_, stream-error>;
|
|
44
|
+
flush: func() -> result<_, stream-error>;
|
|
45
|
+
blocking-flush: func() -> result<_, stream-error>;
|
|
46
|
+
subscribe: func() -> pollable;
|
|
47
|
+
write-zeroes: func(
|
|
48
|
+
len: u64
|
|
49
|
+
) -> result<_, stream-error>;
|
|
50
|
+
blocking-write-zeroes-and-flush: func(
|
|
51
|
+
len: u64
|
|
52
|
+
) -> result<_, stream-error>;
|
|
53
|
+
splice: func(
|
|
54
|
+
src: borrow<input-stream>,
|
|
55
|
+
len: u64,
|
|
56
|
+
) -> result<u64, stream-error>;
|
|
57
|
+
blocking-splice: func(
|
|
58
|
+
src: borrow<input-stream>,
|
|
59
|
+
len: u64,
|
|
60
|
+
) -> result<u64, stream-error>;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
world imports {
|
|
64
|
+
import streams;
|
|
65
|
+
import poll;
|
|
66
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package wasi:logging@0.1.0-draft;
|
|
2
|
+
|
|
3
|
+
/// WASI Logging is a logging API intended to let users emit log messages with
|
|
4
|
+
/// simple priority levels and context values.
|
|
5
|
+
interface logging {
|
|
6
|
+
/// A log level, describing a kind of message.
|
|
7
|
+
enum level {
|
|
8
|
+
/// Describes messages about the values of variables and the flow of
|
|
9
|
+
/// control within a program.
|
|
10
|
+
trace,
|
|
11
|
+
/// Describes messages likely to be of interest to someone debugging a
|
|
12
|
+
/// program.
|
|
13
|
+
debug,
|
|
14
|
+
/// Describes messages likely to be of interest to someone monitoring a
|
|
15
|
+
/// program.
|
|
16
|
+
info,
|
|
17
|
+
/// Describes messages indicating hazardous situations.
|
|
18
|
+
warn,
|
|
19
|
+
/// Describes messages indicating serious errors.
|
|
20
|
+
error,
|
|
21
|
+
/// Describes messages indicating fatal errors.
|
|
22
|
+
critical,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// Emit a log message.
|
|
26
|
+
///
|
|
27
|
+
/// A log message has a `level` describing what kind of message is being
|
|
28
|
+
/// sent, a context, which is an uninterpreted string meant to help
|
|
29
|
+
/// consumers group similar messages, and a string containing the message
|
|
30
|
+
/// text.
|
|
31
|
+
log: func(level: level, context: string, message: string);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
world imports {
|
|
35
|
+
import logging;
|
|
36
|
+
}
|
package/dist/build.d.ts
CHANGED
|
@@ -18,7 +18,9 @@ export type BuildSummary = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare function requirementsForProject(project: WasmcloudProject, deps?: WasmcloudDeps): WitRequirement[];
|
|
20
20
|
/** The disposable `.di-framework/` build directory: WIT world, bundle, and manifests. */
|
|
21
|
-
export declare function buildComponent(project: WasmcloudProject, io: CliIo, deps: WasmcloudDeps
|
|
21
|
+
export declare function buildComponent(project: WasmcloudProject, io: CliIo, deps: WasmcloudDeps, options?: {
|
|
22
|
+
guestLogging?: boolean;
|
|
23
|
+
}): Promise<BuildSummary>;
|
|
22
24
|
/**
|
|
23
25
|
* Stable logical version for deployment. ComponentizeJS snapshots can contain
|
|
24
26
|
* nondeterministic engine bytes, so the rollout key is the canonical bundle,
|
package/dist/build.js
CHANGED
|
@@ -151,7 +151,7 @@ async function inspectComponentImports(project, requirements, deps) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
/** The disposable `.di-framework/` build directory: WIT world, bundle, and manifests. */
|
|
154
|
-
export async function buildComponent(project, io, deps) {
|
|
154
|
+
export async function buildComponent(project, io, deps, options = {}) {
|
|
155
155
|
const generatedDirectory = join(project.projectRoot, '.di-framework');
|
|
156
156
|
const generatedWit = join(generatedDirectory, 'wit');
|
|
157
157
|
const bundledJavaScript = join(generatedDirectory, 'component.js');
|
|
@@ -213,7 +213,7 @@ export async function buildComponent(project, io, deps) {
|
|
|
213
213
|
`import { ${entry.exportName} as invoke } from ${JSON.stringify(project.entryPath)};`,
|
|
214
214
|
`export * from ${JSON.stringify(project.entryPath)};`,
|
|
215
215
|
`export default function fetch(request) {`,
|
|
216
|
-
...(entry.path
|
|
216
|
+
...(entry.path && entry.path !== '/'
|
|
217
217
|
? [
|
|
218
218
|
` if (new URL(request.url).pathname !== ${JSON.stringify(entry.path)}) return new Response(null, { status: 404 });`,
|
|
219
219
|
]
|
|
@@ -236,6 +236,8 @@ export async function buildComponent(project, io, deps) {
|
|
|
236
236
|
cronPath: cronJobs.length > 0 ? join(generatedDirectory, 'cron-invoker.js') : undefined,
|
|
237
237
|
queuesPath: queueHandlers.length > 0 ? join(generatedDirectory, 'queues.js') : undefined,
|
|
238
238
|
projectRoot: project.projectRoot,
|
|
239
|
+
// `"logs": false` wins over the caller: the guest keeps the noop console.
|
|
240
|
+
guestLogging: project.logs === false ? false : options.guestLogging,
|
|
239
241
|
});
|
|
240
242
|
}
|
|
241
243
|
catch (error) {
|
package/dist/command.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { runWasmcloudBuild } from './build.js';
|
|
2
|
+
import { runWasmcloudConsole } from './console/run.js';
|
|
2
3
|
import { runWasmcloudDeploy } from './deploy.js';
|
|
3
4
|
import { DEFAULT_DEPS } from './deps.js';
|
|
4
5
|
import { runWasmcloudDestroy } from './destroy.js';
|
|
@@ -56,14 +57,20 @@ export function createWasmcloudCommand(deps = DEFAULT_DEPS) {
|
|
|
56
57
|
},
|
|
57
58
|
up: {
|
|
58
59
|
description: 'Run pulumi up for a managed target in di-framework.deploy.toml (k0s, registry, operator)',
|
|
59
|
-
usage: 'di-framework platform cluster up
|
|
60
|
-
options: [
|
|
60
|
+
usage: 'di-framework platform cluster up [target] [--yes]',
|
|
61
|
+
options: [
|
|
62
|
+
'[target], --target <name> Managed target from di-framework.deploy.toml (default: default-target)',
|
|
63
|
+
'--yes Skip the Pulumi confirmation prompt',
|
|
64
|
+
],
|
|
61
65
|
run: ({ args, io }) => runWasmcloudPlatformDeploy(args, io, deps),
|
|
62
66
|
},
|
|
63
67
|
destroy: {
|
|
64
68
|
description: 'Run pulumi destroy for a managed platform target only',
|
|
65
|
-
usage: 'di-framework platform cluster destroy
|
|
66
|
-
options: [
|
|
69
|
+
usage: 'di-framework platform cluster destroy [target] [--yes]',
|
|
70
|
+
options: [
|
|
71
|
+
'[target], --target <name> Managed target from di-framework.deploy.toml (default: default-target)',
|
|
72
|
+
'--yes Skip the Pulumi confirmation prompt',
|
|
73
|
+
],
|
|
67
74
|
run: ({ args, io }) => runWasmcloudPlatformDestroy(args, io, deps),
|
|
68
75
|
},
|
|
69
76
|
},
|
|
@@ -73,20 +80,31 @@ export function createWasmcloudCommand(deps = DEFAULT_DEPS) {
|
|
|
73
80
|
usage: 'di-framework platform doctor',
|
|
74
81
|
run: ({ args, io }) => runWasmcloudDoctor(args, io, deps),
|
|
75
82
|
},
|
|
83
|
+
console: {
|
|
84
|
+
description: 'Open a local console for the applications on one tenant credential',
|
|
85
|
+
usage: 'di-framework platform console [--target <tenant>] [--host <address>] [--port <port>]',
|
|
86
|
+
options: [
|
|
87
|
+
'--target <tenant> Tenant target (default: default-target). Uses that target’s kubeconfig only',
|
|
88
|
+
'--host <address> Loopback bind address (default: 127.0.0.1)',
|
|
89
|
+
'--port <port> Listen port (default: a free port chosen by the system)',
|
|
90
|
+
],
|
|
91
|
+
run: ({ args, io }) => runWasmcloudConsole(args, io, deps),
|
|
92
|
+
},
|
|
76
93
|
service: {
|
|
77
|
-
description: 'Create and manage BackingService custom resources (keyvalue/messaging/postgres) via the cluster API',
|
|
94
|
+
description: 'Create and manage BackingService custom resources (keyvalue/messaging/blobstore/postgres/egress) via the cluster API',
|
|
78
95
|
children: {
|
|
79
96
|
create: {
|
|
80
97
|
description: 'Create a BackingService custom resource for an approved capability type',
|
|
81
|
-
usage: 'di-framework platform service create <keyvalue|messaging|postgres> --name=<name> [--class=<class>] [--target <name>] [--namespace <ns>] [--wait]',
|
|
98
|
+
usage: 'di-framework platform service create <keyvalue|messaging|blobstore|postgres|egress> [<name> | --name=<name>] [--class=<class>] [--destination <host[:port]>]… [--target <name>] [--namespace <ns>] [--wait]',
|
|
82
99
|
options: [
|
|
83
|
-
'--name <name> Required BackingService metadata.name (DNS label, max 40)',
|
|
84
|
-
'--class <name> Optional approved BackingServiceClass (defaults: keyvalue-redis, messaging-nats, postgres-dedicated)',
|
|
100
|
+
'--name <name> Required BackingService metadata.name (DNS label, max 40); may also follow the type',
|
|
101
|
+
'--class <name> Optional approved BackingServiceClass (defaults: keyvalue-redis, messaging-nats, blobstore-nats, postgres-dedicated, egress-public)',
|
|
102
|
+
'--destination <d> Egress only, repeatable: host, *.suffix, host:port, or *.suffix:port',
|
|
85
103
|
'--memory <qty> Optional sizing parameter (Kubernetes quantity)',
|
|
86
104
|
'--storage <qty> Optional sizing parameter (Kubernetes quantity)',
|
|
87
105
|
'--cpu <qty> Optional sizing parameter (Kubernetes quantity)',
|
|
88
106
|
'--deletion-policy <Retain|Delete> Retention when the CR is deleted (default Retain)',
|
|
89
|
-
'--target <name> Deployment target from di-framework.deploy.toml',
|
|
107
|
+
'--target <name> Deployment target from di-framework.deploy.toml (default: default-target)',
|
|
90
108
|
'--namespace <ns> Override the target namespace',
|
|
91
109
|
'--context <name> Override the kubeconfig context',
|
|
92
110
|
'--wait Wait until the Ready condition is True',
|
|
@@ -98,7 +116,7 @@ export function createWasmcloudCommand(deps = DEFAULT_DEPS) {
|
|
|
98
116
|
description: 'List BackingService resources in the target namespace',
|
|
99
117
|
usage: 'di-framework platform service list [--target <name>] [--namespace <ns>]',
|
|
100
118
|
options: [
|
|
101
|
-
'--target <name> Deployment target from di-framework.deploy.toml',
|
|
119
|
+
'--target <name> Deployment target from di-framework.deploy.toml (default: default-target)',
|
|
102
120
|
'--namespace <ns> Override the target namespace',
|
|
103
121
|
'--context <name> Override the kubeconfig context',
|
|
104
122
|
],
|
|
@@ -108,7 +126,7 @@ export function createWasmcloudCommand(deps = DEFAULT_DEPS) {
|
|
|
108
126
|
description: 'Show Ready status, type, class, and endpoint summary for a BackingService',
|
|
109
127
|
usage: 'di-framework platform service get <name> [--target <name>] [--namespace <ns>]',
|
|
110
128
|
options: [
|
|
111
|
-
'--target <name> Deployment target from di-framework.deploy.toml',
|
|
129
|
+
'--target <name> Deployment target from di-framework.deploy.toml (default: default-target)',
|
|
112
130
|
'--namespace <ns> Override the target namespace',
|
|
113
131
|
'--context <name> Override the kubeconfig context',
|
|
114
132
|
],
|
|
@@ -118,7 +136,7 @@ export function createWasmcloudCommand(deps = DEFAULT_DEPS) {
|
|
|
118
136
|
description: 'Delete a BackingService custom resource (controller retention/in-use rules still apply)',
|
|
119
137
|
usage: 'di-framework platform service delete <name> [--target <name>] [--namespace <ns>]',
|
|
120
138
|
options: [
|
|
121
|
-
'--target <name> Deployment target from di-framework.deploy.toml',
|
|
139
|
+
'--target <name> Deployment target from di-framework.deploy.toml (default: default-target)',
|
|
122
140
|
'--namespace <ns> Override the target namespace',
|
|
123
141
|
'--context <name> Override the kubeconfig context',
|
|
124
142
|
],
|
|
@@ -128,7 +146,7 @@ export function createWasmcloudCommand(deps = DEFAULT_DEPS) {
|
|
|
128
146
|
description: 'Discover approved BackingServiceClass resources (falls back to platform defaults)',
|
|
129
147
|
usage: 'di-framework platform service classes [--target <name>]',
|
|
130
148
|
options: [
|
|
131
|
-
'--target <name> Deployment target from di-framework.deploy.toml',
|
|
149
|
+
'--target <name> Deployment target from di-framework.deploy.toml (default: default-target)',
|
|
132
150
|
'--namespace <ns> Override the target namespace',
|
|
133
151
|
'--context <name> Override the kubeconfig context',
|
|
134
152
|
],
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SESSION_COOKIE = "di_console_session";
|
|
2
|
+
export declare const CSRF_HEADER = "x-di-console-csrf";
|
|
3
|
+
export declare const SESSION_TTL_MS: number;
|
|
4
|
+
export type Session = {
|
|
5
|
+
csrf: string;
|
|
6
|
+
expiresAt: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
};
|
|
9
|
+
export type SessionStore = {
|
|
10
|
+
create(now?: number): {
|
|
11
|
+
id: string;
|
|
12
|
+
session: Session;
|
|
13
|
+
};
|
|
14
|
+
read(id: string | undefined, now: number): Session | undefined;
|
|
15
|
+
destroy(id: string | undefined): void;
|
|
16
|
+
};
|
|
17
|
+
export declare function createSessionStore(): SessionStore;
|
|
18
|
+
export declare function tokensMatch(provided: string | undefined, expected: string): boolean;
|
|
19
|
+
export declare function readCookie(header: string | undefined, name: string): string | undefined;
|
|
20
|
+
export declare function sessionCookie(id: string, maxAge: number): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
export const SESSION_COOKIE = 'di_console_session';
|
|
3
|
+
export const CSRF_HEADER = 'x-di-console-csrf';
|
|
4
|
+
export const SESSION_TTL_MS = 8 * 60 * 60 * 1000;
|
|
5
|
+
const MAX_SESSIONS = 100;
|
|
6
|
+
export function createSessionStore() {
|
|
7
|
+
const sessions = new Map();
|
|
8
|
+
return {
|
|
9
|
+
create(now = Date.now()) {
|
|
10
|
+
for (const [id, session] of sessions) {
|
|
11
|
+
if (session.expiresAt <= now)
|
|
12
|
+
sessions.delete(id);
|
|
13
|
+
}
|
|
14
|
+
while (sessions.size >= MAX_SESSIONS) {
|
|
15
|
+
const oldest = sessions.keys().next().value;
|
|
16
|
+
if (oldest === undefined)
|
|
17
|
+
break;
|
|
18
|
+
sessions.delete(oldest);
|
|
19
|
+
}
|
|
20
|
+
const id = randomBytes(32).toString('base64url');
|
|
21
|
+
const session = {
|
|
22
|
+
csrf: randomBytes(32).toString('base64url'),
|
|
23
|
+
expiresAt: now + SESSION_TTL_MS,
|
|
24
|
+
createdAt: now,
|
|
25
|
+
};
|
|
26
|
+
sessions.set(id, session);
|
|
27
|
+
return { id, session };
|
|
28
|
+
},
|
|
29
|
+
read(id, now) {
|
|
30
|
+
if (id === undefined || id.length === 0)
|
|
31
|
+
return undefined;
|
|
32
|
+
const session = sessions.get(id);
|
|
33
|
+
if (session === undefined)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (session.expiresAt <= now) {
|
|
36
|
+
sessions.delete(id);
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return session;
|
|
40
|
+
},
|
|
41
|
+
destroy(id) {
|
|
42
|
+
if (id !== undefined)
|
|
43
|
+
sessions.delete(id);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function tokensMatch(provided, expected) {
|
|
48
|
+
if (provided === undefined)
|
|
49
|
+
return false;
|
|
50
|
+
const left = createHash('sha256').update(provided).digest();
|
|
51
|
+
const right = createHash('sha256').update(expected).digest();
|
|
52
|
+
return timingSafeEqual(left, right);
|
|
53
|
+
}
|
|
54
|
+
export function readCookie(header, name) {
|
|
55
|
+
if (header === undefined || header.length === 0)
|
|
56
|
+
return undefined;
|
|
57
|
+
for (const part of header.split(';')) {
|
|
58
|
+
const trimmed = part.trim();
|
|
59
|
+
const separator = trimmed.indexOf('=');
|
|
60
|
+
if (separator <= 0)
|
|
61
|
+
continue;
|
|
62
|
+
if (trimmed.slice(0, separator) !== name)
|
|
63
|
+
continue;
|
|
64
|
+
const raw = trimmed.slice(separator + 1);
|
|
65
|
+
try {
|
|
66
|
+
return decodeURIComponent(raw);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
export function sessionCookie(id, maxAge) {
|
|
75
|
+
return [
|
|
76
|
+
`${SESSION_COOKIE}=${encodeURIComponent(id)}`,
|
|
77
|
+
'HttpOnly',
|
|
78
|
+
'SameSite=Strict',
|
|
79
|
+
'Path=/',
|
|
80
|
+
`Max-Age=${maxAge}`,
|
|
81
|
+
].join('; ');
|
|
82
|
+
}
|