@tellescope/sdk 1.66.3 → 1.66.5

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.
@@ -147,9 +147,23 @@ const setup_tests = async () => {
147
147
  'authToken refresh'
148
148
  )
149
149
 
150
+ // ensure that going to "Non-Admin" triggers a role change
151
+ await sdk.api.users.updateOne(sdkNonAdmin.userInfo.id, { roles: ['Test'] }, { replaceObjectFields: true }),
152
+
153
+ await sdkNonAdmin.authenticate(nonAdminEmail, nonAdminPassword)
154
+ await async_test('non admin authenticated', sdkNonAdmin.test_authenticated, { expectedResult: 'Authenticated!' })
155
+
150
156
  // reset nonAdmin role to a default non-admin
151
157
  await sdk.api.users.updateOne(sdkNonAdmin.userInfo.id, { roles: ['Non-Admin'] }, { replaceObjectFields: true }),
152
158
 
159
+ // should be unauthenticated due to role change
160
+ await wait(undefined, 100)
161
+ await async_test('role change causes deauthentication', sdkNonAdmin.test_authenticated, handleAnyError)
162
+
163
+ // reauthenticate
164
+ await wait(undefined, 1000)
165
+ await sdkNonAdmin.authenticate(nonAdminEmail, nonAdminPassword)
166
+
153
167
  // may do some stuff in background after returning
154
168
  await async_test('reset_db', () => sdk.reset_db(), passOnVoid)
155
169
  await wait(undefined, 250)
@@ -3364,6 +3378,7 @@ const role_based_access_tests = async () => {
3364
3378
  await async_test(
3365
3379
  `[bulk] non-admin for chat message bad`,
3366
3380
  () => sdkNonAdmin.bulk_load({ load: [{ model: 'chats' }] }),
3381
+ // { onResult: result => result.results.flatMap(r => r?.records || []).length === 0 }
3367
3382
  handleAnyError // throws error in this case in enforceForeignAccessConstraints because there are no accessible chats
3368
3383
  )
3369
3384
  await async_test(
@@ -5084,6 +5099,34 @@ const TRACK_OPEN_IMAGE = Buffer.from(
5084
5099
  'base64'
5085
5100
  );
5086
5101
 
5102
+ const validate_schema = () => {
5103
+ const endpoints = new Set<string>([])
5104
+
5105
+ let modelName = undefined! as ModelName
5106
+ for (modelName in schema) {
5107
+ for (const endpointName in schema[modelName].customActions) {
5108
+ const path = schema[modelName].customActions[endpointName].path || ''
5109
+ if (path === '' && endpointName === 'create') continue // uses default
5110
+
5111
+ if (endpoints.has(path)) {
5112
+ throw new Error(`Duplicate path: ${path}, ${endpointName}`)
5113
+ }
5114
+
5115
+ endpoints.add(path)
5116
+ }
5117
+
5118
+ for (const endpointName in (schema[modelName] as any).publicActions ?? {}) {
5119
+ const path = (schema[modelName] as any).publicActions[endpointName].path || ''
5120
+
5121
+ if (endpoints.has(path)) {
5122
+ throw new Error(`Duplicate path: ${path}, ${endpointName}`)
5123
+ }
5124
+
5125
+ endpoints.add(path)
5126
+ }
5127
+ }
5128
+ }
5129
+
5087
5130
  (async () => {
5088
5131
  log_header("API")
5089
5132
 
@@ -5094,6 +5137,8 @@ const TRACK_OPEN_IMAGE = Buffer.from(
5094
5137
  )
5095
5138
 
5096
5139
  try {
5140
+ await validate_schema()
5141
+
5097
5142
  await Promise.all([
5098
5143
  sdk.authenticate(email, password),
5099
5144
  sdkSub.authenticate(subUserEmail, password),
@@ -5119,13 +5164,13 @@ const TRACK_OPEN_IMAGE = Buffer.from(
5119
5164
 
5120
5165
  await mfa_tests()
5121
5166
  await setup_tests()
5167
+ await multi_tenant_tests() // should come right after setup tests
5122
5168
  await automation_trigger_tests()
5123
5169
  await enduser_session_tests()
5124
5170
  await nextReminderInMS_tests()
5125
5171
  await search_tests()
5126
5172
  await wait_for_trigger_tests()
5127
5173
  await role_based_access_tests()
5128
- await multi_tenant_tests() // should come right after setup tests
5129
5174
  await pdf_generation()
5130
5175
  await remove_from_journey_on_incoming_comms_tests()
5131
5176
  await rate_limit_tests()
Binary file