zinkee 0.1.22 → 0.1.23
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/.claude/settings.local.json +2 -1
- package/dist/index.js +94 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/automations.test.ts +130 -0
- package/src/commands/automations.ts +50 -2
- package/src/utils/examples.test.ts +46 -0
- package/src/utils/examples.ts +67 -0
package/dist/index.js
CHANGED
|
@@ -5450,6 +5450,43 @@ var specificExamples = {
|
|
|
5450
5450
|
"steps": ["one", "two"]
|
|
5451
5451
|
}
|
|
5452
5452
|
}
|
|
5453
|
+
}`
|
|
5454
|
+
},
|
|
5455
|
+
{
|
|
5456
|
+
description: "Add a send-message action. --to maps to fieldMapping.recipients and --message maps to fieldMapping.body. Values are wrapped in {rawValue, source} like every other automation field mapping; use --map / --map-json for extra keys.",
|
|
5457
|
+
command: `zinkee --json automations actions add automation-1 --type send_message --name "Notify customer" --to customer@example.com --subject "Your order status has changed" --message "Hello, your order is now processed."`,
|
|
5458
|
+
raw: `{
|
|
5459
|
+
"type": "send_message",
|
|
5460
|
+
"name": "Notify customer",
|
|
5461
|
+
"config": {
|
|
5462
|
+
"fieldMapping": {
|
|
5463
|
+
"recipients": {
|
|
5464
|
+
"rawValue": "customer@example.com",
|
|
5465
|
+
"source": null
|
|
5466
|
+
},
|
|
5467
|
+
"subject": {
|
|
5468
|
+
"rawValue": "Your order status has changed",
|
|
5469
|
+
"source": null
|
|
5470
|
+
},
|
|
5471
|
+
"body": {
|
|
5472
|
+
"rawValue": "Hello, your order is now processed.",
|
|
5473
|
+
"source": null
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
}`
|
|
5478
|
+
},
|
|
5479
|
+
{
|
|
5480
|
+
description: "Add a generate-document action. The renderer reads the template, writes the file, and stores its id in the target FileField of the target schema.",
|
|
5481
|
+
command: 'zinkee --json automations actions add automation-1 --type generate_document --name "Generate invoice PDF" --document-template 6c08673e-f8a6-44d2-8c91-d09eca911f8f --target-schema 68d2c7be-4392-42de-b5ae-625ad79cfc3c --target-file-field c8edbde8-a361-4e9f-a39a-2e88971f21a7',
|
|
5482
|
+
raw: `{
|
|
5483
|
+
"type": "generate_document",
|
|
5484
|
+
"name": "Generate invoice PDF",
|
|
5485
|
+
"config": {
|
|
5486
|
+
"documentTemplateId": "6c08673e-f8a6-44d2-8c91-d09eca911f8f",
|
|
5487
|
+
"targetSchemaId": "68d2c7be-4392-42de-b5ae-625ad79cfc3c",
|
|
5488
|
+
"targetFileFieldId": "c8edbde8-a361-4e9f-a39a-2e88971f21a7"
|
|
5489
|
+
}
|
|
5453
5490
|
}`
|
|
5454
5491
|
}
|
|
5455
5492
|
]),
|
|
@@ -5500,6 +5537,30 @@ var specificExamples = {
|
|
|
5500
5537
|
"authMode": "STORED",
|
|
5501
5538
|
"connectionId": "connection-1"
|
|
5502
5539
|
}
|
|
5540
|
+
}`
|
|
5541
|
+
},
|
|
5542
|
+
{
|
|
5543
|
+
description: "Replace a send-message action. --to maps to fieldMapping.recipients and --message maps to fieldMapping.body; values are wrapped in {rawValue, source}.",
|
|
5544
|
+
command: `zinkee --json automations actions update automation-1 action-1 --type send_message --name "Notify customer" --to customer@example.com --subject "Your order status has changed" --message "Hello, your order is now processed."`,
|
|
5545
|
+
raw: `{
|
|
5546
|
+
"type": "send_message",
|
|
5547
|
+
"name": "Notify customer",
|
|
5548
|
+
"config": {
|
|
5549
|
+
"fieldMapping": {
|
|
5550
|
+
"recipients": {
|
|
5551
|
+
"rawValue": "customer@example.com",
|
|
5552
|
+
"source": null
|
|
5553
|
+
},
|
|
5554
|
+
"subject": {
|
|
5555
|
+
"rawValue": "Your order status has changed",
|
|
5556
|
+
"source": null
|
|
5557
|
+
},
|
|
5558
|
+
"body": {
|
|
5559
|
+
"rawValue": "Hello, your order is now processed.",
|
|
5560
|
+
"source": null
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5503
5564
|
}`
|
|
5504
5565
|
}
|
|
5505
5566
|
]),
|
|
@@ -7007,6 +7068,15 @@ function buildActionInput(options, mode) {
|
|
|
7007
7068
|
if (options.targetSchema !== void 0) {
|
|
7008
7069
|
config.targetSchemaId = options.targetSchema;
|
|
7009
7070
|
}
|
|
7071
|
+
if (options.to !== void 0) {
|
|
7072
|
+
mappings.recipients = options.to;
|
|
7073
|
+
}
|
|
7074
|
+
if (options.subject !== void 0) {
|
|
7075
|
+
mappings.subject = options.subject;
|
|
7076
|
+
}
|
|
7077
|
+
if (options.message !== void 0) {
|
|
7078
|
+
mappings.body = options.message;
|
|
7079
|
+
}
|
|
7010
7080
|
if (!isEmptyObject(mappings)) {
|
|
7011
7081
|
config.fieldMapping = mappings;
|
|
7012
7082
|
}
|
|
@@ -7050,6 +7120,12 @@ function buildActionInput(options, mode) {
|
|
|
7050
7120
|
if (!isEmptyObject(args)) {
|
|
7051
7121
|
config.pluginArgs = args;
|
|
7052
7122
|
}
|
|
7123
|
+
if (options.documentTemplate !== void 0) {
|
|
7124
|
+
config.documentTemplateId = options.documentTemplate;
|
|
7125
|
+
}
|
|
7126
|
+
if (options.targetFileField !== void 0) {
|
|
7127
|
+
config.targetFileFieldId = options.targetFileField;
|
|
7128
|
+
}
|
|
7053
7129
|
if (!isEmptyObject(config)) {
|
|
7054
7130
|
if (isJsonObject2(config.fieldMapping)) {
|
|
7055
7131
|
config.fieldMapping = normalizeAutomationFieldMapping(
|
|
@@ -7236,12 +7312,28 @@ function addTriggerPayloadOptions(command) {
|
|
|
7236
7312
|
[]
|
|
7237
7313
|
).option("--webhook-endpoint-id <uuid>", "webhook endpoint id").option("--raw <json>", "raw trigger JSON payload").option("--raw-file <path>", "path to raw trigger JSON payload");
|
|
7238
7314
|
}
|
|
7315
|
+
var ACTION_TYPES_HELP = `
|
|
7316
|
+
Action types and their flags:
|
|
7317
|
+
create_record --target-schema, --map, --map-json
|
|
7318
|
+
update_record --target-schema, --use-trigger-record, --map,
|
|
7319
|
+
--condition, --condition-json
|
|
7320
|
+
search_records --target-schema, --condition, --condition-json
|
|
7321
|
+
send_message --to, --subject, --message
|
|
7322
|
+
(--map / --map-json also accepted for extra keys)
|
|
7323
|
+
http_request --method, --url, --header, --body, --content-type,
|
|
7324
|
+
--timeout-ms, --var, --auth-mode, --connection
|
|
7325
|
+
execute_plugin --plugin, --arg, --arg-json
|
|
7326
|
+
generate_document --document-template, --target-schema, --target-file-field
|
|
7327
|
+
`;
|
|
7239
7328
|
function addActionPayloadOptions(command) {
|
|
7240
|
-
return command.option(
|
|
7329
|
+
return command.option(
|
|
7330
|
+
"--type <type>",
|
|
7331
|
+
"action type (create_record|update_record|search_records|send_message|http_request|execute_plugin|generate_document)"
|
|
7332
|
+
).option("--name <name>", "action name").option("--target-schema <uuid>", "target schema id").option("--map <field=value>", "field mapping", collectValues, []).option("--map-json <field=json>", "JSON field mapping", collectValues, []).option("--condition <field:comparator:value>", "action condition", collectValues, []).option("--condition-json <json>", "action condition as JSON", collectValues, []).option("--use-trigger-record", "use the triggering record").option("--method <method>", "HTTP method").option("--url <url>", "HTTP target URL").option("--header <key=value>", "HTTP header", collectValues, []).option("--body <json>", "HTTP request body as JSON").option("--body-file <path>", "path to HTTP request body JSON").option("--content-type <type>", "HTTP content type").option(
|
|
7241
7333
|
"--timeout-ms <n>",
|
|
7242
7334
|
"HTTP timeout in milliseconds",
|
|
7243
7335
|
parseNonNegativeInteger
|
|
7244
|
-
).option("--var <key=value>", "HTTP variable", collectValues, []).option("--auth-mode <mode>", "HTTP auth mode").option("--connection <uuid>", "connection id for HTTP auth").option("--plugin <id>", "plugin id for execute_plugin").option("--arg <key=value>", "plugin argument", collectValues, []).option("--arg-json <key=json>", "plugin argument as JSON", collectValues, []).option("--raw <json>", "raw action JSON payload").option("--raw-file <path>", "path to raw action JSON payload");
|
|
7336
|
+
).option("--var <key=value>", "HTTP variable", collectValues, []).option("--auth-mode <mode>", "HTTP auth mode").option("--connection <uuid>", "connection id for HTTP auth").option("--plugin <id>", "plugin id for execute_plugin").option("--arg <key=value>", "plugin argument", collectValues, []).option("--arg-json <key=json>", "plugin argument as JSON", collectValues, []).option("--to <recipient>", "send_message recipient (maps to fieldMapping.recipients)").option("--subject <text>", "send_message subject").option("--message <text>", "send_message body text (maps to fieldMapping.body)").option("--document-template <uuid>", "generate_document template id").option("--target-file-field <uuid>", "generate_document target FileField id").option("--raw <json>", "raw action JSON payload").option("--raw-file <path>", "path to raw action JSON payload").addHelpText("after", ACTION_TYPES_HELP);
|
|
7245
7337
|
}
|
|
7246
7338
|
function registerAutomationsCommands(program, options = {}) {
|
|
7247
7339
|
const filePath = options.configPath ?? defaultConfigPath;
|