@flowrunner/cli 0.1.9-dev.1 → 0.1.9-dev.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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/templates/qa-test/files/README.md +23 -8
- package/templates/qa-test/files/src/index.js +350 -50
package/package.json
CHANGED
|
@@ -25,9 +25,11 @@ Endpoint**, where you supply the URL.
|
|
|
25
25
|
4. **Params — Date Forms** — put the same value in every field and compare what each declaration hands over
|
|
26
26
|
5. **Params — List Of Objects** and **Params — List Of Choices** — the repeatable editors
|
|
27
27
|
6. **Params — Dictionary-backed** — dependent, paged and failing dropdowns
|
|
28
|
-
7. **
|
|
29
|
-
8. **
|
|
30
|
-
9.
|
|
28
|
+
7. **Dynamic Props — Every Field Type** — pick a record type, fill its fields, switch type and check "Name" keeps its value
|
|
29
|
+
8. **Dynamic Props — Loader States** — slow, failing and invalid loaders, and how each one surfaces
|
|
30
|
+
9. **Files — Upload, Read, List, Delete** — the whole storage surface in one call
|
|
31
|
+
10. **Throw An Error** and **Run Longer Than A Timeout** — failure propagation, and that a long run survives
|
|
32
|
+
11. Enable one of the triggers and wait for a poll
|
|
31
33
|
|
|
32
34
|
## List of Actions
|
|
33
35
|
|
|
@@ -47,10 +49,23 @@ Endpoint**, where you supply the URL.
|
|
|
47
49
|
- Params — List Of Choices
|
|
48
50
|
- Params — Nested Object
|
|
49
51
|
- Params — Dictionary-backed
|
|
50
|
-
- Params — Generated At Runtime
|
|
51
52
|
- Params — Unknown Fields Are Stripped
|
|
52
53
|
|
|
53
|
-
**3.
|
|
54
|
+
**3. Dynamic Fields** — fields loaded at design time from the values of other params; each echoes `params` back
|
|
55
|
+
|
|
56
|
+
- Dynamic Props — Every Field Type
|
|
57
|
+
- Dynamic Props — Declared Keys Plus Loaded Ones
|
|
58
|
+
- Dynamic Props — Dropdowns Inside
|
|
59
|
+
- Dynamic Props — List Of Objects
|
|
60
|
+
- Dynamic Props — No Dependencies
|
|
61
|
+
- Dynamic Props — Several Dependencies, Typed
|
|
62
|
+
- Dynamic Props — One Definition, Two Params
|
|
63
|
+
- Dynamic Props — Loader States
|
|
64
|
+
- Dynamic Params — One Field Per Child
|
|
65
|
+
- Dynamic Params — Every Field Type
|
|
66
|
+
- Dynamic Params And Props Together
|
|
67
|
+
|
|
68
|
+
**4. Results** — one per `result` form, because each publishes a different return type or sample source
|
|
54
69
|
|
|
55
70
|
- Returns — Object
|
|
56
71
|
- Returns — List
|
|
@@ -58,7 +73,7 @@ Endpoint**, where you supply the URL.
|
|
|
58
73
|
- Returns — Sample From A Schema
|
|
59
74
|
- Returns — Sample Computed From Params
|
|
60
75
|
|
|
61
|
-
**
|
|
76
|
+
**5. Runtime**
|
|
62
77
|
|
|
63
78
|
- Call Helpers
|
|
64
79
|
- Emit Logs
|
|
@@ -66,11 +81,11 @@ Endpoint**, where you supply the URL.
|
|
|
66
81
|
- Run Longer Than A Timeout
|
|
67
82
|
- Read OAuth Without Declaring It
|
|
68
83
|
|
|
69
|
-
**
|
|
84
|
+
**6. HTTP**
|
|
70
85
|
|
|
71
86
|
- Call An HTTP Endpoint
|
|
72
87
|
|
|
73
|
-
**
|
|
88
|
+
**7. Files**
|
|
74
89
|
|
|
75
90
|
- Files — Upload, Read, List, Delete
|
|
76
91
|
- Files — Storage Usage
|
|
@@ -417,35 +417,101 @@ ext.addAction({
|
|
|
417
417
|
})
|
|
418
418
|
|
|
419
419
|
ext.addAction({
|
|
420
|
-
category
|
|
421
|
-
id
|
|
422
|
-
label
|
|
423
|
-
description
|
|
424
|
-
params
|
|
425
|
-
|
|
420
|
+
category : '2. Params',
|
|
421
|
+
id : 'paramsUnknownStripped',
|
|
422
|
+
label : 'Params — Unknown Fields Are Stripped',
|
|
423
|
+
description: 'Declares one param. Anything else the flow sends should NOT come back.',
|
|
424
|
+
params : z.object({
|
|
425
|
+
keep: z.string().optional().label('Keep'),
|
|
426
426
|
}),
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const shape = {}
|
|
427
|
+
result : { params: {} },
|
|
428
|
+
execute : ({ params }) => ({ params, keys: Object.keys(params) }),
|
|
429
|
+
})
|
|
431
430
|
|
|
432
|
-
|
|
433
|
-
|
|
431
|
+
// ─── 3. Dynamic Fields ───────────────────────────────────────────────────────
|
|
432
|
+
// Fields loaded at design time from the values of other params. `.dynamicProps()` loads the fields INSIDE one
|
|
433
|
+
// param (a loose object, or a list of them); `dynamicParams` loads extra top-level params of the action. Both
|
|
434
|
+
// load again when a param in `dependsOn` changes, and keep what was entered for fields that come back.
|
|
435
|
+
|
|
436
|
+
const RECORD_TYPES = [
|
|
437
|
+
{ id: 'contact', name: 'Contact' },
|
|
438
|
+
{ id: 'product', name: 'Product' },
|
|
439
|
+
{ id: 'event', name: 'Event' },
|
|
440
|
+
]
|
|
441
|
+
|
|
442
|
+
const getRecordTypesDictionary = ext.dictionary({
|
|
443
|
+
id : 'getRecordTypesDictionary',
|
|
444
|
+
label : 'Record Types',
|
|
445
|
+
description: 'Three record types, each with its own fields. All three have "Name", so it survives a switch.',
|
|
446
|
+
execute : ({ search }) => RECORD_TYPES
|
|
447
|
+
.filter(type => matches(type.name, search))
|
|
448
|
+
.map(type => ({ label: type.name, value: type.id })),
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
// The fields of one record type — every kind of field a loader can return. Built per call: a loader answers
|
|
452
|
+
// with fresh zod each time.
|
|
453
|
+
const recordFields = recordType => {
|
|
454
|
+
switch (recordType) {
|
|
455
|
+
case 'contact':
|
|
456
|
+
return {
|
|
457
|
+
name : z.string().label('Name'),
|
|
458
|
+
email: z.email().optional().label('Email (format-checked)'),
|
|
459
|
+
age : z.number().int().min(0).max(150).optional().label('Age (0–150)'),
|
|
460
|
+
vip : z.boolean().optional().default(false).label('VIP (defaults to false)'),
|
|
461
|
+
tier : z.enum(['free', 'pro', 'enterprise'])
|
|
462
|
+
.labels({ free: 'Free', pro: 'Pro', enterprise: 'Enterprise' })
|
|
463
|
+
.optional()
|
|
464
|
+
.label('Tier (labelled enum)'),
|
|
465
|
+
notes: z.text().optional().label('Notes (multi-line)'),
|
|
434
466
|
}
|
|
435
467
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
468
|
+
case 'product':
|
|
469
|
+
return {
|
|
470
|
+
name : z.string().label('Name'),
|
|
471
|
+
price : z.number().min(0).label('Price (≥ 0)'),
|
|
472
|
+
inStock : z.boolean().label('In Stock'),
|
|
473
|
+
tags : z.array(z.string()).optional().label('Tags (list of text)'),
|
|
474
|
+
category: z.enum(['books', 'games', 'music']).default('books').label('Category (defaults to books)'),
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
case 'event':
|
|
478
|
+
return {
|
|
479
|
+
name : z.string().label('Name'),
|
|
480
|
+
startsAt: z.coerce.date().label('Starts At (date)'),
|
|
481
|
+
link : z.url().optional().label('Link (format-checked)'),
|
|
482
|
+
venue : z.object({
|
|
483
|
+
city: z.string().label('City'),
|
|
484
|
+
room: z.string().optional().label('Room'),
|
|
485
|
+
}).optional().label('Venue (nested object)'),
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
default:
|
|
489
|
+
return {}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
ext.addAction({
|
|
494
|
+
category : '3. Dynamic Fields',
|
|
495
|
+
id : 'dynamicPropsEveryType',
|
|
496
|
+
label : 'Dynamic Props — Every Field Type',
|
|
497
|
+
description: 'Pick a record type: "Record" loads its fields — text, email, number, boolean, enum, date, list, nested object.',
|
|
498
|
+
params : z.object({
|
|
499
|
+
recordType: z.string().label('Record Type').dictionary(getRecordTypesDictionary),
|
|
500
|
+
record : z.looseObject({}).label('Record').dynamicProps({
|
|
501
|
+
dependsOn: ['recordType'],
|
|
502
|
+
execute : ({ criteria }) => recordFields(criteria.recordType),
|
|
503
|
+
}),
|
|
504
|
+
}),
|
|
505
|
+
result : { params: {} },
|
|
506
|
+
// The loaded fields arrive nested under `record`, as their declared types
|
|
507
|
+
execute : ({ params }) => ({ params, types: typesOf(params.record) }),
|
|
442
508
|
})
|
|
443
509
|
|
|
444
510
|
ext.addAction({
|
|
445
|
-
category : '
|
|
446
|
-
id : '
|
|
447
|
-
label : '
|
|
448
|
-
description: 'Picking a parent loads one field per child INSIDE "Child Fields"
|
|
511
|
+
category : '3. Dynamic Fields',
|
|
512
|
+
id : 'dynamicPropsDeclaredKeys',
|
|
513
|
+
label : 'Dynamic Props — Declared Keys Plus Loaded Ones',
|
|
514
|
+
description: 'Picking a parent loads one field per child INSIDE "Child Fields", after its declared "Comment".',
|
|
449
515
|
params : z.object({
|
|
450
516
|
parentId : z.string().label('Parent').dictionary(getParentsDictionary),
|
|
451
517
|
// A loose object, so the loaded keys are kept. Declared keys (`comment`) are shown first, loaded ones after.
|
|
@@ -466,28 +532,262 @@ ext.addAction({
|
|
|
466
532
|
}),
|
|
467
533
|
}),
|
|
468
534
|
result : { params: {} },
|
|
469
|
-
// The loaded fields arrive nested under `childFields`
|
|
470
535
|
execute : ({ params }) => ({ params, keys: Object.keys(params.childFields || {}) }),
|
|
471
536
|
})
|
|
472
537
|
|
|
473
538
|
ext.addAction({
|
|
474
|
-
category : '
|
|
475
|
-
id : '
|
|
476
|
-
label : '
|
|
477
|
-
description: '
|
|
539
|
+
category : '3. Dynamic Fields',
|
|
540
|
+
id : 'dynamicPropsWithDictionaries',
|
|
541
|
+
label : 'Dynamic Props — Dropdowns Inside',
|
|
542
|
+
description: 'The loaded fields are dropdowns: plain, dependent (child of the loaded parent), paged and failing.',
|
|
478
543
|
params : z.object({
|
|
479
|
-
|
|
544
|
+
withChild: z.boolean().optional().default(true).label('Include the dependent "Child" dropdown'),
|
|
545
|
+
lookups : z.looseObject({}).label('Lookups').dynamicProps({
|
|
546
|
+
dependsOn: ['withChild'],
|
|
547
|
+
// `criteria.withChild` arrives as a boolean, whatever form the flow sent it in
|
|
548
|
+
execute : ({ criteria }) => ({
|
|
549
|
+
parentId : z.string().label('Parent').dictionary(getParentsDictionary),
|
|
550
|
+
...(criteria.withChild ? { childId: z.string().optional().label('Child (depends on Parent)').dictionary(getChildrenDictionary) } : {}),
|
|
551
|
+
pagedId : z.string().optional().label('Paged (137 items)').dictionary(getPagedDictionary),
|
|
552
|
+
failingId: z.string().optional().label('Failing').dictionary(getFailingDictionary),
|
|
553
|
+
}),
|
|
554
|
+
}),
|
|
480
555
|
}),
|
|
481
556
|
result : { params: {} },
|
|
482
|
-
execute : ({ params }) => ({ params
|
|
557
|
+
execute : ({ params }) => ({ params }),
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
ext.addAction({
|
|
561
|
+
category : '3. Dynamic Fields',
|
|
562
|
+
id : 'dynamicPropsListOfObjects',
|
|
563
|
+
label : 'Dynamic Props — List Of Objects',
|
|
564
|
+
description: 'Each row of "Rows" gets the fields of the picked record type. `.dynamicProps()` sits on the list.',
|
|
565
|
+
params : z.object({
|
|
566
|
+
recordType: z.string().label('Record Type').dictionary(getRecordTypesDictionary),
|
|
567
|
+
rows : z.array(z.looseObject({})).optional().label('Rows').dynamicProps({
|
|
568
|
+
dependsOn: ['recordType'],
|
|
569
|
+
execute : ({ criteria }) => recordFields(criteria.recordType),
|
|
570
|
+
}),
|
|
571
|
+
}),
|
|
572
|
+
result : { params: {} },
|
|
573
|
+
execute : ({ params }) => ({ params, rows: (params.rows || []).length }),
|
|
574
|
+
})
|
|
575
|
+
|
|
576
|
+
ext.addAction({
|
|
577
|
+
category : '3. Dynamic Fields',
|
|
578
|
+
id : 'dynamicPropsNoDependencies',
|
|
579
|
+
label : 'Dynamic Props — No Dependencies',
|
|
580
|
+
description: 'No `dependsOn`: the fields load once when the block opens, and again only on a connection change.',
|
|
581
|
+
params : z.object({
|
|
582
|
+
custom: z.looseObject({}).label('Account Custom Fields').dynamicProps({
|
|
583
|
+
execute: () => ({
|
|
584
|
+
costCenter: z.string().optional().label('Cost Center'),
|
|
585
|
+
priority : z.enum(['low', 'normal', 'high']).optional().label('Priority'),
|
|
586
|
+
loadedAt : z.string().optional().default(new Date().toISOString()).label('Loaded At (default = when it loaded)'),
|
|
587
|
+
}),
|
|
588
|
+
}),
|
|
589
|
+
}),
|
|
590
|
+
result : { params: {} },
|
|
591
|
+
execute : ({ params }) => ({ params }),
|
|
592
|
+
})
|
|
593
|
+
|
|
594
|
+
ext.addAction({
|
|
595
|
+
category : '3. Dynamic Fields',
|
|
596
|
+
id : 'dynamicPropsCriteriaTypes',
|
|
597
|
+
label : 'Dynamic Props — Several Dependencies, Typed',
|
|
598
|
+
description: 'Three dependencies of different types. Each loaded label shows the type its criteria value arrived as.',
|
|
599
|
+
params : z.object({
|
|
600
|
+
count : z.number().int().min(0).max(10).default(2).label('How many fields (0–10)'),
|
|
601
|
+
withFlags: z.boolean().optional().default(false).label('Add a toggle per field'),
|
|
602
|
+
prefix : z.string().optional().default('field').label('Field name prefix'),
|
|
603
|
+
generated: z.looseObject({}).label('Generated').dynamicProps({
|
|
604
|
+
dependsOn: ['count', 'withFlags', 'prefix'],
|
|
605
|
+
// Only the params named in `dependsOn` arrive, coerced by their own schemas
|
|
606
|
+
execute : ({ criteria }) => {
|
|
607
|
+
const { count, withFlags, prefix } = criteria
|
|
608
|
+
const types = `count: ${ typeof count }, withFlags: ${ typeof withFlags }`
|
|
609
|
+
const shape = {}
|
|
610
|
+
|
|
611
|
+
for (let index = 1; index <= count; index++) {
|
|
612
|
+
shape[`${ prefix }_${ index }`] = z.string().optional().label(`${ prefix } ${ index } (${ types })`)
|
|
613
|
+
|
|
614
|
+
if (withFlags) {
|
|
615
|
+
shape[`${ prefix }_${ index }_on`] = z.boolean().optional().label(`${ prefix } ${ index } enabled`)
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return shape
|
|
620
|
+
},
|
|
621
|
+
}),
|
|
622
|
+
}),
|
|
623
|
+
result : { params: {} },
|
|
624
|
+
execute : ({ params }) => ({ params }),
|
|
483
625
|
})
|
|
484
626
|
|
|
485
|
-
//
|
|
627
|
+
// One def, two params: the runner generates a loader per use, so each param loads on its own.
|
|
628
|
+
const addressFields = {
|
|
629
|
+
dependsOn: ['country'],
|
|
630
|
+
execute : ({ criteria }) => criteria.country === 'US'
|
|
631
|
+
? {
|
|
632
|
+
street: z.string().label('Street'),
|
|
633
|
+
state : z.enum(['CA', 'NY', 'TX']).label('State'),
|
|
634
|
+
zip : z.string().regex(/^\d{5}$/, 'Five digits').label('ZIP (5 digits)'),
|
|
635
|
+
}
|
|
636
|
+
: {
|
|
637
|
+
street : z.string().label('Street'),
|
|
638
|
+
county : z.string().optional().label('County'),
|
|
639
|
+
postcode: z.string().label('Postcode'),
|
|
640
|
+
},
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
ext.addAction({
|
|
644
|
+
category : '3. Dynamic Fields',
|
|
645
|
+
id : 'dynamicPropsSharedDefinition',
|
|
646
|
+
label : 'Dynamic Props — One Definition, Two Params',
|
|
647
|
+
description: 'Billing and Shipping share one definition. Switch the country: both reload; "Street" keeps its value.',
|
|
648
|
+
params : z.object({
|
|
649
|
+
country : z.enum(['US', 'UK']).labels({ US: 'United States', UK: 'United Kingdom' }).default('US').label('Country'),
|
|
650
|
+
billing : z.looseObject({}).label('Billing Address').dynamicProps(addressFields),
|
|
651
|
+
shipping: z.looseObject({}).optional().label('Shipping Address').dynamicProps(addressFields),
|
|
652
|
+
}),
|
|
653
|
+
result : { params: {} },
|
|
654
|
+
execute : ({ params }) => ({ params }),
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
ext.addAction({
|
|
658
|
+
category : '3. Dynamic Fields',
|
|
659
|
+
id : 'dynamicPropsLoaderStates',
|
|
660
|
+
label : 'Dynamic Props — Loader States',
|
|
661
|
+
description: 'Pick how the loader behaves: slow, failing, invalid, empty, or repeating a declared key.',
|
|
662
|
+
params : z.object({
|
|
663
|
+
behaviour : z.enum(['ok', 'slow', 'fail', 'invalid', 'empty', 'repeatsDeclared'])
|
|
664
|
+
.labels({
|
|
665
|
+
ok : 'Loads two fields',
|
|
666
|
+
slow : 'Takes 3 seconds',
|
|
667
|
+
fail : 'Throws',
|
|
668
|
+
invalid : 'Returns something that is not a schema',
|
|
669
|
+
empty : 'Returns no fields',
|
|
670
|
+
repeatsDeclared: 'Returns a field the param already declares',
|
|
671
|
+
})
|
|
672
|
+
.default('ok')
|
|
673
|
+
.label('Loader Behaviour'),
|
|
674
|
+
loadedInto: z.looseObject({ declared: z.string().optional().label('Declared Field') })
|
|
675
|
+
.optional()
|
|
676
|
+
.label('Loaded Into')
|
|
677
|
+
.dynamicProps({
|
|
678
|
+
dependsOn: ['behaviour'],
|
|
679
|
+
execute : async ({ criteria }) => {
|
|
680
|
+
const loaded = { first: z.string().optional().label('First'), second: z.number().optional().label('Second') }
|
|
681
|
+
|
|
682
|
+
switch (criteria.behaviour) {
|
|
683
|
+
case 'slow':
|
|
684
|
+
await new Promise(resolve => setTimeout(resolve, 3000))
|
|
685
|
+
|
|
686
|
+
return loaded
|
|
687
|
+
|
|
688
|
+
case 'fail':
|
|
689
|
+
throw new Error('QA: this loader fails on purpose')
|
|
690
|
+
|
|
691
|
+
case 'invalid':
|
|
692
|
+
return 'not a schema'
|
|
693
|
+
|
|
694
|
+
case 'empty':
|
|
695
|
+
return {}
|
|
696
|
+
|
|
697
|
+
case 'repeatsDeclared':
|
|
698
|
+
return { declared: z.string() }
|
|
699
|
+
|
|
700
|
+
default:
|
|
701
|
+
return loaded
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
}),
|
|
705
|
+
}),
|
|
706
|
+
result : { params: {} },
|
|
707
|
+
execute : ({ params }) => ({ params }),
|
|
708
|
+
})
|
|
709
|
+
|
|
710
|
+
ext.addAction({
|
|
711
|
+
category : '3. Dynamic Fields',
|
|
712
|
+
id : 'dynamicParamsPerChild',
|
|
713
|
+
label : 'Dynamic Params — One Field Per Child',
|
|
714
|
+
description : 'Picking a parent adds one top-level field per child. Change the parent and watch them change.',
|
|
715
|
+
params : z.object({
|
|
716
|
+
parentId: z.string().label('Parent').dictionary(getParentsDictionary),
|
|
717
|
+
}),
|
|
718
|
+
dynamicParams: {
|
|
719
|
+
dependsOn: ['parentId'],
|
|
720
|
+
execute : ({ criteria }) => {
|
|
721
|
+
const shape = {}
|
|
722
|
+
|
|
723
|
+
for (const child of CHILDREN[criteria.parentId] || []) {
|
|
724
|
+
shape[`field_${ child.id }`] = z.string().optional().label(`Field for ${ child.name }`)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
return shape
|
|
728
|
+
},
|
|
729
|
+
},
|
|
730
|
+
result : { params: {} },
|
|
731
|
+
// Loaded fields ride through because the action declares dynamicParams — compare with "Unknown Fields Are
|
|
732
|
+
// Stripped" in 2. Params.
|
|
733
|
+
execute : ({ params }) => ({ params, keys: Object.keys(params) }),
|
|
734
|
+
})
|
|
735
|
+
|
|
736
|
+
ext.addAction({
|
|
737
|
+
category : '3. Dynamic Fields',
|
|
738
|
+
id : 'dynamicParamsEveryType',
|
|
739
|
+
label : 'Dynamic Params — Every Field Type',
|
|
740
|
+
description : 'Pick a record type: its fields are added as top-level params, dropdowns and nested object included.',
|
|
741
|
+
params : z.object({
|
|
742
|
+
recordType: z.string().label('Record Type').dictionary(getRecordTypesDictionary),
|
|
743
|
+
}),
|
|
744
|
+
dynamicParams: {
|
|
745
|
+
dependsOn: ['recordType'],
|
|
746
|
+
execute : ({ criteria }) => ({
|
|
747
|
+
...recordFields(criteria.recordType),
|
|
748
|
+
owner: z.string().optional().label('Owner (dropdown)').dictionary(getPagedDictionary),
|
|
749
|
+
}),
|
|
750
|
+
},
|
|
751
|
+
result : { params: {} },
|
|
752
|
+
execute : ({ params }) => ({ params, types: typesOf(params) }),
|
|
753
|
+
})
|
|
754
|
+
|
|
755
|
+
ext.addAction({
|
|
756
|
+
category : '3. Dynamic Fields',
|
|
757
|
+
id : 'dynamicParamsAndProps',
|
|
758
|
+
label : 'Dynamic Params And Props Together',
|
|
759
|
+
description : 'The record type adds top-level params; the parent loads fields into "Child Fields". Both at once.',
|
|
760
|
+
params : z.object({
|
|
761
|
+
recordType : z.string().label('Record Type').dictionary(getRecordTypesDictionary),
|
|
762
|
+
parentId : z.string().optional().label('Parent').dictionary(getParentsDictionary),
|
|
763
|
+
childFields: z.looseObject({}).optional().label('Child Fields').dynamicProps({
|
|
764
|
+
dependsOn: ['parentId'],
|
|
765
|
+
execute : ({ criteria }) => Object.fromEntries((CHILDREN[criteria.parentId] || [])
|
|
766
|
+
.map(child => [`field_${ child.id }`, z.string().optional().label(`Field for ${ child.name }`)])),
|
|
767
|
+
}),
|
|
768
|
+
}),
|
|
769
|
+
dynamicParams: {
|
|
770
|
+
dependsOn: ['recordType'],
|
|
771
|
+
execute : ({ criteria }) => recordFields(criteria.recordType),
|
|
772
|
+
},
|
|
773
|
+
result : { params: {} },
|
|
774
|
+
execute : ({ params }) => ({ params }),
|
|
775
|
+
})
|
|
776
|
+
|
|
777
|
+
// The JS type each value of an object arrived as — a Date is reported as one, not as "object".
|
|
778
|
+
function typesOf(values = {}) {
|
|
779
|
+
return Object.fromEntries(Object.entries(values).map(([key, value]) => [
|
|
780
|
+
key,
|
|
781
|
+
value instanceof Date ? 'Date' : Array.isArray(value) ? 'array' : value === null ? 'null' : typeof value,
|
|
782
|
+
]))
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// ─── 4. Results ──────────────────────────────────────────────────────────────
|
|
486
786
|
// One action per `result` FORM, because each publishes a different return type or sample source — that is
|
|
487
787
|
// what downstream blocks bind their fields to.
|
|
488
788
|
|
|
489
789
|
ext.addAction({
|
|
490
|
-
category : '
|
|
790
|
+
category : '4. Results',
|
|
491
791
|
id : 'returnsObject',
|
|
492
792
|
label : 'Returns — Object',
|
|
493
793
|
description: 'Literal object sample. Published return type: OBJECT.',
|
|
@@ -496,7 +796,7 @@ ext.addAction({
|
|
|
496
796
|
})
|
|
497
797
|
|
|
498
798
|
ext.addAction({
|
|
499
|
-
category : '
|
|
799
|
+
category : '4. Results',
|
|
500
800
|
id : 'returnsList',
|
|
501
801
|
label : 'Returns — List',
|
|
502
802
|
description: 'Literal list sample. Set the size to check large payloads. Published return type: LIST.',
|
|
@@ -508,7 +808,7 @@ ext.addAction({
|
|
|
508
808
|
})
|
|
509
809
|
|
|
510
810
|
ext.addAction({
|
|
511
|
-
category : '
|
|
811
|
+
category : '4. Results',
|
|
512
812
|
id : 'returnsNothing',
|
|
513
813
|
label : 'Returns — Nothing',
|
|
514
814
|
description: 'No `result` declared and nothing returned. Published return type: VOID.',
|
|
@@ -516,7 +816,7 @@ ext.addAction({
|
|
|
516
816
|
})
|
|
517
817
|
|
|
518
818
|
ext.addAction({
|
|
519
|
-
category : '
|
|
819
|
+
category : '4. Results',
|
|
520
820
|
id : 'returnsSampleFromSchema',
|
|
521
821
|
label : 'Returns — Sample From A Schema',
|
|
522
822
|
description: 'The sample comes from .example() on the result schema rather than a literal.',
|
|
@@ -528,7 +828,7 @@ ext.addAction({
|
|
|
528
828
|
})
|
|
529
829
|
|
|
530
830
|
ext.addAction({
|
|
531
|
-
category : '
|
|
831
|
+
category : '4. Results',
|
|
532
832
|
id : 'returnsSampleFromLoader',
|
|
533
833
|
label : 'Returns — Sample Computed From Params',
|
|
534
834
|
description: 'The sample is computed from the params — toggle "Detailed" and watch the shape change.',
|
|
@@ -541,10 +841,10 @@ ext.addAction({
|
|
|
541
841
|
execute : ({ params }) => (params.detailed ? { id: 'x', detail: { extra: true, nested: [1, 2, 3] } } : { id: 'x' }),
|
|
542
842
|
})
|
|
543
843
|
|
|
544
|
-
// ───
|
|
844
|
+
// ─── 5. Runtime ──────────────────────────────────────────────────────────────
|
|
545
845
|
|
|
546
846
|
ext.addAction({
|
|
547
|
-
category : '
|
|
847
|
+
category : '5. Runtime',
|
|
548
848
|
id : 'callHelpers',
|
|
549
849
|
label : 'Call Helpers',
|
|
550
850
|
description: 'Invokes each helper declared on the extension and returns what came back.',
|
|
@@ -559,7 +859,7 @@ ext.addAction({
|
|
|
559
859
|
})
|
|
560
860
|
|
|
561
861
|
ext.addAction({
|
|
562
|
-
category : '
|
|
862
|
+
category : '5. Runtime',
|
|
563
863
|
id : 'emitLogs',
|
|
564
864
|
label : 'Emit Logs',
|
|
565
865
|
description: 'Writes one line at each level. Check they reach the runtime logs.',
|
|
@@ -578,7 +878,7 @@ ext.addAction({
|
|
|
578
878
|
})
|
|
579
879
|
|
|
580
880
|
ext.addAction({
|
|
581
|
-
category : '
|
|
881
|
+
category : '5. Runtime',
|
|
582
882
|
id : 'throwError',
|
|
583
883
|
label : 'Throw An Error',
|
|
584
884
|
description: 'Fails on purpose. Check the message reaches the console and the flow.',
|
|
@@ -592,7 +892,7 @@ ext.addAction({
|
|
|
592
892
|
})
|
|
593
893
|
|
|
594
894
|
ext.addAction({
|
|
595
|
-
category : '
|
|
895
|
+
category : '5. Runtime',
|
|
596
896
|
id : 'runLongerThanATimeout',
|
|
597
897
|
label : 'Run Longer Than A Timeout',
|
|
598
898
|
description: 'Sleeps, then returns. Platform policy is no timeout on service code — verify a long run survives.',
|
|
@@ -609,7 +909,7 @@ ext.addAction({
|
|
|
609
909
|
})
|
|
610
910
|
|
|
611
911
|
ext.addAction({
|
|
612
|
-
category : '
|
|
912
|
+
category : '5. Runtime',
|
|
613
913
|
id : 'readOauthWithoutDeclaringIt',
|
|
614
914
|
label : 'Read OAuth Without Declaring It',
|
|
615
915
|
description: 'This service declares no OAuth, so reading ctx.oauth should fail loudly rather than return null.',
|
|
@@ -617,10 +917,10 @@ ext.addAction({
|
|
|
617
917
|
execute : ({ oauth }) => ({ accessToken: oauth.accessToken }),
|
|
618
918
|
})
|
|
619
919
|
|
|
620
|
-
// ───
|
|
920
|
+
// ─── 6. HTTP ─────────────────────────────────────────────────────────────────
|
|
621
921
|
|
|
622
922
|
ext.addAction({
|
|
623
|
-
category : '
|
|
923
|
+
category : '6. HTTP',
|
|
624
924
|
id : 'callHttpEndpoint',
|
|
625
925
|
label : 'Call An HTTP Endpoint',
|
|
626
926
|
description: 'Runs the shared apiRequest helper against a URL you supply. Try https://httpbin.org/get.',
|
|
@@ -659,12 +959,12 @@ ext.addAction({
|
|
|
659
959
|
},
|
|
660
960
|
})
|
|
661
961
|
|
|
662
|
-
// ───
|
|
962
|
+
// ─── 7. Files ────────────────────────────────────────────────────────────────
|
|
663
963
|
|
|
664
964
|
const SCOPES = ['FLOW', 'EXECUTION', 'WORKSPACE']
|
|
665
965
|
|
|
666
966
|
ext.addAction({
|
|
667
|
-
category : '
|
|
967
|
+
category : '7. Files',
|
|
668
968
|
id : 'filesRoundTrip',
|
|
669
969
|
label : 'Files — Upload, Read, List, Delete',
|
|
670
970
|
description: 'The whole FilesApi surface in one call. The quickest end-to-end check of file storage.',
|
|
@@ -693,7 +993,7 @@ ext.addAction({
|
|
|
693
993
|
})
|
|
694
994
|
|
|
695
995
|
ext.addAction({
|
|
696
|
-
category : '
|
|
996
|
+
category : '7. Files',
|
|
697
997
|
id : 'filesUsage',
|
|
698
998
|
label : 'Files — Storage Usage',
|
|
699
999
|
description: 'Workspace storage usage and quota. Run it either side of a round trip.',
|
|
@@ -701,7 +1001,7 @@ ext.addAction({
|
|
|
701
1001
|
execute : ({ files }) => files.usage(),
|
|
702
1002
|
})
|
|
703
1003
|
|
|
704
|
-
// ───
|
|
1004
|
+
// ─── 8. Polling triggers ─────────────────────────────────────────────────────
|
|
705
1005
|
// All three mechanisms, fed by a synthetic source so they fire without a real API. `emitPerPoll` controls
|
|
706
1006
|
// how many brand-new items each poll invents — set it to 0 to prove a quiet poll emits nothing.
|
|
707
1007
|
|
|
@@ -735,7 +1035,7 @@ const emitPerPoll = () => z.object({
|
|
|
735
1035
|
})
|
|
736
1036
|
|
|
737
1037
|
ext.addPollingTrigger({
|
|
738
|
-
category : '
|
|
1038
|
+
category : '8. Triggers',
|
|
739
1039
|
id : 'onNewItemByDedupe',
|
|
740
1040
|
label : 'On New Item — by id (dedupe)',
|
|
741
1041
|
description: 'Emits ids it has not seen before. Polling interval can be customized (minimum 30 seconds).',
|
|
@@ -746,7 +1046,7 @@ ext.addPollingTrigger({
|
|
|
746
1046
|
})
|
|
747
1047
|
|
|
748
1048
|
ext.addPollingTrigger({
|
|
749
|
-
category : '
|
|
1049
|
+
category : '8. Triggers',
|
|
750
1050
|
id : 'onNewItemByWatermark',
|
|
751
1051
|
label : 'On New Item — by timestamp (watermark)',
|
|
752
1052
|
description: 'Emits items newer than the stored marker. Polling interval can be customized (minimum 30 seconds).',
|
|
@@ -757,7 +1057,7 @@ ext.addPollingTrigger({
|
|
|
757
1057
|
})
|
|
758
1058
|
|
|
759
1059
|
ext.addPollingTrigger({
|
|
760
|
-
category : '
|
|
1060
|
+
category : '8. Triggers',
|
|
761
1061
|
id : 'onNewItemByOwnState',
|
|
762
1062
|
label : 'On New Item — managing its own state (poll)',
|
|
763
1063
|
description: 'Owns its own state and returns it, so you can watch it advance. '
|