@cobaltio/cobalt-js 3.0.4 → 5.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 +19 -20
- package/cobalt.js +13 -14
- package/docs.md +18 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,8 +77,8 @@ cobalt.token = "COBALT_SESSION_TOKEN";
|
|
|
77
77
|
<dt><a href="#Workflow">Workflow</a> : <code>Object</code></dt>
|
|
78
78
|
<dd><p>The workflow.</p>
|
|
79
79
|
</dd>
|
|
80
|
-
<dt><a href="#
|
|
81
|
-
<dd><p>The
|
|
80
|
+
<dt><a href="#ConfigPayload">ConfigPayload</a> : <code>Object</code></dt>
|
|
81
|
+
<dd><p>The payload object for config.</p>
|
|
82
82
|
</dd>
|
|
83
83
|
<dt><a href="#DynamicField">DynamicField</a> : <code>Object</code></dt>
|
|
84
84
|
<dd><p>Field Mapping Label</p>
|
|
@@ -95,14 +95,14 @@ cobalt.token = "COBALT_SESSION_TOKEN";
|
|
|
95
95
|
|
|
96
96
|
* [Cobalt](#Cobalt)
|
|
97
97
|
* [new Cobalt(options)](#new_Cobalt_new)
|
|
98
|
+
* [.getApp([slug])](#Cobalt+getApp) ⇒ [<code>Promise.<Application></code>](#Application)
|
|
98
99
|
* [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.<Boolean></code>
|
|
99
100
|
* [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.<void></code>
|
|
100
|
-
* [.config(slug,
|
|
101
|
-
* [.updateConfig(slug,
|
|
102
|
-
* [.deleteConfig(slug, configId)](#Cobalt+deleteConfig) ⇒ <code>Promise.<unknown></code>
|
|
101
|
+
* [.config(slug, [payload])](#Cobalt+config) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
102
|
+
* [.updateConfig(slug, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
103
|
+
* [.deleteConfig(slug, [configId])](#Cobalt+deleteConfig) ⇒ <code>Promise.<unknown></code>
|
|
103
104
|
* Additional Methods:
|
|
104
|
-
* [.
|
|
105
|
-
* [.getConfig(slug, configId)](#Cobalt+getConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
105
|
+
* [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
106
106
|
|
|
107
107
|
<a name="new_Cobalt_new"></a>
|
|
108
108
|
|
|
@@ -156,7 +156,7 @@ Disconnect the specified application and remove any associated data from Cobalt.
|
|
|
156
156
|
|
|
157
157
|
<a name="Cobalt+config"></a>
|
|
158
158
|
|
|
159
|
-
### cobalt.config(slug,
|
|
159
|
+
### cobalt.config(slug, [payload]) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
160
160
|
Returns the specified config, or creates one if it doesn't exist.
|
|
161
161
|
|
|
162
162
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -165,12 +165,11 @@ Returns the specified config, or creates one if it doesn't exist.
|
|
|
165
165
|
| Param | Type | Description |
|
|
166
166
|
| --- | --- | --- |
|
|
167
167
|
| slug | <code>String</code> | The application slug. |
|
|
168
|
-
|
|
|
169
|
-
| [fields] | [<code>DynamicFields</code>](#DynamicFields) | The dynamic fields payload. |
|
|
168
|
+
| [payload] | [<code>ConfigPayload</code>](#ConfigPayload) | The payload object for config. |
|
|
170
169
|
|
|
171
170
|
<a name="Cobalt+getConfig"></a>
|
|
172
171
|
|
|
173
|
-
### cobalt.getConfig(slug, configId) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
172
|
+
### cobalt.getConfig(slug, [configId]) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
174
173
|
Returns the specified config.
|
|
175
174
|
|
|
176
175
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -179,11 +178,11 @@ Returns the specified config.
|
|
|
179
178
|
| Param | Type | Description |
|
|
180
179
|
| --- | --- | --- |
|
|
181
180
|
| slug | <code>String</code> | The application slug. |
|
|
182
|
-
| configId | <code>String</code> | The unique ID of the config. |
|
|
181
|
+
| [configId] | <code>String</code> | The unique ID of the config. |
|
|
183
182
|
|
|
184
183
|
<a name="Cobalt+updateConfig"></a>
|
|
185
184
|
|
|
186
|
-
### cobalt.updateConfig(slug,
|
|
185
|
+
### cobalt.updateConfig(slug, payload) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
187
186
|
Update the specified config.
|
|
188
187
|
|
|
189
188
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -192,12 +191,11 @@ Update the specified config.
|
|
|
192
191
|
| Param | Type | Description |
|
|
193
192
|
| --- | --- | --- |
|
|
194
193
|
| slug | <code>String</code> | The application slug. |
|
|
195
|
-
| configId | <code>String</code> | The unique ID of the config. |
|
|
196
194
|
| payload | [<code>Config</code>](#Config) | The update payload. |
|
|
197
195
|
|
|
198
196
|
<a name="Cobalt+deleteConfig"></a>
|
|
199
197
|
|
|
200
|
-
### cobalt.deleteConfig(slug, configId) ⇒ <code>Promise.<unknown></code>
|
|
198
|
+
### cobalt.deleteConfig(slug, [configId]) ⇒ <code>Promise.<unknown></code>
|
|
201
199
|
Delete the specified config.
|
|
202
200
|
|
|
203
201
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -205,7 +203,7 @@ Delete the specified config.
|
|
|
205
203
|
| Param | Type | Description |
|
|
206
204
|
| --- | --- | --- |
|
|
207
205
|
| slug | <code>String</code> | The application slug. |
|
|
208
|
-
| configId | <code>String</code> | The unique ID of the config. |
|
|
206
|
+
| [configId] | <code>String</code> | The unique ID of the config. |
|
|
209
207
|
|
|
210
208
|
<a name="Application"></a>
|
|
211
209
|
|
|
@@ -270,17 +268,18 @@ The workflow.
|
|
|
270
268
|
| enabled | <code>Boolean</code> | Whether the workflow is enabled. |
|
|
271
269
|
| data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of workflow's data slots and their values. |
|
|
272
270
|
|
|
273
|
-
<a name="
|
|
271
|
+
<a name="ConfigPayload"></a>
|
|
274
272
|
|
|
275
|
-
##
|
|
276
|
-
The
|
|
273
|
+
## ConfigPayload : <code>Object</code>
|
|
274
|
+
The payload object for config.
|
|
277
275
|
|
|
278
276
|
**Kind**: global typedef
|
|
279
277
|
**Properties**
|
|
280
278
|
|
|
281
279
|
| Name | Type | Description |
|
|
282
280
|
| --- | --- | --- |
|
|
283
|
-
|
|
|
281
|
+
| [config_id] | <code>String</code> | Unique ID for the config. |
|
|
282
|
+
| map_fields_object | <code>Object.<string, DynamicField></code> | Map fields object. |
|
|
284
283
|
|
|
285
284
|
<a name="DynamicField"></a>
|
|
286
285
|
|
package/cobalt.js
CHANGED
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* @typedef {Object}
|
|
42
|
-
* @property {
|
|
41
|
+
* @typedef {Object} ConfigPayload The payload object for config.
|
|
42
|
+
* @property {String} [config_id] Unique ID for the config.
|
|
43
|
+
* @property {Object.<string, DynamicField>} map_fields_object Map fields object.
|
|
43
44
|
*/
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -214,18 +215,17 @@ class Cobalt {
|
|
|
214
215
|
/**
|
|
215
216
|
* Returns the specified config, or creates one if it doesn't exist.
|
|
216
217
|
* @param {String} slug The application slug.
|
|
217
|
-
* @param {
|
|
218
|
-
* @param {DynamicFields} [fields] The dynamic fields payload.
|
|
218
|
+
* @param {ConfigPayload} [payload] The payload object for config.
|
|
219
219
|
* @returns {Promise<Config>} The specified config.
|
|
220
220
|
*/
|
|
221
|
-
async config(slug, configId,
|
|
222
|
-
const res = await fetch(`${this.baseUrl}/api/v2/application/${slug}/installation/${configId}`, {
|
|
221
|
+
async config(slug, configId, payload) {
|
|
222
|
+
const res = await fetch(`${this.baseUrl}/api/v2/application/${slug}/installation/${configId ? configId : ""}`, {
|
|
223
223
|
method: "POST",
|
|
224
224
|
headers: {
|
|
225
225
|
authorization: `Bearer ${this.token}`,
|
|
226
226
|
"content-type": "application/json",
|
|
227
227
|
},
|
|
228
|
-
body: JSON.stringify(
|
|
228
|
+
body: JSON.stringify(payload),
|
|
229
229
|
});
|
|
230
230
|
|
|
231
231
|
if (res.status >= 400 && res.status < 600) {
|
|
@@ -238,11 +238,11 @@ class Cobalt {
|
|
|
238
238
|
/**
|
|
239
239
|
* Returns the specified config.
|
|
240
240
|
* @param {String} slug The application slug.
|
|
241
|
-
* @param {String} configId The unique ID of the config.
|
|
241
|
+
* @param {String} [configId] The unique ID of the config.
|
|
242
242
|
* @returns {Promise<Config>} The specified config.
|
|
243
243
|
*/
|
|
244
244
|
async getConfig(slug, configId) {
|
|
245
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId}`, {
|
|
245
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId ? configId : ""}`, {
|
|
246
246
|
headers: {
|
|
247
247
|
authorization: `Bearer ${this.token}`,
|
|
248
248
|
},
|
|
@@ -258,12 +258,11 @@ class Cobalt {
|
|
|
258
258
|
/**
|
|
259
259
|
* Update the specified config.
|
|
260
260
|
* @param {String} slug The application slug.
|
|
261
|
-
* @param {String} configId The unique ID of the config.
|
|
262
261
|
* @param {Config} payload The update payload.
|
|
263
262
|
* @returns {Promise<Config>} The specified config.
|
|
264
263
|
*/
|
|
265
|
-
async updateConfig(slug,
|
|
266
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation
|
|
264
|
+
async updateConfig(slug, payload = {}) {
|
|
265
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation`, {
|
|
267
266
|
method: "PUT",
|
|
268
267
|
headers: {
|
|
269
268
|
authorization: `Bearer ${this.token}`,
|
|
@@ -282,11 +281,11 @@ class Cobalt {
|
|
|
282
281
|
/**
|
|
283
282
|
* Delete the specified config.
|
|
284
283
|
* @param {String} slug The application slug.
|
|
285
|
-
* @param {String} configId The unique ID of the config.
|
|
284
|
+
* @param {String} [configId] The unique ID of the config.
|
|
286
285
|
* @returns {Promise<unknown>}
|
|
287
286
|
*/
|
|
288
287
|
async deleteConfig(slug, configId) {
|
|
289
|
-
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId}`, {
|
|
288
|
+
const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId ? configId : ""}`, {
|
|
290
289
|
method: "DELETE",
|
|
291
290
|
headers: {
|
|
292
291
|
authorization: `Bearer ${this.token}`,
|
package/docs.md
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
<dt><a href="#Workflow">Workflow</a> : <code>Object</code></dt>
|
|
21
21
|
<dd><p>The workflow.</p>
|
|
22
22
|
</dd>
|
|
23
|
-
<dt><a href="#
|
|
24
|
-
<dd><p>The
|
|
23
|
+
<dt><a href="#ConfigPayload">ConfigPayload</a> : <code>Object</code></dt>
|
|
24
|
+
<dd><p>The payload object for config.</p>
|
|
25
25
|
</dd>
|
|
26
26
|
<dt><a href="#DynamicField">DynamicField</a> : <code>Object</code></dt>
|
|
27
27
|
<dd><p>Field Mapping Label</p>
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
* [.getApp([slug])](#Cobalt+getApp) ⇒ [<code>Promise.<Application></code>](#Application)
|
|
42
42
|
* [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.<Boolean></code>
|
|
43
43
|
* [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.<void></code>
|
|
44
|
-
* [.config(slug,
|
|
45
|
-
* [.getConfig(slug, configId)](#Cobalt+getConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
46
|
-
* [.updateConfig(slug,
|
|
47
|
-
* [.deleteConfig(slug, configId)](#Cobalt+deleteConfig) ⇒ <code>Promise.<unknown></code>
|
|
44
|
+
* [.config(slug, [payload])](#Cobalt+config) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
45
|
+
* [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
46
|
+
* [.updateConfig(slug, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
47
|
+
* [.deleteConfig(slug, [configId])](#Cobalt+deleteConfig) ⇒ <code>Promise.<unknown></code>
|
|
48
48
|
|
|
49
49
|
<a name="new_Cobalt_new"></a>
|
|
50
50
|
|
|
@@ -98,7 +98,7 @@ Disconnect the specified application and remove any associated data from Cobalt.
|
|
|
98
98
|
|
|
99
99
|
<a name="Cobalt+config"></a>
|
|
100
100
|
|
|
101
|
-
### cobalt.config(slug,
|
|
101
|
+
### cobalt.config(slug, [payload]) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
102
102
|
Returns the specified config, or creates one if it doesn't exist.
|
|
103
103
|
|
|
104
104
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -107,12 +107,11 @@ Returns the specified config, or creates one if it doesn't exist.
|
|
|
107
107
|
| Param | Type | Description |
|
|
108
108
|
| --- | --- | --- |
|
|
109
109
|
| slug | <code>String</code> | The application slug. |
|
|
110
|
-
|
|
|
111
|
-
| [fields] | [<code>DynamicFields</code>](#DynamicFields) | The dynamic fields payload. |
|
|
110
|
+
| [payload] | [<code>ConfigPayload</code>](#ConfigPayload) | The payload object for config. |
|
|
112
111
|
|
|
113
112
|
<a name="Cobalt+getConfig"></a>
|
|
114
113
|
|
|
115
|
-
### cobalt.getConfig(slug, configId) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
114
|
+
### cobalt.getConfig(slug, [configId]) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
116
115
|
Returns the specified config.
|
|
117
116
|
|
|
118
117
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -121,11 +120,11 @@ Returns the specified config.
|
|
|
121
120
|
| Param | Type | Description |
|
|
122
121
|
| --- | --- | --- |
|
|
123
122
|
| slug | <code>String</code> | The application slug. |
|
|
124
|
-
| configId | <code>String</code> | The unique ID of the config. |
|
|
123
|
+
| [configId] | <code>String</code> | The unique ID of the config. |
|
|
125
124
|
|
|
126
125
|
<a name="Cobalt+updateConfig"></a>
|
|
127
126
|
|
|
128
|
-
### cobalt.updateConfig(slug,
|
|
127
|
+
### cobalt.updateConfig(slug, payload) ⇒ [<code>Promise.<Config></code>](#Config)
|
|
129
128
|
Update the specified config.
|
|
130
129
|
|
|
131
130
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -134,12 +133,11 @@ Update the specified config.
|
|
|
134
133
|
| Param | Type | Description |
|
|
135
134
|
| --- | --- | --- |
|
|
136
135
|
| slug | <code>String</code> | The application slug. |
|
|
137
|
-
| configId | <code>String</code> | The unique ID of the config. |
|
|
138
136
|
| payload | [<code>Config</code>](#Config) | The update payload. |
|
|
139
137
|
|
|
140
138
|
<a name="Cobalt+deleteConfig"></a>
|
|
141
139
|
|
|
142
|
-
### cobalt.deleteConfig(slug, configId) ⇒ <code>Promise.<unknown></code>
|
|
140
|
+
### cobalt.deleteConfig(slug, [configId]) ⇒ <code>Promise.<unknown></code>
|
|
143
141
|
Delete the specified config.
|
|
144
142
|
|
|
145
143
|
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
@@ -147,7 +145,7 @@ Delete the specified config.
|
|
|
147
145
|
| Param | Type | Description |
|
|
148
146
|
| --- | --- | --- |
|
|
149
147
|
| slug | <code>String</code> | The application slug. |
|
|
150
|
-
| configId | <code>String</code> | The unique ID of the config. |
|
|
148
|
+
| [configId] | <code>String</code> | The unique ID of the config. |
|
|
151
149
|
|
|
152
150
|
<a name="Application"></a>
|
|
153
151
|
|
|
@@ -212,17 +210,18 @@ The workflow.
|
|
|
212
210
|
| enabled | <code>Boolean</code> | Whether the workflow is enabled. |
|
|
213
211
|
| data_slots | <code>Object.<string, (string\|number\|boolean)></code> | A map of workflow's data slots and their values. |
|
|
214
212
|
|
|
215
|
-
<a name="
|
|
213
|
+
<a name="ConfigPayload"></a>
|
|
216
214
|
|
|
217
|
-
##
|
|
218
|
-
The
|
|
215
|
+
## ConfigPayload : <code>Object</code>
|
|
216
|
+
The payload object for config.
|
|
219
217
|
|
|
220
218
|
**Kind**: global typedef
|
|
221
219
|
**Properties**
|
|
222
220
|
|
|
223
221
|
| Name | Type | Description |
|
|
224
222
|
| --- | --- | --- |
|
|
225
|
-
|
|
|
223
|
+
| [config_id] | <code>String</code> | Unique ID for the config. |
|
|
224
|
+
| map_fields_object | <code>Object.<string, DynamicField></code> | Map fields object. |
|
|
226
225
|
|
|
227
226
|
<a name="DynamicField"></a>
|
|
228
227
|
|