@di-framework/cli-plugin-platform 0.0.1 → 6.0.2

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 (169) hide show
  1. package/README.md +408 -0
  2. package/dist/actor-protocol.d.ts +4 -0
  3. package/dist/actor-protocol.js +162 -0
  4. package/dist/actors.d.ts +31 -0
  5. package/dist/actors.js +296 -0
  6. package/dist/args.d.ts +15 -0
  7. package/dist/args.js +66 -0
  8. package/dist/assets/http-adapter.js +876 -0
  9. package/dist/assets/platform/.gitignore.tmpl +6 -0
  10. package/dist/assets/platform/Pulumi.yaml.tmpl +6 -0
  11. package/dist/assets/platform/README.md +208 -0
  12. package/dist/assets/platform/index.ts.tmpl +2 -0
  13. package/dist/assets/platform/package.json.tmpl +18 -0
  14. package/dist/assets/platform/tsconfig.json +11 -0
  15. package/dist/assets/queue-adapter.js +60 -0
  16. package/dist/assets/sqlite/BUILD-INFO.txt +13 -0
  17. package/dist/assets/sqlite/SHA256SUMS +2 -0
  18. package/dist/assets/sqlite/di-framework-sqlite.wasm +0 -0
  19. package/dist/assets/sqlite/di-framework-sqlite.wit +337 -0
  20. package/dist/assets/wit/deps/LICENSE.md +8 -0
  21. package/dist/assets/wit/deps/di-framework-queues/package.wit +18 -0
  22. package/dist/assets/wit/deps/di-framework-sqlite/package.wit +211 -0
  23. package/dist/assets/wit/deps/wasi-cli/package.wit +70 -0
  24. package/dist/assets/wit/deps/wasi-clocks/package.wit +42 -0
  25. package/dist/assets/wit/deps/wasi-config/package.wit +15 -0
  26. package/dist/assets/wit/deps/wasi-filesystem/package.wit +184 -0
  27. package/dist/assets/wit/deps/wasi-http/package.wit +170 -0
  28. package/dist/assets/wit/deps/wasi-random/package.wit +17 -0
  29. package/dist/assets/wit/deps/wasi-sockets/package.wit +105 -0
  30. package/dist/assets/wit/deps/wasi-tls/package.wit +26 -0
  31. package/dist/assets/wit/deps/wasmcloud-blobstore/package.wit +153 -0
  32. package/dist/assets/wit/deps/wasmcloud-keyvalue/package.wit +370 -0
  33. package/dist/assets/wit/deps/wasmcloud-messaging/package.wit +125 -0
  34. package/dist/assets/wit/deps/wasmcloud-postgres/package.wit +435 -0
  35. package/dist/assets/wit/deps/wasmcloud-secrets/package.wit +80 -0
  36. package/dist/async-transform.d.ts +3 -0
  37. package/dist/async-transform.js +60 -0
  38. package/dist/bindings.d.ts +34 -0
  39. package/dist/bindings.js +307 -0
  40. package/dist/build.d.ts +29 -0
  41. package/dist/build.js +325 -0
  42. package/dist/command.d.ts +3 -0
  43. package/dist/command.js +141 -0
  44. package/dist/control/auth.d.ts +18 -0
  45. package/dist/control/auth.js +89 -0
  46. package/dist/control/cron.d.ts +7 -0
  47. package/dist/control/cron.js +86 -0
  48. package/dist/control/index.d.ts +4 -0
  49. package/dist/control/index.js +4 -0
  50. package/dist/control/network.d.ts +12 -0
  51. package/dist/control/network.js +49 -0
  52. package/dist/control/queues.d.ts +15 -0
  53. package/dist/control/queues.js +77 -0
  54. package/dist/cron.d.ts +26 -0
  55. package/dist/cron.js +239 -0
  56. package/dist/deploy.d.ts +29 -0
  57. package/dist/deploy.js +57 -0
  58. package/dist/deps.d.ts +96 -0
  59. package/dist/deps.js +303 -0
  60. package/dist/destroy.d.ts +3 -0
  61. package/dist/destroy.js +24 -0
  62. package/dist/dev-runner.d.ts +24 -0
  63. package/dist/dev-runner.js +83 -0
  64. package/dist/dev.d.ts +8 -0
  65. package/dist/dev.js +76 -0
  66. package/dist/discovery.d.ts +15 -0
  67. package/dist/discovery.js +182 -0
  68. package/dist/doctor.d.ts +8 -0
  69. package/dist/doctor.js +82 -0
  70. package/dist/guests.d.ts +9 -0
  71. package/dist/guests.js +56 -0
  72. package/dist/host-interface.d.ts +29 -0
  73. package/dist/host-interface.js +142 -0
  74. package/dist/index.d.ts +33 -0
  75. package/dist/index.js +39 -0
  76. package/dist/kubernetes.d.ts +9 -0
  77. package/dist/kubernetes.js +17 -0
  78. package/dist/managed-bindings.d.ts +9 -0
  79. package/dist/managed-bindings.js +150 -0
  80. package/dist/manifest.d.ts +36 -0
  81. package/dist/manifest.js +257 -0
  82. package/dist/namespace.d.ts +2 -0
  83. package/dist/namespace.js +4 -0
  84. package/dist/node-compat/async-hooks.d.ts +29 -0
  85. package/dist/node-compat/async-hooks.js +80 -0
  86. package/dist/node-compat/bootstrap.d.ts +1 -0
  87. package/dist/node-compat/bootstrap.js +9 -0
  88. package/dist/node-compat/bytes.d.ts +7 -0
  89. package/dist/node-compat/bytes.js +41 -0
  90. package/dist/node-compat/crypto-hash.d.ts +27 -0
  91. package/dist/node-compat/crypto-hash.js +108 -0
  92. package/dist/node-compat/crypto-subtle.d.ts +59 -0
  93. package/dist/node-compat/crypto-subtle.js +288 -0
  94. package/dist/node-compat/crypto.d.ts +136 -0
  95. package/dist/node-compat/crypto.js +142 -0
  96. package/dist/node-compat/dgram.d.ts +49 -0
  97. package/dist/node-compat/dgram.js +197 -0
  98. package/dist/node-compat/env.d.ts +6 -0
  99. package/dist/node-compat/env.js +88 -0
  100. package/dist/node-compat/fetch-runtime.d.ts +80 -0
  101. package/dist/node-compat/fetch-runtime.js +314 -0
  102. package/dist/node-compat/fs.d.ts +84 -0
  103. package/dist/node-compat/fs.js +285 -0
  104. package/dist/node-compat/http-parser.d.ts +40 -0
  105. package/dist/node-compat/http-parser.js +185 -0
  106. package/dist/node-compat/http.d.ts +130 -0
  107. package/dist/node-compat/http.js +688 -0
  108. package/dist/node-compat/https.d.ts +28 -0
  109. package/dist/node-compat/https.js +88 -0
  110. package/dist/node-compat/module.d.ts +11 -0
  111. package/dist/node-compat/module.js +35 -0
  112. package/dist/node-compat/net.d.ts +119 -0
  113. package/dist/node-compat/net.js +441 -0
  114. package/dist/node-compat/process.d.ts +25 -0
  115. package/dist/node-compat/process.js +63 -0
  116. package/dist/node-compat/runtime-application.d.ts +4 -0
  117. package/dist/node-compat/runtime-application.js +24 -0
  118. package/dist/node-compat/seed-virtual.d.ts +6 -0
  119. package/dist/node-compat/seed-virtual.js +6 -0
  120. package/dist/node-compat/seed.d.ts +20 -0
  121. package/dist/node-compat/seed.js +106 -0
  122. package/dist/node-compat/socket-address.d.ts +35 -0
  123. package/dist/node-compat/socket-address.js +162 -0
  124. package/dist/node-compat/timers.d.ts +32 -0
  125. package/dist/node-compat/timers.js +96 -0
  126. package/dist/node-compat/tls.d.ts +57 -0
  127. package/dist/node-compat/tls.js +290 -0
  128. package/dist/node-compat/wasi-random.d.ts +2 -0
  129. package/dist/node-compat/wasi-random.js +25 -0
  130. package/dist/node-compat/wasi-sockets.d.ts +47 -0
  131. package/dist/node-compat/wasi-sockets.js +134 -0
  132. package/dist/oci.d.ts +9 -0
  133. package/dist/oci.js +9 -0
  134. package/dist/paths.d.ts +7 -0
  135. package/dist/paths.js +13 -0
  136. package/dist/platform-init.d.ts +13 -0
  137. package/dist/platform-init.js +265 -0
  138. package/dist/platform.d.ts +22 -0
  139. package/dist/platform.js +170 -0
  140. package/dist/project.d.ts +39 -0
  141. package/dist/project.js +130 -0
  142. package/dist/publish.d.ts +15 -0
  143. package/dist/publish.js +57 -0
  144. package/dist/pulumi.d.ts +4 -0
  145. package/dist/pulumi.js +27 -0
  146. package/dist/queues-module.d.ts +4 -0
  147. package/dist/queues-module.js +89 -0
  148. package/dist/queues.d.ts +16 -0
  149. package/dist/queues.js +167 -0
  150. package/dist/registry.d.ts +16 -0
  151. package/dist/registry.js +27 -0
  152. package/dist/service.d.ts +162 -0
  153. package/dist/service.js +678 -0
  154. package/dist/support.d.ts +14 -0
  155. package/dist/support.js +37 -0
  156. package/dist/target.d.ts +18 -0
  157. package/dist/target.js +45 -0
  158. package/dist/toml.d.ts +6 -0
  159. package/dist/toml.js +245 -0
  160. package/dist/wash-dev.d.ts +18 -0
  161. package/dist/wash-dev.js +80 -0
  162. package/dist/wit.d.ts +76 -0
  163. package/dist/wit.js +248 -0
  164. package/dist/workload-members.d.ts +12 -0
  165. package/dist/workload-members.js +136 -0
  166. package/dist/workload.d.ts +45 -0
  167. package/dist/workload.js +457 -0
  168. package/package.json +55 -8
  169. package/src/index.ts +0 -2
@@ -0,0 +1,37 @@
1
+ import { CommandFailure } from '@di-framework/cli-extension';
2
+ export function invalidUsage(message, token, details = {}) {
3
+ throw new CommandFailure('INVALID_USAGE', message, 2, { token, ...details });
4
+ }
5
+ export function readOptionValue(args, position, option) {
6
+ const value = args[position];
7
+ if (value == null || value.startsWith('--')) {
8
+ invalidUsage(`Missing value for ${option}`, option);
9
+ }
10
+ return value;
11
+ }
12
+ /**
13
+ * Match `--flag value` or `--flag=value`. Returns the value and the next index to continue from
14
+ * (the index of the value token for space form, or the flag token itself for `=` form).
15
+ */
16
+ export function matchOption(args, position, token, option) {
17
+ if (token === option) {
18
+ return { value: readOptionValue(args, position + 1, option), consumedThrough: position + 1 };
19
+ }
20
+ if (token.startsWith(`${option}=`)) {
21
+ const value = token.slice(option.length + 1);
22
+ if (value.length === 0)
23
+ invalidUsage(`Missing value for ${option}`, option);
24
+ return { value, consumedThrough: position };
25
+ }
26
+ return undefined;
27
+ }
28
+ /** jco runs under real Node.js only; Bun lacks the node internals it uses. */
29
+ export function requireNodeBinary(nodeBinaryPath) {
30
+ if (nodeBinaryPath === undefined) {
31
+ throw new CommandFailure('WASMCLOUD_NODE_REQUIRED', 'Node.js is required to run the jco toolchain; install node and make sure it is on PATH', 3, { tool: 'node' });
32
+ }
33
+ return nodeBinaryPath;
34
+ }
35
+ export function toolFailed(command, exitCode) {
36
+ return new CommandFailure('WASMCLOUD_TOOL_FAILED', `${command} failed with exit code ${exitCode}`, 3, { command, exitCode });
37
+ }
@@ -0,0 +1,18 @@
1
+ import type { WasmcloudDeps } from './deps.js';
2
+ import type { DeployManifest, DeployTarget } from './manifest.js';
3
+ import { type PlatformOutputs } from './platform.js';
4
+ import { type RegistryLocation } from './registry.js';
5
+ export type ClusterConnection = {
6
+ target: string;
7
+ kubeconfig: string;
8
+ namespace: string;
9
+ registry: RegistryLocation;
10
+ context?: string;
11
+ hostgroup?: string;
12
+ storageHostgroup?: string;
13
+ endpoints?: PlatformOutputs['endpoints'];
14
+ platformRoot?: string;
15
+ stack?: string;
16
+ };
17
+ export declare function resolveTarget(manifest: DeployManifest, requested?: string): DeployTarget;
18
+ export declare function resolveConnection(target: DeployTarget, workspaceRoot: string, manifestPath: string, deps: WasmcloudDeps): Promise<ClusterConnection>;
package/dist/target.js ADDED
@@ -0,0 +1,45 @@
1
+ import { CommandFailure } from '@di-framework/cli-extension';
2
+ import { loadPlatformOutputs, resolvePlatformDirectory } from './platform.js';
3
+ import { materializeRegistry } from './registry.js';
4
+ export function resolveTarget(manifest, requested) {
5
+ const name = requested ?? manifest.defaultTarget;
6
+ if (name === undefined) {
7
+ throw new CommandFailure('WASMCLOUD_TARGET_NOT_FOUND', `No deployment target selected. Pass --target <name> or set default-target in ${manifest.path}. Known targets: ${Object.keys(manifest.targets).join(', ')}`, 2, { manifestPath: manifest.path, targets: Object.keys(manifest.targets) });
8
+ }
9
+ const target = manifest.targets[name];
10
+ if (target === undefined) {
11
+ throw new CommandFailure('WASMCLOUD_TARGET_NOT_FOUND', `Unknown target "${name}". Known targets: ${Object.keys(manifest.targets).join(', ')}`, 2, { target: name, targets: Object.keys(manifest.targets), manifestPath: manifest.path });
12
+ }
13
+ return target;
14
+ }
15
+ export async function resolveConnection(target, workspaceRoot, manifestPath, deps) {
16
+ if (target.kind === 'managed') {
17
+ return resolveManagedConnection(target, workspaceRoot, manifestPath, deps);
18
+ }
19
+ return resolveExternalConnection(target);
20
+ }
21
+ async function resolveManagedConnection(target, workspaceRoot, manifestPath, deps) {
22
+ const platformRoot = resolvePlatformDirectory(target, workspaceRoot, manifestPath);
23
+ const outputs = await loadPlatformOutputs(deps, platformRoot, target.stack, target.name);
24
+ return {
25
+ target: target.name,
26
+ kubeconfig: outputs.kubeconfig,
27
+ namespace: outputs.namespace,
28
+ registry: outputs.registry,
29
+ context: outputs.context,
30
+ endpoints: outputs.endpoints,
31
+ platformRoot,
32
+ stack: target.stack,
33
+ };
34
+ }
35
+ function resolveExternalConnection(target) {
36
+ return {
37
+ target: target.name,
38
+ kubeconfig: target.kubeconfig,
39
+ namespace: target.namespace,
40
+ registry: materializeRegistry(target.registry),
41
+ context: target.context,
42
+ ...(target.hostgroup ? { hostgroup: target.hostgroup } : {}),
43
+ ...(target.storageHostgroup ? { storageHostgroup: target.storageHostgroup } : {}),
44
+ };
45
+ }
package/dist/toml.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /** Minimal TOML parser for `di-framework.deploy.toml`. */
2
+ export declare class TomlParseError extends Error {
3
+ readonly line: number;
4
+ constructor(message: string, line: number);
5
+ }
6
+ export declare function parseToml(source: string): Record<string, unknown>;
package/dist/toml.js ADDED
@@ -0,0 +1,245 @@
1
+ /** Minimal TOML parser for `di-framework.deploy.toml`. */
2
+ export class TomlParseError extends Error {
3
+ line;
4
+ constructor(message, line) {
5
+ super(message);
6
+ this.line = line;
7
+ this.name = 'TomlParseError';
8
+ }
9
+ }
10
+ export function parseToml(source) {
11
+ const root = {};
12
+ let current = root;
13
+ const lines = source.split(/\r?\n/);
14
+ for (let index = 0; index < lines.length; index++) {
15
+ const lineNumber = index + 1;
16
+ const line = stripComment(lines[index] ?? '').trim();
17
+ if (line === '')
18
+ continue;
19
+ if (line.startsWith('[')) {
20
+ if (!line.endsWith(']')) {
21
+ throw new TomlParseError(`Unclosed table header: ${line}`, lineNumber);
22
+ }
23
+ const header = line.slice(1, -1).trim();
24
+ if (header === '' || header.startsWith('[')) {
25
+ throw new TomlParseError(`Array tables are not supported: ${line}`, lineNumber);
26
+ }
27
+ current = ensureTable(root, splitDottedKeys(header, lineNumber), lineNumber);
28
+ continue;
29
+ }
30
+ const equals = findUnquotedEquals(line);
31
+ if (equals < 0) {
32
+ throw new TomlParseError(`Expected key = value: ${line}`, lineNumber);
33
+ }
34
+ const key = line.slice(0, equals).trim();
35
+ const rawValue = line.slice(equals + 1).trim();
36
+ if (key === '') {
37
+ throw new TomlParseError('Missing key before "="', lineNumber);
38
+ }
39
+ setValue(current, splitDottedKeys(key, lineNumber), parseValue(rawValue, lineNumber), lineNumber);
40
+ }
41
+ return root;
42
+ }
43
+ function stripComment(line) {
44
+ let inString = false;
45
+ let quote;
46
+ let escaped = false;
47
+ for (let index = 0; index < line.length; index++) {
48
+ const character = line[index] ?? '';
49
+ if (inString) {
50
+ if (escaped) {
51
+ escaped = false;
52
+ continue;
53
+ }
54
+ if (character === '\\' && quote === '"') {
55
+ escaped = true;
56
+ continue;
57
+ }
58
+ if (character === quote) {
59
+ inString = false;
60
+ quote = undefined;
61
+ }
62
+ continue;
63
+ }
64
+ if (character === '"' || character === "'") {
65
+ inString = true;
66
+ quote = character;
67
+ continue;
68
+ }
69
+ if (character === '#')
70
+ return line.slice(0, index);
71
+ }
72
+ return line;
73
+ }
74
+ function findUnquotedEquals(line) {
75
+ let inString = false;
76
+ let quote;
77
+ for (let index = 0; index < line.length; index++) {
78
+ const character = line[index] ?? '';
79
+ if (inString) {
80
+ if (character === quote) {
81
+ inString = false;
82
+ quote = undefined;
83
+ }
84
+ continue;
85
+ }
86
+ if (character === '"' || character === "'") {
87
+ inString = true;
88
+ quote = character;
89
+ continue;
90
+ }
91
+ if (character === '=')
92
+ return index;
93
+ }
94
+ return -1;
95
+ }
96
+ function splitDottedKeys(header, lineNumber) {
97
+ const keys = [];
98
+ let current = '';
99
+ let inQuote = false;
100
+ for (const character of header) {
101
+ if (character === '"') {
102
+ inQuote = !inQuote;
103
+ continue;
104
+ }
105
+ if (character === '.' && !inQuote) {
106
+ if (current === '') {
107
+ throw new TomlParseError(`Invalid dotted key: ${header}`, lineNumber);
108
+ }
109
+ keys.push(current);
110
+ current = '';
111
+ continue;
112
+ }
113
+ current += character;
114
+ }
115
+ if (inQuote || current === '') {
116
+ throw new TomlParseError(`Invalid dotted key: ${header}`, lineNumber);
117
+ }
118
+ keys.push(current);
119
+ return keys;
120
+ }
121
+ function ensureTable(root, keys, lineNumber) {
122
+ let current = root;
123
+ for (const key of keys) {
124
+ const existing = current[key];
125
+ if (existing === undefined) {
126
+ const next = {};
127
+ current[key] = next;
128
+ current = next;
129
+ continue;
130
+ }
131
+ if (!isRecord(existing)) {
132
+ throw new TomlParseError(`Cannot redefine "${key}" as a table`, lineNumber);
133
+ }
134
+ current = existing;
135
+ }
136
+ return current;
137
+ }
138
+ function setValue(table, keys, value, lineNumber) {
139
+ const last = keys[keys.length - 1];
140
+ if (last === undefined) {
141
+ throw new TomlParseError('Missing key', lineNumber);
142
+ }
143
+ const parent = keys.length === 1 ? table : ensureTable(table, keys.slice(0, -1), lineNumber);
144
+ if (parent[last] !== undefined) {
145
+ throw new TomlParseError(`Duplicate key "${keys.join('.')}"`, lineNumber);
146
+ }
147
+ parent[last] = value;
148
+ }
149
+ function parseValue(raw, lineNumber) {
150
+ if (raw.startsWith('"') || raw.startsWith("'")) {
151
+ return parseQuotedString(raw, lineNumber);
152
+ }
153
+ if (raw.startsWith('[')) {
154
+ return parseStringArray(raw, lineNumber);
155
+ }
156
+ if (raw === 'true')
157
+ return true;
158
+ if (raw === 'false')
159
+ return false;
160
+ throw new TomlParseError(`Unsupported value "${raw}"; expected a quoted string, boolean, or an array of strings`, lineNumber);
161
+ }
162
+ function parseQuotedString(raw, lineNumber) {
163
+ const quote = raw[0];
164
+ if ((quote !== '"' && quote !== "'") || raw.length < 2) {
165
+ throw new TomlParseError(`Invalid string: ${raw}`, lineNumber);
166
+ }
167
+ let value = '';
168
+ let escaped = false;
169
+ for (let index = 1; index < raw.length; index++) {
170
+ const character = raw[index] ?? '';
171
+ if (escaped) {
172
+ const escapedCharacter = character === 'n'
173
+ ? '\n'
174
+ : character === 't'
175
+ ? '\t'
176
+ : character === '\\' || character === '"' || character === "'"
177
+ ? character
178
+ : undefined;
179
+ if (escapedCharacter === undefined) {
180
+ throw new TomlParseError(`Unknown escape \\${character}`, lineNumber);
181
+ }
182
+ value += escapedCharacter;
183
+ escaped = false;
184
+ continue;
185
+ }
186
+ if (character === '\\' && quote === '"') {
187
+ escaped = true;
188
+ continue;
189
+ }
190
+ if (character === quote) {
191
+ if (index !== raw.length - 1) {
192
+ throw new TomlParseError(`Unexpected trailing characters: ${raw}`, lineNumber);
193
+ }
194
+ return value;
195
+ }
196
+ value += character;
197
+ }
198
+ throw new TomlParseError(`Unterminated string: ${raw}`, lineNumber);
199
+ }
200
+ function parseStringArray(raw, lineNumber) {
201
+ if (!raw.endsWith(']')) {
202
+ throw new TomlParseError(`Unclosed array: ${raw}`, lineNumber);
203
+ }
204
+ const inner = raw.slice(1, -1).trim();
205
+ if (inner === '')
206
+ return [];
207
+ const values = [];
208
+ let remaining = inner;
209
+ while (remaining !== '') {
210
+ remaining = remaining.trim();
211
+ if (!remaining.startsWith('"') && !remaining.startsWith("'")) {
212
+ throw new TomlParseError('Arrays may only contain quoted strings', lineNumber);
213
+ }
214
+ const quote = remaining[0] ?? '';
215
+ let end = 1;
216
+ let escaped = false;
217
+ for (; end < remaining.length; end++) {
218
+ const character = remaining[end] ?? '';
219
+ if (escaped) {
220
+ escaped = false;
221
+ continue;
222
+ }
223
+ if (character === '\\' && quote === '"') {
224
+ escaped = true;
225
+ continue;
226
+ }
227
+ if (character === quote)
228
+ break;
229
+ }
230
+ if (end >= remaining.length) {
231
+ throw new TomlParseError(`Unterminated string in array: ${raw}`, lineNumber);
232
+ }
233
+ values.push(parseQuotedString(remaining.slice(0, end + 1), lineNumber));
234
+ remaining = remaining.slice(end + 1).trim();
235
+ if (remaining.startsWith(','))
236
+ remaining = remaining.slice(1);
237
+ else if (remaining !== '') {
238
+ throw new TomlParseError(`Expected "," between array values: ${raw}`, lineNumber);
239
+ }
240
+ }
241
+ return values;
242
+ }
243
+ function isRecord(value) {
244
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
245
+ }
@@ -0,0 +1,18 @@
1
+ import type { BindingRecord } from './bindings.js';
2
+ import { type HostInterface } from './host-interface.js';
3
+ import type { WasmcloudProject } from './project.js';
4
+ import type { WitRequirement } from './wit.js';
5
+ export declare const WASH_DEV_CONFIG_NAME = "wash-dev.yaml";
6
+ export type WashDevConfigOptions = {
7
+ componentPath: string;
8
+ host: string;
9
+ port: string;
10
+ postgresUrl?: string;
11
+ };
12
+ export declare function washDevConfigPath(project: WasmcloudProject): string;
13
+ export declare function renderWashDevYaml(interfaces: readonly HostInterface[], options: WashDevConfigOptions): string;
14
+ export declare function writeWashDevConfig(project: WasmcloudProject, requirements: readonly WitRequirement[], bindings: readonly BindingRecord[], options: {
15
+ host: string;
16
+ port: string;
17
+ postgresUrl?: string;
18
+ }): string;
@@ -0,0 +1,80 @@
1
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join, relative, sep } from 'node:path';
3
+ import { hostInterfacesFromRequirements, yamlQuote } from './host-interface.js';
4
+ export const WASH_DEV_CONFIG_NAME = 'wash-dev.yaml';
5
+ export function washDevConfigPath(project) {
6
+ return join(project.projectRoot, '.di-framework', WASH_DEV_CONFIG_NAME);
7
+ }
8
+ function posixRelative(from, to) {
9
+ return relative(from, to).split(sep).join('/');
10
+ }
11
+ export function renderWashDevYaml(interfaces, options) {
12
+ const lines = [
13
+ 'version: 2.5.2',
14
+ 'build:',
15
+ ' command: "true"',
16
+ ` component_path: ${yamlQuote(options.componentPath)}`,
17
+ 'dev:',
18
+ ` address: ${yamlQuote(`${options.host}:${options.port}`)}`,
19
+ ' wasm_proposals:',
20
+ ' - component-model-async',
21
+ ];
22
+ if (options.postgresUrl !== undefined && options.postgresUrl !== '') {
23
+ lines.push(` postgres_url: ${yamlQuote(options.postgresUrl)}`);
24
+ }
25
+ if (interfaces.length > 0) {
26
+ lines.push(' host_interfaces:');
27
+ for (const entry of interfaces) {
28
+ if (entry.name !== undefined) {
29
+ lines.push(` - name: ${yamlQuote(entry.name)}`);
30
+ lines.push(` namespace: ${entry.namespace}`);
31
+ }
32
+ else {
33
+ lines.push(` - namespace: ${entry.namespace}`);
34
+ }
35
+ lines.push(` package: ${entry.package}`);
36
+ lines.push(` version: ${yamlQuote(entry.version)}`);
37
+ lines.push(' interfaces:');
38
+ for (const iface of entry.interfaces)
39
+ lines.push(` - ${iface}`);
40
+ if (entry.config !== undefined) {
41
+ lines.push(' config:');
42
+ for (const [key, value] of Object.entries(entry.config)) {
43
+ lines.push(` ${yamlQuote(key)}: ${yamlQuote(value)}`);
44
+ }
45
+ }
46
+ if (entry.configFrom !== undefined) {
47
+ lines.push(' configFrom:');
48
+ for (const ref of entry.configFrom) {
49
+ lines.push(` - name: ${yamlQuote(ref.name)}`);
50
+ }
51
+ }
52
+ if (entry.secretFrom !== undefined) {
53
+ lines.push(' secretFrom:');
54
+ for (const ref of entry.secretFrom) {
55
+ lines.push(` - name: ${yamlQuote(ref.name)}`);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ lines.push('');
61
+ return lines.join('\n');
62
+ }
63
+ export function writeWashDevConfig(project, requirements, bindings, options) {
64
+ const path = washDevConfigPath(project);
65
+ mkdirSync(dirname(path), { recursive: true });
66
+ const interfaces = hostInterfacesFromRequirements(requirements, { httpHost: options.host }, bindings.map((binding) => ({
67
+ name: binding.name,
68
+ className: binding.className,
69
+ config: binding.config,
70
+ configFrom: binding.configFrom,
71
+ secretFrom: binding.secretFrom,
72
+ })));
73
+ writeFileSync(path, renderWashDevYaml(interfaces, {
74
+ componentPath: posixRelative(project.projectRoot, project.outputPath),
75
+ host: options.host,
76
+ port: options.port,
77
+ postgresUrl: options.postgresUrl,
78
+ }));
79
+ return path;
80
+ }
package/dist/wit.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ /** Component-model / WASI preview the guest targets. Independent of any package version. */
2
+ export declare const COMPONENT_MODEL = "0.3";
3
+ export declare const HTTP_ADAPTER_SOURCE = "http-adapter";
4
+ export declare const NODE_COMPAT_SOURCE = "node-compat";
5
+ export declare const WASI_HTTP_PACKAGE = "wasi:http";
6
+ export declare const WASI_HTTP_VERSION = "0.3.0";
7
+ export declare const WASI_HTTP_INTERFACE = "handler";
8
+ export declare const WASI_SOCKETS_PACKAGE = "wasi:sockets";
9
+ export declare const WASI_SOCKETS_VERSION = "0.3.0";
10
+ export declare const WASI_RANDOM_PACKAGE = "wasi:random";
11
+ export declare const WASI_RANDOM_VERSION = "0.3.0";
12
+ export declare const QUEUE_ADAPTER_SOURCE = "queue-adapter";
13
+ export declare const DI_QUEUES_PACKAGE = "di-framework:queues";
14
+ export declare const DI_QUEUES_VERSION = "0.1.0";
15
+ export declare const DI_QUEUES_INTERFACE = "dispatch";
16
+ export declare const DI_SQLITE_PACKAGE = "di-framework:sqlite";
17
+ export declare const DI_SQLITE_VERSION = "0.1.0";
18
+ export declare const DI_SQLITE_INTERFACE = "database";
19
+ export declare const DI_SQLITE_TYPES_INTERFACE = "types";
20
+ export declare const SQLITE_SOURCE = "sqlite-backend";
21
+ export type WitDirection = 'import' | 'export';
22
+ /**
23
+ * One adapter or binding's WIT needs. A requirement is an interface group:
24
+ * `interfaces` share resource identity and become one hostInterfaces entry.
25
+ */
26
+ export type WitRequirement = {
27
+ package: string;
28
+ version: string;
29
+ interfaces: string[];
30
+ direction: WitDirection;
31
+ instanceName?: string;
32
+ namedImport?: boolean;
33
+ source: string;
34
+ };
35
+ export type AggregatedRequirement = WitRequirement & {
36
+ sources: string[];
37
+ };
38
+ export type WitPackageLock = {
39
+ id: string;
40
+ version: string;
41
+ source: 'bundled';
42
+ path: string;
43
+ digest: string;
44
+ };
45
+ export type WitLock = {
46
+ schemaVersion: 1;
47
+ componentModel: string;
48
+ world: string;
49
+ requirements: AggregatedRequirement[];
50
+ packages: WitPackageLock[];
51
+ };
52
+ export declare const HTTP_ADAPTER_REQUIREMENTS: WitRequirement[];
53
+ /** Default guest world: the HTTP adapter only. Bindings later concat onto this list. */
54
+ export declare function defaultProjectRequirements(): WitRequirement[];
55
+ export declare const QUEUE_ADAPTER_REQUIREMENTS: WitRequirement[];
56
+ export declare const SQLITE_IMPORT_REQUIREMENTS: WitRequirement[];
57
+ /** Queue workers are long-lived HTTP services with SQLite-backed persistence. */
58
+ export declare function queueProjectRequirements(): WitRequirement[];
59
+ export declare function sqliteProjectRequirements(): WitRequirement[];
60
+ /**
61
+ * Runtime WASI pulled in by Node overlays (`node:net`/`dgram` → sockets,
62
+ * `node:crypto` → random). Only added to the guest world when the bundled JS
63
+ * actually imports those specifiers.
64
+ */
65
+ export declare function runtimeRequirementsFromJavaScript(source: string): WitRequirement[];
66
+ /** @deprecated Use {@link runtimeRequirementsFromJavaScript}. */
67
+ export declare function socketRequirementsFromJavaScript(source: string): WitRequirement[];
68
+ export declare function parsePackageId(id: string): {
69
+ namespace: string;
70
+ name: string;
71
+ };
72
+ /** Merge interface groups that share package, version, direction, and instance name. */
73
+ export declare function aggregateRequirements(requirements: readonly WitRequirement[]): AggregatedRequirement[];
74
+ export declare function renderWorldWit(packageName: string, version: string, requirements: readonly WitRequirement[]): string;
75
+ export declare function digestBytes(content: string | Buffer): string;
76
+ export declare function buildWitLock(requirements: readonly WitRequirement[], witDepsDirectory: string): WitLock;