@cxtms/cx-schema 1.0.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.
Files changed (133) hide show
  1. package/README.md +384 -0
  2. package/dist/cli.d.ts +6 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +1523 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +7 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +11 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/types.d.ts +111 -0
  11. package/dist/types.d.ts.map +1 -0
  12. package/dist/types.js +6 -0
  13. package/dist/types.js.map +1 -0
  14. package/dist/utils/schemaLoader.d.ts +17 -0
  15. package/dist/utils/schemaLoader.d.ts.map +1 -0
  16. package/dist/utils/schemaLoader.js +134 -0
  17. package/dist/utils/schemaLoader.js.map +1 -0
  18. package/dist/validator.d.ts +64 -0
  19. package/dist/validator.d.ts.map +1 -0
  20. package/dist/validator.js +380 -0
  21. package/dist/validator.js.map +1 -0
  22. package/dist/workflowValidator.d.ts +64 -0
  23. package/dist/workflowValidator.d.ts.map +1 -0
  24. package/dist/workflowValidator.js +410 -0
  25. package/dist/workflowValidator.js.map +1 -0
  26. package/package.json +50 -0
  27. package/schemas/actions/all.json +26 -0
  28. package/schemas/actions/confirm.json +21 -0
  29. package/schemas/actions/consoleLog.json +16 -0
  30. package/schemas/actions/dialog.json +25 -0
  31. package/schemas/actions/fileDownload.json +16 -0
  32. package/schemas/actions/forEach.json +31 -0
  33. package/schemas/actions/if.json +12 -0
  34. package/schemas/actions/mutation.json +25 -0
  35. package/schemas/actions/navigate.json +18 -0
  36. package/schemas/actions/navigateBack.json +22 -0
  37. package/schemas/actions/navigateBackOrClose.json +21 -0
  38. package/schemas/actions/notification.json +19 -0
  39. package/schemas/actions/openBarcodeScanner.json +104 -0
  40. package/schemas/actions/query.json +32 -0
  41. package/schemas/actions/refresh.json +13 -0
  42. package/schemas/actions/resetDirtyState.json +22 -0
  43. package/schemas/actions/setFields.json +21 -0
  44. package/schemas/actions/setStore.json +13 -0
  45. package/schemas/actions/validateForm.json +15 -0
  46. package/schemas/actions/workflow.json +24 -0
  47. package/schemas/components/README.md +147 -0
  48. package/schemas/components/appComponent.json +50 -0
  49. package/schemas/components/barcodeScanner.json +69 -0
  50. package/schemas/components/button.json +123 -0
  51. package/schemas/components/calendar.json +489 -0
  52. package/schemas/components/card.json +176 -0
  53. package/schemas/components/collection.json +54 -0
  54. package/schemas/components/dataGrid.json +119 -0
  55. package/schemas/components/datasource.json +151 -0
  56. package/schemas/components/dropdown.json +57 -0
  57. package/schemas/components/field-collection.json +618 -0
  58. package/schemas/components/field.json +265 -0
  59. package/schemas/components/form.json +234 -0
  60. package/schemas/components/index.json +68 -0
  61. package/schemas/components/layout.json +69 -0
  62. package/schemas/components/module.json +138 -0
  63. package/schemas/components/navDropdown.json +36 -0
  64. package/schemas/components/navbar.json +78 -0
  65. package/schemas/components/navbarItem.json +28 -0
  66. package/schemas/components/navbarLink.json +36 -0
  67. package/schemas/components/row.json +31 -0
  68. package/schemas/components/tab.json +34 -0
  69. package/schemas/components/tabs.json +35 -0
  70. package/schemas/components/timeline.json +172 -0
  71. package/schemas/components/timelineGrid.json +324 -0
  72. package/schemas/fields/README.md +66 -0
  73. package/schemas/fields/attachment.json +156 -0
  74. package/schemas/fields/autocomplete-googleplaces.json +130 -0
  75. package/schemas/fields/checkbox.json +82 -0
  76. package/schemas/fields/date.json +88 -0
  77. package/schemas/fields/datetime.json +75 -0
  78. package/schemas/fields/email.json +75 -0
  79. package/schemas/fields/index.json +53 -0
  80. package/schemas/fields/number.json +91 -0
  81. package/schemas/fields/password.json +70 -0
  82. package/schemas/fields/radio.json +94 -0
  83. package/schemas/fields/rangedatetime.json +56 -0
  84. package/schemas/fields/select-async.json +334 -0
  85. package/schemas/fields/select.json +115 -0
  86. package/schemas/fields/tel.json +79 -0
  87. package/schemas/fields/text.json +86 -0
  88. package/schemas/fields/textarea.json +95 -0
  89. package/schemas/fields/time.json +91 -0
  90. package/schemas/fields/url.json +74 -0
  91. package/schemas/schema.graphql +10492 -0
  92. package/schemas/schemas.json +598 -0
  93. package/schemas/workflows/activity.json +111 -0
  94. package/schemas/workflows/common/condition.json +48 -0
  95. package/schemas/workflows/common/expression.json +76 -0
  96. package/schemas/workflows/common/mapping.json +134 -0
  97. package/schemas/workflows/input.json +76 -0
  98. package/schemas/workflows/output.json +41 -0
  99. package/schemas/workflows/schedule.json +26 -0
  100. package/schemas/workflows/tasks/accounting-transaction.json +95 -0
  101. package/schemas/workflows/tasks/all.json +34 -0
  102. package/schemas/workflows/tasks/attachment.json +94 -0
  103. package/schemas/workflows/tasks/charge.json +90 -0
  104. package/schemas/workflows/tasks/commodity.json +89 -0
  105. package/schemas/workflows/tasks/contact.json +82 -0
  106. package/schemas/workflows/tasks/csv.json +79 -0
  107. package/schemas/workflows/tasks/document-render.json +105 -0
  108. package/schemas/workflows/tasks/document-send.json +84 -0
  109. package/schemas/workflows/tasks/email-send.json +110 -0
  110. package/schemas/workflows/tasks/error.json +72 -0
  111. package/schemas/workflows/tasks/export.json +90 -0
  112. package/schemas/workflows/tasks/foreach.json +69 -0
  113. package/schemas/workflows/tasks/generic.json +47 -0
  114. package/schemas/workflows/tasks/graphql.json +78 -0
  115. package/schemas/workflows/tasks/httpRequest.json +119 -0
  116. package/schemas/workflows/tasks/job.json +88 -0
  117. package/schemas/workflows/tasks/log.json +73 -0
  118. package/schemas/workflows/tasks/map.json +58 -0
  119. package/schemas/workflows/tasks/order.json +87 -0
  120. package/schemas/workflows/tasks/payment.json +85 -0
  121. package/schemas/workflows/tasks/setVariable.json +76 -0
  122. package/schemas/workflows/tasks/switch.json +75 -0
  123. package/schemas/workflows/tasks/template.json +73 -0
  124. package/schemas/workflows/tasks/validation.json +90 -0
  125. package/schemas/workflows/tasks/while.json +53 -0
  126. package/schemas/workflows/tasks/workflow-execute.json +82 -0
  127. package/schemas/workflows/trigger.json +86 -0
  128. package/schemas/workflows/variable.json +46 -0
  129. package/schemas/workflows/workflow.json +172 -0
  130. package/scripts/postinstall.js +161 -0
  131. package/scripts/setup-vscode.js +80 -0
  132. package/templates/module.yaml +83 -0
  133. package/templates/workflow.yaml +100 -0
@@ -0,0 +1,86 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Workflow Trigger",
4
+ "description": "Definition of a workflow trigger",
5
+ "type": "object",
6
+ "properties": {
7
+ "type": {
8
+ "type": "string",
9
+ "enum": ["Manual", "Entity"],
10
+ "description": "Trigger type"
11
+ },
12
+ "displayName": {
13
+ "type": "string",
14
+ "description": "Display name for manual triggers (button text)"
15
+ },
16
+ "entityName": {
17
+ "type": "string",
18
+ "description": "Entity name for the trigger context"
19
+ },
20
+ "eventType": {
21
+ "type": "string",
22
+ "enum": ["Added", "Modified", "Deleted"],
23
+ "description": "Entity event type (for Entity triggers)"
24
+ },
25
+ "position": {
26
+ "type": "string",
27
+ "enum": ["Before", "After"],
28
+ "description": "When to execute relative to entity operation"
29
+ },
30
+ "conditions": {
31
+ "oneOf": [
32
+ {
33
+ "type": "string",
34
+ "description": "Single condition expression"
35
+ },
36
+ {
37
+ "type": "array",
38
+ "items": {
39
+ "oneOf": [
40
+ {
41
+ "type": "string"
42
+ },
43
+ {
44
+ "type": "object",
45
+ "properties": {
46
+ "expression": {
47
+ "type": "string"
48
+ }
49
+ },
50
+ "required": ["expression"]
51
+ }
52
+ ]
53
+ },
54
+ "description": "Array of condition expressions"
55
+ }
56
+ ],
57
+ "description": "Conditions for trigger activation"
58
+ },
59
+ "additionalProperties": {
60
+ "type": "object",
61
+ "description": "Additional trigger properties",
62
+ "properties": {
63
+ "silent": {
64
+ "type": "boolean"
65
+ }
66
+ },
67
+ "additionalProperties": true
68
+ }
69
+ },
70
+ "allOf": [
71
+ {
72
+ "if": {
73
+ "properties": {
74
+ "type": {
75
+ "const": "Entity"
76
+ }
77
+ },
78
+ "required": ["type"]
79
+ },
80
+ "then": {
81
+ "required": ["entityName", "eventType"]
82
+ }
83
+ }
84
+ ],
85
+ "additionalProperties": true
86
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Workflow Variable",
4
+ "description": "Definition of a workflow variable",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
10
+ "description": "Variable name"
11
+ },
12
+ "value": {
13
+ "description": "Static variable value or template expression"
14
+ },
15
+ "fromConfig": {
16
+ "oneOf": [
17
+ {
18
+ "type": "string",
19
+ "description": "Configuration key to load value from"
20
+ },
21
+ {
22
+ "type": "object",
23
+ "properties": {
24
+ "configName": {
25
+ "type": "string",
26
+ "description": "Configuration name (e.g., 'apps.novaposhta')"
27
+ },
28
+ "key": {
29
+ "type": "string",
30
+ "description": "Optional key within configuration"
31
+ }
32
+ },
33
+ "required": ["configName"],
34
+ "additionalProperties": true
35
+ }
36
+ ],
37
+ "description": "Load value from configuration"
38
+ },
39
+ "expression": {
40
+ "type": "string",
41
+ "description": "NCalc expression to compute value"
42
+ }
43
+ },
44
+ "required": ["name"],
45
+ "additionalProperties": true
46
+ }
@@ -0,0 +1,172 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "CargoXplorer Workflow",
4
+ "description": "Schema for CargoXplorer workflow YAML files",
5
+ "type": "object",
6
+ "properties": {
7
+ "workflow": {
8
+ "type": "object",
9
+ "description": "Workflow metadata and configuration",
10
+ "properties": {
11
+ "workflowId": {
12
+ "type": "string",
13
+ "format": "uuid",
14
+ "description": "Unique workflow identifier (UUID)"
15
+ },
16
+ "name": {
17
+ "type": "string",
18
+ "minLength": 1,
19
+ "description": "Workflow name"
20
+ },
21
+ "description": {
22
+ "type": "string",
23
+ "description": "Workflow description"
24
+ },
25
+ "version": {
26
+ "type": "string",
27
+ "description": "Workflow version (e.g., '1.0')"
28
+ },
29
+ "executionMode": {
30
+ "type": "string",
31
+ "enum": ["Sync", "Async"],
32
+ "description": "Execution mode - synchronous or asynchronous"
33
+ },
34
+ "logLevel": {
35
+ "type": "string",
36
+ "enum": ["None", "Trace", "Debug", "Information", "Warning", "Error"],
37
+ "description": "Logging level for workflow execution"
38
+ },
39
+ "isActive": {
40
+ "type": "boolean",
41
+ "description": "Whether the workflow is active"
42
+ },
43
+ "enableAudit": {
44
+ "type": "boolean",
45
+ "description": "Enable audit logging"
46
+ },
47
+ "enableTransaction": {
48
+ "type": "boolean",
49
+ "description": "Enable transaction support"
50
+ },
51
+ "enableActionEvents": {
52
+ "type": "boolean",
53
+ "description": "Enable action events"
54
+ },
55
+ "priority": {
56
+ "type": "number",
57
+ "description": "Workflow priority (higher = higher priority)"
58
+ },
59
+ "tags": {
60
+ "type": "array",
61
+ "items": {
62
+ "type": "string"
63
+ },
64
+ "description": "Tags for categorization and filtering"
65
+ },
66
+ "workflowType": {
67
+ "type": "string",
68
+ "enum": ["Document", "Quote", "EmailTemplate"],
69
+ "description": "Workflow type classification"
70
+ },
71
+ "runAs": {
72
+ "type": "string",
73
+ "description": "User context for workflow execution"
74
+ },
75
+ "concurrency": {
76
+ "type": "object",
77
+ "properties": {
78
+ "group": {
79
+ "type": "string",
80
+ "description": "Concurrency group identifier"
81
+ },
82
+ "waitTime": {
83
+ "type": "number",
84
+ "description": "Seconds to wait for lock"
85
+ }
86
+ },
87
+ "additionalProperties": true
88
+ },
89
+ "fileName": {
90
+ "type": "string",
91
+ "description": "Path to the workflow YAML file"
92
+ },
93
+ "actionEvent": {
94
+ "type": "object",
95
+ "description": "Workflow action event configuration",
96
+ "additionalProperties": true
97
+ },
98
+ "additionalProperties": {
99
+ "type": "object",
100
+ "description": "Custom additional properties",
101
+ "additionalProperties": true
102
+ }
103
+ },
104
+ "required": ["workflowId", "name"],
105
+ "additionalProperties": true
106
+ },
107
+ "inputs": {
108
+ "type": ["array", "null"],
109
+ "description": "Workflow input parameters",
110
+ "items": {
111
+ "$ref": "input.json"
112
+ }
113
+ },
114
+ "outputs": {
115
+ "type": ["array", "null"],
116
+ "description": "Workflow output definitions",
117
+ "items": {
118
+ "$ref": "output.json"
119
+ }
120
+ },
121
+ "variables": {
122
+ "type": ["array", "null"],
123
+ "description": "Workflow variables",
124
+ "items": {
125
+ "$ref": "variable.json"
126
+ }
127
+ },
128
+ "activities": {
129
+ "type": "array",
130
+ "description": "Workflow activities containing steps",
131
+ "items": {
132
+ "$ref": "activity.json"
133
+ },
134
+ "minItems": 1
135
+ },
136
+ "triggers": {
137
+ "type": "array",
138
+ "description": "Workflow triggers",
139
+ "items": {
140
+ "$ref": "trigger.json"
141
+ }
142
+ },
143
+ "schedules": {
144
+ "type": "array",
145
+ "description": "Scheduled execution configurations",
146
+ "items": {
147
+ "$ref": "schedule.json"
148
+ }
149
+ },
150
+ "events": {
151
+ "type": "object",
152
+ "description": "Workflow-level event handlers",
153
+ "properties": {
154
+ "onWorkflowStarted": {
155
+ "type": "array",
156
+ "description": "Steps to execute when workflow starts"
157
+ },
158
+ "onWorkflowExecuted": {
159
+ "type": "array",
160
+ "description": "Steps to execute when workflow completes"
161
+ },
162
+ "onWorkflowFailed": {
163
+ "type": "array",
164
+ "description": "Steps to execute when workflow fails"
165
+ }
166
+ },
167
+ "additionalProperties": true
168
+ }
169
+ },
170
+ "required": ["workflow", "activities"],
171
+ "additionalProperties": true
172
+ }
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script to create .cx-schema folder in the project root
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ function findProjectRoot() {
11
+ let currentDir = process.cwd();
12
+
13
+ // Walk up the directory tree to find package.json
14
+ while (currentDir !== path.dirname(currentDir)) {
15
+ const packageJsonPath = path.join(currentDir, 'package.json');
16
+ if (fs.existsSync(packageJsonPath)) {
17
+ // Check if this is not the cx-schema-validator package itself
18
+ try {
19
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
20
+ if (packageJson.name !== 'cx-schema-validator') {
21
+ return currentDir;
22
+ }
23
+ } catch (error) {
24
+ // Continue searching
25
+ }
26
+ }
27
+ currentDir = path.dirname(currentDir);
28
+ }
29
+
30
+ return null;
31
+ }
32
+
33
+ function copyDirectory(src, dest) {
34
+ // Create destination directory if it doesn't exist
35
+ if (!fs.existsSync(dest)) {
36
+ fs.mkdirSync(dest, { recursive: true });
37
+ }
38
+
39
+ // Read directory contents
40
+ const entries = fs.readdirSync(src, { withFileTypes: true });
41
+
42
+ for (const entry of entries) {
43
+ const srcPath = path.join(src, entry.name);
44
+ const destPath = path.join(dest, entry.name);
45
+
46
+ if (entry.isDirectory()) {
47
+ copyDirectory(srcPath, destPath);
48
+ } else {
49
+ fs.copyFileSync(srcPath, destPath);
50
+ }
51
+ }
52
+ }
53
+
54
+ function createValidationScript(projectRoot) {
55
+ const scriptContent = `#!/usr/bin/env node
56
+
57
+ /**
58
+ * Local validation script
59
+ * This script uses the schemas in .cx-schema to validate modules
60
+ */
61
+
62
+ const { ModuleValidator } = require('cx-schema-validator');
63
+ const path = require('path');
64
+
65
+ async function main() {
66
+ const args = process.argv.slice(2);
67
+
68
+ if (args.length === 0) {
69
+ console.error('Usage: node .cx-schema/validate.js <module-file>');
70
+ process.exit(1);
71
+ }
72
+
73
+ const schemasPath = path.join(__dirname);
74
+ const validator = new ModuleValidator({ schemasPath });
75
+
76
+ for (const file of args) {
77
+ const result = await validator.validateModule(file);
78
+
79
+ console.log(\`\\nValidation result for \${file}:\`);
80
+ console.log(\` Status: \${result.summary.status}\`);
81
+ console.log(\` Errors: \${result.summary.errorCount}\`);
82
+ console.log(\` Warnings: \${result.summary.warningCount}\`);
83
+
84
+ if (!result.isValid) {
85
+ console.log('\\nErrors:');
86
+ result.errors.forEach((error, index) => {
87
+ console.log(\` [\${index + 1}] \${error.type}: \${error.message}\`);
88
+ console.log(\` Path: \${error.path}\`);
89
+ });
90
+ process.exit(1);
91
+ }
92
+ }
93
+
94
+ console.log('\\nAll validations passed!');
95
+ }
96
+
97
+ main().catch(error => {
98
+ console.error('Error:', error);
99
+ process.exit(1);
100
+ });
101
+ `;
102
+
103
+ const scriptPath = path.join(projectRoot, '.cx-schema', 'validate.js');
104
+ fs.writeFileSync(scriptPath, scriptContent, 'utf-8');
105
+
106
+ // Make it executable on Unix-like systems
107
+ try {
108
+ fs.chmodSync(scriptPath, '755');
109
+ } catch (error) {
110
+ // Ignore chmod errors on Windows
111
+ }
112
+ }
113
+
114
+ function main() {
115
+ console.log('CX Schema Validator: Running postinstall...');
116
+
117
+ // Find project root
118
+ const projectRoot = findProjectRoot();
119
+ if (!projectRoot) {
120
+ console.log('Warning: Could not find project root. Skipping .cx-schema creation.');
121
+ return;
122
+ }
123
+
124
+ console.log(`Project root: ${projectRoot}`);
125
+
126
+ // Create .cx-schema directory
127
+ const cxSchemaDir = path.join(projectRoot, '.cx-schema');
128
+
129
+ if (fs.existsSync(cxSchemaDir)) {
130
+ console.log('.cx-schema directory already exists. Updating schemas...');
131
+ } else {
132
+ console.log('Creating .cx-schema directory...');
133
+ fs.mkdirSync(cxSchemaDir, { recursive: true });
134
+ }
135
+
136
+ // Copy schemas
137
+ const schemasSource = path.join(__dirname, '..', 'schemas');
138
+ console.log(`Copying schemas from ${schemasSource}...`);
139
+
140
+ try {
141
+ copyDirectory(schemasSource, cxSchemaDir);
142
+ console.log('Schemas copied successfully!');
143
+ } catch (error) {
144
+ console.error('Error copying schemas:', error.message);
145
+ process.exit(1);
146
+ }
147
+
148
+ // Create validation script
149
+ console.log('Creating validation script...');
150
+ createValidationScript(projectRoot);
151
+
152
+ console.log('✓ CX Schema Validator installed successfully!');
153
+ console.log('\nUsage:');
154
+ console.log(' npx cx-validate modules/your-module.yaml');
155
+ console.log(' node .cx-schema/validate.js modules/your-module.yaml');
156
+ }
157
+
158
+ // Only run if this is not being installed as a dependency of cx-schema-validator itself
159
+ if (!process.env.npm_package_name || process.env.npm_package_name !== 'cx-schema-validator') {
160
+ main();
161
+ }
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * VS Code integration setup script
5
+ * Creates .vscode/settings.json with YAML schema associations
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ function setupVSCode(projectRoot) {
12
+ const vscodeDir = path.join(projectRoot, '.vscode');
13
+ const settingsPath = path.join(vscodeDir, 'settings.json');
14
+
15
+ // Create .vscode directory if it doesn't exist
16
+ if (!fs.existsSync(vscodeDir)) {
17
+ fs.mkdirSync(vscodeDir, { recursive: true });
18
+ console.log('Created .vscode directory');
19
+ }
20
+
21
+ // Read existing settings or create new
22
+ let settings = {};
23
+ if (fs.existsSync(settingsPath)) {
24
+ try {
25
+ const content = fs.readFileSync(settingsPath, 'utf-8');
26
+ settings = JSON.parse(content);
27
+ console.log('Loaded existing VS Code settings');
28
+ } catch (error) {
29
+ console.warn('Could not parse existing settings.json, creating new one');
30
+ }
31
+ }
32
+
33
+ // Add or update YAML schema associations
34
+ if (!settings['yaml.schemas']) {
35
+ settings['yaml.schemas'] = {};
36
+ }
37
+
38
+ // Add schema mapping for module files
39
+ const schemaPath = path.join(projectRoot, '.cx-schema', 'schemas.json');
40
+ settings['yaml.schemas'][schemaPath] = [
41
+ 'modules/*-module.yaml',
42
+ 'modules/**/*-module.yaml'
43
+ ];
44
+
45
+ // Write updated settings
46
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
47
+ console.log('Updated .vscode/settings.json with schema associations');
48
+
49
+ return true;
50
+ }
51
+
52
+ function main() {
53
+ const projectRoot = process.cwd();
54
+
55
+ console.log('Setting up VS Code integration...');
56
+ console.log(`Project root: ${projectRoot}`);
57
+
58
+ if (!fs.existsSync(path.join(projectRoot, '.cx-schema'))) {
59
+ console.error('Error: .cx-schema directory not found.');
60
+ console.error('Please run npm install first to create the schema directory.');
61
+ process.exit(1);
62
+ }
63
+
64
+ try {
65
+ setupVSCode(projectRoot);
66
+ console.log('\n✓ VS Code integration setup complete!');
67
+ console.log('\nYour YAML module files will now have schema validation and autocomplete in VS Code.');
68
+ console.log('Restart VS Code for changes to take effect.');
69
+ } catch (error) {
70
+ console.error('Error setting up VS Code integration:', error.message);
71
+ process.exit(1);
72
+ }
73
+ }
74
+
75
+ // Run if called directly
76
+ if (require.main === module) {
77
+ main();
78
+ }
79
+
80
+ module.exports = { setupVSCode };
@@ -0,0 +1,83 @@
1
+ # {{displayName}} Module
2
+ # Generated by cx-validate create module
3
+
4
+ module:
5
+ name: "{{name}}"
6
+ appModuleId: "{{uuid}}"
7
+ displayName: "{{displayName}}"
8
+ description: "{{displayName}} module"
9
+ icon: "folder"
10
+ version: "1.0"
11
+ fileName: "{{fileName}}"
12
+
13
+ entities:
14
+ - name: {{name}}
15
+ displayName: "{{displayName}}"
16
+
17
+ permissions:
18
+ - name: "view-{{name}}"
19
+ displayName: "View {{displayName}}"
20
+ - name: "edit-{{name}}"
21
+ displayName: "Edit {{displayName}}"
22
+
23
+ routes:
24
+ - name: "list"
25
+ path: "/{{name}}"
26
+ component: list
27
+ - name: "detail"
28
+ path: "/{{name}}/:id"
29
+ component: detail
30
+
31
+ components:
32
+ - type: layout
33
+ name: list
34
+ title: "{{displayName}} List"
35
+ children:
36
+ - type: dataGrid
37
+ name: {{name}}Grid
38
+ props:
39
+ entityName: "{{name}}"
40
+ columns:
41
+ - field: "name"
42
+ headerName: "Name"
43
+ flex: 1
44
+ - field: "createdAt"
45
+ headerName: "Created"
46
+ type: "date"
47
+ actions:
48
+ onRowClick:
49
+ - type: navigate
50
+ props:
51
+ route: "detail"
52
+ params:
53
+ id: "{{row.id}}"
54
+
55
+ - type: layout
56
+ name: detail
57
+ title: "{{displayName}} Detail"
58
+ children:
59
+ - type: form
60
+ name: {{name}}Form
61
+ props:
62
+ entityName: "{{name}}"
63
+ fields:
64
+ - type: text
65
+ name: name
66
+ props:
67
+ label: "Name"
68
+ required: true
69
+ - type: textarea
70
+ name: description
71
+ props:
72
+ label: "Description"
73
+ rows: 3
74
+ actions:
75
+ onSubmit:
76
+ - type: mutation
77
+ props:
78
+ operation: "update{{displayNameNoSpaces}}"
79
+ input: "{{form}}"
80
+ - type: notification
81
+ props:
82
+ message: "{{displayName}} saved successfully"
83
+ severity: "success"