@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
|
@@ -4,46 +4,66 @@ import {
|
|
|
4
4
|
findClientAudioBuffersByCallSidAndRange,
|
|
5
5
|
getMergedAudioByCallSid,
|
|
6
6
|
getAudioChunksByCallSid,
|
|
7
|
-
} from
|
|
8
|
-
import { ObjectId } from
|
|
9
|
-
import { createAudioBufferInput } from
|
|
7
|
+
} from "../clientAudioBuffer.getters";
|
|
8
|
+
import { ObjectId } from "../../index";
|
|
9
|
+
import { createAudioBufferInput } from "../../../test-utils/factories";
|
|
10
10
|
|
|
11
|
-
describe(
|
|
11
|
+
describe("clientAudioBuffers getters", () => {
|
|
12
12
|
it('should return the "clientAudioBuffers" collection', () => {
|
|
13
13
|
const collection = getClientAudioBuffersCollection();
|
|
14
|
-
expect(collection.collectionName).toBe(
|
|
14
|
+
expect(collection.collectionName).toBe("clientAudioBuffers");
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
it(
|
|
17
|
+
it("should insert a client audio buffer and return insertedId", async () => {
|
|
18
18
|
const inputToCheck = createAudioBufferInput();
|
|
19
19
|
const result = await insertClientAudioBuffer(inputToCheck);
|
|
20
20
|
expect(result.insertedId).toBeInstanceOf(ObjectId);
|
|
21
21
|
|
|
22
|
-
const savedDoc = await getClientAudioBuffersCollection().findOne({
|
|
22
|
+
const savedDoc = await getClientAudioBuffersCollection().findOne({
|
|
23
|
+
_id: result.insertedId,
|
|
24
|
+
});
|
|
23
25
|
expect(savedDoc).toBeDefined();
|
|
24
26
|
expect(savedDoc?.createdAt).toBeInstanceOf(Date);
|
|
25
27
|
expect(savedDoc?.expiresAt).toBeInstanceOf(Date);
|
|
26
28
|
});
|
|
27
29
|
|
|
28
|
-
it(
|
|
29
|
-
const callSid =
|
|
30
|
-
await insertClientAudioBuffer(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await insertClientAudioBuffer(
|
|
30
|
+
it("should return only buffers in the specified bucketStartMs range", async () => {
|
|
31
|
+
const callSid = "CA1234567890abcdef1234567890abcdef";
|
|
32
|
+
await insertClientAudioBuffer(
|
|
33
|
+
createAudioBufferInput({ callSid, bucketStartMs: 500 }),
|
|
34
|
+
);
|
|
35
|
+
await insertClientAudioBuffer(
|
|
36
|
+
createAudioBufferInput({ callSid, bucketStartMs: 1000 }),
|
|
37
|
+
);
|
|
38
|
+
await insertClientAudioBuffer(
|
|
39
|
+
createAudioBufferInput({ callSid, bucketStartMs: 3000 }),
|
|
40
|
+
);
|
|
41
|
+
await insertClientAudioBuffer(
|
|
42
|
+
createAudioBufferInput({ callSid, bucketStartMs: 6000 }),
|
|
43
|
+
);
|
|
34
44
|
|
|
35
|
-
const result = await findClientAudioBuffersByCallSidAndRange(
|
|
45
|
+
const result = await findClientAudioBuffersByCallSidAndRange(
|
|
46
|
+
callSid,
|
|
47
|
+
500,
|
|
48
|
+
3000,
|
|
49
|
+
);
|
|
36
50
|
expect(result).toHaveLength(3);
|
|
37
51
|
const bucketStartValues = result.map((doc) => doc.bucketStartMs);
|
|
38
52
|
const bucketStartsSorted = bucketStartValues.sort((a, b) => a - b);
|
|
39
53
|
expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
|
|
40
54
|
});
|
|
41
55
|
|
|
42
|
-
it(
|
|
43
|
-
const callSid =
|
|
44
|
-
await insertClientAudioBuffer(
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
it("should return all buffers when no range is provided", async () => {
|
|
57
|
+
const callSid = "CA1234567890abcdef1234567890abcdeg";
|
|
58
|
+
await insertClientAudioBuffer(
|
|
59
|
+
createAudioBufferInput({ callSid, bucketStartMs: 500 }),
|
|
60
|
+
);
|
|
61
|
+
await insertClientAudioBuffer(
|
|
62
|
+
createAudioBufferInput({ callSid, bucketStartMs: 1000 }),
|
|
63
|
+
);
|
|
64
|
+
await insertClientAudioBuffer(
|
|
65
|
+
createAudioBufferInput({ callSid, bucketStartMs: 3000 }),
|
|
66
|
+
);
|
|
47
67
|
|
|
48
68
|
const result = await findClientAudioBuffersByCallSidAndRange(callSid);
|
|
49
69
|
expect(result).toHaveLength(3);
|
|
@@ -52,21 +72,33 @@ describe('clientAudioBuffers getters', () => {
|
|
|
52
72
|
expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
|
|
53
73
|
});
|
|
54
74
|
|
|
55
|
-
it(
|
|
56
|
-
const callSid =
|
|
75
|
+
it("should merge audio buffers by callSid in chronological order", async () => {
|
|
76
|
+
const callSid = "CA1234567890abcdef1234567890abcdeh";
|
|
57
77
|
|
|
58
78
|
const firstBuffer = Buffer.from([1, 2]);
|
|
59
79
|
const secondBuffer = Buffer.from([3]);
|
|
60
80
|
const thirdBuffer = Buffer.from([4, 5]);
|
|
61
81
|
|
|
62
82
|
await insertClientAudioBuffer(
|
|
63
|
-
|
|
83
|
+
createAudioBufferInput({
|
|
84
|
+
callSid,
|
|
85
|
+
bucketStartMs: 1000,
|
|
86
|
+
data: secondBuffer,
|
|
87
|
+
}),
|
|
64
88
|
);
|
|
65
89
|
await insertClientAudioBuffer(
|
|
66
|
-
|
|
90
|
+
createAudioBufferInput({
|
|
91
|
+
callSid,
|
|
92
|
+
bucketStartMs: 500,
|
|
93
|
+
data: firstBuffer,
|
|
94
|
+
}),
|
|
67
95
|
);
|
|
68
96
|
await insertClientAudioBuffer(
|
|
69
|
-
|
|
97
|
+
createAudioBufferInput({
|
|
98
|
+
callSid,
|
|
99
|
+
bucketStartMs: 3000,
|
|
100
|
+
data: thirdBuffer,
|
|
101
|
+
}),
|
|
70
102
|
);
|
|
71
103
|
|
|
72
104
|
const merged = await getMergedAudioByCallSid(callSid, 10);
|
|
@@ -77,8 +109,8 @@ describe('clientAudioBuffers getters', () => {
|
|
|
77
109
|
expect(merged.equals(expected)).toBe(true);
|
|
78
110
|
});
|
|
79
111
|
|
|
80
|
-
it(
|
|
81
|
-
const callSid =
|
|
112
|
+
it("should return all audio chunks when less than or equal to limit buffers exist", async () => {
|
|
113
|
+
const callSid = "CA1234567890abcdef1234567890abclt";
|
|
82
114
|
|
|
83
115
|
const limit = 30;
|
|
84
116
|
const buffers: Buffer[] = [];
|
|
@@ -86,11 +118,11 @@ describe('clientAudioBuffers getters', () => {
|
|
|
86
118
|
const buf = Buffer.from([i]);
|
|
87
119
|
buffers.push(buf);
|
|
88
120
|
await insertClientAudioBuffer(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
121
|
+
createAudioBufferInput({
|
|
122
|
+
callSid,
|
|
123
|
+
bucketStartMs: 1000 + i * 1000,
|
|
124
|
+
data: buf,
|
|
125
|
+
}),
|
|
94
126
|
);
|
|
95
127
|
}
|
|
96
128
|
|
|
@@ -101,8 +133,8 @@ describe('clientAudioBuffers getters', () => {
|
|
|
101
133
|
expect(Buffer.concat(chunks).equals(Buffer.concat(buffers))).toBe(true);
|
|
102
134
|
});
|
|
103
135
|
|
|
104
|
-
it(
|
|
105
|
-
const callSid =
|
|
136
|
+
it("should return only the last N audio chunks when more than limit buffers exist", async () => {
|
|
137
|
+
const callSid = "CA1234567890abcdef1234567890abclm";
|
|
106
138
|
|
|
107
139
|
const limit = 30;
|
|
108
140
|
const buffers: Buffer[] = [];
|
|
@@ -110,17 +142,19 @@ describe('clientAudioBuffers getters', () => {
|
|
|
110
142
|
const buf = Buffer.from([i]);
|
|
111
143
|
buffers.push(buf);
|
|
112
144
|
await insertClientAudioBuffer(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
145
|
+
createAudioBufferInput({
|
|
146
|
+
callSid,
|
|
147
|
+
bucketStartMs: 1000 + i * 1000,
|
|
148
|
+
data: buf,
|
|
149
|
+
}),
|
|
118
150
|
);
|
|
119
151
|
}
|
|
120
152
|
|
|
121
153
|
const chunks = await getAudioChunksByCallSid(callSid, limit);
|
|
122
154
|
const expectedBuffers = buffers.slice(-limit);
|
|
123
155
|
expect(chunks).toHaveLength(expectedBuffers.length);
|
|
124
|
-
expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(
|
|
156
|
+
expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(
|
|
157
|
+
true,
|
|
158
|
+
);
|
|
125
159
|
});
|
|
126
160
|
});
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { getDb } from
|
|
1
|
+
import { getDb } from "../index";
|
|
2
2
|
import {
|
|
3
3
|
ClientAudioBufferDoc,
|
|
4
4
|
ClientAudioBufferType,
|
|
5
5
|
CreateAudioBufferInput,
|
|
6
|
-
} from
|
|
7
|
-
import { Collection, InsertOneResult } from
|
|
6
|
+
} from "./clientsAudioBuffers.types";
|
|
7
|
+
import { Collection, InsertOneResult } from "mongodb";
|
|
8
8
|
|
|
9
|
-
const getClientAudioBuffersCollection =
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const getClientAudioBuffersCollection =
|
|
10
|
+
(): Collection<ClientAudioBufferType> => {
|
|
11
|
+
return getDb().collection<ClientAudioBufferType>("clientAudioBuffers");
|
|
12
|
+
};
|
|
12
13
|
|
|
13
14
|
const insertClientAudioBuffer = async (
|
|
14
|
-
audioBufferInput: CreateAudioBufferInput
|
|
15
|
+
audioBufferInput: CreateAudioBufferInput,
|
|
15
16
|
): Promise<InsertOneResult<ClientAudioBufferType>> => {
|
|
16
17
|
const collection = getClientAudioBuffersCollection();
|
|
17
18
|
const realtimeDate = new Date();
|
|
@@ -27,7 +28,7 @@ const insertClientAudioBuffer = async (
|
|
|
27
28
|
};
|
|
28
29
|
const clientAudioBufferMongoDocument: ClientAudioBufferType = {
|
|
29
30
|
...inputFieldsForDocument,
|
|
30
|
-
codec:
|
|
31
|
+
codec: "mulaw",
|
|
31
32
|
sampleRateHz: 8000,
|
|
32
33
|
channels: 1,
|
|
33
34
|
createdAt: realtimeDate,
|
|
@@ -39,7 +40,7 @@ const insertClientAudioBuffer = async (
|
|
|
39
40
|
const findClientAudioBuffersByCallSidAndRange = async (
|
|
40
41
|
callSid: string,
|
|
41
42
|
startMs?: number,
|
|
42
|
-
endMs?: number
|
|
43
|
+
endMs?: number,
|
|
43
44
|
): Promise<ClientAudioBufferDoc[]> => {
|
|
44
45
|
const collection = getClientAudioBuffersCollection();
|
|
45
46
|
if (startMs === undefined) {
|
|
@@ -57,7 +58,10 @@ const findClientAudioBuffersByCallSidAndRange = async (
|
|
|
57
58
|
.toArray();
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
const getAudioChunksByCallSid = async (
|
|
61
|
+
const getAudioChunksByCallSid = async (
|
|
62
|
+
callSid: string,
|
|
63
|
+
limit?: number,
|
|
64
|
+
): Promise<Buffer[]> => {
|
|
61
65
|
const query = getClientAudioBuffersCollection().find({ callSid });
|
|
62
66
|
if (limit) {
|
|
63
67
|
query.sort({ bucketStartMs: -1 }).limit(limit);
|
|
@@ -80,7 +84,10 @@ const getAudioChunksByCallSid = async (callSid: string, limit?: number): Promise
|
|
|
80
84
|
});
|
|
81
85
|
};
|
|
82
86
|
|
|
83
|
-
const getMergedAudioByCallSid = async (
|
|
87
|
+
const getMergedAudioByCallSid = async (
|
|
88
|
+
callSid: string,
|
|
89
|
+
limit: number,
|
|
90
|
+
): Promise<Buffer> => {
|
|
84
91
|
const buffers = await getAudioChunksByCallSid(callSid, limit);
|
|
85
92
|
|
|
86
93
|
if (!buffers.length) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { WithId } from
|
|
1
|
+
import { WithId } from "mongodb";
|
|
2
2
|
|
|
3
3
|
export type ClientAudioBufferType = {
|
|
4
4
|
callSid: string;
|
|
5
5
|
clientId: string;
|
|
6
6
|
bucketStartMs: number;
|
|
7
7
|
bucketDurationMs: number;
|
|
8
|
-
codec:
|
|
8
|
+
codec: "mulaw";
|
|
9
9
|
sampleRateHz: 8000;
|
|
10
10
|
channels: 1;
|
|
11
11
|
data: Buffer;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./clientAudioBuffer.getters";
|
|
2
|
+
export * from "./clientsAudioBuffers.types";
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { getDb, Client } from
|
|
2
|
-
import { Collection } from
|
|
1
|
+
import { getDb, Client } from "../index";
|
|
2
|
+
import { Collection } from "mongodb";
|
|
3
3
|
|
|
4
4
|
export const getClientsCollection = (): Collection<Client> => {
|
|
5
|
-
return getDb().collection<Client>(
|
|
5
|
+
return getDb().collection<Client>("clients");
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export const getClientByAPIKey = async (
|
|
9
|
-
|
|
8
|
+
export const getClientByAPIKey = async (
|
|
9
|
+
apiKey: string,
|
|
10
|
+
): Promise<Client | null> => {
|
|
11
|
+
const client = await getClientsCollection().findOne({
|
|
12
|
+
apiKey,
|
|
13
|
+
isActive: true,
|
|
14
|
+
});
|
|
10
15
|
return client ? client : null;
|
|
11
16
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./clients.getters";
|
|
2
|
+
export * from "./clients.types";
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createClientConfigDoc,
|
|
3
|
+
getClientConfig,
|
|
4
|
+
} from "../clientsConfig.getters";
|
|
5
|
+
import { createClientConfig } from "../../../test-utils/factories";
|
|
3
6
|
|
|
4
|
-
describe(
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
7
|
-
const clientId =
|
|
7
|
+
describe("db.clientsConfig", () => {
|
|
8
|
+
describe("getClientConfig", () => {
|
|
9
|
+
it("should return client config by clientId", async () => {
|
|
10
|
+
const clientId = "test-client-id";
|
|
8
11
|
const clientConfig = createClientConfig({
|
|
9
12
|
clientId,
|
|
10
|
-
language:
|
|
13
|
+
language: "Hebrew",
|
|
11
14
|
products: { feature1: true, feature2: false } as any,
|
|
12
15
|
});
|
|
13
16
|
|
|
@@ -17,25 +20,25 @@ describe('db.clientsConfig', () => {
|
|
|
17
20
|
|
|
18
21
|
expect(result).toMatchObject({
|
|
19
22
|
clientId,
|
|
20
|
-
language:
|
|
23
|
+
language: "Hebrew",
|
|
21
24
|
products: { feature1: true, feature2: false },
|
|
22
25
|
});
|
|
23
26
|
});
|
|
24
27
|
|
|
25
|
-
it(
|
|
26
|
-
const result = await getClientConfig(
|
|
28
|
+
it("should return null for non-existent clientId", async () => {
|
|
29
|
+
const result = await getClientConfig("non-existent-client");
|
|
27
30
|
expect(result).toBeNull();
|
|
28
31
|
});
|
|
29
32
|
|
|
30
|
-
it(
|
|
31
|
-
const clientId =
|
|
33
|
+
it("should support communications config", async () => {
|
|
34
|
+
const clientId = "communications-test";
|
|
32
35
|
const clientConfig = createClientConfig({
|
|
33
36
|
clientId,
|
|
34
37
|
communications: {
|
|
35
38
|
sendGrid: {
|
|
36
|
-
emailTo: [
|
|
37
|
-
templateId:
|
|
38
|
-
senderId:
|
|
39
|
+
emailTo: ["test@example.com"],
|
|
40
|
+
templateId: "temp-123",
|
|
41
|
+
senderId: "sender-123",
|
|
39
42
|
},
|
|
40
43
|
sms: {},
|
|
41
44
|
whatsapp: {},
|
|
@@ -50,9 +53,9 @@ describe('db.clientsConfig', () => {
|
|
|
50
53
|
clientId,
|
|
51
54
|
communications: {
|
|
52
55
|
sendGrid: {
|
|
53
|
-
emailTo: [
|
|
54
|
-
templateId:
|
|
55
|
-
senderId:
|
|
56
|
+
emailTo: ["test@example.com"],
|
|
57
|
+
templateId: "temp-123",
|
|
58
|
+
senderId: "sender-123",
|
|
56
59
|
},
|
|
57
60
|
sms: {},
|
|
58
61
|
whatsapp: {},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClientConfigDoc, getDb, findClientByPhoneNumber } from
|
|
2
|
-
import { Collection } from
|
|
1
|
+
import { ClientConfigDoc, getDb, findClientByPhoneNumber } from "../index";
|
|
2
|
+
import { Collection } from "mongodb";
|
|
3
3
|
|
|
4
4
|
export const getClientsConfigCollection = (): Collection<ClientConfigDoc> => {
|
|
5
|
-
return getDb().collection<ClientConfigDoc>(
|
|
5
|
+
return getDb().collection<ClientConfigDoc>("clientsConfig");
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const getClientConfig = (clientId: string) => {
|
|
@@ -15,6 +15,8 @@ export const getClientConfigByPhone = async (phone: string) => {
|
|
|
15
15
|
return getClientConfig(client.clientId);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const createClientConfigDoc = async (
|
|
18
|
+
export const createClientConfigDoc = async (
|
|
19
|
+
clientConfig: ClientConfigDoc,
|
|
20
|
+
): Promise<void> => {
|
|
19
21
|
await getClientsConfigCollection().insertOne(clientConfig);
|
|
20
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithId } from
|
|
1
|
+
import { WithId } from "mongodb";
|
|
2
2
|
|
|
3
3
|
export type InitiateCallForShortSlaConfig = {
|
|
4
4
|
active: boolean;
|
|
@@ -35,16 +35,16 @@ export type Products = {
|
|
|
35
35
|
export type ClinicsProduct = {
|
|
36
36
|
api_key_secret_name: string;
|
|
37
37
|
base_api_url: string;
|
|
38
|
-
provider:
|
|
38
|
+
provider: "clinix" | (string & {});
|
|
39
39
|
description?: string;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export type ClientLanguageName =
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
43
|
+
| "Hebrew"
|
|
44
|
+
| "English"
|
|
45
|
+
| "Russian"
|
|
46
|
+
| "French"
|
|
47
|
+
| "Spanish"
|
|
48
48
|
| (string & {});
|
|
49
49
|
|
|
50
50
|
export type SendGridConfig = {
|
|
@@ -72,4 +72,6 @@ export type ClientConfig<P extends Products = Products> = {
|
|
|
72
72
|
communications?: CommunicationsConfig;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
export type ClientConfigDoc<P extends Products = Products> = WithId<
|
|
75
|
+
export type ClientConfigDoc<P extends Products = Products> = WithId<
|
|
76
|
+
ClientConfig<P>
|
|
77
|
+
>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./clientsConfig.types";
|
|
2
|
+
export * from "./clientsConfig.getters";
|
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
import { flowMongoSchema } from
|
|
1
|
+
import { flowMongoSchema } from "../flows.schema";
|
|
2
2
|
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
3
|
+
describe("flowMongoSchema", () => {
|
|
4
|
+
it("defines conversationSettings as optional object or null", () => {
|
|
5
5
|
const schema: any = flowMongoSchema;
|
|
6
6
|
|
|
7
|
-
expect(schema.properties).toHaveProperty(
|
|
8
|
-
expect(schema.properties.conversationSettings.bsonType).toEqual([
|
|
9
|
-
|
|
7
|
+
expect(schema.properties).toHaveProperty("conversationSettings");
|
|
8
|
+
expect(schema.properties.conversationSettings.bsonType).toEqual([
|
|
9
|
+
"object",
|
|
10
|
+
"null",
|
|
11
|
+
]);
|
|
12
|
+
expect(schema.required).not.toContain("conversationSettings");
|
|
10
13
|
expect(schema.additionalProperties).toBe(false);
|
|
11
14
|
});
|
|
12
15
|
|
|
13
|
-
it(
|
|
16
|
+
it("defines conversationSettings with expected nested properties", () => {
|
|
14
17
|
const schema: any = flowMongoSchema;
|
|
15
18
|
const convSettings = schema.properties.conversationSettings.properties;
|
|
16
19
|
|
|
17
|
-
expect(convSettings).toHaveProperty(
|
|
18
|
-
expect(convSettings.interruptions.bsonType).toEqual([
|
|
20
|
+
expect(convSettings).toHaveProperty("interruptions");
|
|
21
|
+
expect(convSettings.interruptions.bsonType).toEqual(["object", "null"]);
|
|
19
22
|
|
|
20
23
|
const interruptions = convSettings.interruptions.properties;
|
|
21
|
-
expect(interruptions.enableInterruptionDetection.bsonType).toEqual(
|
|
22
|
-
expect(interruptions.interruptionWindowSeconds.bsonType).toEqual(
|
|
23
|
-
expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual(
|
|
24
|
-
|
|
24
|
+
expect(interruptions.enableInterruptionDetection.bsonType).toEqual("bool");
|
|
25
|
+
expect(interruptions.interruptionWindowSeconds.bsonType).toEqual("number");
|
|
26
|
+
expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual(
|
|
27
|
+
"number",
|
|
28
|
+
);
|
|
29
|
+
expect(interruptions.interruptionInstruction.bsonType).toEqual("string");
|
|
25
30
|
|
|
26
|
-
expect(convSettings).toHaveProperty(
|
|
27
|
-
expect(convSettings.silence.bsonType).toEqual([
|
|
31
|
+
expect(convSettings).toHaveProperty("silence");
|
|
32
|
+
expect(convSettings.silence.bsonType).toEqual(["object", "null"]);
|
|
28
33
|
|
|
29
34
|
const silence = convSettings.silence.properties;
|
|
30
|
-
expect(silence.enableSilenceDetection.bsonType).toEqual(
|
|
31
|
-
expect(silence.firstWarningSilenceSeconds.bsonType).toEqual(
|
|
32
|
-
expect(silence.firstWarningInstruction.bsonType).toEqual(
|
|
33
|
-
expect(silence.secondWarningSilenceSeconds.bsonType).toEqual(
|
|
34
|
-
expect(silence.secondWarningInstruction.bsonType).toEqual(
|
|
35
|
-
expect(silence.disconnectSilenceSeconds.bsonType).toEqual(
|
|
36
|
-
expect(convSettings).toHaveProperty(
|
|
37
|
-
expect(convSettings.liveTimeUpdates.bsonType).toEqual(
|
|
35
|
+
expect(silence.enableSilenceDetection.bsonType).toEqual("bool");
|
|
36
|
+
expect(silence.firstWarningSilenceSeconds.bsonType).toEqual("number");
|
|
37
|
+
expect(silence.firstWarningInstruction.bsonType).toEqual("string");
|
|
38
|
+
expect(silence.secondWarningSilenceSeconds.bsonType).toEqual("number");
|
|
39
|
+
expect(silence.secondWarningInstruction.bsonType).toEqual("string");
|
|
40
|
+
expect(silence.disconnectSilenceSeconds.bsonType).toEqual("number");
|
|
41
|
+
expect(convSettings).toHaveProperty("liveTimeUpdates");
|
|
42
|
+
expect(convSettings.liveTimeUpdates.bsonType).toEqual("bool");
|
|
38
43
|
});
|
|
39
44
|
|
|
40
|
-
it(
|
|
45
|
+
it("should define tools schema and return a backgroundToolType enum with allowed values", () => {
|
|
41
46
|
const schema: any = flowMongoSchema;
|
|
42
47
|
|
|
43
|
-
expect(schema.properties).toHaveProperty(
|
|
44
|
-
expect(schema.properties.tools.bsonType).toEqual([
|
|
48
|
+
expect(schema.properties).toHaveProperty("tools");
|
|
49
|
+
expect(schema.properties.tools.bsonType).toEqual(["array", "null"]);
|
|
45
50
|
|
|
46
51
|
const toolItem = schema.properties.tools.items;
|
|
47
|
-
expect(toolItem.bsonType).toBe(
|
|
52
|
+
expect(toolItem.bsonType).toBe("object");
|
|
48
53
|
|
|
49
|
-
expect(toolItem.properties).toHaveProperty(
|
|
50
|
-
expect(toolItem.properties.runInBackground.bsonType).toBe(
|
|
54
|
+
expect(toolItem.properties).toHaveProperty("runInBackground");
|
|
55
|
+
expect(toolItem.properties.runInBackground.bsonType).toBe("bool");
|
|
51
56
|
|
|
52
|
-
expect(toolItem.properties).toHaveProperty(
|
|
53
|
-
expect(toolItem.properties.backgroundToolType.bsonType).toBe(
|
|
57
|
+
expect(toolItem.properties).toHaveProperty("backgroundToolType");
|
|
58
|
+
expect(toolItem.properties.backgroundToolType.bsonType).toBe("string");
|
|
54
59
|
expect(toolItem.properties.backgroundToolType.enum).toEqual([
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
"backgroundToolAlways",
|
|
61
|
+
"backgroundToolOnce",
|
|
57
62
|
]);
|
|
58
|
-
|
|
59
|
-
expect(toolItem.properties).toHaveProperty('backgroundContinuationInstructions');
|
|
60
|
-
expect(toolItem.properties.backgroundContinuationInstructions.bsonType).toBe('string');
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
|
-
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { Collection, ObjectId, WithId } from
|
|
2
|
-
import { getDb } from
|
|
3
|
-
import type { Flow } from
|
|
1
|
+
import type { Collection, ObjectId, WithId } from "mongodb";
|
|
2
|
+
import { getDb } from "../index";
|
|
3
|
+
import type { Flow } from "./flows.types";
|
|
4
4
|
|
|
5
5
|
export const getFlowsCollection = (): Collection<Flow> => {
|
|
6
|
-
return getDb().collection<Flow>(
|
|
6
|
+
return getDb().collection<Flow>("flows");
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const findFlowById = (
|
|
9
|
+
export const findFlowById = (
|
|
10
|
+
flowId: ObjectId,
|
|
11
|
+
clientId: string,
|
|
12
|
+
): Promise<WithId<Flow> | null> => {
|
|
10
13
|
return getFlowsCollection().findOne({ _id: flowId, clientId });
|
|
11
14
|
};
|