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
|
@@ -0,0 +1,291 @@
|
|
|
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 !== '@cxtms/cx-schema') {
|
|
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('@cxtms/cx-schema');
|
|
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
|
+
const CX_CLAUDE_MARKER = '<!-- cx-schema-instructions -->';
|
|
115
|
+
|
|
116
|
+
function generateClaudeMdContent() {
|
|
117
|
+
return `${CX_CLAUDE_MARKER}
|
|
118
|
+
## CargoXplorer Project
|
|
119
|
+
|
|
120
|
+
This is a CargoXplorer (CX) application. Modules and workflows are defined as YAML files validated against JSON schemas provided by \`@cxtms/cx-schema\`.
|
|
121
|
+
|
|
122
|
+
### Project Structure
|
|
123
|
+
|
|
124
|
+
\`\`\`
|
|
125
|
+
app.yaml # Application manifest (name, version, description)
|
|
126
|
+
modules/ # UI module YAML files
|
|
127
|
+
workflows/ # Workflow YAML files
|
|
128
|
+
features/ # Feature-scoped modules and workflows
|
|
129
|
+
<feature>/
|
|
130
|
+
modules/
|
|
131
|
+
workflows/
|
|
132
|
+
\`\`\`
|
|
133
|
+
|
|
134
|
+
### CLI — \`cxtms\`
|
|
135
|
+
|
|
136
|
+
**Always scaffold via CLI, never write YAML from scratch.**
|
|
137
|
+
|
|
138
|
+
| Command | Description |
|
|
139
|
+
|---------|-------------|
|
|
140
|
+
| \`npx cxtms create module <name>\` | Scaffold a UI module |
|
|
141
|
+
| \`npx cxtms create workflow <name>\` | Scaffold a workflow |
|
|
142
|
+
| \`npx cxtms create module <name> --template <t>\` | Use a specific template |
|
|
143
|
+
| \`npx cxtms create workflow <name> --template <t>\` | Use a specific template |
|
|
144
|
+
| \`npx cxtms create module <name> --feature <f>\` | Place under features/<f>/modules/ |
|
|
145
|
+
| \`npx cxtms <file.yaml>\` | Validate a YAML file |
|
|
146
|
+
| \`npx cxtms <file.yaml> --verbose\` | Validate with detailed errors |
|
|
147
|
+
| \`npx cxtms schema <name>\` | Show JSON schema for a component or task |
|
|
148
|
+
| \`npx cxtms example <name>\` | Show example YAML |
|
|
149
|
+
| \`npx cxtms list\` | List all available schemas |
|
|
150
|
+
| \`npx cxtms extract <src> <comp> --to <tgt>\` | Move component between modules |
|
|
151
|
+
|
|
152
|
+
**Module templates:** \`default\`, \`form\`, \`grid\`, \`select\`, \`configuration\`
|
|
153
|
+
**Workflow templates:** \`basic\`, \`entity-trigger\`, \`document\`, \`scheduled\`, \`utility\`, \`webhook\`, \`public-api\`, \`mcp-tool\`, \`ftp-tracking\`, \`ftp-edi\`, \`api-tracking\`
|
|
154
|
+
|
|
155
|
+
### Skills (slash commands)
|
|
156
|
+
|
|
157
|
+
| Skill | Purpose |
|
|
158
|
+
|-------|---------|
|
|
159
|
+
| \`/cxtms-module-builder <description>\` | Generate a UI module (forms, grids, screens) |
|
|
160
|
+
| \`/cxtms-workflow-builder <description>\` | Generate a workflow (automation, triggers, integrations) |
|
|
161
|
+
| \`/cxtms-developer <entity or question>\` | Look up entity fields, enums, and domain reference |
|
|
162
|
+
|
|
163
|
+
### Workflow: Scaffold → Customize → Validate
|
|
164
|
+
|
|
165
|
+
1. **Scaffold** — \`npx cxtms create module|workflow <name> --template <t>\`
|
|
166
|
+
2. **Read** the generated file
|
|
167
|
+
3. **Customize** for the use case
|
|
168
|
+
4. **Validate** — \`npx cxtms <file.yaml>\` — run after every change, fix all errors
|
|
169
|
+
${CX_CLAUDE_MARKER}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function setupClaudeMd(projectRoot) {
|
|
173
|
+
const claudeMdPath = path.join(projectRoot, 'CLAUDE.md');
|
|
174
|
+
const cxContent = generateClaudeMdContent();
|
|
175
|
+
|
|
176
|
+
if (fs.existsSync(claudeMdPath)) {
|
|
177
|
+
const existing = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
178
|
+
|
|
179
|
+
if (existing.includes(CX_CLAUDE_MARKER)) {
|
|
180
|
+
// Replace existing CX section
|
|
181
|
+
const markerRegex = new RegExp(
|
|
182
|
+
CX_CLAUDE_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') +
|
|
183
|
+
'[\\s\\S]*?' +
|
|
184
|
+
CX_CLAUDE_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
185
|
+
);
|
|
186
|
+
const updated = existing.replace(markerRegex, cxContent);
|
|
187
|
+
if (updated !== existing) {
|
|
188
|
+
fs.writeFileSync(claudeMdPath, updated, 'utf-8');
|
|
189
|
+
console.log('Updated CX instructions in CLAUDE.md');
|
|
190
|
+
} else {
|
|
191
|
+
console.log('CLAUDE.md CX instructions already up to date');
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
// Append to existing file
|
|
195
|
+
const separator = existing.endsWith('\n') ? '\n' : '\n\n';
|
|
196
|
+
fs.writeFileSync(claudeMdPath, existing + separator + cxContent + '\n', 'utf-8');
|
|
197
|
+
console.log('Appended CX instructions to CLAUDE.md');
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
fs.writeFileSync(claudeMdPath, `# Project Instructions\n\n${cxContent}\n`, 'utf-8');
|
|
201
|
+
console.log('Created CLAUDE.md with CX instructions');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function main() {
|
|
206
|
+
console.log('CX Schema Validator: Running postinstall...');
|
|
207
|
+
|
|
208
|
+
// Find project root
|
|
209
|
+
const projectRoot = findProjectRoot();
|
|
210
|
+
if (!projectRoot) {
|
|
211
|
+
console.log('Warning: Could not find project root. Skipping .cx-schema creation.');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
console.log(`Project root: ${projectRoot}`);
|
|
216
|
+
|
|
217
|
+
// Create .cx-schema directory
|
|
218
|
+
const cxSchemaDir = path.join(projectRoot, '.cx-schema');
|
|
219
|
+
|
|
220
|
+
if (fs.existsSync(cxSchemaDir)) {
|
|
221
|
+
console.log('.cx-schema directory already exists. Updating schemas...');
|
|
222
|
+
} else {
|
|
223
|
+
console.log('Creating .cx-schema directory...');
|
|
224
|
+
fs.mkdirSync(cxSchemaDir, { recursive: true });
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Copy schemas
|
|
228
|
+
const schemasSource = path.join(__dirname, '..', 'schemas');
|
|
229
|
+
console.log(`Copying schemas from ${schemasSource}...`);
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
copyDirectory(schemasSource, cxSchemaDir);
|
|
233
|
+
console.log('Schemas copied successfully!');
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.error('Error copying schemas:', error.message);
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Create validation script
|
|
240
|
+
console.log('Creating validation script...');
|
|
241
|
+
createValidationScript(projectRoot);
|
|
242
|
+
|
|
243
|
+
// Copy Claude Code skills (clean existing first to remove stale files)
|
|
244
|
+
const skillNames = ['cxtms-developer', 'cxtms-module-builder', 'cxtms-workflow-builder'];
|
|
245
|
+
for (const skillName of skillNames) {
|
|
246
|
+
const skillSource = path.join(__dirname, '..', 'skills', skillName);
|
|
247
|
+
if (fs.existsSync(skillSource)) {
|
|
248
|
+
const skillDest = path.join(projectRoot, '.claude', 'skills', skillName);
|
|
249
|
+
console.log(`Installing ${skillName} skill...`);
|
|
250
|
+
try {
|
|
251
|
+
// Remove existing skill directory to clean up stale files
|
|
252
|
+
if (fs.existsSync(skillDest)) {
|
|
253
|
+
fs.rmSync(skillDest, { recursive: true });
|
|
254
|
+
}
|
|
255
|
+
copyDirectory(skillSource, skillDest);
|
|
256
|
+
console.log(`${skillName} skill installed successfully!`);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.warn(`Warning: Could not install ${skillName} skill:`, error.message);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Remove deprecated skills
|
|
264
|
+
const deprecatedSkills = ['cx-build', 'cx-core', 'cx-module', 'cx-workflow'];
|
|
265
|
+
for (const oldSkill of deprecatedSkills) {
|
|
266
|
+
const oldSkillDest = path.join(projectRoot, '.claude', 'skills', oldSkill);
|
|
267
|
+
if (fs.existsSync(oldSkillDest)) {
|
|
268
|
+
try {
|
|
269
|
+
fs.rmSync(oldSkillDest, { recursive: true });
|
|
270
|
+
console.log(`Removed deprecated ${oldSkill} skill.`);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
// Ignore cleanup errors
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// TODO: Enable once CLAUDE.md content is finalized
|
|
278
|
+
// setupClaudeMd(projectRoot);
|
|
279
|
+
|
|
280
|
+
console.log('✓ CX Schema Validator installed successfully!');
|
|
281
|
+
console.log('\nUsage:');
|
|
282
|
+
console.log(' npx cxtms modules/your-module.yaml');
|
|
283
|
+
console.log(' node .cx-schema/validate.js modules/your-module.yaml');
|
|
284
|
+
console.log(' /cxtms-module-builder <description> (Claude Code skill - UI modules)');
|
|
285
|
+
console.log(' /cxtms-workflow-builder <description> (Claude Code skill - workflows)');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Only run if this is not being installed as a dependency of cx-schema-validator itself
|
|
289
|
+
if (!process.env.npm_package_name || process.env.npm_package_name !== '@cxtms/cx-schema') {
|
|
290
|
+
main();
|
|
291
|
+
}
|
|
@@ -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,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cxtms-developer
|
|
3
|
+
description: >
|
|
4
|
+
Shared CargoXplorer domain reference — entity fields, enums, customValues, GraphQL queries, and CLI auth.
|
|
5
|
+
Use when the user asks about CX entity fields, enums, customValues, entity relationships, or needs domain reference for Orders, Contacts, Commodities, Jobs, Charges, or other CX entities.
|
|
6
|
+
Also use when the user wants to look up, check, or query specific orders, parcel shipments, commodities, tracking events, workflow logs, or any CX data.
|
|
7
|
+
argument-hint: <entity name or question about fields>
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Shared domain reference for CargoXplorer entities. Used by `cxtms-workflow-builder` and `cxtms-module-builder` skills for entity field names, types, navigation properties, enums, and customValues extension patterns.
|
|
11
|
+
|
|
12
|
+
## Feature File Layout
|
|
13
|
+
|
|
14
|
+
All modules and workflows are organized under feature directories:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
features/
|
|
18
|
+
<feature_name>/
|
|
19
|
+
modules/ # UI module YAML files
|
|
20
|
+
workflows/ # Workflow YAML files
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
When creating new modules or workflows, always place them under the correct feature directory:
|
|
24
|
+
- `features/<feature_name>/modules/<name>-module.yaml`
|
|
25
|
+
- `features/<feature_name>/workflows/<name>.yaml`
|
|
26
|
+
|
|
27
|
+
Use `--feature <feature_name>` with `cx-cli create` to automatically place files in the correct location.
|
|
28
|
+
|
|
29
|
+
## Entity Field Reference
|
|
30
|
+
|
|
31
|
+
### Primary Entities
|
|
32
|
+
|
|
33
|
+
!cat skills/cxtms-developer/ref-entity-order.md
|
|
34
|
+
!cat skills/cxtms-developer/ref-entity-contact.md
|
|
35
|
+
!cat skills/cxtms-developer/ref-entity-commodity.md
|
|
36
|
+
!cat skills/cxtms-developer/ref-entity-accounting.md
|
|
37
|
+
|
|
38
|
+
### Order Sub-Entities & Related
|
|
39
|
+
|
|
40
|
+
!cat skills/cxtms-developer/ref-entity-order-sub.md
|
|
41
|
+
!cat skills/cxtms-developer/ref-entity-job.md
|
|
42
|
+
|
|
43
|
+
### Pricing & Accounting Lookups
|
|
44
|
+
|
|
45
|
+
!cat skills/cxtms-developer/ref-entity-rate.md
|
|
46
|
+
|
|
47
|
+
### Shared & Lookup Entities
|
|
48
|
+
|
|
49
|
+
!cat skills/cxtms-developer/ref-entity-shared.md
|
|
50
|
+
!cat skills/cxtms-developer/ref-entity-geography.md
|
|
51
|
+
|
|
52
|
+
### Warehouse & Inventory
|
|
53
|
+
|
|
54
|
+
!cat skills/cxtms-developer/ref-entity-warehouse.md
|
|
55
|
+
|
|
56
|
+
### Notifications
|
|
57
|
+
|
|
58
|
+
!cat skills/cxtms-developer/ref-entity-notification.md
|
|
59
|
+
|
|
60
|
+
| Category | Entities | Reference |
|
|
61
|
+
|----------|----------|-----------|
|
|
62
|
+
| **Primary** | Order, Contact, Commodity, AccountingTransaction | ref-entity-order/contact/commodity/accounting.md |
|
|
63
|
+
| **Order sub** | OrderEntity, TrackingEvent, EventDefinition, LinkedOrder, OrderDocument | ref-entity-order-sub.md |
|
|
64
|
+
| **Job** | Job, JobOrder, JobStatus | ref-entity-job.md |
|
|
65
|
+
| **Pricing** | Rate, Lane, Discount, AccountingItem, AccountingAccount, PaymentTerm | ref-entity-rate.md |
|
|
66
|
+
| **Shared** | Tag, Attachment, Division, EquipmentType, PackageType, Note/NoteThread | ref-entity-shared.md |
|
|
67
|
+
| **Geography** | Country, State, City, Port, Vessel, CustomCode, ModeOfTransportation | ref-entity-geography.md |
|
|
68
|
+
| **Warehouse** | InventoryItem, WarehouseLocation, CargoMovement (Order variant) | ref-entity-warehouse.md |
|
|
69
|
+
| **Notification** | Notification, UserNotification | ref-entity-notification.md |
|
|
70
|
+
|
|
71
|
+
## CustomValues Pattern
|
|
72
|
+
|
|
73
|
+
Most entities have `customValues` — a `Dictionary<string, object?>` stored as PostgreSQL `jsonb`:
|
|
74
|
+
|
|
75
|
+
- **Access (workflow)**: `{{ entity.customValues.fieldName }}` or `{{ entity.customValues['field-name'] }}`
|
|
76
|
+
- **Access (module)**: `customValues.fieldName` in GraphQL sort/filter paths
|
|
77
|
+
- **Update (workflow)**: `CustomValues.fieldName: "value"` (dot notation) or `customValues: { field: "value" }` (bulk merge)
|
|
78
|
+
- **Merge semantics**: upserts keys — does **not** replace entire dictionary
|
|
79
|
+
- **Full-text searchable**: included in PostgreSQL `tsvector` via `jsonb_to_tsvector`
|
|
80
|
+
- **GraphQL sort/filter**: use `CustomValues.fieldName` path — translates to `jsonb_extract_path_text`
|
|
81
|
+
|
|
82
|
+
### Entities with customValues
|
|
83
|
+
|
|
84
|
+
**Primary entities**: Order, Contact, Commodity, AccountingTransaction, Charge, Payment
|
|
85
|
+
|
|
86
|
+
**Sub-entities**: OrderEntity, OrderCommodity, ContactAddress, ContactPaymentMethod, CommodityType, CommodityTag, OrderTag, LinkedOrder, InventoryItemTag
|
|
87
|
+
|
|
88
|
+
**Lookup entities**: Job, JobStatus, Tag, Attachment, EventDefinition, Rate, Lane, Discount, AccountingItem, Port, Country, State, City, ModeOfTransportation
|
|
89
|
+
|
|
90
|
+
**Without customValues**: Division, EquipmentType, PackageType, Vessel, CustomCode, AccountingAccount, PaymentTerm, WarehouseLocation, JobOrder
|
|
91
|
+
|
|
92
|
+
### Audit Fields (AuditableEntity)
|
|
93
|
+
|
|
94
|
+
Most entities inherit these fields:
|
|
95
|
+
|
|
96
|
+
| Field | Type |
|
|
97
|
+
|-------|------|
|
|
98
|
+
| `created` | `DateTime` |
|
|
99
|
+
| `createdBy` | `string` (user ID) |
|
|
100
|
+
| `lastModified` | `DateTime` |
|
|
101
|
+
| `lastModifiedBy` | `string` (user ID) |
|
|
102
|
+
| `createdUser` | `User` navigation |
|
|
103
|
+
| `updatedUser` | `User` navigation |
|
|
104
|
+
|
|
105
|
+
### Entity Kind Mapping
|
|
106
|
+
|
|
107
|
+
Used in module `entityKind` and Flow workflow `entity.name`:
|
|
108
|
+
|
|
109
|
+
| EntityKind | Entities |
|
|
110
|
+
|------------|----------|
|
|
111
|
+
| `Order` | Order (all types: Brokerage, ParcelShipment, Quote, WarehouseReceipt, etc.) |
|
|
112
|
+
| `Contact` | Contact (all types: Customer, Carrier, Vendor, Driver, Employee, etc.) |
|
|
113
|
+
| `OrderEntity` | OrderEntity (Shipper, Consignee, Carrier roles on an order) |
|
|
114
|
+
| `AccountingTransaction` | Invoice, Bill, CreditMemo |
|
|
115
|
+
| `Commodity` | Commodity |
|
|
116
|
+
| `Calendar` | CalendarEntity |
|
|
117
|
+
| `CalendarEvent` | CalendarEvent |
|
|
118
|
+
| `Other` | Any custom entity |
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# CX Server Authentication & Management
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
- Authentication (OAuth2 login/logout)
|
|
5
|
+
- PAT Tokens (CI/CD alternative to OAuth)
|
|
6
|
+
- Organization Management
|
|
7
|
+
- Session Resolution
|
|
8
|
+
- Publish (push modules and workflows to server)
|
|
9
|
+
|
|
10
|
+
## Authentication
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Login to a CX environment (OAuth2 + PKCE — opens browser)
|
|
14
|
+
npx cxtms login https://tms-v3-dev.usatrt.com
|
|
15
|
+
|
|
16
|
+
# Logout from current session
|
|
17
|
+
npx cxtms logout
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The session is stored at `~/.cxtms/<project-dir>/.session.json`, scoped by project directory name. Each project gets its own server session. The CLI auto-refreshes expired tokens.
|
|
21
|
+
|
|
22
|
+
## PAT Tokens (alternative to OAuth)
|
|
23
|
+
|
|
24
|
+
For CI/CD or headless environments, use Personal Access Tokens instead of interactive OAuth:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Check PAT status and setup instructions
|
|
28
|
+
npx cxtms pat setup
|
|
29
|
+
|
|
30
|
+
# Create a new PAT token (requires OAuth login first)
|
|
31
|
+
npx cxtms pat create "my-ci-token"
|
|
32
|
+
|
|
33
|
+
# List active PAT tokens
|
|
34
|
+
npx cxtms pat list
|
|
35
|
+
|
|
36
|
+
# Revoke a PAT token
|
|
37
|
+
npx cxtms pat revoke <tokenId>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
After creating a PAT, add to `.env` in your project root:
|
|
41
|
+
```
|
|
42
|
+
CXTMS_AUTH=pat_xxxxx...
|
|
43
|
+
CXTMS_SERVER=https://tms-v3-dev.usatrt.com
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
When `CXTMS_AUTH` is set, the CLI skips OAuth and uses the PAT token directly. `CXTMS_SERVER` provides the server URL (or set `server` in `app.yaml`).
|
|
47
|
+
|
|
48
|
+
## Organization Management
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# List organizations on the server
|
|
52
|
+
npx cxtms orgs list
|
|
53
|
+
|
|
54
|
+
# Select an organization interactively
|
|
55
|
+
npx cxtms orgs select
|
|
56
|
+
|
|
57
|
+
# Set active organization by ID
|
|
58
|
+
npx cxtms orgs use <orgId>
|
|
59
|
+
|
|
60
|
+
# Show current context (server, org, app)
|
|
61
|
+
npx cxtms orgs use
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The active org is cached in the session file and used by all server commands. **Always pass `--org <id>` on deploy/undeploy/release/execute/logs commands** to avoid the interactive org picker blocking automation.
|
|
65
|
+
|
|
66
|
+
## Session Resolution
|
|
67
|
+
|
|
68
|
+
Server commands resolve the target session in this order:
|
|
69
|
+
1. `CXTMS_AUTH` env var → PAT token auth (with `CXTMS_SERVER` or `app.yaml` server field)
|
|
70
|
+
2. `~/.cxtms/<project-dir>/.session.json` → project-scoped OAuth session
|
|
71
|
+
3. Not logged in → error
|
|
72
|
+
|
|
73
|
+
## Publish
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Publish all modules and workflows from current project
|
|
77
|
+
npx cxtms publish
|
|
78
|
+
|
|
79
|
+
# Publish only a specific feature directory
|
|
80
|
+
npx cxtms publish --feature billing
|
|
81
|
+
npx cxtms publish billing
|
|
82
|
+
|
|
83
|
+
# Publish with explicit org ID
|
|
84
|
+
npx cxtms publish --org 42
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Validates all YAML files first, then pushes modules and workflows to the server. Skips files with validation errors and reports results.
|
|
88
|
+
|
|
89
|
+
## App Manifest Management
|
|
90
|
+
|
|
91
|
+
Server-side app manifest operations — install from git, release changes to git, and list installed apps.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Install/refresh app from its git repository into the CX server
|
|
95
|
+
npx cxtms app install
|
|
96
|
+
|
|
97
|
+
# Force reinstall even if same version is already installed
|
|
98
|
+
npx cxtms app install --force
|
|
99
|
+
|
|
100
|
+
# Install from a specific branch
|
|
101
|
+
npx cxtms app install --branch develop
|
|
102
|
+
|
|
103
|
+
# Install but skip modules that have unpublished local changes
|
|
104
|
+
npx cxtms app install --skip-changed
|
|
105
|
+
|
|
106
|
+
# Release server changes to git (creates a PR) — message is required
|
|
107
|
+
npx cxtms app release -m "Add new shipping module"
|
|
108
|
+
|
|
109
|
+
# Force release all modules and workflows (not just changed ones)
|
|
110
|
+
npx cxtms app release -m "Full republish" --force
|
|
111
|
+
|
|
112
|
+
# List installed app manifests on the server
|
|
113
|
+
npx cxtms app list
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**`app install`** reads `repository` and `branch` from `app.yaml`, downloads the repo on the server side, and installs/updates all modules and workflows. Use `--force` to reinstall even if the version hasn't changed. Use `--skip-changed` to preserve modules with unpublished changes.
|
|
117
|
+
|
|
118
|
+
**`app release`** takes the current server state and releases it to git by creating a PR. Requires a `-m` message describing the changes (like a git commit message). The server increments the version, creates a release branch, commits all module/workflow YAML files, and opens a pull request to the target branch.
|
|
119
|
+
|
|
120
|
+
**`app list`** shows all installed app manifests with their version, status flags (disabled, unpublished changes, update available), and repository info.
|