cxtms 1.9.13
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 +384 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +4784 -0
- package/dist/cli.js.map +1 -0
- package/dist/extractUtils.d.ts +11 -0
- package/dist/extractUtils.d.ts.map +1 -0
- package/dist/extractUtils.js +19 -0
- package/dist/extractUtils.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/schemaLoader.d.ts +17 -0
- package/dist/utils/schemaLoader.d.ts.map +1 -0
- package/dist/utils/schemaLoader.js +134 -0
- package/dist/utils/schemaLoader.js.map +1 -0
- package/dist/validator.d.ts +72 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +432 -0
- package/dist/validator.js.map +1 -0
- package/dist/workflowValidator.d.ts +103 -0
- package/dist/workflowValidator.d.ts.map +1 -0
- package/dist/workflowValidator.js +753 -0
- package/dist/workflowValidator.js.map +1 -0
- package/package.json +51 -0
- package/schemas/actions/all.json +27 -0
- package/schemas/actions/clipboard.json +46 -0
- package/schemas/actions/confirm.json +21 -0
- package/schemas/actions/consoleLog.json +16 -0
- package/schemas/actions/dialog.json +25 -0
- package/schemas/actions/fileDownload.json +16 -0
- package/schemas/actions/forEach.json +31 -0
- package/schemas/actions/if.json +12 -0
- package/schemas/actions/mutation.json +25 -0
- package/schemas/actions/navigate.json +18 -0
- package/schemas/actions/navigateBack.json +22 -0
- package/schemas/actions/navigateBackOrClose.json +21 -0
- package/schemas/actions/notification.json +19 -0
- package/schemas/actions/openBarcodeScanner.json +104 -0
- package/schemas/actions/query.json +32 -0
- package/schemas/actions/refresh.json +13 -0
- package/schemas/actions/resetDirtyState.json +22 -0
- package/schemas/actions/setFields.json +21 -0
- package/schemas/actions/setStore.json +13 -0
- package/schemas/actions/validateForm.json +15 -0
- package/schemas/actions/workflow.json +24 -0
- package/schemas/components/README.md +147 -0
- package/schemas/components/appComponent.json +58 -0
- package/schemas/components/barcodeScanner.json +69 -0
- package/schemas/components/button.json +123 -0
- package/schemas/components/calendar.json +489 -0
- package/schemas/components/card.json +176 -0
- package/schemas/components/collection.json +54 -0
- package/schemas/components/dataGrid.json +119 -0
- package/schemas/components/datasource.json +151 -0
- package/schemas/components/dropdown.json +57 -0
- package/schemas/components/field-collection.json +618 -0
- package/schemas/components/field.json +265 -0
- package/schemas/components/form.json +234 -0
- package/schemas/components/index.json +71 -0
- package/schemas/components/layout.json +69 -0
- package/schemas/components/module.json +167 -0
- package/schemas/components/navDropdown.json +36 -0
- package/schemas/components/navbar.json +78 -0
- package/schemas/components/navbarItem.json +28 -0
- package/schemas/components/navbarLink.json +36 -0
- package/schemas/components/row.json +31 -0
- package/schemas/components/slot.json +30 -0
- package/schemas/components/tab.json +34 -0
- package/schemas/components/tabs.json +35 -0
- package/schemas/components/timeline.json +172 -0
- package/schemas/components/timelineGrid.json +328 -0
- package/schemas/fields/README.md +66 -0
- package/schemas/fields/attachment.json +156 -0
- package/schemas/fields/autocomplete-googleplaces.json +130 -0
- package/schemas/fields/checkbox.json +82 -0
- package/schemas/fields/date.json +88 -0
- package/schemas/fields/datetime.json +75 -0
- package/schemas/fields/email.json +75 -0
- package/schemas/fields/index.json +53 -0
- package/schemas/fields/number.json +91 -0
- package/schemas/fields/password.json +70 -0
- package/schemas/fields/radio.json +94 -0
- package/schemas/fields/rangedatetime.json +56 -0
- package/schemas/fields/select-async.json +334 -0
- package/schemas/fields/select.json +115 -0
- package/schemas/fields/tel.json +79 -0
- package/schemas/fields/text.json +86 -0
- package/schemas/fields/textarea.json +95 -0
- package/schemas/fields/time.json +91 -0
- package/schemas/fields/url.json +74 -0
- package/schemas/schema.graphql +12248 -0
- package/schemas/schemas.json +610 -0
- package/schemas/workflows/activity.json +96 -0
- package/schemas/workflows/common/condition.json +48 -0
- package/schemas/workflows/common/expression.json +76 -0
- package/schemas/workflows/common/mapping.json +173 -0
- package/schemas/workflows/common/step.json +38 -0
- package/schemas/workflows/flow/aggregation.json +44 -0
- package/schemas/workflows/flow/entity.json +129 -0
- package/schemas/workflows/flow/state.json +105 -0
- package/schemas/workflows/flow/transition.json +143 -0
- package/schemas/workflows/input.json +122 -0
- package/schemas/workflows/output.json +61 -0
- package/schemas/workflows/schedule.json +26 -0
- package/schemas/workflows/tasks/accounting-transaction.json +95 -0
- package/schemas/workflows/tasks/action-event.json +65 -0
- package/schemas/workflows/tasks/all.json +152 -0
- package/schemas/workflows/tasks/appmodule.json +56 -0
- package/schemas/workflows/tasks/attachment.json +97 -0
- package/schemas/workflows/tasks/authentication.json +86 -0
- package/schemas/workflows/tasks/caching.json +68 -0
- package/schemas/workflows/tasks/charge.json +92 -0
- package/schemas/workflows/tasks/commodity.json +92 -0
- package/schemas/workflows/tasks/contact-address.json +72 -0
- package/schemas/workflows/tasks/contact-payment-method.json +72 -0
- package/schemas/workflows/tasks/contact.json +82 -0
- package/schemas/workflows/tasks/csv.json +81 -0
- package/schemas/workflows/tasks/document-render.json +105 -0
- package/schemas/workflows/tasks/document-send.json +84 -0
- package/schemas/workflows/tasks/edi.json +157 -0
- package/schemas/workflows/tasks/email-send.json +110 -0
- package/schemas/workflows/tasks/error.json +72 -0
- package/schemas/workflows/tasks/export.json +90 -0
- package/schemas/workflows/tasks/filetransfer.json +102 -0
- package/schemas/workflows/tasks/flow-transition.json +68 -0
- package/schemas/workflows/tasks/foreach.json +69 -0
- package/schemas/workflows/tasks/generic.json +47 -0
- package/schemas/workflows/tasks/graphql.json +78 -0
- package/schemas/workflows/tasks/httpRequest.json +161 -0
- package/schemas/workflows/tasks/import.json +64 -0
- package/schemas/workflows/tasks/inventory.json +67 -0
- package/schemas/workflows/tasks/job.json +88 -0
- package/schemas/workflows/tasks/log.json +73 -0
- package/schemas/workflows/tasks/map.json +58 -0
- package/schemas/workflows/tasks/movement.json +54 -0
- package/schemas/workflows/tasks/note.json +59 -0
- package/schemas/workflows/tasks/number.json +65 -0
- package/schemas/workflows/tasks/order-tracking-event.json +109 -0
- package/schemas/workflows/tasks/order.json +139 -0
- package/schemas/workflows/tasks/payment.json +85 -0
- package/schemas/workflows/tasks/pdf-document.json +60 -0
- package/schemas/workflows/tasks/postal-codes.json +92 -0
- package/schemas/workflows/tasks/resolve-timezone.json +65 -0
- package/schemas/workflows/tasks/setVariable.json +76 -0
- package/schemas/workflows/tasks/switch.json +75 -0
- package/schemas/workflows/tasks/template.json +73 -0
- package/schemas/workflows/tasks/tracking-event.json +137 -0
- package/schemas/workflows/tasks/transmission.json +185 -0
- package/schemas/workflows/tasks/unzip-file.json +68 -0
- package/schemas/workflows/tasks/user.json +70 -0
- package/schemas/workflows/tasks/validation.json +99 -0
- package/schemas/workflows/tasks/while.json +53 -0
- package/schemas/workflows/tasks/workflow-execute.json +82 -0
- package/schemas/workflows/trigger.json +90 -0
- package/schemas/workflows/variable.json +46 -0
- package/schemas/workflows/workflow.json +335 -0
- package/scripts/postinstall.js +291 -0
- package/scripts/setup-vscode.js +80 -0
- package/skills/cxtms-developer/SKILL.md +118 -0
- package/skills/cxtms-developer/ref-cli-auth.md +120 -0
- package/skills/cxtms-developer/ref-entity-accounting.md +180 -0
- package/skills/cxtms-developer/ref-entity-commodity.md +239 -0
- package/skills/cxtms-developer/ref-entity-contact.md +163 -0
- package/skills/cxtms-developer/ref-entity-geography.md +154 -0
- package/skills/cxtms-developer/ref-entity-job.md +77 -0
- package/skills/cxtms-developer/ref-entity-notification.md +85 -0
- package/skills/cxtms-developer/ref-entity-order-sub.md +160 -0
- package/skills/cxtms-developer/ref-entity-order.md +183 -0
- package/skills/cxtms-developer/ref-entity-organization.md +41 -0
- package/skills/cxtms-developer/ref-entity-rate.md +182 -0
- package/skills/cxtms-developer/ref-entity-shared.md +176 -0
- package/skills/cxtms-developer/ref-entity-warehouse.md +115 -0
- package/skills/cxtms-developer/ref-graphql-query.md +309 -0
- package/skills/cxtms-module-builder/SKILL.md +477 -0
- package/skills/cxtms-module-builder/ref-components-data.md +293 -0
- package/skills/cxtms-module-builder/ref-components-display.md +411 -0
- package/skills/cxtms-module-builder/ref-components-forms.md +369 -0
- package/skills/cxtms-module-builder/ref-components-interactive.md +317 -0
- package/skills/cxtms-module-builder/ref-components-layout.md +390 -0
- package/skills/cxtms-module-builder/ref-components-specialized.md +477 -0
- package/skills/cxtms-workflow-builder/SKILL.md +438 -0
- package/skills/cxtms-workflow-builder/ref-accounting.md +66 -0
- package/skills/cxtms-workflow-builder/ref-communication.md +169 -0
- package/skills/cxtms-workflow-builder/ref-entity.md +342 -0
- package/skills/cxtms-workflow-builder/ref-expressions-ncalc.md +128 -0
- package/skills/cxtms-workflow-builder/ref-expressions-template.md +161 -0
- package/skills/cxtms-workflow-builder/ref-filetransfer.md +80 -0
- package/skills/cxtms-workflow-builder/ref-flow.md +210 -0
- package/skills/cxtms-workflow-builder/ref-other.md +157 -0
- package/skills/cxtms-workflow-builder/ref-query.md +105 -0
- package/skills/cxtms-workflow-builder/ref-utilities.md +417 -0
- package/templates/module-configuration.yaml +44 -0
- package/templates/module-form.yaml +152 -0
- package/templates/module-grid.yaml +229 -0
- package/templates/module-select.yaml +139 -0
- package/templates/module.yaml +84 -0
- package/templates/workflow-api-tracking.yaml +189 -0
- package/templates/workflow-basic.yaml +76 -0
- package/templates/workflow-document.yaml +155 -0
- package/templates/workflow-entity-trigger.yaml +90 -0
- package/templates/workflow-ftp-edi.yaml +158 -0
- package/templates/workflow-ftp-tracking.yaml +161 -0
- package/templates/workflow-mcp-tool.yaml +112 -0
- package/templates/workflow-public-api.yaml +135 -0
- package/templates/workflow-scheduled-execute.yaml +75 -0
- package/templates/workflow-scheduled.yaml +125 -0
- package/templates/workflow-utility.yaml +96 -0
- package/templates/workflow-webhook.yaml +128 -0
- package/templates/workflow.yaml +140 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema loading and caching utilities
|
|
3
|
+
*/
|
|
4
|
+
import { SchemaEntry } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Recursively loads all JSON schema files from a directory
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadSchemas(schemasDir: string): Map<string, SchemaEntry>;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a relative reference to an absolute path
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveSchemaRef(ref: string, currentPath: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts examples from schema for error reporting
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractExampleFromSchema(schema: any): any;
|
|
17
|
+
//# sourceMappingURL=schemaLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaLoader.d.ts","sourceRoot":"","sources":["../../src/utils/schemaLoader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAwBxE;AAiCD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAczE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAwBzD"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Schema loading and caching utilities
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadSchemas = loadSchemas;
|
|
40
|
+
exports.resolveSchemaRef = resolveSchemaRef;
|
|
41
|
+
exports.extractExampleFromSchema = extractExampleFromSchema;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
/**
|
|
45
|
+
* Recursively loads all JSON schema files from a directory
|
|
46
|
+
*/
|
|
47
|
+
function loadSchemas(schemasDir) {
|
|
48
|
+
const schemas = new Map();
|
|
49
|
+
// Load main schemas.json
|
|
50
|
+
const mainSchemaPath = path.join(schemasDir, 'schemas.json');
|
|
51
|
+
if (fs.existsSync(mainSchemaPath)) {
|
|
52
|
+
const schema = JSON.parse(fs.readFileSync(mainSchemaPath, 'utf-8'));
|
|
53
|
+
schemas.set('schemas.json', {
|
|
54
|
+
schema,
|
|
55
|
+
uri: `file:///${mainSchemaPath.replace(/\\/g, '/')}`
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Load schemas from subdirectories
|
|
59
|
+
const subdirs = ['components', 'fields', 'actions'];
|
|
60
|
+
for (const subdir of subdirs) {
|
|
61
|
+
const subdirPath = path.join(schemasDir, subdir);
|
|
62
|
+
if (fs.existsSync(subdirPath)) {
|
|
63
|
+
loadSchemasFromDir(subdirPath, subdir, schemas);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return schemas;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Recursively loads schemas from a directory
|
|
70
|
+
*/
|
|
71
|
+
function loadSchemasFromDir(dir, relativePath, schemas) {
|
|
72
|
+
const files = fs.readdirSync(dir);
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const filePath = path.join(dir, file);
|
|
75
|
+
const stat = fs.statSync(filePath);
|
|
76
|
+
if (stat.isDirectory()) {
|
|
77
|
+
loadSchemasFromDir(filePath, `${relativePath}/${file}`, schemas);
|
|
78
|
+
}
|
|
79
|
+
else if (file.endsWith('.json')) {
|
|
80
|
+
try {
|
|
81
|
+
const schema = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
82
|
+
const key = `${relativePath}/${file}`;
|
|
83
|
+
schemas.set(key, {
|
|
84
|
+
schema,
|
|
85
|
+
uri: `file:///${filePath.replace(/\\/g, '/')}`
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error(`Error loading schema ${filePath}:`, error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Resolves a relative reference to an absolute path
|
|
96
|
+
*/
|
|
97
|
+
function resolveSchemaRef(ref, currentPath) {
|
|
98
|
+
if (ref.startsWith('file://')) {
|
|
99
|
+
return ref;
|
|
100
|
+
}
|
|
101
|
+
// Handle relative paths
|
|
102
|
+
if (ref.startsWith('../') || ref.startsWith('./')) {
|
|
103
|
+
const currentDir = path.dirname(currentPath);
|
|
104
|
+
const resolved = path.normalize(path.join(currentDir, ref));
|
|
105
|
+
return resolved;
|
|
106
|
+
}
|
|
107
|
+
// Direct file reference
|
|
108
|
+
return ref;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Extracts examples from schema for error reporting
|
|
112
|
+
*/
|
|
113
|
+
function extractExampleFromSchema(schema) {
|
|
114
|
+
if (!schema)
|
|
115
|
+
return undefined;
|
|
116
|
+
// Check for x-example
|
|
117
|
+
if (schema['x-example'] !== undefined) {
|
|
118
|
+
return schema['x-example'];
|
|
119
|
+
}
|
|
120
|
+
// Check for x-examples
|
|
121
|
+
if (schema['x-examples'] !== undefined) {
|
|
122
|
+
return schema['x-examples'];
|
|
123
|
+
}
|
|
124
|
+
// Check for examples array
|
|
125
|
+
if (Array.isArray(schema.examples) && schema.examples.length > 0) {
|
|
126
|
+
return schema.examples[0];
|
|
127
|
+
}
|
|
128
|
+
// Check for enum values
|
|
129
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
130
|
+
return schema.enum;
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=schemaLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaLoader.js","sourceRoot":"","sources":["../../src/utils/schemaLoader.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main module validator
|
|
3
|
+
*/
|
|
4
|
+
import { ValidationResult, ValidatorOptions } from './types';
|
|
5
|
+
export declare class ModuleValidator {
|
|
6
|
+
private ajv;
|
|
7
|
+
private schemas;
|
|
8
|
+
private schemasDir;
|
|
9
|
+
private options;
|
|
10
|
+
constructor(options?: ValidatorOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Register all loaded schemas with Ajv
|
|
13
|
+
*/
|
|
14
|
+
private registerSchemas;
|
|
15
|
+
/**
|
|
16
|
+
* Convert schema file path to schema ID for Ajv
|
|
17
|
+
*/
|
|
18
|
+
private getSchemaId;
|
|
19
|
+
/**
|
|
20
|
+
* Validate a YAML module file
|
|
21
|
+
*/
|
|
22
|
+
validateModule(filePath: string): Promise<ValidationResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Normalize file path: forward slashes, strip leading ./
|
|
25
|
+
*/
|
|
26
|
+
private normalizeFilePath;
|
|
27
|
+
/**
|
|
28
|
+
* Validate top-level module structure
|
|
29
|
+
*/
|
|
30
|
+
private validateModuleStructure;
|
|
31
|
+
/**
|
|
32
|
+
* Validate components array
|
|
33
|
+
*/
|
|
34
|
+
private validateComponents;
|
|
35
|
+
/**
|
|
36
|
+
* Validate a single component
|
|
37
|
+
*/
|
|
38
|
+
private validateComponent;
|
|
39
|
+
/**
|
|
40
|
+
* Recursively validate nested components
|
|
41
|
+
*/
|
|
42
|
+
private validateNestedComponent;
|
|
43
|
+
/**
|
|
44
|
+
* Validate component props that may contain nested components
|
|
45
|
+
*/
|
|
46
|
+
private validateComponentProps;
|
|
47
|
+
/**
|
|
48
|
+
* Convert Ajv errors to our error format
|
|
49
|
+
*/
|
|
50
|
+
private addAjvErrors;
|
|
51
|
+
/**
|
|
52
|
+
* Validate routes array
|
|
53
|
+
*/
|
|
54
|
+
private validateRoutes;
|
|
55
|
+
/**
|
|
56
|
+
* Validate entities array
|
|
57
|
+
*/
|
|
58
|
+
private validateEntities;
|
|
59
|
+
/**
|
|
60
|
+
* Validate configurations array
|
|
61
|
+
*/
|
|
62
|
+
private validateConfigurations;
|
|
63
|
+
/**
|
|
64
|
+
* Check for deprecated properties
|
|
65
|
+
*/
|
|
66
|
+
private checkDeprecatedProperties;
|
|
67
|
+
/**
|
|
68
|
+
* Create validation result
|
|
69
|
+
*/
|
|
70
|
+
private createResult;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EACL,gBAAgB,EAGhB,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAOjB,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAA6B;gBAEhC,OAAO,GAAE,gBAAqB;IA2B1C;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgEjE;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAyE/B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAsCzB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAwD/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAuB9B;;OAEG;IACH,OAAO,CAAC,YAAY;IAkBpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAwBtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAwB9B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAqBjC;;OAEG;IACH,OAAO,CAAC,YAAY;CAwBrB"}
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Main module validator
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.ModuleValidator = void 0;
|
|
43
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
44
|
+
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
48
|
+
const schemaLoader_1 = require("./utils/schemaLoader");
|
|
49
|
+
class ModuleValidator {
|
|
50
|
+
constructor(options = {}) {
|
|
51
|
+
this.schemasDir = options.schemasPath || path.join(__dirname, '../schemas');
|
|
52
|
+
this.options = {
|
|
53
|
+
schemasPath: this.schemasDir,
|
|
54
|
+
strictMode: options.strictMode ?? true,
|
|
55
|
+
includeWarnings: options.includeWarnings ?? true
|
|
56
|
+
};
|
|
57
|
+
// Initialize Ajv with Draft 7 support
|
|
58
|
+
this.ajv = new ajv_1.default({
|
|
59
|
+
strict: false,
|
|
60
|
+
allErrors: true,
|
|
61
|
+
verbose: true,
|
|
62
|
+
validateFormats: true,
|
|
63
|
+
allowUnionTypes: true
|
|
64
|
+
});
|
|
65
|
+
// Add format validators
|
|
66
|
+
(0, ajv_formats_1.default)(this.ajv);
|
|
67
|
+
// Load all schemas
|
|
68
|
+
this.schemas = (0, schemaLoader_1.loadSchemas)(this.schemasDir);
|
|
69
|
+
// Register schemas with Ajv
|
|
70
|
+
this.registerSchemas();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Register all loaded schemas with Ajv
|
|
74
|
+
*/
|
|
75
|
+
registerSchemas() {
|
|
76
|
+
// First, add all schemas to Ajv
|
|
77
|
+
for (const [key, entry] of this.schemas.entries()) {
|
|
78
|
+
try {
|
|
79
|
+
const schemaId = this.getSchemaId(key);
|
|
80
|
+
this.ajv.addSchema(entry.schema, schemaId);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(`Error adding schema ${key}:`, error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Convert schema file path to schema ID for Ajv
|
|
89
|
+
*/
|
|
90
|
+
getSchemaId(key) {
|
|
91
|
+
if (key === 'schemas.json') {
|
|
92
|
+
return 'schemas.json';
|
|
93
|
+
}
|
|
94
|
+
return key;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate a YAML module file
|
|
98
|
+
*/
|
|
99
|
+
async validateModule(filePath) {
|
|
100
|
+
const errors = [];
|
|
101
|
+
const warnings = [];
|
|
102
|
+
try {
|
|
103
|
+
// Check if file exists
|
|
104
|
+
if (!fs.existsSync(filePath)) {
|
|
105
|
+
errors.push({
|
|
106
|
+
type: 'file_not_found',
|
|
107
|
+
path: filePath,
|
|
108
|
+
message: `File not found: ${filePath}`
|
|
109
|
+
});
|
|
110
|
+
return this.createResult(filePath, errors, warnings);
|
|
111
|
+
}
|
|
112
|
+
// Read and parse YAML
|
|
113
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
114
|
+
let moduleData;
|
|
115
|
+
try {
|
|
116
|
+
moduleData = yaml_1.default.parse(content);
|
|
117
|
+
}
|
|
118
|
+
catch (yamlError) {
|
|
119
|
+
errors.push({
|
|
120
|
+
type: 'yaml_syntax_error',
|
|
121
|
+
path: filePath,
|
|
122
|
+
message: `YAML syntax error: ${yamlError.message}`
|
|
123
|
+
});
|
|
124
|
+
return this.createResult(filePath, errors, warnings);
|
|
125
|
+
}
|
|
126
|
+
// Validate module structure
|
|
127
|
+
this.validateModuleStructure(moduleData, errors, warnings, filePath);
|
|
128
|
+
// Validate components
|
|
129
|
+
if (moduleData.components && Array.isArray(moduleData.components)) {
|
|
130
|
+
this.validateComponents(moduleData.components, errors, warnings);
|
|
131
|
+
}
|
|
132
|
+
// Validate routes
|
|
133
|
+
if (moduleData.routes && Array.isArray(moduleData.routes)) {
|
|
134
|
+
this.validateRoutes(moduleData.routes, errors, warnings);
|
|
135
|
+
}
|
|
136
|
+
// Validate entities
|
|
137
|
+
if (moduleData.entities && Array.isArray(moduleData.entities)) {
|
|
138
|
+
this.validateEntities(moduleData.entities, errors, warnings);
|
|
139
|
+
}
|
|
140
|
+
// Validate configurations
|
|
141
|
+
if (moduleData.configurations && Array.isArray(moduleData.configurations)) {
|
|
142
|
+
this.validateConfigurations(moduleData.configurations, errors, warnings);
|
|
143
|
+
}
|
|
144
|
+
return this.createResult(filePath, errors, warnings);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
errors.push({
|
|
148
|
+
type: 'unexpected_error',
|
|
149
|
+
path: filePath,
|
|
150
|
+
message: `Unexpected error: ${error.message}`
|
|
151
|
+
});
|
|
152
|
+
return this.createResult(filePath, errors, warnings);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Normalize file path: forward slashes, strip leading ./
|
|
157
|
+
*/
|
|
158
|
+
normalizeFilePath(p) {
|
|
159
|
+
return p.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Validate top-level module structure
|
|
163
|
+
*/
|
|
164
|
+
validateModuleStructure(moduleData, errors, warnings, filePath) {
|
|
165
|
+
// Check required top-level properties
|
|
166
|
+
if (!moduleData.module) {
|
|
167
|
+
errors.push({
|
|
168
|
+
type: 'missing_property',
|
|
169
|
+
path: 'module',
|
|
170
|
+
message: 'Missing required property: module'
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (!moduleData.components) {
|
|
175
|
+
errors.push({
|
|
176
|
+
type: 'missing_property',
|
|
177
|
+
path: 'components',
|
|
178
|
+
message: 'Missing required property: components'
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
// Validate module metadata
|
|
182
|
+
const module = moduleData.module;
|
|
183
|
+
if (!module.name) {
|
|
184
|
+
errors.push({
|
|
185
|
+
type: 'missing_property',
|
|
186
|
+
path: 'module.name',
|
|
187
|
+
message: 'Missing required property: module.name'
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (!module.appModuleId) {
|
|
191
|
+
errors.push({
|
|
192
|
+
type: 'missing_property',
|
|
193
|
+
path: 'module.appModuleId',
|
|
194
|
+
message: 'Missing required property: module.appModuleId'
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (!module.displayName) {
|
|
198
|
+
errors.push({
|
|
199
|
+
type: 'missing_property',
|
|
200
|
+
path: 'module.displayName',
|
|
201
|
+
message: 'Missing required property: module.displayName'
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// filePath / fileName deprecation and validation
|
|
205
|
+
if (module.fileName && !module.filePath) {
|
|
206
|
+
warnings.push({
|
|
207
|
+
type: 'deprecated_property',
|
|
208
|
+
path: 'module.fileName',
|
|
209
|
+
message: 'Use "filePath" instead of "fileName" in module section'
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const declaredPath = module.filePath ?? module.fileName;
|
|
213
|
+
if (declaredPath && filePath) {
|
|
214
|
+
const normalizedActual = this.normalizeFilePath(filePath);
|
|
215
|
+
const normalizedDeclared = this.normalizeFilePath(declaredPath);
|
|
216
|
+
if (!normalizedActual.endsWith(normalizedDeclared)) {
|
|
217
|
+
warnings.push({
|
|
218
|
+
type: 'file_path_mismatch',
|
|
219
|
+
path: 'module.filePath',
|
|
220
|
+
message: `Declared filePath "${normalizedDeclared}" does not match actual file path "${normalizedActual}"`
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Validate components array
|
|
227
|
+
*/
|
|
228
|
+
validateComponents(components, errors, warnings) {
|
|
229
|
+
components.forEach((component, index) => {
|
|
230
|
+
const componentPath = `components[${index}]`;
|
|
231
|
+
this.validateComponent(component, componentPath, errors, warnings);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Validate a single component
|
|
236
|
+
*/
|
|
237
|
+
validateComponent(component, componentPath, errors, warnings) {
|
|
238
|
+
if (!component || typeof component !== 'object') {
|
|
239
|
+
errors.push({
|
|
240
|
+
type: 'invalid_component',
|
|
241
|
+
path: componentPath,
|
|
242
|
+
message: 'Component must be an object'
|
|
243
|
+
});
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// Check for required properties
|
|
247
|
+
if (!component.name) {
|
|
248
|
+
errors.push({
|
|
249
|
+
type: 'missing_property',
|
|
250
|
+
path: `${componentPath}.name`,
|
|
251
|
+
message: 'Component must have a name property'
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
// Validate layout if present
|
|
255
|
+
if (component.layout) {
|
|
256
|
+
this.validateNestedComponent(component.layout, `${componentPath}.layout`, errors, warnings);
|
|
257
|
+
}
|
|
258
|
+
// Check for deprecated properties
|
|
259
|
+
this.checkDeprecatedProperties(component, componentPath, warnings);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Recursively validate nested components
|
|
263
|
+
*/
|
|
264
|
+
validateNestedComponent(component, componentPath, errors, warnings) {
|
|
265
|
+
if (!component || typeof component !== 'object') {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const componentType = component.component;
|
|
269
|
+
if (!componentType) {
|
|
270
|
+
errors.push({
|
|
271
|
+
type: 'missing_property',
|
|
272
|
+
path: `${componentPath}.component`,
|
|
273
|
+
message: 'Component must have a component type'
|
|
274
|
+
});
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Try to validate against specific component schema
|
|
278
|
+
const schemaKey = `components/${componentType}.json`;
|
|
279
|
+
if (this.schemas.has(schemaKey)) {
|
|
280
|
+
try {
|
|
281
|
+
const validate = this.ajv.getSchema(schemaKey);
|
|
282
|
+
if (validate && !validate(component)) {
|
|
283
|
+
this.addAjvErrors(validate.errors, componentPath, errors);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
// Schema not found or validation error
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Recursively validate children
|
|
291
|
+
if (component.children && Array.isArray(component.children)) {
|
|
292
|
+
component.children.forEach((child, index) => {
|
|
293
|
+
this.validateNestedComponent(child, `${componentPath}.children[${index}]`, errors, warnings);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
// Recursively validate props that may contain components
|
|
297
|
+
if (component.props) {
|
|
298
|
+
this.validateComponentProps(component.props, `${componentPath}.props`, errors, warnings);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Validate component props that may contain nested components
|
|
303
|
+
*/
|
|
304
|
+
validateComponentProps(props, propsPath, errors, warnings) {
|
|
305
|
+
if (!props || typeof props !== 'object') {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
// Check for nested layouts or components in props
|
|
309
|
+
for (const [key, value] of Object.entries(props)) {
|
|
310
|
+
if (value && typeof value === 'object' && value.component) {
|
|
311
|
+
this.validateNestedComponent(value, `${propsPath}.${key}`, errors, warnings);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Convert Ajv errors to our error format
|
|
317
|
+
*/
|
|
318
|
+
addAjvErrors(ajvErrors, basePath, errors) {
|
|
319
|
+
if (!ajvErrors)
|
|
320
|
+
return;
|
|
321
|
+
for (const error of ajvErrors) {
|
|
322
|
+
const errorPath = `${basePath}${error.instancePath}`;
|
|
323
|
+
errors.push({
|
|
324
|
+
type: 'schema_violation',
|
|
325
|
+
path: errorPath,
|
|
326
|
+
message: error.message || 'Schema validation failed',
|
|
327
|
+
schemaPath: error.schemaPath
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Validate routes array
|
|
333
|
+
*/
|
|
334
|
+
validateRoutes(routes, errors, warnings) {
|
|
335
|
+
routes.forEach((route, index) => {
|
|
336
|
+
const routePath = `routes[${index}]`;
|
|
337
|
+
if (!route.path) {
|
|
338
|
+
errors.push({
|
|
339
|
+
type: 'missing_property',
|
|
340
|
+
path: `${routePath}.path`,
|
|
341
|
+
message: 'Route must have a path property'
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
if (!route.component) {
|
|
345
|
+
errors.push({
|
|
346
|
+
type: 'missing_property',
|
|
347
|
+
path: `${routePath}.component`,
|
|
348
|
+
message: 'Route must have a component property'
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Validate entities array
|
|
355
|
+
*/
|
|
356
|
+
validateEntities(entities, errors, warnings) {
|
|
357
|
+
entities.forEach((entity, index) => {
|
|
358
|
+
const entityPath = `entities[${index}]`;
|
|
359
|
+
if (!entity.name) {
|
|
360
|
+
errors.push({
|
|
361
|
+
type: 'missing_property',
|
|
362
|
+
path: `${entityPath}.name`,
|
|
363
|
+
message: 'Entity must have a name property'
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Validate configurations array
|
|
370
|
+
*/
|
|
371
|
+
validateConfigurations(configurations, errors, warnings) {
|
|
372
|
+
configurations.forEach((config, index) => {
|
|
373
|
+
const configPath = `configurations[${index}]`;
|
|
374
|
+
if (!config.configName) {
|
|
375
|
+
errors.push({
|
|
376
|
+
type: 'missing_property',
|
|
377
|
+
path: `${configPath}.configName`,
|
|
378
|
+
message: 'Configuration must have a configName property'
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
if (!config.component) {
|
|
382
|
+
errors.push({
|
|
383
|
+
type: 'missing_property',
|
|
384
|
+
path: `${configPath}.component`,
|
|
385
|
+
message: 'Configuration must have a component property'
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Check for deprecated properties
|
|
392
|
+
*/
|
|
393
|
+
checkDeprecatedProperties(obj, path, warnings) {
|
|
394
|
+
const deprecations = {
|
|
395
|
+
key: 'Use "name" instead of "key"',
|
|
396
|
+
type: 'Use "fieldType" instead of "type" for fields'
|
|
397
|
+
};
|
|
398
|
+
for (const [oldProp, message] of Object.entries(deprecations)) {
|
|
399
|
+
if (oldProp in obj) {
|
|
400
|
+
warnings.push({
|
|
401
|
+
type: 'deprecated_property',
|
|
402
|
+
path: `${path}.${oldProp}`,
|
|
403
|
+
message
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Create validation result
|
|
410
|
+
*/
|
|
411
|
+
createResult(filePath, errors, warnings) {
|
|
412
|
+
const errorsByType = {};
|
|
413
|
+
errors.forEach(error => {
|
|
414
|
+
errorsByType[error.type] = (errorsByType[error.type] || 0) + 1;
|
|
415
|
+
});
|
|
416
|
+
return {
|
|
417
|
+
isValid: errors.length === 0,
|
|
418
|
+
errors,
|
|
419
|
+
warnings: this.options.includeWarnings ? warnings : [],
|
|
420
|
+
summary: {
|
|
421
|
+
file: filePath,
|
|
422
|
+
timestamp: new Date().toISOString(),
|
|
423
|
+
status: errors.length === 0 ? 'PASSED' : 'FAILED',
|
|
424
|
+
errorCount: errors.length,
|
|
425
|
+
warningCount: warnings.length,
|
|
426
|
+
errorsByType
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
exports.ModuleValidator = ModuleValidator;
|
|
432
|
+
//# sourceMappingURL=validator.js.map
|