@slflows/sdk 0.0.1
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/v1/index.d.ts +414 -0
- package/package.json +21 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
interface AppSchema {
|
|
2
|
+
name?: string;
|
|
3
|
+
installationInstructions?: string;
|
|
4
|
+
config?: Record<string, AppConfigField>;
|
|
5
|
+
onSync?: (input: AppInput) => Promise<AppLifecycleCallbackOutput>;
|
|
6
|
+
onDrain?: (input: AppInput) => Promise<AppLifecycleCallbackOutput>;
|
|
7
|
+
draftCustomStatusDescription?: string;
|
|
8
|
+
onInternalMessage?: (input: AppOnInternalMessageInput) => Promise<void>;
|
|
9
|
+
blocks: Record<string, AppBlock>;
|
|
10
|
+
http?: AppHTTPComponent;
|
|
11
|
+
ui?: AppUIComponent;
|
|
12
|
+
schedules?: Record<string, AppSchedule>;
|
|
13
|
+
onTimer?: (input: AppOnTimerInput) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
interface AppUIComponent {
|
|
16
|
+
onRequest: (input: AppOnUIRequestInput) => Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
type SimpleType = "string" | "number" | "boolean" | "any";
|
|
19
|
+
type SimpleTypeArray = [SimpleType];
|
|
20
|
+
interface JsonSchema {
|
|
21
|
+
type?: string;
|
|
22
|
+
properties?: Record<string, JsonSchema>;
|
|
23
|
+
items?: JsonSchema;
|
|
24
|
+
required?: string[];
|
|
25
|
+
enum?: (string | number)[];
|
|
26
|
+
anyOf?: JsonSchema[];
|
|
27
|
+
oneOf?: JsonSchema[];
|
|
28
|
+
description?: string;
|
|
29
|
+
additionalProperties?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type Type = SimpleType | SimpleTypeArray | JsonSchema;
|
|
32
|
+
interface AppConfigField {
|
|
33
|
+
name: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
type: Type;
|
|
36
|
+
fixed?: boolean;
|
|
37
|
+
required: boolean;
|
|
38
|
+
default?: unknown;
|
|
39
|
+
}
|
|
40
|
+
interface AppHTTPComponent {
|
|
41
|
+
onRequest: (input: AppOnHTTPRequestInput) => Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
type ScheduleDefinition = {
|
|
44
|
+
type: "cron";
|
|
45
|
+
cron: {
|
|
46
|
+
expression: string;
|
|
47
|
+
location: string;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
type: "frequency";
|
|
51
|
+
frequency: {
|
|
52
|
+
interval: number;
|
|
53
|
+
unit?: "seconds" | "minutes" | "hours";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
interface AppSchedule {
|
|
57
|
+
description?: string;
|
|
58
|
+
customizable?: boolean;
|
|
59
|
+
definition: ScheduleDefinition;
|
|
60
|
+
onTrigger: (input: AppOnTriggerInput) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
interface AppBlock {
|
|
63
|
+
name?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
category?: string;
|
|
66
|
+
config?: Record<string, AppBlockConfigField>;
|
|
67
|
+
onInternalMessage?: (input: EntityOnInternalMessageInput) => Promise<void>;
|
|
68
|
+
inputs?: Record<string, AppBlockComponentInput>;
|
|
69
|
+
outputs?: Record<string, AppBlockComponentOutput>;
|
|
70
|
+
signals?: Record<string, AppBlockSignal>;
|
|
71
|
+
onSync?: (input: EntityInput) => EntityLifecycleCallbackOutput | Promise<EntityLifecycleCallbackOutput>;
|
|
72
|
+
onDrain?: (input: EntityInput) => EntityLifecycleCallbackOutput | Promise<EntityLifecycleCallbackOutput>;
|
|
73
|
+
draftCustomStatusDescription?: string;
|
|
74
|
+
http?: AppBlockHTTPComponent;
|
|
75
|
+
ui?: AppBlockUIComponent;
|
|
76
|
+
schedules?: Record<string, AppBlockSchedule>;
|
|
77
|
+
onTimer?: (input: EntityOnTimerInput) => Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
interface AppBlockConfigField {
|
|
80
|
+
name: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
type: Type;
|
|
83
|
+
fixed?: boolean;
|
|
84
|
+
required: boolean;
|
|
85
|
+
default?: unknown;
|
|
86
|
+
fieldKey?: string;
|
|
87
|
+
}
|
|
88
|
+
interface AppBlockComponentInput {
|
|
89
|
+
name?: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
config?: Record<string, AppBlockConfigField>;
|
|
92
|
+
onEvent: (input: EventInput) => Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
interface AppBlockComponentOutput {
|
|
95
|
+
name?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
default?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Defines which inputs can provide parent events for this output.
|
|
100
|
+
* Used for type inference - determines what fields and types will be
|
|
101
|
+
* available in the output event based on parent input types.
|
|
102
|
+
* Should be a list of input keys that can be used as parents.
|
|
103
|
+
*/
|
|
104
|
+
possiblePrimaryParents?: string[];
|
|
105
|
+
secondary?: boolean;
|
|
106
|
+
type?: Type;
|
|
107
|
+
}
|
|
108
|
+
interface AppBlockHTTPComponent {
|
|
109
|
+
onRequest: (input: EntityOnHTTPRequestInput) => Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
interface AppBlockUIComponent {
|
|
112
|
+
onRequest: (input: EntityOnUIRequestInput) => Promise<any>;
|
|
113
|
+
views?: EntityView[] | null;
|
|
114
|
+
}
|
|
115
|
+
interface AppBlockSignal {
|
|
116
|
+
name: string;
|
|
117
|
+
description: string;
|
|
118
|
+
}
|
|
119
|
+
interface AppBlockSchedule {
|
|
120
|
+
description?: string;
|
|
121
|
+
customizable?: boolean;
|
|
122
|
+
definition: ScheduleDefinition;
|
|
123
|
+
onTrigger: (input: EntityOnTriggerInput) => Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
interface EntityView {
|
|
126
|
+
id: string;
|
|
127
|
+
label: string;
|
|
128
|
+
type: EntityViewType;
|
|
129
|
+
}
|
|
130
|
+
type EntityViewType = "default" | "fullScreen" | "regular";
|
|
131
|
+
interface AppInput {
|
|
132
|
+
app: AppContext;
|
|
133
|
+
}
|
|
134
|
+
interface AppContext {
|
|
135
|
+
config: Record<string, any>;
|
|
136
|
+
installationStatus: "new" | "active" | "failed";
|
|
137
|
+
http: AppHTTPEndpoint;
|
|
138
|
+
installationUrl: string;
|
|
139
|
+
}
|
|
140
|
+
interface AppHTTPEndpoint {
|
|
141
|
+
url: string;
|
|
142
|
+
}
|
|
143
|
+
interface EntityInput extends AppInput {
|
|
144
|
+
block: EntityContext;
|
|
145
|
+
}
|
|
146
|
+
interface EntityContext {
|
|
147
|
+
id: string;
|
|
148
|
+
config: Record<string, any>;
|
|
149
|
+
lifecycle: EntityLifecycleComponent | null;
|
|
150
|
+
http: EntityHTTPEndpoint | null;
|
|
151
|
+
}
|
|
152
|
+
interface EntityLifecycleComponent {
|
|
153
|
+
status: EntityLifecycleStatus;
|
|
154
|
+
signals: Record<string, any> | null;
|
|
155
|
+
}
|
|
156
|
+
type EntityLifecycleStatus = "draft" | "in_progress" | "ready" | "drifted" | "failed" | "draining" | "draining_failed" | "drained";
|
|
157
|
+
interface EntityHTTPEndpoint {
|
|
158
|
+
url: string;
|
|
159
|
+
}
|
|
160
|
+
interface EventInput extends EntityInput {
|
|
161
|
+
event: EventContext;
|
|
162
|
+
}
|
|
163
|
+
interface EventContext {
|
|
164
|
+
id: string;
|
|
165
|
+
inputConfig: Record<string, any>;
|
|
166
|
+
echo?: {
|
|
167
|
+
body: any;
|
|
168
|
+
outputKey: string;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
interface EntityLifecycleCallbackOutput {
|
|
172
|
+
signalUpdates?: Record<string, any>;
|
|
173
|
+
newStatus?: EntityLifecycleStatus;
|
|
174
|
+
customStatusDescription?: string | null;
|
|
175
|
+
nextScheduleDelay?: number;
|
|
176
|
+
}
|
|
177
|
+
interface AppLifecycleCallbackOutput {
|
|
178
|
+
signalUpdates?: Record<string, any>;
|
|
179
|
+
newStatus?: AppLifecycleStatus;
|
|
180
|
+
customStatusDescription?: string | null;
|
|
181
|
+
nextScheduleDelay?: number;
|
|
182
|
+
}
|
|
183
|
+
type AppLifecycleStatus = "draft" | "in_progress" | "ready" | "failed" | "draining" | "draining_failed" | "drained";
|
|
184
|
+
interface AppOnCreateOutput {
|
|
185
|
+
ok?: {};
|
|
186
|
+
redirect?: {
|
|
187
|
+
url: string;
|
|
188
|
+
method: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
interface AppOnInternalMessageInput extends AppInput {
|
|
192
|
+
message: {
|
|
193
|
+
publisherId: string;
|
|
194
|
+
body: any;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
interface EntityOnInternalMessageInput extends EntityInput {
|
|
198
|
+
message: {
|
|
199
|
+
body: any;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
interface AppOnTimerInput extends AppInput {
|
|
203
|
+
timer: {
|
|
204
|
+
payload: any;
|
|
205
|
+
prompt?: {
|
|
206
|
+
id: string;
|
|
207
|
+
description?: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
interface EntityOnTimerInput extends EntityInput {
|
|
212
|
+
timer: {
|
|
213
|
+
payload: any;
|
|
214
|
+
pendingEvent?: {
|
|
215
|
+
id: string;
|
|
216
|
+
body?: any;
|
|
217
|
+
status?: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
interface AppOnTriggerInput extends AppInput {
|
|
222
|
+
schedule: {
|
|
223
|
+
time: string;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
interface EntityOnTriggerInput extends EntityInput {
|
|
227
|
+
schedule: {
|
|
228
|
+
time: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
interface AppOnHTTPRequestInput extends AppInput {
|
|
232
|
+
request: HTTPRequest;
|
|
233
|
+
}
|
|
234
|
+
interface EntityOnHTTPRequestInput extends EntityInput {
|
|
235
|
+
request: HTTPRequest;
|
|
236
|
+
}
|
|
237
|
+
interface HTTPRequest {
|
|
238
|
+
requestId: string;
|
|
239
|
+
path: string;
|
|
240
|
+
method: string;
|
|
241
|
+
headers: Record<string, string>;
|
|
242
|
+
query: Record<string, string>;
|
|
243
|
+
params: Record<string, string>;
|
|
244
|
+
rawBody: string;
|
|
245
|
+
body: any;
|
|
246
|
+
}
|
|
247
|
+
interface AppOnUIRequestInput extends AppInput {
|
|
248
|
+
request: UIRequest;
|
|
249
|
+
}
|
|
250
|
+
interface EntityOnUIRequestInput extends EntityInput {
|
|
251
|
+
request: UIRequest;
|
|
252
|
+
}
|
|
253
|
+
interface UIRequest {
|
|
254
|
+
type: string;
|
|
255
|
+
payload?: any;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
interface KVPair {
|
|
259
|
+
key: string;
|
|
260
|
+
value?: any;
|
|
261
|
+
updatedAt?: number;
|
|
262
|
+
ttl?: number;
|
|
263
|
+
lock?: {
|
|
264
|
+
id: string;
|
|
265
|
+
timeout?: number;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
interface KVListInput {
|
|
269
|
+
keyPrefix: string;
|
|
270
|
+
startingKey?: string;
|
|
271
|
+
}
|
|
272
|
+
interface KVListOutput {
|
|
273
|
+
pairs: Array<KVPair>;
|
|
274
|
+
nextStartingKey?: string;
|
|
275
|
+
}
|
|
276
|
+
interface ListBlocksInput {
|
|
277
|
+
typeIds?: string[];
|
|
278
|
+
}
|
|
279
|
+
interface ListBlocksOutput {
|
|
280
|
+
blocks: {
|
|
281
|
+
id: string;
|
|
282
|
+
typeId: string;
|
|
283
|
+
config: Record<string, any>;
|
|
284
|
+
}[];
|
|
285
|
+
}
|
|
286
|
+
declare const setAppInstallationStatus: (status: "active" | "failed") => Promise<void>;
|
|
287
|
+
interface EmitOptions {
|
|
288
|
+
outputId?: string;
|
|
289
|
+
parentEventId?: string;
|
|
290
|
+
secondaryParentEventIds?: string[];
|
|
291
|
+
echo?: boolean;
|
|
292
|
+
complete?: string;
|
|
293
|
+
}
|
|
294
|
+
interface CreatePendingEventOptions {
|
|
295
|
+
event?: Record<string, any>;
|
|
296
|
+
outputId?: string;
|
|
297
|
+
parentEventId?: string;
|
|
298
|
+
secondaryParentEventIds?: string[];
|
|
299
|
+
statusDescription: string | null;
|
|
300
|
+
}
|
|
301
|
+
interface UpdatePendingEventOptions {
|
|
302
|
+
event?: Record<string, any>;
|
|
303
|
+
outputId?: string;
|
|
304
|
+
parentEventId?: string;
|
|
305
|
+
secondaryParentEventIds?: string[];
|
|
306
|
+
statusDescription?: string | null;
|
|
307
|
+
}
|
|
308
|
+
interface PromptOptions {
|
|
309
|
+
redirect: {
|
|
310
|
+
url: string;
|
|
311
|
+
method: "GET" | "POST";
|
|
312
|
+
formFields?: Record<string, string>;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
interface InvocationMetadata {
|
|
316
|
+
invocationId: string;
|
|
317
|
+
timestamp: number;
|
|
318
|
+
}
|
|
319
|
+
declare const getInvocationMetadata: () => Promise<InvocationMetadata>;
|
|
320
|
+
declare const events: {
|
|
321
|
+
emit: (event: any, options?: EmitOptions) => Promise<void>;
|
|
322
|
+
createPending: (options: CreatePendingEventOptions) => Promise<string>;
|
|
323
|
+
updatePending: (pendingEventId: string, options: UpdatePendingEventOptions) => Promise<void>;
|
|
324
|
+
cancelPending: (pendingEventId: string, reason: string) => Promise<void>;
|
|
325
|
+
completePending: (pendingEventId: string) => Promise<void>;
|
|
326
|
+
};
|
|
327
|
+
declare const kv: {
|
|
328
|
+
block: {
|
|
329
|
+
getMany: (keys: string[]) => Promise<KVPair[]>;
|
|
330
|
+
get: (key: string) => Promise<KVPair>;
|
|
331
|
+
setMany: (pairs: KVPair[]) => Promise<boolean>;
|
|
332
|
+
set: (pair: KVPair) => Promise<boolean>;
|
|
333
|
+
list: (input: KVListInput) => Promise<KVListOutput>;
|
|
334
|
+
delete: (keys: string[]) => Promise<boolean>;
|
|
335
|
+
releaseLock: (params: {
|
|
336
|
+
key: string;
|
|
337
|
+
lockId: string;
|
|
338
|
+
}) => Promise<boolean>;
|
|
339
|
+
renewLock: (params: {
|
|
340
|
+
key: string;
|
|
341
|
+
lock: {
|
|
342
|
+
id: string;
|
|
343
|
+
timeout?: number;
|
|
344
|
+
};
|
|
345
|
+
}) => Promise<boolean>;
|
|
346
|
+
};
|
|
347
|
+
app: {
|
|
348
|
+
getMany: (keys: string[]) => Promise<KVPair[]>;
|
|
349
|
+
get: (key: string) => Promise<KVPair>;
|
|
350
|
+
setMany: (pairs: KVPair[]) => Promise<boolean>;
|
|
351
|
+
set: (pair: KVPair) => Promise<boolean>;
|
|
352
|
+
list: (input: KVListInput) => Promise<KVListOutput>;
|
|
353
|
+
delete: (keys: string[]) => Promise<boolean>;
|
|
354
|
+
releaseLock: (params: {
|
|
355
|
+
key: string;
|
|
356
|
+
lockId: string;
|
|
357
|
+
}) => Promise<boolean>;
|
|
358
|
+
renewLock: (params: {
|
|
359
|
+
key: string;
|
|
360
|
+
lock: {
|
|
361
|
+
id: string;
|
|
362
|
+
timeout?: number;
|
|
363
|
+
};
|
|
364
|
+
}) => Promise<boolean>;
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
declare const messaging: {
|
|
368
|
+
sendToBlocks: (input: {
|
|
369
|
+
body: unknown;
|
|
370
|
+
blockIds: string[];
|
|
371
|
+
}) => Promise<void>;
|
|
372
|
+
sendToApp: (input: {
|
|
373
|
+
body: unknown;
|
|
374
|
+
}) => Promise<void>;
|
|
375
|
+
};
|
|
376
|
+
declare const blocks: {
|
|
377
|
+
list: (input?: ListBlocksInput) => Promise<ListBlocksOutput>;
|
|
378
|
+
};
|
|
379
|
+
declare const http: {
|
|
380
|
+
respond: (requestId: string, response: {
|
|
381
|
+
statusCode?: number;
|
|
382
|
+
headers?: Record<string, string>;
|
|
383
|
+
body?: unknown;
|
|
384
|
+
}) => Promise<void>;
|
|
385
|
+
};
|
|
386
|
+
declare const lifecycle: {
|
|
387
|
+
sync: () => Promise<void>;
|
|
388
|
+
proceed: () => Promise<void>;
|
|
389
|
+
prompt: {
|
|
390
|
+
create: (description: string, options: PromptOptions) => Promise<string>;
|
|
391
|
+
delete: (promptId: string) => Promise<void>;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
declare const timers: {
|
|
395
|
+
set: (delaySeconds: number, options: {
|
|
396
|
+
inputPayload?: unknown;
|
|
397
|
+
pendingEventId?: string;
|
|
398
|
+
promptId?: string;
|
|
399
|
+
description?: string;
|
|
400
|
+
}) => Promise<string>;
|
|
401
|
+
unset: (id: string) => Promise<void>;
|
|
402
|
+
};
|
|
403
|
+
declare const ui: {
|
|
404
|
+
widget: {
|
|
405
|
+
set: (options: {
|
|
406
|
+
blockId?: string;
|
|
407
|
+
elements: any[] | null;
|
|
408
|
+
}) => Promise<void>;
|
|
409
|
+
get: (blockId?: any) => Promise<any[]>;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
declare function defineApp(app: AppSchema): AppSchema;
|
|
413
|
+
|
|
414
|
+
export { type AppBlock, type AppBlockComponentInput, type AppBlockComponentOutput, type AppBlockConfigField, type AppBlockHTTPComponent, type AppBlockSchedule, type AppBlockSignal, type AppBlockUIComponent, type AppConfigField, type AppContext, type AppHTTPComponent, type AppHTTPEndpoint, type AppInput, type AppLifecycleCallbackOutput, type AppLifecycleStatus, type AppOnCreateOutput, type AppOnHTTPRequestInput, type AppOnInternalMessageInput, type AppOnTimerInput, type AppOnTriggerInput, type AppOnUIRequestInput, type AppSchedule, type AppSchema, type AppUIComponent, type EntityContext, type EntityHTTPEndpoint, type EntityInput, type EntityLifecycleCallbackOutput, type EntityLifecycleComponent, type EntityLifecycleStatus, type EntityOnHTTPRequestInput, type EntityOnInternalMessageInput, type EntityOnTimerInput, type EntityOnTriggerInput, type EntityOnUIRequestInput, type EntityView, type EntityViewType, type EventContext, type EventInput, type HTTPRequest, type ScheduleDefinition, type UIRequest, blocks, defineApp, events, getInvocationMetadata, http, kv, lifecycle, messaging, setAppInstallationStatus, timers, ui };
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@slflows/sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./v1": "./dist/v1/index.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"pkgroll": "^2.12.2",
|
|
13
|
+
"rollup": "^4.41.1",
|
|
14
|
+
"rollup-plugin-dts": "^6.2.1",
|
|
15
|
+
"typescript": "^5.8.3"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "pkgroll --clean-dist --src types",
|
|
19
|
+
"watch": "pkgroll --watch --src types"
|
|
20
|
+
}
|
|
21
|
+
}
|