khotan-data 0.0.1 → 0.1.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/AGENTS.md +54 -0
- package/README.md +117 -1
- package/dist/cli.js +2869 -0
- package/dist/factory.cjs +3303 -0
- package/dist/factory.cjs.map +1 -0
- package/dist/factory.d.cts +662 -0
- package/dist/factory.d.ts +662 -0
- package/dist/factory.js +3292 -0
- package/dist/factory.js.map +1 -0
- package/dist/plug-client.cjs +99 -0
- package/dist/plug-client.cjs.map +1 -0
- package/dist/plug-client.d.cts +71 -0
- package/dist/plug-client.d.ts +71 -0
- package/dist/plug-client.js +96 -0
- package/dist/plug-client.js.map +1 -0
- package/dist/templates/agent-skill.md +73 -0
- package/dist/templates/agents.md +41 -0
- package/dist/templates/cache.example.ts +11 -0
- package/dist/templates/cache.ts +58 -0
- package/dist/templates/catch.example.ts +36 -0
- package/dist/templates/catch.ts +119 -0
- package/dist/templates/config-page.tsx +20 -0
- package/dist/templates/debug-index-page.tsx +101 -0
- package/dist/templates/debug-page.tsx +48 -0
- package/dist/templates/graph-page.tsx +11 -0
- package/dist/templates/hub.tsx +450 -0
- package/dist/templates/inflow.example.ts +61 -0
- package/dist/templates/inflow.ts +98 -0
- package/dist/templates/khotan-config.ts +49 -0
- package/dist/templates/khotan-route.ts +13 -0
- package/dist/templates/logs-page.tsx +9 -0
- package/dist/templates/logs.tsx +20 -0
- package/dist/templates/mapping-browser.tsx +761 -0
- package/dist/templates/mappings-page.tsx +9 -0
- package/dist/templates/outflow.example.ts +52 -0
- package/dist/templates/outflow.ts +90 -0
- package/dist/templates/pass.example.ts +51 -0
- package/dist/templates/pass.ts +134 -0
- package/dist/templates/plug-debugger.tsx +1185 -0
- package/dist/templates/plug.example.ts +93 -0
- package/dist/templates/plug.ts +806 -0
- package/dist/templates/relay.example.ts +71 -0
- package/dist/templates/relay.ts +104 -0
- package/dist/templates/runs-table.tsx +592 -0
- package/dist/templates/schema.ts +505 -0
- package/dist/templates/skill-dashboard.md +144 -0
- package/dist/templates/skill-plug.md +216 -0
- package/dist/templates/skill-setup.md +161 -0
- package/dist/templates/skill-webhook.md +196 -0
- package/dist/templates/topology-canvas.tsx +1406 -0
- package/dist/templates/var-panel.tsx +276 -0
- package/dist/templates/webhook-events-table.tsx +241 -0
- package/dist/templates/wire-panel.tsx +216 -0
- package/dist/templates/wire.ts +155 -0
- package/package.json +46 -5
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { PgDatabase } from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
type ResourceConnectField = string | [string, ...string[]];
|
|
4
|
+
interface ResourcePlugParticipation {
|
|
5
|
+
uniqueIdentifier: string;
|
|
6
|
+
}
|
|
7
|
+
interface ResourceMappingRegistration {
|
|
8
|
+
connectField: ResourceConnectField;
|
|
9
|
+
plugs?: Record<string, ResourcePlugParticipation>;
|
|
10
|
+
}
|
|
11
|
+
interface ResourceRegistration {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
mapping: ResourceMappingRegistration;
|
|
15
|
+
}
|
|
16
|
+
type FlowType = "inflow" | "outflow" | "relay" | "webhook";
|
|
17
|
+
type KhotanRunStatus = "pending" | "running" | "completed" | "partial" | "failed" | "cancelled";
|
|
18
|
+
type KhotanTerminalRunStatus = "completed" | "partial" | "failed" | "cancelled";
|
|
19
|
+
interface FlowRunResult {
|
|
20
|
+
status?: KhotanTerminalRunStatus;
|
|
21
|
+
extracted?: number;
|
|
22
|
+
transformed?: number;
|
|
23
|
+
created?: number;
|
|
24
|
+
updated?: number;
|
|
25
|
+
deleted?: number;
|
|
26
|
+
failed?: number;
|
|
27
|
+
error?: string | null;
|
|
28
|
+
metadata?: Record<string, unknown> | null;
|
|
29
|
+
}
|
|
30
|
+
interface BoundPlug {
|
|
31
|
+
get<T>(path: string, options?: {
|
|
32
|
+
params?: Record<string, unknown>;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
}): Promise<T>;
|
|
35
|
+
post<T>(path: string, options?: {
|
|
36
|
+
body?: unknown;
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
}): Promise<T>;
|
|
39
|
+
put<T>(path: string, options?: {
|
|
40
|
+
body?: unknown;
|
|
41
|
+
headers?: Record<string, string>;
|
|
42
|
+
}): Promise<T>;
|
|
43
|
+
patch<T>(path: string, options?: {
|
|
44
|
+
body?: unknown;
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
}): Promise<T>;
|
|
47
|
+
delete<T>(path: string, options?: {
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
}): Promise<T>;
|
|
50
|
+
}
|
|
51
|
+
interface BindablePlug {
|
|
52
|
+
get<T>(path: string, options?: {
|
|
53
|
+
params?: Record<string, unknown>;
|
|
54
|
+
headers?: Record<string, string>;
|
|
55
|
+
vars?: Record<string, string>;
|
|
56
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
57
|
+
}): Promise<T>;
|
|
58
|
+
post<T>(path: string, options?: {
|
|
59
|
+
body?: unknown;
|
|
60
|
+
headers?: Record<string, string>;
|
|
61
|
+
vars?: Record<string, string>;
|
|
62
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
63
|
+
}): Promise<T>;
|
|
64
|
+
put<T>(path: string, options?: {
|
|
65
|
+
body?: unknown;
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
vars?: Record<string, string>;
|
|
68
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
69
|
+
}): Promise<T>;
|
|
70
|
+
patch<T>(path: string, options?: {
|
|
71
|
+
body?: unknown;
|
|
72
|
+
headers?: Record<string, string>;
|
|
73
|
+
vars?: Record<string, string>;
|
|
74
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
75
|
+
}): Promise<T>;
|
|
76
|
+
delete<T>(path: string, options?: {
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
vars?: Record<string, string>;
|
|
79
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
80
|
+
}): Promise<T>;
|
|
81
|
+
}
|
|
82
|
+
interface FlowRunContext {
|
|
83
|
+
plug: BoundPlug;
|
|
84
|
+
flow: {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
plugName: string;
|
|
88
|
+
type: FlowType;
|
|
89
|
+
resource?: string | null;
|
|
90
|
+
to?: string | null;
|
|
91
|
+
};
|
|
92
|
+
runType: string;
|
|
93
|
+
body?: unknown;
|
|
94
|
+
vars: Record<string, string>;
|
|
95
|
+
setVars(updates: Record<string, string>): Promise<void>;
|
|
96
|
+
cache(cacheName: string): CacheInstance;
|
|
97
|
+
}
|
|
98
|
+
interface FlowWorkflowContext {
|
|
99
|
+
flow: {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
plugName: string;
|
|
103
|
+
type: FlowType;
|
|
104
|
+
resource?: string | null;
|
|
105
|
+
to?: string | null;
|
|
106
|
+
};
|
|
107
|
+
runType: string;
|
|
108
|
+
body?: unknown;
|
|
109
|
+
vars: Record<string, string>;
|
|
110
|
+
plugVarsByName?: Record<string, Record<string, string>>;
|
|
111
|
+
khotanRunId: string;
|
|
112
|
+
khotanInstanceId: string;
|
|
113
|
+
}
|
|
114
|
+
declare function bindWorkflowPlug(plug: BindablePlug, ctx: FlowWorkflowContext, plugName?: string): BoundPlug;
|
|
115
|
+
interface KhotanRunUpdate {
|
|
116
|
+
type?: "progress" | "log" | "metric" | "error";
|
|
117
|
+
message: string;
|
|
118
|
+
progress?: number;
|
|
119
|
+
extracted?: number;
|
|
120
|
+
transformed?: number;
|
|
121
|
+
created?: number;
|
|
122
|
+
updated?: number;
|
|
123
|
+
deleted?: number;
|
|
124
|
+
failed?: number;
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
}
|
|
127
|
+
interface FlowRegistration {
|
|
128
|
+
name: string;
|
|
129
|
+
type: FlowType;
|
|
130
|
+
schedule?: string;
|
|
131
|
+
resource?: string;
|
|
132
|
+
to?: string;
|
|
133
|
+
workflow?(ctx: FlowWorkflowContext): Promise<FlowRunResult | void>;
|
|
134
|
+
run?(ctx: FlowRunContext): Promise<FlowRunResult | void>;
|
|
135
|
+
}
|
|
136
|
+
interface WireSubscribeContext {
|
|
137
|
+
plug: {
|
|
138
|
+
get<T>(path: string, options?: {
|
|
139
|
+
params?: Record<string, unknown>;
|
|
140
|
+
headers?: Record<string, string>;
|
|
141
|
+
}): Promise<T>;
|
|
142
|
+
post<T>(path: string, options?: {
|
|
143
|
+
body?: unknown;
|
|
144
|
+
headers?: Record<string, string>;
|
|
145
|
+
}): Promise<T>;
|
|
146
|
+
put<T>(path: string, options?: {
|
|
147
|
+
body?: unknown;
|
|
148
|
+
headers?: Record<string, string>;
|
|
149
|
+
}): Promise<T>;
|
|
150
|
+
patch<T>(path: string, options?: {
|
|
151
|
+
body?: unknown;
|
|
152
|
+
headers?: Record<string, string>;
|
|
153
|
+
}): Promise<T>;
|
|
154
|
+
delete<T>(path: string, options?: {
|
|
155
|
+
headers?: Record<string, string>;
|
|
156
|
+
}): Promise<T>;
|
|
157
|
+
};
|
|
158
|
+
callbackUrl: string;
|
|
159
|
+
events: string[];
|
|
160
|
+
wireVars: Record<string, string>;
|
|
161
|
+
setWireVars(updates: Record<string, string>): Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
interface WireUnsubscribeContext {
|
|
164
|
+
plug: {
|
|
165
|
+
get<T>(path: string, options?: {
|
|
166
|
+
params?: Record<string, unknown>;
|
|
167
|
+
headers?: Record<string, string>;
|
|
168
|
+
}): Promise<T>;
|
|
169
|
+
post<T>(path: string, options?: {
|
|
170
|
+
body?: unknown;
|
|
171
|
+
headers?: Record<string, string>;
|
|
172
|
+
}): Promise<T>;
|
|
173
|
+
put<T>(path: string, options?: {
|
|
174
|
+
body?: unknown;
|
|
175
|
+
headers?: Record<string, string>;
|
|
176
|
+
}): Promise<T>;
|
|
177
|
+
patch<T>(path: string, options?: {
|
|
178
|
+
body?: unknown;
|
|
179
|
+
headers?: Record<string, string>;
|
|
180
|
+
}): Promise<T>;
|
|
181
|
+
delete<T>(path: string, options?: {
|
|
182
|
+
headers?: Record<string, string>;
|
|
183
|
+
}): Promise<T>;
|
|
184
|
+
};
|
|
185
|
+
remoteId: string;
|
|
186
|
+
wireVars: Record<string, string>;
|
|
187
|
+
setWireVars(updates: Record<string, string>): Promise<void>;
|
|
188
|
+
}
|
|
189
|
+
interface WireVerifyContext {
|
|
190
|
+
headers: Record<string, string>;
|
|
191
|
+
body: string;
|
|
192
|
+
wireVars: Record<string, string>;
|
|
193
|
+
}
|
|
194
|
+
interface WireRegistration {
|
|
195
|
+
events: string[];
|
|
196
|
+
onSubscribe(ctx: WireSubscribeContext): Promise<{
|
|
197
|
+
remoteId: string;
|
|
198
|
+
}>;
|
|
199
|
+
onUnsubscribe(ctx: WireUnsubscribeContext): Promise<void>;
|
|
200
|
+
onVerify?(ctx: WireVerifyContext): Promise<boolean>;
|
|
201
|
+
}
|
|
202
|
+
interface CatchRegistration {
|
|
203
|
+
type: "catch";
|
|
204
|
+
name: string;
|
|
205
|
+
events?: string[];
|
|
206
|
+
workflow: (ctx: CatchWorkflowContext) => Promise<void>;
|
|
207
|
+
}
|
|
208
|
+
interface PassRegistration {
|
|
209
|
+
type: "pass";
|
|
210
|
+
name: string;
|
|
211
|
+
to: string;
|
|
212
|
+
events?: string[];
|
|
213
|
+
workflow: (ctx: PassWorkflowContext) => Promise<void>;
|
|
214
|
+
}
|
|
215
|
+
type WebhookRegistration = CatchRegistration | PassRegistration;
|
|
216
|
+
interface CacheScope {
|
|
217
|
+
plug?: string;
|
|
218
|
+
resource?: string;
|
|
219
|
+
flow?: string;
|
|
220
|
+
}
|
|
221
|
+
interface CacheRegistration {
|
|
222
|
+
name: string;
|
|
223
|
+
scope?: CacheScope;
|
|
224
|
+
ttl?: string | number;
|
|
225
|
+
}
|
|
226
|
+
interface CacheEntryRecord {
|
|
227
|
+
id: string;
|
|
228
|
+
cacheId: string;
|
|
229
|
+
key: string;
|
|
230
|
+
value: unknown;
|
|
231
|
+
expiresAt: Date | null;
|
|
232
|
+
createdAt?: Date | undefined;
|
|
233
|
+
updatedAt?: Date | undefined;
|
|
234
|
+
}
|
|
235
|
+
interface CacheInstance {
|
|
236
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
237
|
+
set<T = unknown>(key: string, value: T): Promise<T>;
|
|
238
|
+
delete(key: string): Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
interface CatchWorkflowContext {
|
|
241
|
+
event: Record<string, unknown>;
|
|
242
|
+
eventType: string;
|
|
243
|
+
headers: Record<string, string>;
|
|
244
|
+
khotanRunId: string;
|
|
245
|
+
khotanInstanceId: string;
|
|
246
|
+
}
|
|
247
|
+
interface PassWorkflowContext {
|
|
248
|
+
event: Record<string, unknown>;
|
|
249
|
+
eventType: string;
|
|
250
|
+
headers: Record<string, string>;
|
|
251
|
+
destVars: Record<string, string>;
|
|
252
|
+
khotanRunId: string;
|
|
253
|
+
khotanInstanceId: string;
|
|
254
|
+
}
|
|
255
|
+
interface KhotanWorkflowContextRef {
|
|
256
|
+
khotanInstanceId: string;
|
|
257
|
+
}
|
|
258
|
+
declare function khotanCache(ctx: KhotanWorkflowContextRef, cacheName: string): CacheInstance;
|
|
259
|
+
declare function khotanMappings(ctx: KhotanWorkflowContextRef): {
|
|
260
|
+
list: (params: {
|
|
261
|
+
resourceId: string;
|
|
262
|
+
limit?: number;
|
|
263
|
+
offset?: number;
|
|
264
|
+
search?: string;
|
|
265
|
+
}) => Promise<{
|
|
266
|
+
items: Record<string, unknown>[];
|
|
267
|
+
page: {
|
|
268
|
+
limit: number;
|
|
269
|
+
offset: number;
|
|
270
|
+
hasMore: boolean;
|
|
271
|
+
prevOffset: number;
|
|
272
|
+
nextOffset: number;
|
|
273
|
+
total: number;
|
|
274
|
+
};
|
|
275
|
+
}>;
|
|
276
|
+
lookup: (params: {
|
|
277
|
+
resourceId: string;
|
|
278
|
+
connectValue: string | string[];
|
|
279
|
+
} | {
|
|
280
|
+
resourceId: string;
|
|
281
|
+
plugName: string;
|
|
282
|
+
ref: string;
|
|
283
|
+
}) => Promise<Record<string, unknown> | null>;
|
|
284
|
+
upsert: (mapping: {
|
|
285
|
+
resourceId: string;
|
|
286
|
+
connectValue: string | string[];
|
|
287
|
+
refs: Record<string, string>;
|
|
288
|
+
metadata?: Record<string, unknown> | null;
|
|
289
|
+
}) => Promise<Record<string, unknown>>;
|
|
290
|
+
update: (id: string, mapping: {
|
|
291
|
+
resourceId: string;
|
|
292
|
+
connectValue: string | string[];
|
|
293
|
+
refs: Record<string, string>;
|
|
294
|
+
metadata?: Record<string, unknown> | null;
|
|
295
|
+
}) => Promise<Record<string, unknown>>;
|
|
296
|
+
delete: (id: string) => Promise<void>;
|
|
297
|
+
};
|
|
298
|
+
interface VarField {
|
|
299
|
+
readonly key: string;
|
|
300
|
+
label: string;
|
|
301
|
+
type: "text" | "password" | "url";
|
|
302
|
+
secret?: boolean;
|
|
303
|
+
hidden?: boolean;
|
|
304
|
+
required?: boolean;
|
|
305
|
+
placeholder?: string;
|
|
306
|
+
defaultValue?: string;
|
|
307
|
+
}
|
|
308
|
+
interface PlugRegistration {
|
|
309
|
+
name: string;
|
|
310
|
+
plug: {
|
|
311
|
+
baseUrl: string;
|
|
312
|
+
authType: string;
|
|
313
|
+
varFields?: readonly VarField[];
|
|
314
|
+
endpoints?: Record<string, {
|
|
315
|
+
method: string;
|
|
316
|
+
path: string;
|
|
317
|
+
description?: string;
|
|
318
|
+
body?: {
|
|
319
|
+
_def?: unknown;
|
|
320
|
+
shape?: Record<string, unknown>;
|
|
321
|
+
};
|
|
322
|
+
query?: {
|
|
323
|
+
_def?: unknown;
|
|
324
|
+
shape?: Record<string, unknown>;
|
|
325
|
+
};
|
|
326
|
+
responses?: Record<number, {
|
|
327
|
+
_def?: unknown;
|
|
328
|
+
shape?: Record<string, unknown>;
|
|
329
|
+
}>;
|
|
330
|
+
}>;
|
|
331
|
+
get<T>(path: string, options?: {
|
|
332
|
+
params?: Record<string, unknown>;
|
|
333
|
+
headers?: Record<string, string>;
|
|
334
|
+
vars?: Record<string, string>;
|
|
335
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
336
|
+
_skipHooks?: boolean;
|
|
337
|
+
}): Promise<T>;
|
|
338
|
+
post<T>(path: string, options?: {
|
|
339
|
+
body?: unknown;
|
|
340
|
+
headers?: Record<string, string>;
|
|
341
|
+
vars?: Record<string, string>;
|
|
342
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
343
|
+
_skipHooks?: boolean;
|
|
344
|
+
}): Promise<T>;
|
|
345
|
+
put<T>(path: string, options?: {
|
|
346
|
+
body?: unknown;
|
|
347
|
+
headers?: Record<string, string>;
|
|
348
|
+
vars?: Record<string, string>;
|
|
349
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
350
|
+
_skipHooks?: boolean;
|
|
351
|
+
}): Promise<T>;
|
|
352
|
+
patch<T>(path: string, options?: {
|
|
353
|
+
body?: unknown;
|
|
354
|
+
headers?: Record<string, string>;
|
|
355
|
+
vars?: Record<string, string>;
|
|
356
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
357
|
+
_skipHooks?: boolean;
|
|
358
|
+
}): Promise<T>;
|
|
359
|
+
delete<T>(path: string, options?: {
|
|
360
|
+
headers?: Record<string, string>;
|
|
361
|
+
vars?: Record<string, string>;
|
|
362
|
+
_setVars?: (updates: Record<string, string>) => Promise<void>;
|
|
363
|
+
_skipHooks?: boolean;
|
|
364
|
+
}): Promise<T>;
|
|
365
|
+
};
|
|
366
|
+
vars?: VarField[];
|
|
367
|
+
flows?: FlowRegistration[];
|
|
368
|
+
endpoints?: Record<string, {
|
|
369
|
+
method: string;
|
|
370
|
+
path: string;
|
|
371
|
+
}>;
|
|
372
|
+
wires?: WireRegistration[];
|
|
373
|
+
webhooks?: WebhookRegistration[];
|
|
374
|
+
catches?: CatchRegistration[];
|
|
375
|
+
passes?: PassRegistration[];
|
|
376
|
+
}
|
|
377
|
+
interface KhotanAdapter {
|
|
378
|
+
upsertPlug(plug: {
|
|
379
|
+
name: string;
|
|
380
|
+
baseUrl: string;
|
|
381
|
+
authType: string;
|
|
382
|
+
}): Promise<{
|
|
383
|
+
id: string;
|
|
384
|
+
}>;
|
|
385
|
+
upsertFlow(flow: {
|
|
386
|
+
plugId: string;
|
|
387
|
+
name: string;
|
|
388
|
+
type: string;
|
|
389
|
+
schedule?: string | null;
|
|
390
|
+
}): Promise<{
|
|
391
|
+
id: string;
|
|
392
|
+
}>;
|
|
393
|
+
listPlugs(): Promise<Record<string, unknown>[]>;
|
|
394
|
+
getPlug(id: string): Promise<Record<string, unknown> | null>;
|
|
395
|
+
getPlugFlows(plugId: string): Promise<Record<string, unknown>[]>;
|
|
396
|
+
getFlow(flowId: string): Promise<Record<string, unknown> | null>;
|
|
397
|
+
listFlows(): Promise<Record<string, unknown>[]>;
|
|
398
|
+
getRun(runId: string): Promise<Record<string, unknown> | null>;
|
|
399
|
+
listRuns(flowId: string): Promise<Record<string, unknown>[]>;
|
|
400
|
+
listRunsPage(params: {
|
|
401
|
+
limit: number;
|
|
402
|
+
offset: number;
|
|
403
|
+
}): Promise<{
|
|
404
|
+
items: Record<string, unknown>[];
|
|
405
|
+
hasMore: boolean;
|
|
406
|
+
}>;
|
|
407
|
+
upsertResource(resource: {
|
|
408
|
+
name: string;
|
|
409
|
+
connectField: ResourceConnectField;
|
|
410
|
+
description?: string | null;
|
|
411
|
+
}): Promise<{
|
|
412
|
+
id: string;
|
|
413
|
+
}>;
|
|
414
|
+
upsertCache(cache: {
|
|
415
|
+
name: string;
|
|
416
|
+
scope?: CacheScope | null;
|
|
417
|
+
ttlSeconds?: number | null;
|
|
418
|
+
}): Promise<{
|
|
419
|
+
id: string;
|
|
420
|
+
}>;
|
|
421
|
+
getCacheByName(name: string): Promise<Record<string, unknown> | null>;
|
|
422
|
+
getCacheEntry(cacheId: string, key: string): Promise<Record<string, unknown> | null>;
|
|
423
|
+
upsertCacheEntry(entry: {
|
|
424
|
+
cacheId: string;
|
|
425
|
+
key: string;
|
|
426
|
+
value: unknown;
|
|
427
|
+
expiresAt?: Date | null;
|
|
428
|
+
}): Promise<{
|
|
429
|
+
id: string;
|
|
430
|
+
created: boolean;
|
|
431
|
+
}>;
|
|
432
|
+
deleteCacheEntry(cacheId: string, key: string): Promise<void>;
|
|
433
|
+
listResources(): Promise<Record<string, unknown>[]>;
|
|
434
|
+
getResource(id: string): Promise<Record<string, unknown> | null>;
|
|
435
|
+
getResourceFlows(resourceId: string): Promise<Record<string, unknown>[]>;
|
|
436
|
+
upsertMapping(mapping: {
|
|
437
|
+
id?: string;
|
|
438
|
+
resourceId: string;
|
|
439
|
+
connectValue: string;
|
|
440
|
+
refs: Record<string, string>;
|
|
441
|
+
metadata?: Record<string, unknown> | null;
|
|
442
|
+
}): Promise<{
|
|
443
|
+
id: string;
|
|
444
|
+
created: boolean;
|
|
445
|
+
}>;
|
|
446
|
+
getMapping(id: string): Promise<Record<string, unknown> | null>;
|
|
447
|
+
listMappings(params: {
|
|
448
|
+
resourceId: string;
|
|
449
|
+
limit: number;
|
|
450
|
+
offset: number;
|
|
451
|
+
search?: string;
|
|
452
|
+
}): Promise<{
|
|
453
|
+
items: Record<string, unknown>[];
|
|
454
|
+
hasMore: boolean;
|
|
455
|
+
total: number;
|
|
456
|
+
}>;
|
|
457
|
+
deleteMapping(id: string): Promise<void>;
|
|
458
|
+
lookupMapping(params: {
|
|
459
|
+
resourceId: string;
|
|
460
|
+
connectValue: string;
|
|
461
|
+
} | {
|
|
462
|
+
resourceId: string;
|
|
463
|
+
plugName: string;
|
|
464
|
+
ref: string;
|
|
465
|
+
}): Promise<Record<string, unknown> | null>;
|
|
466
|
+
updateFlowResourceId(flowId: string, resourceId: string): Promise<void>;
|
|
467
|
+
togglePlugEnabled(plugId: string, enabled: boolean): Promise<void>;
|
|
468
|
+
toggleFlowEnabled(flowId: string, enabled: boolean): Promise<void>;
|
|
469
|
+
toggleWebhookHandlerEnabled(handlerId: string, enabled: boolean): Promise<void>;
|
|
470
|
+
insertWire(wire: {
|
|
471
|
+
plugId: string;
|
|
472
|
+
remoteId: string;
|
|
473
|
+
callbackUrl: string;
|
|
474
|
+
eventTypes: string[];
|
|
475
|
+
}): Promise<{
|
|
476
|
+
id: string;
|
|
477
|
+
}>;
|
|
478
|
+
upsertWire(wire: {
|
|
479
|
+
plugId: string;
|
|
480
|
+
}): Promise<{
|
|
481
|
+
id: string;
|
|
482
|
+
}>;
|
|
483
|
+
getActiveWire(plugId: string): Promise<Record<string, unknown> | null>;
|
|
484
|
+
getPlugWire(plugId: string): Promise<Record<string, unknown> | null>;
|
|
485
|
+
getWire(wireId: string): Promise<Record<string, unknown> | null>;
|
|
486
|
+
updateWireStatus(wireId: string, status: "active" | "disabled" | "pending"): Promise<void>;
|
|
487
|
+
updateWireDetails(wireId: string, details: {
|
|
488
|
+
remoteId: string;
|
|
489
|
+
callbackUrl: string;
|
|
490
|
+
eventTypes: string[];
|
|
491
|
+
status: "active";
|
|
492
|
+
}): Promise<void>;
|
|
493
|
+
getWireMetadata(wireId: string): Promise<string | null>;
|
|
494
|
+
updateWireMetadata(wireId: string, metadata: string): Promise<void>;
|
|
495
|
+
getEncryptedVariables(plugId: string): Promise<string | null>;
|
|
496
|
+
setEncryptedVariables(plugId: string, encrypted: string): Promise<void>;
|
|
497
|
+
clearEncryptedVariables(plugId: string): Promise<void>;
|
|
498
|
+
upsertWebhookHandler(handler: {
|
|
499
|
+
wireId: string;
|
|
500
|
+
name: string;
|
|
501
|
+
type: "catch" | "pass";
|
|
502
|
+
destinationPlugId?: string | null;
|
|
503
|
+
}): Promise<{
|
|
504
|
+
id: string;
|
|
505
|
+
}>;
|
|
506
|
+
listWebhookHandlers(wireId: string): Promise<Record<string, unknown>[]>;
|
|
507
|
+
getLatestWebhookHandlerRun(handlerId: string): Promise<Record<string, unknown> | null>;
|
|
508
|
+
insertRun(run: {
|
|
509
|
+
flowId?: string | null;
|
|
510
|
+
wireId?: string | null;
|
|
511
|
+
webhookHandlerId?: string | null;
|
|
512
|
+
workflowRunId?: string | null;
|
|
513
|
+
runType: string;
|
|
514
|
+
status: string;
|
|
515
|
+
}): Promise<{
|
|
516
|
+
id: string;
|
|
517
|
+
}>;
|
|
518
|
+
updateRun(runId: string, updates: {
|
|
519
|
+
status: KhotanRunStatus;
|
|
520
|
+
workflowRunId?: string | null;
|
|
521
|
+
completedAt?: Date;
|
|
522
|
+
durationMs?: number;
|
|
523
|
+
extracted?: number;
|
|
524
|
+
transformed?: number;
|
|
525
|
+
created?: number;
|
|
526
|
+
updated?: number;
|
|
527
|
+
deleted?: number;
|
|
528
|
+
failed?: number;
|
|
529
|
+
error?: string | null;
|
|
530
|
+
metadata?: Record<string, unknown> | null;
|
|
531
|
+
}): Promise<void>;
|
|
532
|
+
insertWebhookEvent(event: {
|
|
533
|
+
wireId: string;
|
|
534
|
+
webhookHandlerId: string;
|
|
535
|
+
khotanRunId: string;
|
|
536
|
+
eventType: string;
|
|
537
|
+
payload: Record<string, unknown>;
|
|
538
|
+
headers: Record<string, string>;
|
|
539
|
+
}): Promise<{
|
|
540
|
+
id: string;
|
|
541
|
+
}>;
|
|
542
|
+
listWebhookEventsPage(params: {
|
|
543
|
+
limit: number;
|
|
544
|
+
offset: number;
|
|
545
|
+
}): Promise<{
|
|
546
|
+
items: Record<string, unknown>[];
|
|
547
|
+
hasMore: boolean;
|
|
548
|
+
}>;
|
|
549
|
+
updateFlowLastRun(flowId: string, updates: {
|
|
550
|
+
lastRunAt: Date;
|
|
551
|
+
lastRunStatus: KhotanTerminalRunStatus;
|
|
552
|
+
}): Promise<void>;
|
|
553
|
+
}
|
|
554
|
+
interface KhotanConfig {
|
|
555
|
+
adapter: KhotanAdapter;
|
|
556
|
+
plugs: PlugRegistration[];
|
|
557
|
+
resources?: ResourceRegistration[];
|
|
558
|
+
caches?: CacheRegistration[];
|
|
559
|
+
secret?: string;
|
|
560
|
+
}
|
|
561
|
+
type KhotanHandler = (request: Request) => Promise<Response>;
|
|
562
|
+
interface WireInstance {
|
|
563
|
+
create(callbackUrl: string): Promise<Record<string, unknown>>;
|
|
564
|
+
delete(wireId: string): Promise<void>;
|
|
565
|
+
get(): Promise<Record<string, unknown> | null>;
|
|
566
|
+
}
|
|
567
|
+
interface FlowStartOptions {
|
|
568
|
+
runType?: string;
|
|
569
|
+
body?: unknown;
|
|
570
|
+
}
|
|
571
|
+
interface FlowSelectorOptions {
|
|
572
|
+
plugName?: string;
|
|
573
|
+
}
|
|
574
|
+
interface FlowInstance {
|
|
575
|
+
start(options?: FlowStartOptions): Promise<Record<string, unknown>>;
|
|
576
|
+
}
|
|
577
|
+
interface KhotanInstance {
|
|
578
|
+
handler: KhotanHandler;
|
|
579
|
+
init(): Promise<void>;
|
|
580
|
+
flow(flowNameOrId: string, options?: FlowSelectorOptions): FlowInstance;
|
|
581
|
+
wire(plugName: string): WireInstance;
|
|
582
|
+
cache(cacheName: string): CacheInstance;
|
|
583
|
+
listMappings(params: {
|
|
584
|
+
resourceId: string;
|
|
585
|
+
limit?: number;
|
|
586
|
+
offset?: number;
|
|
587
|
+
search?: string;
|
|
588
|
+
}): Promise<{
|
|
589
|
+
items: Record<string, unknown>[];
|
|
590
|
+
page: {
|
|
591
|
+
limit: number;
|
|
592
|
+
offset: number;
|
|
593
|
+
hasMore: boolean;
|
|
594
|
+
prevOffset: number;
|
|
595
|
+
nextOffset: number;
|
|
596
|
+
total: number;
|
|
597
|
+
};
|
|
598
|
+
}>;
|
|
599
|
+
lookupMapping(params: {
|
|
600
|
+
resourceId: string;
|
|
601
|
+
connectValue: string | string[];
|
|
602
|
+
} | {
|
|
603
|
+
resourceId: string;
|
|
604
|
+
plugName: string;
|
|
605
|
+
ref: string;
|
|
606
|
+
}): Promise<Record<string, unknown> | null>;
|
|
607
|
+
upsertMapping(mapping: {
|
|
608
|
+
resourceId: string;
|
|
609
|
+
connectValue: string | string[];
|
|
610
|
+
refs: Record<string, string>;
|
|
611
|
+
metadata?: Record<string, unknown> | null;
|
|
612
|
+
}): Promise<Record<string, unknown>>;
|
|
613
|
+
updateMapping(id: string, mapping: {
|
|
614
|
+
resourceId: string;
|
|
615
|
+
connectValue: string | string[];
|
|
616
|
+
refs: Record<string, string>;
|
|
617
|
+
metadata?: Record<string, unknown> | null;
|
|
618
|
+
}): Promise<Record<string, unknown>>;
|
|
619
|
+
deleteMapping(id: string): Promise<void>;
|
|
620
|
+
getVars(plugName: string): Promise<Record<string, string>>;
|
|
621
|
+
setVars(plugName: string, vars: Record<string, string>): Promise<void>;
|
|
622
|
+
clearVars(plugName: string): Promise<void>;
|
|
623
|
+
hasVars(plugName: string): Promise<boolean>;
|
|
624
|
+
getVarFields(plugName: string): readonly VarField[];
|
|
625
|
+
getPlug(plugName: string): PlugRegistration["plug"];
|
|
626
|
+
}
|
|
627
|
+
declare function drizzleAdapter(db: PgDatabase<any, any, any>): KhotanAdapter;
|
|
628
|
+
type WorkflowStartFn = (workflowFn: (...args: any[]) => any, args: unknown[]) => Promise<unknown>;
|
|
629
|
+
interface WorkflowRunHandle {
|
|
630
|
+
runId?: string;
|
|
631
|
+
status?: Promise<string>;
|
|
632
|
+
returnValue?: Promise<unknown>;
|
|
633
|
+
cancel?: () => Promise<void>;
|
|
634
|
+
getReadable?: (options?: {
|
|
635
|
+
startIndex?: number;
|
|
636
|
+
namespace?: string;
|
|
637
|
+
}) => ReadableStream;
|
|
638
|
+
}
|
|
639
|
+
type WorkflowGetRunFn = (runId: string) => WorkflowRunHandle;
|
|
640
|
+
type WorkflowGetWritableFn = <T = unknown>(options?: {
|
|
641
|
+
namespace?: string;
|
|
642
|
+
}) => WritableStream<T>;
|
|
643
|
+
declare function __setWorkflowStartForTests(start: WorkflowStartFn | null): void;
|
|
644
|
+
declare function __setWorkflowGetRunForTests(getRun: WorkflowGetRunFn | null): void;
|
|
645
|
+
declare function __setWorkflowGetWritableForTests(getWritable: WorkflowGetWritableFn | null): void;
|
|
646
|
+
declare function sendUpdate(update: KhotanRunUpdate | string, options?: {
|
|
647
|
+
namespace?: string;
|
|
648
|
+
}): Promise<void>;
|
|
649
|
+
declare function khotan(config: KhotanConfig): KhotanInstance;
|
|
650
|
+
interface NextJsRequest extends Request {
|
|
651
|
+
nextUrl?: URL;
|
|
652
|
+
}
|
|
653
|
+
interface NextJsRouteHandlers {
|
|
654
|
+
GET: (req: NextJsRequest) => Promise<Response>;
|
|
655
|
+
POST: (req: NextJsRequest) => Promise<Response>;
|
|
656
|
+
PUT: (req: NextJsRequest) => Promise<Response>;
|
|
657
|
+
PATCH: (req: NextJsRequest) => Promise<Response>;
|
|
658
|
+
DELETE: (req: NextJsRequest) => Promise<Response>;
|
|
659
|
+
}
|
|
660
|
+
declare function toNextJsHandler(factoryHandler: KhotanHandler): NextJsRouteHandlers;
|
|
661
|
+
|
|
662
|
+
export { type BindablePlug, type BoundPlug, type CacheEntryRecord, type CacheInstance, type CacheRegistration, type CacheScope, type CatchRegistration, type CatchWorkflowContext, type FlowInstance, type FlowRegistration, type FlowRunContext, type FlowRunResult, type FlowSelectorOptions, type FlowStartOptions, type FlowType, type FlowWorkflowContext, type KhotanAdapter, type KhotanConfig, type KhotanHandler, type KhotanInstance, type KhotanRunStatus, type KhotanRunUpdate, type KhotanTerminalRunStatus, type PassRegistration, type PassWorkflowContext, type PlugRegistration, type ResourceConnectField, type ResourceMappingRegistration, type ResourcePlugParticipation, type ResourceRegistration, type VarField, type WebhookRegistration, type WireInstance, type WireRegistration, type WireSubscribeContext, type WireUnsubscribeContext, type WireVerifyContext, __setWorkflowGetRunForTests, __setWorkflowGetWritableForTests, __setWorkflowStartForTests, bindWorkflowPlug, drizzleAdapter, khotan, khotanCache, khotanMappings, sendUpdate, toNextJsHandler };
|