@cobaltio/cobalt-js 0.0.1
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/.github/workflows/npm-publish.yml +36 -0
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/cobalt.js +91 -0
- package/cobalt.min.js +1 -0
- package/docs/Cobalt.html +686 -0
- package/docs/cobalt.js.html +142 -0
- package/docs/css/bootstrap.min.css +6 -0
- package/docs/css/prism.css +138 -0
- package/docs/css/prism.min.css +1 -0
- package/docs/css/template.min.css +1 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/fonts/glyphicons-halflings-regular.eot +0 -0
- package/docs/fonts/glyphicons-halflings-regular.svg +288 -0
- package/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/docs/fonts/glyphicons-halflings-regular.woff +0 -0
- package/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/docs/global.html +662 -0
- package/docs/index.html +74 -0
- package/docs/js/bootstrap.min.js +7 -0
- package/docs/js/clipboard.min.js +7 -0
- package/docs/js/jquery.min.js +2 -0
- package/docs/js/lunr-data.js +923 -0
- package/docs/js/lunr-data.json +923 -0
- package/docs/js/lunr.min.js +6 -0
- package/docs/js/prism.js +869 -0
- package/docs/js/prism.min.js +1 -0
- package/docs/js/template.min.js +1 -0
- package/docs/list_class.html +128 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc-default.css +358 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/package.json +38 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
- uses: actions/setup-node@v3
|
|
16
|
+
with:
|
|
17
|
+
node-version: 16
|
|
18
|
+
- run: |
|
|
19
|
+
echo 'NPM Token ${secrets.NPM_TOKEN}'
|
|
20
|
+
npm ci
|
|
21
|
+
npm test
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
publish-npm:
|
|
25
|
+
needs: build
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v3
|
|
29
|
+
- uses: actions/setup-node@v3
|
|
30
|
+
with:
|
|
31
|
+
node-version: 16
|
|
32
|
+
registry-url: https://registry.npmjs.org/
|
|
33
|
+
- run: npm ci
|
|
34
|
+
- run: npm publish
|
|
35
|
+
env:
|
|
36
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Breakout-Embed
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/cobalt.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cobalt Frontend SDK
|
|
3
|
+
*/
|
|
4
|
+
class Cobalt {
|
|
5
|
+
/**
|
|
6
|
+
* Cobalt Frontend SDK
|
|
7
|
+
* @param {object} options The options to configure the Cobalt SDK.
|
|
8
|
+
* @param {string} [options.baseUrl=https://api.gocobalt.io] The base URL of your Cobalt API.
|
|
9
|
+
*/
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.apiBaseUrl = options?.baseUrl || "https://api.gocobalt.io";
|
|
12
|
+
this.template = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @returns {string} The token to install a template.
|
|
17
|
+
*/
|
|
18
|
+
get token() {
|
|
19
|
+
return this.templateToken;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @returns {string} The token to install a template.
|
|
24
|
+
*/
|
|
25
|
+
set token(token) {
|
|
26
|
+
return this.templateToken = typeof token === "string" ? token : "";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns {string} The base URL of cobalt API.
|
|
31
|
+
*/
|
|
32
|
+
get baseUrl() {
|
|
33
|
+
return this.apiBaseUrl;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {object} Field The Node Field object available for configuration.
|
|
38
|
+
* @property {string} name The field name.
|
|
39
|
+
* @property {string} type The input type of the field.
|
|
40
|
+
* @property {string} placeholder The placeholder text for the field.
|
|
41
|
+
* @property {boolean} required Whether the field is required.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {object} Node The Node object available for configuration.
|
|
46
|
+
* @property {string} node_id The ID of the installed workflow.
|
|
47
|
+
* @property {string} node_name The Name of the installed workflow.
|
|
48
|
+
* @property {Field[]} fields The applications integrated in the workflow.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {object} Workflow The installed workflow.
|
|
53
|
+
* @property {string} workflow_id The ID of the installed workflow.
|
|
54
|
+
* @property {unknown[]} applications The applications integrated in the workflow.
|
|
55
|
+
* @property {Node[]} configure The configuration data for the workflow.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Install the given template.
|
|
60
|
+
* @returns {Promise<Workflow>}
|
|
61
|
+
*/
|
|
62
|
+
async installTemplate() {
|
|
63
|
+
const res = await fetch(`${this.baseUrl}/api/v1/template/install`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: {
|
|
66
|
+
authorization: `Bearer ${this.token}`,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
this.template = await res.json();
|
|
70
|
+
return this.template;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Install the given template.
|
|
75
|
+
* @returns {Promise<Workflow>}
|
|
76
|
+
*/
|
|
77
|
+
async saveNode(nodeId, inputData = {}) {
|
|
78
|
+
const res = await fetch(`${this.baseUrl}/api/v2/workflow/${this.template?.workflow_id}/node/${nodeId}`, {
|
|
79
|
+
method: "PUT",
|
|
80
|
+
headers: {
|
|
81
|
+
authorization: `Bearer ${this.token}`,
|
|
82
|
+
},
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
input_data: inputData,
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
return await res.json();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default Cobalt;
|
package/cobalt.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class Cobalt{constructor(options){this.apiBaseUrl=options?.baseUrl||"https://api.gocobalt.io";this.template={}}get token(){return this.templateToken}set token(token){return this.templateToken=typeof token==="string"?token:""}get baseUrl(){return this.apiBaseUrl}async installTemplate(){const res=await fetch(`${this.baseUrl}/api/v1/template/install`,{method:"POST",headers:{authorization:`Bearer ${this.token}`}});this.template=await res.json();return this.template}async saveNode(nodeId,inputData={}){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${this.template?.workflow_id}/node/${nodeId}`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`},body:JSON.stringify({input_data:inputData})});return await res.json()}}export default Cobalt;
|