cliodot 0.1.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.
Files changed (89) hide show
  1. package/README.md +509 -0
  2. package/dist/ConnectorBuilder.d.ts +68 -0
  3. package/dist/ConnectorBuilder.d.ts.map +1 -0
  4. package/dist/ConnectorBuilder.js +1 -0
  5. package/dist/Flosync.d.ts +67 -0
  6. package/dist/Flosync.d.ts.map +1 -0
  7. package/dist/Flosync.js +1 -0
  8. package/dist/FlosyncClient.d.ts +23 -0
  9. package/dist/FlosyncClient.d.ts.map +1 -0
  10. package/dist/FlosyncClient.js +1 -0
  11. package/dist/FunctionBuilder.d.ts +20 -0
  12. package/dist/FunctionBuilder.d.ts.map +1 -0
  13. package/dist/FunctionBuilder.js +1 -0
  14. package/dist/ValidatorBuilder.d.ts +12 -0
  15. package/dist/ValidatorBuilder.d.ts.map +1 -0
  16. package/dist/ValidatorBuilder.js +1 -0
  17. package/dist/WorkflowBuilder.d.ts +61 -0
  18. package/dist/WorkflowBuilder.d.ts.map +1 -0
  19. package/dist/WorkflowBuilder.js +1 -0
  20. package/dist/__tests__/function.test.d.ts +2 -0
  21. package/dist/__tests__/function.test.d.ts.map +1 -0
  22. package/dist/__tests__/function.test.js +1 -0
  23. package/dist/__tests__/runner.test.d.ts +2 -0
  24. package/dist/__tests__/runner.test.d.ts.map +1 -0
  25. package/dist/__tests__/runner.test.js +1 -0
  26. package/dist/connectors/builtin.d.ts +308 -0
  27. package/dist/connectors/builtin.d.ts.map +1 -0
  28. package/dist/connectors/builtin.js +1 -0
  29. package/dist/connectors/registry.d.ts +69 -0
  30. package/dist/connectors/registry.d.ts.map +1 -0
  31. package/dist/connectors/registry.js +1 -0
  32. package/dist/errors.d.ts +11 -0
  33. package/dist/errors.d.ts.map +1 -0
  34. package/dist/errors.js +1 -0
  35. package/dist/index.d.ts +21 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/runner/ProcessorEngine.d.ts +49 -0
  39. package/dist/runner/ProcessorEngine.d.ts.map +1 -0
  40. package/dist/runner/ProcessorEngine.js +1 -0
  41. package/dist/runner/connector.executor.d.ts +5 -0
  42. package/dist/runner/connector.executor.d.ts.map +1 -0
  43. package/dist/runner/connector.executor.js +1 -0
  44. package/dist/runner/utilities/math.executor.d.ts +2 -0
  45. package/dist/runner/utilities/math.executor.d.ts.map +1 -0
  46. package/dist/runner/utilities/math.executor.js +1 -0
  47. package/dist/runner/utilities/random.executor.d.ts +2 -0
  48. package/dist/runner/utilities/random.executor.d.ts.map +1 -0
  49. package/dist/runner/utilities/random.executor.js +1 -0
  50. package/dist/runner/utilities/string.executor.d.ts +2 -0
  51. package/dist/runner/utilities/string.executor.d.ts.map +1 -0
  52. package/dist/runner/utilities/string.executor.js +1 -0
  53. package/dist/template.d.ts +3 -0
  54. package/dist/template.d.ts.map +1 -0
  55. package/dist/template.js +1 -0
  56. package/dist/transformers/StepsToNodesTransformer.d.ts +41 -0
  57. package/dist/transformers/StepsToNodesTransformer.d.ts.map +1 -0
  58. package/dist/transformers/StepsToNodesTransformer.js +1 -0
  59. package/dist/transformers/WorkflowTransformer.d.ts +26 -0
  60. package/dist/transformers/WorkflowTransformer.d.ts.map +1 -0
  61. package/dist/transformers/WorkflowTransformer.js +1 -0
  62. package/dist/types/builtin.d.ts +12 -0
  63. package/dist/types/builtin.d.ts.map +1 -0
  64. package/dist/types/builtin.js +1 -0
  65. package/dist/types/client.api.d.ts +110 -0
  66. package/dist/types/client.api.d.ts.map +1 -0
  67. package/dist/types/client.api.js +1 -0
  68. package/dist/types/connector.d.ts +57 -0
  69. package/dist/types/connector.d.ts.map +1 -0
  70. package/dist/types/connector.js +1 -0
  71. package/dist/types/function.d.ts +66 -0
  72. package/dist/types/function.d.ts.map +1 -0
  73. package/dist/types/function.js +1 -0
  74. package/dist/types/index.d.ts +7 -0
  75. package/dist/types/index.d.ts.map +1 -0
  76. package/dist/types/index.js +1 -0
  77. package/dist/types/validator.d.ts +24 -0
  78. package/dist/types/validator.d.ts.map +1 -0
  79. package/dist/types/validator.js +1 -0
  80. package/dist/types/workflow.d.ts +195 -0
  81. package/dist/types/workflow.d.ts.map +1 -0
  82. package/dist/types/workflow.js +1 -0
  83. package/dist/validators/validators.d.ts +14 -0
  84. package/dist/validators/validators.d.ts.map +1 -0
  85. package/dist/validators/validators.js +1 -0
  86. package/dist/variable.d.ts +27 -0
  87. package/dist/variable.d.ts.map +1 -0
  88. package/dist/variable.js +1 -0
  89. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,509 @@
1
+ # @cliodot/flosync
2
+
3
+ SDK for building workflows, APIs, and functions with Cliodot Flowsync. Define workflows and functions in code, run them locally, and optionally sync with your Flowsync account.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @cliodot/flosync
9
+ ```
10
+
11
+ Optional peer dependencies:
12
+
13
+ ```bash
14
+ npm install mongodb mysql2
15
+ ```
16
+
17
+ For PostgreSQL and Redis:
18
+
19
+ ```bash
20
+ npm install pg ioredis
21
+ ```
22
+
23
+ For password hashing (Argon2, bcrypt):
24
+
25
+ ```bash
26
+ npm install argon2 bcrypt
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```javascript
32
+ const { flosync, variable: v } = require('@cliodot/flosync');
33
+
34
+ flosync.configure({
35
+ connectors: {
36
+ 'mongodb.system': { uri: process.env.MONGO_URI, database: 'myapp' },
37
+ },
38
+ });
39
+
40
+ const w = flosync.workflow('create-order')
41
+ .http('POST', '/orders')
42
+ .step('save', s => s.db('mongodb', 'insertOne', { collection: 'orders', document: v.body() }))
43
+ .step('respond', s => s.responder('json', { body: v.stepResult('save') }))
44
+ .build();
45
+
46
+ flosync.register(w);
47
+
48
+ const result = await flosync.run('create-order', { body: { item: 'Widget', qty: 2 } });
49
+ ```
50
+
51
+ ### Run Payload
52
+
53
+ Pass a `body` (or plain object) as the trigger; the engine treats it as `trigger.body` and `trigger.data`. You can also pass:
54
+
55
+ | Field | Description |
56
+ |-------|-------------|
57
+ | `body` / `data` | Request body; use `v.body('account')`, `v.body('email')` |
58
+ | `headers` | HTTP headers (`v.header('x-api-key')`) |
59
+ | `pathParams` | Route params (`v.pathParam('id')`) |
60
+ | `params` | Extra params (`v.param('page')`) |
61
+ | `query` | Query string params (`v.query('filter')`) |
62
+ | `vars` | Override workflow vars (`v.vars('apiKey')`) |
63
+ | `envVars` / `env` | Environment overrides (`v.env('MONGO_URI')`) |
64
+
65
+ ```javascript
66
+ flosync.run('my-workflow', { body: { id: 1 } });
67
+ flosync.run('my-workflow', { body: { id: 1 }, headers: { 'x-request-id': 'abc' }, pathParams: { id: '123' }, query: { page: 1 } });
68
+ ```
69
+
70
+ ## Configuration
71
+
72
+ ```javascript
73
+ flosync.configure({
74
+ apiKey: process.env.FLOSYNC_API_KEY,
75
+ apiSecret: process.env.FLOSYNC_API_SECRET,
76
+ baseUrl: 'http://localhost:8080',
77
+ projectId: process.env.FLOSYNC_PROJECT_ID,
78
+ connectors: {
79
+ 'mongodb.system': { uri: process.env.MONGO_URI, database: 'myapp' },
80
+ 'mysql.system': { uri: process.env.MYSQL_URI },
81
+ 'postgres.system': { uri: process.env.PG_URI, database: 'myapp' },
82
+ 'redis.system': { url: process.env.REDIS_URL },
83
+ 'cliodot': { apiKey: process.env.CLIODOT_API_KEY },
84
+ },
85
+ cliodot: { baseUrl: 'https://api.example.com', apiKey: process.env.CLIODOT_API_KEY },
86
+ });
87
+ ```
88
+
89
+ `baseUrl` defaults to `http://localhost:8080` when omitted. For remote runs (workflows, functions, connectors), only `apiKey` and `apiSecret` are required. Set `CLIODOT_BASE_URL` (or `baseUrl`) to match your main Cliodot API server port.
90
+
91
+ ## Workflows
92
+
93
+ ### Triggers (optional)
94
+
95
+ Triggers are optional. If you wrap workflows in your own HTTP handler, omit `.http()` and call `flosync.run()` with your payload.
96
+
97
+ | Method | Description |
98
+ |--------|-------------|
99
+ | `.http(method, path)` | HTTP trigger (e.g. `POST /orders`) |
100
+ | `.job(cron?, timezone?)` | Job/cron trigger (e.g. `'0 * * * *'`, `'UTC'`) |
101
+ | `.schedule(cron, timezone?)` | Alias for scheduled jobs |
102
+ | `.webhook(method, path)` | Alias for `.http()` |
103
+
104
+ ```javascript
105
+ flosync.workflow('api-order').http('POST', '/orders').step(...).build();
106
+ flosync.workflow('daily-job').job('0 0 * * *', 'UTC').step(...).build();
107
+ flosync.workflow('manual').step(...).build();
108
+ ```
109
+
110
+ ### Variable references
111
+
112
+ Use `variable` (or `v`) instead of typing `{{ }}`:
113
+
114
+ | Method | Example | Resolves to |
115
+ |--------|---------|-------------|
116
+ | `v.body(...path)` | `v.body('amount')`, `v.body('user', 'email')` | `{{ body.amount }}`, `{{ body.user.email }}` |
117
+ | `v.trigger(...path)` | `v.trigger('email')` | `{{ trigger.email }}` |
118
+ | `v.stepResult(stepId, ...path)` | `v.stepResult('charge', 'id')` | `{{ stepResults.charge.id }}` |
119
+ | `v.header(key)` | `v.header('x-api-key')` | `{{ headers["x-api-key"] }}` |
120
+ | `v.param(key)` | `v.param('page')` | `{{ params["page"] }}` |
121
+ | `v.pathParam(key)` | `v.pathParam('id')` | `{{ pathParams["id"] }}` |
122
+ | `v.query(key)` | `v.query('filter')` | `{{ query["filter"] }}` |
123
+ | `v.vars(key)` | `v.vars('apiKey')` | `{{ vars["apiKey"] }}` |
124
+ | `v.env(key)` | `v.env('MONGO_URI')` | `{{ env["MONGO_URI"] }}` |
125
+ | `v.args(...path)` | `v.args('amount')` | `{{ args.amount }}` |
126
+ | `v.expr(expression)` | `v.expr('length(body.items) * 10')` | `{{ length(body.items) * 10 }}` |
127
+
128
+ ```javascript
129
+ const { flosync, variable: v } = require('@cliodot/flosync');
130
+
131
+ s.validator({ amount: v.body('amount'), email: v.body('email') });
132
+ s.transform({ total: v.stepResult('calculate', 'total'), id: v.stepResult('charge', 'id') });
133
+ ```
134
+
135
+ ### Step Types
136
+
137
+ - `connector(id, action, config)` - REST/API call
138
+ - `db(engine, action, config)` - MongoDB, MySQL, PostgreSQL, or Redis
139
+ - `validator(fields)` - Validate input
140
+ - `condition(expr)` - Branch on expression (use `.then()` and `.else()`)
141
+ - `transform(mapping)` - Map or transform data
142
+ - `call(slug, args)` - Invoke a function
143
+ - `auth(connectorId, action, config)` - Authentication
144
+ - `util(connectorId, action, config)` - Utility (see [Utilities](#utilities))
145
+ - `encrypt(connectorId, action, config)` - Encryption (see [Encryption](#encryption))
146
+ - `responder(type, config)` - Return response (json, http, raw, redirect, empty)
147
+ - `log(message)` - Log message
148
+ - `delay(ms)` - Delay execution
149
+
150
+ ### Branching
151
+
152
+ Steps that can succeed or fail support `.then()` and `.else()`:
153
+
154
+ ```javascript
155
+ .step('validate', s => s.validator({ amount: '{{ trigger.body.amount }}' })
156
+ .then('process')
157
+ .else('error'))
158
+ .step('check', s => s.condition('{{ stepResults.validate.amount > 0 }}')
159
+ .then('create')
160
+ .else('invalid'))
161
+ ```
162
+
163
+ ## Functions
164
+
165
+ ```javascript
166
+ const validatePayment = flosync.function('validate-payment')
167
+ .input({ amount: 'number', currency: 'string' })
168
+ .step('validate', s => s.validator({ amount: '{{ args.amount }}', currency: '{{ args.currency }}' }))
169
+ .step('format', s => s.transform({ valid: '{{ stepResults.validate.valid }}', amount: '{{ args.amount }}' }))
170
+ .outputFrom('format')
171
+ .build();
172
+
173
+ flosync.registerFunction(validatePayment);
174
+
175
+ const result = await flosync.runFunction('validate-payment', { amount: 100, currency: 'USD' });
176
+ ```
177
+
178
+ ## Run by ID (remote)
179
+
180
+ When configured with `apiKey`, `apiSecret`, and `baseUrl`, you can run workflows and functions by ID without registering them locally. They are assumed to exist on your account.
181
+
182
+ ```javascript
183
+ flosync.configure({ apiKey, apiSecret });
184
+
185
+ await flosync.run('workflow-id-from-account', { body: { amount: 100 } });
186
+ await flosync.runById('workflow-id', { body: { ... } }, { triggerId: 'trigger' });
187
+ await flosync.runByWebhook('/orders', 'POST', { body: { ... } });
188
+
189
+ await flosync.runFunction('function-id-from-account', { amount: 100 });
190
+ await flosync.runFunctionById('function-id', { amount: 100 });
191
+ ```
192
+
193
+ If a workflow/function is registered locally, `run` / `runFunction` use the local version. If not found and the client is configured, they run remotely. Pass `{ remote: false }` to disable remote fallback.
194
+
195
+ ## Database
196
+
197
+ Use `s.db(engine, action, config)` or `s.connector(connectorId, action, config)` with built-in database connectors.
198
+
199
+ | Connector | Engine | Actions |
200
+ |-----------|--------|---------|
201
+ | `mongodb.system` | mongodb | insertOne, insertMany, findOne, find, updateOne, deleteOne |
202
+ | `mysql.system` | mysql | query |
203
+ | `postgres.system` | postgres | query |
204
+ | `redis.system` | redis | redis.get, redis.set, redis.delete, redis.hset, redis.hget, redis.lpush, redis.lpop, redis.zadd, redis.create_hash, redis.delete_key |
205
+
206
+ ```javascript
207
+ s.db('mongodb', 'insertOne', { collection: 'orders', document: v.body() });
208
+ s.db('mysql', 'query', { query: 'SELECT * FROM users WHERE id = ?', params: [v.body('id')] });
209
+ s.db('postgres', 'query', { query: 'SELECT * FROM users', params: [] });
210
+ s.db('redis', 'redis.set', { key: 'cache:user:1', value: v.stepResult('fetch'), ttl: 3600 });
211
+ ```
212
+
213
+ Configure in `flosync.configure({ connectors: { 'postgres.system': { uri, database }, 'redis.system': { url } } })`.
214
+
215
+ ## Utilities
216
+
217
+ Use `s.util(connectorId, action, config)` with built-in utility connectors. Use `ConnectorId.Utility` and `ConnectorActions` or `getConnectorActions(connectorId)` for autocomplete and suggestions.
218
+
219
+ | Connector | Actions |
220
+ |-----------|---------|
221
+ | `utility.date_time` | get_current_date, get_current_time, get_current_datetime, format, format_date, parse_date, add_time, subtract_time, diff_between_dates, start_of_day, end_of_day, start_of_week, end_of_week, start_of_month, end_of_month, start_of_year, end_of_year, convert_timezone, get_timezone, list_timezones, is_leap_year, get_unix_timestamp, from_unix_timestamp |
222
+ | `utility.string` | concat, split, join, replace, replace_all, trim, trim_start, trim_end, to_uppercase, to_lowercase, capitalize, substring, length, contains, starts_with, ends_with, remove_whitespace, slugify, pad_start, pad_end, reverse, encode_base64, decode_base64, encode_uri, decode_uri, after, after_last, before, before_last, between, between_first, camel, char_at, chop_start, chop_end, contains_all, doesnt_contain, doesnt_start_with, doesnt_end_with, deduplicate, excerpt, finish, start, headline, is, is_ascii, is_json, is_ulid, is_url, is_uuid, is_empty, is_match, kebab, snake, studly, title, lcfirst, ucfirst, ucwords, ucsplit, limit, mask, match, match_all, pad_both, plural, singular, position, random, remove, repeat, replace_array, replace_first, replace_last, replace_matches, replace_start, replace_end, squish, substr, substr_count, substr_replace, swap, take, word_count, word_wrap, words, wrap, unwrap, uuid, ulid, strip_tags, ascii, apa, class_basename |
223
+ | `utility.math` | add, subtract, multiply, divide, modulo, power, round, floor, ceil, abs, min, max, average, sum, clamp, random_between, percentage, percentage_of, sqrt, log |
224
+ | `utility.random` | random_int, random_float, random_string, random_uuid, uuid, random_boolean, random_choice, random_password, random_hex, random_alphanumeric, random_date, random_color, shuffle_array |
225
+ | `utility.compare` | diff_objects, diff_arrays, compare_strings, compare_numbers, compare_dates, is_changed, is_equal, is_not_equal, is_greater_than, is_less_than, is_between, is_empty, is_null_or_undefined, is_same_type, deep_equal, shallow_equal, similarity_score, array_intersection, array_union, array_difference |
226
+ | `utility.geo` | calculate_distance, point_in_polygon, get_bounding_box, reverse_geocode, geocode, convert_coordinates |
227
+
228
+ ```javascript
229
+ const { ConnectorId, ConnectorActions, getConnectorActions } = require('@cliodot/flosync');
230
+
231
+ s.util(ConnectorId.Utility.String, 'slugify', { string: 'Hello World' });
232
+ s.util(ConnectorId.Utility.Math, 'clamp', { number: 150, min: 0, max: 100 });
233
+ s.util(ConnectorId.Utility.Compare, 'diff_objects', { object1: v.stepResult('prev'), object2: v.body() });
234
+ s.util(ConnectorId.Utility.Geo, 'calculate_distance', { lat1: 0, lon1: 0, lat2: 1, lon2: 1 });
235
+
236
+ const stringActions = getConnectorActions(ConnectorId.Utility.String);
237
+ ```
238
+
239
+ ## Responders
240
+
241
+ Use `s.responder(type, config)` with built-in responder types.
242
+
243
+ | Type | Description |
244
+ |------|-------------|
245
+ | json | JSON response (default content-type: application/json) |
246
+ | http | Same as json, supports custom headers |
247
+ | raw | Plain text with custom contentType |
248
+ | redirect | 302/301 redirect with Location header |
249
+ | empty | 202 with no body |
250
+
251
+ ```javascript
252
+ s.responder('json', { body: v.stepResult('data') });
253
+ s.responder('raw', { body: 'OK', contentType: 'text/plain' });
254
+ s.responder('redirect', { location: 'https://example.com', statusCode: 301 });
255
+ s.responder('empty', { statusCode: 202 });
256
+ ```
257
+
258
+ ## Encryption
259
+
260
+ Use `s.encrypt(connectorId, action, config)` with built-in encryption connectors. All use Node `crypto`; Argon2 and bcrypt require optional packages.
261
+
262
+ | Connector | Actions |
263
+ |-----------|---------|
264
+ | `base64.encryption` | `base64.encode`, `base64.decode` |
265
+ | `hash.encryption` | `hash`, `hash.md5`, `hash.sha1`, `hash.sha256`, `hash.sha512` |
266
+ | `aes.encryption` | `aes.encrypt`, `aes.decrypt`, `aes.generate_key`, `aes.generate_iv` |
267
+ | `rsa.encryption` | `rsa.generate_keypair`, `rsa.encrypt`, `rsa.decrypt`, `rsa.sign`, `rsa.verify` |
268
+ | `hmac.encryption` | `hmac.create`, `hmac.verify` |
269
+ | `password.encryption` | `password.argon2_hash`, `password.argon2_verify`, `password.pbkdf2_hash`, `password.pbkdf2_verify`, `password.scrypt_hash`, `password.scrypt_verify`, `password.bcrypt_hash`, `password.bcrypt_verify`, `password.generate_salt` |
270
+
271
+ **Examples:**
272
+
273
+ ```javascript
274
+ s.encrypt('hash.encryption', 'hash', { data: v.body('payload'), algorithm: 'sha256' });
275
+ s.encrypt('base64.encryption', 'base64.encode', { data: v.stepResult('prev') });
276
+ s.encrypt('aes.encryption', 'aes.encrypt', { data: v.body('secret'), key: v.vars('key') });
277
+ s.encrypt('rsa.encryption', 'rsa.sign', { data: v.body('payload'), private_key: v.vars('privateKey') });
278
+ s.encrypt('hmac.encryption', 'hmac.create', { data: v.body('message'), key: v.vars('secret') });
279
+ s.encrypt('password.encryption', 'password.argon2_hash', { password: v.body('password') });
280
+ ```
281
+
282
+ **Optional packages:** `password.argon2_hash` / `password.argon2_verify` need `argon2`; `password.bcrypt_hash` / `password.bcrypt_verify` need `bcrypt`. Install with `npm install argon2 bcrypt` if you use those actions.
283
+
284
+ ## Connector Registry
285
+
286
+ Use `ConnectorId` and `ConnectorActions` for built-in connectors, or `defineCustomConnector` for your own. This gives you autocomplete and avoids typos.
287
+
288
+ ### Built-in connectors
289
+
290
+ ```javascript
291
+ const { flosync, ConnectorId, ConnectorActions, getConnectorActions, listBuiltInConnectors } = require('@cliodot/flosync');
292
+
293
+ // Database
294
+ s.db('mongodb', 'insertOne', { collection: 'orders', document: {} });
295
+ s.db('mysql', 'query', { query: 'SELECT 1', params: [] });
296
+ s.db('postgres', 'query', { query: 'SELECT 1', params: [] });
297
+ s.db('redis', 'redis.set', { key: 'key', value: 'value' });
298
+
299
+ // Auth
300
+ s.auth(ConnectorId.Auth.Bearer, ConnectorActions[ConnectorId.Auth.Bearer][0], { token: '{{ headers.authorization }}' });
301
+
302
+ // Utility - use ConnectorActions or getConnectorActions for autocomplete
303
+ s.util(ConnectorId.Utility.DateTime, 'get_current_datetime', {});
304
+ s.util(ConnectorId.Utility.String, 'slugify', { string: 'Hello World' });
305
+ s.util(ConnectorId.Utility.Math, 'add', { numbers: [10, 20] });
306
+ s.util(ConnectorId.Utility.Random, 'random_uuid', {});
307
+ s.util(ConnectorId.Utility.Compare, 'diff_objects', { object1: {}, object2: {} });
308
+ s.util(ConnectorId.Utility.Geo, 'calculate_distance', { lat1: 0, lon1: 0, lat2: 1, lon2: 1 });
309
+
310
+ // Get actions for a connector (for suggestions/autocomplete)
311
+ const stringActions = getConnectorActions(ConnectorId.Utility.String);
312
+
313
+ // List all built-in connectors and their actions
314
+ console.log(listBuiltInConnectors());
315
+ ```
316
+
317
+ ### Custom connectors
318
+
319
+ Define your connector with typed actions for autocomplete:
320
+
321
+ ```javascript
322
+ const { defineCustomConnector } = require('@cliodot/flosync');
323
+
324
+ const MyStore = defineCustomConnector('my.store', {
325
+ login: 'login',
326
+ listItems: 'listItems',
327
+ createItem: 'createItem',
328
+ });
329
+
330
+ flosync.registerConnector(MyStore.id, myStoreConnector);
331
+
332
+ s.connector(MyStore.id, MyStore.actions.login, { body: { email: '{{ body.email }}' } });
333
+ s.connector(MyStore.id, MyStore.actions.listItems, {});
334
+ ```
335
+
336
+ For a simple list of action names:
337
+
338
+ ```javascript
339
+ const { defineCustomConnectorFromList } = require('@cliodot/flosync');
340
+
341
+ const MyStore = defineCustomConnectorFromList('my.store', ['login', 'listItems', 'createItem']);
342
+ ```
343
+
344
+ ## Connectors by ID
345
+
346
+ Use `s.connector(connectorId, action, config)` with any connector ID. For remote runs, connectors are resolved from your account. For local runs, register connectors first with `flosync.registerConnector(id, connector)` or pass config in `configure({ connectors: { 'connector-id': { ... } } })`.
347
+
348
+ ## API Client
349
+
350
+ When configured with `apiKey`, `apiSecret`, and `baseUrl`:
351
+
352
+ ```javascript
353
+ const client = flosync.getClient();
354
+
355
+ await flosync.push(workflow);
356
+ const wf = await flosync.pull(groupId);
357
+
358
+ const { workflowGroups, pagination } = await client.workflows.list({ status: 'active', page: 1, limit: 20 });
359
+ await client.workflows.run(groupId, triggerId, { payload: { ... } });
360
+ await client.workflows.runByWebhook('/orders', 'POST', { body: { ... } });
361
+
362
+ const functions = await client.functions.list();
363
+ await client.functions.push(fn);
364
+ const fn = await client.functions.pull(functionId);
365
+ await client.functions.invoke(functionId, { args: { ... } });
366
+
367
+ await client.projects.create({ name: 'My Project' });
368
+ const projects = await client.projects.list();
369
+ ```
370
+
371
+ ### Run connector from online
372
+
373
+ Execute connectors stored in your Cliodot account:
374
+
375
+ ```javascript
376
+ const result = await flosync.runConnector('paystack', 'Initialize Transaction', {
377
+ body: { email: 'user@example.com', amount: 5000, reference: 'ref_123' },
378
+ });
379
+
380
+ const { connectors, pagination } = await client.connectors.list();
381
+ const { installations } = await client.connectors.installed();
382
+ const connector = await client.connectors.get('paystack');
383
+ const data = await client.connectors.execute('paystack', 'Verify Transaction', {
384
+ pathParams: { reference: 'ref_123' },
385
+ });
386
+ ```
387
+
388
+ | Method | Description |
389
+ |--------|-------------|
390
+ | `flosync.runConnector(id, action, options, { remote? })` | Run connector (local if registered, else remote) |
391
+ | `client.connectors.get(id)` | Get connector definition |
392
+ | `client.connectors.list(options?)` | List connectors (type, status, category, page, limit) |
393
+ | `client.connectors.search(options?)` | Search public connectors |
394
+ | `client.connectors.push(connector)` | Create or update connector (by `_id` or `slug`) |
395
+ | `client.connectors.installed(options?)` | List installed connectors |
396
+ | `client.connectors.install(id, { auth?, base_url? })` | Install connector |
397
+ | `client.connectors.uninstall(id)` | Uninstall connector |
398
+ | `client.connectors.execute(id, action, options)` | Execute connector action remotely |
399
+
400
+ ### Workflows
401
+
402
+ | Method | Description |
403
+ |--------|-------------|
404
+ | `client.workflows.push(workflow)` | Create or update workflow |
405
+ | `client.workflows.pull(groupId)` | Fetch workflow as IWorkflow |
406
+ | `client.workflows.list(options?)` | List workflow groups |
407
+ | `client.workflows.run(groupId, triggerId, payload)` | Run by trigger ID (payload may include `environment: "dev" \| "prod"`) |
408
+ | `client.workflows.runByWebhook(path, method, payload)` | Run by webhook path (payload may include `environment`) |
409
+ | `client.workflows.promote(groupId)` | Promote to production |
410
+
411
+ See [Workflows](../docs/WORKFLOWS.md) for full documentation. See [Building and Pushing Custom Connectors](../docs/BUILDING_CONNECTORS.md) for connectors.
412
+
413
+ ## Custom Connectors
414
+
415
+ See [Building and Pushing Custom Connectors](../docs/BUILDING_CONNECTORS.md) for full samples of JSON, ConnectorBuilder, and custom execute connectors.
416
+
417
+ ### REST connectors
418
+
419
+ ```javascript
420
+ flosync.registerConnector('my-connector', {
421
+ _id: 'my-connector',
422
+ type: 'REST',
423
+ base_url: 'https://api.example.com',
424
+ auth: { type: 'bearer', token: process.env.MY_API_KEY },
425
+ endpoints: [
426
+ { name: 'GetUser', method: 'GET', path: '/users/:id' },
427
+ ],
428
+ });
429
+ ```
430
+
431
+ ### Custom execute connector
432
+
433
+ For full control, provide an `execute` function. The engine calls it with `(action, options, context)`.
434
+
435
+ **Connector definition**
436
+
437
+ ```javascript
438
+ flosync.registerConnector('my.auth', {
439
+ _id: 'my.auth',
440
+ type: 'system',
441
+ name: 'My Auth',
442
+ meta: { category: 'authentication' },
443
+ auth: { type: 'none' },
444
+ execute: async (action, options, context) => { ... },
445
+ });
446
+ ```
447
+
448
+ Import types for TypeScript: `ConnectorExecuteOptions`, `ConnectorContext`, `ConnectorExecuteFn` from `@cliodot/flosync`.
449
+
450
+ **Execute signature**
451
+
452
+ ```typescript
453
+ execute(
454
+ action: string,
455
+ options: ConnectorExecuteOptions,
456
+ context: ConnectorContext
457
+ ): Promise<unknown>
458
+ ```
459
+
460
+ **Options** (from workflow step config):
461
+
462
+ | Field | When used | Description |
463
+ |-------|-----------|-------------|
464
+ | `body` | API, auth, db, encrypt | Request body or payload |
465
+ | `params` | API | Query params |
466
+ | `pathParams` | API | Path params (e.g. `:id` in `/users/:id`) |
467
+ | `headers` | API | Extra headers |
468
+ | `database` | DB | Database name override |
469
+ | `connection_id` | DB | Connection ID override |
470
+
471
+ **Context** (from run state):
472
+
473
+ | Field | Description |
474
+ |-------|-------------|
475
+ | `headers` | HTTP headers from the trigger |
476
+ | `connectorConfig` | Per-connector config from `configure({ connectors: { 'id': {...} } })` |
477
+ | `env` | Environment overrides |
478
+ | `trigger` | Trigger payload (body, pathParams, params, etc.) |
479
+ | `stepResults` | Results of previous steps |
480
+ | `vars` | Workflow variables |
481
+
482
+ **Discovering IDs and actions**
483
+
484
+ - Built-in: `ConnectorId`, `ConnectorActions`, `getConnectorActions(connectorId)`, `listBuiltInConnectors()`
485
+ - Custom: `defineCustomConnector(id, actions)` or `defineCustomConnectorFromList(id, ['action1', 'action2'])`
486
+
487
+ **REST endpoint shape**
488
+
489
+ ```typescript
490
+ {
491
+ name: string; // Action name (matches s.connector(id, name, config))
492
+ action?: string; // Alias for name
493
+ method: string; // GET, POST, PUT, DELETE, etc.
494
+ path: string; // e.g. '/users/:id' or '/orders'
495
+ headers?: Record<string, string>;
496
+ body_schema?: object;
497
+ response_mapping?: Record<string, string>; // { "userId": "data.id" }
498
+ timeout_ms?: number;
499
+ }
500
+ ```
501
+
502
+ **Return format**
503
+
504
+ - API/DB/Encrypt: `{ raw, mapped }` or any object (engine uses `mapped ?? raw`)
505
+ - Auth: `{ valid: boolean, token?, user?, error? }` for success/failure branching
506
+
507
+ ## License
508
+
509
+ MIT
@@ -0,0 +1,68 @@
1
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
+ export interface EndpointOpts {
3
+ action?: string;
4
+ params?: Record<string, any>;
5
+ pathParams?: Record<string, any>;
6
+ body?: any;
7
+ headers?: Record<string, string>;
8
+ description?: string;
9
+ timeout_ms?: number;
10
+ response_mapping?: Record<string, string>;
11
+ body_schema?: Record<string, any>;
12
+ }
13
+ export interface CustomAuthFlow {
14
+ method?: string;
15
+ url: string;
16
+ headers?: Record<string, string>;
17
+ body?: Record<string, any>;
18
+ extract_token?: string;
19
+ extract_expires_in?: string;
20
+ token_location?: "header" | "query" | "body";
21
+ token_template_prefix?: string;
22
+ }
23
+ interface AuthDef {
24
+ type: string;
25
+ token?: string;
26
+ api_key?: string;
27
+ key_name?: string;
28
+ header_name?: string;
29
+ prefix?: string;
30
+ flow?: CustomAuthFlow;
31
+ }
32
+ interface MetaDef {
33
+ category?: string;
34
+ logo?: string;
35
+ [key: string]: any;
36
+ }
37
+ export declare class ConnectorBuilder {
38
+ private _id;
39
+ private _name;
40
+ private _slug?;
41
+ private _description?;
42
+ private _type;
43
+ private _baseUrl;
44
+ private _auth;
45
+ private _meta?;
46
+ private _endpoints;
47
+ constructor(id: string, name?: string);
48
+ rest(): this;
49
+ baseUrl(url: string): this;
50
+ bearer(token: string): this;
51
+ apiKey(key: string, keyName?: string): this;
52
+ botToken(token: string, prefix?: string): this;
53
+ customFlow(flow: CustomAuthFlow): this;
54
+ authConfig(auth: AuthDef): this;
55
+ description(desc: string): this;
56
+ slug(s: string): this;
57
+ meta(m: MetaDef): this;
58
+ endpoint(name: string, method: HttpMethod | string, path: string, opts?: EndpointOpts): this;
59
+ get(name: string, path: string, opts?: EndpointOpts): this;
60
+ post(name: string, path: string, opts?: EndpointOpts): this;
61
+ put(name: string, path: string, opts?: EndpointOpts): this;
62
+ patch(name: string, path: string, opts?: EndpointOpts): this;
63
+ delete(name: string, path: string, opts?: EndpointOpts): this;
64
+ build(): Record<string, any>;
65
+ }
66
+ export declare function connector(id: string, name?: string): ConnectorBuilder;
67
+ export {};
68
+ //# sourceMappingURL=ConnectorBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectorBuilder.d.ts","sourceRoot":"","sources":["../src/ConnectorBuilder.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAA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 @@
1
+ 'use strict';const _0x1dd6ba=_0x243a;(function(_0x2f1584,_0x4ca1d4){const _0x1ebe3a=_0x243a,_0x563473=_0x2f1584();while(!![]){try{const _0x24983a=parseInt(_0x1ebe3a(0x166))/0x1*(-parseInt(_0x1ebe3a(0x16a))/0x2)+parseInt(_0x1ebe3a(0x17d))/0x3+parseInt(_0x1ebe3a(0x170))/0x4+-parseInt(_0x1ebe3a(0x178))/0x5+parseInt(_0x1ebe3a(0x165))/0x6*(parseInt(_0x1ebe3a(0x175))/0x7)+-parseInt(_0x1ebe3a(0x157))/0x8+parseInt(_0x1ebe3a(0x16e))/0x9*(parseInt(_0x1ebe3a(0x15f))/0xa);if(_0x24983a===_0x4ca1d4)break;else _0x563473['push'](_0x563473['shift']());}catch(_0x50a04b){_0x563473['push'](_0x563473['shift']());}}}(_0x1292,0x69e88));Object[_0x1dd6ba(0x176)](exports,'__esModule',{'value':!![]}),exports[_0x1dd6ba(0x17e)]=void 0x0,exports[_0x1dd6ba(0x163)]=connector;class ConnectorBuilder{constructor(_0x3cf356,_0x5069b0){const _0x41c434=_0x1dd6ba;this[_0x41c434(0x179)]=_0x41c434(0x17a),this['_baseUrl']='',this['_auth']={'type':_0x41c434(0x171)},this['_endpoints']=[],this['_id']=_0x3cf356,this[_0x41c434(0x16b)]=_0x5069b0??_0x3cf356;}['rest'](){const _0x361ce0=_0x1dd6ba;return this['_type']=_0x361ce0(0x17a),this;}[_0x1dd6ba(0x17f)](_0x10ad9e){const _0x411598=_0x1dd6ba;return this[_0x411598(0x16f)]=_0x10ad9e,this;}['bearer'](_0x7b503a){const _0x45f80a=_0x1dd6ba;return this['_auth']={'type':_0x45f80a(0x171),'token':_0x7b503a},this;}[_0x1dd6ba(0x15e)](_0x4be7ac,_0x27b3a8){const _0x1fa706=_0x1dd6ba;return this[_0x1fa706(0x173)]={'type':'api_key','api_key':_0x4be7ac,'key_name':_0x27b3a8},this;}[_0x1dd6ba(0x15d)](_0xd56820,_0x1d2767=_0x1dd6ba(0x159)){const _0x36347e=_0x1dd6ba;return this[_0x36347e(0x173)]={'type':_0x36347e(0x171),'token':_0xd56820,'header_name':'Authorization','prefix':_0x1d2767},this;}[_0x1dd6ba(0x181)](_0x416d64){const _0x44b251=_0x1dd6ba;return this[_0x44b251(0x173)]={'type':_0x44b251(0x164),'flow':_0x416d64},this;}[_0x1dd6ba(0x17b)](_0x2f3717){const _0x430d0c=_0x1dd6ba;return this[_0x430d0c(0x173)]=_0x2f3717,this;}[_0x1dd6ba(0x160)](_0x5e2db4){const _0x2641e3=_0x1dd6ba;return this[_0x2641e3(0x17c)]=_0x5e2db4,this;}[_0x1dd6ba(0x161)](_0x1f725a){return this['_slug']=_0x1f725a,this;}[_0x1dd6ba(0x16d)](_0x166fbb){const _0xa5f54e=_0x1dd6ba;return this[_0xa5f54e(0x16c)]=_0x166fbb,this;}[_0x1dd6ba(0x158)](_0x374bdc,_0x427723,_0x939d88,_0x7228c0){const _0xd049d=_0x1dd6ba;return this[_0xd049d(0x174)][_0xd049d(0x177)]({'name':_0x374bdc,'method':(_0x427723||'GET')[_0xd049d(0x172)](),'path':_0x939d88,..._0x7228c0}),this;}[_0x1dd6ba(0x15c)](_0x50b9f5,_0xce2f37,_0x486704){const _0x542bb0=_0x1dd6ba;return this[_0x542bb0(0x158)](_0x50b9f5,_0x542bb0(0x15a),_0xce2f37,_0x486704);}[_0x1dd6ba(0x182)](_0x42d078,_0x5783ae,_0x4c1c0f){const _0x5bc1c4=_0x1dd6ba;return this[_0x5bc1c4(0x158)](_0x42d078,'POST',_0x5783ae,_0x4c1c0f);}[_0x1dd6ba(0x169)](_0x3fa273,_0x37b3f4,_0x1b155c){const _0x53783e=_0x1dd6ba;return this[_0x53783e(0x158)](_0x3fa273,'PUT',_0x37b3f4,_0x1b155c);}['patch'](_0xdc2e98,_0x17c5df,_0x544609){const _0x1dc32c=_0x1dd6ba;return this[_0x1dc32c(0x158)](_0xdc2e98,_0x1dc32c(0x15b),_0x17c5df,_0x544609);}['delete'](_0x4294b4,_0xf80d85,_0x1df549){const _0x3c9a30=_0x1dd6ba;return this[_0x3c9a30(0x158)](_0x4294b4,_0x3c9a30(0x162),_0xf80d85,_0x1df549);}[_0x1dd6ba(0x180)](){const _0x904f67=_0x1dd6ba,_0x301e19={'_id':this[_0x904f67(0x167)],'type':this[_0x904f67(0x179)],'name':this[_0x904f67(0x16b)],'base_url':this[_0x904f67(0x16f)],'auth':this[_0x904f67(0x173)],'endpoints':this[_0x904f67(0x174)]};if(this['_slug'])_0x301e19[_0x904f67(0x161)]=this['_slug'];if(this[_0x904f67(0x17c)])_0x301e19[_0x904f67(0x160)]=this[_0x904f67(0x17c)];return this[_0x904f67(0x16c)]&&(_0x301e19[_0x904f67(0x16d)]={...this['_meta'],'last_updated':this[_0x904f67(0x16c)][_0x904f67(0x168)]??new Date()['toISOString']()}),_0x301e19;}}function _0x243a(_0x4024d0,_0x1345c1){_0x4024d0=_0x4024d0-0x157;const _0x129212=_0x1292();let _0x243a75=_0x129212[_0x4024d0];if(_0x243a['sqQRtX']===undefined){var _0x518c7f=function(_0x3ecf1d){const _0x8976eb='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3cf356='',_0x5069b0='';for(let _0x10ad9e=0x0,_0x7b503a,_0x4be7ac,_0x27b3a8=0x0;_0x4be7ac=_0x3ecf1d['charAt'](_0x27b3a8++);~_0x4be7ac&&(_0x7b503a=_0x10ad9e%0x4?_0x7b503a*0x40+_0x4be7ac:_0x4be7ac,_0x10ad9e++%0x4)?_0x3cf356+=String['fromCharCode'](0xff&_0x7b503a>>(-0x2*_0x10ad9e&0x6)):0x0){_0x4be7ac=_0x8976eb['indexOf'](_0x4be7ac);}for(let _0xd56820=0x0,_0x1d2767=_0x3cf356['length'];_0xd56820<_0x1d2767;_0xd56820++){_0x5069b0+='%'+('00'+_0x3cf356['charCodeAt'](_0xd56820)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5069b0);};_0x243a['IZxPVt']=_0x518c7f,_0x243a['cdYNya']={},_0x243a['sqQRtX']=!![];}const _0x33e8fd=_0x129212[0x0],_0x227370=_0x4024d0+_0x33e8fd,_0x3edfe8=_0x243a['cdYNya'][_0x227370];return!_0x3edfe8?(_0x243a75=_0x243a['IZxPVt'](_0x243a75),_0x243a['cdYNya'][_0x227370]=_0x243a75):_0x243a75=_0x3edfe8,_0x243a75;}function _0x1292(){const _0x3b5852=['yxv0AenVBMzPzW','x2rLC2nYAxb0Aw9U','mta2oda5EKzyz2j0','q29UBMvJDg9YqNvPBgrLCG','yMfZzvvYBa','yNvPBgq','y3vZDg9TrMXVDW','Cg9ZDa','mJq5mZG3mLLtvMfLAG','zw5KCg9PBNq','qM90ia','r0vu','uefuq0G','z2v0','yM90vg9Rzw4','yxbPs2v5','ota2otbLzunpvwK','zgvZy3jPChrPB24','C2X1zW','revmrvrf','y29UBMvJDg9Y','y3vZDg9T','mJi2mJu5nfzPsLrtta','og5UrvnbrW','x2LK','BgfZDf91CgrHDgvK','Chv0','otuYnZH4EK5quNy','x25HBwu','x21LDge','Bwv0yq','otGXCvLhvhDT','x2jHC2vvCMW','mtaYnJaYmg5jy1D5Ca','yMvHCMvY','Dg9vChbLCKnHC2u','x2f1DgG','x2vUzhbVAw50CW','n0njrgLpBG','zgvMAw5LuhjVCgvYDhK','ChvZAa','mJy1ntqXmerMDgT5yW','x3r5Cgu','uKvtva'];_0x1292=function(){return _0x3b5852;};return _0x1292();}exports[_0x1dd6ba(0x17e)]=ConnectorBuilder;function connector(_0x3c745e,_0x3309b6){return new ConnectorBuilder(_0x3c745e,_0x3309b6);}
@@ -0,0 +1,67 @@
1
+ import { IWorkflow } from "./types/workflow";
2
+ import { IFunction } from "./types/function";
3
+ import { WorkflowBuilder } from "./WorkflowBuilder";
4
+ import { FunctionBuilder } from "./FunctionBuilder";
5
+ import { FlosyncClient } from "./FlosyncClient";
6
+ export interface FlosyncConfig {
7
+ apiKey?: string;
8
+ apiSecret?: string;
9
+ baseUrl?: string;
10
+ projectId?: string;
11
+ tenantId?: string;
12
+ connectors?: Record<string, any>;
13
+ cliodot?: {
14
+ baseUrl: string;
15
+ apiKey: string;
16
+ };
17
+ }
18
+ export declare class Flosync {
19
+ private config;
20
+ private workflows;
21
+ private workflowsByName;
22
+ private functions;
23
+ private connectors;
24
+ configure(config: FlosyncConfig): this;
25
+ authenticate(): Promise<void>;
26
+ registerConnector(id: string, connector: any): this;
27
+ workflow(id: string, name?: string): WorkflowBuilder;
28
+ function(id: string, name?: string): FunctionBuilder;
29
+ register(workflowOrWorkflows: IWorkflow | IWorkflow[]): this;
30
+ run(workflowIdOrName: string, payload?: any, options?: {
31
+ remote?: boolean;
32
+ }): Promise<any>;
33
+ runById(workflowId: string, payload?: any, options?: {
34
+ triggerId?: string;
35
+ }): Promise<any>;
36
+ runByWebhook(webhookPath: string, method: string, payload?: any): Promise<any>;
37
+ runFunctionById(functionId: string, args?: Record<string, any>): Promise<any>;
38
+ runConnector(connectorId: string, action: string, options?: {
39
+ body?: Record<string, any>;
40
+ params?: Record<string, any>;
41
+ pathParams?: Record<string, any>;
42
+ headers?: Record<string, string>;
43
+ installation_id?: string;
44
+ database?: string;
45
+ connection_id?: string;
46
+ timeout?: number;
47
+ vars?: Record<string, any>;
48
+ }, runOptions?: {
49
+ remote?: boolean;
50
+ }): Promise<any>;
51
+ private normalizeRunPayload;
52
+ setRunner(runner: any): this;
53
+ getClient(): FlosyncClient | null;
54
+ get c(): FlosyncClient | null;
55
+ setClient(client: any): this;
56
+ push(workflow: IWorkflow): Promise<any>;
57
+ pull(workflowId: string): Promise<IWorkflow>;
58
+ list(): IWorkflow[];
59
+ registerFunction(fn: IFunction): this;
60
+ runFunction(slugOrId: string, args?: Record<string, any>, options?: {
61
+ remote?: boolean;
62
+ }): Promise<any>;
63
+ pushFunction(fn: IFunction): Promise<any>;
64
+ pullFunction(functionId: string): Promise<IFunction>;
65
+ }
66
+ export declare const flosync: Flosync;
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