@n8n/workflow-sdk 0.34.0 → 0.35.0
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/build.tsbuildinfo +1 -1
- package/dist/generate-types/generate-types.d.ts +2 -0
- package/dist/generate-types/generate-types.js +72 -0
- package/dist/generate-types/generate-types.js.map +1 -1
- package/dist/mock-data/context.js +2 -0
- package/dist/mock-data/context.js.map +1 -1
- package/dist/mock-data/data-table-read.d.ts +32 -0
- package/dist/mock-data/data-table-read.js +68 -0
- package/dist/mock-data/data-table-read.js.map +1 -0
- package/dist/mock-data/index.d.ts +1 -0
- package/dist/mock-data/index.js +4 -1
- package/dist/mock-data/index.js.map +1 -1
- package/dist/mock-data/prompt.js +6 -0
- package/dist/mock-data/prompt.js.map +1 -1
- package/dist/mock-data/types.d.ts +2 -0
- package/package.json +10 -10
|
@@ -123,7 +123,9 @@ export interface JsonSchema {
|
|
|
123
123
|
const?: unknown;
|
|
124
124
|
$ref?: string;
|
|
125
125
|
}
|
|
126
|
+
export declare function withSchemaDirIndex<T>(fn: () => Promise<T>): Promise<T>;
|
|
126
127
|
export declare function schemaSearchRoots(): string[];
|
|
128
|
+
export declare function findSchemaDirectory(baseName: string, schemaPath?: string): string | undefined;
|
|
127
129
|
export declare function discoverSchemasForNode(nodeName: string, version: number, schemaPath?: string): OutputSchema[];
|
|
128
130
|
export declare function padVersion(version: number): string;
|
|
129
131
|
export declare function computeSchemaCorpusHash(baseDirs?: string[]): string;
|
|
@@ -35,7 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.NODES_BASE_TYPES = void 0;
|
|
37
37
|
exports.isCustomApiCall = isCustomApiCall;
|
|
38
|
+
exports.withSchemaDirIndex = withSchemaDirIndex;
|
|
38
39
|
exports.schemaSearchRoots = schemaSearchRoots;
|
|
40
|
+
exports.findSchemaDirectory = findSchemaDirectory;
|
|
39
41
|
exports.discoverSchemasForNode = discoverSchemasForNode;
|
|
40
42
|
exports.padVersion = padVersion;
|
|
41
43
|
exports.computeSchemaCorpusHash = computeSchemaCorpusHash;
|
|
@@ -339,6 +341,70 @@ function findNestedSchemaDir(dir, targetNames) {
|
|
|
339
341
|
}
|
|
340
342
|
return undefined;
|
|
341
343
|
}
|
|
344
|
+
function buildSchemaRootIndex(root) {
|
|
345
|
+
const index = { flat: new Map(), nested: new Map() };
|
|
346
|
+
const walk = (dir, depth) => {
|
|
347
|
+
let entries;
|
|
348
|
+
try {
|
|
349
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
for (const entry of entries) {
|
|
355
|
+
if (!entry.isDirectory())
|
|
356
|
+
continue;
|
|
357
|
+
const entryPath = path.join(dir, entry.name);
|
|
358
|
+
const key = entry.name.toLowerCase();
|
|
359
|
+
const schemaPath = path.join(entryPath, '__schema__');
|
|
360
|
+
if (fs.existsSync(schemaPath)) {
|
|
361
|
+
if (depth === 0 && !index.flat.has(key))
|
|
362
|
+
index.flat.set(key, schemaPath);
|
|
363
|
+
if (!index.nested.has(key))
|
|
364
|
+
index.nested.set(key, schemaPath);
|
|
365
|
+
}
|
|
366
|
+
if (entry.name !== '__schema__' && entry.name !== 'node_modules') {
|
|
367
|
+
walk(entryPath, depth + 1);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
walk(root, 0);
|
|
372
|
+
return index;
|
|
373
|
+
}
|
|
374
|
+
let activeSchemaIndexes;
|
|
375
|
+
async function withSchemaDirIndex(fn) {
|
|
376
|
+
if (activeSchemaIndexes)
|
|
377
|
+
return await fn();
|
|
378
|
+
activeSchemaIndexes = new Map();
|
|
379
|
+
try {
|
|
380
|
+
return await fn();
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
activeSchemaIndexes = undefined;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
function indexedSchemaDirectory(indexes, roots, baseName) {
|
|
387
|
+
const rootIndexes = roots.map((root) => {
|
|
388
|
+
let index = indexes.get(root);
|
|
389
|
+
if (!index) {
|
|
390
|
+
index = buildSchemaRootIndex(root);
|
|
391
|
+
indexes.set(root, index);
|
|
392
|
+
}
|
|
393
|
+
return index;
|
|
394
|
+
});
|
|
395
|
+
const key = baseName.toLowerCase();
|
|
396
|
+
for (const index of rootIndexes) {
|
|
397
|
+
const found = index.flat.get(key);
|
|
398
|
+
if (found)
|
|
399
|
+
return found;
|
|
400
|
+
}
|
|
401
|
+
for (const index of rootIndexes) {
|
|
402
|
+
const found = index.nested.get(key);
|
|
403
|
+
if (found)
|
|
404
|
+
return found;
|
|
405
|
+
}
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
342
408
|
function schemaSearchRoots() {
|
|
343
409
|
const cwdRoot = path.resolve(process.cwd(), 'dist', 'nodes');
|
|
344
410
|
if (cwdRoot !== NODES_BASE_DIST && fs.existsSync(cwdRoot)) {
|
|
@@ -356,6 +422,9 @@ function findSchemaDirectory(baseName, schemaPath) {
|
|
|
356
422
|
}
|
|
357
423
|
}
|
|
358
424
|
}
|
|
425
|
+
if (activeSchemaIndexes) {
|
|
426
|
+
return indexedSchemaDirectory(activeSchemaIndexes, roots, baseName);
|
|
427
|
+
}
|
|
359
428
|
const possibleNames = [
|
|
360
429
|
baseName.charAt(0).toUpperCase() + baseName.slice(1),
|
|
361
430
|
baseName,
|
|
@@ -2867,6 +2936,9 @@ async function generateVersionSpecificFiles(packageDir, _packageName, nodesByNam
|
|
|
2867
2936
|
return allNodes;
|
|
2868
2937
|
}
|
|
2869
2938
|
async function orchestrateGeneration(options) {
|
|
2939
|
+
return await withSchemaDirIndex(async () => await generateAll(options));
|
|
2940
|
+
}
|
|
2941
|
+
async function generateAll(options) {
|
|
2870
2942
|
const { nodes, outputDir } = options;
|
|
2871
2943
|
const nodesByPackage = new Map();
|
|
2872
2944
|
for (const node of nodes) {
|