@omen.foundation/node-microservice-runtime 0.1.64 → 0.1.67

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 (44) hide show
  1. package/dist/collector-manager.cjs +17 -1
  2. package/dist/collector-manager.d.ts +3 -0
  3. package/dist/collector-manager.d.ts.map +1 -1
  4. package/dist/collector-manager.js +21 -1
  5. package/dist/collector-manager.js.map +1 -1
  6. package/package.json +4 -1
  7. package/.env +0 -13
  8. package/env.sample +0 -13
  9. package/scripts/generate-openapi.mjs +0 -114
  10. package/scripts/lib/cli-utils.mjs +0 -58
  11. package/scripts/prepare-cjs.mjs +0 -44
  12. package/scripts/publish-service.mjs +0 -1119
  13. package/scripts/validate-service.mjs +0 -103
  14. package/scripts/ws-test.mjs +0 -25
  15. package/src/auth.ts +0 -117
  16. package/src/cli/index.ts +0 -725
  17. package/src/collector-manager.ts +0 -1240
  18. package/src/decorators.ts +0 -207
  19. package/src/dependency.ts +0 -211
  20. package/src/dev.ts +0 -17
  21. package/src/discovery.ts +0 -88
  22. package/src/docs.ts +0 -262
  23. package/src/env.ts +0 -148
  24. package/src/errors.ts +0 -55
  25. package/src/federation.ts +0 -559
  26. package/src/index.ts +0 -84
  27. package/src/inventory.ts +0 -491
  28. package/src/logger.ts +0 -727
  29. package/src/message.ts +0 -19
  30. package/src/requester.ts +0 -126
  31. package/src/routing.ts +0 -42
  32. package/src/runtime.ts +0 -1071
  33. package/src/services.ts +0 -459
  34. package/src/storage.ts +0 -206
  35. package/src/types/beamable-sdk-api.d.ts +0 -5
  36. package/src/types.ts +0 -117
  37. package/src/utils/urls.ts +0 -53
  38. package/src/websocket.ts +0 -170
  39. package/test-downloads/collector-test +0 -0
  40. package/test-downloads/collector-test.gz +0 -0
  41. package/tsconfig.base.json +0 -31
  42. package/tsconfig.build.json +0 -10
  43. package/tsconfig.cjs.json +0 -16
  44. package/tsconfig.dev.json +0 -14
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'node:fs/promises';
4
- import path from 'node:path';
5
- import { pathToFileURL, fileURLToPath } from 'node:url';
6
- import dotenv from 'dotenv';
7
-
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
-
10
- function parseArgs(argv) {
11
- const args = {
12
- entry: 'dist/main.js',
13
- output: 'beam_openApi.json',
14
- envFile: undefined,
15
- cid: undefined,
16
- pid: undefined,
17
- host: undefined,
18
- namePrefix: undefined,
19
- service: undefined,
20
- };
21
-
22
- const queue = [...argv];
23
- while (queue.length > 0) {
24
- const current = queue.shift();
25
- switch (current) {
26
- case '--entry':
27
- args.entry = queue.shift();
28
- break;
29
- case '--output':
30
- args.output = queue.shift();
31
- break;
32
- case '--env-file':
33
- args.envFile = queue.shift();
34
- break;
35
- case '--cid':
36
- args.cid = queue.shift();
37
- break;
38
- case '--pid':
39
- args.pid = queue.shift();
40
- break;
41
- case '--host':
42
- args.host = queue.shift();
43
- break;
44
- case '--routing-key':
45
- case '--name-prefix':
46
- args.namePrefix = queue.shift();
47
- break;
48
- case '--service':
49
- args.service = queue.shift();
50
- break;
51
- default:
52
- throw new Error(`Unknown argument: ${current}`);
53
- }
54
- }
55
-
56
- return args;
57
- }
58
-
59
- async function main() {
60
- const args = parseArgs(process.argv.slice(2));
61
-
62
- if (args.envFile) {
63
- const envPath = path.resolve(args.envFile);
64
- dotenv.config({ path: envPath });
65
- }
66
-
67
- if (args.cid) {
68
- process.env.CID = args.cid;
69
- }
70
- if (args.pid) {
71
- process.env.PID = args.pid;
72
- }
73
- if (args.host) {
74
- process.env.HOST = args.host;
75
- }
76
- if (args.namePrefix) {
77
- process.env.NAME_PREFIX = args.namePrefix;
78
- }
79
-
80
- process.env.BEAMABLE_SKIP_RUNTIME = 'true';
81
-
82
- const entryPath = path.resolve(args.entry);
83
- const outputPath = path.resolve(args.output);
84
-
85
- const runtimeEntry = path.resolve(__dirname, '../dist/runtime.js');
86
- try {
87
- await fs.access(runtimeEntry);
88
- } catch (error) {
89
- throw new Error('Runtime distribution not found. Run "npm run compile" in @omen.foundation/node-microservice-runtime.');
90
- }
91
-
92
- await import(pathToFileURL(entryPath).href);
93
-
94
- const { generateOpenApiDocumentForRegisteredServices } = await import(pathToFileURL(runtimeEntry).href);
95
-
96
- const document = generateOpenApiDocumentForRegisteredServices(
97
- {
98
- cid: process.env.CID,
99
- pid: process.env.PID,
100
- host: process.env.HOST,
101
- routingKey: process.env.NAME_PREFIX,
102
- },
103
- { serviceName: args.service },
104
- );
105
-
106
- await fs.writeFile(outputPath, `${JSON.stringify(document, null, 2)}\n`, 'utf8');
107
-
108
- console.log(`OpenAPI documentation generated at ${outputPath}`);
109
- }
110
-
111
- main().catch((error) => {
112
- console.error(error instanceof Error ? error.message : error);
113
- process.exit(1);
114
- });
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from 'node:child_process';
4
-
5
- export function runCommand(
6
- command,
7
- args,
8
- { cwd = process.cwd(), env = process.env, stdio = 'inherit', capture = false, shell, silent = false } = {},
9
- ) {
10
- return new Promise((resolve, reject) => {
11
- const stdioOption = capture ? 'pipe' : (silent ? 'ignore' : stdio);
12
- const child = spawn(command, args, {
13
- cwd,
14
- env,
15
- stdio: stdioOption,
16
- shell: shell ?? (process.platform === 'win32'),
17
- });
18
-
19
- const stdoutChunks = [];
20
- const stderrChunks = [];
21
-
22
- if (capture) {
23
- child.stdout?.on('data', (chunk) => stdoutChunks.push(chunk));
24
- child.stderr?.on('data', (chunk) => stderrChunks.push(chunk));
25
- }
26
-
27
- child.on('error', (error) => {
28
- reject(error);
29
- });
30
-
31
- child.on('exit', (code, signal) => {
32
- if (code === 0) {
33
- resolve({
34
- code,
35
- signal,
36
- stdout: capture ? Buffer.concat(stdoutChunks).toString('utf8').trim() : undefined,
37
- stderr: capture ? Buffer.concat(stderrChunks).toString('utf8').trim() : undefined,
38
- });
39
- } else {
40
- const error = new Error(`Command failed: ${command} ${args.join(' ')}`);
41
- error.code = code;
42
- error.signal = signal;
43
- if (capture) {
44
- error.stdout = Buffer.concat(stdoutChunks).toString('utf8');
45
- error.stderr = Buffer.concat(stderrChunks).toString('utf8');
46
- }
47
- reject(error);
48
- }
49
- });
50
- });
51
- }
52
-
53
- export function parseBooleanEnv(value, fallback = false) {
54
- if (value === undefined) {
55
- return fallback;
56
- }
57
- return ['1', 'true', 'yes', 'on'].includes(value.toString().trim().toLowerCase());
58
- }
@@ -1,44 +0,0 @@
1
- import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
2
- import { dirname, join } from 'node:path';
3
-
4
- async function ensureDir(path) {
5
- await mkdir(path, { recursive: true });
6
- }
7
-
8
- async function copyCjsFiles() {
9
- const srcRoot = join(process.cwd(), 'dist-cjs');
10
- const dstRoot = join(process.cwd(), 'dist');
11
-
12
- await ensureDir(dstRoot);
13
-
14
- const stack = [''];
15
- while (stack.length > 0) {
16
- const current = stack.pop();
17
- const srcDir = join(srcRoot, current);
18
- const entries = await readdir(srcDir, { withFileTypes: true });
19
- for (const entry of entries) {
20
- const relativePath = join(current, entry.name);
21
- if (entry.isDirectory()) {
22
- stack.push(relativePath);
23
- continue;
24
- }
25
-
26
- if (!entry.name.endsWith('.js')) {
27
- continue;
28
- }
29
-
30
- const sourceFile = join(srcRoot, relativePath);
31
- const destFile = join(dstRoot, current, entry.name.replace(/\.js$/, '.cjs'));
32
- await ensureDir(dirname(destFile));
33
- const contents = await readFile(sourceFile);
34
- await writeFile(destFile, contents);
35
- }
36
- }
37
-
38
- await rm(srcRoot, { recursive: true, force: true });
39
- }
40
-
41
- copyCjsFiles().catch((error) => {
42
- console.error('Failed to prepare CommonJS artifacts:', error);
43
- process.exitCode = 1;
44
- });