@tellescope/schema 1.3.43 → 1.3.48

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/src/schema.ts CHANGED
@@ -128,6 +128,10 @@ import {
128
128
  databaseFieldsValidator,
129
129
  databaseRecordValuesValidator,
130
130
  automationEventsValidator,
131
+ portalPageValidator,
132
+ portalBlocksValidator,
133
+ enduserFormResponsesForEventValidator,
134
+ enduserTasksForEventValidator,
131
135
  } from "@tellescope/validation"
132
136
 
133
137
  import {
@@ -137,6 +141,7 @@ import {
137
141
  ENDUSER_SESSION_TYPE,
138
142
  USER_SESSION_TYPE,
139
143
  } from "@tellescope/constants"
144
+ import { response } from "express"
140
145
 
141
146
  export type RelationshipConstraint<T> = {
142
147
  explanation: string; // human readable, for documentation purposes
@@ -345,7 +350,9 @@ export type CustomActions = {
345
350
  file_download_URL: CustomAction<{ secureName: string }, { downloadURL: string }>,
346
351
  },
347
352
  form_responses: {
348
- prepare_form_response: CustomAction<{ formId: string, enduserId: string, automationStepId?: string }, { accessCode: string, url: string }>,
353
+ prepare_form_response: CustomAction<{ formId: string, enduserId: string, automationStepId?: string, expireAt?: Date },
354
+ { accessCode: string, url: string, response: FormResponse, }>
355
+ ,
349
356
  submit_form_response: CustomAction<{ accessCode: string, responses: FormResponseValue[], automationStepId?: string }, { formResponse: FormResponse }>,
350
357
  info_for_access_code: CustomAction<{ accessCode: string }, {
351
358
  form: Form,
@@ -367,6 +374,7 @@ export type CustomActions = {
367
374
  generate_auth_token: CustomAction<{ id?: string, phone?: string, email?: string, externalId?: string, durationInSeconds?: number }, { authToken: string, enduser: Enduser }>,
368
375
  logout: CustomAction<{ }, { }>,
369
376
  current_session_info: CustomAction<{ }, { enduser: Enduser }>,
377
+ add_to_journey: CustomAction<{ enduserIds: string[], journeyId: string }, { }>,
370
378
  },
371
379
  users: {
372
380
  display_info: CustomAction<{ }, { fname: string, lname: string, id: string }[]>,
@@ -501,6 +509,7 @@ export const schema: SchemaV1 = build_schema({
501
509
  enduserActions: {
502
510
  read: {}, readMany: {},
503
511
  logout: {}, refresh_session: {}, update: {}, current_session_info: {},
512
+ add_to_journey: {},
504
513
  },
505
514
  fields: {
506
515
  ...BuiltInFields,
@@ -608,6 +617,17 @@ export const schema: SchemaV1 = build_schema({
608
617
  // },
609
618
  },
610
619
  customActions: {
620
+ add_to_journey: {
621
+ op: "custom", access: 'update', method: "post",
622
+ name: 'Add to journey',
623
+ path: '/add-endusers-to-journey',
624
+ description: "Adds (or restarts) endusers in a journey",
625
+ parameters: {
626
+ enduserIds: { validator: listOfMongoIdStringValidator, required: true },
627
+ journeyId: { validator: mongoIdStringValidator, required: true },
628
+ },
629
+ returns: { }
630
+ },
611
631
  set_password: {
612
632
  op: "custom", access: 'update', method: "post",
613
633
  name: 'Set enduser password',
@@ -1456,7 +1476,7 @@ export const schema: SchemaV1 = build_schema({
1456
1476
  }],
1457
1477
  },
1458
1478
  defaultActions: {
1459
- create: { adminOnly: true }, delete: { adminOnly: true },
1479
+ create: { adminOnly: true }, createMany: { adminOnly: true }, delete: { adminOnly: true },
1460
1480
  read: {}, readMany: {}, update: { description: "Users can only be updated by self or an organization admin"}
1461
1481
  },
1462
1482
  enduserActions: { display_info: {}, read: {}, readMany: {} },
@@ -1554,6 +1574,7 @@ export const schema: SchemaV1 = build_schema({
1554
1574
  lname: {
1555
1575
  validator: nameValidator,
1556
1576
  },
1577
+ suffixes: { validator: listOfStringsValidatorEmptyOk },
1557
1578
  organization: {
1558
1579
  validator: mongoIdStringValidator,
1559
1580
  updatesDisabled: true,
@@ -2112,10 +2133,12 @@ export const schema: SchemaV1 = build_schema({
2112
2133
  formId: { validator: mongoIdStringValidator, required: true },
2113
2134
  enduserId: { validator: mongoIdStringValidator, required: true },
2114
2135
  automationStepId: { validator: mongoIdStringValidator },
2136
+ expireAt: { validator: dateValidator },
2115
2137
  },
2116
2138
  returns: {
2117
2139
  accessCode: { validator: stringValidator250, required: true },
2118
2140
  url: { validator: stringValidator250, required: true },
2141
+ response: { validator: 'form_response' as any, required: true }
2119
2142
  },
2120
2143
  },
2121
2144
  submit_form_response: {
@@ -2345,6 +2368,15 @@ export const schema: SchemaV1 = build_schema({
2345
2368
  onDependencyDelete: 'setNull',
2346
2369
  }]
2347
2370
  },
2371
+ carePlanId: {
2372
+ validator: mongoIdStringValidator,
2373
+ dependencies: [{
2374
+ dependsOn: ['care_plans'],
2375
+ dependencyField: '_id',
2376
+ relationship: 'foreignKey',
2377
+ onDependencyDelete: 'setNull',
2378
+ }]
2379
+ },
2348
2380
  attendees: {
2349
2381
  validator: listOfUserIndentitiesValidator,
2350
2382
  initializer: () => [],
@@ -2367,6 +2399,9 @@ export const schema: SchemaV1 = build_schema({
2367
2399
  fields: { validator: fieldsValidator },
2368
2400
  numRSVPs: { validator: nonNegNumberValidator },
2369
2401
  image: { validator: stringValidator5000 },
2402
+ sharedContentIds: { validator: listOfMongoIdStringValidatorEmptyOk },
2403
+ enduserFormResponses: { validator: enduserFormResponsesForEventValidator },
2404
+ enduserTasks: { validator: enduserTasksForEventValidator },
2370
2405
  }
2371
2406
  },
2372
2407
  calendar_event_templates: {
@@ -2442,25 +2477,6 @@ export const schema: SchemaV1 = build_schema({
2442
2477
  }
2443
2478
  }
2444
2479
  },
2445
- sequence_automations: {
2446
- info: {},
2447
- constraints: {
2448
- unique: [],
2449
- relationship: [],
2450
- access: []
2451
- },
2452
- defaultActions: DEFAULT_OPERATIONS,
2453
- customActions: { },
2454
- enduserActions: { },
2455
- fields: {
2456
- ...BuiltInFields,
2457
- title: {
2458
- validator: stringValidator250,
2459
- required: true,
2460
- examples: ['Automation Title']
2461
- }
2462
- }
2463
- },
2464
2480
  automation_steps: {
2465
2481
  info: {},
2466
2482
  constraints: {
@@ -2744,6 +2760,9 @@ export const schema: SchemaV1 = build_schema({
2744
2760
  required: true,
2745
2761
  examples: ["Template Name"],
2746
2762
  },
2763
+ category: {
2764
+ validator: stringValidator100,
2765
+ },
2747
2766
  description: {
2748
2767
  validator: stringValidator5000,
2749
2768
  examples: ["Template Subject"],
@@ -3167,6 +3186,121 @@ export const schema: SchemaV1 = build_schema({
3167
3186
  },
3168
3187
  },
3169
3188
  },
3189
+ portal_customizations: {
3190
+ info: {},
3191
+ constraints: {
3192
+ unique: [
3193
+ 'page' // prevents duplicate customizations for the same page (may need to combine with a version number / draft status later to allow drafting)
3194
+ ],
3195
+ relationship: [
3196
+ {
3197
+ explanation: 'One of email or phone is required',
3198
+ evaluate: ({ page, disabled }) => {
3199
+ if (page === 'Home' && disabled)
3200
+ return 'Home page cannot be disabled'
3201
+ }
3202
+ },
3203
+ ],
3204
+ access: []
3205
+ },
3206
+ defaultActions: DEFAULT_OPERATIONS,
3207
+ customActions: { },
3208
+ enduserActions: { readMany: {} },
3209
+ fields: {
3210
+ ...BuiltInFields,
3211
+ title: {
3212
+ validator: stringValidator1000,
3213
+ examples: ['Example Title']
3214
+ },
3215
+ page: {
3216
+ validator: portalPageValidator,
3217
+ required: true,
3218
+ examples: ['Home']
3219
+ },
3220
+ blocks: {
3221
+ required: true,
3222
+ examples: [[]],
3223
+ validator: portalBlocksValidator,
3224
+ },
3225
+ disabled: { validator: booleanValidator },
3226
+ },
3227
+ },
3228
+ enduser_tasks: {
3229
+ info: {},
3230
+ constraints: {
3231
+ unique: [
3232
+ ['enduserId', 'title']
3233
+ ],
3234
+ relationship: [],
3235
+ access: []
3236
+ },
3237
+ defaultActions: DEFAULT_OPERATIONS,
3238
+ customActions: { },
3239
+ enduserActions: { update: {}, read: {}, readMany: {} },
3240
+ fields: {
3241
+ ...BuiltInFields,
3242
+ title: {
3243
+ validator: stringValidator1000,
3244
+ required: true,
3245
+ examples: ['Example Title']
3246
+ },
3247
+ enduserId: {
3248
+ validator: mongoIdStringValidator,
3249
+ examples: [PLACEHOLDER_ID],
3250
+ required: true,
3251
+ dependencies: [{
3252
+ dependsOn: ['endusers'],
3253
+ dependencyField: '_id',
3254
+ relationship: 'foreignKey',
3255
+ onDependencyDelete: 'delete',
3256
+ }]
3257
+ },
3258
+ completedAt: {
3259
+ validator: dateValidator,
3260
+ },
3261
+ description: {
3262
+ validator: stringValidator1000,
3263
+ },
3264
+ },
3265
+ },
3266
+ care_plans: {
3267
+ info: {},
3268
+ constraints: {
3269
+ unique: [
3270
+ ['enduserId', 'title']
3271
+ ],
3272
+ relationship: [],
3273
+ access: []
3274
+ },
3275
+ defaultActions: DEFAULT_OPERATIONS,
3276
+ customActions: { },
3277
+ enduserActions: { read: {}, readMany: {} },
3278
+ fields: {
3279
+ ...BuiltInFields,
3280
+ title: {
3281
+ validator: stringValidator1000,
3282
+ required: true,
3283
+ examples: ['Example Title']
3284
+ },
3285
+ enduserId: {
3286
+ validator: mongoIdStringValidator,
3287
+ examples: [PLACEHOLDER_ID],
3288
+ required: true,
3289
+ dependencies: [{
3290
+ dependsOn: ['endusers'],
3291
+ dependencyField: '_id',
3292
+ relationship: 'foreignKey',
3293
+ onDependencyDelete: 'delete',
3294
+ }]
3295
+ },
3296
+ description: {
3297
+ validator: stringValidator1000,
3298
+ },
3299
+ eventIds: {
3300
+ validator: listOfMongoIdStringValidatorEmptyOk,
3301
+ }
3302
+ },
3303
+ },
3170
3304
  })
3171
3305
 
3172
3306
  // export type SchemaType = typeof schema