@@ -8,126 +8,106 @@ export default {
88 type : "string" ,
99 label : "Record ID" ,
1010 description : "The ID of the recording to fetch" ,
11- async options ( ) {
12- const recordings = await this . listRecordings ( ) ;
13- return recordings . map ( ( recording ) => ( {
14- value : recording . id ,
15- label : recording . title ,
16- } ) ) ;
11+ async options ( { prevContext : { nextPage } } ) {
12+ const {
13+ recordings, cursor,
14+ } = await this . listRecordings ( {
15+ params : {
16+ cursor : nextPage ,
17+ } ,
18+ } ) ;
19+ return {
20+ options : recordings . map ( ( {
21+ id : value , title : label ,
22+ } ) => ( {
23+ value,
24+ label,
25+ } ) ) ,
26+ context : {
27+ nextPage : cursor ,
28+ } ,
29+ } ;
1730 } ,
1831 } ,
19- transcriptFormat : {
32+ viewId : {
2033 type : "string" ,
21- label : "Transcript Format" ,
22- description : "Format for the transcript" ,
23- options : [
24- {
25- label : "JSON" ,
26- value : "json" ,
27- } ,
28- {
29- label : "VTT" ,
30- value : "vtt" ,
31- } ,
32- ] ,
33- optional : true ,
34- } ,
35- intelligenceNotesFormat : {
36- type : "string" ,
37- label : "Intelligence Notes Format" ,
38- description : "Format for the intelligence notes" ,
39- options : [
40- {
41- label : "JSON" ,
42- value : "json" ,
43- } ,
44- {
45- label : "Markdown" ,
46- value : "md" ,
47- } ,
48- {
49- label : "Text" ,
50- value : "text" ,
51- } ,
52- ] ,
53- optional : true ,
54- } ,
55- allowedIntelligenceNotes : {
56- type : "string[]" ,
57- label : "Allowed Intelligence Notes" ,
58- description : "Whitelist of intelligence notes section titles" ,
59- optional : true ,
34+ label : "View ID" ,
35+ description : "The ID of the recording to fetch" ,
36+ async options ( {
37+ type, prevContext : { nextPage } ,
38+ } ) {
39+ const {
40+ views, cursor,
41+ } = await this . listViews ( {
42+ params : {
43+ type_filter : type ,
44+ cursor : nextPage ,
45+ } ,
46+ } ) ;
47+ return {
48+ options : views . map ( ( {
49+ id : value , name : label ,
50+ } ) => ( {
51+ value,
52+ label,
53+ } ) ) ,
54+ context : {
55+ nextPage : cursor ,
56+ } ,
57+ } ;
58+ } ,
6059 } ,
6160 } ,
6261 methods : {
6362 _baseUrl ( ) {
64- return "https://grain.com" ;
63+ return "https://grain.com/_/public-api" ;
64+ } ,
65+ _headers ( ) {
66+ return {
67+ Authorization : `Bearer ${ this . $auth . oauth_access_token } ` ,
68+ } ;
6569 } ,
66- async _makeRequest ( opts = { } ) {
67- const {
68- $ = this , method = "GET" , path = "/" , headers, ...otherOpts
69- } = opts ;
70+ _makeRequest ( {
71+ $ = this , path, ...opts
72+ } ) {
7073 return axios ( $ , {
71- ...otherOpts ,
72- method,
7374 url : this . _baseUrl ( ) + path ,
74- headers : {
75- ...headers ,
76- Authorization : `Bearer ${ this . $auth . oauth_access_token } ` ,
77- } ,
75+ headers : this . _headers ( ) ,
76+ ...opts ,
7877 } ) ;
7978 } ,
80- async listRecordings ( opts = { } ) {
79+ listRecordings ( opts = { } ) {
8180 return this . _makeRequest ( {
82- path : "/_/public-api/ recordings" ,
81+ path : "/recordings" ,
8382 ...opts ,
8483 } ) ;
8584 } ,
86- async fetchRecording ( {
87- recordId, transcriptFormat, intelligenceNotesFormat, allowedIntelligenceNotes, ...opts
88- } ) {
85+ listViews ( opts = { } ) {
8986 return this . _makeRequest ( {
90- path : `/_/public-api/recordings/${ recordId } ` ,
91- params : {
92- transcript_format : transcriptFormat ,
93- intelligence_notes_format : intelligenceNotesFormat ,
94- allowed_intelligence_notes : allowedIntelligenceNotes ,
95- } ,
87+ path : "/views" ,
9688 ...opts ,
9789 } ) ;
9890 } ,
99- async emitNewEvent ( eventType , entityType ) {
100- // Logic to emit event - placeholder implementation
101- console . log ( `Emit ${ eventType } event for ${ entityType } ` ) ;
102- } ,
103- } ,
104- hooks : {
105- async addedHighlight ( ) {
106- await this . emitNewEvent ( "added" , "highlight" ) ;
107- } ,
108- async addedStory ( ) {
109- await this . emitNewEvent ( "added" , "story" ) ;
110- } ,
111- async addedRecording ( ) {
112- await this . emitNewEvent ( "added" , "recording" ) ;
113- } ,
114- async updatedHighlight ( ) {
115- await this . emitNewEvent ( "updated" , "highlight" ) ;
116- } ,
117- async updatedStory ( ) {
118- await this . emitNewEvent ( "updated" , "story" ) ;
119- } ,
120- async updatedRecording ( ) {
121- await this . emitNewEvent ( "updated" , "recording" ) ;
122- } ,
123- async removedHighlight ( ) {
124- await this . emitNewEvent ( "removed" , "highlight" ) ;
91+ fetchRecording ( {
92+ recordId, ...opts
93+ } ) {
94+ return this . _makeRequest ( {
95+ path : `/recordings/${ recordId } ` ,
96+ ...opts ,
97+ } ) ;
12598 } ,
126- async removedStory ( ) {
127- await this . emitNewEvent ( "removed" , "story" ) ;
99+ createWebhook ( opts = { } ) {
100+ return this . _makeRequest ( {
101+ method : "POST" ,
102+ path : "/hooks" ,
103+ ...opts ,
104+ } ) ;
128105 } ,
129- async removedRecording ( ) {
130- await this . emitNewEvent ( "removed" , "recording" ) ;
106+ deleteWebhook ( hookId ) {
107+ return this . _makeRequest ( {
108+ method : "DELETE" ,
109+ path : `/hooks/${ hookId } ` ,
110+ } ) ;
131111 } ,
132112 } ,
133113} ;
0 commit comments