@cobaltio/cobalt-js 9.2.0-beta.6 → 9.2.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.
Files changed (48) hide show
  1. package/.claude/skills/method/SKILL.md +282 -0
  2. package/.claude/skills/review-pr/SKILL.md +80 -0
  3. package/.claude/skills/style/SKILL.md +67 -0
  4. package/.claude/skills/verify/SKILL.md +85 -0
  5. package/.github/workflows/npm-publish.yml +6 -7
  6. package/CLAUDE.md +99 -19
  7. package/cobalt.d.ts +74 -64
  8. package/cobalt.js +421 -365
  9. package/cobalt.ts +104 -124
  10. package/docs/assets/hierarchy.js +1 -1
  11. package/docs/assets/main.js +1 -1
  12. package/docs/assets/navigation.js +1 -1
  13. package/docs/assets/search.js +1 -1
  14. package/docs/classes/Cobalt.html +43 -33
  15. package/docs/enums/AuthStatus.html +2 -2
  16. package/docs/enums/AuthType.html +3 -3
  17. package/docs/hierarchy.html +1 -1
  18. package/docs/index.html +1 -1
  19. package/docs/interfaces/Application.html +19 -15
  20. package/docs/interfaces/CobaltOptions.html +3 -3
  21. package/docs/interfaces/Config.html +2 -2
  22. package/docs/interfaces/ConfigField.html +4 -4
  23. package/docs/interfaces/ConfigPayload.html +5 -5
  24. package/docs/interfaces/ConfigWorkflow.html +2 -2
  25. package/docs/interfaces/ExecuteWorkflowPayload.html +5 -5
  26. package/docs/interfaces/Execution.html +2 -2
  27. package/docs/interfaces/ExecutionFilters.html +16 -0
  28. package/docs/interfaces/GetExecutionsParams.html +19 -0
  29. package/docs/interfaces/InputField.html +10 -10
  30. package/docs/interfaces/Label.html +4 -4
  31. package/docs/interfaces/PublicWorkflow.html +9 -9
  32. package/docs/interfaces/PublicWorkflowPayload.html +5 -5
  33. package/docs/interfaces/PublicWorkflowsPayload.html +13 -2
  34. package/docs/interfaces/RuleOptions.html +2 -2
  35. package/docs/interfaces/UpdateConfigPayload.html +6 -6
  36. package/docs/interfaces/WorkflowPayload.html +5 -5
  37. package/docs/interfaces/WorkflowPayloadResponse.html +2 -2
  38. package/docs/llms.txt +262 -249
  39. package/docs/modules.html +1 -1
  40. package/docs/types/ExecutionSource.html +2 -0
  41. package/docs/types/ExecutionStatus.html +2 -0
  42. package/docs/types/ExecutionType.html +2 -0
  43. package/package.json +4 -4
  44. package/tsconfig.json +12 -12
  45. package/docs/interfaces/AuthConfig.html +0 -9
  46. package/docs/interfaces/ConnectedAccount.html +0 -14
  47. package/docs/interfaces/KeyBasedParams.html +0 -7
  48. package/docs/interfaces/OAuthParams.html +0 -9
package/cobalt.js CHANGED
@@ -2,6 +2,26 @@
2
2
  /**
3
3
  * Cobalt Frontend SDK
4
4
  */
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __rest = (this && this.__rest) || function (s, e) {
15
+ var t = {};
16
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
17
+ t[p] = s[p];
18
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
19
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
20
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
21
+ t[p[i]] = s[p[i]];
22
+ }
23
+ return t;
24
+ };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.Cobalt = exports.AuthStatus = exports.AuthType = void 0;
7
27
  var AuthType;
@@ -34,41 +54,43 @@ class Cobalt {
34
54
  * @private
35
55
  * @returns {Promise<unknown>}
36
56
  */
37
- async getAccountDetails() {
38
- const res = await fetch(`${this.baseUrl}/api/v3/org/basics`, {
39
- headers: {
40
- authorization: `Bearer ${this.token}`,
41
- },
57
+ getAccountDetails() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const res = yield fetch(`${this.baseUrl}/api/v3/org/basics`, {
60
+ headers: {
61
+ authorization: `Bearer ${this.token}`,
62
+ },
63
+ });
64
+ if (res.status >= 400 && res.status < 600) {
65
+ const error = yield res.json();
66
+ throw error;
67
+ }
68
+ const data = yield res.json();
69
+ return data;
42
70
  });
43
- if (res.status >= 400 && res.status < 600) {
44
- const error = await res.json();
45
- throw error;
46
- }
47
- const data = await res.json();
48
- return data;
49
71
  }
50
72
  /**
51
73
  * Returns the org & customer details for the associated token.
52
74
  * @private
53
75
  * @returns {Promise<unknown>}
54
76
  */
55
- async updateAccount(payload) {
56
- const res = await fetch(`${this.baseUrl}/api/v2/public/linked-account`, {
57
- method: "PUT",
58
- headers: {
59
- authorization: `Bearer ${this.token}`,
60
- "content-type": "application/json",
61
- },
62
- body: JSON.stringify({
63
- ...payload,
64
- }),
77
+ updateAccount(payload) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/linked-account`, {
80
+ method: "PUT",
81
+ headers: {
82
+ authorization: `Bearer ${this.token}`,
83
+ "content-type": "application/json",
84
+ },
85
+ body: JSON.stringify(Object.assign({}, payload)),
86
+ });
87
+ if (res.status >= 400 && res.status < 600) {
88
+ const error = yield res.json();
89
+ throw error;
90
+ }
91
+ const data = yield res.json();
92
+ return data;
65
93
  });
66
- if (res.status >= 400 && res.status < 600) {
67
- const error = await res.json();
68
- throw error;
69
- }
70
- const data = await res.json();
71
- return data;
72
94
  }
73
95
  /**
74
96
  * Returns the application details for the specified application, provided
@@ -77,276 +99,260 @@ class Cobalt {
77
99
  * @param {String} [slug] The application slug.
78
100
  * @returns {Promise<Application | Application[]>} The application details.
79
101
  */
80
- async getApp(slug) {
81
- const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/application${slug ? `/${slug}` : ""}`, {
82
- headers: {
83
- authorization: `Bearer ${this.token}`,
84
- },
102
+ getApp(slug) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ const res = yield fetch(`${this.baseUrl}/api/v2/f-sdk/application${slug ? `/${slug}` : ""}`, {
105
+ headers: {
106
+ authorization: `Bearer ${this.token}`,
107
+ },
108
+ });
109
+ if (res.status >= 400 && res.status < 600) {
110
+ const error = yield res.json();
111
+ throw error;
112
+ }
113
+ const data = yield res.json();
114
+ return data;
85
115
  });
86
- if (res.status >= 400 && res.status < 600) {
87
- const error = await res.json();
88
- throw error;
89
- }
90
- const data = await res.json();
91
- return data;
92
116
  }
93
117
  /**
94
118
  * Returns all the enabled apps.
95
119
  * @returns {Promise<Application[]>} The list of applications.
96
120
  */
97
- async getApps() {
98
- const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/application`, {
99
- headers: {
100
- authorization: `Bearer ${this.token}`,
101
- },
102
- });
103
- if (res.status >= 400 && res.status < 600) {
104
- const error = await res.json();
105
- throw error;
106
- }
107
- const data = await res.json();
108
- return data;
109
- }
110
- /**
111
- * Returns the auth configs for the specified application.
112
- * @param {String} slug The application slug.
113
- * @returns {Promise<AuthConfig[]>} The auth configs.
114
- */
115
- async getAuthConfigs(slug) {
116
- const res = await fetch(`${this.baseUrl}/api/v2/public/slug/${slug}/auth-config`, {
117
- headers: {
118
- authorization: `Bearer ${this.token}`,
119
- },
121
+ getApps() {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ const res = yield fetch(`${this.baseUrl}/api/v2/f-sdk/application`, {
124
+ headers: {
125
+ authorization: `Bearer ${this.token}`,
126
+ },
127
+ });
128
+ if (res.status >= 400 && res.status < 600) {
129
+ const error = yield res.json();
130
+ throw error;
131
+ }
132
+ const data = yield res.json();
133
+ return data;
120
134
  });
121
- if (res.status >= 400 && res.status < 600) {
122
- const error = await res.json();
123
- throw error;
124
- }
125
- const data = await res.json();
126
- return data.docs || [];
127
135
  }
128
136
  /**
129
137
  * Returns the auth URL that users can use to authenticate themselves to the
130
138
  * specified application.
131
139
  * @private
132
- * @param {OAuthParams} params The OAuth parameters.
140
+ * @param {String} slug The application slug.
141
+ * @param {Object.<string, string>} [params] The key value pairs of auth data.
133
142
  * @returns {Promise<String>} The auth URL where users can authenticate themselves.
134
143
  */
135
- async getOAuthUrl({ slug, authConfig, payload, }) {
136
- const queryParams = new URLSearchParams();
137
- if (authConfig)
138
- queryParams.append("auth_config_id", authConfig);
139
- if (typeof payload === "object") {
140
- for (const [key, value] of Object.entries(payload)) {
141
- queryParams.append(key, value);
144
+ getOAuthUrl(slug, params) {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ const res = yield fetch(`${this.baseUrl}/api/v1/${slug}/integrate?${new URLSearchParams(params).toString()}`, {
147
+ headers: {
148
+ authorization: `Bearer ${this.token}`,
149
+ },
150
+ });
151
+ if (res.status >= 400 && res.status < 600) {
152
+ const error = yield res.json();
153
+ throw error;
142
154
  }
143
- }
144
- const res = await fetch(`${this.baseUrl}/api/v1/${slug}/integrate?${queryParams.toString()}`, {
145
- headers: {
146
- authorization: `Bearer ${this.token}`,
147
- },
155
+ const data = yield res.json();
156
+ return data.auth_url;
148
157
  });
149
- if (res.status >= 400 && res.status < 600) {
150
- const error = await res.json();
151
- throw error;
152
- }
153
- const data = await res.json();
154
- return data.auth_url;
155
158
  }
156
159
  /**
157
160
  * Handle OAuth for the specified application.
158
161
  * @private
159
- * @param {OAuthParams} params The OAuth parameters.
162
+ * @param {String} slug The application slug.
163
+ * @param {Object.<string, string>} [params] The key value pairs of auth data.
160
164
  * @returns {Promise<Boolean>} Whether the user authenticated.
161
165
  */
162
- async oauth({ slug, authConfig, payload, autoClose = true, }) {
163
- return new Promise((resolve, reject) => {
164
- this.getOAuthUrl({ slug, authConfig, payload })
165
- .then(oauthUrl => {
166
- const connectWindow = window.open(oauthUrl);
167
- // keep checking connection status
168
- const interval = setInterval(() => {
169
- this.getApp(slug)
170
- .then(app => {
171
- const oauthAccounts = app.connected_accounts?.filter(a => a.auth_type === AuthType.OAuth2 && a.status !== AuthStatus.Expired);
172
- if (app && oauthAccounts?.some(a => authConfig ? a.auth_config_id === authConfig : true)) {
173
- // close auth window
174
- if (autoClose)
166
+ oauth(slug, params) {
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ return new Promise((resolve, reject) => {
169
+ this.getOAuthUrl(slug, params)
170
+ .then(oauthUrl => {
171
+ const connectWindow = window.open(oauthUrl);
172
+ // keep checking connection status
173
+ const interval = setInterval(() => {
174
+ this.getApp(slug)
175
+ .then(app => {
176
+ var _a;
177
+ if (app && ((_a = app.connected_accounts) === null || _a === void 0 ? void 0 : _a.filter(a => a.auth_type === AuthType.OAuth2).some(a => a.status === AuthStatus.Active))) {
178
+ // close auth window
175
179
  connectWindow && connectWindow.close();
176
- // clear interval
177
- clearInterval(interval);
178
- // resovle status
179
- resolve(true);
180
- }
181
- else {
182
- // user closed oauth window without authenticating
183
- if (connectWindow && connectWindow.closed) {
184
180
  // clear interval
185
181
  clearInterval(interval);
186
- // resolve status
187
- resolve(false);
182
+ // resovle status
183
+ resolve(true);
188
184
  }
189
- }
190
- })
191
- .catch(e => {
192
- console.error(e);
193
- // connectWindow?.close();
194
- clearInterval(interval);
195
- reject(e);
196
- });
197
- }, 3e3);
198
- })
199
- .catch(reject);
185
+ else {
186
+ // user closed oauth window without authenticating
187
+ if (connectWindow && connectWindow.closed) {
188
+ // clear interval
189
+ clearInterval(interval);
190
+ // resolve status
191
+ resolve(false);
192
+ }
193
+ }
194
+ })
195
+ .catch(e => {
196
+ console.error(e);
197
+ // connectWindow?.close();
198
+ clearInterval(interval);
199
+ reject(e);
200
+ });
201
+ }, 3e3);
202
+ })
203
+ .catch(reject);
204
+ });
200
205
  });
201
206
  }
202
207
  /**
203
208
  * Save auth data for the specified keybased application.
204
- * @param {KeyBasedParams} params The key based parameters.
209
+ * @param {String} slug The application slug.
210
+ * @param {Object.<string, string>} [payload] The key value pairs of auth data.
205
211
  * @returns {Promise<Boolean>} Whether the auth data was saved successfully.
206
212
  */
207
- async keybased({ slug, authConfig, payload, }) {
208
- const res = await fetch(`${this.baseUrl}/api/v2/app/${slug}/save?auth_config_id=${authConfig}`, {
209
- method: "POST",
210
- headers: {
211
- authorization: `Bearer ${this.token}`,
212
- "content-type": "application/json",
213
- },
214
- body: JSON.stringify({
215
- ...payload,
216
- }),
213
+ keybased(slug, payload) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const res = yield fetch(`${this.baseUrl}/api/v2/app/${slug}/save`, {
216
+ method: "POST",
217
+ headers: {
218
+ authorization: `Bearer ${this.token}`,
219
+ "content-type": "application/json",
220
+ },
221
+ body: JSON.stringify(Object.assign({}, payload)),
222
+ });
223
+ if (res.status >= 400 && res.status < 600) {
224
+ const error = yield res.json();
225
+ throw error;
226
+ }
227
+ const data = yield res.json();
228
+ return data.success;
217
229
  });
218
- if (res.status >= 400 && res.status < 600) {
219
- const error = await res.json();
220
- throw error;
221
- }
222
- const data = await res.json();
223
- return data.success;
224
230
  }
225
231
  /**
226
232
  * Connects the specified application using the provided authentication type and optional auth data.
227
233
  * @param params - The parameters for connecting the application.
228
234
  * @param params.slug - The application slug.
229
- * @param params.authConfig - The identifier of the auth config.
230
235
  * @param params.type - The authentication type to use. If not provided, it defaults to `keybased` if payload is provided, otherwise `oauth2`.
231
236
  * @param params.payload - key-value pairs of authentication data required for the specified auth type.
232
- * @param params.autoClose - Whether to close the authentication window automatically. If not provided, it defaults to `true`.
233
237
  * @returns A promise that resolves to true if the connection was successful, otherwise false.
234
238
  * @throws Throws an error if the authentication type is invalid or the connection fails.
235
239
  */
236
- async connect({ slug, authConfig, type, payload, autoClose = true, }) {
237
- switch (type) {
238
- case AuthType.OAuth2:
239
- return this.oauth({ slug, authConfig, payload, autoClose });
240
- case AuthType.KeyBased:
241
- return this.keybased({ slug, authConfig, payload });
242
- default:
243
- if (payload)
244
- return this.keybased({ slug, authConfig, payload });
245
- return this.oauth({ slug, authConfig });
246
- }
240
+ connect(_a) {
241
+ return __awaiter(this, arguments, void 0, function* ({ slug, type, payload, }) {
242
+ switch (type) {
243
+ case AuthType.OAuth2:
244
+ return this.oauth(slug, payload);
245
+ case AuthType.KeyBased:
246
+ return this.keybased(slug, payload);
247
+ default:
248
+ if (payload)
249
+ return this.keybased(slug, payload);
250
+ return this.oauth(slug);
251
+ }
252
+ });
247
253
  }
248
254
  /**
249
255
  * Disconnect the specified application and remove any associated data from Cobalt.
250
256
  * @param {String} slug The application slug.
251
257
  * @param {AuthType} [type] The authentication type to use. If not provided, it'll remove all the connected accounts.
252
- * @param {String} [authConfig] The identifier of the auth config.
253
258
  * @returns {Promise<unknown>}
254
259
  */
255
- async disconnect(slug, type, authConfig) {
256
- const queryParams = new URLSearchParams();
257
- if (type)
258
- queryParams.append("auth_type", type);
259
- if (authConfig)
260
- queryParams.append("auth_config_id", authConfig);
261
- const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${slug}?${queryParams.toString()}`, {
262
- method: "DELETE",
263
- headers: {
264
- authorization: `Bearer ${this.token}`,
265
- },
260
+ disconnect(slug, type) {
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ const res = yield fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${slug}${type ? `?auth_type=${type}` : ""}`, {
263
+ method: "DELETE",
264
+ headers: {
265
+ authorization: `Bearer ${this.token}`,
266
+ },
267
+ });
268
+ if (res.status >= 400 && res.status < 600) {
269
+ const error = yield res.json();
270
+ throw error;
271
+ }
272
+ return yield res.json();
266
273
  });
267
- if (res.status >= 400 && res.status < 600) {
268
- const error = await res.json();
269
- throw error;
270
- }
271
- return await res.json();
272
274
  }
273
275
  /**
274
276
  * Returns the specified config, or creates one if it doesn't exist.
275
277
  * @param {ConfigPayload} payload The payload object for config.
276
278
  * @returns {Promise<Config>} The specified config.
277
279
  */
278
- async config(payload) {
279
- const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/config`, {
280
- method: "POST",
281
- headers: {
282
- authorization: `Bearer ${this.token}`,
283
- "content-type": "application/json",
284
- },
285
- body: JSON.stringify({
286
- ...payload,
287
- labels: payload.labels || [],
288
- }),
280
+ config(payload) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const res = yield fetch(`${this.baseUrl}/api/v2/f-sdk/config`, {
283
+ method: "POST",
284
+ headers: {
285
+ authorization: `Bearer ${this.token}`,
286
+ "content-type": "application/json",
287
+ },
288
+ body: JSON.stringify(Object.assign(Object.assign({}, payload), { labels: payload.labels || [] })),
289
+ });
290
+ if (res.status >= 400 && res.status < 600) {
291
+ const error = yield res.json();
292
+ throw error;
293
+ }
294
+ return yield res.json();
289
295
  });
290
- if (res.status >= 400 && res.status < 600) {
291
- const error = await res.json();
292
- throw error;
293
- }
294
- return await res.json();
295
296
  }
296
297
  /**
297
298
  * Returns the configs created for the specified application.
298
299
  * @param {String} slug The application slug.
299
300
  * @returns {Promise<{ config_id: string; }[]>} The configs created for the specified application.
300
301
  */
301
- async getConfigs(slug) {
302
- const res = await fetch(`${this.baseUrl}/api/v2/public/slug/${slug}/configs`, {
303
- headers: {
304
- authorization: `Bearer ${this.token}`,
305
- },
302
+ getConfigs(slug) {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/slug/${slug}/configs`, {
305
+ headers: {
306
+ authorization: `Bearer ${this.token}`,
307
+ },
308
+ });
309
+ if (res.status >= 400 && res.status < 600) {
310
+ const error = yield res.json();
311
+ throw error;
312
+ }
313
+ return yield res.json();
306
314
  });
307
- if (res.status >= 400 && res.status < 600) {
308
- const error = await res.json();
309
- throw error;
310
- }
311
- return await res.json();
312
315
  }
313
316
  /**
314
317
  * Returns the specified config.
315
318
  * @param {String} slug The application slug.
316
319
  * @param {String} [configId] The unique ID of the config.
320
+ * @param {Boolean} [excludeOptions] Whether to exclude the options from the fields in the response.
317
321
  * @returns {Promise<Config>} The specified config.
318
322
  */
319
- async getConfig(slug, configId) {
320
- const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/slug/${slug}/config${configId ? `/${configId}` : ""}`, {
321
- headers: {
322
- authorization: `Bearer ${this.token}`,
323
- },
323
+ getConfig(slug, configId, excludeOptions) {
324
+ return __awaiter(this, void 0, void 0, function* () {
325
+ const res = yield fetch(`${this.baseUrl}/api/v2/f-sdk/slug/${slug}/config${configId ? `/${configId}` : ""}`, {
326
+ headers: Object.assign({ authorization: `Bearer ${this.token}` }, (excludeOptions ? { disable_field_options: "true" } : {})),
327
+ });
328
+ if (res.status >= 400 && res.status < 600) {
329
+ const error = yield res.json();
330
+ throw error;
331
+ }
332
+ return yield res.json();
324
333
  });
325
- if (res.status >= 400 && res.status < 600) {
326
- const error = await res.json();
327
- throw error;
328
- }
329
- return await res.json();
330
334
  }
331
335
  /**
332
336
  * Update the specified config.
333
337
  * @param {UpdateConfigPayload} payload The update payload.
334
338
  * @returns {Promise<Config>} The specified config.
335
339
  */
336
- async updateConfig(payload) {
337
- const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/config`, {
338
- method: "PUT",
339
- headers: {
340
- authorization: `Bearer ${this.token}`,
341
- "content-type": "application/json",
342
- },
343
- body: JSON.stringify(payload),
340
+ updateConfig(payload) {
341
+ return __awaiter(this, void 0, void 0, function* () {
342
+ const res = yield fetch(`${this.baseUrl}/api/v2/f-sdk/config`, {
343
+ method: "PUT",
344
+ headers: {
345
+ authorization: `Bearer ${this.token}`,
346
+ "content-type": "application/json",
347
+ },
348
+ body: JSON.stringify(payload),
349
+ });
350
+ if (res.status >= 400 && res.status < 600) {
351
+ const error = yield res.json();
352
+ throw error;
353
+ }
354
+ return yield res.json();
344
355
  });
345
- if (res.status >= 400 && res.status < 600) {
346
- const error = await res.json();
347
- throw error;
348
- }
349
- return await res.json();
350
356
  }
351
357
  /**
352
358
  * Delete the specified config.
@@ -354,18 +360,20 @@ class Cobalt {
354
360
  * @param {String} [configId] The unique ID of the config.
355
361
  * @returns {Promise<unknown>}
356
362
  */
357
- async deleteConfig(slug, configId) {
358
- const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/slug/${slug}/config${configId ? `/${configId}` : ""}`, {
359
- method: "DELETE",
360
- headers: {
361
- authorization: `Bearer ${this.token}`,
362
- },
363
+ deleteConfig(slug, configId) {
364
+ return __awaiter(this, void 0, void 0, function* () {
365
+ const res = yield fetch(`${this.baseUrl}/api/v2/f-sdk/slug/${slug}/config${configId ? `/${configId}` : ""}`, {
366
+ method: "DELETE",
367
+ headers: {
368
+ authorization: `Bearer ${this.token}`,
369
+ },
370
+ });
371
+ if (res.status >= 400 && res.status < 600) {
372
+ const error = yield res.json();
373
+ throw error;
374
+ }
375
+ return yield res.json();
363
376
  });
364
- if (res.status >= 400 && res.status < 600) {
365
- const error = await res.json();
366
- throw error;
367
- }
368
- return await res.json();
369
377
  }
370
378
  /**
371
379
  * Returns the specified field of the config.
@@ -374,18 +382,20 @@ class Cobalt {
374
382
  * @param {String} [workflowId] The unique ID of the workflow.
375
383
  * @returns {Promise<Field>} The specified config field.
376
384
  */
377
- async getConfigField(slug, fieldId, workflowId) {
378
- const res = await fetch(`${this.baseUrl}/api/v2/public/config/field/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
379
- headers: {
380
- authorization: `Bearer ${this.token}`,
381
- slug,
382
- },
385
+ getConfigField(slug, fieldId, workflowId) {
386
+ return __awaiter(this, void 0, void 0, function* () {
387
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/config/field/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
388
+ headers: {
389
+ authorization: `Bearer ${this.token}`,
390
+ slug,
391
+ },
392
+ });
393
+ if (res.status >= 400 && res.status < 600) {
394
+ const error = yield res.json();
395
+ throw error;
396
+ }
397
+ return yield res.json();
383
398
  });
384
- if (res.status >= 400 && res.status < 600) {
385
- const error = await res.json();
386
- throw error;
387
- }
388
- return await res.json();
389
399
  }
390
400
  /**
391
401
  * Update the specified config field value.
@@ -395,21 +405,23 @@ class Cobalt {
395
405
  * @param {String} [workflowId] The unique ID of the workflow.
396
406
  * @returns {Promise<Field>} The updated config field.
397
407
  */
398
- async updateConfigField(slug, fieldId, value, workflowId) {
399
- const res = await fetch(`${this.baseUrl}/api/v2/public/config/field/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
400
- method: "PUT",
401
- headers: {
402
- authorization: `Bearer ${this.token}`,
403
- "content-type": "application/json",
404
- slug,
405
- },
406
- body: JSON.stringify({ value }),
408
+ updateConfigField(slug, fieldId, value, workflowId) {
409
+ return __awaiter(this, void 0, void 0, function* () {
410
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/config/field/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
411
+ method: "PUT",
412
+ headers: {
413
+ authorization: `Bearer ${this.token}`,
414
+ "content-type": "application/json",
415
+ slug,
416
+ },
417
+ body: JSON.stringify({ value }),
418
+ });
419
+ if (res.status >= 400 && res.status < 600) {
420
+ const error = yield res.json();
421
+ throw error;
422
+ }
423
+ return yield res.json();
407
424
  });
408
- if (res.status >= 400 && res.status < 600) {
409
- const error = await res.json();
410
- throw error;
411
- }
412
- return await res.json();
413
425
  }
414
426
  /**
415
427
  * Delete the specified config field value.
@@ -418,19 +430,21 @@ class Cobalt {
418
430
  * @param {String} [workflowId] The unique ID of the workflow.
419
431
  * @returns {Promise<unknown>}
420
432
  */
421
- async deleteConfigField(slug, fieldId, workflowId) {
422
- const res = await fetch(`${this.baseUrl}/api/v2/public/config/field/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
423
- method: "DELETE",
424
- headers: {
425
- authorization: `Bearer ${this.token}`,
426
- slug,
427
- },
433
+ deleteConfigField(slug, fieldId, workflowId) {
434
+ return __awaiter(this, void 0, void 0, function* () {
435
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/config/field/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
436
+ method: "DELETE",
437
+ headers: {
438
+ authorization: `Bearer ${this.token}`,
439
+ slug,
440
+ },
441
+ });
442
+ if (res.status >= 400 && res.status < 600) {
443
+ const error = yield res.json();
444
+ throw error;
445
+ }
446
+ return yield res.json();
428
447
  });
429
- if (res.status >= 400 && res.status < 600) {
430
- const error = await res.json();
431
- throw error;
432
- }
433
- return await res.json();
434
448
  }
435
449
  /**
436
450
  * Returns the options for the specified field.
@@ -440,43 +454,58 @@ class Cobalt {
440
454
  * @param {String} [workflowId] The unique ID of the workflow, if this is a workflow field.
441
455
  * @returns {Promise<RuleOptions>} The specified rule field's options.
442
456
  */
443
- async getFieldOptions(lhs, slug, fieldId, workflowId) {
444
- const res = await fetch(`${this.baseUrl}/api/v2/public/config/rule-engine/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
445
- method: "POST",
446
- headers: {
447
- authorization: `Bearer ${this.token}`,
448
- "content-type": "application/json",
449
- slug,
450
- },
451
- body: JSON.stringify({
452
- rule_column: { lhs },
453
- }),
457
+ getFieldOptions(lhs, slug, fieldId, workflowId) {
458
+ return __awaiter(this, void 0, void 0, function* () {
459
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/config/rule-engine/${fieldId}${workflowId ? `?workflow_id=${workflowId}` : ""}`, {
460
+ method: "POST",
461
+ headers: {
462
+ authorization: `Bearer ${this.token}`,
463
+ "content-type": "application/json",
464
+ slug,
465
+ },
466
+ body: JSON.stringify({
467
+ rule_column: { lhs },
468
+ }),
469
+ });
470
+ if (res.status >= 400 && res.status < 600) {
471
+ const error = yield res.json();
472
+ throw error;
473
+ }
474
+ return yield res.json();
454
475
  });
455
- if (res.status >= 400 && res.status < 600) {
456
- const error = await res.json();
457
- throw error;
458
- }
459
- return await res.json();
460
476
  }
461
477
  /**
462
478
  * Returns the private workflows for the specified application.
463
479
  * @param {Object} params
464
480
  * @param {String} [params.slug]
481
+ * @param {String} [params.name]
465
482
  * @param {Number} [params.page]
466
483
  * @param {Number} [params.limit]
484
+ * @param {String} [params.start_date] ISO date string — filter workflows created on or after this date.
485
+ * @param {String} [params.end_date] ISO date string — filter workflows created on or before this date.
486
+ * @param {Boolean} [params.published] Filter by workflow published status.
467
487
  * @returns
468
488
  */
469
- async getWorkflows(params) {
470
- const res = await fetch(`${this.baseUrl}/api/v2/public/workflow?page=${params?.page || 1}&limit=${params?.limit || 100}${params?.slug ? `&slug=${params.slug}` : ""}`, {
471
- headers: {
472
- authorization: `Bearer ${this.token}`,
473
- },
489
+ getWorkflows() {
490
+ return __awaiter(this, arguments, void 0, function* (_a = {}) {
491
+ var { page = 1, limit = 100 } = _a, rest = __rest(_a, ["page", "limit"]);
492
+ const query = new URLSearchParams({ page: String(page), limit: String(limit) });
493
+ for (const key of Object.keys(rest)) {
494
+ const value = rest[key];
495
+ if (value !== undefined && value !== "")
496
+ query.set(key, String(value));
497
+ }
498
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/workflow?${query}`, {
499
+ headers: {
500
+ authorization: `Bearer ${this.token}`,
501
+ },
502
+ });
503
+ if (res.status >= 400 && res.status < 600) {
504
+ const error = yield res.json();
505
+ throw error;
506
+ }
507
+ return yield res.json();
474
508
  });
475
- if (res.status >= 400 && res.status < 600) {
476
- const error = await res.json();
477
- throw error;
478
- }
479
- return await res.json();
480
509
  }
481
510
  /**
482
511
  * Create a public workflow for the linked account.
@@ -487,60 +516,67 @@ class Cobalt {
487
516
  * If slug isn't set, the workflow will be created in the organization's default application.
488
517
  * @returns {Promise<PublicWorkflow>} The created public workflow.
489
518
  */
490
- async createWorkflow(params) {
491
- const res = await fetch(`${this.baseUrl}/api/v2/public/workflow`, {
492
- method: "POST",
493
- headers: {
494
- authorization: `Bearer ${this.token}`,
495
- "content-type": "application/json",
496
- },
497
- body: JSON.stringify({
498
- name: params.name,
499
- description: params.description,
500
- slug: params.slug,
501
- }),
519
+ createWorkflow(params) {
520
+ return __awaiter(this, void 0, void 0, function* () {
521
+ var _a;
522
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/workflow`, {
523
+ method: "POST",
524
+ headers: {
525
+ authorization: `Bearer ${this.token}`,
526
+ "content-type": "application/json",
527
+ },
528
+ body: JSON.stringify({
529
+ name: params.name,
530
+ description: params.description,
531
+ slug: params.slug,
532
+ }),
533
+ });
534
+ if (res.status >= 400 && res.status < 600) {
535
+ const error = yield res.json();
536
+ throw error;
537
+ }
538
+ const data = yield res.json();
539
+ return (_a = data === null || data === void 0 ? void 0 : data.workflow) !== null && _a !== void 0 ? _a : data;
502
540
  });
503
- if (res.status >= 400 && res.status < 600) {
504
- const error = await res.json();
505
- throw error;
506
- }
507
- const data = await res.json();
508
- return data?.workflow ?? data;
509
541
  }
510
542
  /**
511
543
  * Delete the specified public workflow.
512
544
  * @param {String} workflowId The workflow ID.
513
545
  * @returns {Promise<unknown>}
514
546
  */
515
- async deleteWorkflow(workflowId) {
516
- const res = await fetch(`${this.baseUrl}/api/v2/public/workflow/${workflowId}`, {
517
- method: "DELETE",
518
- headers: {
519
- authorization: `Bearer ${this.token}`,
520
- },
547
+ deleteWorkflow(workflowId) {
548
+ return __awaiter(this, void 0, void 0, function* () {
549
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/workflow/${workflowId}`, {
550
+ method: "DELETE",
551
+ headers: {
552
+ authorization: `Bearer ${this.token}`,
553
+ },
554
+ });
555
+ if (res.status >= 400 && res.status < 600) {
556
+ const error = yield res.json();
557
+ throw error;
558
+ }
559
+ return yield res.json();
521
560
  });
522
- if (res.status >= 400 && res.status < 600) {
523
- const error = await res.json();
524
- throw error;
525
- }
526
- return await res.json();
527
561
  }
528
562
  /**
529
563
  * Returns the execution payload for the specified public workflow.
530
564
  * @param {String} workflowId The workflow ID.
531
565
  * @returns {Promise<WorkflowPayloadResponse>} The workflow payload response.
532
566
  */
533
- async getWorkflowPayload(workflowId) {
534
- const res = await fetch(`${this.baseUrl}/api/v2/public/workflow/request-structure/${workflowId}`, {
535
- headers: {
536
- authorization: `Bearer ${this.token}`,
537
- },
567
+ getWorkflowPayload(workflowId) {
568
+ return __awaiter(this, void 0, void 0, function* () {
569
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/workflow/request-structure/${workflowId}`, {
570
+ headers: {
571
+ authorization: `Bearer ${this.token}`,
572
+ },
573
+ });
574
+ if (res.status >= 400 && res.status < 600) {
575
+ const error = yield res.json();
576
+ throw error;
577
+ }
578
+ return yield res.json();
538
579
  });
539
- if (res.status >= 400 && res.status < 600) {
540
- const error = await res.json();
541
- throw error;
542
- }
543
- return await res.json();
544
580
  }
545
581
  /**
546
582
  * Execute the specified public workflow.
@@ -550,58 +586,78 @@ class Cobalt {
550
586
  * @param {Record<string, any>} [options.payload] The execution payload.
551
587
  * @returns {Promise<unknown>}
552
588
  */
553
- async executeWorkflow(options) {
554
- const res = await fetch(`${this.baseUrl}/api/v2/public/workflow/${options?.worklfow}/execute`, {
555
- method: "POST",
556
- headers: {
557
- authorization: `Bearer ${this.token}`,
558
- "content-type": "application/json",
559
- slug: options?.slug || "",
560
- sync_execution: options?.sync_execution ? "true" : "false",
561
- },
562
- body: JSON.stringify(options?.payload),
589
+ executeWorkflow(options) {
590
+ return __awaiter(this, void 0, void 0, function* () {
591
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/workflow/${options === null || options === void 0 ? void 0 : options.worklfow}/execute`, {
592
+ method: "POST",
593
+ headers: {
594
+ authorization: `Bearer ${this.token}`,
595
+ "content-type": "application/json",
596
+ slug: (options === null || options === void 0 ? void 0 : options.slug) || "",
597
+ sync_execution: (options === null || options === void 0 ? void 0 : options.sync_execution) ? "true" : "false",
598
+ },
599
+ body: JSON.stringify(options === null || options === void 0 ? void 0 : options.payload),
600
+ });
601
+ if (res.status >= 400 && res.status < 600) {
602
+ const error = yield res.json();
603
+ throw error;
604
+ }
605
+ return yield res.json();
563
606
  });
564
- if (res.status >= 400 && res.status < 600) {
565
- const error = await res.json();
566
- throw error;
567
- }
568
- return await res.json();
569
607
  }
570
608
  /**
571
609
  * Returns the workflow execution logs for the linked account.
572
610
  * @param {Object} [params]
573
611
  * @param {Number} [params.page]
574
612
  * @param {Number} [params.limit]
613
+ * @param {String} [params.status] - Filter by execution status (COMPLETED, RUNNING, ERRORED, STOPPED, STOPPING, TIMED_OUT)
614
+ * @param {String} [params.workflow_name] - Filter by workflow name
615
+ * @param {String} [params.workflow_id] - Filter by workflow ID
616
+ * @param {String} [params.start_date] - Filter executions after this date
617
+ * @param {String} [params.end_date] - Filter executions before this date
618
+ * @param {String} [params.execution_type] - Filter by execution type (SYNC, ASYNC)
619
+ * @param {String} [params.execution_source] - Filter by execution source (Event, Schedule, API Call)
575
620
  * @returns {Promise<PaginatedResponse<Execution>>} The paginated workflow execution logs.
576
621
  */
577
- async getExecutions({ page = 1, limit = 10 } = {}) {
578
- const res = await fetch(`${this.baseUrl}/api/v2/public/execution?page=${page}&limit=${limit}`, {
579
- headers: {
580
- authorization: `Bearer ${this.token}`,
581
- },
622
+ getExecutions() {
623
+ return __awaiter(this, arguments, void 0, function* (_a = {}) {
624
+ var { page = 1, limit = 10 } = _a, rest = __rest(_a, ["page", "limit"]);
625
+ const query = new URLSearchParams({ page: String(page), limit: String(limit) });
626
+ for (const key of Object.keys(rest)) {
627
+ const value = rest[key];
628
+ if (value !== undefined && value !== "")
629
+ query.set(key, String(value));
630
+ }
631
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/execution?${query}`, {
632
+ headers: {
633
+ authorization: `Bearer ${this.token}`,
634
+ },
635
+ });
636
+ if (res.status >= 400 && res.status < 600) {
637
+ const error = yield res.json();
638
+ throw error;
639
+ }
640
+ return yield res.json();
582
641
  });
583
- if (res.status >= 400 && res.status < 600) {
584
- const error = await res.json();
585
- throw error;
586
- }
587
- return await res.json();
588
642
  }
589
643
  /**
590
644
  * Returns the specified workflow execution log.
591
645
  * @param {String} executionId The execution ID.
592
646
  * @returns {Promise<Execution>} The specified execution log.
593
647
  */
594
- async getExecution(executionId) {
595
- const res = await fetch(`${this.baseUrl}/api/v2/public/execution/${executionId}`, {
596
- headers: {
597
- authorization: `Bearer ${this.token}`,
598
- },
648
+ getExecution(executionId) {
649
+ return __awaiter(this, void 0, void 0, function* () {
650
+ const res = yield fetch(`${this.baseUrl}/api/v2/public/execution/${executionId}`, {
651
+ headers: {
652
+ authorization: `Bearer ${this.token}`,
653
+ },
654
+ });
655
+ if (res.status >= 400 && res.status < 600) {
656
+ const error = yield res.json();
657
+ throw error;
658
+ }
659
+ return yield res.json();
599
660
  });
600
- if (res.status >= 400 && res.status < 600) {
601
- const error = await res.json();
602
- throw error;
603
- }
604
- return await res.json();
605
661
  }
606
662
  }
607
663
  exports.Cobalt = Cobalt;