@tellescope/schema 1.254.0 → 1.255.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/schema",
3
- "version": "1.254.0",
3
+ "version": "1.255.0",
4
4
  "description": "Schema definition for Tellescope models",
5
5
  "main": "./lib/cjs/schema.js",
6
6
  "module": "./lib/esm/schema.js",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "homepage": "https://github.com/tellescope-os/tellescope#readme",
25
25
  "dependencies": {
26
- "@tellescope/constants": "1.254.0",
27
- "@tellescope/types-client": "1.254.0",
28
- "@tellescope/types-models": "1.254.0",
29
- "@tellescope/types-server": "1.254.0",
30
- "@tellescope/types-utilities": "1.254.0",
31
- "@tellescope/utilities": "1.254.0",
32
- "@tellescope/validation": "1.254.0",
26
+ "@tellescope/constants": "1.255.0",
27
+ "@tellescope/types-client": "1.255.0",
28
+ "@tellescope/types-models": "1.255.0",
29
+ "@tellescope/types-server": "1.255.0",
30
+ "@tellescope/types-utilities": "1.255.0",
31
+ "@tellescope/utilities": "1.255.0",
32
+ "@tellescope/validation": "1.255.0",
33
33
  "validator": "13.11.0"
34
34
  },
35
35
  "devDependencies": {
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "c1b4f17fc6da0f03c0abeebf958a7b0c4fd4217c"
46
+ "gitHead": "9031bd85cf05c301b4079444cb8eeb0ae354154f"
47
47
  }
package/src/schema.ts CHANGED
@@ -82,6 +82,7 @@ import {
82
82
  CanvasCoding,
83
83
  StripeKeyDetail,
84
84
  MetriportIntegrationDetail,
85
+ ChargebeeBusinessEntity,
85
86
  EnduserDevice,
86
87
  AIConversationMessage,
87
88
  AICOnversationMessageContent,
@@ -92,6 +93,7 @@ import {
92
93
  TimeTrackTimestamp,
93
94
  TimeTrackReviewHistoryItem,
94
95
  BelugaPharmacyMapping,
96
+ CompoundFilter,
95
97
  BelugaAutomationMappingEntry,
96
98
  BelugaUpdateVisitPatientPreferenceItem,
97
99
  TimeTrack,
@@ -685,6 +687,8 @@ export type CustomActions = {
685
687
  },
686
688
  api_keys: {
687
689
  create: CustomAction<{}, { id: string, key: string}>,
690
+ get_organization_api_keys: CustomAction<{}, { apiKeys: { id: string, creator: string, businessId: string, updatedAt: Date }[] }>,
691
+ delete_organization_api_key: CustomAction<{ id: string }, { }>,
688
692
  },
689
693
  templates: {
690
694
  get_templated_message: CustomAction<
@@ -1718,6 +1722,12 @@ export const schema: SchemaV1 = build_schema({
1718
1722
  useDefaultFromPhoneInAutomations: { validator: booleanValidator },
1719
1723
  stripeCustomerId: { validator: stringValidator100, redactions: ['enduser'], enduserUpdatesDisabled: true },
1720
1724
  stripeKey: { validator: stringValidator250, redactions: ['enduser'], enduserUpdatesDisabled: true },
1725
+ // Chargebee linkage fields. Normally written server-side at customer creation, but exposed as
1726
+ // staff-editable (enduserUpdatesDisabled) for manual correction — e.g. reflecting a Chargebee-side
1727
+ // customer transfer between business entities, for which Chargebee emits no webhook. Empty clears.
1728
+ chargebeeId: { validator: stringValidatorOptionalEmptyOkay, redactions: ['enduser'], enduserUpdatesDisabled: true },
1729
+ chargebeeEnvironment: { validator: stringValidatorOptionalEmptyOkay, redactions: ['enduser'], enduserUpdatesDisabled: true },
1730
+ chargebeeBusinessEntityId: { validator: stringValidatorOptionalEmptyOkay, redactions: ['enduser'], enduserUpdatesDisabled: true },
1721
1731
  diagnoses: {
1722
1732
  validator: listValidatorOptionalOrEmptyOk(enduserDiagnosisValidator),
1723
1733
  redactions: ['enduser'],
@@ -2285,10 +2295,30 @@ export const schema: SchemaV1 = build_schema({
2285
2295
  validator: mongoIdStringValidator,
2286
2296
  },
2287
2297
  key: {
2288
- validator: stringValidator,
2298
+ validator: stringValidator,
2289
2299
  }
2290
2300
  }
2291
- }
2301
+ },
2302
+ get_organization_api_keys: {
2303
+ op: 'custom', access: 'read', method: 'get', adminOnly: true,
2304
+ name: 'Get Organization ApiKeys',
2305
+ path: '/organization-api-keys',
2306
+ description: "Returns metadata (id, creator, businessId, updatedAt) for all ApiKeys in the admin's organization. Never returns the secret key.",
2307
+ parameters: {},
2308
+ returns: {
2309
+ apiKeys: { validator: listOfObjectAnyFieldsAnyValuesValidator as any, required: true },
2310
+ },
2311
+ },
2312
+ delete_organization_api_key: {
2313
+ op: 'custom', access: 'delete', method: 'delete', adminOnly: true,
2314
+ name: 'Delete Organization ApiKey',
2315
+ path: '/organization-api-key/:id',
2316
+ description: "Deletes an ApiKey in the admin's organization by id, regardless of which user created it.",
2317
+ parameters: {
2318
+ id: { validator: mongoIdStringValidator, required: true },
2319
+ },
2320
+ returns: { },
2321
+ },
2292
2322
  }
2293
2323
  },
2294
2324
  integrations: {
@@ -3189,9 +3219,21 @@ export const schema: SchemaV1 = build_schema({
3189
3219
  },
3190
3220
  chat_rooms: {
3191
3221
  info: {},
3192
- constraints: {
3222
+ constraints: {
3193
3223
  unique: [{ array: 'userIds' }, { array: 'enduserIds' }],
3194
- relationship: [],
3224
+ relationship: [
3225
+ {
3226
+ // Patient-initiated rooms targeting specific care-team staff (userIds) are an intended
3227
+ // portal feature and are left unrestricted. An enduser may only add THEMSELVES to a room
3228
+ // they create — they cannot add other patients (cross-patient PHI broadcast).
3229
+ explanation: 'Endusers can only add their own id to enduserIds on chat rooms they create',
3230
+ evaluate: (doc, _, session) => {
3231
+ if (session.type !== ENDUSER_SESSION_TYPE) return
3232
+ if ((doc.enduserIds ?? []).some(id => id !== session.id))
3233
+ return "enduserIds may only contain your own id for enduser session"
3234
+ }
3235
+ },
3236
+ ],
3195
3237
  access: [
3196
3238
  { type: 'filter', field: 'userIds' },
3197
3239
  { type: 'filter', field: 'enduserIds' },
@@ -4846,8 +4888,9 @@ export const schema: SchemaV1 = build_schema({
4846
4888
  },
4847
4889
  belugaCombineMatchingPharmacyMappings: { validator: booleanValidator },
4848
4890
  mdiCaseOfferings: {
4849
- validator: listValidatorOptionalOrEmptyOk(objectValidator<{ offering_id: string }>({
4891
+ validator: listValidatorOptionalOrEmptyOk(objectValidator<{ offering_id: string, conditions?: CompoundFilter<string> }>({
4850
4892
  offering_id: stringValidator100,
4893
+ conditions: compoundFilterValidator,
4851
4894
  }))
4852
4895
  },
4853
4896
  autoMergeOnSubmission: { validator: booleanValidator },
@@ -6457,8 +6500,16 @@ export const schema: SchemaV1 = build_schema({
6457
6500
  enduser_observations: {
6458
6501
  info: {},
6459
6502
  constraints: {
6460
- unique: [],
6461
- relationship: [],
6503
+ unique: [],
6504
+ relationship: [
6505
+ {
6506
+ explanation: 'When created by an enduser, enduserId must match their id',
6507
+ evaluate: ({ enduserId },_,session) => {
6508
+ if (session.type === ENDUSER_SESSION_TYPE && session.id !== enduserId)
6509
+ return "enduserId does not match creator id for enduser session"
6510
+ }
6511
+ },
6512
+ ],
6462
6513
  },
6463
6514
  defaultActions: {
6464
6515
  ...DEFAULT_OPERATIONS,
@@ -6559,11 +6610,23 @@ export const schema: SchemaV1 = build_schema({
6559
6610
  managed_content_records: {
6560
6611
  info: {},
6561
6612
  constraints: {
6562
- unique: [],
6563
- relationship: [],
6613
+ unique: [],
6614
+ relationship: [
6615
+ {
6616
+ explanation: 'Endusers cannot self-publish managed content or bind it to another enduser',
6617
+ evaluate: (doc, _, session) => {
6618
+ if (session.type !== ENDUSER_SESSION_TYPE) return
6619
+ if (doc.publicRead) return "publicRead cannot be set by endusers"
6620
+ if (doc.allowUnauthenticatedAccess) return "allowUnauthenticatedAccess cannot be set by endusers"
6621
+ if (doc.forInternalUse) return "forInternalUse cannot be set by endusers"
6622
+ if (doc.enduserId !== undefined && doc.enduserId !== session.id)
6623
+ return "enduserId does not match creator id for enduser session"
6624
+ }
6625
+ },
6626
+ ],
6564
6627
  },
6565
6628
  defaultActions: DEFAULT_OPERATIONS,
6566
- customActions: {
6629
+ customActions: {
6567
6630
  update_indexes: {
6568
6631
  op: "custom", access: 'update', method: "patch",
6569
6632
  name: 'Update Indexes',
@@ -7240,6 +7303,13 @@ export const schema: SchemaV1 = build_schema({
7240
7303
  environment: stringValidator1000Optional,
7241
7304
  }))
7242
7305
  },
7306
+ chargebeeBusinessEntities: {
7307
+ validator: listValidatorOptionalOrEmptyOk(objectValidator<ChargebeeBusinessEntity>({
7308
+ environment: stringValidator1000,
7309
+ businessEntityId: stringValidator1000,
7310
+ name: stringValidator1000Optional,
7311
+ }))
7312
+ },
7243
7313
  name: {
7244
7314
  validator: stringValidator100,
7245
7315
  required: true,
@@ -9368,8 +9438,17 @@ If a voicemail is left, it is indicated by recordingURI, transcription, or recor
9368
9438
  info: {
9369
9439
  description: 'Lab, medication, and device orders'
9370
9440
  },
9371
- constraints: {
9372
- unique: [], relationship: [],
9441
+ constraints: {
9442
+ unique: [],
9443
+ relationship: [
9444
+ {
9445
+ explanation: 'When created by an enduser, enduserId must match their id',
9446
+ evaluate: ({ enduserId },_,session) => {
9447
+ if (session.type === ENDUSER_SESSION_TYPE && session.id !== enduserId)
9448
+ return "enduserId does not match creator id for enduser session"
9449
+ }
9450
+ },
9451
+ ],
9373
9452
  access: [{ type: 'filter', field: 'userId' }]
9374
9453
  },
9375
9454
  defaultActions: DEFAULT_OPERATIONS,
@@ -9973,8 +10052,9 @@ If a voicemail is left, it is indicated by recordingURI, transcription, or recor
9973
10052
  enduserId: { validator: mongoIdStringValidator, required: true },
9974
10053
  automationStepId: { validator: mongoIdStringValidator, required: true },
9975
10054
  outcomes: { validator: listOfStringsValidator, required: true },
9976
- prompt: { validator: stringValidator5000, required: true },
9977
- sources: { validator: listValidator(AIDecisionSourceValidator), required: true },
10055
+ prompt: { validator: stringValidator5000OptionalEmptyOkay }, // legacy, now optional
10056
+ sources: { validator: listValidator(AIDecisionSourceValidator) }, // legacy, now optional
10057
+ aiSummaryConfiguration: { validator: aiSummaryConfigurationValidator }, // new shared config
9978
10058
  journeyContext: { validator: journeyContextValidator },
9979
10059
  },
9980
10060
  returns: {},