@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 { enrichCompaniesCore } from 'src/logic-functions/handlers/enrich-companies';
|
|
6
|
+
import { type EnrichInput, toBulkEnrichInput } from 'src/logic-functions/utils/to-bulk-enrich-input';
|
|
7
|
+
|
|
8
|
+
const handler = (input: EnrichInput) => {
|
|
9
|
+
return enrichCompaniesCore({ input: toBulkEnrichInput(input) });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default defineLogicFunction({
|
|
13
|
+
universalIdentifier: PDL_LOGIC_FUNCTION_CONSTANTS.enrichCompanies.universalIdentifier,
|
|
14
|
+
name: 'enrich-companies',
|
|
15
|
+
description: 'Enrich one or more Company records with People Data Labs data',
|
|
16
|
+
timeoutSeconds: 300,
|
|
17
|
+
handler,
|
|
18
|
+
httpRouteTriggerSettings: {
|
|
19
|
+
path: PDL_LOGIC_FUNCTION_CONSTANTS.enrichCompanies.path,
|
|
20
|
+
httpMethod: 'POST',
|
|
21
|
+
isAuthRequired: true
|
|
22
|
+
},
|
|
23
|
+
workflowActionTriggerSettings: {
|
|
24
|
+
label: 'Enrich Companies',
|
|
25
|
+
icon: 'IconSparkles',
|
|
26
|
+
inputSchema: [
|
|
27
|
+
{
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
records: {
|
|
31
|
+
type: 'records',
|
|
32
|
+
objectUniversalIdentifier:
|
|
33
|
+
STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.company.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 = {
|
|
@@ -5728,32 +5729,36 @@ var buildSkippedResult = ({
|
|
|
5728
5729
|
});
|
|
5729
5730
|
|
|
5730
5731
|
// node_modules/twenty-sdk/dist/billing/index.mjs
|
|
5731
|
-
var e =
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5732
|
+
var e = /* @__PURE__ */ (function(e2) {
|
|
5733
|
+
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;
|
|
5734
|
+
})({});
|
|
5735
|
+
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;
|
|
5736
|
+
var t = "TWENTY_API_URL";
|
|
5737
|
+
var n = "TWENTY_APP_ACCESS_TOKEN";
|
|
5738
|
+
var r = 5e3;
|
|
5739
|
+
var i = async ({ creditsUsedMicro: e2, operationType: i2, quantity: a = 1, resourceContext: o }) => {
|
|
5740
|
+
let s = process.env[t], c = process.env[n];
|
|
5736
5741
|
if (!(!s || !c)) try {
|
|
5737
|
-
let
|
|
5742
|
+
let t2 = await fetch(`${s.replace(/\/$/, "")}/app/billing/charge`, {
|
|
5738
5743
|
method: "POST",
|
|
5739
5744
|
headers: {
|
|
5740
5745
|
Authorization: `Bearer ${c}`,
|
|
5741
5746
|
"Content-Type": "application/json"
|
|
5742
5747
|
},
|
|
5743
5748
|
body: JSON.stringify({
|
|
5744
|
-
creditsUsedMicro:
|
|
5749
|
+
creditsUsedMicro: e2,
|
|
5745
5750
|
quantity: a,
|
|
5746
|
-
operationType:
|
|
5751
|
+
operationType: i2,
|
|
5747
5752
|
resourceContext: o
|
|
5748
5753
|
}),
|
|
5749
|
-
signal: AbortSignal.timeout(
|
|
5754
|
+
signal: AbortSignal.timeout(r)
|
|
5750
5755
|
});
|
|
5751
|
-
if (!
|
|
5752
|
-
let
|
|
5753
|
-
console.error(`chargeCredits: ${
|
|
5756
|
+
if (!t2.ok) {
|
|
5757
|
+
let e3 = await t2.text().catch(() => "");
|
|
5758
|
+
console.error(`chargeCredits: ${t2.status} ${t2.statusText}: ${e3}`);
|
|
5754
5759
|
}
|
|
5755
|
-
} catch (
|
|
5756
|
-
console.error(`chargeCredits: ${
|
|
5760
|
+
} catch (e3) {
|
|
5761
|
+
console.error(`chargeCredits: ${e3 instanceof Error ? e3.message : String(e3)}`);
|
|
5757
5762
|
}
|
|
5758
5763
|
};
|
|
5759
5764
|
|
|
@@ -5775,7 +5780,7 @@ var chargeMatchedEnrichments = async ({
|
|
|
5775
5780
|
const creditsPerMatchMicro = Math.round(
|
|
5776
5781
|
costPerMatchDollars * BILLING_MARGIN_MULTIPLIER * MICRO_CREDITS_PER_DOLLAR
|
|
5777
5782
|
);
|
|
5778
|
-
await
|
|
5783
|
+
await i({
|
|
5779
5784
|
creditsUsedMicro: matchedCount * creditsPerMatchMicro,
|
|
5780
5785
|
operationType: "CODE_EXECUTION",
|
|
5781
5786
|
quantity: matchedCount,
|
|
@@ -6165,7 +6170,8 @@ var enrich_company_function_default = defineLogicFunction({
|
|
|
6165
6170
|
type: "object",
|
|
6166
6171
|
properties: {
|
|
6167
6172
|
recordId: {
|
|
6168
|
-
type: "
|
|
6173
|
+
type: "record",
|
|
6174
|
+
objectUniversalIdentifier: STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.company.universalIdentifier,
|
|
6169
6175
|
label: "Record"
|
|
6170
6176
|
},
|
|
6171
6177
|
updateFields: {
|