@tellescope/schema 1.4.46 → 1.4.49

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
@@ -5,6 +5,7 @@ import {
5
5
  ObjectId,
6
6
  ModelName,
7
7
  User,
8
+ AppointmentBookingPage,
8
9
  } from "@tellescope/types-server"
9
10
  import {
10
11
  ErrorInfo,
@@ -33,9 +34,11 @@ import {
33
34
  AvailabilityBlock,
34
35
  WithLinkOpenTrackingIds,
35
36
  CommunicationsChannel,
37
+ AppointmentTerm,
36
38
  } from "@tellescope/types-models"
37
39
 
38
40
  import {
41
+ AppointmentBookingPage as AppointmentBookingPageClient,
39
42
  UserDisplayInfo,
40
43
  Enduser,
41
44
  Journey,
@@ -48,6 +51,9 @@ import {
48
51
  CalendarEvent,
49
52
  Organization,
50
53
  User as UserClient,
54
+ AppointmentLocation,
55
+ CalendarEventTemplate,
56
+ Product,
51
57
  } from "@tellescope/types-client"
52
58
 
53
59
  import {
@@ -156,6 +162,13 @@ import {
156
162
  sharedWithOrganizationIdsValidator,
157
163
  stringValidator1000Optional,
158
164
  tellescopeGenderValidator,
165
+ appointmentTermsValidator,
166
+ currencyValidator,
167
+ paymentProcessorValidator,
168
+ purchaseCreditValueValidator,
169
+ costValidator,
170
+ integrationTitleValidator,
171
+ IntegrationsTitleType,
159
172
  } from "@tellescope/validation"
160
173
 
161
174
  import {
@@ -468,6 +481,8 @@ export type CustomActions = {
468
481
  integrations: {
469
482
  generate_google_auth_url: CustomAction<{ }, { authUrl: string, }>,
470
483
  disconnect_google_integration: CustomAction<{}, {}>,
484
+ generate_oauth2_auth_url: CustomAction<{ integration: IntegrationsTitleType }, { authUrl: string, }>,
485
+ disconnect_oauth2_integration: CustomAction<{ integration: IntegrationsTitleType }, {}>,
471
486
  refresh_oauth2_session: CustomAction<{ title: string }, { access_token: string, expiry_date: number }>,
472
487
  },
473
488
  emails: {
@@ -477,12 +492,14 @@ export type CustomActions = {
477
492
  get_events_for_user: CustomAction<{ userId: string, from: Date, to?: Date, limit?: number }, { events: CalendarEvent[] }>,
478
493
  generate_meeting_link: CustomAction<{ eventId: string, enduserId: string }, { link: string }>,
479
494
  get_appointment_availability: CustomAction<{
480
- from: Date, calendarEventTemplateId: string, to?: Date, restrictedByState?: boolean, limit?: number,
495
+ from: Date, calendarEventTemplateId: string, to?: Date, restrictedByState?: boolean, limit?: number, locationId?: string,
496
+ businessId?: string, // for accessing while unauthenticated
481
497
  }, {
482
498
  availabilityBlocks: AvailabilityBlock[],
483
499
  }>,
484
500
  book_appointment: CustomAction<{
485
- userId: string, startTime: Date, calendarEventTemplateId: string,
501
+ userId: string, startTime: Date, calendarEventTemplateId: string, locationId?: string,
502
+ agreedToTerms?: AppointmentTerm[],
486
503
  }, {
487
504
  createdEvent: CalendarEvent,
488
505
  }>,
@@ -526,6 +543,29 @@ export type PublicActions = {
526
543
  // organizationIds?: string[]
527
544
  }, { accessCode: string, authToken: string, url: string, path: string }>,
528
545
  },
546
+ calendar_events: {
547
+ session_for_public_appointment_booking: CustomAction<{
548
+ fname?: string,
549
+ lname?: string,
550
+ dateOfBirth?: string,
551
+ email: string,
552
+ phone?: string,
553
+ calendarEventTemplateId: string,
554
+ businessId: string,
555
+ }, { authToken: string }>,
556
+ details_for_appointment_booking_page: CustomAction<
557
+ {
558
+ appointmentBookingPageId: string,
559
+ businessId: string,
560
+ },
561
+ {
562
+ appointmentBookingPage: AppointmentBookingPageClient,
563
+ locations: AppointmentLocation[],
564
+ calendarEventTemplates: CalendarEventTemplate[],
565
+ products: Product[],
566
+ }
567
+ >,
568
+ },
529
569
  }
530
570
 
531
571
  export type SchemaV1 = Schema & {
@@ -964,21 +1004,32 @@ export const schema: SchemaV1 = build_schema({
964
1004
  op: 'custom', access: 'create', method: 'post',
965
1005
  path: '/generate-google-auth-url',
966
1006
  name: 'Generates a link to create a Google integration with Tellescope',
967
- description: "",
968
- parameters: {},
1007
+ description: "", parameters: {},
1008
+ returns: { authUrl: { validator: stringValidator, required: true }, }
1009
+ },
1010
+ disconnect_google_integration: {
1011
+ op: 'custom', access: 'create', method: 'post',
1012
+ path: '/generate-square-auth-url',
1013
+ name: 'Generates a link to create a Square integration with Tellescope',
1014
+ description: "", parameters: {},
1015
+ returns: { authUrl: { validator: stringValidator, required: true }, }
1016
+ },
1017
+ generate_oauth2_auth_url: {
1018
+ op: 'custom', access: 'delete', method: 'post',
1019
+ path: '/generate-oauth2-auth-url',
1020
+ description: "",
1021
+ parameters: { integration: { validator: integrationTitleValidator, }},
969
1022
  returns: {
970
- authUrl: {
971
- validator: stringValidator,
972
- required: true
973
- },
1023
+ authUrl: { validator: stringValidator, required: true },
1024
+ state: { validator: stringValidator, required: true },
974
1025
  }
975
1026
  },
976
- disconnect_google_integration: {
1027
+ disconnect_oauth2_integration: {
977
1028
  op: 'custom', access: 'delete', method: 'post',
978
- path: '/disconnect-google-integration',
979
- name: 'Disconnects an integration with Google',
980
- description: "",
981
- parameters: {},
1029
+ path: '/disconnect-oauth2-integration',
1030
+ name: 'Disconnects an integration with Square',
1031
+ refresh_oauth2_sessiondescription: "",
1032
+ parameters: { integration: { validator: integrationTitleValidator }},
982
1033
  returns: {}
983
1034
  },
984
1035
  refresh_oauth2_session: {
@@ -1705,6 +1756,9 @@ export const schema: SchemaV1 = build_schema({
1705
1756
  validator: fieldsValidator,
1706
1757
  redactions: ['enduser'],
1707
1758
  },
1759
+ unredactedFields: {
1760
+ validator: fieldsValidator,
1761
+ },
1708
1762
  username: {
1709
1763
  validator: subdomainValidator,
1710
1764
  readonly: true, // able to set once, then not change (for now, due to email configuration)
@@ -2536,9 +2590,11 @@ export const schema: SchemaV1 = build_schema({
2536
2590
  parameters: {
2537
2591
  calendarEventTemplateId: { validator: mongoIdStringValidator, required: true },
2538
2592
  from: { validator: dateValidator, required: true },
2593
+ locationId: { validator: mongoIdStringValidator },
2539
2594
  restrictedByState: { validator: booleanValidator },
2540
2595
  to: { validator: dateValidator },
2541
2596
  limit: { validator: nonNegNumberValidator },
2597
+ businessId: { validator: mongoIdStringValidator }, // required for unauthenticated access
2542
2598
  },
2543
2599
  returns: {
2544
2600
  availabilityBlocks: { validator: availabilityBlocksValidator, required: true }
@@ -2553,13 +2609,52 @@ export const schema: SchemaV1 = build_schema({
2553
2609
  calendarEventTemplateId: { validator: mongoIdStringValidator, required: true },
2554
2610
  userId: { validator: mongoIdStringValidator, required: true },
2555
2611
  startTime: { validator: dateValidator, required: true },
2612
+ locationId: { validator: mongoIdStringValidator },
2613
+ agreedToTerms: { validator: appointmentTermsValidator },
2556
2614
  },
2557
2615
  returns: {
2558
2616
  createdEvent: { validator: 'calenar_event' as any },
2559
2617
  },
2560
2618
  },
2561
2619
  },
2562
- enduserActions: { read: {}, readMany: {}, get_appointment_availability: {}, book_appointment: {} },
2620
+ publicActions: {
2621
+ session_for_public_appointment_booking: {
2622
+ op: "custom", access: 'create', method: "post",
2623
+ path: '/session-for-public-appointment-booking',
2624
+ name: 'Generate Session for Public Appointment Booking',
2625
+ description: "Generates a session for booking an appointment",
2626
+ parameters: {
2627
+ email: { validator: emailValidator, required: true },
2628
+ calendarEventTemplateId: { validator: mongoIdStringValidator, required: true },
2629
+ businessId: { validator: mongoIdStringValidator, required: true }, // organizationIds can be pulled from the corresponding appointment
2630
+ dateOfBirth: { validator: stringValidator },
2631
+ phone: { validator: phoneValidator },
2632
+ fname: { validator: nameValidator },
2633
+ lname: { validator: nameValidator },
2634
+ },
2635
+ returns: {
2636
+ authToken: { validator: stringValidator250, required: true },
2637
+ },
2638
+ },
2639
+ details_for_appointment_booking_page: {
2640
+ op: "custom", access: 'read', method: "get",
2641
+ path: '/details-for-appointment-booking-page',
2642
+ name: 'Gets Appointment Booking Details',
2643
+ description: "Gets details related to booking an appointment",
2644
+ parameters: {
2645
+ appointmentBookingPageId: { validator: mongoIdStringValidator, required: true },
2646
+ businessId: { validator: mongoIdStringValidator, required: true }, // organizationIds can be pulled from the corresponding appointment
2647
+ },
2648
+ returns: {
2649
+ appointmentBookingPage: { validator: 'appointment_booking_page' as any, required: true },
2650
+ calendarEventTemplates: { validator: 'calendar_event_templates' as any, required: true },
2651
+ locations: { validator: 'appointment_locations' as any, required: true },
2652
+ products: { validator: 'products' as any, required: true },
2653
+
2654
+ },
2655
+ }
2656
+ },
2657
+ enduserActions: { read: {}, readMany: {}, get_appointment_availability: {}, book_appointment: {}, session_for_public_appointment_booking: {} },
2563
2658
  fields: {
2564
2659
  ...BuiltInFields,
2565
2660
  title: {
@@ -2577,8 +2672,10 @@ export const schema: SchemaV1 = build_schema({
2577
2672
  examples: [100],
2578
2673
  required: true,
2579
2674
  },
2675
+ locationId: { validator: mongoIdStringValidator },
2580
2676
  type: { validator: stringValidator100 },
2581
2677
  description: { validator: stringValidator5000 },
2678
+ agreedToTerms: { validator: appointmentTermsValidator },
2582
2679
  meetingId: { validator: mongoIdStringValidator, readonly: true },
2583
2680
  meetingStatus: { validator: meetingStatusValidator },
2584
2681
  attachments: { validator: listOfGenericAttachmentsValidator },
@@ -2654,6 +2751,7 @@ export const schema: SchemaV1 = build_schema({
2654
2751
  examples: [100],
2655
2752
  required: true,
2656
2753
  },
2754
+ productIds: { validator: listOfMongoIdStringValidatorEmptyOk },
2657
2755
  type: { validator: stringValidator100 },
2658
2756
  description: { validator: stringValidator5000 },
2659
2757
  reminders: {
@@ -2665,6 +2763,7 @@ export const schema: SchemaV1 = build_schema({
2665
2763
  enableSelfScheduling: { validator: booleanValidator },
2666
2764
  restrictedByState: { validator: booleanValidator },
2667
2765
  image: { validator: stringValidator5000 },
2766
+ // confirmationSenderId: { validator: mongoIdStringValidator },
2668
2767
  }
2669
2768
  },
2670
2769
  calendar_event_RSVPs: {
@@ -3432,6 +3531,10 @@ export const schema: SchemaV1 = build_schema({
3432
3531
  required: true,
3433
3532
  examples: ["subdomain"],
3434
3533
  },
3534
+ limits: {
3535
+ validator: organizationLimitsValidator,
3536
+ readonly: true, // to be set by Tellescope super admin only
3537
+ },
3435
3538
  parentOrganizationId: { validator: mongoIdStringValidator },
3436
3539
  subscriptionExpiresAt: { validator: dateValidator },
3437
3540
  subscriptionPeriod: { validator: numberValidator },
@@ -3445,10 +3548,7 @@ export const schema: SchemaV1 = build_schema({
3445
3548
  customPortalURL: { validator: stringValidator250 },
3446
3549
  portalSettings: { validator: portalSettingsValidator },
3447
3550
  settings: { validator: organizationSettingsValidator },
3448
- limits: {
3449
- validator: organizationLimitsValidator,
3450
- readonly: true, // to be set by Tellescope super admin only
3451
- },
3551
+ timezone: { validator: timezoneValidator },
3452
3552
  },
3453
3553
  },
3454
3554
  databases: {
@@ -3656,6 +3756,182 @@ export const schema: SchemaV1 = build_schema({
3656
3756
  }
3657
3757
  }
3658
3758
  },
3759
+ appointment_booking_pages: {
3760
+ info: {},
3761
+ constraints: {
3762
+ unique: ['title'],
3763
+ relationship: [],
3764
+ },
3765
+ defaultActions: DEFAULT_OPERATIONS,
3766
+ customActions: {},
3767
+ enduserActions: {},
3768
+ fields: {
3769
+ ...BuiltInFields,
3770
+ title: {
3771
+ validator: stringValidator100,
3772
+ required: true,
3773
+ examples: ["Appointment Booking Title"]
3774
+ },
3775
+ calendarEventTemplateIds: {
3776
+ validator: listOfMongoIdStringValidator,
3777
+ required: true,
3778
+ examples: [[PLACEHOLDER_ID]]
3779
+ },
3780
+ locationIds: {
3781
+ validator: listOfMongoIdStringValidatorEmptyOk,
3782
+ required: true,
3783
+ examples: [[PLACEHOLDER_ID]]
3784
+ },
3785
+ terms: { validator: appointmentTermsValidator },
3786
+ endDate: { validator: dateValidator },
3787
+ startDate: { validator: dateValidator },
3788
+ backgroundColor: { validator: stringValidator100 },
3789
+ primaryColor: { validator: stringValidator100 },
3790
+ secondaryColor: { validator: stringValidator100 },
3791
+ intakeTitle: { validator: stringValidator1000 },
3792
+ intakeDescription: { validator: stringValidator1000 },
3793
+ thankYouTitle: { validator: stringValidator1000 },
3794
+ thankYouDescription: { validator: stringValidator1000 },
3795
+ thankYouHeaderImageURL: { validator: stringValidator1000 },
3796
+ thankYouMainImageURL: { validator: stringValidator1000 },
3797
+ }
3798
+ },
3799
+ appointment_locations: {
3800
+ info: {},
3801
+ constraints: {
3802
+ unique: ['title'],
3803
+ relationship: [],
3804
+ },
3805
+ defaultActions: DEFAULT_OPERATIONS,
3806
+ customActions: {},
3807
+ enduserActions: {},
3808
+ fields: {
3809
+ ...BuiltInFields,
3810
+ title: {
3811
+ validator: stringValidator100,
3812
+ required: true,
3813
+ examples: ["Appointment Booking Title"]
3814
+ },
3815
+ address: { validator: stringValidator1000 },
3816
+ zipCode: { validator: stringValidator1000 },
3817
+ phone: { validator: stringValidator }, // phoneValidator assumes cell phone and strips formatting, this should not
3818
+ state: { validator: stateValidator },
3819
+ timezone: { validator: timezoneValidator },
3820
+ }
3821
+ },
3822
+ products: {
3823
+ info: {},
3824
+ constraints: {
3825
+ unique: ['title'],
3826
+ relationship: [],
3827
+ },
3828
+ defaultActions: DEFAULT_OPERATIONS,
3829
+ customActions: {},
3830
+ enduserActions: {},
3831
+ fields: {
3832
+ ...BuiltInFields,
3833
+ title: {
3834
+ validator: stringValidator100,
3835
+ required: true,
3836
+ examples: ["Product Title"]
3837
+ },
3838
+ cost: {
3839
+ validator: costValidator,
3840
+ required: true,
3841
+ examples: [{ amount: 500, currency: 'USD' }],
3842
+ },
3843
+ processor: {
3844
+ validator: paymentProcessorValidator,
3845
+ required: true,
3846
+ examples: ['Stripe'],
3847
+ },
3848
+ description: { validator: stringValidator5000EmptyOkay },
3849
+ }
3850
+ },
3851
+ purchases: {
3852
+ info: {},
3853
+ constraints: { unique: [], relationship: [] },
3854
+ defaultActions: DEFAULT_OPERATIONS,
3855
+ customActions: {},
3856
+ enduserActions: {},
3857
+ fields: {
3858
+ ...BuiltInFields,
3859
+ productId: {
3860
+ validator: mongoIdStringValidator,
3861
+ required: true,
3862
+ examples: [PLACEHOLDER_ID],
3863
+ dependencies: [{
3864
+ dependsOn: ['products'],
3865
+ dependencyField: '_id',
3866
+ relationship: 'foreignKey',
3867
+ onDependencyDelete: 'nop',
3868
+ }]
3869
+ },
3870
+ enduserId: {
3871
+ validator: mongoIdStringValidator,
3872
+ examples: [PLACEHOLDER_ID],
3873
+ required: true,
3874
+ dependencies: [{
3875
+ dependsOn: ['endusers'],
3876
+ dependencyField: '_id',
3877
+ relationship: 'foreignKey',
3878
+ onDependencyDelete: 'delete',
3879
+ }]
3880
+ },
3881
+ title: {
3882
+ validator: stringValidator100,
3883
+ required: true,
3884
+ examples: ["Product Title"]
3885
+ },
3886
+ cost: {
3887
+ validator: costValidator,
3888
+ required: true,
3889
+ examples: [{ amount: 500, currency: 'USD' }],
3890
+ },
3891
+ processor: {
3892
+ validator: paymentProcessorValidator,
3893
+ required: true,
3894
+ examples: ['Stripe'],
3895
+ },
3896
+ description: { validator: stringValidator5000EmptyOkay },
3897
+ }
3898
+ },
3899
+ purchase_credits: {
3900
+ info: {},
3901
+ constraints: { unique: [], relationship: [], },
3902
+ defaultActions: DEFAULT_OPERATIONS,
3903
+ customActions: {},
3904
+ enduserActions: {},
3905
+ fields: {
3906
+ ...BuiltInFields,
3907
+ enduserId: {
3908
+ validator: mongoIdStringValidator,
3909
+ examples: [PLACEHOLDER_ID],
3910
+ required: true,
3911
+ dependencies: [{
3912
+ dependsOn: ['endusers'],
3913
+ dependencyField: '_id',
3914
+ relationship: 'foreignKey',
3915
+ onDependencyDelete: 'delete',
3916
+ }]
3917
+ },
3918
+ title: {
3919
+ validator: stringValidator100,
3920
+ required: true,
3921
+ examples: ["Purchase Credit"]
3922
+ },
3923
+ value: {
3924
+ validator: purchaseCreditValueValidator,
3925
+ required: true,
3926
+ examples: [{
3927
+ type: "Voucher",
3928
+ info: {},
3929
+ }]
3930
+ },
3931
+ usedAt: { validator: dateValidator, },
3932
+ description: { validator: stringValidator5000EmptyOkay },
3933
+ }
3934
+ },
3659
3935
  })
3660
3936
 
3661
3937
  // export type SchemaType = typeof schema