@cobaltio/cobalt-js 3.0.4 → 4.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 +13 -13
  2. package/cobalt.js +8 -9
  3. package/docs.md +11 -12
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -95,14 +95,15 @@ 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.&lt;Application&gt;</code>](#Application)
98
99
  * [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.&lt;Boolean&gt;</code>
99
100
  * [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.&lt;void&gt;</code>
100
- * [.config(slug, configId, [fields])](#Cobalt+config) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
101
- * [.updateConfig(slug, configId, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
102
- * [.deleteConfig(slug, configId)](#Cobalt+deleteConfig) ⇒ <code>Promise.&lt;unknown&gt;</code>
101
+ * [.config(slug, [configId], [fields])](#Cobalt+config) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
102
+ * [.updateConfig(slug, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
103
+ * [.deleteConfig(slug, [configId])](#Cobalt+deleteConfig) ⇒ <code>Promise.&lt;unknown&gt;</code>
103
104
  * Additional Methods:
104
- * [.getApp([slug])](#Cobalt+getApp) ⇒ [<code>Promise.&lt;Application&gt;</code>](#Application)
105
- * [.getConfig(slug, configId)](#Cobalt+getConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
105
+ * [.getConfig(slug, [configId])](#Cobalt+getConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
106
+
106
107
 
107
108
  <a name="new_Cobalt_new"></a>
108
109
 
@@ -156,7 +157,7 @@ Disconnect the specified application and remove any associated data from Cobalt.
156
157
 
157
158
  <a name="Cobalt+config"></a>
158
159
 
159
- ### cobalt.config(slug, configId, [fields]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
160
+ ### cobalt.config(slug, [configId], [fields]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
160
161
  Returns the specified config, or creates one if it doesn't exist.
161
162
 
162
163
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -165,12 +166,12 @@ Returns the specified config, or creates one if it doesn't exist.
165
166
  | Param | Type | Description |
166
167
  | --- | --- | --- |
167
168
  | slug | <code>String</code> | The application slug. |
168
- | configId | <code>String</code> | A unique ID for the config. |
169
+ | [configId] | <code>String</code> | The unique ID of the config. |
169
170
  | [fields] | [<code>DynamicFields</code>](#DynamicFields) | The dynamic fields payload. |
170
171
 
171
172
  <a name="Cobalt+getConfig"></a>
172
173
 
173
- ### cobalt.getConfig(slug, configId) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
174
+ ### cobalt.getConfig(slug, [configId]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
174
175
  Returns the specified config.
175
176
 
176
177
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -179,11 +180,11 @@ Returns the specified config.
179
180
  | Param | Type | Description |
180
181
  | --- | --- | --- |
181
182
  | slug | <code>String</code> | The application slug. |
182
- | configId | <code>String</code> | The unique ID of the config. |
183
+ | [configId] | <code>String</code> | The unique ID of the config. |
183
184
 
184
185
  <a name="Cobalt+updateConfig"></a>
185
186
 
186
- ### cobalt.updateConfig(slug, configId, payload) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
187
+ ### cobalt.updateConfig(slug, payload) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
187
188
  Update the specified config.
188
189
 
189
190
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -192,12 +193,11 @@ Update the specified config.
192
193
  | Param | Type | Description |
193
194
  | --- | --- | --- |
194
195
  | slug | <code>String</code> | The application slug. |
195
- | configId | <code>String</code> | The unique ID of the config. |
196
196
  | payload | [<code>Config</code>](#Config) | The update payload. |
197
197
 
198
198
  <a name="Cobalt+deleteConfig"></a>
199
199
 
200
- ### cobalt.deleteConfig(slug, configId) ⇒ <code>Promise.&lt;unknown&gt;</code>
200
+ ### cobalt.deleteConfig(slug, [configId]) ⇒ <code>Promise.&lt;unknown&gt;</code>
201
201
  Delete the specified config.
202
202
 
203
203
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -205,7 +205,7 @@ Delete the specified config.
205
205
  | Param | Type | Description |
206
206
  | --- | --- | --- |
207
207
  | slug | <code>String</code> | The application slug. |
208
- | configId | <code>String</code> | The unique ID of the config. |
208
+ | [configId] | <code>String</code> | The unique ID of the config. |
209
209
 
210
210
  <a name="Application"></a>
211
211
 
package/cobalt.js CHANGED
@@ -214,12 +214,12 @@ class Cobalt {
214
214
  /**
215
215
  * Returns the specified config, or creates one if it doesn't exist.
216
216
  * @param {String} slug The application slug.
217
- * @param {String} configId A unique ID for the config.
217
+ * @param {String} [configId] The unique ID of the config.
218
218
  * @param {DynamicFields} [fields] The dynamic fields payload.
219
219
  * @returns {Promise<Config>} The specified config.
220
220
  */
221
221
  async config(slug, configId, fields) {
222
- const res = await fetch(`${this.baseUrl}/api/v2/application/${slug}/installation/${configId}`, {
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}`,
@@ -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, configId, payload = {}) {
266
- const res = await fetch(`${this.baseUrl}/api/v1/application/${slug}/installation/${configId}`, {
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
@@ -41,10 +41,10 @@
41
41
  * [.getApp([slug])](#Cobalt+getApp) ⇒ [<code>Promise.&lt;Application&gt;</code>](#Application)
42
42
  * [.connect(slug, [payload])](#Cobalt+connect) ⇒ <code>Promise.&lt;Boolean&gt;</code>
43
43
  * [.disconnect(slug)](#Cobalt+disconnect) ⇒ <code>Promise.&lt;void&gt;</code>
44
- * [.config(slug, configId, [fields])](#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, configId, payload)](#Cobalt+updateConfig) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
47
- * [.deleteConfig(slug, configId)](#Cobalt+deleteConfig) ⇒ <code>Promise.&lt;unknown&gt;</code>
44
+ * [.config(slug, [configId], [fields])](#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)
47
+ * [.deleteConfig(slug, [configId])](#Cobalt+deleteConfig) ⇒ <code>Promise.&lt;unknown&gt;</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, configId, [fields]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
101
+ ### cobalt.config(slug, [configId], [fields]) ⇒ [<code>Promise.&lt;Config&gt;</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,12 @@ 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
- | configId | <code>String</code> | A unique ID for the config. |
110
+ | [configId] | <code>String</code> | The unique ID of the config. |
111
111
  | [fields] | [<code>DynamicFields</code>](#DynamicFields) | The dynamic fields payload. |
112
112
 
113
113
  <a name="Cobalt+getConfig"></a>
114
114
 
115
- ### cobalt.getConfig(slug, configId) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
115
+ ### cobalt.getConfig(slug, [configId]) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
116
116
  Returns the specified config.
117
117
 
118
118
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -121,11 +121,11 @@ Returns the specified config.
121
121
  | Param | Type | Description |
122
122
  | --- | --- | --- |
123
123
  | slug | <code>String</code> | The application slug. |
124
- | configId | <code>String</code> | The unique ID of the config. |
124
+ | [configId] | <code>String</code> | The unique ID of the config. |
125
125
 
126
126
  <a name="Cobalt+updateConfig"></a>
127
127
 
128
- ### cobalt.updateConfig(slug, configId, payload) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
128
+ ### cobalt.updateConfig(slug, payload) ⇒ [<code>Promise.&lt;Config&gt;</code>](#Config)
129
129
  Update the specified config.
130
130
 
131
131
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -134,12 +134,11 @@ Update the specified config.
134
134
  | Param | Type | Description |
135
135
  | --- | --- | --- |
136
136
  | slug | <code>String</code> | The application slug. |
137
- | configId | <code>String</code> | The unique ID of the config. |
138
137
  | payload | [<code>Config</code>](#Config) | The update payload. |
139
138
 
140
139
  <a name="Cobalt+deleteConfig"></a>
141
140
 
142
- ### cobalt.deleteConfig(slug, configId) ⇒ <code>Promise.&lt;unknown&gt;</code>
141
+ ### cobalt.deleteConfig(slug, [configId]) ⇒ <code>Promise.&lt;unknown&gt;</code>
143
142
  Delete the specified config.
144
143
 
145
144
  **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
@@ -147,7 +146,7 @@ Delete the specified config.
147
146
  | Param | Type | Description |
148
147
  | --- | --- | --- |
149
148
  | slug | <code>String</code> | The application slug. |
150
- | configId | <code>String</code> | The unique ID of the config. |
149
+ | [configId] | <code>String</code> | The unique ID of the config. |
151
150
 
152
151
  <a name="Application"></a>
153
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobaltio/cobalt-js",
3
- "version": "3.0.4",
3
+ "version": "4.0.0",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "scripts": {