zinkee 0.1.12 → 0.1.17
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/AGENTS.md +42 -0
- package/README.md +7 -0
- package/dist/index.js +967 -1425
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/records.ts +7 -0
- package/src/cli-examples.ts +3 -58
- package/src/cli-runner.ts +1 -5
- package/src/command-registry.ts +7 -0
- package/src/commands/automations.test.ts +5 -5
- package/src/commands/displays.test.ts +2 -2
- package/src/commands/records.test.ts +58 -0
- package/src/commands/records.ts +19 -0
- package/src/index.test.ts +1 -8
- package/src/utils/examples.test.ts +22 -1
- package/src/utils/examples.ts +34 -566
- package/src/utils/schema-fields.ts +12 -10
- package/.claude/settings.local.json +0 -44
package/src/utils/examples.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { AutomationsApi } from "../api/automations.js";
|
|
2
|
-
import { SchemasApi, type ApiSchema, type ApiSchemaField } from "../api/schemas.js";
|
|
3
|
-
import { ApiClient } from "../client.js";
|
|
4
|
-
import { defaultConfigPath, readRuntimeConfig } from "../config.js";
|
|
5
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
6
|
-
import { resolveRuntimeContext } from "../runtime-context.js";
|
|
7
|
-
import type { RuntimeOverrides } from "../types.js";
|
|
8
1
|
import {
|
|
9
2
|
getSchemaFieldTypeDefinitions,
|
|
10
3
|
resolveSchemaFieldType,
|
|
@@ -17,12 +10,6 @@ export interface CommandExample {
|
|
|
17
10
|
response?: string;
|
|
18
11
|
}
|
|
19
12
|
|
|
20
|
-
export interface ExampleContextOptions {
|
|
21
|
-
enabled?: boolean;
|
|
22
|
-
configPath?: string;
|
|
23
|
-
overrides?: RuntimeOverrides;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
13
|
export function buildCommandExample(example: CommandExample): CommandExample {
|
|
27
14
|
return {
|
|
28
15
|
command: example.command,
|
|
@@ -411,11 +398,11 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
411
398
|
{
|
|
412
399
|
description: "Patch formula field (formula text).",
|
|
413
400
|
command:
|
|
414
|
-
`zinkee --json schemas fields update contacts formula-total --raw '{"type":"FormulaField","config":{"formulaText":"
|
|
401
|
+
`zinkee --json schemas fields update contacts formula-total --raw '{"type":"FormulaField","config":{"formulaText":"c52efe3f-2825-4c60-a7e3-34dd4c1ce043 * 1.10","uiFormatKind":"number","status":"ACTIVE","numberFormatOptions":{"format":"number","decimals":2,"thousandsSeparator":true},"conditionalFormatting":[]}}'`,
|
|
415
402
|
raw: `{
|
|
416
403
|
"type": "FormulaField",
|
|
417
404
|
"config": {
|
|
418
|
-
"formulaText": "
|
|
405
|
+
"formulaText": "c52efe3f-2825-4c60-a7e3-34dd4c1ce043 * 1.10",
|
|
419
406
|
"uiFormatKind": "number",
|
|
420
407
|
"status": "ACTIVE",
|
|
421
408
|
"numberFormatOptions": {
|
|
@@ -623,9 +610,9 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
623
610
|
},
|
|
624
611
|
{
|
|
625
612
|
description:
|
|
626
|
-
"Create a record mixing text, option, number, date and
|
|
613
|
+
"Create a record mixing text, option, number, date, reference and member fields. ReferenceField values must match the target's current targetDisplayField (read it from the target record before writing).",
|
|
627
614
|
command:
|
|
628
|
-
`zinkee --json records create contacts --set contact-name="Grace Hopper" --set contact-email=grace@example.com --set
|
|
615
|
+
`zinkee --json records create contacts --set contact-name="Grace Hopper" --set contact-email=grace@example.com --set status=2 --set amount=1999.99 --set due-date=2026-06-01T09:00:00Z --set customer-ref="CUST-12" --set owner=6c8a3e0d-4e5f-4a1b-9c2d-3e4f5a6b7c8d`,
|
|
629
616
|
raw: `{
|
|
630
617
|
"values": {
|
|
631
618
|
"contact-name": "Grace Hopper",
|
|
@@ -633,7 +620,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
633
620
|
"status": 2,
|
|
634
621
|
"amount": 1999.99,
|
|
635
622
|
"due-date": "2026-06-01T09:00:00Z",
|
|
636
|
-
"customer-ref": "
|
|
623
|
+
"customer-ref": "CUST-12",
|
|
637
624
|
"owner": "6c8a3e0d-4e5f-4a1b-9c2d-3e4f5a6b7c8d"
|
|
638
625
|
}
|
|
639
626
|
}`,
|
|
@@ -664,7 +651,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
664
651
|
{
|
|
665
652
|
description: "Patch multiple typed values at once.",
|
|
666
653
|
command:
|
|
667
|
-
'zinkee --json records update contacts 550e8400-e29b-41d4-a716-446655440000 --set
|
|
654
|
+
'zinkee --json records update contacts 550e8400-e29b-41d4-a716-446655440000 --set status=3 --set amount=2500.00 --set due-date=2026-07-01T09:00:00Z --set owner=6c8a3e0d-4e5f-4a1b-9c2d-3e4f5a6b7c8d',
|
|
668
655
|
raw: `{
|
|
669
656
|
"set": {
|
|
670
657
|
"status": 3,
|
|
@@ -1398,9 +1385,9 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1398
1385
|
}`,
|
|
1399
1386
|
},
|
|
1400
1387
|
{
|
|
1401
|
-
description: "Create a
|
|
1388
|
+
description: "Create a bars CHART widget with a time-serie x-axis and two y-axis series.",
|
|
1402
1389
|
command:
|
|
1403
|
-
`zinkee --json displays widgets create 0f6f062f-1478-4df2-96a1-c495d037d260 --type CHART --name "Revenue by month" --origin-resource 2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e --layout '{"x":0,"y":0,"w":8,"h":6}' --chart-type
|
|
1390
|
+
`zinkee --json displays widgets create 0f6f062f-1478-4df2-96a1-c495d037d260 --type CHART --name "Revenue by month" --origin-resource 2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e --layout '{"x":0,"y":0,"w":8,"h":6}' --chart-type bars --x-axis-field due-date --x-axis-date-format MONTH --x-axis-time-series --y-axis-serie '{"typeCalc":"SUM","fieldCalc":"amount","color":"#4B9CD3","axisType":"PRIMARY"}' --y-axis-serie '{"typeCalc":"COUNT","fieldCalc":"id","color":"#E57373","axisType":"SECONDARY"}' --legend '{"position":"bottom"}'`,
|
|
1404
1391
|
raw: `{
|
|
1405
1392
|
"type": "CHART",
|
|
1406
1393
|
"source": {
|
|
@@ -1412,7 +1399,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1412
1399
|
},
|
|
1413
1400
|
"presentation": { "name": "Revenue by month" },
|
|
1414
1401
|
"chart": {
|
|
1415
|
-
"chartType": "
|
|
1402
|
+
"chartType": "bars",
|
|
1416
1403
|
"xAxisFieldId": "due-date",
|
|
1417
1404
|
"xAxisDateFormat": "MONTH",
|
|
1418
1405
|
"xAxisAsTimeSerie": true,
|
|
@@ -1421,13 +1408,13 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1421
1408
|
"typeCalc": "SUM",
|
|
1422
1409
|
"fieldCalc": "amount",
|
|
1423
1410
|
"color": "#4B9CD3",
|
|
1424
|
-
"axisType": "
|
|
1411
|
+
"axisType": "PRIMARY"
|
|
1425
1412
|
},
|
|
1426
1413
|
{
|
|
1427
1414
|
"typeCalc": "COUNT",
|
|
1428
1415
|
"fieldCalc": "id",
|
|
1429
1416
|
"color": "#E57373",
|
|
1430
|
-
"axisType": "
|
|
1417
|
+
"axisType": "SECONDARY"
|
|
1431
1418
|
}
|
|
1432
1419
|
],
|
|
1433
1420
|
"legend": { "position": "bottom" }
|
|
@@ -1582,12 +1569,12 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1582
1569
|
}`,
|
|
1583
1570
|
},
|
|
1584
1571
|
{
|
|
1585
|
-
description: "Replace the chart series with
|
|
1572
|
+
description: "Replace the chart series with weekly lines.",
|
|
1586
1573
|
command:
|
|
1587
|
-
`zinkee --json displays widgets update 0f6f062f-1478-4df2-96a1-c495d037d260 22222222-2222-4222-a222-222222222222 --chart-type
|
|
1574
|
+
`zinkee --json displays widgets update 0f6f062f-1478-4df2-96a1-c495d037d260 22222222-2222-4222-a222-222222222222 --chart-type lines --x-axis-field due-date --x-axis-date-format WEEK --x-axis-time-series --y-axis-serie '{"typeCalc":"SUM","fieldCalc":"amount","color":"#2E7D32","axisType":"PRIMARY"}'`,
|
|
1588
1575
|
raw: `{
|
|
1589
1576
|
"chart": {
|
|
1590
|
-
"chartType": "
|
|
1577
|
+
"chartType": "lines",
|
|
1591
1578
|
"xAxisFieldId": "due-date",
|
|
1592
1579
|
"xAxisDateFormat": "WEEK",
|
|
1593
1580
|
"xAxisAsTimeSerie": true,
|
|
@@ -1596,7 +1583,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1596
1583
|
"typeCalc": "SUM",
|
|
1597
1584
|
"fieldCalc": "amount",
|
|
1598
1585
|
"color": "#2E7D32",
|
|
1599
|
-
"axisType": "
|
|
1586
|
+
"axisType": "PRIMARY"
|
|
1600
1587
|
}
|
|
1601
1588
|
]
|
|
1602
1589
|
}
|
|
@@ -1932,7 +1919,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1932
1919
|
"required": false,
|
|
1933
1920
|
"system": false,
|
|
1934
1921
|
"config": {
|
|
1935
|
-
"formulaText": "
|
|
1922
|
+
"formulaText": "c52efe3f-2825-4c60-a7e3-34dd4c1ce043 * 1.21",
|
|
1936
1923
|
"uiFormatKind": "number",
|
|
1937
1924
|
"status": "ACTIVE",
|
|
1938
1925
|
"defaultValue": null,
|
|
@@ -1947,12 +1934,12 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1947
1934
|
{
|
|
1948
1935
|
"id": "6d7e8f90-1234-5678-9abc-def012345678",
|
|
1949
1936
|
"type": "FormulaField",
|
|
1950
|
-
"slug": "formula-
|
|
1951
|
-
"label": "
|
|
1937
|
+
"slug": "formula-period",
|
|
1938
|
+
"label": "Formula Period",
|
|
1952
1939
|
"required": false,
|
|
1953
1940
|
"system": false,
|
|
1954
1941
|
"config": {
|
|
1955
|
-
"formulaText": "
|
|
1942
|
+
"formulaText": "date_format(d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90, \"AAAA-MM\")",
|
|
1956
1943
|
"uiFormatKind": "date",
|
|
1957
1944
|
"status": "ACTIVE",
|
|
1958
1945
|
"defaultValue": null,
|
|
@@ -2234,6 +2221,17 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
2234
2221
|
response: `{
|
|
2235
2222
|
"recordId": "550e8400-e29b-41d4-a716-446655440000",
|
|
2236
2223
|
"deleted": true
|
|
2224
|
+
}`,
|
|
2225
|
+
},
|
|
2226
|
+
]),
|
|
2227
|
+
"records clear": buildCommandExamples([
|
|
2228
|
+
{
|
|
2229
|
+
description:
|
|
2230
|
+
"Delete every record from a schema's table. Heritage rules (CASCADE / SET NULL) propagate to child schemas asynchronously via the CDC pipeline.",
|
|
2231
|
+
command: "zinkee --json records clear contacts",
|
|
2232
|
+
response: `{
|
|
2233
|
+
"schemaId": "2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e",
|
|
2234
|
+
"cleared": true
|
|
2237
2235
|
}`,
|
|
2238
2236
|
},
|
|
2239
2237
|
]),
|
|
@@ -3353,7 +3351,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
3353
3351
|
description:
|
|
3354
3352
|
"Add a search-records action whose condition pulls its value from the trigger payload using --condition-json.",
|
|
3355
3353
|
command:
|
|
3356
|
-
`zinkee --json automations actions add automation-1 --type search_records --name "Find duplicates" --target-schema followups --condition-json '{"field":"email","comparator":"eq","values":[{"rawValue":null,"source":{"type":"TRIGGER","id":"
|
|
3354
|
+
`zinkee --json automations actions add automation-1 --type search_records --name "Find duplicates" --target-schema followups --condition-json '{"field":"email","comparator":"eq","values":[{"rawValue":null,"source":{"type":"TRIGGER","id":"f1e1d000-0000-0000-0000-000000000005"}}]}'`,
|
|
3357
3355
|
raw: `{
|
|
3358
3356
|
"type": "search_records",
|
|
3359
3357
|
"name": "Find duplicates",
|
|
@@ -3368,7 +3366,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
3368
3366
|
"rawValue": null,
|
|
3369
3367
|
"source": {
|
|
3370
3368
|
"type": "TRIGGER",
|
|
3371
|
-
"id": "
|
|
3369
|
+
"id": "f1e1d000-0000-0000-0000-000000000005"
|
|
3372
3370
|
}
|
|
3373
3371
|
}
|
|
3374
3372
|
]
|
|
@@ -3694,539 +3692,9 @@ export function getCommandExamples(
|
|
|
3694
3692
|
return specificExamples[commandName] ?? fallbackExamples(commandName);
|
|
3695
3693
|
}
|
|
3696
3694
|
|
|
3697
|
-
|
|
3698
|
-
automationsApi: AutomationsApi;
|
|
3699
|
-
schemasApi: SchemasApi;
|
|
3700
|
-
}
|
|
3701
|
-
|
|
3702
|
-
interface SchemaFieldReference {
|
|
3703
|
-
schemaId: string;
|
|
3704
|
-
schemaRef: string;
|
|
3705
|
-
fieldId: string;
|
|
3706
|
-
fieldRef: string;
|
|
3707
|
-
}
|
|
3708
|
-
|
|
3709
|
-
interface AutomationActionReference {
|
|
3710
|
-
automationId: string;
|
|
3711
|
-
actionId: string;
|
|
3712
|
-
}
|
|
3713
|
-
|
|
3714
|
-
function selector(value: string): NormalizedUuidOrSlug {
|
|
3715
|
-
return {
|
|
3716
|
-
kind: "uuid",
|
|
3717
|
-
value,
|
|
3718
|
-
};
|
|
3719
|
-
}
|
|
3720
|
-
|
|
3721
|
-
async function createExampleAutomationContext(
|
|
3722
|
-
options: ExampleContextOptions = {},
|
|
3723
|
-
): Promise<ExampleAutomationContext | null> {
|
|
3724
|
-
if (options.enabled !== true) {
|
|
3725
|
-
return null;
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
try {
|
|
3729
|
-
const config = readRuntimeConfig(options.configPath ?? defaultConfigPath);
|
|
3730
|
-
const runtime = resolveRuntimeContext(config, options.overrides);
|
|
3731
|
-
|
|
3732
|
-
if (!runtime.baseUrl) {
|
|
3733
|
-
return null;
|
|
3734
|
-
}
|
|
3735
|
-
|
|
3736
|
-
const client = new ApiClient({
|
|
3737
|
-
baseUrl: runtime.baseUrl,
|
|
3738
|
-
apiKey: runtime.apiKey,
|
|
3739
|
-
});
|
|
3740
|
-
|
|
3741
|
-
return {
|
|
3742
|
-
automationsApi: new AutomationsApi(client),
|
|
3743
|
-
schemasApi: new SchemasApi(client),
|
|
3744
|
-
};
|
|
3745
|
-
} catch {
|
|
3746
|
-
return null;
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
|
|
3750
|
-
function referenceValue(value: { slug?: string; id?: string }): string | undefined {
|
|
3751
|
-
return value.slug ?? value.id;
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
function pickExampleField(fields: readonly ApiSchemaField[]): ApiSchemaField | undefined {
|
|
3755
|
-
return fields.find((field) => !field.required || field.slug || field.id) ?? fields[0];
|
|
3756
|
-
}
|
|
3757
|
-
|
|
3758
|
-
async function findSchemaFieldReference(
|
|
3759
|
-
context: ExampleAutomationContext,
|
|
3760
|
-
): Promise<SchemaFieldReference | null> {
|
|
3761
|
-
const schemas = await context.schemasApi.listSchemas();
|
|
3762
|
-
|
|
3763
|
-
for (const schema of schemas) {
|
|
3764
|
-
if (typeof schema.id !== "string") {
|
|
3765
|
-
continue;
|
|
3766
|
-
}
|
|
3767
|
-
|
|
3768
|
-
const fullSchema = await context.schemasApi.getSchema(selector(schema.id));
|
|
3769
|
-
const fields = Array.isArray(fullSchema.fields) ? fullSchema.fields : [];
|
|
3770
|
-
const field = pickExampleField(fields);
|
|
3771
|
-
const schemaRef = referenceValue(schema);
|
|
3772
|
-
const fieldRef = field ? referenceValue(field) : undefined;
|
|
3773
|
-
const fieldId = typeof field?.id === "string" ? field.id : undefined;
|
|
3774
|
-
|
|
3775
|
-
if (!schemaRef || !fieldRef || !fieldId) {
|
|
3776
|
-
continue;
|
|
3777
|
-
}
|
|
3778
|
-
|
|
3779
|
-
return {
|
|
3780
|
-
schemaId: schema.id,
|
|
3781
|
-
schemaRef,
|
|
3782
|
-
fieldId,
|
|
3783
|
-
fieldRef,
|
|
3784
|
-
};
|
|
3785
|
-
}
|
|
3786
|
-
|
|
3787
|
-
return null;
|
|
3788
|
-
}
|
|
3789
|
-
|
|
3790
|
-
async function findAutomationId(context: ExampleAutomationContext): Promise<string | null> {
|
|
3791
|
-
const automations = await context.automationsApi.listAutomations();
|
|
3792
|
-
const first = automations.find((automation) => typeof automation.id === "string");
|
|
3793
|
-
return typeof first?.id === "string" ? first.id : null;
|
|
3794
|
-
}
|
|
3795
|
-
|
|
3796
|
-
async function findAutomationWithAction(
|
|
3797
|
-
context: ExampleAutomationContext,
|
|
3798
|
-
): Promise<AutomationActionReference | null> {
|
|
3799
|
-
const automations = await context.automationsApi.listAutomations();
|
|
3800
|
-
|
|
3801
|
-
for (const automation of automations) {
|
|
3802
|
-
if (typeof automation.id !== "string") {
|
|
3803
|
-
continue;
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
|
-
const actions = await context.automationsApi.listActions(selector(automation.id));
|
|
3807
|
-
const firstAction = actions.find((action) => typeof action.id === "string");
|
|
3808
|
-
|
|
3809
|
-
if (typeof firstAction?.id === "string") {
|
|
3810
|
-
return {
|
|
3811
|
-
automationId: automation.id,
|
|
3812
|
-
actionId: firstAction.id,
|
|
3813
|
-
};
|
|
3814
|
-
}
|
|
3815
|
-
}
|
|
3816
|
-
|
|
3817
|
-
return null;
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
|
-
async function buildDynamicAutomationExamples(
|
|
3821
|
-
commandName: string,
|
|
3822
|
-
options: ExampleContextOptions = {},
|
|
3823
|
-
): Promise<readonly CommandExample[]> {
|
|
3824
|
-
const context = await createExampleAutomationContext(options);
|
|
3825
|
-
|
|
3826
|
-
if (!context) {
|
|
3827
|
-
return [];
|
|
3828
|
-
}
|
|
3829
|
-
|
|
3830
|
-
const schemaField = await findSchemaFieldReference(context);
|
|
3831
|
-
const automationId = await findAutomationId(context);
|
|
3832
|
-
const automationWithAction = await findAutomationWithAction(context);
|
|
3833
|
-
const plugins = await context.automationsApi.listPlugins();
|
|
3834
|
-
const pluginId = typeof plugins[0]?.id === "string" ? plugins[0].id : undefined;
|
|
3835
|
-
const connections = await context.automationsApi.listConnections();
|
|
3836
|
-
const connectionId = typeof connections[0]?.id === "string" ? connections[0].id : undefined;
|
|
3837
|
-
|
|
3838
|
-
switch (commandName) {
|
|
3839
|
-
case "automations create":
|
|
3840
|
-
if (!schemaField) {
|
|
3841
|
-
return [];
|
|
3842
|
-
}
|
|
3843
|
-
return buildCommandExamples([
|
|
3844
|
-
{
|
|
3845
|
-
description:
|
|
3846
|
-
"Create a scheduled automation with a six-field cron expression. This is the safest first example because it does not depend on workspace schemas.",
|
|
3847
|
-
command:
|
|
3848
|
-
'zinkee --json automations create --name "Nightly invoice sync" --trigger-type scheduled --cron "0 15 10 * * 1"',
|
|
3849
|
-
raw: `{
|
|
3850
|
-
"name": "Nightly invoice sync",
|
|
3851
|
-
"trigger": {
|
|
3852
|
-
"type": "scheduled",
|
|
3853
|
-
"config": {
|
|
3854
|
-
"cronExpression": "0 15 10 * * 1"
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
}`,
|
|
3858
|
-
response: `{
|
|
3859
|
-
"automationId": "d2df2478-2513-4ecb-a2aa-2cea8c3d614a",
|
|
3860
|
-
"webhookEndpoint": null
|
|
3861
|
-
}`,
|
|
3862
|
-
},
|
|
3863
|
-
{
|
|
3864
|
-
description:
|
|
3865
|
-
`Create a record-created automation using a real schema reference from this workspace (${schemaField.schemaRef}), with an 'is not empty' condition on ${schemaField.fieldRef}.`,
|
|
3866
|
-
command: `zinkee --json automations create --name "Record created demo" --trigger-type record_created --trigger-schema ${schemaField.schemaRef} --condition-json '{"field":"${schemaField.fieldRef}","comparator":"ine","values":[{"rawValue":"","source":null}]}'`,
|
|
3867
|
-
raw: `{
|
|
3868
|
-
"name": "Record created demo",
|
|
3869
|
-
"trigger": {
|
|
3870
|
-
"type": "record_created",
|
|
3871
|
-
"config": {
|
|
3872
|
-
"schemaId": "${schemaField.schemaRef}",
|
|
3873
|
-
"conditions": [
|
|
3874
|
-
{
|
|
3875
|
-
"field": "${schemaField.fieldRef}",
|
|
3876
|
-
"comparator": "ine",
|
|
3877
|
-
"values": [{"rawValue": "", "source": null}]
|
|
3878
|
-
}
|
|
3879
|
-
]
|
|
3880
|
-
}
|
|
3881
|
-
}
|
|
3882
|
-
}`,
|
|
3883
|
-
},
|
|
3884
|
-
{
|
|
3885
|
-
description:
|
|
3886
|
-
`Create a record-changed automation watching ${schemaField.fieldRef} on ${schemaField.schemaRef}, with an 'is not empty' condition on that field.`,
|
|
3887
|
-
command: `zinkee --json automations create --name "Record changed demo" --trigger-type record_changed --trigger-schema ${schemaField.schemaRef} --trigger-field ${schemaField.fieldRef} --condition-json '{"field":"${schemaField.fieldRef}","comparator":"ine","values":[{"rawValue":"","source":null}]}'`,
|
|
3888
|
-
raw: `{
|
|
3889
|
-
"name": "Record changed demo",
|
|
3890
|
-
"trigger": {
|
|
3891
|
-
"type": "record_changed",
|
|
3892
|
-
"config": {
|
|
3893
|
-
"schemaId": "${schemaField.schemaRef}",
|
|
3894
|
-
"fieldIds": ["${schemaField.fieldRef}"],
|
|
3895
|
-
"conditions": [
|
|
3896
|
-
{
|
|
3897
|
-
"field": "${schemaField.fieldRef}",
|
|
3898
|
-
"comparator": "ine",
|
|
3899
|
-
"values": [{"rawValue": "", "source": null}]
|
|
3900
|
-
}
|
|
3901
|
-
]
|
|
3902
|
-
}
|
|
3903
|
-
}
|
|
3904
|
-
}`,
|
|
3905
|
-
},
|
|
3906
|
-
]);
|
|
3907
|
-
case "automations trigger set":
|
|
3908
|
-
if (!automationId || !schemaField) {
|
|
3909
|
-
return [];
|
|
3910
|
-
}
|
|
3911
|
-
return buildCommandExamples([
|
|
3912
|
-
{
|
|
3913
|
-
description: "Replace the trigger with a scheduled trigger on a real automation from this workspace.",
|
|
3914
|
-
command: `zinkee --json automations trigger set ${automationId} --trigger-type scheduled --cron "0 15 10 * * 1"`,
|
|
3915
|
-
raw: `{
|
|
3916
|
-
"type": "scheduled",
|
|
3917
|
-
"config": {
|
|
3918
|
-
"cronExpression": "0 15 10 * * 1"
|
|
3919
|
-
}
|
|
3920
|
-
}`,
|
|
3921
|
-
},
|
|
3922
|
-
{
|
|
3923
|
-
description:
|
|
3924
|
-
`Replace the trigger with a record-created trigger on ${schemaField.schemaRef}, with an 'is not empty' condition on ${schemaField.fieldRef}.`,
|
|
3925
|
-
command: `zinkee --json automations trigger set ${automationId} --trigger-type record_created --trigger-schema ${schemaField.schemaRef} --condition-json '{"field":"${schemaField.fieldRef}","comparator":"ine","values":[{"rawValue":"","source":null}]}'`,
|
|
3926
|
-
raw: `{
|
|
3927
|
-
"type": "record_created",
|
|
3928
|
-
"config": {
|
|
3929
|
-
"schemaId": "${schemaField.schemaRef}",
|
|
3930
|
-
"conditions": [
|
|
3931
|
-
{
|
|
3932
|
-
"field": "${schemaField.fieldRef}",
|
|
3933
|
-
"comparator": "ine",
|
|
3934
|
-
"values": [{"rawValue": "", "source": null}]
|
|
3935
|
-
}
|
|
3936
|
-
]
|
|
3937
|
-
}
|
|
3938
|
-
}`,
|
|
3939
|
-
},
|
|
3940
|
-
{
|
|
3941
|
-
description:
|
|
3942
|
-
`Replace the trigger with a record-changed trigger watching ${schemaField.fieldRef} on ${schemaField.schemaRef}.`,
|
|
3943
|
-
command: `zinkee --json automations trigger set ${automationId} --trigger-type record_changed --trigger-schema ${schemaField.schemaRef} --trigger-field ${schemaField.fieldRef} --condition-json '{"field":"${schemaField.fieldRef}","comparator":"ine","values":[{"rawValue":"","source":null}]}'`,
|
|
3944
|
-
raw: `{
|
|
3945
|
-
"type": "record_changed",
|
|
3946
|
-
"config": {
|
|
3947
|
-
"schemaId": "${schemaField.schemaRef}",
|
|
3948
|
-
"fieldIds": ["${schemaField.fieldRef}"],
|
|
3949
|
-
"conditions": [
|
|
3950
|
-
{
|
|
3951
|
-
"field": "${schemaField.fieldRef}",
|
|
3952
|
-
"comparator": "ine",
|
|
3953
|
-
"values": [{"rawValue": "", "source": null}]
|
|
3954
|
-
}
|
|
3955
|
-
]
|
|
3956
|
-
}
|
|
3957
|
-
}`,
|
|
3958
|
-
},
|
|
3959
|
-
]);
|
|
3960
|
-
case "automations actions add":
|
|
3961
|
-
if (!automationId || !schemaField) {
|
|
3962
|
-
return [];
|
|
3963
|
-
}
|
|
3964
|
-
return buildCommandExamples([
|
|
3965
|
-
{
|
|
3966
|
-
description:
|
|
3967
|
-
`Add a create-record action with literal and trigger-based mappings targeting ${schemaField.schemaRef}.`,
|
|
3968
|
-
command: `zinkee --json automations actions add ${automationId} --type create_record --name "Create follow-up order" --target-schema ${schemaField.schemaRef} --map ${schemaField.fieldRef}=pending --map-json owner='{"rawValue":null,"source":{"type":"TRIGGER","id":"payload_value"}}'`,
|
|
3969
|
-
raw: `{
|
|
3970
|
-
"type": "create_record",
|
|
3971
|
-
"name": "Create follow-up order",
|
|
3972
|
-
"config": {
|
|
3973
|
-
"targetSchemaId": "${schemaField.schemaRef}",
|
|
3974
|
-
"fieldMapping": {
|
|
3975
|
-
"${schemaField.fieldRef}": {
|
|
3976
|
-
"rawValue": "pending",
|
|
3977
|
-
"source": null
|
|
3978
|
-
},
|
|
3979
|
-
"owner": {
|
|
3980
|
-
"rawValue": null,
|
|
3981
|
-
"source": {
|
|
3982
|
-
"type": "TRIGGER",
|
|
3983
|
-
"id": "payload_value"
|
|
3984
|
-
}
|
|
3985
|
-
}
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
}`,
|
|
3989
|
-
},
|
|
3990
|
-
{
|
|
3991
|
-
description:
|
|
3992
|
-
`Add an update-record action that targets the trigger record on ${schemaField.schemaRef}.`,
|
|
3993
|
-
command: `zinkee --json automations actions add ${automationId} --type update_record --name "Mark record as processed" --target-schema ${schemaField.schemaRef} --use-trigger-record --map ${schemaField.fieldRef}=processed`,
|
|
3994
|
-
raw: `{
|
|
3995
|
-
"type": "update_record",
|
|
3996
|
-
"name": "Mark record as processed",
|
|
3997
|
-
"config": {
|
|
3998
|
-
"targetSchemaId": "${schemaField.schemaRef}",
|
|
3999
|
-
"fieldMapping": {
|
|
4000
|
-
"${schemaField.fieldRef}": {
|
|
4001
|
-
"rawValue": "processed",
|
|
4002
|
-
"source": null
|
|
4003
|
-
}
|
|
4004
|
-
},
|
|
4005
|
-
"useTriggerRecord": true
|
|
4006
|
-
}
|
|
4007
|
-
}`,
|
|
4008
|
-
},
|
|
4009
|
-
{
|
|
4010
|
-
description: `Add a search-records action with a trigger-based condition on ${schemaField.schemaRef}.`,
|
|
4011
|
-
command: `zinkee --json automations actions add ${automationId} --type search_records --name "Find duplicates" --target-schema ${schemaField.schemaRef} --condition-json '{"field":"${schemaField.fieldRef}","comparator":"eq","values":[{"rawValue":null,"source":{"type":"TRIGGER","id":"payload_value"}}]}'`,
|
|
4012
|
-
raw: `{
|
|
4013
|
-
"type": "search_records",
|
|
4014
|
-
"name": "Find duplicates",
|
|
4015
|
-
"config": {
|
|
4016
|
-
"targetSchemaId": "${schemaField.schemaRef}",
|
|
4017
|
-
"conditions": [
|
|
4018
|
-
{
|
|
4019
|
-
"field": "${schemaField.fieldRef}",
|
|
4020
|
-
"comparator": "eq",
|
|
4021
|
-
"values": [
|
|
4022
|
-
{
|
|
4023
|
-
"rawValue": null,
|
|
4024
|
-
"source": {
|
|
4025
|
-
"type": "TRIGGER",
|
|
4026
|
-
"id": "payload_value"
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
]
|
|
4030
|
-
}
|
|
4031
|
-
]
|
|
4032
|
-
}
|
|
4033
|
-
}`,
|
|
4034
|
-
},
|
|
4035
|
-
...(connectionId
|
|
4036
|
-
? buildCommandExamples([
|
|
4037
|
-
{
|
|
4038
|
-
description: `Add an HTTP request action authenticated through a stored connection (${connectionId}).`,
|
|
4039
|
-
command: `zinkee --json automations actions add ${automationId} --type http_request --name "Notify external ERP" --method POST --url https://example.com/integrations/order-status --header X-Demo=codex --content-type application/json --timeout-ms 5000 --auth-mode STORED --connection ${connectionId}`,
|
|
4040
|
-
raw: `{
|
|
4041
|
-
"type": "http_request",
|
|
4042
|
-
"name": "Notify external ERP",
|
|
4043
|
-
"config": {
|
|
4044
|
-
"method": "POST",
|
|
4045
|
-
"url": "https://example.com/integrations/order-status",
|
|
4046
|
-
"headers": {
|
|
4047
|
-
"X-Demo": "codex"
|
|
4048
|
-
},
|
|
4049
|
-
"contentType": "application/json",
|
|
4050
|
-
"timeoutMs": 5000,
|
|
4051
|
-
"authMode": "STORED",
|
|
4052
|
-
"connectionId": "${connectionId}"
|
|
4053
|
-
}
|
|
4054
|
-
}`,
|
|
4055
|
-
},
|
|
4056
|
-
])
|
|
4057
|
-
: buildCommandExamples([
|
|
4058
|
-
{
|
|
4059
|
-
description: "Add an HTTP request action through the generic --type path.",
|
|
4060
|
-
command: `zinkee --json automations actions add ${automationId} --type http_request --name "Notify external ERP" --method POST --url https://example.com/integrations/order-status --content-type application/json`,
|
|
4061
|
-
raw: `{
|
|
4062
|
-
"type": "http_request",
|
|
4063
|
-
"name": "Notify external ERP",
|
|
4064
|
-
"config": {
|
|
4065
|
-
"method": "POST",
|
|
4066
|
-
"url": "https://example.com/integrations/order-status",
|
|
4067
|
-
"contentType": "application/json"
|
|
4068
|
-
}
|
|
4069
|
-
}`,
|
|
4070
|
-
},
|
|
4071
|
-
])),
|
|
4072
|
-
...(pluginId
|
|
4073
|
-
? buildCommandExamples([
|
|
4074
|
-
{
|
|
4075
|
-
description: `Add an execute-plugin action using an active plugin from this workspace (${pluginId}).`,
|
|
4076
|
-
command: `zinkee --json automations actions add ${automationId} --type execute_plugin --name "Run billing plugin" --plugin ${pluginId} --arg mode=safe --arg-json steps='["one","two"]'`,
|
|
4077
|
-
raw: `{
|
|
4078
|
-
"type": "execute_plugin",
|
|
4079
|
-
"name": "Run billing plugin",
|
|
4080
|
-
"config": {
|
|
4081
|
-
"pluginId": "${pluginId}",
|
|
4082
|
-
"pluginArgs": {
|
|
4083
|
-
"mode": "safe",
|
|
4084
|
-
"steps": ["one", "two"]
|
|
4085
|
-
}
|
|
4086
|
-
}
|
|
4087
|
-
}`,
|
|
4088
|
-
},
|
|
4089
|
-
])
|
|
4090
|
-
: []),
|
|
4091
|
-
]);
|
|
4092
|
-
case "automations actions update":
|
|
4093
|
-
if (!automationWithAction || !schemaField) {
|
|
4094
|
-
return [];
|
|
4095
|
-
}
|
|
4096
|
-
return buildCommandExamples([
|
|
4097
|
-
{
|
|
4098
|
-
description: "Update a record action on a real automation/action pair using the trigger record.",
|
|
4099
|
-
command: `zinkee --json automations actions update ${automationWithAction.automationId} ${automationWithAction.actionId} --type update_record --name "Update trigger record" --target-schema ${schemaField.schemaRef} --map ${schemaField.fieldRef}=ready --use-trigger-record`,
|
|
4100
|
-
raw: `{
|
|
4101
|
-
"type": "update_record",
|
|
4102
|
-
"name": "Update trigger record",
|
|
4103
|
-
"config": {
|
|
4104
|
-
"targetSchemaId": "${schemaField.schemaRef}",
|
|
4105
|
-
"fieldMapping": {
|
|
4106
|
-
"${schemaField.fieldRef}": {
|
|
4107
|
-
"rawValue": "ready",
|
|
4108
|
-
"source": null
|
|
4109
|
-
}
|
|
4110
|
-
},
|
|
4111
|
-
"useTriggerRecord": true
|
|
4112
|
-
}
|
|
4113
|
-
}`,
|
|
4114
|
-
response: `{
|
|
4115
|
-
"id": "${automationWithAction.actionId}",
|
|
4116
|
-
"type": "update_record",
|
|
4117
|
-
"name": "Update trigger record",
|
|
4118
|
-
"config": {
|
|
4119
|
-
"targetSchemaId": "${schemaField.schemaRef}",
|
|
4120
|
-
"fieldMapping": {
|
|
4121
|
-
"${schemaField.fieldRef}": {
|
|
4122
|
-
"rawValue": "ready",
|
|
4123
|
-
"source": null
|
|
4124
|
-
}
|
|
4125
|
-
},
|
|
4126
|
-
"useTriggerRecord": true
|
|
4127
|
-
}
|
|
4128
|
-
}`,
|
|
4129
|
-
},
|
|
4130
|
-
]);
|
|
4131
|
-
case "automations flow set":
|
|
4132
|
-
if (!automationWithAction) {
|
|
4133
|
-
return [];
|
|
4134
|
-
}
|
|
4135
|
-
return buildCommandExamples([
|
|
4136
|
-
{
|
|
4137
|
-
description: "Set flow entry actions using a real automation/action pair from this workspace.",
|
|
4138
|
-
command: `zinkee --json automations flow set ${automationWithAction.automationId} --entry ${automationWithAction.actionId}`,
|
|
4139
|
-
raw: `{
|
|
4140
|
-
"entryActionIds": ["${automationWithAction.actionId}"],
|
|
4141
|
-
"transitions": []
|
|
4142
|
-
}`,
|
|
4143
|
-
},
|
|
4144
|
-
]);
|
|
4145
|
-
case "automations connections create":
|
|
4146
|
-
return buildCommandExamples([
|
|
4147
|
-
{
|
|
4148
|
-
description: "Create a stored workspace connection for HTTP request actions.",
|
|
4149
|
-
command:
|
|
4150
|
-
'zinkee --json automations connections create --name "ERP API Key" --type api_key --scope workspace --config \'{"headerName":"Authorization"}\' --secret apiKey=super-secret --active',
|
|
4151
|
-
raw: `{
|
|
4152
|
-
"name": "ERP API Key",
|
|
4153
|
-
"type": "api_key",
|
|
4154
|
-
"scope": "workspace",
|
|
4155
|
-
"config": {
|
|
4156
|
-
"headerName": "Authorization"
|
|
4157
|
-
},
|
|
4158
|
-
"secret": {
|
|
4159
|
-
"apiKey": "super-secret"
|
|
4160
|
-
},
|
|
4161
|
-
"active": true
|
|
4162
|
-
}`,
|
|
4163
|
-
response: `{
|
|
4164
|
-
"id": "4fc20b5c-9353-4991-b68e-1027cb674ed4",
|
|
4165
|
-
"name": "ERP API Key",
|
|
4166
|
-
"type": "api_key",
|
|
4167
|
-
"scope": "workspace",
|
|
4168
|
-
"ownerMemberId": "6c8a3e0d-7b1f-4c98-a2e9-8b9a2e3f5b14",
|
|
4169
|
-
"active": true,
|
|
4170
|
-
"config": {
|
|
4171
|
-
"headerName": "Authorization"
|
|
4172
|
-
},
|
|
4173
|
-
"createdAt": "2026-04-21T09:00:00Z",
|
|
4174
|
-
"updatedAt": "2026-04-21T09:00:00Z",
|
|
4175
|
-
"createdBy": "developer@zinkee.com",
|
|
4176
|
-
"updatedBy": "developer@zinkee.com"
|
|
4177
|
-
}`,
|
|
4178
|
-
},
|
|
4179
|
-
]);
|
|
4180
|
-
case "automations connections update":
|
|
4181
|
-
if (!connectionId) {
|
|
4182
|
-
return [];
|
|
4183
|
-
}
|
|
4184
|
-
return buildCommandExamples([
|
|
4185
|
-
{
|
|
4186
|
-
description: "Patch an existing stored connection from this workspace.",
|
|
4187
|
-
command: `zinkee --json automations connections update ${connectionId} --raw '{"set":{"name":"ERP API Key Updated","config":{"headerName":"Authorization"}}}'`,
|
|
4188
|
-
raw: `{
|
|
4189
|
-
"set": {
|
|
4190
|
-
"name": "ERP API Key Updated",
|
|
4191
|
-
"config": {
|
|
4192
|
-
"headerName": "Authorization"
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
}`,
|
|
4196
|
-
response: `{
|
|
4197
|
-
"id": "${connectionId}",
|
|
4198
|
-
"name": "ERP API Key Updated",
|
|
4199
|
-
"type": "api_key",
|
|
4200
|
-
"scope": "workspace",
|
|
4201
|
-
"ownerMemberId": "6c8a3e0d-7b1f-4c98-a2e9-8b9a2e3f5b14",
|
|
4202
|
-
"active": true,
|
|
4203
|
-
"config": {
|
|
4204
|
-
"headerName": "Authorization"
|
|
4205
|
-
},
|
|
4206
|
-
"createdAt": "2026-04-21T09:00:00Z",
|
|
4207
|
-
"updatedAt": "2026-04-21T10:15:00Z",
|
|
4208
|
-
"createdBy": "developer@zinkee.com",
|
|
4209
|
-
"updatedBy": "developer@zinkee.com"
|
|
4210
|
-
}`,
|
|
4211
|
-
},
|
|
4212
|
-
]);
|
|
4213
|
-
default:
|
|
4214
|
-
return [];
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
|
|
4218
|
-
export async function getResolvedCommandExamples(
|
|
3695
|
+
export function getResolvedCommandExamples(
|
|
4219
3696
|
commandName: string,
|
|
4220
3697
|
filters: { type?: string } = {},
|
|
4221
|
-
|
|
4222
|
-
): Promise<readonly CommandExample[]> {
|
|
4223
|
-
const dynamicExamples = commandName.startsWith("automations")
|
|
4224
|
-
? await buildDynamicAutomationExamples(commandName, options)
|
|
4225
|
-
: [];
|
|
4226
|
-
|
|
4227
|
-
if (dynamicExamples.length > 0) {
|
|
4228
|
-
return dynamicExamples;
|
|
4229
|
-
}
|
|
4230
|
-
|
|
3698
|
+
): readonly CommandExample[] {
|
|
4231
3699
|
return getCommandExamples(commandName, filters);
|
|
4232
3700
|
}
|