@erxes/api-shared 0.0.0-stage → 3.2.19-1
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,113 @@
|
|
|
1
|
+
import { IncomingHttpHeaders } from 'http';
|
|
2
|
+
|
|
3
|
+
export const userHeaderName = 'user';
|
|
4
|
+
export const clientPortalHeaderName = 'clientportal';
|
|
5
|
+
export const cpUserHeaderName = 'cpuser';
|
|
6
|
+
|
|
7
|
+
export function extractUserFromHeader(headers: IncomingHttpHeaders): any {
|
|
8
|
+
const userHeader = headers[userHeaderName];
|
|
9
|
+
if (!userHeader) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(userHeader)) {
|
|
13
|
+
throw new Error(`Multiple user headers`);
|
|
14
|
+
}
|
|
15
|
+
const userJson = Buffer.from(userHeader, 'base64').toString('utf-8');
|
|
16
|
+
return JSON.parse(userJson);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function extractCPUserFromHeader(headers: IncomingHttpHeaders): any {
|
|
20
|
+
const cpUserHeader = headers[cpUserHeaderName];
|
|
21
|
+
|
|
22
|
+
if (!cpUserHeader) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (Array.isArray(cpUserHeader)) {
|
|
27
|
+
throw new Error(`Multiple cp user headers`);
|
|
28
|
+
}
|
|
29
|
+
const cpUserJson = Buffer.from(cpUserHeader, 'base64').toString('utf-8');
|
|
30
|
+
return JSON.parse(cpUserJson);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function extractClientPortalFromHeader(
|
|
34
|
+
headers: IncomingHttpHeaders,
|
|
35
|
+
): any {
|
|
36
|
+
const clientPortalHeader = headers[clientPortalHeaderName];
|
|
37
|
+
|
|
38
|
+
if (!clientPortalHeader) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(clientPortalHeader)) {
|
|
43
|
+
throw new Error(`Multiple client portal headers`);
|
|
44
|
+
}
|
|
45
|
+
const clientPortalJson = Buffer.from(clientPortalHeader, 'base64').toString(
|
|
46
|
+
'utf-8',
|
|
47
|
+
);
|
|
48
|
+
return JSON.parse(clientPortalJson);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const USER_HEADER_OMITTED_FIELDS = [
|
|
52
|
+
'emailSignatures',
|
|
53
|
+
'customFieldsData',
|
|
54
|
+
'propertiesData',
|
|
55
|
+
'links',
|
|
56
|
+
'loginToken',
|
|
57
|
+
] as const;
|
|
58
|
+
|
|
59
|
+
export const HEADER_SIZE_WARN_BYTES = 32 * 1024;
|
|
60
|
+
|
|
61
|
+
function encodeHeader(name: string, id: string, value: unknown): string {
|
|
62
|
+
const encoded = Buffer.from(JSON.stringify(value), 'utf8').toString('base64');
|
|
63
|
+
|
|
64
|
+
if (encoded.length > HEADER_SIZE_WARN_BYTES) {
|
|
65
|
+
console.warn(
|
|
66
|
+
`${name} header is ${encoded.length} bytes for ${id}; requests fail once it passes the service header budget`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return encoded;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function compactUserForHeader<T extends Record<string, unknown>>(
|
|
74
|
+
user: T,
|
|
75
|
+
): Omit<T, (typeof USER_HEADER_OMITTED_FIELDS)[number]> {
|
|
76
|
+
const omitted: readonly string[] = USER_HEADER_OMITTED_FIELDS;
|
|
77
|
+
|
|
78
|
+
return Object.fromEntries(
|
|
79
|
+
Object.entries(user).filter(([field]) => !omitted.includes(field)),
|
|
80
|
+
) as Omit<T, (typeof USER_HEADER_OMITTED_FIELDS)[number]>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function setUserHeader(headers: IncomingHttpHeaders, user: any) {
|
|
84
|
+
if (!user) return;
|
|
85
|
+
headers[userHeaderName] = encodeHeader(
|
|
86
|
+
userHeaderName,
|
|
87
|
+
user._id,
|
|
88
|
+
compactUserForHeader(user),
|
|
89
|
+
);
|
|
90
|
+
headers['userid'] = user._id || '';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function setCPUserHeader(headers: IncomingHttpHeaders, cpUser: any) {
|
|
94
|
+
if (!cpUser) return;
|
|
95
|
+
headers[cpUserHeaderName] = encodeHeader(
|
|
96
|
+
cpUserHeaderName,
|
|
97
|
+
cpUser._id,
|
|
98
|
+
cpUser,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function setClientPortalHeader(
|
|
103
|
+
headers: IncomingHttpHeaders,
|
|
104
|
+
clientPortal: any,
|
|
105
|
+
) {
|
|
106
|
+
if (!clientPortal) return;
|
|
107
|
+
const clientPortalJson = JSON.stringify(clientPortal);
|
|
108
|
+
const clientPortalJsonBase64 = Buffer.from(clientPortalJson, 'utf8').toString(
|
|
109
|
+
'base64',
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
headers[clientPortalHeaderName] = clientPortalJsonBase64;
|
|
113
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from './apollo';
|
|
2
|
+
export * from './agent-tools';
|
|
3
|
+
export * from './constants';
|
|
4
|
+
export * from './graphqlPubSub';
|
|
5
|
+
export * from './headers';
|
|
6
|
+
export * from './logs';
|
|
7
|
+
export * from './knowledge';
|
|
8
|
+
export * from './mongo';
|
|
9
|
+
export * from './mq-worker';
|
|
10
|
+
export * from './random';
|
|
11
|
+
export * from './redis';
|
|
12
|
+
export * from './saas';
|
|
13
|
+
export * from './sanitize';
|
|
14
|
+
export * from './service-discovery';
|
|
15
|
+
export * from './start-plugin';
|
|
16
|
+
export * from './trpc';
|
|
17
|
+
export * from './trpc/sendCoreModuleProducer';
|
|
18
|
+
export * from './utils';
|
|
19
|
+
export * from './file/read';
|
|
20
|
+
export * from './file/upload';
|
|
21
|
+
export * from './mongo/cursor-util';
|
|
22
|
+
export * from './string';
|
|
23
|
+
export * from './bulkUtils';
|
|
24
|
+
export * from './editor';
|
|
25
|
+
export * from './errorClassifier';
|
|
26
|
+
export * from './sentry-init';
|
|
27
|
+
export * from './email';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { DefaultJobOptions } from 'bullmq';
|
|
2
|
+
import { sendWorkerQueue } from './mq-worker';
|
|
3
|
+
|
|
4
|
+
export type TKnowledgeVisibility = 'public' | 'internal';
|
|
5
|
+
|
|
6
|
+
export type TKnowledgeContentFormat = 'html' | 'markdown' | 'text';
|
|
7
|
+
|
|
8
|
+
export type TKnowledgeSourceReference = {
|
|
9
|
+
type: string;
|
|
10
|
+
id: string;
|
|
11
|
+
version: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type TKnowledgeDocumentMetadata = {
|
|
17
|
+
visibility: TKnowledgeVisibility;
|
|
18
|
+
language?: 'mn' | 'en' | 'mixed' | 'unknown';
|
|
19
|
+
tags?: string[];
|
|
20
|
+
relatedEntityIds?: string[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TKnowledgeDocument = {
|
|
25
|
+
source: TKnowledgeSourceReference;
|
|
26
|
+
title: string;
|
|
27
|
+
content: string;
|
|
28
|
+
contentFormat?: TKnowledgeContentFormat;
|
|
29
|
+
metadata: TKnowledgeDocumentMetadata;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type TAiKnowledgeSourceReference = {
|
|
33
|
+
pluginName: string;
|
|
34
|
+
moduleName: string;
|
|
35
|
+
key: string;
|
|
36
|
+
sourceId: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const buildKnowledgeSourceType = ({
|
|
41
|
+
pluginName,
|
|
42
|
+
moduleName,
|
|
43
|
+
key,
|
|
44
|
+
}: Pick<TAiKnowledgeSourceReference, 'pluginName' | 'moduleName' | 'key'>) =>
|
|
45
|
+
`${pluginName}:${moduleName}:${key}`;
|
|
46
|
+
|
|
47
|
+
export type TKnowledgeIndexJob =
|
|
48
|
+
| {
|
|
49
|
+
operation: 'upsert';
|
|
50
|
+
document: TKnowledgeDocument;
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
operation: 'remove';
|
|
54
|
+
source: TKnowledgeSourceReference;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const enqueueKnowledgeIndexJob = async ({
|
|
58
|
+
subdomain,
|
|
59
|
+
job,
|
|
60
|
+
jobOptions,
|
|
61
|
+
}: {
|
|
62
|
+
subdomain: string;
|
|
63
|
+
job: TKnowledgeIndexJob;
|
|
64
|
+
jobOptions?: DefaultJobOptions;
|
|
65
|
+
}) => {
|
|
66
|
+
const source = job.operation === 'upsert' ? job.document.source : job.source;
|
|
67
|
+
const queue = sendWorkerQueue('automations', 'aiAgent');
|
|
68
|
+
|
|
69
|
+
return queue.add(
|
|
70
|
+
'indexKnowledgeDocument',
|
|
71
|
+
{
|
|
72
|
+
subdomain,
|
|
73
|
+
data: job,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
attempts: 2,
|
|
77
|
+
jobId: `knowledge:${source.type}:${source.id}:${job.operation}:${source.version}:${source.updatedAt}`,
|
|
78
|
+
removeOnComplete: true,
|
|
79
|
+
removeOnFail: true,
|
|
80
|
+
...jobOptions,
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const enqueueAiKnowledgeSourceRefreshJob = async ({
|
|
86
|
+
subdomain,
|
|
87
|
+
source,
|
|
88
|
+
jobOptions,
|
|
89
|
+
}: {
|
|
90
|
+
subdomain: string;
|
|
91
|
+
source: TAiKnowledgeSourceReference;
|
|
92
|
+
jobOptions?: DefaultJobOptions;
|
|
93
|
+
}) => {
|
|
94
|
+
const queue = sendWorkerQueue('automations', 'aiAgent');
|
|
95
|
+
|
|
96
|
+
return queue.add(
|
|
97
|
+
'refreshAiKnowledgeSource',
|
|
98
|
+
{ subdomain, data: { source } },
|
|
99
|
+
{
|
|
100
|
+
attempts: 2,
|
|
101
|
+
jobId: `knowledge-source:${source.pluginName}:${source.moduleName}:${source.key}:${source.sourceId}:${source.updatedAt}`,
|
|
102
|
+
removeOnComplete: true,
|
|
103
|
+
removeOnFail: true,
|
|
104
|
+
...jobOptions,
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { checkServiceRunning } from '../utils';
|
|
2
|
+
import { ILogDoc } from '../../core-types';
|
|
3
|
+
import { sendWorkerQueue } from '../mq-worker';
|
|
4
|
+
import { initializePluginConfig } from '../service-discovery';
|
|
5
|
+
import { Express } from 'express';
|
|
6
|
+
import * as trpcExpress from '@trpc/server/adapters/express';
|
|
7
|
+
import { initTRPC } from '@trpc/server';
|
|
8
|
+
import { createTRPCContext } from '../trpc';
|
|
9
|
+
import { nanoid } from 'nanoid';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
|
|
12
|
+
export const logHandler = async (
|
|
13
|
+
resolver: () => Promise<any> | any,
|
|
14
|
+
logDoc: ILogDoc,
|
|
15
|
+
onSuccess?: any,
|
|
16
|
+
onError?: any,
|
|
17
|
+
skipSaveResult?: boolean,
|
|
18
|
+
) => {
|
|
19
|
+
if (!(await checkServiceRunning('logs'))) {
|
|
20
|
+
return await resolver();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const payload = { ...(logDoc?.payload || {}) };
|
|
24
|
+
const startDate = new Date();
|
|
25
|
+
const startTime = performance.now();
|
|
26
|
+
try {
|
|
27
|
+
const result = await resolver();
|
|
28
|
+
|
|
29
|
+
const endTime = performance.now();
|
|
30
|
+
const durationMs = endTime - startTime;
|
|
31
|
+
logDoc.payload = { ...payload, ...onSuccess };
|
|
32
|
+
if (!skipSaveResult) {
|
|
33
|
+
logDoc.payload.result = result;
|
|
34
|
+
}
|
|
35
|
+
logDoc.executionTime = {
|
|
36
|
+
startDate,
|
|
37
|
+
endDate: new Date(),
|
|
38
|
+
durationMs: durationMs,
|
|
39
|
+
};
|
|
40
|
+
logDoc.status = 'success';
|
|
41
|
+
sendWorkerQueue('logs', 'put_log').add('put_log', logDoc, {
|
|
42
|
+
removeOnComplete: true,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
const errorDetails = {
|
|
48
|
+
message: error.message || 'Unknown error',
|
|
49
|
+
stack: error.stack || 'No stack available',
|
|
50
|
+
name: error.name || 'Error',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
logDoc.payload = { ...payload, ...onError, error: errorDetails };
|
|
54
|
+
logDoc.status = 'failed';
|
|
55
|
+
sendWorkerQueue('logs', 'put_log').add('put_log', logDoc, {
|
|
56
|
+
removeOnComplete: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
type IContext = {
|
|
63
|
+
subdomain: string;
|
|
64
|
+
processId?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type AfterMutation = {
|
|
68
|
+
type: 'afterMutation';
|
|
69
|
+
mutationNames: string[];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type UpdatedDocument = {
|
|
73
|
+
type: 'updatedDocument';
|
|
74
|
+
contentTypes: string[];
|
|
75
|
+
when?: {
|
|
76
|
+
fieldsUpdated?: string[];
|
|
77
|
+
fieldsRemoved?: string[];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type CreateDocument = {
|
|
82
|
+
type: 'createdDocument';
|
|
83
|
+
contentTypes: string[];
|
|
84
|
+
when?: {
|
|
85
|
+
fieldsWith?: string[];
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type AfterAPIRequest = {
|
|
90
|
+
type: 'afterAPIRequest';
|
|
91
|
+
paths: string[];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type AfterAuth = {
|
|
95
|
+
type: 'afterAuth';
|
|
96
|
+
types: string[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type IAfterProcessRule =
|
|
100
|
+
| AfterMutation
|
|
101
|
+
| CreateDocument
|
|
102
|
+
| UpdatedDocument
|
|
103
|
+
| AfterAPIRequest
|
|
104
|
+
| AfterAuth;
|
|
105
|
+
|
|
106
|
+
export type TAfterProcessRule = {
|
|
107
|
+
AfterMutation: AfterMutation;
|
|
108
|
+
CreateDocument: CreateDocument;
|
|
109
|
+
UpdatedDocument: UpdatedDocument;
|
|
110
|
+
AfterAPIRequest: AfterAPIRequest;
|
|
111
|
+
AfterAuth: AfterAuth;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export interface AfterProcessConfigs {
|
|
115
|
+
rules: IAfterProcessRule[];
|
|
116
|
+
afterMutation?: (
|
|
117
|
+
context: IContext,
|
|
118
|
+
args: {
|
|
119
|
+
data: {
|
|
120
|
+
mutationName: string;
|
|
121
|
+
args: { [key: string]: any };
|
|
122
|
+
result: any;
|
|
123
|
+
userId?: string;
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
) => void | Promise<void>;
|
|
127
|
+
afterAuth?: (
|
|
128
|
+
context: IContext,
|
|
129
|
+
args: { userId: string; email: string; result: string },
|
|
130
|
+
) => void;
|
|
131
|
+
afterApiRequest?: (context: IContext, args: any) => void;
|
|
132
|
+
afterDocumentUpdated?: <TDocument = any>(
|
|
133
|
+
context: IContext,
|
|
134
|
+
args: {
|
|
135
|
+
data: {
|
|
136
|
+
collectionName: string;
|
|
137
|
+
docId: string;
|
|
138
|
+
prevDocument?: any;
|
|
139
|
+
currentDocument?: any;
|
|
140
|
+
updateDescription: {
|
|
141
|
+
added: { [key: string]: any };
|
|
142
|
+
updated: { [key: string]: any };
|
|
143
|
+
removed: string[];
|
|
144
|
+
};
|
|
145
|
+
userId: string;
|
|
146
|
+
processId: string;
|
|
147
|
+
contentType: string;
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
) => void;
|
|
151
|
+
afterDocumentCreated?: <TDocument = any>(
|
|
152
|
+
context: IContext,
|
|
153
|
+
args: {
|
|
154
|
+
data: {
|
|
155
|
+
collectionName: string;
|
|
156
|
+
docId: string;
|
|
157
|
+
currentDocument?: any;
|
|
158
|
+
userId: string;
|
|
159
|
+
processId: string;
|
|
160
|
+
contentType: string;
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
) => void;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface AfterProcessModuleConfig<TModels = any> {
|
|
167
|
+
rules: IAfterProcessRule[];
|
|
168
|
+
createdDocument?: Record<
|
|
169
|
+
string,
|
|
170
|
+
(models: TModels, data: any) => Promise<void>
|
|
171
|
+
>;
|
|
172
|
+
updatedDocument?: Record<
|
|
173
|
+
string,
|
|
174
|
+
(subdomain: string, models: TModels, data: any) => Promise<void>
|
|
175
|
+
>;
|
|
176
|
+
afterMutation?: Record<
|
|
177
|
+
string,
|
|
178
|
+
(subdomain: string, models: TModels, data: any) => Promise<void>
|
|
179
|
+
>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface AfterProcessModules<TModels = any> {
|
|
183
|
+
[moduleName: string]: AfterProcessModuleConfig<TModels>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const startAfterProcess = async (
|
|
187
|
+
app: Express,
|
|
188
|
+
pluginName: string,
|
|
189
|
+
config: AfterProcessConfigs,
|
|
190
|
+
) => {
|
|
191
|
+
await initializePluginConfig(pluginName, 'afterProcess', config);
|
|
192
|
+
|
|
193
|
+
const t = initTRPC.context<IContext>().create();
|
|
194
|
+
|
|
195
|
+
const {
|
|
196
|
+
afterMutation,
|
|
197
|
+
afterAuth,
|
|
198
|
+
afterApiRequest,
|
|
199
|
+
afterDocumentUpdated,
|
|
200
|
+
afterDocumentCreated,
|
|
201
|
+
} = config || {};
|
|
202
|
+
|
|
203
|
+
const routes: Record<string, any> = {};
|
|
204
|
+
|
|
205
|
+
if (afterMutation) {
|
|
206
|
+
routes.afterMutation = t.procedure
|
|
207
|
+
.input(z.any())
|
|
208
|
+
.mutation(async ({ ctx, input }) => afterMutation(ctx, input));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (afterAuth) {
|
|
212
|
+
routes.afterAuth = t.procedure
|
|
213
|
+
.input(z.any())
|
|
214
|
+
.mutation(async ({ ctx, input }) => afterAuth(ctx, input));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (afterApiRequest) {
|
|
218
|
+
routes.afterApiRequest = t.procedure
|
|
219
|
+
.input(z.any())
|
|
220
|
+
.mutation(async ({ ctx, input }) => afterApiRequest(ctx, input));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (afterDocumentUpdated) {
|
|
224
|
+
routes.afterDocumentUpdated = t.procedure
|
|
225
|
+
.input(z.any())
|
|
226
|
+
.mutation(async ({ ctx, input }) => afterDocumentUpdated(ctx, input));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (afterDocumentCreated) {
|
|
230
|
+
routes.afterDocumentCreated = t.procedure
|
|
231
|
+
.input(z.any())
|
|
232
|
+
.mutation(async ({ ctx, input }) => afterDocumentCreated(ctx, input));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const afterProcessRouter = t.router(routes);
|
|
236
|
+
|
|
237
|
+
const trpcMiddleware = trpcExpress.createExpressMiddleware({
|
|
238
|
+
router: afterProcessRouter,
|
|
239
|
+
createContext: createTRPCContext(async (_subdomain, context) => {
|
|
240
|
+
const processId = nanoid(12);
|
|
241
|
+
context.processId = processId;
|
|
242
|
+
return context;
|
|
243
|
+
}),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
app.use('/afterProcess', trpcMiddleware);
|
|
247
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { SortOrder, FilterQuery, Model, Types, PipelineStage } from 'mongoose';
|
|
2
|
+
import { fixNum } from '../utils';
|
|
3
|
+
|
|
4
|
+
export interface CursorPaginateParams<T> {
|
|
5
|
+
model: Model<T>;
|
|
6
|
+
params: {
|
|
7
|
+
limit?: number;
|
|
8
|
+
cursor?: string;
|
|
9
|
+
direction?: 'forward' | 'backward';
|
|
10
|
+
orderBy?: Record<string, SortOrder>;
|
|
11
|
+
};
|
|
12
|
+
query?: FilterQuery<T>;
|
|
13
|
+
formatter?: Record<string, CursorFieldType>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CursorPaginateAggregationParams<T> {
|
|
17
|
+
model: Model<T>;
|
|
18
|
+
pipeline?: PipelineStage[];
|
|
19
|
+
params: {
|
|
20
|
+
limit?: number;
|
|
21
|
+
cursor?: string;
|
|
22
|
+
direction?: 'forward' | 'backward';
|
|
23
|
+
orderBy?: Record<string, SortOrder>;
|
|
24
|
+
};
|
|
25
|
+
formatter?: Record<string, CursorFieldType>;
|
|
26
|
+
uniqConcatFields?: string[]; // optional: if unwinded then concat field names
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PageInfo {
|
|
30
|
+
hasNextPage: boolean;
|
|
31
|
+
hasPreviousPage: boolean;
|
|
32
|
+
startCursor: string | null;
|
|
33
|
+
endCursor: string | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CursorResult<T> {
|
|
37
|
+
list: T[];
|
|
38
|
+
totalCount: number;
|
|
39
|
+
pageInfo: PageInfo;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const encodeCursor = (item: any, sortFields: string[]): string => {
|
|
43
|
+
const cursorData: any = {};
|
|
44
|
+
|
|
45
|
+
for (const field of sortFields) {
|
|
46
|
+
if (item[field] !== undefined) {
|
|
47
|
+
cursorData[field] = item[field];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Handle ObjectId serialization
|
|
52
|
+
cursorData._id =
|
|
53
|
+
item._id instanceof Types.ObjectId ? item._id.toString() : item._id;
|
|
54
|
+
|
|
55
|
+
return Buffer.from(JSON.stringify(cursorData)).toString('base64');
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const decodeCursor = (cursor: string): any => {
|
|
59
|
+
try {
|
|
60
|
+
const decoded = JSON.parse(Buffer.from(cursor, 'base64').toString());
|
|
61
|
+
|
|
62
|
+
// Convert _id back to ObjectId if it's a valid ObjectId string
|
|
63
|
+
if (decoded._id && Types.ObjectId.isValid(decoded._id)) {
|
|
64
|
+
decoded._id = new Types.ObjectId(decoded._id);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return decoded;
|
|
68
|
+
} catch {
|
|
69
|
+
throw new Error('Invalid cursor format');
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type CursorFieldType = 'date' | 'number' | 'boolean';
|
|
74
|
+
const convertValue = (value: any, type: CursorFieldType) => {
|
|
75
|
+
if (value == null) return value;
|
|
76
|
+
|
|
77
|
+
switch (type) {
|
|
78
|
+
case 'date':
|
|
79
|
+
return new Date(value);
|
|
80
|
+
case 'number':
|
|
81
|
+
return fixNum(value, 10);
|
|
82
|
+
case 'boolean':
|
|
83
|
+
return value === 'true' || value === true;
|
|
84
|
+
default:
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const buildCursorQuery = (
|
|
90
|
+
cursor: string,
|
|
91
|
+
orderBy: Record<string, SortOrder>,
|
|
92
|
+
direction: 'forward' | 'backward',
|
|
93
|
+
formatter?: Record<string, CursorFieldType>,
|
|
94
|
+
): Record<string, any> => {
|
|
95
|
+
const cursorData = decodeCursor(cursor);
|
|
96
|
+
|
|
97
|
+
if (formatter) {
|
|
98
|
+
for (const key of Object.keys(formatter)) {
|
|
99
|
+
if (cursorData[key] !== undefined) {
|
|
100
|
+
cursorData[key] = convertValue(cursorData[key], formatter[key]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const sortFields = Object.keys(orderBy);
|
|
106
|
+
|
|
107
|
+
if (sortFields.length === 0) {
|
|
108
|
+
const operator = direction === 'forward' ? '$gt' : '$lt';
|
|
109
|
+
return { _id: { [operator]: cursorData._id } };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const orConditions: Record<string, any>[] = [];
|
|
113
|
+
|
|
114
|
+
for (let i = 0; i < sortFields.length; i++) {
|
|
115
|
+
const field = sortFields[i];
|
|
116
|
+
const sortOrder = orderBy[field];
|
|
117
|
+
const isAscending = sortOrder === 1 || sortOrder === 'asc';
|
|
118
|
+
|
|
119
|
+
const condition: Record<string, any> = {};
|
|
120
|
+
|
|
121
|
+
for (let j = 0; j < i; j++) {
|
|
122
|
+
const prevField = sortFields[j];
|
|
123
|
+
condition[prevField] = cursorData[prevField];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const operator =
|
|
127
|
+
direction === 'forward'
|
|
128
|
+
? isAscending
|
|
129
|
+
? '$gt'
|
|
130
|
+
: '$lt'
|
|
131
|
+
: isAscending
|
|
132
|
+
? '$lt'
|
|
133
|
+
: '$gt';
|
|
134
|
+
|
|
135
|
+
if (cursorData[field] !== undefined) {
|
|
136
|
+
condition[field] = { [operator]: cursorData[field] };
|
|
137
|
+
orConditions.push(condition);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const finalCondition: Record<string, any> = {};
|
|
142
|
+
for (const field of sortFields) {
|
|
143
|
+
if (cursorData[field] !== undefined) {
|
|
144
|
+
finalCondition[field] = cursorData[field];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const idOperator = direction === 'forward' ? '$gt' : '$lt';
|
|
149
|
+
finalCondition._id = { [idOperator]: cursorData._id };
|
|
150
|
+
orConditions.push(finalCondition);
|
|
151
|
+
|
|
152
|
+
return orConditions.length > 0 ? { $or: orConditions } : {};
|
|
153
|
+
};
|