@cobaltio/cobalt-js 0.0.12 → 0.0.14
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 +5 -2
- package/cobalt.min.js +1 -1
- package/docs.md +1 -0
- package/package.json +1 -1
package/cobalt.js
CHANGED
|
@@ -64,14 +64,17 @@ class Cobalt {
|
|
|
64
64
|
/**
|
|
65
65
|
* Install the given template.
|
|
66
66
|
* @property {string} templateId The ID of the template you want to install.
|
|
67
|
+
* @property {object} udf Custom key value pairs you want to store with the installed worklfow.
|
|
67
68
|
* @returns {Promise<Workflow>}
|
|
68
69
|
*/
|
|
69
|
-
async installTemplate(templateId) {
|
|
70
|
+
async installTemplate(templateId, udf = {}) {
|
|
70
71
|
const res = await fetch(`${this.baseUrl}/api/v1/template/install/${templateId}`, {
|
|
71
72
|
method: "POST",
|
|
72
73
|
headers: {
|
|
73
74
|
authorization: `Bearer ${this.token}`,
|
|
75
|
+
"content-type": "application/json",
|
|
74
76
|
},
|
|
77
|
+
body: JSON.stringify(udf),
|
|
75
78
|
});
|
|
76
79
|
|
|
77
80
|
if (res.status >= 400 && res.status < 600) {
|
|
@@ -108,7 +111,7 @@ class Cobalt {
|
|
|
108
111
|
* @returns {Promise<string>} The auth URL where users can authenticate themselves.
|
|
109
112
|
*/
|
|
110
113
|
async getAppAuthUrl(application) {
|
|
111
|
-
const res = await fetch(`${this.baseUrl}/api/v1
|
|
114
|
+
const res = await fetch(`${this.baseUrl}/api/v1/${application}/integrate`, {
|
|
112
115
|
headers: {
|
|
113
116
|
authorization: `Bearer ${this.token}`,
|
|
114
117
|
},
|
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}
|
|
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,udf={}){const res=await fetch(`${this.baseUrl}/api/v1/template/install/${templateId}`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,"content-type":"application/json"},body:JSON.stringify(udf)});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/${application}/integrate`,{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
|
@@ -84,6 +84,7 @@ Install the given template.
|
|
|
84
84
|
| Name | Type | Description |
|
|
85
85
|
| --- | --- | --- |
|
|
86
86
|
| templateId | <code>string</code> | The ID of the template you want to install. |
|
|
87
|
+
| udf | <code>object</code> | Custom key value pairs you want to store with the installed worklfow. |
|
|
87
88
|
|
|
88
89
|
<a name="Cobalt+getAppAuthStatus"></a>
|
|
89
90
|
|