@cobaltio/cobalt-js 0.0.8 → 0.0.10

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 (53) hide show
  1. package/README.md +2 -0
  2. package/cobalt.js +48 -0
  3. package/cobalt.min.js +1 -1
  4. package/docs.md +216 -0
  5. package/package.json +4 -5
  6. package/docs/Cobalt.html +0 -1514
  7. package/docs/cobalt.js.html +0 -213
  8. package/docs/css/bootstrap.min.css +0 -6
  9. package/docs/css/prism.css +0 -138
  10. package/docs/css/prism.min.css +0 -1
  11. package/docs/css/template.min.css +0 -1
  12. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  13. package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  14. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  15. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  16. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  17. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  18. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  19. package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  20. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  21. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  22. package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  23. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  24. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  25. package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  26. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  27. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  28. package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  29. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  30. package/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  31. package/docs/fonts/glyphicons-halflings-regular.svg +0 -288
  32. package/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  33. package/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  34. package/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  35. package/docs/global.html +0 -786
  36. package/docs/index.html +0 -100
  37. package/docs/js/bootstrap.min.js +0 -7
  38. package/docs/js/clipboard.min.js +0 -7
  39. package/docs/js/jquery.min.js +0 -2
  40. package/docs/js/lunr-data.js +0 -923
  41. package/docs/js/lunr-data.json +0 -923
  42. package/docs/js/lunr.min.js +0 -6
  43. package/docs/js/prism.js +0 -869
  44. package/docs/js/prism.min.js +0 -1
  45. package/docs/js/template.min.js +0 -1
  46. package/docs/list_class.html +0 -128
  47. package/docs/scripts/linenumber.js +0 -25
  48. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  49. package/docs/scripts/prettify/lang-css.js +0 -2
  50. package/docs/scripts/prettify/prettify.js +0 -28
  51. package/docs/styles/jsdoc-default.css +0 -358
  52. package/docs/styles/prettify-jsdoc.css +0 -111
  53. package/docs/styles/prettify-tomorrow.css +0 -132
package/README.md CHANGED
@@ -15,6 +15,8 @@ yarn add @cobaltio/cobalt-js
15
15
 
16
16
  ## Usage
17
17
 
18
+ Check the SDK [documentation](docs.md) for detailed information.
19
+
18
20
  ### Include
19
21
 
20
22
  #### Browser
package/cobalt.js CHANGED
@@ -73,6 +73,11 @@ class Cobalt {
73
73
  authorization: `Bearer ${this.token}`,
74
74
  },
75
75
  });
76
+
77
+ if (res.status >= 400 && res.status < 600) {
78
+ throw new Error(res.statusText);
79
+ }
80
+
76
81
  return await res.json();
77
82
  }
78
83
 
@@ -87,6 +92,11 @@ class Cobalt {
87
92
  authorization: `Bearer ${this.token}`,
88
93
  },
89
94
  });
95
+
96
+ if (res.status >= 400 && res.status < 600) {
97
+ throw new Error(res.statusText);
98
+ }
99
+
90
100
  const data = await res.json();
91
101
  return !!data?.status;
92
102
  }
@@ -103,10 +113,33 @@ class Cobalt {
103
113
  authorization: `Bearer ${this.token}`,
104
114
  },
105
115
  });
116
+
117
+ if (res.status >= 400 && res.status < 600) {
118
+ throw new Error(res.statusText);
119
+ }
120
+
106
121
  const data = await res.json();
107
122
  return data?.auth_url;
108
123
  }
109
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
+
110
143
  /**
111
144
  * Save the input data for the specified node.
112
145
  * @property {string} workflowId The ID of the workflow.
@@ -125,6 +158,11 @@ class Cobalt {
125
158
  input_data: inputData,
126
159
  }),
127
160
  });
161
+
162
+ if (res.status >= 400 && res.status < 600) {
163
+ throw new Error(res.statusText);
164
+ }
165
+
128
166
  return await res.json();
129
167
  }
130
168
 
@@ -140,6 +178,11 @@ class Cobalt {
140
178
  authorization: `Bearer ${this.token}`,
141
179
  },
142
180
  });
181
+
182
+ if (res.status >= 400 && res.status < 600) {
183
+ throw new Error(res.statusText);
184
+ }
185
+
143
186
  return await res.json();
144
187
  }
145
188
 
@@ -155,6 +198,11 @@ class Cobalt {
155
198
  authorization: `Bearer ${this.token}`,
156
199
  },
157
200
  });
201
+
202
+ if (res.status >= 400 && res.status < 600) {
203
+ throw new Error(res.statusText);
204
+ }
205
+
158
206
  return await res.json();
159
207
  }
160
208
  }
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}`}});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}`}});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}`}});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})});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}`}});return await res.json()}async deleteWorkflow(workflowId){const res=await fetch(`${this.baseUrl}/api/v1/workflow/${workflowId}`,{method:"DELETE",headers:{authorization:`Bearer ${this.token}`}});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 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;
package/docs.md ADDED
@@ -0,0 +1,216 @@
1
+ ## Classes
2
+
3
+ <dl>
4
+ <dt><a href="#Cobalt">Cobalt</a></dt>
5
+ <dd><p>Cobalt Frontend SDK</p>
6
+ </dd>
7
+ </dl>
8
+
9
+ ## Typedefs
10
+
11
+ <dl>
12
+ <dt><a href="#Field">Field</a> : <code>object</code></dt>
13
+ <dd><p>The Node Field object available for configuration.</p>
14
+ </dd>
15
+ <dt><a href="#Node">Node</a> : <code>object</code></dt>
16
+ <dd><p>The Node object available for configuration.</p>
17
+ </dd>
18
+ <dt><a href="#Workflow">Workflow</a> : <code>object</code></dt>
19
+ <dd><p>The installed workflow.</p>
20
+ </dd>
21
+ <dt><a href="#AppAuthStatus">AppAuthStatus</a> : <code>object</code></dt>
22
+ <dd><p>The auth status of the user for an application.</p>
23
+ </dd>
24
+ </dl>
25
+
26
+ <a name="Cobalt"></a>
27
+
28
+ ## Cobalt
29
+ Cobalt Frontend SDK
30
+
31
+ **Kind**: global class
32
+
33
+ * [Cobalt](#Cobalt)
34
+ * [new Cobalt(options)](#new_Cobalt_new)
35
+ * [.token](#Cobalt+token) ⇒ <code>string</code>
36
+ * [.token](#Cobalt+token) ⇒ <code>string</code>
37
+ * [.baseUrl](#Cobalt+baseUrl) ⇒ <code>string</code>
38
+ * [.installTemplate()](#Cobalt+installTemplate) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
39
+ * [.getAppAuthStatus()](#Cobalt+getAppAuthStatus) ⇒ <code>Promise.&lt;boolean&gt;</code>
40
+ * [.getAppAuthUrl()](#Cobalt+getAppAuthUrl) ⇒ <code>Promise.&lt;string&gt;</code>
41
+ * [.removeAppAuth()](#Cobalt+removeAppAuth) ⇒ <code>Promise.&lt;void&gt;</code>
42
+ * [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
43
+ * [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
44
+ * [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.&lt;unknown&gt;</code>
45
+
46
+ <a name="new_Cobalt_new"></a>
47
+
48
+ ### new Cobalt(options)
49
+ Cobalt Frontend SDK
50
+
51
+
52
+ | Param | Type | Default | Description |
53
+ | --- | --- | --- | --- |
54
+ | options | <code>object</code> | | The options to configure the Cobalt SDK. |
55
+ | [options.token] | <code>string</code> | | The session token. |
56
+ | [options.baseUrl] | <code>string</code> | <code>&quot;https://api.gocobalt.io&quot;</code> | The base URL of your Cobalt API. |
57
+
58
+ <a name="Cobalt+token"></a>
59
+
60
+ ### cobalt.token ⇒ <code>string</code>
61
+ **Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
62
+ **Returns**: <code>string</code> - The session token.
63
+ <a name="Cobalt+token"></a>
64
+
65
+ ### cobalt.token ⇒ <code>string</code>
66
+ **Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
67
+ **Returns**: <code>string</code> - The session token.
68
+ <a name="Cobalt+baseUrl"></a>
69
+
70
+ ### cobalt.baseUrl ⇒ <code>string</code>
71
+ **Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
72
+ **Returns**: <code>string</code> - The base URL of cobalt API.
73
+ <a name="Cobalt+installTemplate"></a>
74
+
75
+ ### cobalt.installTemplate() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
76
+ Install the given template.
77
+
78
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
79
+ **Properties**
80
+
81
+ | Name | Type | Description |
82
+ | --- | --- | --- |
83
+ | templateId | <code>string</code> | The ID of the template you want to install. |
84
+
85
+ <a name="Cobalt+getAppAuthStatus"></a>
86
+
87
+ ### cobalt.getAppAuthStatus() ⇒ <code>Promise.&lt;boolean&gt;</code>
88
+ Returns the auth status of the user for the specified application.
89
+
90
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
91
+ **Returns**: <code>Promise.&lt;boolean&gt;</code> - The auth status of the user.
92
+ **Properties**
93
+
94
+ | Name | Type | Description |
95
+ | --- | --- | --- |
96
+ | application | <code>string</code> | The application type. |
97
+
98
+ <a name="Cobalt+getAppAuthUrl"></a>
99
+
100
+ ### cobalt.getAppAuthUrl() ⇒ <code>Promise.&lt;string&gt;</code>
101
+ Returns the auth URL that users can use to authenticate themselves to the
102
+ specified application.
103
+
104
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
105
+ **Returns**: <code>Promise.&lt;string&gt;</code> - The auth URL where users can authenticate themselves.
106
+ **Properties**
107
+
108
+ | Name | Type | Description |
109
+ | --- | --- | --- |
110
+ | application | <code>string</code> | The application type. |
111
+
112
+ <a name="Cobalt+removeAppAuth"></a>
113
+
114
+ ### cobalt.removeAppAuth() ⇒ <code>Promise.&lt;void&gt;</code>
115
+ Unauthorize the specified application and remove any associated data from Cobalt.
116
+
117
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
118
+ **Properties**
119
+
120
+ | Name | Type | Description |
121
+ | --- | --- | --- |
122
+ | application | <code>string</code> | The application type. |
123
+
124
+ <a name="Cobalt+saveNode"></a>
125
+
126
+ ### cobalt.saveNode() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
127
+ Save the input data for the specified node.
128
+
129
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
130
+ **Properties**
131
+
132
+ | Name | Type | Description |
133
+ | --- | --- | --- |
134
+ | workflowId | <code>string</code> | The ID of the workflow. |
135
+ | nodeId | <code>string</code> | The ID of the node. |
136
+ | inputData | <code>object</code> | The input data for the node. |
137
+
138
+ <a name="Cobalt+toggleWorkflowStatus"></a>
139
+
140
+ ### cobalt.toggleWorkflowStatus() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
141
+ Toggle the status of the specified workflow.
142
+
143
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
144
+ **Properties**
145
+
146
+ | Name | Type | Description |
147
+ | --- | --- | --- |
148
+ | workflowId | <code>string</code> | The ID of the workflow. |
149
+
150
+ <a name="Cobalt+deleteWorkflow"></a>
151
+
152
+ ### cobalt.deleteWorkflow() ⇒ <code>Promise.&lt;unknown&gt;</code>
153
+ Delete the specified workflow.
154
+
155
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
156
+ **Properties**
157
+
158
+ | Name | Type | Description |
159
+ | --- | --- | --- |
160
+ | workflowId | <code>string</code> | The ID of the workflow. |
161
+
162
+ <a name="Field"></a>
163
+
164
+ ## Field : <code>object</code>
165
+ The Node Field object available for configuration.
166
+
167
+ **Kind**: global typedef
168
+ **Properties**
169
+
170
+ | Name | Type | Description |
171
+ | --- | --- | --- |
172
+ | name | <code>string</code> | The field name. |
173
+ | type | <code>string</code> | The input type of the field. |
174
+ | placeholder | <code>string</code> | The placeholder text for the field. |
175
+ | required | <code>boolean</code> | Whether the field is required. |
176
+
177
+ <a name="Node"></a>
178
+
179
+ ## Node : <code>object</code>
180
+ The Node object available for configuration.
181
+
182
+ **Kind**: global typedef
183
+ **Properties**
184
+
185
+ | Name | Type | Description |
186
+ | --- | --- | --- |
187
+ | node_id | <code>string</code> | The ID of the installed workflow. |
188
+ | node_name | <code>string</code> | The Name of the installed workflow. |
189
+ | fields | [<code>Array.&lt;Field&gt;</code>](#Field) | The applications integrated in the workflow. |
190
+
191
+ <a name="Workflow"></a>
192
+
193
+ ## Workflow : <code>object</code>
194
+ The installed workflow.
195
+
196
+ **Kind**: global typedef
197
+ **Properties**
198
+
199
+ | Name | Type | Description |
200
+ | --- | --- | --- |
201
+ | workflow_id | <code>string</code> | The ID of the installed workflow. |
202
+ | applications | <code>Array.&lt;unknown&gt;</code> | The applications integrated in the workflow. |
203
+ | configure | [<code>Array.&lt;Node&gt;</code>](#Node) | The configuration data for the workflow. |
204
+
205
+ <a name="AppAuthStatus"></a>
206
+
207
+ ## AppAuthStatus : <code>object</code>
208
+ The auth status of the user for an application.
209
+
210
+ **Kind**: global typedef
211
+ **Properties**
212
+
213
+ | Name | Type | Description |
214
+ | --- | --- | --- |
215
+ | status | <code>boolean</code> | Whether the user has authenticated with this application. |
216
+
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@cobaltio/cobalt-js",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "scripts": {
7
7
  "build": "uglifyjs cobalt.js -o cobalt.min.js",
8
- "docgen": "jsdoc . -R README.md -d docs",
8
+ "docgen": "jsdoc2md cobalt.js > docs.md",
9
9
  "test": "echo \"Warn: no test specified\""
10
10
  },
11
11
  "repository": {
@@ -29,10 +29,9 @@
29
29
  },
30
30
  "homepage": "https://github.com/Breakout-Embed/cobalt-js#readme",
31
31
  "devDependencies": {
32
+ "foodoc": "^0.0.9",
32
33
  "jsdoc": "^3.6.11",
34
+ "jsdoc-to-markdown": "^7.1.1",
33
35
  "uglify-js": "^3.17.0"
34
- },
35
- "dependencies": {
36
- "foodoc": "^0.0.9"
37
36
  }
38
37
  }