@cobaltio/cobalt-js 0.0.4 → 0.0.7

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
@@ -56,6 +56,11 @@ class Cobalt {
56
56
  * @property {Node[]} configure The configuration data for the workflow.
57
57
  */
58
58
 
59
+ /**
60
+ * @typedef {object} AppAuthStatus The auth status of the user for an application.
61
+ * @property {boolean} status Whether the user has authenticated with this application.
62
+ */
63
+
59
64
  /**
60
65
  * Install the given template.
61
66
  * @property {string} templateId The ID of the template you want to install.
@@ -71,6 +76,37 @@ class Cobalt {
71
76
  return await res.json();
72
77
  }
73
78
 
79
+ /**
80
+ * Returns the auth status of the user for the specified application.
81
+ * @property {string} application The application type.
82
+ * @returns {Promise<boolean>} The auth status of the user.
83
+ */
84
+ async getAppAuthStatus(application) {
85
+ const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/auth?integration_type=${application}`, {
86
+ headers: {
87
+ authorization: `Bearer ${this.token}`,
88
+ },
89
+ });
90
+ const data = await res.json();
91
+ return !!data?.status;
92
+ }
93
+
94
+ /**
95
+ * Returns the auth URL that users can use to authenticate themselves to the
96
+ * specified application.
97
+ * @property {string} application The application type.
98
+ * @returns {Promise<string>} The auth URL where users can authenticate themselves.
99
+ */
100
+ async getAppAuthUrl(application) {
101
+ const res = await fetch(`${this.baseUrl}/api/v1/google/integrate?type=${application}`, {
102
+ headers: {
103
+ authorization: `Bearer ${this.token}`,
104
+ },
105
+ });
106
+ const data = await res.json();
107
+ return data?.auth_url;
108
+ }
109
+
74
110
  /**
75
111
  * Save the input data for the specified node.
76
112
  * @property {string} workflowId The ID of the workflow.
@@ -83,6 +119,7 @@ class Cobalt {
83
119
  method: "PUT",
84
120
  headers: {
85
121
  authorization: `Bearer ${this.token}`,
122
+ "content-type": "application/json",
86
123
  },
87
124
  body: JSON.stringify({
88
125
  input_data: inputData,
@@ -90,6 +127,21 @@ class Cobalt {
90
127
  });
91
128
  return await res.json();
92
129
  }
130
+
131
+ /**
132
+ * Toggle the status of the specified workflow.
133
+ * @property {string} workflowId The ID of the workflow.
134
+ * @returns {Promise<Workflow>}
135
+ */
136
+ async toggleWorkflowStatus(workflowId) {
137
+ const res = await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/toggle-status`, {
138
+ method: "PUT",
139
+ headers: {
140
+ authorization: `Bearer ${this.token}`,
141
+ },
142
+ });
143
+ return await res.json();
144
+ }
93
145
  }
94
146
 
95
147
  module.exports = Cobalt;
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 saveNode(workflowId,nodeId,inputData={}){const res=await fetch(`${this.baseUrl}/api/v2/workflow/${workflowId}/node/${nodeId}`,{method:"PUT",headers:{authorization:`Bearer ${this.token}`},body:JSON.stringify({input_data:inputData})});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}`}});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()}}module.exports=Cobalt;
package/docs/Cobalt.html CHANGED
@@ -486,6 +486,331 @@
486
486
 
487
487
 
488
488
 
489
+ <h4 class="name" id="getAppAuthStatus"><span class="type-signature">(async) </span>getAppAuthStatus<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;boolean>}</span></h4>
490
+
491
+
492
+
493
+
494
+
495
+
496
+ <div class="description">
497
+ Returns the auth status of the user for the specified application.
498
+ </div>
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+ <h5 class="subsection-title">Properties:</h5>
513
+
514
+
515
+
516
+ <table class="props">
517
+ <thead>
518
+ <tr>
519
+
520
+ <th>Name</th>
521
+
522
+
523
+ <th>Type</th>
524
+
525
+
526
+
527
+
528
+
529
+ <th class="last">Description</th>
530
+ </tr>
531
+ </thead>
532
+
533
+ <tbody>
534
+
535
+
536
+ <tr>
537
+
538
+ <td class="name"><code>application</code></td>
539
+
540
+
541
+ <td class="type">
542
+
543
+
544
+ <span class="param-type">string</span>
545
+
546
+
547
+
548
+ </td>
549
+
550
+
551
+
552
+
553
+
554
+ <td class="description last">The application type.</td>
555
+ </tr>
556
+
557
+
558
+ </tbody>
559
+ </table>
560
+
561
+
562
+
563
+
564
+ <dl class="details">
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+ <dt class="tag-source">Source:</dt>
592
+ <dd class="tag-source"><ul class="dummy"><li>
593
+ <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line84">line 84</a>
594
+ </li></ul></dd>
595
+
596
+
597
+
598
+
599
+
600
+
601
+
602
+ </dl>
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+ <h5>Returns:</h5>
619
+
620
+
621
+ <div class="param-desc">
622
+ The auth status of the user.
623
+ </div>
624
+
625
+
626
+
627
+ <dl>
628
+ <dt>
629
+ Type
630
+ </dt>
631
+ <dd>
632
+
633
+ <span class="param-type">Promise.&lt;boolean></span>
634
+
635
+
636
+ </dd>
637
+ </dl>
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+ <h4 class="name" id="getAppAuthUrl"><span class="type-signature">(async) </span>getAppAuthUrl<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;string>}</span></h4>
652
+
653
+
654
+
655
+
656
+
657
+
658
+ <div class="description">
659
+ Returns the auth URL that users can use to authenticate themselves to the
660
+ specified application.
661
+ </div>
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+ <h5 class="subsection-title">Properties:</h5>
676
+
677
+
678
+
679
+ <table class="props">
680
+ <thead>
681
+ <tr>
682
+
683
+ <th>Name</th>
684
+
685
+
686
+ <th>Type</th>
687
+
688
+
689
+
690
+
691
+
692
+ <th class="last">Description</th>
693
+ </tr>
694
+ </thead>
695
+
696
+ <tbody>
697
+
698
+
699
+ <tr>
700
+
701
+ <td class="name"><code>application</code></td>
702
+
703
+
704
+ <td class="type">
705
+
706
+
707
+ <span class="param-type">string</span>
708
+
709
+
710
+
711
+ </td>
712
+
713
+
714
+
715
+
716
+
717
+ <td class="description last">The application type.</td>
718
+ </tr>
719
+
720
+
721
+ </tbody>
722
+ </table>
723
+
724
+
725
+
726
+
727
+ <dl class="details">
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+ <dt class="tag-source">Source:</dt>
755
+ <dd class="tag-source"><ul class="dummy"><li>
756
+ <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line100">line 100</a>
757
+ </li></ul></dd>
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+ </dl>
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+ <h5>Returns:</h5>
782
+
783
+
784
+ <div class="param-desc">
785
+ The auth URL where users can authenticate themselves.
786
+ </div>
787
+
788
+
789
+
790
+ <dl>
791
+ <dt>
792
+ Type
793
+ </dt>
794
+ <dd>
795
+
796
+ <span class="param-type">Promise.&lt;string></span>
797
+
798
+
799
+ </dd>
800
+ </dl>
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
489
814
  <h4 class="name" id="installTemplate"><span class="type-signature">(async) </span>installTemplate<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="global.html#Workflow">Workflow</a>>}</span></h4>
490
815
 
491
816
 
@@ -590,7 +915,7 @@
590
915
 
591
916
  <dt class="tag-source">Source:</dt>
592
917
  <dd class="tag-source"><ul class="dummy"><li>
593
- <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line64">line 64</a>
918
+ <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line69">line 69</a>
594
919
  </li></ul></dd>
595
920
 
596
921
 
@@ -794,7 +1119,7 @@
794
1119
 
795
1120
  <dt class="tag-source">Source:</dt>
796
1121
  <dd class="tag-source"><ul class="dummy"><li>
797
- <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line81">line 81</a>
1122
+ <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line117">line 117</a>
798
1123
  </li></ul></dd>
799
1124
 
800
1125
 
@@ -864,7 +1189,7 @@
864
1189
  <br class="clear">
865
1190
 
866
1191
  <footer>
867
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Wed Sep 07 2022 13:14:31 GMT+0530 (India Standard Time)
1192
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Sep 09 2022 11:59:06 GMT+0530 (India Standard Time)
868
1193
  </footer>
869
1194
 
870
1195
  <script> prettyPrint(); </script>
@@ -84,6 +84,11 @@ class Cobalt {
84
84
  * @property {Node[]} configure The configuration data for the workflow.
85
85
  */
86
86
 
87
+ /**
88
+ * @typedef {object} AppAuthStatus The auth status of the user for an application.
89
+ * @property {boolean} status Whether the user has authenticated with this application.
90
+ */
91
+
87
92
  /**
88
93
  * Install the given template.
89
94
  * @property {string} templateId The ID of the template you want to install.
@@ -99,6 +104,37 @@ class Cobalt {
99
104
  return await res.json();
100
105
  }
101
106
 
107
+ /**
108
+ * Returns the auth status of the user for the specified application.
109
+ * @property {string} application The application type.
110
+ * @returns {Promise&lt;boolean>} The auth status of the user.
111
+ */
112
+ async getAppAuthStatus(application) {
113
+ const res = await fetch(`${this.baseUrl}/api/v1/linked-acc/integration/auth?integration_type=${application}`, {
114
+ headers: {
115
+ authorization: `Bearer ${this.token}`,
116
+ },
117
+ });
118
+ const data = await res.json();
119
+ return !!data?.status;
120
+ }
121
+
122
+ /**
123
+ * Returns the auth URL that users can use to authenticate themselves to the
124
+ * specified application.
125
+ * @property {string} application The application type.
126
+ * @returns {Promise&lt;string>} The auth URL where users can authenticate themselves.
127
+ */
128
+ async getAppAuthUrl(application) {
129
+ const res = await fetch(`${this.baseUrl}/api/v1/google/integrate?type=${application}`, {
130
+ headers: {
131
+ authorization: `Bearer ${this.token}`,
132
+ },
133
+ });
134
+ const data = await res.json();
135
+ return data?.auth_url;
136
+ }
137
+
102
138
  /**
103
139
  * Save the input data for the specified node.
104
140
  * @property {string} workflowId The ID of the workflow.
@@ -137,7 +173,7 @@ module.exports = Cobalt;
137
173
  <br class="clear">
138
174
 
139
175
  <footer>
140
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Wed Sep 07 2022 13:14:31 GMT+0530 (India Standard Time)
176
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Sep 09 2022 11:59:06 GMT+0530 (India Standard Time)
141
177
  </footer>
142
178
 
143
179
  <script> prettyPrint(); </script>
package/docs/global.html CHANGED
@@ -102,6 +102,130 @@
102
102
 
103
103
 
104
104
 
105
+ <h4 class="name" id="AppAuthStatus">AppAuthStatus</h4>
106
+
107
+
108
+
109
+
110
+ <div class="description">
111
+ The auth status of the user for an application.
112
+ </div>
113
+
114
+
115
+
116
+ <h5>Type:</h5>
117
+ <ul>
118
+ <li>
119
+
120
+ <span class="param-type">object</span>
121
+
122
+
123
+ </li>
124
+ </ul>
125
+
126
+
127
+
128
+
129
+
130
+ <h5 class="subsection-title">Properties:</h5>
131
+
132
+
133
+
134
+ <table class="props">
135
+ <thead>
136
+ <tr>
137
+
138
+ <th>Name</th>
139
+
140
+
141
+ <th>Type</th>
142
+
143
+
144
+
145
+
146
+
147
+ <th class="last">Description</th>
148
+ </tr>
149
+ </thead>
150
+
151
+ <tbody>
152
+
153
+
154
+ <tr>
155
+
156
+ <td class="name"><code>status</code></td>
157
+
158
+
159
+ <td class="type">
160
+
161
+
162
+ <span class="param-type">boolean</span>
163
+
164
+
165
+
166
+ </td>
167
+
168
+
169
+
170
+
171
+
172
+ <td class="description last">Whether the user has authenticated with this application.</td>
173
+ </tr>
174
+
175
+
176
+ </tbody>
177
+ </table>
178
+
179
+
180
+
181
+
182
+ <dl class="details">
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ <dt class="tag-source">Source:</dt>
210
+ <dd class="tag-source"><ul class="dummy"><li>
211
+ <a href="cobalt.js.html">cobalt.js</a>, <a href="cobalt.js.html#line59">line 59</a>
212
+ </li></ul></dd>
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ </dl>
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
105
229
  <h4 class="name" id="Field">Field</h4>
106
230
 
107
231
 
@@ -653,7 +777,7 @@
653
777
  <br class="clear">
654
778
 
655
779
  <footer>
656
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Wed Sep 07 2022 13:14:31 GMT+0530 (India Standard Time)
780
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Sep 09 2022 11:59:06 GMT+0530 (India Standard Time)
657
781
  </footer>
658
782
 
659
783
  <script> prettyPrint(); </script>
package/docs/index.html CHANGED
@@ -91,7 +91,7 @@ cobalt.token = &quot;COBALT_SESSION_TOKEN&quot;;
91
91
  <br class="clear">
92
92
 
93
93
  <footer>
94
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Wed Sep 07 2022 13:14:31 GMT+0530 (India Standard Time)
94
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Sep 09 2022 11:59:06 GMT+0530 (India Standard Time)
95
95
  </footer>
96
96
 
97
97
  <script> prettyPrint(); </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobaltio/cobalt-js",
3
- "version": "0.0.4",
3
+ "version": "0.0.7",
4
4
  "description": "Cobalt frontend SDK",
5
5
  "main": "./cobalt.js",
6
6
  "scripts": {