@flowcore/sdk 1.10.3 → 1.11.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/CHANGELOG.md +106 -83
- package/README.md +655 -18
- package/esm/_dnt.shims.d.ts +9 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +64 -0
- package/esm/common/notification-client.d.ts +80 -0
- package/esm/common/notification-client.d.ts.map +1 -0
- package/esm/common/notification-client.js +212 -0
- package/esm/mod.d.ts +1 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -0
- package/esm/utils/logger.d.ts +8 -0
- package/esm/utils/logger.d.ts.map +1 -0
- package/esm/utils/logger.js +14 -0
- package/package.json +7 -3
- package/script/_dnt.shims.d.ts +9 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +72 -0
- package/script/common/notification-client.d.ts +80 -0
- package/script/common/notification-client.d.ts.map +1 -0
- package/script/common/notification-client.js +239 -0
- package/script/mod.d.ts +1 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -0
- package/script/utils/logger.d.ts +8 -0
- package/script/utils/logger.d.ts.map +1 -0
- package/script/utils/logger.js +17 -0
package/README.md
CHANGED
|
@@ -2,52 +2,689 @@
|
|
|
2
2
|
|
|
3
3
|
This is the Flowcore SDK, a TypeScript library for interacting with the Flowcore API.
|
|
4
4
|
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Client Configuration](#client-configuration)
|
|
10
|
+
- [API Reference](#api-reference)
|
|
11
|
+
- [Tenant Operations](#tenant-operations)
|
|
12
|
+
- [API Key Management](#api-key-management)
|
|
13
|
+
- [Secret Operations](#secret-operations)
|
|
14
|
+
- [Variable Operations](#variable-operations)
|
|
15
|
+
- [Data Core Operations](#data-core-operations)
|
|
16
|
+
- [Flow Type Operations](#flow-type-operations)
|
|
17
|
+
- [Event Type Operations](#event-type-operations)
|
|
18
|
+
- [Notifications](#notifications)
|
|
19
|
+
|
|
5
20
|
## Installation
|
|
6
21
|
|
|
7
22
|
```bash
|
|
8
|
-
#
|
|
9
|
-
|
|
23
|
+
# Bun
|
|
24
|
+
bunx jsr add @flowcore/sdk
|
|
10
25
|
|
|
11
26
|
# Deno
|
|
12
27
|
deno add jsr:@flowcore/sdk
|
|
28
|
+
|
|
29
|
+
# npm / yarn
|
|
30
|
+
npx jsr add @flowcore/sdk
|
|
13
31
|
```
|
|
14
32
|
|
|
15
|
-
##
|
|
33
|
+
## Getting Started
|
|
16
34
|
|
|
17
|
-
###
|
|
35
|
+
### Client Configuration
|
|
36
|
+
|
|
37
|
+
The FlowcoreClient can be initialized in several ways:
|
|
18
38
|
|
|
19
39
|
```typescript
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
import { FlowcoreClient } from "@flowcore/sdk"
|
|
41
|
+
|
|
42
|
+
// 1. With a bearer token
|
|
43
|
+
const clientWithBearer = new FlowcoreClient({
|
|
23
44
|
getBearerToken: async (): Promise<string> => {
|
|
24
45
|
const token = await someMethodToGetToken()
|
|
25
46
|
return token
|
|
26
47
|
},
|
|
27
48
|
})
|
|
28
49
|
|
|
29
|
-
// With an
|
|
30
|
-
const
|
|
50
|
+
// 2. With an API key
|
|
51
|
+
const clientWithApiKey = new FlowcoreClient({
|
|
31
52
|
apiKeyId: "my-api-key-id",
|
|
32
53
|
apiKey: "my-api-key",
|
|
33
54
|
})
|
|
34
55
|
|
|
35
|
-
// With retry
|
|
36
|
-
|
|
37
|
-
// To disable retry set retry to null.
|
|
38
|
-
const client = new FlowcoreClient({
|
|
56
|
+
// 3. With retry configuration
|
|
57
|
+
const clientWithRetry = new FlowcoreClient({
|
|
39
58
|
apiKeyId: "my-api-key-id",
|
|
40
59
|
apiKey: "my-api-key",
|
|
41
60
|
retry: {
|
|
42
|
-
delay: 100,
|
|
43
|
-
maxRetries: 5,
|
|
61
|
+
delay: 100, // Delay in milliseconds between retries
|
|
62
|
+
maxRetries: 5, // Maximum number of retry attempts
|
|
44
63
|
},
|
|
45
64
|
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
> **Note**: When retry is not configured, it defaults to 250ms delay and 3 max retries. To disable retry, set `retry` to `null`.
|
|
68
|
+
|
|
69
|
+
## API Reference
|
|
70
|
+
|
|
71
|
+
### Tenant Operations
|
|
72
|
+
|
|
73
|
+
> **Important**: Tenant operations require bearer token authentication and cannot be performed using API key authentication.
|
|
74
|
+
|
|
75
|
+
#### Fetch a Tenant
|
|
76
|
+
|
|
77
|
+
You can fetch a Tenant either by ID or by name:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { TenantFetchCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
81
|
+
|
|
82
|
+
// Fetch by ID
|
|
83
|
+
const fetchById = new TenantFetchCommand({
|
|
84
|
+
tenantId: "your-tenant-id"
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// Fetch by name
|
|
88
|
+
const fetchByName = new TenantFetchCommand({
|
|
89
|
+
tenant: "your-tenant-name"
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const result = await client.execute(fetchById) // or fetchByName
|
|
93
|
+
// Returns a Tenant object:
|
|
94
|
+
// {
|
|
95
|
+
// id: string;
|
|
96
|
+
// name: string;
|
|
97
|
+
// displayName: string;
|
|
98
|
+
// description: string;
|
|
99
|
+
// website: string;
|
|
100
|
+
// }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### List Tenants
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { TenantListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
107
|
+
|
|
108
|
+
const command = new TenantListCommand({})
|
|
109
|
+
|
|
110
|
+
const tenants = await client.execute(command)
|
|
111
|
+
// Returns an array of TenantWithLinkType objects:
|
|
112
|
+
// {
|
|
113
|
+
// id: string;
|
|
114
|
+
// name: string;
|
|
115
|
+
// displayName: string;
|
|
116
|
+
// description: string;
|
|
117
|
+
// website: string;
|
|
118
|
+
// linkType: "OWNER" | "COLLABORATOR";
|
|
119
|
+
// }
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
> **Note**: The `linkType` field indicates your relationship with the tenant - either as an owner or collaborator.
|
|
123
|
+
|
|
124
|
+
### API Key Management
|
|
125
|
+
|
|
126
|
+
> **Important**: API key management operations require bearer token authentication and cannot be performed using API key authentication.
|
|
127
|
+
|
|
128
|
+
#### Create an API Key
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { ApiKeyCreateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
132
|
+
|
|
133
|
+
const command = new ApiKeyCreateCommand({
|
|
134
|
+
tenantId: "your-tenant-id",
|
|
135
|
+
name: "my-new-api-key"
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
const result = await client.execute(command)
|
|
139
|
+
// Result will contain:
|
|
140
|
+
// {
|
|
141
|
+
// id: string;
|
|
142
|
+
// name: string;
|
|
143
|
+
// createdAt: string;
|
|
144
|
+
// value: string; // The API key value - store this securely!
|
|
145
|
+
// }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
> **Important**: The API key value is only returned once during creation. Make sure to store it securely as you won't be able to retrieve it again.
|
|
149
|
+
|
|
150
|
+
#### List API Keys
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { ApiKeyListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
154
|
+
|
|
155
|
+
const command = new ApiKeyListCommand({
|
|
156
|
+
tenantId: "your-tenant-id"
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const apiKeys = await client.execute(command)
|
|
160
|
+
// Returns an array of:
|
|
161
|
+
// {
|
|
162
|
+
// id: string;
|
|
163
|
+
// name: string;
|
|
164
|
+
// createdAt: string;
|
|
165
|
+
// }
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Delete an API Key
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { ApiKeyDeleteCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
172
|
+
|
|
173
|
+
const command = new ApiKeyDeleteCommand({
|
|
174
|
+
tenantId: "your-tenant-id",
|
|
175
|
+
apiKeyId: "api-key-id-to-delete"
|
|
176
|
+
})
|
|
46
177
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
178
|
+
const result = await client.execute(command)
|
|
179
|
+
// Returns true if deletion was successful
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Secret Operations
|
|
183
|
+
|
|
184
|
+
> **Important**: Secret operations require bearer token authentication and cannot be performed using API key authentication.
|
|
185
|
+
|
|
186
|
+
#### Create a Secret
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { SecretCreateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
190
|
+
|
|
191
|
+
const command = new SecretCreateCommand({
|
|
192
|
+
tenantId: "your-tenant-id",
|
|
193
|
+
key: "MY_SECRET_KEY",
|
|
194
|
+
value: "my-secret-value"
|
|
50
195
|
})
|
|
51
196
|
|
|
52
197
|
const result = await client.execute(command)
|
|
198
|
+
// Returns: boolean indicating if creation was successful
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
> **Important**: Secret values should be handled securely and never logged or exposed in your application.
|
|
202
|
+
|
|
203
|
+
#### List Secrets
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { SecretListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
207
|
+
|
|
208
|
+
const command = new SecretListCommand({
|
|
209
|
+
tenantId: "your-tenant-id"
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
const secrets = await client.execute(command)
|
|
213
|
+
// Returns an array of secret keys (not values):
|
|
214
|
+
// string[]
|
|
53
215
|
```
|
|
216
|
+
|
|
217
|
+
> **Note**: For security reasons, the list operation only returns the secret keys, not their values.
|
|
218
|
+
|
|
219
|
+
#### Delete a Secret
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { SecretDeleteCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
223
|
+
|
|
224
|
+
const command = new SecretDeleteCommand({
|
|
225
|
+
tenantId: "your-tenant-id",
|
|
226
|
+
key: "MY_SECRET_KEY"
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
const result = await client.execute(command)
|
|
230
|
+
// Returns: boolean indicating if deletion was successful
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
> **Important**: Deleting a secret is irreversible. Make sure you have a backup if needed.
|
|
234
|
+
|
|
235
|
+
### Variable Operations
|
|
236
|
+
|
|
237
|
+
> **Important**: Variable operations require bearer token authentication and cannot be performed using API key authentication.
|
|
238
|
+
|
|
239
|
+
#### Create a Variable
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { VariableCreateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
243
|
+
|
|
244
|
+
const command = new VariableCreateCommand({
|
|
245
|
+
tenantId: "your-tenant-id",
|
|
246
|
+
key: "MY_VARIABLE_KEY",
|
|
247
|
+
value: "my-variable-value"
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const result = await client.execute(command)
|
|
251
|
+
// Returns the created Variable:
|
|
252
|
+
// {
|
|
253
|
+
// key: string;
|
|
254
|
+
// value: string;
|
|
255
|
+
// }
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### List Variables
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
import { VariableListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
262
|
+
|
|
263
|
+
const command = new VariableListCommand({
|
|
264
|
+
tenantId: "your-tenant-id"
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
const variables = await client.execute(command)
|
|
268
|
+
// Returns an array of Variables:
|
|
269
|
+
// {
|
|
270
|
+
// key: string;
|
|
271
|
+
// value: string;
|
|
272
|
+
// }[]
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Delete a Variable
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import { VariableDeleteCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
279
|
+
|
|
280
|
+
const command = new VariableDeleteCommand({
|
|
281
|
+
tenantId: "your-tenant-id",
|
|
282
|
+
key: "MY_VARIABLE_KEY"
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
const result = await client.execute(command)
|
|
286
|
+
// Returns: boolean indicating if deletion was successful
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
> **Important**: Deleting a variable is irreversible. Make sure you have a backup if needed.
|
|
290
|
+
|
|
291
|
+
### Data Core Operations
|
|
292
|
+
|
|
293
|
+
#### Create a Data Core
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
import { DataCoreCreateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
297
|
+
|
|
298
|
+
const command = new DataCoreCreateCommand({
|
|
299
|
+
tenantId: "your-tenant-id",
|
|
300
|
+
name: "my-data-core",
|
|
301
|
+
description: "My awesome data core",
|
|
302
|
+
accessControl: "private",
|
|
303
|
+
deleteProtection: true
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
const result = await client.execute(command)
|
|
307
|
+
// Returns the created DataCore object:
|
|
308
|
+
// {
|
|
309
|
+
// id: string;
|
|
310
|
+
// name: string;
|
|
311
|
+
// description: string;
|
|
312
|
+
// accessControl: "public" | "private";
|
|
313
|
+
// deleteProtection: boolean;
|
|
314
|
+
// createdAt: string;
|
|
315
|
+
// updatedAt: string;
|
|
316
|
+
// }
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### Fetch a Data Core
|
|
320
|
+
|
|
321
|
+
You can fetch a Data Core either by ID or by name:
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import { DataCoreFetchCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
325
|
+
|
|
326
|
+
// Fetch by ID
|
|
327
|
+
const fetchById = new DataCoreFetchCommand({
|
|
328
|
+
dataCoreId: "your-data-core-id"
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
// Fetch by name
|
|
332
|
+
const fetchByName = new DataCoreFetchCommand({
|
|
333
|
+
tenantId: "your-tenant-id",
|
|
334
|
+
dataCore: "your-data-core-name"
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
const result = await client.execute(fetchById) // or fetchByName
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
#### List Data Cores
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
import { DataCoreListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
344
|
+
|
|
345
|
+
const command = new DataCoreListCommand({
|
|
346
|
+
tenantId: "your-tenant-id", // Optional: Filter by tenant ID
|
|
347
|
+
tenant: "tenant-name" // Optional: Filter by tenant name
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
const dataCores = await client.execute(command)
|
|
351
|
+
// Returns an array of DataCore objects
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
#### Update a Data Core
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
import { DataCoreUpdateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
358
|
+
|
|
359
|
+
const command = new DataCoreUpdateCommand({
|
|
360
|
+
dataCoreId: "your-data-core-id",
|
|
361
|
+
description: "Updated description", // Optional
|
|
362
|
+
accessControl: "public", // Optional
|
|
363
|
+
deleteProtection: false // Optional
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
const updatedDataCore = await client.execute(command)
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### Check if a Data Core Exists
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { DataCoreExistsCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
373
|
+
|
|
374
|
+
const command = new DataCoreExistsCommand({
|
|
375
|
+
dataCoreId: "your-data-core-id"
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
const result = await client.execute(command)
|
|
379
|
+
// Returns: { exists: boolean }
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
#### Delete a Data Core
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
import { DataCoreDeleteRequestCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
386
|
+
|
|
387
|
+
const command = new DataCoreDeleteRequestCommand({
|
|
388
|
+
dataCoreId: "your-data-core-id",
|
|
389
|
+
waitForDelete: true // Optional: Wait for deletion to complete (default: true)
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
const result = await client.execute(command)
|
|
393
|
+
// Returns: boolean indicating if deletion was successful
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
> **Note**: If `waitForDelete` is set to `true`, the command will wait up to 25 seconds for the deletion to complete.
|
|
397
|
+
|
|
398
|
+
### Flow Type Operations
|
|
399
|
+
|
|
400
|
+
#### Create a Flow Type
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
import { FlowTypeCreateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
404
|
+
|
|
405
|
+
const command = new FlowTypeCreateCommand({
|
|
406
|
+
dataCoreId: "your-data-core-id",
|
|
407
|
+
name: "my-flow-type",
|
|
408
|
+
description: "My awesome flow type"
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
const result = await client.execute(command)
|
|
412
|
+
// Returns the created FlowType object:
|
|
413
|
+
// {
|
|
414
|
+
// id: string;
|
|
415
|
+
// name: string;
|
|
416
|
+
// description: string;
|
|
417
|
+
// dataCoreId: string;
|
|
418
|
+
// createdAt: string;
|
|
419
|
+
// updatedAt: string;
|
|
420
|
+
// }
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
#### Fetch a Flow Type
|
|
424
|
+
|
|
425
|
+
You can fetch a Flow Type either by ID or by name:
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
import { FlowTypeFetchCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
429
|
+
|
|
430
|
+
// Fetch by ID
|
|
431
|
+
const fetchById = new FlowTypeFetchCommand({
|
|
432
|
+
flowTypeId: "your-flow-type-id"
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
// Fetch by name
|
|
436
|
+
const fetchByName = new FlowTypeFetchCommand({
|
|
437
|
+
dataCoreId: "your-data-core-id",
|
|
438
|
+
flowType: "your-flow-type-name"
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
const result = await client.execute(fetchById) // or fetchByName
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### List Flow Types
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
import { FlowTypeListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
448
|
+
|
|
449
|
+
const command = new FlowTypeListCommand({
|
|
450
|
+
dataCoreId: "your-data-core-id"
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
const flowTypes = await client.execute(command)
|
|
454
|
+
// Returns an array of FlowType objects
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
#### Update a Flow Type
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import { FlowTypeUpdateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
461
|
+
|
|
462
|
+
const command = new FlowTypeUpdateCommand({
|
|
463
|
+
flowTypeId: "your-flow-type-id",
|
|
464
|
+
description: "Updated description" // Optional
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
const updatedFlowType = await client.execute(command)
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
#### Check if a Flow Type Exists
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
import { FlowTypeExistsCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
474
|
+
|
|
475
|
+
const command = new FlowTypeExistsCommand({
|
|
476
|
+
flowTypeId: "your-flow-type-id"
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
const result = await client.execute(command)
|
|
480
|
+
// Returns: { exists: boolean }
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
#### Delete a Flow Type
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
import { FlowTypeDeleteRequestCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
487
|
+
|
|
488
|
+
const command = new FlowTypeDeleteRequestCommand({
|
|
489
|
+
flowTypeId: "your-flow-type-id",
|
|
490
|
+
waitForDelete: true // Optional: Wait for deletion to complete (default: true)
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
const result = await client.execute(command)
|
|
494
|
+
// Returns: boolean indicating if deletion was successful
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
> **Note**: If `waitForDelete` is set to `true`, the command will wait up to 25 seconds for the deletion to complete.
|
|
498
|
+
> **Important**: Flow Type deletion operations require bearer token authentication.
|
|
499
|
+
|
|
500
|
+
### Event Type Operations
|
|
501
|
+
|
|
502
|
+
#### Create an Event Type
|
|
503
|
+
|
|
504
|
+
```typescript
|
|
505
|
+
import { EventTypeCreateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
506
|
+
|
|
507
|
+
const command = new EventTypeCreateCommand({
|
|
508
|
+
flowTypeId: "your-flow-type-id",
|
|
509
|
+
name: "my-event-type",
|
|
510
|
+
description: "My awesome event type"
|
|
511
|
+
})
|
|
512
|
+
|
|
513
|
+
const result = await client.execute(command)
|
|
514
|
+
// Returns the created EventType object:
|
|
515
|
+
// {
|
|
516
|
+
// id: string;
|
|
517
|
+
// name: string;
|
|
518
|
+
// description: string;
|
|
519
|
+
// flowTypeId: string;
|
|
520
|
+
// createdAt: string;
|
|
521
|
+
// updatedAt: string;
|
|
522
|
+
// }
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
#### Fetch an Event Type
|
|
526
|
+
|
|
527
|
+
You can fetch an Event Type either by ID or by name:
|
|
528
|
+
|
|
529
|
+
```typescript
|
|
530
|
+
import { EventTypeFetchCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
531
|
+
|
|
532
|
+
// Fetch by ID
|
|
533
|
+
const fetchById = new EventTypeFetchCommand({
|
|
534
|
+
eventTypeId: "your-event-type-id"
|
|
535
|
+
})
|
|
536
|
+
|
|
537
|
+
// Fetch by name
|
|
538
|
+
const fetchByName = new EventTypeFetchCommand({
|
|
539
|
+
flowTypeId: "your-flow-type-id",
|
|
540
|
+
eventType: "your-event-type-name"
|
|
541
|
+
})
|
|
542
|
+
|
|
543
|
+
const result = await client.execute(fetchById) // or fetchByName
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### List Event Types
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
import { EventTypeListCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
550
|
+
|
|
551
|
+
const command = new EventTypeListCommand({
|
|
552
|
+
flowTypeId: "your-flow-type-id"
|
|
553
|
+
})
|
|
554
|
+
|
|
555
|
+
const eventTypes = await client.execute(command)
|
|
556
|
+
// Returns an array of EventType objects
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
#### Update an Event Type
|
|
560
|
+
|
|
561
|
+
```typescript
|
|
562
|
+
import { EventTypeUpdateCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
563
|
+
|
|
564
|
+
const command = new EventTypeUpdateCommand({
|
|
565
|
+
eventTypeId: "your-event-type-id",
|
|
566
|
+
description: "Updated description" // Optional
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
const updatedEventType = await client.execute(command)
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
#### Check if an Event Type Exists
|
|
573
|
+
|
|
574
|
+
```typescript
|
|
575
|
+
import { EventTypeExistsCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
576
|
+
|
|
577
|
+
const command = new EventTypeExistsCommand({
|
|
578
|
+
eventTypeId: "your-event-type-id"
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
const result = await client.execute(command)
|
|
582
|
+
// Returns: { exists: boolean }
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
#### Delete an Event Type
|
|
586
|
+
|
|
587
|
+
```typescript
|
|
588
|
+
import { EventTypeDeleteRequestCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
589
|
+
|
|
590
|
+
const command = new EventTypeDeleteRequestCommand({
|
|
591
|
+
eventTypeId: "your-event-type-id",
|
|
592
|
+
waitForDelete: true // Optional: Wait for deletion to complete (default: true)
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
const result = await client.execute(command)
|
|
596
|
+
// Returns: boolean indicating if deletion was successful
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
#### Truncate an Event Type
|
|
600
|
+
|
|
601
|
+
```typescript
|
|
602
|
+
import { EventTypeTruncateRequestCommand, FlowcoreClient } from "@flowcore/sdk"
|
|
603
|
+
|
|
604
|
+
const command = new EventTypeTruncateRequestCommand({
|
|
605
|
+
eventTypeId: "your-event-type-id",
|
|
606
|
+
waitForTruncate: true // Optional: Wait for truncation to complete (default: true)
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
const result = await client.execute(command)
|
|
610
|
+
// Returns: boolean indicating if truncation was successful
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
> **Note**: If `waitForDelete` or `waitForTruncate` is set to `true`, the command will wait up to 25 seconds for the operation to complete.
|
|
614
|
+
> **Important**: Event Type deletion and truncation operations require bearer token authentication.
|
|
615
|
+
|
|
616
|
+
### Notifications
|
|
617
|
+
|
|
618
|
+
The NotificationClient allows you to receive real-time notifications when events are ingested into an event type. The notifications follow the hierarchical structure: Data Core → Flow Type → Event Type.
|
|
619
|
+
|
|
620
|
+
#### Setting up Notifications
|
|
621
|
+
|
|
622
|
+
```typescript
|
|
623
|
+
import { NotificationClient, type NotificationEvent } from "@flowcore/sdk"
|
|
624
|
+
import { Subject } from "rxjs"
|
|
625
|
+
|
|
626
|
+
// Create an RxJS Subject to handle the notifications
|
|
627
|
+
const subject = new Subject<NotificationEvent>()
|
|
628
|
+
|
|
629
|
+
// Subscribe to handle notifications
|
|
630
|
+
subject.subscribe({
|
|
631
|
+
next: (event) => {
|
|
632
|
+
console.log("Received event:", event)
|
|
633
|
+
// event.data contains:
|
|
634
|
+
// {
|
|
635
|
+
// tenant: string; // Tenant ID
|
|
636
|
+
// eventId: string; // Unique event ID
|
|
637
|
+
// dataCoreId: string; // Data Core ID
|
|
638
|
+
// flowType: string; // Flow Type name
|
|
639
|
+
// eventType: string; // Event Type name
|
|
640
|
+
// validTime: string; // Timestamp
|
|
641
|
+
// }
|
|
642
|
+
},
|
|
643
|
+
error: (error) => console.error("Error:", error),
|
|
644
|
+
complete: () => console.log("Notification stream completed")
|
|
645
|
+
})
|
|
646
|
+
|
|
647
|
+
// Create the notification client
|
|
648
|
+
const client = new NotificationClient(
|
|
649
|
+
subject,
|
|
650
|
+
oidcClient, // Your OIDC client for authentication
|
|
651
|
+
{
|
|
652
|
+
tenant: "your-tenant-name",
|
|
653
|
+
dataCore: "your-data-core-name",
|
|
654
|
+
flowType: "your-flow-type-name", // Optional: Subscribe to specific flow type
|
|
655
|
+
eventType: "your-event-type-name" // Optional: Subscribe to specific event type
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
reconnectInterval: 1000, // Optional: Milliseconds between reconnection attempts
|
|
659
|
+
maxReconnects: 5, // Optional: Maximum number of reconnection attempts
|
|
660
|
+
maxEvents: 1000, // Optional: Maximum number of events to receive
|
|
661
|
+
logger: customLogger // Optional: Custom logger implementation
|
|
662
|
+
}
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
// Connect to start receiving notifications
|
|
666
|
+
await client.connect()
|
|
667
|
+
|
|
668
|
+
// Disconnect when done
|
|
669
|
+
client.disconnect()
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
> **Note**: The NotificationClient uses WebSocket connections to receive real-time updates.
|
|
673
|
+
|
|
674
|
+
#### Configuration Options
|
|
675
|
+
|
|
676
|
+
- **reconnectInterval**: Time in milliseconds between reconnection attempts (default: 1000)
|
|
677
|
+
- **maxReconnects**: Maximum number of reconnection attempts (optional)
|
|
678
|
+
- **maxEvents**: Maximum number of events to receive before auto-disconnecting (optional)
|
|
679
|
+
- **logger**: Custom logger implementation (optional)
|
|
680
|
+
|
|
681
|
+
#### Subscription Specification
|
|
682
|
+
|
|
683
|
+
You can narrow down your notification subscription by specifying:
|
|
684
|
+
|
|
685
|
+
- **tenant**: Required - The tenant name
|
|
686
|
+
- **dataCore**: Required - The data core name
|
|
687
|
+
- **flowType**: Optional - Specific flow type to monitor
|
|
688
|
+
- **eventType**: Optional - Specific event type to monitor (requires flowType to be specified)
|
|
689
|
+
|
|
690
|
+
> **Important**: The NotificationClient requires OIDC authentication. Make sure your OIDC client implements the required `getToken()` method that returns a Promise with an `accessToken`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
import { default as WebSocket } from "ws";
|
|
4
|
+
export { default as WebSocket } from "ws";
|
|
5
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno" | "WebSocket"> & {
|
|
6
|
+
Deno: typeof Deno;
|
|
7
|
+
WebSocket: typeof WebSocket;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=_dnt.shims.d.ts.map
|