@cdmx/n8n-nodes-schema-validator 0.1.14 → 0.1.16
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/README.md +55 -2
- package/dist/nodes/SchemaValidator/SchemaValidator.node.js +7699 -483
- package/dist/nodes/SchemaValidator/SchemaValidator.node.js.map +7 -1
- package/dist/nodes/SchemaValidator/lib/dataExtractor.js +74 -48
- package/dist/nodes/SchemaValidator/lib/dataExtractor.js.map +7 -1
- package/dist/nodes/SchemaValidator/lib/index.js +7270 -18
- package/dist/nodes/SchemaValidator/lib/index.js.map +7 -1
- package/dist/nodes/SchemaValidator/lib/schemaParser.js +49 -24
- package/dist/nodes/SchemaValidator/lib/schemaParser.js.map +7 -1
- package/dist/nodes/SchemaValidator/lib/validator.d.ts +2 -2
- package/dist/nodes/SchemaValidator/lib/validator.js +7163 -82
- package/dist/nodes/SchemaValidator/lib/validator.js.map +7 -1
- package/dist/nodes/SchemaValidator/types.js +18 -2
- package/dist/nodes/SchemaValidator/types.js.map +7 -1
- package/package.json +6 -8
|
@@ -1,60 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// nodes/SchemaValidator/lib/dataExtractor.ts
|
|
21
|
+
var dataExtractor_exports = {};
|
|
22
|
+
__export(dataExtractor_exports, {
|
|
23
|
+
extractCustomJsonData: () => extractCustomJsonData,
|
|
24
|
+
extractDataFromPath: () => extractDataFromPath,
|
|
25
|
+
extractDataToValidate: () => extractDataToValidate
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(dataExtractor_exports);
|
|
6
28
|
function extractCustomJsonData(customJsonParam) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error(`Invalid custom JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
13
|
-
}
|
|
29
|
+
if (typeof customJsonParam === "string") {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(customJsonParam);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw new Error(`Invalid custom JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
14
34
|
}
|
|
15
|
-
|
|
35
|
+
}
|
|
36
|
+
return customJsonParam;
|
|
16
37
|
}
|
|
17
38
|
function extractDataToValidate(item, dataSource, customJsonParam) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return extractCustomJsonData(customJsonParam);
|
|
39
|
+
if (dataSource === "customJson") {
|
|
40
|
+
if (!customJsonParam) {
|
|
41
|
+
throw new Error('Custom JSON is required when Data Source is "Custom JSON"');
|
|
23
42
|
}
|
|
24
|
-
return
|
|
43
|
+
return extractCustomJsonData(customJsonParam);
|
|
44
|
+
}
|
|
45
|
+
return item.json;
|
|
25
46
|
}
|
|
26
47
|
function extractDataFromPath(item, path) {
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
if (typeof path !== "string") {
|
|
49
|
+
return path;
|
|
50
|
+
}
|
|
51
|
+
if (!path || path.trim() === "") {
|
|
52
|
+
return item.json;
|
|
53
|
+
}
|
|
54
|
+
const parts = path.split(".").flatMap((part) => {
|
|
55
|
+
const arrayMatch = part.match(/^(\w+)\[(\d+)\]$/);
|
|
56
|
+
if (arrayMatch) {
|
|
57
|
+
return [arrayMatch[1], parseInt(arrayMatch[2], 10)];
|
|
29
58
|
}
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
return part;
|
|
60
|
+
});
|
|
61
|
+
let current = item.json;
|
|
62
|
+
for (const part of parts) {
|
|
63
|
+
if (current === null || current === void 0) {
|
|
64
|
+
return void 0;
|
|
32
65
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
if (typeof part === 'number') {
|
|
46
|
-
if (!Array.isArray(current)) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
current = current[part];
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (typeof current !== 'object') {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
current = current[part];
|
|
56
|
-
}
|
|
66
|
+
if (typeof part === "number") {
|
|
67
|
+
if (!Array.isArray(current)) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
current = current[part];
|
|
71
|
+
} else {
|
|
72
|
+
if (typeof current !== "object") {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
current = current[part];
|
|
57
76
|
}
|
|
58
|
-
|
|
77
|
+
}
|
|
78
|
+
return current;
|
|
59
79
|
}
|
|
60
|
-
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
extractCustomJsonData,
|
|
83
|
+
extractDataFromPath,
|
|
84
|
+
extractDataToValidate
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=dataExtractor.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../nodes/SchemaValidator/lib/dataExtractor.ts"],
|
|
4
|
+
"sourcesContent": ["import type { INodeExecutionData } from 'n8n-workflow';\nimport type { DataSource } from '../types';\n\n/**\n * Extracts data to validate from custom JSON parameter.\n * @param customJsonParam Custom JSON string or object\n * @returns Parsed data\n * @throws Error if JSON is invalid\n */\nexport function extractCustomJsonData(customJsonParam: string | object): unknown {\n\tif (typeof customJsonParam === 'string') {\n\t\ttry {\n\t\t\treturn JSON.parse(customJsonParam);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Invalid custom JSON: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t}\n\treturn customJsonParam;\n}\n\n/**\n * Determines what data to validate based on data source.\n * @param item Input item\n * @param dataSource Data source type\n * @param customJsonParam Custom JSON parameter (required if dataSource is 'customJson')\n * @returns Data to validate or array of data items for array mode\n */\nexport function extractDataToValidate(\n\titem: INodeExecutionData,\n\tdataSource: DataSource,\n\tcustomJsonParam?: string | object,\n): unknown {\n\tif (dataSource === 'customJson') {\n\t\tif (!customJsonParam) {\n\t\t\tthrow new Error('Custom JSON is required when Data Source is \"Custom JSON\"');\n\t\t}\n\t\treturn extractCustomJsonData(customJsonParam);\n\t}\n\t\n\treturn item.json;\n}\n\n/**\n * Extracts data from a specific JSON path within the item.\n * @param item Input item\n * @param path JSON path (e.g., 'data.user' or 'items[0]') or direct data value\n * @returns Extracted data or undefined if path doesn't exist\n */\nexport function extractDataFromPath(item: INodeExecutionData, path: string | unknown): unknown {\n\t// If path is not a string, treat it as direct data (from expression evaluation)\n\tif (typeof path !== 'string') {\n\t\treturn path;\n\t}\n\n\t// If path is empty, return the entire json\n\tif (!path || path.trim() === '') {\n\t\treturn item.json;\n\t}\n\n\tconst parts = path.split('.').flatMap(part => {\n\t\t// Handle array notation like 'items[0]'\n\t\tconst arrayMatch = part.match(/^(\\w+)\\[(\\d+)\\]$/);\n\t\tif (arrayMatch) {\n\t\t\treturn [arrayMatch[1], parseInt(arrayMatch[2], 10)];\n\t\t}\n\t\treturn part;\n\t});\n\n\tlet current: unknown = item.json;\n\tfor (const part of parts) {\n\t\tif (current === null || current === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (typeof part === 'number') {\n\t\t\tif (!Array.isArray(current)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcurrent = current[part];\n\t\t} else {\n\t\t\tif (typeof current !== 'object') {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcurrent = (current as Record<string, unknown>)[part];\n\t\t}\n\t}\n\treturn current;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,sBAAsB,iBAA2C;AAChF,MAAI,OAAO,oBAAoB,UAAU;AACxC,QAAI;AACH,aAAO,KAAK,MAAM,eAAe;AAAA,IAClC,SAAS,OAAO;AACf,YAAM,IAAI,MAAM,wBAAwB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAAA,IACjG;AAAA,EACD;AACA,SAAO;AACR;AASO,SAAS,sBACf,MACA,YACA,iBACU;AACV,MAAI,eAAe,cAAc;AAChC,QAAI,CAAC,iBAAiB;AACrB,YAAM,IAAI,MAAM,2DAA2D;AAAA,IAC5E;AACA,WAAO,sBAAsB,eAAe;AAAA,EAC7C;AAEA,SAAO,KAAK;AACb;AAQO,SAAS,oBAAoB,MAA0B,MAAiC;AAE9F,MAAI,OAAO,SAAS,UAAU;AAC7B,WAAO;AAAA,EACR;AAGA,MAAI,CAAC,QAAQ,KAAK,KAAK,MAAM,IAAI;AAChC,WAAO,KAAK;AAAA,EACb;AAEA,QAAM,QAAQ,KAAK,MAAM,GAAG,EAAE,QAAQ,UAAQ;AAE7C,UAAM,aAAa,KAAK,MAAM,kBAAkB;AAChD,QAAI,YAAY;AACf,aAAO,CAAC,WAAW,CAAC,GAAG,SAAS,WAAW,CAAC,GAAG,EAAE,CAAC;AAAA,IACnD;AACA,WAAO;AAAA,EACR,CAAC;AAED,MAAI,UAAmB,KAAK;AAC5B,aAAW,QAAQ,OAAO;AACzB,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC9C,aAAO;AAAA,IACR;AACA,QAAI,OAAO,SAAS,UAAU;AAC7B,UAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AAC5B,eAAO;AAAA,MACR;AACA,gBAAU,QAAQ,IAAI;AAAA,IACvB,OAAO;AACN,UAAI,OAAO,YAAY,UAAU;AAChC,eAAO;AAAA,MACR;AACA,gBAAW,QAAoC,IAAI;AAAA,IACpD;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|