@cobaltio/cobalt-js 0.0.9 → 0.0.11
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 +65 -0
- package/cobalt.min.js +1 -1
- package/docs.md +42 -0
- package/package.json +1 -1
package/cobalt.js
CHANGED
|
@@ -122,6 +122,52 @@ class Cobalt {
|
|
|
122
122
|
return data?.auth_url;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Unauthorize the specified application and remove any associated data from Cobalt.
|
|
127
|
+
* @property {string} application The application type.
|
|
128
|
+
* @returns {Promise<void>}
|
|
129
|
+
*/
|
|
130
|
+
async removeAppAuth(application) {
|
|
131
|
+
const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/${application}`, {
|
|
132
|
+
method: "DELETE",
|
|
133
|
+
headers: {
|
|
134
|
+
authorization: `Bearer ${this.token}`,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (res.status >= 400 && res.status < 600) {
|
|
139
|
+
throw new Error(res.statusText);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Returns the node configuration data for dynamic fields.
|
|
145
|
+
* @property {string} workflowId The ID of the workflow.
|
|
146
|
+
* @property {string} nodeId The ID of the node.
|
|
147
|
+
* @property {string} fieldName The field name for which config data is required.
|
|
148
|
+
* @property {object} selectedValues The input data already selected for the node.
|
|
149
|
+
* @returns {Promise<Field[]>}
|
|
150
|
+
*/
|
|
151
|
+
async getNodeConfiguration(workflowId, nodeId, fieldName, selectedValues = {}) {
|
|
152
|
+
const res = await fetch(`${this.baseUrl}/api/v1/workflow/${workflowId}/node/${nodeId}/configuration`, {
|
|
153
|
+
method: "POST",
|
|
154
|
+
headers: {
|
|
155
|
+
authorization: `Bearer ${this.token}`,
|
|
156
|
+
"content-type": "application/json",
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify({
|
|
159
|
+
fieldName,
|
|
160
|
+
selectedValues,
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (res.status >= 400 && res.status < 600) {
|
|
165
|
+
throw new Error(res.statusText);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return await res.json();
|
|
169
|
+
}
|
|
170
|
+
|
|
125
171
|
/**
|
|
126
172
|
* Save the input data for the specified node.
|
|
127
173
|
* @property {string} workflowId The ID of the workflow.
|
|
@@ -148,6 +194,25 @@ class Cobalt {
|
|
|
148
194
|
return await res.json();
|
|
149
195
|
}
|
|
150
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Returns the workflow configuration data.
|
|
199
|
+
* @property {string} workflowId The ID of the workflow.
|
|
200
|
+
* @returns {Promise<Workflow>}
|
|
201
|
+
*/
|
|
202
|
+
async getWorkflowConfiguration(workflowId) {
|
|
203
|
+
const res = await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/configuration`, {
|
|
204
|
+
headers: {
|
|
205
|
+
authorization: `Bearer ${this.token}`,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
if (res.status >= 400 && res.status < 600) {
|
|
210
|
+
throw new Error(res.statusText);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return await res.json();
|
|
214
|
+
}
|
|
215
|
+
|
|
151
216
|
/**
|
|
152
217
|
* Toggle the status of the specified workflow.
|
|
153
218
|
* @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 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 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 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
|
@@ -38,7 +38,10 @@ Cobalt Frontend SDK
|
|
|
38
38
|
* [.installTemplate()](#Cobalt+installTemplate) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
39
39
|
* [.getAppAuthStatus()](#Cobalt+getAppAuthStatus) ⇒ <code>Promise.<boolean></code>
|
|
40
40
|
* [.getAppAuthUrl()](#Cobalt+getAppAuthUrl) ⇒ <code>Promise.<string></code>
|
|
41
|
+
* [.removeAppAuth()](#Cobalt+removeAppAuth) ⇒ <code>Promise.<void></code>
|
|
42
|
+
* [.getNodeConfiguration()](#Cobalt+getNodeConfiguration) ⇒ <code>Promise.<Array.<Field>></code>
|
|
41
43
|
* [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
44
|
+
* [.getWorkflowConfiguration()](#Cobalt+getWorkflowConfiguration) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
42
45
|
* [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
43
46
|
* [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.<unknown></code>
|
|
44
47
|
|
|
@@ -108,6 +111,33 @@ specified application.
|
|
|
108
111
|
| --- | --- | --- |
|
|
109
112
|
| application | <code>string</code> | The application type. |
|
|
110
113
|
|
|
114
|
+
<a name="Cobalt+removeAppAuth"></a>
|
|
115
|
+
|
|
116
|
+
### cobalt.removeAppAuth() ⇒ <code>Promise.<void></code>
|
|
117
|
+
Unauthorize the specified application and remove any associated data from Cobalt.
|
|
118
|
+
|
|
119
|
+
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
120
|
+
**Properties**
|
|
121
|
+
|
|
122
|
+
| Name | Type | Description |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| application | <code>string</code> | The application type. |
|
|
125
|
+
|
|
126
|
+
<a name="Cobalt+getNodeConfiguration"></a>
|
|
127
|
+
|
|
128
|
+
### cobalt.getNodeConfiguration() ⇒ <code>Promise.<Array.<Field>></code>
|
|
129
|
+
Returns the node configuration data for dynamic fields.
|
|
130
|
+
|
|
131
|
+
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
132
|
+
**Properties**
|
|
133
|
+
|
|
134
|
+
| Name | Type | Description |
|
|
135
|
+
| --- | --- | --- |
|
|
136
|
+
| workflowId | <code>string</code> | The ID of the workflow. |
|
|
137
|
+
| nodeId | <code>string</code> | The ID of the node. |
|
|
138
|
+
| fieldName | <code>string</code> | The field name for which config data is required. |
|
|
139
|
+
| selectedValues | <code>object</code> | The input data already selected for the node. |
|
|
140
|
+
|
|
111
141
|
<a name="Cobalt+saveNode"></a>
|
|
112
142
|
|
|
113
143
|
### cobalt.saveNode() ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
@@ -122,6 +152,18 @@ Save the input data for the specified node.
|
|
|
122
152
|
| nodeId | <code>string</code> | The ID of the node. |
|
|
123
153
|
| inputData | <code>object</code> | The input data for the node. |
|
|
124
154
|
|
|
155
|
+
<a name="Cobalt+getWorkflowConfiguration"></a>
|
|
156
|
+
|
|
157
|
+
### cobalt.getWorkflowConfiguration() ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|
|
158
|
+
Returns the workflow configuration data.
|
|
159
|
+
|
|
160
|
+
**Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
|
|
161
|
+
**Properties**
|
|
162
|
+
|
|
163
|
+
| Name | Type | Description |
|
|
164
|
+
| --- | --- | --- |
|
|
165
|
+
| workflowId | <code>string</code> | The ID of the workflow. |
|
|
166
|
+
|
|
125
167
|
<a name="Cobalt+toggleWorkflowStatus"></a>
|
|
126
168
|
|
|
127
169
|
### cobalt.toggleWorkflowStatus() ⇒ [<code>Promise.<Workflow></code>](#Workflow)
|