@talkpilot/core-db 1.1.8 → 1.1.10
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/README.md +7 -0
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +21 -24
- package/dist/connection.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/municipal/cities/cities.getters.d.ts +2 -2
- package/dist/municipal/cities/cities.getters.d.ts.map +1 -1
- package/dist/municipal/cities/cities.getters.js +8 -4
- package/dist/municipal/cities/cities.getters.js.map +1 -1
- package/dist/municipal/cities/cities.types.d.ts +1 -1
- package/dist/municipal/cities/index.d.ts +2 -2
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts +3 -3
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts.map +1 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js +30 -22
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js.map +1 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts +4 -4
- package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts.map +1 -1
- package/dist/municipal/departmentsSubjects/index.d.ts +2 -2
- package/dist/municipal/index.d.ts +8 -8
- package/dist/municipal/index.d.ts.map +1 -1
- package/dist/municipal/index.js +1 -1
- package/dist/municipal/mongodb-client.d.ts +1 -1
- package/dist/municipal/mongodb-client.d.ts.map +1 -1
- package/dist/municipal/mongodb-client.js +7 -7
- package/dist/municipal/mongodb-client.js.map +1 -1
- package/dist/municipal/streets/index.d.ts +2 -2
- package/dist/municipal/streets/streets.getters.d.ts +3 -3
- package/dist/municipal/streets/streets.getters.d.ts.map +1 -1
- package/dist/municipal/streets/streets.getters.js +19 -9
- package/dist/municipal/streets/streets.getters.js.map +1 -1
- package/dist/municipal/streets/streets.types.d.ts +1 -1
- package/dist/municipal/systemInstructions/index.d.ts +3 -3
- package/dist/municipal/systemInstructions/index.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.getters.d.ts +3 -3
- package/dist/municipal/systemInstructions/instructions.getters.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.getters.js +10 -4
- package/dist/municipal/systemInstructions/instructions.getters.js.map +1 -1
- package/dist/municipal/systemInstructions/instructions.setters.d.ts +2 -2
- package/dist/municipal/systemInstructions/instructions.setters.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.setters.js +13 -8
- package/dist/municipal/systemInstructions/instructions.setters.js.map +1 -1
- package/dist/municipal/systemInstructions/instructions.types.d.ts +3 -3
- package/dist/municipal/systemInstructions/instructions.types.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.types.js +6 -6
- package/dist/municipal/tickets/index.d.ts +2 -2
- package/dist/municipal/tickets/tickets.getters.d.ts +3 -3
- package/dist/municipal/tickets/tickets.getters.d.ts.map +1 -1
- package/dist/municipal/tickets/tickets.getters.js +50 -29
- package/dist/municipal/tickets/tickets.getters.js.map +1 -1
- package/dist/municipal/tickets/tickets.types.d.ts +1 -1
- package/dist/municipal/tickets/tickets.types.d.ts.map +1 -1
- package/dist/municipal/utils/types.d.ts +1 -1
- package/dist/municipal/utils/types.d.ts.map +1 -1
- package/dist/talkpilot/agents/agents.getters.d.ts +1 -1
- package/dist/talkpilot/agents/agents.getters.js +2 -2
- package/dist/talkpilot/agents/agents.types.d.ts +2 -2
- package/dist/talkpilot/agents/index.d.ts +2 -2
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts +2 -2
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts.map +1 -1
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js +1 -1
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js.map +1 -1
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.types.d.ts +2 -2
- package/dist/talkpilot/backgroundToolResults/index.d.ts +2 -2
- package/dist/talkpilot/calls/calls.getters.d.ts +4 -3
- package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.getters.js +24 -16
- package/dist/talkpilot/calls/calls.getters.js.map +1 -1
- package/dist/talkpilot/calls/calls.types.d.ts +26 -3
- package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.types.js +2 -2
- package/dist/talkpilot/calls/index.d.ts +2 -2
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts +2 -2
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts.map +1 -1
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js +2 -2
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js.map +1 -1
- package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts +2 -2
- package/dist/talkpilot/clientAudioBuffers/index.d.ts +2 -2
- package/dist/talkpilot/clients/clients.getters.d.ts +2 -2
- package/dist/talkpilot/clients/clients.getters.d.ts.map +1 -1
- package/dist/talkpilot/clients/clients.getters.js +5 -2
- package/dist/talkpilot/clients/clients.getters.js.map +1 -1
- package/dist/talkpilot/clients/clients.types.d.ts +1 -1
- package/dist/talkpilot/clients/index.d.ts +2 -2
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +2 -2
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +3 -3
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
- package/dist/talkpilot/clientsConfig/index.d.ts +2 -2
- package/dist/talkpilot/flows/flows.getter.d.ts +2 -2
- package/dist/talkpilot/flows/flows.getter.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.getter.js +1 -1
- package/dist/talkpilot/flows/flows.getter.js.map +1 -1
- package/dist/talkpilot/flows/flows.schema.d.ts +0 -3
- package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.schema.js +87 -80
- package/dist/talkpilot/flows/flows.schema.js.map +1 -1
- package/dist/talkpilot/flows/flows.types.d.ts +16 -17
- package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
- package/dist/talkpilot/flows/index.d.ts +2 -2
- package/dist/talkpilot/groups/groups.getters.d.ts +2 -2
- package/dist/talkpilot/groups/groups.getters.d.ts.map +1 -1
- package/dist/talkpilot/groups/groups.getters.js +2 -2
- package/dist/talkpilot/groups/groups.getters.js.map +1 -1
- package/dist/talkpilot/groups/groups.types.d.ts +1 -1
- package/dist/talkpilot/groups/index.d.ts +3 -3
- package/dist/talkpilot/groups/phone.utils.d.ts +1 -1
- package/dist/talkpilot/groups/phone.utils.d.ts.map +1 -1
- package/dist/talkpilot/groups/phone.utils.js +2 -2
- package/dist/talkpilot/groups/phone.utils.js.map +1 -1
- package/dist/talkpilot/index.d.ts +16 -16
- package/dist/talkpilot/index.js +1 -1
- package/dist/talkpilot/leads/index.d.ts +2 -2
- package/dist/talkpilot/leads/leads.getter.d.ts +2 -2
- package/dist/talkpilot/leads/leads.getter.d.ts.map +1 -1
- package/dist/talkpilot/leads/leads.getter.js +1 -1
- package/dist/talkpilot/leads/leads.getter.js.map +1 -1
- package/dist/talkpilot/leads/leads.schema.js +16 -16
- package/dist/talkpilot/leads/leads.types.d.ts +1 -1
- package/dist/talkpilot/mongodb-client.d.ts +1 -1
- package/dist/talkpilot/mongodb-client.js +8 -9
- package/dist/talkpilot/mongodb-client.js.map +1 -1
- package/dist/talkpilot/phone_numbers/index.d.ts +1 -1
- package/dist/talkpilot/phone_numbers/index.d.ts.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +5 -2
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +66 -12
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.schema.d.ts +11 -2
- package/dist/talkpilot/phone_numbers/phone_numbers.schema.d.ts.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +5 -2
- package/dist/talkpilot/phone_numbers/phone_numbers.schema.js.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +16 -3
- package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -1
- package/dist/talkpilot/plans/index.d.ts +2 -2
- package/dist/talkpilot/plans/plans.getters.d.ts +2 -2
- package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -1
- package/dist/talkpilot/plans/plans.getters.js +3 -3
- package/dist/talkpilot/plans/plans.getters.js.map +1 -1
- package/dist/talkpilot/plans/plans.types.d.ts +4 -4
- package/dist/talkpilot/plans/plans.types.d.ts.map +1 -1
- package/dist/talkpilot/plans/plans.types.js +19 -19
- package/dist/talkpilot/results/index.d.ts +2 -2
- package/dist/talkpilot/results/index.d.ts.map +1 -1
- package/dist/talkpilot/results/index.js.map +1 -1
- package/dist/talkpilot/results/results.getter.d.ts +3 -3
- package/dist/talkpilot/results/results.getter.d.ts.map +1 -1
- package/dist/talkpilot/results/results.getter.js +4 -4
- package/dist/talkpilot/results/results.getter.js.map +1 -1
- package/dist/talkpilot/results/results.schema.js +18 -18
- package/dist/talkpilot/results/results.types.d.ts +1 -1
- package/dist/talkpilot/sessions/index.d.ts +2 -2
- package/dist/talkpilot/sessions/sessions.getter.d.ts +3 -3
- package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -1
- package/dist/talkpilot/sessions/sessions.getter.js +13 -10
- package/dist/talkpilot/sessions/sessions.getter.js.map +1 -1
- package/dist/talkpilot/sessions/sessions.schema.js +17 -17
- package/dist/talkpilot/sessions/sessions.types.d.ts +2 -2
- package/dist/talkpilot/subscriptions/index.d.ts +3 -3
- package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +2 -2
- package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.getters.js +11 -11
- package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +2 -2
- package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +2 -2
- package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.types.js +7 -7
- package/dist/talkpilot/utils/query.utils.d.ts +1 -1
- package/dist/test-utils/db-utils.d.ts +1 -1
- package/dist/test-utils/db-utils.js +2 -2
- package/dist/test-utils/factories/index.d.ts +12 -12
- package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
- package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/cities.js +1 -1
- package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
- package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/departmentsSubjects.js +7 -1
- package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
- package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
- package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/streets.js +6 -1
- package/dist/test-utils/factories/municipal/streets.js.map +1 -1
- package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
- package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/tickets.js +7 -1
- package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/agents.js +4 -4
- package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/calls.js +1 -1
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
- package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/groups.js +9 -9
- package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
- package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
- package/dist/utils/validation.js +2 -2
- package/dist/utils/validation.js.map +1 -1
- package/package.json +3 -1
- package/src/__tests__/setup.ts +3 -3
- package/src/connection.ts +27 -25
- package/src/index.ts +9 -9
- package/src/municipal/__tests__/validation.spec.ts +35 -23
- package/src/municipal/cities/cities.getters.ts +16 -10
- package/src/municipal/cities/cities.types.ts +1 -1
- package/src/municipal/cities/index.ts +2 -2
- package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +53 -44
- package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
- package/src/municipal/departmentsSubjects/index.ts +2 -3
- package/src/municipal/index.ts +10 -10
- package/src/municipal/mongodb-client.ts +13 -10
- package/src/municipal/streets/index.ts +2 -2
- package/src/municipal/streets/streets.getters.ts +43 -23
- package/src/municipal/streets/streets.types.ts +1 -1
- package/src/municipal/systemInstructions/__tests__/getters.spec.ts +67 -52
- package/src/municipal/systemInstructions/__tests__/setters.spec.ts +271 -238
- package/src/municipal/systemInstructions/index.ts +7 -3
- package/src/municipal/systemInstructions/instructions.getters.ts +30 -18
- package/src/municipal/systemInstructions/instructions.setters.ts +43 -19
- package/src/municipal/systemInstructions/instructions.types.ts +10 -10
- package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
- package/src/municipal/tickets/index.ts +2 -2
- package/src/municipal/tickets/tickets.getters.ts +69 -42
- package/src/municipal/tickets/tickets.types.ts +2 -2
- package/src/municipal/utils/types.ts +8 -3
- package/src/talkpilot/__tests__/db.spec.ts +12 -12
- package/src/talkpilot/__tests__/mongodb-client.spec.ts +7 -8
- package/src/talkpilot/__tests__/validation.spec.ts +30 -24
- package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
- package/src/talkpilot/agents/agents.getters.ts +3 -3
- package/src/talkpilot/agents/agents.types.ts +2 -2
- package/src/talkpilot/agents/index.ts +2 -2
- package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +42 -31
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +2 -3
- package/src/talkpilot/backgroundToolResults/index.ts +2 -2
- package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
- package/src/talkpilot/calls/__tests__/calls.spec.ts +178 -40
- package/src/talkpilot/calls/calls.getters.ts +57 -27
- package/src/talkpilot/calls/calls.types.ts +39 -16
- package/src/talkpilot/calls/index.ts +2 -2
- package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +73 -39
- package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +18 -11
- package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
- package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
- package/src/talkpilot/clients/clients.getters.ts +10 -5
- package/src/talkpilot/clients/clients.types.ts +1 -1
- package/src/talkpilot/clients/index.ts +2 -2
- package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +21 -18
- package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +6 -4
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +10 -8
- package/src/talkpilot/clientsConfig/index.ts +2 -2
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +38 -37
- package/src/talkpilot/flows/flows.getter.ts +8 -5
- package/src/talkpilot/flows/flows.schema.ts +87 -80
- package/src/talkpilot/flows/flows.types.ts +23 -24
- package/src/talkpilot/flows/index.ts +2 -2
- package/src/talkpilot/groups/__tests__/groups.spec.ts +34 -27
- package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
- package/src/talkpilot/groups/groups.getters.ts +8 -5
- package/src/talkpilot/groups/groups.types.ts +1 -1
- package/src/talkpilot/groups/index.ts +3 -3
- package/src/talkpilot/groups/phone.utils.ts +12 -6
- package/src/talkpilot/index.ts +17 -17
- package/src/talkpilot/leads/index.ts +2 -2
- package/src/talkpilot/leads/leads.getter.ts +5 -4
- package/src/talkpilot/leads/leads.schema.ts +16 -16
- package/src/talkpilot/leads/leads.types.ts +1 -1
- package/src/talkpilot/mongodb-client.ts +12 -12
- package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +162 -33
- package/src/talkpilot/phone_numbers/index.ts +1 -1
- package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +94 -18
- package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +5 -2
- package/src/talkpilot/phone_numbers/phone_numbers.types.ts +18 -3
- package/src/talkpilot/plans/__tests__/plans.spec.ts +30 -26
- package/src/talkpilot/plans/index.ts +2 -2
- package/src/talkpilot/plans/plans.getters.ts +25 -18
- package/src/talkpilot/plans/plans.types.ts +27 -23
- package/src/talkpilot/results/index.ts +5 -2
- package/src/talkpilot/results/results.getter.ts +9 -8
- package/src/talkpilot/results/results.schema.ts +18 -18
- package/src/talkpilot/results/results.types.ts +1 -1
- package/src/talkpilot/sessions/__tests__/sessions.spec.ts +65 -41
- package/src/talkpilot/sessions/index.ts +2 -2
- package/src/talkpilot/sessions/sessions.getter.ts +21 -16
- package/src/talkpilot/sessions/sessions.schema.ts +17 -17
- package/src/talkpilot/sessions/sessions.types.ts +2 -2
- package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +18 -15
- package/src/talkpilot/subscriptions/index.ts +3 -3
- package/src/talkpilot/subscriptions/subscriptions.getters.ts +36 -33
- package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +10 -3
- package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
- package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
- package/src/talkpilot/utils/query.utils.ts +2 -2
- package/src/test-utils/db-utils.ts +5 -5
- package/src/test-utils/factories/index.ts +12 -12
- package/src/test-utils/factories/municipal/cities.ts +5 -5
- package/src/test-utils/factories/municipal/departmentsSubjects.ts +32 -25
- package/src/test-utils/factories/municipal/streets.ts +10 -5
- package/src/test-utils/factories/municipal/tickets.ts +12 -6
- package/src/test-utils/factories/talkpilot/agents.ts +8 -8
- package/src/test-utils/factories/talkpilot/calls.ts +5 -5
- package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +14 -12
- package/src/test-utils/factories/talkpilot/clientsConfig.ts +7 -8
- package/src/test-utils/factories/talkpilot/flows.ts +7 -5
- package/src/test-utils/factories/talkpilot/groups.ts +13 -13
- package/src/test-utils/factories/talkpilot/phone_numbers.ts +8 -6
- package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
- package/src/utils/validation.ts +4 -4
|
@@ -1,241 +1,274 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import {getSystemInstructionById} from
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
2
|
+
createSystemInstruction,
|
|
3
|
+
updateSystemInstruction,
|
|
4
|
+
deleteSystemInstruction,
|
|
5
|
+
deactivateSystemInstruction,
|
|
6
|
+
activateSystemInstruction,
|
|
7
|
+
} from "../instructions.setters";
|
|
8
|
+
import { getSystemInstructionById } from "../instructions.getters";
|
|
9
|
+
import {
|
|
10
|
+
MIS_SystemInstruction,
|
|
11
|
+
MIS_TOOLS,
|
|
12
|
+
QUERY_TYPES,
|
|
13
|
+
} from "../instructions.types";
|
|
14
|
+
import { ObjectId } from "mongodb";
|
|
15
|
+
|
|
16
|
+
describe("System Instructions Setter Tests", () => {
|
|
17
|
+
const testCity = "Ashdod";
|
|
18
|
+
|
|
19
|
+
describe("createSystemInstruction", () => {
|
|
20
|
+
it("given valid data when created then save document with timestamps", async () => {
|
|
21
|
+
// Given
|
|
22
|
+
const instructionData: Omit<
|
|
23
|
+
MIS_SystemInstruction,
|
|
24
|
+
"_id" | "createdAt" | "updatedAt"
|
|
25
|
+
> = {
|
|
26
|
+
cityName: testCity,
|
|
27
|
+
instruction: "Test Instruction",
|
|
28
|
+
isActive: true,
|
|
29
|
+
tool: MIS_TOOLS.findSubject,
|
|
30
|
+
queryType: QUERY_TYPES.any,
|
|
31
|
+
tags: ["test", "unit"],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// When
|
|
35
|
+
const id = await createSystemInstruction(instructionData);
|
|
36
|
+
|
|
37
|
+
// Then
|
|
38
|
+
const saved = await getSystemInstructionById(id.toString());
|
|
39
|
+
expect(saved).toBeDefined();
|
|
40
|
+
expect(saved?._id).toBeDefined();
|
|
41
|
+
expect(saved).toMatchObject(instructionData);
|
|
42
|
+
expect(saved?.createdAt).toBeInstanceOf(Date);
|
|
43
|
+
expect(saved?.updatedAt).toBeInstanceOf(Date);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("given data without tags when created then save document with default isActive true and no tags", async () => {
|
|
47
|
+
// Given
|
|
48
|
+
const instructionData: Omit<
|
|
49
|
+
MIS_SystemInstruction,
|
|
50
|
+
"_id" | "createdAt" | "updatedAt"
|
|
51
|
+
> = {
|
|
52
|
+
cityName: testCity,
|
|
53
|
+
instruction: "No Tags Instruction",
|
|
54
|
+
isActive: true,
|
|
55
|
+
tool: MIS_TOOLS.findStreet,
|
|
56
|
+
queryType: QUERY_TYPES.exactlyOne,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// When
|
|
60
|
+
const id = await createSystemInstruction(instructionData);
|
|
61
|
+
|
|
62
|
+
// Then
|
|
63
|
+
const saved = await getSystemInstructionById(id.toString());
|
|
64
|
+
expect(saved).toBeDefined();
|
|
65
|
+
expect(saved?.tags).toBeUndefined();
|
|
66
|
+
expect(saved?.isActive).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should throw error when creating with invalid tool", async () => {
|
|
70
|
+
const invalidData = {
|
|
71
|
+
cityName: testCity,
|
|
72
|
+
instruction: "Invalid Tool Test",
|
|
73
|
+
isActive: true,
|
|
74
|
+
tool: "invalidTool" as any,
|
|
75
|
+
queryType: QUERY_TYPES.any,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
await expect(createSystemInstruction(invalidData)).rejects.toThrow(
|
|
79
|
+
`Invalid tool value: invalidTool. Allowed values are: ${Object.values(MIS_TOOLS).join(", ")}`,
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should throw error when creating with invalid queryType", async () => {
|
|
84
|
+
const invalidData = {
|
|
85
|
+
cityName: testCity,
|
|
86
|
+
instruction: "Invalid QueryType Test",
|
|
87
|
+
isActive: true,
|
|
88
|
+
tool: MIS_TOOLS.findSubject,
|
|
89
|
+
queryType: "invalidType" as any,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
await expect(createSystemInstruction(invalidData)).rejects.toThrow(
|
|
93
|
+
`Invalid queryType value: invalidType. Allowed values are: ${Object.values(QUERY_TYPES).join(", ")}`,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("updateSystemInstruction", () => {
|
|
99
|
+
let instructionId: string;
|
|
100
|
+
//Given before each test
|
|
101
|
+
beforeEach(async () => {
|
|
102
|
+
const id = await createSystemInstruction({
|
|
103
|
+
cityName: testCity,
|
|
104
|
+
instruction: "Find Me",
|
|
105
|
+
isActive: true,
|
|
106
|
+
tool: MIS_TOOLS.findSubject,
|
|
107
|
+
queryType: QUERY_TYPES.any,
|
|
108
|
+
});
|
|
109
|
+
instructionId = id.toString();
|
|
110
|
+
|
|
111
|
+
await createSystemInstruction({
|
|
112
|
+
cityName: testCity,
|
|
113
|
+
instruction: "Inactive One",
|
|
114
|
+
isActive: false,
|
|
115
|
+
tool: MIS_TOOLS.findSubject,
|
|
116
|
+
queryType: QUERY_TYPES.any,
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
it("given existing doc when updated then change values and refresh updatedAt", async () => {
|
|
120
|
+
const originalDoc = await getSystemInstructionById(
|
|
121
|
+
instructionId.toString(),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// Wait a bit to ensure timestamp difference
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
126
|
+
|
|
127
|
+
// When
|
|
128
|
+
await updateSystemInstruction(instructionId.toString(), {
|
|
129
|
+
instruction: "New Text",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Then
|
|
133
|
+
const updatedDoc = await getSystemInstructionById(
|
|
134
|
+
instructionId.toString(),
|
|
135
|
+
);
|
|
136
|
+
expect(updatedDoc?.instruction).toBe("New Text");
|
|
137
|
+
expect(updatedDoc?.updatedAt.getTime()).toBeGreaterThan(
|
|
138
|
+
originalDoc!.updatedAt.getTime(),
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("given multiple fields when updated then change all provided values", async () => {
|
|
143
|
+
// When
|
|
144
|
+
await updateSystemInstruction(instructionId, {
|
|
145
|
+
isActive: false,
|
|
146
|
+
tool: MIS_TOOLS.findStreet,
|
|
147
|
+
tags: ["new-tag"],
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Then
|
|
151
|
+
const updatedDoc = await getSystemInstructionById(instructionId);
|
|
152
|
+
expect(updatedDoc?.isActive).toBe(false);
|
|
153
|
+
expect(updatedDoc?.tool).toBe(MIS_TOOLS.findStreet);
|
|
154
|
+
expect(updatedDoc?.tags).toEqual(["new-tag"]);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should throw error when updating with invalid tool", async () => {
|
|
158
|
+
const invalidUpdate = { tool: "invalidTool" as any };
|
|
159
|
+
|
|
160
|
+
await expect(
|
|
161
|
+
updateSystemInstruction(instructionId, invalidUpdate),
|
|
162
|
+
).rejects.toThrow(
|
|
163
|
+
`Invalid tool value: invalidTool. Allowed values are: ${Object.values(MIS_TOOLS).join(", ")}`,
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("should throw error when updating with invalid queryType", async () => {
|
|
168
|
+
const invalidUpdate = { queryType: "invalidType" as any };
|
|
169
|
+
|
|
170
|
+
await expect(
|
|
171
|
+
updateSystemInstruction(instructionId, invalidUpdate),
|
|
172
|
+
).rejects.toThrow(
|
|
173
|
+
`Invalid queryType value: invalidType. Allowed values are: ${Object.values(QUERY_TYPES).join(", ")}`,
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("given system instructions, when deactivating it then its status updated to active", async () => {
|
|
178
|
+
//When
|
|
179
|
+
const success = await deactivateSystemInstruction(
|
|
180
|
+
instructionId.toString(),
|
|
181
|
+
);
|
|
182
|
+
const updatedDoc = await getSystemInstructionById(
|
|
183
|
+
instructionId.toString(),
|
|
184
|
+
);
|
|
185
|
+
//Then
|
|
186
|
+
expect(success).toBe(true);
|
|
187
|
+
expect(updatedDoc?.isActive).toBe(false);
|
|
188
|
+
});
|
|
189
|
+
it("given invalidId when deactivating it then return false", async () => {
|
|
190
|
+
//When
|
|
191
|
+
const success = await deactivateSystemInstruction(
|
|
192
|
+
new ObjectId().toHexString(),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
//Then
|
|
196
|
+
expect(success).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("given already inactive instruction when deactivating then still return true and remain inactive", async () => {
|
|
200
|
+
// Given
|
|
201
|
+
await deactivateSystemInstruction(instructionId);
|
|
202
|
+
|
|
203
|
+
// When
|
|
204
|
+
const success = await deactivateSystemInstruction(instructionId);
|
|
205
|
+
|
|
206
|
+
// Then
|
|
207
|
+
expect(success).toBe(true);
|
|
208
|
+
const doc = await getSystemInstructionById(instructionId);
|
|
209
|
+
expect(doc?.isActive).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe("activateSystemInstruction", () => {
|
|
214
|
+
let instructionId: string;
|
|
215
|
+
beforeEach(async () => {
|
|
216
|
+
const id = await createSystemInstruction({
|
|
217
|
+
cityName: testCity,
|
|
218
|
+
instruction: "Inactive Instruction",
|
|
219
|
+
isActive: false,
|
|
220
|
+
tool: MIS_TOOLS.findSubject,
|
|
221
|
+
queryType: QUERY_TYPES.any,
|
|
222
|
+
});
|
|
223
|
+
instructionId = id.toString();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("given inactive doc when activating then set isActive to true", async () => {
|
|
227
|
+
// When
|
|
228
|
+
const success = await activateSystemInstruction(instructionId);
|
|
229
|
+
|
|
230
|
+
// Then
|
|
231
|
+
expect(success).toBe(true);
|
|
232
|
+
const updatedDoc = await getSystemInstructionById(instructionId);
|
|
233
|
+
expect(updatedDoc?.isActive).toBe(true);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("given invalidId when activating then return false", async () => {
|
|
237
|
+
// When
|
|
238
|
+
const success = await activateSystemInstruction(
|
|
239
|
+
new ObjectId().toHexString(),
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Then
|
|
243
|
+
expect(success).toBe(false);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe("deleteSystemInstruction", () => {
|
|
248
|
+
it("given existing id when deleted then remove document from DB", async () => {
|
|
249
|
+
const id = await createSystemInstruction({
|
|
250
|
+
cityName: testCity,
|
|
251
|
+
instruction: "To be deleted",
|
|
252
|
+
isActive: true,
|
|
253
|
+
tool: MIS_TOOLS.findSubject,
|
|
254
|
+
queryType: QUERY_TYPES.any,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const deleteResult = await deleteSystemInstruction(id.toString());
|
|
258
|
+
expect(deleteResult).toBe(true);
|
|
259
|
+
|
|
260
|
+
const findResult = await getSystemInstructionById(id.toString());
|
|
261
|
+
expect(findResult).toBeNull();
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("given non-existent id when deleting then return false", async () => {
|
|
265
|
+
// When
|
|
266
|
+
const result = await deleteSystemInstruction(
|
|
267
|
+
new ObjectId().toHexString(),
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
// Then
|
|
271
|
+
expect(result).toBe(false);
|
|
240
272
|
});
|
|
273
|
+
});
|
|
241
274
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export type {
|
|
1
|
+
export * from "./instructions.getters";
|
|
2
|
+
export * from "./instructions.setters";
|
|
3
|
+
export type {
|
|
4
|
+
MIS_SystemInstruction,
|
|
5
|
+
MIS_Tool,
|
|
6
|
+
QueryType,
|
|
7
|
+
} from "./instructions.types";
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {CityName, getDb, ObjectId} from
|
|
2
|
-
import { Collection, Filter } from
|
|
3
|
-
import { MIS_SystemInstruction, MIS_Tool } from
|
|
1
|
+
import { CityName, getDb, ObjectId } from "../index";
|
|
2
|
+
import { Collection, Filter } from "mongodb";
|
|
3
|
+
import { MIS_SystemInstruction, MIS_Tool } from "./instructions.types";
|
|
4
4
|
|
|
5
|
-
export const getSystemInstructionsCollection =
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export const getSystemInstructionsCollection =
|
|
6
|
+
(): Collection<MIS_SystemInstruction> => {
|
|
7
|
+
return getDb().collection<MIS_SystemInstruction>("system_instructions");
|
|
8
|
+
};
|
|
8
9
|
/**
|
|
9
10
|
* Find system instructions by filter
|
|
10
11
|
* @param filter filter to apply
|
|
11
12
|
* @returns array of system instructions
|
|
12
13
|
*/
|
|
13
14
|
export const findSystemInstructions = async (
|
|
14
|
-
filter: Filter<MIS_SystemInstruction> = {}
|
|
15
|
+
filter: Filter<MIS_SystemInstruction> = {},
|
|
15
16
|
): Promise<MIS_SystemInstruction[]> => {
|
|
16
17
|
return await getSystemInstructionsCollection().find(filter).toArray();
|
|
17
18
|
};
|
|
@@ -21,25 +22,36 @@ export const findSystemInstructions = async (
|
|
|
21
22
|
* @param id system instruction id
|
|
22
23
|
* @returns system instruction or null if not found
|
|
23
24
|
*/
|
|
24
|
-
export const getSystemInstructionById = async (
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
export const getSystemInstructionById = async (
|
|
26
|
+
id: string,
|
|
27
|
+
): Promise<MIS_SystemInstruction | null> => {
|
|
28
|
+
return await getSystemInstructionsCollection().findOne({
|
|
29
|
+
_id: new ObjectId(id),
|
|
30
|
+
});
|
|
31
|
+
};
|
|
27
32
|
/**
|
|
28
33
|
* Get all active system instructions for a city
|
|
29
34
|
* @param cityName city name
|
|
30
35
|
* @returns array of active system instructions
|
|
31
36
|
*/
|
|
32
|
-
export const getActiveSystemInstructionsByCity = async (
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
export const getActiveSystemInstructionsByCity = async (
|
|
38
|
+
cityName: CityName,
|
|
39
|
+
): Promise<MIS_SystemInstruction[]> => {
|
|
40
|
+
return await getSystemInstructionsCollection()
|
|
41
|
+
.find({ cityName, isActive: true })
|
|
42
|
+
.toArray();
|
|
43
|
+
};
|
|
35
44
|
/**
|
|
36
45
|
* Get system instructions by tool and city
|
|
37
46
|
* @param cityName city name
|
|
38
47
|
* @param toolName tool name
|
|
39
48
|
* @returns array of system instructions
|
|
40
49
|
*/
|
|
41
|
-
export const getSystemInstructionsByToolAndCity = async (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
export const getSystemInstructionsByToolAndCity = async (
|
|
51
|
+
cityName: CityName,
|
|
52
|
+
toolName: MIS_Tool,
|
|
53
|
+
): Promise<MIS_SystemInstruction[]> => {
|
|
54
|
+
return await getSystemInstructionsCollection()
|
|
55
|
+
.find({ cityName: cityName, tool: toolName })
|
|
56
|
+
.toArray();
|
|
57
|
+
};
|