@flowrunner/cli 0.1.12 → 0.1.13
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/ai-docs/instructions/service-code-format/06-oauth2.md +20 -1
- package/ai-docs/instructions/service-code-format/09-realtime-triggers.md +104 -5
- package/ai-docs/instructions/service-code-format/13-runtime-contracts.md +6 -3
- package/dist/cli.js +116 -21
- package/dist/cli.js.map +2 -2
- package/dist/index.js +115 -20
- package/dist/index.js.map +2 -2
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/trigger-method.d.ts +12 -2
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +11 -2
- package/package.json +1 -1
- package/runtime/index.js +115 -20
- package/runtime/index.js.map +2 -2
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/trigger-method.d.ts +12 -2
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +11 -2
|
@@ -6,7 +6,7 @@ import type { SharedExtensionMethod } from '../model/model-types';
|
|
|
6
6
|
import { MethodParams } from '../params';
|
|
7
7
|
import { ResultSpec } from '../result';
|
|
8
8
|
import type { ProviderPayload } from '../types';
|
|
9
|
-
import type { RealtimeTriggerProps } from './types';
|
|
9
|
+
import type { RealtimeInstance, RealtimeTriggerProps } from './types';
|
|
10
10
|
export declare class RealtimeTriggerMethod extends ExtensionMethod implements LoaderOwner {
|
|
11
11
|
private readonly props;
|
|
12
12
|
readonly params: MethodParams;
|
|
@@ -21,6 +21,16 @@ export declare class RealtimeTriggerMethod extends ExtensionMethod implements Lo
|
|
|
21
21
|
providerEventNames(params?: Record<string, unknown>): string[];
|
|
22
22
|
claims(providerEventName: string): boolean;
|
|
23
23
|
extendEventData(requestBody: ProviderPayload, providerEventData: ProviderPayload): Record<string, unknown> | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Whether `extendMatchData` should run before these instances are matched. Only when something will READ its
|
|
26
|
+
* result — otherwise the API call is pure cost, paid on every event:
|
|
27
|
+
* - no instances, or no `match` → nothing to decide (with no `match` every instance fires);
|
|
28
|
+
* - declarative `match`, and no instance fills any of its params → every instance matches regardless,
|
|
29
|
+
* since an empty param means "any". This is the v1 rule: read the resource only when a flow filters.
|
|
30
|
+
* A predicate `match` is opaque, so the hook runs and receives the instances to make that call itself.
|
|
31
|
+
*/
|
|
32
|
+
needsMatchData(instances: RealtimeInstance[]): boolean;
|
|
33
|
+
extendMatchData(providerEventData: ProviderPayload, instances: RealtimeInstance[], ctx: ExecutionContext, webhookData?: ProviderPayload): Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
|
|
24
34
|
/**
|
|
25
35
|
* Whether one CONFIGURED INSTANCE of this trigger cares about an event. Declarative form: type-coerced
|
|
26
36
|
* equality per filled param, where an empty param means "any" — that is what lets a user leave a filter
|
|
@@ -30,7 +40,7 @@ export declare class RealtimeTriggerMethod extends ExtensionMethod implements Lo
|
|
|
30
40
|
* subscription registered (a tenant id, a resource the webhook was scoped to) has nowhere else to get it.
|
|
31
41
|
* Returning a new document is not a thing this seam can do; only subscribe/refresh/unsubscribe persist.
|
|
32
42
|
*/
|
|
33
|
-
matches(params: Record<string, unknown>, providerEventData: ProviderPayload, webhookData?: ProviderPayload): boolean
|
|
43
|
+
matches(params: Record<string, unknown>, providerEventData: ProviderPayload, webhookData?: ProviderPayload): Promise<boolean>;
|
|
34
44
|
extendResult(providerEventData: ProviderPayload, ctx: ExecutionContext, webhookData?: ProviderPayload): Promise<unknown> | unknown;
|
|
35
45
|
hasExtendResult(): boolean;
|
|
36
46
|
toModel(): SharedExtensionMethod;
|
|
@@ -66,7 +66,7 @@ export interface RealtimeSetupProps<TShape extends ExtensionShape = AnyShape> {
|
|
|
66
66
|
verify?: RealtimeVerify<TShape>;
|
|
67
67
|
handshake?: (bag: InboundBag<TShape> & {
|
|
68
68
|
requestBody: ProviderPayload;
|
|
69
|
-
}) => HandshakeResult | void | Promise<HandshakeResult | void>;
|
|
69
|
+
}) => HandshakeResult | boolean | void | Promise<HandshakeResult | boolean | void>;
|
|
70
70
|
subscribe: (bag: HandlerBag<TShape> & {
|
|
71
71
|
callbackUrl: string;
|
|
72
72
|
triggers: RealtimeSubTrigger[];
|
|
@@ -116,11 +116,16 @@ export interface RealtimeTriggerProps<TShape extends ExtensionShape = AnyShape,
|
|
|
116
116
|
requestBody: ProviderPayload;
|
|
117
117
|
providerEventData: ProviderPayload;
|
|
118
118
|
}) => Record<string, unknown>;
|
|
119
|
+
extendMatchData?: (bag: HandlerBag<TShape> & {
|
|
120
|
+
providerEventData: ProviderPayload;
|
|
121
|
+
webhookData: ProviderPayload;
|
|
122
|
+
instances: RealtimeInstance<Infer<TParams>>[];
|
|
123
|
+
}) => Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
|
|
119
124
|
match?: Record<string, string> | ((bag: {
|
|
120
125
|
params: Infer<TParams>;
|
|
121
126
|
providerEventData: ProviderPayload;
|
|
122
127
|
webhookData: ProviderPayload;
|
|
123
|
-
}) => boolean);
|
|
128
|
+
}) => boolean | Promise<boolean>);
|
|
124
129
|
extendResult?: (bag: HandlerBag<TShape> & {
|
|
125
130
|
providerEventData: ProviderPayload;
|
|
126
131
|
webhookData: ProviderPayload;
|
|
@@ -129,6 +134,10 @@ export interface RealtimeTriggerProps<TShape extends ExtensionShape = AnyShape,
|
|
|
129
134
|
logo?: string;
|
|
130
135
|
appearanceColors?: [string, string];
|
|
131
136
|
}
|
|
137
|
+
export interface RealtimeInstance<TParams = Record<string, unknown>> {
|
|
138
|
+
id: string;
|
|
139
|
+
params: TParams;
|
|
140
|
+
}
|
|
132
141
|
export interface RealtimeInvocation {
|
|
133
142
|
callbackUrl?: string;
|
|
134
143
|
events?: {
|