@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
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.leadsMongoSchema = void 0;
|
|
4
4
|
exports.leadsMongoSchema = {
|
|
5
|
-
bsonType:
|
|
6
|
-
required: [
|
|
5
|
+
bsonType: "object",
|
|
6
|
+
required: ["flowId", "clientId", "createdAt", "leads"],
|
|
7
7
|
properties: {
|
|
8
|
-
_id: { bsonType:
|
|
9
|
-
flowId: { bsonType:
|
|
10
|
-
clientId: { bsonType:
|
|
11
|
-
createdAt: { bsonType:
|
|
8
|
+
_id: { bsonType: "objectId" },
|
|
9
|
+
flowId: { bsonType: "string" },
|
|
10
|
+
clientId: { bsonType: "string" },
|
|
11
|
+
createdAt: { bsonType: "date" },
|
|
12
12
|
leads: {
|
|
13
|
-
bsonType:
|
|
13
|
+
bsonType: "array",
|
|
14
14
|
items: {
|
|
15
|
-
bsonType:
|
|
16
|
-
required: [
|
|
15
|
+
bsonType: "object",
|
|
16
|
+
required: ["callSid", "timestamp"],
|
|
17
17
|
properties: {
|
|
18
|
-
callSid: { bsonType:
|
|
19
|
-
timestamp: { bsonType:
|
|
18
|
+
callSid: { bsonType: "string" },
|
|
19
|
+
timestamp: { bsonType: "date" },
|
|
20
20
|
properties: {
|
|
21
|
-
bsonType:
|
|
21
|
+
bsonType: "array",
|
|
22
22
|
items: {
|
|
23
|
-
bsonType:
|
|
24
|
-
required: [
|
|
23
|
+
bsonType: "object",
|
|
24
|
+
required: ["name", "value"],
|
|
25
25
|
properties: {
|
|
26
|
-
name: { bsonType:
|
|
27
|
-
value: { bsonType:
|
|
26
|
+
name: { bsonType: "string" },
|
|
27
|
+
value: { bsonType: "string" },
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
},
|
|
@@ -22,24 +22,23 @@ class MongoDBClient {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
const mongodbUri = uri || process.env.MONGO_URI || process.env.MONGODB_URI;
|
|
25
|
-
(0, validation_1.validateConfig)(
|
|
25
|
+
(0, validation_1.validateConfig)("MONGO_URI", mongodbUri);
|
|
26
26
|
(0, validation_1.validateMongoUri)(mongodbUri);
|
|
27
27
|
try {
|
|
28
28
|
this.client = new mongodb_1.MongoClient(mongodbUri);
|
|
29
29
|
await this.client.connect();
|
|
30
30
|
const dbNameFromUri = this.extractDatabaseName(mongodbUri);
|
|
31
|
-
const
|
|
32
|
-
const dbName = databaseName || dbNameFromUri || dbNameFromEnv;
|
|
31
|
+
const dbName = databaseName || process.env.TALKPILOT_DB_NAME || dbNameFromUri;
|
|
33
32
|
if (!dbName) {
|
|
34
|
-
throw new Error(
|
|
35
|
-
|
|
33
|
+
throw new Error("[core-db] Database name not specified. Please pass databaseName to connect(), " +
|
|
34
|
+
"add it to the URI, or set TALKPILOT_DB_NAME.");
|
|
36
35
|
}
|
|
37
36
|
this.db = this.client.db(dbName);
|
|
38
37
|
(0, index_1.setDb)(this.db);
|
|
39
38
|
console.info(`[core-db] TalkPilot MongoDB connected: ${dbName}`);
|
|
40
39
|
}
|
|
41
40
|
catch (error) {
|
|
42
|
-
console.error(
|
|
41
|
+
console.error("[core-db] TalkPilot connection failed", error);
|
|
43
42
|
throw error;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -49,17 +48,17 @@ class MongoDBClient {
|
|
|
49
48
|
await this.client.close();
|
|
50
49
|
this.client = null;
|
|
51
50
|
this.db = null;
|
|
52
|
-
console.info(
|
|
51
|
+
console.info("MongoDB disconnected successfully");
|
|
53
52
|
}
|
|
54
53
|
catch (error) {
|
|
55
|
-
console.error(
|
|
54
|
+
console.error("[core-db] Disconnection failed", error);
|
|
56
55
|
throw error;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
getDb() {
|
|
61
60
|
if (!this.db) {
|
|
62
|
-
throw new Error(
|
|
61
|
+
throw new Error("Database not initialized. Call connect() first.");
|
|
63
62
|
}
|
|
64
63
|
return this.db;
|
|
65
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-client.js","sourceRoot":"","sources":["../../src/talkpilot/mongodb-client.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,mCAAgC;AAChC,oDAAuE;AAEvE,MAAM,aAAa;IACT,MAAM,GAAuB,IAAI,CAAC;IAClC,EAAE,GAAc,IAAI,CAAC;IAErB,mBAAmB,CAAC,GAAW;QACrC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YACzB,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrC,OAAO,MAAM,IAAI,IAAI,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAY,EAAE,YAAqB;QAC/C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;QAC3E,IAAA,2BAAc,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACxC,IAAA,6BAAgB,EAAC,UAAW,CAAC,CAAC;QAE9B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAW,CAAC,UAAW,CAAC,CAAC;YAC3C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAE5B,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAW,CAAC,CAAC;YAC5D,MAAM,
|
|
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":"AAAA,cAAc,wBAAwB,CAAC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,uBAAuB,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { Collection } from
|
|
1
|
+
import type { Collection } from "mongodb";
|
|
2
2
|
import { Client } from '../index';
|
|
3
|
-
import { PhoneNumber, PhoneNumberWithFlow } from
|
|
3
|
+
import { ClientPhoneNumberForFlow, PhoneNumber, PhoneNumberWithFlow, PurchasedPhoneProviderPayload } from "./phone_numbers.types";
|
|
4
4
|
export declare const getPhoneNumbersCollection: () => Collection<PhoneNumber>;
|
|
5
5
|
export declare const getPhoneDataByPhoneNumber: (phoneNumber: string) => Promise<PhoneNumberWithFlow | null>;
|
|
6
6
|
export declare const getClientPrimaryPhoneNumber: (clientId: string) => Promise<string | null>;
|
|
7
7
|
export declare const getClientPhoneNumber: (clientId: string) => Promise<string | null>;
|
|
8
8
|
export declare const getClientPhoneData: (clientId: string, isPrimary?: boolean) => Promise<PhoneNumber | null>;
|
|
9
|
+
export declare const getPhoneNumbersForFlows: (clientId: string) => Promise<ClientPhoneNumberForFlow[]>;
|
|
9
10
|
export declare const createPhoneNumberEntity: (phoneNumber: string, flowId: string, clientId: string) => Promise<PhoneNumber>;
|
|
11
|
+
/** API-purchased number; `flowId` may be omitted until the number is bound to a flow. */
|
|
12
|
+
export declare const createPurchasedPhoneNumber: (phoneNumber: string, providerPayload: PurchasedPhoneProviderPayload, clientId: string, flowId?: string | null) => Promise<PhoneNumber>;
|
|
10
13
|
export declare const findClientByPhoneNumber: (phoneNumber: string) => Promise<Client>;
|
|
11
14
|
//# sourceMappingURL=phone_numbers.getter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone_numbers.getter.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.getter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EACL,MAAM,EAMP,MAAM,UAAU,CAAC;AAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"phone_numbers.getter.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.getter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EACL,MAAM,EAMP,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,wBAAwB,EACxB,WAAW,EACX,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,yBAAyB,QAAO,UAAU,CAAC,WAAW,CACjB,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,MAAM,KAClB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAwBpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,KACf,OAAO,CAAC,MAAM,GAAG,IAAI,CASvB,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAZrB,MAAM,KACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAWuC,CAAC;AAEhE,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,YAAY,OAAO,KAClB,OAAO,CAAC,WAAW,GAAG,IAAI,CAK5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,KACf,OAAO,CAAC,wBAAwB,EAAE,CAepC,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,UAAU,MAAM,KACf,OAAO,CAAC,WAAW,CAerB,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,0BAA0B,GACrC,aAAa,MAAM,EACnB,iBAAiB,6BAA6B,EAC9C,UAAU,MAAM,EAChB,SAAS,MAAM,GAAG,IAAI,KACrB,OAAO,CAAC,WAAW,CA0BrB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,MAAM,CAOjF,CAAC"}
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findClientByPhoneNumber = exports.createPhoneNumberEntity = exports.getClientPhoneData = exports.getClientPhoneNumber = exports.getClientPrimaryPhoneNumber = exports.getPhoneDataByPhoneNumber = exports.getPhoneNumbersCollection = void 0;
|
|
3
|
+
exports.findClientByPhoneNumber = exports.createPurchasedPhoneNumber = exports.createPhoneNumberEntity = exports.getPhoneNumbersForFlows = exports.getClientPhoneData = exports.getClientPhoneNumber = exports.getClientPrimaryPhoneNumber = exports.getPhoneDataByPhoneNumber = exports.getPhoneNumbersCollection = void 0;
|
|
4
4
|
const index_1 = require("../index");
|
|
5
|
-
const getPhoneNumbersCollection = () => (0, index_1.getDb)().collection(
|
|
5
|
+
const getPhoneNumbersCollection = () => (0, index_1.getDb)().collection("phone_numbers");
|
|
6
6
|
exports.getPhoneNumbersCollection = getPhoneNumbersCollection;
|
|
7
7
|
const getPhoneDataByPhoneNumber = async (phoneNumber) => {
|
|
8
|
-
const phoneCallData = await (0, exports.getPhoneNumbersCollection)().findOne({
|
|
8
|
+
const phoneCallData = await (0, exports.getPhoneNumbersCollection)().findOne({
|
|
9
|
+
phone_number: phoneNumber,
|
|
10
|
+
});
|
|
9
11
|
if (!phoneCallData) {
|
|
10
|
-
throw new Error(
|
|
12
|
+
throw new Error("PhoneNumber not found");
|
|
11
13
|
}
|
|
12
|
-
const flow = await (0, index_1.getFlowsCollection)().findOne({
|
|
14
|
+
const flow = await (0, index_1.getFlowsCollection)().findOne({
|
|
15
|
+
_id: new index_1.ObjectId(phoneCallData.flow_id),
|
|
16
|
+
});
|
|
13
17
|
if (!flow) {
|
|
14
|
-
throw new Error(
|
|
18
|
+
throw new Error("Flow not found");
|
|
15
19
|
}
|
|
16
|
-
const [subscription] = (await (0, index_1.findSubscriptions)({
|
|
17
|
-
|
|
20
|
+
const [subscription] = (await (0, index_1.findSubscriptions)({
|
|
21
|
+
clientId: phoneCallData.client_id,
|
|
22
|
+
isActive: true,
|
|
23
|
+
})) || [];
|
|
24
|
+
return {
|
|
25
|
+
...phoneCallData,
|
|
26
|
+
flow,
|
|
27
|
+
subscriptionId: subscription?._id?.toString() ?? undefined,
|
|
28
|
+
};
|
|
18
29
|
};
|
|
19
30
|
exports.getPhoneDataByPhoneNumber = getPhoneDataByPhoneNumber;
|
|
20
31
|
const getClientPrimaryPhoneNumber = async (clientId) => {
|
|
21
|
-
return ((await (0, exports.getPhoneNumbersCollection)().findOne({
|
|
22
|
-
|
|
32
|
+
return ((await (0, exports.getPhoneNumbersCollection)().findOne({
|
|
33
|
+
client_id: clientId,
|
|
34
|
+
is_primary: true,
|
|
35
|
+
}))?.phone_number ?? null);
|
|
23
36
|
};
|
|
24
37
|
exports.getClientPrimaryPhoneNumber = getClientPrimaryPhoneNumber;
|
|
25
38
|
exports.getClientPhoneNumber = exports.getClientPrimaryPhoneNumber;
|
|
@@ -29,6 +42,22 @@ const getClientPhoneData = async (clientId, isPrimary) => {
|
|
|
29
42
|
return (0, exports.getPhoneNumbersCollection)().findOne(filter, options);
|
|
30
43
|
};
|
|
31
44
|
exports.getClientPhoneData = getClientPhoneData;
|
|
45
|
+
const getPhoneNumbersForFlows = async (clientId) => {
|
|
46
|
+
const docs = await (0, exports.getPhoneNumbersCollection)()
|
|
47
|
+
.find({
|
|
48
|
+
client_id: clientId,
|
|
49
|
+
flow_id: { $exists: true, $type: "objectId" },
|
|
50
|
+
})
|
|
51
|
+
.project({ _id: 0, flow_id: 1, phone_number: 1, is_primary: 1 })
|
|
52
|
+
.sort({ createdAt: -1 })
|
|
53
|
+
.toArray();
|
|
54
|
+
return docs.map((doc) => ({
|
|
55
|
+
flowId: String(doc.flow_id),
|
|
56
|
+
phoneNumber: doc.phone_number,
|
|
57
|
+
isPrimary: doc.is_primary,
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
exports.getPhoneNumbersForFlows = getPhoneNumbersForFlows;
|
|
32
61
|
const createPhoneNumberEntity = async (phoneNumber, flowId, clientId) => {
|
|
33
62
|
const existing = await (0, exports.getClientPhoneData)(clientId);
|
|
34
63
|
const isPrimary = !existing;
|
|
@@ -42,10 +71,35 @@ const createPhoneNumberEntity = async (phoneNumber, flowId, clientId) => {
|
|
|
42
71
|
});
|
|
43
72
|
const phoneNumberData = await (0, exports.getClientPhoneData)(clientId, isPrimary);
|
|
44
73
|
if (!phoneNumberData)
|
|
45
|
-
throw new Error(
|
|
74
|
+
throw new Error("Failed to create phoneNumber");
|
|
46
75
|
return phoneNumberData;
|
|
47
76
|
};
|
|
48
77
|
exports.createPhoneNumberEntity = createPhoneNumberEntity;
|
|
78
|
+
/** API-purchased number; `flowId` may be omitted until the number is bound to a flow. */
|
|
79
|
+
const createPurchasedPhoneNumber = async (phoneNumber, providerPayload, clientId, flowId) => {
|
|
80
|
+
const existingPhoneForClient = await (0, exports.getClientPhoneData)(clientId);
|
|
81
|
+
const isPrimary = !existingPhoneForClient;
|
|
82
|
+
const now = new Date();
|
|
83
|
+
const trimmedFlowId = flowId?.trim();
|
|
84
|
+
const flowObjectId = trimmedFlowId ? new index_1.ObjectId(trimmedFlowId) : undefined;
|
|
85
|
+
const doc = {
|
|
86
|
+
phone_number: phoneNumber,
|
|
87
|
+
client_id: clientId,
|
|
88
|
+
is_primary: isPrimary,
|
|
89
|
+
...providerPayload,
|
|
90
|
+
createdAt: now,
|
|
91
|
+
updatedAt: now,
|
|
92
|
+
};
|
|
93
|
+
if (flowObjectId) {
|
|
94
|
+
doc.flow_id = flowObjectId;
|
|
95
|
+
}
|
|
96
|
+
await (0, exports.getPhoneNumbersCollection)().insertOne(doc);
|
|
97
|
+
const created = await (0, exports.getClientPhoneData)(clientId, isPrimary);
|
|
98
|
+
if (!created)
|
|
99
|
+
throw new Error('Failed to create phoneNumber');
|
|
100
|
+
return created;
|
|
101
|
+
};
|
|
102
|
+
exports.createPurchasedPhoneNumber = createPurchasedPhoneNumber;
|
|
49
103
|
const findClientByPhoneNumber = async (phoneNumber) => {
|
|
50
104
|
const phoneData = await (0, exports.getPhoneNumbersCollection)().findOne({ phone_number: phoneNumber });
|
|
51
105
|
if (!phoneData)
|
|
@@ -53,7 +107,7 @@ const findClientByPhoneNumber = async (phoneNumber) => {
|
|
|
53
107
|
const clientId = phoneData.client_id;
|
|
54
108
|
const client = await (0, index_1.getClientsCollection)().findOne({ clientId });
|
|
55
109
|
if (!client)
|
|
56
|
-
throw new Error(
|
|
110
|
+
throw new Error("Failed to get client");
|
|
57
111
|
return client;
|
|
58
112
|
};
|
|
59
113
|
exports.findClientByPhoneNumber = findClientByPhoneNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone_numbers.getter.js","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.getter.ts"],"names":[],"mappings":";;;AACA,oCAOkB;
|
|
1
|
+
{"version":3,"file":"phone_numbers.getter.js","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.getter.ts"],"names":[],"mappings":";;;AACA,oCAOkB;AAQX,MAAM,yBAAyB,GAAG,GAA4B,EAAE,CACrE,IAAA,aAAK,GAAE,CAAC,UAAU,CAAc,eAAe,CAAC,CAAC;AADtC,QAAA,yBAAyB,6BACa;AAE5C,MAAM,yBAAyB,GAAG,KAAK,EAC5C,WAAmB,EACkB,EAAE;IACvC,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAyB,GAAE,CAAC,OAAO,CAAC;QAC9D,YAAY,EAAE,WAAW;KAC1B,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,GA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AAC;AACjB,CAAC,CAAC;AA/BW,QAAA,0BAA0B,8BA+BrC;AAEK,MAAM,uBAAuB,GAAG,KAAK,EAAE,WAAmB,EAAmB,EAAE;IACpF,MAAM,SAAS,GAAG,MAAM,IAAA,iCAAyB,GAAE,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3F,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,IAAA,4BAAoB,GAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAPW,QAAA,uBAAuB,2BAOlC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const phoneNumbersMongoSchema: {
|
|
2
2
|
readonly bsonType: "object";
|
|
3
|
-
readonly required: readonly ["client_id", "
|
|
3
|
+
readonly required: readonly ["client_id", "phone_number"];
|
|
4
4
|
readonly properties: {
|
|
5
5
|
readonly _id: {
|
|
6
6
|
readonly bsonType: "objectId";
|
|
@@ -9,7 +9,7 @@ export declare const phoneNumbersMongoSchema: {
|
|
|
9
9
|
readonly bsonType: "string";
|
|
10
10
|
};
|
|
11
11
|
readonly flow_id: {
|
|
12
|
-
readonly bsonType: "string";
|
|
12
|
+
readonly bsonType: readonly ["objectId", "string"];
|
|
13
13
|
};
|
|
14
14
|
readonly phone_number: {
|
|
15
15
|
readonly bsonType: "string";
|
|
@@ -17,6 +17,15 @@ export declare const phoneNumbersMongoSchema: {
|
|
|
17
17
|
readonly is_primary: {
|
|
18
18
|
readonly bsonType: "bool";
|
|
19
19
|
};
|
|
20
|
+
readonly provider: {
|
|
21
|
+
readonly bsonType: "string";
|
|
22
|
+
};
|
|
23
|
+
readonly provider_sid: {
|
|
24
|
+
readonly bsonType: "string";
|
|
25
|
+
};
|
|
26
|
+
readonly friendly_name: {
|
|
27
|
+
readonly bsonType: "string";
|
|
28
|
+
};
|
|
20
29
|
readonly createdAt: {
|
|
21
30
|
readonly bsonType: "date";
|
|
22
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone_numbers.schema.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"phone_numbers.schema.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgB1B,CAAC"}
|
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.phoneNumbersMongoSchema = void 0;
|
|
4
4
|
exports.phoneNumbersMongoSchema = {
|
|
5
5
|
bsonType: 'object',
|
|
6
|
-
required: ['client_id', '
|
|
6
|
+
required: ['client_id', 'phone_number'],
|
|
7
7
|
properties: {
|
|
8
8
|
_id: { bsonType: 'objectId' },
|
|
9
9
|
client_id: { bsonType: 'string' },
|
|
10
|
-
flow_id: { bsonType: 'string' },
|
|
10
|
+
flow_id: { bsonType: ['objectId', 'string'] },
|
|
11
11
|
phone_number: { bsonType: 'string' },
|
|
12
12
|
is_primary: { bsonType: 'bool' },
|
|
13
|
+
provider: { bsonType: 'string' },
|
|
14
|
+
provider_sid: { bsonType: 'string' },
|
|
15
|
+
friendly_name: { bsonType: 'string' },
|
|
13
16
|
createdAt: { bsonType: 'date' },
|
|
14
17
|
updatedAt: { bsonType: 'date' },
|
|
15
18
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone_numbers.schema.js","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.schema.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG;IACrC,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,CAAC,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"phone_numbers.schema.js","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.schema.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG;IACrC,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;IACvC,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;QAC7B,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACjC,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE;QAC7C,YAAY,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACpC,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;QAChC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAChC,YAAY,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACpC,aAAa,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACrC,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;QAC/B,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;KAChC;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import { ObjectId, WithId } from
|
|
2
|
-
import { Flow } from
|
|
1
|
+
import { ObjectId, WithId } from 'mongodb';
|
|
2
|
+
import { Flow } from '../flows/flows.types';
|
|
3
|
+
export type PurchasedPhoneProviderPayload = {
|
|
4
|
+
provider: 'twilio' | 'telnyx';
|
|
5
|
+
provider_sid: string;
|
|
6
|
+
friendly_name?: string;
|
|
7
|
+
};
|
|
3
8
|
export type PhoneNumber = {
|
|
4
9
|
_id?: ObjectId;
|
|
5
10
|
client_id: string;
|
|
6
|
-
flow_id
|
|
11
|
+
flow_id?: ObjectId;
|
|
7
12
|
phone_number: string;
|
|
8
13
|
subscriptionId?: string;
|
|
9
14
|
is_primary: boolean;
|
|
15
|
+
provider?: 'twilio' | 'telnyx';
|
|
16
|
+
provider_sid?: string;
|
|
17
|
+
friendly_name?: string;
|
|
10
18
|
createdAt: Date;
|
|
11
19
|
updatedAt: Date;
|
|
12
20
|
};
|
|
13
21
|
export type PhoneNumberWithFlow = WithId<PhoneNumber> & {
|
|
14
22
|
flow: Flow;
|
|
15
23
|
};
|
|
24
|
+
export type ClientPhoneNumberForFlow = {
|
|
25
|
+
flowId: string;
|
|
26
|
+
phoneNumber: string;
|
|
27
|
+
isPrimary: boolean;
|
|
28
|
+
};
|
|
16
29
|
//# sourceMappingURL=phone_numbers.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone_numbers.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"phone_numbers.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/phone_numbers/phone_numbers.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./plans.types";
|
|
2
|
+
export * from "./plans.getters";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plan, PlanDoc, PlanFilter, PlanQueryOptions } from
|
|
2
|
-
import { Filter, ObjectId } from
|
|
1
|
+
import { Plan, PlanDoc, PlanFilter, PlanQueryOptions } from "../index";
|
|
2
|
+
import { Filter, ObjectId } from "mongodb";
|
|
3
3
|
export declare const getPlansCollection: () => import("mongodb").Collection<Plan>;
|
|
4
4
|
/**
|
|
5
5
|
* Generic function to find plans with flexible filtering
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.getters.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/plans/plans.getters.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"plans.getters.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/plans/plans.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EACJ,OAAO,EACP,UAAU,EACV,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG3C,eAAO,MAAM,kBAAkB,0CAE9B,CAAC;AAiCF;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,SAAS,UAAU,EACnB,UAAU,gBAAgB,KACzB,OAAO,CAAC,OAAO,EAAE,CAkCnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,EACnB,UAAU,gBAAgB,KACzB,OAAO,CAAC,OAAO,EAAE,CAGnB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,OAAO,MAAM,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,MAAM,CAEpE,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,UAAU,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC,KAC9C,OAAO,CAAC,OAAO,CAWjB,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,QAAQ,QAAQ,EAChB,SAAS,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC,CAAC,KACtD,OAAO,CAAC,OAAO,GAAG,IAAI,CAaxB,CAAC"}
|
|
@@ -5,7 +5,7 @@ const index_1 = require("../index");
|
|
|
5
5
|
const mongodb_1 = require("mongodb");
|
|
6
6
|
const query_utils_1 = require("../utils/query.utils");
|
|
7
7
|
const getPlansCollection = () => {
|
|
8
|
-
return (0, index_1.getDb)().collection(
|
|
8
|
+
return (0, index_1.getDb)().collection("plans");
|
|
9
9
|
};
|
|
10
10
|
exports.getPlansCollection = getPlansCollection;
|
|
11
11
|
/**
|
|
@@ -88,7 +88,7 @@ const createPlanDoc = async (planData) => {
|
|
|
88
88
|
});
|
|
89
89
|
const plans = await (0, exports.findPlans)({ _id: result.insertedId });
|
|
90
90
|
if (!plans[0])
|
|
91
|
-
throw new Error(
|
|
91
|
+
throw new Error("Failed to retrieve created plan");
|
|
92
92
|
return plans[0];
|
|
93
93
|
};
|
|
94
94
|
exports.createPlanDoc = createPlanDoc;
|
|
@@ -99,7 +99,7 @@ const updatePlanDoc = async (planId, updates) => {
|
|
|
99
99
|
updatedAt: new Date(),
|
|
100
100
|
},
|
|
101
101
|
}, {
|
|
102
|
-
returnDocument:
|
|
102
|
+
returnDocument: "after",
|
|
103
103
|
});
|
|
104
104
|
};
|
|
105
105
|
exports.updatePlanDoc = updatePlanDoc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.getters.js","sourceRoot":"","sources":["../../../src/talkpilot/plans/plans.getters.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"plans.getters.js","sourceRoot":"","sources":["../../../src/talkpilot/plans/plans.getters.ts"],"names":[],"mappings":";;;AAAA,oCAOkB;AAClB,qCAA2C;AAC3C,sDAAyD;AAElD,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAO,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEF;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,MAAwB,EAAgB,EAAE;IAClE,MAAM,KAAK,GAAiB,EAAE,CAAC;IAE/B,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,KAAK,CAAC,GAAG,GAAG,IAAI,kBAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,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C,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,MAAM,aAAa,GAAG,KAAK,EAChC,QAA+C,EAC7B,EAAE;IACpB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAkB,GAAE,CAAC,SAAS,CAAC;QAClD,GAAG,QAAQ;QACX,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAS,EAAC,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB;AAEK,MAAM,aAAa,GAAG,KAAK,EAChC,MAAgB,EAChB,OAAuD,EAC9B,EAAE;IAC3B,OAAO,MAAM,IAAA,0BAAkB,GAAE,CAAC,gBAAgB,CAChD,EAAE,GAAG,EAAE,MAAM,EAAE,EACf;QACE,IAAI,EAAE;YACJ,GAAG,OAAO;YACV,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB;KACF,EACD;QACE,cAAc,EAAE,OAAO;KACxB,CACF,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sort, ObjectId, WithId } from
|
|
1
|
+
import { Sort, ObjectId, WithId } from "mongodb";
|
|
2
2
|
export declare const CURRENCY_CODES: readonly ["ILS", "USD", "EUR"];
|
|
3
3
|
export type CurrencyCode = (typeof CURRENCY_CODES)[number];
|
|
4
4
|
/** Required fields for creating a new plan */
|
|
@@ -6,10 +6,10 @@ export declare const PLAN_REQUIRED_FIELDS: string[];
|
|
|
6
6
|
/** All allowed fields that can be set/updated on a plan (excluding system fields) */
|
|
7
7
|
export declare const PLAN_ALLOWED_FIELDS: string[];
|
|
8
8
|
/** Logical product family, like "basic-500". Multiple regional variants can share it. */
|
|
9
|
-
export type ProductKey =
|
|
9
|
+
export type ProductKey = "basic-500" | "pro-1100" | "scale-6000" | (string & {});
|
|
10
10
|
/** Optional targeting to keep variants explicit */
|
|
11
|
-
export type RegionCode =
|
|
12
|
-
export type CountryCode =
|
|
11
|
+
export type RegionCode = "IL" | "EU" | "US" | (string & {});
|
|
12
|
+
export type CountryCode = "IL" | "DE" | "FR" | "ES" | "GB" | (string & {});
|
|
13
13
|
export type Tax = {
|
|
14
14
|
vatIncluded: boolean;
|
|
15
15
|
vatRatePct: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/plans/plans.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,cAAc,gCAAiC,CAAC;AAC7D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,UAa/B,CAAC;AAEF,yFAAyF;AACzF,MAAM,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"plans.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/plans/plans.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,cAAc,gCAAiC,CAAC;AAC7D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,UAOh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CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG;IAC1C,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACxB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,MAAM,MAAM,KAAK,GAAG,OAAO,EAAE,CAAC"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PLAN_ALLOWED_FIELDS = exports.PLAN_REQUIRED_FIELDS = exports.CURRENCY_CODES = void 0;
|
|
4
|
-
exports.CURRENCY_CODES = [
|
|
4
|
+
exports.CURRENCY_CODES = ["ILS", "USD", "EUR"];
|
|
5
5
|
/** Required fields for creating a new plan */
|
|
6
6
|
exports.PLAN_REQUIRED_FIELDS = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
"productKey",
|
|
8
|
+
"name",
|
|
9
|
+
"monthlyCallQuota",
|
|
10
|
+
"currency",
|
|
11
|
+
"priceMonthlyMinor",
|
|
12
|
+
"isActive",
|
|
13
13
|
];
|
|
14
14
|
/** All allowed fields that can be set/updated on a plan (excluding system fields) */
|
|
15
15
|
exports.PLAN_ALLOWED_FIELDS = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
"productKey",
|
|
17
|
+
"name",
|
|
18
|
+
"monthlyCallQuota",
|
|
19
|
+
"currency",
|
|
20
|
+
"priceMonthlyMinor",
|
|
21
|
+
"region",
|
|
22
|
+
"countryCode",
|
|
23
|
+
"isActive",
|
|
24
|
+
"originalPlanId",
|
|
25
|
+
"tax",
|
|
26
|
+
"metadata",
|
|
27
|
+
"updatedAt",
|
|
28
28
|
];
|
|
29
29
|
//# sourceMappingURL=plans.types.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { getResultsCollection, initializeResultDocument } from
|
|
2
|
-
export type * from
|
|
1
|
+
export { getResultsCollection, initializeResultDocument, } from "./results.getter";
|
|
2
|
+
export type * from "./results.types";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/results/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/results/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,mBAAmB,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/talkpilot/results/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/talkpilot/results/index.ts"],"names":[],"mappings":";;;AAAA,mDAG0B;AAFxB,sHAAA,oBAAoB,OAAA;AACpB,0HAAA,wBAAwB,OAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Collection } from
|
|
2
|
-
import { Session } from
|
|
3
|
-
import type { Result } from
|
|
1
|
+
import type { Collection } from "mongodb";
|
|
2
|
+
import { Session } from "../index";
|
|
3
|
+
import type { Result } from "./results.types";
|
|
4
4
|
export declare const getResultsCollection: () => Collection<Result>;
|
|
5
5
|
export declare const createRunId: () => string;
|
|
6
6
|
export declare const initializeResultDocument: (clientId: string, session?: Session) => Promise<Result>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.getter.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/results/results.getter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAmB,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,eAAO,MAAM,oBAAoB,QAAO,UAAU,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"results.getter.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/results/results.getter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAmB,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,eAAO,MAAM,oBAAoB,QAAO,UAAU,CAAC,MAAM,CAClB,CAAC;AAExC,eAAO,MAAM,WAAW,QAAO,MAE9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,UAAU,MAAM,EAChB,UAAU,OAAO,KAChB,OAAO,CAAC,MAAM,CAYhB,CAAC"}
|