@relayflows/surface 2.0.9 → 2.0.10
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 +3 -2
- package/dist/completion.d.ts +2 -0
- package/dist/completion.d.ts.map +1 -1
- package/dist/context.d.ts +27 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/effect-transport.d.ts +22 -0
- package/dist/effect-transport.d.ts.map +1 -0
- package/dist/effect-transport.js +42 -0
- package/dist/effect-transport.js.map +1 -0
- package/dist/flow.d.ts +30 -17
- package/dist/flow.d.ts.map +1 -1
- package/dist/flow.js +58 -73
- package/dist/flow.js.map +1 -1
- package/dist/helper-clients.d.ts +86 -0
- package/dist/helper-clients.d.ts.map +1 -0
- package/dist/helper-clients.js +30 -0
- package/dist/helper-clients.js.map +1 -0
- package/dist/helpers/airtable.d.ts +4 -0
- package/dist/helpers/airtable.d.ts.map +1 -0
- package/dist/helpers/airtable.js +5 -0
- package/dist/helpers/airtable.js.map +1 -0
- package/dist/helpers/asana.d.ts +5 -0
- package/dist/helpers/asana.d.ts.map +1 -0
- package/dist/helpers/asana.js +6 -0
- package/dist/helpers/asana.js.map +1 -0
- package/dist/helpers/azure-blob.d.ts +5 -0
- package/dist/helpers/azure-blob.d.ts.map +1 -0
- package/dist/helpers/azure-blob.js +6 -0
- package/dist/helpers/azure-blob.js.map +1 -0
- package/dist/helpers/box.d.ts +5 -0
- package/dist/helpers/box.d.ts.map +1 -0
- package/dist/helpers/box.js +6 -0
- package/dist/helpers/box.js.map +1 -0
- package/dist/helpers/calendly.d.ts +5 -0
- package/dist/helpers/calendly.d.ts.map +1 -0
- package/dist/helpers/calendly.js +6 -0
- package/dist/helpers/calendly.js.map +1 -0
- package/dist/helpers/clickup.d.ts +5 -0
- package/dist/helpers/clickup.d.ts.map +1 -0
- package/dist/helpers/clickup.js +6 -0
- package/dist/helpers/clickup.js.map +1 -0
- package/dist/helpers/clients.d.ts +3 -0
- package/dist/helpers/clients.d.ts.map +1 -0
- package/dist/helpers/clients.js +46 -0
- package/dist/helpers/clients.js.map +1 -0
- package/dist/helpers/cloudflare.d.ts +5 -0
- package/dist/helpers/cloudflare.d.ts.map +1 -0
- package/dist/helpers/cloudflare.js +6 -0
- package/dist/helpers/cloudflare.js.map +1 -0
- package/dist/helpers/confluence.d.ts +5 -0
- package/dist/helpers/confluence.d.ts.map +1 -0
- package/dist/helpers/confluence.js +6 -0
- package/dist/helpers/confluence.js.map +1 -0
- package/dist/helpers/daytona.d.ts +5 -0
- package/dist/helpers/daytona.d.ts.map +1 -0
- package/dist/helpers/daytona.js +6 -0
- package/dist/helpers/daytona.js.map +1 -0
- package/dist/helpers/docker-hub.d.ts +4 -0
- package/dist/helpers/docker-hub.d.ts.map +1 -0
- package/dist/helpers/docker-hub.js +5 -0
- package/dist/helpers/docker-hub.js.map +1 -0
- package/dist/helpers/dropbox.d.ts +5 -0
- package/dist/helpers/dropbox.d.ts.map +1 -0
- package/dist/helpers/dropbox.js +6 -0
- package/dist/helpers/dropbox.js.map +1 -0
- package/dist/helpers/fathom.d.ts +4 -0
- package/dist/helpers/fathom.d.ts.map +1 -0
- package/dist/helpers/fathom.js +5 -0
- package/dist/helpers/fathom.js.map +1 -0
- package/dist/helpers/gcp.d.ts +4 -0
- package/dist/helpers/gcp.d.ts.map +1 -0
- package/dist/helpers/gcp.js +5 -0
- package/dist/helpers/gcp.js.map +1 -0
- package/dist/helpers/gcs.d.ts +5 -0
- package/dist/helpers/gcs.d.ts.map +1 -0
- package/dist/helpers/gcs.js +6 -0
- package/dist/helpers/gcs.js.map +1 -0
- package/dist/helpers/github.d.ts +5 -0
- package/dist/helpers/github.d.ts.map +1 -0
- package/dist/helpers/github.js +6 -0
- package/dist/helpers/github.js.map +1 -0
- package/dist/helpers/gitlab.d.ts +5 -0
- package/dist/helpers/gitlab.d.ts.map +1 -0
- package/dist/helpers/gitlab.js +6 -0
- package/dist/helpers/gitlab.js.map +1 -0
- package/dist/helpers/gmail.d.ts +5 -0
- package/dist/helpers/gmail.d.ts.map +1 -0
- package/dist/helpers/gmail.js +6 -0
- package/dist/helpers/gmail.js.map +1 -0
- package/dist/helpers/google-calendar.d.ts +5 -0
- package/dist/helpers/google-calendar.d.ts.map +1 -0
- package/dist/helpers/google-calendar.js +6 -0
- package/dist/helpers/google-calendar.js.map +1 -0
- package/dist/helpers/google-drive.d.ts +5 -0
- package/dist/helpers/google-drive.d.ts.map +1 -0
- package/dist/helpers/google-drive.js +6 -0
- package/dist/helpers/google-drive.js.map +1 -0
- package/dist/helpers/granola.d.ts +5 -0
- package/dist/helpers/granola.d.ts.map +1 -0
- package/dist/helpers/granola.js +6 -0
- package/dist/helpers/granola.js.map +1 -0
- package/dist/helpers/hubspot.d.ts +5 -0
- package/dist/helpers/hubspot.d.ts.map +1 -0
- package/dist/helpers/hubspot.js +6 -0
- package/dist/helpers/hubspot.js.map +1 -0
- package/dist/helpers/index.d.ts +155 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +105 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/intercom.d.ts +5 -0
- package/dist/helpers/intercom.d.ts.map +1 -0
- package/dist/helpers/intercom.js +6 -0
- package/dist/helpers/intercom.js.map +1 -0
- package/dist/helpers/jira.d.ts +5 -0
- package/dist/helpers/jira.d.ts.map +1 -0
- package/dist/helpers/jira.js +6 -0
- package/dist/helpers/jira.js.map +1 -0
- package/dist/helpers/linear.d.ts +5 -0
- package/dist/helpers/linear.d.ts.map +1 -0
- package/dist/helpers/linear.js +6 -0
- package/dist/helpers/linear.js.map +1 -0
- package/dist/helpers/mailgun.d.ts +5 -0
- package/dist/helpers/mailgun.d.ts.map +1 -0
- package/dist/helpers/mailgun.js +6 -0
- package/dist/helpers/mailgun.js.map +1 -0
- package/dist/helpers/mixpanel.d.ts +5 -0
- package/dist/helpers/mixpanel.d.ts.map +1 -0
- package/dist/helpers/mixpanel.js +6 -0
- package/dist/helpers/mixpanel.js.map +1 -0
- package/dist/helpers/neon.d.ts +4 -0
- package/dist/helpers/neon.d.ts.map +1 -0
- package/dist/helpers/neon.js +5 -0
- package/dist/helpers/neon.js.map +1 -0
- package/dist/helpers/notion.d.ts +5 -0
- package/dist/helpers/notion.d.ts.map +1 -0
- package/dist/helpers/notion.js +6 -0
- package/dist/helpers/notion.js.map +1 -0
- package/dist/helpers/onedrive.d.ts +5 -0
- package/dist/helpers/onedrive.d.ts.map +1 -0
- package/dist/helpers/onedrive.js +6 -0
- package/dist/helpers/onedrive.js.map +1 -0
- package/dist/helpers/pipedrive.d.ts +5 -0
- package/dist/helpers/pipedrive.d.ts.map +1 -0
- package/dist/helpers/pipedrive.js +6 -0
- package/dist/helpers/pipedrive.js.map +1 -0
- package/dist/helpers/postgres.d.ts +5 -0
- package/dist/helpers/postgres.d.ts.map +1 -0
- package/dist/helpers/postgres.js +6 -0
- package/dist/helpers/postgres.js.map +1 -0
- package/dist/helpers/posthog.d.ts +4 -0
- package/dist/helpers/posthog.d.ts.map +1 -0
- package/dist/helpers/posthog.js +5 -0
- package/dist/helpers/posthog.js.map +1 -0
- package/dist/helpers/providers.d.ts +252 -0
- package/dist/helpers/providers.d.ts.map +1 -0
- package/dist/helpers/providers.js +305 -0
- package/dist/helpers/providers.js.map +1 -0
- package/dist/helpers/ramp.d.ts +7 -0
- package/dist/helpers/ramp.d.ts.map +1 -0
- package/dist/helpers/ramp.js +7 -0
- package/dist/helpers/ramp.js.map +1 -0
- package/dist/helpers/recall.d.ts +5 -0
- package/dist/helpers/recall.d.ts.map +1 -0
- package/dist/helpers/recall.js +6 -0
- package/dist/helpers/recall.js.map +1 -0
- package/dist/helpers/reddit.d.ts +5 -0
- package/dist/helpers/reddit.d.ts.map +1 -0
- package/dist/helpers/reddit.js +6 -0
- package/dist/helpers/reddit.js.map +1 -0
- package/dist/helpers/redis.d.ts +5 -0
- package/dist/helpers/redis.d.ts.map +1 -0
- package/dist/helpers/redis.js +6 -0
- package/dist/helpers/redis.js.map +1 -0
- package/dist/helpers/s3.d.ts +5 -0
- package/dist/helpers/s3.d.ts.map +1 -0
- package/dist/helpers/s3.js +6 -0
- package/dist/helpers/s3.js.map +1 -0
- package/dist/helpers/salesforce.d.ts +5 -0
- package/dist/helpers/salesforce.d.ts.map +1 -0
- package/dist/helpers/salesforce.js +6 -0
- package/dist/helpers/salesforce.js.map +1 -0
- package/dist/helpers/segment.d.ts +4 -0
- package/dist/helpers/segment.d.ts.map +1 -0
- package/dist/helpers/segment.js +5 -0
- package/dist/helpers/segment.js.map +1 -0
- package/dist/helpers/sendgrid.d.ts +5 -0
- package/dist/helpers/sendgrid.d.ts.map +1 -0
- package/dist/helpers/sendgrid.js +6 -0
- package/dist/helpers/sendgrid.js.map +1 -0
- package/dist/helpers/sharepoint.d.ts +5 -0
- package/dist/helpers/sharepoint.d.ts.map +1 -0
- package/dist/helpers/sharepoint.js +6 -0
- package/dist/helpers/sharepoint.js.map +1 -0
- package/dist/helpers/shopify.d.ts +4 -0
- package/dist/helpers/shopify.d.ts.map +1 -0
- package/dist/helpers/shopify.js +5 -0
- package/dist/helpers/shopify.js.map +1 -0
- package/dist/helpers/shortcut.d.ts +5 -0
- package/dist/helpers/shortcut.d.ts.map +1 -0
- package/dist/helpers/shortcut.js +6 -0
- package/dist/helpers/shortcut.js.map +1 -0
- package/dist/helpers/slack.d.ts +17 -0
- package/dist/helpers/slack.d.ts.map +1 -0
- package/dist/helpers/slack.js +4 -0
- package/dist/helpers/slack.js.map +1 -0
- package/dist/helpers/stripe.d.ts +5 -0
- package/dist/helpers/stripe.d.ts.map +1 -0
- package/dist/helpers/stripe.js +6 -0
- package/dist/helpers/stripe.js.map +1 -0
- package/dist/helpers/teams.d.ts +5 -0
- package/dist/helpers/teams.d.ts.map +1 -0
- package/dist/helpers/teams.js +6 -0
- package/dist/helpers/teams.js.map +1 -0
- package/dist/helpers/telegram.d.ts +5 -0
- package/dist/helpers/telegram.d.ts.map +1 -0
- package/dist/helpers/telegram.js +6 -0
- package/dist/helpers/telegram.js.map +1 -0
- package/dist/helpers/webhook-server.d.ts +4 -0
- package/dist/helpers/webhook-server.d.ts.map +1 -0
- package/dist/helpers/webhook-server.js +5 -0
- package/dist/helpers/webhook-server.js.map +1 -0
- package/dist/helpers/x.d.ts +4 -0
- package/dist/helpers/x.d.ts.map +1 -0
- package/dist/helpers/x.js +5 -0
- package/dist/helpers/x.js.map +1 -0
- package/dist/helpers/zendesk.d.ts +5 -0
- package/dist/helpers/zendesk.d.ts.map +1 -0
- package/dist/helpers/zendesk.js +6 -0
- package/dist/helpers/zendesk.js.map +1 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +19 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +2 -0
- package/dist/memory.js.map +1 -0
- package/dist/plugin-contract.d.ts +5 -0
- package/dist/plugin-contract.d.ts.map +1 -0
- package/dist/plugin-contract.js +2 -0
- package/dist/plugin-contract.js.map +1 -0
- package/dist/provider-trigger.d.ts +13 -0
- package/dist/provider-trigger.d.ts.map +1 -0
- package/dist/provider-trigger.js +18 -0
- package/dist/provider-trigger.js.map +1 -0
- package/dist/runtime.d.ts +6 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -1
- package/dist/slack.d.ts +34 -0
- package/dist/slack.d.ts.map +1 -0
- package/dist/slack.js +17 -0
- package/dist/slack.js.map +1 -0
- package/dist/step.d.ts +43 -1
- package/dist/step.d.ts.map +1 -1
- package/dist/triggers/github.d.ts +8 -0
- package/dist/triggers/github.d.ts.map +1 -0
- package/dist/triggers/github.js +17 -0
- package/dist/triggers/github.js.map +1 -0
- package/dist/triggers/index.d.ts +8 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +9 -0
- package/dist/triggers/index.js.map +1 -0
- package/dist/triggers/slack.d.ts +8 -0
- package/dist/triggers/slack.d.ts.map +1 -0
- package/dist/triggers/slack.js +17 -0
- package/dist/triggers/slack.js.map +1 -0
- package/dist/triggers.d.ts +15 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +43 -0
- package/dist/triggers.js.map +1 -0
- package/package.json +21 -2
- package/src/completion.ts +3 -0
- package/src/context.ts +26 -6
- package/src/effect-transport.ts +59 -0
- package/src/flow.ts +77 -106
- package/src/helper-clients.ts +30 -0
- package/src/helpers/README.md +42 -0
- package/src/helpers/airtable.ts +9 -0
- package/src/helpers/asana.ts +10 -0
- package/src/helpers/azure-blob.ts +10 -0
- package/src/helpers/box.ts +10 -0
- package/src/helpers/calendly.ts +10 -0
- package/src/helpers/clickup.ts +10 -0
- package/src/helpers/clients.ts +48 -0
- package/src/helpers/cloudflare.ts +10 -0
- package/src/helpers/confluence.ts +10 -0
- package/src/helpers/daytona.ts +10 -0
- package/src/helpers/docker-hub.ts +9 -0
- package/src/helpers/dropbox.ts +10 -0
- package/src/helpers/fathom.ts +9 -0
- package/src/helpers/gcp.ts +9 -0
- package/src/helpers/gcs.ts +10 -0
- package/src/helpers/github.ts +10 -0
- package/src/helpers/gitlab.ts +10 -0
- package/src/helpers/gmail.ts +10 -0
- package/src/helpers/google-calendar.ts +10 -0
- package/src/helpers/google-drive.ts +10 -0
- package/src/helpers/granola.ts +10 -0
- package/src/helpers/hubspot.ts +10 -0
- package/src/helpers/index.ts +212 -0
- package/src/helpers/intercom.ts +10 -0
- package/src/helpers/jira.ts +10 -0
- package/src/helpers/linear.ts +10 -0
- package/src/helpers/mailgun.ts +10 -0
- package/src/helpers/mixpanel.ts +10 -0
- package/src/helpers/neon.ts +9 -0
- package/src/helpers/notion.ts +10 -0
- package/src/helpers/onedrive.ts +10 -0
- package/src/helpers/pipedrive.ts +10 -0
- package/src/helpers/postgres.ts +10 -0
- package/src/helpers/posthog.ts +9 -0
- package/src/helpers/providers.ts +305 -0
- package/src/helpers/ramp.ts +12 -0
- package/src/helpers/recall.ts +10 -0
- package/src/helpers/reddit.ts +10 -0
- package/src/helpers/redis.ts +10 -0
- package/src/helpers/s3.ts +10 -0
- package/src/helpers/salesforce.ts +10 -0
- package/src/helpers/segment.ts +9 -0
- package/src/helpers/sendgrid.ts +10 -0
- package/src/helpers/sharepoint.ts +10 -0
- package/src/helpers/shopify.ts +9 -0
- package/src/helpers/shortcut.ts +10 -0
- package/src/helpers/slack.ts +16 -0
- package/src/helpers/stripe.ts +10 -0
- package/src/helpers/teams.ts +10 -0
- package/src/helpers/telegram.ts +10 -0
- package/src/helpers/webhook-server.ts +9 -0
- package/src/helpers/x.ts +9 -0
- package/src/helpers/zendesk.ts +10 -0
- package/src/index.ts +26 -3
- package/src/memory.ts +20 -0
- package/src/plugin-contract.ts +5 -0
- package/src/provider-trigger.ts +26 -0
- package/src/runtime.ts +8 -0
- package/src/slack.ts +47 -0
- package/src/step.ts +52 -1
- package/src/triggers/README.md +75 -0
- package/src/triggers/github.ts +19 -0
- package/src/triggers/index.ts +10 -0
- package/src/triggers/slack.ts +19 -0
- package/src/triggers.ts +49 -0
package/dist/step.d.ts
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
/** A journal-backed step result with its postfix verification gate. */
|
|
2
2
|
export interface Step<T> extends PromiseLike<T> {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Attach a named data gate to this step's `verification:` field. The gate is
|
|
5
|
+
* lowered by the SDK into a slice-P journal-honest check that survives
|
|
6
|
+
* replay — its shape is data, not code, so covenant 1 (journal-as-truth)
|
|
7
|
+
* holds. See `packages/sdk/src/named-gates.ts` for the enforcement.
|
|
8
|
+
*/
|
|
9
|
+
gate(config: NamedGate): Step<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Predicate gates cannot be journaled — the JavaScript closure would not
|
|
12
|
+
* survive replay — so the executor refuses this branch with
|
|
13
|
+
* `unsupported_gate`. Use a `NamedGate` config-object gate above, or the
|
|
14
|
+
* declarative `verification:` field on the compiled step spec, when you
|
|
15
|
+
* need journal-honest verification.
|
|
16
|
+
*/
|
|
4
17
|
gate(predicate: (value: T) => boolean, because?: string): Step<T>;
|
|
5
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Slice-P named data gates the authored surface can attach postfix via
|
|
21
|
+
* `.gate(config)`. The SDK's named-gate lowering enforces these exactly (see
|
|
22
|
+
* `packages/sdk/src/named-gates.ts`); the shapes here are the surface-visible
|
|
23
|
+
* subset kept in sync with `NamedDataGate` in the SDK spec.
|
|
24
|
+
*/
|
|
25
|
+
export type NamedGate = ReferencesInputNamedGate | SubprocessNamedGate | WordCountBoundsNamedGate | RegexMatchNamedGate;
|
|
26
|
+
export interface ReferencesInputNamedGate {
|
|
27
|
+
type: 'references_input';
|
|
28
|
+
input_key: string;
|
|
29
|
+
in_output_at?: Array<string | number>;
|
|
30
|
+
}
|
|
31
|
+
export interface SubprocessNamedGate {
|
|
32
|
+
type: 'subprocess_gate';
|
|
33
|
+
command: string;
|
|
34
|
+
from_output?: Array<string | number>;
|
|
35
|
+
}
|
|
36
|
+
export interface WordCountBoundsNamedGate {
|
|
37
|
+
type: 'word_count_bounds';
|
|
38
|
+
min?: number;
|
|
39
|
+
max?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface RegexMatchNamedGate {
|
|
42
|
+
type: 'regex_match';
|
|
43
|
+
pattern: string;
|
|
44
|
+
/** Only i, m, and s; evaluated by a non-backtracking RE2 engine. */
|
|
45
|
+
flags?: string;
|
|
46
|
+
in_output_at?: Array<string | number>;
|
|
47
|
+
}
|
|
6
48
|
//# sourceMappingURL=step.d.ts.map
|
package/dist/step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,WAAW,IAAI,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IAC7C,
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,WAAW,IAAI,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC;;;;;;OAMG;IACH,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACnE;AAED;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GACjB,wBAAwB,GACxB,mBAAmB,GACnB,wBAAwB,GACxB,mBAAmB,CAAC;AAExB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACvC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WebhookFilter } from "../triggers.js";
|
|
2
|
+
export declare const github: Readonly<{
|
|
3
|
+
issues(filter?: WebhookFilter): import("../provider-trigger.js").ProviderTriggerSource<"github", "issues">;
|
|
4
|
+
pull_request(action?: string): import("../provider-trigger.js").ProviderTriggerSource<"github", "pull_request">;
|
|
5
|
+
pull_request_review(filter?: WebhookFilter): import("../provider-trigger.js").ProviderTriggerSource<"github", "pull_request_review">;
|
|
6
|
+
push(filter?: WebhookFilter): import("../provider-trigger.js").ProviderTriggerSource<"github", "push">;
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/triggers/github.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,MAAM;oBACD,aAAa;0BAGP,MAAM;iCAGC,aAAa;kBAG5B,aAAa;EAG3B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// GENERATED by scripts/generate-triggers.mjs — do not edit.
|
|
2
|
+
import { providerTrigger, triggerArgument } from "../provider-trigger.js";
|
|
3
|
+
export const github = Object.freeze({
|
|
4
|
+
issues(filter) {
|
|
5
|
+
return providerTrigger("github", "issues", filter);
|
|
6
|
+
},
|
|
7
|
+
pull_request(action) {
|
|
8
|
+
return providerTrigger("github", "pull_request", action === undefined ? undefined : { action: triggerArgument(action, "action") });
|
|
9
|
+
},
|
|
10
|
+
pull_request_review(filter) {
|
|
11
|
+
return providerTrigger("github", "pull_request_review", filter);
|
|
12
|
+
},
|
|
13
|
+
push(filter) {
|
|
14
|
+
return providerTrigger("github", "push", filter);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/triggers/github.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG1E,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAClC,MAAM,CAAC,MAAsB;QAC3B,OAAO,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IACD,YAAY,CAAC,MAAe;QAC1B,OAAO,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrI,CAAC;IACD,mBAAmB,CAAC,MAAsB;QACxC,OAAO,eAAe,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,CAAC,MAAsB;QACzB,OAAO,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { github } from "./github.js";
|
|
2
|
+
export { slack } from "./slack.js";
|
|
3
|
+
/** Exact upstream event names, plus the generated Slack mention shorthand. */
|
|
4
|
+
export declare const providerEventTypes: Readonly<{
|
|
5
|
+
github: readonly ["issues", "pull_request", "pull_request_review", "push"];
|
|
6
|
+
slack: readonly ["app_mention", "message", "reaction_added"];
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/triggers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB;;;EAG7B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// GENERATED by scripts/generate-triggers.mjs — do not edit.
|
|
2
|
+
export { github } from "./github.js";
|
|
3
|
+
export { slack } from "./slack.js";
|
|
4
|
+
/** Exact upstream event names, plus the generated Slack mention shorthand. */
|
|
5
|
+
export const providerEventTypes = Object.freeze({
|
|
6
|
+
"github": Object.freeze(["issues", "pull_request", "pull_request_review", "push"]),
|
|
7
|
+
"slack": Object.freeze(["app_mention", "message", "reaction_added"]),
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/triggers/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAC,cAAc,EAAC,qBAAqB,EAAC,MAAM,CAAU,CAAC;IACxF,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,EAAC,SAAS,EAAC,gBAAgB,CAAU,CAAC;CAC5E,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WebhookFilter } from "../triggers.js";
|
|
2
|
+
export declare const slack: Readonly<{
|
|
3
|
+
message(filter?: WebhookFilter): import("../provider-trigger.js").ProviderTriggerSource<"slack", "message">;
|
|
4
|
+
reaction_added(filter?: WebhookFilter): import("../provider-trigger.js").ProviderTriggerSource<"slack", "reaction_added">;
|
|
5
|
+
mention(channel: string): import("../provider-trigger.js").ProviderTriggerSource<"slack", "app_mention">;
|
|
6
|
+
reaction(emoji: string): import("../provider-trigger.js").ProviderTriggerSource<"slack", "reaction_added">;
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=slack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../src/triggers/slack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,KAAK;qBACC,aAAa;4BAGN,aAAa;qBAGpB,MAAM;oBAGP,MAAM;EAGtB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// GENERATED by scripts/generate-triggers.mjs — do not edit.
|
|
2
|
+
import { providerTrigger, triggerArgument } from "../provider-trigger.js";
|
|
3
|
+
export const slack = Object.freeze({
|
|
4
|
+
message(filter) {
|
|
5
|
+
return providerTrigger("slack", "message", filter);
|
|
6
|
+
},
|
|
7
|
+
reaction_added(filter) {
|
|
8
|
+
return providerTrigger("slack", "reaction_added", filter);
|
|
9
|
+
},
|
|
10
|
+
mention(channel) {
|
|
11
|
+
return providerTrigger("slack", "app_mention", { channel: triggerArgument(channel, "channel") });
|
|
12
|
+
},
|
|
13
|
+
reaction(emoji) {
|
|
14
|
+
return providerTrigger("slack", "reaction_added", { reaction: triggerArgument(emoji, "emoji") });
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=slack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.js","sourceRoot":"","sources":["../../src/triggers/slack.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG1E,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,OAAO,CAAC,MAAsB;QAC5B,OAAO,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IACD,cAAc,CAAC,MAAsB;QACnC,OAAO,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,CAAC,OAAe;QACrB,OAAO,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACnG,CAAC;IACD,QAAQ,CAAC,KAAa;QACpB,OAAO,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACnG,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type WebhookValue = null | boolean | number | string | readonly WebhookValue[] | {
|
|
2
|
+
readonly [key: string]: WebhookValue;
|
|
3
|
+
};
|
|
4
|
+
/** Recursive object subset; array and scalar leaves match exactly. */
|
|
5
|
+
export type WebhookFilter = {
|
|
6
|
+
readonly [key: string]: WebhookValue;
|
|
7
|
+
};
|
|
8
|
+
export interface TriggerSource {
|
|
9
|
+
readonly kind: "webhook";
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly filter?: WebhookFilter;
|
|
12
|
+
}
|
|
13
|
+
/** Plain, immutable data. Constructing a source opens no receiver. */
|
|
14
|
+
export declare function webhook(name: string, filter?: WebhookFilter): TriggerSource;
|
|
15
|
+
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../src/triggers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GACvD,SAAS,YAAY,EAAE,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AAEvE,sEAAsE;AACtE,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;CACjC;AAED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa,CAS3E"}
|
package/dist/triggers.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Plain, immutable data. Constructing a source opens no receiver. */
|
|
2
|
+
export function webhook(name, filter) {
|
|
3
|
+
if (typeof name !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(name)) {
|
|
4
|
+
throw new TypeError("webhook name must be 1-128 letters, digits, underscores or hyphens, starting with a letter or digit");
|
|
5
|
+
}
|
|
6
|
+
if (filter === undefined)
|
|
7
|
+
return Object.freeze({ kind: "webhook", name });
|
|
8
|
+
if (filter === null || typeof filter !== "object" || Array.isArray(filter)) {
|
|
9
|
+
throw new TypeError("webhook filter must be a JSON object");
|
|
10
|
+
}
|
|
11
|
+
return Object.freeze({ kind: "webhook", name, filter: snapshot(filter) });
|
|
12
|
+
}
|
|
13
|
+
function snapshot(value, ancestors = new Set()) {
|
|
14
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
15
|
+
return value;
|
|
16
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
17
|
+
return value;
|
|
18
|
+
if (typeof value !== "object" || value === null || ancestors.has(value)) {
|
|
19
|
+
throw new TypeError("webhook filter must contain finite, acyclic JSON data");
|
|
20
|
+
}
|
|
21
|
+
const array = Array.isArray(value);
|
|
22
|
+
if (!array && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
|
|
23
|
+
throw new TypeError("webhook filter must contain plain JSON objects");
|
|
24
|
+
}
|
|
25
|
+
ancestors.add(value);
|
|
26
|
+
const entries = [];
|
|
27
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
28
|
+
if (array && key === "length")
|
|
29
|
+
continue;
|
|
30
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
31
|
+
if (typeof key !== "string" || !descriptor.enumerable || !("value" in descriptor)) {
|
|
32
|
+
throw new TypeError("webhook filter must contain JSON data properties");
|
|
33
|
+
}
|
|
34
|
+
if (array && !/^(0|[1-9][0-9]*)$/.test(key))
|
|
35
|
+
throw new TypeError("invalid JSON array property");
|
|
36
|
+
entries.push([key, snapshot(descriptor.value, ancestors)]);
|
|
37
|
+
}
|
|
38
|
+
ancestors.delete(value);
|
|
39
|
+
if (array && entries.length !== value.length)
|
|
40
|
+
throw new TypeError("webhook filter arrays must not be sparse");
|
|
41
|
+
return Object.freeze(array ? entries.map(([, item]) => item) : Object.fromEntries(entries));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=triggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.js","sourceRoot":"","sources":["../src/triggers.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relayflows/surface",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "TypeScript authoring surface for Relayflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,6 +15,16 @@
|
|
|
15
15
|
"types": "./dist/runtime.d.ts",
|
|
16
16
|
"import": "./dist/runtime.js",
|
|
17
17
|
"require": "./dist/runtime.js"
|
|
18
|
+
},
|
|
19
|
+
"./triggers": {
|
|
20
|
+
"types": "./dist/triggers/index.d.ts",
|
|
21
|
+
"import": "./dist/triggers/index.js",
|
|
22
|
+
"require": "./dist/triggers/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./triggers/*": {
|
|
25
|
+
"types": "./dist/triggers/*.d.ts",
|
|
26
|
+
"import": "./dist/triggers/*.js",
|
|
27
|
+
"require": "./dist/triggers/*.js"
|
|
18
28
|
}
|
|
19
29
|
},
|
|
20
30
|
"files": [
|
|
@@ -22,10 +32,12 @@
|
|
|
22
32
|
"src"
|
|
23
33
|
],
|
|
24
34
|
"scripts": {
|
|
35
|
+
"gen": "node ../../scripts/generate-helpers.mjs",
|
|
36
|
+
"gen:triggers": "node ../../scripts/generate-triggers.mjs",
|
|
25
37
|
"build": "tsc",
|
|
26
38
|
"prepare": "bun run build",
|
|
27
39
|
"typecheck": "tsc --noEmit",
|
|
28
|
-
"typecheck:regressions": "tsc -p ../../regressions/tsconfig.json",
|
|
40
|
+
"typecheck:regressions": "tsc -p ../../regressions/tsconfig.json && tsc -p tsconfig.test.json && node scripts/check-generated-helpers.mjs",
|
|
29
41
|
"typecheck:examples": "tsc -p ../../examples/tsconfig.json",
|
|
30
42
|
"test": "bun run build && tsc -p tsconfig.test.json && vitest run"
|
|
31
43
|
},
|
|
@@ -34,6 +46,7 @@
|
|
|
34
46
|
"node": ">=20.19.0 || >=22.12.0"
|
|
35
47
|
},
|
|
36
48
|
"devDependencies": {
|
|
49
|
+
"@types/node": "^22.20.2",
|
|
37
50
|
"typescript": "^5.6.0",
|
|
38
51
|
"vitest": "^2.1.0"
|
|
39
52
|
},
|
|
@@ -41,5 +54,11 @@
|
|
|
41
54
|
"type": "git",
|
|
42
55
|
"url": "git+https://github.com/AgentWorkforce/flows.git",
|
|
43
56
|
"directory": "packages/surface"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@relayfile/relay-helpers": "0.4.11"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"ai-hist": "0.4.1"
|
|
44
63
|
}
|
|
45
64
|
}
|
package/src/completion.ts
CHANGED
|
@@ -22,3 +22,6 @@ export const RUN_COMPLETION_REASONS = [
|
|
|
22
22
|
] as const;
|
|
23
23
|
|
|
24
24
|
export type RunCompletionReason = (typeof RUN_COMPLETION_REASONS)[number];
|
|
25
|
+
|
|
26
|
+
/** Authored outcomes include a human handoff; it is not a kernel terminal reason. */
|
|
27
|
+
export type FlowCompletionReason = RunCompletionReason | 'needs_human';
|
package/src/context.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Helpers } from "./helpers/index.js";
|
|
2
|
+
import type { MemoryHelper } from "./memory.js";
|
|
1
3
|
import type { CloudHelper } from "./cloud.js";
|
|
2
|
-
import type {
|
|
4
|
+
import type { FlowCompletionReason } from "./completion.js";
|
|
3
5
|
import type { Step } from "./step.js";
|
|
4
6
|
|
|
5
7
|
export interface AgentResult {
|
|
@@ -10,9 +12,22 @@ export interface AgentResult {
|
|
|
10
12
|
export interface AgentOptions {
|
|
11
13
|
task: string;
|
|
12
14
|
workspace?: string;
|
|
13
|
-
/** Overrides a named declaration's (or the flow/project default's) CLI for this step only. */
|
|
14
15
|
cli?: string;
|
|
15
|
-
|
|
16
|
+
model?: string;
|
|
17
|
+
/** Working directory for the CLI subprocess; defaults to the flow-runner's cwd. */
|
|
18
|
+
cwd?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Dispatch transport (flows#385). `'direct'` (default) spawns the CLI as a
|
|
21
|
+
* local subprocess. `'relay'` posts to agent-relay so the agent registers
|
|
22
|
+
* as a first-class workspace participant that DMs can steer.
|
|
23
|
+
*/
|
|
24
|
+
transport?: 'direct' | 'relay';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface LlmOptions {
|
|
28
|
+
/** JSON Schema checked before the result is accepted by the journal. */
|
|
29
|
+
output: Record<string, unknown>;
|
|
30
|
+
cli?: string;
|
|
16
31
|
model?: string;
|
|
17
32
|
}
|
|
18
33
|
|
|
@@ -22,12 +37,17 @@ export interface AgentOptions {
|
|
|
22
37
|
* This package declares the authoring contract only. It cannot construct a
|
|
23
38
|
* context or execute a step, so all effects remain behind the journal client.
|
|
24
39
|
*/
|
|
25
|
-
export interface Ctx {
|
|
26
|
-
|
|
40
|
+
export interface Ctx extends Helpers {
|
|
41
|
+
readonly mcp: Readonly<Record<string, Readonly<Record<string, (args: unknown) => Step<unknown>>>>>;
|
|
42
|
+
/** Command lease: milliseconds or a duration such as "5m"; default 30s, maximum 15m. */
|
|
43
|
+
run(command: string, options?: { timeout?: string | number }): Step<string>;
|
|
27
44
|
llm(strings: TemplateStringsArray, ...values: unknown[]): Step<string>;
|
|
45
|
+
/** JSON Schema validates the value at runtime; narrow unknown in author code. */
|
|
46
|
+
llm(prompt: string, options: LlmOptions): Step<unknown>;
|
|
28
47
|
agent(name: string, options: AgentOptions): Step<AgentResult>;
|
|
29
48
|
human(question: string, options: { to: string }): Promise<boolean>;
|
|
30
49
|
dispatch<T>(flow: string, input: unknown): Promise<T>;
|
|
31
|
-
done(reason:
|
|
50
|
+
done(reason: FlowCompletionReason): void;
|
|
32
51
|
cloud: CloudHelper;
|
|
52
|
+
memory: MemoryHelper;
|
|
33
53
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RelayClientOptions, RelayTransport } from '@relayfile/relay-helpers/transport';
|
|
2
|
+
import type { Step } from './step.js';
|
|
3
|
+
|
|
4
|
+
/** Promise-returning client verbs become lazy, journal-owned steps. */
|
|
5
|
+
export type JournalHelper<T> = {
|
|
6
|
+
[K in keyof T]: T[K] extends (...args: infer A) => Promise<infer R>
|
|
7
|
+
? (...args: A) => Step<R>
|
|
8
|
+
: T[K] extends (...args: infer A) => infer R ? (...args: A) => R
|
|
9
|
+
: T[K] extends object ? JournalHelper<T[K]> : T[K];
|
|
10
|
+
};
|
|
11
|
+
export interface HelperCall {
|
|
12
|
+
type: 'effect';
|
|
13
|
+
provider: string;
|
|
14
|
+
verb: string;
|
|
15
|
+
args: unknown[];
|
|
16
|
+
}
|
|
17
|
+
export type EffectDispatcher = <T>(call: HelperCall) => Step<T>;
|
|
18
|
+
export interface UnavailableHelper { readonly available: false }
|
|
19
|
+
export type HelperFactory = (options: RelayClientOptions) => object;
|
|
20
|
+
|
|
21
|
+
const unavailableTransport: RelayTransport = {
|
|
22
|
+
async read() { throw new Error('Helper I/O requires a journaled step'); },
|
|
23
|
+
async list() { throw new Error('Helper I/O requires a journaled step'); },
|
|
24
|
+
async write() { throw new Error('Helper I/O requires a journaled step'); },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function bindHelper<T extends object>(provider: string, factory: (options: RelayClientOptions) => T, dispatch: EffectDispatcher): JournalHelper<T>;
|
|
28
|
+
export function bindHelper(provider: string, factory: undefined, dispatch: EffectDispatcher): UnavailableHelper;
|
|
29
|
+
export function bindHelper(provider: string, factory: HelperFactory | undefined, dispatch: EffectDispatcher): object {
|
|
30
|
+
if (!factory) return Object.freeze({ available: false });
|
|
31
|
+
function wrap(client: object, prefix = ''): object {
|
|
32
|
+
return Object.fromEntries(Object.entries(client).map(([key, value]) => {
|
|
33
|
+
const verb = `${prefix}${key}`;
|
|
34
|
+
if (typeof value === 'function') return [key, key === 'path'
|
|
35
|
+
? value.bind(client)
|
|
36
|
+
: (...args: unknown[]) => {
|
|
37
|
+
while (args.length && args.at(-1) === undefined) args.pop();
|
|
38
|
+
return dispatch({ type: 'effect', provider, verb, args });
|
|
39
|
+
}];
|
|
40
|
+
return [key, value && typeof value === 'object' ? wrap(value, `${verb}.`) : value];
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
return wrap(factory({ transport: unavailableTransport }));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Resolve only own, generated client methods; never arbitrary prototype members. */
|
|
47
|
+
export async function invokeHelper(factory: HelperFactory, call: HelperCall, transport: RelayTransport): Promise<unknown> {
|
|
48
|
+
let target: unknown = factory({ transport });
|
|
49
|
+
const parts = call.verb.split('.');
|
|
50
|
+
for (const part of parts.slice(0, -1)) {
|
|
51
|
+
if (!target || typeof target !== 'object' || !Object.hasOwn(target, part)) throw new Error('Unknown helper resource');
|
|
52
|
+
target = (target as Record<string, unknown>)[part];
|
|
53
|
+
}
|
|
54
|
+
const verb = parts.at(-1)!;
|
|
55
|
+
if (!target || typeof target !== 'object' || !Object.hasOwn(target, verb) || verb === 'path') throw new Error('Unknown helper verb');
|
|
56
|
+
const method = (target as Record<string, unknown>)[verb];
|
|
57
|
+
if (typeof method !== 'function') throw new Error('Unknown helper verb');
|
|
58
|
+
return await method.apply(target, call.args) ?? null;
|
|
59
|
+
}
|