@talkpilot/core-db 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +13 -25
- 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 +3 -3
- package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.getters.js +19 -15
- package/dist/talkpilot/calls/calls.getters.js.map +1 -1
- package/dist/talkpilot/calls/calls.types.d.ts +3 -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 +9 -2
- 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.map +1 -1
- package/dist/talkpilot/flows/flows.schema.js +87 -79
- package/dist/talkpilot/flows/flows.schema.js.map +1 -1
- package/dist/talkpilot/flows/flows.types.d.ts +16 -16
- 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.d.ts.map +1 -1
- package/dist/talkpilot/mongodb-client.js +16 -29
- package/dist/talkpilot/mongodb-client.js.map +1 -1
- package/dist/talkpilot/phone_numbers/index.d.ts +2 -2
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +3 -3
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +28 -13
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +9 -9
- package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +1 -1
- 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/subscriptions/subscriptions.utils.d.ts +4 -0
- package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +1 -0
- package/dist/talkpilot/subscriptions/subscriptions.utils.js +20 -0
- package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +1 -0
- 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 +19 -26
- 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 +79 -39
- package/src/talkpilot/calls/calls.getters.ts +48 -28
- package/src/talkpilot/calls/calls.types.ts +16 -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 +17 -7
- package/src/talkpilot/clientsConfig/index.ts +2 -2
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +38 -34
- package/src/talkpilot/flows/flows.getter.ts +8 -5
- package/src/talkpilot/flows/flows.schema.ts +87 -79
- package/src/talkpilot/flows/flows.types.ts +23 -23
- 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 +23 -33
- package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +84 -44
- package/src/talkpilot/phone_numbers/index.ts +2 -2
- package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +44 -22
- package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +9 -9
- package/src/talkpilot/phone_numbers/phone_numbers.types.ts +1 -1
- 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,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
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getLeadsCollection } from
|
|
2
|
-
export type { Lead, LeadItem, LeadProperty } from
|
|
1
|
+
export { getLeadsCollection } from "./leads.getter";
|
|
2
|
+
export type { Lead, LeadItem, LeadProperty } from "./leads.types";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Collection } from
|
|
2
|
-
import { getDb } from
|
|
3
|
-
import type { Lead } from
|
|
1
|
+
import type { Collection } from "mongodb";
|
|
2
|
+
import { getDb } from "../index";
|
|
3
|
+
import type { Lead } from "./leads.types";
|
|
4
4
|
|
|
5
|
-
export const getLeadsCollection = (): Collection<Lead> =>
|
|
5
|
+
export const getLeadsCollection = (): Collection<Lead> =>
|
|
6
|
+
getDb().collection<Lead>("leads");
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
export const leadsMongoSchema = {
|
|
2
|
-
bsonType:
|
|
3
|
-
required: [
|
|
2
|
+
bsonType: "object",
|
|
3
|
+
required: ["flowId", "clientId", "createdAt", "leads"],
|
|
4
4
|
properties: {
|
|
5
|
-
_id: { bsonType:
|
|
6
|
-
flowId: { bsonType:
|
|
7
|
-
clientId: { bsonType:
|
|
8
|
-
createdAt: { bsonType:
|
|
5
|
+
_id: { bsonType: "objectId" },
|
|
6
|
+
flowId: { bsonType: "string" },
|
|
7
|
+
clientId: { bsonType: "string" },
|
|
8
|
+
createdAt: { bsonType: "date" },
|
|
9
9
|
leads: {
|
|
10
|
-
bsonType:
|
|
10
|
+
bsonType: "array",
|
|
11
11
|
items: {
|
|
12
|
-
bsonType:
|
|
13
|
-
required: [
|
|
12
|
+
bsonType: "object",
|
|
13
|
+
required: ["callSid", "timestamp"],
|
|
14
14
|
properties: {
|
|
15
|
-
callSid: { bsonType:
|
|
16
|
-
timestamp: { bsonType:
|
|
15
|
+
callSid: { bsonType: "string" },
|
|
16
|
+
timestamp: { bsonType: "date" },
|
|
17
17
|
properties: {
|
|
18
|
-
bsonType:
|
|
18
|
+
bsonType: "array",
|
|
19
19
|
items: {
|
|
20
|
-
bsonType:
|
|
21
|
-
required: [
|
|
20
|
+
bsonType: "object",
|
|
21
|
+
required: ["name", "value"],
|
|
22
22
|
properties: {
|
|
23
|
-
name: { bsonType:
|
|
24
|
-
value: { bsonType:
|
|
23
|
+
name: { bsonType: "string" },
|
|
24
|
+
value: { bsonType: "string" },
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MongoClient, Db } from
|
|
2
|
-
import { setDb } from
|
|
3
|
-
import { validateConfig, validateMongoUri } from
|
|
1
|
+
import { MongoClient, Db } from "mongodb";
|
|
2
|
+
import { setDb } from "./index";
|
|
3
|
+
import { validateConfig, validateMongoUri } from "../utils/validation";
|
|
4
4
|
|
|
5
5
|
class MongoDBClient {
|
|
6
6
|
private client: MongoClient | null = null;
|
|
@@ -22,50 +22,40 @@ class MongoDBClient {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const mongodbUri = uri || process.env.MONGO_URI || process.env.MONGODB_URI;
|
|
25
|
-
validateConfig(
|
|
25
|
+
validateConfig("MONGO_URI", mongodbUri);
|
|
26
26
|
validateMongoUri(mongodbUri!);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
await this.client.connect();
|
|
31
|
-
|
|
32
|
-
const dbNameFromUri = this.extractDatabaseName(mongodbUri!);
|
|
33
|
-
const dbNameFromEnv = process.env.MONGODB_DB_NAME;
|
|
34
|
-
const dbName = databaseName || dbNameFromUri || dbNameFromEnv;
|
|
28
|
+
this.client = new MongoClient(mongodbUri!);
|
|
29
|
+
await this.client.connect();
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
'add it to the URI, or set MONGODB_DB_NAME.'
|
|
40
|
-
);
|
|
41
|
-
}
|
|
31
|
+
const dbNameFromUri = this.extractDatabaseName(mongodbUri!);
|
|
32
|
+
const dbName =
|
|
33
|
+
databaseName || dbNameFromUri || process.env.TALKPILOT_DB_NAME;
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
throw error;
|
|
35
|
+
if (!dbName) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"[core-db] Database name not specified. Please pass databaseName to connect(), " +
|
|
38
|
+
"add it to the URI, or set TALKPILOT_DB_NAME.",
|
|
39
|
+
);
|
|
49
40
|
}
|
|
41
|
+
|
|
42
|
+
this.db = this.client.db(dbName);
|
|
43
|
+
setDb(this.db);
|
|
44
|
+
console.info(`[core-db] TalkPilot MongoDB connected: ${dbName}`);
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
async disconnect(): Promise<void> {
|
|
53
48
|
if (this.client) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.info('MongoDB disconnected successfully');
|
|
59
|
-
} catch (error) {
|
|
60
|
-
console.error('Error disconnecting from MongoDB', error as Error);
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
49
|
+
await this.client.close();
|
|
50
|
+
this.client = null;
|
|
51
|
+
this.db = null;
|
|
52
|
+
console.info("MongoDB disconnected successfully");
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
55
|
|
|
66
56
|
getDb(): Db {
|
|
67
57
|
if (!this.db) {
|
|
68
|
-
throw new Error(
|
|
58
|
+
throw new Error("Database not initialized. Call connect() first.");
|
|
69
59
|
}
|
|
70
60
|
return this.db;
|
|
71
61
|
}
|
|
@@ -4,40 +4,46 @@ import {
|
|
|
4
4
|
getClientPhoneNumber,
|
|
5
5
|
getClientPhoneData,
|
|
6
6
|
createPhoneNumberEntity,
|
|
7
|
-
} from
|
|
8
|
-
import { getFlowsCollection } from
|
|
9
|
-
import { createFlow, createPhoneNumber } from
|
|
10
|
-
import { ObjectId } from
|
|
11
|
-
|
|
12
|
-
describe(
|
|
13
|
-
describe(
|
|
14
|
-
it(
|
|
7
|
+
} from "../phone_numbers.getter";
|
|
8
|
+
import { getFlowsCollection } from "../../flows";
|
|
9
|
+
import { createFlow, createPhoneNumber } from "../../../test-utils/factories";
|
|
10
|
+
import { ObjectId } from "mongodb";
|
|
11
|
+
|
|
12
|
+
describe("db.phoneNumbers", () => {
|
|
13
|
+
describe("getPhoneDataByPhoneNumber", () => {
|
|
14
|
+
it("return phone number data with flow", async () => {
|
|
15
15
|
const flow = createFlow({
|
|
16
|
-
clientId:
|
|
16
|
+
clientId: "test-client-id",
|
|
17
17
|
conversationSettings: {
|
|
18
18
|
interruptions: {
|
|
19
19
|
enableInterruptionDetection: true,
|
|
20
20
|
interruptionWindowSeconds: 60,
|
|
21
21
|
interruptionThresholdSeconds: 10,
|
|
22
|
-
interruptionInstruction:
|
|
22
|
+
interruptionInstruction:
|
|
23
|
+
"I am hearing background noise that makes it hard for me to focus on what you are saying. Please try to move to a quieter place or reduce the noise so I can better assist you.",
|
|
23
24
|
},
|
|
24
25
|
silence: {
|
|
25
26
|
enableSilenceDetection: true,
|
|
26
27
|
firstWarningSilenceSeconds: 5,
|
|
27
|
-
firstWarningInstruction:
|
|
28
|
+
firstWarningInstruction:
|
|
29
|
+
"I have not heard you for a few seconds. If you are still on the line, please say something so we can continue.",
|
|
28
30
|
secondWarningSilenceSeconds: 10,
|
|
29
|
-
secondWarningInstruction:
|
|
31
|
+
secondWarningInstruction:
|
|
32
|
+
"I still have not heard anything from you. If you do not respond in the next few seconds, I will have to end this call.",
|
|
30
33
|
disconnectSilenceSeconds: 30,
|
|
31
34
|
},
|
|
32
35
|
},
|
|
33
36
|
});
|
|
34
|
-
const phoneData = createPhoneNumber({
|
|
35
|
-
|
|
37
|
+
const phoneData = createPhoneNumber({
|
|
38
|
+
flow_id: flow._id,
|
|
39
|
+
client_id: "test-client-id",
|
|
40
|
+
});
|
|
41
|
+
|
|
36
42
|
await getFlowsCollection().insertOne(flow);
|
|
37
43
|
await getPhoneNumbersCollection().insertOne(phoneData);
|
|
38
44
|
|
|
39
45
|
const result = await getPhoneDataByPhoneNumber(phoneData.phone_number);
|
|
40
|
-
|
|
46
|
+
|
|
41
47
|
expect(result).toBeDefined();
|
|
42
48
|
expect(result).toMatchObject({
|
|
43
49
|
client_id: phoneData.client_id,
|
|
@@ -46,15 +52,20 @@ describe('db.phoneNumbers', () => {
|
|
|
46
52
|
});
|
|
47
53
|
// Specifically check if the flow was joined correctly
|
|
48
54
|
expect(result?.flow.flowName).toBe(flow.flowName);
|
|
49
|
-
expect(
|
|
55
|
+
expect(
|
|
56
|
+
result?.flow.conversationSettings?.silence?.firstWarningSilenceSeconds,
|
|
57
|
+
).toBe(5);
|
|
50
58
|
});
|
|
51
59
|
});
|
|
52
60
|
|
|
53
|
-
describe(
|
|
54
|
-
it(
|
|
61
|
+
describe("getClientPhoneNumber", () => {
|
|
62
|
+
it("return phone number by client id", async () => {
|
|
55
63
|
const flow = createFlow();
|
|
56
|
-
const phoneData = createPhoneNumber({
|
|
57
|
-
|
|
64
|
+
const phoneData = createPhoneNumber({
|
|
65
|
+
flow_id: flow._id,
|
|
66
|
+
is_primary: true,
|
|
67
|
+
});
|
|
68
|
+
|
|
58
69
|
await getFlowsCollection().insertOne(flow);
|
|
59
70
|
await getPhoneNumbersCollection().insertOne(phoneData);
|
|
60
71
|
|
|
@@ -63,55 +74,84 @@ describe('db.phoneNumbers', () => {
|
|
|
63
74
|
});
|
|
64
75
|
});
|
|
65
76
|
|
|
66
|
-
describe(
|
|
67
|
-
it(
|
|
68
|
-
const clientId =
|
|
69
|
-
const phone1 = createPhoneNumber({
|
|
70
|
-
|
|
77
|
+
describe("getClientPhoneData", () => {
|
|
78
|
+
it("returns primary phone data by default", async () => {
|
|
79
|
+
const clientId = "multiPhoneClient";
|
|
80
|
+
const phone1 = createPhoneNumber({
|
|
81
|
+
client_id: clientId,
|
|
82
|
+
is_primary: false,
|
|
83
|
+
phone_number: "1",
|
|
84
|
+
createdAt: new Date("2023-01-01"),
|
|
85
|
+
});
|
|
86
|
+
const phone2 = createPhoneNumber({
|
|
87
|
+
client_id: clientId,
|
|
88
|
+
is_primary: true,
|
|
89
|
+
phone_number: "2",
|
|
90
|
+
createdAt: new Date("2023-01-02"),
|
|
91
|
+
});
|
|
71
92
|
|
|
72
93
|
await getPhoneNumbersCollection().insertOne(phone1);
|
|
73
94
|
await getPhoneNumbersCollection().insertOne(phone2);
|
|
74
95
|
|
|
75
96
|
const result = await getClientPhoneData(clientId);
|
|
76
|
-
expect(result?.phone_number).toBe(
|
|
97
|
+
expect(result?.phone_number).toBe("2");
|
|
77
98
|
});
|
|
78
99
|
|
|
79
|
-
it(
|
|
80
|
-
const clientId =
|
|
81
|
-
const phone1 = createPhoneNumber({
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
it("returns most recent non-primary phone data if isPrimary is false", async () => {
|
|
101
|
+
const clientId = "multiPhoneClient2";
|
|
102
|
+
const phone1 = createPhoneNumber({
|
|
103
|
+
client_id: clientId,
|
|
104
|
+
is_primary: false,
|
|
105
|
+
phone_number: "1",
|
|
106
|
+
createdAt: new Date("2023-01-01"),
|
|
107
|
+
});
|
|
108
|
+
const phone2 = createPhoneNumber({
|
|
109
|
+
client_id: clientId,
|
|
110
|
+
is_primary: false,
|
|
111
|
+
phone_number: "2",
|
|
112
|
+
createdAt: new Date("2023-01-02"),
|
|
113
|
+
});
|
|
114
|
+
const phone3 = createPhoneNumber({
|
|
115
|
+
client_id: clientId,
|
|
116
|
+
is_primary: true,
|
|
117
|
+
phone_number: "3",
|
|
118
|
+
createdAt: new Date("2023-01-03"),
|
|
119
|
+
});
|
|
84
120
|
|
|
85
121
|
await getPhoneNumbersCollection().insertOne(phone1);
|
|
86
122
|
await getPhoneNumbersCollection().insertOne(phone2);
|
|
87
123
|
await getPhoneNumbersCollection().insertOne(phone3);
|
|
88
124
|
|
|
89
125
|
const result = await getClientPhoneData(clientId, false);
|
|
90
|
-
expect(result?.phone_number).toBe(
|
|
126
|
+
expect(result?.phone_number).toBe("2");
|
|
91
127
|
});
|
|
92
128
|
});
|
|
93
129
|
|
|
94
|
-
describe(
|
|
95
|
-
it(
|
|
96
|
-
const clientId =
|
|
130
|
+
describe("createPhoneNumberEntity", () => {
|
|
131
|
+
it("creates first phone number as primary", async () => {
|
|
132
|
+
const clientId = "newClient";
|
|
97
133
|
const flowId = new ObjectId().toHexString();
|
|
98
|
-
const phoneNumber =
|
|
134
|
+
const phoneNumber = "+123456789";
|
|
99
135
|
|
|
100
|
-
const result = await createPhoneNumberEntity(
|
|
136
|
+
const result = await createPhoneNumberEntity(
|
|
137
|
+
phoneNumber,
|
|
138
|
+
flowId,
|
|
139
|
+
clientId,
|
|
140
|
+
);
|
|
101
141
|
expect(result.phone_number).toBe(phoneNumber);
|
|
102
142
|
expect(result.is_primary).toBe(true);
|
|
103
143
|
});
|
|
104
144
|
|
|
105
|
-
it(
|
|
106
|
-
const clientId =
|
|
145
|
+
it("creates subsequent phone number as non-primary", async () => {
|
|
146
|
+
const clientId = "existingClient";
|
|
107
147
|
const flowId = new ObjectId().toHexString();
|
|
108
|
-
|
|
148
|
+
|
|
109
149
|
// Create first one
|
|
110
|
-
await createPhoneNumberEntity(
|
|
111
|
-
|
|
150
|
+
await createPhoneNumberEntity("+111", flowId, clientId);
|
|
151
|
+
|
|
112
152
|
// Create second one
|
|
113
|
-
const result = await createPhoneNumberEntity(
|
|
114
|
-
expect(result.phone_number).toBe(
|
|
153
|
+
const result = await createPhoneNumberEntity("+222", flowId, clientId);
|
|
154
|
+
expect(result.phone_number).toBe("+222");
|
|
115
155
|
expect(result.is_primary).toBe(false);
|
|
116
156
|
});
|
|
117
157
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export type { PhoneNumber } from
|
|
1
|
+
export * from "./phone_numbers.getter";
|
|
2
|
+
export type { PhoneNumber } from "./phone_numbers.types";
|