@tellescope/sdk 1.71.0 → 1.71.2
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/sdk.d.ts +3 -0
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +3 -3
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/tests/tests.d.ts +1 -0
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +150 -57
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/esm/sdk.d.ts +5 -2
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +3 -3
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/tests/tests.d.ts +1 -0
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +149 -57
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/sdk.ts +3 -3
- package/src/tests/tests.ts +106 -5
- package/test_generated.pdf +0 -0
package/src/tests/tests.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
UserDisplayInfo,
|
|
11
11
|
} from "@tellescope/types-client"
|
|
12
12
|
import {
|
|
13
|
+
CompoundFilter,
|
|
13
14
|
CreateTicketActionInfo,
|
|
14
15
|
CreateTicketAssignmentStrategies,
|
|
15
16
|
CreateTicketAssignmentStrategy,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
} from "@tellescope/validation"
|
|
33
34
|
|
|
34
35
|
import { Session, APIQuery, EnduserSession } from "../sdk"
|
|
35
|
-
import { weighted_round_robin } from "@tellescope/utilities"
|
|
36
|
+
import { FORM_LOGIC_CALCULATED_FIELDS, responses_satisfy_conditions, weighted_round_robin } from "@tellescope/utilities"
|
|
36
37
|
import { DEFAULT_OPERATIONS, PLACEHOLDER_ID } from "@tellescope/constants"
|
|
37
38
|
import {
|
|
38
39
|
schema,
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
} from "@tellescope/utilities"
|
|
54
55
|
|
|
55
56
|
import fs from "fs"
|
|
57
|
+
import { response } from "express";
|
|
56
58
|
|
|
57
59
|
const UniquenessViolationMessage = 'Uniqueness Violation'
|
|
58
60
|
|
|
@@ -5004,6 +5006,16 @@ const mfa_tests = async () => {
|
|
|
5004
5006
|
() => sdkMfaApiKey.api.endusers.deleteOne(enduser.id),
|
|
5005
5007
|
passOnAnyResult
|
|
5006
5008
|
)
|
|
5009
|
+
|
|
5010
|
+
sdkMfa.setAuthToken((await sdkMfaApiKey.api.users.generate_auth_token({ email: mfaEmail })).authToken)
|
|
5011
|
+
|
|
5012
|
+
// test usage and cleanup
|
|
5013
|
+
const e = await sdkMfa.api.endusers.createOne({ fname: 'will work'})
|
|
5014
|
+
await async_test(
|
|
5015
|
+
"API-key generated token does not require MFA",
|
|
5016
|
+
() => sdkMfa.api.endusers.deleteOne(e.id),
|
|
5017
|
+
passOnAnyResult
|
|
5018
|
+
)
|
|
5007
5019
|
}
|
|
5008
5020
|
|
|
5009
5021
|
const nextReminderInMS_tests = async () => {
|
|
@@ -6070,12 +6082,13 @@ const enduser_access_tags_tests = async () => {
|
|
|
6070
6082
|
|
|
6071
6083
|
const matchTag = 'Access'
|
|
6072
6084
|
const dontMatchTag = 'No Access'
|
|
6085
|
+
const ticketTitle = 'ticket'
|
|
6073
6086
|
|
|
6074
6087
|
const matchEnduser = await sdk.api.endusers.createOne({ accessTags: [matchTag]})
|
|
6075
6088
|
const matchMultiTagEnduser = await sdk.api.endusers.createOne({ accessTags: [matchTag, dontMatchTag]})
|
|
6076
6089
|
const dontMatchEnduser = await sdk.api.endusers.createOne({ accessTags: [dontMatchTag]})
|
|
6077
|
-
const matchTicket = await sdk.api.tickets.createOne({ enduserId: matchEnduser.id, title:
|
|
6078
|
-
const dontMatchTicket = await sdk.api.tickets.createOne({ enduserId: dontMatchEnduser.id, title:
|
|
6090
|
+
const matchTicket = await sdk.api.tickets.createOne({ enduserId: matchEnduser.id, title: ticketTitle })
|
|
6091
|
+
const dontMatchTicket = await sdk.api.tickets.createOne({ enduserId: dontMatchEnduser.id, title: ticketTitle })
|
|
6079
6092
|
|
|
6080
6093
|
// start with disabled setting an no tags on non-admin
|
|
6081
6094
|
await sdk.api.users.updateOne(sdkNonAdmin.userInfo.id, { tags: [] }, { replaceObjectFields: true })
|
|
@@ -6087,6 +6100,10 @@ const enduser_access_tags_tests = async () => {
|
|
|
6087
6100
|
await async_test(`Setting disabled, matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), handleAnyError)
|
|
6088
6101
|
await async_test(`Setting disabled, dontMatchEnduser`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6089
6102
|
await async_test(`Setting disabled, no tags, tickets`, sdkNonAdmin.api.tickets.getSome, { onResult: r => r.length === 0 })
|
|
6103
|
+
await async_test(`Setting disabled, no tags, tickets search`,
|
|
6104
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6105
|
+
{ onResult: r => r.length === 0 }
|
|
6106
|
+
)
|
|
6090
6107
|
await async_test(`Setting disabled, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), handleAnyError)
|
|
6091
6108
|
await async_test(`Setting disabled, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6092
6109
|
await async_test(
|
|
@@ -6110,6 +6127,10 @@ const enduser_access_tags_tests = async () => {
|
|
|
6110
6127
|
await async_test(`enable setting, matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), handleAnyError)
|
|
6111
6128
|
await async_test(`enable setting, dontMatchEnduser`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6112
6129
|
await async_test(`enable setting, no tags, tickets`, sdkNonAdmin.api.tickets.getSome, { onResult: r => r.length === 0 })
|
|
6130
|
+
await async_test(`enable setting, no tags, tickets search`,
|
|
6131
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6132
|
+
{ onResult: r => r.length === 0 }
|
|
6133
|
+
)
|
|
6113
6134
|
await async_test(`enable setting, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), handleAnyError)
|
|
6114
6135
|
await async_test(`enable setting, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6115
6136
|
await async_test(
|
|
@@ -6134,6 +6155,10 @@ const enduser_access_tags_tests = async () => {
|
|
|
6134
6155
|
await async_test(`disable setting, matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), handleAnyError)
|
|
6135
6156
|
await async_test(`disable setting, dontMatchEnduser`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6136
6157
|
await async_test(`disable setting, enable tags, tickets`, sdkNonAdmin.api.tickets.getSome, { onResult: r => r.length === 0 })
|
|
6158
|
+
await async_test(`disable setting, no tags, tickets search`,
|
|
6159
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6160
|
+
{ onResult: r => r.length === 0 }
|
|
6161
|
+
)
|
|
6137
6162
|
await async_test(`disable setting, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), handleAnyError)
|
|
6138
6163
|
await async_test(`disable setting, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6139
6164
|
await async_test(
|
|
@@ -6158,9 +6183,13 @@ const enduser_access_tags_tests = async () => {
|
|
|
6158
6183
|
})
|
|
6159
6184
|
await async_test(`access matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), passOnAnyResult)
|
|
6160
6185
|
await async_test(`access dontMatchEnduser bad`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6161
|
-
await async_test(`access setting,
|
|
6186
|
+
await async_test(`access setting, tickets`, sdkNonAdmin.api.tickets.getSome, {
|
|
6162
6187
|
onResult: r => r.length === 1 && !r.find(t => t.id === dontMatchTicket.id)
|
|
6163
6188
|
})
|
|
6189
|
+
await async_test(`access setting tickets search`,
|
|
6190
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6191
|
+
{ onResult: r => r.length === 1 }
|
|
6192
|
+
)
|
|
6164
6193
|
await async_test(`access, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), passOnAnyResult)
|
|
6165
6194
|
await async_test(`access, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6166
6195
|
await async_test(
|
|
@@ -6272,6 +6301,76 @@ const marketing_email_unsubscribe_tests = async () => {
|
|
|
6272
6301
|
])
|
|
6273
6302
|
}
|
|
6274
6303
|
|
|
6304
|
+
export const form_conditional_logic_tests = async () => {
|
|
6305
|
+
log_header("Form Conditional Logic Tests")
|
|
6306
|
+
|
|
6307
|
+
const responses: FormResponseValue[] = [
|
|
6308
|
+
{
|
|
6309
|
+
fieldId: "0",
|
|
6310
|
+
answer: { type: 'string', value: 'hello' },
|
|
6311
|
+
fieldTitle: '',
|
|
6312
|
+
},
|
|
6313
|
+
{
|
|
6314
|
+
fieldId: "0list",
|
|
6315
|
+
answer: { type: 'multiple_choice', value: ['hello'] },
|
|
6316
|
+
fieldTitle: '',
|
|
6317
|
+
},
|
|
6318
|
+
{
|
|
6319
|
+
fieldId: "1",
|
|
6320
|
+
answer: { type: 'string', value: '' },
|
|
6321
|
+
fieldTitle: '',
|
|
6322
|
+
},
|
|
6323
|
+
{
|
|
6324
|
+
fieldId: "2",
|
|
6325
|
+
answer: { type: 'multiple_choice', value: [''] },
|
|
6326
|
+
fieldTitle: '',
|
|
6327
|
+
},
|
|
6328
|
+
{
|
|
6329
|
+
fieldId: "3",
|
|
6330
|
+
answer: { type: 'number', value: 73 },
|
|
6331
|
+
fieldTitle: '',
|
|
6332
|
+
computedValueKey: 'Height',
|
|
6333
|
+
},
|
|
6334
|
+
{
|
|
6335
|
+
fieldId: "4",
|
|
6336
|
+
answer: { type: 'number', value: 190 },
|
|
6337
|
+
fieldTitle: '',
|
|
6338
|
+
computedValueKey: 'Weight',
|
|
6339
|
+
},
|
|
6340
|
+
]
|
|
6341
|
+
|
|
6342
|
+
let i = 0
|
|
6343
|
+
const run_conditional_form_test = (conditions: CompoundFilter<string>, expected: boolean, title=`Test ${++i}`) => {
|
|
6344
|
+
assert(
|
|
6345
|
+
responses_satisfy_conditions(responses, conditions) === expected,
|
|
6346
|
+
`Failed condition:\n${JSON.stringify(conditions, null, 2)}`,
|
|
6347
|
+
title,
|
|
6348
|
+
)
|
|
6349
|
+
}
|
|
6350
|
+
|
|
6351
|
+
run_conditional_form_test({ $and: [{ condition: { '0': { $contains: 'hel'} } }] }, true)
|
|
6352
|
+
run_conditional_form_test({ $and: [{ condition: { '0': { $contains: 'hello'} } }] }, true)
|
|
6353
|
+
run_conditional_form_test({ $and: [{ condition: { '0': { $contains: 'hllo'} } }] }, false)
|
|
6354
|
+
run_conditional_form_test({ $and: [{ condition: { '0list': { $contains: 'hel'} } }] }, true)
|
|
6355
|
+
run_conditional_form_test({ $and: [{ condition: { '0list': { $contains: 'hello'} } }] }, true)
|
|
6356
|
+
run_conditional_form_test({ $and: [{ condition: { '0list': { $contains: 'hllo'} } }] }, false)
|
|
6357
|
+
run_conditional_form_test({ $and: [{ condition: { '1': '' } }] }, true)
|
|
6358
|
+
run_conditional_form_test({ $and: [{ condition: { '1': { $exists: true } } }] }, false)
|
|
6359
|
+
run_conditional_form_test({ $and: [{ condition: { '1': { $exists: false } } }] }, true)
|
|
6360
|
+
run_conditional_form_test({ $and: [{ condition: { '2': '' } }] }, true)
|
|
6361
|
+
run_conditional_form_test({ $and: [{ condition: { '2': { $exists: true } } }] }, true)
|
|
6362
|
+
run_conditional_form_test({ $and: [{ condition: { '2': { $exists: false } } }] }, false)
|
|
6363
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $gt: 72 } } }] }, true)
|
|
6364
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $gt: 73 } } }] }, false)
|
|
6365
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $gt: 74 } } }] }, false)
|
|
6366
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $lt: 72 } } }] }, false)
|
|
6367
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $lt: 73 } } }] }, false)
|
|
6368
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $lt: 74 } } }] }, true)
|
|
6369
|
+
run_conditional_form_test({ $and: [{ condition: { [FORM_LOGIC_CALCULATED_FIELDS[0]]: { $exists: true } } }] }, true)
|
|
6370
|
+
run_conditional_form_test({ $and: [{ condition: { [FORM_LOGIC_CALCULATED_FIELDS[0]]: { $gt: 25 } } }] }, true)
|
|
6371
|
+
run_conditional_form_test({ $and: [{ condition: { [FORM_LOGIC_CALCULATED_FIELDS[0]]: { $lt: 25 } } }] }, false)
|
|
6372
|
+
}
|
|
6373
|
+
|
|
6275
6374
|
(async () => {
|
|
6276
6375
|
log_header("API")
|
|
6277
6376
|
|
|
@@ -6282,6 +6381,8 @@ const marketing_email_unsubscribe_tests = async () => {
|
|
|
6282
6381
|
)
|
|
6283
6382
|
|
|
6284
6383
|
try {
|
|
6384
|
+
form_conditional_logic_tests()
|
|
6385
|
+
|
|
6285
6386
|
await test_weighted_round_robin()
|
|
6286
6387
|
|
|
6287
6388
|
await validate_schema()
|
|
@@ -6312,9 +6413,9 @@ const marketing_email_unsubscribe_tests = async () => {
|
|
|
6312
6413
|
await mfa_tests()
|
|
6313
6414
|
await setup_tests()
|
|
6314
6415
|
await multi_tenant_tests() // should come right after setup tests
|
|
6416
|
+
await enduser_access_tags_tests()
|
|
6315
6417
|
await marketing_email_unsubscribe_tests()
|
|
6316
6418
|
await unique_strings_tests()
|
|
6317
|
-
await enduser_access_tags_tests()
|
|
6318
6419
|
await self_serve_appointment_booking_tests()
|
|
6319
6420
|
await alternate_phones_tests()
|
|
6320
6421
|
await ticket_queue_tests()
|
package/test_generated.pdf
CHANGED
|
Binary file
|