@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,141 +1,148 @@
|
|
|
1
1
|
export const flowMongoSchema = {
|
|
2
|
-
bsonType:
|
|
3
|
-
required: [
|
|
2
|
+
bsonType: "object",
|
|
3
|
+
required: [
|
|
4
|
+
"flowName",
|
|
5
|
+
"systemInstructions",
|
|
6
|
+
"initialSentence",
|
|
7
|
+
"interactions",
|
|
8
|
+
],
|
|
4
9
|
properties: {
|
|
5
|
-
_id: { bsonType:
|
|
6
|
-
flowName: { bsonType:
|
|
7
|
-
clientId: { bsonType:
|
|
8
|
-
systemInstructions: { bsonType:
|
|
9
|
-
initialSentence: { bsonType:
|
|
10
|
-
voice: { bsonType: [
|
|
10
|
+
_id: { bsonType: "objectId" },
|
|
11
|
+
flowName: { bsonType: "string" },
|
|
12
|
+
clientId: { bsonType: "string" },
|
|
13
|
+
systemInstructions: { bsonType: "string" },
|
|
14
|
+
initialSentence: { bsonType: "string" },
|
|
15
|
+
voice: { bsonType: ["string", "null"] },
|
|
11
16
|
conversationSettings: {
|
|
12
|
-
bsonType: [
|
|
17
|
+
bsonType: ["object", "null"],
|
|
13
18
|
properties: {
|
|
14
19
|
interruptions: {
|
|
15
|
-
bsonType: [
|
|
20
|
+
bsonType: ["object", "null"],
|
|
16
21
|
properties: {
|
|
17
|
-
enableInterruptionDetection: { bsonType:
|
|
18
|
-
interruptionWindowSeconds: { bsonType:
|
|
19
|
-
interruptionThresholdSeconds: { bsonType:
|
|
20
|
-
interruptionInstruction: { bsonType:
|
|
22
|
+
enableInterruptionDetection: { bsonType: "bool" },
|
|
23
|
+
interruptionWindowSeconds: { bsonType: "number" },
|
|
24
|
+
interruptionThresholdSeconds: { bsonType: "number" },
|
|
25
|
+
interruptionInstruction: { bsonType: "string" },
|
|
21
26
|
},
|
|
22
27
|
additionalProperties: false,
|
|
23
28
|
},
|
|
24
29
|
silence: {
|
|
25
|
-
bsonType: [
|
|
30
|
+
bsonType: ["object", "null"],
|
|
26
31
|
properties: {
|
|
27
|
-
enableSilenceDetection: { bsonType:
|
|
28
|
-
firstWarningSilenceSeconds: { bsonType:
|
|
29
|
-
firstWarningInstruction: { bsonType:
|
|
30
|
-
secondWarningSilenceSeconds: { bsonType:
|
|
31
|
-
secondWarningInstruction: { bsonType:
|
|
32
|
-
disconnectSilenceSeconds: { bsonType:
|
|
32
|
+
enableSilenceDetection: { bsonType: "bool" },
|
|
33
|
+
firstWarningSilenceSeconds: { bsonType: "number" },
|
|
34
|
+
firstWarningInstruction: { bsonType: "string" },
|
|
35
|
+
secondWarningSilenceSeconds: { bsonType: "number" },
|
|
36
|
+
secondWarningInstruction: { bsonType: "string" },
|
|
37
|
+
disconnectSilenceSeconds: { bsonType: "number" },
|
|
33
38
|
},
|
|
34
39
|
additionalProperties: false,
|
|
35
40
|
},
|
|
36
|
-
liveTimeUpdates: { bsonType:
|
|
41
|
+
liveTimeUpdates: { bsonType: "bool" },
|
|
37
42
|
},
|
|
38
43
|
additionalProperties: false,
|
|
39
44
|
},
|
|
40
45
|
interactions: {
|
|
41
|
-
bsonType:
|
|
46
|
+
bsonType: "array",
|
|
42
47
|
items: {
|
|
43
|
-
bsonType:
|
|
44
|
-
required: [
|
|
48
|
+
bsonType: "object",
|
|
49
|
+
required: ["id", "type", "text", "position"],
|
|
45
50
|
properties: {
|
|
46
|
-
id: { bsonType:
|
|
47
|
-
type: { bsonType:
|
|
48
|
-
text: { bsonType:
|
|
49
|
-
successStatus: { bsonType: [
|
|
51
|
+
id: { bsonType: "string" },
|
|
52
|
+
type: { bsonType: "string" },
|
|
53
|
+
text: { bsonType: "string" },
|
|
54
|
+
successStatus: { bsonType: ["string", "null"] },
|
|
50
55
|
conditions: {
|
|
51
|
-
bsonType: [
|
|
56
|
+
bsonType: ["array", "null"],
|
|
52
57
|
items: {
|
|
53
|
-
bsonType:
|
|
54
|
-
required: [
|
|
58
|
+
bsonType: "object",
|
|
59
|
+
required: ["conditionString"],
|
|
55
60
|
properties: {
|
|
56
|
-
conditionString: { bsonType:
|
|
57
|
-
nodeType: { bsonType: [
|
|
58
|
-
id: { bsonType: [
|
|
61
|
+
conditionString: { bsonType: "string" },
|
|
62
|
+
nodeType: { bsonType: ["string", "null"] },
|
|
63
|
+
id: { bsonType: ["string", "null"] },
|
|
59
64
|
},
|
|
60
65
|
},
|
|
61
66
|
},
|
|
62
|
-
defaultNodeType: { bsonType: [
|
|
67
|
+
defaultNodeType: { bsonType: ["string", "null"] },
|
|
63
68
|
defaultChild: {
|
|
64
|
-
bsonType: [
|
|
65
|
-
properties: { id: { bsonType:
|
|
69
|
+
bsonType: ["object", "null"],
|
|
70
|
+
properties: { id: { bsonType: "string" } },
|
|
66
71
|
},
|
|
67
72
|
position: {
|
|
68
|
-
bsonType:
|
|
69
|
-
required: [
|
|
73
|
+
bsonType: "object",
|
|
74
|
+
required: ["x", "y"],
|
|
70
75
|
properties: {
|
|
71
|
-
x: { bsonType:
|
|
72
|
-
y: { bsonType:
|
|
76
|
+
x: { bsonType: "number" },
|
|
77
|
+
y: { bsonType: "number" },
|
|
73
78
|
},
|
|
74
79
|
},
|
|
75
|
-
name: { bsonType: [
|
|
76
|
-
children: {
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
name: { bsonType: ["string", "null"] },
|
|
81
|
+
children: {
|
|
82
|
+
bsonType: ["array", "null"],
|
|
83
|
+
items: { bsonType: "string" },
|
|
84
|
+
},
|
|
85
|
+
resultsLabel: { bsonType: ["string", "null"] },
|
|
86
|
+
resultsColor: { bsonType: ["string", "null"] },
|
|
79
87
|
},
|
|
80
88
|
},
|
|
81
89
|
},
|
|
82
90
|
edges: {
|
|
83
|
-
bsonType: [
|
|
91
|
+
bsonType: ["array", "null"],
|
|
84
92
|
items: {
|
|
85
|
-
bsonType:
|
|
86
|
-
required: [
|
|
93
|
+
bsonType: "object",
|
|
94
|
+
required: ["id", "source", "target"],
|
|
87
95
|
properties: {
|
|
88
|
-
id: { bsonType:
|
|
89
|
-
source: { bsonType:
|
|
90
|
-
target: { bsonType:
|
|
91
|
-
label: { bsonType: [
|
|
96
|
+
id: { bsonType: "string" },
|
|
97
|
+
source: { bsonType: "string" },
|
|
98
|
+
target: { bsonType: "string" },
|
|
99
|
+
label: { bsonType: ["string", "null"] },
|
|
92
100
|
},
|
|
93
101
|
},
|
|
94
102
|
},
|
|
95
103
|
metaKeys: {
|
|
96
|
-
bsonType: [
|
|
104
|
+
bsonType: ["array", "null"],
|
|
97
105
|
items: {
|
|
98
|
-
bsonType:
|
|
99
|
-
required: [
|
|
106
|
+
bsonType: "object",
|
|
107
|
+
required: ["key"],
|
|
100
108
|
properties: {
|
|
101
|
-
key: { bsonType:
|
|
102
|
-
required: { bsonType:
|
|
109
|
+
key: { bsonType: "string" },
|
|
110
|
+
required: { bsonType: "bool" },
|
|
103
111
|
},
|
|
104
112
|
},
|
|
105
113
|
},
|
|
106
114
|
userProperties: {
|
|
107
|
-
bsonType: [
|
|
115
|
+
bsonType: ["array", "null"],
|
|
108
116
|
items: {
|
|
109
|
-
bsonType:
|
|
110
|
-
required: [
|
|
117
|
+
bsonType: "object",
|
|
118
|
+
required: ["name", "description"],
|
|
111
119
|
properties: {
|
|
112
|
-
name: { bsonType:
|
|
113
|
-
description: { bsonType:
|
|
120
|
+
name: { bsonType: "string" },
|
|
121
|
+
description: { bsonType: "string" },
|
|
114
122
|
},
|
|
115
123
|
},
|
|
116
124
|
},
|
|
117
125
|
tools: {
|
|
118
|
-
bsonType: [
|
|
126
|
+
bsonType: ["array", "null"],
|
|
119
127
|
items: {
|
|
120
|
-
bsonType:
|
|
121
|
-
required: [
|
|
128
|
+
bsonType: "object",
|
|
129
|
+
required: ["id", "name", "url", "method", "parameters"],
|
|
122
130
|
properties: {
|
|
123
|
-
id: { bsonType:
|
|
124
|
-
name: { bsonType:
|
|
125
|
-
description: { bsonType:
|
|
126
|
-
url: { bsonType:
|
|
127
|
-
method: { bsonType:
|
|
128
|
-
headers: { bsonType:
|
|
129
|
-
parameters: { bsonType:
|
|
130
|
-
bodyFormat: { bsonType:
|
|
131
|
-
preventAudioDuringTool: { bsonType:
|
|
132
|
-
sendUserAuthToken: { bsonType:
|
|
133
|
-
runInBackground: { bsonType:
|
|
131
|
+
id: { bsonType: "string" },
|
|
132
|
+
name: { bsonType: "string" },
|
|
133
|
+
description: { bsonType: "string" },
|
|
134
|
+
url: { bsonType: "string" },
|
|
135
|
+
method: { bsonType: "string" },
|
|
136
|
+
headers: { bsonType: "object" },
|
|
137
|
+
parameters: { bsonType: "object" },
|
|
138
|
+
bodyFormat: { bsonType: "string", enum: ["json", "form-data"] },
|
|
139
|
+
preventAudioDuringTool: { bsonType: "bool" },
|
|
140
|
+
sendUserAuthToken: { bsonType: "bool" },
|
|
141
|
+
runInBackground: { bsonType: "bool" },
|
|
134
142
|
backgroundToolType: {
|
|
135
|
-
bsonType:
|
|
136
|
-
enum: [
|
|
143
|
+
bsonType: "string",
|
|
144
|
+
enum: ["backgroundToolAlways", "backgroundToolOnce"],
|
|
137
145
|
},
|
|
138
|
-
backgroundContinuationInstructions: { bsonType: 'string' },
|
|
139
146
|
},
|
|
140
147
|
additionalProperties: false,
|
|
141
148
|
},
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ObjectId } from
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
2
|
|
|
3
3
|
/* ---------- Basic helpers ---------- */
|
|
4
4
|
|
|
5
5
|
export type Position = { x: number; y: number };
|
|
6
|
-
export type HttpMethod =
|
|
6
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
7
7
|
|
|
8
|
-
export type QuestionType =
|
|
9
|
-
export type SelectionType =
|
|
8
|
+
export type QuestionType = "open" | "multiple" | "table";
|
|
9
|
+
export type SelectionType = "single" | "multiple";
|
|
10
10
|
|
|
11
11
|
export type Question = {
|
|
12
12
|
id: string;
|
|
@@ -24,14 +24,14 @@ export type Question = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export type NodeKind =
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
27
|
+
| "start"
|
|
28
|
+
| "say"
|
|
29
|
+
| "condition"
|
|
30
|
+
| "improvise"
|
|
31
|
+
| "tool"
|
|
32
|
+
| "sendMessage"
|
|
33
|
+
| "questionsList"
|
|
34
|
+
| "end";
|
|
35
35
|
type BaseNode = {
|
|
36
36
|
id: string;
|
|
37
37
|
type: NodeKind;
|
|
@@ -44,12 +44,12 @@ type BaseNode = {
|
|
|
44
44
|
questions?: Question[] | null;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export type StartNode = BaseNode & { type:
|
|
47
|
+
export type StartNode = BaseNode & { type: "start" };
|
|
48
48
|
|
|
49
|
-
export type SayNode = BaseNode & { type:
|
|
49
|
+
export type SayNode = BaseNode & { type: "say" };
|
|
50
50
|
|
|
51
51
|
export type ConditionNode = BaseNode & {
|
|
52
|
-
type:
|
|
52
|
+
type: "condition";
|
|
53
53
|
conditions: Array<{
|
|
54
54
|
conditionString: string;
|
|
55
55
|
nodeType?: string | null;
|
|
@@ -59,7 +59,7 @@ export type ConditionNode = BaseNode & {
|
|
|
59
59
|
defaultChild?: { id?: string } | null;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export type ImproviseNode = BaseNode & { type:
|
|
62
|
+
export type ImproviseNode = BaseNode & { type: "improvise" };
|
|
63
63
|
|
|
64
64
|
export type FlowTool = {
|
|
65
65
|
id: string;
|
|
@@ -69,18 +69,17 @@ export type FlowTool = {
|
|
|
69
69
|
method: HttpMethod;
|
|
70
70
|
headers?: Record<string, string>;
|
|
71
71
|
parameters: Record<string, unknown>;
|
|
72
|
-
bodyFormat?:
|
|
72
|
+
bodyFormat?: "json" | "form-data";
|
|
73
73
|
preventAudioDuringTool?: boolean;
|
|
74
74
|
sendUserAuthToken?: boolean;
|
|
75
75
|
runInBackground?: boolean;
|
|
76
|
-
backgroundToolType?:
|
|
77
|
-
backgroundContinuationInstructions?: string;
|
|
76
|
+
backgroundToolType?: "backgroundToolAlways" | "backgroundToolOnce";
|
|
78
77
|
};
|
|
79
78
|
|
|
80
|
-
export type SendMethod =
|
|
79
|
+
export type SendMethod = "sms" | "whatsapp";
|
|
81
80
|
|
|
82
81
|
export type SendMessageNode = BaseNode & {
|
|
83
|
-
type:
|
|
82
|
+
type: "sendMessage";
|
|
84
83
|
/** Which channel to use. If omitted, decide at runtime (e.g., default to whatsapp). */
|
|
85
84
|
send_method: SendMethod;
|
|
86
85
|
/** Destination phone (E.164 or templated string like "{{userPhone}}"). */
|
|
@@ -88,17 +87,17 @@ export type SendMessageNode = BaseNode & {
|
|
|
88
87
|
};
|
|
89
88
|
|
|
90
89
|
export type ToolNode = BaseNode & {
|
|
91
|
-
type:
|
|
90
|
+
type: "tool";
|
|
92
91
|
name: string;
|
|
93
92
|
text: string;
|
|
94
93
|
};
|
|
95
94
|
|
|
96
95
|
export type QuestionsListNode = BaseNode & {
|
|
97
|
-
type:
|
|
96
|
+
type: "questionsList";
|
|
98
97
|
questions: Question[];
|
|
99
98
|
};
|
|
100
99
|
|
|
101
|
-
export type EndNode = BaseNode & { type:
|
|
100
|
+
export type EndNode = BaseNode & { type: "end" };
|
|
102
101
|
|
|
103
102
|
export type Interaction =
|
|
104
103
|
| StartNode
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getFlowsCollection, findFlowById } from
|
|
2
|
-
export type * from
|
|
1
|
+
export { getFlowsCollection, findFlowById } from "./flows.getter";
|
|
2
|
+
export type * from "./flows.types";
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import { ObjectId } from
|
|
2
|
-
import { faker } from
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
|
+
import { faker } from "@faker-js/faker";
|
|
3
3
|
import {
|
|
4
4
|
getGroupsCollection,
|
|
5
5
|
findGroups,
|
|
6
6
|
createGroup,
|
|
7
7
|
updateGroup,
|
|
8
8
|
removeGroup,
|
|
9
|
-
} from
|
|
10
|
-
import { createGroup as createGroupDoc } from
|
|
9
|
+
} from "../groups.getters";
|
|
10
|
+
import { createGroup as createGroupDoc } from "../../../test-utils/factories";
|
|
11
11
|
|
|
12
|
-
describe(
|
|
13
|
-
describe(
|
|
12
|
+
describe("db.groups", () => {
|
|
13
|
+
describe("getGroupsCollection", () => {
|
|
14
14
|
it('returns the "groups" collection', () => {
|
|
15
|
-
expect(getGroupsCollection().collectionName).toBe(
|
|
15
|
+
expect(getGroupsCollection().collectionName).toBe("groups");
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
describe(
|
|
20
|
-
it(
|
|
19
|
+
describe("findGroups", () => {
|
|
20
|
+
it("returns groups matching the provided filter", async () => {
|
|
21
21
|
const clientId = faker.string.uuid();
|
|
22
|
-
const g1 = createGroupDoc({ clientId, name:
|
|
23
|
-
const g2 = createGroupDoc({ clientId, name:
|
|
24
|
-
const gOther = createGroupDoc({
|
|
22
|
+
const g1 = createGroupDoc({ clientId, name: "Group A" });
|
|
23
|
+
const g2 = createGroupDoc({ clientId, name: "Group B" });
|
|
24
|
+
const gOther = createGroupDoc({
|
|
25
|
+
clientId: faker.string.uuid(),
|
|
26
|
+
name: "Group C",
|
|
27
|
+
});
|
|
25
28
|
|
|
26
29
|
await getGroupsCollection().insertMany([g1, g2, gOther]);
|
|
27
30
|
|
|
@@ -29,26 +32,29 @@ describe('db.groups', () => {
|
|
|
29
32
|
const names = result.map((g) => g.name).sort();
|
|
30
33
|
|
|
31
34
|
expect(result).toHaveLength(2);
|
|
32
|
-
expect(names).toEqual([
|
|
35
|
+
expect(names).toEqual(["Group A", "Group B"]);
|
|
33
36
|
});
|
|
34
37
|
});
|
|
35
38
|
|
|
36
|
-
describe(
|
|
37
|
-
it(
|
|
38
|
-
const toInsert = createGroupDoc({ name:
|
|
39
|
+
describe("createGroup", () => {
|
|
40
|
+
it("inserts a group and returns insertedId", async () => {
|
|
41
|
+
const toInsert = createGroupDoc({ name: "New Group" });
|
|
39
42
|
|
|
40
43
|
const insertedId = await createGroup(toInsert);
|
|
41
44
|
expect(insertedId).toBeInstanceOf(ObjectId);
|
|
42
45
|
|
|
43
46
|
const fromDb = await getGroupsCollection().findOne({ _id: insertedId });
|
|
44
|
-
expect(fromDb?.name).toBe(
|
|
47
|
+
expect(fromDb?.name).toBe("New Group");
|
|
45
48
|
expect(fromDb?.clientId).toBe(toInsert.clientId);
|
|
46
49
|
});
|
|
47
50
|
});
|
|
48
51
|
|
|
49
|
-
describe(
|
|
50
|
-
it(
|
|
51
|
-
const original = createGroupDoc({
|
|
52
|
+
describe("updateGroup", () => {
|
|
53
|
+
it("updates the group and sets updatedAt, returning the updated document", async () => {
|
|
54
|
+
const original = createGroupDoc({
|
|
55
|
+
name: "Before",
|
|
56
|
+
description: "Old desc",
|
|
57
|
+
});
|
|
52
58
|
const { insertedId } = await getGroupsCollection().insertOne(original);
|
|
53
59
|
const before = await getGroupsCollection().findOne({ _id: insertedId });
|
|
54
60
|
|
|
@@ -57,21 +63,22 @@ describe('db.groups', () => {
|
|
|
57
63
|
|
|
58
64
|
const res = await updateGroup(
|
|
59
65
|
{ _id: insertedId },
|
|
60
|
-
{ name:
|
|
66
|
+
{ name: "After", description: "New desc" },
|
|
61
67
|
);
|
|
62
68
|
|
|
63
69
|
expect(res?._id).toEqual(insertedId);
|
|
64
|
-
expect(res?.name).toBe(
|
|
65
|
-
expect(res?.description).toBe(
|
|
70
|
+
expect(res?.name).toBe("After");
|
|
71
|
+
expect(res?.description).toBe("New desc");
|
|
66
72
|
expect(new Date(res!.updatedAt).getTime()).toBeGreaterThan(
|
|
67
|
-
new Date(before!.updatedAt).getTime()
|
|
73
|
+
new Date(before!.updatedAt).getTime(),
|
|
68
74
|
);
|
|
69
75
|
});
|
|
70
76
|
});
|
|
71
77
|
|
|
72
|
-
describe(
|
|
73
|
-
it(
|
|
74
|
-
const { insertedId } =
|
|
78
|
+
describe("removeGroup", () => {
|
|
79
|
+
it("removes a group by string id", async () => {
|
|
80
|
+
const { insertedId } =
|
|
81
|
+
await getGroupsCollection().insertOne(createGroupDoc());
|
|
75
82
|
|
|
76
83
|
const result = await removeGroup(insertedId.toHexString());
|
|
77
84
|
expect(result.deletedCount).toBe(1);
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { enrichPhoneNumber, isValidE164 } from
|
|
1
|
+
import { enrichPhoneNumber, isValidE164 } from "../phone.utils";
|
|
2
2
|
|
|
3
|
-
describe(
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
6
|
-
const result = enrichPhoneNumber(
|
|
7
|
-
expect(result?.e164).toBe(
|
|
3
|
+
describe("Phone Utilities", () => {
|
|
4
|
+
describe("enrichPhoneNumber", () => {
|
|
5
|
+
it("should enrich Israeli number", () => {
|
|
6
|
+
const result = enrichPhoneNumber("+972507725874");
|
|
7
|
+
expect(result?.e164).toBe("+972507725874");
|
|
8
8
|
expect(result?.region).toBeDefined();
|
|
9
|
-
expect(result?.countryCallingCode).toBe(
|
|
9
|
+
expect(result?.countryCallingCode).toBe("972");
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
it(
|
|
13
|
-
const result = enrichPhoneNumber(
|
|
14
|
-
expect(result?.region).toBe(
|
|
15
|
-
expect(result?.countryCallingCode).toBe(
|
|
12
|
+
it("should enrich US number", () => {
|
|
13
|
+
const result = enrichPhoneNumber("+12025551234");
|
|
14
|
+
expect(result?.region).toBe("US");
|
|
15
|
+
expect(result?.countryCallingCode).toBe("1");
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
it(
|
|
19
|
-
expect(enrichPhoneNumber(
|
|
20
|
-
expect(enrichPhoneNumber(
|
|
18
|
+
it("should return null for invalid", () => {
|
|
19
|
+
expect(enrichPhoneNumber("invalid")).toBeNull();
|
|
20
|
+
expect(enrichPhoneNumber("0507725874")).toBeNull();
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
describe(
|
|
25
|
-
it(
|
|
26
|
-
expect(isValidE164(
|
|
27
|
-
expect(isValidE164(
|
|
28
|
-
expect(isValidE164(
|
|
29
|
-
expect(isValidE164(
|
|
24
|
+
describe("isValidE164", () => {
|
|
25
|
+
it("should validate E.164 format", () => {
|
|
26
|
+
expect(isValidE164("+972508832983")).toBe(true);
|
|
27
|
+
expect(isValidE164("+12025551234")).toBe(true);
|
|
28
|
+
expect(isValidE164("0501234567")).toBe(false);
|
|
29
|
+
expect(isValidE164("invalid")).toBe(false);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getDb, ObjectId, Group } from
|
|
2
|
-
import { Collection, Filter } from
|
|
1
|
+
import { getDb, ObjectId, Group } from "../index";
|
|
2
|
+
import { Collection, Filter } from "mongodb";
|
|
3
3
|
|
|
4
4
|
export const getGroupsCollection = (): Collection<Group> => {
|
|
5
|
-
return getDb().collection<Group>(
|
|
5
|
+
return getDb().collection<Group>("groups");
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const findGroups = async (filter: Filter<Group>): Promise<Group[]> => {
|
|
@@ -14,11 +14,14 @@ export const createGroup = async (group: Group) => {
|
|
|
14
14
|
return insertedId;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const updateGroup = async (
|
|
17
|
+
export const updateGroup = async (
|
|
18
|
+
filter: Filter<Group>,
|
|
19
|
+
data: Partial<Group>,
|
|
20
|
+
) => {
|
|
18
21
|
return await getGroupsCollection().findOneAndUpdate(
|
|
19
22
|
filter,
|
|
20
23
|
{ $set: { ...data, updatedAt: new Date() } },
|
|
21
|
-
{ returnDocument:
|
|
24
|
+
{ returnDocument: "after" },
|
|
22
25
|
);
|
|
23
26
|
};
|
|
24
27
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./groups.getters";
|
|
2
|
+
export * from "./groups.types";
|
|
3
|
+
export * from "./phone.utils";
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { PhoneNumberUtil, PhoneNumberFormat } from
|
|
2
|
-
import type { Phone, E164, CountryISO } from
|
|
1
|
+
import { PhoneNumberUtil, PhoneNumberFormat } from "google-libphonenumber";
|
|
2
|
+
import type { Phone, E164, CountryISO } from "./groups.types";
|
|
3
3
|
|
|
4
4
|
const phoneUtil = PhoneNumberUtil.getInstance();
|
|
5
5
|
|
|
6
6
|
export const enrichPhoneNumber = (e164: string): Phone | null => {
|
|
7
7
|
try {
|
|
8
|
-
const phoneNumber = phoneUtil.parse(e164,
|
|
8
|
+
const phoneNumber = phoneUtil.parse(e164, "ZZ");
|
|
9
9
|
if (!phoneUtil.isValidNumber(phoneNumber)) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const normalizedE164 = phoneUtil.format(
|
|
13
|
+
const normalizedE164 = phoneUtil.format(
|
|
14
|
+
phoneNumber,
|
|
15
|
+
PhoneNumberFormat.E164,
|
|
16
|
+
) as E164;
|
|
14
17
|
const region = phoneUtil.getRegionCodeForNumber(phoneNumber) as CountryISO;
|
|
15
18
|
const countryCallingCode = phoneNumber.getCountryCode()?.toString();
|
|
16
19
|
const national = phoneNumber.getNationalNumber()?.toString();
|
|
17
20
|
const ext = phoneNumber.getExtension() || undefined;
|
|
18
|
-
const formatted = phoneUtil.format(
|
|
21
|
+
const formatted = phoneUtil.format(
|
|
22
|
+
phoneNumber,
|
|
23
|
+
PhoneNumberFormat.INTERNATIONAL,
|
|
24
|
+
);
|
|
19
25
|
|
|
20
26
|
return {
|
|
21
27
|
e164: normalizedE164,
|
|
@@ -32,7 +38,7 @@ export const enrichPhoneNumber = (e164: string): Phone | null => {
|
|
|
32
38
|
|
|
33
39
|
export const isValidE164 = (e164: string): boolean => {
|
|
34
40
|
try {
|
|
35
|
-
const phoneNumber = phoneUtil.parse(e164,
|
|
41
|
+
const phoneNumber = phoneUtil.parse(e164, "ZZ");
|
|
36
42
|
return phoneUtil.isValidNumber(phoneNumber);
|
|
37
43
|
} catch (error) {
|
|
38
44
|
return false;
|
package/src/talkpilot/index.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Db, ObjectId as MongoObjectId } from
|
|
1
|
+
import { Db, ObjectId as MongoObjectId } from "mongodb";
|
|
2
2
|
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export { mongodbClient } from
|
|
3
|
+
export * from "./flows";
|
|
4
|
+
export * from "./results";
|
|
5
|
+
export * from "./sessions";
|
|
6
|
+
export * from "./phone_numbers";
|
|
7
|
+
export * from "./leads";
|
|
8
|
+
export * from "./clients";
|
|
9
|
+
export * from "./agents";
|
|
10
|
+
export * from "./plans";
|
|
11
|
+
export * from "./subscriptions";
|
|
12
|
+
export * from "./groups";
|
|
13
|
+
export * from "./calls";
|
|
14
|
+
export * from "./clientAudioBuffers";
|
|
15
|
+
export * from "./clientsConfig";
|
|
16
|
+
export * from "./backgroundToolResults";
|
|
17
|
+
export { mongodbClient } from "./mongodb-client";
|
|
18
18
|
|
|
19
19
|
let db: Db;
|
|
20
20
|
export const setDb = (d: Db) => {
|
|
21
21
|
db = d;
|
|
22
22
|
};
|
|
23
23
|
export const getDb = (): Db => {
|
|
24
|
-
if (!db) throw new Error(
|
|
24
|
+
if (!db) throw new Error("DB not initialised");
|
|
25
25
|
return db;
|
|
26
26
|
};
|
|
27
27
|
|