@servicetitan/titan-chatbot-api 4.4.1 → 4.4.3
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/CHANGELOG.md +12 -0
- package/dist/api-client/utils/__tests__/model-utils.test.js +195 -101
- package/dist/api-client/utils/__tests__/model-utils.test.js.map +1 -1
- package/dist/api-client/utils/model-utils.d.ts.map +1 -1
- package/dist/api-client/utils/model-utils.js +31 -18
- package/dist/api-client/utils/model-utils.js.map +1 -1
- package/dist/stores/__tests__/filter.store.test.js +4 -5
- package/dist/stores/__tests__/filter.store.test.js.map +1 -1
- package/package.json +3 -3
- package/src/api-client/utils/__tests__/model-utils.test.ts +195 -130
- package/src/api-client/utils/model-utils.ts +33 -18
- package/src/stores/__tests__/filter.store.test.ts +4 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -16,6 +16,7 @@ export function createSelectionsModel(
|
|
|
16
16
|
subOptions: {},
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
+
return result.subOptions!;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
const filterList = filters.filter(
|
|
@@ -25,8 +26,7 @@ export function createSelectionsModel(
|
|
|
25
26
|
const selectedLeafOptions = filter.subOptions!.filter(
|
|
26
27
|
x =>
|
|
27
28
|
x.type === Models.OptionType.Selectable &&
|
|
28
|
-
selected.get(filter.key)?.includes(x.key!)
|
|
29
|
-
!x.subOptions?.length
|
|
29
|
+
selected.get(filter.key)?.includes(x.key!)
|
|
30
30
|
);
|
|
31
31
|
let values: string[] | undefined;
|
|
32
32
|
if (selectedLeafOptions.length) {
|
|
@@ -35,10 +35,14 @@ export function createSelectionsModel(
|
|
|
35
35
|
?.map(o => o.key)
|
|
36
36
|
.filter(o => selected.get(filter.key)?.includes(o));
|
|
37
37
|
if (values?.length) {
|
|
38
|
-
ensureResult();
|
|
39
|
-
|
|
38
|
+
const subOptions = ensureResult();
|
|
39
|
+
subOptions[filter.key] = new Models.Selections({ values });
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
if (!selectedLeafOptions.length) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
// Non-leaf filter: add selected options as selectables and process sub-filters
|
|
43
47
|
const selectedNonLeafOptions = filter.subOptions!.filter(
|
|
44
48
|
x =>
|
|
@@ -49,21 +53,32 @@ export function createSelectionsModel(
|
|
|
49
53
|
if (!selectedNonLeafOptions.length) {
|
|
50
54
|
continue;
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
result!.subOptions![filter.key] = filterResult;
|
|
58
|
-
for (const noneLeafOption of selectedNonLeafOptions) {
|
|
59
|
-
// Process sub-filters: if any sub-filters selected, add them to the result
|
|
60
|
-
const subFilters = noneLeafOption.subOptions!;
|
|
56
|
+
|
|
57
|
+
// We have some sub-filters to process: collect their results
|
|
58
|
+
const subFilterResults = new Map<string, Models.Selections>();
|
|
59
|
+
for (const nonLeafOption of selectedNonLeafOptions) {
|
|
60
|
+
const subFilters = nonLeafOption.subOptions!;
|
|
61
61
|
const resultSubFilters = process(subFilters);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
if (!resultSubFilters) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
subFilterResults.set(nonLeafOption.key!, resultSubFilters);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// If any sub-filters selected, ensure result and add them to the current subOptions
|
|
69
|
+
if (subFilterResults.size) {
|
|
70
|
+
const subOptions = ensureResult();
|
|
71
|
+
for (const [key, value] of subFilterResults) {
|
|
72
|
+
let subFilterSelection = subOptions[filter.key];
|
|
73
|
+
if (!subFilterSelection) {
|
|
74
|
+
subFilterSelection = new Models.Selections({});
|
|
75
|
+
subOptions[filter.key] = subFilterSelection;
|
|
76
|
+
}
|
|
77
|
+
if (!subFilterSelection.subOptions) {
|
|
78
|
+
subFilterSelection.subOptions = {};
|
|
79
|
+
}
|
|
80
|
+
subFilterSelection.subOptions![key] = value;
|
|
81
|
+
}
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
return result;
|
|
@@ -277,6 +277,7 @@ describe('[FilterStore]', () => {
|
|
|
277
277
|
expect(exported).toEqual({
|
|
278
278
|
subOptions: {
|
|
279
279
|
Sources: {
|
|
280
|
+
values: ['KnowledgeBase', 'Jarvis'],
|
|
280
281
|
subOptions: {
|
|
281
282
|
KnowledgeBase: {
|
|
282
283
|
subOptions: {
|
|
@@ -314,11 +315,7 @@ describe('[FilterStore]', () => {
|
|
|
314
315
|
expect(exported).toEqual({
|
|
315
316
|
subOptions: {
|
|
316
317
|
Sources: {
|
|
317
|
-
|
|
318
|
-
KnowledgeBase: {
|
|
319
|
-
subOptions: {},
|
|
320
|
-
},
|
|
321
|
-
},
|
|
318
|
+
values: ['KnowledgeBase'],
|
|
322
319
|
},
|
|
323
320
|
},
|
|
324
321
|
});
|
|
@@ -335,6 +332,7 @@ describe('[FilterStore]', () => {
|
|
|
335
332
|
expect(exported).toEqual({
|
|
336
333
|
subOptions: {
|
|
337
334
|
Sources: {
|
|
335
|
+
values: ['KnowledgeBase'],
|
|
338
336
|
subOptions: {
|
|
339
337
|
KnowledgeBase: {
|
|
340
338
|
subOptions: {
|
|
@@ -359,6 +357,7 @@ describe('[FilterStore]', () => {
|
|
|
359
357
|
expect(exported).toEqual({
|
|
360
358
|
subOptions: {
|
|
361
359
|
Sources: {
|
|
360
|
+
values: ['KnowledgeBase', 'Jarvis'],
|
|
362
361
|
subOptions: {
|
|
363
362
|
KnowledgeBase: {
|
|
364
363
|
subOptions: {
|