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.
Files changed (215) 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 +4784 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/extractUtils.d.ts +11 -0
  7. package/dist/extractUtils.d.ts.map +1 -0
  8. package/dist/extractUtils.js +19 -0
  9. package/dist/extractUtils.js.map +1 -0
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +11 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/types.d.ts +129 -0
  15. package/dist/types.d.ts.map +1 -0
  16. package/dist/types.js +6 -0
  17. package/dist/types.js.map +1 -0
  18. package/dist/utils/schemaLoader.d.ts +17 -0
  19. package/dist/utils/schemaLoader.d.ts.map +1 -0
  20. package/dist/utils/schemaLoader.js +134 -0
  21. package/dist/utils/schemaLoader.js.map +1 -0
  22. package/dist/validator.d.ts +72 -0
  23. package/dist/validator.d.ts.map +1 -0
  24. package/dist/validator.js +432 -0
  25. package/dist/validator.js.map +1 -0
  26. package/dist/workflowValidator.d.ts +103 -0
  27. package/dist/workflowValidator.d.ts.map +1 -0
  28. package/dist/workflowValidator.js +753 -0
  29. package/dist/workflowValidator.js.map +1 -0
  30. package/package.json +51 -0
  31. package/schemas/actions/all.json +27 -0
  32. package/schemas/actions/clipboard.json +46 -0
  33. package/schemas/actions/confirm.json +21 -0
  34. package/schemas/actions/consoleLog.json +16 -0
  35. package/schemas/actions/dialog.json +25 -0
  36. package/schemas/actions/fileDownload.json +16 -0
  37. package/schemas/actions/forEach.json +31 -0
  38. package/schemas/actions/if.json +12 -0
  39. package/schemas/actions/mutation.json +25 -0
  40. package/schemas/actions/navigate.json +18 -0
  41. package/schemas/actions/navigateBack.json +22 -0
  42. package/schemas/actions/navigateBackOrClose.json +21 -0
  43. package/schemas/actions/notification.json +19 -0
  44. package/schemas/actions/openBarcodeScanner.json +104 -0
  45. package/schemas/actions/query.json +32 -0
  46. package/schemas/actions/refresh.json +13 -0
  47. package/schemas/actions/resetDirtyState.json +22 -0
  48. package/schemas/actions/setFields.json +21 -0
  49. package/schemas/actions/setStore.json +13 -0
  50. package/schemas/actions/validateForm.json +15 -0
  51. package/schemas/actions/workflow.json +24 -0
  52. package/schemas/components/README.md +147 -0
  53. package/schemas/components/appComponent.json +58 -0
  54. package/schemas/components/barcodeScanner.json +69 -0
  55. package/schemas/components/button.json +123 -0
  56. package/schemas/components/calendar.json +489 -0
  57. package/schemas/components/card.json +176 -0
  58. package/schemas/components/collection.json +54 -0
  59. package/schemas/components/dataGrid.json +119 -0
  60. package/schemas/components/datasource.json +151 -0
  61. package/schemas/components/dropdown.json +57 -0
  62. package/schemas/components/field-collection.json +618 -0
  63. package/schemas/components/field.json +265 -0
  64. package/schemas/components/form.json +234 -0
  65. package/schemas/components/index.json +71 -0
  66. package/schemas/components/layout.json +69 -0
  67. package/schemas/components/module.json +167 -0
  68. package/schemas/components/navDropdown.json +36 -0
  69. package/schemas/components/navbar.json +78 -0
  70. package/schemas/components/navbarItem.json +28 -0
  71. package/schemas/components/navbarLink.json +36 -0
  72. package/schemas/components/row.json +31 -0
  73. package/schemas/components/slot.json +30 -0
  74. package/schemas/components/tab.json +34 -0
  75. package/schemas/components/tabs.json +35 -0
  76. package/schemas/components/timeline.json +172 -0
  77. package/schemas/components/timelineGrid.json +328 -0
  78. package/schemas/fields/README.md +66 -0
  79. package/schemas/fields/attachment.json +156 -0
  80. package/schemas/fields/autocomplete-googleplaces.json +130 -0
  81. package/schemas/fields/checkbox.json +82 -0
  82. package/schemas/fields/date.json +88 -0
  83. package/schemas/fields/datetime.json +75 -0
  84. package/schemas/fields/email.json +75 -0
  85. package/schemas/fields/index.json +53 -0
  86. package/schemas/fields/number.json +91 -0
  87. package/schemas/fields/password.json +70 -0
  88. package/schemas/fields/radio.json +94 -0
  89. package/schemas/fields/rangedatetime.json +56 -0
  90. package/schemas/fields/select-async.json +334 -0
  91. package/schemas/fields/select.json +115 -0
  92. package/schemas/fields/tel.json +79 -0
  93. package/schemas/fields/text.json +86 -0
  94. package/schemas/fields/textarea.json +95 -0
  95. package/schemas/fields/time.json +91 -0
  96. package/schemas/fields/url.json +74 -0
  97. package/schemas/schema.graphql +12248 -0
  98. package/schemas/schemas.json +610 -0
  99. package/schemas/workflows/activity.json +96 -0
  100. package/schemas/workflows/common/condition.json +48 -0
  101. package/schemas/workflows/common/expression.json +76 -0
  102. package/schemas/workflows/common/mapping.json +173 -0
  103. package/schemas/workflows/common/step.json +38 -0
  104. package/schemas/workflows/flow/aggregation.json +44 -0
  105. package/schemas/workflows/flow/entity.json +129 -0
  106. package/schemas/workflows/flow/state.json +105 -0
  107. package/schemas/workflows/flow/transition.json +143 -0
  108. package/schemas/workflows/input.json +122 -0
  109. package/schemas/workflows/output.json +61 -0
  110. package/schemas/workflows/schedule.json +26 -0
  111. package/schemas/workflows/tasks/accounting-transaction.json +95 -0
  112. package/schemas/workflows/tasks/action-event.json +65 -0
  113. package/schemas/workflows/tasks/all.json +152 -0
  114. package/schemas/workflows/tasks/appmodule.json +56 -0
  115. package/schemas/workflows/tasks/attachment.json +97 -0
  116. package/schemas/workflows/tasks/authentication.json +86 -0
  117. package/schemas/workflows/tasks/caching.json +68 -0
  118. package/schemas/workflows/tasks/charge.json +92 -0
  119. package/schemas/workflows/tasks/commodity.json +92 -0
  120. package/schemas/workflows/tasks/contact-address.json +72 -0
  121. package/schemas/workflows/tasks/contact-payment-method.json +72 -0
  122. package/schemas/workflows/tasks/contact.json +82 -0
  123. package/schemas/workflows/tasks/csv.json +81 -0
  124. package/schemas/workflows/tasks/document-render.json +105 -0
  125. package/schemas/workflows/tasks/document-send.json +84 -0
  126. package/schemas/workflows/tasks/edi.json +157 -0
  127. package/schemas/workflows/tasks/email-send.json +110 -0
  128. package/schemas/workflows/tasks/error.json +72 -0
  129. package/schemas/workflows/tasks/export.json +90 -0
  130. package/schemas/workflows/tasks/filetransfer.json +102 -0
  131. package/schemas/workflows/tasks/flow-transition.json +68 -0
  132. package/schemas/workflows/tasks/foreach.json +69 -0
  133. package/schemas/workflows/tasks/generic.json +47 -0
  134. package/schemas/workflows/tasks/graphql.json +78 -0
  135. package/schemas/workflows/tasks/httpRequest.json +161 -0
  136. package/schemas/workflows/tasks/import.json +64 -0
  137. package/schemas/workflows/tasks/inventory.json +67 -0
  138. package/schemas/workflows/tasks/job.json +88 -0
  139. package/schemas/workflows/tasks/log.json +73 -0
  140. package/schemas/workflows/tasks/map.json +58 -0
  141. package/schemas/workflows/tasks/movement.json +54 -0
  142. package/schemas/workflows/tasks/note.json +59 -0
  143. package/schemas/workflows/tasks/number.json +65 -0
  144. package/schemas/workflows/tasks/order-tracking-event.json +109 -0
  145. package/schemas/workflows/tasks/order.json +139 -0
  146. package/schemas/workflows/tasks/payment.json +85 -0
  147. package/schemas/workflows/tasks/pdf-document.json +60 -0
  148. package/schemas/workflows/tasks/postal-codes.json +92 -0
  149. package/schemas/workflows/tasks/resolve-timezone.json +65 -0
  150. package/schemas/workflows/tasks/setVariable.json +76 -0
  151. package/schemas/workflows/tasks/switch.json +75 -0
  152. package/schemas/workflows/tasks/template.json +73 -0
  153. package/schemas/workflows/tasks/tracking-event.json +137 -0
  154. package/schemas/workflows/tasks/transmission.json +185 -0
  155. package/schemas/workflows/tasks/unzip-file.json +68 -0
  156. package/schemas/workflows/tasks/user.json +70 -0
  157. package/schemas/workflows/tasks/validation.json +99 -0
  158. package/schemas/workflows/tasks/while.json +53 -0
  159. package/schemas/workflows/tasks/workflow-execute.json +82 -0
  160. package/schemas/workflows/trigger.json +90 -0
  161. package/schemas/workflows/variable.json +46 -0
  162. package/schemas/workflows/workflow.json +335 -0
  163. package/scripts/postinstall.js +291 -0
  164. package/scripts/setup-vscode.js +80 -0
  165. package/skills/cxtms-developer/SKILL.md +118 -0
  166. package/skills/cxtms-developer/ref-cli-auth.md +120 -0
  167. package/skills/cxtms-developer/ref-entity-accounting.md +180 -0
  168. package/skills/cxtms-developer/ref-entity-commodity.md +239 -0
  169. package/skills/cxtms-developer/ref-entity-contact.md +163 -0
  170. package/skills/cxtms-developer/ref-entity-geography.md +154 -0
  171. package/skills/cxtms-developer/ref-entity-job.md +77 -0
  172. package/skills/cxtms-developer/ref-entity-notification.md +85 -0
  173. package/skills/cxtms-developer/ref-entity-order-sub.md +160 -0
  174. package/skills/cxtms-developer/ref-entity-order.md +183 -0
  175. package/skills/cxtms-developer/ref-entity-organization.md +41 -0
  176. package/skills/cxtms-developer/ref-entity-rate.md +182 -0
  177. package/skills/cxtms-developer/ref-entity-shared.md +176 -0
  178. package/skills/cxtms-developer/ref-entity-warehouse.md +115 -0
  179. package/skills/cxtms-developer/ref-graphql-query.md +309 -0
  180. package/skills/cxtms-module-builder/SKILL.md +477 -0
  181. package/skills/cxtms-module-builder/ref-components-data.md +293 -0
  182. package/skills/cxtms-module-builder/ref-components-display.md +411 -0
  183. package/skills/cxtms-module-builder/ref-components-forms.md +369 -0
  184. package/skills/cxtms-module-builder/ref-components-interactive.md +317 -0
  185. package/skills/cxtms-module-builder/ref-components-layout.md +390 -0
  186. package/skills/cxtms-module-builder/ref-components-specialized.md +477 -0
  187. package/skills/cxtms-workflow-builder/SKILL.md +438 -0
  188. package/skills/cxtms-workflow-builder/ref-accounting.md +66 -0
  189. package/skills/cxtms-workflow-builder/ref-communication.md +169 -0
  190. package/skills/cxtms-workflow-builder/ref-entity.md +342 -0
  191. package/skills/cxtms-workflow-builder/ref-expressions-ncalc.md +128 -0
  192. package/skills/cxtms-workflow-builder/ref-expressions-template.md +161 -0
  193. package/skills/cxtms-workflow-builder/ref-filetransfer.md +80 -0
  194. package/skills/cxtms-workflow-builder/ref-flow.md +210 -0
  195. package/skills/cxtms-workflow-builder/ref-other.md +157 -0
  196. package/skills/cxtms-workflow-builder/ref-query.md +105 -0
  197. package/skills/cxtms-workflow-builder/ref-utilities.md +417 -0
  198. package/templates/module-configuration.yaml +44 -0
  199. package/templates/module-form.yaml +152 -0
  200. package/templates/module-grid.yaml +229 -0
  201. package/templates/module-select.yaml +139 -0
  202. package/templates/module.yaml +84 -0
  203. package/templates/workflow-api-tracking.yaml +189 -0
  204. package/templates/workflow-basic.yaml +76 -0
  205. package/templates/workflow-document.yaml +155 -0
  206. package/templates/workflow-entity-trigger.yaml +90 -0
  207. package/templates/workflow-ftp-edi.yaml +158 -0
  208. package/templates/workflow-ftp-tracking.yaml +161 -0
  209. package/templates/workflow-mcp-tool.yaml +112 -0
  210. package/templates/workflow-public-api.yaml +135 -0
  211. package/templates/workflow-scheduled-execute.yaml +75 -0
  212. package/templates/workflow-scheduled.yaml +125 -0
  213. package/templates/workflow-utility.yaml +96 -0
  214. package/templates/workflow-webhook.yaml +128 -0
  215. package/templates/workflow.yaml +140 -0
@@ -0,0 +1,438 @@
1
+ ---
2
+ name: cxtms-workflow-builder
3
+ description: >
4
+ Works with CXTMS workflow YAML files — creates, modifies, fixes, validates, and deploys standard process and Flow state machine workflows.
5
+ Use when the user asks to create, modify, or fix a workflow YAML file, references workflow/*.yaml files, mentions a specific workflow by name, or asks about workflow tasks/triggers/activities/expressions in a CX project.
6
+ Also use when debugging workflow errors, fixing template expressions, or troubleshooting workflow steps.
7
+ argument-hint: <description of what to build>
8
+ ---
9
+
10
+ You are a CargoXplorer workflow YAML builder. You generate schema-valid YAML for CX workflows — both standard process workflows (activities, steps, triggers) and Flow state machine workflows (entity lifecycle, states, transitions). All output must conform to the JSON schemas in `.cx-schema/`.
11
+
12
+ **IMPORTANT — use `cxtms` for all workflow operations:**
13
+ - **Scaffold**: `npx cxtms create workflow <name> --template <template>` — generates a schema-valid YAML file. ALWAYS run this first, then read the generated file, then customize. Do NOT write YAML from scratch or copy templates manually.
14
+ - **Validate**: `npx cxtms <file.yaml>` — run after every change
15
+ - **Schema lookup**: `npx cxtms schema <task>` — e.g., `cxtms schema graphql`, `cxtms schema foreach`, `cxtms schema action-event`. Schema names use kebab-case file names. Case-insensitive: `ActionEvent` resolves to `action-event`.
16
+ - **Examples**: `npx cxtms example <task>` — show example YAML for a task
17
+ - **List schemas**: `npx cxtms list --type workflow` — shows all available task schemas in the Tasks section
18
+ - **Feature folder**: `npx cxtms create workflow <name> --template <template> --feature <feature-name>`
19
+ - **Deploy to server**: `npx cxtms workflow deploy <file.yaml> --org <id>` — creates or updates workflow on the CX server
20
+ - **Undeploy from server**: `npx cxtms workflow undeploy <workflowId> --org <id>` — removes a workflow by UUID
21
+ - **Execute**: `npx cxtms workflow execute <workflowId|file.yaml> --org <id> [--vars '<json>'] [--file varName=path]` — trigger a workflow execution (--file uploads a local file and passes the URL as a variable)
22
+ - **List logs**: `npx cxtms workflow logs <workflowId|file.yaml> --org <id> [--from YYYY-MM-DD] [--to YYYY-MM-DD]` — list executions with log availability
23
+ - **Download log**: `npx cxtms workflow log <executionId> --org <id> [--json] [--console] [--output <file>]` — download execution log
24
+ - **Publish all**: `npx cxtms publish [--feature <name>] --org <id>` — deploy all modules and workflows to the server
25
+
26
+ ## Generation Workflow
27
+
28
+ ### Step 1: Scaffold via CLI — MANDATORY
29
+
30
+ **You MUST run `cxtms create workflow` to generate the initial file.** Do not skip this step. Do not write YAML from scratch. Do not read template files and copy them manually. The CLI generates correct UUIDs, file paths, and structure.
31
+
32
+ ```bash
33
+ npx cxtms create workflow <name> --template <template>
34
+ ```
35
+
36
+ | Template | Use Case |
37
+ |----------|----------|
38
+ | `basic` | Minimal starting point |
39
+ | `entity-trigger` | React to entity changes |
40
+ | `document` | Generate PDF/Excel |
41
+ | `scheduled` | Cron batch jobs |
42
+ | `utility` | Reusable helper (no triggers) |
43
+ | `ftp-tracking` | Import tracking events from FTP |
44
+ | `ftp-edi` | Import orders from FTP via EDI |
45
+ | `api-tracking` | Fetch tracking from carrier API |
46
+ | `webhook` | HTTP endpoint for external callers |
47
+ | `public-api` | REST API endpoint with OpenAPI docs |
48
+
49
+ ### Step 2: Read the generated file
50
+
51
+ ### Step 3: Customize for the use case
52
+
53
+ **All templates** — update `name`, `description`, `tags`, `inputs`, `variables`, replace placeholder steps.
54
+
55
+ **`entity-trigger`** — set `entityName`, `eventType` (Modified/Created/Deleted), `position` (Before/After), `conditions` on `changes`. Access entity via `{{ entity.* }}`. Before: use `Validation/Validate@1`. After: cascade changes.
56
+
57
+ **`document`** — keep `file`/`fileName`/`fileDisposition` outputs. Update `Document/Render@1`: `engine` (handlebars/jsrender), `recipe` (chrome-pdf/html-to-xlsx), `content` (HTML template), `data` mapping.
58
+
59
+ **`scheduled`** — set `cron`, `pageSize`, GraphQL filter, foreach processing body. Add `runAs`, `continueOnError` for unattended execution.
60
+
61
+ **`utility`** — define `inputs`/`outputs`, keep `executionMode: Sync`, no triggers. Called via `Workflow/Execute@1`.
62
+
63
+ **`ftp-tracking`** — update `ftpConfig` configName, `directory` and `pattern` in ListFiles, map downloaded content to `trackingEvents` array in ParseContent step, configure `Order/Import@1` match fields and `trackingEventMatchByFields`. Adjust `cron` schedule and MoveFile destination path.
64
+
65
+ **`ftp-edi`** — update `ftpConfig` configName, `directory` in ListFiles, set `workflowId` or `workflowName` in `Workflow/Execute@1` to point to your EDI parser sub-workflow. Map parsed EDI output to `orders` for `Order/Import@1`. Configure `orderMatchByFields` and `commodityMatchByFields`. Adjust `cron` schedule and MoveFile destination path.
66
+
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.
68
+
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.
70
+
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.
72
+
73
+ **All templates** include workflow-level `events` (`onWorkflowStarted`, `onWorkflowCompleted`, `onWorkflowFailed`) and activity-level `events` (`onActivityStarted`, `onActivityCompleted`, `onActivityFailed`) with Log steps. Replace/extend these with notification tasks (Email/Send, HttpRequest, Workflow/Execute) as needed. (`onWorkflowExecuted` is a deprecated alias for `onWorkflowCompleted` — use `onWorkflowCompleted` in new workflows.)
74
+
75
+ **Flow workflows** — scaffold with `basic` then set `workflowType: Flow`, remove `activities`/`triggers`, add `entity`, `states`, `transitions`, `aggregations`. Load Flow reference: `!cat skills/cxtms-workflow-builder/ref-flow.md`
76
+
77
+ ### Step 4: Validate
78
+
79
+ ```bash
80
+ npx cxtms <generated-file.yaml>
81
+ ```
82
+
83
+ ### File Placement
84
+
85
+ - **Root**: `workflows/<name>.yaml` — shared/global workflows
86
+ - **Feature**: `features/<feature-name>/workflows/<name>.yaml` — feature-scoped
87
+
88
+ ---
89
+
90
+ ## Top-Level Structure
91
+
92
+ ```yaml
93
+ workflow:
94
+ workflowId: "<uuid>"
95
+ name: "Workflow Name"
96
+ description: "What this workflow does"
97
+ version: "1.0"
98
+ executionMode: Sync | Async
99
+ logLevel: None | Trace | Debug | Information | Warning | Error
100
+ isActive: true
101
+ enableAudit: true
102
+ filePath: "workflows/<name>.yaml"
103
+ workflowType: Document | Quote | Flow | Webhook | PublicApi # omit for standard process workflows
104
+ runAs: "system" # Optional elevated permissions
105
+ tags: ["tag1", "tag2"]
106
+ concurrency: # Optional
107
+ enabled: true
108
+ group: "groupName"
109
+ waitTime: 30
110
+
111
+ inputs:
112
+ - name: inputName # Valid identifier [a-zA-Z_][a-zA-Z0-9_]*
113
+ type: text | number | integer | boolean | date | datetime | options | object | array
114
+ props:
115
+ displayName: "Input Label"
116
+ description: "Help text"
117
+ required: true
118
+ visible: true
119
+ defaultValue: "..."
120
+ mapping: "order.orderId" # Maps to entity property
121
+
122
+ outputs:
123
+ - name: outputName
124
+ mapping: "ActivityName.StepName.resultVar"
125
+
126
+ variables:
127
+ - name: varName
128
+ value: null # Static value
129
+ - name: configVar
130
+ fromConfig: "apps.myApp" # App configuration
131
+ - name: computed
132
+ expression: "1 + 2" # NCalc expression
133
+
134
+ activities:
135
+ - name: ActivityName
136
+ conditions:
137
+ - expression: "[shouldRun] = true"
138
+ events: # Activity-level event handlers
139
+ onActivityStarted: [...]
140
+ onActivityCompleted: [...]
141
+ onActivityFailed: [...]
142
+ steps:
143
+ - task: "TaskType"
144
+ name: StepName
145
+ inputs: { ... }
146
+ outputs:
147
+ - name: resultVar
148
+ mapping: "response.data"
149
+ conditions:
150
+ - expression: "[someVar] = true"
151
+ continueOnError: false
152
+
153
+ triggers:
154
+ - type: Manual
155
+ name: ManualTrigger
156
+ - type: Entity
157
+ entityName: "Order"
158
+ eventType: Added | Modified | Deleted
159
+ position: Before | After
160
+
161
+ schedules:
162
+ - cron: "0 8 * * 1-5"
163
+ displayName: "Daily morning run"
164
+
165
+ events: # Workflow-level event handlers
166
+ onWorkflowStarted: [...]
167
+ onWorkflowCompleted: [...]
168
+ onWorkflowFailed: [...]
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Execution Model
174
+
175
+ **Flow**: Workflow -> Activities (sequential) -> Steps (sequential)
176
+
177
+ **Outputs stored as**: `ActivityName.StepName.outputKey` (in both activity and global scope)
178
+
179
+ **System variables**: `organizationId`, `currentUserId`, `executionId`, `workflowId`, `triggerType`, `eventType`, `position`, `entityName`, `entityId`, `entity`, `data`, `changes`
180
+
181
+ **Conditions**: Any step/activity can have `conditions` — all must be true (AND) or step is skipped.
182
+
183
+ **Events**: `onWorkflowStarted`, `onWorkflowCompleted`, `onWorkflowFailed`, `onActivityStarted`, `onActivityCompleted`, `onActivityFailed`
184
+
185
+ **Task naming**: `Namespace/TaskName@Version` — version optional, defaults to highest.
186
+
187
+ ---
188
+
189
+ ## Variable References (quick summary)
190
+
191
+ For template expressions and value directives: see [ref-expressions-template.md](skills/cxtms-workflow-builder/ref-expressions-template.md)
192
+ For NCalc conditions and functions: see [ref-expressions-ncalc.md](skills/cxtms-workflow-builder/ref-expressions-ncalc.md)
193
+
194
+ **`{{ path }}`** — in step inputs. Single `{{ }}` returns raw object. Multiple returns string interpolation.
195
+ **`[variable]`** — in conditions and `expression:` directives. NCalc syntax.
196
+ **Value directives**: `expression`, `coalesce`, `foreach`, `switch`, `extends`, `$raw`
197
+ **38 custom functions** + NCalc built-ins. Key ones: `isNullOrEmpty()`, `any()`, `all()`, `count()`, `sum()`, `first()`, `last()`, `contains()`, `join()`, `split()`, `format()`, `now()`, `addDays()`, `formatDate()`, `if()`, `groupBy()`, `concat()`, `distinct()`
198
+
199
+ ### Null-Safe Operator `?` — USE BY DEFAULT
200
+
201
+ **Always use the `?` suffix on every segment of a variable path** unless the variable is a guaranteed system variable. Without `?`, a null reference at any segment throws a runtime exception and fails the workflow.
202
+
203
+ **When to use `?`** (default — always):
204
+ ```yaml
205
+ # Template expressions — every segment gets ?
206
+ message: "{{ Activity?.Step?.output?.field? }}"
207
+ # NCalc conditions — every segment gets ?
208
+ expression: "[Activity?.Step?.output?.field?] = 'value'"
209
+ # Output mappings
210
+ mapping: "responseField?"
211
+ # Collection paths
212
+ collection: "Activity?.Step?.output?.items?"
213
+ # fromConfig variables
214
+ url: "{{ config?.baseUrl? }}"
215
+ ```
216
+
217
+ **Engine-level null safety for object inputs**: Task inputs resolved as complex objects (e.g., `headers`, `columnMappings`, configuration objects) are automatically null-safe at the engine level. If an optional object input is omitted from YAML, the engine returns `null` instead of throwing — no `?` suffix needed on the YAML key itself. The `?` operator is still required in template expressions and NCalc paths that reference those objects.
218
+
219
+ **When `?` is NOT needed** (guaranteed system variables):
220
+ `organizationId`, `currentUserId`, `executionId`, `workflowId`, `triggerType`, `eventType`, `position`, `entityName`, `entityId`, `entity`, `entity.*`, `data`, `changes`, `inputs.*`, `exception.message`, `item` (foreach current), `item.*`, `index`, `iteration`
221
+
222
+ **Examples**:
223
+ ```yaml
224
+ # CORRECT — system var (no ?), step output (?)
225
+ organizationId: "{{ int organizationId }}"
226
+ orderId: "{{ Main?.GetOrder?.order?.orderId? }}"
227
+ expression: "[offset] < [BatchProcess?.PageLoop?.GetPage?.result?.totalCount?]"
228
+
229
+ # WRONG — missing ? on step outputs, will throw null ref
230
+ orderId: "{{ Main.GetOrder.order.orderId }}"
231
+ expression: "[offset] < [BatchProcess.PageLoop.GetPage.result.totalCount]"
232
+ ```
233
+
234
+ ---
235
+
236
+ ## System Tasks (Control Flow)
237
+
238
+ ### foreach
239
+ ```yaml
240
+ - task: foreach
241
+ name: ProcessItems
242
+ collection: "Data?.GetOrders?.result?.items?"
243
+ item: "currentOrder" # default: "item"
244
+ continueOnError: true
245
+ steps: [...]
246
+ ```
247
+ Implicit variables: `index` (zero-based), `{item}` (current item).
248
+
249
+ ### switch
250
+ Evaluates cases in order, executes first match (implicit break). Optional `default`.
251
+ ```yaml
252
+ - task: switch
253
+ name: RouteByStatus
254
+ cases:
255
+ - when:
256
+ - expression: "[status] = 'Active'"
257
+ steps: [...]
258
+ default:
259
+ - task: "Utilities/Log@1"
260
+ name: LogOther
261
+ inputs: { message: "Unknown status" }
262
+ ```
263
+
264
+ ### while
265
+ ```yaml
266
+ - task: while
267
+ name: PageLoop
268
+ maxIterations: 100 # default: 10000
269
+ conditions:
270
+ - expression: "[hasMore] = true"
271
+ steps: [...]
272
+ ```
273
+ Implicit variable: `iteration` (zero-based).
274
+
275
+ ---
276
+
277
+ ## Task Reference (load on demand by category)
278
+
279
+ | Category | Tasks | Load Reference |
280
+ |----------|-------|----------------|
281
+ | Utilities | SetVariable, Log, Error, HttpRequest, Map, Template, Import, Export, CsvParse, UnzipFile | `!cat skills/cxtms-workflow-builder/ref-utilities.md` |
282
+ | Query & Workflow | Query/GraphQL, Validation, Workflow/Execute | `!cat skills/cxtms-workflow-builder/ref-query.md` |
283
+ | Entity CRUD | Order, Contact, Commodity, Job, Charge, Discount, Inventory, Movement, Transmission | `!cat skills/cxtms-workflow-builder/ref-entity.md` |
284
+ | Communication | Email/Send, Document/Render, Attachment, PdfDocument/Merge | `!cat skills/cxtms-workflow-builder/ref-communication.md` |
285
+ | File Transfer | Connect, Disconnect, ListFiles, Download, Upload, Move, Delete | `!cat skills/cxtms-workflow-builder/ref-filetransfer.md` |
286
+ | Accounting | AccountingTransaction, Payment, Number/Generate, SequenceNumber | `!cat skills/cxtms-workflow-builder/ref-accounting.md` |
287
+ | Other | User, Auth, Caching, X12/Parse, EDIFACT, Flow/Transition, Notes, AppModule, ActionEvent | `!cat skills/cxtms-workflow-builder/ref-other.md` |
288
+
289
+ ## Entity Field Reference (cxtms-developer)
290
+
291
+ !cat skills/cxtms-developer/SKILL.md
292
+
293
+ ## Additional References (load on demand)
294
+
295
+ | Reference | Load |
296
+ |-----------|------|
297
+ | Template Expressions & Value Directives | `!cat skills/cxtms-workflow-builder/ref-expressions-template.md` |
298
+ | NCalc Expressions & Functions | `!cat skills/cxtms-workflow-builder/ref-expressions-ncalc.md` |
299
+ | Flow Workflows (state machines) | `!cat skills/cxtms-workflow-builder/ref-flow.md` |
300
+
301
+ ## Dynamic Schema Access (load on demand)
302
+
303
+ | Schema | Load |
304
+ |--------|------|
305
+ | Workflow | `!cat .cx-schema/workflows/workflow.json` |
306
+ | Activity | `!cat .cx-schema/workflows/activity.json` |
307
+ | Input | `!cat .cx-schema/workflows/input.json` |
308
+ | Output | `!cat .cx-schema/workflows/output.json` |
309
+ | Variable | `!cat .cx-schema/workflows/variable.json` |
310
+ | Trigger | `!cat .cx-schema/workflows/trigger.json` |
311
+ | Schedule | `!cat .cx-schema/workflows/schedule.json` |
312
+ | All Tasks | `!cat .cx-schema/workflows/tasks/all.json` |
313
+ | Flow Entity | `!cat .cx-schema/workflows/flow/entity.json` |
314
+ | Flow State | `!cat .cx-schema/workflows/flow/state.json` |
315
+ | Flow Transition | `!cat .cx-schema/workflows/flow/transition.json` |
316
+ | Flow Aggregation | `!cat .cx-schema/workflows/flow/aggregation.json` |
317
+
318
+ ---
319
+
320
+ ## Server Workflow Commands
321
+
322
+ Deploy, undeploy, and release commands are listed in the CLI section at the top of this file. For authentication setup (login, PAT tokens, org management): see [cxtms-developer/ref-cli-auth.md](skills/cxtms-developer/ref-cli-auth.md)
323
+
324
+ ### Releasing App to GitHub
325
+
326
+ Use `app release` to release modified workflows and modules from the CX server to a GitHub repository. This creates a branch and pull request — it does NOT push directly to the target branch.
327
+
328
+ ```bash
329
+ # Release all unpublished changes to GitHub (creates a PR) — message is required
330
+ npx cxtms app release -m "Add order notification workflow"
331
+
332
+ # Release specific workflows and/or modules by YAML file
333
+ npx cxtms app release -m "Fix tracking workflow" workflows/my-workflow.yaml
334
+ npx cxtms app release -m "Update shipping" workflows/a.yaml modules/b.yaml
335
+
336
+ # Force release all workflows and modules (not just unpublished ones)
337
+ npx cxtms app release -m "Full republish" --force
338
+
339
+ # Release with explicit org
340
+ npx cxtms app release -m "Add order notification workflow" --org 42
341
+ ```
342
+
343
+ **What `app release` does:**
344
+ 1. Reads `app.yaml` for the `id` (appManifestId), repository, and branch
345
+ 2. Increments the app version (patch bump)
346
+ 3. Creates a `publish/{app-name}-v{version}-{timestamp}` branch on GitHub
347
+ 4. Commits `app.yaml` + selected workflow/module YAML files to the branch
348
+ 5. Creates a pull request from the publish branch to the target branch
349
+ 6. Marks published workflows and modules as `hasUnpublishedChanges: false`
350
+
351
+ **This is a release-to-git operation** — it commits the current server-side YAML directly to GitHub via the API. No local git repo is involved. The workflows and modules being released are taken from the CX server database, not from local files. The YAML file arguments only identify *which* items to include by their IDs.
352
+
353
+ **Important:** Workflows and modules must be deployed to the TMS server before they can be released. Use `cxtms workflow deploy` or `cxtms appmodule deploy` first, then `cxtms app release` to commit them to GitHub.
354
+
355
+ **Do NOT run `app release` automatically.** Only release when the user explicitly requests it. Releasing creates a branch and PR on GitHub, so it should be done once when all changes are ready — not after every deploy.
356
+
357
+ **Prerequisites:**
358
+ - `app.yaml` must exist with a valid `id` field
359
+ - The app manifest must be installed on the server (`app install` first)
360
+ - The server must have a GitHub token configured for the organization
361
+ - The repository and branch must be set on the app manifest
362
+
363
+ **Related commands:**
364
+ - `npx cxtms app install` — install/refresh app from GitHub into the server
365
+ - `npx cxtms app install --force` — force reinstall even if same version
366
+ - `npx cxtms app install --branch develop` — install from a specific branch
367
+ - `npx cxtms app install --skip-changed` — skip modules with local changes
368
+ - `npx cxtms app list` — list installed app manifests on the server
369
+
370
+ ### Execute
371
+
372
+ ```bash
373
+ # Execute a workflow by UUID or YAML file
374
+ npx cxtms workflow execute <workflowId>
375
+ npx cxtms workflow execute workflows/my-workflow.yaml
376
+
377
+ # Pass input variables as JSON
378
+ npx cxtms workflow execute <workflowId> --vars '{"city": "London", "count": 5}'
379
+
380
+ # Upload a local file and pass its URL as a workflow variable
381
+ npx cxtms workflow execute workflow.yaml --file importFile=/path/to/data.csv
382
+
383
+ # Combine variables and file uploads
384
+ npx cxtms workflow execute workflow.yaml --vars '{"mode": "preview"}' --file importFile=data.csv --file templateFile=template.xlsx
385
+ ```
386
+
387
+ `--file varName=path` uploads the local file to the server via presigned URL and sets the resulting URL as the named variable. Can be specified multiple times.
388
+
389
+ Returns execution result including `executionId`, `isAsync`, `outputs` (for Sync workflows).
390
+
391
+ ### Execution Logs
392
+
393
+ ```bash
394
+ # List executions with log availability (sorted desc by date)
395
+ npx cxtms workflow logs <workflowId|file.yaml>
396
+
397
+ # Filter by date range
398
+ npx cxtms workflow logs <workflowId> --from 2026-01-01 --to 2026-01-31
399
+
400
+ # Download a specific execution log (saves to temp dir by default)
401
+ npx cxtms workflow log <executionId>
402
+
403
+ # Save to specific file
404
+ npx cxtms workflow log <executionId> --output mylog.txt
405
+
406
+ # Print to stdout
407
+ npx cxtms workflow log <executionId> --console
408
+
409
+ # Download JSON log (richer data: inputs, outputs, timing, metadata)
410
+ npx cxtms workflow log <executionId> --json
411
+
412
+ # JSON log to stdout
413
+ npx cxtms workflow log <executionId> --json --console
414
+ ```
415
+
416
+ `workflow logs` shows a table with execution status, date, duration, user, and log availability indicators (filled/empty circle). `workflow log` downloads the actual log content from the server (gzip-compressed S3 URLs).
417
+
418
+ ### Debugging Tips
419
+
420
+ - Use `--json` for detailed structured data (ExecutionId, Inputs, Outputs, Exception, timing)
421
+ - Text logs show step-by-step execution trace with timestamps
422
+ - Sync workflow executions may not appear in `workflow logs` — they return results inline
423
+ - Use `workflow execute --vars` to test workflows with specific inputs
424
+ - Use `workflow execute --file varName=path` to upload local files for workflows that expect file URL inputs
425
+
426
+ ---
427
+
428
+ ## Generation Rules
429
+
430
+ 1. **Always scaffold via `cxtms create workflow` first** — never write YAML from scratch, never copy templates manually
431
+ 2. **Naming conventions**: step names PascalCase, variables camelCase, states PascalCase, transitions camelCase
432
+ 3. **Template expressions** use `{{ expression }}` — NCalc conditions use `[variable]`
433
+ 4. **Do not change `workflowId` or `filePath`** — set correctly by CLI scaffold
434
+ 5. **Standard workflows** require `activities` with at least one step per activity
435
+ 6. **Flow workflows** require `entity`, `states`, `transitions` (no `activities`)
436
+ 7. **Entity triggers** require `entityName` and `eventType`
437
+ 8. **Always use null-safe `?`** on variable paths — `Activity?.Step?.output?` — unless referencing guaranteed system variables (see Variable References section)
438
+ 9. **Always validate** the final YAML: `npx cxtms <file.yaml>`
@@ -0,0 +1,66 @@
1
+ # Accounting, Payment & Finance Tasks Reference
2
+
3
+ ## Accounting Transactions
4
+
5
+ | Task | Description |
6
+ |------|-------------|
7
+ | `AccountingTransaction/Generate` | Generate Invoice, Bill, or CreditMemo |
8
+ | `AccountingTransaction/Update` | Update accounting transaction |
9
+ | `AccountingTransaction/ApplyCreditToInvoices` | Apply credit memo to outstanding invoices |
10
+
11
+ ```yaml
12
+ - task: "AccountingTransaction/Generate@1"
13
+ name: GenerateInvoice
14
+ inputs:
15
+ orderId: "{{ inputs.orderId }}"
16
+ transactionType: "Invoice"
17
+ outputs:
18
+ - name: invoice
19
+ mapping: "transaction"
20
+ ```
21
+
22
+ ```yaml
23
+ - task: "AccountingTransaction/ApplyCreditToInvoices@1"
24
+ name: ApplyCredit
25
+ inputs:
26
+ creditMemoId: "{{ inputs.creditMemoId }}"
27
+ invoiceIds:
28
+ - "{{ Data.GetInvoices.invoice1.id }}"
29
+ - "{{ Data.GetInvoices.invoice2.id }}"
30
+ ```
31
+
32
+ ## Payment
33
+
34
+ | Task | Description |
35
+ |------|-------------|
36
+ | `Payment/Create` | Create a payment record |
37
+
38
+ ```yaml
39
+ - task: "Payment/Create@1"
40
+ name: CreatePayment
41
+ inputs:
42
+ orderId: "{{ inputs.orderId }}"
43
+ amount: "{{ inputs.amount }}"
44
+ paymentMethod: "{{ inputs.paymentMethod }}"
45
+ outputs:
46
+ - name: payment
47
+ mapping: "payment"
48
+ ```
49
+
50
+ ## Number Generation
51
+
52
+ | Task | Description |
53
+ |------|-------------|
54
+ | `Number/Generate` | Generate sequential number (e.g., invoice numbers) |
55
+ | `SequenceNumber/Get` | Get next sequence number |
56
+
57
+ ```yaml
58
+ - task: "Number/Generate@1"
59
+ name: GenInvoiceNumber
60
+ inputs:
61
+ format: "INV-{0:D6}"
62
+ sequenceName: "invoice"
63
+ outputs:
64
+ - name: number
65
+ mapping: "number"
66
+ ```
@@ -0,0 +1,169 @@
1
+ # Communication & Document Tasks Reference
2
+
3
+ ## Contents
4
+ - Email/Send task (send emails with templates and attachments)
5
+ - Email/VerifyCode task (send and verify email verification codes)
6
+ - Document/Render task (render PDF or Excel from HTML templates)
7
+ - Document/Send task (send a previously rendered document)
8
+ - Attachment tasks (Create, Update, Thumbnail, PdfThumbnail, RegenerateThumbnails)
9
+ - PdfDocument/Merge task (merge multiple PDFs into one)
10
+
11
+ ## Email/Send
12
+
13
+ Sends emails with optional templates and attachments.
14
+
15
+ ```yaml
16
+ - task: "Email/Send"
17
+ name: SendNotification
18
+ inputs:
19
+ to: "{{ recipient.email }}"
20
+ cc: ["manager@example.com"]
21
+ subject: "Order {{ orderNumber }} Updated"
22
+ body: "<p>Your order status changed to {{ status }}.</p>"
23
+ ```
24
+
25
+ With template:
26
+ ```yaml
27
+ - task: "Email/Send"
28
+ name: SendTemplated
29
+ inputs:
30
+ to: "{{ Data.GetOrder.order.customer.email }}"
31
+ template: "order-status-notification"
32
+ templateData:
33
+ orderId: "{{ Data.GetOrder.order.orderId }}"
34
+ orderNumber: "{{ Data.GetOrder.order.orderNumber }}"
35
+ status: "{{ Data.GetOrder.order.status }}"
36
+ ```
37
+
38
+ With attachment:
39
+ ```yaml
40
+ - task: "Email/Send"
41
+ name: SendWithDoc
42
+ inputs:
43
+ to: "{{ recipient.email }}"
44
+ subject: "Your Invoice"
45
+ body: "<p>Please find your invoice attached.</p>"
46
+ attachments:
47
+ - fileName: "invoice.pdf"
48
+ content: "{{ GenerateDoc.Render.document }}"
49
+ contentType: "application/pdf"
50
+ ```
51
+
52
+ ## Email/VerifyCode
53
+
54
+ Sends and verifies email verification codes.
55
+
56
+ ```yaml
57
+ - task: "Email/VerifyCode"
58
+ name: VerifyEmail
59
+ inputs:
60
+ email: "{{ inputs.email }}"
61
+ code: "{{ inputs.verificationCode }}"
62
+ ```
63
+
64
+ ## Document/Render
65
+
66
+ Renders documents from HTML templates. Supports PDF (handlebars + chrome-pdf) and Excel (jsrender + html-to-xlsx).
67
+
68
+ **PDF rendering:**
69
+ ```yaml
70
+ - task: "Document/Render@1"
71
+ name: RenderPdf
72
+ inputs:
73
+ template:
74
+ engine: "handlebars"
75
+ recipe: "chrome-pdf"
76
+ content: |
77
+ <html>
78
+ <head>
79
+ <style>
80
+ body { font-family: Arial, sans-serif; margin: 40px; }
81
+ table { width: 100%; border-collapse: collapse; }
82
+ th, td { border: 1px solid #ddd; padding: 8px; }
83
+ </style>
84
+ </head>
85
+ <body>
86
+ <h1>Invoice #{{orderNumber}}</h1>
87
+ <p>Customer: {{customerName}}</p>
88
+ <table>
89
+ <tr><th>Item</th><th>Amount</th></tr>
90
+ {{#each charges}}
91
+ <tr><td>{{description}}</td><td>{{amount}}</td></tr>
92
+ {{/each}}
93
+ </table>
94
+ </body>
95
+ </html>
96
+ data:
97
+ orderNumber: "{{ Data.GetOrder.order.orderNumber }}"
98
+ customerName: "{{ Data.GetOrder.order.customer.name }}"
99
+ charges: "{{ Data.GetOrder.order.charges }}"
100
+ outputs:
101
+ - name: document
102
+ mapping: "document"
103
+ ```
104
+
105
+ **Excel rendering:**
106
+ ```yaml
107
+ - task: "Document/Render@1"
108
+ name: RenderExcel
109
+ inputs:
110
+ template:
111
+ engine: "jsrender"
112
+ recipe: "html-to-xlsx"
113
+ content: |
114
+ <table>
115
+ <tr><th>Order #</th><th>Status</th><th>Amount</th></tr>
116
+ {{for items}}
117
+ <tr><td>{{:orderNumber}}</td><td>{{:status}}</td><td>{{:amount}}</td></tr>
118
+ {{/for}}
119
+ </table>
120
+ data:
121
+ items: "{{ Data.GetOrders.result.items }}"
122
+ outputs:
123
+ - name: document
124
+ mapping: "document"
125
+ ```
126
+
127
+ **Engines**: `handlebars`, `jsrender`
128
+ **Recipes**: `chrome-pdf`, `html-to-xlsx`, `html`, `xlsx`, `docx`, `csv`
129
+
130
+ ## Document/Send
131
+
132
+ Sends a previously rendered document.
133
+
134
+ ## Attachment Tasks
135
+
136
+ | Task | Description |
137
+ |------|-------------|
138
+ | `Attachment/Create` | Create file attachment on an entity |
139
+ | `Attachment/Update` | Update attachment metadata |
140
+ | `Attachment/Thumbnail` | Generate image thumbnail |
141
+ | `Attachment/PdfThumbnail` | Generate PDF thumbnail |
142
+ | `Attachment/RegenerateThumbnails` | Regenerate all thumbnails |
143
+
144
+ ```yaml
145
+ - task: "Attachment/Create"
146
+ name: AttachDocument
147
+ inputs:
148
+ entityName: "Order"
149
+ entityId: "{{ inputs.orderId }}"
150
+ fileName: "invoice.pdf"
151
+ content: "{{ GenerateDoc.Render.document }}"
152
+ contentType: "application/pdf"
153
+ ```
154
+
155
+ ## PdfDocument/Merge
156
+
157
+ Merges multiple PDF documents into one.
158
+
159
+ ```yaml
160
+ - task: "PdfDocument/Merge@1"
161
+ name: MergePdfs
162
+ inputs:
163
+ documents:
164
+ - "{{ RenderPage1.document }}"
165
+ - "{{ RenderPage2.document }}"
166
+ outputs:
167
+ - name: merged
168
+ mapping: "document"
169
+ ```