nvent 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +49 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +68 -10
- package/dist/types.d.mts +2 -0
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -338,6 +338,55 @@ interface NventIiiOptions {
|
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
interface LayerInfo {
|
|
342
|
+
rootDir: string;
|
|
343
|
+
serverDir: string;
|
|
344
|
+
/**
|
|
345
|
+
* Prefix prepended to every function ID discovered in this layer.
|
|
346
|
+
* Empty string (or undefined) means no prefix — root project convention.
|
|
347
|
+
* e.g. 'auth' → 'login.ts' becomes 'auth::login'
|
|
348
|
+
*/
|
|
349
|
+
prefix?: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
interface NventExtendedFunction {
|
|
353
|
+
/** iii function ID (e.g. `fhir::terminology::lookup`) */
|
|
354
|
+
id: string;
|
|
355
|
+
/** Absolute file path, or root-relative path, to a TS/JS function module */
|
|
356
|
+
absPath: string;
|
|
357
|
+
/** Optional human-readable description */
|
|
358
|
+
description?: string;
|
|
359
|
+
}
|
|
360
|
+
interface NventExtendedPythonFunction {
|
|
361
|
+
/** iii function ID (e.g. `fhir::terminology::expand`) */
|
|
362
|
+
id: string;
|
|
363
|
+
/** Absolute file path, or root-relative path, to a .py file */
|
|
364
|
+
absPath: string;
|
|
365
|
+
/** When true, start this function in a dedicated worker process */
|
|
366
|
+
standalone?: boolean;
|
|
367
|
+
}
|
|
368
|
+
interface NventExtendFunctionsHookPayload {
|
|
369
|
+
/** Push extra TS/JS function files to register */
|
|
370
|
+
functions: NventExtendedFunction[];
|
|
371
|
+
/** Push extra Python function files to register */
|
|
372
|
+
pythonFunctions: NventExtendedPythonFunction[];
|
|
373
|
+
/** Nuxt project root */
|
|
374
|
+
rootDir: string;
|
|
375
|
+
/** Layer scan context (same as nvent internal scan) */
|
|
376
|
+
layerInfos: LayerInfo[];
|
|
377
|
+
/** Configured functions dir relative to each layer's server dir */
|
|
378
|
+
functionsDir: string;
|
|
379
|
+
}
|
|
380
|
+
declare module '@nuxt/schema' {
|
|
381
|
+
interface NuxtHooks {
|
|
382
|
+
/**
|
|
383
|
+
* Extend nvent function discovery with additional TS/JS or Python function files.
|
|
384
|
+
* Useful for Nuxt modules that ship their own iii handlers.
|
|
385
|
+
*/
|
|
386
|
+
'nvent:functions:extend': (payload: NventExtendFunctionsHookPayload) => void | Promise<void>;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
341
389
|
declare const _default: _nuxt_schema.NuxtModule<NventIiiOptions, NventIiiOptions, false>;
|
|
342
390
|
|
|
343
391
|
export { _default as default };
|
|
392
|
+
export type { NventExtendFunctionsHookPayload, NventExtendedFunction, NventExtendedPythonFunction };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join, dirname, basename, relative, parse } from 'node:path';
|
|
1
|
+
import { join, dirname, basename, relative, parse, isAbsolute } from 'node:path';
|
|
2
2
|
import { defineNuxtModule, createResolver, extendViteConfig, hasNuxtModule, addTemplate, addServerPlugin, addServerHandler, addServerImports, addImports, addPlugin, updateTemplates } from '@nuxt/kit';
|
|
3
3
|
import { existsSync, mkdirSync, chmodSync, createWriteStream, unlinkSync, writeFileSync, readFileSync, copyFileSync } from 'node:fs';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
@@ -847,20 +847,26 @@ function defaultIiiEngineConfig() {
|
|
|
847
847
|
function defaultStateAdapter(stateDir) {
|
|
848
848
|
return {
|
|
849
849
|
name: "kv",
|
|
850
|
-
config: { store_method: "file_based", file_path: "
|
|
850
|
+
config: { store_method: "file_based", file_path: "./.data/state_store" }
|
|
851
851
|
};
|
|
852
852
|
}
|
|
853
853
|
function defaultQueueAdapter(queueDir) {
|
|
854
854
|
return {
|
|
855
855
|
name: "builtin",
|
|
856
|
-
config: { store_method: "file_based", file_path: "
|
|
856
|
+
config: { store_method: "file_based", file_path: "./.data/queue_store" }
|
|
857
857
|
};
|
|
858
858
|
}
|
|
859
859
|
function defaultCronAdapter() {
|
|
860
|
-
return {
|
|
860
|
+
return {
|
|
861
|
+
name: "kv",
|
|
862
|
+
config: { store_method: "file_based", file_path: "./.data/cron_store" }
|
|
863
|
+
};
|
|
861
864
|
}
|
|
862
865
|
function defaultStreamAdapter() {
|
|
863
|
-
return {
|
|
866
|
+
return {
|
|
867
|
+
name: "kv",
|
|
868
|
+
config: { store_method: "file_based", file_path: "./.data/stream_store" }
|
|
869
|
+
};
|
|
864
870
|
}
|
|
865
871
|
function generateIiiConfigYaml(cfg) {
|
|
866
872
|
const workers = [];
|
|
@@ -1362,7 +1368,52 @@ const module$1 = defineNuxtModule({
|
|
|
1362
1368
|
serverDir: l.config?.serverDir ?? join(l.config.rootDir, "server"),
|
|
1363
1369
|
prefix: resolveLayerPrefix(l, i === 0)
|
|
1364
1370
|
}));
|
|
1365
|
-
|
|
1371
|
+
async function scanFunctionsWithExtensions() {
|
|
1372
|
+
const scanned = await scanFunctions({ layerInfos, functionsDir });
|
|
1373
|
+
const payload = {
|
|
1374
|
+
functions: [],
|
|
1375
|
+
pythonFunctions: [],
|
|
1376
|
+
rootDir: nuxt.options.rootDir,
|
|
1377
|
+
layerInfos,
|
|
1378
|
+
functionsDir
|
|
1379
|
+
};
|
|
1380
|
+
await nuxt.callHook("nvent:functions:extend", payload);
|
|
1381
|
+
const normalizePath = (path) => isAbsolute(path) ? path : join(nuxt.options.rootDir, path);
|
|
1382
|
+
const seenTs = new Set(scanned.functions.map((f) => f.id));
|
|
1383
|
+
for (const fn of payload.functions) {
|
|
1384
|
+
if (!fn?.id || !fn?.absPath) continue;
|
|
1385
|
+
if (seenTs.has(fn.id)) {
|
|
1386
|
+
console.warn(`[nvent] skipping extended TS function '${fn.id}' (duplicate id)`);
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
const absPath = normalizePath(fn.absPath);
|
|
1390
|
+
scanned.functions.push({
|
|
1391
|
+
id: fn.id,
|
|
1392
|
+
absPath,
|
|
1393
|
+
relativePath: basename(absPath),
|
|
1394
|
+
description: fn.description
|
|
1395
|
+
});
|
|
1396
|
+
seenTs.add(fn.id);
|
|
1397
|
+
}
|
|
1398
|
+
const seenPy = new Set(scanned.pythonFunctions.map((f) => f.id));
|
|
1399
|
+
for (const fn of payload.pythonFunctions) {
|
|
1400
|
+
if (!fn?.id || !fn?.absPath) continue;
|
|
1401
|
+
if (seenPy.has(fn.id)) {
|
|
1402
|
+
console.warn(`[nvent] skipping extended Python function '${fn.id}' (duplicate id)`);
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
const absPath = normalizePath(fn.absPath);
|
|
1406
|
+
scanned.pythonFunctions.push({
|
|
1407
|
+
id: fn.id,
|
|
1408
|
+
absPath,
|
|
1409
|
+
relativePath: basename(absPath),
|
|
1410
|
+
standalone: !!fn.standalone
|
|
1411
|
+
});
|
|
1412
|
+
seenPy.add(fn.id);
|
|
1413
|
+
}
|
|
1414
|
+
return scanned;
|
|
1415
|
+
}
|
|
1416
|
+
let lastScanned = await scanFunctionsWithExtensions();
|
|
1366
1417
|
let pythonPathRewrite;
|
|
1367
1418
|
if (!nuxt.options.dev && !skipPython && lastScanned.pythonFunctions.length > 0) {
|
|
1368
1419
|
pythonPathRewrite = /* @__PURE__ */ new Map();
|
|
@@ -1374,6 +1425,10 @@ const module$1 = defineNuxtModule({
|
|
|
1374
1425
|
break;
|
|
1375
1426
|
}
|
|
1376
1427
|
}
|
|
1428
|
+
if (!pythonPathRewrite.has(fn.absPath)) {
|
|
1429
|
+
const rel = `${fn.id.replace(/::/g, "/")}.py`.replace(/[^a-zA-Z0-9/_\-.]/g, "_");
|
|
1430
|
+
pythonPathRewrite.set(fn.absPath, rel);
|
|
1431
|
+
}
|
|
1377
1432
|
}
|
|
1378
1433
|
}
|
|
1379
1434
|
addTemplate({
|
|
@@ -1484,7 +1539,7 @@ const module$1 = defineNuxtModule({
|
|
|
1484
1539
|
(l) => join(l.serverDir ?? join(l.rootDir, "server"), functionsDir)
|
|
1485
1540
|
);
|
|
1486
1541
|
const refresh = debounce(async (changedPath) => {
|
|
1487
|
-
lastScanned = await
|
|
1542
|
+
lastScanned = await scanFunctionsWithExtensions();
|
|
1488
1543
|
await updateTemplates({ filter: (t) => t.filename === III_REGISTRY_TEMPLATE });
|
|
1489
1544
|
console.log(`[nvent] registry refreshed${changedPath ? ` (${changedPath})` : ""}`);
|
|
1490
1545
|
if (!skipPython && changedPath?.endsWith(".py")) {
|
|
@@ -1520,15 +1575,18 @@ const module$1 = defineNuxtModule({
|
|
|
1520
1575
|
copyFileSync(PYTHON_RUNTIME_SRC, join(workersDir, "_runtime.py"));
|
|
1521
1576
|
copyFileSync(PYTHON_NVENT_HELPER_SRC, join(workersDir, "nvent.py"));
|
|
1522
1577
|
for (const fn of lastScanned.pythonFunctions) {
|
|
1578
|
+
let relativeDest;
|
|
1523
1579
|
for (const layer of layerInfos) {
|
|
1524
1580
|
const fnDir = join(layer.serverDir, functionsDir);
|
|
1525
1581
|
if (fn.absPath.startsWith(fnDir)) {
|
|
1526
|
-
|
|
1527
|
-
mkdirSync(join(dest, ".."), { recursive: true });
|
|
1528
|
-
copyFileSync(fn.absPath, dest);
|
|
1582
|
+
relativeDest = relative(fnDir, fn.absPath);
|
|
1529
1583
|
break;
|
|
1530
1584
|
}
|
|
1531
1585
|
}
|
|
1586
|
+
relativeDest ||= pythonPathRewrite?.get(fn.absPath) ?? `${fn.id.replace(/::/g, "/")}.py`;
|
|
1587
|
+
const dest = join(outputNventDir, "functions", relativeDest);
|
|
1588
|
+
mkdirSync(join(dest, ".."), { recursive: true });
|
|
1589
|
+
copyFileSync(fn.absPath, dest);
|
|
1532
1590
|
}
|
|
1533
1591
|
console.log("[nvent] Python worker files copied to .output/nvent/");
|
|
1534
1592
|
});
|
package/dist/types.d.mts
CHANGED
|
@@ -5,3 +5,5 @@ import type { default as Module } from './module.mjs'
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
7
|
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type NventExtendFunctionsHookPayload, type NventExtendedFunction, type NventExtendedPythonFunction } from './module.mjs'
|