nvent 1.0.0-alpha.11 → 1.0.0-alpha.12
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 +293 -338
- package/dist/module.json +1 -1
- package/dist/module.mjs +180 -48
- package/dist/runtime/nitro/server.d.ts +3 -2
- package/dist/runtime/nitro/server.js +2 -1
- package/dist/runtime/nitro/utils/engine.d.ts +2 -0
- package/dist/runtime/nitro/utils/engine.js +9 -2
- package/dist/runtime/python/nvent.py +39 -7
- package/dist/runtime/python/worker_runtime.py +17 -4
- package/dist/runtime/virtual.d.ts +3 -2
- package/package.json +11 -10
package/dist/module.d.mts
CHANGED
|
@@ -40,345 +40,300 @@ type NventQueueConfig = {
|
|
|
40
40
|
* `iii/config.ts` can import them without creating a circular dependency with
|
|
41
41
|
* `module.ts`.
|
|
42
42
|
*/
|
|
43
|
+
|
|
43
44
|
interface NventIiiOptions {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
telemetry?: {
|
|
337
|
-
enabled?: boolean;
|
|
338
|
-
apiKey?: string;
|
|
339
|
-
sdkApiKey?: string;
|
|
340
|
-
heartbeatIntervalSecs?: number;
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
functions?: {
|
|
344
|
-
/** Directory under server/ where functions are, relative to serverDir (default: 'functions') */
|
|
345
|
-
dir?: string;
|
|
346
|
-
/**
|
|
347
|
-
* Function ID prefix for this layer's functions.
|
|
348
|
-
* Set in a layer's `nuxt.config.ts` to namespace its functions.
|
|
349
|
-
* Priority: this value → `$meta.name` → package.json name → directory name.
|
|
350
|
-
* Set to `''` (empty string) to explicitly opt out of any prefix.
|
|
351
|
-
* Has no effect in the root project (always un-prefixed).
|
|
352
|
-
* Example: 'myorg::auth'
|
|
353
|
-
*/
|
|
354
|
-
prefix?: string;
|
|
355
|
-
python?: {
|
|
356
|
-
/**
|
|
357
|
-
* Path to the Python executable used **in development only** (e.g. a virtualenv).
|
|
358
|
-
* Has no effect in production — set `NVENT_PYTHON_BIN` env var instead.
|
|
359
|
-
* Default: 'python3'
|
|
360
|
-
* Example: '.venv/bin/python3'
|
|
361
|
-
*/
|
|
362
|
-
devPath?: string;
|
|
363
|
-
/**
|
|
364
|
-
* Skip Python worker support entirely (no Python scanning, no workers started).
|
|
365
|
-
* Useful when the project has no Python functions. Default: false
|
|
366
|
-
*/
|
|
367
|
-
skip?: boolean;
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
|
-
app?: {
|
|
371
|
-
/** Enable the nvent app UI and its built-in route. Default: true */
|
|
372
|
-
enabled?: boolean;
|
|
373
|
-
/** Route path for the nvent app. Default: '/_nvent' */
|
|
374
|
-
routePath?: string;
|
|
375
|
-
/**
|
|
376
|
-
* Layout to use for the nvent app route.
|
|
377
|
-
* Set to false for no layout, or a string to use a named layout.
|
|
378
|
-
* Default: false
|
|
379
|
-
*/
|
|
380
|
-
layout?: string | false;
|
|
381
|
-
};
|
|
45
|
+
iii?: {
|
|
46
|
+
/** Version of the iii engine to install. Default: 'latest' */
|
|
47
|
+
version?: string
|
|
48
|
+
/** 'local' uses a local binary, 'docker' uses Docker, 'remote' skips lifecycle management */
|
|
49
|
+
mode?: 'local' | 'docker' | 'remote'
|
|
50
|
+
/** WebSocket URL for workers to connect to (default: ws://localhost:49134) */
|
|
51
|
+
wsUrl?: string
|
|
52
|
+
/** HTTP port for iii REST API (default: 3111) */
|
|
53
|
+
httpPort?: number
|
|
54
|
+
/** HTTP host for iii REST API (default: 'localhost') */
|
|
55
|
+
httpHost?: string
|
|
56
|
+
/** WebSocket port for workers (default: 49134) */
|
|
57
|
+
wsPort?: number
|
|
58
|
+
/** WebSocket port for the Stream module (default: 3112) */
|
|
59
|
+
streamPort?: number
|
|
60
|
+
/** Whether nvent manages engine lifecycle. Default: true in dev, false in prod */
|
|
61
|
+
managed?: boolean
|
|
62
|
+
/** Exit with non-zero code if engine installation fails. Default: false */
|
|
63
|
+
failOnInstallFailure?: boolean
|
|
64
|
+
modules?: {
|
|
65
|
+
state?: boolean
|
|
66
|
+
queue?: boolean
|
|
67
|
+
cron?: boolean
|
|
68
|
+
observability?: boolean
|
|
69
|
+
stream?: boolean
|
|
70
|
+
}
|
|
71
|
+
/** State module adapter configuration */
|
|
72
|
+
state?: {
|
|
73
|
+
adapter?:
|
|
74
|
+
| { type: 'kv'; storeMethod?: 'file_based' | 'in_memory'; filePath?: string; saveIntervalMs?: number }
|
|
75
|
+
| { type: 'redis'; redisUrl?: string }
|
|
76
|
+
| { type: 'bridge'; bridgeUrl: string }
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Queue module configuration.
|
|
80
|
+
* Named queues must be declared here for the iii engine to route messages through them.
|
|
81
|
+
*/
|
|
82
|
+
queue?: {
|
|
83
|
+
adapter?:
|
|
84
|
+
| {
|
|
85
|
+
type: 'builtin'
|
|
86
|
+
storeMethod?: 'file_based' | 'in_memory'
|
|
87
|
+
filePath?: string
|
|
88
|
+
saveIntervalMs?: number
|
|
89
|
+
maxAttempts?: number
|
|
90
|
+
backoffMs?: number
|
|
91
|
+
concurrency?: number
|
|
92
|
+
pollIntervalMs?: number
|
|
93
|
+
/** Processing order. 'concurrent' (parallel) or 'fifo' (sequential). Default: 'concurrent' */
|
|
94
|
+
mode?: 'concurrent' | 'fifo'
|
|
95
|
+
}
|
|
96
|
+
| { type: 'redis'; redisUrl?: string }
|
|
97
|
+
| {
|
|
98
|
+
type: 'rabbitmq'
|
|
99
|
+
amqpUrl?: string
|
|
100
|
+
maxAttempts?: number
|
|
101
|
+
prefetchCount?: number
|
|
102
|
+
/** 'standard' or 'quorum' (HA replicated). Default: 'standard' */
|
|
103
|
+
queueMode?: 'standard' | 'quorum'
|
|
104
|
+
}
|
|
105
|
+
| { type: 'bridge'; bridgeUrl: string }
|
|
106
|
+
queueConfigs?: Record<string, {
|
|
107
|
+
type?: 'standard' | 'fifo'
|
|
108
|
+
concurrency?: number
|
|
109
|
+
/** Alias of maxRetries */
|
|
110
|
+
retries?: number
|
|
111
|
+
maxRetries?: number
|
|
112
|
+
/** Alias of backoffMs */
|
|
113
|
+
backoff?: number
|
|
114
|
+
backoffMs?: number
|
|
115
|
+
/** Optional visibility timeout / lease timeout if supported by the engine */
|
|
116
|
+
visibilityTimeoutMs?: number
|
|
117
|
+
leaseTimeoutMs?: number
|
|
118
|
+
/** Optional dead-letter / fallback queue names if supported by the engine */
|
|
119
|
+
deadLetterQueue?: string
|
|
120
|
+
fallbackQueue?: string
|
|
121
|
+
/** FIFO only: field in the payload used to group messages */
|
|
122
|
+
messageGroupField?: string
|
|
123
|
+
}>
|
|
124
|
+
}
|
|
125
|
+
/** Cron module adapter configuration */
|
|
126
|
+
cron?: {
|
|
127
|
+
adapter?:
|
|
128
|
+
| { type: 'kv'; lockTtlMs?: number; lockIndex?: string; storeMethod?: 'file_based' | 'in_memory'; filePath?: string; saveIntervalMs?: number }
|
|
129
|
+
| { type: 'redis'; redisUrl?: string }
|
|
130
|
+
}
|
|
131
|
+
/** WebSocket Stream module configuration */
|
|
132
|
+
stream?: {
|
|
133
|
+
host?: string
|
|
134
|
+
authFunction?: string | null
|
|
135
|
+
adapter?:
|
|
136
|
+
| { type: 'kv'; storeMethod?: 'file_based' | 'in_memory'; filePath?: string; saveIntervalMs?: number }
|
|
137
|
+
| { type: 'redis'; redisUrl?: string }
|
|
138
|
+
| { type: 'bridge'; bridgeUrl: string }
|
|
139
|
+
}
|
|
140
|
+
/** REST API module extra settings */
|
|
141
|
+
restApi?: {
|
|
142
|
+
host?: string
|
|
143
|
+
defaultTimeout?: number
|
|
144
|
+
concurrencyRequestLimit?: number
|
|
145
|
+
/** CORS configuration for browser clients */
|
|
146
|
+
cors?: {
|
|
147
|
+
/** Origins allowed to make requests. Use '*' for any, or list specific domains. */
|
|
148
|
+
allowedOrigins?: string[]
|
|
149
|
+
/** HTTP methods permitted for cross-origin requests. */
|
|
150
|
+
allowedMethods?: string[]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** OtelModule (observability) configuration */
|
|
154
|
+
observability?: {
|
|
155
|
+
enabled?: boolean
|
|
156
|
+
serviceName?: string
|
|
157
|
+
serviceVersion?: string
|
|
158
|
+
serviceNamespace?: string
|
|
159
|
+
/**
|
|
160
|
+
* Trace export destination.
|
|
161
|
+
* 'memory' = queryable via iii API / console (default).
|
|
162
|
+
* 'otlp' = external collector (set endpoint too).
|
|
163
|
+
* 'both' = memory + otlp.
|
|
164
|
+
*/
|
|
165
|
+
exporter?: 'memory' | 'otlp' | 'both'
|
|
166
|
+
endpoint?: string
|
|
167
|
+
samplingRatio?: number
|
|
168
|
+
memoryMaxSpans?: number
|
|
169
|
+
metricsEnabled?: boolean
|
|
170
|
+
metricsExporter?: 'memory' | 'otlp'
|
|
171
|
+
metricsRetentionSeconds?: number
|
|
172
|
+
metricsMaxCount?: number
|
|
173
|
+
logsEnabled?: boolean
|
|
174
|
+
logsExporter?: 'memory' | 'otlp' | 'both'
|
|
175
|
+
logsMaxCount?: number
|
|
176
|
+
logsRetentionSeconds?: number
|
|
177
|
+
logsBatchSize?: number
|
|
178
|
+
logsFlushIntervalMs?: number
|
|
179
|
+
logsSamplingRatio?: number
|
|
180
|
+
logsConsoleOutput?: boolean
|
|
181
|
+
/** Advanced sampling rules — override samplingRatio for matched operations. */
|
|
182
|
+
sampling?: {
|
|
183
|
+
default?: number
|
|
184
|
+
parentBased?: boolean
|
|
185
|
+
rules?: Array<{ operation?: string; service?: string; rate: number }>
|
|
186
|
+
rateLimit?: { maxTracesPerSecond?: number }
|
|
187
|
+
}
|
|
188
|
+
/** Alert rules — trigger a webhook or function when a metric crosses a threshold. */
|
|
189
|
+
alerts?: Array<{
|
|
190
|
+
name: string
|
|
191
|
+
metric: string
|
|
192
|
+
threshold: number
|
|
193
|
+
operator: '>' | '>=' | '<' | '<=' | '==' | '!='
|
|
194
|
+
windowSeconds: number
|
|
195
|
+
enabled?: boolean
|
|
196
|
+
cooldownSeconds?: number
|
|
197
|
+
action: { type: 'webhook'; url: string } | { type: 'function'; path: string }
|
|
198
|
+
}>
|
|
199
|
+
level?: 'trace' | 'debug' | 'info' | 'warn' | 'error'
|
|
200
|
+
format?: 'default' | 'json'
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Minimum log level for iii engine output.
|
|
204
|
+
* 'none' silences all output, 'error' shows only errors, 'warn' shows warnings + errors,
|
|
205
|
+
* 'info' shows everything. Default: 'warn'
|
|
206
|
+
*/
|
|
207
|
+
logLevel?: 'none' | 'error' | 'warn' | 'info'
|
|
208
|
+
/**
|
|
209
|
+
* Enable the iii-console web UI (separate binary, http://localhost:3113).
|
|
210
|
+
* Pass `true` for defaults or an object to customise.
|
|
211
|
+
*/
|
|
212
|
+
console?: boolean | {
|
|
213
|
+
/** Version to install. Default: same as iii engine version */
|
|
214
|
+
version?: string
|
|
215
|
+
/** Port for the console web UI. Default: 3113 */
|
|
216
|
+
port?: number
|
|
217
|
+
/** Host for the console web UI. Default: 'localhost' */
|
|
218
|
+
host?: string
|
|
219
|
+
/** Enable the Flow visualization page */
|
|
220
|
+
flow?: boolean
|
|
221
|
+
}
|
|
222
|
+
/** PubSub worker — topic-based event fanout across functions. */
|
|
223
|
+
pubsub?: {
|
|
224
|
+
adapter?:
|
|
225
|
+
| { type: 'local' }
|
|
226
|
+
| { type: 'redis'; redisUrl?: string }
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* HTTP Functions worker — enables outbound HTTP calls from the engine.
|
|
230
|
+
* Required for functions registered with HttpInvocationConfig.
|
|
231
|
+
*/
|
|
232
|
+
httpFunctions?: {
|
|
233
|
+
security?: {
|
|
234
|
+
/** URL patterns allowed for outbound requests. Use '*' to allow all. */
|
|
235
|
+
urlAllowlist?: string[]
|
|
236
|
+
/** Block requests to private/internal IP ranges (SSRF prevention). Default: true */
|
|
237
|
+
blockPrivateIps?: boolean
|
|
238
|
+
/** Require HTTPS for all outbound requests. Default: true */
|
|
239
|
+
requireHttps?: boolean
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Additional iii-worker-manager instance with RBAC.
|
|
244
|
+
* nvent uses this automatically when browser SDK is enabled.
|
|
245
|
+
* Can also be configured manually for custom auth scenarios.
|
|
246
|
+
*/
|
|
247
|
+
workerManager?: {
|
|
248
|
+
rbac?: {
|
|
249
|
+
/** Port for the RBAC worker manager. Default: 49135 */
|
|
250
|
+
port?: number
|
|
251
|
+
/** Function ID called on every WebSocket upgrade for auth. */
|
|
252
|
+
authFunctionId?: string
|
|
253
|
+
/** Functions the connecting worker is allowed to invoke (patterns supported). */
|
|
254
|
+
exposeFunctions?: string[]
|
|
255
|
+
/** Function invoked before each handler — enrich or audit requests. */
|
|
256
|
+
middlewareFunctionId?: string
|
|
257
|
+
/** Allow workers to register their own function handlers. Default: true */
|
|
258
|
+
allowFunctionRegistration?: boolean
|
|
259
|
+
/** Allow workers to register new trigger types. Default: false */
|
|
260
|
+
allowTriggerTypeRegistration?: boolean
|
|
261
|
+
/** Prefix prepended to every function the worker registers. */
|
|
262
|
+
functionRegistrationPrefix?: string
|
|
263
|
+
/** TTL for signed browser auth tokens generated by the Nuxt proxy. Default: 120 */
|
|
264
|
+
tokenTtlSeconds?: number
|
|
265
|
+
/** Allow browser connections without a custom resolver returning user context. Default: true */
|
|
266
|
+
allowAnonymous?: boolean
|
|
267
|
+
/** Optional path (relative to project root) to a custom browser auth resolver module. */
|
|
268
|
+
authResolverPath?: string
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Bridge client workers — connects this engine to remote iii instances.
|
|
273
|
+
* Each entry creates an `iii-bridge` worker in the config.
|
|
274
|
+
*/
|
|
275
|
+
bridge?: Array<{
|
|
276
|
+
url: string
|
|
277
|
+
serviceId: string
|
|
278
|
+
serviceName?: string
|
|
279
|
+
expose?: Array<{ localFunction: string; remoteFunction?: string }>
|
|
280
|
+
forward?: Array<{ localFunction: string; remoteFunction: string; timeoutMs?: number }>
|
|
281
|
+
}>
|
|
282
|
+
/**
|
|
283
|
+
* Exec workers — spawns external processes alongside the engine.
|
|
284
|
+
* Each entry creates an `iii-exec` worker in the config.
|
|
285
|
+
*/
|
|
286
|
+
exec?: Array<{
|
|
287
|
+
watch?: string[]
|
|
288
|
+
exec: string[]
|
|
289
|
+
}>
|
|
290
|
+
/** Anonymous usage telemetry. Set enabled: false to opt out. */
|
|
291
|
+
telemetry?: {
|
|
292
|
+
enabled?: boolean
|
|
293
|
+
apiKey?: string
|
|
294
|
+
sdkApiKey?: string
|
|
295
|
+
heartbeatIntervalSecs?: number
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
functions?: {
|
|
299
|
+
/** Directory under server/ where functions are, relative to serverDir (default: 'functions') */
|
|
300
|
+
dir?: string
|
|
301
|
+
/**
|
|
302
|
+
* Function ID prefix for this layer's functions.
|
|
303
|
+
* Set in a layer's `nuxt.config.ts` to namespace its functions.
|
|
304
|
+
* Priority: this value → `$meta.name` → package.json name → directory name.
|
|
305
|
+
* Set to `''` (empty string) to explicitly opt out of any prefix.
|
|
306
|
+
* Has no effect in the root project (always un-prefixed).
|
|
307
|
+
* Example: 'myorg::auth'
|
|
308
|
+
*/
|
|
309
|
+
prefix?: string
|
|
310
|
+
python?: {
|
|
311
|
+
/**
|
|
312
|
+
* Path to the Python executable used **in development only** (e.g. a virtualenv).
|
|
313
|
+
* Has no effect in production — set `NVENT_PYTHON_BIN` env var instead.
|
|
314
|
+
* Default: 'python3'
|
|
315
|
+
* Example: '.venv/bin/python3'
|
|
316
|
+
*/
|
|
317
|
+
devPath?: string
|
|
318
|
+
/**
|
|
319
|
+
* Skip Python worker support entirely (no Python scanning, no workers started).
|
|
320
|
+
* Useful when the project has no Python functions. Default: false
|
|
321
|
+
*/
|
|
322
|
+
skip?: boolean
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
app?: {
|
|
326
|
+
/** Enable the nvent app UI and its built-in route. Default: true */
|
|
327
|
+
enabled?: boolean
|
|
328
|
+
/** Route path for the nvent app. Default: '/_nvent' */
|
|
329
|
+
routePath?: string
|
|
330
|
+
/**
|
|
331
|
+
* Layout to use for the nvent app route.
|
|
332
|
+
* Set to false for no layout, or a string to use a named layout.
|
|
333
|
+
* Default: false
|
|
334
|
+
*/
|
|
335
|
+
layout?: string | false
|
|
336
|
+
}
|
|
382
337
|
}
|
|
383
338
|
|
|
384
339
|
interface LayerInfo {
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -699,8 +699,100 @@ async function ensureIiiEngine(options) {
|
|
|
699
699
|
if (!existsSync(binDir)) {
|
|
700
700
|
mkdirSync(binDir, { recursive: true });
|
|
701
701
|
}
|
|
702
|
-
|
|
703
|
-
|
|
702
|
+
getPlatformAsset(version);
|
|
703
|
+
const tried = [];
|
|
704
|
+
async function tryDownloadForVersion(ver) {
|
|
705
|
+
try {
|
|
706
|
+
const a = getPlatformAsset(ver);
|
|
707
|
+
tried.push(a.url);
|
|
708
|
+
await downloadAndExtract(a.url, a.ext, binDir, logLevel);
|
|
709
|
+
return true;
|
|
710
|
+
} catch (err) {
|
|
711
|
+
if (logLevel === "info") logger$1.info(`Download for ${ver} failed: ${String(err)}`);
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
let downloaded = false;
|
|
716
|
+
downloaded = await tryDownloadForVersion(version);
|
|
717
|
+
if (!downloaded && !version.includes("/")) {
|
|
718
|
+
const releaseTag = toReleaseTag$1(version);
|
|
719
|
+
const variants = [
|
|
720
|
+
`iii/${releaseTag}`,
|
|
721
|
+
releaseTag,
|
|
722
|
+
semverFromTag$1(releaseTag),
|
|
723
|
+
`iii/${semverFromTag$1(releaseTag)}`
|
|
724
|
+
];
|
|
725
|
+
for (const v of variants) {
|
|
726
|
+
if (downloaded) break;
|
|
727
|
+
if (v === version) continue;
|
|
728
|
+
downloaded = await tryDownloadForVersion(v);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (!downloaded) {
|
|
732
|
+
const candidateTags = [version];
|
|
733
|
+
if (!version.includes("/")) candidateTags.push(toReleaseTag$1(version), `iii/${toReleaseTag$1(version)}`);
|
|
734
|
+
for (const tag of candidateTags) {
|
|
735
|
+
try {
|
|
736
|
+
const apiUrl = `https://api.github.com/repos/iii-hq/iii/releases/tags/${encodeURIComponent(tag)}`;
|
|
737
|
+
if (logLevel === "info") logger$1.info(`Querying GitHub Release: ${apiUrl}`);
|
|
738
|
+
const res = await fetch(apiUrl, { headers: { "Accept": "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28" } });
|
|
739
|
+
if (!res.ok) {
|
|
740
|
+
if (logLevel === "info") logger$1.info(`GitHub API responded ${res.status} ${res.statusText} for tag ${tag}`);
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
const data = await res.json();
|
|
744
|
+
const assets = Array.isArray(data.assets) ? data.assets : [];
|
|
745
|
+
const platformCandidates = [
|
|
746
|
+
"x86_64-unknown-linux-gnu",
|
|
747
|
+
"aarch64-unknown-linux-gnu",
|
|
748
|
+
"x86_64-apple-darwin",
|
|
749
|
+
"aarch64-apple-darwin",
|
|
750
|
+
"x86_64-pc-windows-msvc",
|
|
751
|
+
"aarch64-pc-windows-msvc"
|
|
752
|
+
];
|
|
753
|
+
const match = assets.find((a) => platformCandidates.some((p) => a.name.includes(p)));
|
|
754
|
+
if (match && match.browser_download_url) {
|
|
755
|
+
if (logLevel === "info") logger$1.info(`Found asset via GitHub API: ${match.name}`);
|
|
756
|
+
await downloadAndExtract(match.browser_download_url, match.name.endsWith(".zip") ? "zip" : "tar.gz", binDir, logLevel);
|
|
757
|
+
downloaded = true;
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
} catch (err) {
|
|
761
|
+
if (logLevel === "info") logger$1.info(`GitHub API lookup failed for tag ${tag}: ${String(err)}`);
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (!downloaded) {
|
|
767
|
+
try {
|
|
768
|
+
const releasesRes = await fetch("https://api.github.com/repos/iii-hq/iii/releases?per_page=50", {
|
|
769
|
+
headers: { "Accept": "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28" }
|
|
770
|
+
});
|
|
771
|
+
let tags = [];
|
|
772
|
+
if (releasesRes.ok) {
|
|
773
|
+
const releases = await releasesRes.json();
|
|
774
|
+
tags = releases.map((r) => r.tag_name).filter(Boolean);
|
|
775
|
+
} else {
|
|
776
|
+
try {
|
|
777
|
+
const tagsRes = await fetch("https://api.github.com/repos/iii-hq/iii/tags?per_page=50", {
|
|
778
|
+
headers: { "Accept": "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28" }
|
|
779
|
+
});
|
|
780
|
+
if (tagsRes.ok) {
|
|
781
|
+
const tagsData = await tagsRes.json();
|
|
782
|
+
tags = tagsData.map((t) => t.name).filter(Boolean);
|
|
783
|
+
}
|
|
784
|
+
} catch {
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const shown = tags.slice(0, 20);
|
|
788
|
+
const tagPart = shown.length ? ` Available release tags (first ${shown.length}): ${shown.join(", ")}.` : "";
|
|
789
|
+
throw new Error(
|
|
790
|
+
`Failed to download iii engine from tried URLs: ${tried.join(", ")}.` + tagPart + ` Set a matching 'nvent.iii.version' in your nuxt config (e.g. 'iii/v0.22.1' or 'v0.22.1').`
|
|
791
|
+
);
|
|
792
|
+
} catch (err) {
|
|
793
|
+
throw new Error(`Failed to download iii engine from tried URLs: ${tried.join(", ")}. (${String(err)})`);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
704
796
|
if (process.platform !== "win32") {
|
|
705
797
|
chmodSync(binaryPath, 493);
|
|
706
798
|
}
|
|
@@ -1352,6 +1444,7 @@ const module$1 = defineNuxtModule({
|
|
|
1352
1444
|
const managed = iiiOpts.managed ?? mode === "local";
|
|
1353
1445
|
const version = iiiOpts.version ?? "latest";
|
|
1354
1446
|
const logLevel = iiiOpts.logLevel ?? "warn";
|
|
1447
|
+
const failOnInstallFailure = iiiOpts.failOnInstallFailure ?? false;
|
|
1355
1448
|
const consoleCfg = typeof iiiOpts.console === "object" ? iiiOpts.console : {};
|
|
1356
1449
|
installNventPyToSitePackages(pythonBin, readFileSync(PYTHON_NVENT_HELPER_SRC, "utf-8"));
|
|
1357
1450
|
if (hasNuxtModule("@nvent-addon/app")) {
|
|
@@ -1547,44 +1640,74 @@ const module$1 = defineNuxtModule({
|
|
|
1547
1640
|
const nventDir = join(nuxt.options.rootDir, "node_modules", ".nvent");
|
|
1548
1641
|
const binDir = join(nventDir, "bin");
|
|
1549
1642
|
if (managed && mode === "local") {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
const
|
|
1568
|
-
binaryPath
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1643
|
+
let binaryPath;
|
|
1644
|
+
let consoleBinaryPath;
|
|
1645
|
+
try {
|
|
1646
|
+
binaryPath = await ensureIiiEngine({ binDir, version, logLevel });
|
|
1647
|
+
consoleBinaryPath = iiiOpts.console ? await ensureIiiConsole({ binDir, version: consoleCfg.version ?? version, logLevel }) : void 0;
|
|
1648
|
+
} catch (err) {
|
|
1649
|
+
console.error("[nvent] III engine installation failed \u2014 skipping engine start. Error:");
|
|
1650
|
+
if (err && err.stack) console.error(err.stack);
|
|
1651
|
+
else console.error(JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
1652
|
+
if (failOnInstallFailure) {
|
|
1653
|
+
console.error("[nvent] failOnInstallFailure enabled \u2014 aborting startup.");
|
|
1654
|
+
process.exit(1);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
if (binaryPath) {
|
|
1658
|
+
const nventConfigPath = join(nventDir, "iii-config.yaml");
|
|
1659
|
+
writeIiiConfig(nventConfigPath, engineCfg);
|
|
1660
|
+
const engine = createEngineManager({
|
|
1661
|
+
binaryPath,
|
|
1662
|
+
configPath: nventConfigPath,
|
|
1663
|
+
httpPort: engineCfg.httpPort,
|
|
1664
|
+
wsPort: engineCfg.wsPort,
|
|
1665
|
+
workingDir: nventDir,
|
|
1573
1666
|
logLevel
|
|
1574
1667
|
});
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1668
|
+
try {
|
|
1669
|
+
await engine.start();
|
|
1670
|
+
nuxt.hook("close", async () => {
|
|
1671
|
+
await engine.stop();
|
|
1672
|
+
});
|
|
1673
|
+
} catch (err) {
|
|
1674
|
+
console.error("[nvent] Failed to start iii engine \u2014 continuing without engine. Error:");
|
|
1675
|
+
if (err && err.stack) console.error(err.stack);
|
|
1676
|
+
else console.error(JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
1677
|
+
if (failOnInstallFailure) {
|
|
1678
|
+
console.error("[nvent] failOnInstallFailure enabled \u2014 aborting startup.");
|
|
1679
|
+
process.exit(1);
|
|
1586
1680
|
}
|
|
1587
|
-
}
|
|
1681
|
+
}
|
|
1682
|
+
if (consoleBinaryPath) {
|
|
1683
|
+
const consolePort = consoleCfg.port ?? 3113;
|
|
1684
|
+
const consoleManager = new ConsoleManager({
|
|
1685
|
+
binaryPath: consoleBinaryPath,
|
|
1686
|
+
port: consolePort,
|
|
1687
|
+
enginePort: engineCfg.httpPort,
|
|
1688
|
+
bridgePort: engineCfg.wsPort,
|
|
1689
|
+
flow: consoleCfg.flow ?? true,
|
|
1690
|
+
logLevel
|
|
1691
|
+
});
|
|
1692
|
+
try {
|
|
1693
|
+
await consoleManager.start();
|
|
1694
|
+
nuxt.hook("close", async () => {
|
|
1695
|
+
await consoleManager.stop();
|
|
1696
|
+
});
|
|
1697
|
+
addCustomTab({
|
|
1698
|
+
name: "nvent-console",
|
|
1699
|
+
title: "nvent",
|
|
1700
|
+
icon: "carbon:flow",
|
|
1701
|
+
view: {
|
|
1702
|
+
type: "iframe",
|
|
1703
|
+
src: `http://localhost:${consolePort}`
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
} catch (err) {
|
|
1707
|
+
console.error("[nvent] Failed to start iii console UI \u2014 continuing. Error:");
|
|
1708
|
+
console.error(err && err.message ? err.message : err);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1588
1711
|
}
|
|
1589
1712
|
}
|
|
1590
1713
|
if (!skipPython) {
|
|
@@ -1630,17 +1753,26 @@ const module$1 = defineNuxtModule({
|
|
|
1630
1753
|
} else {
|
|
1631
1754
|
if (managed && mode === "local") {
|
|
1632
1755
|
const binDir = join(nuxt.options.rootDir, "node_modules", ".nvent", "bin");
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1756
|
+
let binaryPath;
|
|
1757
|
+
let consoleBinaryPath;
|
|
1758
|
+
try {
|
|
1759
|
+
binaryPath = await ensureIiiEngine({ binDir, version, logLevel });
|
|
1760
|
+
consoleBinaryPath = iiiOpts.console ? await ensureIiiConsole({ binDir, version: consoleCfg.version ?? version, logLevel }) : void 0;
|
|
1761
|
+
} catch (err) {
|
|
1762
|
+
console.warn("[nvent] Could not download iii engine for build embedding \u2014 skipping binary copy. Error:");
|
|
1763
|
+
console.warn(err && err.message ? err.message : err);
|
|
1764
|
+
}
|
|
1765
|
+
if (binaryPath) {
|
|
1766
|
+
nuxt.hook("nitro:build:public-assets", async (nitro) => {
|
|
1767
|
+
const outputNventDir = join(nitro.options.output.dir, "nvent");
|
|
1768
|
+
const outputBinDir = join(outputNventDir, "bin");
|
|
1769
|
+
mkdirSync(outputBinDir, { recursive: true });
|
|
1770
|
+
copyFileSync(binaryPath, join(outputBinDir, basename(binaryPath)));
|
|
1771
|
+
if (consoleBinaryPath) copyFileSync(consoleBinaryPath, join(outputBinDir, basename(consoleBinaryPath)));
|
|
1772
|
+
writeFileSync(join(outputNventDir, "iii-config.yaml"), engineConfigYaml, "utf-8");
|
|
1773
|
+
console.log("[nvent] Engine binaries + config copied to .output/nvent/");
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1644
1776
|
}
|
|
1645
1777
|
if (!skipPython) {
|
|
1646
1778
|
nuxt.hook("nitro:build:public-assets", async (nitro) => {
|
|
@@ -10,5 +10,6 @@
|
|
|
10
10
|
export { defineFunction } from './utils/defineFunction.js';
|
|
11
11
|
export type { FunctionDef, FunctionHandler, TriggerConfig, HttpTriggerConfig, CronTriggerConfig, QueueTriggerConfig, StateTriggerConfig, StreamTriggerConfig, SubscribeTriggerConfig, LogTriggerConfig, CustomTriggerConfig, HttpRequest, } from './utils/defineFunction.js';
|
|
12
12
|
export { useIii, useIiiHealth } from './utils/useIii.js';
|
|
13
|
-
export {
|
|
14
|
-
export
|
|
13
|
+
export { registerWorker, TriggerAction } from 'iii-sdk';
|
|
14
|
+
export { Logger } from '@iii-dev/helpers/observability';
|
|
15
|
+
export type { IIIClient, InitOptions } from 'iii-sdk';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { defineFunction } from "./utils/defineFunction.js";
|
|
2
2
|
export { useIii, useIiiHealth } from "./utils/useIii.js";
|
|
3
|
-
export {
|
|
3
|
+
export { registerWorker, TriggerAction } from "iii-sdk";
|
|
4
|
+
export { Logger } from "@iii-dev/helpers/observability";
|
|
@@ -10,6 +10,8 @@ export interface EngineManagerOptions {
|
|
|
10
10
|
configPath: string;
|
|
11
11
|
httpPort?: number;
|
|
12
12
|
wsPort?: number;
|
|
13
|
+
/** Working directory for the engine process. Defaults to process.cwd() */
|
|
14
|
+
workingDir?: string;
|
|
13
15
|
/** Minimum log level for engine output. Default: 'warn' */
|
|
14
16
|
logLevel?: 'none' | 'error' | 'warn' | 'info';
|
|
15
17
|
}
|
|
@@ -50,7 +50,13 @@ export class EngineManager {
|
|
|
50
50
|
pendingGroup = null;
|
|
51
51
|
pendingTimer = null;
|
|
52
52
|
constructor(opts) {
|
|
53
|
-
this.opts = {
|
|
53
|
+
this.opts = {
|
|
54
|
+
httpPort: 3111,
|
|
55
|
+
wsPort: 49134,
|
|
56
|
+
logLevel: "warn",
|
|
57
|
+
workingDir: process.cwd(),
|
|
58
|
+
...opts
|
|
59
|
+
};
|
|
54
60
|
}
|
|
55
61
|
isRunning() {
|
|
56
62
|
return this.process !== null && !this.process.killed && this.process.exitCode === null;
|
|
@@ -126,7 +132,8 @@ export class EngineManager {
|
|
|
126
132
|
this.startupComplete = false;
|
|
127
133
|
this.process = spawn(binaryPath, ["--config", configPath], {
|
|
128
134
|
stdio: ["ignore", "pipe", "pipe"],
|
|
129
|
-
detached: false
|
|
135
|
+
detached: false,
|
|
136
|
+
cwd: this.opts.workingDir
|
|
130
137
|
});
|
|
131
138
|
this.process.stdout?.on("data", (chunk) => {
|
|
132
139
|
for (const line of chunk.toString().split("\n").filter(Boolean))
|
|
@@ -35,11 +35,13 @@ def cron(expression: str) -> dict:
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
# ── Request / Response ─────────────────────────────────────────────────────
|
|
38
|
+
# Stubs for Pylance. Runtime imports real types from iii_helpers.http via _runtime.py.
|
|
38
39
|
|
|
39
|
-
class
|
|
40
|
+
class HttpRequest:
|
|
40
41
|
"""HTTP request input for http-triggered Python functions.
|
|
41
42
|
|
|
42
|
-
The iii SDK uses
|
|
43
|
+
The iii SDK 0.21.3+ uses HttpRequest from iii_helpers.http.
|
|
44
|
+
Fields use snake_case:
|
|
43
45
|
req.headers — dict[str, str]
|
|
44
46
|
req.method — 'GET' | 'POST' | ...
|
|
45
47
|
req.path_params — dict[str, str]
|
|
@@ -53,23 +55,51 @@ class ApiRequest:
|
|
|
53
55
|
body: Optional[Any]
|
|
54
56
|
|
|
55
57
|
|
|
56
|
-
class
|
|
58
|
+
class HttpResponse:
|
|
57
59
|
"""HTTP response returned from an http-triggered handler.
|
|
58
60
|
|
|
61
|
+
The iii SDK 0.21.3+ uses HttpResponse from iii_helpers.http.
|
|
62
|
+
|
|
59
63
|
Example::
|
|
60
64
|
|
|
61
|
-
return
|
|
62
|
-
return
|
|
65
|
+
return HttpResponse(status_code=200, body={"ok": True})
|
|
66
|
+
return HttpResponse(status_code=201, body=result, headers={"x-request-id": rid})
|
|
63
67
|
"""
|
|
64
68
|
def __init__(
|
|
65
69
|
self,
|
|
66
70
|
*,
|
|
67
|
-
|
|
71
|
+
status_code: int = 200,
|
|
68
72
|
body: Any = None,
|
|
69
73
|
headers: dict[str, str] = None,
|
|
70
74
|
) -> None: ...
|
|
71
75
|
|
|
72
76
|
|
|
77
|
+
# Backward compatibility aliases
|
|
78
|
+
ApiRequest = HttpRequest
|
|
79
|
+
ApiResponse = HttpResponse
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# ── Logger ─────────────────────────────────────────────────────────────────
|
|
83
|
+
# Stub for Pylance. Runtime imports real Logger from iii_helpers.observability.
|
|
84
|
+
|
|
85
|
+
class Logger:
|
|
86
|
+
"""Structured logger from iii_helpers.observability.
|
|
87
|
+
|
|
88
|
+
Emits logs as OpenTelemetry LogRecords with automatic trace/span correlation.
|
|
89
|
+
|
|
90
|
+
Usage::
|
|
91
|
+
|
|
92
|
+
logger = Logger("my-function")
|
|
93
|
+
logger.info("Processing order", {"orderId": order_id})
|
|
94
|
+
logger.error("Validation failed", {"field": "email"})
|
|
95
|
+
"""
|
|
96
|
+
def __init__(self, name: str = "nvent"): ...
|
|
97
|
+
def debug(self, message: str, attributes: dict[str, Any] | None = None) -> None: ...
|
|
98
|
+
def info(self, message: str, attributes: dict[str, Any] | None = None) -> None: ...
|
|
99
|
+
def warn(self, message: str, attributes: dict[str, Any] | None = None) -> None: ...
|
|
100
|
+
def error(self, message: str, attributes: dict[str, Any] | None = None) -> None: ...
|
|
101
|
+
|
|
102
|
+
|
|
73
103
|
# ── Stream ─────────────────────────────────────────────────────────────────
|
|
74
104
|
|
|
75
105
|
class IStream:
|
|
@@ -314,8 +344,10 @@ try:
|
|
|
314
344
|
cron,
|
|
315
345
|
define_function,
|
|
316
346
|
FlowContext,
|
|
347
|
+
ApiRequest,
|
|
348
|
+
ApiResponse,
|
|
317
349
|
)
|
|
318
|
-
from
|
|
350
|
+
from iii_helpers.observability import Logger # type: ignore[no-redef] # noqa: F401, E402
|
|
319
351
|
except ImportError:
|
|
320
352
|
pass
|
|
321
353
|
|
|
@@ -22,8 +22,10 @@ import logging as _logging
|
|
|
22
22
|
|
|
23
23
|
try:
|
|
24
24
|
import iii as _iii_sdk
|
|
25
|
+
from iii_helpers.http import HttpRequest as _HttpRequest, HttpResponse as _HttpResponse
|
|
26
|
+
from iii_helpers.observability import Logger
|
|
25
27
|
except ImportError:
|
|
26
|
-
print("[nvent] iii package not found — install it: pip install iii-sdk[otel]", flush=True)
|
|
28
|
+
print("[nvent] iii package not found — install it: pip install iii-sdk[otel] iii-helpers", flush=True)
|
|
27
29
|
sys.exit(1)
|
|
28
30
|
|
|
29
31
|
# Direct Python logging to stdout so nvent captures it alongside other output.
|
|
@@ -103,6 +105,15 @@ def set_span_ok(span) -> None:
|
|
|
103
105
|
_NVENT_STREAM_KEY = '__nventStream'
|
|
104
106
|
|
|
105
107
|
|
|
108
|
+
# ---------------------------------------------------------------------------
|
|
109
|
+
# HTTP Request/Response wrappers — convenience aliases for iii_helpers.http
|
|
110
|
+
# ---------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
# Expose iii_helpers.http types as ApiRequest/ApiResponse for backward compatibility
|
|
113
|
+
ApiRequest = _HttpRequest
|
|
114
|
+
ApiResponse = _HttpResponse
|
|
115
|
+
|
|
116
|
+
|
|
106
117
|
# ---------------------------------------------------------------------------
|
|
107
118
|
# Trigger config helpers — use these in config["triggers"]
|
|
108
119
|
# ---------------------------------------------------------------------------
|
|
@@ -403,7 +414,7 @@ class FlowContext:
|
|
|
403
414
|
self._input = input_data
|
|
404
415
|
self._stream_name = stream_name or fn_id.split("::")[0]
|
|
405
416
|
self._stream_group_id = inherited_group_id
|
|
406
|
-
self.logger =
|
|
417
|
+
self.logger = Logger(fn_id)
|
|
407
418
|
self.state = _State(client, fn_id)
|
|
408
419
|
self.stream = _Stream(client, self._stream_name, self._get_or_create_group_id)
|
|
409
420
|
|
|
@@ -621,7 +632,8 @@ def _register_one(client, mod, default_id: str, fn_def: dict) -> None:
|
|
|
621
632
|
|
|
622
633
|
def _make_wrapper_thin(_h, _is_http):
|
|
623
634
|
async def _wrapped(data):
|
|
624
|
-
|
|
635
|
+
# Wrap dict in HttpRequest for HTTP triggers
|
|
636
|
+
input_data = ApiRequest(**data) if (_is_http and isinstance(data, dict)) else data
|
|
625
637
|
return await _h(input_data)
|
|
626
638
|
return _wrapped
|
|
627
639
|
|
|
@@ -702,7 +714,8 @@ def _register_legacy(client, mod, default_id: str) -> None:
|
|
|
702
714
|
inherited_group = nvent_stream.get('groupId')
|
|
703
715
|
effective_stream = nvent_stream.get('name') or _stream_name
|
|
704
716
|
clean_data = {k: v for k, v in data.items() if k != _NVENT_STREAM_KEY}
|
|
705
|
-
|
|
717
|
+
# Wrap dict in HttpRequest for HTTP triggers
|
|
718
|
+
input_data = ApiRequest(**clean_data) if (_is_http and isinstance(clean_data, dict)) else clean_data
|
|
706
719
|
if not _hc:
|
|
707
720
|
return await _h(input_data)
|
|
708
721
|
ctx = FlowContext(client, _fn_id, _t_type, input_data, effective_stream, inherited_group)
|
|
@@ -30,6 +30,7 @@ declare module '#nvent/server' {
|
|
|
30
30
|
HttpRequest,
|
|
31
31
|
} from '../nitro/utils/defineFunction'
|
|
32
32
|
export { useIii, useIiiHealth } from '../nitro/utils/useIii'
|
|
33
|
-
export {
|
|
34
|
-
export
|
|
33
|
+
export { registerWorker, TriggerAction } from 'iii-sdk'
|
|
34
|
+
export { Logger } from '@iii-dev/helpers/observability'
|
|
35
|
+
export type { IIIClient, InitOptions} from 'iii-sdk'
|
|
35
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nvent",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.12",
|
|
4
4
|
|
|
5
5
|
"description": "Event-driven workflows for Nuxt",
|
|
6
6
|
"repository": "nhealthorg/nvent",
|
|
@@ -24,22 +24,23 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@nuxt/devtools-kit": "^3.2.4",
|
|
27
|
-
"@nuxt/kit": "4.4.
|
|
27
|
+
"@nuxt/kit": "4.4.8",
|
|
28
28
|
"chokidar": "^5.0.0",
|
|
29
29
|
"confbox": "^0.2.4",
|
|
30
|
-
"globby": "16.2.
|
|
31
|
-
"iii-browser-sdk": "
|
|
32
|
-
"iii-sdk": "
|
|
30
|
+
"globby": "16.2.1",
|
|
31
|
+
"iii-browser-sdk": "0.21.3",
|
|
32
|
+
"iii-sdk": "0.21.3",
|
|
33
|
+
"@iii-dev/helpers": "0.21.3",
|
|
33
34
|
"knitwork": "^1.3.0",
|
|
34
|
-
"nuxt": "4.4.
|
|
35
|
+
"nuxt": "4.4.8",
|
|
35
36
|
"pathe": "^2.0.3",
|
|
36
37
|
"perfect-debounce": "^2.1.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@nuxt/module-builder": "^1.0.2",
|
|
40
|
-
"@nuxt/schema": "4.4.
|
|
41
|
-
"@types/node": "^
|
|
42
|
-
"typescript": "
|
|
43
|
-
"vitest": "^4.1.
|
|
41
|
+
"@nuxt/schema": "4.4.8",
|
|
42
|
+
"@types/node": "^26.1.1",
|
|
43
|
+
"typescript": "5.9.3",
|
|
44
|
+
"vitest": "^4.1.10"
|
|
44
45
|
}
|
|
45
46
|
}
|