@cobaltio/cobalt-js 0.0.11 → 0.0.12

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/cobalt.js CHANGED
@@ -213,6 +213,26 @@ class Cobalt {
213
213
  return await res.json();
214
214
  }
215
215
 
216
+ /**
217
+ * Activate the given installed workflow.
218
+ * @property {string} workflowId The ID of the workflow you want to activate.
219
+ * @returns {Promise<void>}
220
+ */
221
+ async activateWorkflow(workflowId) {
222
+ const res = await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/install/success`, {
223
+ method: "PUT",
224
+ headers: {
225
+ authorization: `Bearer ${this.token}`,
226
+ },
227
+ });
228
+
229
+ if (res.status >= 400 && res.status < 600) {
230
+ throw new Error(res.statusText);
231
+ }
232
+
233
+ return await res.json();
234
+ }
235
+
216
236
  /**
217
237
  * Toggle the status of the specified workflow.
218
238
  * @property {string} workflowId The ID of the workflow.
package/cobalt.min.js CHANGED
@@ -1 +1 @@
1
- class Cobalt{constructor(options){this.apiBaseUrl=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:""}get baseUrl(){return this.apiBaseUrl}async installTemplate(templateId){const res=await fetch(`${this.baseUrl}/api/v1/template/install/${templateId}`,{method:"POST",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async getAppAuthStatus(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 getAppAuthUrl(application){const res=await fetch(`${this.baseUrl}/api/v1/google/integrate?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?.auth_url}async removeAppAuth(application){const res=await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${application}`,{method:"DELETE",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}}async getNodeConfiguration(workflowId,nodeId,fieldName,selectedValues={}){const res=await fetch(`${this.baseUrl}/api/v1/workflow/${workflowId}/node/${nodeId}/configuration`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify({fieldName:fieldName,selectedValues:selectedValues})});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async saveNode(workflowId,nodeId,inputData={}){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/node/${nodeId}`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify({input_data:inputData})});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async getWorkflowConfiguration(workflowId){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/configuration`,{headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async toggleWorkflowStatus(workflowId){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/toggle-status`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async deleteWorkflow(workflowId){const res=await fetch(`${this.baseUrl}/api/v1/workflow/${workflowId}`,{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;
1
+ class Cobalt{constructor(options){this.apiBaseUrl=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:""}get baseUrl(){return this.apiBaseUrl}async installTemplate(templateId){const res=await fetch(`${this.baseUrl}/api/v1/template/install/${templateId}`,{method:"POST",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async getAppAuthStatus(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 getAppAuthUrl(application){const res=await fetch(`${this.baseUrl}/api/v1/google/integrate?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?.auth_url}async removeAppAuth(application){const res=await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${application}`,{method:"DELETE",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}}async getNodeConfiguration(workflowId,nodeId,fieldName,selectedValues={}){const res=await fetch(`${this.baseUrl}/api/v1/workflow/${workflowId}/node/${nodeId}/configuration`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify({fieldName:fieldName,selectedValues:selectedValues})});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async saveNode(workflowId,nodeId,inputData={}){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/node/${nodeId}`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify({input_data:inputData})});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async getWorkflowConfiguration(workflowId){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/configuration`,{headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async activateWorkflow(workflowId){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/install/success`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async toggleWorkflowStatus(workflowId){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/toggle-status`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`}});if(res.status>=400&&res.status<600){throw new Error(res.statusText)}return await res.json()}async deleteWorkflow(workflowId){const res=await fetch(`${this.baseUrl}/api/v1/workflow/${workflowId}`,{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
@@ -42,6 +42,7 @@ Cobalt Frontend SDK
42
42
  * [.getNodeConfiguration()](#Cobalt+getNodeConfiguration) ⇒ <code>Promise.&lt;Array.&lt;Field&gt;&gt;</code>
43
43
  * [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
44
44
  * [.getWorkflowConfiguration()](#Cobalt+getWorkflowConfiguration) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
45
+ * [.activateWorkflow()](#Cobalt+activateWorkflow) ⇒ <code>Promise.&lt;void&gt;</code>
45
46
  * [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
46
47
  * [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.&lt;unknown&gt;</code>
47
48
 
@@ -164,6 +165,18 @@ Returns the workflow configuration data.
164
165
  | --- | --- | --- |
165
166
  | workflowId | <code>string</code> | The ID of the workflow. |
166
167
 
168
+ <a name="Cobalt+activateWorkflow"></a>
169
+
170
+ ### cobalt.activateWorkflow() ⇒ <code>Promise.&lt;void&gt;</code>
171
+ Activate the given installed workflow.
172
+
173
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
174
+ **Properties**
175
+
176
+ | Name | Type | Description |
177
+ | --- | --- | --- |
178
+ | workflowId | <code>string</code> | The ID of the workflow you want to activate. |
179
+
167
180
  <a name="Cobalt+toggleWorkflowStatus"></a>
168
181
 
169
182
  ### cobalt.toggleWorkflowStatus() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobaltio/cobalt-js",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "scripts": {