@twentyhq/people-data-labs 1.0.2 → 1.0.7
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/README.md +16 -0
- package/manifest.json +39 -38
- package/package.json +5 -4
- package/src/front-components/enrich-companies-component-effect.mjs +10 -10
- package/src/front-components/enrich-companies-component-effect.mjs.map +4 -4
- package/src/front-components/enrich-companies-component-effect.tsx +21 -0
- package/src/front-components/enrich-people-component-effect.mjs +10 -10
- package/src/front-components/enrich-people-component-effect.mjs.map +4 -4
- package/src/front-components/enrich-people-component-effect.tsx +21 -0
- package/src/logic-functions/enrich-companies.function.mjs +22 -17
- package/src/logic-functions/enrich-companies.function.mjs.map +4 -4
- package/src/logic-functions/enrich-companies.function.ts +77 -0
- package/src/logic-functions/enrich-company.function.mjs +22 -16
- package/src/logic-functions/enrich-company.function.mjs.map +4 -4
- package/src/logic-functions/enrich-company.function.ts +75 -0
- package/src/logic-functions/enrich-people.function.mjs +22 -17
- package/src/logic-functions/enrich-people.function.mjs.map +4 -4
- package/src/logic-functions/enrich-people.function.ts +77 -0
- package/src/logic-functions/enrich-person.function.mjs +22 -16
- package/src/logic-functions/enrich-person.function.mjs.map +4 -4
- package/src/logic-functions/enrich-person.function.ts +75 -0
- package/src/logic-functions/post-install.function.mjs.map +1 -1
- package/src/logic-functions/post-install.function.ts +17 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { defineLogicFunction, STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS } from 'twenty-sdk/define';
|
|
2
|
+
|
|
3
|
+
import { UPDATE_FIELDS_OPTION_VALUES } from 'src/constants/update-fields-option-values';
|
|
4
|
+
import { PDL_LOGIC_FUNCTION_CONSTANTS } from 'src/constants/universal-identifiers';
|
|
5
|
+
import { enrichPeopleCore } from 'src/logic-functions/handlers/enrich-people';
|
|
6
|
+
import { type EnrichInput, toBulkEnrichInput } from 'src/logic-functions/utils/to-bulk-enrich-input';
|
|
7
|
+
|
|
8
|
+
const handler = (input: EnrichInput) => {
|
|
9
|
+
return enrichPeopleCore({ input: toBulkEnrichInput(input) });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default defineLogicFunction({
|
|
13
|
+
universalIdentifier: PDL_LOGIC_FUNCTION_CONSTANTS.enrichPeople.universalIdentifier,
|
|
14
|
+
name: 'enrich-people',
|
|
15
|
+
description: 'Enrich one or more Person records with People Data Labs data',
|
|
16
|
+
timeoutSeconds: 300,
|
|
17
|
+
handler,
|
|
18
|
+
httpRouteTriggerSettings: {
|
|
19
|
+
path: PDL_LOGIC_FUNCTION_CONSTANTS.enrichPeople.path,
|
|
20
|
+
httpMethod: 'POST',
|
|
21
|
+
isAuthRequired: true
|
|
22
|
+
},
|
|
23
|
+
workflowActionTriggerSettings: {
|
|
24
|
+
label: 'Enrich People',
|
|
25
|
+
icon: 'IconSparkles',
|
|
26
|
+
inputSchema: [
|
|
27
|
+
{
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
records: {
|
|
31
|
+
type: 'records',
|
|
32
|
+
objectUniversalIdentifier:
|
|
33
|
+
STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.person.universalIdentifier,
|
|
34
|
+
label: 'Records',
|
|
35
|
+
},
|
|
36
|
+
updateFields: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
label: 'Update fields',
|
|
39
|
+
enum: [...UPDATE_FIELDS_OPTION_VALUES],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
outputSchema: [
|
|
45
|
+
{
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
success: { type: 'boolean', label: 'Success' },
|
|
49
|
+
total: { type: 'number', label: 'Total' },
|
|
50
|
+
matched: { type: 'number', label: 'Matched' },
|
|
51
|
+
notFound: { type: 'number', label: 'Not Found' },
|
|
52
|
+
skipped: { type: 'number', label: 'Skipped' },
|
|
53
|
+
errored: { type: 'number', label: 'Errored' },
|
|
54
|
+
results: {
|
|
55
|
+
type: 'array',
|
|
56
|
+
items: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
success: { type: 'boolean', label: 'Success' },
|
|
60
|
+
recordId: { type: 'string', label: 'Record Id' },
|
|
61
|
+
status: { type: 'string', label: 'Status' },
|
|
62
|
+
updatedFields: {
|
|
63
|
+
type: 'array',
|
|
64
|
+
items: { type: 'string' },
|
|
65
|
+
label: 'Updated Fields',
|
|
66
|
+
},
|
|
67
|
+
data: { type: 'object', label: 'Data' },
|
|
68
|
+
message: { type: 'string', label: 'Message' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
label: 'Results',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
});
|
|
@@ -211,6 +211,7 @@ var __anyHandler = {
|
|
|
211
211
|
};
|
|
212
212
|
var __anyStub = new Proxy(() => void 0, __anyHandler);
|
|
213
213
|
var defineLogicFunction = __defineFactoryStub;
|
|
214
|
+
var STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS = __anyStub;
|
|
214
215
|
|
|
215
216
|
// src/constants/update-fields-options.ts
|
|
216
217
|
var UPDATE_FIELDS_OPTIONS = {
|
|
@@ -6431,32 +6432,36 @@ var buildSkippedResult = ({
|
|
|
6431
6432
|
});
|
|
6432
6433
|
|
|
6433
6434
|
// node_modules/twenty-sdk/dist/billing/index.mjs
|
|
6434
|
-
var e =
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6435
|
+
var e = /* @__PURE__ */ (function(e2) {
|
|
6436
|
+
return e2.ACTOR = "ACTOR", e2.ADDRESS = "ADDRESS", e2.ARRAY = "ARRAY", e2.BOOLEAN = "BOOLEAN", e2.CURRENCY = "CURRENCY", e2.DATE = "DATE", e2.DATE_TIME = "DATE_TIME", e2.EMAILS = "EMAILS", e2.FILES = "FILES", e2.FULL_NAME = "FULL_NAME", e2.LINKS = "LINKS", e2.MORPH_RELATION = "MORPH_RELATION", e2.MULTI_SELECT = "MULTI_SELECT", e2.NUMBER = "NUMBER", e2.NUMERIC = "NUMERIC", e2.PHONES = "PHONES", e2.POSITION = "POSITION", e2.RATING = "RATING", e2.RAW_JSON = "RAW_JSON", e2.RELATION = "RELATION", e2.RICH_TEXT = "RICH_TEXT", e2.SELECT = "SELECT", e2.TEXT = "TEXT", e2.TS_VECTOR = "TS_VECTOR", e2.UUID = "UUID", e2;
|
|
6437
|
+
})({});
|
|
6438
|
+
e.TEXT, e.ARRAY, e.BOOLEAN, e.DATE, e.DATE_TIME, e.NUMBER, e.NUMERIC, e.RAW_JSON, e.RICH_TEXT, e.SELECT, e.MULTI_SELECT;
|
|
6439
|
+
var t = "TWENTY_API_URL";
|
|
6440
|
+
var n = "TWENTY_APP_ACCESS_TOKEN";
|
|
6441
|
+
var r = 5e3;
|
|
6442
|
+
var i = async ({ creditsUsedMicro: e2, operationType: i2, quantity: a = 1, resourceContext: o }) => {
|
|
6443
|
+
let s = process.env[t], c = process.env[n];
|
|
6439
6444
|
if (!(!s || !c)) try {
|
|
6440
|
-
let
|
|
6445
|
+
let t2 = await fetch(`${s.replace(/\/$/, "")}/app/billing/charge`, {
|
|
6441
6446
|
method: "POST",
|
|
6442
6447
|
headers: {
|
|
6443
6448
|
Authorization: `Bearer ${c}`,
|
|
6444
6449
|
"Content-Type": "application/json"
|
|
6445
6450
|
},
|
|
6446
6451
|
body: JSON.stringify({
|
|
6447
|
-
creditsUsedMicro:
|
|
6452
|
+
creditsUsedMicro: e2,
|
|
6448
6453
|
quantity: a,
|
|
6449
|
-
operationType:
|
|
6454
|
+
operationType: i2,
|
|
6450
6455
|
resourceContext: o
|
|
6451
6456
|
}),
|
|
6452
|
-
signal: AbortSignal.timeout(
|
|
6457
|
+
signal: AbortSignal.timeout(r)
|
|
6453
6458
|
});
|
|
6454
|
-
if (!
|
|
6455
|
-
let
|
|
6456
|
-
console.error(`chargeCredits: ${
|
|
6459
|
+
if (!t2.ok) {
|
|
6460
|
+
let e3 = await t2.text().catch(() => "");
|
|
6461
|
+
console.error(`chargeCredits: ${t2.status} ${t2.statusText}: ${e3}`);
|
|
6457
6462
|
}
|
|
6458
|
-
} catch (
|
|
6459
|
-
console.error(`chargeCredits: ${
|
|
6463
|
+
} catch (e3) {
|
|
6464
|
+
console.error(`chargeCredits: ${e3 instanceof Error ? e3.message : String(e3)}`);
|
|
6460
6465
|
}
|
|
6461
6466
|
};
|
|
6462
6467
|
|
|
@@ -6478,7 +6483,7 @@ var chargeMatchedEnrichments = async ({
|
|
|
6478
6483
|
const creditsPerMatchMicro = Math.round(
|
|
6479
6484
|
costPerMatchDollars * BILLING_MARGIN_MULTIPLIER * MICRO_CREDITS_PER_DOLLAR
|
|
6480
6485
|
);
|
|
6481
|
-
await
|
|
6486
|
+
await i({
|
|
6482
6487
|
creditsUsedMicro: matchedCount * creditsPerMatchMicro,
|
|
6483
6488
|
operationType: "CODE_EXECUTION",
|
|
6484
6489
|
quantity: matchedCount,
|
|
@@ -6868,7 +6873,8 @@ var enrich_person_function_default = defineLogicFunction({
|
|
|
6868
6873
|
type: "object",
|
|
6869
6874
|
properties: {
|
|
6870
6875
|
recordId: {
|
|
6871
|
-
type: "
|
|
6876
|
+
type: "record",
|
|
6877
|
+
objectUniversalIdentifier: STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.person.universalIdentifier,
|
|
6872
6878
|
label: "Record"
|
|
6873
6879
|
},
|
|
6874
6880
|
updateFields: {
|