zinkee 0.1.0 → 0.1.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/README.md CHANGED
@@ -8,9 +8,9 @@ Implemented command groups:
8
8
 
9
9
  - `profiles`
10
10
  - `config`
11
- - `files`
12
11
  - `schemas`
13
12
  - `records`
13
+ - `files`
14
14
  - `comments`
15
15
  - `navigation`
16
16
  - `teamspace`
@@ -37,7 +37,7 @@ npm test
37
37
 
38
38
  ## Configuration
39
39
 
40
- The CLI is compatible with the existing config file:
40
+ The CLI uses a TOML config file:
41
41
 
42
42
  ```text
43
43
  ~/.config/zinkee/config.toml
@@ -55,303 +55,513 @@ base_url = "https://api.zinkee.com"
55
55
 
56
56
  ## Global Options
57
57
 
58
- - `--profile <name>`
59
- - `--base-url <url>`
60
- - `--api-key <token>`
61
- - `--read-only`
62
- - `--example <command path>`
63
- - `--json`
58
+ | Option | Description |
59
+ |---|---|
60
+ | `--profile <name>` | Select a profile from config |
61
+ | `--base-url <url>` | Override the configured base URL |
62
+ | `--api-key <token>` | Override the configured API key |
63
+ | `--read-only` | Run in read-only mode |
64
+ | `--example` | Show examples for a command |
65
+ | `--json` | Emit JSON output |
66
+
67
+ ## Runtime Resolution
68
+
69
+ The CLI resolves runtime settings with this precedence:
70
+
71
+ 1. CLI flags: `--profile`, `--base-url`, `--api-key`
72
+ 2. Environment variables: `ZINKEE_PROFILE`, `ZINKEE_API_BASE_URL`, `ZINKEE_API_KEY`
73
+ 3. `~/.config/zinkee/config.toml`
74
+
75
+ If a runtime API key is provided, a runtime base URL must also be provided.
76
+ If a runtime base URL is provided, a runtime API key must also be provided.
77
+
78
+ Example for local development without config:
79
+
80
+ ```bash
81
+ ZINKEE_API_BASE_URL=http://localhost:8088 \
82
+ ZINKEE_API_KEY="<workspace_token>" \
83
+ zinkee --json schemas list
84
+ ```
85
+
86
+ Example using an env-selected profile:
87
+
88
+ ```bash
89
+ ZINKEE_PROFILE=local zinkee --json schemas list
90
+ ```
64
91
 
65
92
  ## JSON Contract
66
93
 
67
94
  Successful commands emit:
68
95
 
69
96
  ```json
70
- {
71
- "data": {},
72
- "meta": {}
73
- }
97
+ { "data": {}, "meta": {} }
74
98
  ```
75
99
 
76
100
  Failing commands emit:
77
101
 
78
102
  ```json
79
- {
80
- "error": {},
81
- "meta": {}
82
- }
103
+ { "error": {}, "meta": {} }
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Schemas
109
+
110
+ ### Create a schema
111
+
112
+ ```bash
113
+ zinkee schemas create --name "Projects" --slug projects --auditable --commentable
83
114
  ```
84
115
 
85
- ## Quick Examples
116
+ ### List and get schemas
86
117
 
87
118
  ```bash
88
- zinkee profiles list
89
- zinkee --json config validate
90
119
  zinkee --json schemas list
91
- zinkee --json schemas get tareas
92
- zinkee --json records list contacts --limit 50 --offset 0
93
- zinkee --json records query contacts --where "status eq active"
94
- zinkee --json files storage
95
- zinkee --json automations list
96
- zinkee --example records query
97
- zinkee --json --example automations create
98
- zinkee --json --example automations trigger set
99
- zinkee --json --example automations actions add
100
- zinkee --json --example automations webhook set
101
- zinkee --json --example automations connections create
120
+ zinkee --json schemas get projects
102
121
  ```
103
122
 
104
- ## Automations
123
+ ### Create fields
105
124
 
106
- The `automations` group manages the full public automation surface:
125
+ Simple field types use `--type`, `--slug`, `--label`:
107
126
 
108
- - automation folders
109
- - automation metadata
110
- - triggers
111
- - actions
112
- - flow wiring
113
- - webhook endpoint configuration
114
- - plugins
115
- - stored connections for HTTP actions
127
+ ```bash
128
+ zinkee schemas fields create projects --type text --slug name --label "Name"
129
+ zinkee schemas fields create projects --type number --slug budget --label "Budget"
130
+ zinkee schemas fields create projects --type date --slug start-date --label "Start Date"
131
+ zinkee schemas fields create projects --type file --slug attachment --label "Attachment"
132
+ zinkee schemas fields create projects --type autoincremental --slug code --label "Code"
133
+ zinkee schemas fields create projects --type member --slug owner --label "Owner"
134
+ ```
135
+
136
+ Valid types: `text`, `number`, `date`, `file`, `autoincremental`, `member`, `option`, `reference`, `formula`.
116
137
 
117
- If you are scripting, prefer `--json`. If you are discovering the CLI, prefer `--example <command path>`.
138
+ Complex types require `--raw`:
118
139
 
119
- ### Before You Start
140
+ ```bash
141
+ # Option field
142
+ zinkee schemas fields create projects --raw '{
143
+ "type":"option","slug":"status","label":"Status",
144
+ "options":[
145
+ {"id":1,"name":"Open","color":"default"},
146
+ {"id":2,"name":"In Progress","color":"primary"},
147
+ {"id":3,"name":"Done","color":"success"}
148
+ ]
149
+ }'
150
+
151
+ # Reference field (targetSchema and targetDisplayField must be UUIDs)
152
+ zinkee schemas fields create tasks --raw '{
153
+ "type":"reference","slug":"project","label":"Project",
154
+ "targetSchema":"<schema-uuid>",
155
+ "targetDisplayField":"<field-uuid>",
156
+ "deleteBehavior":"SET_NULL"
157
+ }'
158
+
159
+ # Formula field (use formulaText, not expression)
160
+ zinkee schemas fields create projects --raw '{
161
+ "type":"formula","slug":"code","label":"Code",
162
+ "formulaText":"concat(\"PRJ-\", <_id-field-uuid>)"
163
+ }'
164
+ ```
120
165
 
121
- - `automations create` requires `--name` and a valid trigger.
122
- - For `record_created` and `record_changed`, `--trigger-schema` accepts a real schema UUID or schema slug from your workspace.
123
- - For `record_changed`, every `--trigger-field` must be a real field UUID or field slug from that schema.
124
- - `--condition` uses the format `<field:comparator:value>`.
125
- - `--condition-json` accepts a full JSON condition object when you need structured `rawValue/source` entries.
126
- - For record-based automation values, the CLI sends `{ rawValue, source }` objects to the API v2 contract.
127
- - The `scheduled` trigger uses a six-field cron expression, for example `0 15 10 * * 1`.
166
+ ### Update field config
128
167
 
129
- Useful discovery commands:
168
+ Config properties must be wrapped inside a `config` key:
130
169
 
131
170
  ```bash
132
- zinkee --json schemas list
133
- zinkee --json schemas get <schema-uuid-or-slug>
134
- zinkee --json schemas fields list <schema-uuid-or-slug>
135
- zinkee --json automations plugins list
136
- zinkee --json automations connections list
171
+ # Number formatting
172
+ zinkee schemas fields update projects budget --raw '{
173
+ "config":{
174
+ "defaultValue":"0",
175
+ "formatOptions":{
176
+ "format":"number","decimals":2,"thousandsSeparator":true,
177
+ "symbolEnabled":true,"symbolValue":" €","symbolPosition":"right"
178
+ }
179
+ }
180
+ }'
181
+
182
+ # Date formatting
183
+ zinkee schemas fields update projects start-date --raw '{
184
+ "config":{"formatOptions":{"format":"date","dateFormat":"L","showTime":false}}
185
+ }'
186
+
187
+ # Text type (valid values: NORMAL, LONG)
188
+ zinkee schemas fields update projects description --raw '{"config":{"textType":"LONG"}}'
137
189
  ```
138
190
 
139
- ### Trigger Types
191
+ ### Formula syntax
140
192
 
141
- Valid trigger types are:
193
+ Formulas reference fields by UUID **without brackets**:
142
194
 
143
- - `scheduled`
144
- - `record_created`
145
- - `record_changed`
146
- - `webhook`
195
+ ```
196
+ concat("PRJ-", f1e1d000-0000-0000-0000-000000000005)
197
+ if(8e73e31d-c47d-4123-a14c-331991c39c0e > 10, "High", "Low")
198
+ date_format(44b72f55-3fc3-40f4-88bb-343bb4a6270c, "AAAA-MM")
199
+ ```
147
200
 
148
- Minimal scheduled automation:
201
+ - Field references: UUID without brackets (no `[uuid]`)
202
+ - Date masks are in Spanish: `AAAA`, `MM`, `DD`, `MMMM`, `DDDD`, etc.
203
+ - Date masks must be quoted: `"AAAA-MM"`
204
+ - Functions: `concat`, `if`, `date_format`, `datetime_diff`, arithmetic (`+`,`-`,`*`,`/`)
205
+ - Invalid formulas are created with status `DRAFT` and evaluate to `null`
206
+
207
+ ---
208
+
209
+ ## Records
210
+
211
+ ### CRUD operations
149
212
 
150
213
  ```bash
151
- zinkee --json automations create \
152
- --name "Nightly invoice sync" \
153
- --trigger-type scheduled \
154
- --cron "0 15 10 * * 1"
214
+ # Create
215
+ zinkee records create projects \
216
+ --set name="Website Redesign" \
217
+ --set budget=25000 \
218
+ --set start-date="2026-01-15T00:00:00.000Z" \
219
+ --set status=1
220
+
221
+ # List and query
222
+ zinkee --json records list projects --limit 50
223
+ zinkee --json records query projects --limit 10 --sort "_id:desc"
224
+
225
+ # Get
226
+ zinkee --json records get projects <record-uuid>
227
+
228
+ # Update
229
+ zinkee records update projects <record-uuid> --set status=2
230
+
231
+ # Delete
232
+ zinkee records delete projects <record-uuid>
155
233
  ```
156
234
 
157
- Record-created automation using a schema slug:
235
+ Option values are written as numbers (`--set status=1`) but returned as strings (`"1"`). Number values are stored and returned as strings.
236
+
237
+ ---
238
+
239
+ ## Files
158
240
 
159
241
  ```bash
160
- zinkee --json automations create \
161
- --name "Lead welcome" \
162
- --trigger-type record_created \
163
- --trigger-schema leads
242
+ # Upload
243
+ zinkee --json files upload /path/to/document.pdf
244
+
245
+ # Download
246
+ zinkee files download <file-uuid> --output /path/to/download.pdf
247
+
248
+ # Attach to a record's FileField
249
+ zinkee records update projects <record-uuid> \
250
+ --set-json 'attachment=[{"id":"<file-uuid>","name":"doc.pdf","contentType":"application/pdf"}]'
251
+
252
+ # Detach
253
+ zinkee records update projects <record-uuid> --set-json 'attachment=[]'
254
+
255
+ # Delete (storage only — does NOT clean record references)
256
+ zinkee files delete <file-uuid>
257
+
258
+ # Storage info
259
+ zinkee --json files storage
164
260
  ```
165
261
 
166
- Record-changed automation using schema and field slugs:
262
+ > **Important**: deleting a file does not remove references from records. Manually clear the FileField before or after deleting.
263
+
264
+ ---
265
+
266
+ ## Comments
267
+
268
+ Requires schemas with `commentable: true`.
167
269
 
168
270
  ```bash
169
- zinkee --json automations create \
170
- --name "Order status sync" \
171
- --trigger-type record_changed \
172
- --trigger-schema orders \
173
- --trigger-field status
271
+ zinkee comments create <schema-slug> <record-uuid> --text "This is a comment"
272
+ zinkee comments list <schema-slug> <record-uuid>
174
273
  ```
175
274
 
176
- Replace the trigger on an existing automation:
275
+ ---
276
+
277
+ ## Navigation
278
+
279
+ Organize schemas into database folders.
177
280
 
178
281
  ```bash
179
- zinkee --json automations trigger set automation-1 \
180
- --trigger-type record_changed \
181
- --trigger-schema orders \
182
- --trigger-field status
282
+ # List folders with contents
283
+ zinkee --json navigation folders list
284
+
285
+ # Create folder
286
+ zinkee navigation folders create --name "CRM" --order 1
287
+
288
+ # Move a schema into a folder
289
+ zinkee navigation resources move <schema-uuid> --type SCHEMA --to "CRM"
290
+
291
+ # Delete folder (resources move back to root silently)
292
+ zinkee navigation folders delete "CRM"
183
293
  ```
184
294
 
185
- Add trigger conditions:
295
+ Root folder cannot be deleted.
296
+
297
+ ---
298
+
299
+ ## Teamspace
300
+
301
+ Publish resources (schemas, displays) to the teamspace visible to non-admin users.
186
302
 
187
303
  ```bash
188
- zinkee --json automations trigger set automation-1 \
189
- --trigger-type record_changed \
190
- --trigger-schema orders \
191
- --trigger-field status \
192
- --condition status:eq:approved
304
+ # Create teamspace folder
305
+ zinkee teamspace folders create --name "Dashboards" --order 1
306
+
307
+ # Publish a schema (accepts UUID or slug)
308
+ zinkee teamspace resources publish projects --to "Dashboards"
309
+
310
+ # Publish a display
311
+ zinkee teamspace resources publish <display-uuid> --to "Dashboards"
312
+
313
+ # Unpublish
314
+ zinkee teamspace resources unpublish <resource-uuid>
315
+
316
+ # List folders with resources
317
+ zinkee --json teamspace folders list --include-resources
318
+
319
+ # Re-publishing moves the resource to the new folder
320
+ zinkee teamspace resources publish projects --to "Other Folder"
193
321
  ```
194
322
 
195
- For `record_created` and `record_changed`, trigger conditions are always sent as literal values under the new `{ rawValue, source }` shape. Trigger conditions do not support `source`.
323
+ ---
324
+
325
+ ## Displays
196
326
 
197
- ### Actions
327
+ Displays are dashboards composed of widgets that visualize data from schemas.
198
328
 
199
- Valid action types are:
329
+ ### Creation flow
200
330
 
201
- - `create_record`
202
- - `update_record`
203
- - `search_records`
204
- - `send_message`
205
- - `http_request`
206
- - `execute_plugin`
331
+ 1. Create the display
332
+ 2. Create context variables
333
+ 3. Create widgets with `variableMap` bindings
334
+ 4. Set freeform layout positions
207
335
 
208
- Notes:
336
+ ### Templates
209
337
 
210
- - `schema` references inside `automations` are standardized to accept either a UUID or a slug.
211
- - `field` references inside `automations` are standardized to accept either a UUID or a slug.
212
- - `pluginId` for `execute_plugin` must be an active plugin id from `zinkee --json automations plugins list`.
338
+ - `freeform` — grid with `x/y/w/h` positioning (recommended)
339
+ - `single_view` — single widget view
340
+ - `widget_row` — stacked rows
341
+ - `widget_row_tabs` — rows with tabs
342
+ - `side_tabs_widgets` — tabs with sidebar
213
343
 
214
- Create-record action:
344
+ ### Create a freeform display
215
345
 
216
346
  ```bash
217
- zinkee --json automations actions add automation-1 \
218
- --type create_record \
219
- --name "Create follow-up" \
220
- --target-schema followups \
221
- --map status=pending \
222
- --map-json owner='{"rawValue":null,"source":{"type":"TRIGGER","id":"payload_value"}}'
347
+ zinkee --json displays create --name "Project Dashboard" --template freeform
223
348
  ```
224
349
 
225
- The CLI wraps `--map field=value` literals as:
350
+ ### Add a context variable
226
351
 
227
- ```json
228
- {
229
- "rawValue": "value",
230
- "source": null
231
- }
352
+ ```bash
353
+ zinkee --json displays variables create <display-uuid> \
354
+ --type reference \
355
+ --name "Project" \
356
+ --source-schema projects \
357
+ --source-field project-name
232
358
  ```
233
359
 
234
- For source-based values, pass the full object through `--map-json`. Valid `source.type` values are `TRIGGER` and `PREVIOUS_ACTION`.
360
+ Variables accept slugs for `--source-schema` and `--source-field`.
235
361
 
236
- Search-records action with a trigger-based condition:
362
+ ### Add widgets
237
363
 
238
- ```bash
239
- zinkee --json automations actions add automation-1 \
240
- --type search_records \
241
- --name "Find duplicates" \
242
- --target-schema followups \
243
- --condition-json '{"field":"email","comparator":"eq","values":[{"rawValue":null,"source":{"type":"TRIGGER","id":"payload_value"}}]}'
244
- ```
364
+ Every widget MUST include a `variableMap` that maps each display variable to a field in the widget's schema:
245
365
 
246
- Update-record action using the trigger record:
366
+ - **Same schema as variable**: bind to the same display field (e.g., `project-name`)
367
+ - **Different schema**: bind to the ReferenceField pointing to the variable's schema (e.g., `task-project`)
368
+ - **No filtering**: set to `null`
247
369
 
248
370
  ```bash
249
- zinkee --json automations actions add automation-1 \
250
- --type update_record \
251
- --name "Update trigger record" \
252
- --target-schema followups \
253
- --map status=ready \
254
- --use-trigger-record
371
+ # Table widget (--field accepts slugs)
372
+ zinkee --json displays widgets create <display-uuid> \
373
+ --type TABLE_OR_SUBTABLE \
374
+ --name "Tasks" \
375
+ --origin-resource <tasks-schema-uuid> \
376
+ --field task-code \
377
+ --field task-title \
378
+ --field task-status \
379
+ --raw '{"bindings":{"variableMap":{"<variable-uuid>":"<task-project-field-uuid>"}}}'
380
+
381
+ # KPI widget
382
+ zinkee --json displays widgets create <display-uuid> \
383
+ --type KPI \
384
+ --name "Total Hours" \
385
+ --origin-resource <hours-schema-uuid> \
386
+ --raw '{
387
+ "bindings":{"variableMap":{"<variable-uuid>":"<hours-project-field-uuid>"}},
388
+ "kpi":{"typeCalc":"SUM","fieldCalc":"hours-field-slug"}
389
+ }'
390
+
391
+ # Chart widget (valid types: lines, bars, stackedBars, combined)
392
+ zinkee --json displays widgets create <display-uuid> \
393
+ --type CHART \
394
+ --name "Hours by Employee" \
395
+ --origin-resource <hours-schema-uuid> \
396
+ --chart-type bars \
397
+ --x-axis-field employee-field-slug \
398
+ --raw '{
399
+ "bindings":{"variableMap":{"<variable-uuid>":"<hours-project-field-uuid>"}},
400
+ "chart":{"yAxisSeries":[{"typeCalc":"SUM","fieldCalc":"hours-field-slug","axisType":"PRIMARY"}]}
401
+ }'
402
+
403
+ # KANBAN, TIMELINE, DETAIL also supported
255
404
  ```
256
405
 
257
- When `--use-trigger-record` is enabled, the CLI does not send `conditions`.
406
+ Widget types: `TABLE_OR_SUBTABLE`, `DETAIL`, `KPI`, `CHART`, `TIMELINE`, `KANBAN`, `HIERARCHY`.
407
+
408
+ ### Set freeform layout
258
409
 
259
- HTTP request action:
410
+ After creating widgets, position them on a 12-column grid:
260
411
 
261
412
  ```bash
262
- zinkee --json automations actions add automation-1 \
263
- --type http_request \
264
- --name "Notify ERP" \
265
- --method POST \
266
- --url https://example.com/integrations/order-status \
267
- --header X-Demo=cli \
268
- --body '{"event":"order.status.changed"}' \
269
- --content-type application/json \
270
- --timeout-ms 5000
413
+ zinkee displays layout update <display-uuid> --template freeform --freeform-layouts '{
414
+ "lg": [
415
+ {"i":"<kpi-widget-uuid>","x":0,"y":0,"w":3,"h":4},
416
+ {"i":"<kpi-widget-uuid>","x":3,"y":0,"w":3,"h":4},
417
+ {"i":"<table-widget-uuid>","x":0,"y":4,"w":12,"h":10}
418
+ ]
419
+ }'
271
420
  ```
272
421
 
273
- HTTP request action with stored auth:
422
+ ### KPI with filters
423
+
424
+ The `--filter` flag doesn't work on KPI widgets. Pass filters in `--raw`:
274
425
 
275
426
  ```bash
276
- zinkee --json automations actions add automation-1 \
277
- --type http_request \
278
- --name "Notify ERP" \
279
- --method POST \
280
- --url https://example.com/integrations/order-status \
281
- --content-type application/json \
282
- --auth-mode STORED \
283
- --connection 550e8400-e29b-41d4-a716-446655440001
427
+ --raw '{"query":{"filters":[{"fieldId":"<field-uuid>","operator":"EQUALS","value":"2"}]}}'
284
428
  ```
285
429
 
286
- Execute-plugin action:
430
+ ### Slug support
431
+
432
+ Slugs are resolved to UUIDs in: `--field`, `--source-schema`, `--source-field`, `--x-axis-field`, `kpi.fieldCalc`, `chart.xAxisFieldId`, `chart.yAxisSeries[].fieldCalc`, `bindings.variableMap` values.
433
+
434
+ Display UUIDs are required for `displays widgets create/update` and `displays variables create`.
435
+
436
+ ---
437
+
438
+ ## Automations
439
+
440
+ Automations execute actions in response to triggers (record events, schedules, webhooks).
441
+
442
+ ### Creation flow
443
+
444
+ 1. Create automation with trigger
445
+ 2. Add actions
446
+ 3. Wire the flow (connect trigger → actions → actions)
447
+ 4. Activate
448
+
449
+ ### Trigger types
287
450
 
288
451
  ```bash
289
- zinkee --json automations actions add automation-1 \
290
- --type execute_plugin \
291
- --name "Run plugin" \
292
- --plugin clone-budget \
293
- --arg mode=safe \
294
- --arg-json payload='{"dryRun":true}'
452
+ # Scheduled (six-field cron — includes seconds)
453
+ zinkee --json automations create \
454
+ --name "Weekly report" \
455
+ --trigger-type scheduled \
456
+ --cron "0 15 10 * * 1"
457
+
458
+ # Record created (requires at least one --condition)
459
+ zinkee --json automations create \
460
+ --name "High priority task" \
461
+ --trigger-type record_created \
462
+ --trigger-schema tasks \
463
+ --condition priority:eq:3
464
+
465
+ # Record changed (requires --trigger-field)
466
+ zinkee --json automations create \
467
+ --name "Status change" \
468
+ --trigger-type record_changed \
469
+ --trigger-schema tasks \
470
+ --trigger-field status
471
+
472
+ # Webhook
473
+ zinkee --json automations create \
474
+ --name "External webhook" \
475
+ --trigger-type webhook
295
476
  ```
296
477
 
297
- Update an existing action:
478
+ Valid trigger types: `scheduled`, `record_created`, `record_changed`, `webhook`.
479
+
480
+ ### Action types
298
481
 
299
482
  ```bash
300
- zinkee --json automations actions update automation-1 action-1 \
483
+ # Create record with literal and trigger-sourced values
484
+ zinkee --json automations actions add <automation-uuid> \
485
+ --type create_record \
486
+ --name "Create time entry" \
487
+ --target-schema time-entries \
488
+ --map description="Auto-created" \
489
+ --map hours=0 \
490
+ --map-json project='{"rawValue":null,"source":{"type":"TRIGGER","id":"<project-field-uuid>"}}'
491
+
492
+ # Update the trigger record
493
+ zinkee --json automations actions add <automation-uuid> \
301
494
  --type update_record \
302
- --name "Update trigger record" \
303
- --target-schema followups \
304
- --map status=ready \
305
- --use-trigger-record
306
- ```
495
+ --name "Mark as processed" \
496
+ --target-schema tasks \
497
+ --use-trigger-record \
498
+ --map processed=true
307
499
 
308
- ### Flow Wiring
500
+ # Search records
501
+ zinkee --json automations actions add <automation-uuid> \
502
+ --type search_records \
503
+ --name "Find related" \
504
+ --target-schema time-entries \
505
+ --condition-json '{"field":"project","comparator":"eq","values":[{"rawValue":null,"source":{"type":"TRIGGER","id":"<project-field-uuid>"}}]}'
309
506
 
310
- Use `flow set` after you have action ids:
507
+ # HTTP request
508
+ zinkee --json automations actions add <automation-uuid> \
509
+ --type http_request \
510
+ --name "Notify webhook" \
511
+ --method POST \
512
+ --url https://example.com/hook \
513
+ --content-type application/json \
514
+ --body '{"event":"task.created"}'
311
515
 
312
- ```bash
313
- zinkee --json automations flow set automation-1 \
314
- --entry action-1 \
315
- --transition action-1:action-2 \
316
- --transition action-2:action-3
516
+ # Execute plugin
517
+ zinkee --json automations actions add <automation-uuid> \
518
+ --type execute_plugin \
519
+ --name "Clone budget" \
520
+ --plugin clone-budget \
521
+ --arg mode=safe
317
522
  ```
318
523
 
319
- The resulting payload uses:
524
+ Valid action types: `create_record`, `update_record`, `search_records`, `send_message`, `http_request`, `execute_plugin`.
320
525
 
321
- - `entryActionIds`
322
- - `transitions[].fromActionId`
323
- - `transitions[].toActionId`
526
+ ### Field mapping format
324
527
 
325
- ### Webhook Automations
528
+ - `--map field=value` → `{"rawValue":"value","source":null}` (literal)
529
+ - `--map-json field='{"rawValue":null,"source":{"type":"TRIGGER","id":"<field-uuid>"}}'` (from trigger)
530
+ - `source.type` values: `TRIGGER`, `PREVIOUS_ACTION`
531
+ - `source.id` must be a field UUID — slugs are not resolved here
326
532
 
327
- The webhook endpoint configuration is a separate resource from the trigger itself.
533
+ ### Flow wiring
328
534
 
329
- Configure webhook ingestion for an automation:
535
+ Actions are NOT auto-wired. Connect them explicitly:
330
536
 
331
537
  ```bash
332
- zinkee --json automations webhook set automation-1 \
333
- --active \
334
- --idempotency-key-path "$.id" \
335
- --event-type-path "$.type" \
336
- --allowed-event-type frontend.demo.created \
337
- --field-mapping '{"variable":"external_id","jsonPath":"$.data.id"}'
538
+ zinkee --json automations flow set <automation-uuid> \
539
+ --entry <action-1-uuid> \
540
+ --transition <action-1-uuid>:<action-2-uuid> \
541
+ --transition <action-2-uuid>:<action-3-uuid>
338
542
  ```
339
543
 
340
- Read the generated endpoint details:
544
+ ### Activate / deactivate
341
545
 
342
546
  ```bash
343
- zinkee --json automations webhook get automation-1
547
+ zinkee automations activate <automation-uuid>
548
+ zinkee automations deactivate <automation-uuid>
344
549
  ```
345
550
 
346
- If you want the automation trigger itself to be webhook-based:
551
+ ### Webhook configuration
347
552
 
348
553
  ```bash
349
- zinkee --json automations trigger set automation-1 --trigger-type webhook
350
- ```
554
+ zinkee --json automations webhook set <automation-uuid> \
555
+ --active \
556
+ --idempotency-key-path "$.id" \
557
+ --event-type-path "$.type" \
558
+ --allowed-event-type order.created \
559
+ --field-mapping '{"variable":"external_id","jsonPath":"$.data.id"}'
351
560
 
352
- ### Stored Connections
561
+ zinkee --json automations webhook get <automation-uuid>
562
+ ```
353
563
 
354
- Create a stored connection for `http_request` actions:
564
+ ### Stored connections
355
565
 
356
566
  ```bash
357
567
  zinkee --json automations connections create \
@@ -361,35 +571,30 @@ zinkee --json automations connections create \
361
571
  --config '{"headerName":"Authorization"}' \
362
572
  --secret apiKey=super-secret \
363
573
  --active
574
+
575
+ zinkee --json automations connections list
364
576
  ```
365
577
 
366
- Patch a stored connection:
578
+ ### Troubleshooting
367
579
 
368
- ```bash
369
- zinkee --json automations connections update connection-1 \
370
- --raw '{"set":{"name":"ERP API Key Updated","config":{"headerName":"Authorization"}}}'
371
- ```
580
+ - `Automation payload is invalid` → trigger is missing or malformed
581
+ - Use `scheduled` (not `schedule`) as trigger type
582
+ - Cron must be six fields (includes seconds): `"0 15 10 * * 1"`
583
+ - `record_created` requires at least one `--condition`
584
+ - `record_changed` requires at least one `--trigger-field`
585
+ - Actions must be wired with `flow set` before they execute
586
+ - Use `--json --example automations <subcommand>` for canonical examples
372
587
 
373
- ### Patching Automations
588
+ ---
374
589
 
375
- `automations update` uses the backend patch contract with `set` and `unset`.
590
+ ## Discovery
376
591
 
377
592
  ```bash
378
- zinkee --json automations update automation-1 \
379
- --raw '{"set":{"description":"Updated by CLI docs"},"unset":["folderId"]}'
593
+ zinkee --json schemas list
594
+ zinkee --json schemas fields list <schema>
595
+ zinkee --json displays list
596
+ zinkee --json automations list
597
+ zinkee --json automations plugins list
598
+ zinkee --json automations connections list
599
+ zinkee --example <command path>
380
600
  ```
381
-
382
- Supported metadata patch paths:
383
-
384
- - `name`
385
- - `description`
386
- - `folderId`
387
-
388
- ### Troubleshooting
389
-
390
- - `Automation payload is invalid` during create usually means the trigger is missing or malformed.
391
- - `scheduled` is the correct trigger type, not `schedule`.
392
- - Use a six-field cron expression for `scheduled`.
393
- - `record_changed` requires at least one `--trigger-field`.
394
- - Record-based triggers only work with real schema and field UUIDs or slugs from your workspace.
395
- - `zinkee --json --example automations <subcommand>` returns canonical command recipes without executing the command.