@talkpilot/core-db 1.0.18 → 1.0.20
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/dist/municipal/systemInstructions/index.d.ts +1 -1
- package/dist/municipal/systemInstructions/index.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.getters.d.ts +6 -6
- package/dist/municipal/systemInstructions/instructions.getters.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.getters.js.map +1 -1
- package/dist/municipal/systemInstructions/instructions.setters.d.ts +3 -3
- package/dist/municipal/systemInstructions/instructions.setters.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.setters.js +16 -0
- package/dist/municipal/systemInstructions/instructions.setters.js.map +1 -1
- package/dist/municipal/systemInstructions/instructions.types.d.ts +15 -3
- package/dist/municipal/systemInstructions/instructions.types.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.types.js +11 -0
- package/dist/municipal/systemInstructions/instructions.types.js.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +1 -0
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.schema.d.ts +40 -10
- package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.schema.js +22 -4
- package/dist/talkpilot/flows/flows.schema.js.map +1 -1
- package/dist/talkpilot/flows/flows.types.d.ts +16 -3
- package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/municipal/systemInstructions/__tests__/getters.spec.ts +10 -9
- package/src/municipal/systemInstructions/__tests__/setters.spec.ts +59 -19
- package/src/municipal/systemInstructions/index.ts +1 -1
- package/src/municipal/systemInstructions/instructions.getters.ts +8 -8
- package/src/municipal/systemInstructions/instructions.setters.ts +22 -6
- package/src/municipal/systemInstructions/instructions.types.ts +18 -3
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +1 -0
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +19 -11
- package/src/talkpilot/flows/flows.schema.ts +22 -4
- package/src/talkpilot/flows/flows.types.ts +18 -3
- package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +20 -2
- package/src/talkpilot/sessions/__tests__/sessions.spec.ts +18 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './instructions.getters';
|
|
2
2
|
export * from './instructions.setters';
|
|
3
|
-
export type {
|
|
3
|
+
export type { MIS_SystemInstruction, MIS_Tool, QueryType } from './instructions.types';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { CityName } from '../index';
|
|
2
2
|
import { Collection, Filter } from 'mongodb';
|
|
3
|
-
import {
|
|
4
|
-
export declare const getSystemInstructionsCollection: () => Collection<
|
|
3
|
+
import { MIS_SystemInstruction, MIS_Tool } from './instructions.types';
|
|
4
|
+
export declare const getSystemInstructionsCollection: () => Collection<MIS_SystemInstruction>;
|
|
5
5
|
/**
|
|
6
6
|
* Find system instructions by filter
|
|
7
7
|
* @param filter filter to apply
|
|
8
8
|
* @returns array of system instructions
|
|
9
9
|
*/
|
|
10
|
-
export declare const findSystemInstructions: (filter?: Filter<
|
|
10
|
+
export declare const findSystemInstructions: (filter?: Filter<MIS_SystemInstruction>) => Promise<MIS_SystemInstruction[]>;
|
|
11
11
|
/**
|
|
12
12
|
* Get system instruction by id
|
|
13
13
|
* @param id system instruction id
|
|
14
14
|
* @returns system instruction or null if not found
|
|
15
15
|
*/
|
|
16
|
-
export declare const getSystemInstructionById: (id: string) => Promise<
|
|
16
|
+
export declare const getSystemInstructionById: (id: string) => Promise<MIS_SystemInstruction | null>;
|
|
17
17
|
/**
|
|
18
18
|
* Get all active system instructions for a city
|
|
19
19
|
* @param cityName city name
|
|
20
20
|
* @returns array of active system instructions
|
|
21
21
|
*/
|
|
22
|
-
export declare const getActiveSystemInstructionsByCity: (cityName: CityName) => Promise<
|
|
22
|
+
export declare const getActiveSystemInstructionsByCity: (cityName: CityName) => Promise<MIS_SystemInstruction[]>;
|
|
23
23
|
/**
|
|
24
24
|
* Get system instructions by tool and city
|
|
25
25
|
* @param cityName city name
|
|
26
26
|
* @param toolName tool name
|
|
27
27
|
* @returns array of system instructions
|
|
28
28
|
*/
|
|
29
|
-
export declare const getSystemInstructionsByToolAndCity: (cityName: CityName, toolName:
|
|
29
|
+
export declare const getSystemInstructionsByToolAndCity: (cityName: CityName, toolName: MIS_Tool) => Promise<MIS_SystemInstruction[]>;
|
|
30
30
|
//# sourceMappingURL=instructions.getters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.getters.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAkB,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"instructions.getters.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAkB,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEvE,eAAO,MAAM,+BAA+B,QAAO,UAAU,CAAC,qBAAqB,CAElF,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAQ,MAAM,CAAC,qBAAqB,CAAM,KACzC,OAAO,CAAC,qBAAqB,EAAE,CAEjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAE/F,CAAA;AACD;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAAU,UAAU,QAAQ,KAAG,OAAO,CAAC,qBAAqB,EAAE,CAE3G,CAAA;AACD;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,GAAU,UAAU,QAAQ,EAAE,UAAU,QAAQ,KAAG,OAAO,CAAC,qBAAqB,EAAE,CAEhI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.getters.js","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.getters.ts"],"names":[],"mappings":";;;AAAA,oCAAmD;AAI5C,MAAM,+BAA+B,GAAG,
|
|
1
|
+
{"version":3,"file":"instructions.getters.js","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.getters.ts"],"names":[],"mappings":";;;AAAA,oCAAmD;AAI5C,MAAM,+BAA+B,GAAG,GAAsC,EAAE;IACrF,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAwB,qBAAqB,CAAC,CAAC;AAC1E,CAAC,CAAC;AAFW,QAAA,+BAA+B,mCAE1C;AACF;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,SAAwC,EAAE,EACR,EAAE;IACpC,OAAO,MAAM,IAAA,uCAA+B,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AACxE,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC;AAEF;;;;GAIG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAAU,EAAyC,EAAE;IAClG,OAAO,MAAM,IAAA,uCAA+B,GAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpF,CAAC,CAAA;AAFY,QAAA,wBAAwB,4BAEpC;AACD;;;;GAIG;AACI,MAAM,iCAAiC,GAAG,KAAK,EAAE,QAAkB,EAAoC,EAAE;IAC9G,OAAO,MAAM,IAAA,uCAA+B,GAAE,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5F,CAAC,CAAA;AAFY,QAAA,iCAAiC,qCAE7C;AACD;;;;;GAKG;AACI,MAAM,kCAAkC,GAAG,KAAK,EAAE,QAAkB,EAAE,QAAkB,EAAoC,EAAE;IACnI,OAAO,MAAM,IAAA,uCAA+B,GAAE,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACtG,CAAC,CAAA;AAFY,QAAA,kCAAkC,sCAE9C"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ObjectId as MongoObjectId } from 'mongodb';
|
|
2
|
-
import {
|
|
2
|
+
import { MIS_SystemInstruction } from './instructions.types';
|
|
3
3
|
/**
|
|
4
4
|
* Create a new system instruction
|
|
5
5
|
* @param instructionData system instruction data
|
|
6
6
|
* @returns inserted system instruction id
|
|
7
7
|
*/
|
|
8
|
-
export declare const createSystemInstruction: (instructionData: Omit<
|
|
8
|
+
export declare const createSystemInstruction: (instructionData: Omit<MIS_SystemInstruction, "_id" | "createdAt" | "updatedAt">) => Promise<MongoObjectId>;
|
|
9
9
|
/**
|
|
10
10
|
* Update a system instruction by id
|
|
11
11
|
* @param id system instruction id
|
|
12
12
|
* @param data partial system instruction data
|
|
13
13
|
* @returns updated system instruction or null if not found
|
|
14
14
|
*/
|
|
15
|
-
export declare const updateSystemInstruction: (id: string, data: Partial<Omit<
|
|
15
|
+
export declare const updateSystemInstruction: (id: string, data: Partial<Omit<MIS_SystemInstruction, "_id" | "createdAt" | "updatedAt">>) => Promise<MIS_SystemInstruction | null>;
|
|
16
16
|
/**
|
|
17
17
|
* Delete a system instruction by id
|
|
18
18
|
* @param id system instruction id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.setters.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.setters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"instructions.setters.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.setters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAA0B,MAAM,sBAAsB,CAAC;AAiBrF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,iBAAiB,IAAI,CAAC,qBAAqB,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC,KAC9E,OAAO,CAAC,aAAa,CAWvB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,IAAI,MAAM,EACV,MAAM,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC,KAC5E,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAQtC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,OAAO,CAGzE,CAAC;AACF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,OAAO,CAO3E,CAAC;AACF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,OAAO,CAO7E,CAAA"}
|
|
@@ -2,13 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deactivateSystemInstruction = exports.activateSystemInstruction = exports.deleteSystemInstruction = exports.updateSystemInstruction = exports.createSystemInstruction = void 0;
|
|
4
4
|
const index_1 = require("../index");
|
|
5
|
+
const instructions_types_1 = require("./instructions.types");
|
|
5
6
|
const instructions_getters_1 = require("./instructions.getters");
|
|
7
|
+
/**
|
|
8
|
+
* Validate system instruction data
|
|
9
|
+
* @param data partial system instruction data
|
|
10
|
+
* @throws Error if tool or queryType is invalid
|
|
11
|
+
*/
|
|
12
|
+
const validateInstructionData = (data) => {
|
|
13
|
+
if (data.tool && !Object.values(instructions_types_1.MIS_TOOLS).includes(data.tool)) {
|
|
14
|
+
throw new Error(`Invalid tool value: ${data.tool}. Allowed values are: ${Object.values(instructions_types_1.MIS_TOOLS).join(', ')}`);
|
|
15
|
+
}
|
|
16
|
+
if (data.queryType && !Object.values(instructions_types_1.QUERY_TYPES).includes(data.queryType)) {
|
|
17
|
+
throw new Error(`Invalid queryType value: ${data.queryType}. Allowed values are: ${Object.values(instructions_types_1.QUERY_TYPES).join(', ')}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
6
20
|
/**
|
|
7
21
|
* Create a new system instruction
|
|
8
22
|
* @param instructionData system instruction data
|
|
9
23
|
* @returns inserted system instruction id
|
|
10
24
|
*/
|
|
11
25
|
const createSystemInstruction = async (instructionData) => {
|
|
26
|
+
validateInstructionData(instructionData);
|
|
12
27
|
const instruction = {
|
|
13
28
|
...instructionData,
|
|
14
29
|
createdAt: new Date(),
|
|
@@ -25,6 +40,7 @@ exports.createSystemInstruction = createSystemInstruction;
|
|
|
25
40
|
* @returns updated system instruction or null if not found
|
|
26
41
|
*/
|
|
27
42
|
const updateSystemInstruction = async (id, data) => {
|
|
43
|
+
validateInstructionData(data);
|
|
28
44
|
const result = await (0, instructions_getters_1.getSystemInstructionsCollection)().findOneAndUpdate({ _id: new index_1.ObjectId(id) }, { $set: { ...data, updatedAt: new Date() } }, { returnDocument: 'after' });
|
|
29
45
|
return result || null;
|
|
30
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.setters.js","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.setters.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;
|
|
1
|
+
{"version":3,"file":"instructions.setters.js","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.setters.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AAEpC,6DAAqF;AACrF,iEAAyE;AAEzE;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,CAAC,IAAoC,EAAE,EAAE;IACvE,IAAI,IAAI,CAAC,IAAI,IAAI,CAAE,MAAM,CAAC,MAAM,CAAC,8BAAS,CAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,IAAI,yBAAyB,MAAM,CAAC,MAAM,CAAC,8BAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClH,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,IAAI,CAAE,MAAM,CAAC,MAAM,CAAC,gCAAW,CAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACzF,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,yBAAyB,MAAM,CAAC,MAAM,CAAC,gCAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9H,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACI,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AAoB,EAAE;IAC9E,MAAM,MAAM,GAAG,MAAM,IAAA,sDAA+B,GAAE,CAAC,gBAAgB,CACrE,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,EAAE,CAAC,EAAE,EACzB,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAC5B,EAAE,cAAc,EAAE,OAAO,EAAE,CAC5B,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC,CAAC;AAPW,QAAA,yBAAyB,6BAOpC;AACF;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,KAAK,EAAE,EAAU,EAAoB,EAAE;IAChF,MAAM,MAAM,GAAG,MAAM,IAAA,sDAA+B,GAAE,CAAC,gBAAgB,CACrE,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,EAAE,CAAC,EAAE,EACzB,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAC3B,EAAC,cAAc,EAAE,OAAO,EAAC,CAC5B,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC,CAAA;AAPY,QAAA,2BAA2B,+BAOvC"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { ObjectId } from 'mongodb';
|
|
2
2
|
import { CityName } from "../utils/types";
|
|
3
|
-
export
|
|
3
|
+
export declare const MIS_TOOLS: {
|
|
4
|
+
readonly findStreet: "findStreet";
|
|
5
|
+
readonly findSubject: "findSubject";
|
|
6
|
+
};
|
|
7
|
+
export declare const QUERY_TYPES: {
|
|
8
|
+
readonly exactlyOne: "exactlyOne";
|
|
9
|
+
readonly any: "any";
|
|
10
|
+
readonly all: "all";
|
|
11
|
+
readonly none: "none";
|
|
12
|
+
};
|
|
13
|
+
export type MIS_Tool = typeof MIS_TOOLS[keyof typeof MIS_TOOLS];
|
|
14
|
+
export type QueryType = typeof QUERY_TYPES[keyof typeof QUERY_TYPES];
|
|
15
|
+
export type MIS_SystemInstruction = {
|
|
4
16
|
_id: ObjectId;
|
|
5
17
|
createdAt: Date;
|
|
6
18
|
updatedAt: Date;
|
|
7
19
|
cityName: CityName;
|
|
8
20
|
instruction: string;
|
|
9
21
|
isActive: boolean;
|
|
10
|
-
tool:
|
|
11
|
-
queryType:
|
|
22
|
+
tool: MIS_Tool;
|
|
23
|
+
queryType: QueryType;
|
|
12
24
|
tags?: string[];
|
|
13
25
|
};
|
|
14
26
|
//# sourceMappingURL=instructions.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.types.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"instructions.types.d.ts","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,eAAO,MAAM,SAAS;;;CAGZ,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAChE,MAAM,MAAM,SAAS,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,QAAQ,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUERY_TYPES = exports.MIS_TOOLS = void 0;
|
|
4
|
+
exports.MIS_TOOLS = {
|
|
5
|
+
findStreet: 'findStreet',
|
|
6
|
+
findSubject: 'findSubject'
|
|
7
|
+
};
|
|
8
|
+
exports.QUERY_TYPES = {
|
|
9
|
+
exactlyOne: 'exactlyOne',
|
|
10
|
+
any: 'any',
|
|
11
|
+
all: 'all',
|
|
12
|
+
none: 'none'
|
|
13
|
+
};
|
|
3
14
|
//# sourceMappingURL=instructions.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.types.js","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"instructions.types.js","sourceRoot":"","sources":["../../../src/municipal/systemInstructions/instructions.types.ts"],"names":[],"mappings":";;;AAIa,QAAA,SAAS,GAAG;IACvB,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;CAClB,CAAC;AAEE,QAAA,WAAW,GAAG;IACzB,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientsConfig.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/clientsConfig/clientsConfig.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAA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B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -23,17 +23,47 @@ export declare const flowMongoSchema: {
|
|
|
23
23
|
readonly conversationSettings: {
|
|
24
24
|
readonly bsonType: readonly ["object", "null"];
|
|
25
25
|
readonly properties: {
|
|
26
|
-
readonly
|
|
27
|
-
readonly bsonType: "
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
readonly interruptions: {
|
|
27
|
+
readonly bsonType: readonly ["object", "null"];
|
|
28
|
+
readonly properties: {
|
|
29
|
+
readonly enableInterruptionDetection: {
|
|
30
|
+
readonly bsonType: "bool";
|
|
31
|
+
};
|
|
32
|
+
readonly interruptionWindowSeconds: {
|
|
33
|
+
readonly bsonType: "number";
|
|
34
|
+
};
|
|
35
|
+
readonly interruptionThresholdSeconds: {
|
|
36
|
+
readonly bsonType: "number";
|
|
37
|
+
};
|
|
38
|
+
readonly interruptionInstruction: {
|
|
39
|
+
readonly bsonType: "string";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly additionalProperties: false;
|
|
34
43
|
};
|
|
35
|
-
readonly
|
|
36
|
-
readonly bsonType: "
|
|
44
|
+
readonly silence: {
|
|
45
|
+
readonly bsonType: readonly ["object", "null"];
|
|
46
|
+
readonly properties: {
|
|
47
|
+
readonly enableSilenceDetection: {
|
|
48
|
+
readonly bsonType: "bool";
|
|
49
|
+
};
|
|
50
|
+
readonly firstWarningSilenceSeconds: {
|
|
51
|
+
readonly bsonType: "number";
|
|
52
|
+
};
|
|
53
|
+
readonly firstWarningInstruction: {
|
|
54
|
+
readonly bsonType: "string";
|
|
55
|
+
};
|
|
56
|
+
readonly secondWarningSilenceSeconds: {
|
|
57
|
+
readonly bsonType: "number";
|
|
58
|
+
};
|
|
59
|
+
readonly secondWarningInstruction: {
|
|
60
|
+
readonly bsonType: "string";
|
|
61
|
+
};
|
|
62
|
+
readonly disconnectSilenceSeconds: {
|
|
63
|
+
readonly bsonType: "number";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
readonly additionalProperties: false;
|
|
37
67
|
};
|
|
38
68
|
};
|
|
39
69
|
readonly additionalProperties: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.schema.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/flows/flows.schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"flows.schema.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/flows/flows.schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHlB,CAAC"}
|
|
@@ -14,10 +14,28 @@ exports.flowMongoSchema = {
|
|
|
14
14
|
conversationSettings: {
|
|
15
15
|
bsonType: ['object', 'null'],
|
|
16
16
|
properties: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
interruptions: {
|
|
18
|
+
bsonType: ['object', 'null'],
|
|
19
|
+
properties: {
|
|
20
|
+
enableInterruptionDetection: { bsonType: 'bool' },
|
|
21
|
+
interruptionWindowSeconds: { bsonType: 'number' },
|
|
22
|
+
interruptionThresholdSeconds: { bsonType: 'number' },
|
|
23
|
+
interruptionInstruction: { bsonType: 'string' },
|
|
24
|
+
},
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
},
|
|
27
|
+
silence: {
|
|
28
|
+
bsonType: ['object', 'null'],
|
|
29
|
+
properties: {
|
|
30
|
+
enableSilenceDetection: { bsonType: 'bool' },
|
|
31
|
+
firstWarningSilenceSeconds: { bsonType: 'number' },
|
|
32
|
+
firstWarningInstruction: { bsonType: 'string' },
|
|
33
|
+
secondWarningSilenceSeconds: { bsonType: 'number' },
|
|
34
|
+
secondWarningInstruction: { bsonType: 'string' },
|
|
35
|
+
disconnectSilenceSeconds: { bsonType: 'number' },
|
|
36
|
+
},
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
},
|
|
21
39
|
},
|
|
22
40
|
additionalProperties: false,
|
|
23
41
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.schema.js","sourceRoot":"","sources":["../../../src/talkpilot/flows/flows.schema.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,CAAC;IAC/E,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;QAC7B,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAChC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ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AAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;oBAC9B,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;oBAC9B,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;iBACxC;aACF;SACF;QACD,QAAQ,EAAE;YACR,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;YAC3B,KAAK,EAAE;gBACL,QAAQ,EAAE,QAAQ;gBAClB,QAAQ,EAAE,CAAC,KAAK,CAAC;gBACjB,UAAU,EAAE;oBACV,GAAG,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;oBAC3B,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;iBAC/B;aACF;SACF;QACD,cAAc,EAAE;YACd,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;YAC3B,KAAK,EAAE;gBACL,QAAQ,EAAE,QAAQ;gBAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;gBACjC,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;oBAC5B,WAAW,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;iBACpC;aACF;SACF;KACF;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
|
|
@@ -96,11 +96,24 @@ export type UserProperty = {
|
|
|
96
96
|
name: string;
|
|
97
97
|
description: string;
|
|
98
98
|
};
|
|
99
|
-
export type
|
|
100
|
-
silenceTimeoutSeconds?: number;
|
|
99
|
+
export type InterruptionSettings = {
|
|
101
100
|
enableInterruptionDetection?: boolean;
|
|
102
|
-
|
|
101
|
+
interruptionWindowSeconds?: number;
|
|
103
102
|
interruptionThresholdSeconds?: number;
|
|
103
|
+
interruptionInstruction?: string;
|
|
104
|
+
};
|
|
105
|
+
export type SilenceEscalationSettings = {
|
|
106
|
+
enableSilenceDetection?: boolean;
|
|
107
|
+
firstWarningSilenceSeconds?: number;
|
|
108
|
+
firstWarningInstruction?: string;
|
|
109
|
+
secondWarningSilenceSeconds?: number;
|
|
110
|
+
secondWarningInstruction?: string;
|
|
111
|
+
disconnectSilenceSeconds?: number;
|
|
112
|
+
silenceTimeoutSeconds?: number;
|
|
113
|
+
};
|
|
114
|
+
export type ConversationSettings = {
|
|
115
|
+
interruptions?: InterruptionSettings;
|
|
116
|
+
silence?: SilenceEscalationSettings;
|
|
104
117
|
};
|
|
105
118
|
export type Flow = {
|
|
106
119
|
freeTextContent?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/flows/flows.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AACzD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAErC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAEh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AAE,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5B,cAAc,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,UAAU,CAAC,EAAE,GAAG,CAAC;IAGjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
findSystemInstructions
|
|
7
7
|
} from '../instructions.getters';
|
|
8
8
|
import { ObjectId } from 'mongodb';
|
|
9
|
+
import { MIS_TOOLS, QUERY_TYPES } from '../instructions.types';
|
|
9
10
|
|
|
10
11
|
describe('System Instructions Getter Tests', () => {
|
|
11
12
|
const testCity = 'Ashdod';
|
|
@@ -19,8 +20,8 @@ describe('System Instructions Getter Tests', () => {
|
|
|
19
20
|
cityName: testCity,
|
|
20
21
|
instruction: 'Find Me',
|
|
21
22
|
isActive: true,
|
|
22
|
-
tool:
|
|
23
|
-
queryType:
|
|
23
|
+
tool: MIS_TOOLS.findSubject,
|
|
24
|
+
queryType: QUERY_TYPES.any,
|
|
24
25
|
tags: ['important', 'urgent']
|
|
25
26
|
});
|
|
26
27
|
instructionId = id.toString();
|
|
@@ -30,16 +31,16 @@ describe('System Instructions Getter Tests', () => {
|
|
|
30
31
|
cityName: testCity,
|
|
31
32
|
instruction: 'Inactive One',
|
|
32
33
|
isActive: false,
|
|
33
|
-
tool:
|
|
34
|
-
queryType:
|
|
34
|
+
tool: MIS_TOOLS.findSubject,
|
|
35
|
+
queryType: QUERY_TYPES.any,
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
await createSystemInstruction({
|
|
38
39
|
cityName: otherCity,
|
|
39
40
|
instruction: 'Other City Instruction',
|
|
40
41
|
isActive: true,
|
|
41
|
-
tool:
|
|
42
|
-
queryType:
|
|
42
|
+
tool: MIS_TOOLS.findStreet,
|
|
43
|
+
queryType: QUERY_TYPES.exactlyOne,
|
|
43
44
|
});
|
|
44
45
|
});
|
|
45
46
|
|
|
@@ -70,13 +71,13 @@ describe('System Instructions Getter Tests', () => {
|
|
|
70
71
|
|
|
71
72
|
describe('getSystemInstructionsByToolAndCity', () => {
|
|
72
73
|
it('given valid city and tool when fetched then return matching instructions', async () => {
|
|
73
|
-
const result = await getSystemInstructionsByToolAndCity(testCity,
|
|
74
|
+
const result = await getSystemInstructionsByToolAndCity(testCity, MIS_TOOLS.findSubject);
|
|
74
75
|
expect(result.length).toBe(2); // One active, one inactive
|
|
75
|
-
expect(result.every(r => r.cityName === testCity && r.tool ===
|
|
76
|
+
expect(result.every(r => r.cityName === testCity && r.tool === MIS_TOOLS.findSubject)).toBe(true);
|
|
76
77
|
});
|
|
77
78
|
|
|
78
79
|
it('given valid city but wrong tool when fetched then return empty array', async () => {
|
|
79
|
-
const result = await getSystemInstructionsByToolAndCity(testCity,
|
|
80
|
+
const result = await getSystemInstructionsByToolAndCity(testCity, MIS_TOOLS.findStreet);
|
|
80
81
|
expect(result).toEqual([]);
|
|
81
82
|
});
|
|
82
83
|
});
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
deactivateSystemInstruction,
|
|
6
6
|
activateSystemInstruction
|
|
7
7
|
} from '../instructions.setters';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import {getSystemInstructionById} from '../instructions.getters';
|
|
9
|
+
import {MIS_SystemInstruction, MIS_TOOLS, QUERY_TYPES} from "../instructions.types";
|
|
10
|
+
import {ObjectId} from 'mongodb';
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
describe('System Instructions Setter Tests', () => {
|
|
@@ -16,12 +16,12 @@ describe('System Instructions Setter Tests', () => {
|
|
|
16
16
|
describe('createSystemInstruction', () => {
|
|
17
17
|
it('given valid data when created then save document with timestamps', async () => {
|
|
18
18
|
// Given
|
|
19
|
-
const instructionData: Omit<
|
|
19
|
+
const instructionData: Omit<MIS_SystemInstruction, '_id' | 'createdAt' | 'updatedAt'> = {
|
|
20
20
|
cityName: testCity,
|
|
21
21
|
instruction: 'Test Instruction',
|
|
22
22
|
isActive: true,
|
|
23
|
-
tool:
|
|
24
|
-
queryType:
|
|
23
|
+
tool: MIS_TOOLS.findSubject,
|
|
24
|
+
queryType: QUERY_TYPES.any,
|
|
25
25
|
tags: ['test', 'unit']
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -39,12 +39,12 @@ describe('System Instructions Setter Tests', () => {
|
|
|
39
39
|
|
|
40
40
|
it('given data without tags when created then save document with default isActive true and no tags', async () => {
|
|
41
41
|
// Given
|
|
42
|
-
const instructionData: Omit<
|
|
42
|
+
const instructionData: Omit<MIS_SystemInstruction, '_id' | 'createdAt' | 'updatedAt'> = {
|
|
43
43
|
cityName: testCity,
|
|
44
44
|
instruction: 'No Tags Instruction',
|
|
45
45
|
isActive: true,
|
|
46
|
-
tool:
|
|
47
|
-
queryType:
|
|
46
|
+
tool: MIS_TOOLS.findStreet,
|
|
47
|
+
queryType: QUERY_TYPES.exactlyOne,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// When
|
|
@@ -56,6 +56,32 @@ describe('System Instructions Setter Tests', () => {
|
|
|
56
56
|
expect(saved?.tags).toBeUndefined();
|
|
57
57
|
expect(saved?.isActive).toBe(true);
|
|
58
58
|
});
|
|
59
|
+
|
|
60
|
+
it('should throw error when creating with invalid tool', async () => {
|
|
61
|
+
const invalidData = {
|
|
62
|
+
cityName: testCity,
|
|
63
|
+
instruction: 'Invalid Tool Test',
|
|
64
|
+
isActive: true,
|
|
65
|
+
tool: 'invalidTool' as any,
|
|
66
|
+
queryType: QUERY_TYPES.any,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
await expect(createSystemInstruction(invalidData))
|
|
70
|
+
.rejects.toThrow(`Invalid tool value: invalidTool. Allowed values are: ${Object.values(MIS_TOOLS).join(', ')}`);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should throw error when creating with invalid queryType', async () => {
|
|
74
|
+
const invalidData = {
|
|
75
|
+
cityName: testCity,
|
|
76
|
+
instruction: 'Invalid QueryType Test',
|
|
77
|
+
isActive: true,
|
|
78
|
+
tool: MIS_TOOLS.findSubject,
|
|
79
|
+
queryType: 'invalidType' as any,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
await expect(createSystemInstruction(invalidData))
|
|
83
|
+
.rejects.toThrow(`Invalid queryType value: invalidType. Allowed values are: ${Object.values(QUERY_TYPES).join(', ')}`);
|
|
84
|
+
});
|
|
59
85
|
});
|
|
60
86
|
|
|
61
87
|
describe('updateSystemInstruction', () => {
|
|
@@ -66,8 +92,8 @@ describe('System Instructions Setter Tests', () => {
|
|
|
66
92
|
cityName: testCity,
|
|
67
93
|
instruction: 'Find Me',
|
|
68
94
|
isActive: true,
|
|
69
|
-
tool:
|
|
70
|
-
queryType:
|
|
95
|
+
tool: MIS_TOOLS.findSubject,
|
|
96
|
+
queryType: QUERY_TYPES.any,
|
|
71
97
|
});
|
|
72
98
|
instructionId = id.toString();
|
|
73
99
|
|
|
@@ -75,8 +101,8 @@ describe('System Instructions Setter Tests', () => {
|
|
|
75
101
|
cityName: testCity,
|
|
76
102
|
instruction: 'Inactive One',
|
|
77
103
|
isActive: false,
|
|
78
|
-
tool:
|
|
79
|
-
queryType:
|
|
104
|
+
tool: MIS_TOOLS.findSubject,
|
|
105
|
+
queryType: QUERY_TYPES.any,
|
|
80
106
|
});
|
|
81
107
|
});
|
|
82
108
|
it('given existing doc when updated then change values and refresh updatedAt', async () => {
|
|
@@ -99,17 +125,31 @@ describe('System Instructions Setter Tests', () => {
|
|
|
99
125
|
// When
|
|
100
126
|
await updateSystemInstruction(instructionId, {
|
|
101
127
|
isActive: false,
|
|
102
|
-
tool:
|
|
128
|
+
tool: MIS_TOOLS.findStreet,
|
|
103
129
|
tags: ['new-tag']
|
|
104
130
|
});
|
|
105
131
|
|
|
106
132
|
// Then
|
|
107
133
|
const updatedDoc = await getSystemInstructionById(instructionId);
|
|
108
134
|
expect(updatedDoc?.isActive).toBe(false);
|
|
109
|
-
expect(updatedDoc?.tool).toBe(
|
|
135
|
+
expect(updatedDoc?.tool).toBe(MIS_TOOLS.findStreet);
|
|
110
136
|
expect(updatedDoc?.tags).toEqual(['new-tag']);
|
|
111
137
|
});
|
|
112
138
|
|
|
139
|
+
it('should throw error when updating with invalid tool', async () => {
|
|
140
|
+
const invalidUpdate = { tool: 'invalidTool' as any };
|
|
141
|
+
|
|
142
|
+
await expect(updateSystemInstruction(instructionId, invalidUpdate))
|
|
143
|
+
.rejects.toThrow(`Invalid tool value: invalidTool. Allowed values are: ${Object.values(MIS_TOOLS).join(', ')}`);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should throw error when updating with invalid queryType', async () => {
|
|
147
|
+
const invalidUpdate = { queryType: 'invalidType' as any };
|
|
148
|
+
|
|
149
|
+
await expect(updateSystemInstruction(instructionId, invalidUpdate))
|
|
150
|
+
.rejects.toThrow(`Invalid queryType value: invalidType. Allowed values are: ${Object.values(QUERY_TYPES).join(', ')}`);
|
|
151
|
+
});
|
|
152
|
+
|
|
113
153
|
it('given system instructions, when deactivating it then its status updated to active', async () => {
|
|
114
154
|
//When
|
|
115
155
|
const success= await deactivateSystemInstruction(instructionId.toString());
|
|
@@ -148,8 +188,8 @@ describe('System Instructions Setter Tests', () => {
|
|
|
148
188
|
cityName: testCity,
|
|
149
189
|
instruction: 'Inactive Instruction',
|
|
150
190
|
isActive: false,
|
|
151
|
-
tool:
|
|
152
|
-
queryType:
|
|
191
|
+
tool: MIS_TOOLS.findSubject,
|
|
192
|
+
queryType: QUERY_TYPES.any,
|
|
153
193
|
});
|
|
154
194
|
instructionId = id.toString();
|
|
155
195
|
});
|
|
@@ -179,8 +219,8 @@ describe('System Instructions Setter Tests', () => {
|
|
|
179
219
|
cityName: testCity,
|
|
180
220
|
instruction: 'To be deleted',
|
|
181
221
|
isActive: true,
|
|
182
|
-
tool:
|
|
183
|
-
queryType:
|
|
222
|
+
tool: MIS_TOOLS.findSubject,
|
|
223
|
+
queryType: QUERY_TYPES.any,
|
|
184
224
|
});
|
|
185
225
|
|
|
186
226
|
const deleteResult = await deleteSystemInstruction(id.toString());
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {CityName, getDb, ObjectId} from '../index';
|
|
2
2
|
import { Collection, Filter } from 'mongodb';
|
|
3
|
-
import {
|
|
3
|
+
import { MIS_SystemInstruction, MIS_Tool } from './instructions.types';
|
|
4
4
|
|
|
5
|
-
export const getSystemInstructionsCollection = (): Collection<
|
|
6
|
-
return getDb().collection<
|
|
5
|
+
export const getSystemInstructionsCollection = (): Collection<MIS_SystemInstruction> => {
|
|
6
|
+
return getDb().collection<MIS_SystemInstruction>('system_instructions');
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Find system instructions by filter
|
|
@@ -11,8 +11,8 @@ export const getSystemInstructionsCollection = (): Collection<SystemInstruction>
|
|
|
11
11
|
* @returns array of system instructions
|
|
12
12
|
*/
|
|
13
13
|
export const findSystemInstructions = async (
|
|
14
|
-
filter: Filter<
|
|
15
|
-
): Promise<
|
|
14
|
+
filter: Filter<MIS_SystemInstruction> = {}
|
|
15
|
+
): Promise<MIS_SystemInstruction[]> => {
|
|
16
16
|
return await getSystemInstructionsCollection().find(filter).toArray();
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ export const findSystemInstructions = async (
|
|
|
21
21
|
* @param id system instruction id
|
|
22
22
|
* @returns system instruction or null if not found
|
|
23
23
|
*/
|
|
24
|
-
export const getSystemInstructionById = async (id: string): Promise<
|
|
24
|
+
export const getSystemInstructionById = async (id: string): Promise<MIS_SystemInstruction | null> => {
|
|
25
25
|
return await getSystemInstructionsCollection().findOne({ _id: new ObjectId(id) });
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -29,7 +29,7 @@ export const getSystemInstructionById = async (id: string): Promise<SystemInstru
|
|
|
29
29
|
* @param cityName city name
|
|
30
30
|
* @returns array of active system instructions
|
|
31
31
|
*/
|
|
32
|
-
export const getActiveSystemInstructionsByCity = async (cityName: CityName): Promise<
|
|
32
|
+
export const getActiveSystemInstructionsByCity = async (cityName: CityName): Promise<MIS_SystemInstruction[]> => {
|
|
33
33
|
return await getSystemInstructionsCollection().find({cityName, isActive: true}).toArray();
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -38,7 +38,7 @@ export const getActiveSystemInstructionsByCity = async (cityName: CityName): Pro
|
|
|
38
38
|
* @param toolName tool name
|
|
39
39
|
* @returns array of system instructions
|
|
40
40
|
*/
|
|
41
|
-
export const getSystemInstructionsByToolAndCity = async (cityName: CityName, toolName:
|
|
41
|
+
export const getSystemInstructionsByToolAndCity = async (cityName: CityName, toolName: MIS_Tool): Promise<MIS_SystemInstruction[]> => {
|
|
42
42
|
return await getSystemInstructionsCollection().find({cityName: cityName, tool: toolName}).toArray();
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
import { ObjectId } from '../index';
|
|
2
2
|
import { ObjectId as MongoObjectId } from 'mongodb';
|
|
3
|
-
import {
|
|
3
|
+
import { MIS_SystemInstruction, MIS_TOOLS, QUERY_TYPES } from './instructions.types';
|
|
4
4
|
import { getSystemInstructionsCollection } from './instructions.getters';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Validate system instruction data
|
|
8
|
+
* @param data partial system instruction data
|
|
9
|
+
* @throws Error if tool or queryType is invalid
|
|
10
|
+
*/
|
|
11
|
+
const validateInstructionData = (data: Partial<MIS_SystemInstruction>) => {
|
|
12
|
+
if (data.tool && !(Object.values(MIS_TOOLS) as string[]).includes(data.tool)) {
|
|
13
|
+
throw new Error(`Invalid tool value: ${data.tool}. Allowed values are: ${Object.values(MIS_TOOLS).join(', ')}`);
|
|
14
|
+
}
|
|
15
|
+
if (data.queryType && !(Object.values(QUERY_TYPES) as string[]).includes(data.queryType)) {
|
|
16
|
+
throw new Error(`Invalid queryType value: ${data.queryType}. Allowed values are: ${Object.values(QUERY_TYPES).join(', ')}`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
/**
|
|
7
21
|
* Create a new system instruction
|
|
8
22
|
* @param instructionData system instruction data
|
|
9
23
|
* @returns inserted system instruction id
|
|
10
24
|
*/
|
|
11
25
|
export const createSystemInstruction = async (
|
|
12
|
-
instructionData: Omit<
|
|
26
|
+
instructionData: Omit<MIS_SystemInstruction, '_id' | 'createdAt' | 'updatedAt'>
|
|
13
27
|
): Promise<MongoObjectId> => {
|
|
14
|
-
|
|
28
|
+
validateInstructionData(instructionData as Partial<MIS_SystemInstruction>);
|
|
29
|
+
const instruction: Omit<MIS_SystemInstruction, '_id'> = { //append doc metadata to user provided data
|
|
15
30
|
...instructionData,
|
|
16
31
|
createdAt: new Date(),
|
|
17
32
|
updatedAt: new Date(),
|
|
18
33
|
};
|
|
19
34
|
const { insertedId } = await getSystemInstructionsCollection().insertOne(
|
|
20
|
-
instruction as
|
|
35
|
+
instruction as MIS_SystemInstruction
|
|
21
36
|
);
|
|
22
37
|
return insertedId;
|
|
23
38
|
};
|
|
@@ -30,8 +45,9 @@ export const createSystemInstruction = async (
|
|
|
30
45
|
*/
|
|
31
46
|
export const updateSystemInstruction = async (
|
|
32
47
|
id: string,
|
|
33
|
-
data: Partial<Omit<
|
|
34
|
-
): Promise<
|
|
48
|
+
data: Partial<Omit<MIS_SystemInstruction, '_id' | 'createdAt' | 'updatedAt'>>
|
|
49
|
+
): Promise<MIS_SystemInstruction | null> => {
|
|
50
|
+
validateInstructionData(data as Partial<MIS_SystemInstruction>);
|
|
35
51
|
const result = await getSystemInstructionsCollection().findOneAndUpdate(
|
|
36
52
|
{ _id: new ObjectId(id) },
|
|
37
53
|
{ $set: { ...data, updatedAt: new Date() } },
|
|
@@ -2,14 +2,29 @@ import { ObjectId } from 'mongodb';
|
|
|
2
2
|
|
|
3
3
|
import {CityName} from "../utils/types";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export const MIS_TOOLS = {
|
|
6
|
+
findStreet: 'findStreet',
|
|
7
|
+
findSubject: 'findSubject'
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export const QUERY_TYPES = {
|
|
11
|
+
exactlyOne: 'exactlyOne',
|
|
12
|
+
any: 'any',
|
|
13
|
+
all: 'all',
|
|
14
|
+
none: 'none'
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export type MIS_Tool = typeof MIS_TOOLS[keyof typeof MIS_TOOLS];
|
|
18
|
+
export type QueryType = typeof QUERY_TYPES[keyof typeof QUERY_TYPES];
|
|
19
|
+
|
|
20
|
+
export type MIS_SystemInstruction = {
|
|
6
21
|
_id: ObjectId;
|
|
7
22
|
createdAt: Date;
|
|
8
23
|
updatedAt: Date;
|
|
9
24
|
cityName: CityName;
|
|
10
25
|
instruction: string;
|
|
11
26
|
isActive: boolean;
|
|
12
|
-
tool:
|
|
13
|
-
queryType:
|
|
27
|
+
tool: MIS_Tool;
|
|
28
|
+
queryType: QueryType;
|
|
14
29
|
tags?: string[]; //no tags implies all wildcard (?)
|
|
15
30
|
};
|
|
@@ -14,17 +14,25 @@ describe('flowMongoSchema', () => {
|
|
|
14
14
|
const schema: any = flowMongoSchema;
|
|
15
15
|
const convSettings = schema.properties.conversationSettings.properties;
|
|
16
16
|
|
|
17
|
-
expect(convSettings).toHaveProperty('
|
|
18
|
-
expect(convSettings.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
|
|
23
|
-
expect(
|
|
24
|
-
expect(
|
|
25
|
-
|
|
26
|
-
expect(convSettings).toHaveProperty('
|
|
27
|
-
expect(convSettings.
|
|
17
|
+
expect(convSettings).toHaveProperty('interruptions');
|
|
18
|
+
expect(convSettings.interruptions.bsonType).toEqual(['object', 'null']);
|
|
19
|
+
|
|
20
|
+
const interruptions = convSettings.interruptions.properties;
|
|
21
|
+
expect(interruptions.enableInterruptionDetection.bsonType).toEqual('bool');
|
|
22
|
+
expect(interruptions.interruptionWindowSeconds.bsonType).toEqual('number');
|
|
23
|
+
expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual('number');
|
|
24
|
+
expect(interruptions.interruptionInstruction.bsonType).toEqual('string');
|
|
25
|
+
|
|
26
|
+
expect(convSettings).toHaveProperty('silence');
|
|
27
|
+
expect(convSettings.silence.bsonType).toEqual(['object', 'null']);
|
|
28
|
+
|
|
29
|
+
const silence = convSettings.silence.properties;
|
|
30
|
+
expect(silence.enableSilenceDetection.bsonType).toEqual('bool');
|
|
31
|
+
expect(silence.firstWarningSilenceSeconds.bsonType).toEqual('number');
|
|
32
|
+
expect(silence.firstWarningInstruction.bsonType).toEqual('string');
|
|
33
|
+
expect(silence.secondWarningSilenceSeconds.bsonType).toEqual('number');
|
|
34
|
+
expect(silence.secondWarningInstruction.bsonType).toEqual('string');
|
|
35
|
+
expect(silence.disconnectSilenceSeconds.bsonType).toEqual('number');
|
|
28
36
|
});
|
|
29
37
|
});
|
|
30
38
|
|
|
@@ -11,10 +11,28 @@ export const flowMongoSchema = {
|
|
|
11
11
|
conversationSettings: {
|
|
12
12
|
bsonType: ['object', 'null'],
|
|
13
13
|
properties: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
interruptions: {
|
|
15
|
+
bsonType: ['object', 'null'],
|
|
16
|
+
properties: {
|
|
17
|
+
enableInterruptionDetection: { bsonType: 'bool' },
|
|
18
|
+
interruptionWindowSeconds: { bsonType: 'number' },
|
|
19
|
+
interruptionThresholdSeconds: { bsonType: 'number' },
|
|
20
|
+
interruptionInstruction: { bsonType: 'string' },
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
silence: {
|
|
25
|
+
bsonType: ['object', 'null'],
|
|
26
|
+
properties: {
|
|
27
|
+
enableSilenceDetection: { bsonType: 'bool' },
|
|
28
|
+
firstWarningSilenceSeconds: { bsonType: 'number' },
|
|
29
|
+
firstWarningInstruction: { bsonType: 'string' },
|
|
30
|
+
secondWarningSilenceSeconds: { bsonType: 'number' },
|
|
31
|
+
secondWarningInstruction: { bsonType: 'string' },
|
|
32
|
+
disconnectSilenceSeconds: { bsonType: 'number' },
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
},
|
|
18
36
|
},
|
|
19
37
|
additionalProperties: false,
|
|
20
38
|
},
|
|
@@ -124,11 +124,26 @@ export type UserProperty = {
|
|
|
124
124
|
description: string;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
export type
|
|
128
|
-
silenceTimeoutSeconds?: number;
|
|
127
|
+
export type InterruptionSettings = {
|
|
129
128
|
enableInterruptionDetection?: boolean;
|
|
130
|
-
|
|
129
|
+
interruptionWindowSeconds?: number;
|
|
131
130
|
interruptionThresholdSeconds?: number;
|
|
131
|
+
interruptionInstruction?: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type SilenceEscalationSettings = {
|
|
135
|
+
enableSilenceDetection?: boolean;
|
|
136
|
+
firstWarningSilenceSeconds?: number;
|
|
137
|
+
firstWarningInstruction?: string;
|
|
138
|
+
secondWarningSilenceSeconds?: number;
|
|
139
|
+
secondWarningInstruction?: string;
|
|
140
|
+
disconnectSilenceSeconds?: number;
|
|
141
|
+
silenceTimeoutSeconds?: number;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type ConversationSettings = {
|
|
145
|
+
interruptions?: InterruptionSettings;
|
|
146
|
+
silence?: SilenceEscalationSettings;
|
|
132
147
|
};
|
|
133
148
|
|
|
134
149
|
/* ---------- The Flow object ---------- */
|
|
@@ -12,7 +12,25 @@ import { ObjectId } from 'mongodb';
|
|
|
12
12
|
describe('db.phoneNumbers', () => {
|
|
13
13
|
describe('getPhoneDataByPhoneNumber', () => {
|
|
14
14
|
it('return phone number data with flow', async () => {
|
|
15
|
-
const flow = createFlow({
|
|
15
|
+
const flow = createFlow({
|
|
16
|
+
clientId: 'test-client-id',
|
|
17
|
+
conversationSettings: {
|
|
18
|
+
interruptions: {
|
|
19
|
+
enableInterruptionDetection: true,
|
|
20
|
+
interruptionWindowSeconds: 60,
|
|
21
|
+
interruptionThresholdSeconds: 10,
|
|
22
|
+
interruptionInstruction: 'I am hearing background noise that makes it hard for me to focus on what you are saying. Please try to move to a quieter place or reduce the noise so I can better assist you.',
|
|
23
|
+
},
|
|
24
|
+
silence: {
|
|
25
|
+
enableSilenceDetection: true,
|
|
26
|
+
firstWarningSilenceSeconds: 5,
|
|
27
|
+
firstWarningInstruction: 'I have not heard you for a few seconds. If you are still on the line, please say something so we can continue.',
|
|
28
|
+
secondWarningSilenceSeconds: 10,
|
|
29
|
+
secondWarningInstruction: 'I still have not heard anything from you. If you do not respond in the next few seconds, I will have to end this call.',
|
|
30
|
+
disconnectSilenceSeconds: 30,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
16
34
|
const phoneData = createPhoneNumber({ flow_id: flow._id, client_id: 'test-client-id' });
|
|
17
35
|
|
|
18
36
|
await getFlowsCollection().insertOne(flow);
|
|
@@ -28,7 +46,7 @@ describe('db.phoneNumbers', () => {
|
|
|
28
46
|
});
|
|
29
47
|
// Specifically check if the flow was joined correctly
|
|
30
48
|
expect(result?.flow.flowName).toBe(flow.flowName);
|
|
31
|
-
expect(result?.flow.conversationSettings?.
|
|
49
|
+
expect(result?.flow.conversationSettings?.silence?.firstWarningSilenceSeconds).toBe(5);
|
|
32
50
|
});
|
|
33
51
|
});
|
|
34
52
|
|
|
@@ -10,7 +10,24 @@ describe('sessions', () => {
|
|
|
10
10
|
it('returns session by incoming phone number', async () => {
|
|
11
11
|
const to = '+972500000000';
|
|
12
12
|
const from = '+972540000000';
|
|
13
|
-
const flow = createFlow({
|
|
13
|
+
const flow = createFlow({
|
|
14
|
+
conversationSettings: {
|
|
15
|
+
interruptions: {
|
|
16
|
+
enableInterruptionDetection: true,
|
|
17
|
+
interruptionWindowSeconds: 60,
|
|
18
|
+
interruptionThresholdSeconds: 10,
|
|
19
|
+
interruptionInstruction: 'I am hearing background noise that makes it hard for me to focus on what you are saying. Please try to move to a quieter place or reduce the noise so I can better assist you.',
|
|
20
|
+
},
|
|
21
|
+
silence: {
|
|
22
|
+
enableSilenceDetection: true,
|
|
23
|
+
firstWarningSilenceSeconds: 5,
|
|
24
|
+
firstWarningInstruction: 'I have not heard you for a few seconds. If you are still on the line, please say something so we can continue.',
|
|
25
|
+
secondWarningSilenceSeconds: 10,
|
|
26
|
+
secondWarningInstruction: 'I still have not heard anything from you. If you do not respond in the next few seconds, I will have to end this call.',
|
|
27
|
+
disconnectSilenceSeconds: 30,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
14
31
|
const phoneNumberData = createPhoneNumber({ phone_number: to, flow_id: flow._id });
|
|
15
32
|
const json = { [faker.lorem.word()]: faker.lorem.sentence() };
|
|
16
33
|
|