@cobaltio/cobalt-js 9.2.1 → 9.3.0-beta.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 (41) hide show
  1. package/.github/workflows/npm-publish.yml +10 -2
  2. package/cobalt.d.ts +61 -20
  3. package/cobalt.js +377 -410
  4. package/cobalt.ts +120 -34
  5. package/docs/assets/hierarchy.js +1 -1
  6. package/docs/assets/navigation.js +1 -1
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/Cobalt.html +32 -26
  9. package/docs/enums/AuthStatus.html +2 -2
  10. package/docs/enums/AuthType.html +2 -2
  11. package/docs/hierarchy.html +1 -1
  12. package/docs/interfaces/Application.html +14 -18
  13. package/docs/interfaces/AuthConfig.html +9 -0
  14. package/docs/interfaces/CobaltOptions.html +3 -3
  15. package/docs/interfaces/Config.html +2 -2
  16. package/docs/interfaces/ConfigField.html +4 -4
  17. package/docs/interfaces/ConfigPayload.html +4 -4
  18. package/docs/interfaces/ConfigWorkflow.html +2 -2
  19. package/docs/interfaces/ConnectedAccount.html +14 -0
  20. package/docs/interfaces/ExecuteWorkflowPayload.html +5 -5
  21. package/docs/interfaces/Execution.html +2 -2
  22. package/docs/interfaces/ExecutionFilters.html +8 -8
  23. package/docs/interfaces/GetExecutionsParams.html +9 -9
  24. package/docs/interfaces/InputField.html +9 -9
  25. package/docs/interfaces/KeyBasedParams.html +7 -0
  26. package/docs/interfaces/Label.html +3 -3
  27. package/docs/interfaces/OAuthParams.html +9 -0
  28. package/docs/interfaces/PublicWorkflow.html +8 -8
  29. package/docs/interfaces/PublicWorkflowPayload.html +4 -4
  30. package/docs/interfaces/PublicWorkflowsPayload.html +7 -7
  31. package/docs/interfaces/RuleOptions.html +2 -2
  32. package/docs/interfaces/UpdateConfigPayload.html +5 -5
  33. package/docs/interfaces/WorkflowPayload.html +4 -4
  34. package/docs/interfaces/WorkflowPayloadResponse.html +2 -2
  35. package/docs/llms.txt +282 -197
  36. package/docs/modules.html +1 -1
  37. package/docs/types/ExecutionSource.html +1 -1
  38. package/docs/types/ExecutionStatus.html +1 -1
  39. package/docs/types/ExecutionType.html +1 -1
  40. package/package.json +1 -1
  41. package/tsconfig.json +12 -12
@@ -30,6 +30,14 @@ jobs:
30
30
  node-version: 24
31
31
  registry-url: https://registry.npmjs.org/
32
32
  - run: npm ci
33
- - run: npm publish
33
+ - name: Set npm tag
34
+ id: tag
35
+ run: |
36
+ if [ "${{ github.event.release.prerelease }}" = "true" ]; then
37
+ echo "tag=beta" >> $GITHUB_OUTPUT
38
+ else
39
+ echo "tag=latest" >> $GITHUB_OUTPUT
40
+ fi
41
+ - run: npm publish --tag ${{ steps.tag.outputs.tag }}
34
42
  env:
35
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
43
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/cobalt.d.ts CHANGED
@@ -9,6 +9,21 @@ export declare enum AuthStatus {
9
9
  Active = "active",
10
10
  Expired = "expired"
11
11
  }
12
+ /** A connected account for an application. */
13
+ export interface ConnectedAccount {
14
+ /** The unique identifier for this connected account. */
15
+ connection_id: string;
16
+ /** The identifier of the auth config. */
17
+ auth_config_id: string;
18
+ /** The identifier (username, email, etc.) of the connected account. */
19
+ identifier: unknown;
20
+ /** The auth type used to connect the account. */
21
+ auth_type: AuthType;
22
+ /** The timestamp at which the account was connected. */
23
+ connectedAt: string;
24
+ /** The current status of the connection. */
25
+ status?: AuthStatus;
26
+ }
12
27
  /** An application in Cobalt. */
13
28
  export interface Application {
14
29
  /** Application ID */
@@ -33,16 +48,7 @@ export interface Application {
33
48
  [key in AuthType]: InputField[];
34
49
  };
35
50
  /** 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
- }[];
51
+ connected_accounts?: ConnectedAccount[];
46
52
  /**
47
53
  * The type of auth used by application.
48
54
  * @deprecated Check `auth_type_options` and `connected_accounts` for multiple auth types support.
@@ -64,6 +70,16 @@ export interface Application {
64
70
  */
65
71
  auth_input_map?: InputField[];
66
72
  }
73
+ export interface AuthConfig {
74
+ /** The auth config ID. */
75
+ _id: string;
76
+ /** The display name of the auth config. */
77
+ name: string;
78
+ /** The description of the auth config. */
79
+ description?: string;
80
+ /** Whether the auth config is the default auth config for the application. */
81
+ is_default?: boolean;
82
+ }
67
83
  /** An Input field to take input from the user. */
68
84
  export interface InputField {
69
85
  /** Key name of the field. */
@@ -86,6 +102,24 @@ export interface InputField {
86
102
  value: string;
87
103
  }[];
88
104
  }
105
+ export interface OAuthParams {
106
+ /** The application slug. */
107
+ slug: string;
108
+ /** The identifier of the auth config. */
109
+ authConfig?: string;
110
+ /** The key value pairs of auth data. */
111
+ payload?: Record<string, string>;
112
+ /** Whether to close the authentication window automatically. */
113
+ autoClose?: boolean;
114
+ }
115
+ export interface KeyBasedParams {
116
+ /** The application slug. */
117
+ slug: string;
118
+ /** The identifier of the auth config. */
119
+ authConfig?: string;
120
+ /** The key value pairs of auth data. */
121
+ payload?: Record<string, string>;
122
+ }
89
123
  /** The payload object for config. */
90
124
  export interface ConfigPayload {
91
125
  /** The application slug. */
@@ -372,27 +406,30 @@ declare class Cobalt {
372
406
  * @returns {Promise<Application[]>} The list of applications.
373
407
  */
374
408
  getApps(): Promise<Application[]>;
409
+ /**
410
+ * Returns the auth configs for the specified application.
411
+ * @param {String} slug The application slug.
412
+ * @returns {Promise<AuthConfig[]>} The auth configs.
413
+ */
414
+ getAuthConfigs(slug: string): Promise<AuthConfig[]>;
375
415
  /**
376
416
  * Returns the auth URL that users can use to authenticate themselves to the
377
417
  * specified application.
378
418
  * @private
379
- * @param {String} slug The application slug.
380
- * @param {Object.<string, string>} [params] The key value pairs of auth data.
419
+ * @param {OAuthParams} params The OAuth parameters.
381
420
  * @returns {Promise<String>} The auth URL where users can authenticate themselves.
382
421
  */
383
422
  private getOAuthUrl;
384
423
  /**
385
424
  * Handle OAuth for the specified application.
386
425
  * @private
387
- * @param {String} slug The application slug.
388
- * @param {Object.<string, string>} [params] The key value pairs of auth data.
426
+ * @param {OAuthParams} params The OAuth parameters.
389
427
  * @returns {Promise<Boolean>} Whether the user authenticated.
390
428
  */
391
429
  private oauth;
392
430
  /**
393
431
  * Save auth data for the specified keybased application.
394
- * @param {String} slug The application slug.
395
- * @param {Object.<string, string>} [payload] The key value pairs of auth data.
432
+ * @param {KeyBasedParams} params The key based parameters.
396
433
  * @returns {Promise<Boolean>} Whether the auth data was saved successfully.
397
434
  */
398
435
  private keybased;
@@ -400,23 +437,28 @@ declare class Cobalt {
400
437
  * Connects the specified application using the provided authentication type and optional auth data.
401
438
  * @param params - The parameters for connecting the application.
402
439
  * @param params.slug - The application slug.
440
+ * @param params.authConfig - The identifier of the auth config.
403
441
  * @param params.type - The authentication type to use. If not provided, it defaults to `keybased` if payload is provided, otherwise `oauth2`.
404
442
  * @param params.payload - key-value pairs of authentication data required for the specified auth type.
443
+ * @param params.autoClose - Whether to close the authentication window automatically. If not provided, it defaults to `true`.
405
444
  * @returns A promise that resolves to true if the connection was successful, otherwise false.
406
445
  * @throws Throws an error if the authentication type is invalid or the connection fails.
407
446
  */
408
- connect({ slug, type, payload, }: {
447
+ connect({ slug, authConfig, type, payload, autoClose, }: {
409
448
  slug: string;
449
+ authConfig?: string;
410
450
  type?: AuthType;
411
451
  payload?: Record<string, string>;
452
+ autoClose?: boolean;
412
453
  }): Promise<boolean>;
413
454
  /**
414
455
  * Disconnect the specified application and remove any associated data from Cobalt.
415
456
  * @param {String} slug The application slug.
416
457
  * @param {AuthType} [type] The authentication type to use. If not provided, it'll remove all the connected accounts.
458
+ * @param {String} [authConfig] The identifier of the auth config.
417
459
  * @returns {Promise<unknown>}
418
460
  */
419
- disconnect(slug: string, type?: AuthType): Promise<unknown>;
461
+ disconnect(slug: string, type?: AuthType, authConfig?: string): Promise<unknown>;
420
462
  /**
421
463
  * Returns the specified config, or creates one if it doesn't exist.
422
464
  * @param {ConfigPayload} payload The payload object for config.
@@ -435,10 +477,9 @@ declare class Cobalt {
435
477
  * Returns the specified config.
436
478
  * @param {String} slug The application slug.
437
479
  * @param {String} [configId] The unique ID of the config.
438
- * @param {Boolean} [excludeOptions] Whether to exclude the options from the fields in the response.
439
480
  * @returns {Promise<Config>} The specified config.
440
481
  */
441
- getConfig(slug: string, configId: string, excludeOptions?: boolean): Promise<Config>;
482
+ getConfig(slug: string, configId: string): Promise<Config>;
442
483
  /**
443
484
  * Update the specified config.
444
485
  * @param {UpdateConfigPayload} payload The update payload.