@talkpilot/core-db 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +21 -24
- package/dist/connection.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/municipal/cities/cities.getters.d.ts +2 -2
- package/dist/municipal/cities/cities.getters.d.ts.map +1 -1
- package/dist/municipal/cities/cities.getters.js +8 -4
- package/dist/municipal/cities/cities.getters.js.map +1 -1
- package/dist/municipal/cities/cities.types.d.ts +1 -1
- package/dist/municipal/cities/index.d.ts +2 -2
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts +3 -3
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.d.ts.map +1 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js +30 -22
- package/dist/municipal/departmentsSubjects/departmentsSubjects.getters.js.map +1 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts +4 -4
- package/dist/municipal/departmentsSubjects/departmentsSubjects.types.d.ts.map +1 -1
- package/dist/municipal/departmentsSubjects/index.d.ts +2 -2
- package/dist/municipal/index.d.ts +8 -8
- package/dist/municipal/index.d.ts.map +1 -1
- package/dist/municipal/index.js +1 -1
- package/dist/municipal/mongodb-client.d.ts +1 -1
- package/dist/municipal/mongodb-client.d.ts.map +1 -1
- package/dist/municipal/mongodb-client.js +13 -25
- package/dist/municipal/mongodb-client.js.map +1 -1
- package/dist/municipal/streets/index.d.ts +2 -2
- package/dist/municipal/streets/streets.getters.d.ts +3 -3
- package/dist/municipal/streets/streets.getters.d.ts.map +1 -1
- package/dist/municipal/streets/streets.getters.js +19 -9
- package/dist/municipal/streets/streets.getters.js.map +1 -1
- package/dist/municipal/streets/streets.types.d.ts +1 -1
- package/dist/municipal/systemInstructions/index.d.ts +3 -3
- package/dist/municipal/systemInstructions/index.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.getters.d.ts +3 -3
- package/dist/municipal/systemInstructions/instructions.getters.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.getters.js +10 -4
- package/dist/municipal/systemInstructions/instructions.getters.js.map +1 -1
- package/dist/municipal/systemInstructions/instructions.setters.d.ts +2 -2
- package/dist/municipal/systemInstructions/instructions.setters.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.setters.js +13 -8
- package/dist/municipal/systemInstructions/instructions.setters.js.map +1 -1
- package/dist/municipal/systemInstructions/instructions.types.d.ts +3 -3
- package/dist/municipal/systemInstructions/instructions.types.d.ts.map +1 -1
- package/dist/municipal/systemInstructions/instructions.types.js +6 -6
- package/dist/municipal/tickets/index.d.ts +2 -2
- package/dist/municipal/tickets/tickets.getters.d.ts +3 -3
- package/dist/municipal/tickets/tickets.getters.d.ts.map +1 -1
- package/dist/municipal/tickets/tickets.getters.js +50 -29
- package/dist/municipal/tickets/tickets.getters.js.map +1 -1
- package/dist/municipal/tickets/tickets.types.d.ts +1 -1
- package/dist/municipal/tickets/tickets.types.d.ts.map +1 -1
- package/dist/municipal/utils/types.d.ts +1 -1
- package/dist/municipal/utils/types.d.ts.map +1 -1
- package/dist/talkpilot/agents/agents.getters.d.ts +1 -1
- package/dist/talkpilot/agents/agents.getters.js +2 -2
- package/dist/talkpilot/agents/agents.types.d.ts +2 -2
- package/dist/talkpilot/agents/index.d.ts +2 -2
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts +2 -2
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.d.ts.map +1 -1
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js +1 -1
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.getters.js.map +1 -1
- package/dist/talkpilot/backgroundToolResults/backgroundToolResults.types.d.ts +2 -2
- package/dist/talkpilot/backgroundToolResults/index.d.ts +2 -2
- package/dist/talkpilot/calls/calls.getters.d.ts +3 -3
- package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.getters.js +19 -15
- package/dist/talkpilot/calls/calls.getters.js.map +1 -1
- package/dist/talkpilot/calls/calls.types.d.ts +3 -3
- package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.types.js +2 -2
- package/dist/talkpilot/calls/index.d.ts +2 -2
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts +2 -2
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.d.ts.map +1 -1
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js +2 -2
- package/dist/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.js.map +1 -1
- package/dist/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.d.ts +2 -2
- package/dist/talkpilot/clientAudioBuffers/index.d.ts +2 -2
- package/dist/talkpilot/clients/clients.getters.d.ts +2 -2
- package/dist/talkpilot/clients/clients.getters.d.ts.map +1 -1
- package/dist/talkpilot/clients/clients.getters.js +5 -2
- package/dist/talkpilot/clients/clients.getters.js.map +1 -1
- package/dist/talkpilot/clients/clients.types.d.ts +1 -1
- package/dist/talkpilot/clients/index.d.ts +2 -2
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +2 -2
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +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.map +1 -1
- package/dist/talkpilot/flows/flows.schema.js +87 -79
- package/dist/talkpilot/flows/flows.schema.js.map +1 -1
- package/dist/talkpilot/flows/flows.types.d.ts +16 -16
- package/dist/talkpilot/flows/index.d.ts +2 -2
- package/dist/talkpilot/groups/groups.getters.d.ts +2 -2
- package/dist/talkpilot/groups/groups.getters.d.ts.map +1 -1
- package/dist/talkpilot/groups/groups.getters.js +2 -2
- package/dist/talkpilot/groups/groups.getters.js.map +1 -1
- package/dist/talkpilot/groups/groups.types.d.ts +1 -1
- package/dist/talkpilot/groups/index.d.ts +3 -3
- package/dist/talkpilot/groups/phone.utils.d.ts +1 -1
- package/dist/talkpilot/groups/phone.utils.d.ts.map +1 -1
- package/dist/talkpilot/groups/phone.utils.js +2 -2
- package/dist/talkpilot/groups/phone.utils.js.map +1 -1
- package/dist/talkpilot/index.d.ts +16 -16
- package/dist/talkpilot/index.js +1 -1
- package/dist/talkpilot/leads/index.d.ts +2 -2
- package/dist/talkpilot/leads/leads.getter.d.ts +2 -2
- package/dist/talkpilot/leads/leads.getter.d.ts.map +1 -1
- package/dist/talkpilot/leads/leads.getter.js +1 -1
- package/dist/talkpilot/leads/leads.getter.js.map +1 -1
- package/dist/talkpilot/leads/leads.schema.js +16 -16
- package/dist/talkpilot/leads/leads.types.d.ts +1 -1
- package/dist/talkpilot/mongodb-client.d.ts +1 -1
- package/dist/talkpilot/mongodb-client.d.ts.map +1 -1
- package/dist/talkpilot/mongodb-client.js +16 -29
- package/dist/talkpilot/mongodb-client.js.map +1 -1
- package/dist/talkpilot/phone_numbers/index.d.ts +2 -2
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts +3 -3
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.d.ts.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.js +28 -13
- package/dist/talkpilot/phone_numbers/phone_numbers.getter.js.map +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.schema.js +9 -9
- package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts +1 -1
- package/dist/talkpilot/phone_numbers/phone_numbers.types.d.ts.map +1 -1
- package/dist/talkpilot/plans/index.d.ts +2 -2
- package/dist/talkpilot/plans/plans.getters.d.ts +2 -2
- package/dist/talkpilot/plans/plans.getters.d.ts.map +1 -1
- package/dist/talkpilot/plans/plans.getters.js +3 -3
- package/dist/talkpilot/plans/plans.getters.js.map +1 -1
- package/dist/talkpilot/plans/plans.types.d.ts +4 -4
- package/dist/talkpilot/plans/plans.types.d.ts.map +1 -1
- package/dist/talkpilot/plans/plans.types.js +19 -19
- package/dist/talkpilot/results/index.d.ts +2 -2
- package/dist/talkpilot/results/index.d.ts.map +1 -1
- package/dist/talkpilot/results/index.js.map +1 -1
- package/dist/talkpilot/results/results.getter.d.ts +3 -3
- package/dist/talkpilot/results/results.getter.d.ts.map +1 -1
- package/dist/talkpilot/results/results.getter.js +4 -4
- package/dist/talkpilot/results/results.getter.js.map +1 -1
- package/dist/talkpilot/results/results.schema.js +18 -18
- package/dist/talkpilot/results/results.types.d.ts +1 -1
- package/dist/talkpilot/sessions/index.d.ts +2 -2
- package/dist/talkpilot/sessions/sessions.getter.d.ts +3 -3
- package/dist/talkpilot/sessions/sessions.getter.d.ts.map +1 -1
- package/dist/talkpilot/sessions/sessions.getter.js +13 -10
- package/dist/talkpilot/sessions/sessions.getter.js.map +1 -1
- package/dist/talkpilot/sessions/sessions.schema.js +17 -17
- package/dist/talkpilot/sessions/sessions.types.d.ts +2 -2
- package/dist/talkpilot/subscriptions/index.d.ts +3 -3
- package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts +2 -2
- package/dist/talkpilot/subscriptions/subscriptions.getters.d.ts.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.getters.js +11 -11
- package/dist/talkpilot/subscriptions/subscriptions.getters.js.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts +2 -2
- package/dist/talkpilot/subscriptions/subscriptions.getters.utils.d.ts.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.getters.utils.js.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.types.d.ts +2 -2
- package/dist/talkpilot/subscriptions/subscriptions.types.d.ts.map +1 -1
- package/dist/talkpilot/subscriptions/subscriptions.types.js +7 -7
- package/dist/talkpilot/utils/query.utils.d.ts +1 -1
- package/dist/test-utils/db-utils.d.ts +1 -1
- package/dist/test-utils/db-utils.js +2 -2
- package/dist/test-utils/factories/index.d.ts +12 -12
- package/dist/test-utils/factories/municipal/cities.d.ts +2 -2
- package/dist/test-utils/factories/municipal/cities.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/cities.js +1 -1
- package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts +2 -2
- package/dist/test-utils/factories/municipal/departmentsSubjects.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/departmentsSubjects.js +7 -1
- package/dist/test-utils/factories/municipal/departmentsSubjects.js.map +1 -1
- package/dist/test-utils/factories/municipal/streets.d.ts +2 -2
- package/dist/test-utils/factories/municipal/streets.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/streets.js +6 -1
- package/dist/test-utils/factories/municipal/streets.js.map +1 -1
- package/dist/test-utils/factories/municipal/tickets.d.ts +2 -2
- package/dist/test-utils/factories/municipal/tickets.d.ts.map +1 -1
- package/dist/test-utils/factories/municipal/tickets.js +7 -1
- package/dist/test-utils/factories/municipal/tickets.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/agents.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/agents.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/agents.js +4 -4
- package/dist/test-utils/factories/talkpilot/calls.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/calls.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/calls.js +1 -1
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js +1 -1
- package/dist/test-utils/factories/talkpilot/clientAudioBuffers.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/clientsConfig.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/clientsConfig.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/flows.d.ts +3 -3
- package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/groups.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/groups.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/groups.js +9 -9
- package/dist/test-utils/factories/talkpilot/groups.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts +3 -3
- package/dist/test-utils/factories/talkpilot/phone_numbers.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/phone_numbers.js.map +1 -1
- package/dist/test-utils/factories/talkpilot/sessions.d.ts +2 -2
- package/dist/test-utils/factories/talkpilot/sessions.d.ts.map +1 -1
- package/dist/test-utils/factories/talkpilot/sessions.js +1 -1
- package/dist/utils/validation.js +2 -2
- package/dist/utils/validation.js.map +1 -1
- package/package.json +3 -1
- package/src/__tests__/setup.ts +3 -3
- package/src/connection.ts +27 -25
- package/src/index.ts +9 -9
- package/src/municipal/__tests__/validation.spec.ts +35 -23
- package/src/municipal/cities/cities.getters.ts +16 -10
- package/src/municipal/cities/cities.types.ts +1 -1
- package/src/municipal/cities/index.ts +2 -2
- package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +53 -44
- package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +5 -5
- package/src/municipal/departmentsSubjects/index.ts +2 -3
- package/src/municipal/index.ts +10 -10
- package/src/municipal/mongodb-client.ts +19 -26
- package/src/municipal/streets/index.ts +2 -2
- package/src/municipal/streets/streets.getters.ts +43 -23
- package/src/municipal/streets/streets.types.ts +1 -1
- package/src/municipal/systemInstructions/__tests__/getters.spec.ts +67 -52
- package/src/municipal/systemInstructions/__tests__/setters.spec.ts +271 -238
- package/src/municipal/systemInstructions/index.ts +7 -3
- package/src/municipal/systemInstructions/instructions.getters.ts +30 -18
- package/src/municipal/systemInstructions/instructions.setters.ts +43 -19
- package/src/municipal/systemInstructions/instructions.types.ts +10 -10
- package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +12 -12
- package/src/municipal/tickets/index.ts +2 -2
- package/src/municipal/tickets/tickets.getters.ts +69 -42
- package/src/municipal/tickets/tickets.types.ts +2 -2
- package/src/municipal/utils/types.ts +8 -3
- package/src/talkpilot/__tests__/db.spec.ts +12 -12
- package/src/talkpilot/__tests__/mongodb-client.spec.ts +7 -8
- package/src/talkpilot/__tests__/validation.spec.ts +30 -24
- package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +10 -10
- package/src/talkpilot/agents/agents.getters.ts +3 -3
- package/src/talkpilot/agents/agents.types.ts +2 -2
- package/src/talkpilot/agents/index.ts +2 -2
- package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +42 -31
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +11 -11
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +2 -3
- package/src/talkpilot/backgroundToolResults/index.ts +2 -2
- package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +27 -27
- package/src/talkpilot/calls/__tests__/calls.spec.ts +79 -39
- package/src/talkpilot/calls/calls.getters.ts +48 -28
- package/src/talkpilot/calls/calls.types.ts +16 -16
- package/src/talkpilot/calls/index.ts +2 -2
- package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +73 -39
- package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +18 -11
- package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +2 -2
- package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
- package/src/talkpilot/clients/clients.getters.ts +10 -5
- package/src/talkpilot/clients/clients.types.ts +1 -1
- package/src/talkpilot/clients/index.ts +2 -2
- package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +21 -18
- package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +6 -4
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +10 -8
- package/src/talkpilot/clientsConfig/index.ts +2 -2
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +38 -34
- package/src/talkpilot/flows/flows.getter.ts +8 -5
- package/src/talkpilot/flows/flows.schema.ts +87 -79
- package/src/talkpilot/flows/flows.types.ts +23 -23
- package/src/talkpilot/flows/index.ts +2 -2
- package/src/talkpilot/groups/__tests__/groups.spec.ts +34 -27
- package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +20 -20
- package/src/talkpilot/groups/groups.getters.ts +8 -5
- package/src/talkpilot/groups/groups.types.ts +1 -1
- package/src/talkpilot/groups/index.ts +3 -3
- package/src/talkpilot/groups/phone.utils.ts +12 -6
- package/src/talkpilot/index.ts +17 -17
- package/src/talkpilot/leads/index.ts +2 -2
- package/src/talkpilot/leads/leads.getter.ts +5 -4
- package/src/talkpilot/leads/leads.schema.ts +16 -16
- package/src/talkpilot/leads/leads.types.ts +1 -1
- package/src/talkpilot/mongodb-client.ts +23 -33
- package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +84 -44
- package/src/talkpilot/phone_numbers/index.ts +2 -2
- package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +44 -22
- package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +9 -9
- package/src/talkpilot/phone_numbers/phone_numbers.types.ts +1 -1
- package/src/talkpilot/plans/__tests__/plans.spec.ts +30 -26
- package/src/talkpilot/plans/index.ts +2 -2
- package/src/talkpilot/plans/plans.getters.ts +25 -18
- package/src/talkpilot/plans/plans.types.ts +27 -23
- package/src/talkpilot/results/index.ts +5 -2
- package/src/talkpilot/results/results.getter.ts +9 -8
- package/src/talkpilot/results/results.schema.ts +18 -18
- package/src/talkpilot/results/results.types.ts +1 -1
- package/src/talkpilot/sessions/__tests__/sessions.spec.ts +65 -41
- package/src/talkpilot/sessions/index.ts +2 -2
- package/src/talkpilot/sessions/sessions.getter.ts +21 -16
- package/src/talkpilot/sessions/sessions.schema.ts +17 -17
- package/src/talkpilot/sessions/sessions.types.ts +2 -2
- package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +18 -15
- package/src/talkpilot/subscriptions/index.ts +3 -3
- package/src/talkpilot/subscriptions/subscriptions.getters.ts +36 -33
- package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +10 -3
- package/src/talkpilot/subscriptions/subscriptions.types.ts +9 -9
- package/src/talkpilot/utils/__tests__/query.utils.spec.ts +8 -8
- package/src/talkpilot/utils/query.utils.ts +2 -2
- package/src/test-utils/db-utils.ts +5 -5
- package/src/test-utils/factories/index.ts +12 -12
- package/src/test-utils/factories/municipal/cities.ts +5 -5
- package/src/test-utils/factories/municipal/departmentsSubjects.ts +32 -25
- package/src/test-utils/factories/municipal/streets.ts +10 -5
- package/src/test-utils/factories/municipal/tickets.ts +12 -6
- package/src/test-utils/factories/talkpilot/agents.ts +8 -8
- package/src/test-utils/factories/talkpilot/calls.ts +5 -5
- package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +14 -12
- package/src/test-utils/factories/talkpilot/clientsConfig.ts +7 -8
- package/src/test-utils/factories/talkpilot/flows.ts +7 -5
- package/src/test-utils/factories/talkpilot/groups.ts +13 -13
- package/src/test-utils/factories/talkpilot/phone_numbers.ts +8 -6
- package/src/test-utils/factories/talkpilot/sessions.ts +5 -5
- package/src/utils/validation.ts +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithId } from
|
|
1
|
+
import { WithId } from "mongodb";
|
|
2
2
|
|
|
3
3
|
export type InitiateCallForShortSlaConfig = {
|
|
4
4
|
active: boolean;
|
|
@@ -35,16 +35,16 @@ export type Products = {
|
|
|
35
35
|
export type ClinicsProduct = {
|
|
36
36
|
api_key_secret_name: string;
|
|
37
37
|
base_api_url: string;
|
|
38
|
-
provider:
|
|
38
|
+
provider: "clinix" | (string & {});
|
|
39
39
|
description?: string;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export type ClientLanguageName =
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
43
|
+
| "Hebrew"
|
|
44
|
+
| "English"
|
|
45
|
+
| "Russian"
|
|
46
|
+
| "French"
|
|
47
|
+
| "Spanish"
|
|
48
48
|
| (string & {});
|
|
49
49
|
|
|
50
50
|
export type SendGridConfig = {
|
|
@@ -72,4 +72,6 @@ export type ClientConfig<P extends Products = Products> = {
|
|
|
72
72
|
communications?: CommunicationsConfig;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
export type ClientConfigDoc<P extends Products = Products> = WithId<
|
|
75
|
+
export type ClientConfigDoc<P extends Products = Products> = WithId<
|
|
76
|
+
ClientConfig<P>
|
|
77
|
+
>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./clientsConfig.types";
|
|
2
|
+
export * from "./clientsConfig.getters";
|
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
import { flowMongoSchema } from
|
|
1
|
+
import { flowMongoSchema } from "../flows.schema";
|
|
2
2
|
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
3
|
+
describe("flowMongoSchema", () => {
|
|
4
|
+
it("defines conversationSettings as optional object or null", () => {
|
|
5
5
|
const schema: any = flowMongoSchema;
|
|
6
6
|
|
|
7
|
-
expect(schema.properties).toHaveProperty(
|
|
8
|
-
expect(schema.properties.conversationSettings.bsonType).toEqual([
|
|
9
|
-
|
|
7
|
+
expect(schema.properties).toHaveProperty("conversationSettings");
|
|
8
|
+
expect(schema.properties.conversationSettings.bsonType).toEqual([
|
|
9
|
+
"object",
|
|
10
|
+
"null",
|
|
11
|
+
]);
|
|
12
|
+
expect(schema.required).not.toContain("conversationSettings");
|
|
10
13
|
expect(schema.additionalProperties).toBe(false);
|
|
11
14
|
});
|
|
12
15
|
|
|
13
|
-
it(
|
|
16
|
+
it("defines conversationSettings with expected nested properties", () => {
|
|
14
17
|
const schema: any = flowMongoSchema;
|
|
15
18
|
const convSettings = schema.properties.conversationSettings.properties;
|
|
16
19
|
|
|
17
|
-
expect(convSettings).toHaveProperty(
|
|
18
|
-
expect(convSettings.interruptions.bsonType).toEqual([
|
|
20
|
+
expect(convSettings).toHaveProperty("interruptions");
|
|
21
|
+
expect(convSettings.interruptions.bsonType).toEqual(["object", "null"]);
|
|
19
22
|
|
|
20
23
|
const interruptions = convSettings.interruptions.properties;
|
|
21
|
-
expect(interruptions.enableInterruptionDetection.bsonType).toEqual(
|
|
22
|
-
expect(interruptions.interruptionWindowSeconds.bsonType).toEqual(
|
|
23
|
-
expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual(
|
|
24
|
-
|
|
24
|
+
expect(interruptions.enableInterruptionDetection.bsonType).toEqual("bool");
|
|
25
|
+
expect(interruptions.interruptionWindowSeconds.bsonType).toEqual("number");
|
|
26
|
+
expect(interruptions.interruptionThresholdSeconds.bsonType).toEqual(
|
|
27
|
+
"number",
|
|
28
|
+
);
|
|
29
|
+
expect(interruptions.interruptionInstruction.bsonType).toEqual("string");
|
|
25
30
|
|
|
26
|
-
expect(convSettings).toHaveProperty(
|
|
27
|
-
expect(convSettings.silence.bsonType).toEqual([
|
|
31
|
+
expect(convSettings).toHaveProperty("silence");
|
|
32
|
+
expect(convSettings.silence.bsonType).toEqual(["object", "null"]);
|
|
28
33
|
|
|
29
34
|
const silence = convSettings.silence.properties;
|
|
30
|
-
expect(silence.enableSilenceDetection.bsonType).toEqual(
|
|
31
|
-
expect(silence.firstWarningSilenceSeconds.bsonType).toEqual(
|
|
32
|
-
expect(silence.firstWarningInstruction.bsonType).toEqual(
|
|
33
|
-
expect(silence.secondWarningSilenceSeconds.bsonType).toEqual(
|
|
34
|
-
expect(silence.secondWarningInstruction.bsonType).toEqual(
|
|
35
|
-
expect(silence.disconnectSilenceSeconds.bsonType).toEqual(
|
|
36
|
-
expect(convSettings).toHaveProperty(
|
|
37
|
-
expect(convSettings.liveTimeUpdates.bsonType).toEqual(
|
|
35
|
+
expect(silence.enableSilenceDetection.bsonType).toEqual("bool");
|
|
36
|
+
expect(silence.firstWarningSilenceSeconds.bsonType).toEqual("number");
|
|
37
|
+
expect(silence.firstWarningInstruction.bsonType).toEqual("string");
|
|
38
|
+
expect(silence.secondWarningSilenceSeconds.bsonType).toEqual("number");
|
|
39
|
+
expect(silence.secondWarningInstruction.bsonType).toEqual("string");
|
|
40
|
+
expect(silence.disconnectSilenceSeconds.bsonType).toEqual("number");
|
|
41
|
+
expect(convSettings).toHaveProperty("liveTimeUpdates");
|
|
42
|
+
expect(convSettings.liveTimeUpdates.bsonType).toEqual("bool");
|
|
38
43
|
});
|
|
39
44
|
|
|
40
|
-
it(
|
|
45
|
+
it("should define tools schema and return a backgroundToolType enum with allowed values", () => {
|
|
41
46
|
const schema: any = flowMongoSchema;
|
|
42
47
|
|
|
43
|
-
expect(schema.properties).toHaveProperty(
|
|
44
|
-
expect(schema.properties.tools.bsonType).toEqual([
|
|
48
|
+
expect(schema.properties).toHaveProperty("tools");
|
|
49
|
+
expect(schema.properties.tools.bsonType).toEqual(["array", "null"]);
|
|
45
50
|
|
|
46
51
|
const toolItem = schema.properties.tools.items;
|
|
47
|
-
expect(toolItem.bsonType).toBe(
|
|
52
|
+
expect(toolItem.bsonType).toBe("object");
|
|
48
53
|
|
|
49
|
-
expect(toolItem.properties).toHaveProperty(
|
|
50
|
-
expect(toolItem.properties.runInBackground.bsonType).toBe(
|
|
54
|
+
expect(toolItem.properties).toHaveProperty("runInBackground");
|
|
55
|
+
expect(toolItem.properties.runInBackground.bsonType).toBe("bool");
|
|
51
56
|
|
|
52
|
-
expect(toolItem.properties).toHaveProperty(
|
|
53
|
-
expect(toolItem.properties.backgroundToolType.bsonType).toBe(
|
|
57
|
+
expect(toolItem.properties).toHaveProperty("backgroundToolType");
|
|
58
|
+
expect(toolItem.properties.backgroundToolType.bsonType).toBe("string");
|
|
54
59
|
expect(toolItem.properties.backgroundToolType.enum).toEqual([
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
"backgroundToolAlways",
|
|
61
|
+
"backgroundToolOnce",
|
|
57
62
|
]);
|
|
58
63
|
});
|
|
59
64
|
});
|
|
60
|
-
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { Collection, ObjectId, WithId } from
|
|
2
|
-
import { getDb } from
|
|
3
|
-
import type { Flow } from
|
|
1
|
+
import type { Collection, ObjectId, WithId } from "mongodb";
|
|
2
|
+
import { getDb } from "../index";
|
|
3
|
+
import type { Flow } from "./flows.types";
|
|
4
4
|
|
|
5
5
|
export const getFlowsCollection = (): Collection<Flow> => {
|
|
6
|
-
return getDb().collection<Flow>(
|
|
6
|
+
return getDb().collection<Flow>("flows");
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const findFlowById = (
|
|
9
|
+
export const findFlowById = (
|
|
10
|
+
flowId: ObjectId,
|
|
11
|
+
clientId: string,
|
|
12
|
+
): Promise<WithId<Flow> | null> => {
|
|
10
13
|
return getFlowsCollection().findOne({ _id: flowId, clientId });
|
|
11
14
|
};
|
|
@@ -1,139 +1,147 @@
|
|
|
1
1
|
export const flowMongoSchema = {
|
|
2
|
-
bsonType:
|
|
3
|
-
required: [
|
|
2
|
+
bsonType: "object",
|
|
3
|
+
required: [
|
|
4
|
+
"flowName",
|
|
5
|
+
"systemInstructions",
|
|
6
|
+
"initialSentence",
|
|
7
|
+
"interactions",
|
|
8
|
+
],
|
|
4
9
|
properties: {
|
|
5
|
-
_id: { bsonType:
|
|
6
|
-
flowName: { bsonType:
|
|
7
|
-
clientId: { bsonType:
|
|
8
|
-
systemInstructions: { bsonType:
|
|
9
|
-
initialSentence: { bsonType:
|
|
10
|
-
voice: { bsonType: [
|
|
10
|
+
_id: { bsonType: "objectId" },
|
|
11
|
+
flowName: { bsonType: "string" },
|
|
12
|
+
clientId: { bsonType: "string" },
|
|
13
|
+
systemInstructions: { bsonType: "string" },
|
|
14
|
+
initialSentence: { bsonType: "string" },
|
|
15
|
+
voice: { bsonType: ["string", "null"] },
|
|
11
16
|
conversationSettings: {
|
|
12
|
-
bsonType: [
|
|
17
|
+
bsonType: ["object", "null"],
|
|
13
18
|
properties: {
|
|
14
19
|
interruptions: {
|
|
15
|
-
bsonType: [
|
|
20
|
+
bsonType: ["object", "null"],
|
|
16
21
|
properties: {
|
|
17
|
-
enableInterruptionDetection: { bsonType:
|
|
18
|
-
interruptionWindowSeconds: { bsonType:
|
|
19
|
-
interruptionThresholdSeconds: { bsonType:
|
|
20
|
-
interruptionInstruction: { bsonType:
|
|
22
|
+
enableInterruptionDetection: { bsonType: "bool" },
|
|
23
|
+
interruptionWindowSeconds: { bsonType: "number" },
|
|
24
|
+
interruptionThresholdSeconds: { bsonType: "number" },
|
|
25
|
+
interruptionInstruction: { bsonType: "string" },
|
|
21
26
|
},
|
|
22
27
|
additionalProperties: false,
|
|
23
28
|
},
|
|
24
29
|
silence: {
|
|
25
|
-
bsonType: [
|
|
30
|
+
bsonType: ["object", "null"],
|
|
26
31
|
properties: {
|
|
27
|
-
enableSilenceDetection: { bsonType:
|
|
28
|
-
firstWarningSilenceSeconds: { bsonType:
|
|
29
|
-
firstWarningInstruction: { bsonType:
|
|
30
|
-
secondWarningSilenceSeconds: { bsonType:
|
|
31
|
-
secondWarningInstruction: { bsonType:
|
|
32
|
-
disconnectSilenceSeconds: { bsonType:
|
|
32
|
+
enableSilenceDetection: { bsonType: "bool" },
|
|
33
|
+
firstWarningSilenceSeconds: { bsonType: "number" },
|
|
34
|
+
firstWarningInstruction: { bsonType: "string" },
|
|
35
|
+
secondWarningSilenceSeconds: { bsonType: "number" },
|
|
36
|
+
secondWarningInstruction: { bsonType: "string" },
|
|
37
|
+
disconnectSilenceSeconds: { bsonType: "number" },
|
|
33
38
|
},
|
|
34
39
|
additionalProperties: false,
|
|
35
40
|
},
|
|
36
|
-
liveTimeUpdates: { bsonType:
|
|
41
|
+
liveTimeUpdates: { bsonType: "bool" },
|
|
37
42
|
},
|
|
38
43
|
additionalProperties: false,
|
|
39
44
|
},
|
|
40
45
|
interactions: {
|
|
41
|
-
bsonType:
|
|
46
|
+
bsonType: "array",
|
|
42
47
|
items: {
|
|
43
|
-
bsonType:
|
|
44
|
-
required: [
|
|
48
|
+
bsonType: "object",
|
|
49
|
+
required: ["id", "type", "text", "position"],
|
|
45
50
|
properties: {
|
|
46
|
-
id: { bsonType:
|
|
47
|
-
type: { bsonType:
|
|
48
|
-
text: { bsonType:
|
|
49
|
-
successStatus: { bsonType: [
|
|
51
|
+
id: { bsonType: "string" },
|
|
52
|
+
type: { bsonType: "string" },
|
|
53
|
+
text: { bsonType: "string" },
|
|
54
|
+
successStatus: { bsonType: ["string", "null"] },
|
|
50
55
|
conditions: {
|
|
51
|
-
bsonType: [
|
|
56
|
+
bsonType: ["array", "null"],
|
|
52
57
|
items: {
|
|
53
|
-
bsonType:
|
|
54
|
-
required: [
|
|
58
|
+
bsonType: "object",
|
|
59
|
+
required: ["conditionString"],
|
|
55
60
|
properties: {
|
|
56
|
-
conditionString: { bsonType:
|
|
57
|
-
nodeType: { bsonType: [
|
|
58
|
-
id: { bsonType: [
|
|
61
|
+
conditionString: { bsonType: "string" },
|
|
62
|
+
nodeType: { bsonType: ["string", "null"] },
|
|
63
|
+
id: { bsonType: ["string", "null"] },
|
|
59
64
|
},
|
|
60
65
|
},
|
|
61
66
|
},
|
|
62
|
-
defaultNodeType: { bsonType: [
|
|
67
|
+
defaultNodeType: { bsonType: ["string", "null"] },
|
|
63
68
|
defaultChild: {
|
|
64
|
-
bsonType: [
|
|
65
|
-
properties: { id: { bsonType:
|
|
69
|
+
bsonType: ["object", "null"],
|
|
70
|
+
properties: { id: { bsonType: "string" } },
|
|
66
71
|
},
|
|
67
72
|
position: {
|
|
68
|
-
bsonType:
|
|
69
|
-
required: [
|
|
73
|
+
bsonType: "object",
|
|
74
|
+
required: ["x", "y"],
|
|
70
75
|
properties: {
|
|
71
|
-
x: { bsonType:
|
|
72
|
-
y: { bsonType:
|
|
76
|
+
x: { bsonType: "number" },
|
|
77
|
+
y: { bsonType: "number" },
|
|
73
78
|
},
|
|
74
79
|
},
|
|
75
|
-
name: { bsonType: [
|
|
76
|
-
children: {
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
name: { bsonType: ["string", "null"] },
|
|
81
|
+
children: {
|
|
82
|
+
bsonType: ["array", "null"],
|
|
83
|
+
items: { bsonType: "string" },
|
|
84
|
+
},
|
|
85
|
+
resultsLabel: { bsonType: ["string", "null"] },
|
|
86
|
+
resultsColor: { bsonType: ["string", "null"] },
|
|
79
87
|
},
|
|
80
88
|
},
|
|
81
89
|
},
|
|
82
90
|
edges: {
|
|
83
|
-
bsonType: [
|
|
91
|
+
bsonType: ["array", "null"],
|
|
84
92
|
items: {
|
|
85
|
-
bsonType:
|
|
86
|
-
required: [
|
|
93
|
+
bsonType: "object",
|
|
94
|
+
required: ["id", "source", "target"],
|
|
87
95
|
properties: {
|
|
88
|
-
id: { bsonType:
|
|
89
|
-
source: { bsonType:
|
|
90
|
-
target: { bsonType:
|
|
91
|
-
label: { bsonType: [
|
|
96
|
+
id: { bsonType: "string" },
|
|
97
|
+
source: { bsonType: "string" },
|
|
98
|
+
target: { bsonType: "string" },
|
|
99
|
+
label: { bsonType: ["string", "null"] },
|
|
92
100
|
},
|
|
93
101
|
},
|
|
94
102
|
},
|
|
95
103
|
metaKeys: {
|
|
96
|
-
bsonType: [
|
|
104
|
+
bsonType: ["array", "null"],
|
|
97
105
|
items: {
|
|
98
|
-
bsonType:
|
|
99
|
-
required: [
|
|
106
|
+
bsonType: "object",
|
|
107
|
+
required: ["key"],
|
|
100
108
|
properties: {
|
|
101
|
-
key: { bsonType:
|
|
102
|
-
required: { bsonType:
|
|
109
|
+
key: { bsonType: "string" },
|
|
110
|
+
required: { bsonType: "bool" },
|
|
103
111
|
},
|
|
104
112
|
},
|
|
105
113
|
},
|
|
106
114
|
userProperties: {
|
|
107
|
-
bsonType: [
|
|
115
|
+
bsonType: ["array", "null"],
|
|
108
116
|
items: {
|
|
109
|
-
bsonType:
|
|
110
|
-
required: [
|
|
117
|
+
bsonType: "object",
|
|
118
|
+
required: ["name", "description"],
|
|
111
119
|
properties: {
|
|
112
|
-
name: { bsonType:
|
|
113
|
-
description: { bsonType:
|
|
120
|
+
name: { bsonType: "string" },
|
|
121
|
+
description: { bsonType: "string" },
|
|
114
122
|
},
|
|
115
123
|
},
|
|
116
124
|
},
|
|
117
125
|
tools: {
|
|
118
|
-
bsonType: [
|
|
126
|
+
bsonType: ["array", "null"],
|
|
119
127
|
items: {
|
|
120
|
-
bsonType:
|
|
121
|
-
required: [
|
|
128
|
+
bsonType: "object",
|
|
129
|
+
required: ["id", "name", "url", "method", "parameters"],
|
|
122
130
|
properties: {
|
|
123
|
-
id: { bsonType:
|
|
124
|
-
name: { bsonType:
|
|
125
|
-
description: { bsonType:
|
|
126
|
-
url: { bsonType:
|
|
127
|
-
method: { bsonType:
|
|
128
|
-
headers: { bsonType:
|
|
129
|
-
parameters: { bsonType:
|
|
130
|
-
bodyFormat: { bsonType:
|
|
131
|
-
preventAudioDuringTool: { bsonType:
|
|
132
|
-
sendUserAuthToken: { bsonType:
|
|
133
|
-
runInBackground: { bsonType:
|
|
131
|
+
id: { bsonType: "string" },
|
|
132
|
+
name: { bsonType: "string" },
|
|
133
|
+
description: { bsonType: "string" },
|
|
134
|
+
url: { bsonType: "string" },
|
|
135
|
+
method: { bsonType: "string" },
|
|
136
|
+
headers: { bsonType: "object" },
|
|
137
|
+
parameters: { bsonType: "object" },
|
|
138
|
+
bodyFormat: { bsonType: "string", enum: ["json", "form-data"] },
|
|
139
|
+
preventAudioDuringTool: { bsonType: "bool" },
|
|
140
|
+
sendUserAuthToken: { bsonType: "bool" },
|
|
141
|
+
runInBackground: { bsonType: "bool" },
|
|
134
142
|
backgroundToolType: {
|
|
135
|
-
bsonType:
|
|
136
|
-
enum: [
|
|
143
|
+
bsonType: "string",
|
|
144
|
+
enum: ["backgroundToolAlways", "backgroundToolOnce"],
|
|
137
145
|
},
|
|
138
146
|
},
|
|
139
147
|
additionalProperties: false,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ObjectId } from
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
2
|
|
|
3
3
|
/* ---------- Basic helpers ---------- */
|
|
4
4
|
|
|
5
5
|
export type Position = { x: number; y: number };
|
|
6
|
-
export type HttpMethod =
|
|
6
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
7
7
|
|
|
8
|
-
export type QuestionType =
|
|
9
|
-
export type SelectionType =
|
|
8
|
+
export type QuestionType = "open" | "multiple" | "table";
|
|
9
|
+
export type SelectionType = "single" | "multiple";
|
|
10
10
|
|
|
11
11
|
export type Question = {
|
|
12
12
|
id: string;
|
|
@@ -24,14 +24,14 @@ export type Question = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export type NodeKind =
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
27
|
+
| "start"
|
|
28
|
+
| "say"
|
|
29
|
+
| "condition"
|
|
30
|
+
| "improvise"
|
|
31
|
+
| "tool"
|
|
32
|
+
| "sendMessage"
|
|
33
|
+
| "questionsList"
|
|
34
|
+
| "end";
|
|
35
35
|
type BaseNode = {
|
|
36
36
|
id: string;
|
|
37
37
|
type: NodeKind;
|
|
@@ -44,12 +44,12 @@ type BaseNode = {
|
|
|
44
44
|
questions?: Question[] | null;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export type StartNode = BaseNode & { type:
|
|
47
|
+
export type StartNode = BaseNode & { type: "start" };
|
|
48
48
|
|
|
49
|
-
export type SayNode = BaseNode & { type:
|
|
49
|
+
export type SayNode = BaseNode & { type: "say" };
|
|
50
50
|
|
|
51
51
|
export type ConditionNode = BaseNode & {
|
|
52
|
-
type:
|
|
52
|
+
type: "condition";
|
|
53
53
|
conditions: Array<{
|
|
54
54
|
conditionString: string;
|
|
55
55
|
nodeType?: string | null;
|
|
@@ -59,7 +59,7 @@ export type ConditionNode = BaseNode & {
|
|
|
59
59
|
defaultChild?: { id?: string } | null;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export type ImproviseNode = BaseNode & { type:
|
|
62
|
+
export type ImproviseNode = BaseNode & { type: "improvise" };
|
|
63
63
|
|
|
64
64
|
export type FlowTool = {
|
|
65
65
|
id: string;
|
|
@@ -69,17 +69,17 @@ export type FlowTool = {
|
|
|
69
69
|
method: HttpMethod;
|
|
70
70
|
headers?: Record<string, string>;
|
|
71
71
|
parameters: Record<string, unknown>;
|
|
72
|
-
bodyFormat?:
|
|
72
|
+
bodyFormat?: "json" | "form-data";
|
|
73
73
|
preventAudioDuringTool?: boolean;
|
|
74
74
|
sendUserAuthToken?: boolean;
|
|
75
75
|
runInBackground?: boolean;
|
|
76
|
-
backgroundToolType?:
|
|
76
|
+
backgroundToolType?: "backgroundToolAlways" | "backgroundToolOnce";
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
export type SendMethod =
|
|
79
|
+
export type SendMethod = "sms" | "whatsapp";
|
|
80
80
|
|
|
81
81
|
export type SendMessageNode = BaseNode & {
|
|
82
|
-
type:
|
|
82
|
+
type: "sendMessage";
|
|
83
83
|
/** Which channel to use. If omitted, decide at runtime (e.g., default to whatsapp). */
|
|
84
84
|
send_method: SendMethod;
|
|
85
85
|
/** Destination phone (E.164 or templated string like "{{userPhone}}"). */
|
|
@@ -87,17 +87,17 @@ export type SendMessageNode = BaseNode & {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
export type ToolNode = BaseNode & {
|
|
90
|
-
type:
|
|
90
|
+
type: "tool";
|
|
91
91
|
name: string;
|
|
92
92
|
text: string;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export type QuestionsListNode = BaseNode & {
|
|
96
|
-
type:
|
|
96
|
+
type: "questionsList";
|
|
97
97
|
questions: Question[];
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
export type EndNode = BaseNode & { type:
|
|
100
|
+
export type EndNode = BaseNode & { type: "end" };
|
|
101
101
|
|
|
102
102
|
export type Interaction =
|
|
103
103
|
| StartNode
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getFlowsCollection, findFlowById } from
|
|
2
|
-
export type * from
|
|
1
|
+
export { getFlowsCollection, findFlowById } from "./flows.getter";
|
|
2
|
+
export type * from "./flows.types";
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import { ObjectId } from
|
|
2
|
-
import { faker } from
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
|
+
import { faker } from "@faker-js/faker";
|
|
3
3
|
import {
|
|
4
4
|
getGroupsCollection,
|
|
5
5
|
findGroups,
|
|
6
6
|
createGroup,
|
|
7
7
|
updateGroup,
|
|
8
8
|
removeGroup,
|
|
9
|
-
} from
|
|
10
|
-
import { createGroup as createGroupDoc } from
|
|
9
|
+
} from "../groups.getters";
|
|
10
|
+
import { createGroup as createGroupDoc } from "../../../test-utils/factories";
|
|
11
11
|
|
|
12
|
-
describe(
|
|
13
|
-
describe(
|
|
12
|
+
describe("db.groups", () => {
|
|
13
|
+
describe("getGroupsCollection", () => {
|
|
14
14
|
it('returns the "groups" collection', () => {
|
|
15
|
-
expect(getGroupsCollection().collectionName).toBe(
|
|
15
|
+
expect(getGroupsCollection().collectionName).toBe("groups");
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
describe(
|
|
20
|
-
it(
|
|
19
|
+
describe("findGroups", () => {
|
|
20
|
+
it("returns groups matching the provided filter", async () => {
|
|
21
21
|
const clientId = faker.string.uuid();
|
|
22
|
-
const g1 = createGroupDoc({ clientId, name:
|
|
23
|
-
const g2 = createGroupDoc({ clientId, name:
|
|
24
|
-
const gOther = createGroupDoc({
|
|
22
|
+
const g1 = createGroupDoc({ clientId, name: "Group A" });
|
|
23
|
+
const g2 = createGroupDoc({ clientId, name: "Group B" });
|
|
24
|
+
const gOther = createGroupDoc({
|
|
25
|
+
clientId: faker.string.uuid(),
|
|
26
|
+
name: "Group C",
|
|
27
|
+
});
|
|
25
28
|
|
|
26
29
|
await getGroupsCollection().insertMany([g1, g2, gOther]);
|
|
27
30
|
|
|
@@ -29,26 +32,29 @@ describe('db.groups', () => {
|
|
|
29
32
|
const names = result.map((g) => g.name).sort();
|
|
30
33
|
|
|
31
34
|
expect(result).toHaveLength(2);
|
|
32
|
-
expect(names).toEqual([
|
|
35
|
+
expect(names).toEqual(["Group A", "Group B"]);
|
|
33
36
|
});
|
|
34
37
|
});
|
|
35
38
|
|
|
36
|
-
describe(
|
|
37
|
-
it(
|
|
38
|
-
const toInsert = createGroupDoc({ name:
|
|
39
|
+
describe("createGroup", () => {
|
|
40
|
+
it("inserts a group and returns insertedId", async () => {
|
|
41
|
+
const toInsert = createGroupDoc({ name: "New Group" });
|
|
39
42
|
|
|
40
43
|
const insertedId = await createGroup(toInsert);
|
|
41
44
|
expect(insertedId).toBeInstanceOf(ObjectId);
|
|
42
45
|
|
|
43
46
|
const fromDb = await getGroupsCollection().findOne({ _id: insertedId });
|
|
44
|
-
expect(fromDb?.name).toBe(
|
|
47
|
+
expect(fromDb?.name).toBe("New Group");
|
|
45
48
|
expect(fromDb?.clientId).toBe(toInsert.clientId);
|
|
46
49
|
});
|
|
47
50
|
});
|
|
48
51
|
|
|
49
|
-
describe(
|
|
50
|
-
it(
|
|
51
|
-
const original = createGroupDoc({
|
|
52
|
+
describe("updateGroup", () => {
|
|
53
|
+
it("updates the group and sets updatedAt, returning the updated document", async () => {
|
|
54
|
+
const original = createGroupDoc({
|
|
55
|
+
name: "Before",
|
|
56
|
+
description: "Old desc",
|
|
57
|
+
});
|
|
52
58
|
const { insertedId } = await getGroupsCollection().insertOne(original);
|
|
53
59
|
const before = await getGroupsCollection().findOne({ _id: insertedId });
|
|
54
60
|
|
|
@@ -57,21 +63,22 @@ describe('db.groups', () => {
|
|
|
57
63
|
|
|
58
64
|
const res = await updateGroup(
|
|
59
65
|
{ _id: insertedId },
|
|
60
|
-
{ name:
|
|
66
|
+
{ name: "After", description: "New desc" },
|
|
61
67
|
);
|
|
62
68
|
|
|
63
69
|
expect(res?._id).toEqual(insertedId);
|
|
64
|
-
expect(res?.name).toBe(
|
|
65
|
-
expect(res?.description).toBe(
|
|
70
|
+
expect(res?.name).toBe("After");
|
|
71
|
+
expect(res?.description).toBe("New desc");
|
|
66
72
|
expect(new Date(res!.updatedAt).getTime()).toBeGreaterThan(
|
|
67
|
-
new Date(before!.updatedAt).getTime()
|
|
73
|
+
new Date(before!.updatedAt).getTime(),
|
|
68
74
|
);
|
|
69
75
|
});
|
|
70
76
|
});
|
|
71
77
|
|
|
72
|
-
describe(
|
|
73
|
-
it(
|
|
74
|
-
const { insertedId } =
|
|
78
|
+
describe("removeGroup", () => {
|
|
79
|
+
it("removes a group by string id", async () => {
|
|
80
|
+
const { insertedId } =
|
|
81
|
+
await getGroupsCollection().insertOne(createGroupDoc());
|
|
75
82
|
|
|
76
83
|
const result = await removeGroup(insertedId.toHexString());
|
|
77
84
|
expect(result.deletedCount).toBe(1);
|