File tree Expand file tree Collapse file tree 6 files changed +231
-1
lines changed
Expand file tree Collapse file tree 6 files changed +231
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/google_sheets" ,
3- "version" : " 0.12 .0" ,
3+ "version" : " 0.13 .0" ,
44 "description" : " Pipedream Google_sheets Components" ,
55 "main" : " google_sheets.app.mjs" ,
66 "keywords" : [
Original file line number Diff line number Diff line change 1+ export default {
2+ methods : {
3+ _getLastTs ( ) {
4+ return this . db . get ( "lastTs" ) ;
5+ } ,
6+ _setLastTs ( lastTs ) {
7+ this . db . set ( "lastTs" , lastTs ) ;
8+ } ,
9+ generateMeta ( comment ) {
10+ return {
11+ id : comment . id ,
12+ summary : `New Comment: ${ comment . content } ` ,
13+ ts : Date . parse ( comment . createdTime ) ,
14+ } ;
15+ } ,
16+ getSheetId ( ) {
17+ return this . sheetID . toString ( ) ;
18+ } ,
19+ async processSpreadsheet ( ) {
20+ const comments = [ ] ;
21+ const lastTs = this . _getLastTs ( ) ;
22+ const results = this . googleSheets . listComments ( this . sheetID , lastTs ) ;
23+ for await ( const comment of results ) {
24+ comments . push ( comment ) ;
25+ }
26+ if ( ! comments . length ) {
27+ return ;
28+ }
29+ this . _setLastTs ( comments [ 0 ] . createdTime ) ;
30+ comments . reverse ( ) . forEach ( ( comment ) => {
31+ const meta = this . generateMeta ( comment ) ;
32+ this . $emit ( comment , meta ) ;
33+ } ) ;
34+ } ,
35+ } ,
36+ } ;
Original file line number Diff line number Diff line change 1+ import googleSheets from "../../google_sheets.app.mjs" ;
2+ import common from "../common/new-comment.mjs" ;
3+ import base from "../common/http-based/base.mjs" ;
4+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform" ;
5+
6+ export default {
7+ ...common ,
8+ key : "google_sheets-new-comment-polling" ,
9+ name : "New Comment" ,
10+ description : "Emit new event each time a comment is added to a spreadsheet." ,
11+ version : "0.0.1" ,
12+ dedupe : "unique" ,
13+ type : "source" ,
14+ props : {
15+ googleSheets,
16+ db : "$.service.db" ,
17+ timer : {
18+ type : "$.interface.timer" ,
19+ static : {
20+ intervalSeconds : DEFAULT_POLLING_SOURCE_TIMER_INTERVAL ,
21+ } ,
22+ } ,
23+ watchedDrive : {
24+ propDefinition : [
25+ googleSheets ,
26+ "watchedDrive" ,
27+ ] ,
28+ description : "Defaults to My Drive. To select a [Shared Drive](https://support.google.com/a/users/answer/9310351) instead, select it from this list." ,
29+ } ,
30+ sheetID : {
31+ propDefinition : [
32+ googleSheets ,
33+ "sheetID" ,
34+ ( c ) => ( {
35+ driveId : googleSheets . methods . getDriveId ( c . watchedDrive ) ,
36+ } ) ,
37+ ] ,
38+ } ,
39+ ...common . props ,
40+ } ,
41+ methods : {
42+ ...base . methods ,
43+ ...common . methods ,
44+ } ,
45+ async run ( ) {
46+ return this . processSpreadsheet ( ) ;
47+ } ,
48+ } ;
Original file line number Diff line number Diff line change 1+ export default {
2+ "id" : "AAABM3vICvg" ,
3+ "kind" : "drive#comment" ,
4+ "createdTime" : "2024-05-08T21:32:04.823Z" ,
5+ "modifiedTime" : "2024-05-08T21:32:04.823Z" ,
6+ "anchor" : "{\"type\":\"workbook-range\",\"uid\":0,\"range\":\"1600938329\"}" ,
7+ "replies" : [ ] ,
8+ "author" : {
9+ "displayName" : "Test User" ,
10+ "kind" : "drive#user" ,
11+ "me" : true ,
12+ "photoLink" : "//lh3.googleusercontent.com/a/ACg8ocKv3FxHiUdLT981ghC9w01W50yqe5fi2XWOSA4TgnZf8pCxmg=s50-c-k-no"
13+ } ,
14+ "deleted" : false ,
15+ "htmlContent" : "comment" ,
16+ "content" : "comment" ,
17+ "quotedFileContent" : {
18+ "mimeType" : "text/html" ,
19+ "value" : "1"
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ import googleSheets from "../../google_sheets.app.mjs" ;
2+ import common from "../common/new-updates.mjs" ;
3+ import base from "../common/http-based/base.mjs" ;
4+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform" ;
5+
6+ export default {
7+ ...common ,
8+ key : "google_sheets-new-updates-polling" ,
9+ name : "New Updates" ,
10+ description : "Emit new event each time a row or cell is updated in a spreadsheet." ,
11+ version : "0.0.1" ,
12+ dedupe : "unique" ,
13+ type : "source" ,
14+ props : {
15+ googleSheets,
16+ db : "$.service.db" ,
17+ timer : {
18+ type : "$.interface.timer" ,
19+ static : {
20+ intervalSeconds : DEFAULT_POLLING_SOURCE_TIMER_INTERVAL ,
21+ } ,
22+ } ,
23+ watchedDrive : {
24+ propDefinition : [
25+ googleSheets ,
26+ "watchedDrive" ,
27+ ] ,
28+ description : "Defaults to My Drive. To select a [Shared Drive](https://support.google.com/a/users/answer/9310351) instead, select it from this list." ,
29+ } ,
30+ sheetID : {
31+ propDefinition : [
32+ googleSheets ,
33+ "sheetID" ,
34+ ( c ) => ( {
35+ driveId : googleSheets . methods . getDriveId ( c . watchedDrive ) ,
36+ } ) ,
37+ ] ,
38+ } ,
39+ ...common . props ,
40+ } ,
41+ methods : {
42+ ...base . methods ,
43+ ...common . methods ,
44+ } ,
45+ hooks : {
46+ async deploy ( ) {
47+ await this . takeSheetSnapshot ( ) ;
48+ } ,
49+ } ,
50+ async run ( ) {
51+ const spreadsheet = await this . googleSheets . getSpreadsheet ( this . sheetID ) ;
52+ return this . processSpreadsheet ( spreadsheet ) ;
53+ } ,
54+ } ;
Original file line number Diff line number Diff line change 1+ export default {
2+ "worksheet" : {
3+ "properties" : {
4+ "sheetId" : 358595775 ,
5+ "title" : "Test" ,
6+ "index" : 0 ,
7+ "sheetType" : "GRID" ,
8+ "gridProperties" : {
9+ "rowCount" : 1029 ,
10+ "columnCount" : 50
11+ }
12+ }
13+ } ,
14+ "currentValues" : {
15+ "values" : [
16+ [
17+ "1" ,
18+ "Leo 1 Updated"
19+ ] ,
20+ [
21+ "2" ,
22+ "Leo 2"
23+ ] ,
24+ [
25+ "3" ,
26+ "Leo 3"
27+ ] ,
28+ [
29+ "4" ,
30+ "Updated"
31+ ] ,
32+ [
33+ "5" ,
34+ "Updated 0857"
35+ ] ,
36+ [
37+ "6" ,
38+ "Update 0858"
39+ ]
40+ ] ,
41+ "range" : "Test!A1:AX1029" ,
42+ "majorDimension" : "ROWS"
43+ } ,
44+ "changes" : [
45+ {
46+ "cell" : "B:4" ,
47+ "previous_value" : "" ,
48+ "new_value" : "Updated"
49+ } ,
50+ {
51+ "cell" : "A:5" ,
52+ "previous_value" : "" ,
53+ "new_value" : "5"
54+ } ,
55+ {
56+ "cell" : "B:5" ,
57+ "previous_value" : "" ,
58+ "new_value" : "Updated 0857"
59+ } ,
60+ {
61+ "cell" : "A:6" ,
62+ "previous_value" : "" ,
63+ "new_value" : "6"
64+ } ,
65+ {
66+ "cell" : "B:6" ,
67+ "previous_value" : "" ,
68+ "new_value" : "Update 0858"
69+ }
70+ ]
71+ }
You can’t perform that action at this time.
0 commit comments