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