@di-framework/cli-plugin-platform 6.0.3 → 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.
Files changed (69) hide show
  1. package/README.md +196 -21
  2. package/dist/args.d.ts +2 -1
  3. package/dist/args.js +9 -5
  4. package/dist/assets/http-adapter.js +63 -0
  5. package/dist/assets/platform/README.md +22 -6
  6. package/dist/assets/sqlite/BUILD-INFO.txt +1 -1
  7. package/dist/assets/wit/deps/wasi-clocks-0.2.12/package.wit +43 -0
  8. package/dist/assets/wit/deps/wasi-filesystem-0.2.12/package.wit +196 -0
  9. package/dist/assets/wit/deps/wasi-io-0.2.12/package.wit +66 -0
  10. package/dist/assets/wit/deps/wasi-logging/package.wit +36 -0
  11. package/dist/build.d.ts +3 -1
  12. package/dist/build.js +4 -2
  13. package/dist/command.js +31 -13
  14. package/dist/console/auth.d.ts +20 -0
  15. package/dist/console/auth.js +82 -0
  16. package/dist/console/catalog.d.ts +196 -0
  17. package/dist/console/catalog.js +821 -0
  18. package/dist/console/cluster.d.ts +30 -0
  19. package/dist/console/cluster.js +299 -0
  20. package/dist/console/errors.d.ts +10 -0
  21. package/dist/console/errors.js +32 -0
  22. package/dist/console/run.d.ts +18 -0
  23. package/dist/console/run.js +102 -0
  24. package/dist/console/server.d.ts +25 -0
  25. package/dist/console/server.js +668 -0
  26. package/dist/console/services.d.ts +47 -0
  27. package/dist/console/services.js +111 -0
  28. package/dist/console-ui/app.css +1 -0
  29. package/dist/console-ui/app.js +260 -0
  30. package/dist/console-ui/di-framework-mark.png +0 -0
  31. package/dist/console-ui/index.html +13 -0
  32. package/dist/deps.d.ts +2 -0
  33. package/dist/deps.js +5 -3
  34. package/dist/dev.js +10 -5
  35. package/dist/egress.d.ts +40 -0
  36. package/dist/egress.js +214 -0
  37. package/dist/host-interface.js +2 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.js +1 -0
  40. package/dist/manifest.d.ts +7 -0
  41. package/dist/manifest.js +35 -8
  42. package/dist/node-compat/console.d.ts +18 -0
  43. package/dist/node-compat/console.js +42 -0
  44. package/dist/node-compat/env.js +6 -0
  45. package/dist/node-compat/events.d.ts +20 -0
  46. package/dist/node-compat/events.js +55 -0
  47. package/dist/node-compat/fetch-runtime.d.ts +31 -0
  48. package/dist/node-compat/fetch-runtime.js +62 -0
  49. package/dist/node-compat/fs-promises.d.ts +30 -0
  50. package/dist/node-compat/fs-promises.js +3 -0
  51. package/dist/node-compat/fs.d.ts +79 -0
  52. package/dist/node-compat/fs.js +112 -5
  53. package/dist/node-compat/net.d.ts +2 -1
  54. package/dist/node-compat/net.js +3 -1
  55. package/dist/node-compat/storage.d.ts +87 -0
  56. package/dist/node-compat/storage.js +244 -0
  57. package/dist/node-compat/stream.d.ts +24 -0
  58. package/dist/node-compat/stream.js +70 -0
  59. package/dist/platform.js +2 -4
  60. package/dist/project.d.ts +5 -0
  61. package/dist/project.js +4 -0
  62. package/dist/service.d.ts +21 -2
  63. package/dist/service.js +71 -5
  64. package/dist/target.js +6 -1
  65. package/dist/wit.d.ts +8 -0
  66. package/dist/wit.js +28 -0
  67. package/dist/workload.d.ts +45 -0
  68. package/dist/workload.js +98 -26
  69. package/package.json +14 -4
@@ -0,0 +1,47 @@
1
+ import type { CliIo } from '@di-framework/cli-extension';
2
+ import type { WasmcloudDeps } from '../deps.js';
3
+ export type ServiceClassView = {
4
+ name: string;
5
+ type: string;
6
+ provider: string;
7
+ default: boolean;
8
+ };
9
+ export type ServiceView = {
10
+ name: string;
11
+ namespace: string;
12
+ type: string;
13
+ className: string;
14
+ ready: string;
15
+ reason?: string;
16
+ message?: string;
17
+ endpoint?: {
18
+ host: string;
19
+ port: number;
20
+ capability: string;
21
+ };
22
+ deletionPolicy?: string;
23
+ target: string;
24
+ };
25
+ export type ServiceCreateInput = {
26
+ target: string;
27
+ type: string;
28
+ name: string;
29
+ className?: string;
30
+ memory?: string;
31
+ storage?: string;
32
+ cpu?: string;
33
+ deletionPolicy?: string;
34
+ };
35
+ export type ConsoleServices = {
36
+ list(target: string): Promise<ServiceView[]>;
37
+ classes(target: string): Promise<{
38
+ classes: ServiceClassView[];
39
+ fromCluster: boolean;
40
+ }>;
41
+ create(input: ServiceCreateInput): Promise<ServiceView>;
42
+ delete(target: string, name: string): Promise<{
43
+ name: string;
44
+ deletionPolicy?: string;
45
+ }>;
46
+ };
47
+ export declare function createCliConsoleServices(deps: WasmcloudDeps, io: CliIo): ConsoleServices;
@@ -0,0 +1,111 @@
1
+ import { runWasmcloudServiceClasses, runWasmcloudServiceCreate, runWasmcloudServiceDelete, runWasmcloudServiceList, } from '../service.js';
2
+ import { sanitizePublicText } from './errors.js';
3
+ export function createCliConsoleServices(deps, io) {
4
+ return {
5
+ async list(target) {
6
+ const result = await runWasmcloudServiceList(['--target', target], io, deps);
7
+ return readServices(record(result.data).services).map((service) => toView(service, target));
8
+ },
9
+ async classes(target) {
10
+ const result = await runWasmcloudServiceClasses(['--target', target], io, deps);
11
+ const data = record(result.data);
12
+ return {
13
+ // Egress needs destinations, which the console create form does not collect.
14
+ classes: readClasses(data.classes).filter((entry) => entry.type !== 'egress'),
15
+ fromCluster: data.fromCluster === true,
16
+ };
17
+ },
18
+ async create(input) {
19
+ const args = ['--target', input.target, '--name', input.name];
20
+ if (input.className !== undefined)
21
+ args.push('--class', input.className);
22
+ if (input.memory !== undefined)
23
+ args.push('--memory', input.memory);
24
+ if (input.storage !== undefined)
25
+ args.push('--storage', input.storage);
26
+ if (input.cpu !== undefined)
27
+ args.push('--cpu', input.cpu);
28
+ if (input.deletionPolicy !== undefined)
29
+ args.push('--deletion-policy', input.deletionPolicy);
30
+ const result = await runWasmcloudServiceCreate([input.type, ...args], io, deps);
31
+ const data = record(result.data);
32
+ return {
33
+ name: stringField(data.name, input.name),
34
+ namespace: stringField(data.namespace, ''),
35
+ type: stringField(data.type, input.type),
36
+ className: stringField(data.className, input.className ?? ''),
37
+ ready: stringField(data.ready, 'Unknown'),
38
+ target: input.target,
39
+ ...(data.deletionPolicy !== undefined
40
+ ? { deletionPolicy: stringField(data.deletionPolicy, '') }
41
+ : {}),
42
+ ...(isEndpoint(data.endpoint) ? { endpoint: data.endpoint } : {}),
43
+ };
44
+ },
45
+ async delete(target, name) {
46
+ const result = await runWasmcloudServiceDelete([name, '--target', target], io, deps);
47
+ const policy = record(result.data).deletionPolicy;
48
+ return {
49
+ name,
50
+ ...(typeof policy === 'string' ? { deletionPolicy: policy } : {}),
51
+ };
52
+ },
53
+ };
54
+ }
55
+ function toView(service, target) {
56
+ const endpoint = isEndpoint(service.endpoint) ? service.endpoint : undefined;
57
+ const reason = typeof service.reason === 'string' ? service.reason : undefined;
58
+ const message = typeof service.message === 'string' ? service.message : undefined;
59
+ const deletionPolicy = typeof service.deletionPolicy === 'string' ? service.deletionPolicy : undefined;
60
+ return {
61
+ name: stringField(service.name, ''),
62
+ namespace: stringField(service.namespace, ''),
63
+ type: stringField(service.type, ''),
64
+ className: stringField(service.className, ''),
65
+ ready: stringField(service.ready, 'Unknown'),
66
+ target,
67
+ ...(reason ? { reason } : {}),
68
+ ...(message ? { message: sanitizePublicText(message, 200) } : {}),
69
+ ...(endpoint ? { endpoint } : {}),
70
+ ...(deletionPolicy ? { deletionPolicy } : {}),
71
+ };
72
+ }
73
+ function record(value) {
74
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
75
+ }
76
+ function readServices(value) {
77
+ if (!Array.isArray(value))
78
+ return [];
79
+ return value.filter((entry) => entry !== null &&
80
+ typeof entry === 'object' &&
81
+ !Array.isArray(entry) &&
82
+ typeof entry.name === 'string');
83
+ }
84
+ function readClasses(value) {
85
+ if (!Array.isArray(value))
86
+ return [];
87
+ const classes = [];
88
+ for (const entry of value) {
89
+ if (entry === null || typeof entry !== 'object' || Array.isArray(entry))
90
+ continue;
91
+ if (typeof entry.name !== 'string' || typeof entry.type !== 'string')
92
+ continue;
93
+ classes.push({
94
+ name: entry.name,
95
+ type: entry.type,
96
+ provider: typeof entry.provider === 'string' ? entry.provider : '',
97
+ default: entry.default === true,
98
+ });
99
+ }
100
+ return classes;
101
+ }
102
+ function stringField(value, fallback) {
103
+ return typeof value === 'string' ? value : fallback;
104
+ }
105
+ function isEndpoint(value) {
106
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
107
+ return false;
108
+ return (typeof value.host === 'string' &&
109
+ typeof value.port === 'number' &&
110
+ typeof value.capability === 'string');
111
+ }