@cobaltio/cobalt-js 5.1.0 → 7.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.
Files changed (4) hide show
  1. package/README.md +48 -63
  2. package/cobalt.js +62 -56
  3. package/docs.md +43 -58
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # cobalt.js
1
+ # Cobalt Javascript SDK
2
2
  Cobalt frontend SDK.
3
3
 
4
4
  ## Install
@@ -22,10 +22,10 @@ yarn add @cobaltio/cobalt-js
22
22
  #### Browser
23
23
  ```html
24
24
  <!-- use a specific version -->
25
- <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@3.0.1"></script>
25
+ <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@7.0.0"></script>
26
26
  <!-- use a version range instead of a specific version -->
27
- <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@3"></script>
28
- <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@3.0"></script>
27
+ <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@7"></script>
28
+ <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js@7.0"></script>
29
29
  <!-- omit the version completely to use the latest one -->
30
30
  <!-- you should NOT use this in production -->
31
31
  <script src="https://cdn.jsdelivr.net/npm/@cobaltio/cobalt-js"></script>
@@ -71,20 +71,17 @@ cobalt.token = "COBALT_SESSION_TOKEN";
71
71
  <dt><a href="#InputField">InputField</a> : <code>Object</code></dt>
72
72
  <dd><p>An Input field to take input from the user.</p>
73
73
  </dd>
74
- <dt><a href="#Config">Config</a> : <code>Object</code></dt>
75
- <dd><p>The configuration data for an application.</p>
76
- </dd>
77
- <dt><a href="#Workflow">Workflow</a> : <code>Object</code></dt>
78
- <dd><p>The workflow.</p>
79
- </dd>
80
74
  <dt><a href="#ConfigPayload">ConfigPayload</a> : <code>Object</code></dt>
81
75
  <dd><p>The payload object for config.</p>
82
76
  </dd>
83
- <dt><a href="#DynamicField">DynamicField</a> : <code>Object</code></dt>
84
- <dd><p>Field Mapping Label</p>
85
- </dd>
86
77
  <dt><a href="#Label">Label</a> : <code>Object</code></dt>
87
- <dd><p>Field Mapping Label</p>
78
+ <dd><p>Label Mapping</p>
79
+ </dd>
80
+ <dt><a href="#UpdateConfigPayload">UpdateConfigPayload</a> : <code>Object</code></dt>
81
+ <dd><p>The configuration data for an application.</p>
82
+ </dd>
83
+ <dt><a href="#WorkflowPayload">WorkflowPayload</a> : <code>Object</code></dt>
84
+ <dd><p>The workflow.</p>
88
85
  </dd>
89
86
  </dl>
90
87
 
@@ -98,11 +95,11 @@ cobalt.token = "COBALT_SESSION_TOKEN";
98
95
  * [.getApp([slug])](#Cobalt+getApp) ⇒ [<code>Promise.&lt;Application&gt;</code>](#Application)
99
96
  * [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.&lt;Boolean&gt;</code>
100
97
  * [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.&lt;void&gt;</code>
101
- * [.config(slug, [payload])](#Cobalt+config) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
102
- * [.updateConfig(slug, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
98
+ * [.config(payload)](#Cobalt+config) ⇒ <code>Promise.&lt;Config&gt;</code>
99
+ * [.updateConfig(payload)](#Cobalt+updateConfig) ⇒ <code>Promise.&lt;Config&gt;</code>
103
100
  * [.deleteConfig(slug, [configId])](#Cobalt+deleteConfig) ⇒ <code>Promise.&lt;unknown&gt;</code>
104
- * Additional Methods:
105
- * [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
101
+ * Additional Methods
102
+ * [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ <code>Promise.&lt;Config&gt;</code>
106
103
 
107
104
  <a name="new_Cobalt_new"></a>
108
105
 
@@ -126,9 +123,9 @@ it returns all the enabled applications.
126
123
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
127
124
  **Returns**: [<code>Promise.&lt;Application&gt;</code>](#Application) - The application details.
128
125
 
129
- | Param | Type | Default | Description |
130
- | --- | --- | --- | --- |
131
- | [slug] | <code>String</code> | <code>&quot;*&quot;</code> | The application slug. |
126
+ | Param | Type | Description |
127
+ | --- | --- | --- |
128
+ | [slug] | <code>String</code> | The application slug. |
132
129
 
133
130
  <a name="Cobalt+connect"></a>
134
131
 
@@ -156,24 +153,23 @@ Disconnect the specified application and remove any associated data from Cobalt.
156
153
 
157
154
  <a name="Cobalt+config"></a>
158
155
 
159
- ### cobalt.config(slug, [payload]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
156
+ ### cobalt.config(payload) ⇒ <code>Promise.&lt;Config&gt;</code>
160
157
  Returns the specified config, or creates one if it doesn't exist.
161
158
 
162
159
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
163
- **Returns**: [<code>Promise.&lt;Config&gt;</code>](#Config) - The specified config.
160
+ **Returns**: <code>Promise.&lt;Config&gt;</code> - The specified config.
164
161
 
165
162
  | Param | Type | Description |
166
163
  | --- | --- | --- |
167
- | slug | <code>String</code> | The application slug. |
168
- | [payload] | [<code>ConfigPayload</code>](#ConfigPayload) | The payload object for config. |
164
+ | payload | [<code>ConfigPayload</code>](#ConfigPayload) | The payload object for config. |
169
165
 
170
166
  <a name="Cobalt+getConfig"></a>
171
167
 
172
- ### cobalt.getConfig(slug, [configId]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
168
+ ### cobalt.getConfig(slug, [configId]) ⇒ <code>Promise.&lt;Config&gt;</code>
173
169
  Returns the specified config.
174
170
 
175
171
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
176
- **Returns**: [<code>Promise.&lt;Config&gt;</code>](#Config) - The specified config.
172
+ **Returns**: <code>Promise.&lt;Config&gt;</code> - The specified config.
177
173
 
178
174
  | Param | Type | Description |
179
175
  | --- | --- | --- |
@@ -182,16 +178,15 @@ Returns the specified config.
182
178
 
183
179
  <a name="Cobalt+updateConfig"></a>
184
180
 
185
- ### cobalt.updateConfig(slug, payload) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
181
+ ### cobalt.updateConfig(payload) ⇒ <code>Promise.&lt;Config&gt;</code>
186
182
  Update the specified config.
187
183
 
188
184
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
189
- **Returns**: [<code>Promise.&lt;Config&gt;</code>](#Config) - The specified config.
185
+ **Returns**: <code>Promise.&lt;Config&gt;</code> - The specified config.
190
186
 
191
187
  | Param | Type | Description |
192
188
  | --- | --- | --- |
193
- | slug | <code>String</code> | The application slug. |
194
- | payload | [<code>Config</code>](#Config) | The update payload. |
189
+ | payload | [<code>UpdateConfigPayload</code>](#UpdateConfigPayload) | The update payload. |
195
190
 
196
191
  <a name="Cobalt+deleteConfig"></a>
197
192
 
@@ -240,68 +235,58 @@ An Input field to take input from the user.
240
235
  | placeholder | <code>String</code> | The placeholder of the field. |
241
236
  | label | <code>String</code> | The label of the field. |
242
237
 
243
- <a name="Config"></a>
238
+ <a name="ConfigPayload"></a>
244
239
 
245
- ## Config : <code>Object</code>
246
- The configuration data for an application.
240
+ ## ConfigPayload : <code>Object</code>
241
+ The payload object for config.
247
242
 
248
243
  **Kind**: global typedef
249
244
  **Properties**
250
245
 
251
246
  | Name | Type | Description |
252
247
  | --- | --- | --- |
248
+ | slug | <code>String</code> | The application slug. |
253
249
  | [config_id] | <code>String</code> | Unique ID for the config. |
254
- | application_data_slots | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of application data slots and their values. |
255
- | workflows | [<code>Array.&lt;Workflow&gt;</code>](#Workflow) | Whether the workflow is enabled. |
250
+ | labels | <code>Object.&lt;string, Array.&lt;Label&gt;&gt;</code> | The dynamic label mappings. |
256
251
 
257
- <a name="Workflow"></a>
252
+ <a name="Label"></a>
258
253
 
259
- ## Workflow : <code>Object</code>
260
- The workflow.
254
+ ## Label : <code>Object</code>
255
+ Label Mapping
261
256
 
262
257
  **Kind**: global typedef
263
258
  **Properties**
264
259
 
265
260
  | Name | Type | Description |
266
261
  | --- | --- | --- |
267
- | id | <code>String</code> | The ID of the workflow. |
268
- | enabled | <code>Boolean</code> | Whether the workflow is enabled. |
269
- | data_slots | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of workflow's data slots and their values. |
262
+ | name | <code>string</code> | The label name. |
263
+ | value | <code>string</code> \| <code>number</code> \| <code>boolean</code> | The label value. |
270
264
 
271
- <a name="ConfigPayload"></a>
265
+ <a name="UpdateConfigPayload"></a>
272
266
 
273
- ## ConfigPayload : <code>Object</code>
274
- The payload object for config.
267
+ ## UpdateConfigPayload : <code>Object</code>
268
+ The configuration data for an application.
275
269
 
276
270
  **Kind**: global typedef
277
271
  **Properties**
278
272
 
279
273
  | Name | Type | Description |
280
274
  | --- | --- | --- |
275
+ | slug | <code>String</code> | The application slug. |
281
276
  | [config_id] | <code>String</code> | Unique ID for the config. |
282
- | map_fields_object | <code>Object.&lt;string, DynamicField&gt;</code> | Map fields object. |
283
-
284
- <a name="DynamicField"></a>
277
+ | fields | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of application fields and their values. |
278
+ | workflows | [<code>Array.&lt;WorkflowPayload&gt;</code>](#WorkflowPayload) | Whether the workflow is enabled. |
285
279
 
286
- ## DynamicField : <code>Object</code>
287
- Field Mapping Label
280
+ <a name="WorkflowPayload"></a>
288
281
 
289
- **Kind**: global typedef
290
- **Properties**
291
-
292
- | Name | Type | Description |
293
- | --- | --- | --- |
294
- | fields | [<code>Array.&lt;Label&gt;</code>](#Label) | The Label name. |
295
-
296
- <a name="Label"></a>
297
-
298
- ## Label : <code>Object</code>
299
- Field Mapping Label
282
+ ## WorkflowPayload : <code>Object</code>
283
+ The workflow.
300
284
 
301
285
  **Kind**: global typedef
302
286
  **Properties**
303
287
 
304
288
  | Name | Type | Description |
305
289
  | --- | --- | --- |
306
- | name | <code>string</code> | The Label name. |
307
- | value | <code>string</code> \| <code>number</code> \| <code>boolean</code> | The Label value. |
290
+ | id | <code>String</code> | The ID of the workflow. |
291
+ | enabled | <code>Boolean</code> | Whether the workflow is enabled. |
292
+ | fields | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of workflow fields and their values. |
package/cobalt.js CHANGED
@@ -24,34 +24,31 @@
24
24
  */
25
25
 
26
26
  /**
27
- * @typedef {Object} Config The configuration data for an application.
27
+ * @typedef {Object} ConfigPayload The payload object for config.
28
+ * @property {String} slug The application slug.
28
29
  * @property {String} [config_id] Unique ID for the config.
29
- * @property {Object.<string, string | number | boolean>} application_data_slots A map of application data slots and their values.
30
- * @property {Workflow[]} workflows Whether the workflow is enabled.
30
+ * @property {Object.<string, Label[]>} labels The dynamic label mappings.
31
31
  */
32
32
 
33
33
  /**
34
- * @typedef {Object} Workflow The workflow.
35
- * @property {String} id The ID of the workflow.
36
- * @property {Boolean} enabled Whether the workflow is enabled.
37
- * @property {Object.<string, string | number | boolean>} data_slots A map of workflow's data slots and their values.
34
+ * @typedef {Object} Label Label Mapping
35
+ * @property {string} name The label name.
36
+ * @property {string | number | boolean} value The label value.
38
37
  */
39
38
 
40
39
  /**
41
- * @typedef {Object} ConfigPayload The payload object for config.
40
+ * @typedef {Object} UpdateConfigPayload The configuration data for an application.
41
+ * @property {String} slug The application slug.
42
42
  * @property {String} [config_id] Unique ID for the config.
43
- * @property {Object.<string, DynamicField>} map_fields_object Map fields object.
43
+ * @property {Object.<string, string | number | boolean>} fields A map of application fields and their values.
44
+ * @property {WorkflowPayload[]} workflows Whether the workflow is enabled.
44
45
  */
45
46
 
46
47
  /**
47
- * @typedef {Object} DynamicField Field Mapping Label
48
- * @property {Label[]} fields The Label name.
49
- */
50
-
51
- /**
52
- * @typedef {Object} Label Field Mapping Label
53
- * @property {string} name The Label name.
54
- * @property {string | number | boolean} value The Label value.
48
+ * @typedef {Object} WorkflowPayload The workflow.
49
+ * @property {String} id The ID of the workflow.
50
+ * @property {Boolean} enabled Whether the workflow is enabled.
51
+ * @property {Object.<string, string | number | boolean>} fields A map of workflow fields and their values.
55
52
  */
56
53
 
57
54
  class Cobalt {
@@ -98,11 +95,11 @@ class Cobalt {
98
95
  * Returns the application details for the specified application, provided
99
96
  * the application is enabled in Cobalt. If no application is specified,
100
97
  * it returns all the enabled applications.
101
- * @param {String} [slug="*"] The application slug.
98
+ * @param {String} [slug] The application slug.
102
99
  * @returns {Promise<Application>} The application details.
103
100
  */
104
- async getApp(slug = "*") {
105
- const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/application` + (slug ? `/${slug}` : ""), {
101
+ async getApp(slug) {
102
+ const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/application${slug ? `/${slug}` : ""}`, {
106
103
  headers: {
107
104
  authorization: `Bearer ${this.token}`,
108
105
  },
@@ -121,10 +118,11 @@ class Cobalt {
121
118
  * specified application.
122
119
  * @private
123
120
  * @param {String} slug The application slug.
121
+ * @param {Object.<string, string | number | boolean>} [params={}] The key value pairs of auth data.
124
122
  * @returns {Promise<String>} The auth URL where users can authenticate themselves.
125
123
  */
126
- async getOAuthUrl(slug) {
127
- const res = await fetch(`${this.baseUrl}/api/v1/${slug}/integrate`, {
124
+ async getOAuthUrl(slug, params) {
125
+ const res = await fetch(`${this.baseUrl}/api/v1/${slug}/integrate?${new URLSearchParams(params).toString()}`, {
128
126
  headers: {
129
127
  authorization: `Bearer ${this.token}`,
130
128
  },
@@ -142,11 +140,12 @@ class Cobalt {
142
140
  * Handle OAuth for the specified native application.
143
141
  * @private
144
142
  * @param {String} slug The application slug.
143
+ * @param {Object.<string, string | number | boolean>} [params={}] The key value pairs of auth data.
145
144
  * @returns {Promise<Boolean>} Whether the user authenticated.
146
145
  */
147
- async oauth(slug) {
146
+ async oauth(slug, params) {
148
147
  return new Promise((resolve, reject) => {
149
- this.getOAuthUrl(slug)
148
+ this.getOAuthUrl(slug, params)
150
149
  .then(oauthUrl => {
151
150
  const connectWindow = window.open(oauthUrl);
152
151
 
@@ -189,29 +188,38 @@ class Cobalt {
189
188
  * @returns {Promise<Boolean>} Whether the connection was successful.
190
189
  */
191
190
  async connect(slug, payload) {
192
- if (payload) {
193
- // save auth
194
- const res = await fetch(`${this.baseUrl}/api/v2/app/${slug}/save`, {
195
- method: "POST",
196
- headers: {
197
- authorization: `Bearer ${this.token}`,
198
- "content-type": "application/json",
199
- },
200
- body: JSON.stringify({
201
- ...payload,
202
- }),
203
- });
204
-
205
- if (res.status >= 400 && res.status < 600) {
206
- throw new Error(res.statusText);
207
- }
191
+ return new Promise(async (resolve, reject) => {
192
+ try {
193
+ const app = await this.getApp(slug);
194
+
195
+ // oauth
196
+ if (app?.auth_type ==="oauth2") {
197
+ const connected = await this.oauth(slug, payload);
198
+ resolve(connected);
199
+ // key based
200
+ } else {
201
+ const res = await fetch(`${this.baseUrl}/api/v2/app/${slug}/save`, {
202
+ method: "POST",
203
+ headers: {
204
+ authorization: `Bearer ${this.token}`,
205
+ "content-type": "application/json",
206
+ },
207
+ body: JSON.stringify({
208
+ ...payload,
209
+ }),
210
+ });
208
211
 
209
- const data = await res.json();
210
- return data.success;
211
- } else {
212
- // oauth
213
- return this.oauth(slug);
214
- }
212
+ if (res.status >= 400 && res.status < 600) {
213
+ reject(new Error(res.statusText));
214
+ }
215
+
216
+ const data = await res.json();
217
+ resolve(data.success);
218
+ }
219
+ } catch (error) {
220
+ reject(error);
221
+ }
222
+ });
215
223
  }
216
224
 
217
225
  /**
@@ -234,12 +242,11 @@ class Cobalt {
234
242
 
235
243
  /**
236
244
  * Returns the specified config, or creates one if it doesn't exist.
237
- * @param {String} slug The application slug.
238
- * @param {ConfigPayload} [payload] The payload object for config.
245
+ * @param {ConfigPayload} payload The payload object for config.
239
246
  * @returns {Promise<Config>} The specified config.
240
247
  */
241
- async config(slug, payload) {
242
- const res = await fetch(`${this.baseUrl}/api/v2/application/${slug}/installation`, {
248
+ async config(payload) {
249
+ const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/config`, {
243
250
  method: "POST",
244
251
  headers: {
245
252
  authorization: `Bearer ${this.token}`,
@@ -262,7 +269,7 @@ class Cobalt {
262
269
  * @returns {Promise<Config>} The specified config.
263
270
  */
264
271
  async getConfig(slug, configId) {
265
- const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId ? configId : ""}`, {
272
+ const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/slug/${slug}/config${configId ? `/${configId}` : ""}`, {
266
273
  headers: {
267
274
  authorization: `Bearer ${this.token}`,
268
275
  },
@@ -277,12 +284,11 @@ class Cobalt {
277
284
 
278
285
  /**
279
286
  * Update the specified config.
280
- * @param {String} slug The application slug.
281
- * @param {Config} payload The update payload.
287
+ * @param {UpdateConfigPayload} payload The update payload.
282
288
  * @returns {Promise<Config>} The specified config.
283
289
  */
284
- async updateConfig(slug, payload = {}) {
285
- const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation`, {
290
+ async updateConfig(payload) {
291
+ const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/config`, {
286
292
  method: "PUT",
287
293
  headers: {
288
294
  authorization: `Bearer ${this.token}`,
@@ -305,7 +311,7 @@ class Cobalt {
305
311
  * @returns {Promise<unknown>}
306
312
  */
307
313
  async deleteConfig(slug, configId) {
308
- const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId ? configId : ""}`, {
314
+ const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/slug/${slug}/config${configId ? `/${configId}` : ""}`, {
309
315
  method: "DELETE",
310
316
  headers: {
311
317
  authorization: `Bearer ${this.token}`,
package/docs.md CHANGED
@@ -14,20 +14,17 @@
14
14
  <dt><a href="#InputField">InputField</a> : <code>Object</code></dt>
15
15
  <dd><p>An Input field to take input from the user.</p>
16
16
  </dd>
17
- <dt><a href="#Config">Config</a> : <code>Object</code></dt>
18
- <dd><p>The configuration data for an application.</p>
19
- </dd>
20
- <dt><a href="#Workflow">Workflow</a> : <code>Object</code></dt>
21
- <dd><p>The workflow.</p>
22
- </dd>
23
17
  <dt><a href="#ConfigPayload">ConfigPayload</a> : <code>Object</code></dt>
24
18
  <dd><p>The payload object for config.</p>
25
19
  </dd>
26
- <dt><a href="#DynamicField">DynamicField</a> : <code>Object</code></dt>
27
- <dd><p>Field Mapping Label</p>
28
- </dd>
29
20
  <dt><a href="#Label">Label</a> : <code>Object</code></dt>
30
- <dd><p>Field Mapping Label</p>
21
+ <dd><p>Label Mapping</p>
22
+ </dd>
23
+ <dt><a href="#UpdateConfigPayload">UpdateConfigPayload</a> : <code>Object</code></dt>
24
+ <dd><p>The configuration data for an application.</p>
25
+ </dd>
26
+ <dt><a href="#WorkflowPayload">WorkflowPayload</a> : <code>Object</code></dt>
27
+ <dd><p>The workflow.</p>
31
28
  </dd>
32
29
  </dl>
33
30
 
@@ -41,9 +38,9 @@
41
38
  * [.getApp([slug])](#Cobalt+getApp) ⇒ [<code>Promise.&lt;Application&gt;</code>](#Application)
42
39
  * [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.&lt;Boolean&gt;</code>
43
40
  * [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.&lt;void&gt;</code>
44
- * [.config(slug, [payload])](#Cobalt+config) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
45
- * [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
46
- * [.updateConfig(slug, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
41
+ * [.config(payload)](#Cobalt+config) ⇒ <code>Promise.&lt;Config&gt;</code>
42
+ * [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ <code>Promise.&lt;Config&gt;</code>
43
+ * [.updateConfig(payload)](#Cobalt+updateConfig) ⇒ <code>Promise.&lt;Config&gt;</code>
47
44
  * [.deleteConfig(slug, [configId])](#Cobalt+deleteConfig) ⇒ <code>Promise.&lt;unknown&gt;</code>
48
45
 
49
46
  <a name="new_Cobalt_new"></a>
@@ -68,9 +65,9 @@ it returns all the enabled applications.
68
65
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
69
66
  **Returns**: [<code>Promise.&lt;Application&gt;</code>](#Application) - The application details.
70
67
 
71
- | Param | Type | Default | Description |
72
- | --- | --- | --- | --- |
73
- | [slug] | <code>String</code> | <code>&quot;*&quot;</code> | The application slug. |
68
+ | Param | Type | Description |
69
+ | --- | --- | --- |
70
+ | [slug] | <code>String</code> | The application slug. |
74
71
 
75
72
  <a name="Cobalt+connect"></a>
76
73
 
@@ -98,24 +95,23 @@ Disconnect the specified application and remove any associated data from Cobalt.
98
95
 
99
96
  <a name="Cobalt+config"></a>
100
97
 
101
- ### cobalt.config(slug, [payload]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
98
+ ### cobalt.config(payload) ⇒ <code>Promise.&lt;Config&gt;</code>
102
99
  Returns the specified config, or creates one if it doesn't exist.
103
100
 
104
101
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
105
- **Returns**: [<code>Promise.&lt;Config&gt;</code>](#Config) - The specified config.
102
+ **Returns**: <code>Promise.&lt;Config&gt;</code> - The specified config.
106
103
 
107
104
  | Param | Type | Description |
108
105
  | --- | --- | --- |
109
- | slug | <code>String</code> | The application slug. |
110
- | [payload] | [<code>ConfigPayload</code>](#ConfigPayload) | The payload object for config. |
106
+ | payload | [<code>ConfigPayload</code>](#ConfigPayload) | The payload object for config. |
111
107
 
112
108
  <a name="Cobalt+getConfig"></a>
113
109
 
114
- ### cobalt.getConfig(slug, [configId]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
110
+ ### cobalt.getConfig(slug, [configId]) ⇒ <code>Promise.&lt;Config&gt;</code>
115
111
  Returns the specified config.
116
112
 
117
113
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
118
- **Returns**: [<code>Promise.&lt;Config&gt;</code>](#Config) - The specified config.
114
+ **Returns**: <code>Promise.&lt;Config&gt;</code> - The specified config.
119
115
 
120
116
  | Param | Type | Description |
121
117
  | --- | --- | --- |
@@ -124,16 +120,15 @@ Returns the specified config.
124
120
 
125
121
  <a name="Cobalt+updateConfig"></a>
126
122
 
127
- ### cobalt.updateConfig(slug, payload) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
123
+ ### cobalt.updateConfig(payload) ⇒ <code>Promise.&lt;Config&gt;</code>
128
124
  Update the specified config.
129
125
 
130
126
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
131
- **Returns**: [<code>Promise.&lt;Config&gt;</code>](#Config) - The specified config.
127
+ **Returns**: <code>Promise.&lt;Config&gt;</code> - The specified config.
132
128
 
133
129
  | Param | Type | Description |
134
130
  | --- | --- | --- |
135
- | slug | <code>String</code> | The application slug. |
136
- | payload | [<code>Config</code>](#Config) | The update payload. |
131
+ | payload | [<code>UpdateConfigPayload</code>](#UpdateConfigPayload) | The update payload. |
137
132
 
138
133
  <a name="Cobalt+deleteConfig"></a>
139
134
 
@@ -182,69 +177,59 @@ An Input field to take input from the user.
182
177
  | placeholder | <code>String</code> | The placeholder of the field. |
183
178
  | label | <code>String</code> | The label of the field. |
184
179
 
185
- <a name="Config"></a>
180
+ <a name="ConfigPayload"></a>
186
181
 
187
- ## Config : <code>Object</code>
188
- The configuration data for an application.
182
+ ## ConfigPayload : <code>Object</code>
183
+ The payload object for config.
189
184
 
190
185
  **Kind**: global typedef
191
186
  **Properties**
192
187
 
193
188
  | Name | Type | Description |
194
189
  | --- | --- | --- |
190
+ | slug | <code>String</code> | The application slug. |
195
191
  | [config_id] | <code>String</code> | Unique ID for the config. |
196
- | application_data_slots | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of application data slots and their values. |
197
- | workflows | [<code>Array.&lt;Workflow&gt;</code>](#Workflow) | Whether the workflow is enabled. |
192
+ | labels | <code>Object.&lt;string, Array.&lt;Label&gt;&gt;</code> | The dynamic label mappings. |
198
193
 
199
- <a name="Workflow"></a>
194
+ <a name="Label"></a>
200
195
 
201
- ## Workflow : <code>Object</code>
202
- The workflow.
196
+ ## Label : <code>Object</code>
197
+ Label Mapping
203
198
 
204
199
  **Kind**: global typedef
205
200
  **Properties**
206
201
 
207
202
  | Name | Type | Description |
208
203
  | --- | --- | --- |
209
- | id | <code>String</code> | The ID of the workflow. |
210
- | enabled | <code>Boolean</code> | Whether the workflow is enabled. |
211
- | data_slots | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of workflow's data slots and their values. |
204
+ | name | <code>string</code> | The label name. |
205
+ | value | <code>string</code> \| <code>number</code> \| <code>boolean</code> | The label value. |
212
206
 
213
- <a name="ConfigPayload"></a>
207
+ <a name="UpdateConfigPayload"></a>
214
208
 
215
- ## ConfigPayload : <code>Object</code>
216
- The payload object for config.
209
+ ## UpdateConfigPayload : <code>Object</code>
210
+ The configuration data for an application.
217
211
 
218
212
  **Kind**: global typedef
219
213
  **Properties**
220
214
 
221
215
  | Name | Type | Description |
222
216
  | --- | --- | --- |
217
+ | slug | <code>String</code> | The application slug. |
223
218
  | [config_id] | <code>String</code> | Unique ID for the config. |
224
- | map_fields_object | <code>Object.&lt;string, DynamicField&gt;</code> | Map fields object. |
225
-
226
- <a name="DynamicField"></a>
219
+ | fields | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of application fields and their values. |
220
+ | workflows | [<code>Array.&lt;WorkflowPayload&gt;</code>](#WorkflowPayload) | Whether the workflow is enabled. |
227
221
 
228
- ## DynamicField : <code>Object</code>
229
- Field Mapping Label
222
+ <a name="WorkflowPayload"></a>
230
223
 
231
- **Kind**: global typedef
232
- **Properties**
233
-
234
- | Name | Type | Description |
235
- | --- | --- | --- |
236
- | fields | [<code>Array.&lt;Label&gt;</code>](#Label) | The Label name. |
237
-
238
- <a name="Label"></a>
239
-
240
- ## Label : <code>Object</code>
241
- Field Mapping Label
224
+ ## WorkflowPayload : <code>Object</code>
225
+ The workflow.
242
226
 
243
227
  **Kind**: global typedef
244
228
  **Properties**
245
229
 
246
230
  | Name | Type | Description |
247
231
  | --- | --- | --- |
248
- | name | <code>string</code> | The Label name. |
249
- | value | <code>string</code> \| <code>number</code> \| <code>boolean</code> | The Label value. |
232
+ | id | <code>String</code> | The ID of the workflow. |
233
+ | enabled | <code>Boolean</code> | Whether the workflow is enabled. |
234
+ | fields | <code>Object.&lt;string, (string\|number\|boolean)&gt;</code> | A map of workflow fields and their values. |
250
235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobaltio/cobalt-js",
3
- "version": "5.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "scripts": {