@erxes/core-contract 0.1.0-v2.7 → 0.1.0-v2.9
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/dist/activities.d.ts +154 -14
- package/dist/activities.js +20 -8
- package/dist/automationRuns.d.ts +38 -1
- package/dist/automationRuns.js +34 -3
- package/dist/automations.d.ts +3 -0
- package/dist/client.d.ts +1069 -42
- package/dist/client.js +23 -1
- package/dist/companies.d.ts +70 -0
- package/dist/companies.js +3 -1
- package/dist/contract/routes.json.js +24 -0
- package/dist/customers.d.ts +77 -0
- package/dist/customers.js +3 -2
- package/dist/db/src/enums.d.ts +5 -0
- package/dist/db/src/enums.js +43 -4
- package/dist/db/src/schema/fields.js +16 -2
- package/dist/db/src/schema/views.js +5 -3
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +8 -0
- package/dist/events.js +1 -1
- package/dist/fields.d.ts +226 -0
- package/dist/fields.js +16 -9
- package/dist/index.d.ts +722 -46
- package/dist/index.js +8 -6
- package/dist/pluginFields.d.ts +158 -0
- package/dist/pluginFields.js +65 -0
- package/dist/pluginJobs.d.ts +1 -0
- package/dist/pluginJobs.js +5 -0
- package/dist/plugins.d.ts +53 -6
- package/dist/plugins.js +11 -31
- package/dist/timelines.d.ts +36 -0
- package/dist/timelines.js +38 -0
- package/dist/views.d.ts +149 -12
- package/dist/views.js +37 -11
- package/package.json +3 -1
package/dist/client.js
CHANGED
|
@@ -63,6 +63,28 @@ const contactQueries = {
|
|
|
63
63
|
})
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
+
* Where erxes-ui's list filter searches customers and companies for `customer` and `company`
|
|
67
|
+
* fields: `<ListFilter contacts={contactSearchQueries} … />`. A rule's picked contacts load by id.
|
|
68
|
+
*/
|
|
69
|
+
const contactSearchQueries = {
|
|
70
|
+
customers: ({ search, ids }) => orpc.customers.list.queryOptions({
|
|
71
|
+
input: {
|
|
72
|
+
limit: ids ? 100 : 20,
|
|
73
|
+
search,
|
|
74
|
+
ids: ids?.join(",")
|
|
75
|
+
},
|
|
76
|
+
staleTime: 6e4
|
|
77
|
+
}),
|
|
78
|
+
companies: ({ search, ids }) => orpc.companies.list.queryOptions({
|
|
79
|
+
input: {
|
|
80
|
+
limit: ids ? 100 : 20,
|
|
81
|
+
search,
|
|
82
|
+
ids: ids?.join(",")
|
|
83
|
+
},
|
|
84
|
+
staleTime: 6e4
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
66
88
|
* Whether core answered with `code` (`TAKEN`, `NOT_FOUND`, …). It narrows
|
|
67
89
|
* `error.data` to what `ERRORS` declares for the code, so the field a
|
|
68
90
|
* `TAKEN` is about reads as `error.data.field`.
|
|
@@ -74,4 +96,4 @@ const messageOf = (error) => {
|
|
|
74
96
|
if (issue) return `${issue.path.join(".")}: ${issue.message}`;
|
|
75
97
|
return error instanceof Error ? error.message : "Something went wrong. Try again.";
|
|
76
98
|
};
|
|
77
|
-
export { contactQueries, isApiError, memberQueries, messageOf, orpc };
|
|
99
|
+
export { contactQueries, contactSearchQueries, isApiError, memberQueries, messageOf, orpc };
|
package/dist/companies.d.ts
CHANGED
|
@@ -267,6 +267,13 @@ export declare const companiesContract: {
|
|
|
267
267
|
NOT_A_LEAD: {
|
|
268
268
|
status: number;
|
|
269
269
|
};
|
|
270
|
+
PLUGIN_FIELD: {
|
|
271
|
+
status: number;
|
|
272
|
+
data: z.ZodObject<{
|
|
273
|
+
fieldId: z.ZodString;
|
|
274
|
+
plugin: z.ZodString;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
};
|
|
270
277
|
TAG_LIMIT: {
|
|
271
278
|
status: number;
|
|
272
279
|
};
|
|
@@ -415,6 +422,13 @@ export declare const companiesContract: {
|
|
|
415
422
|
NOT_A_LEAD: {
|
|
416
423
|
status: number;
|
|
417
424
|
};
|
|
425
|
+
PLUGIN_FIELD: {
|
|
426
|
+
status: number;
|
|
427
|
+
data: z.ZodObject<{
|
|
428
|
+
fieldId: z.ZodString;
|
|
429
|
+
plugin: z.ZodString;
|
|
430
|
+
}, z.core.$strip>;
|
|
431
|
+
};
|
|
418
432
|
TAG_LIMIT: {
|
|
419
433
|
status: number;
|
|
420
434
|
};
|
|
@@ -589,6 +603,13 @@ export declare const companiesContract: {
|
|
|
589
603
|
NOT_A_LEAD: {
|
|
590
604
|
status: number;
|
|
591
605
|
};
|
|
606
|
+
PLUGIN_FIELD: {
|
|
607
|
+
status: number;
|
|
608
|
+
data: z.ZodObject<{
|
|
609
|
+
fieldId: z.ZodString;
|
|
610
|
+
plugin: z.ZodString;
|
|
611
|
+
}, z.core.$strip>;
|
|
612
|
+
};
|
|
592
613
|
TAG_LIMIT: {
|
|
593
614
|
status: number;
|
|
594
615
|
};
|
|
@@ -764,6 +785,13 @@ export declare const companiesContract: {
|
|
|
764
785
|
NOT_A_LEAD: {
|
|
765
786
|
status: number;
|
|
766
787
|
};
|
|
788
|
+
PLUGIN_FIELD: {
|
|
789
|
+
status: number;
|
|
790
|
+
data: z.ZodObject<{
|
|
791
|
+
fieldId: z.ZodString;
|
|
792
|
+
plugin: z.ZodString;
|
|
793
|
+
}, z.core.$strip>;
|
|
794
|
+
};
|
|
767
795
|
TAG_LIMIT: {
|
|
768
796
|
status: number;
|
|
769
797
|
};
|
|
@@ -880,6 +908,13 @@ export declare const companiesContract: {
|
|
|
880
908
|
NOT_A_LEAD: {
|
|
881
909
|
status: number;
|
|
882
910
|
};
|
|
911
|
+
PLUGIN_FIELD: {
|
|
912
|
+
status: number;
|
|
913
|
+
data: z.ZodObject<{
|
|
914
|
+
fieldId: z.ZodString;
|
|
915
|
+
plugin: z.ZodString;
|
|
916
|
+
}, z.core.$strip>;
|
|
917
|
+
};
|
|
883
918
|
TAG_LIMIT: {
|
|
884
919
|
status: number;
|
|
885
920
|
};
|
|
@@ -1029,6 +1064,13 @@ export declare const companiesContract: {
|
|
|
1029
1064
|
NOT_A_LEAD: {
|
|
1030
1065
|
status: number;
|
|
1031
1066
|
};
|
|
1067
|
+
PLUGIN_FIELD: {
|
|
1068
|
+
status: number;
|
|
1069
|
+
data: z.ZodObject<{
|
|
1070
|
+
fieldId: z.ZodString;
|
|
1071
|
+
plugin: z.ZodString;
|
|
1072
|
+
}, z.core.$strip>;
|
|
1073
|
+
};
|
|
1032
1074
|
TAG_LIMIT: {
|
|
1033
1075
|
status: number;
|
|
1034
1076
|
};
|
|
@@ -1147,6 +1189,13 @@ export declare const companiesContract: {
|
|
|
1147
1189
|
NOT_A_LEAD: {
|
|
1148
1190
|
status: number;
|
|
1149
1191
|
};
|
|
1192
|
+
PLUGIN_FIELD: {
|
|
1193
|
+
status: number;
|
|
1194
|
+
data: z.ZodObject<{
|
|
1195
|
+
fieldId: z.ZodString;
|
|
1196
|
+
plugin: z.ZodString;
|
|
1197
|
+
}, z.core.$strip>;
|
|
1198
|
+
};
|
|
1150
1199
|
TAG_LIMIT: {
|
|
1151
1200
|
status: number;
|
|
1152
1201
|
};
|
|
@@ -1286,6 +1335,13 @@ export declare const companiesContract: {
|
|
|
1286
1335
|
NOT_A_LEAD: {
|
|
1287
1336
|
status: number;
|
|
1288
1337
|
};
|
|
1338
|
+
PLUGIN_FIELD: {
|
|
1339
|
+
status: number;
|
|
1340
|
+
data: z.ZodObject<{
|
|
1341
|
+
fieldId: z.ZodString;
|
|
1342
|
+
plugin: z.ZodString;
|
|
1343
|
+
}, z.core.$strip>;
|
|
1344
|
+
};
|
|
1289
1345
|
TAG_LIMIT: {
|
|
1290
1346
|
status: number;
|
|
1291
1347
|
};
|
|
@@ -1409,6 +1465,13 @@ export declare const companiesContract: {
|
|
|
1409
1465
|
NOT_A_LEAD: {
|
|
1410
1466
|
status: number;
|
|
1411
1467
|
};
|
|
1468
|
+
PLUGIN_FIELD: {
|
|
1469
|
+
status: number;
|
|
1470
|
+
data: z.ZodObject<{
|
|
1471
|
+
fieldId: z.ZodString;
|
|
1472
|
+
plugin: z.ZodString;
|
|
1473
|
+
}, z.core.$strip>;
|
|
1474
|
+
};
|
|
1412
1475
|
TAG_LIMIT: {
|
|
1413
1476
|
status: number;
|
|
1414
1477
|
};
|
|
@@ -1526,6 +1589,13 @@ export declare const companiesContract: {
|
|
|
1526
1589
|
NOT_A_LEAD: {
|
|
1527
1590
|
status: number;
|
|
1528
1591
|
};
|
|
1592
|
+
PLUGIN_FIELD: {
|
|
1593
|
+
status: number;
|
|
1594
|
+
data: z.ZodObject<{
|
|
1595
|
+
fieldId: z.ZodString;
|
|
1596
|
+
plugin: z.ZodString;
|
|
1597
|
+
}, z.core.$strip>;
|
|
1598
|
+
};
|
|
1529
1599
|
TAG_LIMIT: {
|
|
1530
1600
|
status: number;
|
|
1531
1601
|
};
|
package/dist/companies.js
CHANGED
|
@@ -87,6 +87,7 @@ const CompanyFields = createUpdateSchema(companies, {
|
|
|
87
87
|
...LIFECYCLE_INPUT_COLUMNS
|
|
88
88
|
}).extend({
|
|
89
89
|
tagIds: z.array(Id).max(50).optional(),
|
|
90
|
+
/** Sets the given custom fields; `null` clears one. Others stay. A plugin's field: 403 PLUGIN_FIELD. */
|
|
90
91
|
customFields: CustomFieldsPatch.optional()
|
|
91
92
|
});
|
|
92
93
|
const ID = z.object({ id: Id });
|
|
@@ -101,7 +102,7 @@ const TagChange = z.object({
|
|
|
101
102
|
add: z.array(Id).max(50).default([]),
|
|
102
103
|
remove: z.array(Id).max(50).default([])
|
|
103
104
|
});
|
|
104
|
-
const { INVALID_ACTOR, INVALID_FIELD, INVALID_FIELD_VALUE, INVALID_OWNER, INVALID_TAG, INVALID_TYPE, MASS_DELETE_STOPPED, NOT_A_LEAD, TAG_LIMIT } = ERRORS;
|
|
105
|
+
const { INVALID_ACTOR, INVALID_FIELD, INVALID_FIELD_VALUE, INVALID_OWNER, INVALID_TAG, INVALID_TYPE, MASS_DELETE_STOPPED, NOT_A_LEAD, PLUGIN_FIELD, TAG_LIMIT } = ERRORS;
|
|
105
106
|
/** What these procedures answer with besides the common errors. */
|
|
106
107
|
const base = oc.errors({
|
|
107
108
|
...COMMON_ERRORS,
|
|
@@ -113,6 +114,7 @@ const base = oc.errors({
|
|
|
113
114
|
INVALID_TYPE,
|
|
114
115
|
MASS_DELETE_STOPPED,
|
|
115
116
|
NOT_A_LEAD,
|
|
117
|
+
PLUGIN_FIELD,
|
|
116
118
|
TAG_LIMIT
|
|
117
119
|
});
|
|
118
120
|
const companiesContract = {
|
|
@@ -17,6 +17,14 @@ var routes_default = {
|
|
|
17
17
|
"path": "/activities/notes"
|
|
18
18
|
}
|
|
19
19
|
} },
|
|
20
|
+
"importNote": { "~orpc": {
|
|
21
|
+
"errorMap": {},
|
|
22
|
+
"meta": {},
|
|
23
|
+
"route": {
|
|
24
|
+
"method": "POST",
|
|
25
|
+
"path": "/activities/notes/import"
|
|
26
|
+
}
|
|
27
|
+
} },
|
|
20
28
|
"react": { "~orpc": {
|
|
21
29
|
"errorMap": {},
|
|
22
30
|
"meta": {},
|
|
@@ -940,6 +948,14 @@ var routes_default = {
|
|
|
940
948
|
"method": "DELETE",
|
|
941
949
|
"path": "/fields/{id}"
|
|
942
950
|
}
|
|
951
|
+
} },
|
|
952
|
+
"setPluginValues": { "~orpc": {
|
|
953
|
+
"errorMap": {},
|
|
954
|
+
"meta": {},
|
|
955
|
+
"route": {
|
|
956
|
+
"method": "POST",
|
|
957
|
+
"path": "/fields/plugin-values"
|
|
958
|
+
}
|
|
943
959
|
} }
|
|
944
960
|
},
|
|
945
961
|
files: {
|
|
@@ -1746,6 +1762,14 @@ var routes_default = {
|
|
|
1746
1762
|
"method": "GET",
|
|
1747
1763
|
"path": "/views/fields"
|
|
1748
1764
|
}
|
|
1765
|
+
} },
|
|
1766
|
+
"matches": { "~orpc": {
|
|
1767
|
+
"errorMap": {},
|
|
1768
|
+
"meta": {},
|
|
1769
|
+
"route": {
|
|
1770
|
+
"method": "POST",
|
|
1771
|
+
"path": "/views/{viewId}/matches"
|
|
1772
|
+
}
|
|
1749
1773
|
} }
|
|
1750
1774
|
},
|
|
1751
1775
|
webhooks: {
|
package/dist/customers.d.ts
CHANGED
|
@@ -290,6 +290,13 @@ export declare const customersContract: {
|
|
|
290
290
|
NOT_A_LEAD: {
|
|
291
291
|
status: number;
|
|
292
292
|
};
|
|
293
|
+
PLUGIN_FIELD: {
|
|
294
|
+
status: number;
|
|
295
|
+
data: z.ZodObject<{
|
|
296
|
+
fieldId: z.ZodString;
|
|
297
|
+
plugin: z.ZodString;
|
|
298
|
+
}, z.core.$strip>;
|
|
299
|
+
};
|
|
293
300
|
TAG_LIMIT: {
|
|
294
301
|
status: number;
|
|
295
302
|
};
|
|
@@ -451,6 +458,13 @@ export declare const customersContract: {
|
|
|
451
458
|
NOT_A_LEAD: {
|
|
452
459
|
status: number;
|
|
453
460
|
};
|
|
461
|
+
PLUGIN_FIELD: {
|
|
462
|
+
status: number;
|
|
463
|
+
data: z.ZodObject<{
|
|
464
|
+
fieldId: z.ZodString;
|
|
465
|
+
plugin: z.ZodString;
|
|
466
|
+
}, z.core.$strip>;
|
|
467
|
+
};
|
|
454
468
|
TAG_LIMIT: {
|
|
455
469
|
status: number;
|
|
456
470
|
};
|
|
@@ -600,6 +614,13 @@ export declare const customersContract: {
|
|
|
600
614
|
NOT_A_LEAD: {
|
|
601
615
|
status: number;
|
|
602
616
|
};
|
|
617
|
+
PLUGIN_FIELD: {
|
|
618
|
+
status: number;
|
|
619
|
+
data: z.ZodObject<{
|
|
620
|
+
fieldId: z.ZodString;
|
|
621
|
+
plugin: z.ZodString;
|
|
622
|
+
}, z.core.$strip>;
|
|
623
|
+
};
|
|
603
624
|
TAG_LIMIT: {
|
|
604
625
|
status: number;
|
|
605
626
|
};
|
|
@@ -776,6 +797,13 @@ export declare const customersContract: {
|
|
|
776
797
|
NOT_A_LEAD: {
|
|
777
798
|
status: number;
|
|
778
799
|
};
|
|
800
|
+
PLUGIN_FIELD: {
|
|
801
|
+
status: number;
|
|
802
|
+
data: z.ZodObject<{
|
|
803
|
+
fieldId: z.ZodString;
|
|
804
|
+
plugin: z.ZodString;
|
|
805
|
+
}, z.core.$strip>;
|
|
806
|
+
};
|
|
779
807
|
TAG_LIMIT: {
|
|
780
808
|
status: number;
|
|
781
809
|
};
|
|
@@ -953,6 +981,13 @@ export declare const customersContract: {
|
|
|
953
981
|
NOT_A_LEAD: {
|
|
954
982
|
status: number;
|
|
955
983
|
};
|
|
984
|
+
PLUGIN_FIELD: {
|
|
985
|
+
status: number;
|
|
986
|
+
data: z.ZodObject<{
|
|
987
|
+
fieldId: z.ZodString;
|
|
988
|
+
plugin: z.ZodString;
|
|
989
|
+
}, z.core.$strip>;
|
|
990
|
+
};
|
|
956
991
|
TAG_LIMIT: {
|
|
957
992
|
status: number;
|
|
958
993
|
};
|
|
@@ -1069,6 +1104,13 @@ export declare const customersContract: {
|
|
|
1069
1104
|
NOT_A_LEAD: {
|
|
1070
1105
|
status: number;
|
|
1071
1106
|
};
|
|
1107
|
+
PLUGIN_FIELD: {
|
|
1108
|
+
status: number;
|
|
1109
|
+
data: z.ZodObject<{
|
|
1110
|
+
fieldId: z.ZodString;
|
|
1111
|
+
plugin: z.ZodString;
|
|
1112
|
+
}, z.core.$strip>;
|
|
1113
|
+
};
|
|
1072
1114
|
TAG_LIMIT: {
|
|
1073
1115
|
status: number;
|
|
1074
1116
|
};
|
|
@@ -1219,6 +1261,13 @@ export declare const customersContract: {
|
|
|
1219
1261
|
NOT_A_LEAD: {
|
|
1220
1262
|
status: number;
|
|
1221
1263
|
};
|
|
1264
|
+
PLUGIN_FIELD: {
|
|
1265
|
+
status: number;
|
|
1266
|
+
data: z.ZodObject<{
|
|
1267
|
+
fieldId: z.ZodString;
|
|
1268
|
+
plugin: z.ZodString;
|
|
1269
|
+
}, z.core.$strip>;
|
|
1270
|
+
};
|
|
1222
1271
|
TAG_LIMIT: {
|
|
1223
1272
|
status: number;
|
|
1224
1273
|
};
|
|
@@ -1337,6 +1386,13 @@ export declare const customersContract: {
|
|
|
1337
1386
|
NOT_A_LEAD: {
|
|
1338
1387
|
status: number;
|
|
1339
1388
|
};
|
|
1389
|
+
PLUGIN_FIELD: {
|
|
1390
|
+
status: number;
|
|
1391
|
+
data: z.ZodObject<{
|
|
1392
|
+
fieldId: z.ZodString;
|
|
1393
|
+
plugin: z.ZodString;
|
|
1394
|
+
}, z.core.$strip>;
|
|
1395
|
+
};
|
|
1340
1396
|
TAG_LIMIT: {
|
|
1341
1397
|
status: number;
|
|
1342
1398
|
};
|
|
@@ -1470,6 +1526,13 @@ export declare const customersContract: {
|
|
|
1470
1526
|
NOT_A_LEAD: {
|
|
1471
1527
|
status: number;
|
|
1472
1528
|
};
|
|
1529
|
+
PLUGIN_FIELD: {
|
|
1530
|
+
status: number;
|
|
1531
|
+
data: z.ZodObject<{
|
|
1532
|
+
fieldId: z.ZodString;
|
|
1533
|
+
plugin: z.ZodString;
|
|
1534
|
+
}, z.core.$strip>;
|
|
1535
|
+
};
|
|
1473
1536
|
TAG_LIMIT: {
|
|
1474
1537
|
status: number;
|
|
1475
1538
|
};
|
|
@@ -1593,6 +1656,13 @@ export declare const customersContract: {
|
|
|
1593
1656
|
NOT_A_LEAD: {
|
|
1594
1657
|
status: number;
|
|
1595
1658
|
};
|
|
1659
|
+
PLUGIN_FIELD: {
|
|
1660
|
+
status: number;
|
|
1661
|
+
data: z.ZodObject<{
|
|
1662
|
+
fieldId: z.ZodString;
|
|
1663
|
+
plugin: z.ZodString;
|
|
1664
|
+
}, z.core.$strip>;
|
|
1665
|
+
};
|
|
1596
1666
|
TAG_LIMIT: {
|
|
1597
1667
|
status: number;
|
|
1598
1668
|
};
|
|
@@ -1710,6 +1780,13 @@ export declare const customersContract: {
|
|
|
1710
1780
|
NOT_A_LEAD: {
|
|
1711
1781
|
status: number;
|
|
1712
1782
|
};
|
|
1783
|
+
PLUGIN_FIELD: {
|
|
1784
|
+
status: number;
|
|
1785
|
+
data: z.ZodObject<{
|
|
1786
|
+
fieldId: z.ZodString;
|
|
1787
|
+
plugin: z.ZodString;
|
|
1788
|
+
}, z.core.$strip>;
|
|
1789
|
+
};
|
|
1713
1790
|
TAG_LIMIT: {
|
|
1714
1791
|
status: number;
|
|
1715
1792
|
};
|
package/dist/customers.js
CHANGED
|
@@ -85,7 +85,7 @@ const CustomerFields = createUpdateSchema(customers, {
|
|
|
85
85
|
}).extend({
|
|
86
86
|
/** Replaces the tags (customer tags only). */
|
|
87
87
|
tagIds: z.array(Id).max(50).optional(),
|
|
88
|
-
/** Sets the given custom fields; `null` clears one. Others stay. */
|
|
88
|
+
/** Sets the given custom fields; `null` clears one. Others stay. A plugin's field: 403 PLUGIN_FIELD. */
|
|
89
89
|
customFields: CustomFieldsPatch.optional()
|
|
90
90
|
});
|
|
91
91
|
const identifies = (value) => Boolean(value.firstName || value.lastName || value.primaryEmail || value.primaryPhone || value.emails?.length || value.phones?.length);
|
|
@@ -127,7 +127,7 @@ const TagChange = z.object({
|
|
|
127
127
|
add: z.array(Id).max(50).default([]),
|
|
128
128
|
remove: z.array(Id).max(50).default([])
|
|
129
129
|
});
|
|
130
|
-
const { INVALID_ACTOR, INVALID_FIELD, INVALID_FIELD_VALUE, INVALID_OWNER, INVALID_TAG, INVALID_TYPE, MASS_DELETE_STOPPED, NOT_A_LEAD, TAG_LIMIT } = ERRORS;
|
|
130
|
+
const { INVALID_ACTOR, INVALID_FIELD, INVALID_FIELD_VALUE, INVALID_OWNER, INVALID_TAG, INVALID_TYPE, MASS_DELETE_STOPPED, NOT_A_LEAD, PLUGIN_FIELD, TAG_LIMIT } = ERRORS;
|
|
131
131
|
/** What these procedures answer with besides the common errors. */
|
|
132
132
|
const base = oc.errors({
|
|
133
133
|
...COMMON_ERRORS,
|
|
@@ -139,6 +139,7 @@ const base = oc.errors({
|
|
|
139
139
|
INVALID_TYPE,
|
|
140
140
|
MASS_DELETE_STOPPED,
|
|
141
141
|
NOT_A_LEAD,
|
|
142
|
+
PLUGIN_FIELD,
|
|
142
143
|
TAG_LIMIT
|
|
143
144
|
});
|
|
144
145
|
const customersContract = {
|
package/dist/db/src/enums.d.ts
CHANGED
|
@@ -5,4 +5,9 @@ export declare const CONDITION_OPERATORS: readonly ['eq', 'neq', 'gt', 'gte', 'l
|
|
|
5
5
|
'within_last', 'more_than_ago', 'within_next',
|
|
6
6
|
/** The day and month fall within the next `amount` days (birthdays, anniversaries), whatever the year. */
|
|
7
7
|
'anniversary_within'];
|
|
8
|
+
/**
|
|
9
|
+
* What a plugin may do in core, granted per organisation when it is
|
|
10
|
+
* installed. A plugin only ever gets the scopes it asked for in its manifest.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PLUGIN_SCOPES: readonly ['activities:write', 'customers:read', 'customers:write', 'audit:write', 'emails:write', 'events:read', 'events:write', 'fields:write', 'files:read', 'files:write', 'live:write', 'notifications:write', 'payments:read', 'payments:write', 'products:read', 'products:write', 'users:read', 'views:read'];
|
|
8
13
|
export declare const DELAY_UNITS: readonly ['minutes', 'hours', 'days'];
|
package/dist/db/src/enums.js
CHANGED
|
@@ -41,6 +41,11 @@ const VIEW_RECORD_TYPES = [
|
|
|
41
41
|
"company_lead",
|
|
42
42
|
"product"
|
|
43
43
|
];
|
|
44
|
+
/**
|
|
45
|
+
* A plugin's list a view can belong to: its record type, `<plugin>:<record>` (`sales:deal`).
|
|
46
|
+
* Core only stores these views; the plugin's own API applies their filter.
|
|
47
|
+
*/
|
|
48
|
+
const PLUGIN_VIEW_TYPE = "^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$";
|
|
44
49
|
const ACTIVITY_TARGETS = ["customer", "company"];
|
|
45
50
|
/** Which activities a record's timeline shows. */
|
|
46
51
|
const TIMELINE_KINDS = [
|
|
@@ -65,13 +70,22 @@ const FILTER_FIELD_TYPES = [
|
|
|
65
70
|
"member",
|
|
66
71
|
"tags"
|
|
67
72
|
];
|
|
68
|
-
/** Where a list filter comes from, for grouping in the picker. */
|
|
73
|
+
/** Where a list filter comes from, for grouping in the picker; `plugin`: a plugin's fields, under its name. */
|
|
69
74
|
const FILTER_FIELD_GROUPS = [
|
|
70
75
|
"fields",
|
|
71
76
|
"lead",
|
|
72
77
|
"custom",
|
|
73
78
|
"company",
|
|
74
|
-
"activity"
|
|
79
|
+
"activity",
|
|
80
|
+
"plugin"
|
|
81
|
+
];
|
|
82
|
+
/** Types of the fields a plugin declares in its manifest (it writes their values). */
|
|
83
|
+
const PLUGIN_FIELD_TYPES = [
|
|
84
|
+
"number",
|
|
85
|
+
"date",
|
|
86
|
+
"text",
|
|
87
|
+
"select",
|
|
88
|
+
"multiselect"
|
|
75
89
|
];
|
|
76
90
|
const FIELD_TYPES = [
|
|
77
91
|
"text",
|
|
@@ -148,6 +162,30 @@ const PLUGIN_TIERS = [
|
|
|
148
162
|
"pro"
|
|
149
163
|
];
|
|
150
164
|
const PLUGIN_STATUSES = ["active", "disabled"];
|
|
165
|
+
/**
|
|
166
|
+
* What a plugin may do in core, granted per organisation when it is
|
|
167
|
+
* installed. A plugin only ever gets the scopes it asked for in its manifest.
|
|
168
|
+
*/
|
|
169
|
+
const PLUGIN_SCOPES = [
|
|
170
|
+
"activities:write",
|
|
171
|
+
"customers:read",
|
|
172
|
+
"customers:write",
|
|
173
|
+
"audit:write",
|
|
174
|
+
"emails:write",
|
|
175
|
+
"events:read",
|
|
176
|
+
"events:write",
|
|
177
|
+
"fields:write",
|
|
178
|
+
"files:read",
|
|
179
|
+
"files:write",
|
|
180
|
+
"live:write",
|
|
181
|
+
"notifications:write",
|
|
182
|
+
"payments:read",
|
|
183
|
+
"payments:write",
|
|
184
|
+
"products:read",
|
|
185
|
+
"products:write",
|
|
186
|
+
"users:read",
|
|
187
|
+
"views:read"
|
|
188
|
+
];
|
|
151
189
|
/** A plugin's billing status on erxes.io: `past_due` while Stripe retries, `canceling` until the period ends. */
|
|
152
190
|
const ENTITLEMENT_STATUSES = [
|
|
153
191
|
"active",
|
|
@@ -311,7 +349,8 @@ const ACTION_FIELD_TYPES = [
|
|
|
311
349
|
"json",
|
|
312
350
|
"custom_field",
|
|
313
351
|
"lead_stage",
|
|
314
|
-
"recipients"
|
|
352
|
+
"recipients",
|
|
353
|
+
"plugin_record"
|
|
315
354
|
];
|
|
316
355
|
const PAYMENT_GATEWAY_KINDS = ["qpay", "test"];
|
|
317
356
|
const PAYMENT_GATEWAY_STATUSES = ["active", "disabled"];
|
|
@@ -331,4 +370,4 @@ const INVOICE_STATUSES = [
|
|
|
331
370
|
];
|
|
332
371
|
const REFUND_STATUSES = ["succeeded", "failed"];
|
|
333
372
|
const REFUND_METHODS = ["gateway", "manual"];
|
|
334
|
-
export { ACTION_FIELD_TYPES, ACTIVITY_TARGETS, ACTOR_TYPES, AUDIT_STREAM_FORMATS, AUDIT_STREAM_STARTS, AUDIT_STREAM_STATUSES, AUTH_TOKEN_PURPOSES, AUTOMATION_FIELD_TYPES, AUTOMATION_STATUSES, AUTOMATION_SUBJECTS, BOOLEAN_STRINGS, CONDITION_MATCHES, CONDITION_OPERATORS, CONTENT_TYPES, CURSOR_MODES, CUSTOMER_CODE_PURPOSES, CUSTOMER_LOGIN_KINDS, CUSTOMER_SEXES, CUSTOMER_STATES, DELAY_UNITS, ENTITLEMENT_STATUSES, EVENT_FAILURE_STATUSES, EXPORT_FORMATS, EXPORT_STATUSES, FIELD_CONTENT_TYPES, FIELD_TYPES, FIELD_VALIDATIONS, FILE_STATUSES, FILE_STORAGES, FILTER_FIELD_GROUPS, FILTER_FIELD_TYPES, FINISHED_RUN_STATUSES, GATEWAY_REFUND_KINDS, IMPORT_MATCH_KEYS, IMPORT_MODES, IMPORT_ROW_ACTIONS, IMPORT_STATUSES, INVOICE_STATUSES, LANGUAGES, LEAD_EVENTS, LEAD_STAGE_KINDS, LIVE_MODES, NOTIFICATION_DELIVERIES, NOTIFICATION_PRIORITIES, ORGANIZATION_STATUSES, PAGE_DIRECTIONS, PAYMENT_GATEWAY_KINDS, PAYMENT_GATEWAY_STATUSES, PLUGIN_ACCESS, PLUGIN_STATUSES, PLUGIN_TIERS, PRODUCT_KINDS, PRODUCT_STATUSES, REENTRY_RULES, REFUND_METHODS, REFUND_STATUSES, RELATIVE_DATE_UNITS, RUN_STATUSES, RUN_STEP_STATUSES, SCHEDULE_INTERVALS, SORT_DIRECTIONS, TIMELINE_KINDS, TRANSFER_FIELD_GROUPS, TRANSFER_RECORD_TYPES, USER_STATUSES, VIEW_RECORD_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_STATUSES };
|
|
373
|
+
export { ACTION_FIELD_TYPES, ACTIVITY_TARGETS, ACTOR_TYPES, AUDIT_STREAM_FORMATS, AUDIT_STREAM_STARTS, AUDIT_STREAM_STATUSES, AUTH_TOKEN_PURPOSES, AUTOMATION_FIELD_TYPES, AUTOMATION_STATUSES, AUTOMATION_SUBJECTS, BOOLEAN_STRINGS, CONDITION_MATCHES, CONDITION_OPERATORS, CONTENT_TYPES, CURSOR_MODES, CUSTOMER_CODE_PURPOSES, CUSTOMER_LOGIN_KINDS, CUSTOMER_SEXES, CUSTOMER_STATES, DELAY_UNITS, ENTITLEMENT_STATUSES, EVENT_FAILURE_STATUSES, EXPORT_FORMATS, EXPORT_STATUSES, FIELD_CONTENT_TYPES, FIELD_TYPES, FIELD_VALIDATIONS, FILE_STATUSES, FILE_STORAGES, FILTER_FIELD_GROUPS, FILTER_FIELD_TYPES, FINISHED_RUN_STATUSES, GATEWAY_REFUND_KINDS, IMPORT_MATCH_KEYS, IMPORT_MODES, IMPORT_ROW_ACTIONS, IMPORT_STATUSES, INVOICE_STATUSES, LANGUAGES, LEAD_EVENTS, LEAD_STAGE_KINDS, LIVE_MODES, NOTIFICATION_DELIVERIES, NOTIFICATION_PRIORITIES, ORGANIZATION_STATUSES, PAGE_DIRECTIONS, PAYMENT_GATEWAY_KINDS, PAYMENT_GATEWAY_STATUSES, PLUGIN_ACCESS, PLUGIN_FIELD_TYPES, PLUGIN_SCOPES, PLUGIN_STATUSES, PLUGIN_TIERS, PLUGIN_VIEW_TYPE, PRODUCT_KINDS, PRODUCT_STATUSES, REENTRY_RULES, REFUND_METHODS, REFUND_STATUSES, RELATIVE_DATE_UNITS, RUN_STATUSES, RUN_STEP_STATUSES, SCHEDULE_INTERVALS, SORT_DIRECTIONS, TIMELINE_KINDS, TRANSFER_FIELD_GROUPS, TRANSFER_RECORD_TYPES, USER_STATUSES, VIEW_RECORD_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_STATUSES };
|
|
@@ -2,6 +2,7 @@ import { FIELD_CONTENT_TYPES, FIELD_TYPES, FIELD_VALIDATIONS } from "../enums.js
|
|
|
2
2
|
import { inList, orgIdColumn, pgTable } from "../table.js";
|
|
3
3
|
import { createdAt, updatedAt } from "./common.js";
|
|
4
4
|
import { organizations } from "./organizations.js";
|
|
5
|
+
import { plugins } from "./plugins.js";
|
|
5
6
|
import { boolean, check, foreignKey, index, integer, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
|
|
6
7
|
import { sql } from "drizzle-orm";
|
|
7
8
|
// ../db/src/schema/fields.ts
|
|
@@ -57,6 +58,11 @@ const fields = pgTable("fields", {
|
|
|
57
58
|
/** Shown where records show (table columns, record panel). */
|
|
58
59
|
isVisible: boolean().default(true).notNull(),
|
|
59
60
|
order: integer().default(0).notNull(),
|
|
61
|
+
/**
|
|
62
|
+
* The plugin that declared it in its manifest and writes its values; members only read it.
|
|
63
|
+
* Null: a member made it.
|
|
64
|
+
*/
|
|
65
|
+
plugin: text(),
|
|
60
66
|
archivedAt: timestamp({
|
|
61
67
|
withTimezone: true,
|
|
62
68
|
mode: "date"
|
|
@@ -64,8 +70,10 @@ const fields = pgTable("fields", {
|
|
|
64
70
|
createdAt: createdAt(),
|
|
65
71
|
updatedAt: updatedAt()
|
|
66
72
|
}, (table) => [
|
|
67
|
-
uniqueIndex("core_fields_org_type_label_key").on(table.orgId, table.contentType, sql`lower(${table.label})`),
|
|
68
|
-
uniqueIndex("core_fields_org_type_code_key").on(table.orgId, table.contentType, sql`lower(${table.code})`).where(sql`${table.code} IS NOT NULL`),
|
|
73
|
+
uniqueIndex("core_fields_org_type_label_key").on(table.orgId, table.contentType, sql`lower(${table.label})`).where(sql`${table.plugin} IS NULL`),
|
|
74
|
+
uniqueIndex("core_fields_org_type_code_key").on(table.orgId, table.contentType, sql`lower(${table.code})`).where(sql`${table.code} IS NOT NULL AND ${table.plugin} IS NULL`),
|
|
75
|
+
uniqueIndex("core_fields_org_type_plugin_code_key").on(table.orgId, table.contentType, table.plugin, table.code).where(sql`${table.plugin} IS NOT NULL`),
|
|
76
|
+
index("core_fields_plugin_idx").on(table.plugin).where(sql`${table.plugin} IS NOT NULL`),
|
|
69
77
|
index("core_fields_org_type_idx").on(table.orgId, table.contentType, table.order),
|
|
70
78
|
index("core_fields_group_id_idx").on(table.groupId),
|
|
71
79
|
foreignKey({
|
|
@@ -73,6 +81,12 @@ const fields = pgTable("fields", {
|
|
|
73
81
|
foreignColumns: [organizations.id],
|
|
74
82
|
name: "core_fields_org_id_fkey"
|
|
75
83
|
}).onDelete("cascade"),
|
|
84
|
+
foreignKey({
|
|
85
|
+
columns: [table.plugin],
|
|
86
|
+
foreignColumns: [plugins.name],
|
|
87
|
+
name: "core_fields_plugin_fkey"
|
|
88
|
+
}).onDelete("cascade"),
|
|
89
|
+
check("core_fields_plugin_code_check", sql`${table.plugin} IS NULL OR ${table.code} IS NOT NULL`),
|
|
76
90
|
foreignKey({
|
|
77
91
|
columns: [table.groupId],
|
|
78
92
|
foreignColumns: [fieldGroups.id],
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { VIEW_RECORD_TYPES } from "../enums.js";
|
|
1
|
+
import { PLUGIN_VIEW_TYPE, VIEW_RECORD_TYPES } from "../enums.js";
|
|
2
2
|
import { inList, orgIdColumn, pgTable } from "../table.js";
|
|
3
3
|
import { createdAt, updatedAt } from "./common.js";
|
|
4
4
|
import { organizations } from "./organizations.js";
|
|
5
5
|
import { boolean, check, foreignKey, index, jsonb, text } from "drizzle-orm/pg-core";
|
|
6
|
+
import { sql } from "drizzle-orm";
|
|
6
7
|
// ../db/src/schema/views.ts
|
|
7
8
|
/**
|
|
8
9
|
* A saved list: a name, a filter (the same condition language automations
|
|
@@ -12,7 +13,8 @@ import { boolean, check, foreignKey, index, jsonb, text } from "drizzle-orm/pg-c
|
|
|
12
13
|
const views = pgTable("views", {
|
|
13
14
|
id: text().primaryKey(),
|
|
14
15
|
orgId: orgIdColumn(),
|
|
15
|
-
|
|
16
|
+
/** One of core's lists, or a plugin's record type (`PLUGIN_VIEW_TYPE`). */
|
|
17
|
+
recordType: text().$type().notNull(),
|
|
16
18
|
name: text().notNull(),
|
|
17
19
|
filter: jsonb().$type(),
|
|
18
20
|
search: text(),
|
|
@@ -25,7 +27,7 @@ const views = pgTable("views", {
|
|
|
25
27
|
updatedAt: updatedAt()
|
|
26
28
|
}, (table) => [
|
|
27
29
|
index("core_views_org_type_idx").on(table.orgId, table.recordType),
|
|
28
|
-
check("core_views_record_type_check", inList(table.recordType, VIEW_RECORD_TYPES)),
|
|
30
|
+
check("core_views_record_type_check", sql`${inList(table.recordType, VIEW_RECORD_TYPES)} OR ${table.recordType} ~ ${sql.raw(`'${PLUGIN_VIEW_TYPE}'`)}`),
|
|
29
31
|
foreignKey({
|
|
30
32
|
columns: [table.orgId],
|
|
31
33
|
foreignColumns: [organizations.id],
|
package/dist/errors.d.ts
CHANGED
|
@@ -282,6 +282,16 @@ export declare const ERRORS: {
|
|
|
282
282
|
fieldId: z.ZodString;
|
|
283
283
|
}, z.core.$strip>>;
|
|
284
284
|
};
|
|
285
|
+
PLUGIN_FIELD: {
|
|
286
|
+
status: number;
|
|
287
|
+
data: z.ZodObject<{
|
|
288
|
+
fieldId: z.ZodString;
|
|
289
|
+
plugin: z.ZodString;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
};
|
|
292
|
+
VIEW_NOT_SHARED: {
|
|
293
|
+
status: number;
|
|
294
|
+
};
|
|
285
295
|
INVALID_CATEGORY: {
|
|
286
296
|
status: number;
|
|
287
297
|
};
|
package/dist/errors.js
CHANGED
|
@@ -130,6 +130,14 @@ const ERRORS = {
|
|
|
130
130
|
status: 409,
|
|
131
131
|
data: z.object({ fieldId: z.string() }).optional()
|
|
132
132
|
},
|
|
133
|
+
PLUGIN_FIELD: {
|
|
134
|
+
status: 403,
|
|
135
|
+
data: z.object({
|
|
136
|
+
fieldId: z.string(),
|
|
137
|
+
plugin: z.string()
|
|
138
|
+
})
|
|
139
|
+
},
|
|
140
|
+
VIEW_NOT_SHARED: { status: 403 },
|
|
133
141
|
INVALID_CATEGORY: { status: 400 },
|
|
134
142
|
CATEGORY_HAS_CHILDREN: { status: 409 },
|
|
135
143
|
INVALID_PRODUCT: { status: 400 },
|
package/dist/events.js
CHANGED
|
@@ -3,7 +3,7 @@ import { events } from "./db/src/schema/events.js";
|
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
4
|
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
5
5
|
import { CursorQuery, Id, cursorPageOf, isoDate } from "./common.js";
|
|
6
|
-
import { ActivityTarget } from "./
|
|
6
|
+
import { ActivityTarget } from "./timelines.js";
|
|
7
7
|
import { AppLink, DedupeKey, EntityType, EventType } from "./platform.js";
|
|
8
8
|
import { oc } from "@orpc/contract";
|
|
9
9
|
import { z } from "zod";
|