@cobaltio/cobalt-js 2.1.3 → 3.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 +250 -325
- package/cobalt.js +96 -160
- package/docs.md +59 -134
- package/package.json +34 -36
- package/cobalt.min.js +0 -1
package/cobalt.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cobalt Frontend SDK
|
|
3
|
-
* @property {String} token The session token.
|
|
4
3
|
*/
|
|
5
4
|
class Cobalt {
|
|
6
5
|
/**
|
|
@@ -22,15 +21,37 @@ class Cobalt {
|
|
|
22
21
|
return this.sessionToken = typeof token === "string" ? token : "";
|
|
23
22
|
};
|
|
24
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Returns the application details for the specified application, provided
|
|
26
|
+
* the application is enabled in Cobalt.
|
|
27
|
+
* @private
|
|
28
|
+
* @param {String} slug The application slug.
|
|
29
|
+
* @returns {Promise<Application>} The application details.
|
|
30
|
+
*/
|
|
31
|
+
async getApp(slug) {
|
|
32
|
+
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/application/${slug}`, {
|
|
33
|
+
headers: {
|
|
34
|
+
authorization: `Bearer ${this.token}`,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (res.status >= 400 && res.status < 600) {
|
|
39
|
+
throw new Error(res.statusText);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const data = await res.json();
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
/**
|
|
26
47
|
* Returns the auth URL that users can use to authenticate themselves to the
|
|
27
48
|
* specified application.
|
|
28
49
|
* @private
|
|
29
|
-
* @param {String}
|
|
50
|
+
* @param {String} slug The application slug.
|
|
30
51
|
* @returns {Promise<String>} The auth URL where users can authenticate themselves.
|
|
31
52
|
*/
|
|
32
|
-
async getOAuthUrl(
|
|
33
|
-
const res = await fetch(`${this.baseUrl}/api/v1/${
|
|
53
|
+
async getOAuthUrl(slug) {
|
|
54
|
+
const res = await fetch(`${this.baseUrl}/api/v1/${slug}/integrate`, {
|
|
34
55
|
headers: {
|
|
35
56
|
authorization: `Bearer ${this.token}`,
|
|
36
57
|
},
|
|
@@ -46,20 +67,21 @@ class Cobalt {
|
|
|
46
67
|
|
|
47
68
|
/**
|
|
48
69
|
* Handle OAuth for the specified native application.
|
|
49
|
-
* @
|
|
70
|
+
* @private
|
|
71
|
+
* @param {String} slug The application slug.
|
|
50
72
|
* @returns {Promise<Boolean>} Whether the user authenticated.
|
|
51
73
|
*/
|
|
52
|
-
async oauth(
|
|
74
|
+
async oauth(slug) {
|
|
53
75
|
return new Promise((resolve, reject) => {
|
|
54
|
-
this.getOAuthUrl(
|
|
76
|
+
this.getOAuthUrl(slug)
|
|
55
77
|
.then(oauthUrl => {
|
|
56
78
|
const connectWindow = window.open(oauthUrl);
|
|
57
79
|
|
|
58
80
|
// keep checking connection status
|
|
59
81
|
const interval = setInterval(() => {
|
|
60
|
-
this.
|
|
61
|
-
.then(
|
|
62
|
-
if (connected === true) {
|
|
82
|
+
this.getApp(slug)
|
|
83
|
+
.then(app => {
|
|
84
|
+
if (app && app.connected === true) {
|
|
63
85
|
// close auth window
|
|
64
86
|
connectWindow && connectWindow.close();
|
|
65
87
|
// clear interval
|
|
@@ -88,87 +110,44 @@ class Cobalt {
|
|
|
88
110
|
}
|
|
89
111
|
|
|
90
112
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @param {
|
|
94
|
-
* @
|
|
95
|
-
* @returns {Promise<unknown>}
|
|
96
|
-
*/
|
|
97
|
-
async auth(application, payload) {
|
|
98
|
-
const res = await fetch(`${this.baseUrl}/api/v1/${application}/save`, {
|
|
99
|
-
method: "POST",
|
|
100
|
-
headers: {
|
|
101
|
-
authorization: `Bearer ${this.token}`,
|
|
102
|
-
"content-type": "application/json",
|
|
103
|
-
},
|
|
104
|
-
body: JSON.stringify({
|
|
105
|
-
...payload,
|
|
106
|
-
}),
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
if (res.status >= 400 && res.status < 600) {
|
|
110
|
-
throw new Error(res.statusText);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const data = await res.json();
|
|
114
|
-
return data;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
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>}
|
|
113
|
+
* Connect the specified application, optionally with the auth data that user provides.
|
|
114
|
+
* @param {String} slug The application slug.
|
|
115
|
+
* @param {Object.<string, string | number | boolean>} [payload={}] The key value pairs of auth data.
|
|
116
|
+
* @returns {Promise<Boolean>} Whether the connection was successful.
|
|
123
117
|
*/
|
|
124
|
-
async
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
118
|
+
async connect(slug, payload) {
|
|
119
|
+
if (payload) {
|
|
120
|
+
// save auth
|
|
121
|
+
const res = await fetch(`${this.baseUrl}/api/v2/app/${slug}/save`, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: {
|
|
124
|
+
authorization: `Bearer ${this.token}`,
|
|
125
|
+
"content-type": "application/json",
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify({
|
|
128
|
+
...payload,
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (res.status >= 400 && res.status < 600) {
|
|
133
|
+
throw new Error(res.statusText);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const data = await res.json();
|
|
137
|
+
return data.success;
|
|
138
|
+
} else {
|
|
139
|
+
// oauth
|
|
140
|
+
return this.oauth(slug);
|
|
138
141
|
}
|
|
139
|
-
|
|
140
|
-
const data = await res.json();
|
|
141
|
-
return data;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @param {String}
|
|
147
|
-
* @returns {Promise<Boolean>} The auth status of the user.
|
|
148
|
-
*/
|
|
149
|
-
async checkAuth(application) {
|
|
150
|
-
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/auth?integration_type=${application}`, {
|
|
151
|
-
headers: {
|
|
152
|
-
authorization: `Bearer ${this.token}`,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
if (res.status >= 400 && res.status < 600) {
|
|
157
|
-
throw new Error(res.statusText);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const data = await res.json();
|
|
161
|
-
return !!data.status;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
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.
|
|
145
|
+
* Disconnect the specified application and remove any associated data from Cobalt.
|
|
146
|
+
* @param {String} slug The application slug.
|
|
168
147
|
* @returns {Promise<void>}
|
|
169
148
|
*/
|
|
170
|
-
async
|
|
171
|
-
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${
|
|
149
|
+
async disconnect(slug) {
|
|
150
|
+
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${slug}`, {
|
|
172
151
|
method: "DELETE",
|
|
173
152
|
headers: {
|
|
174
153
|
authorization: `Bearer ${this.token}`,
|
|
@@ -180,32 +159,31 @@ class Cobalt {
|
|
|
180
159
|
}
|
|
181
160
|
}
|
|
182
161
|
|
|
183
|
-
/**
|
|
184
|
-
* @typedef {object} Config The configuration data for an application.
|
|
185
|
-
* @property {DataSlot[]} application_data_slots Array of application data slots.
|
|
186
|
-
* @property {Workflow[]} workflows Array of workflows.
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
162
|
/**
|
|
190
163
|
* @typedef {Object} Label Field Mapping Label
|
|
191
164
|
* @property {string} name The Label name.
|
|
192
165
|
* @property {string | number | boolean} value The Label value.
|
|
193
166
|
*/
|
|
194
167
|
|
|
168
|
+
/**
|
|
169
|
+
* @typedef {Object} DynamicField Field Mapping Label
|
|
170
|
+
* @property {Label[]} fields The Label name.
|
|
171
|
+
*/
|
|
172
|
+
|
|
195
173
|
/**
|
|
196
174
|
* @typedef {Object} DynamicFields The dynamic fields payload.
|
|
197
|
-
* @property {Object.<string,
|
|
175
|
+
* @property {Object.<string, DynamicField>} map_fields_object desc.
|
|
198
176
|
*/
|
|
199
177
|
|
|
200
178
|
/**
|
|
201
|
-
* Returns the specified
|
|
202
|
-
* @param {String}
|
|
203
|
-
* @param {String} configId
|
|
204
|
-
* @param {DynamicFields} fields The dynamic fields payload.
|
|
205
|
-
* @returns {Promise<
|
|
179
|
+
* Returns the specified config, or creates one if it doesn't exist.
|
|
180
|
+
* @param {String} slug The application slug.
|
|
181
|
+
* @param {String} configId A unique ID for the config.
|
|
182
|
+
* @param {DynamicFields} [fields] The dynamic fields payload.
|
|
183
|
+
* @returns {Promise<Config>} The specified config.
|
|
206
184
|
*/
|
|
207
|
-
async config(
|
|
208
|
-
const res = await fetch(`${this.baseUrl}/api/v2/application/${
|
|
185
|
+
async config(slug, configId, fields) {
|
|
186
|
+
const res = await fetch(`${this.baseUrl}/api/v2/application/${slug}/installation/${configId}`, {
|
|
209
187
|
method: "POST",
|
|
210
188
|
headers: {
|
|
211
189
|
authorization: `Bearer ${this.token}`,
|
|
@@ -222,27 +200,8 @@ class Cobalt {
|
|
|
222
200
|
}
|
|
223
201
|
|
|
224
202
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @
|
|
227
|
-
* @returns {Promise<Config>} The specified application's configuration data.
|
|
228
|
-
*/
|
|
229
|
-
async getConfig(application) {
|
|
230
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${application}/config`, {
|
|
231
|
-
headers: {
|
|
232
|
-
authorization: `Bearer ${this.token}`,
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
if (res.status >= 400 && res.status < 600) {
|
|
237
|
-
throw new Error(res.statusText);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return await res.json();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @typedef {Object} SavedConfig An saved config.
|
|
245
|
-
* @property {String} [config_id] Unique ID for the saved config.
|
|
203
|
+
* @typedef {Object} Config The configuration data for an application.
|
|
204
|
+
* @property {String} [config_id] Unique ID for the config.
|
|
246
205
|
* @property {Object.<string, string | number | boolean>} application_data_slots A map of application data slots and their values.
|
|
247
206
|
* @property {Workflow[]} workflows Whether the workflow is enabled.
|
|
248
207
|
*/
|
|
@@ -255,36 +214,13 @@ class Cobalt {
|
|
|
255
214
|
*/
|
|
256
215
|
|
|
257
216
|
/**
|
|
258
|
-
*
|
|
259
|
-
* @param {String}
|
|
260
|
-
* @param {
|
|
261
|
-
* @returns {Promise<
|
|
262
|
-
*/
|
|
263
|
-
async saveConfig(applicationId, payload = {}) {
|
|
264
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${applicationId}/install`, {
|
|
265
|
-
method: "POST",
|
|
266
|
-
headers: {
|
|
267
|
-
authorization: `Bearer ${this.token}`,
|
|
268
|
-
"content-type": "application/json",
|
|
269
|
-
},
|
|
270
|
-
body: JSON.stringify(payload),
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
if (res.status >= 400 && res.status < 600) {
|
|
274
|
-
throw new Error(res.statusText);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return await res.json();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Returns the specified saved config.
|
|
282
|
-
* @param {String} applicationId The application ID.
|
|
283
|
-
* @param {String} configId The config ID of the saved config.
|
|
284
|
-
* @returns {Promise<SavedConfig>} The specified saved config.
|
|
217
|
+
* Returns the specified config.
|
|
218
|
+
* @param {String} slug The application slug.
|
|
219
|
+
* @param {String} configId The unique ID of the config.
|
|
220
|
+
* @returns {Promise<Config>} The specified config.
|
|
285
221
|
*/
|
|
286
|
-
async
|
|
287
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${
|
|
222
|
+
async getConfig(slug, configId) {
|
|
223
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId}`, {
|
|
288
224
|
headers: {
|
|
289
225
|
authorization: `Bearer ${this.token}`,
|
|
290
226
|
},
|
|
@@ -298,14 +234,14 @@ class Cobalt {
|
|
|
298
234
|
}
|
|
299
235
|
|
|
300
236
|
/**
|
|
301
|
-
* Update the specified
|
|
302
|
-
* @param {String}
|
|
303
|
-
* @param {String} configId The
|
|
304
|
-
* @param {
|
|
305
|
-
* @returns {Promise<
|
|
237
|
+
* Update the specified config.
|
|
238
|
+
* @param {String} slug The application slug.
|
|
239
|
+
* @param {String} configId The unique ID of the config.
|
|
240
|
+
* @param {Config} payload The update payload.
|
|
241
|
+
* @returns {Promise<Config>} The specified config.
|
|
306
242
|
*/
|
|
307
|
-
async
|
|
308
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${
|
|
243
|
+
async updateConfig(slug, configId, payload = {}) {
|
|
244
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId}`, {
|
|
309
245
|
method: "PUT",
|
|
310
246
|
headers: {
|
|
311
247
|
authorization: `Bearer ${this.token}`,
|
|
@@ -322,13 +258,13 @@ class Cobalt {
|
|
|
322
258
|
}
|
|
323
259
|
|
|
324
260
|
/**
|
|
325
|
-
* Delete the specified
|
|
326
|
-
* @param {String}
|
|
327
|
-
* @param {String} configId The
|
|
261
|
+
* Delete the specified config.
|
|
262
|
+
* @param {String} slug The application slug.
|
|
263
|
+
* @param {String} configId The unique ID of the config.
|
|
328
264
|
* @returns {Promise<unknown>}
|
|
329
265
|
*/
|
|
330
|
-
async
|
|
331
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${
|
|
266
|
+
async deleteConfig(slug, configId) {
|
|
267
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId}`, {
|
|
332
268
|
method: "DELETE",
|
|
333
269
|
headers: {
|
|
334
270
|
authorization: `Bearer ${this.token}`,
|
package/docs.md
CHANGED
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
## Typedefs
|
|
10
10
|
|
|
11
11
|
<dl>
|
|
12
|
-
<dt><a href="#Config">Config</a> : <code>object</code></dt>
|
|
13
|
-
<dd><p>The configuration data for an application.</p>
|
|
14
|
-
</dd>
|
|
15
12
|
<dt><a href="#Label">Label</a> : <code>Object</code></dt>
|
|
16
13
|
<dd><p>Field Mapping Label</p>
|
|
17
14
|
</dd>
|
|
15
|
+
<dt><a href="#DynamicField">DynamicField</a> : <code>Object</code></dt>
|
|
16
|
+
<dd><p>Field Mapping Label</p>
|
|
17
|
+
</dd>
|
|
18
18
|
<dt><a href="#DynamicFields">DynamicFields</a> : <code>Object</code></dt>
|
|
19
19
|
<dd><p>The dynamic fields payload.</p>
|
|
20
20
|
</dd>
|
|
21
|
-
<dt><a href="#
|
|
22
|
-
<dd><p>
|
|
21
|
+
<dt><a href="#Config">Config</a> : <code>Object</code></dt>
|
|
22
|
+
<dd><p>The configuration data for an application.</p>
|
|
23
23
|
</dd>
|
|
24
24
|
<dt><a href="#Workflow">Workflow</a> : <code>Object</code></dt>
|
|
25
25
|
<dd><p>The workflow.</p>
|
|
@@ -32,26 +32,15 @@
|
|
|
32
32
|
Cobalt Frontend SDK
|
|
33
33
|
|
|
34
34
|
**Kind**: global class
|
|
35
|
-
**Properties**
|
|
36
|
-
|
|
37
|
-
| Name | Type | Description |
|
|
38
|
-
| --- | --- | --- |
|
|
39
|
-
| token | <code>String</code> | The session token. |
|
|
40
|
-
|
|
41
35
|
|
|
42
36
|
* [Cobalt](#Cobalt)
|
|
43
37
|
* [new Cobalt(options)](#new_Cobalt_new)
|
|
44
|
-
* [.
|
|
45
|
-
* [.
|
|
46
|
-
* [.
|
|
47
|
-
* [.
|
|
48
|
-
* [.
|
|
49
|
-
* [.
|
|
50
|
-
* [.getConfig(application)](#Cobalt+getConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
51
|
-
* [.saveConfig(applicationId, payload)](#Cobalt+saveConfig) ⇒ [<code>Promise.<SavedConfig></code>](#SavedConfig)
|
|
52
|
-
* [.getSavedConfig(applicationId, configId)](#Cobalt+getSavedConfig) ⇒ [<code>Promise.<SavedConfig></code>](#SavedConfig)
|
|
53
|
-
* [.updateSavedConfig(applicationId, configId, payload)](#Cobalt+updateSavedConfig) ⇒ [<code>Promise.<SavedConfig></code>](#SavedConfig)
|
|
54
|
-
* [.deleteSavedConfig(applicationId, configId)](#Cobalt+deleteSavedConfig) ⇒ <code>Promise.<unknown></code>
|
|
38
|
+
* [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.<Boolean></code>
|
|
39
|
+
* [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.<void></code>
|
|
40
|
+
* [.config(slug, configId, [fields])](#Cobalt+config) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
41
|
+
* [.getConfig(slug, configId)](#Cobalt+getConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
42
|
+
* [.updateConfig(slug, configId, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
43
|
+
* [.deleteConfig(slug, configId)](#Cobalt+deleteConfig) ⇒ <code>Promise.<unknown></code>
|
|
55
44
|
|
|
56
45
|
<a name="new_Cobalt_new"></a>
|
|
57
46
|
|
|
@@ -65,162 +54,99 @@ Cobalt Frontend SDK
|
|
|
65
54
|
| [options.token] | <code>String</code> | | The session token. |
|
|
66
55
|
| [options.baseUrl] | <code>String</code> | <code>https://api.gocobalt.io</code> | The base URL of the Cobalt API. |
|
|
67
56
|
|
|
68
|
-
<a name="Cobalt+
|
|
69
|
-
|
|
70
|
-
### cobalt.oauth(application) ⇒ <code>Promise.<Boolean></code>
|
|
71
|
-
Handle OAuth for the specified native application.
|
|
72
|
-
|
|
73
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
74
|
-
**Returns**: <code>Promise.<Boolean></code> - Whether the user authenticated.
|
|
75
|
-
|
|
76
|
-
| Param | Type | Description |
|
|
77
|
-
| --- | --- | --- |
|
|
78
|
-
| application | <code>String</code> | The application type. |
|
|
79
|
-
|
|
80
|
-
<a name="Cobalt+auth"></a>
|
|
81
|
-
|
|
82
|
-
### cobalt.auth(application, payload) ⇒ <code>Promise.<unknown></code>
|
|
83
|
-
Save the auth data that user provides to authenticate themselves to the
|
|
84
|
-
specified native application.
|
|
85
|
-
|
|
86
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
87
|
-
|
|
88
|
-
| Param | Type | Description |
|
|
89
|
-
| --- | --- | --- |
|
|
90
|
-
| application | <code>String</code> | The application type. |
|
|
91
|
-
| payload | <code>Object.<string, (string\|number\|boolean)></code> | The key value pairs of auth data. |
|
|
92
|
-
|
|
93
|
-
<a name="Cobalt+authCustom"></a>
|
|
94
|
-
|
|
95
|
-
### cobalt.authCustom(applicationId, payload) ⇒ <code>Promise.<unknown></code>
|
|
96
|
-
Save the auth data that user provides to authenticate themselves to the
|
|
97
|
-
specified custom application.
|
|
98
|
-
|
|
99
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
100
|
-
|
|
101
|
-
| Param | Type | Description |
|
|
102
|
-
| --- | --- | --- |
|
|
103
|
-
| applicationId | <code>String</code> | The application ID of the custom application. |
|
|
104
|
-
| payload | <code>Object.<string, (string\|number\|boolean)></code> | The key value pairs of auth data. |
|
|
105
|
-
|
|
106
|
-
<a name="Cobalt+checkAuth"></a>
|
|
57
|
+
<a name="Cobalt+connect"></a>
|
|
107
58
|
|
|
108
|
-
### cobalt.
|
|
109
|
-
|
|
59
|
+
### cobalt.connect(slug, [payload]) ⇒ <code>Promise.<Boolean></code>
|
|
60
|
+
Connect the specified application, optionally with the auth data that user provides.
|
|
110
61
|
|
|
111
62
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
112
|
-
**Returns**: <code>Promise.<Boolean></code> -
|
|
63
|
+
**Returns**: <code>Promise.<Boolean></code> - Whether the connection was successful.
|
|
113
64
|
|
|
114
|
-
| Param | Type | Description |
|
|
115
|
-
| --- | --- | --- |
|
|
116
|
-
|
|
|
65
|
+
| Param | Type | Default | Description |
|
|
66
|
+
| --- | --- | --- | --- |
|
|
67
|
+
| slug | <code>String</code> | | The application slug. |
|
|
68
|
+
| [payload] | <code>Object.<string, (string\|number\|boolean)></code> | <code>{}</code> | The key value pairs of auth data. |
|
|
117
69
|
|
|
118
|
-
<a name="Cobalt+
|
|
70
|
+
<a name="Cobalt+disconnect"></a>
|
|
119
71
|
|
|
120
|
-
### cobalt.
|
|
121
|
-
|
|
72
|
+
### cobalt.disconnect(slug) ⇒ <code>Promise.<void></code>
|
|
73
|
+
Disconnect the specified application and remove any associated data from Cobalt.
|
|
122
74
|
|
|
123
75
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
124
76
|
|
|
125
77
|
| Param | Type | Description |
|
|
126
78
|
| --- | --- | --- |
|
|
127
|
-
|
|
|
128
|
-
| [applicationId] | <code>String</code> | The application ID in case of custom applications. |
|
|
79
|
+
| slug | <code>String</code> | The application slug. |
|
|
129
80
|
|
|
130
81
|
<a name="Cobalt+config"></a>
|
|
131
82
|
|
|
132
|
-
### cobalt.config(
|
|
133
|
-
Returns the specified
|
|
83
|
+
### cobalt.config(slug, configId, [fields]) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
84
|
+
Returns the specified config, or creates one if it doesn't exist.
|
|
134
85
|
|
|
135
86
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
136
|
-
**Returns**: [<code>Promise.<
|
|
87
|
+
**Returns**: [<code>Promise.<Config></code>](#Config) - The specified config.
|
|
137
88
|
|
|
138
89
|
| Param | Type | Description |
|
|
139
90
|
| --- | --- | --- |
|
|
140
|
-
|
|
|
141
|
-
| configId | <code>String</code> |
|
|
142
|
-
| fields | [<code>DynamicFields</code>](#DynamicFields) | The dynamic fields payload. |
|
|
91
|
+
| slug | <code>String</code> | The application slug. |
|
|
92
|
+
| configId | <code>String</code> | A unique ID for the config. |
|
|
93
|
+
| [fields] | [<code>DynamicFields</code>](#DynamicFields) | The dynamic fields payload. |
|
|
143
94
|
|
|
144
95
|
<a name="Cobalt+getConfig"></a>
|
|
145
96
|
|
|
146
|
-
### cobalt.getConfig(
|
|
147
|
-
Returns the
|
|
148
|
-
|
|
149
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
150
|
-
**Returns**: [<code>Promise.<Config></code>](#Config) - The specified application's configuration data.
|
|
151
|
-
|
|
152
|
-
| Param | Type | Description |
|
|
153
|
-
| --- | --- | --- |
|
|
154
|
-
| application | <code>String</code> | The application ID. |
|
|
155
|
-
|
|
156
|
-
<a name="Cobalt+saveConfig"></a>
|
|
157
|
-
|
|
158
|
-
### cobalt.saveConfig(applicationId, payload) ⇒ [<code>Promise.<SavedConfig></code>](#SavedConfig)
|
|
159
|
-
Save the specified config.
|
|
97
|
+
### cobalt.getConfig(slug, configId) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
98
|
+
Returns the specified config.
|
|
160
99
|
|
|
161
100
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
162
|
-
**Returns**: [<code>Promise.<
|
|
101
|
+
**Returns**: [<code>Promise.<Config></code>](#Config) - The specified config.
|
|
163
102
|
|
|
164
103
|
| Param | Type | Description |
|
|
165
104
|
| --- | --- | --- |
|
|
166
|
-
|
|
|
167
|
-
|
|
|
105
|
+
| slug | <code>String</code> | The application slug. |
|
|
106
|
+
| configId | <code>String</code> | The unique ID of the config. |
|
|
168
107
|
|
|
169
|
-
<a name="Cobalt+
|
|
108
|
+
<a name="Cobalt+updateConfig"></a>
|
|
170
109
|
|
|
171
|
-
### cobalt.
|
|
172
|
-
|
|
110
|
+
### cobalt.updateConfig(slug, configId, payload) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
111
|
+
Update the specified config.
|
|
173
112
|
|
|
174
113
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
175
|
-
**Returns**: [<code>Promise.<
|
|
114
|
+
**Returns**: [<code>Promise.<Config></code>](#Config) - The specified config.
|
|
176
115
|
|
|
177
116
|
| Param | Type | Description |
|
|
178
117
|
| --- | --- | --- |
|
|
179
|
-
|
|
|
180
|
-
| configId | <code>String</code> | The
|
|
118
|
+
| slug | <code>String</code> | The application slug. |
|
|
119
|
+
| configId | <code>String</code> | The unique ID of the config. |
|
|
120
|
+
| payload | [<code>Config</code>](#Config) | The update payload. |
|
|
181
121
|
|
|
182
|
-
<a name="Cobalt+
|
|
122
|
+
<a name="Cobalt+deleteConfig"></a>
|
|
183
123
|
|
|
184
|
-
### cobalt.
|
|
185
|
-
|
|
124
|
+
### cobalt.deleteConfig(slug, configId) ⇒ <code>Promise.<unknown></code>
|
|
125
|
+
Delete the specified config.
|
|
186
126
|
|
|
187
127
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
188
|
-
**Returns**: [<code>Promise.<SavedConfig></code>](#SavedConfig) - The specified saved config.
|
|
189
128
|
|
|
190
129
|
| Param | Type | Description |
|
|
191
130
|
| --- | --- | --- |
|
|
192
|
-
|
|
|
193
|
-
| configId | <code>String</code> | The
|
|
194
|
-
| payload | [<code>SavedConfig</code>](#SavedConfig) | The update payload. |
|
|
195
|
-
|
|
196
|
-
<a name="Cobalt+deleteSavedConfig"></a>
|
|
131
|
+
| slug | <code>String</code> | The application slug. |
|
|
132
|
+
| configId | <code>String</code> | The unique ID of the config. |
|
|
197
133
|
|
|
198
|
-
|
|
199
|
-
Delete the specified saved config.
|
|
200
|
-
|
|
201
|
-
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
202
|
-
|
|
203
|
-
| Param | Type | Description |
|
|
204
|
-
| --- | --- | --- |
|
|
205
|
-
| applicationId | <code>String</code> | The application ID. |
|
|
206
|
-
| configId | <code>String</code> | The config ID of the saved config. |
|
|
207
|
-
|
|
208
|
-
<a name="Config"></a>
|
|
134
|
+
<a name="Label"></a>
|
|
209
135
|
|
|
210
|
-
##
|
|
211
|
-
|
|
136
|
+
## Label : <code>Object</code>
|
|
137
|
+
Field Mapping Label
|
|
212
138
|
|
|
213
139
|
**Kind**: global typedef
|
|
214
140
|
**Properties**
|
|
215
141
|
|
|
216
142
|
| Name | Type | Description |
|
|
217
143
|
| --- | --- | --- |
|
|
218
|
-
|
|
|
219
|
-
|
|
|
144
|
+
| name | <code>string</code> | The Label name. |
|
|
145
|
+
| value | <code>string</code> \| <code>number</code> \| <code>boolean</code> | The Label value. |
|
|
220
146
|
|
|
221
|
-
<a name="
|
|
147
|
+
<a name="DynamicField"></a>
|
|
222
148
|
|
|
223
|
-
##
|
|
149
|
+
## DynamicField : <code>Object</code>
|
|
224
150
|
Field Mapping Label
|
|
225
151
|
|
|
226
152
|
**Kind**: global typedef
|
|
@@ -228,8 +154,7 @@ Field Mapping Label
|
|
|
228
154
|
|
|
229
155
|
| Name | Type | Description |
|
|
230
156
|
| --- | --- | --- |
|
|
231
|
-
|
|
|
232
|
-
| value | <code>string</code> \| <code>number</code> \| <code>boolean</code> | The Label value. |
|
|
157
|
+
| fields | [<code>Array.<Label></code>](#Label) | The Label name. |
|
|
233
158
|
|
|
234
159
|
<a name="DynamicFields"></a>
|
|
235
160
|
|
|
@@ -241,19 +166,19 @@ The dynamic fields payload.
|
|
|
241
166
|
|
|
242
167
|
| Name | Type | Description |
|
|
243
168
|
| --- | --- | --- |
|
|
244
|
-
| map_fields_object | <code>Object.<string,
|
|
169
|
+
| map_fields_object | <code>Object.<string, DynamicField></code> | desc. |
|
|
245
170
|
|
|
246
|
-
<a name="
|
|
171
|
+
<a name="Config"></a>
|
|
247
172
|
|
|
248
|
-
##
|
|
249
|
-
|
|
173
|
+
## Config : <code>Object</code>
|
|
174
|
+
The configuration data for an application.
|
|
250
175
|
|
|
251
176
|
**Kind**: global typedef
|
|
252
177
|
**Properties**
|
|
253
178
|
|
|
254
179
|
| Name | Type | Description |
|
|
255
180
|
| --- | --- | --- |
|
|
256
|
-
| [config_id] | <code>String</code> | Unique ID for the
|
|
181
|
+
| [config_id] | <code>String</code> | Unique ID for the config. |
|
|
257
182
|
| application_data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of application data slots and their values. |
|
|
258
183
|
| workflows | [<code>Array.<Workflow></code>](#Workflow) | Whether the workflow is enabled. |
|
|
259
184
|
|