nvent 0.5.15 → 1.0.0-alpha.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.
- package/dist/module.d.mts +181 -8
- package/dist/module.json +1 -1
- package/dist/module.mjs +1257 -1196
- package/dist/runtime/app/composables/useFunctionCall.d.ts +17 -0
- package/dist/runtime/app/composables/useFunctionCall.js +25 -0
- package/dist/runtime/app/composables/useNventStream.d.ts +23 -0
- package/dist/runtime/app/composables/useNventStream.js +58 -0
- package/dist/runtime/nitro/plugins/00.iii-lifecycle.d.ts +19 -0
- package/dist/runtime/nitro/plugins/00.iii-lifecycle.js +62 -0
- package/dist/runtime/nitro/plugins/01.iii-worker.d.ts +15 -0
- package/dist/runtime/nitro/plugins/01.iii-worker.js +91 -0
- package/dist/runtime/nitro/routes/stream-proxy.d.ts +17 -0
- package/dist/runtime/nitro/routes/stream-proxy.js +45 -0
- package/dist/runtime/nitro/utils/console.d.ts +32 -0
- package/dist/runtime/nitro/utils/console.js +95 -0
- package/dist/runtime/nitro/utils/defineFunction.d.ts +378 -3
- package/dist/runtime/nitro/utils/defineFunction.js +224 -4
- package/dist/runtime/nitro/utils/engine.d.ts +25 -0
- package/dist/runtime/nitro/utils/engine.js +130 -0
- package/dist/runtime/nitro/utils/nventDir.d.ts +1 -0
- package/dist/runtime/nitro/utils/nventDir.js +20 -0
- package/dist/runtime/nitro/utils/useIii.d.ts +23 -0
- package/dist/runtime/nitro/utils/useIii.js +14 -0
- package/dist/runtime/nitro/utils/workers/node.d.ts +24 -0
- package/dist/runtime/nitro/utils/workers/node.js +57 -0
- package/dist/runtime/nitro/utils/workers/python.d.ts +67 -0
- package/dist/runtime/nitro/utils/workers/python.js +220 -0
- package/dist/runtime/python/nvent.py +208 -0
- package/dist/runtime/python/worker_runtime.py +659 -0
- package/dist/runtime/virtual.d.ts +17 -0
- package/dist/types.d.mts +5 -1
- package/package.json +11 -14
- package/dist/runtime/adapters/base/index.d.ts +0 -6
- package/dist/runtime/adapters/base/index.js +0 -1
- package/dist/runtime/adapters/base/store-validator.d.ts +0 -48
- package/dist/runtime/adapters/base/store-validator.js +0 -147
- package/dist/runtime/adapters/builtin/file-queue.d.ts +0 -67
- package/dist/runtime/adapters/builtin/file-queue.js +0 -499
- package/dist/runtime/adapters/builtin/file-store.d.ts +0 -32
- package/dist/runtime/adapters/builtin/file-store.js +0 -206
- package/dist/runtime/adapters/builtin/file-stream.d.ts +0 -39
- package/dist/runtime/adapters/builtin/file-stream.js +0 -56
- package/dist/runtime/adapters/builtin/index.d.ts +0 -10
- package/dist/runtime/adapters/builtin/index.js +0 -5
- package/dist/runtime/adapters/builtin/memory-queue.d.ts +0 -52
- package/dist/runtime/adapters/builtin/memory-queue.js +0 -243
- package/dist/runtime/adapters/builtin/memory-store.d.ts +0 -69
- package/dist/runtime/adapters/builtin/memory-store.js +0 -357
- package/dist/runtime/adapters/builtin/memory-stream.d.ts +0 -21
- package/dist/runtime/adapters/builtin/memory-stream.js +0 -56
- package/dist/runtime/adapters/factory.d.ts +0 -31
- package/dist/runtime/adapters/factory.js +0 -135
- package/dist/runtime/adapters/index.d.ts +0 -8
- package/dist/runtime/adapters/index.js +0 -3
- package/dist/runtime/adapters/interfaces/index.d.ts +0 -11
- package/dist/runtime/adapters/interfaces/index.js +0 -3
- package/dist/runtime/adapters/interfaces/queue.d.ts +0 -155
- package/dist/runtime/adapters/interfaces/queue.js +0 -0
- package/dist/runtime/adapters/interfaces/store.d.ts +0 -299
- package/dist/runtime/adapters/interfaces/store.js +0 -0
- package/dist/runtime/adapters/interfaces/stream.d.ts +0 -62
- package/dist/runtime/adapters/interfaces/stream.js +0 -0
- package/dist/runtime/adapters/registry.d.ts +0 -85
- package/dist/runtime/adapters/registry.js +0 -161
- package/dist/runtime/config/index.d.ts +0 -23
- package/dist/runtime/config/index.js +0 -200
- package/dist/runtime/config/types.d.ts +0 -439
- package/dist/runtime/config/types.js +0 -0
- package/dist/runtime/events/eventBus.d.ts +0 -20
- package/dist/runtime/events/eventBus.js +0 -35
- package/dist/runtime/events/types.d.ts +0 -144
- package/dist/runtime/events/types.js +0 -0
- package/dist/runtime/events/utils/scheduleTrigger.d.ts +0 -8
- package/dist/runtime/events/utils/scheduleTrigger.js +0 -71
- package/dist/runtime/events/utils/stallDetector.d.ts +0 -83
- package/dist/runtime/events/utils/stallDetector.js +0 -318
- package/dist/runtime/events/utils/triggerRuntime.d.ts +0 -58
- package/dist/runtime/events/utils/triggerRuntime.js +0 -212
- package/dist/runtime/events/wiring/flowWiring.d.ts +0 -34
- package/dist/runtime/events/wiring/flowWiring.js +0 -1258
- package/dist/runtime/events/wiring/registry.d.ts +0 -19
- package/dist/runtime/events/wiring/registry.js +0 -43
- package/dist/runtime/events/wiring/stateWiring.d.ts +0 -37
- package/dist/runtime/events/wiring/stateWiring.js +0 -92
- package/dist/runtime/events/wiring/streamWiring.d.ts +0 -36
- package/dist/runtime/events/wiring/streamWiring.js +0 -156
- package/dist/runtime/events/wiring/triggerWiring.d.ts +0 -21
- package/dist/runtime/events/wiring/triggerWiring.js +0 -422
- package/dist/runtime/nitro/plugins/00.adapters.d.ts +0 -14
- package/dist/runtime/nitro/plugins/00.adapters.js +0 -73
- package/dist/runtime/nitro/plugins/01.ws-lifecycle.d.ts +0 -5
- package/dist/runtime/nitro/plugins/01.ws-lifecycle.js +0 -69
- package/dist/runtime/nitro/plugins/02.workers.d.ts +0 -2
- package/dist/runtime/nitro/plugins/02.workers.js +0 -92
- package/dist/runtime/nitro/plugins/03.triggers.d.ts +0 -12
- package/dist/runtime/nitro/plugins/03.triggers.js +0 -55
- package/dist/runtime/nitro/routes/webhook.await.d.ts +0 -23
- package/dist/runtime/nitro/routes/webhook.await.js +0 -112
- package/dist/runtime/nitro/routes/webhook.trigger.d.ts +0 -86
- package/dist/runtime/nitro/routes/webhook.trigger.js +0 -73
- package/dist/runtime/nitro/utils/adapters.d.ts +0 -66
- package/dist/runtime/nitro/utils/adapters.js +0 -51
- package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +0 -15
- package/dist/runtime/nitro/utils/awaitPatterns/event.js +0 -128
- package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +0 -28
- package/dist/runtime/nitro/utils/awaitPatterns/index.js +0 -55
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +0 -16
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +0 -83
- package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +0 -15
- package/dist/runtime/nitro/utils/awaitPatterns/time.js +0 -71
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +0 -15
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +0 -128
- package/dist/runtime/nitro/utils/defineFunctionConfig.d.ts +0 -378
- package/dist/runtime/nitro/utils/defineFunctionConfig.js +0 -3
- package/dist/runtime/nitro/utils/defineHooks.d.ts +0 -95
- package/dist/runtime/nitro/utils/defineHooks.js +0 -9
- package/dist/runtime/nitro/utils/registerAdapter.d.ts +0 -59
- package/dist/runtime/nitro/utils/registerAdapter.js +0 -13
- package/dist/runtime/nitro/utils/useAwait.d.ts +0 -83
- package/dist/runtime/nitro/utils/useAwait.js +0 -169
- package/dist/runtime/nitro/utils/useEventManager.d.ts +0 -15
- package/dist/runtime/nitro/utils/useEventManager.js +0 -26
- package/dist/runtime/nitro/utils/useFlow.d.ts +0 -66
- package/dist/runtime/nitro/utils/useFlow.js +0 -310
- package/dist/runtime/nitro/utils/useHookRegistry.d.ts +0 -40
- package/dist/runtime/nitro/utils/useHookRegistry.js +0 -25
- package/dist/runtime/nitro/utils/useNventLogger.d.ts +0 -42
- package/dist/runtime/nitro/utils/useNventLogger.js +0 -54
- package/dist/runtime/nitro/utils/useRunContext.d.ts +0 -6
- package/dist/runtime/nitro/utils/useRunContext.js +0 -102
- package/dist/runtime/nitro/utils/useStreamTopics.d.ts +0 -83
- package/dist/runtime/nitro/utils/useStreamTopics.js +0 -94
- package/dist/runtime/nitro/utils/useTrigger.d.ts +0 -150
- package/dist/runtime/nitro/utils/useTrigger.js +0 -311
- package/dist/runtime/nitro/utils/wsPeerManager.d.ts +0 -44
- package/dist/runtime/nitro/utils/wsPeerManager.js +0 -32
- package/dist/runtime/scheduler/index.d.ts +0 -33
- package/dist/runtime/scheduler/index.js +0 -42
- package/dist/runtime/scheduler/scheduler.d.ts +0 -132
- package/dist/runtime/scheduler/scheduler.js +0 -799
- package/dist/runtime/scheduler/types.d.ts +0 -122
- package/dist/runtime/scheduler/types.js +0 -0
- package/dist/runtime/worker/node/runner.d.ts +0 -95
- package/dist/runtime/worker/node/runner.js +0 -272
- package/dist/runtime/worker/python/get_config.py +0 -64
- package/dist/runtime/worker/system/awaitHandlers.d.ts +0 -27
- package/dist/runtime/worker/system/awaitHandlers.js +0 -230
- package/dist/runtime/worker/system/index.d.ts +0 -24
- package/dist/runtime/worker/system/index.js +0 -39
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
export class AdapterRegistry {
|
|
2
|
-
queueAdapters = /* @__PURE__ */ new Map();
|
|
3
|
-
streamAdapters = /* @__PURE__ */ new Map();
|
|
4
|
-
storeAdapters = /* @__PURE__ */ new Map();
|
|
5
|
-
// ============================================================
|
|
6
|
-
// Registration
|
|
7
|
-
// ============================================================
|
|
8
|
-
/**
|
|
9
|
-
* Register a queue adapter
|
|
10
|
-
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
11
|
-
* @param adapter - QueueAdapter implementation
|
|
12
|
-
*/
|
|
13
|
-
registerQueue(name, adapter) {
|
|
14
|
-
if (this.queueAdapters.has(name)) {
|
|
15
|
-
console.warn(`[nvent] Queue adapter "${name}" is already registered, overwriting`);
|
|
16
|
-
}
|
|
17
|
-
this.queueAdapters.set(name, adapter);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Register a stream adapter
|
|
21
|
-
* @param name - Adapter name (e.g., 'redis', 'memory', 'rabbitmq')
|
|
22
|
-
* @param adapter - StreamAdapter implementation
|
|
23
|
-
*/
|
|
24
|
-
registerStream(name, adapter) {
|
|
25
|
-
if (this.streamAdapters.has(name)) {
|
|
26
|
-
console.warn(`[nvent] Stream adapter "${name}" is already registered, overwriting`);
|
|
27
|
-
}
|
|
28
|
-
this.streamAdapters.set(name, adapter);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Register a store adapter
|
|
32
|
-
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
33
|
-
* @param adapter - StoreAdapter implementation
|
|
34
|
-
*/
|
|
35
|
-
registerStore(name, adapter) {
|
|
36
|
-
if (this.storeAdapters.has(name)) {
|
|
37
|
-
console.warn(`[nvent] Store adapter "${name}" is already registered, overwriting`);
|
|
38
|
-
}
|
|
39
|
-
this.storeAdapters.set(name, adapter);
|
|
40
|
-
}
|
|
41
|
-
// ============================================================
|
|
42
|
-
// Retrieval
|
|
43
|
-
// ============================================================
|
|
44
|
-
/**
|
|
45
|
-
* Get a queue adapter by name
|
|
46
|
-
* @throws Error if adapter not found
|
|
47
|
-
*/
|
|
48
|
-
getQueue(name) {
|
|
49
|
-
const adapter = this.queueAdapters.get(name);
|
|
50
|
-
if (!adapter) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`[nvent] Queue adapter "${name}" not found. Available: ${Array.from(this.queueAdapters.keys()).join(", ")}`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return adapter;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get a stream adapter by name
|
|
59
|
-
* @throws Error if adapter not found
|
|
60
|
-
*/
|
|
61
|
-
getStream(name) {
|
|
62
|
-
const adapter = this.streamAdapters.get(name);
|
|
63
|
-
if (!adapter) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`[nvent] Stream adapter "${name}" not found. Available: ${Array.from(this.streamAdapters.keys()).join(", ")}`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
return adapter;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get a store adapter by name
|
|
72
|
-
* @throws Error if adapter not found
|
|
73
|
-
*/
|
|
74
|
-
getStore(name) {
|
|
75
|
-
const adapter = this.storeAdapters.get(name);
|
|
76
|
-
if (!adapter) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`[nvent] Store adapter "${name}" not found. Available: ${Array.from(this.storeAdapters.keys()).join(", ")}`
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
return adapter;
|
|
82
|
-
}
|
|
83
|
-
// ============================================================
|
|
84
|
-
// Utilities
|
|
85
|
-
// ============================================================
|
|
86
|
-
/**
|
|
87
|
-
* Check if a queue adapter is registered
|
|
88
|
-
*/
|
|
89
|
-
hasQueue(name) {
|
|
90
|
-
return this.queueAdapters.has(name);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Check if a stream adapter is registered
|
|
94
|
-
*/
|
|
95
|
-
hasStream(name) {
|
|
96
|
-
return this.streamAdapters.has(name);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if a store adapter is registered
|
|
100
|
-
*/
|
|
101
|
-
hasStore(name) {
|
|
102
|
-
return this.storeAdapters.has(name);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* List all registered queue adapters
|
|
106
|
-
*/
|
|
107
|
-
listQueueAdapters() {
|
|
108
|
-
return Array.from(this.queueAdapters.keys());
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* List all registered stream adapters
|
|
112
|
-
*/
|
|
113
|
-
listStreamAdapters() {
|
|
114
|
-
return Array.from(this.streamAdapters.keys());
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* List all registered store adapters
|
|
118
|
-
*/
|
|
119
|
-
listStoreAdapters() {
|
|
120
|
-
return Array.from(this.storeAdapters.keys());
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Initialize all registered adapters
|
|
124
|
-
*/
|
|
125
|
-
async initAll() {
|
|
126
|
-
const promises = [];
|
|
127
|
-
Array.from(this.queueAdapters.values()).forEach((adapter) => {
|
|
128
|
-
promises.push(adapter.init());
|
|
129
|
-
});
|
|
130
|
-
Array.from(this.streamAdapters.values()).forEach((adapter) => {
|
|
131
|
-
promises.push(adapter.init());
|
|
132
|
-
});
|
|
133
|
-
await Promise.all(promises);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Close/cleanup all registered adapters
|
|
137
|
-
*/
|
|
138
|
-
async closeAll() {
|
|
139
|
-
const promises = [];
|
|
140
|
-
Array.from(this.queueAdapters.values()).forEach((adapter) => {
|
|
141
|
-
promises.push(adapter.close());
|
|
142
|
-
});
|
|
143
|
-
Array.from(this.streamAdapters.values()).forEach((adapter) => {
|
|
144
|
-
promises.push(adapter.shutdown());
|
|
145
|
-
});
|
|
146
|
-
Array.from(this.storeAdapters.values()).forEach((adapter) => {
|
|
147
|
-
promises.push(adapter.close());
|
|
148
|
-
});
|
|
149
|
-
await Promise.all(promises);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
let registry = null;
|
|
153
|
-
export function useAdapterRegistry() {
|
|
154
|
-
if (!registry) {
|
|
155
|
-
registry = new AdapterRegistry();
|
|
156
|
-
}
|
|
157
|
-
return registry;
|
|
158
|
-
}
|
|
159
|
-
export function resetAdapterRegistry() {
|
|
160
|
-
registry = null;
|
|
161
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ModuleOptions, ModuleConfig } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Merge and normalize module options with defaults.
|
|
4
|
-
* Applies connection fallback: adapter-specific connections override connections.redis/postgres.
|
|
5
|
-
* Only includes connection defaults for adapters that are actually used.
|
|
6
|
-
*/
|
|
7
|
-
export declare function normalizeModuleOptions(options: ModuleOptions): Required<ModuleOptions>;
|
|
8
|
-
/**
|
|
9
|
-
* Convert normalized module options to runtime config format.
|
|
10
|
-
*/
|
|
11
|
-
export declare function toRuntimeConfig(normalizedOptions: Required<ModuleOptions>): ModuleConfig;
|
|
12
|
-
/**
|
|
13
|
-
* Get Redis connection config for nitro storage.
|
|
14
|
-
* Uses shared connections.redis as primary source.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getRedisStorageConfig(normalizedOptions: Required<ModuleOptions>): {
|
|
17
|
-
host: string | undefined;
|
|
18
|
-
port: number | undefined;
|
|
19
|
-
username: string | undefined;
|
|
20
|
-
password: string | undefined;
|
|
21
|
-
db: number | undefined;
|
|
22
|
-
};
|
|
23
|
-
export type { ModuleOptions, ModuleConfig } from './types.js';
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import defu from "defu";
|
|
2
|
-
export function normalizeModuleOptions(options) {
|
|
3
|
-
const defaults = {
|
|
4
|
-
dir: "functions",
|
|
5
|
-
ui: true,
|
|
6
|
-
debug: {},
|
|
7
|
-
connections: {},
|
|
8
|
-
queue: {
|
|
9
|
-
adapter: "file",
|
|
10
|
-
prefix: "nvent",
|
|
11
|
-
schema: "nvent_queue",
|
|
12
|
-
defaultJobOptions: {},
|
|
13
|
-
worker: {
|
|
14
|
-
concurrency: 2,
|
|
15
|
-
autorun: true,
|
|
16
|
-
pollingIntervalMs: 1e3
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
stream: {
|
|
20
|
-
adapter: "memory",
|
|
21
|
-
prefix: "nvent"
|
|
22
|
-
},
|
|
23
|
-
store: {
|
|
24
|
-
adapter: "file",
|
|
25
|
-
prefix: "nvent",
|
|
26
|
-
schema: "nvent_store",
|
|
27
|
-
state: {
|
|
28
|
-
autoScope: "always",
|
|
29
|
-
cleanup: {
|
|
30
|
-
strategy: "never",
|
|
31
|
-
ttlMs: 36e5
|
|
32
|
-
// 1 hour
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
eventTTL: 604800,
|
|
36
|
-
// 7 days
|
|
37
|
-
metadataTTL: 2592e3
|
|
38
|
-
// 30 days
|
|
39
|
-
},
|
|
40
|
-
flow: {
|
|
41
|
-
stallDetection: {
|
|
42
|
-
enabled: true,
|
|
43
|
-
stallTimeout: 30 * 60 * 1e3,
|
|
44
|
-
// 30 minutes
|
|
45
|
-
checkInterval: 15 * 60 * 1e3,
|
|
46
|
-
// 15 minutes
|
|
47
|
-
enablePeriodicCheck: true
|
|
48
|
-
},
|
|
49
|
-
awaitDefaults: {
|
|
50
|
-
webhookTimeout: 24 * 60 * 60 * 1e3,
|
|
51
|
-
// 24 hours
|
|
52
|
-
eventTimeout: 24 * 60 * 60 * 1e3,
|
|
53
|
-
// 24 hours
|
|
54
|
-
timeTimeout: void 0,
|
|
55
|
-
// No default timeout for time awaits
|
|
56
|
-
scheduleTimeout: void 0,
|
|
57
|
-
// No default timeout for schedule awaits
|
|
58
|
-
timeoutAction: "fail"
|
|
59
|
-
},
|
|
60
|
-
stepTimeout: 5 * 60 * 1e3
|
|
61
|
-
// 5 minutes default step execution timeout
|
|
62
|
-
},
|
|
63
|
-
webhooks: {
|
|
64
|
-
// baseUrl will be determined at runtime from Nitro context
|
|
65
|
-
// Users can override via NUXT_PUBLIC_SITE_URL or explicit config
|
|
66
|
-
baseUrl: process.env.NUXT_PUBLIC_SITE_URL || void 0
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const normalized = defu(options, defaults);
|
|
70
|
-
if (normalized.connections?.redis) {
|
|
71
|
-
console.log("[nvent-config] Redis connection after normalization:", {
|
|
72
|
-
host: normalized.connections.redis.host,
|
|
73
|
-
port: normalized.connections.redis.port
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const neededConnections = /* @__PURE__ */ new Set();
|
|
77
|
-
const queueAdapter = normalized.queue.adapter;
|
|
78
|
-
if (queueAdapter === "redis") {
|
|
79
|
-
neededConnections.add("redis");
|
|
80
|
-
} else if (queueAdapter === "postgres") {
|
|
81
|
-
neededConnections.add("postgres");
|
|
82
|
-
} else if (queueAdapter === "file") {
|
|
83
|
-
neededConnections.add("file");
|
|
84
|
-
}
|
|
85
|
-
const streamAdapter = normalized.stream.adapter;
|
|
86
|
-
if (streamAdapter === "redis") {
|
|
87
|
-
neededConnections.add("redis");
|
|
88
|
-
} else if (streamAdapter === "rabbitmq") {
|
|
89
|
-
neededConnections.add("rabbitmq");
|
|
90
|
-
} else if (streamAdapter === "kafka") {
|
|
91
|
-
neededConnections.add("kafka");
|
|
92
|
-
}
|
|
93
|
-
const storeAdapter = normalized.store.adapter;
|
|
94
|
-
if (storeAdapter === "redis") {
|
|
95
|
-
neededConnections.add("redis");
|
|
96
|
-
} else if (storeAdapter === "postgres") {
|
|
97
|
-
neededConnections.add("postgres");
|
|
98
|
-
} else if (storeAdapter === "file") {
|
|
99
|
-
neededConnections.add("file");
|
|
100
|
-
}
|
|
101
|
-
if (!normalized.connections) {
|
|
102
|
-
normalized.connections = {};
|
|
103
|
-
}
|
|
104
|
-
if (neededConnections.has("redis") && !normalized.connections.redis) {
|
|
105
|
-
normalized.connections.redis = {
|
|
106
|
-
host: process.env.REDIS_HOST || "127.0.0.1",
|
|
107
|
-
port: Number.parseInt(process.env.REDIS_PORT || "6379", 10),
|
|
108
|
-
password: process.env.REDIS_PASSWORD,
|
|
109
|
-
username: process.env.REDIS_USERNAME,
|
|
110
|
-
db: process.env.REDIS_DB ? Number.parseInt(process.env.REDIS_DB, 10) : 0
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
if (neededConnections.has("postgres") && !normalized.connections.postgres) {
|
|
114
|
-
normalized.connections.postgres = {
|
|
115
|
-
connectionString: process.env.DATABASE_URL || "postgresql://localhost:5432/nvent"
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
if (neededConnections.has("rabbitmq") && !normalized.connections.rabbitmq) {
|
|
119
|
-
normalized.connections.rabbitmq = {
|
|
120
|
-
host: "localhost",
|
|
121
|
-
port: 5672
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
if (neededConnections.has("kafka") && !normalized.connections.kafka) {
|
|
125
|
-
normalized.connections.kafka = {
|
|
126
|
-
brokers: ["localhost:9092"]
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
if (neededConnections.has("file") && !normalized.connections.file) {
|
|
130
|
-
normalized.connections.file = {
|
|
131
|
-
dataDir: ".data"
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
applyConnectionFallback(normalized);
|
|
135
|
-
return normalized;
|
|
136
|
-
}
|
|
137
|
-
function applyConnectionFallback(config) {
|
|
138
|
-
if (!config.queue.redis && config.connections.redis) {
|
|
139
|
-
config.queue.redis = config.connections.redis;
|
|
140
|
-
}
|
|
141
|
-
if (!config.queue.postgres && config.connections.postgres) {
|
|
142
|
-
config.queue.postgres = config.connections.postgres;
|
|
143
|
-
}
|
|
144
|
-
if (!config.queue.file && config.connections.file) {
|
|
145
|
-
config.queue.file = {
|
|
146
|
-
dataDir: `${config.connections.file.dataDir}/queue`
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
if (!config.stream.redis && config.connections.redis) {
|
|
150
|
-
config.stream.redis = config.connections.redis;
|
|
151
|
-
}
|
|
152
|
-
if (!config.stream.rabbitmq && config.connections.rabbitmq) {
|
|
153
|
-
config.stream.rabbitmq = config.connections.rabbitmq;
|
|
154
|
-
}
|
|
155
|
-
if (!config.stream.kafka && config.connections.kafka) {
|
|
156
|
-
config.stream.kafka = config.connections.kafka;
|
|
157
|
-
}
|
|
158
|
-
if (!config.store.redis && config.connections.redis) {
|
|
159
|
-
config.store.redis = config.connections.redis;
|
|
160
|
-
}
|
|
161
|
-
if (!config.store.postgres && config.connections.postgres) {
|
|
162
|
-
config.store.postgres = config.connections.postgres;
|
|
163
|
-
}
|
|
164
|
-
if (!config.store.file && config.connections.file) {
|
|
165
|
-
config.store.file = {
|
|
166
|
-
dataDir: `${config.connections.file.dataDir}/store`
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
export function toRuntimeConfig(normalizedOptions) {
|
|
171
|
-
return {
|
|
172
|
-
debug: normalizedOptions.debug,
|
|
173
|
-
rootDir: void 0,
|
|
174
|
-
queue: normalizedOptions.queue,
|
|
175
|
-
stream: normalizedOptions.stream,
|
|
176
|
-
store: normalizedOptions.store,
|
|
177
|
-
connections: normalizedOptions.connections,
|
|
178
|
-
flow: normalizedOptions.flow,
|
|
179
|
-
webhooks: normalizedOptions.webhooks
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
export function getRedisStorageConfig(normalizedOptions) {
|
|
183
|
-
const redisConfig = normalizedOptions.connections.redis;
|
|
184
|
-
if (!redisConfig) {
|
|
185
|
-
return {
|
|
186
|
-
host: process.env.REDIS_HOST || "127.0.0.1",
|
|
187
|
-
port: Number.parseInt(process.env.REDIS_PORT || "6379", 10),
|
|
188
|
-
username: process.env.REDIS_USERNAME,
|
|
189
|
-
password: process.env.REDIS_PASSWORD,
|
|
190
|
-
db: process.env.REDIS_DB ? Number.parseInt(process.env.REDIS_DB, 10) : 0
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
host: redisConfig.host,
|
|
195
|
-
port: redisConfig.port,
|
|
196
|
-
username: redisConfig.username,
|
|
197
|
-
password: redisConfig.password,
|
|
198
|
-
db: redisConfig.db
|
|
199
|
-
};
|
|
200
|
-
}
|