@activepieces/piece-google-contacts 0.2.1 → 0.2.3
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 +5 -5
- package/src/index.js +1 -5
- package/src/index.js.map +1 -1
- package/src/lib/trigger/new-contact.js +54 -24
- package/src/lib/trigger/new-contact.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-google-contacts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@sinclair/typebox": "0.26.8",
|
|
6
6
|
"axios": "1.2.4",
|
|
7
7
|
"nanoid": "3.3.4",
|
|
8
|
-
"@activepieces/pieces-framework": "0.3.
|
|
9
|
-
"@activepieces/shared": "0.3.
|
|
10
|
-
"@activepieces/pieces-common": "0.0.
|
|
11
|
-
"tslib": "2.
|
|
8
|
+
"@activepieces/pieces-framework": "0.3.30",
|
|
9
|
+
"@activepieces/shared": "0.3.52",
|
|
10
|
+
"@activepieces/pieces-common": "0.0.9",
|
|
11
|
+
"tslib": "2.5.3"
|
|
12
12
|
},
|
|
13
13
|
"main": "./src/index.js",
|
|
14
14
|
"types": "./src/index.d.ts"
|
package/src/index.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.googleContacts = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const package_json_1 = tslib_1.__importDefault(require("../package.json"));
|
|
6
4
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
5
|
const create_contact_1 = require("./lib/action/create-contact");
|
|
8
6
|
const new_contact_1 = require("./lib/trigger/new-contact");
|
|
9
7
|
exports.googleContacts = (0, pieces_framework_1.createPiece)({
|
|
10
|
-
name: 'google-contacts',
|
|
11
8
|
logoUrl: 'https://cdn.activepieces.com/pieces/google-contacts.png',
|
|
12
9
|
actions: [create_contact_1.googleContactsAddContactAction],
|
|
13
10
|
displayName: "Google Contacts",
|
|
14
|
-
authors: ['abuaboud'],
|
|
11
|
+
authors: ['abuaboud', 'abdallah-alwarawreh'],
|
|
15
12
|
triggers: [new_contact_1.googleContactNewOrUpdatedContact],
|
|
16
|
-
version: package_json_1.default.version,
|
|
17
13
|
});
|
|
18
14
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/google-contacts/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/google-contacts/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,gEAA6E;AAC7E,2DAA6E;AAEhE,QAAA,cAAc,GAAG,IAAA,8BAAW,EAAC;IACzC,OAAO,EAAE,yDAAyD;IAClE,OAAO,EAAE,CAAC,+CAA8B,CAAC;IACzC,WAAW,EAAE,iBAAiB;IAC9B,OAAO,EAAE,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC5C,QAAQ,EAAE,CAAC,8CAAgC,CAAC;CAC5C,CAAC,CAAC"}
|
|
@@ -5,6 +5,33 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
6
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
|
+
const polling = {
|
|
9
|
+
strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
|
|
10
|
+
items: ({ store, propsValue: { authentication } }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
let newContacts = [];
|
|
12
|
+
let fetchMore = true;
|
|
13
|
+
while (fetchMore) {
|
|
14
|
+
const syncToken = (yield store.get("syncToken"));
|
|
15
|
+
const response = yield listContacts((0, pieces_common_1.getAccessTokenOrThrow)(authentication), syncToken);
|
|
16
|
+
const newConnections = response.body.connections;
|
|
17
|
+
yield store.put("syncToken", response.body.nextSyncToken);
|
|
18
|
+
if (newConnections === undefined || newConnections.length == 0) {
|
|
19
|
+
fetchMore = false;
|
|
20
|
+
}
|
|
21
|
+
if (newConnections !== undefined) {
|
|
22
|
+
newContacts = [...newContacts, ...newConnections];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
console.log(`Found ${newContacts.length} new contacts`);
|
|
26
|
+
newContacts = newContacts.filter(f => {
|
|
27
|
+
return f.metadata.deleted !== true;
|
|
28
|
+
});
|
|
29
|
+
return newContacts.map((item) => ({
|
|
30
|
+
id: newContacts.indexOf(item),
|
|
31
|
+
data: item,
|
|
32
|
+
}));
|
|
33
|
+
})
|
|
34
|
+
};
|
|
8
35
|
exports.googleContactNewOrUpdatedContact = (0, pieces_framework_1.createTrigger)({
|
|
9
36
|
name: 'new_or_updated_contact',
|
|
10
37
|
displayName: 'New Or Updated Contact',
|
|
@@ -72,47 +99,50 @@ exports.googleContactNewOrUpdatedContact = (0, pieces_framework_1.createTrigger)
|
|
|
72
99
|
},
|
|
73
100
|
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
74
101
|
onEnable(ctx) {
|
|
75
|
-
var _a;
|
|
76
102
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
78
|
-
|
|
103
|
+
return yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
104
|
+
store: ctx.store,
|
|
105
|
+
propsValue: {
|
|
106
|
+
authentication: ctx.propsValue['authentication'],
|
|
107
|
+
},
|
|
108
|
+
});
|
|
79
109
|
});
|
|
80
110
|
},
|
|
81
111
|
onDisable(ctx) {
|
|
82
112
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
|
|
113
|
+
return yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
114
|
+
store: ctx.store,
|
|
115
|
+
propsValue: {
|
|
116
|
+
authentication: ctx.propsValue['authentication'],
|
|
117
|
+
},
|
|
118
|
+
});
|
|
84
119
|
});
|
|
85
120
|
},
|
|
86
121
|
run(ctx) {
|
|
87
|
-
var _a, _b;
|
|
88
122
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const newConnections = response.body.connections;
|
|
95
|
-
yield ((_b = ctx.store) === null || _b === void 0 ? void 0 : _b.put("syncToken", response.body.nextSyncToken));
|
|
96
|
-
if (newConnections === undefined || newConnections.length == 0) {
|
|
97
|
-
fetchMore = false;
|
|
98
|
-
}
|
|
99
|
-
if (newConnections !== undefined) {
|
|
100
|
-
newContacts = [...newContacts, ...newConnections];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
console.log(`Found ${newContacts.length} new contacts`);
|
|
104
|
-
return newContacts.filter(f => {
|
|
105
|
-
return f.metadata.deleted !== true;
|
|
123
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
124
|
+
store: ctx.store,
|
|
125
|
+
propsValue: {
|
|
126
|
+
authentication: ctx.propsValue['authentication'],
|
|
127
|
+
},
|
|
106
128
|
});
|
|
107
129
|
});
|
|
108
130
|
},
|
|
131
|
+
test: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
133
|
+
store: ctx.store,
|
|
134
|
+
propsValue: {
|
|
135
|
+
authentication: ctx.propsValue['authentication'],
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
})
|
|
109
139
|
});
|
|
110
140
|
function listContacts(access_token, syncToken) {
|
|
111
141
|
let qParams = {
|
|
112
|
-
personFields: "
|
|
142
|
+
personFields: "addresses,ageRanges,biographies,birthdays,calendarUrls,clientData,coverPhotos,emailAddresses,events,externalIds,genders,imClients,interests,locales,locations,memberships,metadata,miscKeywords,names,nicknames,occupations,organizations,phoneNumbers,photos,relations,sipAddresses,skills,urls,userDefined",
|
|
113
143
|
requestSyncToken: "true"
|
|
114
144
|
};
|
|
115
|
-
if (syncToken !== undefined) {
|
|
145
|
+
if (syncToken !== undefined && syncToken !== null) {
|
|
116
146
|
qParams = Object.assign(Object.assign({}, qParams), { syncToken: syncToken });
|
|
117
147
|
}
|
|
118
148
|
return pieces_common_1.httpClient.sendRequest({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-contact.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-contacts/src/lib/trigger/new-contact.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"new-contact.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-contacts/src/lib/trigger/new-contact.ts"],"names":[],"mappings":";;;;AAAA,qEAAqG;AACrG,+DAAqK;AACrK,sCAAiD;AAGjD,MAAM,OAAO,GAAqD;IAC9D,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,CAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE;QACvD,IAAI,WAAW,GAAiB,EAAE,CAAC;QACnC,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,OAAO,SAAS,EAAE;YACd,MAAM,SAAS,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAS,WAAW,CAAC,CAAE,CAAC;YAC1D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAA,qCAAqB,EAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;YACtF,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;YACjD,MAAM,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC1D,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,CAAC,MAAM,IAAI,CAAC,E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