@cobaltio/cobalt-js 0.1.0 → 1.0.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.
- package/README.md +107 -183
- package/cobalt.js +103 -175
- package/cobalt.min.js +1 -1
- package/docs.md +106 -182
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ yarn add @cobaltio/cobalt-js
|
|
|
21
21
|
|
|
22
22
|
#### Browser
|
|
23
23
|
```js
|
|
24
|
-
<script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@1"></script>
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
#### Node
|
|
@@ -59,17 +59,14 @@ cobalt.token = "COBALT_SESSION_TOKEN";
|
|
|
59
59
|
## Typedefs
|
|
60
60
|
|
|
61
61
|
<dl>
|
|
62
|
-
<dt><a href="#
|
|
63
|
-
<dd><p>The
|
|
62
|
+
<dt><a href="#AppConfig">AppConfig</a> : <code>object</code></dt>
|
|
63
|
+
<dd><p>The configuration data for an application.</p>
|
|
64
64
|
</dd>
|
|
65
|
-
<dt><a href="#
|
|
66
|
-
<dd><p>
|
|
65
|
+
<dt><a href="#AppInstance">AppInstance</a> : <code>Object</code></dt>
|
|
66
|
+
<dd><p>An installed application.</p>
|
|
67
67
|
</dd>
|
|
68
|
-
<dt><a href="#
|
|
69
|
-
<dd><p>The
|
|
70
|
-
</dd>
|
|
71
|
-
<dt><a href="#AppAuthStatus">AppAuthStatus</a> : <code>object</code></dt>
|
|
72
|
-
<dd><p>The auth status of the user for an application.</p>
|
|
68
|
+
<dt><a href="#WorkflowTemplate">WorkflowTemplate</a> : <code>Object</code></dt>
|
|
69
|
+
<dd><p>The workflow template.</p>
|
|
73
70
|
</dd>
|
|
74
71
|
</dl>
|
|
75
72
|
|
|
@@ -79,25 +76,25 @@ cobalt.token = "COBALT_SESSION_TOKEN";
|
|
|
79
76
|
Cobalt Frontend SDK
|
|
80
77
|
|
|
81
78
|
**Kind**: global class
|
|
79
|
+
**Properties**
|
|
80
|
+
|
|
81
|
+
| Name | Type | Description |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| token | <code>String</code> | The session token. |
|
|
84
|
+
|
|
82
85
|
|
|
83
86
|
* [Cobalt](#Cobalt)
|
|
84
87
|
* [new Cobalt(options)](#new_Cobalt_new)
|
|
85
|
-
* [.
|
|
86
|
-
* [.
|
|
87
|
-
* [.
|
|
88
|
-
* [.
|
|
89
|
-
* [.
|
|
90
|
-
* [.
|
|
91
|
-
* [.
|
|
92
|
-
* [.
|
|
93
|
-
* [.
|
|
94
|
-
* [.
|
|
95
|
-
* [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
96
|
-
* [.getWorkflowConfiguration()](#Cobalt+getWorkflowConfiguration) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
97
|
-
* [.activateWorkflow()](#Cobalt+activateWorkflow) ⇒ <code>Promise.<void></code>
|
|
98
|
-
* [.activateWorkflows()](#Cobalt+activateWorkflows) ⇒ <code>Promise.<void></code>
|
|
99
|
-
* [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
100
|
-
* [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.<unknown></code>
|
|
88
|
+
* [.oauth(application)](#Cobalt+oauth) ⇒ <code>Promise.<Boolean></code>
|
|
89
|
+
* [.auth(application, payload)](#Cobalt+auth) ⇒ <code>Promise.<unknown></code>
|
|
90
|
+
* [.authCustom(applicationId, payload)](#Cobalt+authCustom) ⇒ <code>Promise.<unknown></code>
|
|
91
|
+
* [.checkAuth(application)](#Cobalt+checkAuth) ⇒ <code>Promise.<Boolean></code>
|
|
92
|
+
* [.removeAuth(application, [applicationId])](#Cobalt+removeAuth) ⇒ <code>Promise.<void></code>
|
|
93
|
+
* [.getAppConfig(application)](#Cobalt+getAppConfig) ⇒ [<code>Promise.<AppConfig></code>](#AppConfig)
|
|
94
|
+
* [.install(applicationId, payload)](#Cobalt+install) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
95
|
+
* [.getInstallation(applicationId, installationId)](#Cobalt+getInstallation) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
96
|
+
* [.updateInstallation(applicationId, installationId, payload)](#Cobalt+updateInstallation) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
97
|
+
* [.deleteInstallation(applicationId, installationId)](#Cobalt+deleteInstallation) ⇒ <code>Promise.<unknown></code>
|
|
101
98
|
|
|
102
99
|
<a name="new_Cobalt_new"></a>
|
|
103
100
|
|
|
@@ -107,246 +104,173 @@ Cobalt Frontend SDK
|
|
|
107
104
|
|
|
108
105
|
| Param | Type | Default | Description |
|
|
109
106
|
| --- | --- | --- | --- |
|
|
110
|
-
| options | <code>
|
|
111
|
-
| [options.token] | <code>
|
|
112
|
-
| [options.baseUrl] | <code>
|
|
113
|
-
|
|
114
|
-
<a name="Cobalt+token"></a>
|
|
115
|
-
|
|
116
|
-
### cobalt.token ⇒ <code>string</code>
|
|
117
|
-
**Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
|
|
118
|
-
**Returns**: <code>string</code> - The session token.
|
|
119
|
-
<a name="Cobalt+token"></a>
|
|
120
|
-
|
|
121
|
-
### cobalt.token ⇒ <code>string</code>
|
|
122
|
-
**Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
|
|
123
|
-
**Returns**: <code>string</code> - The session token.
|
|
124
|
-
<a name="Cobalt+baseUrl"></a>
|
|
125
|
-
|
|
126
|
-
### cobalt.baseUrl ⇒ <code>string</code>
|
|
127
|
-
**Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
|
|
128
|
-
**Returns**: <code>string</code> - The base URL of cobalt API.
|
|
129
|
-
<a name="Cobalt+installTemplate"></a>
|
|
130
|
-
|
|
131
|
-
### cobalt.installTemplate() ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
132
|
-
Install the given template.
|
|
133
|
-
|
|
134
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
135
|
-
**Properties**
|
|
136
|
-
|
|
137
|
-
| Name | Type | Description |
|
|
138
|
-
| --- | --- | --- |
|
|
139
|
-
| templateId | <code>string</code> | The ID of the template you want to install. |
|
|
140
|
-
| udf | <code>object</code> | Custom key value pairs you want to store with the installed worklfow. |
|
|
141
|
-
|
|
142
|
-
<a name="Cobalt+getAppAuthStatus"></a>
|
|
143
|
-
|
|
144
|
-
### cobalt.getAppAuthStatus() ⇒ <code>Promise.<boolean></code>
|
|
145
|
-
Returns the auth status of the user for the specified application.
|
|
146
|
-
|
|
147
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
148
|
-
**Returns**: <code>Promise.<boolean></code> - The auth status of the user.
|
|
149
|
-
**Properties**
|
|
150
|
-
|
|
151
|
-
| Name | Type | Description |
|
|
152
|
-
| --- | --- | --- |
|
|
153
|
-
| application | <code>string</code> | The application type. |
|
|
154
|
-
|
|
155
|
-
<a name="Cobalt+getAppAuthUrl"></a>
|
|
156
|
-
|
|
157
|
-
### cobalt.getAppAuthUrl() ⇒ <code>Promise.<string></code>
|
|
158
|
-
Returns the auth URL that users can use to authenticate themselves to the
|
|
159
|
-
specified application.
|
|
160
|
-
|
|
161
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
162
|
-
**Returns**: <code>Promise.<string></code> - The auth URL where users can authenticate themselves.
|
|
163
|
-
**Properties**
|
|
164
|
-
|
|
165
|
-
| Name | Type | Description |
|
|
166
|
-
| --- | --- | --- |
|
|
167
|
-
| application | <code>string</code> | The application type. |
|
|
107
|
+
| options | <code>Object</code> | | The options to configure the Cobalt SDK. |
|
|
108
|
+
| [options.token] | <code>String</code> | | The session token. |
|
|
109
|
+
| [options.baseUrl] | <code>String</code> | <code>https://api.gocobalt.io</code> | The base URL of the Cobalt API. |
|
|
168
110
|
|
|
169
111
|
<a name="Cobalt+oauth"></a>
|
|
170
112
|
|
|
171
|
-
### cobalt.oauth() ⇒ <code>Promise.<
|
|
172
|
-
Handle OAuth for the specified application.
|
|
113
|
+
### cobalt.oauth(application) ⇒ <code>Promise.<Boolean></code>
|
|
114
|
+
Handle OAuth for the specified native application.
|
|
173
115
|
|
|
174
116
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
175
|
-
**Returns**: <code>Promise.<
|
|
176
|
-
**Properties**
|
|
117
|
+
**Returns**: <code>Promise.<Boolean></code> - Whether the user authenticated.
|
|
177
118
|
|
|
178
|
-
|
|
|
119
|
+
| Param | Type | Description |
|
|
179
120
|
| --- | --- | --- |
|
|
180
|
-
| application | <code>
|
|
121
|
+
| application | <code>String</code> | The application type. |
|
|
181
122
|
|
|
182
|
-
<a name="Cobalt+
|
|
123
|
+
<a name="Cobalt+auth"></a>
|
|
183
124
|
|
|
184
|
-
### cobalt.
|
|
125
|
+
### cobalt.auth(application, payload) ⇒ <code>Promise.<unknown></code>
|
|
185
126
|
Save the auth data that user provides to authenticate themselves to the
|
|
186
|
-
specified application.
|
|
127
|
+
specified native application.
|
|
187
128
|
|
|
188
129
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
189
|
-
**Properties**
|
|
190
130
|
|
|
191
|
-
|
|
|
131
|
+
| Param | Type | Description |
|
|
192
132
|
| --- | --- | --- |
|
|
193
|
-
| application | <code>
|
|
194
|
-
| payload | <code>
|
|
195
|
-
| appId | <code>object</code> | The application ID in case of custom applications. |
|
|
133
|
+
| application | <code>String</code> | The application type. |
|
|
134
|
+
| payload | <code>Object.<string, (string\|number\|boolean)></code> | The key value pairs of auth data. |
|
|
196
135
|
|
|
197
|
-
<a name="Cobalt+
|
|
136
|
+
<a name="Cobalt+authCustom"></a>
|
|
198
137
|
|
|
199
|
-
### cobalt.
|
|
200
|
-
|
|
138
|
+
### cobalt.authCustom(applicationId, payload) ⇒ <code>Promise.<unknown></code>
|
|
139
|
+
Save the auth data that user provides to authenticate themselves to the
|
|
140
|
+
specified custom application.
|
|
201
141
|
|
|
202
142
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
203
|
-
**Properties**
|
|
204
143
|
|
|
205
|
-
|
|
|
144
|
+
| Param | Type | Description |
|
|
206
145
|
| --- | --- | --- |
|
|
207
|
-
|
|
|
208
|
-
|
|
|
146
|
+
| applicationId | <code>String</code> | The application ID of the custom application. |
|
|
147
|
+
| payload | <code>Object.<string, (string\|number\|boolean)></code> | The key value pairs of auth data. |
|
|
209
148
|
|
|
210
|
-
<a name="Cobalt+
|
|
149
|
+
<a name="Cobalt+checkAuth"></a>
|
|
211
150
|
|
|
212
|
-
### cobalt.
|
|
213
|
-
Returns the
|
|
151
|
+
### cobalt.checkAuth(application) ⇒ <code>Promise.<Boolean></code>
|
|
152
|
+
Returns the auth status of the user for the specified application.
|
|
214
153
|
|
|
215
154
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
216
|
-
**
|
|
155
|
+
**Returns**: <code>Promise.<Boolean></code> - The auth status of the user.
|
|
217
156
|
|
|
218
|
-
|
|
|
157
|
+
| Param | Type | Description |
|
|
219
158
|
| --- | --- | --- |
|
|
220
|
-
|
|
|
221
|
-
| nodeId | <code>string</code> | The ID of the node. |
|
|
222
|
-
| fieldName | <code>string</code> | The field name for which config data is required. |
|
|
223
|
-
| selectedValues | <code>object</code> | The input data already selected for the node. |
|
|
159
|
+
| application | <code>String</code> | The application type. |
|
|
224
160
|
|
|
225
|
-
<a name="Cobalt+
|
|
161
|
+
<a name="Cobalt+removeAuth"></a>
|
|
226
162
|
|
|
227
|
-
### cobalt.
|
|
228
|
-
|
|
163
|
+
### cobalt.removeAuth(application, [applicationId]) ⇒ <code>Promise.<void></code>
|
|
164
|
+
Unauthorize the specified application and remove any associated data from Cobalt.
|
|
229
165
|
|
|
230
166
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
231
|
-
**Properties**
|
|
232
167
|
|
|
233
|
-
|
|
|
168
|
+
| Param | Type | Description |
|
|
234
169
|
| --- | --- | --- |
|
|
235
|
-
|
|
|
236
|
-
|
|
|
237
|
-
| inputData | <code>object</code> | The input data for the node. |
|
|
170
|
+
| application | <code>String</code> | The application type. |
|
|
171
|
+
| [applicationId] | <code>String</code> | The application ID in case of custom applications. |
|
|
238
172
|
|
|
239
|
-
<a name="Cobalt+
|
|
173
|
+
<a name="Cobalt+getAppConfig"></a>
|
|
240
174
|
|
|
241
|
-
### cobalt.
|
|
242
|
-
Returns the
|
|
175
|
+
### cobalt.getAppConfig(application) ⇒ [<code>Promise.<AppConfig></code>](#AppConfig)
|
|
176
|
+
Returns the configuration data for the specified application.
|
|
243
177
|
|
|
244
178
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
245
|
-
**
|
|
179
|
+
**Returns**: [<code>Promise.<AppConfig></code>](#AppConfig) - The specified application's configuration data.
|
|
246
180
|
|
|
247
|
-
|
|
|
181
|
+
| Param | Type | Description |
|
|
248
182
|
| --- | --- | --- |
|
|
249
|
-
|
|
|
183
|
+
| application | <code>String</code> | The application ID. |
|
|
250
184
|
|
|
251
|
-
<a name="Cobalt+
|
|
185
|
+
<a name="Cobalt+install"></a>
|
|
252
186
|
|
|
253
|
-
### cobalt.
|
|
254
|
-
|
|
187
|
+
### cobalt.install(applicationId, payload) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
188
|
+
Install the specified application.
|
|
255
189
|
|
|
256
190
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
257
|
-
**
|
|
191
|
+
**Returns**: [<code>Promise.<AppInstance></code>](#AppInstance) - The specified application installation.
|
|
258
192
|
|
|
259
|
-
|
|
|
193
|
+
| Param | Type | Description |
|
|
260
194
|
| --- | --- | --- |
|
|
261
|
-
|
|
|
195
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
196
|
+
| payload | [<code>AppInstance</code>](#AppInstance) | The install payload. |
|
|
262
197
|
|
|
263
|
-
<a name="Cobalt+
|
|
198
|
+
<a name="Cobalt+getInstallation"></a>
|
|
264
199
|
|
|
265
|
-
### cobalt.
|
|
266
|
-
|
|
200
|
+
### cobalt.getInstallation(applicationId, installationId) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
201
|
+
Returns the specified application installation.
|
|
267
202
|
|
|
268
203
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
269
|
-
**
|
|
204
|
+
**Returns**: [<code>Promise.<AppInstance></code>](#AppInstance) - The specified application installation.
|
|
270
205
|
|
|
271
|
-
|
|
|
206
|
+
| Param | Type | Description |
|
|
272
207
|
| --- | --- | --- |
|
|
273
|
-
|
|
|
208
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
209
|
+
| installationId | <code>String</code> | The installation ID of the application instance. |
|
|
274
210
|
|
|
275
|
-
<a name="Cobalt+
|
|
211
|
+
<a name="Cobalt+updateInstallation"></a>
|
|
276
212
|
|
|
277
|
-
### cobalt.
|
|
278
|
-
|
|
213
|
+
### cobalt.updateInstallation(applicationId, installationId, payload) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
214
|
+
Update the specified application installation.
|
|
279
215
|
|
|
280
216
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
281
|
-
**
|
|
217
|
+
**Returns**: [<code>Promise.<AppInstance></code>](#AppInstance) - The specified application installation.
|
|
282
218
|
|
|
283
|
-
|
|
|
219
|
+
| Param | Type | Description |
|
|
284
220
|
| --- | --- | --- |
|
|
285
|
-
|
|
|
221
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
222
|
+
| installationId | <code>String</code> | The installation ID of the application instance. |
|
|
223
|
+
| payload | [<code>AppInstance</code>](#AppInstance) | The update payload. |
|
|
286
224
|
|
|
287
|
-
<a name="Cobalt+
|
|
225
|
+
<a name="Cobalt+deleteInstallation"></a>
|
|
288
226
|
|
|
289
|
-
### cobalt.
|
|
290
|
-
Delete the specified
|
|
227
|
+
### cobalt.deleteInstallation(applicationId, installationId) ⇒ <code>Promise.<unknown></code>
|
|
228
|
+
Delete the specified installation.
|
|
291
229
|
|
|
292
230
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
293
|
-
**Properties**
|
|
294
|
-
|
|
295
|
-
| Name | Type | Description |
|
|
296
|
-
| --- | --- | --- |
|
|
297
|
-
| workflowId | <code>string</code> | The ID of the workflow. |
|
|
298
|
-
|
|
299
|
-
<a name="Field"></a>
|
|
300
|
-
|
|
301
|
-
## Field : <code>object</code>
|
|
302
|
-
The Node Field object available for configuration.
|
|
303
231
|
|
|
304
|
-
|
|
305
|
-
**Properties**
|
|
306
|
-
|
|
307
|
-
| Name | Type | Description |
|
|
232
|
+
| Param | Type | Description |
|
|
308
233
|
| --- | --- | --- |
|
|
309
|
-
|
|
|
310
|
-
|
|
|
311
|
-
| placeholder | <code>string</code> | The placeholder text for the field. |
|
|
312
|
-
| required | <code>boolean</code> | Whether the field is required. |
|
|
234
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
235
|
+
| installationId | <code>String</code> | The installation ID of the application instance. |
|
|
313
236
|
|
|
314
|
-
<a name="
|
|
237
|
+
<a name="AppConfig"></a>
|
|
315
238
|
|
|
316
|
-
##
|
|
317
|
-
The
|
|
239
|
+
## AppConfig : <code>object</code>
|
|
240
|
+
The configuration data for an application.
|
|
318
241
|
|
|
319
242
|
**Kind**: global typedef
|
|
320
243
|
**Properties**
|
|
321
244
|
|
|
322
245
|
| Name | Type | Description |
|
|
323
246
|
| --- | --- | --- |
|
|
324
|
-
|
|
|
325
|
-
|
|
|
326
|
-
| fields | [<code>Array.<Field></code>](#Field) | The applications integrated in the workflow. |
|
|
247
|
+
| application_data_slots | <code>Array.<DataSlot></code> | Array of application data slots. |
|
|
248
|
+
| templates | <code>Array.<Template></code> | Array of workflow templates. |
|
|
327
249
|
|
|
328
|
-
<a name="
|
|
250
|
+
<a name="AppInstance"></a>
|
|
329
251
|
|
|
330
|
-
##
|
|
331
|
-
|
|
252
|
+
## AppInstance : <code>Object</code>
|
|
253
|
+
An installed application.
|
|
332
254
|
|
|
333
255
|
**Kind**: global typedef
|
|
334
256
|
**Properties**
|
|
335
257
|
|
|
336
258
|
| Name | Type | Description |
|
|
337
259
|
| --- | --- | --- |
|
|
338
|
-
|
|
|
339
|
-
|
|
|
340
|
-
|
|
|
260
|
+
| [intallation_id] | <code>String</code> | Unique ID for the installation. |
|
|
261
|
+
| application_data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of application data slots and their values. |
|
|
262
|
+
| templates | [<code>Array.<WorkflowTemplate></code>](#WorkflowTemplate) | Whether the workflow template is enabled. |
|
|
341
263
|
|
|
342
|
-
<a name="
|
|
264
|
+
<a name="WorkflowTemplate"></a>
|
|
343
265
|
|
|
344
|
-
##
|
|
345
|
-
The
|
|
266
|
+
## WorkflowTemplate : <code>Object</code>
|
|
267
|
+
The workflow template.
|
|
346
268
|
|
|
347
269
|
**Kind**: global typedef
|
|
348
270
|
**Properties**
|
|
349
271
|
|
|
350
272
|
| Name | Type | Description |
|
|
351
273
|
| --- | --- | --- |
|
|
352
|
-
|
|
|
274
|
+
| id | <code>String</code> | The ID of the workflow template. |
|
|
275
|
+
| enabled | <code>Boolean</code> | Whether the workflow template is enabled. |
|
|
276
|
+
| data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of workflow template's data slots and their values. |
|
package/cobalt.js
CHANGED
|
@@ -1,116 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cobalt Frontend SDK
|
|
3
|
+
* @property {String} token The session token.
|
|
3
4
|
*/
|
|
4
5
|
class Cobalt {
|
|
5
6
|
/**
|
|
6
7
|
* Cobalt Frontend SDK
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
8
|
+
* @param {Object} options The options to configure the Cobalt SDK.
|
|
9
|
+
* @param {String} [options.token] The session token.
|
|
10
|
+
* @param {String} [options.baseUrl=https://api.gocobalt.io] The base URL of the Cobalt API.
|
|
10
11
|
*/
|
|
11
12
|
constructor(options) {
|
|
12
|
-
this.
|
|
13
|
+
this.baseUrl = options?.baseUrl || "https://api.gocobalt.io";
|
|
13
14
|
this.token = options?.token;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
* @returns {string} The session token.
|
|
18
|
-
*/
|
|
19
17
|
get token() {
|
|
20
18
|
return this.sessionToken;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
/**
|
|
24
|
-
* @returns {string} The session token.
|
|
25
|
-
*/
|
|
26
21
|
set token(token) {
|
|
27
22
|
return this.sessionToken = typeof token === "string" ? token : "";
|
|
28
23
|
};
|
|
29
24
|
|
|
30
|
-
/**
|
|
31
|
-
* @returns {string} The base URL of cobalt API.
|
|
32
|
-
*/
|
|
33
|
-
get baseUrl() {
|
|
34
|
-
return this.apiBaseUrl;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {object} Field The Node Field object available for configuration.
|
|
39
|
-
* @property {string} name The field name.
|
|
40
|
-
* @property {string} type The input type of the field.
|
|
41
|
-
* @property {string} placeholder The placeholder text for the field.
|
|
42
|
-
* @property {boolean} required Whether the field is required.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @typedef {object} Node The Node object available for configuration.
|
|
47
|
-
* @property {string} node_id The ID of the installed workflow.
|
|
48
|
-
* @property {string} node_name The Name of the installed workflow.
|
|
49
|
-
* @property {Field[]} fields The applications integrated in the workflow.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @typedef {object} Workflow The installed workflow.
|
|
54
|
-
* @property {string} workflow_id The ID of the installed workflow.
|
|
55
|
-
* @property {unknown[]} applications The applications integrated in the workflow.
|
|
56
|
-
* @property {Node[]} configure The configuration data for the workflow.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @typedef {object} AppAuthStatus The auth status of the user for an application.
|
|
61
|
-
* @property {boolean} status Whether the user has authenticated with this application.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Install the given template.
|
|
66
|
-
* @property {string} templateId The ID of the template you want to install.
|
|
67
|
-
* @property {object} udf Custom key value pairs you want to store with the installed worklfow.
|
|
68
|
-
* @returns {Promise<Workflow>}
|
|
69
|
-
*/
|
|
70
|
-
async installTemplate(templateId, udf = {}) {
|
|
71
|
-
const res = await fetch(`${this.baseUrl}/api/v1/template/install/${templateId}`, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers: {
|
|
74
|
-
authorization: `Bearer ${this.token}`,
|
|
75
|
-
"content-type": "application/json",
|
|
76
|
-
},
|
|
77
|
-
body: JSON.stringify({ udf }),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
if (res.status >= 400 && res.status < 600) {
|
|
81
|
-
throw new Error(res.statusText);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return await res.json();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Returns the auth status of the user for the specified application.
|
|
89
|
-
* @property {string} application The application type.
|
|
90
|
-
* @returns {Promise<boolean>} The auth status of the user.
|
|
91
|
-
*/
|
|
92
|
-
async getAppAuthStatus(application) {
|
|
93
|
-
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/auth?integration_type=${application}`, {
|
|
94
|
-
headers: {
|
|
95
|
-
authorization: `Bearer ${this.token}`,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (res.status >= 400 && res.status < 600) {
|
|
100
|
-
throw new Error(res.statusText);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const data = await res.json();
|
|
104
|
-
return !!data?.status;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
25
|
/**
|
|
108
26
|
* Returns the auth URL that users can use to authenticate themselves to the
|
|
109
27
|
* specified application.
|
|
110
|
-
* @
|
|
111
|
-
* @
|
|
28
|
+
* @private
|
|
29
|
+
* @param {String} application The application type.
|
|
30
|
+
* @returns {Promise<String>} The auth URL where users can authenticate themselves.
|
|
112
31
|
*/
|
|
113
|
-
async
|
|
32
|
+
async getOAuthUrl(application) {
|
|
114
33
|
const res = await fetch(`${this.baseUrl}/api/v1/${application}/integrate`, {
|
|
115
34
|
headers: {
|
|
116
35
|
authorization: `Bearer ${this.token}`,
|
|
@@ -126,19 +45,19 @@ class Cobalt {
|
|
|
126
45
|
}
|
|
127
46
|
|
|
128
47
|
/**
|
|
129
|
-
* Handle OAuth for the specified application.
|
|
130
|
-
* @
|
|
131
|
-
* @returns {Promise<
|
|
48
|
+
* Handle OAuth for the specified native application.
|
|
49
|
+
* @param {String} application The application type.
|
|
50
|
+
* @returns {Promise<Boolean>} Whether the user authenticated.
|
|
132
51
|
*/
|
|
133
52
|
async oauth(application) {
|
|
134
53
|
return new Promise((resolve, reject) => {
|
|
135
|
-
this.
|
|
54
|
+
this.getOAuthUrl(application)
|
|
136
55
|
.then(oauthUrl => {
|
|
137
56
|
const connectWindow = window.open(oauthUrl);
|
|
138
57
|
|
|
139
58
|
// keep checking connection status
|
|
140
59
|
const interval = setInterval(() => {
|
|
141
|
-
this.
|
|
60
|
+
this.checkAuth(application)
|
|
142
61
|
.then(connected => {
|
|
143
62
|
if (connected === true) {
|
|
144
63
|
// close auth window
|
|
@@ -170,14 +89,13 @@ class Cobalt {
|
|
|
170
89
|
|
|
171
90
|
/**
|
|
172
91
|
* Save the auth data that user provides to authenticate themselves to the
|
|
173
|
-
* specified application.
|
|
174
|
-
* @
|
|
175
|
-
* @
|
|
176
|
-
* @
|
|
177
|
-
* @returns {Promise<void>}
|
|
92
|
+
* specified native application.
|
|
93
|
+
* @param {String} application The application type.
|
|
94
|
+
* @param {Object.<string, string | number | boolean>} payload The key value pairs of auth data.
|
|
95
|
+
* @returns {Promise<unknown>}
|
|
178
96
|
*/
|
|
179
|
-
async
|
|
180
|
-
const res = await fetch(
|
|
97
|
+
async auth(application, payload) {
|
|
98
|
+
const res = await fetch(`${this.baseUrl}/api/v1/${application}/save`, {
|
|
181
99
|
method: "POST",
|
|
182
100
|
headers: {
|
|
183
101
|
authorization: `Bearer ${this.token}`,
|
|
@@ -197,93 +115,84 @@ class Cobalt {
|
|
|
197
115
|
}
|
|
198
116
|
|
|
199
117
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* @
|
|
203
|
-
* @
|
|
118
|
+
* Save the auth data that user provides to authenticate themselves to the
|
|
119
|
+
* specified custom application.
|
|
120
|
+
* @param {String} applicationId The application ID of the custom application.
|
|
121
|
+
* @param {Object.<string, string | number | boolean>} payload The key value pairs of auth data.
|
|
122
|
+
* @returns {Promise<unknown>}
|
|
204
123
|
*/
|
|
205
|
-
async
|
|
206
|
-
const res = await fetch(`${this.baseUrl}/api/v1/
|
|
207
|
-
method: "
|
|
124
|
+
async authCustom(applicationId, payload) {
|
|
125
|
+
const res = await fetch(`${this.baseUrl}/api/v1/custom/${applicationId}/save`, {
|
|
126
|
+
method: "POST",
|
|
208
127
|
headers: {
|
|
209
128
|
authorization: `Bearer ${this.token}`,
|
|
129
|
+
"content-type": "application/json",
|
|
210
130
|
},
|
|
131
|
+
body: JSON.stringify({
|
|
132
|
+
...payload,
|
|
133
|
+
}),
|
|
211
134
|
});
|
|
212
135
|
|
|
213
136
|
if (res.status >= 400 && res.status < 600) {
|
|
214
137
|
throw new Error(res.statusText);
|
|
215
138
|
}
|
|
139
|
+
|
|
140
|
+
const data = await res.json();
|
|
141
|
+
return data;
|
|
216
142
|
}
|
|
217
143
|
|
|
218
144
|
/**
|
|
219
|
-
* Returns the
|
|
220
|
-
* @
|
|
221
|
-
* @
|
|
222
|
-
* @property {string} fieldName The field name for which config data is required.
|
|
223
|
-
* @property {object} selectedValues The input data already selected for the node.
|
|
224
|
-
* @returns {Promise<Field[]>}
|
|
145
|
+
* Returns the auth status of the user for the specified application.
|
|
146
|
+
* @param {String} application The application type.
|
|
147
|
+
* @returns {Promise<Boolean>} The auth status of the user.
|
|
225
148
|
*/
|
|
226
|
-
async
|
|
227
|
-
const res = await fetch(`${this.baseUrl}/api/v1/
|
|
228
|
-
method: "POST",
|
|
149
|
+
async checkAuth(application) {
|
|
150
|
+
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/auth?integration_type=${application}`, {
|
|
229
151
|
headers: {
|
|
230
152
|
authorization: `Bearer ${this.token}`,
|
|
231
|
-
"content-type": "application/json",
|
|
232
153
|
},
|
|
233
|
-
body: JSON.stringify({
|
|
234
|
-
fieldName,
|
|
235
|
-
selectedValues,
|
|
236
|
-
}),
|
|
237
154
|
});
|
|
238
155
|
|
|
239
156
|
if (res.status >= 400 && res.status < 600) {
|
|
240
157
|
throw new Error(res.statusText);
|
|
241
158
|
}
|
|
242
159
|
|
|
243
|
-
|
|
160
|
+
const data = await res.json();
|
|
161
|
+
return !!data?.status;
|
|
244
162
|
}
|
|
245
163
|
|
|
246
164
|
/**
|
|
247
|
-
*
|
|
248
|
-
* @
|
|
249
|
-
* @
|
|
250
|
-
* @
|
|
251
|
-
* @returns {Promise<Workflow>}
|
|
165
|
+
* Unauthorize the specified application and remove any associated data from Cobalt.
|
|
166
|
+
* @param {String} application The application type.
|
|
167
|
+
* @param {String} [applicationId] The application ID in case of custom applications.
|
|
168
|
+
* @returns {Promise<void>}
|
|
252
169
|
*/
|
|
253
|
-
async
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
if (Object.hasOwnProperty.call(inputData, key)) {
|
|
257
|
-
const value = inputData[key];
|
|
258
|
-
payload[key] = { value };
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const res = await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/node/${nodeId}`, {
|
|
263
|
-
method: "PUT",
|
|
170
|
+
async removeAuth(application, applicationId) {
|
|
171
|
+
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${application}?app_id=${applicationId}`, {
|
|
172
|
+
method: "DELETE",
|
|
264
173
|
headers: {
|
|
265
174
|
authorization: `Bearer ${this.token}`,
|
|
266
|
-
"content-type": "application/json",
|
|
267
175
|
},
|
|
268
|
-
body: JSON.stringify({
|
|
269
|
-
input_data: payload,
|
|
270
|
-
}),
|
|
271
176
|
});
|
|
272
177
|
|
|
273
178
|
if (res.status >= 400 && res.status < 600) {
|
|
274
179
|
throw new Error(res.statusText);
|
|
275
180
|
}
|
|
276
|
-
|
|
277
|
-
return await res.json();
|
|
278
181
|
}
|
|
279
182
|
|
|
280
183
|
/**
|
|
281
|
-
*
|
|
282
|
-
* @property {
|
|
283
|
-
* @
|
|
184
|
+
* @typedef {object} AppConfig The configuration data for an application.
|
|
185
|
+
* @property {DataSlot[]} application_data_slots Array of application data slots.
|
|
186
|
+
* @property {Template[]} templates Array of workflow templates.
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Returns the configuration data for the specified application.
|
|
191
|
+
* @param {String} application The application ID.
|
|
192
|
+
* @returns {Promise<AppConfig>} The specified application's configuration data.
|
|
284
193
|
*/
|
|
285
|
-
async
|
|
286
|
-
const res = await fetch(`${this.baseUrl}/api/
|
|
194
|
+
async getAppConfig(application) {
|
|
195
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${application}/config`, {
|
|
287
196
|
headers: {
|
|
288
197
|
authorization: `Bearer ${this.token}`,
|
|
289
198
|
},
|
|
@@ -297,16 +206,33 @@ class Cobalt {
|
|
|
297
206
|
}
|
|
298
207
|
|
|
299
208
|
/**
|
|
300
|
-
*
|
|
301
|
-
* @property {
|
|
302
|
-
* @
|
|
209
|
+
* @typedef {Object} AppInstance An installed application.
|
|
210
|
+
* @property {String} [intallation_id] Unique ID for the installation.
|
|
211
|
+
* @property {Object.<string, string | number | boolean>} application_data_slots A map of application data slots and their values.
|
|
212
|
+
* @property {WorkflowTemplate[]} templates Whether the workflow template is enabled.
|
|
303
213
|
*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @typedef {Object} WorkflowTemplate The workflow template.
|
|
217
|
+
* @property {String} id The ID of the workflow template.
|
|
218
|
+
* @property {Boolean} enabled Whether the workflow template is enabled.
|
|
219
|
+
* @property {Object.<string, string | number | boolean>} data_slots A map of workflow template's data slots and their values.
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Install the specified application.
|
|
224
|
+
* @param {String} applicationId The application ID.
|
|
225
|
+
* @param {AppInstance} payload The install payload.
|
|
226
|
+
* @returns {Promise<AppInstance>} The specified application installation.
|
|
227
|
+
*/
|
|
228
|
+
async install(applicationId, payload = {}) {
|
|
229
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/install`, {
|
|
230
|
+
method: "POST",
|
|
307
231
|
headers: {
|
|
308
232
|
authorization: `Bearer ${this.token}`,
|
|
233
|
+
"content-type": "application/json",
|
|
309
234
|
},
|
|
235
|
+
body: JSON.stringify(payload),
|
|
310
236
|
});
|
|
311
237
|
|
|
312
238
|
if (res.status >= 400 && res.status < 600) {
|
|
@@ -317,19 +243,16 @@ class Cobalt {
|
|
|
317
243
|
}
|
|
318
244
|
|
|
319
245
|
/**
|
|
320
|
-
*
|
|
321
|
-
* @
|
|
322
|
-
* @
|
|
246
|
+
* Returns the specified application installation.
|
|
247
|
+
* @param {String} applicationId The application ID.
|
|
248
|
+
* @param {String} installationId The installation ID of the application instance.
|
|
249
|
+
* @returns {Promise<AppInstance>} The specified application installation.
|
|
323
250
|
*/
|
|
324
|
-
async
|
|
325
|
-
const res = await fetch(`${this.baseUrl}/api/
|
|
326
|
-
method: "PUT",
|
|
251
|
+
async getInstallation(applicationId, installationId) {
|
|
252
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/installation/${installationId}`, {
|
|
327
253
|
headers: {
|
|
328
254
|
authorization: `Bearer ${this.token}`,
|
|
329
255
|
},
|
|
330
|
-
body: JSON.stringify({
|
|
331
|
-
workflow_ids: workflowIds,
|
|
332
|
-
}),
|
|
333
256
|
});
|
|
334
257
|
|
|
335
258
|
if (res.status >= 400 && res.status < 600) {
|
|
@@ -340,16 +263,20 @@ class Cobalt {
|
|
|
340
263
|
}
|
|
341
264
|
|
|
342
265
|
/**
|
|
343
|
-
*
|
|
344
|
-
* @
|
|
345
|
-
* @
|
|
266
|
+
* Update the specified application installation.
|
|
267
|
+
* @param {String} applicationId The application ID.
|
|
268
|
+
* @param {String} installationId The installation ID of the application instance.
|
|
269
|
+
* @param {AppInstance} payload The update payload.
|
|
270
|
+
* @returns {Promise<AppInstance>} The specified application installation.
|
|
346
271
|
*/
|
|
347
|
-
async
|
|
348
|
-
const res = await fetch(`${this.baseUrl}/api/
|
|
272
|
+
async updateInstallation(applicationId, installationId, payload = {}) {
|
|
273
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/installation/${installationId}`, {
|
|
349
274
|
method: "PUT",
|
|
350
275
|
headers: {
|
|
351
276
|
authorization: `Bearer ${this.token}`,
|
|
277
|
+
"content-type": "application/json",
|
|
352
278
|
},
|
|
279
|
+
body: JSON.stringify(payload),
|
|
353
280
|
});
|
|
354
281
|
|
|
355
282
|
if (res.status >= 400 && res.status < 600) {
|
|
@@ -360,12 +287,13 @@ class Cobalt {
|
|
|
360
287
|
}
|
|
361
288
|
|
|
362
289
|
/**
|
|
363
|
-
* Delete the specified
|
|
364
|
-
* @
|
|
290
|
+
* Delete the specified installation.
|
|
291
|
+
* @param {String} applicationId The application ID.
|
|
292
|
+
* @param {String} installationId The installation ID of the application instance.
|
|
365
293
|
* @returns {Promise<unknown>}
|
|
366
294
|
*/
|
|
367
|
-
async
|
|
368
|
-
const res = await fetch(`${this.baseUrl}/api/v1/
|
|
295
|
+
async deleteInstallation(applicationId, installationId) {
|
|
296
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/installation/${installationId}`, {
|
|
369
297
|
method: "DELETE",
|
|
370
298
|
headers: {
|
|
371
299
|
authorization: `Bearer ${this.token}`,
|
package/cobalt.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class Cobalt{constructor(options){this.
|
|
1
|
+
class Cobalt{constructor(options){this.baseUrl=options?.baseUrl||"https://api.gocobalt.io";this.token=options?.token}get token(){return this.sessionToken}set token(token){return this.sessionToken=typeof token==="string"?token:""}async getOAuthUrl(application){const res=await fetch(`${this.baseUrl}/api/v1/${application}/integrate`,{headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}const data=await res.json();return data?.auth_url}async oauth(application){return new Promise((resolve,reject)=>{this.getOAuthUrl(application).then(oauthUrl=>{const connectWindow=window.open(oauthUrl);const interval=setInterval(()=>{this.checkAuth(application).then(connected=>{if(connected===true){connectWindow?.close();clearInterval(interval);resolve(true)}else{if(connectWindow?.closed){clearInterval(interval);resolve(false)}}}).catch(e=>{console.error(e);clearInterval(interval);reject(e)})},3e3)}).catch(reject)})}async auth(application,payload){const res=await fetch(`${this.baseUrl}/api/v1/${application}/save`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify({...payload})});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}const data=await res.json();return data}async authCustom(applicationId,payload){const res=await fetch(`${this.baseUrl}/api/v1/custom/${applicationId}/save`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify({...payload})});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}const data=await res.json();return data}async checkAuth(application){const res=await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/auth?integration_type=${application}`,{headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}const data=await res.json();return!!data?.status}async removeAuth(application,applicationId){const res=await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${application}?app_id=${applicationId}`,{method:"DELETE",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}}async getAppConfig(application){const res=await fetch(`${this.baseUrl}/api/v1/application/${application}/config`,{headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async install(applicationId,payload={}){const res=await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/install`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify(payload)});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async getInstallation(applicationId,installationId){const res=await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/installation/${installationId}`,{headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async updateInstallation(applicationId,installationId,payload={}){const res=await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/installation/${installationId}`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify(payload)});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async deleteInstallation(applicationId,installationId){const res=await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/installation/${installationId}`,{method:"DELETE",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}}module.exports=Cobalt;
|
package/docs.md
CHANGED
|
@@ -9,17 +9,14 @@
|
|
|
9
9
|
## Typedefs
|
|
10
10
|
|
|
11
11
|
<dl>
|
|
12
|
-
<dt><a href="#
|
|
13
|
-
<dd><p>The
|
|
12
|
+
<dt><a href="#AppConfig">AppConfig</a> : <code>object</code></dt>
|
|
13
|
+
<dd><p>The configuration data for an application.</p>
|
|
14
14
|
</dd>
|
|
15
|
-
<dt><a href="#
|
|
16
|
-
<dd><p>
|
|
15
|
+
<dt><a href="#AppInstance">AppInstance</a> : <code>Object</code></dt>
|
|
16
|
+
<dd><p>An installed application.</p>
|
|
17
17
|
</dd>
|
|
18
|
-
<dt><a href="#
|
|
19
|
-
<dd><p>The
|
|
20
|
-
</dd>
|
|
21
|
-
<dt><a href="#AppAuthStatus">AppAuthStatus</a> : <code>object</code></dt>
|
|
22
|
-
<dd><p>The auth status of the user for an application.</p>
|
|
18
|
+
<dt><a href="#WorkflowTemplate">WorkflowTemplate</a> : <code>Object</code></dt>
|
|
19
|
+
<dd><p>The workflow template.</p>
|
|
23
20
|
</dd>
|
|
24
21
|
</dl>
|
|
25
22
|
|
|
@@ -29,25 +26,25 @@
|
|
|
29
26
|
Cobalt Frontend SDK
|
|
30
27
|
|
|
31
28
|
**Kind**: global class
|
|
29
|
+
**Properties**
|
|
30
|
+
|
|
31
|
+
| Name | Type | Description |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| token | <code>String</code> | The session token. |
|
|
34
|
+
|
|
32
35
|
|
|
33
36
|
* [Cobalt](#Cobalt)
|
|
34
37
|
* [new Cobalt(options)](#new_Cobalt_new)
|
|
35
|
-
* [.
|
|
36
|
-
* [.
|
|
37
|
-
* [.
|
|
38
|
-
* [.
|
|
39
|
-
* [.
|
|
40
|
-
* [.
|
|
41
|
-
* [.
|
|
42
|
-
* [.
|
|
43
|
-
* [.
|
|
44
|
-
* [.
|
|
45
|
-
* [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
46
|
-
* [.getWorkflowConfiguration()](#Cobalt+getWorkflowConfiguration) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
47
|
-
* [.activateWorkflow()](#Cobalt+activateWorkflow) ⇒ <code>Promise.<void></code>
|
|
48
|
-
* [.activateWorkflows()](#Cobalt+activateWorkflows) ⇒ <code>Promise.<void></code>
|
|
49
|
-
* [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
50
|
-
* [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.<unknown></code>
|
|
38
|
+
* [.oauth(application)](#Cobalt+oauth) ⇒ <code>Promise.<Boolean></code>
|
|
39
|
+
* [.auth(application, payload)](#Cobalt+auth) ⇒ <code>Promise.<unknown></code>
|
|
40
|
+
* [.authCustom(applicationId, payload)](#Cobalt+authCustom) ⇒ <code>Promise.<unknown></code>
|
|
41
|
+
* [.checkAuth(application)](#Cobalt+checkAuth) ⇒ <code>Promise.<Boolean></code>
|
|
42
|
+
* [.removeAuth(application, [applicationId])](#Cobalt+removeAuth) ⇒ <code>Promise.<void></code>
|
|
43
|
+
* [.getAppConfig(application)](#Cobalt+getAppConfig) ⇒ [<code>Promise.<AppConfig></code>](#AppConfig)
|
|
44
|
+
* [.install(applicationId, payload)](#Cobalt+install) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
45
|
+
* [.getInstallation(applicationId, installationId)](#Cobalt+getInstallation) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
46
|
+
* [.updateInstallation(applicationId, installationId, payload)](#Cobalt+updateInstallation) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
47
|
+
* [.deleteInstallation(applicationId, installationId)](#Cobalt+deleteInstallation) ⇒ <code>Promise.<unknown></code>
|
|
51
48
|
|
|
52
49
|
<a name="new_Cobalt_new"></a>
|
|
53
50
|
|
|
@@ -57,247 +54,174 @@ Cobalt Frontend SDK
|
|
|
57
54
|
|
|
58
55
|
| Param | Type | Default | Description |
|
|
59
56
|
| --- | --- | --- | --- |
|
|
60
|
-
| options | <code>
|
|
61
|
-
| [options.token] | <code>
|
|
62
|
-
| [options.baseUrl] | <code>
|
|
63
|
-
|
|
64
|
-
<a name="Cobalt+token"></a>
|
|
65
|
-
|
|
66
|
-
### cobalt.token ⇒ <code>string</code>
|
|
67
|
-
**Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
|
|
68
|
-
**Returns**: <code>string</code> - The session token.
|
|
69
|
-
<a name="Cobalt+token"></a>
|
|
70
|
-
|
|
71
|
-
### cobalt.token ⇒ <code>string</code>
|
|
72
|
-
**Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
|
|
73
|
-
**Returns**: <code>string</code> - The session token.
|
|
74
|
-
<a name="Cobalt+baseUrl"></a>
|
|
75
|
-
|
|
76
|
-
### cobalt.baseUrl ⇒ <code>string</code>
|
|
77
|
-
**Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
|
|
78
|
-
**Returns**: <code>string</code> - The base URL of cobalt API.
|
|
79
|
-
<a name="Cobalt+installTemplate"></a>
|
|
80
|
-
|
|
81
|
-
### cobalt.installTemplate() ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
82
|
-
Install the given template.
|
|
83
|
-
|
|
84
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
85
|
-
**Properties**
|
|
86
|
-
|
|
87
|
-
| Name | Type | Description |
|
|
88
|
-
| --- | --- | --- |
|
|
89
|
-
| templateId | <code>string</code> | The ID of the template you want to install. |
|
|
90
|
-
| udf | <code>object</code> | Custom key value pairs you want to store with the installed worklfow. |
|
|
91
|
-
|
|
92
|
-
<a name="Cobalt+getAppAuthStatus"></a>
|
|
93
|
-
|
|
94
|
-
### cobalt.getAppAuthStatus() ⇒ <code>Promise.<boolean></code>
|
|
95
|
-
Returns the auth status of the user for the specified application.
|
|
96
|
-
|
|
97
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
98
|
-
**Returns**: <code>Promise.<boolean></code> - The auth status of the user.
|
|
99
|
-
**Properties**
|
|
100
|
-
|
|
101
|
-
| Name | Type | Description |
|
|
102
|
-
| --- | --- | --- |
|
|
103
|
-
| application | <code>string</code> | The application type. |
|
|
104
|
-
|
|
105
|
-
<a name="Cobalt+getAppAuthUrl"></a>
|
|
106
|
-
|
|
107
|
-
### cobalt.getAppAuthUrl() ⇒ <code>Promise.<string></code>
|
|
108
|
-
Returns the auth URL that users can use to authenticate themselves to the
|
|
109
|
-
specified application.
|
|
110
|
-
|
|
111
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
112
|
-
**Returns**: <code>Promise.<string></code> - The auth URL where users can authenticate themselves.
|
|
113
|
-
**Properties**
|
|
114
|
-
|
|
115
|
-
| Name | Type | Description |
|
|
116
|
-
| --- | --- | --- |
|
|
117
|
-
| application | <code>string</code> | The application type. |
|
|
57
|
+
| options | <code>Object</code> | | The options to configure the Cobalt SDK. |
|
|
58
|
+
| [options.token] | <code>String</code> | | The session token. |
|
|
59
|
+
| [options.baseUrl] | <code>String</code> | <code>https://api.gocobalt.io</code> | The base URL of the Cobalt API. |
|
|
118
60
|
|
|
119
61
|
<a name="Cobalt+oauth"></a>
|
|
120
62
|
|
|
121
|
-
### cobalt.oauth() ⇒ <code>Promise.<
|
|
122
|
-
Handle OAuth for the specified application.
|
|
63
|
+
### cobalt.oauth(application) ⇒ <code>Promise.<Boolean></code>
|
|
64
|
+
Handle OAuth for the specified native application.
|
|
123
65
|
|
|
124
66
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
125
|
-
**Returns**: <code>Promise.<
|
|
126
|
-
**Properties**
|
|
67
|
+
**Returns**: <code>Promise.<Boolean></code> - Whether the user authenticated.
|
|
127
68
|
|
|
128
|
-
|
|
|
69
|
+
| Param | Type | Description |
|
|
129
70
|
| --- | --- | --- |
|
|
130
|
-
| application | <code>
|
|
71
|
+
| application | <code>String</code> | The application type. |
|
|
131
72
|
|
|
132
|
-
<a name="Cobalt+
|
|
73
|
+
<a name="Cobalt+auth"></a>
|
|
133
74
|
|
|
134
|
-
### cobalt.
|
|
75
|
+
### cobalt.auth(application, payload) ⇒ <code>Promise.<unknown></code>
|
|
135
76
|
Save the auth data that user provides to authenticate themselves to the
|
|
136
|
-
specified application.
|
|
77
|
+
specified native application.
|
|
137
78
|
|
|
138
79
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
139
|
-
**Properties**
|
|
140
80
|
|
|
141
|
-
|
|
|
81
|
+
| Param | Type | Description |
|
|
142
82
|
| --- | --- | --- |
|
|
143
|
-
| application | <code>
|
|
144
|
-
| payload | <code>
|
|
145
|
-
| appId | <code>object</code> | The application ID in case of custom applications. |
|
|
83
|
+
| application | <code>String</code> | The application type. |
|
|
84
|
+
| payload | <code>Object.<string, (string\|number\|boolean)></code> | The key value pairs of auth data. |
|
|
146
85
|
|
|
147
|
-
<a name="Cobalt+
|
|
86
|
+
<a name="Cobalt+authCustom"></a>
|
|
148
87
|
|
|
149
|
-
### cobalt.
|
|
150
|
-
|
|
88
|
+
### cobalt.authCustom(applicationId, payload) ⇒ <code>Promise.<unknown></code>
|
|
89
|
+
Save the auth data that user provides to authenticate themselves to the
|
|
90
|
+
specified custom application.
|
|
151
91
|
|
|
152
92
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
153
|
-
**Properties**
|
|
154
93
|
|
|
155
|
-
|
|
|
94
|
+
| Param | Type | Description |
|
|
156
95
|
| --- | --- | --- |
|
|
157
|
-
|
|
|
158
|
-
|
|
|
96
|
+
| applicationId | <code>String</code> | The application ID of the custom application. |
|
|
97
|
+
| payload | <code>Object.<string, (string\|number\|boolean)></code> | The key value pairs of auth data. |
|
|
159
98
|
|
|
160
|
-
<a name="Cobalt+
|
|
99
|
+
<a name="Cobalt+checkAuth"></a>
|
|
161
100
|
|
|
162
|
-
### cobalt.
|
|
163
|
-
Returns the
|
|
101
|
+
### cobalt.checkAuth(application) ⇒ <code>Promise.<Boolean></code>
|
|
102
|
+
Returns the auth status of the user for the specified application.
|
|
164
103
|
|
|
165
104
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
166
|
-
**
|
|
105
|
+
**Returns**: <code>Promise.<Boolean></code> - The auth status of the user.
|
|
167
106
|
|
|
168
|
-
|
|
|
107
|
+
| Param | Type | Description |
|
|
169
108
|
| --- | --- | --- |
|
|
170
|
-
|
|
|
171
|
-
| nodeId | <code>string</code> | The ID of the node. |
|
|
172
|
-
| fieldName | <code>string</code> | The field name for which config data is required. |
|
|
173
|
-
| selectedValues | <code>object</code> | The input data already selected for the node. |
|
|
109
|
+
| application | <code>String</code> | The application type. |
|
|
174
110
|
|
|
175
|
-
<a name="Cobalt+
|
|
111
|
+
<a name="Cobalt+removeAuth"></a>
|
|
176
112
|
|
|
177
|
-
### cobalt.
|
|
178
|
-
|
|
113
|
+
### cobalt.removeAuth(application, [applicationId]) ⇒ <code>Promise.<void></code>
|
|
114
|
+
Unauthorize the specified application and remove any associated data from Cobalt.
|
|
179
115
|
|
|
180
116
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
181
|
-
**Properties**
|
|
182
117
|
|
|
183
|
-
|
|
|
118
|
+
| Param | Type | Description |
|
|
184
119
|
| --- | --- | --- |
|
|
185
|
-
|
|
|
186
|
-
|
|
|
187
|
-
| inputData | <code>object</code> | The input data for the node. |
|
|
120
|
+
| application | <code>String</code> | The application type. |
|
|
121
|
+
| [applicationId] | <code>String</code> | The application ID in case of custom applications. |
|
|
188
122
|
|
|
189
|
-
<a name="Cobalt+
|
|
123
|
+
<a name="Cobalt+getAppConfig"></a>
|
|
190
124
|
|
|
191
|
-
### cobalt.
|
|
192
|
-
Returns the
|
|
125
|
+
### cobalt.getAppConfig(application) ⇒ [<code>Promise.<AppConfig></code>](#AppConfig)
|
|
126
|
+
Returns the configuration data for the specified application.
|
|
193
127
|
|
|
194
128
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
195
|
-
**
|
|
129
|
+
**Returns**: [<code>Promise.<AppConfig></code>](#AppConfig) - The specified application's configuration data.
|
|
196
130
|
|
|
197
|
-
|
|
|
131
|
+
| Param | Type | Description |
|
|
198
132
|
| --- | --- | --- |
|
|
199
|
-
|
|
|
133
|
+
| application | <code>String</code> | The application ID. |
|
|
200
134
|
|
|
201
|
-
<a name="Cobalt+
|
|
135
|
+
<a name="Cobalt+install"></a>
|
|
202
136
|
|
|
203
|
-
### cobalt.
|
|
204
|
-
|
|
137
|
+
### cobalt.install(applicationId, payload) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
138
|
+
Install the specified application.
|
|
205
139
|
|
|
206
140
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
207
|
-
**
|
|
141
|
+
**Returns**: [<code>Promise.<AppInstance></code>](#AppInstance) - The specified application installation.
|
|
208
142
|
|
|
209
|
-
|
|
|
143
|
+
| Param | Type | Description |
|
|
210
144
|
| --- | --- | --- |
|
|
211
|
-
|
|
|
145
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
146
|
+
| payload | [<code>AppInstance</code>](#AppInstance) | The install payload. |
|
|
212
147
|
|
|
213
|
-
<a name="Cobalt+
|
|
148
|
+
<a name="Cobalt+getInstallation"></a>
|
|
214
149
|
|
|
215
|
-
### cobalt.
|
|
216
|
-
|
|
150
|
+
### cobalt.getInstallation(applicationId, installationId) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
151
|
+
Returns the specified application installation.
|
|
217
152
|
|
|
218
153
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
219
|
-
**
|
|
154
|
+
**Returns**: [<code>Promise.<AppInstance></code>](#AppInstance) - The specified application installation.
|
|
220
155
|
|
|
221
|
-
|
|
|
156
|
+
| Param | Type | Description |
|
|
222
157
|
| --- | --- | --- |
|
|
223
|
-
|
|
|
158
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
159
|
+
| installationId | <code>String</code> | The installation ID of the application instance. |
|
|
224
160
|
|
|
225
|
-
<a name="Cobalt+
|
|
161
|
+
<a name="Cobalt+updateInstallation"></a>
|
|
226
162
|
|
|
227
|
-
### cobalt.
|
|
228
|
-
|
|
163
|
+
### cobalt.updateInstallation(applicationId, installationId, payload) ⇒ [<code>Promise.<AppInstance></code>](#AppInstance)
|
|
164
|
+
Update the specified application installation.
|
|
229
165
|
|
|
230
166
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
231
|
-
**
|
|
167
|
+
**Returns**: [<code>Promise.<AppInstance></code>](#AppInstance) - The specified application installation.
|
|
232
168
|
|
|
233
|
-
|
|
|
169
|
+
| Param | Type | Description |
|
|
234
170
|
| --- | --- | --- |
|
|
235
|
-
|
|
|
171
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
172
|
+
| installationId | <code>String</code> | The installation ID of the application instance. |
|
|
173
|
+
| payload | [<code>AppInstance</code>](#AppInstance) | The update payload. |
|
|
236
174
|
|
|
237
|
-
<a name="Cobalt+
|
|
175
|
+
<a name="Cobalt+deleteInstallation"></a>
|
|
238
176
|
|
|
239
|
-
### cobalt.
|
|
240
|
-
Delete the specified
|
|
177
|
+
### cobalt.deleteInstallation(applicationId, installationId) ⇒ <code>Promise.<unknown></code>
|
|
178
|
+
Delete the specified installation.
|
|
241
179
|
|
|
242
180
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
243
|
-
**Properties**
|
|
244
|
-
|
|
245
|
-
| Name | Type | Description |
|
|
246
|
-
| --- | --- | --- |
|
|
247
|
-
| workflowId | <code>string</code> | The ID of the workflow. |
|
|
248
|
-
|
|
249
|
-
<a name="Field"></a>
|
|
250
|
-
|
|
251
|
-
## Field : <code>object</code>
|
|
252
|
-
The Node Field object available for configuration.
|
|
253
181
|
|
|
254
|
-
|
|
255
|
-
**Properties**
|
|
256
|
-
|
|
257
|
-
| Name | Type | Description |
|
|
182
|
+
| Param | Type | Description |
|
|
258
183
|
| --- | --- | --- |
|
|
259
|
-
|
|
|
260
|
-
|
|
|
261
|
-
| placeholder | <code>string</code> | The placeholder text for the field. |
|
|
262
|
-
| required | <code>boolean</code> | Whether the field is required. |
|
|
184
|
+
| applicationId | <code>String</code> | The application ID. |
|
|
185
|
+
| installationId | <code>String</code> | The installation ID of the application instance. |
|
|
263
186
|
|
|
264
|
-
<a name="
|
|
187
|
+
<a name="AppConfig"></a>
|
|
265
188
|
|
|
266
|
-
##
|
|
267
|
-
The
|
|
189
|
+
## AppConfig : <code>object</code>
|
|
190
|
+
The configuration data for an application.
|
|
268
191
|
|
|
269
192
|
**Kind**: global typedef
|
|
270
193
|
**Properties**
|
|
271
194
|
|
|
272
195
|
| Name | Type | Description |
|
|
273
196
|
| --- | --- | --- |
|
|
274
|
-
|
|
|
275
|
-
|
|
|
276
|
-
| fields | [<code>Array.<Field></code>](#Field) | The applications integrated in the workflow. |
|
|
197
|
+
| application_data_slots | <code>Array.<DataSlot></code> | Array of application data slots. |
|
|
198
|
+
| templates | <code>Array.<Template></code> | Array of workflow templates. |
|
|
277
199
|
|
|
278
|
-
<a name="
|
|
200
|
+
<a name="AppInstance"></a>
|
|
279
201
|
|
|
280
|
-
##
|
|
281
|
-
|
|
202
|
+
## AppInstance : <code>Object</code>
|
|
203
|
+
An installed application.
|
|
282
204
|
|
|
283
205
|
**Kind**: global typedef
|
|
284
206
|
**Properties**
|
|
285
207
|
|
|
286
208
|
| Name | Type | Description |
|
|
287
209
|
| --- | --- | --- |
|
|
288
|
-
|
|
|
289
|
-
|
|
|
290
|
-
|
|
|
210
|
+
| [intallation_id] | <code>String</code> | Unique ID for the installation. |
|
|
211
|
+
| application_data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of application data slots and their values. |
|
|
212
|
+
| templates | [<code>Array.<WorkflowTemplate></code>](#WorkflowTemplate) | Whether the workflow template is enabled. |
|
|
291
213
|
|
|
292
|
-
<a name="
|
|
214
|
+
<a name="WorkflowTemplate"></a>
|
|
293
215
|
|
|
294
|
-
##
|
|
295
|
-
The
|
|
216
|
+
## WorkflowTemplate : <code>Object</code>
|
|
217
|
+
The workflow template.
|
|
296
218
|
|
|
297
219
|
**Kind**: global typedef
|
|
298
220
|
**Properties**
|
|
299
221
|
|
|
300
222
|
| Name | Type | Description |
|
|
301
223
|
| --- | --- | --- |
|
|
302
|
-
|
|
|
224
|
+
| id | <code>String</code> | The ID of the workflow template. |
|
|
225
|
+
| enabled | <code>Boolean</code> | Whether the workflow template is enabled. |
|
|
226
|
+
| data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of workflow template's data slots and their values. |
|
|
303
227
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobaltio/cobalt-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Cobalt frontend SDK",
|
|
5
5
|
"main": "./cobalt.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/Breakout-Embed/cobalt-js#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"foodoc": "^0.0.9",
|
|
33
32
|
"jsdoc": "^4.0.0",
|
|
34
33
|
"jsdoc-to-markdown": "^8.0.0",
|
|
35
34
|
"uglify-js": "^3.17.4"
|