@pipedream/google_drive 0.8.10 → 0.8.11
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/package.json
CHANGED
@@ -10,11 +10,18 @@ export default {
|
|
10
10
|
key: "google_drive-new-files-instant",
|
11
11
|
name: "New Files (Instant)",
|
12
12
|
description: "Emit new event when a new file is added in your linked Google Drive",
|
13
|
-
version: "0.1.
|
13
|
+
version: "0.1.12",
|
14
14
|
type: "source",
|
15
15
|
dedupe: "unique",
|
16
16
|
props: {
|
17
17
|
...common.props,
|
18
|
+
alert: {
|
19
|
+
type: "alert",
|
20
|
+
content: "For shared drives, prefer to use [New Files (Shared Drive)](https://pipedream.com/apps/google-drive/triggers/new-files-shared-drive) instead. \
|
21
|
+
It provides a more reliable way to track changes using polling. \
|
22
|
+
Shared drive notifications may be delayed or incomplete, as they don't immediately reflect all changes made by other users. \
|
23
|
+
For more details, see [Google's documentation](https://developers.google.com/drive/api/guides/about-changes#track_shared_drives).",
|
24
|
+
},
|
18
25
|
folders: {
|
19
26
|
type: "string[]",
|
20
27
|
label: "Folders",
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
2
|
+
import sourceComponent from "../new-files-instant/new-files-instant.mjs";
|
3
|
+
import sampleEmit from "../new-files-instant/test-event.mjs";
|
4
|
+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
5
|
+
|
6
|
+
export default {
|
7
|
+
key: "google_drive-new-files-shared-drive",
|
8
|
+
name: "New Files (Shared Drive)",
|
9
|
+
description: "Emit new event when a new file is added in your shared Google Drive",
|
10
|
+
version: "0.0.1",
|
11
|
+
type: "source",
|
12
|
+
dedupe: "unique",
|
13
|
+
props: {
|
14
|
+
googleDrive,
|
15
|
+
db: "$.service.db",
|
16
|
+
timer: {
|
17
|
+
label: "Polling interval",
|
18
|
+
description: "Interval to poll the Google Drive API for new files",
|
19
|
+
type: "$.interface.timer",
|
20
|
+
default: {
|
21
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
22
|
+
},
|
23
|
+
},
|
24
|
+
drive: {
|
25
|
+
propDefinition: [
|
26
|
+
googleDrive,
|
27
|
+
"sharedDrive",
|
28
|
+
],
|
29
|
+
description: "Select a [Shared Drive](https://support.google.com/a/users/answer/9310351) from this list",
|
30
|
+
optional: false,
|
31
|
+
},
|
32
|
+
folders: sourceComponent.props.folders,
|
33
|
+
},
|
34
|
+
hooks: {
|
35
|
+
async deploy() {
|
36
|
+
// Get initial page token for change tracking
|
37
|
+
const startPageToken = await this.googleDrive.getPageToken(this.getDriveId());
|
38
|
+
this._setPageToken(startPageToken);
|
39
|
+
this._setLastFileCreatedTime(Date.now());
|
40
|
+
|
41
|
+
// Emit the most recent files
|
42
|
+
await sourceComponent.hooks.deploy.bind(this)();
|
43
|
+
},
|
44
|
+
},
|
45
|
+
methods: sourceComponent.methods,
|
46
|
+
async run() {
|
47
|
+
const pageToken = this._getPageToken();
|
48
|
+
|
49
|
+
const driveId = this.getDriveId();
|
50
|
+
const changedFilesStream = this.googleDrive.listChanges(pageToken, driveId);
|
51
|
+
for await (const changedFilesPage of changedFilesStream) {
|
52
|
+
const { nextPageToken } = changedFilesPage;
|
53
|
+
|
54
|
+
// Process all the changed files retrieved from the current page
|
55
|
+
await this.processChanges();
|
56
|
+
|
57
|
+
// After successfully processing the changed files, we store the page
|
58
|
+
// token of the next page
|
59
|
+
this._setPageToken(nextPageToken);
|
60
|
+
}
|
61
|
+
},
|
62
|
+
sampleEmit,
|
63
|
+
};
|