@talkpilot/core-db 1.1.6 → 1.1.8
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 +24 -21
- 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 +4 -8
- 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 +22 -30
- 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 +25 -13
- 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 +9 -19
- 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 +4 -10
- 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 +8 -13
- 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 +29 -50
- 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 +15 -19
- 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 +2 -5
- 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 +3 -0
- package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.schema.js +80 -87
- package/dist/talkpilot/flows/flows.schema.js.map +1 -1
- package/dist/talkpilot/flows/flows.types.d.ts +17 -16
- 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.d.ts.map +1 -1
- package/dist/talkpilot/mongodb-client.js +29 -16
- 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 +13 -28
- 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 +10 -13
- 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 +1 -7
- 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 +1 -6
- 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 +1 -7
- 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 +1 -3
- package/src/__tests__/setup.ts +3 -3
- package/src/connection.ts +25 -27
- package/src/index.ts +9 -9
- package/src/municipal/__tests__/validation.spec.ts +23 -35
- package/src/municipal/cities/cities.getters.ts +10 -16
- package/src/municipal/cities/cities.types.ts +1 -1
- package/src/municipal/cities/index.ts +2 -2
- package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +44 -53
- package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
- package/src/municipal/departmentsSubjects/index.ts +3 -2
- package/src/municipal/index.ts +10 -10
- package/src/municipal/mongodb-client.ts +26 -19
- package/src/municipal/streets/index.ts +2 -2
- package/src/municipal/streets/streets.getters.ts +23 -43
- package/src/municipal/streets/streets.types.ts +1 -1
- package/src/municipal/systemInstructions/__tests__/getters.spec.ts +52 -67
- package/src/municipal/systemInstructions/__tests__/setters.spec.ts +238 -271
- package/src/municipal/systemInstructions/index.ts +3 -7
- package/src/municipal/systemInstructions/instructions.getters.ts +18 -30
- package/src/municipal/systemInstructions/instructions.setters.ts +19 -43
- 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 +42 -69
- package/src/municipal/tickets/tickets.types.ts +2 -2
- package/src/municipal/utils/types.ts +3 -8
- package/src/talkpilot/__tests__/db.spec.ts +12 -12
- package/src/talkpilot/__tests__/mongodb-client.spec.ts +8 -7
- package/src/talkpilot/__tests__/validation.spec.ts +24 -30
- 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 +31 -42
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +3 -2
- 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 +39 -79
- package/src/talkpilot/calls/calls.getters.ts +28 -48
- 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 +39 -73
- package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +11 -18
- package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
- package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
- package/src/talkpilot/clients/clients.getters.ts +5 -10
- 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 +18 -21
- package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +4 -6
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +8 -10
- package/src/talkpilot/clientsConfig/index.ts +2 -2
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +37 -38
- package/src/talkpilot/flows/flows.getter.ts +5 -8
- package/src/talkpilot/flows/flows.schema.ts +80 -87
- package/src/talkpilot/flows/flows.types.ts +24 -23
- package/src/talkpilot/flows/index.ts +2 -2
- package/src/talkpilot/groups/__tests__/groups.spec.ts +27 -34
- package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
- package/src/talkpilot/groups/groups.getters.ts +5 -8
- package/src/talkpilot/groups/groups.types.ts +1 -1
- package/src/talkpilot/groups/index.ts +3 -3
- package/src/talkpilot/groups/phone.utils.ts +6 -12
- package/src/talkpilot/index.ts +17 -17
- package/src/talkpilot/leads/index.ts +2 -2
- package/src/talkpilot/leads/leads.getter.ts +4 -5
- package/src/talkpilot/leads/leads.schema.ts +16 -16
- package/src/talkpilot/leads/leads.types.ts +1 -1
- package/src/talkpilot/mongodb-client.ts +33 -23
- package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +44 -84
- package/src/talkpilot/phone_numbers/index.ts +2 -2
- package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +22 -44
- 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 +26 -30
- package/src/talkpilot/plans/index.ts +2 -2
- package/src/talkpilot/plans/plans.getters.ts +18 -25
- package/src/talkpilot/plans/plans.types.ts +23 -27
- package/src/talkpilot/results/index.ts +2 -5
- package/src/talkpilot/results/results.getter.ts +8 -9
- 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 +41 -65
- package/src/talkpilot/sessions/index.ts +2 -2
- package/src/talkpilot/sessions/sessions.getter.ts +16 -21
- 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 +15 -18
- package/src/talkpilot/subscriptions/index.ts +3 -3
- package/src/talkpilot/subscriptions/subscriptions.getters.ts +33 -36
- package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +3 -10
- 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 +25 -32
- package/src/test-utils/factories/municipal/streets.ts +5 -10
- package/src/test-utils/factories/municipal/tickets.ts +6 -12
- 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 +12 -14
- package/src/test-utils/factories/talkpilot/clientsConfig.ts +8 -7
- package/src/test-utils/factories/talkpilot/flows.ts +5 -7
- package/src/test-utils/factories/talkpilot/groups.ts +13 -13
- package/src/test-utils/factories/talkpilot/phone_numbers.ts +6 -8
- package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
- package/src/utils/validation.ts +4 -4
- package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +0 -4
- package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +0 -1
- package/dist/talkpilot/subscriptions/subscriptions.utils.js +0 -20
- package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +0 -1
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
getDb,
|
|
7
|
-
} from "../index";
|
|
8
|
-
import type { CallsByHour, CountOpts, DateRange } from "./calls.types";
|
|
9
|
-
import { Filter, ObjectId } from "mongodb";
|
|
10
|
-
import * as process from "node:process";
|
|
11
|
-
import { applyQueryOptions } from "../utils/query.utils";
|
|
1
|
+
import { getDb, Call, CallDoc, CallUpdateParams, CallQueryOptions } from '../index';
|
|
2
|
+
import type { CallsByHour, CountOpts, DateRange } from './calls.types';
|
|
3
|
+
import { ObjectId, Filter } from 'mongodb';
|
|
4
|
+
import * as process from 'node:process';
|
|
5
|
+
import { applyQueryOptions } from '../utils/query.utils';
|
|
12
6
|
|
|
13
7
|
export const getCallsCollection = () => {
|
|
14
|
-
return getDb().collection<Call>(
|
|
8
|
+
return getDb().collection<Call>('calls');
|
|
15
9
|
};
|
|
16
10
|
|
|
17
11
|
export const getCallByCallSid = (callSid: string) => {
|
|
@@ -19,9 +13,7 @@ export const getCallByCallSid = (callSid: string) => {
|
|
|
19
13
|
};
|
|
20
14
|
|
|
21
15
|
export const getCallsByPhoneNumber = (phoneNumber: string) => {
|
|
22
|
-
return getCallsCollection()
|
|
23
|
-
.find({ customerPhoneNumber: phoneNumber })
|
|
24
|
-
.toArray();
|
|
16
|
+
return getCallsCollection().find({ customerPhoneNumber: phoneNumber }).toArray();
|
|
25
17
|
};
|
|
26
18
|
|
|
27
19
|
export const getCallsByClient = (clientId: string) => {
|
|
@@ -32,22 +24,20 @@ export const getCallsByFlow = (flowId: ObjectId) => {
|
|
|
32
24
|
return getCallsCollection().find({ flowId }).toArray();
|
|
33
25
|
};
|
|
34
26
|
|
|
35
|
-
export const createCallDoc = (
|
|
36
|
-
call: Omit<Call, "createdAt" | "updatedAt" | "env">,
|
|
37
|
-
) => {
|
|
27
|
+
export const createCallDoc = (call: Omit<Call, 'createdAt' | 'updatedAt' | 'env'>) => {
|
|
38
28
|
return getCallsCollection().insertOne({
|
|
39
29
|
...call,
|
|
40
30
|
createdAt: new Date(),
|
|
41
31
|
updatedAt: new Date(),
|
|
42
|
-
env: process.env.ENV ??
|
|
32
|
+
env: process.env.ENV ?? 'unknown',
|
|
43
33
|
});
|
|
44
34
|
};
|
|
45
35
|
|
|
46
36
|
export const updateCallByCallSid = async (
|
|
47
37
|
callSid: string,
|
|
48
|
-
updates: CallUpdateParams
|
|
38
|
+
updates: CallUpdateParams
|
|
49
39
|
): Promise<CallDoc | null> => {
|
|
50
|
-
|
|
40
|
+
const result = await getCallsCollection().findOneAndUpdate(
|
|
51
41
|
{ callSid: callSid },
|
|
52
42
|
{
|
|
53
43
|
$set: {
|
|
@@ -55,17 +45,15 @@ export const updateCallByCallSid = async (
|
|
|
55
45
|
updatedAt: new Date(),
|
|
56
46
|
},
|
|
57
47
|
},
|
|
58
|
-
{ returnDocument:
|
|
48
|
+
{ returnDocument: 'after' }
|
|
59
49
|
);
|
|
50
|
+
|
|
51
|
+
return result;
|
|
60
52
|
};
|
|
61
53
|
|
|
62
54
|
// get calls by client and date range
|
|
63
55
|
//client here is the user id
|
|
64
|
-
export const getCallsByClientAndDateRange = (
|
|
65
|
-
clientId: string,
|
|
66
|
-
startDate: Date,
|
|
67
|
-
endDate: Date,
|
|
68
|
-
) => {
|
|
56
|
+
export const getCallsByClientAndDateRange = (clientId: string, startDate: Date, endDate: Date) => {
|
|
69
57
|
return getCallsCollection()
|
|
70
58
|
.find({
|
|
71
59
|
clientId,
|
|
@@ -79,7 +67,7 @@ export const getCallsByClientAndDateRange = (
|
|
|
79
67
|
|
|
80
68
|
export const findCallsByQuery = async (
|
|
81
69
|
query: Filter<Call>,
|
|
82
|
-
options?: CallQueryOptions
|
|
70
|
+
options?: CallQueryOptions
|
|
83
71
|
): Promise<CallDoc[]> => {
|
|
84
72
|
const cursor = getCallsCollection().find(query);
|
|
85
73
|
return await applyQueryOptions(cursor, options).toArray();
|
|
@@ -136,7 +124,7 @@ export const range = {
|
|
|
136
124
|
|
|
137
125
|
export function startOfDay(d: Date = new Date()): Date {
|
|
138
126
|
const x = new Date(d);
|
|
139
|
-
x.
|
|
127
|
+
x.setHours(0, 0, 0, 0);
|
|
140
128
|
return x;
|
|
141
129
|
}
|
|
142
130
|
|
|
@@ -154,29 +142,21 @@ export async function getCallsStatsForDateRange(
|
|
|
154
142
|
clientId: string,
|
|
155
143
|
startStr: string,
|
|
156
144
|
endStr: string,
|
|
157
|
-
timezone: string
|
|
145
|
+
timezone: string
|
|
158
146
|
): Promise<{ count: number; totalLen: number; completed: number }> {
|
|
159
147
|
const coll = getCallsCollection();
|
|
160
148
|
const out = await coll
|
|
161
|
-
.aggregate<{
|
|
162
|
-
_id: null;
|
|
163
|
-
count: number;
|
|
164
|
-
totalLen: number;
|
|
165
|
-
completed: number;
|
|
166
|
-
}>([
|
|
149
|
+
.aggregate<{ _id: null; count: number; totalLen: number; completed: number }>([
|
|
167
150
|
// 1. Restrict to the given client
|
|
168
151
|
{ $match: { clientId } },
|
|
169
152
|
// 2. Derive dateLocal (createdAt as YYYY-MM-DD in timezone) and isCompleted (agentHungUp or status='completed')
|
|
170
153
|
{
|
|
171
154
|
$addFields: {
|
|
172
155
|
dateLocal: {
|
|
173
|
-
$dateToString: { format:
|
|
156
|
+
$dateToString: { format: '%Y-%m-%d', date: '$createdAt', timezone },
|
|
174
157
|
},
|
|
175
158
|
isCompleted: {
|
|
176
|
-
$or: [
|
|
177
|
-
{ $eq: ["$agentHungUp", true] },
|
|
178
|
-
{ $eq: ["$status", "completed"] },
|
|
179
|
-
],
|
|
159
|
+
$or: [{ $eq: ['$agentHungUp', true] }, { $eq: ['$status', 'completed'] }],
|
|
180
160
|
},
|
|
181
161
|
},
|
|
182
162
|
},
|
|
@@ -187,8 +167,8 @@ export async function getCallsStatsForDateRange(
|
|
|
187
167
|
$group: {
|
|
188
168
|
_id: null,
|
|
189
169
|
count: { $sum: 1 },
|
|
190
|
-
totalLen: { $sum:
|
|
191
|
-
completed: { $sum: { $cond: [
|
|
170
|
+
totalLen: { $sum: '$callLength' },
|
|
171
|
+
completed: { $sum: { $cond: ['$isCompleted', 1, 0] } },
|
|
192
172
|
},
|
|
193
173
|
},
|
|
194
174
|
])
|
|
@@ -206,7 +186,7 @@ export async function getCallsStatsForDateRange(
|
|
|
206
186
|
export async function getCallsHourlyAggregation(
|
|
207
187
|
clientId: string,
|
|
208
188
|
dateStr: string,
|
|
209
|
-
timezone: string
|
|
189
|
+
timezone: string
|
|
210
190
|
): Promise<CallsByHour[]> {
|
|
211
191
|
const coll = getCallsCollection();
|
|
212
192
|
const rows = await coll
|
|
@@ -217,22 +197,22 @@ export async function getCallsHourlyAggregation(
|
|
|
217
197
|
{
|
|
218
198
|
$addFields: {
|
|
219
199
|
dateLocal: {
|
|
220
|
-
$dateToString: { format:
|
|
200
|
+
$dateToString: { format: '%Y-%m-%d', date: '$createdAt', timezone },
|
|
221
201
|
},
|
|
222
|
-
hour: { $hour: { date:
|
|
202
|
+
hour: { $hour: { date: '$createdAt', timezone } },
|
|
223
203
|
},
|
|
224
204
|
},
|
|
225
205
|
// 3. Keep only the requested date
|
|
226
206
|
{ $match: { dateLocal: dateStr } },
|
|
227
207
|
// 4. Group by hour, sum calls per hour
|
|
228
|
-
{ $group: { _id:
|
|
208
|
+
{ $group: { _id: '$hour', calls: { $sum: 1 } } },
|
|
229
209
|
// 5. Order by hour ascending (0..23)
|
|
230
210
|
{ $sort: { _id: 1 } },
|
|
231
211
|
])
|
|
232
212
|
.toArray();
|
|
233
213
|
|
|
234
214
|
return rows.map((r: any) => ({
|
|
235
|
-
hour: `${String(r._id).padStart(2,
|
|
215
|
+
hour: `${String(r._id).padStart(2, '0')}:00`,
|
|
236
216
|
calls: r.calls,
|
|
237
217
|
}));
|
|
238
218
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ObjectId, Sort, WithId } from
|
|
2
|
-
import { TranscriptionSegment } from
|
|
1
|
+
import { ObjectId, Sort, WithId } from 'mongodb';
|
|
2
|
+
import { TranscriptionSegment } from '../results/results.types';
|
|
3
3
|
|
|
4
|
-
export const CONFERENCE_ROLE_CUSTOMER =
|
|
5
|
-
export const CONFERENCE_ROLE_SUPERVISOR =
|
|
4
|
+
export const CONFERENCE_ROLE_CUSTOMER = 'customer' as const;
|
|
5
|
+
export const CONFERENCE_ROLE_SUPERVISOR = 'supervisor' as const;
|
|
6
6
|
|
|
7
7
|
export type ConferenceRole =
|
|
8
8
|
| typeof CONFERENCE_ROLE_CUSTOMER
|
|
@@ -62,18 +62,18 @@ export type CallsFilterParams = {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export type ImmutableCallFields =
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
65
|
+
| 'customerPhoneNumber'
|
|
66
|
+
| 'agentPhoneNumber'
|
|
67
|
+
| 'isIncomingCall'
|
|
68
|
+
| 'isOutgoingCall'
|
|
69
|
+
| 'sessionId'
|
|
70
|
+
| 'callSid'
|
|
71
|
+
| 'flowId'
|
|
72
|
+
| 'clientId'
|
|
73
|
+
| 'runId'
|
|
74
|
+
| 'resultId'
|
|
75
|
+
| 'env'
|
|
76
|
+
| 'createdAt';
|
|
77
77
|
|
|
78
78
|
export type CallUpdateParams = Partial<Omit<Call, ImmutableCallFields>>;
|
|
79
79
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './calls.types';
|
|
2
|
+
export * from './calls.getters';
|
|
@@ -4,66 +4,46 @@ 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({
|
|
23
|
-
_id: result.insertedId,
|
|
24
|
-
});
|
|
22
|
+
const savedDoc = await getClientAudioBuffersCollection().findOne({ _id: result.insertedId });
|
|
25
23
|
expect(savedDoc).toBeDefined();
|
|
26
24
|
expect(savedDoc?.createdAt).toBeInstanceOf(Date);
|
|
27
25
|
expect(savedDoc?.expiresAt).toBeInstanceOf(Date);
|
|
28
26
|
});
|
|
29
27
|
|
|
30
|
-
it(
|
|
31
|
-
const callSid =
|
|
32
|
-
await insertClientAudioBuffer(
|
|
33
|
-
|
|
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
|
-
);
|
|
28
|
+
it('should return only buffers in the specified bucketStartMs range', async () => {
|
|
29
|
+
const callSid = 'CA1234567890abcdef1234567890abcdef';
|
|
30
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 500 }));
|
|
31
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 1000 }));
|
|
32
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 3000 }));
|
|
33
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 6000 }));
|
|
44
34
|
|
|
45
|
-
const result = await findClientAudioBuffersByCallSidAndRange(
|
|
46
|
-
callSid,
|
|
47
|
-
500,
|
|
48
|
-
3000,
|
|
49
|
-
);
|
|
35
|
+
const result = await findClientAudioBuffersByCallSidAndRange(callSid, 500, 3000);
|
|
50
36
|
expect(result).toHaveLength(3);
|
|
51
37
|
const bucketStartValues = result.map((doc) => doc.bucketStartMs);
|
|
52
38
|
const bucketStartsSorted = bucketStartValues.sort((a, b) => a - b);
|
|
53
39
|
expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
|
|
54
40
|
});
|
|
55
41
|
|
|
56
|
-
it(
|
|
57
|
-
const callSid =
|
|
58
|
-
await insertClientAudioBuffer(
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
await insertClientAudioBuffer(
|
|
62
|
-
createAudioBufferInput({ callSid, bucketStartMs: 1000 }),
|
|
63
|
-
);
|
|
64
|
-
await insertClientAudioBuffer(
|
|
65
|
-
createAudioBufferInput({ callSid, bucketStartMs: 3000 }),
|
|
66
|
-
);
|
|
42
|
+
it('should return all buffers when no range is provided', async () => {
|
|
43
|
+
const callSid = 'CA1234567890abcdef1234567890abcdeg';
|
|
44
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 500 }));
|
|
45
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 1000 }));
|
|
46
|
+
await insertClientAudioBuffer(createAudioBufferInput({ callSid, bucketStartMs: 3000 }));
|
|
67
47
|
|
|
68
48
|
const result = await findClientAudioBuffersByCallSidAndRange(callSid);
|
|
69
49
|
expect(result).toHaveLength(3);
|
|
@@ -72,33 +52,21 @@ describe("clientAudioBuffers getters", () => {
|
|
|
72
52
|
expect(bucketStartsSorted).toEqual([500, 1000, 3000]);
|
|
73
53
|
});
|
|
74
54
|
|
|
75
|
-
it(
|
|
76
|
-
const callSid =
|
|
55
|
+
it('should merge audio buffers by callSid in chronological order', async () => {
|
|
56
|
+
const callSid = 'CA1234567890abcdef1234567890abcdeh';
|
|
77
57
|
|
|
78
58
|
const firstBuffer = Buffer.from([1, 2]);
|
|
79
59
|
const secondBuffer = Buffer.from([3]);
|
|
80
60
|
const thirdBuffer = Buffer.from([4, 5]);
|
|
81
61
|
|
|
82
62
|
await insertClientAudioBuffer(
|
|
83
|
-
|
|
84
|
-
callSid,
|
|
85
|
-
bucketStartMs: 1000,
|
|
86
|
-
data: secondBuffer,
|
|
87
|
-
}),
|
|
63
|
+
createAudioBufferInput({ callSid, bucketStartMs: 1000, data: secondBuffer })
|
|
88
64
|
);
|
|
89
65
|
await insertClientAudioBuffer(
|
|
90
|
-
|
|
91
|
-
callSid,
|
|
92
|
-
bucketStartMs: 500,
|
|
93
|
-
data: firstBuffer,
|
|
94
|
-
}),
|
|
66
|
+
createAudioBufferInput({ callSid, bucketStartMs: 500, data: firstBuffer })
|
|
95
67
|
);
|
|
96
68
|
await insertClientAudioBuffer(
|
|
97
|
-
|
|
98
|
-
callSid,
|
|
99
|
-
bucketStartMs: 3000,
|
|
100
|
-
data: thirdBuffer,
|
|
101
|
-
}),
|
|
69
|
+
createAudioBufferInput({ callSid, bucketStartMs: 3000, data: thirdBuffer })
|
|
102
70
|
);
|
|
103
71
|
|
|
104
72
|
const merged = await getMergedAudioByCallSid(callSid, 10);
|
|
@@ -109,8 +77,8 @@ describe("clientAudioBuffers getters", () => {
|
|
|
109
77
|
expect(merged.equals(expected)).toBe(true);
|
|
110
78
|
});
|
|
111
79
|
|
|
112
|
-
it(
|
|
113
|
-
const callSid =
|
|
80
|
+
it('should return all audio chunks when less than or equal to limit buffers exist', async () => {
|
|
81
|
+
const callSid = 'CA1234567890abcdef1234567890abclt';
|
|
114
82
|
|
|
115
83
|
const limit = 30;
|
|
116
84
|
const buffers: Buffer[] = [];
|
|
@@ -118,11 +86,11 @@ describe("clientAudioBuffers getters", () => {
|
|
|
118
86
|
const buf = Buffer.from([i]);
|
|
119
87
|
buffers.push(buf);
|
|
120
88
|
await insertClientAudioBuffer(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
89
|
+
createAudioBufferInput({
|
|
90
|
+
callSid,
|
|
91
|
+
bucketStartMs: 1000 + i * 1000,
|
|
92
|
+
data: buf,
|
|
93
|
+
})
|
|
126
94
|
);
|
|
127
95
|
}
|
|
128
96
|
|
|
@@ -133,8 +101,8 @@ describe("clientAudioBuffers getters", () => {
|
|
|
133
101
|
expect(Buffer.concat(chunks).equals(Buffer.concat(buffers))).toBe(true);
|
|
134
102
|
});
|
|
135
103
|
|
|
136
|
-
it(
|
|
137
|
-
const callSid =
|
|
104
|
+
it('should return only the last N audio chunks when more than limit buffers exist', async () => {
|
|
105
|
+
const callSid = 'CA1234567890abcdef1234567890abclm';
|
|
138
106
|
|
|
139
107
|
const limit = 30;
|
|
140
108
|
const buffers: Buffer[] = [];
|
|
@@ -142,19 +110,17 @@ describe("clientAudioBuffers getters", () => {
|
|
|
142
110
|
const buf = Buffer.from([i]);
|
|
143
111
|
buffers.push(buf);
|
|
144
112
|
await insertClientAudioBuffer(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
113
|
+
createAudioBufferInput({
|
|
114
|
+
callSid,
|
|
115
|
+
bucketStartMs: 1000 + i * 1000,
|
|
116
|
+
data: buf,
|
|
117
|
+
})
|
|
150
118
|
);
|
|
151
119
|
}
|
|
152
120
|
|
|
153
121
|
const chunks = await getAudioChunksByCallSid(callSid, limit);
|
|
154
122
|
const expectedBuffers = buffers.slice(-limit);
|
|
155
123
|
expect(chunks).toHaveLength(expectedBuffers.length);
|
|
156
|
-
expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(
|
|
157
|
-
true,
|
|
158
|
-
);
|
|
124
|
+
expect(Buffer.concat(chunks).equals(Buffer.concat(expectedBuffers))).toBe(true);
|
|
159
125
|
});
|
|
160
126
|
});
|
|
@@ -1,18 +1,17 @@
|
|
|
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
|
-
|
|
12
|
-
};
|
|
9
|
+
const getClientAudioBuffersCollection = (): Collection<ClientAudioBufferType> => {
|
|
10
|
+
return getDb().collection<ClientAudioBufferType>('clientAudioBuffers');
|
|
11
|
+
};
|
|
13
12
|
|
|
14
13
|
const insertClientAudioBuffer = async (
|
|
15
|
-
audioBufferInput: CreateAudioBufferInput
|
|
14
|
+
audioBufferInput: CreateAudioBufferInput
|
|
16
15
|
): Promise<InsertOneResult<ClientAudioBufferType>> => {
|
|
17
16
|
const collection = getClientAudioBuffersCollection();
|
|
18
17
|
const realtimeDate = new Date();
|
|
@@ -28,7 +27,7 @@ const insertClientAudioBuffer = async (
|
|
|
28
27
|
};
|
|
29
28
|
const clientAudioBufferMongoDocument: ClientAudioBufferType = {
|
|
30
29
|
...inputFieldsForDocument,
|
|
31
|
-
codec:
|
|
30
|
+
codec: 'mulaw',
|
|
32
31
|
sampleRateHz: 8000,
|
|
33
32
|
channels: 1,
|
|
34
33
|
createdAt: realtimeDate,
|
|
@@ -40,7 +39,7 @@ const insertClientAudioBuffer = async (
|
|
|
40
39
|
const findClientAudioBuffersByCallSidAndRange = async (
|
|
41
40
|
callSid: string,
|
|
42
41
|
startMs?: number,
|
|
43
|
-
endMs?: number
|
|
42
|
+
endMs?: number
|
|
44
43
|
): Promise<ClientAudioBufferDoc[]> => {
|
|
45
44
|
const collection = getClientAudioBuffersCollection();
|
|
46
45
|
if (startMs === undefined) {
|
|
@@ -58,10 +57,7 @@ const findClientAudioBuffersByCallSidAndRange = async (
|
|
|
58
57
|
.toArray();
|
|
59
58
|
};
|
|
60
59
|
|
|
61
|
-
const getAudioChunksByCallSid = async (
|
|
62
|
-
callSid: string,
|
|
63
|
-
limit?: number,
|
|
64
|
-
): Promise<Buffer[]> => {
|
|
60
|
+
const getAudioChunksByCallSid = async (callSid: string, limit?: number): Promise<Buffer[]> => {
|
|
65
61
|
const query = getClientAudioBuffersCollection().find({ callSid });
|
|
66
62
|
if (limit) {
|
|
67
63
|
query.sort({ bucketStartMs: -1 }).limit(limit);
|
|
@@ -84,10 +80,7 @@ const getAudioChunksByCallSid = async (
|
|
|
84
80
|
});
|
|
85
81
|
};
|
|
86
82
|
|
|
87
|
-
const getMergedAudioByCallSid = async (
|
|
88
|
-
callSid: string,
|
|
89
|
-
limit: number,
|
|
90
|
-
): Promise<Buffer> => {
|
|
83
|
+
const getMergedAudioByCallSid = async (callSid: string, limit: number): Promise<Buffer> => {
|
|
91
84
|
const buffers = await getAudioChunksByCallSid(callSid, limit);
|
|
92
85
|
|
|
93
86
|
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,16 +1,11 @@
|
|
|
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
|
-
apiKey:
|
|
10
|
-
): Promise<Client | null> => {
|
|
11
|
-
const client = await getClientsCollection().findOne({
|
|
12
|
-
apiKey,
|
|
13
|
-
isActive: true,
|
|
14
|
-
});
|
|
8
|
+
export const getClientByAPIKey = async (apiKey: string): Promise<Client | null> => {
|
|
9
|
+
const client = await getClientsCollection().findOne({ apiKey, isActive: true });
|
|
15
10
|
return client ? client : null;
|
|
16
11
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './clients.getters';
|
|
2
|
+
export * from './clients.types';
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
getClientConfig,
|
|
4
|
-
} from "../clientsConfig.getters";
|
|
5
|
-
import { createClientConfig } from "../../../test-utils/factories";
|
|
1
|
+
import { createClientConfigDoc, getClientConfig } from '../clientsConfig.getters';
|
|
2
|
+
import { createClientConfig } from '../../../test-utils/factories';
|
|
6
3
|
|
|
7
|
-
describe(
|
|
8
|
-
describe(
|
|
9
|
-
it(
|
|
10
|
-
const clientId =
|
|
4
|
+
describe('db.clientsConfig', () => {
|
|
5
|
+
describe('getClientConfig', () => {
|
|
6
|
+
it('should return client config by clientId', async () => {
|
|
7
|
+
const clientId = 'test-client-id';
|
|
11
8
|
const clientConfig = createClientConfig({
|
|
12
9
|
clientId,
|
|
13
|
-
language:
|
|
10
|
+
language: 'Hebrew',
|
|
14
11
|
products: { feature1: true, feature2: false } as any,
|
|
15
12
|
});
|
|
16
13
|
|
|
@@ -20,25 +17,25 @@ describe("db.clientsConfig", () => {
|
|
|
20
17
|
|
|
21
18
|
expect(result).toMatchObject({
|
|
22
19
|
clientId,
|
|
23
|
-
language:
|
|
20
|
+
language: 'Hebrew',
|
|
24
21
|
products: { feature1: true, feature2: false },
|
|
25
22
|
});
|
|
26
23
|
});
|
|
27
24
|
|
|
28
|
-
it(
|
|
29
|
-
const result = await getClientConfig(
|
|
25
|
+
it('should return null for non-existent clientId', async () => {
|
|
26
|
+
const result = await getClientConfig('non-existent-client');
|
|
30
27
|
expect(result).toBeNull();
|
|
31
28
|
});
|
|
32
29
|
|
|
33
|
-
it(
|
|
34
|
-
const clientId =
|
|
30
|
+
it('should support communications config', async () => {
|
|
31
|
+
const clientId = 'communications-test';
|
|
35
32
|
const clientConfig = createClientConfig({
|
|
36
33
|
clientId,
|
|
37
34
|
communications: {
|
|
38
35
|
sendGrid: {
|
|
39
|
-
emailTo: [
|
|
40
|
-
templateId:
|
|
41
|
-
senderId:
|
|
36
|
+
emailTo: ['test@example.com'],
|
|
37
|
+
templateId: 'temp-123',
|
|
38
|
+
senderId: 'sender-123',
|
|
42
39
|
},
|
|
43
40
|
sms: {},
|
|
44
41
|
whatsapp: {},
|
|
@@ -53,9 +50,9 @@ describe("db.clientsConfig", () => {
|
|
|
53
50
|
clientId,
|
|
54
51
|
communications: {
|
|
55
52
|
sendGrid: {
|
|
56
|
-
emailTo: [
|
|
57
|
-
templateId:
|
|
58
|
-
senderId:
|
|
53
|
+
emailTo: ['test@example.com'],
|
|
54
|
+
templateId: 'temp-123',
|
|
55
|
+
senderId: 'sender-123',
|
|
59
56
|
},
|
|
60
57
|
sms: {},
|
|
61
58
|
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,8 +15,6 @@ export const getClientConfigByPhone = async (phone: string) => {
|
|
|
15
15
|
return getClientConfig(client.clientId);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const createClientConfigDoc = async (
|
|
19
|
-
clientConfig: ClientConfigDoc,
|
|
20
|
-
): Promise<void> => {
|
|
18
|
+
export const createClientConfigDoc = async (clientConfig: ClientConfigDoc): Promise<void> => {
|
|
21
19
|
await getClientsConfigCollection().insertOne(clientConfig);
|
|
22
20
|
};
|