@cobaltio/cobalt-js 0.0.10 → 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 CHANGED
@@ -140,6 +140,34 @@ class Cobalt {
140
140
  }
141
141
  }
142
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
+
143
171
  /**
144
172
  * Save the input data for the specified node.
145
173
  * @property {string} workflowId The ID of the workflow.
@@ -166,6 +194,25 @@ class Cobalt {
166
194
  return await res.json();
167
195
  }
168
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
+
169
216
  /**
170
217
  * Toggle the status of the specified workflow.
171
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 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 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
@@ -39,7 +39,9 @@ Cobalt Frontend SDK
39
39
  * [.getAppAuthStatus()](#Cobalt+getAppAuthStatus) ⇒ <code>Promise.&lt;boolean&gt;</code>
40
40
  * [.getAppAuthUrl()](#Cobalt+getAppAuthUrl) ⇒ <code>Promise.&lt;string&gt;</code>
41
41
  * [.removeAppAuth()](#Cobalt+removeAppAuth) ⇒ <code>Promise.&lt;void&gt;</code>
42
+ * [.getNodeConfiguration()](#Cobalt+getNodeConfiguration) ⇒ <code>Promise.&lt;Array.&lt;Field&gt;&gt;</code>
42
43
  * [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
44
+ * [.getWorkflowConfiguration()](#Cobalt+getWorkflowConfiguration) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
43
45
  * [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
44
46
  * [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.&lt;unknown&gt;</code>
45
47
 
@@ -121,6 +123,21 @@ Unauthorize the specified application and remove any associated data from Cobalt
121
123
  | --- | --- | --- |
122
124
  | application | <code>string</code> | The application type. |
123
125
 
126
+ <a name="Cobalt+getNodeConfiguration"></a>
127
+
128
+ ### cobalt.getNodeConfiguration() ⇒ <code>Promise.&lt;Array.&lt;Field&gt;&gt;</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
+
124
141
  <a name="Cobalt+saveNode"></a>
125
142
 
126
143
  ### cobalt.saveNode() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
@@ -135,6 +152,18 @@ Save the input data for the specified node.
135
152
  | nodeId | <code>string</code> | The ID of the node. |
136
153
  | inputData | <code>object</code> | The input data for the node. |
137
154
 
155
+ <a name="Cobalt+getWorkflowConfiguration"></a>
156
+
157
+ ### cobalt.getWorkflowConfiguration() ⇒ [<code>Promise.&lt;Workflow&gt;</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
+
138
167
  <a name="Cobalt+toggleWorkflowStatus"></a>
139
168
 
140
169
  ### 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.10",
3
+ "version": "0.0.11",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "scripts": {