@teamkeel/testing-runtime 0.464.0 → 0.465.0
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/package.json +1 -1
- package/src/FlowExecutor.mjs +43 -41
- package/src/index.d.ts +28 -14
- package/src/index.mjs +3 -0
package/package.json
CHANGED
package/src/FlowExecutor.mjs
CHANGED
|
@@ -85,53 +85,55 @@ export class FlowExecutor {
|
|
|
85
85
|
}).then(handleResponse);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
body.expiresAt =
|
|
94
|
-
options.expiresAt instanceof Date
|
|
95
|
-
? options.expiresAt.toISOString()
|
|
96
|
-
: options.expiresAt;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const result = await fetch(this._flowUrl + "/share", {
|
|
100
|
-
method: "POST",
|
|
101
|
-
body: JSON.stringify(body),
|
|
102
|
-
headers: this.headers(),
|
|
103
|
-
}).then(handleResponse);
|
|
88
|
+
// The signed-link management namespace for this flow: create, list and revoke signed links. The
|
|
89
|
+
// generated testing types only expose `signedLinks` on flows declared with @externalAccess.
|
|
90
|
+
get signedLinks() {
|
|
91
|
+
const flowUrl = this._flowUrl;
|
|
92
|
+
const headers = () => this.headers();
|
|
104
93
|
|
|
105
94
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
async create(options = {}) {
|
|
96
|
+
const body = {};
|
|
97
|
+
if (options.inputs !== undefined) body.inputs = options.inputs;
|
|
98
|
+
if (options.reusable !== undefined) body.reusable = options.reusable;
|
|
99
|
+
if (options.expiresAt !== undefined && options.expiresAt !== null) {
|
|
100
|
+
body.expiresAt =
|
|
101
|
+
options.expiresAt instanceof Date
|
|
102
|
+
? options.expiresAt.toISOString()
|
|
103
|
+
: options.expiresAt;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return fetch(flowUrl + "/share", {
|
|
107
|
+
method: "POST",
|
|
108
|
+
body: JSON.stringify(body),
|
|
109
|
+
headers: headers(),
|
|
110
|
+
}).then(handleResponse);
|
|
111
111
|
},
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
async list(options = {}) {
|
|
114
|
+
let url = flowUrl + "/share";
|
|
115
|
+
if (options.status !== undefined && options.status !== null) {
|
|
116
|
+
const queryString = new URLSearchParams({
|
|
117
|
+
status: options.status,
|
|
118
|
+
}).toString();
|
|
119
|
+
url = `${url}?${queryString}`;
|
|
120
|
+
}
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
122
|
+
const result = await fetch(url, {
|
|
123
|
+
method: "GET",
|
|
124
|
+
headers: headers(),
|
|
125
|
+
}).then(handleResponse);
|
|
129
126
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
return { results: result.signedLinks || [] };
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
async revoke(linkId) {
|
|
131
|
+
return fetch(flowUrl + "/share/" + encodeURIComponent(linkId), {
|
|
132
|
+
method: "DELETE",
|
|
133
|
+
headers: headers(),
|
|
134
|
+
}).then(handleResponse);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
async cancel(id) {
|
package/src/index.d.ts
CHANGED
|
@@ -138,23 +138,10 @@ export type UIElement =
|
|
|
138
138
|
// Union type for UI configurations
|
|
139
139
|
export type UIConfig = UIPage | UIComplete;
|
|
140
140
|
|
|
141
|
-
declare class FlowExecutor<Input = {}> {
|
|
141
|
+
export declare class FlowExecutor<Input = {}> {
|
|
142
142
|
withIdentity(identity: sdk.Identity): FlowExecutor<Input>;
|
|
143
143
|
withAuthToken(token: string): FlowExecutor<Input>;
|
|
144
144
|
start(inputs: Input): Promise<FlowRun<Input>>;
|
|
145
|
-
signedLink(options?: {
|
|
146
|
-
inputs?: Input;
|
|
147
|
-
expiresAt?: Date;
|
|
148
|
-
reusable?: boolean;
|
|
149
|
-
}): Promise<{
|
|
150
|
-
url: string;
|
|
151
|
-
expiresAt: Date | null;
|
|
152
|
-
flow: { name: string; runId: string | null };
|
|
153
|
-
}>;
|
|
154
|
-
listSignedLinks(options?: {
|
|
155
|
-
status?: "active" | "revoked" | "expired";
|
|
156
|
-
}): Promise<{ signedLinks: SignedLinkRecord[] }>;
|
|
157
|
-
revokeSignedLink(linkId: string): Promise<SignedLinkRecord>;
|
|
158
145
|
get(id: string): Promise<FlowRun<Input>>;
|
|
159
146
|
cancel(id: string): Promise<FlowRun<Input>>;
|
|
160
147
|
back(id: string): Promise<FlowRun<Input>>;
|
|
@@ -175,6 +162,33 @@ declare class FlowExecutor<Input = {}> {
|
|
|
175
162
|
untilFinished(id: string, timeout?: number): Promise<FlowRun<Input>>;
|
|
176
163
|
}
|
|
177
164
|
|
|
165
|
+
// The signed-link management namespace exposed on a shareable flow's executor as `signedLinks`.
|
|
166
|
+
export interface SignedLinksAPI<Input = {}> {
|
|
167
|
+
// Mint a signed link that lets an external, unauthenticated actor execute this flow.
|
|
168
|
+
create(options?: {
|
|
169
|
+
inputs?: Input;
|
|
170
|
+
expiresAt?: Date;
|
|
171
|
+
reusable?: boolean;
|
|
172
|
+
}): Promise<SignedLinkRecord>;
|
|
173
|
+
// List the signed links minted for this flow, optionally filtered by status.
|
|
174
|
+
list(options?: {
|
|
175
|
+
status?: "active" | "revoked" | "expired";
|
|
176
|
+
}): Promise<{ results: SignedLinkRecord[] }>;
|
|
177
|
+
// Revoke a signed link by id so it can no longer be opened. Idempotent.
|
|
178
|
+
revoke(linkId: string): Promise<SignedLinkRecord>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// A FlowExecutor for flows declared with @externalAccess: adds the signed-link management
|
|
182
|
+
// namespace. Runtime-wise there is a single FlowExecutor class; this declaration-only split lets
|
|
183
|
+
// generated testing types expose `signedLinks` only on shareable flows.
|
|
184
|
+
export declare class ShareableFlowExecutor<
|
|
185
|
+
Input = {},
|
|
186
|
+
> extends FlowExecutor<Input> {
|
|
187
|
+
withIdentity(identity: sdk.Identity): ShareableFlowExecutor<Input>;
|
|
188
|
+
withAuthToken(token: string): ShareableFlowExecutor<Input>;
|
|
189
|
+
readonly signedLinks: SignedLinksAPI<Input>;
|
|
190
|
+
}
|
|
191
|
+
|
|
178
192
|
// A persisted shareable signed link for a flow. The shareable url is exposed so the link can be
|
|
179
193
|
// re-shared; the raw token/hash is never exposed. url is absent for links minted before the token
|
|
180
194
|
// was persisted.
|
package/src/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { sql } from "kysely";
|
|
2
2
|
export { ActionExecutor } from "./ActionExecutor.mjs";
|
|
3
3
|
export { FlowExecutor } from "./FlowExecutor.mjs";
|
|
4
|
+
// ShareableFlowExecutor is a declaration-only refinement of FlowExecutor (see index.d.ts); at
|
|
5
|
+
// runtime they are the same class.
|
|
6
|
+
export { FlowExecutor as ShareableFlowExecutor } from "./FlowExecutor.mjs";
|
|
4
7
|
export { JobExecutor } from "./JobExecutor.mjs";
|
|
5
8
|
export { SubscriberExecutor } from "./SubscriberExecutor.mjs";
|
|
6
9
|
export { toHaveError } from "./toHaveError.mjs";
|