@pipedream/google_drive 0.3.3 → 0.4.0
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/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +83 -0
- package/actions/copy-file/copy-file.mjs +34 -0
- package/actions/create-file/create-file.mjs +242 -0
- package/actions/create-file-from-template/create-file-from-template.mjs +98 -0
- package/actions/create-file-from-text/create-file-from-text.mjs +67 -0
- package/actions/create-folder/create-folder.mjs +54 -0
- package/actions/create-shared-drive/create-shared-drive.mjs +25 -0
- package/actions/delete-file/delete-file.mjs +37 -0
- package/actions/delete-shared-drive/delete-shared-drive.mjs +30 -0
- package/actions/download-file/download-file.mjs +120 -0
- package/actions/find-file/find-file.mjs +35 -0
- package/actions/find-folder/find-folder.mjs +38 -0
- package/actions/get-folder-id-for-path/get-folder-id-for-path.mjs +62 -0
- package/actions/get-shared-drive/get-shared-drive.mjs +37 -0
- package/actions/google-mime-types.mjs +19 -0
- package/actions/google-workspace-export-formats.mjs +74 -0
- package/actions/language-codes.mjs +742 -0
- package/actions/move-file/move-file.mjs +52 -0
- package/actions/move-file-to-trash/move-file-to-trash.mjs +41 -0
- package/actions/replace-file/replace-file.mjs +90 -0
- package/actions/search-shared-drives/search-shared-drives.mjs +34 -0
- package/actions/update-file/update-file.mjs +164 -0
- package/actions/update-shared-drive/update-shared-drive.mjs +77 -0
- package/actions/upload-file/upload-file.mjs +89 -0
- package/constants.mjs +190 -0
- package/google_drive.app.mjs +1429 -0
- package/package.json +23 -20
- package/pnpm-lock.yaml +393 -0
- package/sources/changes-to-specific-files/changes-to-specific-files.mjs +226 -0
- package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +110 -0
- package/sources/common-webhook.mjs +201 -0
- package/sources/new-files-instant/new-files-instant.mjs +95 -0
- package/sources/new-or-modified-comments/new-or-modified-comments.mjs +104 -0
- package/sources/new-or-modified-files/new-or-modified-files.mjs +66 -0
- package/sources/new-or-modified-folders/new-or-modified-folders.mjs +86 -0
- package/sources/new-shared-drive/new-shared-drive.mjs +68 -0
- package/utils.mjs +247 -0
- package/LICENSE +0 -7
- package/google_drive.app.js +0 -212
- package/sources/changes-to-specific-files/changes-to-specific-files.js +0 -226
- package/sources/new-or-modified-files/new-or-modified-files.js +0 -213
package/constants.mjs
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {string} UpdateType - a type of push notification as defined by
|
|
3
|
+
* the [Google Drive API docs](https://bit.ly/3wcsY2X)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A new channel was successfully created. You can expect to start receiving
|
|
8
|
+
* notifications for it.
|
|
9
|
+
*
|
|
10
|
+
* @type {UpdateType}
|
|
11
|
+
*/
|
|
12
|
+
const GOOGLE_DRIVE_NOTIFICATION_SYNC = "sync";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A new resource was created or shared
|
|
16
|
+
*
|
|
17
|
+
* @type {UpdateType}
|
|
18
|
+
*/
|
|
19
|
+
const GOOGLE_DRIVE_NOTIFICATION_ADD = "add";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* An existing resource was deleted or unshared
|
|
23
|
+
*
|
|
24
|
+
* @type {UpdateType}
|
|
25
|
+
*/
|
|
26
|
+
const GOOGLE_DRIVE_NOTIFICATION_REMOVE = "remove";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* One or more properties (metadata) of a resource have been updated
|
|
30
|
+
*
|
|
31
|
+
* @type {UpdateType}
|
|
32
|
+
*/
|
|
33
|
+
const GOOGLE_DRIVE_NOTIFICATION_UPDATE = "update";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A resource has been moved to the trash
|
|
37
|
+
*
|
|
38
|
+
* @type {UpdateType}
|
|
39
|
+
*/
|
|
40
|
+
const GOOGLE_DRIVE_NOTIFICATION_TRASH = "trash";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A resource has been removed from the trash
|
|
44
|
+
*
|
|
45
|
+
* @type {UpdateType}
|
|
46
|
+
*/
|
|
47
|
+
const GOOGLE_DRIVE_NOTIFICATION_UNTRASH = "untrash";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* One or more new changelog items have been added
|
|
51
|
+
*
|
|
52
|
+
* @type {UpdateType}
|
|
53
|
+
*/
|
|
54
|
+
const GOOGLE_DRIVE_NOTIFICATION_CHANGE = "change";
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* All the available Google Drive update types
|
|
58
|
+
* @type {UpdateType[]}
|
|
59
|
+
*/
|
|
60
|
+
const GOOGLE_DRIVE_UPDATE_TYPES = [
|
|
61
|
+
GOOGLE_DRIVE_NOTIFICATION_SYNC,
|
|
62
|
+
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
|
63
|
+
GOOGLE_DRIVE_NOTIFICATION_REMOVE,
|
|
64
|
+
GOOGLE_DRIVE_NOTIFICATION_UPDATE,
|
|
65
|
+
GOOGLE_DRIVE_NOTIFICATION_TRASH,
|
|
66
|
+
GOOGLE_DRIVE_NOTIFICATION_UNTRASH,
|
|
67
|
+
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* This is a custom string value to represent the 'My Drive' Google Drive, which
|
|
72
|
+
* is represented as `null` by the Google Drive API. In order to simplify the
|
|
73
|
+
* code by avoiding null values, we assign this special value to the 'My Drive'
|
|
74
|
+
* drive.
|
|
75
|
+
*/
|
|
76
|
+
const MY_DRIVE_VALUE = "My Drive";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This is a legacy value for the `MY_DRIVE_VALUE` constant, supporting workflow configurations
|
|
80
|
+
* using this value.
|
|
81
|
+
*/
|
|
82
|
+
const LEGACY_MY_DRIVE_VALUE = "myDrive";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The maximum amount of time a subscription can be active without expiring is
|
|
86
|
+
* 24 hours. In order to minimize subscription renewals (which involve the
|
|
87
|
+
* execution of an event source) we set the expiration of subscriptions to its
|
|
88
|
+
* maximum allowed value.
|
|
89
|
+
*
|
|
90
|
+
* More information can be found in the API docs:
|
|
91
|
+
* https://developers.google.com/drive/api/v3/push#optional-properties
|
|
92
|
+
*/
|
|
93
|
+
const WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS = 24 * 60 * 60 * 1000;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The default time interval between webhook subscription renewals. Since
|
|
97
|
+
* subscriptions expire after 24 hours at most, we set this time to 95% of this
|
|
98
|
+
* time window by default to make sure the event sources don't miss any events
|
|
99
|
+
* due to an expired subscription not being renewed on time.
|
|
100
|
+
*
|
|
101
|
+
* More information can be found in the API docs:
|
|
102
|
+
* https://developers.google.com/drive/api/v3/push#optional-properties
|
|
103
|
+
*/
|
|
104
|
+
const WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS =
|
|
105
|
+
(WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS * 0.95) / 1000;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The maximum number of path segments to include in an option label for a prop whose value is a
|
|
109
|
+
* file ID. To make sure the file name is displayed in the option label in the UI, we truncate paths
|
|
110
|
+
* with more than this many path segments.
|
|
111
|
+
*/
|
|
112
|
+
const MAX_FILE_OPTION_PATH_SEGMENTS = 3;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The MIME type prefix of Google Drive MIME types as defined by the [Google
|
|
116
|
+
* Drive API docs](https://developers.google.com/drive/api/v3/mime-types)
|
|
117
|
+
*/
|
|
118
|
+
const GOOGLE_DRIVE_MIME_TYPE_PREFIX = "application/vnd.google-apps";
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The MIME type of Google Drive folders as defined by the [Google Drive API
|
|
122
|
+
* docs](https://developers.google.com/drive/api/v3/mime-types)
|
|
123
|
+
*/
|
|
124
|
+
const GOOGLE_DRIVE_FOLDER_MIME_TYPE = "application/vnd.google-apps.folder";
|
|
125
|
+
|
|
126
|
+
const GOOGLE_DRIVE_ROLE_OWNER = "owner";
|
|
127
|
+
const GOOGLE_DRIVE_ROLE_ORGANIZER = "organizer";
|
|
128
|
+
const GOOGLE_DRIVE_ROLE_FILEORGANIZER = "fileOrganizer";
|
|
129
|
+
const GOOGLE_DRIVE_ROLE_WRITER = "writer";
|
|
130
|
+
const GOOGLE_DRIVE_ROLE_COMMENTER = "commenter";
|
|
131
|
+
const GOOGLE_DRIVE_ROLE_READER = "reader";
|
|
132
|
+
/**
|
|
133
|
+
* All of the available Google Drive roles granted by a permission as defined by the [Google
|
|
134
|
+
* Drive API docs](https://developers.google.com/drive/api/v3/reference/permissions)
|
|
135
|
+
*/
|
|
136
|
+
const GOOGLE_DRIVE_ROLES = [
|
|
137
|
+
GOOGLE_DRIVE_ROLE_OWNER,
|
|
138
|
+
GOOGLE_DRIVE_ROLE_ORGANIZER,
|
|
139
|
+
GOOGLE_DRIVE_ROLE_FILEORGANIZER,
|
|
140
|
+
GOOGLE_DRIVE_ROLE_WRITER,
|
|
141
|
+
GOOGLE_DRIVE_ROLE_COMMENTER,
|
|
142
|
+
GOOGLE_DRIVE_ROLE_READER,
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
const GOOGLE_DRIVE_GRANTEE_USER = "user";
|
|
146
|
+
const GOOGLE_DRIVE_GRANTEE_GROUP = "group";
|
|
147
|
+
const GOOGLE_DRIVE_GRANTEE_DOMAIN = "domain";
|
|
148
|
+
const GOOGLE_DRIVE_GRANTEE_ANYONE = "anyone";
|
|
149
|
+
/**
|
|
150
|
+
* All of the available Google Drive grantee types as defined by the [Google Drive API
|
|
151
|
+
* docs](https://developers.google.com/drive/api/v3/reference/permissions)
|
|
152
|
+
*/
|
|
153
|
+
const GOOGLE_DRIVE_GRANTEE_TYPES = [
|
|
154
|
+
GOOGLE_DRIVE_GRANTEE_USER,
|
|
155
|
+
GOOGLE_DRIVE_GRANTEE_GROUP,
|
|
156
|
+
GOOGLE_DRIVE_GRANTEE_DOMAIN,
|
|
157
|
+
GOOGLE_DRIVE_GRANTEE_ANYONE,
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
GOOGLE_DRIVE_NOTIFICATION_SYNC,
|
|
162
|
+
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
|
163
|
+
GOOGLE_DRIVE_NOTIFICATION_REMOVE,
|
|
164
|
+
GOOGLE_DRIVE_NOTIFICATION_UPDATE,
|
|
165
|
+
GOOGLE_DRIVE_NOTIFICATION_TRASH,
|
|
166
|
+
GOOGLE_DRIVE_NOTIFICATION_UNTRASH,
|
|
167
|
+
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
|
168
|
+
GOOGLE_DRIVE_UPDATE_TYPES,
|
|
169
|
+
MY_DRIVE_VALUE,
|
|
170
|
+
LEGACY_MY_DRIVE_VALUE,
|
|
171
|
+
WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS,
|
|
172
|
+
WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS,
|
|
173
|
+
MAX_FILE_OPTION_PATH_SEGMENTS,
|
|
174
|
+
GOOGLE_DRIVE_MIME_TYPE_PREFIX,
|
|
175
|
+
GOOGLE_DRIVE_FOLDER_MIME_TYPE,
|
|
176
|
+
// Google Drive Roles
|
|
177
|
+
GOOGLE_DRIVE_ROLE_OWNER,
|
|
178
|
+
GOOGLE_DRIVE_ROLE_ORGANIZER,
|
|
179
|
+
GOOGLE_DRIVE_ROLE_FILEORGANIZER,
|
|
180
|
+
GOOGLE_DRIVE_ROLE_WRITER,
|
|
181
|
+
GOOGLE_DRIVE_ROLE_COMMENTER,
|
|
182
|
+
GOOGLE_DRIVE_ROLE_READER,
|
|
183
|
+
GOOGLE_DRIVE_ROLES,
|
|
184
|
+
// Google Drive Grantee Types
|
|
185
|
+
GOOGLE_DRIVE_GRANTEE_USER,
|
|
186
|
+
GOOGLE_DRIVE_GRANTEE_GROUP,
|
|
187
|
+
GOOGLE_DRIVE_GRANTEE_DOMAIN,
|
|
188
|
+
GOOGLE_DRIVE_GRANTEE_ANYONE,
|
|
189
|
+
GOOGLE_DRIVE_GRANTEE_TYPES,
|
|
190
|
+
};
|