@erxes/api-shared 0.0.0-stage → 3.2.19-2
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/LICENSE.md +672 -0
- package/core-modules/dist/erxes-api-shared-core-modules.cjs.d.ts +2 -0
- package/core-modules/dist/erxes-api-shared-core-modules.cjs.dev.js +6685 -0
- package/core-modules/dist/erxes-api-shared-core-modules.cjs.js +7 -0
- package/core-modules/dist/erxes-api-shared-core-modules.cjs.prod.js +6685 -0
- package/core-modules/dist/erxes-api-shared-core-modules.esm.js +6298 -0
- package/core-modules/package.json +5 -0
- package/core-types/dist/erxes-api-shared-core-types.cjs.d.ts +2 -0
- package/core-types/dist/erxes-api-shared-core-types.cjs.dev.js +12 -0
- package/core-types/dist/erxes-api-shared-core-types.cjs.js +7 -0
- package/core-types/dist/erxes-api-shared-core-types.cjs.prod.js +12 -0
- package/core-types/dist/erxes-api-shared-core-types.esm.js +8 -0
- package/core-types/package.json +5 -0
- package/dist/declarations/src/core-modules/approval/approvalChangeTypes.d.ts +15 -0
- package/dist/declarations/src/core-modules/approval/approvalChangeTypes.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/approval/checkApprovalLock.d.ts +7 -0
- package/dist/declarations/src/core-modules/approval/checkApprovalLock.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/approval/constants.d.ts +37 -0
- package/dist/declarations/src/core-modules/approval/constants.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/approval/index.d.ts +7 -0
- package/dist/declarations/src/core-modules/approval/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/approval/initApproval.d.ts +9 -0
- package/dist/declarations/src/core-modules/approval/initApproval.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/approval/types.d.ts +164 -0
- package/dist/declarations/src/core-modules/approval/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/approval/zodSchemas.d.ts +125 -0
- package/dist/declarations/src/core-modules/approval/zodSchemas.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/apps/@types/app.d.ts +15 -0
- package/dist/declarations/src/core-modules/apps/@types/app.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/apps/db/definitions/apps.d.ts +13 -0
- package/dist/declarations/src/core-modules/apps/db/definitions/apps.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/apps/index.d.ts +3 -0
- package/dist/declarations/src/core-modules/apps/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/actionErrorPolicy.d.ts +68 -0
- package/dist/declarations/src/core-modules/automations/actionErrorPolicy.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/actionOutcome.d.ts +51 -0
- package/dist/declarations/src/core-modules/automations/actionOutcome.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/constants.d.ts +101 -0
- package/dist/declarations/src/core-modules/automations/constants.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/definitions/aiAgents.d.ts +141 -0
- package/dist/declarations/src/core-modules/automations/definitions/aiAgents.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/definitions/automations.d.ts +868 -0
- package/dist/declarations/src/core-modules/automations/definitions/automations.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts +316 -0
- package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/definitions/index.d.ts +4 -0
- package/dist/declarations/src/core-modules/automations/definitions/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/index.d.ts +14 -0
- package/dist/declarations/src/core-modules/automations/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/outputResolvers.d.ts +67 -0
- package/dist/declarations/src/core-modules/automations/outputResolvers.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/reEnrollment.d.ts +23 -0
- package/dist/declarations/src/core-modules/automations/reEnrollment.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/segmentMembership.d.ts +19 -0
- package/dist/declarations/src/core-modules/automations/segmentMembership.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/sendAutomationMessage.d.ts +51 -0
- package/dist/declarations/src/core-modules/automations/sendAutomationMessage.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/setupAutomationProducers.d.ts +4 -0
- package/dist/declarations/src/core-modules/automations/setupAutomationProducers.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/typeUtils.d.ts +2 -0
- package/dist/declarations/src/core-modules/automations/typeUtils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/types.d.ts +474 -0
- package/dist/declarations/src/core-modules/automations/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/utils.d.ts +38 -0
- package/dist/declarations/src/core-modules/automations/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/workflowValidation.d.ts +3 -0
- package/dist/declarations/src/core-modules/automations/workflowValidation.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/automations/zodTypes.d.ts +2366 -0
- package/dist/declarations/src/core-modules/automations/zodTypes.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/clientPortal.d.ts +375 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/clientPortal.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/comment.d.ts +53 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/comment.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/cpNotification.d.ts +110 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/cpNotification.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/cpUser.d.ts +828 -0
- package/dist/declarations/src/core-modules/client-portals/definitions/cpUser.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/client-portals/index.d.ts +5 -0
- package/dist/declarations/src/core-modules/client-portals/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/db/definitions/common.d.ts +77 -0
- package/dist/declarations/src/core-modules/common/db/definitions/common.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/createEventHandlers.d.ts +8 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/createEventHandlers.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/generateEventHandlers.d.ts +4 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/generateEventHandlers.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/index.d.ts +5 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/runtimeContext.d.ts +9 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/runtimeContext.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/schemas.d.ts +82 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/schemas.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/types.d.ts +87 -0
- package/dist/declarations/src/core-modules/common/eventHandlers/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/index.d.ts +5 -0
- package/dist/declarations/src/core-modules/common/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/references/getRecordReferenceFields.d.ts +57 -0
- package/dist/declarations/src/core-modules/common/references/getRecordReferenceFields.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/references/index.d.ts +6 -0
- package/dist/declarations/src/core-modules/common/references/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/references/initRecordReferences.d.ts +4 -0
- package/dist/declarations/src/core-modules/common/references/initRecordReferences.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/references/resolveRecordReferencePlaceholders.d.ts +12 -0
- package/dist/declarations/src/core-modules/common/references/resolveRecordReferencePlaceholders.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/references/resolveRecordReferenceValue.d.ts +6 -0
- package/dist/declarations/src/core-modules/common/references/resolveRecordReferenceValue.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/references/types.d.ts +63 -0
- package/dist/declarations/src/core-modules/common/references/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/common/routeToModuleProducer.d.ts +55 -0
- package/dist/declarations/src/core-modules/common/routeToModuleProducer.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/blocksToHtml.d.ts +72 -0
- package/dist/declarations/src/core-modules/email-content/blocksToHtml.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/constants.d.ts +5 -0
- package/dist/declarations/src/core-modules/email-content/constants.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/emailFooter.d.ts +5 -0
- package/dist/declarations/src/core-modules/email-content/emailFooter.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/expandRepeatRows.d.ts +9 -0
- package/dist/declarations/src/core-modules/email-content/expandRepeatRows.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/index.d.ts +9 -0
- package/dist/declarations/src/core-modules/email-content/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/renderEmailContent.d.ts +19 -0
- package/dist/declarations/src/core-modules/email-content/renderEmailContent.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/replacePlaceholders.d.ts +36 -0
- package/dist/declarations/src/core-modules/email-content/replacePlaceholders.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/types.d.ts +48 -0
- package/dist/declarations/src/core-modules/email-content/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/email-content/unresolvedPlaceholders.d.ts +4 -0
- package/dist/declarations/src/core-modules/email-content/unresolvedPlaceholders.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/forms/index.d.ts +3 -0
- package/dist/declarations/src/core-modules/forms/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/forms/types.d.ts +55 -0
- package/dist/declarations/src/core-modules/forms/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/forms/utils.d.ts +4 -0
- package/dist/declarations/src/core-modules/forms/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/index.d.ts +8 -0
- package/dist/declarations/src/core-modules/import-export/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/types.d.ts +181 -0
- package/dist/declarations/src/core-modules/import-export/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/utils/exportCursor.d.ts +14 -0
- package/dist/declarations/src/core-modules/import-export/utils/exportCursor.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/utils/headerMatcher.d.ts +32 -0
- package/dist/declarations/src/core-modules/import-export/utils/headerMatcher.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/utils/importExportRuntime.d.ts +32 -0
- package/dist/declarations/src/core-modules/import-export/utils/importExportRuntime.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/utils/importUtils.d.ts +25 -0
- package/dist/declarations/src/core-modules/import-export/utils/importUtils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/worker.d.ts +8 -0
- package/dist/declarations/src/core-modules/import-export/worker.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/import-export/zodSchemas.d.ts +111 -0
- package/dist/declarations/src/core-modules/import-export/zodSchemas.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/index.d.ts +16 -0
- package/dist/declarations/src/core-modules/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/activityLog/builder.d.ts +3 -0
- package/dist/declarations/src/core-modules/logs/activityLog/builder.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/activityLog/index.d.ts +5 -0
- package/dist/declarations/src/core-modules/logs/activityLog/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/activityLog/sharedBuilders.d.ts +18 -0
- package/dist/declarations/src/core-modules/logs/activityLog/sharedBuilders.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/activityLog/types.d.ts +21 -0
- package/dist/declarations/src/core-modules/logs/activityLog/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/activityLog/utils.d.ts +10 -0
- package/dist/declarations/src/core-modules/logs/activityLog/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/activityLogUtils.d.ts +72 -0
- package/dist/declarations/src/core-modules/logs/activityLogUtils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/definitions/activityLog.d.ts +84 -0
- package/dist/declarations/src/core-modules/logs/definitions/activityLog.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/definitions/logs.d.ts +39 -0
- package/dist/declarations/src/core-modules/logs/definitions/logs.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/index.d.ts +6 -0
- package/dist/declarations/src/core-modules/logs/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/logs/types.d.ts +15 -0
- package/dist/declarations/src/core-modules/logs/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailAddresses.d.ts +73 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailAddresses.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailDeliveries.d.ts +115 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailDeliveries.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailRamp.d.ts +65 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailRamp.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailSenders.d.ts +58 -0
- package/dist/declarations/src/core-modules/notifications/definitions/emailSenders.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/definitions/notificationSettings.d.ts +66 -0
- package/dist/declarations/src/core-modules/notifications/definitions/notificationSettings.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/definitions/notifications.d.ts +89 -0
- package/dist/declarations/src/core-modules/notifications/definitions/notifications.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/index.d.ts +8 -0
- package/dist/declarations/src/core-modules/notifications/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/notifications/utils.d.ts +85 -0
- package/dist/declarations/src/core-modules/notifications/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/permissions/db/definitions/permissions.d.ts +60 -0
- package/dist/declarations/src/core-modules/permissions/db/definitions/permissions.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/permissions/index.d.ts +4 -0
- package/dist/declarations/src/core-modules/permissions/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/permissions/user-actions-map.d.ts +4 -0
- package/dist/declarations/src/core-modules/permissions/user-actions-map.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/permissions/utils.d.ts +22 -0
- package/dist/declarations/src/core-modules/permissions/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/filter.d.ts +5 -0
- package/dist/declarations/src/core-modules/properties/filter.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/importExport.d.ts +18 -0
- package/dist/declarations/src/core-modules/properties/importExport.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/index.d.ts +10 -0
- package/dist/declarations/src/core-modules/properties/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/keys.d.ts +46 -0
- package/dist/declarations/src/core-modules/properties/keys.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/mergeRows.d.ts +8 -0
- package/dist/declarations/src/core-modules/properties/mergeRows.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/operators.d.ts +6 -0
- package/dist/declarations/src/core-modules/properties/operators.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/options.d.ts +10 -0
- package/dist/declarations/src/core-modules/properties/options.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/setupPropertyProducers.d.ts +4 -0
- package/dist/declarations/src/core-modules/properties/setupPropertyProducers.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/types.d.ts +14 -0
- package/dist/declarations/src/core-modules/properties/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/properties/valueUsage.d.ts +56 -0
- package/dist/declarations/src/core-modules/properties/valueUsage.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/dependencies.d.ts +6 -0
- package/dist/declarations/src/core-modules/segments/dependencies.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/evaluate.d.ts +11 -0
- package/dist/declarations/src/core-modules/segments/evaluate.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/evaluateBatch.d.ts +42 -0
- package/dist/declarations/src/core-modules/segments/evaluateBatch.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/evaluateFieldsRouter.d.ts +29 -0
- package/dist/declarations/src/core-modules/segments/evaluateFieldsRouter.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/evaluateOwned.d.ts +27 -0
- package/dist/declarations/src/core-modules/segments/evaluateOwned.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/events.d.ts +45 -0
- package/dist/declarations/src/core-modules/segments/events.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/fieldBuilders.d.ts +35 -0
- package/dist/declarations/src/core-modules/segments/fieldBuilders.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/fieldMeta.d.ts +62 -0
- package/dist/declarations/src/core-modules/segments/fieldMeta.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/fieldRequests.d.ts +33 -0
- package/dist/declarations/src/core-modules/segments/fieldRequests.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/fingerprint.d.ts +6 -0
- package/dist/declarations/src/core-modules/segments/fingerprint.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/index.d.ts +31 -0
- package/dist/declarations/src/core-modules/segments/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/joinChanges.d.ts +11 -0
- package/dist/declarations/src/core-modules/segments/joinChanges.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/materialized.d.ts +9 -0
- package/dist/declarations/src/core-modules/segments/materialized.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/measureRelations.d.ts +18 -0
- package/dist/declarations/src/core-modules/segments/measureRelations.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/memberQuery.d.ts +13 -0
- package/dist/declarations/src/core-modules/segments/memberQuery.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/membership.d.ts +24 -0
- package/dist/declarations/src/core-modules/segments/membership.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/mongoFilter.d.ts +15 -0
- package/dist/declarations/src/core-modules/segments/mongoFilter.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/nodeRefs.d.ts +5 -0
- package/dist/declarations/src/core-modules/segments/nodeRefs.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/nodes.d.ts +42 -0
- package/dist/declarations/src/core-modules/segments/nodes.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/operators.d.ts +46 -0
- package/dist/declarations/src/core-modules/segments/operators.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/ownedSource.d.ts +7 -0
- package/dist/declarations/src/core-modules/segments/ownedSource.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/plan.d.ts +35 -0
- package/dist/declarations/src/core-modules/segments/plan.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/relationRegistry.d.ts +33 -0
- package/dist/declarations/src/core-modules/segments/relationRegistry.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/setupSegmentProducers.d.ts +4 -0
- package/dist/declarations/src/core-modules/segments/setupSegmentProducers.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/subjectsReachedBy.d.ts +11 -0
- package/dist/declarations/src/core-modules/segments/subjectsReachedBy.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/timeZone.d.ts +2 -0
- package/dist/declarations/src/core-modules/segments/timeZone.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/types.d.ts +67 -0
- package/dist/declarations/src/core-modules/segments/types.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/utils.d.ts +4 -0
- package/dist/declarations/src/core-modules/segments/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/walkNodes.d.ts +9 -0
- package/dist/declarations/src/core-modules/segments/walkNodes.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/zodSchemas.d.ts +532 -0
- package/dist/declarations/src/core-modules/segments/zodSchemas.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/segments/zonedTime.d.ts +25 -0
- package/dist/declarations/src/core-modules/segments/zonedTime.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/templates/index.d.ts +2 -0
- package/dist/declarations/src/core-modules/templates/index.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/templates/utils.d.ts +11 -0
- package/dist/declarations/src/core-modules/templates/utils.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/users/constants.d.ts +114 -0
- package/dist/declarations/src/core-modules/users/constants.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/users/db/definitions/users.d.ts +24 -0
- package/dist/declarations/src/core-modules/users/db/definitions/users.d.ts.map +1 -0
- package/dist/declarations/src/core-modules/users/index.d.ts +3 -0
- package/dist/declarations/src/core-modules/users/index.d.ts.map +1 -0
- package/dist/declarations/src/core-types/common.d.ts +149 -0
- package/dist/declarations/src/core-types/common.d.ts.map +1 -0
- package/dist/declarations/src/core-types/index.d.ts +20 -0
- package/dist/declarations/src/core-types/index.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/app/app.d.ts +12 -0
- package/dist/declarations/src/core-types/modules/app/app.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/automations/automations.d.ts +19 -0
- package/dist/declarations/src/core-types/modules/automations/automations.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/contacts/company.d.ts +53 -0
- package/dist/declarations/src/core-types/modules/contacts/company.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/contacts/contacts-common.d.ts +32 -0
- package/dist/declarations/src/core-types/modules/contacts/contacts-common.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/contacts/customer.d.ts +74 -0
- package/dist/declarations/src/core-types/modules/contacts/customer.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/emailTemplates/emailTemplate.d.ts +18 -0
- package/dist/declarations/src/core-types/modules/emailTemplates/emailTemplate.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/logs/logs.d.ts +28 -0
- package/dist/declarations/src/core-types/modules/logs/logs.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/permissions/permission.d.ts +56 -0
- package/dist/declarations/src/core-types/modules/permissions/permission.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/permissions/role.d.ts +21 -0
- package/dist/declarations/src/core-types/modules/permissions/role.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/products/product.d.ts +76 -0
- package/dist/declarations/src/core-types/modules/products/product.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/products/productCategory.d.ts +26 -0
- package/dist/declarations/src/core-types/modules/products/productCategory.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/products/productConfig.d.ts +9 -0
- package/dist/declarations/src/core-types/modules/products/productConfig.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/products/uom.d.ts +11 -0
- package/dist/declarations/src/core-types/modules/products/uom.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/relations/relations.d.ts +13 -0
- package/dist/declarations/src/core-types/modules/relations/relations.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/saas/organization.d.ts +8 -0
- package/dist/declarations/src/core-types/modules/saas/organization.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/tags/tag.d.ts +16 -0
- package/dist/declarations/src/core-types/modules/tags/tag.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/team-member/structure.d.ts +19 -0
- package/dist/declarations/src/core-types/modules/team-member/structure.d.ts.map +1 -0
- package/dist/declarations/src/core-types/modules/team-member/user.d.ts +90 -0
- package/dist/declarations/src/core-types/modules/team-member/user.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/agent-tools/auth.d.ts +18 -0
- package/dist/declarations/src/utils/agent-tools/auth.d.ts.map +1 -0
- package/dist/declarations/src/utils/agent-tools/endpoints.d.ts +16 -0
- package/dist/declarations/src/utils/agent-tools/endpoints.d.ts.map +1 -0
- package/dist/declarations/src/utils/agent-tools/index.d.ts +6 -0
- package/dist/declarations/src/utils/agent-tools/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/agent-tools/manifest.d.ts +11 -0
- package/dist/declarations/src/utils/agent-tools/manifest.d.ts.map +1 -0
- package/dist/declarations/src/utils/agent-tools/responseLimit.d.ts +26 -0
- package/dist/declarations/src/utils/agent-tools/responseLimit.d.ts.map +1 -0
- package/dist/declarations/src/utils/agent-tools/types.d.ts +48 -0
- package/dist/declarations/src/utils/agent-tools/types.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/beforeResolvers.d.ts +41 -0
- package/dist/declarations/src/utils/apollo/beforeResolvers.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/commonTypeDefs.d.ts +7 -0
- package/dist/declarations/src/utils/apollo/commonTypeDefs.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/constants.d.ts +3 -0
- package/dist/declarations/src/utils/apollo/constants.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/customScalars.d.ts +6 -0
- package/dist/declarations/src/utils/apollo/customScalars.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/expectedErrorPlugin.d.ts +11 -0
- package/dist/declarations/src/utils/apollo/expectedErrorPlugin.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/index.d.ts +10 -0
- package/dist/declarations/src/utils/apollo/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/runBeforeResolvers.d.ts +27 -0
- package/dist/declarations/src/utils/apollo/runBeforeResolvers.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/utils.d.ts +5 -0
- package/dist/declarations/src/utils/apollo/utils.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/wrapperMutations.d.ts +8 -0
- package/dist/declarations/src/utils/apollo/wrapperMutations.d.ts.map +1 -0
- package/dist/declarations/src/utils/apollo/wrapperResolvers.d.ts +8 -0
- package/dist/declarations/src/utils/apollo/wrapperResolvers.d.ts.map +1 -0
- package/dist/declarations/src/utils/bulkUtils.d.ts +7 -0
- package/dist/declarations/src/utils/bulkUtils.d.ts.map +1 -0
- package/dist/declarations/src/utils/constants.d.ts +40 -0
- package/dist/declarations/src/utils/constants.d.ts.map +1 -0
- package/dist/declarations/src/utils/editor.d.ts +45 -0
- package/dist/declarations/src/utils/editor.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/address.d.ts +10 -0
- package/dist/declarations/src/utils/email/address.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/attachments.d.ts +12 -0
- package/dist/declarations/src/utils/email/attachments.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/config.d.ts +10 -0
- package/dist/declarations/src/utils/email/config.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/constants.d.ts +6 -0
- package/dist/declarations/src/utils/email/constants.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/index.d.ts +12 -0
- package/dist/declarations/src/utils/email/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/providers/sendgrid.d.ts +17 -0
- package/dist/declarations/src/utils/email/providers/sendgrid.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/providers/sendgridEvents.d.ts +18 -0
- package/dist/declarations/src/utils/email/providers/sendgridEvents.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/providers/ses.d.ts +19 -0
- package/dist/declarations/src/utils/email/providers/ses.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/providers/smtp.d.ts +14 -0
- package/dist/declarations/src/utils/email/providers/smtp.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/resolveProvider.d.ts +6 -0
- package/dist/declarations/src/utils/email/resolveProvider.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/service.d.ts +50 -0
- package/dist/declarations/src/utils/email/service.d.ts.map +1 -0
- package/dist/declarations/src/utils/email/types.d.ts +87 -0
- package/dist/declarations/src/utils/email/types.d.ts.map +1 -0
- package/dist/declarations/src/utils/errorClassifier.d.ts +56 -0
- package/dist/declarations/src/utils/errorClassifier.d.ts.map +1 -0
- package/dist/declarations/src/utils/file/read.d.ts +14 -0
- package/dist/declarations/src/utils/file/read.d.ts.map +1 -0
- package/dist/declarations/src/utils/file/upload.d.ts +10 -0
- package/dist/declarations/src/utils/file/upload.d.ts.map +1 -0
- package/dist/declarations/src/utils/graphqlPubSub.d.ts +3 -0
- package/dist/declarations/src/utils/graphqlPubSub.d.ts.map +1 -0
- package/dist/declarations/src/utils/headers/get-hostname.d.ts +5 -0
- package/dist/declarations/src/utils/headers/get-hostname.d.ts.map +1 -0
- package/dist/declarations/src/utils/headers/index.d.ts +5 -0
- package/dist/declarations/src/utils/headers/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/headers/sanitize.d.ts +3 -0
- package/dist/declarations/src/utils/headers/sanitize.d.ts.map +1 -0
- package/dist/declarations/src/utils/headers/subdomain.d.ts +4 -0
- package/dist/declarations/src/utils/headers/subdomain.d.ts.map +1 -0
- package/dist/declarations/src/utils/headers/user.d.ts +14 -0
- package/dist/declarations/src/utils/headers/user.d.ts.map +1 -0
- package/dist/declarations/src/utils/index.d.ts +28 -0
- package/dist/declarations/src/utils/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/knowledge.d.ts +50 -0
- package/dist/declarations/src/utils/knowledge.d.ts.map +1 -0
- package/dist/declarations/src/utils/logs/index.d.ts +103 -0
- package/dist/declarations/src/utils/logs/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/cursor-util.d.ts +41 -0
- package/dist/declarations/src/utils/mongo/cursor-util.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/generate-models.d.ts +4 -0
- package/dist/declarations/src/utils/mongo/generate-models.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/index.d.ts +6 -0
- package/dist/declarations/src/utils/mongo/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/mongo-connection.d.ts +5 -0
- package/dist/declarations/src/utils/mongo/mongo-connection.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/mongoose-types.d.ts +22 -0
- package/dist/declarations/src/utils/mongo/mongoose-types.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/mongoose-utils.d.ts +30 -0
- package/dist/declarations/src/utils/mongo/mongoose-utils.d.ts.map +1 -0
- package/dist/declarations/src/utils/mongo/search-tokens.d.ts +21 -0
- package/dist/declarations/src/utils/mongo/search-tokens.d.ts.map +1 -0
- package/dist/declarations/src/utils/mq-worker.d.ts +19 -0
- package/dist/declarations/src/utils/mq-worker.d.ts.map +1 -0
- package/dist/declarations/src/utils/random.d.ts +3 -0
- package/dist/declarations/src/utils/random.d.ts.map +1 -0
- package/dist/declarations/src/utils/redis.d.ts +4 -0
- package/dist/declarations/src/utils/redis.d.ts.map +1 -0
- package/dist/declarations/src/utils/saas/index.d.ts +3 -0
- package/dist/declarations/src/utils/saas/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/saas/saas-mongo-connection.d.ts +59 -0
- package/dist/declarations/src/utils/saas/saas-mongo-connection.d.ts.map +1 -0
- package/dist/declarations/src/utils/saas/types.d.ts +96 -0
- package/dist/declarations/src/utils/saas/types.d.ts.map +1 -0
- package/dist/declarations/src/utils/sanitize.d.ts +3 -0
- package/dist/declarations/src/utils/sanitize.d.ts.map +1 -0
- package/dist/declarations/src/utils/sentry-init.d.ts +15 -0
- package/dist/declarations/src/utils/sentry-init.d.ts.map +1 -0
- package/dist/declarations/src/utils/sentry-instrument.d.ts +2 -0
- package/dist/declarations/src/utils/sentry-instrument.d.ts.map +1 -0
- package/dist/declarations/src/utils/serializablePayload.d.ts +11 -0
- package/dist/declarations/src/utils/serializablePayload.d.ts.map +1 -0
- package/dist/declarations/src/utils/service-discovery.d.ts +25 -0
- package/dist/declarations/src/utils/service-discovery.d.ts.map +1 -0
- package/dist/declarations/src/utils/start-plugin.d.ts +85 -0
- package/dist/declarations/src/utils/start-plugin.d.ts.map +1 -0
- package/dist/declarations/src/utils/string.d.ts +82 -0
- package/dist/declarations/src/utils/string.d.ts.map +1 -0
- package/dist/declarations/src/utils/trpc/index.d.ts +79 -0
- package/dist/declarations/src/utils/trpc/index.d.ts.map +1 -0
- package/dist/declarations/src/utils/trpc/sendCoreModuleProducer.d.ts +53 -0
- package/dist/declarations/src/utils/trpc/sendCoreModuleProducer.d.ts.map +1 -0
- package/dist/declarations/src/utils/utils.d.ts +69 -0
- package/dist/declarations/src/utils/utils.d.ts.map +1 -0
- package/dist/erxes-api-shared.cjs.d.ts +3 -0
- package/dist/erxes-api-shared.cjs.dev.js +7 -0
- package/dist/erxes-api-shared.cjs.js +7 -0
- package/dist/erxes-api-shared.cjs.prod.js +7 -0
- package/dist/erxes-api-shared.esm.js +3 -0
- package/dist/start-plugin-576e707d.cjs.prod.js +23223 -0
- package/dist/start-plugin-6e76556c.esm.js +22742 -0
- package/dist/start-plugin-89fa2bd2.cjs.dev.js +23225 -0
- package/package.json +105 -4
- package/src/common-modules/payment/worker.ts +53 -0
- package/src/core-modules/approval/approvalChangeTypes.ts +31 -0
- package/src/core-modules/approval/checkApprovalLock.ts +85 -0
- package/src/core-modules/approval/constants.ts +45 -0
- package/src/core-modules/approval/index.ts +6 -0
- package/src/core-modules/approval/initApproval.ts +59 -0
- package/src/core-modules/approval/types.ts +206 -0
- package/src/core-modules/approval/zodSchemas.ts +55 -0
- package/src/core-modules/apps/@types/app.ts +15 -0
- package/src/core-modules/apps/db/definitions/apps.ts +30 -0
- package/src/core-modules/apps/index.ts +2 -0
- package/src/core-modules/automations/actionErrorPolicy.test.ts +125 -0
- package/src/core-modules/automations/actionErrorPolicy.ts +162 -0
- package/src/core-modules/automations/actionInputs.test.ts +70 -0
- package/src/core-modules/automations/actionOutcome.test.ts +87 -0
- package/src/core-modules/automations/actionOutcome.ts +128 -0
- package/src/core-modules/automations/constants.ts +181 -0
- package/src/core-modules/automations/definitions/aiAgents.ts +343 -0
- package/src/core-modules/automations/definitions/automations.ts +207 -0
- package/src/core-modules/automations/definitions/executions.ts +190 -0
- package/src/core-modules/automations/definitions/index.ts +3 -0
- package/src/core-modules/automations/getValueByPath.test.ts +49 -0
- package/src/core-modules/automations/index.ts +13 -0
- package/src/core-modules/automations/outputResolvers.test.ts +97 -0
- package/src/core-modules/automations/outputResolvers.ts +1238 -0
- package/src/core-modules/automations/reEnrollment.ts +34 -0
- package/src/core-modules/automations/segmentMembership.ts +34 -0
- package/src/core-modules/automations/sendAutomationMessage.ts +219 -0
- package/src/core-modules/automations/setPropertyOutcome.test.ts +105 -0
- package/src/core-modules/automations/setPropertyRows.test.ts +61 -0
- package/src/core-modules/automations/setupAutomationProducers.ts +187 -0
- package/src/core-modules/automations/typeUtils.ts +3 -0
- package/src/core-modules/automations/types.ts +577 -0
- package/src/core-modules/automations/utils.ts +1128 -0
- package/src/core-modules/automations/workflowValidation.ts +32 -0
- package/src/core-modules/automations/zodTypes.ts +221 -0
- package/src/core-modules/client-portals/definitions/clientPortal.ts +230 -0
- package/src/core-modules/client-portals/definitions/comment.ts +26 -0
- package/src/core-modules/client-portals/definitions/cpNotification.ts +112 -0
- package/src/core-modules/client-portals/definitions/cpUser.ts +236 -0
- package/src/core-modules/client-portals/index.ts +4 -0
- package/src/core-modules/common/db/definitions/common.ts +43 -0
- package/src/core-modules/common/eventHandlers/createEventHandlers.ts +236 -0
- package/src/core-modules/common/eventHandlers/generateEventHandlers.ts +37 -0
- package/src/core-modules/common/eventHandlers/index.ts +11 -0
- package/src/core-modules/common/eventHandlers/runtimeContext.ts +36 -0
- package/src/core-modules/common/eventHandlers/schemas.ts +53 -0
- package/src/core-modules/common/eventHandlers/types.ts +97 -0
- package/src/core-modules/common/eventHandlers/utils.ts +113 -0
- package/src/core-modules/common/index.ts +4 -0
- package/src/core-modules/common/references/fetchRecordReferenceTargets.ts +43 -0
- package/src/core-modules/common/references/getRecordReferenceFields.ts +243 -0
- package/src/core-modules/common/references/index.ts +9 -0
- package/src/core-modules/common/references/initRecordReferences.ts +84 -0
- package/src/core-modules/common/references/normalizeRecordReferenceConfig.ts +59 -0
- package/src/core-modules/common/references/resolveRecordReferencePath.ts +473 -0
- package/src/core-modules/common/references/resolveRecordReferencePlaceholders.ts +173 -0
- package/src/core-modules/common/references/resolveRecordReferenceValue.ts +41 -0
- package/src/core-modules/common/references/resolveRecordRelationIds.ts +57 -0
- package/src/core-modules/common/references/types.ts +78 -0
- package/src/core-modules/common/references/utils.ts +60 -0
- package/src/core-modules/common/references/zodInputs.ts +13 -0
- package/src/core-modules/common/routeToModuleProducer.ts +118 -0
- package/src/core-modules/email-content/blocksToHtml.ts +551 -0
- package/src/core-modules/email-content/constants.ts +4 -0
- package/src/core-modules/email-content/emailFooter.ts +17 -0
- package/src/core-modules/email-content/expandRepeatRows.test.ts +36 -0
- package/src/core-modules/email-content/expandRepeatRows.ts +59 -0
- package/src/core-modules/email-content/index.ts +8 -0
- package/src/core-modules/email-content/renderEmailContent.ts +88 -0
- package/src/core-modules/email-content/replacePlaceholders.ts +143 -0
- package/src/core-modules/email-content/types.ts +49 -0
- package/src/core-modules/email-content/unresolvedPlaceholders.ts +27 -0
- package/src/core-modules/forms/index.ts +2 -0
- package/src/core-modules/forms/types.ts +86 -0
- package/src/core-modules/forms/utils.ts +34 -0
- package/src/core-modules/import-export/index.ts +7 -0
- package/src/core-modules/import-export/types.ts +204 -0
- package/src/core-modules/import-export/utils/createCoreImportClient.ts +131 -0
- package/src/core-modules/import-export/utils/exportBatchProcess.ts +560 -0
- package/src/core-modules/import-export/utils/exportCursor.ts +47 -0
- package/src/core-modules/import-export/utils/headerMatcher.test.ts +90 -0
- package/src/core-modules/import-export/utils/headerMatcher.ts +229 -0
- package/src/core-modules/import-export/utils/importBatchProcess.ts +780 -0
- package/src/core-modules/import-export/utils/importExportError.ts +71 -0
- package/src/core-modules/import-export/utils/importExportRuntime.ts +96 -0
- package/src/core-modules/import-export/utils/importUtils.ts +59 -0
- package/src/core-modules/import-export/utils/progressUpdate.ts +25 -0
- package/src/core-modules/import-export/utils/tempWorkspace.ts +34 -0
- package/src/core-modules/import-export/worker.ts +215 -0
- package/src/core-modules/import-export/zodSchemas.ts +63 -0
- package/src/core-modules/index.ts +15 -0
- package/src/core-modules/logs/activityLog/builder.ts +232 -0
- package/src/core-modules/logs/activityLog/index.ts +4 -0
- package/src/core-modules/logs/activityLog/sharedBuilders.ts +95 -0
- package/src/core-modules/logs/activityLog/types.ts +26 -0
- package/src/core-modules/logs/activityLog/utils.ts +61 -0
- package/src/core-modules/logs/activityLogUtils.ts +677 -0
- package/src/core-modules/logs/definitions/activityLog.ts +71 -0
- package/src/core-modules/logs/definitions/logs.ts +49 -0
- package/src/core-modules/logs/index.ts +5 -0
- package/src/core-modules/logs/types.ts +16 -0
- package/src/core-modules/notifications/definitions/emailAddresses.ts +105 -0
- package/src/core-modules/notifications/definitions/emailDeliveries.ts +188 -0
- package/src/core-modules/notifications/definitions/emailRamp.ts +83 -0
- package/src/core-modules/notifications/definitions/emailSenders.ts +84 -0
- package/src/core-modules/notifications/definitions/notificationConfigs.ts +110 -0
- package/src/core-modules/notifications/definitions/notificationSettings.ts +67 -0
- package/src/core-modules/notifications/definitions/notifications.ts +130 -0
- package/src/core-modules/notifications/emailUtils.ts +88 -0
- package/src/core-modules/notifications/index.ts +7 -0
- package/src/core-modules/notifications/utils.ts +143 -0
- package/src/core-modules/permissions/db/definitions/permissions.ts +82 -0
- package/src/core-modules/permissions/index.ts +3 -0
- package/src/core-modules/permissions/oauth-scopes.test.ts +102 -0
- package/src/core-modules/permissions/user-actions-map.ts +170 -0
- package/src/core-modules/permissions/utils.ts +317 -0
- package/src/core-modules/properties/README.md +161 -0
- package/src/core-modules/properties/filter.test.ts +74 -0
- package/src/core-modules/properties/filter.ts +156 -0
- package/src/core-modules/properties/importExport.ts +159 -0
- package/src/core-modules/properties/index.ts +9 -0
- package/src/core-modules/properties/keys.test.ts +71 -0
- package/src/core-modules/properties/keys.ts +128 -0
- package/src/core-modules/properties/mergePropertyData.test.ts +65 -0
- package/src/core-modules/properties/mergeRows.ts +93 -0
- package/src/core-modules/properties/operators.ts +91 -0
- package/src/core-modules/properties/options.test.ts +119 -0
- package/src/core-modules/properties/options.ts +55 -0
- package/src/core-modules/properties/setupPropertyProducers.ts +32 -0
- package/src/core-modules/properties/types.ts +31 -0
- package/src/core-modules/properties/valueUsage.test.ts +158 -0
- package/src/core-modules/properties/valueUsage.ts +153 -0
- package/src/core-modules/segments/anniversary.test.ts +122 -0
- package/src/core-modules/segments/dependencies.test.ts +173 -0
- package/src/core-modules/segments/dependencies.ts +70 -0
- package/src/core-modules/segments/evaluate.test.ts +339 -0
- package/src/core-modules/segments/evaluate.ts +388 -0
- package/src/core-modules/segments/evaluateBatch.test.ts +233 -0
- package/src/core-modules/segments/evaluateBatch.ts +263 -0
- package/src/core-modules/segments/evaluateFieldsRouter.test.ts +148 -0
- package/src/core-modules/segments/evaluateFieldsRouter.ts +94 -0
- package/src/core-modules/segments/evaluateOwned.ts +162 -0
- package/src/core-modules/segments/events.ts +142 -0
- package/src/core-modules/segments/fieldBuilders.ts +152 -0
- package/src/core-modules/segments/fieldMeta.ts +96 -0
- package/src/core-modules/segments/fieldRequests.test.ts +302 -0
- package/src/core-modules/segments/fieldRequests.ts +172 -0
- package/src/core-modules/segments/fieldSources.test.ts +99 -0
- package/src/core-modules/segments/fingerprint.test.ts +111 -0
- package/src/core-modules/segments/fingerprint.ts +70 -0
- package/src/core-modules/segments/index.ts +30 -0
- package/src/core-modules/segments/joinChanges.test.ts +96 -0
- package/src/core-modules/segments/joinChanges.ts +67 -0
- package/src/core-modules/segments/materialized.ts +23 -0
- package/src/core-modules/segments/measureRelations.test.ts +222 -0
- package/src/core-modules/segments/measureRelations.ts +322 -0
- package/src/core-modules/segments/memberQuery.test.ts +60 -0
- package/src/core-modules/segments/memberQuery.ts +45 -0
- package/src/core-modules/segments/membership.ts +170 -0
- package/src/core-modules/segments/mongoFilter.test.ts +326 -0
- package/src/core-modules/segments/mongoFilter.ts +355 -0
- package/src/core-modules/segments/nodeRefs.ts +29 -0
- package/src/core-modules/segments/nodes.ts +48 -0
- package/src/core-modules/segments/operators.ts +243 -0
- package/src/core-modules/segments/ownedSource.ts +16 -0
- package/src/core-modules/segments/plan.test.ts +172 -0
- package/src/core-modules/segments/plan.ts +155 -0
- package/src/core-modules/segments/relationRegistry.test.ts +64 -0
- package/src/core-modules/segments/relationRegistry.ts +198 -0
- package/src/core-modules/segments/segmentReference.test.ts +142 -0
- package/src/core-modules/segments/setupSegmentProducers.ts +77 -0
- package/src/core-modules/segments/subjectsReachedBy.ts +70 -0
- package/src/core-modules/segments/timeZone.ts +56 -0
- package/src/core-modules/segments/types.ts +97 -0
- package/src/core-modules/segments/utils.ts +122 -0
- package/src/core-modules/segments/walkNodes.ts +76 -0
- package/src/core-modules/segments/zodSchemas.ts +130 -0
- package/src/core-modules/segments/zonedTime.test.ts +163 -0
- package/src/core-modules/segments/zonedTime.ts +198 -0
- package/src/core-modules/templates/index.ts +1 -0
- package/src/core-modules/templates/utils.ts +91 -0
- package/src/core-modules/users/constants.ts +318 -0
- package/src/core-modules/users/db/definitions/users.ts +226 -0
- package/src/core-modules/users/index.ts +2 -0
- package/src/core-types/common.ts +183 -0
- package/src/core-types/index.ts +19 -0
- package/src/core-types/modules/app/app.ts +13 -0
- package/src/core-types/modules/automations/automations.ts +23 -0
- package/src/core-types/modules/contacts/company.ts +70 -0
- package/src/core-types/modules/contacts/contacts-common.ts +32 -0
- package/src/core-types/modules/contacts/customer.ts +94 -0
- package/src/core-types/modules/emailTemplates/emailTemplate.ts +19 -0
- package/src/core-types/modules/emailTemplates/index.ts +1 -0
- package/src/core-types/modules/logs/logs.ts +30 -0
- package/src/core-types/modules/permissions/permission.ts +63 -0
- package/src/core-types/modules/permissions/role.ts +24 -0
- package/src/core-types/modules/products/product.ts +100 -0
- package/src/core-types/modules/products/productCategory.ts +27 -0
- package/src/core-types/modules/products/productConfig.ts +10 -0
- package/src/core-types/modules/products/uom.ts +12 -0
- package/src/core-types/modules/relations/relations.ts +14 -0
- package/src/core-types/modules/saas/organization.ts +7 -0
- package/src/core-types/modules/structure/structure.ts +29 -0
- package/src/core-types/modules/tags/tag.ts +17 -0
- package/src/core-types/modules/team-member/structure.ts +23 -0
- package/src/core-types/modules/team-member/user.ts +93 -0
- package/src/index.ts +1 -0
- package/src/utils/agent-tools/auth.ts +129 -0
- package/src/utils/agent-tools/endpoints.ts +274 -0
- package/src/utils/agent-tools/index.ts +5 -0
- package/src/utils/agent-tools/manifest.ts +152 -0
- package/src/utils/agent-tools/responseLimit.test.ts +99 -0
- package/src/utils/agent-tools/responseLimit.ts +66 -0
- package/src/utils/agent-tools/types.ts +52 -0
- package/src/utils/apollo/beforeResolvers.ts +117 -0
- package/src/utils/apollo/commonTypeDefs.ts +78 -0
- package/src/utils/apollo/constants.ts +16 -0
- package/src/utils/apollo/customScalars.ts +69 -0
- package/src/utils/apollo/expectedErrorPlugin.ts +83 -0
- package/src/utils/apollo/index.ts +10 -0
- package/src/utils/apollo/runBeforeResolvers.ts +214 -0
- package/src/utils/apollo/utils.ts +80 -0
- package/src/utils/apollo/wrapperMutations.ts +75 -0
- package/src/utils/apollo/wrapperResolvers.ts +182 -0
- package/src/utils/bulkUtils.ts +62 -0
- package/src/utils/constants.ts +99 -0
- package/src/utils/editor.ts +412 -0
- package/src/utils/email/address.ts +42 -0
- package/src/utils/email/attachments.ts +74 -0
- package/src/utils/email/config.ts +46 -0
- package/src/utils/email/constants.ts +25 -0
- package/src/utils/email/index.ts +11 -0
- package/src/utils/email/providers/sendgrid.ts +280 -0
- package/src/utils/email/providers/sendgridEvents.ts +48 -0
- package/src/utils/email/providers/ses.ts +250 -0
- package/src/utils/email/providers/smtp.ts +99 -0
- package/src/utils/email/resolveProvider.ts +75 -0
- package/src/utils/email/service.ts +192 -0
- package/src/utils/email/types.ts +127 -0
- package/src/utils/errorClassifier.test.ts +231 -0
- package/src/utils/errorClassifier.ts +458 -0
- package/src/utils/file/read.ts +464 -0
- package/src/utils/file/upload.ts +531 -0
- package/src/utils/graphqlPubSub.ts +28 -0
- package/src/utils/headers/get-hostname.ts +18 -0
- package/src/utils/headers/index.ts +4 -0
- package/src/utils/headers/sanitize.ts +9 -0
- package/src/utils/headers/subdomain.ts +13 -0
- package/src/utils/headers/user.test.ts +76 -0
- package/src/utils/headers/user.ts +113 -0
- package/src/utils/index.ts +27 -0
- package/src/utils/knowledge.ts +107 -0
- package/src/utils/logs/index.ts +247 -0
- package/src/utils/mongo/cursor-util.ts +153 -0
- package/src/utils/mongo/generate-models.ts +97 -0
- package/src/utils/mongo/index.ts +5 -0
- package/src/utils/mongo/mongo-connection.ts +42 -0
- package/src/utils/mongo/mongoose-types.ts +26 -0
- package/src/utils/mongo/mongoose-utils.ts +329 -0
- package/src/utils/mongo/search-tokens.ts +193 -0
- package/src/utils/mq-worker.ts +150 -0
- package/src/utils/random.ts +6 -0
- package/src/utils/redis.ts +23 -0
- package/src/utils/saas/constants.ts +32 -0
- package/src/utils/saas/definition.ts +318 -0
- package/src/utils/saas/index.ts +2 -0
- package/src/utils/saas/saas-mongo-connection.ts +595 -0
- package/src/utils/saas/types.ts +107 -0
- package/src/utils/sanitize.ts +73 -0
- package/src/utils/sentry-init.ts +128 -0
- package/src/utils/sentry-instrument.ts +5 -0
- package/src/utils/serializablePayload.test.ts +65 -0
- package/src/utils/serializablePayload.ts +44 -0
- package/src/utils/service-discovery.ts +256 -0
- package/src/utils/start-plugin.ts +482 -0
- package/src/utils/string.ts +159 -0
- package/src/utils/trpc/index.ts +278 -0
- package/src/utils/trpc/sendCoreModuleProducer.ts +146 -0
- package/src/utils/trpc/trpc-setup.ts +91 -0
- package/src/utils/utils.ts +669 -0
- package/utils/dist/erxes-api-shared-utils.cjs.d.ts +2 -0
- package/utils/dist/erxes-api-shared-utils.cjs.dev.js +3066 -0
- package/utils/dist/erxes-api-shared-utils.cjs.js +7 -0
- package/utils/dist/erxes-api-shared-utils.cjs.prod.js +3066 -0
- package/utils/dist/erxes-api-shared-utils.esm.js +2776 -0
- package/utils/package.json +5 -0
- package/README.md +0 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createScopedEventHandlers } from '../../core-modules/common/eventHandlers/generateEventHandlers';
|
|
2
|
+
import mongoose, { Connection } from 'mongoose';
|
|
3
|
+
import {
|
|
4
|
+
coreModelOrganizations,
|
|
5
|
+
getSaasCoreConnection,
|
|
6
|
+
} from '../saas/saas-mongo-connection';
|
|
7
|
+
import { getEnv, getSubdomain } from '../utils';
|
|
8
|
+
import { connect } from './mongo-connection';
|
|
9
|
+
import type { ScopedEventHandlers } from '../../core-modules/common/eventHandlers/types';
|
|
10
|
+
|
|
11
|
+
const returnGeneratedModels = async <IModels>(
|
|
12
|
+
connection: Connection,
|
|
13
|
+
loadClasses: (
|
|
14
|
+
db: mongoose.Connection,
|
|
15
|
+
subdomain: string,
|
|
16
|
+
eventHandlers: ScopedEventHandlers,
|
|
17
|
+
) => IModels | Promise<IModels>,
|
|
18
|
+
subdomain: string,
|
|
19
|
+
context?: Record<string, any>,
|
|
20
|
+
) => {
|
|
21
|
+
const eventHandlers = createScopedEventHandlers(subdomain, context);
|
|
22
|
+
return await loadClasses(connection, subdomain, eventHandlers);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const createGenerateModels = <IModels>(
|
|
26
|
+
loadClasses: (
|
|
27
|
+
db: mongoose.Connection,
|
|
28
|
+
subdomain: string,
|
|
29
|
+
eventHandlers: ScopedEventHandlers,
|
|
30
|
+
) => IModels | Promise<IModels>,
|
|
31
|
+
): ((
|
|
32
|
+
hostnameOrSubdomain: string,
|
|
33
|
+
context?: Record<string, any>,
|
|
34
|
+
) => Promise<IModels>) => {
|
|
35
|
+
const VERSION = getEnv({ name: 'VERSION', defaultValue: 'os' });
|
|
36
|
+
|
|
37
|
+
connect();
|
|
38
|
+
|
|
39
|
+
if (VERSION && VERSION !== 'saas') {
|
|
40
|
+
return async function genereteModels(
|
|
41
|
+
hostnameOrSubdomain: string,
|
|
42
|
+
context?: Record<string, any>,
|
|
43
|
+
): Promise<IModels> {
|
|
44
|
+
return await returnGeneratedModels(
|
|
45
|
+
mongoose.connection,
|
|
46
|
+
loadClasses,
|
|
47
|
+
hostnameOrSubdomain,
|
|
48
|
+
context,
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
return async function genereteModels(
|
|
53
|
+
hostnameOrSubdomain = '',
|
|
54
|
+
context?: Record<string, any>,
|
|
55
|
+
): Promise<IModels> {
|
|
56
|
+
let subdomain: string = hostnameOrSubdomain;
|
|
57
|
+
|
|
58
|
+
if (!subdomain) {
|
|
59
|
+
throw new Error(`Subdomain is \`${subdomain}\``);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// means hostname
|
|
63
|
+
if (subdomain?.includes('.')) {
|
|
64
|
+
subdomain = getSubdomain(hostnameOrSubdomain);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
await getSaasCoreConnection();
|
|
68
|
+
|
|
69
|
+
const organization = await coreModelOrganizations.findOne({ subdomain });
|
|
70
|
+
|
|
71
|
+
if (!organization) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Organization with subdomain = ${subdomain} is not found`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const DB_NAME = getEnv({ name: 'DB_NAME' });
|
|
78
|
+
const GE_MONGO_URL = (DB_NAME || 'erxes_<organizationId>').replace(
|
|
79
|
+
'<organizationId>',
|
|
80
|
+
organization._id,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const tenantCon = mongoose.connection.useDb(GE_MONGO_URL, {
|
|
84
|
+
// so that conn.model method can use cached connection
|
|
85
|
+
useCache: true,
|
|
86
|
+
noListener: true,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return await returnGeneratedModels(
|
|
90
|
+
tenantCon,
|
|
91
|
+
loadClasses,
|
|
92
|
+
subdomain,
|
|
93
|
+
context,
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const { MONGO_URL = 'mongodb://127.0.0.1:27017/erxes?directConnection=true' } =
|
|
4
|
+
process.env;
|
|
5
|
+
|
|
6
|
+
export const mongooseConnectionOptions: mongoose.ConnectOptions = {
|
|
7
|
+
family: 4,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
mongoose.connection
|
|
11
|
+
.on('connected', () => {
|
|
12
|
+
console.log(`Connected to the database: ${MONGO_URL}`);
|
|
13
|
+
})
|
|
14
|
+
.on('disconnected', (...props) => {
|
|
15
|
+
console.log(`Disconnected from the database: ${MONGO_URL}`);
|
|
16
|
+
|
|
17
|
+
process.exit(1);
|
|
18
|
+
})
|
|
19
|
+
.on('error', (error) => {
|
|
20
|
+
console.error(`Database connection error: ${MONGO_URL} ${error}`);
|
|
21
|
+
|
|
22
|
+
process.exit(1);
|
|
23
|
+
})
|
|
24
|
+
.on('close', () => {});
|
|
25
|
+
|
|
26
|
+
export async function connect(): Promise<mongoose.Connection> {
|
|
27
|
+
if (!MONGO_URL) {
|
|
28
|
+
throw new Error('MONGO_URL is not defined');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await mongoose.connect(MONGO_URL, mongooseConnectionOptions);
|
|
32
|
+
return mongoose.connection;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function closeMongooose() {
|
|
36
|
+
try {
|
|
37
|
+
await mongoose.connection.close();
|
|
38
|
+
console.log('Mongoose connection disconnected ');
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
|
+
|
|
3
|
+
export const mongooseStringRandomId = {
|
|
4
|
+
type: String,
|
|
5
|
+
default: () => nanoid(),
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Allows `null | undefined`.
|
|
10
|
+
* But if it's a `string`, it must contain atleast one non whitespace character.
|
|
11
|
+
*/
|
|
12
|
+
export const mongooseStringNonBlank = {
|
|
13
|
+
type: String,
|
|
14
|
+
validate: /\S+?/,
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export const mongoStringRequired = {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
export const mongooseStringRequiredNonBlank = {
|
|
23
|
+
type: String,
|
|
24
|
+
validate: /\S+?/,
|
|
25
|
+
required: true,
|
|
26
|
+
} as const;
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import mongoose, {
|
|
2
|
+
Document,
|
|
3
|
+
FilterQuery,
|
|
4
|
+
PipelineStage,
|
|
5
|
+
Schema,
|
|
6
|
+
} from 'mongoose';
|
|
7
|
+
import { nanoid } from 'nanoid';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
buildCursorQuery,
|
|
11
|
+
CursorPaginateAggregationParams,
|
|
12
|
+
CursorPaginateParams,
|
|
13
|
+
CursorResult,
|
|
14
|
+
encodeCursor,
|
|
15
|
+
PageInfo,
|
|
16
|
+
} from './cursor-util';
|
|
17
|
+
import { mongooseStringRandomId } from './mongoose-types';
|
|
18
|
+
import {
|
|
19
|
+
configureSchemaSearchTokens,
|
|
20
|
+
ISchemaWrapperOptions,
|
|
21
|
+
} from './search-tokens';
|
|
22
|
+
|
|
23
|
+
export interface IOrderInput {
|
|
24
|
+
_id: string;
|
|
25
|
+
order: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const mongooseField = (options: any) => {
|
|
29
|
+
const { pkey, type, optional } = options;
|
|
30
|
+
|
|
31
|
+
if (type === String && !pkey && !optional) {
|
|
32
|
+
options.validate = /\S+/;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (pkey) {
|
|
36
|
+
options.type = String;
|
|
37
|
+
options.default = () => nanoid();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return options;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const updateMongoDocumentOrder = async (
|
|
44
|
+
collection: any,
|
|
45
|
+
orders: IOrderInput[],
|
|
46
|
+
) => {
|
|
47
|
+
if (orders.length === 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ids: string[] = [];
|
|
52
|
+
const bulkOps: Array<{
|
|
53
|
+
updateOne: {
|
|
54
|
+
query: { _id: string };
|
|
55
|
+
update: { order: number };
|
|
56
|
+
};
|
|
57
|
+
}> = [];
|
|
58
|
+
|
|
59
|
+
for (const { _id, order } of orders) {
|
|
60
|
+
ids.push(_id);
|
|
61
|
+
|
|
62
|
+
const selector: { order: number } = { order };
|
|
63
|
+
|
|
64
|
+
bulkOps.push({
|
|
65
|
+
updateOne: {
|
|
66
|
+
query: { _id },
|
|
67
|
+
update: selector,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await collection.bulkWrite(bulkOps);
|
|
73
|
+
|
|
74
|
+
return collection.find({ _id: { $in: ids } }).sort({ order: 1 });
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const defaultPaginate = (
|
|
78
|
+
collection: mongoose.Query<any, any>,
|
|
79
|
+
params: {
|
|
80
|
+
ids?: string[];
|
|
81
|
+
page?: number;
|
|
82
|
+
perPage?: number;
|
|
83
|
+
excludeIds?: boolean;
|
|
84
|
+
},
|
|
85
|
+
) => {
|
|
86
|
+
const { page = 1, perPage = 20, ids, excludeIds } = params || { ids: null };
|
|
87
|
+
|
|
88
|
+
const _page = Number(page || '1');
|
|
89
|
+
const _limit = Number(perPage || '20');
|
|
90
|
+
|
|
91
|
+
if (ids && ids.length > 0) {
|
|
92
|
+
return excludeIds ? collection.limit(_limit) : collection;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return collection.limit(_limit).skip((_page - 1) * _limit);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const cursorPaginate = async <T extends Document>({
|
|
99
|
+
model,
|
|
100
|
+
params,
|
|
101
|
+
query,
|
|
102
|
+
formatter,
|
|
103
|
+
}: CursorPaginateParams<T>): Promise<CursorResult<T>> => {
|
|
104
|
+
const { limit = 20, cursor, direction = 'forward', orderBy = {} } = params;
|
|
105
|
+
|
|
106
|
+
if (limit < 1 || limit > 100) {
|
|
107
|
+
throw new Error('Limit must be between 1 and 100');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const baseQuery: FilterQuery<T> = cursor
|
|
111
|
+
? {
|
|
112
|
+
$and: [
|
|
113
|
+
query || {},
|
|
114
|
+
buildCursorQuery(cursor, orderBy, direction, formatter),
|
|
115
|
+
],
|
|
116
|
+
}
|
|
117
|
+
: { ...(query || {}) };
|
|
118
|
+
|
|
119
|
+
const sortFields = Object.keys(orderBy);
|
|
120
|
+
const sortOrder: Record<string, 1 | -1> = {};
|
|
121
|
+
|
|
122
|
+
for (const [field, order] of Object.entries(orderBy)) {
|
|
123
|
+
const normalizedOrder = order === 1 || order === 'asc' ? 1 : -1;
|
|
124
|
+
sortOrder[field] =
|
|
125
|
+
direction === 'forward'
|
|
126
|
+
? normalizedOrder
|
|
127
|
+
: normalizedOrder === 1
|
|
128
|
+
? -1
|
|
129
|
+
: 1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
sortOrder._id = (direction === 'forward' ? 1 : -1) as 1 | -1;
|
|
133
|
+
|
|
134
|
+
const [items, totalCount] = await Promise.all([
|
|
135
|
+
model
|
|
136
|
+
.find(baseQuery as FilterQuery<T>)
|
|
137
|
+
.sort(sortOrder)
|
|
138
|
+
.limit(limit + 1)
|
|
139
|
+
.lean(),
|
|
140
|
+
model.countDocuments(query as FilterQuery<T>),
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
const hasMore = items.length > limit;
|
|
144
|
+
let list = hasMore ? items.slice(0, limit) : items;
|
|
145
|
+
|
|
146
|
+
if (direction === 'backward') {
|
|
147
|
+
list = list.reverse();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const startCursor =
|
|
151
|
+
list.length > 0 ? encodeCursor(list[0], sortFields) : null;
|
|
152
|
+
const endCursor =
|
|
153
|
+
list.length > 0 ? encodeCursor(list[list.length - 1], sortFields) : null;
|
|
154
|
+
|
|
155
|
+
const pageInfo: PageInfo = {
|
|
156
|
+
hasNextPage: direction === 'forward' ? hasMore : Boolean(cursor),
|
|
157
|
+
hasPreviousPage: direction === 'backward' ? hasMore : Boolean(cursor),
|
|
158
|
+
startCursor,
|
|
159
|
+
endCursor,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
list: list as T[],
|
|
164
|
+
totalCount,
|
|
165
|
+
pageInfo,
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export async function cursorPaginateAggregation<T>({
|
|
170
|
+
model,
|
|
171
|
+
pipeline = [],
|
|
172
|
+
params,
|
|
173
|
+
formatter,
|
|
174
|
+
uniqConcatFields,
|
|
175
|
+
}: CursorPaginateAggregationParams<T>): Promise<CursorResult<T>> {
|
|
176
|
+
const { limit = 20, cursor, direction = 'forward', orderBy = {} } = params;
|
|
177
|
+
|
|
178
|
+
if (limit < 1 || limit > 100) {
|
|
179
|
+
throw new Error('Limit must be between 1 and 100');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// --- merge default order ---
|
|
183
|
+
const sortFields = Object.keys(orderBy);
|
|
184
|
+
|
|
185
|
+
// --- cursor match ---
|
|
186
|
+
const cursorMatch = cursor
|
|
187
|
+
? buildCursorQuery(cursor, orderBy, direction, formatter)
|
|
188
|
+
: null;
|
|
189
|
+
|
|
190
|
+
// --- build aggregation pipeline ---
|
|
191
|
+
const aggPipeline: PipelineStage[] = [...pipeline];
|
|
192
|
+
|
|
193
|
+
if (cursorMatch) {
|
|
194
|
+
aggPipeline.push({ $match: cursorMatch });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// --- sorting ---
|
|
198
|
+
aggPipeline.push({ $sort: orderBy as any });
|
|
199
|
+
|
|
200
|
+
// --- unwind if needed ---
|
|
201
|
+
if (uniqConcatFields) {
|
|
202
|
+
// add composite field for cursor
|
|
203
|
+
aggPipeline.push({
|
|
204
|
+
$addFields: {
|
|
205
|
+
compositeField: {
|
|
206
|
+
$concat: uniqConcatFields.map((field) => ({ $toString: field })),
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// --- limit + 1 for hasNextPage ---
|
|
213
|
+
aggPipeline.push({ $limit: limit + 1 });
|
|
214
|
+
|
|
215
|
+
// --- execute aggregation ---
|
|
216
|
+
const listRaw = await model.aggregate(aggPipeline);
|
|
217
|
+
|
|
218
|
+
// --- filtered totalCount ---
|
|
219
|
+
const countPipeline: PipelineStage[] = [
|
|
220
|
+
...pipeline,
|
|
221
|
+
{ $count: 'totalCount' },
|
|
222
|
+
];
|
|
223
|
+
const countResult = await model.aggregate(countPipeline);
|
|
224
|
+
const totalCount = countResult[0]?.totalCount ?? 0;
|
|
225
|
+
|
|
226
|
+
// --- slice list for hasNextPage ---
|
|
227
|
+
const hasMore = listRaw.length > limit;
|
|
228
|
+
let list = hasMore ? listRaw.slice(0, limit) : listRaw;
|
|
229
|
+
|
|
230
|
+
if (direction === 'backward') {
|
|
231
|
+
list = list.reverse();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// --- cursors ---
|
|
235
|
+
const startCursor =
|
|
236
|
+
list.length > 0 ? encodeCursor(list[0], sortFields) : null;
|
|
237
|
+
const endCursor =
|
|
238
|
+
list.length > 0 ? encodeCursor(list[list.length - 1], sortFields) : null;
|
|
239
|
+
|
|
240
|
+
const pageInfo: PageInfo = {
|
|
241
|
+
hasNextPage: direction === 'forward' ? hasMore : Boolean(cursor),
|
|
242
|
+
hasPreviousPage: direction === 'backward' ? hasMore : Boolean(cursor),
|
|
243
|
+
startCursor,
|
|
244
|
+
endCursor,
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
list,
|
|
249
|
+
totalCount,
|
|
250
|
+
pageInfo,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export const checkCollectionCodeDuplication = async (
|
|
255
|
+
collection: any,
|
|
256
|
+
code: string,
|
|
257
|
+
) => {
|
|
258
|
+
if (code.includes('/')) {
|
|
259
|
+
throw new Error('The "/" character is not allowed in the code');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const category = await collection.findOne({
|
|
263
|
+
code,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
if (category) {
|
|
267
|
+
throw new Error('Code must be unique');
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export const schemaWrapper = (
|
|
272
|
+
schema: Schema,
|
|
273
|
+
options: ISchemaWrapperOptions = {},
|
|
274
|
+
) => {
|
|
275
|
+
schema.add({ _id: mongooseStringRandomId });
|
|
276
|
+
schema.add({ processId: { type: String, optional: true } });
|
|
277
|
+
|
|
278
|
+
// Segment membership is written here by the segmentation worker, for whatever
|
|
279
|
+
// content types segments are built against. Declared once for every schema
|
|
280
|
+
// rather than per model: a field that has to be added and indexed by hand on
|
|
281
|
+
// each of a hundred schemas is a field that will be missing from some of them.
|
|
282
|
+
//
|
|
283
|
+
// `default: undefined` keeps the field absent until membership is actually
|
|
284
|
+
// written, which is what lets the sparse index stay empty - and cost nothing -
|
|
285
|
+
// on the collections no segment ever targets.
|
|
286
|
+
schema.add({
|
|
287
|
+
segmentIds: {
|
|
288
|
+
type: [String],
|
|
289
|
+
optional: true,
|
|
290
|
+
default: undefined,
|
|
291
|
+
index: true,
|
|
292
|
+
sparse: true,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// Provenance for records nobody typed in: written by whatever produced them
|
|
297
|
+
// — a campaign, an automation — and never by a person. Declared here for the
|
|
298
|
+
// same reason as `segmentIds` above: a field that has to be remembered on a
|
|
299
|
+
// hundred schemas is a field that will be missing from some of them.
|
|
300
|
+
//
|
|
301
|
+
// `default: undefined` keeps it absent until something writes it, so the
|
|
302
|
+
// sparse index costs nothing on the collections that are only ever filled in
|
|
303
|
+
// by hand.
|
|
304
|
+
schema.add({
|
|
305
|
+
createdVia: {
|
|
306
|
+
type: {
|
|
307
|
+
source: { type: String },
|
|
308
|
+
sourceId: { type: String },
|
|
309
|
+
sourceName: { type: String, optional: true },
|
|
310
|
+
runId: { type: String, optional: true },
|
|
311
|
+
actorId: { type: String, optional: true },
|
|
312
|
+
},
|
|
313
|
+
optional: true,
|
|
314
|
+
default: undefined,
|
|
315
|
+
_id: false,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
schema.index(
|
|
320
|
+
{ 'createdVia.sourceId': 1 },
|
|
321
|
+
{ sparse: true, name: 'createdVia_sourceId' },
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
if (options.search) {
|
|
325
|
+
configureSchemaSearchTokens(schema, options.search);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return schema;
|
|
329
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { FilterQuery, Schema } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
export type SearchTokenMode = 'exact' | 'word' | 'prefix' | 'word-prefix';
|
|
4
|
+
|
|
5
|
+
export interface ISearchTokenFieldConfig {
|
|
6
|
+
path: string;
|
|
7
|
+
mode: SearchTokenMode;
|
|
8
|
+
minLength?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ISearchTokenConfig {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
fields: ISearchTokenFieldConfig[];
|
|
14
|
+
tokenField?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ISchemaWrapperOptions {
|
|
18
|
+
search?: ISearchTokenConfig;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const DEFAULT_MIN_LENGTH = 3;
|
|
22
|
+
const DEFAULT_TOKEN_FIELD = 'searchTokens';
|
|
23
|
+
const TOKEN_MODE_KEYS: Record<SearchTokenMode, string> = {
|
|
24
|
+
exact: 'e',
|
|
25
|
+
word: 'w',
|
|
26
|
+
prefix: 'p',
|
|
27
|
+
'word-prefix': 'wp',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const searchConfigurations = new WeakMap<Schema, ISearchTokenConfig>();
|
|
31
|
+
|
|
32
|
+
const normalizeValue = (value: string) =>
|
|
33
|
+
value.normalize('NFKC').toLocaleLowerCase().trim().replace(/\s+/g, ' ');
|
|
34
|
+
|
|
35
|
+
export const splitSearchWords = (value: string): string[] =>
|
|
36
|
+
normalizeValue(value).match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
37
|
+
|
|
38
|
+
const normalizeExactValue = (value: string) => splitSearchWords(value).join('');
|
|
39
|
+
|
|
40
|
+
const getValuesAtPath = (source: unknown, path: string): string[] => {
|
|
41
|
+
const value = path.split('.').reduce<unknown>((current, key) => {
|
|
42
|
+
if (current === null || typeof current !== 'object') {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (current as Record<string, unknown>)[key];
|
|
47
|
+
}, source);
|
|
48
|
+
|
|
49
|
+
const values = Array.isArray(value) ? value : [value];
|
|
50
|
+
|
|
51
|
+
return values
|
|
52
|
+
.filter(
|
|
53
|
+
(item): item is string | number =>
|
|
54
|
+
typeof item === 'string' || typeof item === 'number',
|
|
55
|
+
)
|
|
56
|
+
.map(String)
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const formatToken = (field: ISearchTokenFieldConfig, value: string): string =>
|
|
61
|
+
`${field.path}:${TOKEN_MODE_KEYS[field.mode]}:${value}`;
|
|
62
|
+
|
|
63
|
+
const generateFieldTokens = (
|
|
64
|
+
value: string,
|
|
65
|
+
field: ISearchTokenFieldConfig,
|
|
66
|
+
): string[] => {
|
|
67
|
+
const minLength = field.minLength ?? DEFAULT_MIN_LENGTH;
|
|
68
|
+
|
|
69
|
+
if (field.mode === 'exact') {
|
|
70
|
+
const exactValue = normalizeExactValue(value);
|
|
71
|
+
return exactValue.length >= minLength
|
|
72
|
+
? [formatToken(field, exactValue)]
|
|
73
|
+
: [];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const words =
|
|
77
|
+
field.mode === 'prefix' ? [normalizeValue(value)] : splitSearchWords(value);
|
|
78
|
+
|
|
79
|
+
if (field.mode === 'word') {
|
|
80
|
+
return words
|
|
81
|
+
.filter((word) => word.length >= minLength)
|
|
82
|
+
.map((word) => formatToken(field, word));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return words.flatMap((word) => {
|
|
86
|
+
const tokens: string[] = [];
|
|
87
|
+
|
|
88
|
+
for (let length = minLength; length <= word.length; length += 1) {
|
|
89
|
+
tokens.push(formatToken(field, word.slice(0, length)));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return tokens;
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const generateConfiguredSearchTokens = (
|
|
97
|
+
source: unknown,
|
|
98
|
+
config: ISearchTokenConfig,
|
|
99
|
+
): string[] => {
|
|
100
|
+
if (!config.enabled) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const tokens = config.fields.flatMap((field) =>
|
|
105
|
+
getValuesAtPath(source, field.path).flatMap((value) =>
|
|
106
|
+
generateFieldTokens(value, field),
|
|
107
|
+
),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
return [...new Set(tokens)];
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const buildSearchTokenFilter = <T>(
|
|
114
|
+
searchValue: string,
|
|
115
|
+
config: ISearchTokenConfig,
|
|
116
|
+
): FilterQuery<T> => {
|
|
117
|
+
const words = splitSearchWords(searchValue);
|
|
118
|
+
|
|
119
|
+
if (!config.enabled || words.length === 0) {
|
|
120
|
+
return { _id: { $in: [] } } as FilterQuery<T>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const wordClauses = words.map((word) => {
|
|
124
|
+
const candidates = config.fields.flatMap((field) => {
|
|
125
|
+
if (field.mode === 'exact') {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const minLength = field.minLength ?? DEFAULT_MIN_LENGTH;
|
|
130
|
+
|
|
131
|
+
if (word.length < minLength) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return [formatToken(field, normalizeValue(word))];
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return candidates.length > 0
|
|
139
|
+
? { [config.tokenField ?? DEFAULT_TOKEN_FIELD]: { $in: candidates } }
|
|
140
|
+
: { _id: { $in: [] } };
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const exactValue = normalizeExactValue(searchValue);
|
|
144
|
+
const exactCandidates = config.fields.flatMap((field) => {
|
|
145
|
+
const minLength = field.minLength ?? DEFAULT_MIN_LENGTH;
|
|
146
|
+
|
|
147
|
+
return field.mode === 'exact' && exactValue.length >= minLength
|
|
148
|
+
? [formatToken(field, exactValue)]
|
|
149
|
+
: [];
|
|
150
|
+
});
|
|
151
|
+
const alternatives: FilterQuery<T>[] = [];
|
|
152
|
+
|
|
153
|
+
if (wordClauses.length > 0) {
|
|
154
|
+
alternatives.push({ $and: wordClauses } as FilterQuery<T>);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (exactCandidates.length > 0) {
|
|
158
|
+
alternatives.push({
|
|
159
|
+
[config.tokenField ?? DEFAULT_TOKEN_FIELD]: { $in: exactCandidates },
|
|
160
|
+
} as FilterQuery<T>);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return alternatives.length > 0
|
|
164
|
+
? ({ $or: alternatives } as FilterQuery<T>)
|
|
165
|
+
: ({ _id: { $in: [] } } as FilterQuery<T>);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const configureSchemaSearchTokens = (
|
|
169
|
+
schema: Schema,
|
|
170
|
+
config: ISearchTokenConfig,
|
|
171
|
+
) => {
|
|
172
|
+
if (!config.enabled) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const tokenField = config.tokenField ?? DEFAULT_TOKEN_FIELD;
|
|
177
|
+
|
|
178
|
+
schema.add({
|
|
179
|
+
[tokenField]: { type: [String], default: [] },
|
|
180
|
+
});
|
|
181
|
+
searchConfigurations.set(schema, config);
|
|
182
|
+
|
|
183
|
+
schema.pre('save', function () {
|
|
184
|
+
this.set(
|
|
185
|
+
tokenField,
|
|
186
|
+
generateConfiguredSearchTokens(this.toObject(), config),
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const getSchemaSearchTokenConfig = (
|
|
192
|
+
schema: Schema,
|
|
193
|
+
): ISearchTokenConfig | undefined => searchConfigurations.get(schema);
|