@cobaltio/cobalt-js 8.9.1 → 8.9.2-beta.2

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/cobalt.d.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  /**
2
2
  * Cobalt Frontend SDK
3
3
  */
4
+ export declare enum AuthType {
5
+ OAuth2 = "oauth2",
6
+ KeyBased = "keybased"
7
+ }
8
+ export declare enum AuthStatus {
9
+ Active = "active",
10
+ Expired = "expired"
11
+ }
4
12
  /** An application in Cobalt. */
5
13
  export interface Application {
6
14
  /** Application ID */
@@ -18,16 +26,43 @@ export interface Application {
18
26
  type: string | "custom";
19
27
  /** The application slug. */
20
28
  slug: string;
21
- /**The type of auth used by application. */
29
+ /** The categories/tags for the application. */
30
+ tags?: string[];
31
+ /** The supported auth types for the application, and the fields required from the user to connect the application. */
32
+ auth_type_options?: {
33
+ [key in AuthType]: InputField[];
34
+ };
35
+ /** The list of connected accounts for this application */
36
+ connected_accounts?: {
37
+ /** The identifier (username, email, etc.) of the connected account. */
38
+ identifier: unknown;
39
+ /** The auth type used to connect the account. */
40
+ auth_type: AuthType;
41
+ /** The timestamp at which the account was connected. */
42
+ connectedAt: string;
43
+ /** The current status of the connection. */
44
+ status?: AuthStatus;
45
+ }[];
46
+ /**
47
+ * The type of auth used by application.
48
+ * @deprecated Check `auth_type_options` and `connected_accounts` for multiple auth types support.
49
+ */
22
50
  auth_type: "oauth2" | "keybased";
23
- /** Whether the user has connected the application. */
51
+ /**
52
+ * Whether the user has connected the application.
53
+ * @deprecated Check `connected_accounts` for multiple auth types support.
54
+ */
24
55
  connected?: boolean;
25
- /** Whether the connection has expired and re-auth is required. */
56
+ /**
57
+ * Whether the connection has expired and re-auth is required.
58
+ * @deprecated Check `connected_accounts` for multiple auth types support.
59
+ */
26
60
  reauth_required?: boolean;
27
- /** The fields required from the user to connect the application (for `keybased` auth type). */
61
+ /**
62
+ * The fields required from the user to connect the application (for `keybased` auth type).
63
+ * @deprecated Check `auth_type_options` for multiple auth types support.
64
+ */
28
65
  auth_input_map?: InputField[];
29
- /** The categories/tags for the application. */
30
- tags?: string[];
31
66
  }
32
67
  /** An Input field to take input from the user. */
33
68
  export interface InputField {
@@ -248,6 +283,18 @@ export interface Execution {
248
283
  associated_event_id: string;
249
284
  custom_trigger_id?: string;
250
285
  custom_application_id?: string;
286
+ completion_percentage?: number;
287
+ nodes?: {
288
+ node_id: string;
289
+ node_name: string;
290
+ node_type: string;
291
+ node_status: "Success" | "Ready" | "Errored" | "Waiting" | "Stopped" | "Rejected" | "Errored_and_Skipped" | "Timed_Out";
292
+ is_batch?: boolean;
293
+ attempts_made: number;
294
+ maximum_attempts: number;
295
+ input_data: unknown;
296
+ latest_output: unknown;
297
+ }[];
251
298
  createdAt: string;
252
299
  }
253
300
  declare class Cobalt {
package/cobalt.js CHANGED
@@ -12,7 +12,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  });
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.Cobalt = void 0;
15
+ exports.Cobalt = exports.AuthStatus = exports.AuthType = void 0;
16
+ var AuthType;
17
+ (function (AuthType) {
18
+ AuthType["OAuth2"] = "oauth2";
19
+ AuthType["KeyBased"] = "keybased";
20
+ })(AuthType || (exports.AuthType = AuthType = {}));
21
+ var AuthStatus;
22
+ (function (AuthStatus) {
23
+ AuthStatus["Active"] = "active";
24
+ AuthStatus["Expired"] = "expired";
25
+ })(AuthStatus || (exports.AuthStatus = AuthStatus = {}));
16
26
  class Cobalt {
17
27
  /**
18
28
  * Cobalt Frontend SDK
@@ -152,7 +162,8 @@ class Cobalt {
152
162
  const interval = setInterval(() => {
153
163
  this.getApp(slug)
154
164
  .then(app => {
155
- if (app && app.connected === true && !app.reauth_required) {
165
+ var _a;
166
+ 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))) {
156
167
  // close auth window
157
168
  connectWindow && connectWindow.close();
158
169
  // clear interval
@@ -194,7 +205,7 @@ class Cobalt {
194
205
  try {
195
206
  const app = yield this.getApp(slug);
196
207
  // oauth
197
- if (app && app.auth_type === "oauth2") {
208
+ if (app && app.auth_type === AuthType.OAuth2) {
198
209
  const connected = yield this.oauth(slug, payload);
199
210
  resolve(connected);
200
211
  // key based
package/cobalt.ts CHANGED
@@ -2,6 +2,16 @@
2
2
  * Cobalt Frontend SDK
3
3
  */
4
4
 
5
+ export enum AuthType {
6
+ OAuth2 = "oauth2",
7
+ KeyBased = "keybased",
8
+ }
9
+
10
+ export enum AuthStatus {
11
+ Active = "active",
12
+ Expired = "expired",
13
+ }
14
+
5
15
  /** An application in Cobalt. */
6
16
  export interface Application {
7
17
  /** Application ID */
@@ -19,16 +29,44 @@ export interface Application {
19
29
  type: string | "custom";
20
30
  /** The application slug. */
21
31
  slug: string;
22
- /**The type of auth used by application. */
32
+ /** The categories/tags for the application. */
33
+ tags?: string[];
34
+ /** The supported auth types for the application, and the fields required from the user to connect the application. */
35
+ auth_type_options?: {
36
+ /** The fields required from the user to connect the application. */
37
+ [key in AuthType]: InputField[];
38
+ };
39
+ /** The list of connected accounts for this application */
40
+ connected_accounts?: {
41
+ /** The identifier (username, email, etc.) of the connected account. */
42
+ identifier: unknown;
43
+ /** The auth type used to connect the account. */
44
+ auth_type: AuthType;
45
+ /** The timestamp at which the account was connected. */
46
+ connectedAt: string;
47
+ /** The current status of the connection. */
48
+ status?: AuthStatus;
49
+ }[];
50
+ /**
51
+ * The type of auth used by application.
52
+ * @deprecated Check `auth_type_options` and `connected_accounts` for multiple auth types support.
53
+ */
23
54
  auth_type: "oauth2" | "keybased";
24
- /** Whether the user has connected the application. */
55
+ /**
56
+ * Whether the user has connected the application.
57
+ * @deprecated Check `connected_accounts` for multiple auth types support.
58
+ */
25
59
  connected?: boolean;
26
- /** Whether the connection has expired and re-auth is required. */
60
+ /**
61
+ * Whether the connection has expired and re-auth is required.
62
+ * @deprecated Check `connected_accounts` for multiple auth types support.
63
+ */
27
64
  reauth_required?: boolean;
28
- /** The fields required from the user to connect the application (for `keybased` auth type). */
65
+ /**
66
+ * The fields required from the user to connect the application (for `keybased` auth type).
67
+ * @deprecated Check `auth_type_options` for multiple auth types support.
68
+ */
29
69
  auth_input_map?: InputField[];
30
- /** The categories/tags for the application. */
31
- tags?: string[];
32
70
  }
33
71
 
34
72
  /** An Input field to take input from the user. */
@@ -244,12 +282,12 @@ export interface Execution {
244
282
  _id: string;
245
283
  name: string;
246
284
  icon?: string;
247
- },
248
- status: "COMPLETED" | "RUNNING" | "ERRORED" | "STOPPED" | "STOPPING" | "TIMED_OUT",
285
+ };
286
+ status: "COMPLETED" | "RUNNING" | "ERRORED" | "STOPPED" | "STOPPING" | "TIMED_OUT";
249
287
  associated_workflow: {
250
288
  _id: string;
251
289
  name: string;
252
- },
290
+ };
253
291
  associated_trigger_application: {
254
292
  _id: string;
255
293
  name: string;
@@ -259,7 +297,7 @@ export interface Execution {
259
297
  _id: string;
260
298
  name: string;
261
299
  }
262
- },
300
+ };
263
301
  trigger_application_event?: string;
264
302
  linked_account_id: string;
265
303
  environment: "test" | "production";
@@ -267,6 +305,18 @@ export interface Execution {
267
305
  associated_event_id: string;
268
306
  custom_trigger_id?: string;
269
307
  custom_application_id?: string;
308
+ completion_percentage?: number;
309
+ nodes?: {
310
+ node_id: string;
311
+ node_name: string;
312
+ node_type: string;
313
+ node_status: "Success" | "Ready" | "Errored" | "Waiting" | "Stopped" | "Rejected"| "Errored_and_Skipped" | "Timed_Out";
314
+ is_batch?: boolean;
315
+ attempts_made: number;
316
+ maximum_attempts: number;
317
+ input_data: unknown;
318
+ latest_output: unknown;
319
+ }[];
270
320
  createdAt: string;
271
321
  }
272
322
 
@@ -434,7 +484,7 @@ class Cobalt {
434
484
  const interval = setInterval(() => {
435
485
  this.getApp(slug)
436
486
  .then(app => {
437
- if (app && app.connected === true && !app.reauth_required) {
487
+ if (app && app.connected_accounts?.filter(a => a.auth_type === AuthType.OAuth2).some(a => a.status === AuthStatus.Active)) {
438
488
  // close auth window
439
489
  connectWindow && connectWindow.close();
440
490
  // clear interval
@@ -475,7 +525,7 @@ class Cobalt {
475
525
  const app = await this.getApp(slug);
476
526
 
477
527
  // oauth
478
- if (app && app.auth_type === "oauth2") {
528
+ if (app && app.auth_type === AuthType.OAuth2) {
479
529
  const connected = await this.oauth(slug, payload);
480
530
  resolve(connected);
481
531
  // key based
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobaltio/cobalt-js",
3
- "version": "8.9.1",
3
+ "version": "8.9.2-beta.2",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "typings": "./cobalt.d.ts",