@tellescope/schema 0.0.52 → 0.0.55
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/lib/cjs/schema.d.ts +11 -2
- package/lib/cjs/schema.d.ts.map +1 -1
- package/lib/cjs/schema.js +194 -15
- package/lib/cjs/schema.js.map +1 -1
- package/lib/esm/schema.d.ts +11 -2
- package/lib/esm/schema.d.ts.map +1 -1
- package/lib/esm/schema.js +195 -16
- package/lib/esm/schema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/schema.ts +226 -16
package/src/schema.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
UserDisplayInfo,
|
|
33
33
|
Enduser,
|
|
34
|
+
Journey,
|
|
34
35
|
} from "@tellescope/types-client"
|
|
35
36
|
|
|
36
37
|
import {
|
|
@@ -58,7 +59,6 @@ import {
|
|
|
58
59
|
emailEncodingValidator,
|
|
59
60
|
numberToDateValidator,
|
|
60
61
|
SMSMessageValidator,
|
|
61
|
-
chatRoomTopicValidator,
|
|
62
62
|
chatRoomTypeValidator,
|
|
63
63
|
idStringToDateValidator,
|
|
64
64
|
subdomainValidator,
|
|
@@ -82,6 +82,10 @@ import {
|
|
|
82
82
|
intakePhoneValidator,
|
|
83
83
|
formResponsesValidator,
|
|
84
84
|
stringValidator25000,
|
|
85
|
+
automationActionValidator,
|
|
86
|
+
automationEventValidator,
|
|
87
|
+
automationEnduserStatusValidator,
|
|
88
|
+
listOfStringsValidatorEmptyOk,
|
|
85
89
|
} from "@tellescope/validation"
|
|
86
90
|
|
|
87
91
|
import {
|
|
@@ -214,9 +218,9 @@ export type Schema = {
|
|
|
214
218
|
}
|
|
215
219
|
|
|
216
220
|
const sideEffects = {
|
|
217
|
-
|
|
218
|
-
name: "
|
|
219
|
-
description: "
|
|
221
|
+
handleJourneyStateChange: {
|
|
222
|
+
name: "handleJourneyStateChange",
|
|
223
|
+
description: "Handles change in an enduser's journey"
|
|
220
224
|
},
|
|
221
225
|
sendEmails: {
|
|
222
226
|
name: "sendEmails",
|
|
@@ -265,6 +269,7 @@ export type CustomActions = {
|
|
|
265
269
|
},
|
|
266
270
|
journeys: {
|
|
267
271
|
update_state: CustomAction<{ updates: JourneyState, id: string, name: string }, {}>,
|
|
272
|
+
delete_states: CustomAction<{ id: string, states: string[] }, { updated: Journey }>,
|
|
268
273
|
},
|
|
269
274
|
endusers: {
|
|
270
275
|
set_password: CustomAction<{ id: string, password: string }, { }>,
|
|
@@ -296,6 +301,7 @@ export type CustomActions = {
|
|
|
296
301
|
webhooks: {
|
|
297
302
|
configure: CustomAction<{ url: string, secret: string, subscriptions?: WebhookSubscriptionsType }, { }>,
|
|
298
303
|
update: CustomAction<{ url?: string, secret?: string, subscriptionUpdates?: WebhookSubscriptionsType }, { }>,
|
|
304
|
+
send_automation_webhook: CustomAction<{ message: string }, { }>,
|
|
299
305
|
},
|
|
300
306
|
}
|
|
301
307
|
|
|
@@ -328,8 +334,8 @@ export const schema: SchemaV1 = build_schema({
|
|
|
328
334
|
endusers: {
|
|
329
335
|
info: {
|
|
330
336
|
sideEffects: {
|
|
331
|
-
create: [sideEffects.
|
|
332
|
-
update: [sideEffects.
|
|
337
|
+
create: [sideEffects.handleJourneyStateChange],
|
|
338
|
+
update: [sideEffects.handleJourneyStateChange],
|
|
333
339
|
}
|
|
334
340
|
},
|
|
335
341
|
constraints: {
|
|
@@ -407,7 +413,7 @@ export const schema: SchemaV1 = build_schema({
|
|
|
407
413
|
]
|
|
408
414
|
},
|
|
409
415
|
tags: {
|
|
410
|
-
validator:
|
|
416
|
+
validator: listOfStringsValidatorEmptyOk,
|
|
411
417
|
},
|
|
412
418
|
fields: {
|
|
413
419
|
validator: fieldsValidator,
|
|
@@ -573,7 +579,7 @@ export const schema: SchemaV1 = build_schema({
|
|
|
573
579
|
dependsOn: ['endusers'],
|
|
574
580
|
dependencyField: '_id',
|
|
575
581
|
relationship: 'foreignKey',
|
|
576
|
-
onDependencyDelete: '
|
|
582
|
+
onDependencyDelete: 'delete',
|
|
577
583
|
}]
|
|
578
584
|
},
|
|
579
585
|
type: {
|
|
@@ -648,13 +654,24 @@ export const schema: SchemaV1 = build_schema({
|
|
|
648
654
|
op: 'custom', access: 'update', method: "patch",
|
|
649
655
|
name: 'Update State',
|
|
650
656
|
path: '/journey/:id/state/:name',
|
|
651
|
-
description: "Updates a state in a journey.
|
|
657
|
+
description: "Updates a state in a journey. Endusers and automations are updated automatically.",
|
|
652
658
|
parameters: {
|
|
653
659
|
id: { validator: mongoIdStringValidator },
|
|
654
660
|
name: { validator: stringValidator100 },
|
|
655
|
-
updates: { validator: journeyStateValidator },
|
|
661
|
+
updates: { validator: journeyStateValidator, required: true },
|
|
656
662
|
},
|
|
657
663
|
returns: {},
|
|
664
|
+
},
|
|
665
|
+
delete_states: {
|
|
666
|
+
op: 'custom', access: 'update', method: "delete",
|
|
667
|
+
name: 'Delete States',
|
|
668
|
+
path: '/journey/:id/states',
|
|
669
|
+
description: "Deletes states in a journey. Endusers and automations are updated automatically.",
|
|
670
|
+
parameters: {
|
|
671
|
+
id: { validator: mongoIdStringValidator, required: true },
|
|
672
|
+
states: { validator: listOfStringsValidator, required: true },
|
|
673
|
+
},
|
|
674
|
+
returns: { updated: 'journey' as any },
|
|
658
675
|
}
|
|
659
676
|
},
|
|
660
677
|
},
|
|
@@ -742,7 +759,7 @@ export const schema: SchemaV1 = build_schema({
|
|
|
742
759
|
dependsOn: ['endusers'],
|
|
743
760
|
dependencyField: '_id',
|
|
744
761
|
relationship: 'foreignKey',
|
|
745
|
-
onDependencyDelete: '
|
|
762
|
+
onDependencyDelete: 'delete',
|
|
746
763
|
}]
|
|
747
764
|
},
|
|
748
765
|
businessUserId: {
|
|
@@ -863,7 +880,7 @@ export const schema: SchemaV1 = build_schema({
|
|
|
863
880
|
dependsOn: ['endusers'],
|
|
864
881
|
dependencyField: '_id',
|
|
865
882
|
relationship: 'foreignKey',
|
|
866
|
-
onDependencyDelete: '
|
|
883
|
+
onDependencyDelete: 'delete',
|
|
867
884
|
}]
|
|
868
885
|
},
|
|
869
886
|
businessUserId: {
|
|
@@ -922,10 +939,10 @@ export const schema: SchemaV1 = build_schema({
|
|
|
922
939
|
initializer: () => 'internal' as ChatRoomType
|
|
923
940
|
},
|
|
924
941
|
topic: {
|
|
925
|
-
validator:
|
|
942
|
+
validator: stringValidator100,
|
|
926
943
|
},
|
|
927
|
-
topicId: {
|
|
928
|
-
validator:
|
|
944
|
+
topicId: {
|
|
945
|
+
validator: stringValidator100,
|
|
929
946
|
},
|
|
930
947
|
description: {
|
|
931
948
|
validator: stringValidator250,
|
|
@@ -1257,7 +1274,15 @@ export const schema: SchemaV1 = build_schema({
|
|
|
1257
1274
|
validator: fileTypeValidator,
|
|
1258
1275
|
required: true
|
|
1259
1276
|
},
|
|
1260
|
-
enduserId: {
|
|
1277
|
+
enduserId: {
|
|
1278
|
+
validator: mongoIdStringValidator ,
|
|
1279
|
+
dependencies: [{
|
|
1280
|
+
dependsOn: ['endusers'],
|
|
1281
|
+
dependencyField: '_id',
|
|
1282
|
+
relationship: 'foreignKey',
|
|
1283
|
+
onDependencyDelete: 'setNull',
|
|
1284
|
+
}]
|
|
1285
|
+
},
|
|
1261
1286
|
},
|
|
1262
1287
|
returns: {
|
|
1263
1288
|
presignedUpload: {
|
|
@@ -1310,6 +1335,12 @@ export const schema: SchemaV1 = build_schema({
|
|
|
1310
1335
|
validator: mongoIdStringValidator,
|
|
1311
1336
|
required: true,
|
|
1312
1337
|
examples: [PLACEHOLDER_ID],
|
|
1338
|
+
dependencies: [{
|
|
1339
|
+
dependsOn: ['endusers'],
|
|
1340
|
+
dependencyField: '_id',
|
|
1341
|
+
relationship: 'foreignKey',
|
|
1342
|
+
onDependencyDelete: 'setNull',
|
|
1343
|
+
}]
|
|
1313
1344
|
},
|
|
1314
1345
|
chatRoomId: {
|
|
1315
1346
|
validator: mongoIdStringValidator,
|
|
@@ -1439,6 +1470,12 @@ export const schema: SchemaV1 = build_schema({
|
|
|
1439
1470
|
validator: mongoIdStringValidator,
|
|
1440
1471
|
required: true,
|
|
1441
1472
|
examples: [PLACEHOLDER_ID],
|
|
1473
|
+
dependencies: [{
|
|
1474
|
+
dependsOn: ['endusers'],
|
|
1475
|
+
dependencyField: '_id',
|
|
1476
|
+
relationship: 'foreignKey',
|
|
1477
|
+
onDependencyDelete: 'delete',
|
|
1478
|
+
}]
|
|
1442
1479
|
},
|
|
1443
1480
|
ticketId: {
|
|
1444
1481
|
validator: mongoIdStringValidator,
|
|
@@ -1548,6 +1585,14 @@ export const schema: SchemaV1 = build_schema({
|
|
|
1548
1585
|
For a given webhook, relatedRecords may be empty, or may not include all related ids. In such cases, you'll need to query against the Tellescope API for an up-to-date reference.
|
|
1549
1586
|
|
|
1550
1587
|
Currently supported models for Webhooks: ${Object.keys(WEBHOOK_MODELS).join(', ')}
|
|
1588
|
+
|
|
1589
|
+
You can also handle webhooks from automations in Tellescope, which have a simpler format: <pre>{
|
|
1590
|
+
type: 'automation'
|
|
1591
|
+
message: string,
|
|
1592
|
+
timestamp: string,
|
|
1593
|
+
integrity: string,
|
|
1594
|
+
}</pre>
|
|
1595
|
+
In this case, integrity is a simple sha256 hash of message + timestamp + secret
|
|
1551
1596
|
`
|
|
1552
1597
|
},
|
|
1553
1598
|
constraints: {
|
|
@@ -1580,6 +1625,16 @@ export const schema: SchemaV1 = build_schema({
|
|
|
1580
1625
|
},
|
|
1581
1626
|
returns: {},
|
|
1582
1627
|
},
|
|
1628
|
+
send_automation_webhook: {
|
|
1629
|
+
op: "custom", access: 'create', method: "post",
|
|
1630
|
+
name: 'Send Automation Webhook',
|
|
1631
|
+
path: '/send-automation-webhook',
|
|
1632
|
+
description: "Sends a webhook with the automations format, useful for testing automation integrations",
|
|
1633
|
+
parameters: {
|
|
1634
|
+
message: { validator: stringValidator5000, required: true },
|
|
1635
|
+
},
|
|
1636
|
+
returns: {},
|
|
1637
|
+
},
|
|
1583
1638
|
},
|
|
1584
1639
|
enduserActions: {},
|
|
1585
1640
|
fields: {
|
|
@@ -1642,6 +1697,161 @@ export const schema: SchemaV1 = build_schema({
|
|
|
1642
1697
|
}
|
|
1643
1698
|
}
|
|
1644
1699
|
},
|
|
1700
|
+
sequence_automations: {
|
|
1701
|
+
info: {},
|
|
1702
|
+
constraints: {
|
|
1703
|
+
unique: [],
|
|
1704
|
+
relationship: [],
|
|
1705
|
+
access: []
|
|
1706
|
+
},
|
|
1707
|
+
defaultActions: DEFAULT_OPERATIONS,
|
|
1708
|
+
customActions: { },
|
|
1709
|
+
enduserActions: { },
|
|
1710
|
+
fields: {
|
|
1711
|
+
...BuiltInFields,
|
|
1712
|
+
title: {
|
|
1713
|
+
validator: stringValidator250,
|
|
1714
|
+
required: true,
|
|
1715
|
+
examples: ['Automation Title']
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1719
|
+
event_automations: {
|
|
1720
|
+
info: {},
|
|
1721
|
+
constraints: {
|
|
1722
|
+
unique: [],
|
|
1723
|
+
relationship: [
|
|
1724
|
+
{
|
|
1725
|
+
explanation: 'updateStateForJourney cannot have the same info as enterState or leaveState events',
|
|
1726
|
+
evaluate: ({ action, event }) => {
|
|
1727
|
+
if (action?.type === 'updateStateForJourney')
|
|
1728
|
+
if (event?.type === 'enterState' &&
|
|
1729
|
+
action.info?.journeyId === event.info.journeyId &&
|
|
1730
|
+
action.info?.state === event.info.state
|
|
1731
|
+
) {
|
|
1732
|
+
return "updateStateForJourney cannot have the same journey and state as the enterState event"
|
|
1733
|
+
}
|
|
1734
|
+
else if (event?.type === 'leaveState' &&
|
|
1735
|
+
action.info?.journeyId === event.info.journeyId &&
|
|
1736
|
+
action.info?.state === event.info.state
|
|
1737
|
+
) {
|
|
1738
|
+
return "updateStateForJourney cannot have the same journey and state as the leaveState event"
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
explanation: 'Event and action cannot both be shared by an existing event automation (no duplicates)',
|
|
1744
|
+
evaluate: () => {} // implemented in routing.ts
|
|
1745
|
+
},
|
|
1746
|
+
],
|
|
1747
|
+
access: []
|
|
1748
|
+
},
|
|
1749
|
+
defaultActions: DEFAULT_OPERATIONS,
|
|
1750
|
+
customActions: { },
|
|
1751
|
+
enduserActions: { },
|
|
1752
|
+
fields: {
|
|
1753
|
+
...BuiltInFields,
|
|
1754
|
+
journeyId: {
|
|
1755
|
+
validator: mongoIdStringValidator,
|
|
1756
|
+
required: true,
|
|
1757
|
+
examples: [PLACEHOLDER_ID],
|
|
1758
|
+
dependencies: [{
|
|
1759
|
+
dependsOn: ['journeys'],
|
|
1760
|
+
dependencyField: '_id',
|
|
1761
|
+
relationship: 'foreignKey',
|
|
1762
|
+
onDependencyDelete: 'delete',
|
|
1763
|
+
}]
|
|
1764
|
+
},
|
|
1765
|
+
event: {
|
|
1766
|
+
validator: automationEventValidator,
|
|
1767
|
+
examples: [{
|
|
1768
|
+
type: "enterState",
|
|
1769
|
+
info: {
|
|
1770
|
+
journeyId: PLACEHOLDER_ID,
|
|
1771
|
+
state: 'state',
|
|
1772
|
+
},
|
|
1773
|
+
}],
|
|
1774
|
+
required: true,
|
|
1775
|
+
},
|
|
1776
|
+
action: {
|
|
1777
|
+
validator: automationActionValidator,
|
|
1778
|
+
required: true,
|
|
1779
|
+
examples: [{
|
|
1780
|
+
type: "sendEmail",
|
|
1781
|
+
info: {
|
|
1782
|
+
senderId: PLACEHOLDER_ID,
|
|
1783
|
+
templateId: PLACEHOLDER_ID,
|
|
1784
|
+
},
|
|
1785
|
+
}]
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
},
|
|
1789
|
+
automation_endusers: {
|
|
1790
|
+
info: {},
|
|
1791
|
+
constraints: {
|
|
1792
|
+
unique: ['enduserId'],
|
|
1793
|
+
relationship: [],
|
|
1794
|
+
access: []
|
|
1795
|
+
},
|
|
1796
|
+
defaultActions: DEFAULT_OPERATIONS,
|
|
1797
|
+
customActions: { },
|
|
1798
|
+
enduserActions: { },
|
|
1799
|
+
fields: {
|
|
1800
|
+
...BuiltInFields,
|
|
1801
|
+
automationId: {
|
|
1802
|
+
validator: mongoIdStringValidator,
|
|
1803
|
+
required: true,
|
|
1804
|
+
examples: [PLACEHOLDER_ID],
|
|
1805
|
+
|
|
1806
|
+
// todo: add or replace with separate depency, when automations model migrated to this schema
|
|
1807
|
+
dependencies: [{
|
|
1808
|
+
dependsOn: ['event_automations'],
|
|
1809
|
+
dependencyField: '_id',
|
|
1810
|
+
relationship: 'foreignKey',
|
|
1811
|
+
onDependencyDelete: 'delete',
|
|
1812
|
+
}]
|
|
1813
|
+
},
|
|
1814
|
+
enduserId: {
|
|
1815
|
+
validator: mongoIdStringValidator,
|
|
1816
|
+
required: true,
|
|
1817
|
+
examples: [PLACEHOLDER_ID],
|
|
1818
|
+
dependencies: [{
|
|
1819
|
+
dependsOn: ['endusers'],
|
|
1820
|
+
dependencyField: '_id',
|
|
1821
|
+
relationship: 'foreignKey',
|
|
1822
|
+
onDependencyDelete: 'delete',
|
|
1823
|
+
}]
|
|
1824
|
+
},
|
|
1825
|
+
event: {
|
|
1826
|
+
validator: automationEventValidator,
|
|
1827
|
+
examples: [{
|
|
1828
|
+
type: "enterState",
|
|
1829
|
+
info: {
|
|
1830
|
+
journeyId: PLACEHOLDER_ID,
|
|
1831
|
+
state: 'state',
|
|
1832
|
+
},
|
|
1833
|
+
}],
|
|
1834
|
+
required: true,
|
|
1835
|
+
},
|
|
1836
|
+
action: {
|
|
1837
|
+
validator: automationActionValidator,
|
|
1838
|
+
required: true,
|
|
1839
|
+
examples: [{
|
|
1840
|
+
type: "sendEmail",
|
|
1841
|
+
info: {
|
|
1842
|
+
senderId: PLACEHOLDER_ID,
|
|
1843
|
+
templateId: PLACEHOLDER_ID,
|
|
1844
|
+
},
|
|
1845
|
+
}]
|
|
1846
|
+
},
|
|
1847
|
+
status: {
|
|
1848
|
+
validator: automationEnduserStatusValidator,
|
|
1849
|
+
required: true,
|
|
1850
|
+
examples: ['active']
|
|
1851
|
+
},
|
|
1852
|
+
stepNumber: { validator: nonNegNumberValidator },
|
|
1853
|
+
}
|
|
1854
|
+
},
|
|
1645
1855
|
})
|
|
1646
1856
|
|
|
1647
1857
|
// export type SchemaType = typeof schema
|