@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
package/dist/queues.js ADDED
@@ -0,0 +1,167 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import ts from 'typescript';
4
+ function stringLiteral(node) {
5
+ if (node === undefined)
6
+ return undefined;
7
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node))
8
+ return node.text;
9
+ return undefined;
10
+ }
11
+ function numericLiteral(node) {
12
+ if (ts.isNumericLiteral(node))
13
+ return Number(node.text);
14
+ return undefined;
15
+ }
16
+ function objectOptions(node) {
17
+ if (node === undefined || !ts.isObjectLiteralExpression(node))
18
+ return {};
19
+ const result = {};
20
+ for (const prop of node.properties) {
21
+ if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name))
22
+ continue;
23
+ const name = prop.name.text;
24
+ const val = numericLiteral(prop.initializer);
25
+ if (val !== undefined) {
26
+ result[name] = val;
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+ function methodDecorators(node) {
32
+ const fromModifiers = (node.modifiers ?? []).filter((modifier) => ts.isDecorator(modifier));
33
+ const legacy = node
34
+ .decorators;
35
+ return [...fromModifiers, ...(legacy ?? [])];
36
+ }
37
+ function findSourceFiles(dir, fileList = []) {
38
+ if (!existsSync(dir))
39
+ return fileList;
40
+ const entries = readdirSync(dir, { withFileTypes: true });
41
+ for (const entry of entries) {
42
+ const fullPath = join(dir, entry.name);
43
+ if (entry.isDirectory()) {
44
+ if (entry.name === 'node_modules' ||
45
+ entry.name === 'dist' ||
46
+ entry.name === '.di-framework' ||
47
+ entry.name === '.git') {
48
+ continue;
49
+ }
50
+ findSourceFiles(fullPath, fileList);
51
+ }
52
+ else if (entry.isFile() &&
53
+ (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx') || entry.name.endsWith('.js'))) {
54
+ fileList.push(fullPath);
55
+ }
56
+ }
57
+ return fileList;
58
+ }
59
+ export function parseQueueHandlersInFile(filePath) {
60
+ let content = '';
61
+ try {
62
+ content = readFileSync(filePath, 'utf8');
63
+ }
64
+ catch {
65
+ return [];
66
+ }
67
+ if (!content.includes('QueueHandler'))
68
+ return [];
69
+ const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
70
+ const handlers = [];
71
+ function visit(node) {
72
+ if (ts.isClassDeclaration(node)) {
73
+ const className = node.name ? node.name.text : 'AnonymousService';
74
+ for (const member of node.members) {
75
+ if (ts.isMethodDeclaration(member)) {
76
+ const methodName = member.name && ts.isIdentifier(member.name) ? member.name.text : '';
77
+ for (const decorator of methodDecorators(member)) {
78
+ const expr = decorator.expression;
79
+ if (ts.isCallExpression(expr)) {
80
+ const callTarget = expr.expression;
81
+ const decName = ts.isIdentifier(callTarget)
82
+ ? callTarget.text
83
+ : ts.isPropertyAccessExpression(callTarget) && ts.isIdentifier(callTarget.name)
84
+ ? callTarget.name.text
85
+ : undefined;
86
+ if (decName === 'QueueHandler') {
87
+ const queueName = stringLiteral(expr.arguments[0]);
88
+ if (queueName) {
89
+ const opts = objectOptions(expr.arguments[1]);
90
+ handlers.push({
91
+ className,
92
+ methodName,
93
+ queueName,
94
+ filePath,
95
+ options: {
96
+ maxRetries: opts.maxRetries,
97
+ backoffMs: opts.backoffMs,
98
+ timeoutMs: opts.timeoutMs,
99
+ concurrency: opts.concurrency,
100
+ },
101
+ });
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ ts.forEachChild(node, visit);
110
+ }
111
+ visit(source);
112
+ return handlers;
113
+ }
114
+ export function discoverQueueHandlers(project) {
115
+ const filesToScan = new Set();
116
+ if (existsSync(project.entryPath)) {
117
+ filesToScan.add(project.entryPath);
118
+ }
119
+ const srcDir = join(project.projectRoot, 'src');
120
+ if (existsSync(srcDir)) {
121
+ for (const file of findSourceFiles(srcDir)) {
122
+ filesToScan.add(file);
123
+ }
124
+ }
125
+ for (const file of findSourceFiles(project.projectRoot)) {
126
+ filesToScan.add(file);
127
+ }
128
+ const allHandlers = [];
129
+ for (const file of filesToScan) {
130
+ allHandlers.push(...parseQueueHandlersInFile(file));
131
+ }
132
+ // Deduplicate handlers by className + methodName + queueName
133
+ const unique = new Map();
134
+ for (const h of allHandlers) {
135
+ const key = `${h.className}#${h.methodName}#${h.queueName}`;
136
+ if (!unique.has(key)) {
137
+ unique.set(key, h);
138
+ }
139
+ }
140
+ return [...unique.values()];
141
+ }
142
+ export function isQueueWorkerProject(project, queueHandlers) {
143
+ if (queueHandlers.length === 0)
144
+ return false;
145
+ if (project.applicationType === 'worker')
146
+ return true;
147
+ // If there are queue handlers, check if project declares any HTTP controllers
148
+ let hasHttpControllers = false;
149
+ const srcFiles = findSourceFiles(project.projectRoot);
150
+ for (const file of srcFiles) {
151
+ try {
152
+ const code = readFileSync(file, 'utf8');
153
+ if (code.includes('@Controller') ||
154
+ code.includes('@Get(') ||
155
+ code.includes('@Post(') ||
156
+ code.includes('@Put(') ||
157
+ code.includes('@Delete(')) {
158
+ hasHttpControllers = true;
159
+ break;
160
+ }
161
+ }
162
+ catch {
163
+ // ignore
164
+ }
165
+ }
166
+ return !hasHttpControllers;
167
+ }
@@ -0,0 +1,16 @@
1
+ export type RegistryLocation = {
2
+ /** Host-side endpoint used by ORAS. May include http:// or https://. */
3
+ push: string;
4
+ /** Cluster-side endpoint embedded in workload OCI references. */
5
+ pull: string;
6
+ /** Explicitly permits plain HTTP for the push endpoint. */
7
+ insecure: boolean;
8
+ };
9
+ export type RegistryInput = string | {
10
+ push: string;
11
+ pull: string;
12
+ insecure?: boolean;
13
+ };
14
+ export declare function materializeRegistry(input: RegistryInput): RegistryLocation;
15
+ export declare function registryUsesPlainHttp(registry: RegistryLocation): boolean;
16
+ export declare function registryReferenceHost(registry: string): string;
@@ -0,0 +1,27 @@
1
+ export function materializeRegistry(input) {
2
+ if (typeof input === 'string') {
3
+ return { push: input, pull: input, insecure: usesHttp(input) };
4
+ }
5
+ return {
6
+ push: input.push,
7
+ pull: input.pull,
8
+ insecure: input.insecure ?? usesHttp(input.push),
9
+ };
10
+ }
11
+ export function registryUsesPlainHttp(registry) {
12
+ return registry.insecure || usesHttp(registry.push);
13
+ }
14
+ export function registryReferenceHost(registry) {
15
+ let host = registry.trim();
16
+ const lower = host.toLowerCase();
17
+ if (lower.startsWith('https://'))
18
+ host = host.slice('https://'.length);
19
+ else if (lower.startsWith('http://'))
20
+ host = host.slice('http://'.length);
21
+ while (host.endsWith('/'))
22
+ host = host.slice(0, -1);
23
+ return host;
24
+ }
25
+ function usesHttp(value) {
26
+ return value.trim().toLowerCase().startsWith('http://');
27
+ }
@@ -0,0 +1,162 @@
1
+ import { type CliIo, type JsonValue } from '@di-framework/cli-extension';
2
+ import { type WasmcloudDeps } from './deps.js';
3
+ export declare const BACKING_SERVICE_API_VERSION = "platform.di-framework.dev/v1alpha1";
4
+ export declare const BACKING_SERVICE_KIND = "BackingService";
5
+ export declare const BACKING_SERVICE_RESOURCE = "backingservices.platform.di-framework.dev";
6
+ export declare const BACKING_SERVICE_CLASS_RESOURCE = "backingserviceclasses.platform.di-framework.dev";
7
+ export declare const SERVICE_TYPES: readonly ["keyvalue", "messaging", "postgres"];
8
+ export type ServiceType = (typeof SERVICE_TYPES)[number];
9
+ export declare const DEFAULT_SERVICE_CLASSES: {
10
+ readonly keyvalue: "keyvalue-redis";
11
+ readonly messaging: "messaging-nats";
12
+ readonly postgres: "postgres-dedicated";
13
+ };
14
+ export declare const DEFAULT_WAIT_TIMEOUT_MS = 120000;
15
+ export declare const WAIT_POLL_INTERVAL_MS = 2000;
16
+ declare const DELETION_POLICIES: readonly ["Retain", "Delete"];
17
+ export type DeletionPolicy = (typeof DELETION_POLICIES)[number];
18
+ export type ServiceSizingParameters = {
19
+ storage?: string;
20
+ memory?: string;
21
+ cpu?: string;
22
+ };
23
+ export type ServiceCreateOptions = {
24
+ type?: ServiceType;
25
+ name?: string;
26
+ className?: string;
27
+ parameters?: ServiceSizingParameters;
28
+ deletionPolicy?: DeletionPolicy;
29
+ target?: string;
30
+ namespace?: string;
31
+ context?: string;
32
+ wait: boolean;
33
+ timeoutMs: number;
34
+ };
35
+ export type ServiceNameOptions = {
36
+ name?: string;
37
+ target?: string;
38
+ namespace?: string;
39
+ context?: string;
40
+ };
41
+ export type ServiceListOptions = {
42
+ target?: string;
43
+ namespace?: string;
44
+ context?: string;
45
+ };
46
+ type ReadyCondition = {
47
+ type?: string;
48
+ status?: string;
49
+ reason?: string;
50
+ message?: string;
51
+ };
52
+ type BackingServiceDocument = {
53
+ metadata?: {
54
+ name?: string;
55
+ namespace?: string;
56
+ deletionTimestamp?: string;
57
+ };
58
+ spec?: {
59
+ type?: string;
60
+ className?: string;
61
+ parameters?: ServiceSizingParameters;
62
+ deletionPolicy?: string;
63
+ };
64
+ status?: {
65
+ conditions?: ReadyCondition[];
66
+ endpoint?: {
67
+ host?: string;
68
+ port?: number;
69
+ capability?: string;
70
+ };
71
+ classRef?: {
72
+ name?: string;
73
+ };
74
+ runtimeNamespace?: string;
75
+ };
76
+ };
77
+ export type ServiceSummary = {
78
+ name: string;
79
+ namespace: string;
80
+ type: string;
81
+ className: string;
82
+ ready: string;
83
+ reason?: string;
84
+ message?: string;
85
+ endpoint?: {
86
+ host: string;
87
+ port: number;
88
+ capability: string;
89
+ };
90
+ deletionPolicy?: string;
91
+ };
92
+ export declare function isServiceType(value: string): value is ServiceType;
93
+ /** DNS-label rules aligned with the BackingService CRD metadata.name schema (max 40). */
94
+ export declare function isBackingServiceName(value: string, max?: number): boolean;
95
+ export declare function serviceTypeDiscoveryText(): string;
96
+ export declare function buildBackingServiceManifest(options: {
97
+ name: string;
98
+ type: ServiceType;
99
+ className?: string;
100
+ parameters?: ServiceSizingParameters;
101
+ deletionPolicy?: DeletionPolicy;
102
+ }): Record<string, unknown>;
103
+ export declare function parseServiceCreateArgs(args: readonly string[]): ServiceCreateOptions;
104
+ export declare function parseServiceNameArgs(args: readonly string[], command: string): ServiceNameOptions;
105
+ export declare function parseServiceListArgs(args: readonly string[]): ServiceListOptions;
106
+ export declare function summarizeService(document: BackingServiceDocument): ServiceSummary;
107
+ export declare function runWasmcloudServiceCreate(args: readonly string[], io: CliIo, deps?: WasmcloudDeps): Promise<{
108
+ data: {
109
+ resource: {
110
+ apiVersion: string;
111
+ kind: string;
112
+ };
113
+ endpoint?: {
114
+ host: string;
115
+ port: number;
116
+ capability: string;
117
+ } | undefined;
118
+ wait: boolean;
119
+ ready: string;
120
+ deletionPolicy?: "Retain" | "Delete" | undefined;
121
+ parameters?: ServiceSizingParameters | undefined;
122
+ context?: string | undefined;
123
+ name: string;
124
+ type: "messaging" | "postgres" | "keyvalue";
125
+ className: string;
126
+ namespace: string;
127
+ target: string;
128
+ };
129
+ text: string;
130
+ }>;
131
+ export declare function runWasmcloudServiceList(args: readonly string[], _io: CliIo, deps?: WasmcloudDeps): Promise<{
132
+ data: {
133
+ namespace: string;
134
+ target: string;
135
+ services: JsonValue;
136
+ };
137
+ text: string;
138
+ }>;
139
+ export declare function runWasmcloudServiceGet(args: readonly string[], _io: CliIo, deps?: WasmcloudDeps): Promise<{
140
+ data: JsonValue;
141
+ text: string;
142
+ }>;
143
+ export declare function runWasmcloudServiceDelete(args: readonly string[], io: CliIo, deps?: WasmcloudDeps): Promise<{
144
+ data: {
145
+ deletionPolicy?: string | undefined;
146
+ name: string;
147
+ namespace: string;
148
+ target: string;
149
+ deleted: boolean;
150
+ };
151
+ text: string;
152
+ }>;
153
+ export declare function runWasmcloudServiceClasses(args: readonly string[], _io: CliIo, deps?: WasmcloudDeps): Promise<{
154
+ data: {
155
+ namespace: string;
156
+ target: string;
157
+ classes: JsonValue;
158
+ fromCluster: boolean;
159
+ };
160
+ text: string;
161
+ }>;
162
+ export {};