@tellescope/sdk 1.68.7 → 1.68.9
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/enduser.d.ts +20 -0
- package/lib/cjs/enduser.d.ts.map +1 -1
- package/lib/cjs/sdk.d.ts +42 -0
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +1 -0
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +232 -74
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/esm/enduser.d.ts +20 -0
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/sdk.d.ts +42 -0
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +1 -0
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +222 -64
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/sdk.ts +1 -0
- package/src/tests/tests.ts +171 -1
- package/test_generated.pdf +0 -0
package/src/tests/tests.ts
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
CreateTicketAssignmentStrategy,
|
|
16
16
|
FormResponseValue,
|
|
17
17
|
ModelName,
|
|
18
|
+
RoundRobinAssignmentInfo,
|
|
19
|
+
User,
|
|
18
20
|
} from "@tellescope/types-models"
|
|
19
21
|
|
|
20
22
|
import {
|
|
@@ -30,7 +32,7 @@ import {
|
|
|
30
32
|
} from "@tellescope/validation"
|
|
31
33
|
|
|
32
34
|
import { Session, APIQuery, EnduserSession } from "../sdk"
|
|
33
|
-
import {
|
|
35
|
+
import { weighted_round_robin } from "@tellescope/utilities"
|
|
34
36
|
import { DEFAULT_OPERATIONS, PLACEHOLDER_ID } from "@tellescope/constants"
|
|
35
37
|
import {
|
|
36
38
|
schema,
|
|
@@ -5780,6 +5782,7 @@ const tests: { [K in keyof ClientModelForName]: () => void } = {
|
|
|
5780
5782
|
ticket_threads: NO_TEST,
|
|
5781
5783
|
ticket_thread_comments: NO_TEST,
|
|
5782
5784
|
configurations: NO_TEST,
|
|
5785
|
+
group_mms_conversations: NO_TEST,
|
|
5783
5786
|
};
|
|
5784
5787
|
|
|
5785
5788
|
const TRACK_OPEN_IMAGE = Buffer.from(
|
|
@@ -5788,6 +5791,8 @@ const TRACK_OPEN_IMAGE = Buffer.from(
|
|
|
5788
5791
|
);
|
|
5789
5792
|
|
|
5790
5793
|
const validate_schema = () => {
|
|
5794
|
+
log_header("Validate Schema")
|
|
5795
|
+
|
|
5791
5796
|
const endpoints = new Set<string>([])
|
|
5792
5797
|
|
|
5793
5798
|
let modelName = undefined! as ModelName
|
|
@@ -5815,6 +5820,169 @@ const validate_schema = () => {
|
|
|
5815
5820
|
}
|
|
5816
5821
|
}
|
|
5817
5822
|
|
|
5823
|
+
const test_weighted_round_robin = async () => {
|
|
5824
|
+
log_header("Test validate_weighted_round_robin")
|
|
5825
|
+
|
|
5826
|
+
const testUsers: Pick<User, 'id' | 'ticketAssignmentPriority'>[] = [
|
|
5827
|
+
{ id: '0', ticketAssignmentPriority: undefined }, // will default to 5
|
|
5828
|
+
{ id: '1', ticketAssignmentPriority: 1 },
|
|
5829
|
+
{ id: '2', ticketAssignmentPriority: 2 },
|
|
5830
|
+
{ id: '3', ticketAssignmentPriority: 3 },
|
|
5831
|
+
]
|
|
5832
|
+
const userIds = testUsers.map(u => u.id)
|
|
5833
|
+
const testAssignments: RoundRobinAssignmentInfo[] = testUsers.map((u, i) => ({
|
|
5834
|
+
id: i.toString(),
|
|
5835
|
+
key: 'test',
|
|
5836
|
+
timestamp: Date.now() - 1000,
|
|
5837
|
+
userId: u.id,
|
|
5838
|
+
}))
|
|
5839
|
+
|
|
5840
|
+
await async_test(
|
|
5841
|
+
`Both empty`,
|
|
5842
|
+
async () => weighted_round_robin({ assignments: [], users: [] }),
|
|
5843
|
+
{ onResult: r => r.selected === undefined }
|
|
5844
|
+
)
|
|
5845
|
+
await async_test(
|
|
5846
|
+
`Single user, empty assignment`,
|
|
5847
|
+
async () => weighted_round_robin({ assignments: [], users: [testUsers[0]] }),
|
|
5848
|
+
{ onResult: r => r.selected === testUsers[0].id }
|
|
5849
|
+
)
|
|
5850
|
+
await async_test(
|
|
5851
|
+
`Both singletons`,
|
|
5852
|
+
async () => weighted_round_robin({ assignments: [testAssignments[0]], users: [testUsers[0]] }),
|
|
5853
|
+
{ onResult: r => r.selected === testUsers[0].id }
|
|
5854
|
+
)
|
|
5855
|
+
|
|
5856
|
+
const run_assignment_simulation = ({
|
|
5857
|
+
iterations,
|
|
5858
|
+
expectedSelections,
|
|
5859
|
+
users=testUsers,
|
|
5860
|
+
title=`Simulation ${iterations}`,
|
|
5861
|
+
} : {
|
|
5862
|
+
expectedSelections: string[],
|
|
5863
|
+
iterations: number,
|
|
5864
|
+
users?: typeof testUsers,
|
|
5865
|
+
title?: string,
|
|
5866
|
+
}) => {
|
|
5867
|
+
const assignments: RoundRobinAssignmentInfo[] = []
|
|
5868
|
+
const selections: (string | undefined)[] = []
|
|
5869
|
+
|
|
5870
|
+
for (let i = 0; i < iterations; i++) {
|
|
5871
|
+
if (assignments.length !== i) {
|
|
5872
|
+
throw new Error("Invariant Violation: assignment not saved in history")
|
|
5873
|
+
}
|
|
5874
|
+
|
|
5875
|
+
const { selected } = weighted_round_robin({ assignments, users })
|
|
5876
|
+
selections.push(selected)
|
|
5877
|
+
|
|
5878
|
+
const assignment: RoundRobinAssignmentInfo = {
|
|
5879
|
+
id: i.toString(),
|
|
5880
|
+
userId: selected || '',
|
|
5881
|
+
key: 'test',
|
|
5882
|
+
timestamp: i, // simply ensures increasing timestamps per assignment
|
|
5883
|
+
}
|
|
5884
|
+
|
|
5885
|
+
// ensure that assignment order doesn't matter (e.g. weighted_round_robin sorts internally)
|
|
5886
|
+
if (i % 2 === 0) {
|
|
5887
|
+
assignments.push(assignment) // add to back
|
|
5888
|
+
} else {
|
|
5889
|
+
assignments.unshift(assignment) // add to front
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
|
|
5893
|
+
assert(objects_equivalent(selections, expectedSelections), title + '\n' + JSON.stringify({ expected: expectedSelections, got: selections }, null, 2), title)
|
|
5894
|
+
}
|
|
5895
|
+
|
|
5896
|
+
run_assignment_simulation({ expectedSelections: [], iterations: 0 })
|
|
5897
|
+
run_assignment_simulation({ expectedSelections: [userIds[0]], iterations: 1 })
|
|
5898
|
+
run_assignment_simulation({ expectedSelections: [userIds[0], userIds[1]], iterations: 2 })
|
|
5899
|
+
run_assignment_simulation({ expectedSelections: [userIds[0], userIds[1], userIds[2]], iterations: 3 })
|
|
5900
|
+
run_assignment_simulation({ expectedSelections: [userIds[0], userIds[1], userIds[2], userIds[3]], iterations: 4 })
|
|
5901
|
+
run_assignment_simulation({ iterations: 5,
|
|
5902
|
+
expectedSelections: [
|
|
5903
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5904
|
+
userIds[0],
|
|
5905
|
+
],
|
|
5906
|
+
})
|
|
5907
|
+
run_assignment_simulation({ iterations: 6, expectedSelections: [
|
|
5908
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5909
|
+
userIds[0], userIds[2],
|
|
5910
|
+
]})
|
|
5911
|
+
run_assignment_simulation({ iterations: 7, expectedSelections: [
|
|
5912
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5913
|
+
userIds[0], userIds[2], userIds[3],
|
|
5914
|
+
]})
|
|
5915
|
+
run_assignment_simulation({ iterations: 8, expectedSelections: [
|
|
5916
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5917
|
+
userIds[0], userIds[2], userIds[3],
|
|
5918
|
+
userIds[0],
|
|
5919
|
+
]})
|
|
5920
|
+
run_assignment_simulation({ iterations: 9,
|
|
5921
|
+
expectedSelections: [
|
|
5922
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5923
|
+
userIds[0], userIds[2], userIds[3],
|
|
5924
|
+
userIds[0], userIds[3],
|
|
5925
|
+
],
|
|
5926
|
+
})
|
|
5927
|
+
run_assignment_simulation({ iterations: 10,
|
|
5928
|
+
expectedSelections: [
|
|
5929
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5930
|
+
userIds[0], userIds[2], userIds[3],
|
|
5931
|
+
userIds[0], userIds[3],
|
|
5932
|
+
userIds[0],
|
|
5933
|
+
],
|
|
5934
|
+
})
|
|
5935
|
+
run_assignment_simulation({ iterations: 11,
|
|
5936
|
+
expectedSelections: [
|
|
5937
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5938
|
+
userIds[0], userIds[2], userIds[3],
|
|
5939
|
+
userIds[0], userIds[3],
|
|
5940
|
+
userIds[0],
|
|
5941
|
+
userIds[0],
|
|
5942
|
+
],
|
|
5943
|
+
})
|
|
5944
|
+
run_assignment_simulation({ iterations: 12,
|
|
5945
|
+
expectedSelections: [
|
|
5946
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5947
|
+
userIds[0], userIds[2], userIds[3],
|
|
5948
|
+
userIds[0], userIds[3],
|
|
5949
|
+
userIds[0],
|
|
5950
|
+
userIds[0],
|
|
5951
|
+
userIds[0],
|
|
5952
|
+
],
|
|
5953
|
+
})
|
|
5954
|
+
run_assignment_simulation({ iterations: 13,
|
|
5955
|
+
expectedSelections: [
|
|
5956
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5957
|
+
userIds[0], userIds[2], userIds[3],
|
|
5958
|
+
userIds[0], userIds[3],
|
|
5959
|
+
userIds[0],
|
|
5960
|
+
userIds[0],
|
|
5961
|
+
userIds[0], userIds[1],
|
|
5962
|
+
],
|
|
5963
|
+
})
|
|
5964
|
+
run_assignment_simulation({ iterations: 14,
|
|
5965
|
+
expectedSelections: [
|
|
5966
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5967
|
+
userIds[0], userIds[2], userIds[3],
|
|
5968
|
+
userIds[0], userIds[3],
|
|
5969
|
+
userIds[0],
|
|
5970
|
+
userIds[0],
|
|
5971
|
+
userIds[0], userIds[1], userIds[2],
|
|
5972
|
+
],
|
|
5973
|
+
})
|
|
5974
|
+
run_assignment_simulation({ iterations: 15,
|
|
5975
|
+
expectedSelections: [
|
|
5976
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5977
|
+
userIds[0], userIds[2], userIds[3],
|
|
5978
|
+
userIds[0], userIds[3],
|
|
5979
|
+
userIds[0],
|
|
5980
|
+
userIds[0],
|
|
5981
|
+
userIds[0], userIds[1], userIds[2], userIds[3],
|
|
5982
|
+
],
|
|
5983
|
+
})
|
|
5984
|
+
}
|
|
5985
|
+
|
|
5818
5986
|
(async () => {
|
|
5819
5987
|
log_header("API")
|
|
5820
5988
|
|
|
@@ -5825,6 +5993,8 @@ const validate_schema = () => {
|
|
|
5825
5993
|
)
|
|
5826
5994
|
|
|
5827
5995
|
try {
|
|
5996
|
+
await test_weighted_round_robin()
|
|
5997
|
+
|
|
5828
5998
|
await validate_schema()
|
|
5829
5999
|
|
|
5830
6000
|
await Promise.all([
|
package/test_generated.pdf
CHANGED
|
Binary file
|