@cobaltio/cobalt-js 0.0.8 → 0.0.9

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 +30 -0
  3. package/cobalt.min.js +1 -1
  4. package/docs.md +203 -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,6 +113,11 @@ 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
  }
@@ -125,6 +140,11 @@ class Cobalt {
125
140
  input_data: inputData,
126
141
  }),
127
142
  });
143
+
144
+ if (res.status >= 400 && res.status < 600) {
145
+ throw new Error(res.statusText);
146
+ }
147
+
128
148
  return await res.json();
129
149
  }
130
150
 
@@ -140,6 +160,11 @@ class Cobalt {
140
160
  authorization: `Bearer ${this.token}`,
141
161
  },
142
162
  });
163
+
164
+ if (res.status >= 400 && res.status < 600) {
165
+ throw new Error(res.statusText);
166
+ }
167
+
143
168
  return await res.json();
144
169
  }
145
170
 
@@ -155,6 +180,11 @@ class Cobalt {
155
180
  authorization: `Bearer ${this.token}`,
156
181
  },
157
182
  });
183
+
184
+ if (res.status >= 400 && res.status < 600) {
185
+ throw new Error(res.statusText);
186
+ }
187
+
158
188
  return await res.json();
159
189
  }
160
190
  }
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 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,203 @@
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
+ * [.saveNode()](#Cobalt+saveNode) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
42
+ * [.toggleWorkflowStatus()](#Cobalt+toggleWorkflowStatus) ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
43
+ * [.deleteWorkflow()](#Cobalt+deleteWorkflow) ⇒ <code>Promise.&lt;unknown&gt;</code>
44
+
45
+ <a name="new_Cobalt_new"></a>
46
+
47
+ ### new Cobalt(options)
48
+ Cobalt Frontend SDK
49
+
50
+
51
+ | Param | Type | Default | Description |
52
+ | --- | --- | --- | --- |
53
+ | options | <code>object</code> | | The options to configure the Cobalt SDK. |
54
+ | [options.token] | <code>string</code> | | The session token. |
55
+ | [options.baseUrl] | <code>string</code> | <code>&quot;https://api.gocobalt.io&quot;</code> | The base URL of your Cobalt API. |
56
+
57
+ <a name="Cobalt+token"></a>
58
+
59
+ ### cobalt.token ⇒ <code>string</code>
60
+ **Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
61
+ **Returns**: <code>string</code> - The session token.
62
+ <a name="Cobalt+token"></a>
63
+
64
+ ### cobalt.token ⇒ <code>string</code>
65
+ **Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
66
+ **Returns**: <code>string</code> - The session token.
67
+ <a name="Cobalt+baseUrl"></a>
68
+
69
+ ### cobalt.baseUrl ⇒ <code>string</code>
70
+ **Kind**: instance property of [<code>Cobalt</code>](#Cobalt)
71
+ **Returns**: <code>string</code> - The base URL of cobalt API.
72
+ <a name="Cobalt+installTemplate"></a>
73
+
74
+ ### cobalt.installTemplate() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
75
+ Install the given template.
76
+
77
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
78
+ **Properties**
79
+
80
+ | Name | Type | Description |
81
+ | --- | --- | --- |
82
+ | templateId | <code>string</code> | The ID of the template you want to install. |
83
+
84
+ <a name="Cobalt+getAppAuthStatus"></a>
85
+
86
+ ### cobalt.getAppAuthStatus() ⇒ <code>Promise.&lt;boolean&gt;</code>
87
+ Returns the auth status of the user for the specified application.
88
+
89
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
90
+ **Returns**: <code>Promise.&lt;boolean&gt;</code> - The auth status of the user.
91
+ **Properties**
92
+
93
+ | Name | Type | Description |
94
+ | --- | --- | --- |
95
+ | application | <code>string</code> | The application type. |
96
+
97
+ <a name="Cobalt+getAppAuthUrl"></a>
98
+
99
+ ### cobalt.getAppAuthUrl() ⇒ <code>Promise.&lt;string&gt;</code>
100
+ Returns the auth URL that users can use to authenticate themselves to the
101
+ specified application.
102
+
103
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
104
+ **Returns**: <code>Promise.&lt;string&gt;</code> - The auth URL where users can authenticate themselves.
105
+ **Properties**
106
+
107
+ | Name | Type | Description |
108
+ | --- | --- | --- |
109
+ | application | <code>string</code> | The application type. |
110
+
111
+ <a name="Cobalt+saveNode"></a>
112
+
113
+ ### cobalt.saveNode() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
114
+ Save the input data for the specified node.
115
+
116
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
117
+ **Properties**
118
+
119
+ | Name | Type | Description |
120
+ | --- | --- | --- |
121
+ | workflowId | <code>string</code> | The ID of the workflow. |
122
+ | nodeId | <code>string</code> | The ID of the node. |
123
+ | inputData | <code>object</code> | The input data for the node. |
124
+
125
+ <a name="Cobalt+toggleWorkflowStatus"></a>
126
+
127
+ ### cobalt.toggleWorkflowStatus() ⇒ [<code>Promise.&lt;Workflow&gt;</code>](#Workflow)
128
+ Toggle the status of the specified workflow.
129
+
130
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
131
+ **Properties**
132
+
133
+ | Name | Type | Description |
134
+ | --- | --- | --- |
135
+ | workflowId | <code>string</code> | The ID of the workflow. |
136
+
137
+ <a name="Cobalt+deleteWorkflow"></a>
138
+
139
+ ### cobalt.deleteWorkflow() ⇒ <code>Promise.&lt;unknown&gt;</code>
140
+ Delete the specified workflow.
141
+
142
+ **Kind**: instance method of [<code>Cobalt</code>](#Cobalt)
143
+ **Properties**
144
+
145
+ | Name | Type | Description |
146
+ | --- | --- | --- |
147
+ | workflowId | <code>string</code> | The ID of the workflow. |
148
+
149
+ <a name="Field"></a>
150
+
151
+ ## Field : <code>object</code>
152
+ The Node Field object available for configuration.
153
+
154
+ **Kind**: global typedef
155
+ **Properties**
156
+
157
+ | Name | Type | Description |
158
+ | --- | --- | --- |
159
+ | name | <code>string</code> | The field name. |
160
+ | type | <code>string</code> | The input type of the field. |
161
+ | placeholder | <code>string</code> | The placeholder text for the field. |
162
+ | required | <code>boolean</code> | Whether the field is required. |
163
+
164
+ <a name="Node"></a>
165
+
166
+ ## Node : <code>object</code>
167
+ The Node object available for configuration.
168
+
169
+ **Kind**: global typedef
170
+ **Properties**
171
+
172
+ | Name | Type | Description |
173
+ | --- | --- | --- |
174
+ | node_id | <code>string</code> | The ID of the installed workflow. |
175
+ | node_name | <code>string</code> | The Name of the installed workflow. |
176
+ | fields | [<code>Array.&lt;Field&gt;</code>](#Field) | The applications integrated in the workflow. |
177
+
178
+ <a name="Workflow"></a>
179
+
180
+ ## Workflow : <code>object</code>
181
+ The installed workflow.
182
+
183
+ **Kind**: global typedef
184
+ **Properties**
185
+
186
+ | Name | Type | Description |
187
+ | --- | --- | --- |
188
+ | workflow_id | <code>string</code> | The ID of the installed workflow. |
189
+ | applications | <code>Array.&lt;unknown&gt;</code> | The applications integrated in the workflow. |
190
+ | configure | [<code>Array.&lt;Node&gt;</code>](#Node) | The configuration data for the workflow. |
191
+
192
+ <a name="AppAuthStatus"></a>
193
+
194
+ ## AppAuthStatus : <code>object</code>
195
+ The auth status of the user for an application.
196
+
197
+ **Kind**: global typedef
198
+ **Properties**
199
+
200
+ | Name | Type | Description |
201
+ | --- | --- | --- |
202
+ | status | <code>boolean</code> | Whether the user has authenticated with this application. |
203
+
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.9",
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
  }