@cxtms/cx-schema 1.9.1 → 1.9.2
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/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -111,6 +111,97 @@ main().catch(error => {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
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
|
+
|
|
114
205
|
function main() {
|
|
115
206
|
console.log('CX Schema Validator: Running postinstall...');
|
|
116
207
|
|
|
@@ -183,6 +274,9 @@ function main() {
|
|
|
183
274
|
}
|
|
184
275
|
}
|
|
185
276
|
|
|
277
|
+
// TODO: Enable once CLAUDE.md content is finalized
|
|
278
|
+
// setupClaudeMd(projectRoot);
|
|
279
|
+
|
|
186
280
|
console.log('✓ CX Schema Validator installed successfully!');
|
|
187
281
|
console.log('\nUsage:');
|
|
188
282
|
console.log(' npx cxtms modules/your-module.yaml');
|
|
@@ -3,6 +3,7 @@ name: cxtms-developer
|
|
|
3
3
|
description: >
|
|
4
4
|
Shared CargoXplorer domain reference — entity fields, enums, customValues, GraphQL queries, and CLI auth.
|
|
5
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.
|
|
6
7
|
argument-hint: <entity name or question about fields>
|
|
7
8
|
---
|
|
8
9
|
|
|
@@ -290,17 +290,6 @@ npx cxtms gql type EntityAuditHistoryLightResult
|
|
|
290
290
|
npx cxtms gql type CreateOrderInput
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
### TMS MCP: `graphql_schema` / `graphql_type` — equivalent MCP tools
|
|
294
|
-
|
|
295
|
-
When TMS MCP is available, the same discovery is available via MCP tools:
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
graphql_schema(section: "queries", filter: "order")
|
|
299
|
-
graphql_schema(section: "types", filter: "audit")
|
|
300
|
-
graphql_type(typeName: "OrderGqlDto")
|
|
301
|
-
graphql_execute(query: "{ orders(organizationId: 1, take: 1) { items { orderId } } }")
|
|
302
|
-
```
|
|
303
|
-
|
|
304
293
|
### Workflow: discover → query
|
|
305
294
|
|
|
306
295
|
1. **Find the type** — `cxtms gql types --filter order` to find type names
|
|
@@ -43,7 +43,6 @@ npx cxtms create workflow <name> --template <template>
|
|
|
43
43
|
| `ftp-tracking` | Import tracking events from FTP |
|
|
44
44
|
| `ftp-edi` | Import orders from FTP via EDI |
|
|
45
45
|
| `api-tracking` | Fetch tracking from carrier API |
|
|
46
|
-
| `mcp-tool` | Expose workflow as MCP tool |
|
|
47
46
|
| `webhook` | HTTP endpoint for external callers |
|
|
48
47
|
| `public-api` | REST API endpoint with OpenAPI docs |
|
|
49
48
|
|
|
@@ -67,8 +66,6 @@ npx cxtms create workflow <name> --template <template>
|
|
|
67
66
|
|
|
68
67
|
**`api-tracking`** — update `apiConfig` configName with carrier API credentials (`baseUrl`, `apiKey`, `carrierId`). Update the GraphQL filter to select orders needing tracking. Map the carrier's API response structure in ParseTrackingResponse (foreach path, field names for `eventDate`, `location`, `statusCode`). Configure `trackingEventMatchByFields` and `matchByEventDefinition` custom value keys.
|
|
69
68
|
|
|
70
|
-
**`mcp-tool`** — write a clear `agentInstruction` describing when to use the tool, expected inputs, and return values. Keep `executionMode: Sync` so the agent gets results immediately. Define typed `inputs` with descriptive `props` (the AI reads these). Return structured data via `outputs`. The `mcp-tool` tag is required — it's what makes the workflow discoverable via `list_custom_tools` in the MCP server. Validate inputs with `Utilities/Error@1` conditions.
|
|
71
|
-
|
|
72
69
|
**`webhook`** — endpoint: `POST /api/v2/orgs/{organizationId}/webhooks/{workflowId}`. The endpoint is anonymous (`[AllowAnonymous]`) and rate-limited (10/sec, 100/min per IP). Two inputs are auto-injected by the controller: `payload` (parsed JSON body or raw string) and `request` (object with `headers`, `body`, `remoteIpAddress`). Control the HTTP response via `response` and `statusCode` outputs. Update `webhookSecret` configName to your app config path. Customize the `ValidateWebhook` step for your auth method (header secret, HMAC signature, etc.). Use `executionMode: Sync` when the caller needs a response; use `Async` for fire-and-forget (returns immediately). Keep `runAs: "system"` since the endpoint is anonymous. Add `additionalProperties.cors.allowedOrigins` to restrict CORS if needed.
|
|
73
70
|
|
|
74
71
|
**`public-api`** — requires a top-level `api` section defining the REST endpoint. Set `api.path` with route params (e.g., `/orders/{orderId}`), `api.method` (GET/POST/PUT/PATCH/DELETE), `api.authentication` (`none`, `bearer`, `apiKey`), `api.document` (swagger doc name, default `"public"`), and `api.category` (swagger tag). Configure `api.rateLimit` with `perSecond`/`perMinute`. Each input uses `props.in` (`path`, `query`, `header`, `body`) to specify where the parameter comes from, and `props.format` for OpenAPI type hints (e.g., `uuid`, `date-time`). Outputs use `props.type`, `props.description`, and `props.schema` to describe the response for OpenAPI docs. Must use `executionMode: Sync`. Control HTTP response via `response` and `statusCode` outputs.
|