@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,3066 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var startPlugin = require('../../dist/start-plugin-576e707d.cjs.prod.js');
|
|
6
|
+
var mongoose = require('mongoose');
|
|
7
|
+
var stream$1 = require('stream');
|
|
8
|
+
var _loadash = require('lodash');
|
|
9
|
+
var fetch = require('node-fetch');
|
|
10
|
+
var crypto = require('crypto');
|
|
11
|
+
var AWS = require('aws-sdk');
|
|
12
|
+
var nodemailer = require('nodemailer');
|
|
13
|
+
require('@sentry/node');
|
|
14
|
+
require('node:fs');
|
|
15
|
+
require('node:path');
|
|
16
|
+
require('@apollo/server');
|
|
17
|
+
require('@apollo/server/express4');
|
|
18
|
+
require('@apollo/server/plugin/drainHttpServer');
|
|
19
|
+
require('@apollo/subgraph');
|
|
20
|
+
require('@trpc/server/adapters/express');
|
|
21
|
+
require('cookie-parser');
|
|
22
|
+
require('cors');
|
|
23
|
+
require('dotenv');
|
|
24
|
+
require('express');
|
|
25
|
+
require('http');
|
|
26
|
+
require('path');
|
|
27
|
+
require('express-rate-limit');
|
|
28
|
+
require('graphql');
|
|
29
|
+
require('graphql/language');
|
|
30
|
+
require('dayjs');
|
|
31
|
+
require('nanoid');
|
|
32
|
+
require('ioredis');
|
|
33
|
+
require('bullmq');
|
|
34
|
+
require('@trpc/client');
|
|
35
|
+
require('async_hooks');
|
|
36
|
+
require('zod');
|
|
37
|
+
require('@trpc/server');
|
|
38
|
+
require('node:crypto');
|
|
39
|
+
require('graphql-redis-subscriptions');
|
|
40
|
+
require('@azure/storage-blob');
|
|
41
|
+
require('@google-cloud/storage');
|
|
42
|
+
require('fs');
|
|
43
|
+
require('form-data');
|
|
44
|
+
require('os');
|
|
45
|
+
require('csv-parse');
|
|
46
|
+
|
|
47
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
48
|
+
|
|
49
|
+
function _interopNamespace(e) {
|
|
50
|
+
if (e && e.__esModule) return e;
|
|
51
|
+
var n = Object.create(null);
|
|
52
|
+
if (e) {
|
|
53
|
+
Object.keys(e).forEach(function (k) {
|
|
54
|
+
if (k !== 'default') {
|
|
55
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
56
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return e[k]; }
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
n["default"] = e;
|
|
64
|
+
return Object.freeze(n);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var mongoose__default = /*#__PURE__*/_interopDefault(mongoose);
|
|
68
|
+
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
|
69
|
+
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
70
|
+
var AWS__namespace = /*#__PURE__*/_interopNamespace(AWS);
|
|
71
|
+
var nodemailer__namespace = /*#__PURE__*/_interopNamespace(nodemailer);
|
|
72
|
+
|
|
73
|
+
var graphqlAttachmentType = "\n type Attachment {\n url: String!\n name: String\n type: String\n size: Float\n duration: Float\n }\n";
|
|
74
|
+
var graphqlAttachmentInput = "\n input AttachmentInput {\n url: String!\n name: String!\n type: String\n size: Float\n duration: Float\n }\n";
|
|
75
|
+
var graphqlPdfAttachmentType = "\n type PdfAttachment {\n pdf: Attachment\n pages: [Attachment]\n }\n";
|
|
76
|
+
var graphqlPdfAttachmentInput = "\n input PdfAttachmentInput {\n pdf: AttachmentInput\n pages: [AttachmentInput]\n }\n";
|
|
77
|
+
var graphqlPaginationInfo = "\n type PageInfo {\n hasNextPage: Boolean,\n hasPreviousPage: Boolean,\n startCursor: String,\n endCursor: String,\n }\n";
|
|
78
|
+
var apolloCommonTypes = "\n scalar Date\n scalar JSON\n\n enum CURSOR_DIRECTION {\n forward,\n backward\n }\n\n enum CURSOR_MODE {\n inclusive,\n exclusive\n }\n\n enum CONTACT_STATUS {\n active,\n deleted\n }\n\n type Coordinate {\n longitude: String\n latitude: String\n }\n\n input CoordinateInput {\n longitude: String\n latitude: String\n }\n\n ".concat(graphqlAttachmentType, "\n ").concat(graphqlAttachmentInput, "\n ").concat(graphqlPdfAttachmentType, "\n ").concat(graphqlPdfAttachmentInput, "\n ").concat(graphqlPaginationInfo, "\n");
|
|
79
|
+
|
|
80
|
+
var GQL_CURSOR_PARAM_DEFS = "\n limit: Int\n cursor: String\n cursorMode: CURSOR_MODE\n direction: CURSOR_DIRECTION\n orderBy: JSON\n sortMode: String\n aggregationPipeline: [JSON]\n";
|
|
81
|
+
var GQL_OFFSET_PARAM_DEFS = "\n page: Int\n perPage: Int\n sortField: String\n sortDirection: String\n";
|
|
82
|
+
|
|
83
|
+
var erxesSubdomainHeaderName = 'erxes-subdomain';
|
|
84
|
+
var getSubomdainHeader = function getSubomdainHeader(req) {
|
|
85
|
+
var subdomainHeader = req.headers[erxesSubdomainHeaderName];
|
|
86
|
+
if (Array.isArray(subdomainHeader)) {
|
|
87
|
+
throw new Error("Multiple ".concat(erxesSubdomainHeaderName, " headers!"));
|
|
88
|
+
}
|
|
89
|
+
return subdomainHeader;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function sanitizeHeaders(headers) {
|
|
93
|
+
delete headers[erxesSubdomainHeaderName];
|
|
94
|
+
delete headers[startPlugin.userHeaderName];
|
|
95
|
+
delete headers['userid'];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// trimmed version of getHostname, since we don't enable trust
|
|
99
|
+
var getHostnameZeroTrust = function getHostnameZeroTrust(req) {
|
|
100
|
+
var host = req.headers.host;
|
|
101
|
+
if (!host) return;
|
|
102
|
+
|
|
103
|
+
// IPv6 literal support
|
|
104
|
+
var offset = host[0] === '[' ? host.indexOf(']') + 1 : 0;
|
|
105
|
+
var index = host.indexOf(':', offset);
|
|
106
|
+
return index !== -1 ? host.substring(0, index) : host;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var returnGeneratedModels = /*#__PURE__*/function () {
|
|
110
|
+
var _ref = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(connection, loadClasses, subdomain, context) {
|
|
111
|
+
var eventHandlers;
|
|
112
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
113
|
+
while (1) switch (_context.prev = _context.next) {
|
|
114
|
+
case 0:
|
|
115
|
+
eventHandlers = startPlugin.createScopedEventHandlers(subdomain, context);
|
|
116
|
+
_context.next = 3;
|
|
117
|
+
return loadClasses(connection, subdomain, eventHandlers);
|
|
118
|
+
case 3:
|
|
119
|
+
return _context.abrupt("return", _context.sent);
|
|
120
|
+
case 4:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee);
|
|
125
|
+
}));
|
|
126
|
+
return function returnGeneratedModels(_x, _x2, _x3, _x4) {
|
|
127
|
+
return _ref.apply(this, arguments);
|
|
128
|
+
};
|
|
129
|
+
}();
|
|
130
|
+
var createGenerateModels = function createGenerateModels(loadClasses) {
|
|
131
|
+
var VERSION = startPlugin.getEnv({
|
|
132
|
+
name: 'VERSION',
|
|
133
|
+
defaultValue: 'os'
|
|
134
|
+
});
|
|
135
|
+
startPlugin.connect();
|
|
136
|
+
if (VERSION && VERSION !== 'saas') {
|
|
137
|
+
return /*#__PURE__*/function () {
|
|
138
|
+
var _genereteModels = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(hostnameOrSubdomain, context) {
|
|
139
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
140
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
141
|
+
case 0:
|
|
142
|
+
_context2.next = 2;
|
|
143
|
+
return returnGeneratedModels(mongoose__default["default"].connection, loadClasses, hostnameOrSubdomain, context);
|
|
144
|
+
case 2:
|
|
145
|
+
return _context2.abrupt("return", _context2.sent);
|
|
146
|
+
case 3:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context2.stop();
|
|
149
|
+
}
|
|
150
|
+
}, _callee2);
|
|
151
|
+
}));
|
|
152
|
+
function genereteModels(_x5, _x6) {
|
|
153
|
+
return _genereteModels.apply(this, arguments);
|
|
154
|
+
}
|
|
155
|
+
return genereteModels;
|
|
156
|
+
}();
|
|
157
|
+
} else {
|
|
158
|
+
return /*#__PURE__*/function () {
|
|
159
|
+
var _genereteModels2 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3() {
|
|
160
|
+
var _subdomain;
|
|
161
|
+
var hostnameOrSubdomain,
|
|
162
|
+
context,
|
|
163
|
+
subdomain,
|
|
164
|
+
organization,
|
|
165
|
+
DB_NAME,
|
|
166
|
+
GE_MONGO_URL,
|
|
167
|
+
tenantCon,
|
|
168
|
+
_args3 = arguments;
|
|
169
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
170
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
171
|
+
case 0:
|
|
172
|
+
hostnameOrSubdomain = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : '';
|
|
173
|
+
context = _args3.length > 1 ? _args3[1] : undefined;
|
|
174
|
+
subdomain = hostnameOrSubdomain;
|
|
175
|
+
if (subdomain) {
|
|
176
|
+
_context3.next = 5;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
throw new Error("Subdomain is `".concat(subdomain, "`"));
|
|
180
|
+
case 5:
|
|
181
|
+
// means hostname
|
|
182
|
+
if ((_subdomain = subdomain) !== null && _subdomain !== void 0 && _subdomain.includes('.')) {
|
|
183
|
+
subdomain = startPlugin.getSubdomain(hostnameOrSubdomain);
|
|
184
|
+
}
|
|
185
|
+
_context3.next = 8;
|
|
186
|
+
return startPlugin.getSaasCoreConnection();
|
|
187
|
+
case 8:
|
|
188
|
+
_context3.next = 10;
|
|
189
|
+
return startPlugin.coreModelOrganizations.findOne({
|
|
190
|
+
subdomain: subdomain
|
|
191
|
+
});
|
|
192
|
+
case 10:
|
|
193
|
+
organization = _context3.sent;
|
|
194
|
+
if (organization) {
|
|
195
|
+
_context3.next = 13;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
throw new Error("Organization with subdomain = ".concat(subdomain, " is not found"));
|
|
199
|
+
case 13:
|
|
200
|
+
DB_NAME = startPlugin.getEnv({
|
|
201
|
+
name: 'DB_NAME'
|
|
202
|
+
});
|
|
203
|
+
GE_MONGO_URL = (DB_NAME || 'erxes_<organizationId>').replace('<organizationId>', organization._id);
|
|
204
|
+
tenantCon = mongoose__default["default"].connection.useDb(GE_MONGO_URL, {
|
|
205
|
+
// so that conn.model method can use cached connection
|
|
206
|
+
useCache: true,
|
|
207
|
+
noListener: true
|
|
208
|
+
});
|
|
209
|
+
_context3.next = 18;
|
|
210
|
+
return returnGeneratedModels(tenantCon, loadClasses, subdomain, context);
|
|
211
|
+
case 18:
|
|
212
|
+
return _context3.abrupt("return", _context3.sent);
|
|
213
|
+
case 19:
|
|
214
|
+
case "end":
|
|
215
|
+
return _context3.stop();
|
|
216
|
+
}
|
|
217
|
+
}, _callee3);
|
|
218
|
+
}));
|
|
219
|
+
function genereteModels() {
|
|
220
|
+
return _genereteModels2.apply(this, arguments);
|
|
221
|
+
}
|
|
222
|
+
return genereteModels;
|
|
223
|
+
}();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
var withLogging = function withLogging(resolver) {
|
|
228
|
+
return /*#__PURE__*/function () {
|
|
229
|
+
var _ref = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(root, args, context, info) {
|
|
230
|
+
var user, req, processId, subdomain, requestData;
|
|
231
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
232
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
233
|
+
case 0:
|
|
234
|
+
user = context.user, req = context.req, processId = context.processId, subdomain = context.subdomain;
|
|
235
|
+
requestData = req.headers;
|
|
236
|
+
_context2.next = 4;
|
|
237
|
+
return startPlugin.logHandler(/*#__PURE__*/startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee() {
|
|
238
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
239
|
+
while (1) switch (_context.prev = _context.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
_context.next = 2;
|
|
242
|
+
return resolver(root, args, context, info);
|
|
243
|
+
case 2:
|
|
244
|
+
return _context.abrupt("return", _context.sent);
|
|
245
|
+
case 3:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee);
|
|
250
|
+
})), {
|
|
251
|
+
subdomain: subdomain,
|
|
252
|
+
source: 'graphql',
|
|
253
|
+
action: 'mutation',
|
|
254
|
+
payload: {
|
|
255
|
+
mutationName: info.fieldName,
|
|
256
|
+
requestData: requestData,
|
|
257
|
+
args: args
|
|
258
|
+
},
|
|
259
|
+
processId: processId,
|
|
260
|
+
userId: user === null || user === void 0 ? void 0 : user._id
|
|
261
|
+
});
|
|
262
|
+
case 4:
|
|
263
|
+
return _context2.abrupt("return", _context2.sent);
|
|
264
|
+
case 5:
|
|
265
|
+
case "end":
|
|
266
|
+
return _context2.stop();
|
|
267
|
+
}
|
|
268
|
+
}, _callee2);
|
|
269
|
+
}));
|
|
270
|
+
return function (_x, _x2, _x3, _x4) {
|
|
271
|
+
return _ref.apply(this, arguments);
|
|
272
|
+
};
|
|
273
|
+
}();
|
|
274
|
+
};
|
|
275
|
+
var withBefore = function withBefore(resolver, resolverKey) {
|
|
276
|
+
return /*#__PURE__*/function () {
|
|
277
|
+
var _ref3 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3(root, args, context, info) {
|
|
278
|
+
var _requestInfo, _req;
|
|
279
|
+
var subdomain, user, headers, result;
|
|
280
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
281
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
subdomain = context.subdomain, user = context.user;
|
|
284
|
+
headers = ((_requestInfo = context.requestInfo) === null || _requestInfo === void 0 ? void 0 : _requestInfo.headers) || ((_req = context.req) === null || _req === void 0 ? void 0 : _req.headers);
|
|
285
|
+
_context3.next = 4;
|
|
286
|
+
return startPlugin.runBeforeResolvers(resolverKey, args, {
|
|
287
|
+
subdomain: subdomain,
|
|
288
|
+
user: user,
|
|
289
|
+
headers: headers
|
|
290
|
+
});
|
|
291
|
+
case 4:
|
|
292
|
+
result = _context3.sent;
|
|
293
|
+
if (!result.resolved) {
|
|
294
|
+
_context3.next = 7;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
return _context3.abrupt("return", result.data);
|
|
298
|
+
case 7:
|
|
299
|
+
return _context3.abrupt("return", resolver(root, result.args, context, info));
|
|
300
|
+
case 8:
|
|
301
|
+
case "end":
|
|
302
|
+
return _context3.stop();
|
|
303
|
+
}
|
|
304
|
+
}, _callee3);
|
|
305
|
+
}));
|
|
306
|
+
return function (_x5, _x6, _x7, _x8) {
|
|
307
|
+
return _ref3.apply(this, arguments);
|
|
308
|
+
};
|
|
309
|
+
}();
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// Apply middleware to all mutations in an object
|
|
313
|
+
var wrapApolloMutations = function wrapApolloMutations(mutations, muataionsForSkip) {
|
|
314
|
+
var wrappedMutations = {};
|
|
315
|
+
for (var _i = 0, _Object$entries = Object.entries(mutations); _i < _Object$entries.length; _i++) {
|
|
316
|
+
var _Object$entries$_i = startPlugin._slicedToArray(_Object$entries[_i], 2),
|
|
317
|
+
key = _Object$entries$_i[0],
|
|
318
|
+
resolver = _Object$entries$_i[1];
|
|
319
|
+
if (muataionsForSkip !== null && muataionsForSkip !== void 0 && muataionsForSkip.includes(key)) {
|
|
320
|
+
wrappedMutations[key] = resolver;
|
|
321
|
+
} else {
|
|
322
|
+
wrappedMutations[key] = withLogging(withBefore(resolver, key));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return wrappedMutations;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
var STATUSES = [{
|
|
329
|
+
label: 'Active',
|
|
330
|
+
value: 'Active'
|
|
331
|
+
}, {
|
|
332
|
+
label: 'Deleted',
|
|
333
|
+
value: 'Deleted'
|
|
334
|
+
}];
|
|
335
|
+
var DEFAULT_SOCIAL_LINKS = [{
|
|
336
|
+
label: 'Facebook',
|
|
337
|
+
value: 'facebook'
|
|
338
|
+
}, {
|
|
339
|
+
label: 'whatsapp',
|
|
340
|
+
value: 'whatsapp'
|
|
341
|
+
}, {
|
|
342
|
+
label: 'Twitter',
|
|
343
|
+
value: 'twitter'
|
|
344
|
+
}, {
|
|
345
|
+
label: 'Youtube',
|
|
346
|
+
value: 'youtube'
|
|
347
|
+
}, {
|
|
348
|
+
label: 'Website',
|
|
349
|
+
value: 'website'
|
|
350
|
+
}];
|
|
351
|
+
var SOCIAL_LINKS = [].concat(DEFAULT_SOCIAL_LINKS, [{
|
|
352
|
+
label: 'Academia.edu',
|
|
353
|
+
value: 'academia.edu'
|
|
354
|
+
}, {
|
|
355
|
+
label: 'Chess.com',
|
|
356
|
+
value: 'chess.com'
|
|
357
|
+
}, {
|
|
358
|
+
label: 'Crunchyroll',
|
|
359
|
+
value: 'crunchyroll'
|
|
360
|
+
}, {
|
|
361
|
+
label: 'DeviantArt',
|
|
362
|
+
value: 'deviantArt'
|
|
363
|
+
}, {
|
|
364
|
+
label: 'Discord',
|
|
365
|
+
value: 'discord'
|
|
366
|
+
}, {
|
|
367
|
+
label: 'Douban',
|
|
368
|
+
value: 'douban'
|
|
369
|
+
}, {
|
|
370
|
+
label: 'eToro',
|
|
371
|
+
value: 'eToro'
|
|
372
|
+
}, {
|
|
373
|
+
label: 'Flickr',
|
|
374
|
+
value: 'flickr'
|
|
375
|
+
}, {
|
|
376
|
+
label: 'Gapo',
|
|
377
|
+
value: 'gapo'
|
|
378
|
+
}, {
|
|
379
|
+
label: 'Goodreads',
|
|
380
|
+
value: 'goodreads'
|
|
381
|
+
}, {
|
|
382
|
+
label: 'GitHub',
|
|
383
|
+
value: 'gitHub'
|
|
384
|
+
}, {
|
|
385
|
+
label: 'Instagram',
|
|
386
|
+
value: 'instagram'
|
|
387
|
+
}, {
|
|
388
|
+
label: 'KakaoStory',
|
|
389
|
+
value: 'kakaoStory'
|
|
390
|
+
}, {
|
|
391
|
+
label: 'KizlarSoruyor',
|
|
392
|
+
value: 'kizlarSoruyor'
|
|
393
|
+
}, {
|
|
394
|
+
label: 'Last.fm',
|
|
395
|
+
value: 'last.fm'
|
|
396
|
+
}, {
|
|
397
|
+
label: 'LinkedIn',
|
|
398
|
+
value: 'linkedIn'
|
|
399
|
+
}, {
|
|
400
|
+
label: 'LiveJournal',
|
|
401
|
+
value: 'liveJournal'
|
|
402
|
+
}, {
|
|
403
|
+
label: 'Pinterest',
|
|
404
|
+
value: 'pinterest'
|
|
405
|
+
}, {
|
|
406
|
+
label: 'Pixnet',
|
|
407
|
+
value: 'pixnet'
|
|
408
|
+
}, {
|
|
409
|
+
label: 'Plurk',
|
|
410
|
+
value: 'plurk'
|
|
411
|
+
}, {
|
|
412
|
+
label: 'Quora',
|
|
413
|
+
value: 'quora'
|
|
414
|
+
}, {
|
|
415
|
+
label: 'Reddit',
|
|
416
|
+
value: 'reddit'
|
|
417
|
+
}, {
|
|
418
|
+
label: 'Renren',
|
|
419
|
+
value: 'renren'
|
|
420
|
+
}, {
|
|
421
|
+
label: 'Sina Weibo',
|
|
422
|
+
value: 'sinaWeibo'
|
|
423
|
+
}, {
|
|
424
|
+
label: 'SoundCloud',
|
|
425
|
+
value: 'soundCloud'
|
|
426
|
+
}, {
|
|
427
|
+
label: 'Spotify',
|
|
428
|
+
value: 'spotify'
|
|
429
|
+
}, {
|
|
430
|
+
label: 'Steam',
|
|
431
|
+
value: 'steam'
|
|
432
|
+
}, {
|
|
433
|
+
label: 'Tagged',
|
|
434
|
+
value: 'tagged'
|
|
435
|
+
}, {
|
|
436
|
+
label: 'Taringa',
|
|
437
|
+
value: 'taringa'
|
|
438
|
+
}, {
|
|
439
|
+
label: 'Tumblr',
|
|
440
|
+
value: 'tumblr'
|
|
441
|
+
}, {
|
|
442
|
+
label: 'VK',
|
|
443
|
+
value: 'vk'
|
|
444
|
+
}, {
|
|
445
|
+
label: 'Voat',
|
|
446
|
+
value: 'voat'
|
|
447
|
+
}, {
|
|
448
|
+
label: 'Wattpad',
|
|
449
|
+
value: 'wattpad'
|
|
450
|
+
}, {
|
|
451
|
+
label: 'XING',
|
|
452
|
+
value: 'xing'
|
|
453
|
+
}, {
|
|
454
|
+
label: 'Yammer',
|
|
455
|
+
value: 'yammer'
|
|
456
|
+
}, {
|
|
457
|
+
label: 'Yelp',
|
|
458
|
+
value: 'yelp'
|
|
459
|
+
}]);
|
|
460
|
+
var DEFAULT_SEX_CHOICES = [{
|
|
461
|
+
label: 'Not known',
|
|
462
|
+
value: 0
|
|
463
|
+
}, {
|
|
464
|
+
label: 'Male',
|
|
465
|
+
value: 1
|
|
466
|
+
}, {
|
|
467
|
+
label: 'Female',
|
|
468
|
+
value: 2
|
|
469
|
+
}, {
|
|
470
|
+
label: 'Not applicable',
|
|
471
|
+
value: 9
|
|
472
|
+
}];
|
|
473
|
+
var SEX_OPTIONS = [].concat(DEFAULT_SEX_CHOICES, [{
|
|
474
|
+
label: 'co/co',
|
|
475
|
+
value: 10
|
|
476
|
+
}, {
|
|
477
|
+
label: 'en/en',
|
|
478
|
+
value: 11
|
|
479
|
+
}, {
|
|
480
|
+
label: 'ey/em',
|
|
481
|
+
value: 12
|
|
482
|
+
}, {
|
|
483
|
+
label: 'he/him',
|
|
484
|
+
value: 13
|
|
485
|
+
}, {
|
|
486
|
+
label: 'he/them',
|
|
487
|
+
value: 14
|
|
488
|
+
}, {
|
|
489
|
+
label: 'she/her',
|
|
490
|
+
value: 15
|
|
491
|
+
}, {
|
|
492
|
+
label: 'she/them',
|
|
493
|
+
value: 16
|
|
494
|
+
}, {
|
|
495
|
+
label: 'they/them',
|
|
496
|
+
value: 17
|
|
497
|
+
}, {
|
|
498
|
+
label: 'xie/hir',
|
|
499
|
+
value: 18
|
|
500
|
+
}, {
|
|
501
|
+
label: 'yo/yo',
|
|
502
|
+
value: 19
|
|
503
|
+
}, {
|
|
504
|
+
label: 'ze/zir',
|
|
505
|
+
value: 20
|
|
506
|
+
}, {
|
|
507
|
+
label: 've/vis',
|
|
508
|
+
value: 21
|
|
509
|
+
}, {
|
|
510
|
+
label: 'xe/xem',
|
|
511
|
+
value: 22
|
|
512
|
+
}]);
|
|
513
|
+
var USER_ROLES = {
|
|
514
|
+
SYSTEM: 'system',
|
|
515
|
+
USER: 'user',
|
|
516
|
+
ALL: ['system', 'user']
|
|
517
|
+
};
|
|
518
|
+
var LOG_STATUSES = {
|
|
519
|
+
FAILED: 'failed',
|
|
520
|
+
SUCCESS: 'success'
|
|
521
|
+
};
|
|
522
|
+
var CONFORMITY_TYPE = {
|
|
523
|
+
customers: 'customer',
|
|
524
|
+
companies: 'company'
|
|
525
|
+
};
|
|
526
|
+
var PERMISSION_ROLES = {
|
|
527
|
+
OWNER: 'owner',
|
|
528
|
+
ADMIN: 'admin',
|
|
529
|
+
MEMBER: 'member',
|
|
530
|
+
ALL: ['owner', 'admin', 'member']
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
var buildKnowledgeSourceType = function buildKnowledgeSourceType(_ref) {
|
|
534
|
+
var pluginName = _ref.pluginName,
|
|
535
|
+
moduleName = _ref.moduleName,
|
|
536
|
+
key = _ref.key;
|
|
537
|
+
return "".concat(pluginName, ":").concat(moduleName, ":").concat(key);
|
|
538
|
+
};
|
|
539
|
+
var enqueueKnowledgeIndexJob = /*#__PURE__*/function () {
|
|
540
|
+
var _ref3 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(_ref2) {
|
|
541
|
+
var subdomain, job, jobOptions, source, queue;
|
|
542
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
543
|
+
while (1) switch (_context.prev = _context.next) {
|
|
544
|
+
case 0:
|
|
545
|
+
subdomain = _ref2.subdomain, job = _ref2.job, jobOptions = _ref2.jobOptions;
|
|
546
|
+
source = job.operation === 'upsert' ? job.document.source : job.source;
|
|
547
|
+
queue = startPlugin.sendWorkerQueue('automations', 'aiAgent');
|
|
548
|
+
return _context.abrupt("return", queue.add('indexKnowledgeDocument', {
|
|
549
|
+
subdomain: subdomain,
|
|
550
|
+
data: job
|
|
551
|
+
}, startPlugin._objectSpread2({
|
|
552
|
+
attempts: 2,
|
|
553
|
+
jobId: "knowledge:".concat(source.type, ":").concat(source.id, ":").concat(job.operation, ":").concat(source.version, ":").concat(source.updatedAt),
|
|
554
|
+
removeOnComplete: true,
|
|
555
|
+
removeOnFail: true
|
|
556
|
+
}, jobOptions)));
|
|
557
|
+
case 4:
|
|
558
|
+
case "end":
|
|
559
|
+
return _context.stop();
|
|
560
|
+
}
|
|
561
|
+
}, _callee);
|
|
562
|
+
}));
|
|
563
|
+
return function enqueueKnowledgeIndexJob(_x) {
|
|
564
|
+
return _ref3.apply(this, arguments);
|
|
565
|
+
};
|
|
566
|
+
}();
|
|
567
|
+
var enqueueAiKnowledgeSourceRefreshJob = /*#__PURE__*/function () {
|
|
568
|
+
var _ref5 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(_ref4) {
|
|
569
|
+
var subdomain, source, jobOptions, queue;
|
|
570
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
571
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
572
|
+
case 0:
|
|
573
|
+
subdomain = _ref4.subdomain, source = _ref4.source, jobOptions = _ref4.jobOptions;
|
|
574
|
+
queue = startPlugin.sendWorkerQueue('automations', 'aiAgent');
|
|
575
|
+
return _context2.abrupt("return", queue.add('refreshAiKnowledgeSource', {
|
|
576
|
+
subdomain: subdomain,
|
|
577
|
+
data: {
|
|
578
|
+
source: source
|
|
579
|
+
}
|
|
580
|
+
}, startPlugin._objectSpread2({
|
|
581
|
+
attempts: 2,
|
|
582
|
+
jobId: "knowledge-source:".concat(source.pluginName, ":").concat(source.moduleName, ":").concat(source.key, ":").concat(source.sourceId, ":").concat(source.updatedAt),
|
|
583
|
+
removeOnComplete: true,
|
|
584
|
+
removeOnFail: true
|
|
585
|
+
}, jobOptions)));
|
|
586
|
+
case 3:
|
|
587
|
+
case "end":
|
|
588
|
+
return _context2.stop();
|
|
589
|
+
}
|
|
590
|
+
}, _callee2);
|
|
591
|
+
}));
|
|
592
|
+
return function enqueueAiKnowledgeSourceRefreshJob(_x2) {
|
|
593
|
+
return _ref5.apply(this, arguments);
|
|
594
|
+
};
|
|
595
|
+
}();
|
|
596
|
+
|
|
597
|
+
var stream = /*#__PURE__*/function () {
|
|
598
|
+
var _ref = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3(executeChunk, transformCallback, generateChildStream, chunkSize) {
|
|
599
|
+
var variables, onFinishPiping, parentTransformerStream, childCursor;
|
|
600
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
601
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
602
|
+
case 0:
|
|
603
|
+
variables = {}; // Function to handle remaining items after streaming
|
|
604
|
+
onFinishPiping = /*#__PURE__*/function () {
|
|
605
|
+
var _ref2 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee() {
|
|
606
|
+
var chunks, _iterator, _step, chunk;
|
|
607
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
608
|
+
while (1) switch (_context.prev = _context.next) {
|
|
609
|
+
case 0:
|
|
610
|
+
if (!(variables.parentIds && variables.parentIds.length > 0)) {
|
|
611
|
+
_context.next = 19;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
chunks = startPlugin.chunkArray(variables.parentIds, chunkSize);
|
|
615
|
+
_iterator = startPlugin._createForOfIteratorHelper(chunks);
|
|
616
|
+
_context.prev = 3;
|
|
617
|
+
_iterator.s();
|
|
618
|
+
case 5:
|
|
619
|
+
if ((_step = _iterator.n()).done) {
|
|
620
|
+
_context.next = 11;
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
chunk = _step.value;
|
|
624
|
+
_context.next = 9;
|
|
625
|
+
return executeChunk(chunk);
|
|
626
|
+
case 9:
|
|
627
|
+
_context.next = 5;
|
|
628
|
+
break;
|
|
629
|
+
case 11:
|
|
630
|
+
_context.next = 16;
|
|
631
|
+
break;
|
|
632
|
+
case 13:
|
|
633
|
+
_context.prev = 13;
|
|
634
|
+
_context.t0 = _context["catch"](3);
|
|
635
|
+
_iterator.e(_context.t0);
|
|
636
|
+
case 16:
|
|
637
|
+
_context.prev = 16;
|
|
638
|
+
_iterator.f();
|
|
639
|
+
return _context.finish(16);
|
|
640
|
+
case 19:
|
|
641
|
+
case "end":
|
|
642
|
+
return _context.stop();
|
|
643
|
+
}
|
|
644
|
+
}, _callee, null, [[3, 13, 16, 19]]);
|
|
645
|
+
}));
|
|
646
|
+
return function onFinishPiping() {
|
|
647
|
+
return _ref2.apply(this, arguments);
|
|
648
|
+
};
|
|
649
|
+
}(); // Transformer stream to process each item
|
|
650
|
+
parentTransformerStream = new stream$1.Transform({
|
|
651
|
+
objectMode: true,
|
|
652
|
+
transform: function transform(root, _encoding, callback) {
|
|
653
|
+
try {
|
|
654
|
+
transformCallback(variables, root);
|
|
655
|
+
callback();
|
|
656
|
+
} catch (err) {
|
|
657
|
+
callback(err);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
childCursor = generateChildStream().cursor();
|
|
662
|
+
_context3.prev = 4;
|
|
663
|
+
_context3.next = 7;
|
|
664
|
+
return new Promise(function (resolve, reject) {
|
|
665
|
+
childCursor.pipe(parentTransformerStream);
|
|
666
|
+
parentTransformerStream.on('finish', /*#__PURE__*/startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2() {
|
|
667
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
668
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
669
|
+
case 0:
|
|
670
|
+
_context2.prev = 0;
|
|
671
|
+
_context2.next = 3;
|
|
672
|
+
return onFinishPiping();
|
|
673
|
+
case 3:
|
|
674
|
+
resolve();
|
|
675
|
+
_context2.next = 9;
|
|
676
|
+
break;
|
|
677
|
+
case 6:
|
|
678
|
+
_context2.prev = 6;
|
|
679
|
+
_context2.t0 = _context2["catch"](0);
|
|
680
|
+
reject(_context2.t0);
|
|
681
|
+
case 9:
|
|
682
|
+
case "end":
|
|
683
|
+
return _context2.stop();
|
|
684
|
+
}
|
|
685
|
+
}, _callee2, null, [[0, 6]]);
|
|
686
|
+
})));
|
|
687
|
+
parentTransformerStream.on('error', reject);
|
|
688
|
+
});
|
|
689
|
+
case 7:
|
|
690
|
+
return _context3.abrupt("return", 'done');
|
|
691
|
+
case 10:
|
|
692
|
+
_context3.prev = 10;
|
|
693
|
+
_context3.t0 = _context3["catch"](4);
|
|
694
|
+
parentTransformerStream.destroy();
|
|
695
|
+
throw _context3.t0;
|
|
696
|
+
case 14:
|
|
697
|
+
_context3.prev = 14;
|
|
698
|
+
if (typeof childCursor.destroy === 'function') {
|
|
699
|
+
childCursor.destroy();
|
|
700
|
+
}
|
|
701
|
+
return _context3.finish(14);
|
|
702
|
+
case 17:
|
|
703
|
+
case "end":
|
|
704
|
+
return _context3.stop();
|
|
705
|
+
}
|
|
706
|
+
}, _callee3, null, [[4, 10, 14, 17]]);
|
|
707
|
+
}));
|
|
708
|
+
return function stream(_x, _x2, _x3, _x4) {
|
|
709
|
+
return _ref.apply(this, arguments);
|
|
710
|
+
};
|
|
711
|
+
}();
|
|
712
|
+
|
|
713
|
+
var getCustomerName = function getCustomerName(customer) {
|
|
714
|
+
if (customer.firstName || customer.lastName) {
|
|
715
|
+
return (customer.firstName || '') + ' ' + (customer.lastName || '');
|
|
716
|
+
}
|
|
717
|
+
if (customer.primaryEmail || customer.primaryPhone) {
|
|
718
|
+
return customer.primaryEmail || customer.primaryPhone;
|
|
719
|
+
}
|
|
720
|
+
var visitorContactInfo = customer.visitorContactInfo;
|
|
721
|
+
if (visitorContactInfo) {
|
|
722
|
+
return visitorContactInfo.phone || visitorContactInfo.email;
|
|
723
|
+
}
|
|
724
|
+
return 'Unknown';
|
|
725
|
+
};
|
|
726
|
+
function runReplacersOn(content) {
|
|
727
|
+
var replacers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
728
|
+
var replacedContent = content;
|
|
729
|
+
var _iterator = startPlugin._createForOfIteratorHelper(replacers),
|
|
730
|
+
_step;
|
|
731
|
+
try {
|
|
732
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
733
|
+
var replacer = _step.value;
|
|
734
|
+
var regex = new RegExp(replacer.key, 'gi');
|
|
735
|
+
replacedContent = replacedContent.replace(regex, replacer.value);
|
|
736
|
+
}
|
|
737
|
+
} catch (err) {
|
|
738
|
+
_iterator.e(err);
|
|
739
|
+
} finally {
|
|
740
|
+
_iterator.f();
|
|
741
|
+
}
|
|
742
|
+
return replacedContent;
|
|
743
|
+
}
|
|
744
|
+
var EditorAttributeUtil = /*#__PURE__*/function () {
|
|
745
|
+
function EditorAttributeUtil(API_DOMAIN, availableServices, subdomain) {
|
|
746
|
+
startPlugin._classCallCheck(this, EditorAttributeUtil);
|
|
747
|
+
this.API_DOMAIN = API_DOMAIN;
|
|
748
|
+
this.availableServices = new Set(availableServices);
|
|
749
|
+
this.subdomain = subdomain || 'os';
|
|
750
|
+
}
|
|
751
|
+
return startPlugin._createClass(EditorAttributeUtil, [{
|
|
752
|
+
key: "fileToFileLink",
|
|
753
|
+
value: function () {
|
|
754
|
+
var _fileToFileLink = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(url, name) {
|
|
755
|
+
var href, key, uriName;
|
|
756
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
757
|
+
while (1) switch (_context.prev = _context.next) {
|
|
758
|
+
case 0:
|
|
759
|
+
if (url) {
|
|
760
|
+
_context.next = 2;
|
|
761
|
+
break;
|
|
762
|
+
}
|
|
763
|
+
return _context.abrupt("return", '');
|
|
764
|
+
case 2:
|
|
765
|
+
if (startPlugin.isValidURL(url) || url.includes('/')) {
|
|
766
|
+
href = url;
|
|
767
|
+
} else {
|
|
768
|
+
key = url;
|
|
769
|
+
uriName = name ? encodeURIComponent(name) : url;
|
|
770
|
+
href = "".concat(this.API_DOMAIN, "/read-file?key=").concat(key, "&name=").concat(uriName);
|
|
771
|
+
}
|
|
772
|
+
return _context.abrupt("return", "<a target=\"_blank\" download href=\"".concat(href, "\">").concat(name || url, "</a>"));
|
|
773
|
+
case 4:
|
|
774
|
+
case "end":
|
|
775
|
+
return _context.stop();
|
|
776
|
+
}
|
|
777
|
+
}, _callee, this);
|
|
778
|
+
}));
|
|
779
|
+
function fileToFileLink(_x, _x2) {
|
|
780
|
+
return _fileToFileLink.apply(this, arguments);
|
|
781
|
+
}
|
|
782
|
+
return fileToFileLink;
|
|
783
|
+
}()
|
|
784
|
+
}, {
|
|
785
|
+
key: "customFieldsDataItemToFileLink",
|
|
786
|
+
value: function () {
|
|
787
|
+
var _customFieldsDataItemToFileLink = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(customFieldDataItem) {
|
|
788
|
+
var _this = this;
|
|
789
|
+
var value, links;
|
|
790
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
791
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
792
|
+
case 0:
|
|
793
|
+
value = customFieldDataItem.value;
|
|
794
|
+
if (!Array.isArray(value)) {
|
|
795
|
+
_context2.next = 6;
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
_context2.next = 4;
|
|
799
|
+
return Promise.all(value.map(function (v) {
|
|
800
|
+
return _this.fileToFileLink(v.url, v.name);
|
|
801
|
+
}));
|
|
802
|
+
case 4:
|
|
803
|
+
links = _context2.sent;
|
|
804
|
+
return _context2.abrupt("return", links.join(' | '));
|
|
805
|
+
case 6:
|
|
806
|
+
return _context2.abrupt("return", this.fileToFileLink(value.url, value.name));
|
|
807
|
+
case 7:
|
|
808
|
+
case "end":
|
|
809
|
+
return _context2.stop();
|
|
810
|
+
}
|
|
811
|
+
}, _callee2, this);
|
|
812
|
+
}));
|
|
813
|
+
function customFieldsDataItemToFileLink(_x3) {
|
|
814
|
+
return _customFieldsDataItemToFileLink.apply(this, arguments);
|
|
815
|
+
}
|
|
816
|
+
return customFieldsDataItemToFileLink;
|
|
817
|
+
}()
|
|
818
|
+
}, {
|
|
819
|
+
key: "getPossibleCustomerFields",
|
|
820
|
+
value: function () {
|
|
821
|
+
var _getPossibleCustomerFields = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3() {
|
|
822
|
+
var _this$_possibleCustom;
|
|
823
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
824
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
825
|
+
case 0:
|
|
826
|
+
if (!((_this$_possibleCustom = this._possibleCustomerFields) !== null && _this$_possibleCustom !== void 0)) {
|
|
827
|
+
_context3.next = 4;
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
_context3.next = 7;
|
|
831
|
+
break;
|
|
832
|
+
case 4:
|
|
833
|
+
_context3.next = 6;
|
|
834
|
+
return startPlugin.sendTRPCMessage({
|
|
835
|
+
subdomain: this.subdomain,
|
|
836
|
+
pluginName: 'core',
|
|
837
|
+
method: 'query',
|
|
838
|
+
module: 'fields',
|
|
839
|
+
action: 'fieldsCombinedByContentType',
|
|
840
|
+
input: {
|
|
841
|
+
contentType: 'core:customer'
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
case 6:
|
|
845
|
+
this._possibleCustomerFields = _context3.sent;
|
|
846
|
+
case 7:
|
|
847
|
+
if (this._possibleCustomerFields) {
|
|
848
|
+
_context3.next = 9;
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
throw new Error('Cannot acquire possibleCustomerFields');
|
|
852
|
+
case 9:
|
|
853
|
+
return _context3.abrupt("return", this._possibleCustomerFields || []);
|
|
854
|
+
case 10:
|
|
855
|
+
case "end":
|
|
856
|
+
return _context3.stop();
|
|
857
|
+
}
|
|
858
|
+
}, _callee3, this);
|
|
859
|
+
}));
|
|
860
|
+
function getPossibleCustomerFields() {
|
|
861
|
+
return _getPossibleCustomerFields.apply(this, arguments);
|
|
862
|
+
}
|
|
863
|
+
return getPossibleCustomerFields;
|
|
864
|
+
}()
|
|
865
|
+
}, {
|
|
866
|
+
key: "getCustomerFields",
|
|
867
|
+
value: function () {
|
|
868
|
+
var _getCustomerFields = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee4(content) {
|
|
869
|
+
var customerFields, possibleCustomerFields, _iterator2, _step2, field;
|
|
870
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
871
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
872
|
+
case 0:
|
|
873
|
+
customerFields = ['firstName', 'lastName', 'middleName'];
|
|
874
|
+
_context4.next = 3;
|
|
875
|
+
return this.getPossibleCustomerFields();
|
|
876
|
+
case 3:
|
|
877
|
+
possibleCustomerFields = _context4.sent;
|
|
878
|
+
_iterator2 = startPlugin._createForOfIteratorHelper(possibleCustomerFields);
|
|
879
|
+
_context4.prev = 5;
|
|
880
|
+
_iterator2.s();
|
|
881
|
+
case 7:
|
|
882
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
883
|
+
_context4.next = 20;
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
field = _step2.value;
|
|
887
|
+
if (content.includes("{{ customer.".concat(field.name, " }}"))) {
|
|
888
|
+
_context4.next = 11;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
return _context4.abrupt("continue", 18);
|
|
892
|
+
case 11:
|
|
893
|
+
if (!field.name.includes('trackedData')) {
|
|
894
|
+
_context4.next = 14;
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
897
|
+
customerFields.push('trackedData');
|
|
898
|
+
return _context4.abrupt("continue", 18);
|
|
899
|
+
case 14:
|
|
900
|
+
if (!field.name.includes('customFieldsData')) {
|
|
901
|
+
_context4.next = 17;
|
|
902
|
+
break;
|
|
903
|
+
}
|
|
904
|
+
customerFields.push('customFieldsData');
|
|
905
|
+
return _context4.abrupt("continue", 18);
|
|
906
|
+
case 17:
|
|
907
|
+
customerFields.push(field.name);
|
|
908
|
+
case 18:
|
|
909
|
+
_context4.next = 7;
|
|
910
|
+
break;
|
|
911
|
+
case 20:
|
|
912
|
+
_context4.next = 25;
|
|
913
|
+
break;
|
|
914
|
+
case 22:
|
|
915
|
+
_context4.prev = 22;
|
|
916
|
+
_context4.t0 = _context4["catch"](5);
|
|
917
|
+
_iterator2.e(_context4.t0);
|
|
918
|
+
case 25:
|
|
919
|
+
_context4.prev = 25;
|
|
920
|
+
_iterator2.f();
|
|
921
|
+
return _context4.finish(25);
|
|
922
|
+
case 28:
|
|
923
|
+
return _context4.abrupt("return", customerFields);
|
|
924
|
+
case 29:
|
|
925
|
+
case "end":
|
|
926
|
+
return _context4.stop();
|
|
927
|
+
}
|
|
928
|
+
}, _callee4, this, [[5, 22, 25, 28]]);
|
|
929
|
+
}));
|
|
930
|
+
function getCustomerFields(_x4) {
|
|
931
|
+
return _getCustomerFields.apply(this, arguments);
|
|
932
|
+
}
|
|
933
|
+
return getCustomerFields;
|
|
934
|
+
}()
|
|
935
|
+
}, {
|
|
936
|
+
key: "fillMissingCustomFieldsDataItemOfCustomer",
|
|
937
|
+
value: function () {
|
|
938
|
+
var _fillMissingCustomFieldsDataItemOfCustomer = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee5(content, customer) {
|
|
939
|
+
var existingItemsByFieldId, possibleCustomerFields, _iterator3, _step3, field, fieldId;
|
|
940
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
941
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
942
|
+
case 0:
|
|
943
|
+
if (!customer.customFieldsData) {
|
|
944
|
+
customer.customFieldsData = [];
|
|
945
|
+
}
|
|
946
|
+
existingItemsByFieldId = _loadash.keyBy(customer.customFieldsData, 'field');
|
|
947
|
+
_context5.next = 4;
|
|
948
|
+
return this.getPossibleCustomerFields();
|
|
949
|
+
case 4:
|
|
950
|
+
possibleCustomerFields = _context5.sent;
|
|
951
|
+
_iterator3 = startPlugin._createForOfIteratorHelper(possibleCustomerFields);
|
|
952
|
+
_context5.prev = 6;
|
|
953
|
+
_iterator3.s();
|
|
954
|
+
case 8:
|
|
955
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
956
|
+
_context5.next = 15;
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
field = _step3.value;
|
|
960
|
+
if (content.includes("{{ customer.".concat(field.name, " }}"))) {
|
|
961
|
+
_context5.next = 12;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
return _context5.abrupt("continue", 13);
|
|
965
|
+
case 12:
|
|
966
|
+
if (field.name.includes('customFieldsData')) {
|
|
967
|
+
fieldId = field.name.split('.').pop(); // if content has attribute that doesn't have fieldId, fill with dummy item
|
|
968
|
+
// if content has field attribute that doesn't exist on the customer.customFieldsData, fill with dummy item
|
|
969
|
+
if (!fieldId || !existingItemsByFieldId[fieldId]) {
|
|
970
|
+
customer.customFieldsData.push({
|
|
971
|
+
field: fieldId || '',
|
|
972
|
+
stringValue: '',
|
|
973
|
+
value: ''
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
case 13:
|
|
978
|
+
_context5.next = 8;
|
|
979
|
+
break;
|
|
980
|
+
case 15:
|
|
981
|
+
_context5.next = 20;
|
|
982
|
+
break;
|
|
983
|
+
case 17:
|
|
984
|
+
_context5.prev = 17;
|
|
985
|
+
_context5.t0 = _context5["catch"](6);
|
|
986
|
+
_iterator3.e(_context5.t0);
|
|
987
|
+
case 20:
|
|
988
|
+
_context5.prev = 20;
|
|
989
|
+
_iterator3.f();
|
|
990
|
+
return _context5.finish(20);
|
|
991
|
+
case 23:
|
|
992
|
+
case "end":
|
|
993
|
+
return _context5.stop();
|
|
994
|
+
}
|
|
995
|
+
}, _callee5, this, [[6, 17, 20, 23]]);
|
|
996
|
+
}));
|
|
997
|
+
function fillMissingCustomFieldsDataItemOfCustomer(_x5, _x6) {
|
|
998
|
+
return _fillMissingCustomFieldsDataItemOfCustomer.apply(this, arguments);
|
|
999
|
+
}
|
|
1000
|
+
return fillMissingCustomFieldsDataItemOfCustomer;
|
|
1001
|
+
}()
|
|
1002
|
+
}, {
|
|
1003
|
+
key: "generateAmounts",
|
|
1004
|
+
value: function () {
|
|
1005
|
+
var _generateAmounts = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee6(productsData) {
|
|
1006
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1007
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1008
|
+
case 0:
|
|
1009
|
+
if (this.availableServices.has('sales')) {
|
|
1010
|
+
_context6.next = 2;
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
throw new Error('Sales service is not running.');
|
|
1014
|
+
case 2:
|
|
1015
|
+
return _context6.abrupt("return", startPlugin.sendTRPCMessage({
|
|
1016
|
+
subdomain: this.subdomain,
|
|
1017
|
+
pluginName: 'sales',
|
|
1018
|
+
method: 'query',
|
|
1019
|
+
module: 'deal',
|
|
1020
|
+
action: 'generateAmounts',
|
|
1021
|
+
input: productsData
|
|
1022
|
+
}));
|
|
1023
|
+
case 3:
|
|
1024
|
+
case "end":
|
|
1025
|
+
return _context6.stop();
|
|
1026
|
+
}
|
|
1027
|
+
}, _callee6, this);
|
|
1028
|
+
}));
|
|
1029
|
+
function generateAmounts(_x7) {
|
|
1030
|
+
return _generateAmounts.apply(this, arguments);
|
|
1031
|
+
}
|
|
1032
|
+
return generateAmounts;
|
|
1033
|
+
}()
|
|
1034
|
+
}, {
|
|
1035
|
+
key: "generateProducts",
|
|
1036
|
+
value: function () {
|
|
1037
|
+
var _generateProducts = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee7(productsData) {
|
|
1038
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1039
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1040
|
+
case 0:
|
|
1041
|
+
if (this.availableServices.has('sales')) {
|
|
1042
|
+
_context7.next = 2;
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1045
|
+
throw new Error('Sales service is not running.');
|
|
1046
|
+
case 2:
|
|
1047
|
+
return _context7.abrupt("return", startPlugin.sendTRPCMessage({
|
|
1048
|
+
subdomain: this.subdomain,
|
|
1049
|
+
pluginName: 'sales',
|
|
1050
|
+
method: 'query',
|
|
1051
|
+
module: 'deal',
|
|
1052
|
+
action: 'generateProducts',
|
|
1053
|
+
input: productsData
|
|
1054
|
+
}));
|
|
1055
|
+
case 3:
|
|
1056
|
+
case "end":
|
|
1057
|
+
return _context7.stop();
|
|
1058
|
+
}
|
|
1059
|
+
}, _callee7, this);
|
|
1060
|
+
}));
|
|
1061
|
+
function generateProducts(_x8) {
|
|
1062
|
+
return _generateProducts.apply(this, arguments);
|
|
1063
|
+
}
|
|
1064
|
+
return generateProducts;
|
|
1065
|
+
}()
|
|
1066
|
+
}, {
|
|
1067
|
+
key: "generateReplacers",
|
|
1068
|
+
value: function () {
|
|
1069
|
+
var _generateReplacers = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee8(args) {
|
|
1070
|
+
var _this2 = this;
|
|
1071
|
+
var content, user, brand, item, replacers, customer, customerFields, fields, customerFileFieldsById, _iterator4, _step4, field, dbFieldName, _iterator5, _step5, customFieldsDataItem, replaceValue, products, amounts, fieldMetaDatas, _iterator6, _step6, _loop;
|
|
1072
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee8$(_context9) {
|
|
1073
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1074
|
+
case 0:
|
|
1075
|
+
content = args.content, user = args.user, brand = args.brand, item = args.item;
|
|
1076
|
+
replacers = []; // replace customer fields
|
|
1077
|
+
if (!args.customer) {
|
|
1078
|
+
_context9.next = 59;
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
customer = args.customer;
|
|
1082
|
+
customerFields = args.customerFields;
|
|
1083
|
+
if (!(!customerFields || customerFields.length === 0)) {
|
|
1084
|
+
_context9.next = 9;
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
_context9.next = 8;
|
|
1088
|
+
return this.getCustomerFields(content);
|
|
1089
|
+
case 8:
|
|
1090
|
+
customerFields = _context9.sent;
|
|
1091
|
+
case 9:
|
|
1092
|
+
_context9.next = 11;
|
|
1093
|
+
return this.fillMissingCustomFieldsDataItemOfCustomer(content, customer);
|
|
1094
|
+
case 11:
|
|
1095
|
+
replacers.push({
|
|
1096
|
+
key: '{{ customer.name }}',
|
|
1097
|
+
value: getCustomerName(customer) || 'Unknown'
|
|
1098
|
+
});
|
|
1099
|
+
_context9.next = 14;
|
|
1100
|
+
return startPlugin.sendTRPCMessage({
|
|
1101
|
+
subdomain: this.subdomain,
|
|
1102
|
+
pluginName: 'core',
|
|
1103
|
+
method: 'query',
|
|
1104
|
+
module: 'fields',
|
|
1105
|
+
action: 'find',
|
|
1106
|
+
input: {
|
|
1107
|
+
query: {
|
|
1108
|
+
type: 'file',
|
|
1109
|
+
contentType: 'core:customer'
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
case 14:
|
|
1114
|
+
fields = _context9.sent;
|
|
1115
|
+
customerFileFieldsById = _loadash.keyBy(fields, '_id');
|
|
1116
|
+
_iterator4 = startPlugin._createForOfIteratorHelper(customerFields);
|
|
1117
|
+
_context9.prev = 17;
|
|
1118
|
+
_iterator4.s();
|
|
1119
|
+
case 19:
|
|
1120
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
1121
|
+
_context9.next = 51;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
field = _step4.value;
|
|
1125
|
+
if (!(field.includes('trackedData') || field.includes('customFieldsData'))) {
|
|
1126
|
+
_context9.next = 48;
|
|
1127
|
+
break;
|
|
1128
|
+
}
|
|
1129
|
+
dbFieldName = field.includes('trackedData') ? 'trackedData' : 'customFieldsData';
|
|
1130
|
+
_iterator5 = startPlugin._createForOfIteratorHelper(customer[dbFieldName] || []);
|
|
1131
|
+
_context9.prev = 24;
|
|
1132
|
+
_iterator5.s();
|
|
1133
|
+
case 26:
|
|
1134
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
1135
|
+
_context9.next = 39;
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
customFieldsDataItem = _step5.value;
|
|
1139
|
+
if (!customerFileFieldsById[customFieldsDataItem.field]) {
|
|
1140
|
+
_context9.next = 34;
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
_context9.next = 31;
|
|
1144
|
+
return this.customFieldsDataItemToFileLink(customFieldsDataItem);
|
|
1145
|
+
case 31:
|
|
1146
|
+
_context9.t0 = _context9.sent;
|
|
1147
|
+
_context9.next = 35;
|
|
1148
|
+
break;
|
|
1149
|
+
case 34:
|
|
1150
|
+
_context9.t0 = customFieldsDataItem.stringValue || customFieldsDataItem.value || '';
|
|
1151
|
+
case 35:
|
|
1152
|
+
replaceValue = _context9.t0;
|
|
1153
|
+
replacers.push({
|
|
1154
|
+
key: "{{ customer.".concat(dbFieldName, ".").concat(customFieldsDataItem.field, " }}"),
|
|
1155
|
+
value: replaceValue
|
|
1156
|
+
});
|
|
1157
|
+
case 37:
|
|
1158
|
+
_context9.next = 26;
|
|
1159
|
+
break;
|
|
1160
|
+
case 39:
|
|
1161
|
+
_context9.next = 44;
|
|
1162
|
+
break;
|
|
1163
|
+
case 41:
|
|
1164
|
+
_context9.prev = 41;
|
|
1165
|
+
_context9.t1 = _context9["catch"](24);
|
|
1166
|
+
_iterator5.e(_context9.t1);
|
|
1167
|
+
case 44:
|
|
1168
|
+
_context9.prev = 44;
|
|
1169
|
+
_iterator5.f();
|
|
1170
|
+
return _context9.finish(44);
|
|
1171
|
+
case 47:
|
|
1172
|
+
return _context9.abrupt("continue", 49);
|
|
1173
|
+
case 48:
|
|
1174
|
+
replacers.push({
|
|
1175
|
+
key: "{{ customer.".concat(field, " }}"),
|
|
1176
|
+
value: customer[field] || ''
|
|
1177
|
+
});
|
|
1178
|
+
case 49:
|
|
1179
|
+
_context9.next = 19;
|
|
1180
|
+
break;
|
|
1181
|
+
case 51:
|
|
1182
|
+
_context9.next = 56;
|
|
1183
|
+
break;
|
|
1184
|
+
case 53:
|
|
1185
|
+
_context9.prev = 53;
|
|
1186
|
+
_context9.t2 = _context9["catch"](17);
|
|
1187
|
+
_iterator4.e(_context9.t2);
|
|
1188
|
+
case 56:
|
|
1189
|
+
_context9.prev = 56;
|
|
1190
|
+
_iterator4.f();
|
|
1191
|
+
return _context9.finish(56);
|
|
1192
|
+
case 59:
|
|
1193
|
+
// replace user fields
|
|
1194
|
+
if (user) {
|
|
1195
|
+
replacers.push({
|
|
1196
|
+
key: '{{ user.email }}',
|
|
1197
|
+
value: user.email || ''
|
|
1198
|
+
});
|
|
1199
|
+
if (user.details) {
|
|
1200
|
+
replacers.push({
|
|
1201
|
+
key: '{{ user.fullName }}',
|
|
1202
|
+
value: user.details.fullName || ''
|
|
1203
|
+
}, {
|
|
1204
|
+
key: '{{ user.position }}',
|
|
1205
|
+
value: user.details.position || ''
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// replace brand fields
|
|
1211
|
+
if (brand) {
|
|
1212
|
+
replacers.push({
|
|
1213
|
+
key: '{{ brandName }}',
|
|
1214
|
+
value: brand.name || ''
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// deal, ticket, task mapping
|
|
1219
|
+
if (!item) {
|
|
1220
|
+
_context9.next = 91;
|
|
1221
|
+
break;
|
|
1222
|
+
}
|
|
1223
|
+
replacers.push({
|
|
1224
|
+
key: '{{ itemName }}',
|
|
1225
|
+
value: item.name || ''
|
|
1226
|
+
}, {
|
|
1227
|
+
key: '{{ itemDescription }}',
|
|
1228
|
+
value: item.description || ''
|
|
1229
|
+
}, {
|
|
1230
|
+
key: '{{ itemCloseDate }}',
|
|
1231
|
+
value: item.closeDate ? new Date(item.closeDate).toLocaleDateString() : ''
|
|
1232
|
+
}, {
|
|
1233
|
+
key: '{{ itemCreatedAt }}',
|
|
1234
|
+
value: item.createdAt ? new Date(item.createdAt).toLocaleDateString() : ''
|
|
1235
|
+
}, {
|
|
1236
|
+
key: '{{ itemModifiedAt }}',
|
|
1237
|
+
value: item.modifiedAt ? new Date(item.modifiedAt).toLocaleDateString() : ''
|
|
1238
|
+
});
|
|
1239
|
+
_context9.next = 65;
|
|
1240
|
+
return this.generateProducts(item.productsData);
|
|
1241
|
+
case 65:
|
|
1242
|
+
products = _context9.sent;
|
|
1243
|
+
_context9.next = 68;
|
|
1244
|
+
return this.generateAmounts(item.productsData);
|
|
1245
|
+
case 68:
|
|
1246
|
+
amounts = _context9.sent;
|
|
1247
|
+
replacers.push({
|
|
1248
|
+
key: '{{ dealProducts }}',
|
|
1249
|
+
value: products.map(function (p) {
|
|
1250
|
+
return p.product.name;
|
|
1251
|
+
}).join(',')
|
|
1252
|
+
}, {
|
|
1253
|
+
key: '{{ dealAmounts }}',
|
|
1254
|
+
value: Object.keys(amounts).map(function (key) {
|
|
1255
|
+
return "".concat(amounts[key]).concat(key);
|
|
1256
|
+
}).join(',')
|
|
1257
|
+
});
|
|
1258
|
+
_context9.next = 72;
|
|
1259
|
+
return startPlugin.sendTRPCMessage({
|
|
1260
|
+
subdomain: this.subdomain,
|
|
1261
|
+
pluginName: 'core',
|
|
1262
|
+
method: 'query',
|
|
1263
|
+
module: 'fields',
|
|
1264
|
+
action: 'find',
|
|
1265
|
+
input: {
|
|
1266
|
+
query: {
|
|
1267
|
+
contentType: item.contentType,
|
|
1268
|
+
isDefinedByErxes: false
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
case 72:
|
|
1273
|
+
fieldMetaDatas = _context9.sent;
|
|
1274
|
+
_iterator6 = startPlugin._createForOfIteratorHelper(fieldMetaDatas);
|
|
1275
|
+
_context9.prev = 74;
|
|
1276
|
+
_loop = /*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _loop() {
|
|
1277
|
+
var fieldMetaData, customFieldsData, customFieldsDataItem, key, replaceValue;
|
|
1278
|
+
return startPlugin._regeneratorRuntime().wrap(function _loop$(_context8) {
|
|
1279
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1280
|
+
case 0:
|
|
1281
|
+
fieldMetaData = _step6.value;
|
|
1282
|
+
customFieldsData = item.customFieldsData || [];
|
|
1283
|
+
customFieldsDataItem = customFieldsData.find(function (c) {
|
|
1284
|
+
return c.field === fieldMetaData._id;
|
|
1285
|
+
});
|
|
1286
|
+
key = "{{ itemCustomField.".concat(fieldMetaData._id, " }}");
|
|
1287
|
+
if (customFieldsDataItem) {
|
|
1288
|
+
_context8.next = 7;
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
if (content.includes(key)) {
|
|
1292
|
+
replacers.push({
|
|
1293
|
+
key: key,
|
|
1294
|
+
value: ''
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
return _context8.abrupt("return", 1);
|
|
1298
|
+
case 7:
|
|
1299
|
+
if (!(fieldMetaData.type === 'file')) {
|
|
1300
|
+
_context8.next = 13;
|
|
1301
|
+
break;
|
|
1302
|
+
}
|
|
1303
|
+
_context8.next = 10;
|
|
1304
|
+
return _this2.customFieldsDataItemToFileLink(customFieldsDataItem);
|
|
1305
|
+
case 10:
|
|
1306
|
+
_context8.t0 = _context8.sent;
|
|
1307
|
+
_context8.next = 14;
|
|
1308
|
+
break;
|
|
1309
|
+
case 13:
|
|
1310
|
+
_context8.t0 = customFieldsDataItem.stringValue || customFieldsDataItem.value || '';
|
|
1311
|
+
case 14:
|
|
1312
|
+
replaceValue = _context8.t0;
|
|
1313
|
+
replacers.push({
|
|
1314
|
+
key: key,
|
|
1315
|
+
value: replaceValue
|
|
1316
|
+
});
|
|
1317
|
+
case 16:
|
|
1318
|
+
case "end":
|
|
1319
|
+
return _context8.stop();
|
|
1320
|
+
}
|
|
1321
|
+
}, _loop);
|
|
1322
|
+
});
|
|
1323
|
+
_iterator6.s();
|
|
1324
|
+
case 77:
|
|
1325
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
1326
|
+
_context9.next = 83;
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
return _context9.delegateYield(_loop(), "t3", 79);
|
|
1330
|
+
case 79:
|
|
1331
|
+
if (!_context9.t3) {
|
|
1332
|
+
_context9.next = 81;
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
return _context9.abrupt("continue", 81);
|
|
1336
|
+
case 81:
|
|
1337
|
+
_context9.next = 77;
|
|
1338
|
+
break;
|
|
1339
|
+
case 83:
|
|
1340
|
+
_context9.next = 88;
|
|
1341
|
+
break;
|
|
1342
|
+
case 85:
|
|
1343
|
+
_context9.prev = 85;
|
|
1344
|
+
_context9.t4 = _context9["catch"](74);
|
|
1345
|
+
_iterator6.e(_context9.t4);
|
|
1346
|
+
case 88:
|
|
1347
|
+
_context9.prev = 88;
|
|
1348
|
+
_iterator6.f();
|
|
1349
|
+
return _context9.finish(88);
|
|
1350
|
+
case 91:
|
|
1351
|
+
return _context9.abrupt("return", replacers);
|
|
1352
|
+
case 92:
|
|
1353
|
+
case "end":
|
|
1354
|
+
return _context9.stop();
|
|
1355
|
+
}
|
|
1356
|
+
}, _callee8, this, [[17, 53, 56, 59], [24, 41, 44, 47], [74, 85, 88, 91]]);
|
|
1357
|
+
}));
|
|
1358
|
+
function generateReplacers(_x9) {
|
|
1359
|
+
return _generateReplacers.apply(this, arguments);
|
|
1360
|
+
}
|
|
1361
|
+
return generateReplacers;
|
|
1362
|
+
}()
|
|
1363
|
+
}, {
|
|
1364
|
+
key: "replaceAttributes",
|
|
1365
|
+
value: function () {
|
|
1366
|
+
var _replaceAttributes = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee9(args) {
|
|
1367
|
+
var replacers, replacedContent;
|
|
1368
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee9$(_context0) {
|
|
1369
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
1370
|
+
case 0:
|
|
1371
|
+
_context0.next = 2;
|
|
1372
|
+
return this.generateReplacers(args);
|
|
1373
|
+
case 2:
|
|
1374
|
+
replacers = _context0.sent;
|
|
1375
|
+
replacedContent = runReplacersOn(args.content, replacers);
|
|
1376
|
+
return _context0.abrupt("return", replacedContent);
|
|
1377
|
+
case 5:
|
|
1378
|
+
case "end":
|
|
1379
|
+
return _context0.stop();
|
|
1380
|
+
}
|
|
1381
|
+
}, _callee9, this);
|
|
1382
|
+
}));
|
|
1383
|
+
function replaceAttributes(_x0) {
|
|
1384
|
+
return _replaceAttributes.apply(this, arguments);
|
|
1385
|
+
}
|
|
1386
|
+
return replaceAttributes;
|
|
1387
|
+
}()
|
|
1388
|
+
}]);
|
|
1389
|
+
}();
|
|
1390
|
+
|
|
1391
|
+
var normalizeEmail = function normalizeEmail(email) {
|
|
1392
|
+
return email.trim().toLowerCase();
|
|
1393
|
+
};
|
|
1394
|
+
var parseAddress = function parseAddress(value) {
|
|
1395
|
+
var match = /^\s*(.*?)\s*<([^>]+)>\s*$/.exec(value || '');
|
|
1396
|
+
return match ? {
|
|
1397
|
+
name: match[1].replace(/^"|"$/g, ''),
|
|
1398
|
+
address: match[2].trim()
|
|
1399
|
+
} : {
|
|
1400
|
+
name: '',
|
|
1401
|
+
address: (value || '').trim()
|
|
1402
|
+
};
|
|
1403
|
+
};
|
|
1404
|
+
var SPECIALS = /[()<>@,;:\\".[\]]/;
|
|
1405
|
+
var quoteName = function quoteName(name) {
|
|
1406
|
+
var clean = name.replace(/[\r\n]/g, ' ').trim();
|
|
1407
|
+
if (!clean) {
|
|
1408
|
+
return '';
|
|
1409
|
+
}
|
|
1410
|
+
return SPECIALS.test(clean) ? "\"".concat(clean.replace(/(["\\])/g, '\\$1'), "\"") : clean;
|
|
1411
|
+
};
|
|
1412
|
+
var alignSender = function alignSender(requested, replyTo, alignedFrom) {
|
|
1413
|
+
var reply = (replyTo === null || replyTo === void 0 ? void 0 : replyTo.trim()) || undefined;
|
|
1414
|
+
if (!alignedFrom) {
|
|
1415
|
+
return {
|
|
1416
|
+
from: requested,
|
|
1417
|
+
replyTo: reply
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
var _parseAddress = parseAddress(requested),
|
|
1421
|
+
name = _parseAddress.name,
|
|
1422
|
+
address = _parseAddress.address;
|
|
1423
|
+
return {
|
|
1424
|
+
from: "".concat(quoteName(name) || address, " <").concat(alignedFrom, ">"),
|
|
1425
|
+
replyTo: reply || (address === alignedFrom ? undefined : address)
|
|
1426
|
+
};
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
var DOWNLOAD_TIMEOUT_MS = 15000;
|
|
1430
|
+
var MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
|
|
1431
|
+
var toBase64Attachment = /*#__PURE__*/function () {
|
|
1432
|
+
var _ref = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(attachment) {
|
|
1433
|
+
var controller, timer, response, declaredSize, buffer;
|
|
1434
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1435
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1436
|
+
case 0:
|
|
1437
|
+
if (!attachment.content) {
|
|
1438
|
+
_context.next = 2;
|
|
1439
|
+
break;
|
|
1440
|
+
}
|
|
1441
|
+
return _context.abrupt("return", {
|
|
1442
|
+
filename: attachment.filename,
|
|
1443
|
+
content: attachment.content,
|
|
1444
|
+
type: attachment.contentType
|
|
1445
|
+
});
|
|
1446
|
+
case 2:
|
|
1447
|
+
if (attachment.path) {
|
|
1448
|
+
_context.next = 4;
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
throw new Error("Attachment \"".concat(attachment.filename, "\" has neither \"content\" nor \"path\""));
|
|
1452
|
+
case 4:
|
|
1453
|
+
controller = new AbortController();
|
|
1454
|
+
timer = setTimeout(function () {
|
|
1455
|
+
return controller.abort();
|
|
1456
|
+
}, DOWNLOAD_TIMEOUT_MS);
|
|
1457
|
+
_context.prev = 6;
|
|
1458
|
+
_context.next = 9;
|
|
1459
|
+
return fetch__default["default"](attachment.path, {
|
|
1460
|
+
signal: controller.signal
|
|
1461
|
+
});
|
|
1462
|
+
case 9:
|
|
1463
|
+
response = _context.sent;
|
|
1464
|
+
case 10:
|
|
1465
|
+
_context.prev = 10;
|
|
1466
|
+
clearTimeout(timer);
|
|
1467
|
+
return _context.finish(10);
|
|
1468
|
+
case 13:
|
|
1469
|
+
if (response.ok) {
|
|
1470
|
+
_context.next = 15;
|
|
1471
|
+
break;
|
|
1472
|
+
}
|
|
1473
|
+
throw new Error("Failed to download attachment \"".concat(attachment.filename, "\" from ").concat(attachment.path, ": ").concat(response.status));
|
|
1474
|
+
case 15:
|
|
1475
|
+
declaredSize = Number(response.headers.get('content-length'));
|
|
1476
|
+
if (!(declaredSize && declaredSize > MAX_ATTACHMENT_BYTES)) {
|
|
1477
|
+
_context.next = 18;
|
|
1478
|
+
break;
|
|
1479
|
+
}
|
|
1480
|
+
throw new Error("Attachment \"".concat(attachment.filename, "\" exceeds the ").concat(MAX_ATTACHMENT_BYTES / (1024 * 1024), "MB limit"));
|
|
1481
|
+
case 18:
|
|
1482
|
+
_context.next = 20;
|
|
1483
|
+
return response.buffer();
|
|
1484
|
+
case 20:
|
|
1485
|
+
buffer = _context.sent;
|
|
1486
|
+
if (!(buffer.byteLength > MAX_ATTACHMENT_BYTES)) {
|
|
1487
|
+
_context.next = 23;
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
throw new Error("Attachment \"".concat(attachment.filename, "\" exceeds the ").concat(MAX_ATTACHMENT_BYTES / (1024 * 1024), "MB limit"));
|
|
1491
|
+
case 23:
|
|
1492
|
+
return _context.abrupt("return", {
|
|
1493
|
+
filename: attachment.filename,
|
|
1494
|
+
content: buffer.toString('base64'),
|
|
1495
|
+
type: attachment.contentType || response.headers.get('content-type') || undefined
|
|
1496
|
+
});
|
|
1497
|
+
case 24:
|
|
1498
|
+
case "end":
|
|
1499
|
+
return _context.stop();
|
|
1500
|
+
}
|
|
1501
|
+
}, _callee, null, [[6,, 10, 13]]);
|
|
1502
|
+
}));
|
|
1503
|
+
return function toBase64Attachment(_x) {
|
|
1504
|
+
return _ref.apply(this, arguments);
|
|
1505
|
+
};
|
|
1506
|
+
}();
|
|
1507
|
+
var toBase64Attachments = /*#__PURE__*/function () {
|
|
1508
|
+
var _ref2 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2() {
|
|
1509
|
+
var attachments,
|
|
1510
|
+
_args2 = arguments;
|
|
1511
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1512
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1513
|
+
case 0:
|
|
1514
|
+
attachments = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : [];
|
|
1515
|
+
return _context2.abrupt("return", Promise.all(attachments.map(toBase64Attachment)));
|
|
1516
|
+
case 2:
|
|
1517
|
+
case "end":
|
|
1518
|
+
return _context2.stop();
|
|
1519
|
+
}
|
|
1520
|
+
}, _callee2);
|
|
1521
|
+
}));
|
|
1522
|
+
return function toBase64Attachments() {
|
|
1523
|
+
return _ref2.apply(this, arguments);
|
|
1524
|
+
};
|
|
1525
|
+
}();
|
|
1526
|
+
|
|
1527
|
+
var EMAIL_PROVIDER_CONFIG_CODES = ['DEFAULT_EMAIL_SERVICE', 'AWS_SES_ACCESS_KEY_ID', 'AWS_SES_SECRET_ACCESS_KEY', 'AWS_REGION', 'AWS_SES_CONFIG_SET', 'SENDGRID_API_KEY', 'SENDGRID_SUBUSER', 'MAIL_SERVICE', 'MAIL_HOST', 'MAIL_PORT', 'MAIL_USER', 'MAIL_PASS'];
|
|
1528
|
+
var DEFAULT_EMAIL_PROVIDER = 'SES';
|
|
1529
|
+
var SENDGRID_API_BASE_URL = 'https://api.sendgrid.com/v3';
|
|
1530
|
+
var SES_DKIM_CNAME_SUFFIX = 'dkim.amazonses.com';
|
|
1531
|
+
|
|
1532
|
+
var loadEmailProviderConfig = /*#__PURE__*/function () {
|
|
1533
|
+
var _ref = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(read) {
|
|
1534
|
+
var values;
|
|
1535
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1536
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1537
|
+
case 0:
|
|
1538
|
+
_context.next = 2;
|
|
1539
|
+
return Promise.all(EMAIL_PROVIDER_CONFIG_CODES.map(function (code) {
|
|
1540
|
+
return read(code, '');
|
|
1541
|
+
}));
|
|
1542
|
+
case 2:
|
|
1543
|
+
values = _context.sent;
|
|
1544
|
+
return _context.abrupt("return", EMAIL_PROVIDER_CONFIG_CODES.reduce(function (config, code, index) {
|
|
1545
|
+
var value = values[index];
|
|
1546
|
+
if (value) {
|
|
1547
|
+
config[code] = value;
|
|
1548
|
+
}
|
|
1549
|
+
return config;
|
|
1550
|
+
}, {}));
|
|
1551
|
+
case 4:
|
|
1552
|
+
case "end":
|
|
1553
|
+
return _context.stop();
|
|
1554
|
+
}
|
|
1555
|
+
}, _callee);
|
|
1556
|
+
}));
|
|
1557
|
+
return function loadEmailProviderConfig(_x) {
|
|
1558
|
+
return _ref.apply(this, arguments);
|
|
1559
|
+
};
|
|
1560
|
+
}();
|
|
1561
|
+
var resolveDefaultSenderEmail = function resolveDefaultSenderEmail(_ref2) {
|
|
1562
|
+
var isSaas = _ref2.isSaas,
|
|
1563
|
+
companyEmailFrom = _ref2.companyEmailFrom,
|
|
1564
|
+
fallbackEmail = _ref2.fallbackEmail;
|
|
1565
|
+
return (isSaas ? fallbackEmail : companyEmailFrom || fallbackEmail) || '';
|
|
1566
|
+
};
|
|
1567
|
+
var getEmailProviderConfigFingerprint = function getEmailProviderConfigFingerprint(config) {
|
|
1568
|
+
return EMAIL_PROVIDER_CONFIG_CODES.map(function (code) {
|
|
1569
|
+
var _config$code;
|
|
1570
|
+
return "".concat(code, "=").concat((_config$code = config[code]) !== null && _config$code !== void 0 ? _config$code : '');
|
|
1571
|
+
}).join('|');
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
var EmailProviderNotSupportedError = /*#__PURE__*/function (_Error) {
|
|
1575
|
+
function EmailProviderNotSupportedError(provider, operation) {
|
|
1576
|
+
var _this;
|
|
1577
|
+
startPlugin._classCallCheck(this, EmailProviderNotSupportedError);
|
|
1578
|
+
_this = startPlugin._callSuper(this, EmailProviderNotSupportedError, ["\"".concat(operation, "\" is not supported by the \"").concat(provider, "\" email provider")]);
|
|
1579
|
+
_this.name = 'EmailProviderNotSupportedError';
|
|
1580
|
+
return _this;
|
|
1581
|
+
}
|
|
1582
|
+
startPlugin._inherits(EmailProviderNotSupportedError, _Error);
|
|
1583
|
+
return startPlugin._createClass(EmailProviderNotSupportedError);
|
|
1584
|
+
}(/*#__PURE__*/startPlugin._wrapNativeSuper(Error));
|
|
1585
|
+
var EmailProviderConfigError = /*#__PURE__*/function (_Error2) {
|
|
1586
|
+
function EmailProviderConfigError(provider, missing) {
|
|
1587
|
+
var _this2;
|
|
1588
|
+
startPlugin._classCallCheck(this, EmailProviderConfigError);
|
|
1589
|
+
_this2 = startPlugin._callSuper(this, EmailProviderConfigError, ["\"".concat(provider, "\" email provider is missing configuration: ").concat(missing.join(', '))]);
|
|
1590
|
+
_this2.name = 'EmailProviderConfigError';
|
|
1591
|
+
return _this2;
|
|
1592
|
+
}
|
|
1593
|
+
startPlugin._inherits(EmailProviderConfigError, _Error2);
|
|
1594
|
+
return startPlugin._createClass(EmailProviderConfigError);
|
|
1595
|
+
}(/*#__PURE__*/startPlugin._wrapNativeSuper(Error));
|
|
1596
|
+
var EmailProviderRequestError = /*#__PURE__*/function (_Error3) {
|
|
1597
|
+
function EmailProviderRequestError(provider, status, body) {
|
|
1598
|
+
var _this3;
|
|
1599
|
+
startPlugin._classCallCheck(this, EmailProviderRequestError);
|
|
1600
|
+
_this3 = startPlugin._callSuper(this, EmailProviderRequestError, ["\"".concat(provider, "\" API request failed with status ").concat(status, ": ").concat(body)]);
|
|
1601
|
+
_this3.name = 'EmailProviderRequestError';
|
|
1602
|
+
_this3.status = status;
|
|
1603
|
+
_this3.body = body;
|
|
1604
|
+
return _this3;
|
|
1605
|
+
}
|
|
1606
|
+
startPlugin._inherits(EmailProviderRequestError, _Error3);
|
|
1607
|
+
return startPlugin._createClass(EmailProviderRequestError);
|
|
1608
|
+
}(/*#__PURE__*/startPlugin._wrapNativeSuper(Error));
|
|
1609
|
+
|
|
1610
|
+
var REQUEST_TIMEOUT_MS = 15000;
|
|
1611
|
+
var toDnsRecords = function toDnsRecords(dns) {
|
|
1612
|
+
return Object.values(dns || {}).map(function (entry) {
|
|
1613
|
+
return {
|
|
1614
|
+
type: entry.type.toUpperCase(),
|
|
1615
|
+
host: entry.host,
|
|
1616
|
+
data: entry.data,
|
|
1617
|
+
valid: entry.valid
|
|
1618
|
+
};
|
|
1619
|
+
});
|
|
1620
|
+
};
|
|
1621
|
+
var toSingleSender = function toSingleSender(sender) {
|
|
1622
|
+
return {
|
|
1623
|
+
id: String(sender.id),
|
|
1624
|
+
type: 'single',
|
|
1625
|
+
value: sender.from_email,
|
|
1626
|
+
name: sender.from_name || sender.nickname,
|
|
1627
|
+
status: sender.verified ? 'verified' : 'pending'
|
|
1628
|
+
};
|
|
1629
|
+
};
|
|
1630
|
+
var toDomainSender = function toDomainSender(domain) {
|
|
1631
|
+
return {
|
|
1632
|
+
id: String(domain.id),
|
|
1633
|
+
type: 'domain',
|
|
1634
|
+
value: domain.domain,
|
|
1635
|
+
status: domain.valid ? 'verified' : 'pending',
|
|
1636
|
+
dnsRecords: toDnsRecords(domain.dns)
|
|
1637
|
+
};
|
|
1638
|
+
};
|
|
1639
|
+
var toSendError = function toSendError(error) {
|
|
1640
|
+
var response = error === null || error === void 0 ? void 0 : error.response;
|
|
1641
|
+
if (!response) {
|
|
1642
|
+
return error;
|
|
1643
|
+
}
|
|
1644
|
+
return new EmailProviderRequestError('sendgrid', response.statusCode || 0, typeof response.body === 'string' ? response.body : JSON.stringify(response.body));
|
|
1645
|
+
};
|
|
1646
|
+
var SendgridEmailProvider = /*#__PURE__*/function () {
|
|
1647
|
+
function SendgridEmailProvider(config) {
|
|
1648
|
+
startPlugin._classCallCheck(this, SendgridEmailProvider);
|
|
1649
|
+
startPlugin._defineProperty(this, "name", 'sendgrid');
|
|
1650
|
+
if (!config.SENDGRID_API_KEY) {
|
|
1651
|
+
throw new EmailProviderConfigError('sendgrid', ['SENDGRID_API_KEY']);
|
|
1652
|
+
}
|
|
1653
|
+
this.apiKey = config.SENDGRID_API_KEY;
|
|
1654
|
+
this.subuser = config.SENDGRID_SUBUSER;
|
|
1655
|
+
var _require = require('@sendgrid/mail'),
|
|
1656
|
+
MailService = _require.MailService;
|
|
1657
|
+
var mailer = new MailService();
|
|
1658
|
+
mailer.setApiKey(this.apiKey);
|
|
1659
|
+
this.mailer = mailer;
|
|
1660
|
+
}
|
|
1661
|
+
return startPlugin._createClass(SendgridEmailProvider, [{
|
|
1662
|
+
key: "send",
|
|
1663
|
+
value: function () {
|
|
1664
|
+
var _send = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(message) {
|
|
1665
|
+
var _message$attachments, _message$cc, _message$bcc, _response, _response2;
|
|
1666
|
+
var attachments, payload, response, _yield$this$mailer$se, _yield$this$mailer$se2, messageId;
|
|
1667
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1668
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1669
|
+
case 0:
|
|
1670
|
+
if (!((_message$attachments = message.attachments) !== null && _message$attachments !== void 0 && _message$attachments.length)) {
|
|
1671
|
+
_context.next = 6;
|
|
1672
|
+
break;
|
|
1673
|
+
}
|
|
1674
|
+
_context.next = 3;
|
|
1675
|
+
return toBase64Attachments(message.attachments);
|
|
1676
|
+
case 3:
|
|
1677
|
+
_context.t0 = _context.sent;
|
|
1678
|
+
_context.next = 7;
|
|
1679
|
+
break;
|
|
1680
|
+
case 6:
|
|
1681
|
+
_context.t0 = undefined;
|
|
1682
|
+
case 7:
|
|
1683
|
+
attachments = _context.t0;
|
|
1684
|
+
payload = {
|
|
1685
|
+
from: message.from,
|
|
1686
|
+
to: message.to,
|
|
1687
|
+
cc: (_message$cc = message.cc) !== null && _message$cc !== void 0 && _message$cc.length ? message.cc : undefined,
|
|
1688
|
+
bcc: (_message$bcc = message.bcc) !== null && _message$bcc !== void 0 && _message$bcc.length ? message.bcc : undefined,
|
|
1689
|
+
replyTo: message.replyTo,
|
|
1690
|
+
subject: message.subject,
|
|
1691
|
+
html: message.html,
|
|
1692
|
+
text: message.text,
|
|
1693
|
+
attachments: attachments,
|
|
1694
|
+
headers: message.headers,
|
|
1695
|
+
customArgs: message.customArgs
|
|
1696
|
+
};
|
|
1697
|
+
_context.prev = 9;
|
|
1698
|
+
_context.next = 12;
|
|
1699
|
+
return this.mailer.send(payload);
|
|
1700
|
+
case 12:
|
|
1701
|
+
_yield$this$mailer$se = _context.sent;
|
|
1702
|
+
_yield$this$mailer$se2 = startPlugin._slicedToArray(_yield$this$mailer$se, 1);
|
|
1703
|
+
response = _yield$this$mailer$se2[0];
|
|
1704
|
+
_context.next = 20;
|
|
1705
|
+
break;
|
|
1706
|
+
case 17:
|
|
1707
|
+
_context.prev = 17;
|
|
1708
|
+
_context.t1 = _context["catch"](9);
|
|
1709
|
+
throw toSendError(_context.t1);
|
|
1710
|
+
case 20:
|
|
1711
|
+
messageId = ((_response = response) === null || _response === void 0 || (_response = _response.headers) === null || _response === void 0 ? void 0 : _response['x-message-id']) || ((_response2 = response) === null || _response2 === void 0 || (_response2 = _response2.headers) === null || _response2 === void 0 ? void 0 : _response2['X-Message-Id']) || '';
|
|
1712
|
+
return _context.abrupt("return", {
|
|
1713
|
+
messageId: String(messageId),
|
|
1714
|
+
provider: this.name,
|
|
1715
|
+
accepted: message.to,
|
|
1716
|
+
rejected: []
|
|
1717
|
+
});
|
|
1718
|
+
case 22:
|
|
1719
|
+
case "end":
|
|
1720
|
+
return _context.stop();
|
|
1721
|
+
}
|
|
1722
|
+
}, _callee, this, [[9, 17]]);
|
|
1723
|
+
}));
|
|
1724
|
+
function send(_x) {
|
|
1725
|
+
return _send.apply(this, arguments);
|
|
1726
|
+
}
|
|
1727
|
+
return send;
|
|
1728
|
+
}()
|
|
1729
|
+
}, {
|
|
1730
|
+
key: "listSingleSenders",
|
|
1731
|
+
value: function () {
|
|
1732
|
+
var _listSingleSenders = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(ids) {
|
|
1733
|
+
var _this = this;
|
|
1734
|
+
var paths, pages;
|
|
1735
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1736
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1737
|
+
case 0:
|
|
1738
|
+
paths = ids !== null && ids !== void 0 && ids.length ? ids.map(function (id) {
|
|
1739
|
+
return "/verified_senders?id=".concat(encodeURIComponent(id));
|
|
1740
|
+
}) : ['/verified_senders'];
|
|
1741
|
+
_context2.next = 3;
|
|
1742
|
+
return Promise.all(paths.map(function (path) {
|
|
1743
|
+
return _this.request('GET', path);
|
|
1744
|
+
}));
|
|
1745
|
+
case 3:
|
|
1746
|
+
pages = _context2.sent;
|
|
1747
|
+
return _context2.abrupt("return", pages.flatMap(function (page) {
|
|
1748
|
+
return ((page === null || page === void 0 ? void 0 : page.results) || []).map(toSingleSender);
|
|
1749
|
+
}));
|
|
1750
|
+
case 5:
|
|
1751
|
+
case "end":
|
|
1752
|
+
return _context2.stop();
|
|
1753
|
+
}
|
|
1754
|
+
}, _callee2);
|
|
1755
|
+
}));
|
|
1756
|
+
function listSingleSenders(_x2) {
|
|
1757
|
+
return _listSingleSenders.apply(this, arguments);
|
|
1758
|
+
}
|
|
1759
|
+
return listSingleSenders;
|
|
1760
|
+
}()
|
|
1761
|
+
}, {
|
|
1762
|
+
key: "listAuthenticatedDomains",
|
|
1763
|
+
value: function () {
|
|
1764
|
+
var _listAuthenticatedDomains = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3(domains) {
|
|
1765
|
+
var _this2 = this;
|
|
1766
|
+
var paths, pages;
|
|
1767
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1768
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1769
|
+
case 0:
|
|
1770
|
+
paths = domains !== null && domains !== void 0 && domains.length ? domains.map(function (domain) {
|
|
1771
|
+
return "/whitelabel/domains?domain=".concat(encodeURIComponent(domain));
|
|
1772
|
+
}) : ['/whitelabel/domains'];
|
|
1773
|
+
_context3.next = 3;
|
|
1774
|
+
return Promise.all(paths.map(function (path) {
|
|
1775
|
+
return _this2.request('GET', path);
|
|
1776
|
+
}));
|
|
1777
|
+
case 3:
|
|
1778
|
+
pages = _context3.sent;
|
|
1779
|
+
return _context3.abrupt("return", pages.flatMap(function (page) {
|
|
1780
|
+
return (page || []).map(toDomainSender);
|
|
1781
|
+
}));
|
|
1782
|
+
case 5:
|
|
1783
|
+
case "end":
|
|
1784
|
+
return _context3.stop();
|
|
1785
|
+
}
|
|
1786
|
+
}, _callee3);
|
|
1787
|
+
}));
|
|
1788
|
+
function listAuthenticatedDomains(_x3) {
|
|
1789
|
+
return _listAuthenticatedDomains.apply(this, arguments);
|
|
1790
|
+
}
|
|
1791
|
+
return listAuthenticatedDomains;
|
|
1792
|
+
}()
|
|
1793
|
+
}, {
|
|
1794
|
+
key: "verifySingleSender",
|
|
1795
|
+
value: function () {
|
|
1796
|
+
var _verifySingleSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee4(input) {
|
|
1797
|
+
var created;
|
|
1798
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1799
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1800
|
+
case 0:
|
|
1801
|
+
_context4.next = 2;
|
|
1802
|
+
return this.request('POST', '/verified_senders', {
|
|
1803
|
+
nickname: input.name || input.email,
|
|
1804
|
+
from_email: input.email,
|
|
1805
|
+
from_name: input.name || input.email,
|
|
1806
|
+
reply_to: input.replyTo || input.email,
|
|
1807
|
+
address: input.address || '',
|
|
1808
|
+
city: input.city || '',
|
|
1809
|
+
country: input.country || ''
|
|
1810
|
+
});
|
|
1811
|
+
case 2:
|
|
1812
|
+
created = _context4.sent;
|
|
1813
|
+
return _context4.abrupt("return", {
|
|
1814
|
+
id: String(created.id),
|
|
1815
|
+
type: 'single',
|
|
1816
|
+
value: created.from_email,
|
|
1817
|
+
name: created.from_name,
|
|
1818
|
+
status: created.verified ? 'verified' : 'pending'
|
|
1819
|
+
});
|
|
1820
|
+
case 4:
|
|
1821
|
+
case "end":
|
|
1822
|
+
return _context4.stop();
|
|
1823
|
+
}
|
|
1824
|
+
}, _callee4, this);
|
|
1825
|
+
}));
|
|
1826
|
+
function verifySingleSender(_x4) {
|
|
1827
|
+
return _verifySingleSender.apply(this, arguments);
|
|
1828
|
+
}
|
|
1829
|
+
return verifySingleSender;
|
|
1830
|
+
}()
|
|
1831
|
+
}, {
|
|
1832
|
+
key: "removeSender",
|
|
1833
|
+
value: function () {
|
|
1834
|
+
var _removeSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee5(id) {
|
|
1835
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1836
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1837
|
+
case 0:
|
|
1838
|
+
_context5.next = 2;
|
|
1839
|
+
return this.request('DELETE', "/verified_senders/".concat(encodeURIComponent(id)));
|
|
1840
|
+
case 2:
|
|
1841
|
+
case "end":
|
|
1842
|
+
return _context5.stop();
|
|
1843
|
+
}
|
|
1844
|
+
}, _callee5, this);
|
|
1845
|
+
}));
|
|
1846
|
+
function removeSender(_x5) {
|
|
1847
|
+
return _removeSender.apply(this, arguments);
|
|
1848
|
+
}
|
|
1849
|
+
return removeSender;
|
|
1850
|
+
}()
|
|
1851
|
+
}, {
|
|
1852
|
+
key: "authenticateDomain",
|
|
1853
|
+
value: function () {
|
|
1854
|
+
var _authenticateDomain = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee6(domain) {
|
|
1855
|
+
var created;
|
|
1856
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1857
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1858
|
+
case 0:
|
|
1859
|
+
_context6.next = 2;
|
|
1860
|
+
return this.request('POST', '/whitelabel/domains', {
|
|
1861
|
+
domain: domain,
|
|
1862
|
+
automatic_security: true
|
|
1863
|
+
});
|
|
1864
|
+
case 2:
|
|
1865
|
+
created = _context6.sent;
|
|
1866
|
+
return _context6.abrupt("return", toDomainSender(created));
|
|
1867
|
+
case 4:
|
|
1868
|
+
case "end":
|
|
1869
|
+
return _context6.stop();
|
|
1870
|
+
}
|
|
1871
|
+
}, _callee6, this);
|
|
1872
|
+
}));
|
|
1873
|
+
function authenticateDomain(_x6) {
|
|
1874
|
+
return _authenticateDomain.apply(this, arguments);
|
|
1875
|
+
}
|
|
1876
|
+
return authenticateDomain;
|
|
1877
|
+
}()
|
|
1878
|
+
}, {
|
|
1879
|
+
key: "validateDomain",
|
|
1880
|
+
value: function () {
|
|
1881
|
+
var _validateDomain = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee7(id) {
|
|
1882
|
+
var encodedId, domain;
|
|
1883
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1884
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1885
|
+
case 0:
|
|
1886
|
+
encodedId = encodeURIComponent(id);
|
|
1887
|
+
_context7.next = 3;
|
|
1888
|
+
return this.request('POST', "/whitelabel/domains/".concat(encodedId, "/validate"));
|
|
1889
|
+
case 3:
|
|
1890
|
+
_context7.next = 5;
|
|
1891
|
+
return this.request('GET', "/whitelabel/domains/".concat(encodedId));
|
|
1892
|
+
case 5:
|
|
1893
|
+
domain = _context7.sent;
|
|
1894
|
+
return _context7.abrupt("return", toDomainSender(domain));
|
|
1895
|
+
case 7:
|
|
1896
|
+
case "end":
|
|
1897
|
+
return _context7.stop();
|
|
1898
|
+
}
|
|
1899
|
+
}, _callee7, this);
|
|
1900
|
+
}));
|
|
1901
|
+
function validateDomain(_x7) {
|
|
1902
|
+
return _validateDomain.apply(this, arguments);
|
|
1903
|
+
}
|
|
1904
|
+
return validateDomain;
|
|
1905
|
+
}()
|
|
1906
|
+
}, {
|
|
1907
|
+
key: "request",
|
|
1908
|
+
value: function () {
|
|
1909
|
+
var _request = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee8(method, path, body) {
|
|
1910
|
+
var headers, controller, timer, response, text;
|
|
1911
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1912
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1913
|
+
case 0:
|
|
1914
|
+
headers = {
|
|
1915
|
+
Authorization: "Bearer ".concat(this.apiKey),
|
|
1916
|
+
'Content-Type': 'application/json'
|
|
1917
|
+
};
|
|
1918
|
+
if (this.subuser) {
|
|
1919
|
+
headers['on-behalf-of'] = this.subuser;
|
|
1920
|
+
}
|
|
1921
|
+
controller = new AbortController();
|
|
1922
|
+
timer = setTimeout(function () {
|
|
1923
|
+
return controller.abort();
|
|
1924
|
+
}, REQUEST_TIMEOUT_MS);
|
|
1925
|
+
_context8.prev = 4;
|
|
1926
|
+
_context8.next = 7;
|
|
1927
|
+
return fetch__default["default"]("".concat(SENDGRID_API_BASE_URL).concat(path), {
|
|
1928
|
+
method: method,
|
|
1929
|
+
headers: headers,
|
|
1930
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
1931
|
+
signal: controller.signal
|
|
1932
|
+
});
|
|
1933
|
+
case 7:
|
|
1934
|
+
response = _context8.sent;
|
|
1935
|
+
case 8:
|
|
1936
|
+
_context8.prev = 8;
|
|
1937
|
+
clearTimeout(timer);
|
|
1938
|
+
return _context8.finish(8);
|
|
1939
|
+
case 11:
|
|
1940
|
+
if (response.ok) {
|
|
1941
|
+
_context8.next = 18;
|
|
1942
|
+
break;
|
|
1943
|
+
}
|
|
1944
|
+
_context8.t0 = EmailProviderRequestError;
|
|
1945
|
+
_context8.t1 = response.status;
|
|
1946
|
+
_context8.next = 16;
|
|
1947
|
+
return response.text();
|
|
1948
|
+
case 16:
|
|
1949
|
+
_context8.t2 = _context8.sent;
|
|
1950
|
+
throw new _context8.t0('sendgrid', _context8.t1, _context8.t2);
|
|
1951
|
+
case 18:
|
|
1952
|
+
if (!(response.status === 204)) {
|
|
1953
|
+
_context8.next = 20;
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1956
|
+
return _context8.abrupt("return", undefined);
|
|
1957
|
+
case 20:
|
|
1958
|
+
_context8.next = 22;
|
|
1959
|
+
return response.text();
|
|
1960
|
+
case 22:
|
|
1961
|
+
text = _context8.sent;
|
|
1962
|
+
if (text) {
|
|
1963
|
+
_context8.next = 25;
|
|
1964
|
+
break;
|
|
1965
|
+
}
|
|
1966
|
+
return _context8.abrupt("return", undefined);
|
|
1967
|
+
case 25:
|
|
1968
|
+
return _context8.abrupt("return", JSON.parse(text));
|
|
1969
|
+
case 26:
|
|
1970
|
+
case "end":
|
|
1971
|
+
return _context8.stop();
|
|
1972
|
+
}
|
|
1973
|
+
}, _callee8, this, [[4,, 8, 11]]);
|
|
1974
|
+
}));
|
|
1975
|
+
function request(_x8, _x9, _x0) {
|
|
1976
|
+
return _request.apply(this, arguments);
|
|
1977
|
+
}
|
|
1978
|
+
return request;
|
|
1979
|
+
}()
|
|
1980
|
+
}]);
|
|
1981
|
+
}();
|
|
1982
|
+
|
|
1983
|
+
var SENDGRID_SIGNATURE_HEADER = 'x-twilio-email-event-webhook-signature';
|
|
1984
|
+
var SENDGRID_TIMESTAMP_HEADER = 'x-twilio-email-event-webhook-timestamp';
|
|
1985
|
+
var verifySendgridSignature = function verifySendgridSignature(_ref) {
|
|
1986
|
+
var publicKey = _ref.publicKey,
|
|
1987
|
+
signature = _ref.signature,
|
|
1988
|
+
timestamp = _ref.timestamp,
|
|
1989
|
+
payload = _ref.payload;
|
|
1990
|
+
if (!publicKey || !signature || !timestamp) {
|
|
1991
|
+
return false;
|
|
1992
|
+
}
|
|
1993
|
+
try {
|
|
1994
|
+
var key = crypto__namespace.createPublicKey({
|
|
1995
|
+
key: Buffer.from(publicKey, 'base64'),
|
|
1996
|
+
format: 'der',
|
|
1997
|
+
type: 'spki'
|
|
1998
|
+
});
|
|
1999
|
+
return crypto__namespace.createVerify('sha256').update(timestamp).update(payload).verify(key, signature, 'base64');
|
|
2000
|
+
} catch (_unused) {
|
|
2001
|
+
return false;
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
var toSenderStatus = function toSenderStatus(verificationStatus) {
|
|
2006
|
+
if (verificationStatus === 'Success') {
|
|
2007
|
+
return 'verified';
|
|
2008
|
+
}
|
|
2009
|
+
if (verificationStatus === 'Failed' || verificationStatus === 'TemporaryFailure') {
|
|
2010
|
+
return 'failed';
|
|
2011
|
+
}
|
|
2012
|
+
return 'pending';
|
|
2013
|
+
};
|
|
2014
|
+
var SesEmailProvider = /*#__PURE__*/function () {
|
|
2015
|
+
function SesEmailProvider(config) {
|
|
2016
|
+
startPlugin._classCallCheck(this, SesEmailProvider);
|
|
2017
|
+
startPlugin._defineProperty(this, "name", 'SES');
|
|
2018
|
+
var missing = [];
|
|
2019
|
+
if (!config.AWS_SES_ACCESS_KEY_ID) {
|
|
2020
|
+
missing.push('AWS_SES_ACCESS_KEY_ID');
|
|
2021
|
+
}
|
|
2022
|
+
if (!config.AWS_SES_SECRET_ACCESS_KEY) {
|
|
2023
|
+
missing.push('AWS_SES_SECRET_ACCESS_KEY');
|
|
2024
|
+
}
|
|
2025
|
+
if (!config.AWS_REGION) {
|
|
2026
|
+
missing.push('AWS_REGION');
|
|
2027
|
+
}
|
|
2028
|
+
if (missing.length) {
|
|
2029
|
+
throw new EmailProviderConfigError('SES', missing);
|
|
2030
|
+
}
|
|
2031
|
+
this.configSet = config.AWS_SES_CONFIG_SET;
|
|
2032
|
+
this.client = new AWS__namespace.SES({
|
|
2033
|
+
apiVersion: '2010-12-01',
|
|
2034
|
+
region: config.AWS_REGION,
|
|
2035
|
+
accessKeyId: config.AWS_SES_ACCESS_KEY_ID,
|
|
2036
|
+
secretAccessKey: config.AWS_SES_SECRET_ACCESS_KEY
|
|
2037
|
+
});
|
|
2038
|
+
this.transporter = nodemailer__namespace.createTransport({
|
|
2039
|
+
SES: this.client
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
return startPlugin._createClass(SesEmailProvider, [{
|
|
2043
|
+
key: "send",
|
|
2044
|
+
value: function () {
|
|
2045
|
+
var _send = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(message) {
|
|
2046
|
+
var _message$cc, _message$bcc, _message$attachments;
|
|
2047
|
+
var headers, _i, _Object$entries, _Object$entries$_i, key, value, info;
|
|
2048
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2049
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2050
|
+
case 0:
|
|
2051
|
+
headers = startPlugin._objectSpread2(startPlugin._objectSpread2({}, this.configSet ? {
|
|
2052
|
+
'X-SES-CONFIGURATION-SET': this.configSet
|
|
2053
|
+
} : {}), message.headers || {});
|
|
2054
|
+
for (_i = 0, _Object$entries = Object.entries(message.customArgs || {}); _i < _Object$entries.length; _i++) {
|
|
2055
|
+
_Object$entries$_i = startPlugin._slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
2056
|
+
headers[key] = value;
|
|
2057
|
+
}
|
|
2058
|
+
_context.next = 4;
|
|
2059
|
+
return this.transporter.sendMail({
|
|
2060
|
+
from: message.from,
|
|
2061
|
+
to: message.to.join(', '),
|
|
2062
|
+
cc: (_message$cc = message.cc) !== null && _message$cc !== void 0 && _message$cc.length ? message.cc.join(', ') : undefined,
|
|
2063
|
+
bcc: (_message$bcc = message.bcc) !== null && _message$bcc !== void 0 && _message$bcc.length ? message.bcc.join(', ') : undefined,
|
|
2064
|
+
replyTo: message.replyTo,
|
|
2065
|
+
subject: message.subject,
|
|
2066
|
+
html: message.html,
|
|
2067
|
+
text: message.text,
|
|
2068
|
+
attachments: (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments.map(function (attachment) {
|
|
2069
|
+
return {
|
|
2070
|
+
filename: attachment.filename,
|
|
2071
|
+
path: attachment.path,
|
|
2072
|
+
content: attachment.content ? Buffer.from(attachment.content, 'base64') : undefined,
|
|
2073
|
+
contentType: attachment.contentType
|
|
2074
|
+
};
|
|
2075
|
+
}),
|
|
2076
|
+
headers: headers
|
|
2077
|
+
});
|
|
2078
|
+
case 4:
|
|
2079
|
+
info = _context.sent;
|
|
2080
|
+
return _context.abrupt("return", {
|
|
2081
|
+
messageId: info.messageId,
|
|
2082
|
+
provider: this.name,
|
|
2083
|
+
accepted: (info.accepted || []).map(String),
|
|
2084
|
+
rejected: (info.rejected || []).map(String)
|
|
2085
|
+
});
|
|
2086
|
+
case 6:
|
|
2087
|
+
case "end":
|
|
2088
|
+
return _context.stop();
|
|
2089
|
+
}
|
|
2090
|
+
}, _callee, this);
|
|
2091
|
+
}));
|
|
2092
|
+
function send(_x) {
|
|
2093
|
+
return _send.apply(this, arguments);
|
|
2094
|
+
}
|
|
2095
|
+
return send;
|
|
2096
|
+
}()
|
|
2097
|
+
}, {
|
|
2098
|
+
key: "listSingleSenders",
|
|
2099
|
+
value: function () {
|
|
2100
|
+
var _listSingleSenders = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2(ids) {
|
|
2101
|
+
var emails, statuses;
|
|
2102
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2104
|
+
case 0:
|
|
2105
|
+
if (!(ids !== null && ids !== void 0)) {
|
|
2106
|
+
_context2.next = 4;
|
|
2107
|
+
break;
|
|
2108
|
+
}
|
|
2109
|
+
_context2.t0 = ids;
|
|
2110
|
+
_context2.next = 7;
|
|
2111
|
+
break;
|
|
2112
|
+
case 4:
|
|
2113
|
+
_context2.next = 6;
|
|
2114
|
+
return this.listAllIdentities('EmailAddress');
|
|
2115
|
+
case 6:
|
|
2116
|
+
_context2.t0 = _context2.sent;
|
|
2117
|
+
case 7:
|
|
2118
|
+
emails = _context2.t0;
|
|
2119
|
+
if (emails.length) {
|
|
2120
|
+
_context2.next = 10;
|
|
2121
|
+
break;
|
|
2122
|
+
}
|
|
2123
|
+
return _context2.abrupt("return", []);
|
|
2124
|
+
case 10:
|
|
2125
|
+
_context2.next = 12;
|
|
2126
|
+
return this.getVerificationStatuses(emails);
|
|
2127
|
+
case 12:
|
|
2128
|
+
statuses = _context2.sent;
|
|
2129
|
+
return _context2.abrupt("return", emails.map(function (email) {
|
|
2130
|
+
return {
|
|
2131
|
+
id: email,
|
|
2132
|
+
type: 'single',
|
|
2133
|
+
value: email,
|
|
2134
|
+
status: toSenderStatus(statuses[email])
|
|
2135
|
+
};
|
|
2136
|
+
}));
|
|
2137
|
+
case 14:
|
|
2138
|
+
case "end":
|
|
2139
|
+
return _context2.stop();
|
|
2140
|
+
}
|
|
2141
|
+
}, _callee2, this);
|
|
2142
|
+
}));
|
|
2143
|
+
function listSingleSenders(_x2) {
|
|
2144
|
+
return _listSingleSenders.apply(this, arguments);
|
|
2145
|
+
}
|
|
2146
|
+
return listSingleSenders;
|
|
2147
|
+
}()
|
|
2148
|
+
}, {
|
|
2149
|
+
key: "listAuthenticatedDomains",
|
|
2150
|
+
value: function () {
|
|
2151
|
+
var _listAuthenticatedDomains = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3(domains) {
|
|
2152
|
+
var _this = this;
|
|
2153
|
+
var names;
|
|
2154
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2155
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2156
|
+
case 0:
|
|
2157
|
+
if (!(domains !== null && domains !== void 0)) {
|
|
2158
|
+
_context3.next = 4;
|
|
2159
|
+
break;
|
|
2160
|
+
}
|
|
2161
|
+
_context3.t0 = domains;
|
|
2162
|
+
_context3.next = 7;
|
|
2163
|
+
break;
|
|
2164
|
+
case 4:
|
|
2165
|
+
_context3.next = 6;
|
|
2166
|
+
return this.listAllIdentities('Domain');
|
|
2167
|
+
case 6:
|
|
2168
|
+
_context3.t0 = _context3.sent;
|
|
2169
|
+
case 7:
|
|
2170
|
+
names = _context3.t0;
|
|
2171
|
+
return _context3.abrupt("return", Promise.all(names.map(function (domain) {
|
|
2172
|
+
return _this.getDomainSender(domain);
|
|
2173
|
+
})));
|
|
2174
|
+
case 9:
|
|
2175
|
+
case "end":
|
|
2176
|
+
return _context3.stop();
|
|
2177
|
+
}
|
|
2178
|
+
}, _callee3, this);
|
|
2179
|
+
}));
|
|
2180
|
+
function listAuthenticatedDomains(_x3) {
|
|
2181
|
+
return _listAuthenticatedDomains.apply(this, arguments);
|
|
2182
|
+
}
|
|
2183
|
+
return listAuthenticatedDomains;
|
|
2184
|
+
}()
|
|
2185
|
+
}, {
|
|
2186
|
+
key: "listAllIdentities",
|
|
2187
|
+
value: function () {
|
|
2188
|
+
var _listAllIdentities = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee4(identityType) {
|
|
2189
|
+
var identities, nextToken, _page$Identities, page;
|
|
2190
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2191
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
2192
|
+
case 0:
|
|
2193
|
+
identities = [];
|
|
2194
|
+
case 1:
|
|
2195
|
+
_context4.next = 3;
|
|
2196
|
+
return this.client.listIdentities({
|
|
2197
|
+
IdentityType: identityType,
|
|
2198
|
+
MaxItems: 100,
|
|
2199
|
+
NextToken: nextToken
|
|
2200
|
+
}).promise();
|
|
2201
|
+
case 3:
|
|
2202
|
+
page = _context4.sent;
|
|
2203
|
+
identities.push.apply(identities, startPlugin._toConsumableArray((_page$Identities = page.Identities) !== null && _page$Identities !== void 0 ? _page$Identities : []));
|
|
2204
|
+
nextToken = page.NextToken;
|
|
2205
|
+
case 6:
|
|
2206
|
+
if (nextToken) {
|
|
2207
|
+
_context4.next = 1;
|
|
2208
|
+
break;
|
|
2209
|
+
}
|
|
2210
|
+
case 7:
|
|
2211
|
+
return _context4.abrupt("return", identities);
|
|
2212
|
+
case 8:
|
|
2213
|
+
case "end":
|
|
2214
|
+
return _context4.stop();
|
|
2215
|
+
}
|
|
2216
|
+
}, _callee4, this);
|
|
2217
|
+
}));
|
|
2218
|
+
function listAllIdentities(_x4) {
|
|
2219
|
+
return _listAllIdentities.apply(this, arguments);
|
|
2220
|
+
}
|
|
2221
|
+
return listAllIdentities;
|
|
2222
|
+
}()
|
|
2223
|
+
}, {
|
|
2224
|
+
key: "getVerificationStatuses",
|
|
2225
|
+
value: function () {
|
|
2226
|
+
var _getVerificationStatuses = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee5(identities) {
|
|
2227
|
+
var statuses, i, attributes, _i2, _Object$entries2, _attributes$Verificat, _Object$entries2$_i, identity, attribute;
|
|
2228
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
2229
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
2230
|
+
case 0:
|
|
2231
|
+
statuses = {};
|
|
2232
|
+
i = 0;
|
|
2233
|
+
case 2:
|
|
2234
|
+
if (!(i < identities.length)) {
|
|
2235
|
+
_context5.next = 10;
|
|
2236
|
+
break;
|
|
2237
|
+
}
|
|
2238
|
+
_context5.next = 5;
|
|
2239
|
+
return this.client.getIdentityVerificationAttributes({
|
|
2240
|
+
Identities: identities.slice(i, i + 100)
|
|
2241
|
+
}).promise();
|
|
2242
|
+
case 5:
|
|
2243
|
+
attributes = _context5.sent;
|
|
2244
|
+
for (_i2 = 0, _Object$entries2 = Object.entries((_attributes$Verificat = attributes.VerificationAttributes) !== null && _attributes$Verificat !== void 0 ? _attributes$Verificat : {}); _i2 < _Object$entries2.length; _i2++) {
|
|
2245
|
+
_Object$entries2$_i = startPlugin._slicedToArray(_Object$entries2[_i2], 2), identity = _Object$entries2$_i[0], attribute = _Object$entries2$_i[1];
|
|
2246
|
+
statuses[identity] = attribute.VerificationStatus;
|
|
2247
|
+
}
|
|
2248
|
+
case 7:
|
|
2249
|
+
i += 100;
|
|
2250
|
+
_context5.next = 2;
|
|
2251
|
+
break;
|
|
2252
|
+
case 10:
|
|
2253
|
+
return _context5.abrupt("return", statuses);
|
|
2254
|
+
case 11:
|
|
2255
|
+
case "end":
|
|
2256
|
+
return _context5.stop();
|
|
2257
|
+
}
|
|
2258
|
+
}, _callee5, this);
|
|
2259
|
+
}));
|
|
2260
|
+
function getVerificationStatuses(_x5) {
|
|
2261
|
+
return _getVerificationStatuses.apply(this, arguments);
|
|
2262
|
+
}
|
|
2263
|
+
return getVerificationStatuses;
|
|
2264
|
+
}()
|
|
2265
|
+
}, {
|
|
2266
|
+
key: "verifySingleSender",
|
|
2267
|
+
value: function () {
|
|
2268
|
+
var _verifySingleSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee6(input) {
|
|
2269
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
2270
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
2271
|
+
case 0:
|
|
2272
|
+
_context6.next = 2;
|
|
2273
|
+
return this.client.verifyEmailAddress({
|
|
2274
|
+
EmailAddress: input.email
|
|
2275
|
+
}).promise();
|
|
2276
|
+
case 2:
|
|
2277
|
+
return _context6.abrupt("return", {
|
|
2278
|
+
id: input.email,
|
|
2279
|
+
type: 'single',
|
|
2280
|
+
value: input.email,
|
|
2281
|
+
name: input.name,
|
|
2282
|
+
status: 'pending'
|
|
2283
|
+
});
|
|
2284
|
+
case 3:
|
|
2285
|
+
case "end":
|
|
2286
|
+
return _context6.stop();
|
|
2287
|
+
}
|
|
2288
|
+
}, _callee6, this);
|
|
2289
|
+
}));
|
|
2290
|
+
function verifySingleSender(_x6) {
|
|
2291
|
+
return _verifySingleSender.apply(this, arguments);
|
|
2292
|
+
}
|
|
2293
|
+
return verifySingleSender;
|
|
2294
|
+
}()
|
|
2295
|
+
}, {
|
|
2296
|
+
key: "removeSender",
|
|
2297
|
+
value: function () {
|
|
2298
|
+
var _removeSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee7(id) {
|
|
2299
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2300
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
2301
|
+
case 0:
|
|
2302
|
+
_context7.next = 2;
|
|
2303
|
+
return this.client.deleteIdentity({
|
|
2304
|
+
Identity: id
|
|
2305
|
+
}).promise();
|
|
2306
|
+
case 2:
|
|
2307
|
+
case "end":
|
|
2308
|
+
return _context7.stop();
|
|
2309
|
+
}
|
|
2310
|
+
}, _callee7, this);
|
|
2311
|
+
}));
|
|
2312
|
+
function removeSender(_x7) {
|
|
2313
|
+
return _removeSender.apply(this, arguments);
|
|
2314
|
+
}
|
|
2315
|
+
return removeSender;
|
|
2316
|
+
}()
|
|
2317
|
+
}, {
|
|
2318
|
+
key: "authenticateDomain",
|
|
2319
|
+
value: function () {
|
|
2320
|
+
var _authenticateDomain = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee8(domain) {
|
|
2321
|
+
var dkim, dnsRecords;
|
|
2322
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
2323
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
2324
|
+
case 0:
|
|
2325
|
+
_context8.next = 2;
|
|
2326
|
+
return this.client.verifyDomainIdentity({
|
|
2327
|
+
Domain: domain
|
|
2328
|
+
}).promise();
|
|
2329
|
+
case 2:
|
|
2330
|
+
_context8.next = 4;
|
|
2331
|
+
return this.client.verifyDomainDkim({
|
|
2332
|
+
Domain: domain
|
|
2333
|
+
}).promise();
|
|
2334
|
+
case 4:
|
|
2335
|
+
dkim = _context8.sent;
|
|
2336
|
+
dnsRecords = (dkim.DkimTokens || []).map(function (token) {
|
|
2337
|
+
return {
|
|
2338
|
+
type: 'CNAME',
|
|
2339
|
+
host: "".concat(token, "._domainkey.").concat(domain),
|
|
2340
|
+
data: "".concat(token, ".").concat(SES_DKIM_CNAME_SUFFIX),
|
|
2341
|
+
valid: false
|
|
2342
|
+
};
|
|
2343
|
+
});
|
|
2344
|
+
return _context8.abrupt("return", {
|
|
2345
|
+
id: domain,
|
|
2346
|
+
type: 'domain',
|
|
2347
|
+
value: domain,
|
|
2348
|
+
status: 'pending',
|
|
2349
|
+
dnsRecords: dnsRecords
|
|
2350
|
+
});
|
|
2351
|
+
case 7:
|
|
2352
|
+
case "end":
|
|
2353
|
+
return _context8.stop();
|
|
2354
|
+
}
|
|
2355
|
+
}, _callee8, this);
|
|
2356
|
+
}));
|
|
2357
|
+
function authenticateDomain(_x8) {
|
|
2358
|
+
return _authenticateDomain.apply(this, arguments);
|
|
2359
|
+
}
|
|
2360
|
+
return authenticateDomain;
|
|
2361
|
+
}()
|
|
2362
|
+
}, {
|
|
2363
|
+
key: "validateDomain",
|
|
2364
|
+
value: function () {
|
|
2365
|
+
var _validateDomain = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee9(id) {
|
|
2366
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2367
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
2368
|
+
case 0:
|
|
2369
|
+
return _context9.abrupt("return", this.getDomainSender(id));
|
|
2370
|
+
case 1:
|
|
2371
|
+
case "end":
|
|
2372
|
+
return _context9.stop();
|
|
2373
|
+
}
|
|
2374
|
+
}, _callee9, this);
|
|
2375
|
+
}));
|
|
2376
|
+
function validateDomain(_x9) {
|
|
2377
|
+
return _validateDomain.apply(this, arguments);
|
|
2378
|
+
}
|
|
2379
|
+
return validateDomain;
|
|
2380
|
+
}()
|
|
2381
|
+
}, {
|
|
2382
|
+
key: "getDomainSender",
|
|
2383
|
+
value: function () {
|
|
2384
|
+
var _getDomainSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee0(domain) {
|
|
2385
|
+
var _dkim$DkimAttributes;
|
|
2386
|
+
var dkim, attributes, dnsRecords;
|
|
2387
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee0$(_context0) {
|
|
2388
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
2389
|
+
case 0:
|
|
2390
|
+
_context0.next = 2;
|
|
2391
|
+
return this.client.getIdentityDkimAttributes({
|
|
2392
|
+
Identities: [domain]
|
|
2393
|
+
}).promise();
|
|
2394
|
+
case 2:
|
|
2395
|
+
dkim = _context0.sent;
|
|
2396
|
+
attributes = (_dkim$DkimAttributes = dkim.DkimAttributes) === null || _dkim$DkimAttributes === void 0 ? void 0 : _dkim$DkimAttributes[domain];
|
|
2397
|
+
dnsRecords = ((attributes === null || attributes === void 0 ? void 0 : attributes.DkimTokens) || []).map(function (token) {
|
|
2398
|
+
return {
|
|
2399
|
+
type: 'CNAME',
|
|
2400
|
+
host: "".concat(token, "._domainkey.").concat(domain),
|
|
2401
|
+
data: "".concat(token, ".").concat(SES_DKIM_CNAME_SUFFIX),
|
|
2402
|
+
valid: (attributes === null || attributes === void 0 ? void 0 : attributes.DkimVerificationStatus) === 'Success'
|
|
2403
|
+
};
|
|
2404
|
+
});
|
|
2405
|
+
return _context0.abrupt("return", {
|
|
2406
|
+
id: domain,
|
|
2407
|
+
type: 'domain',
|
|
2408
|
+
value: domain,
|
|
2409
|
+
status: toSenderStatus(attributes === null || attributes === void 0 ? void 0 : attributes.DkimVerificationStatus),
|
|
2410
|
+
dnsRecords: dnsRecords
|
|
2411
|
+
});
|
|
2412
|
+
case 6:
|
|
2413
|
+
case "end":
|
|
2414
|
+
return _context0.stop();
|
|
2415
|
+
}
|
|
2416
|
+
}, _callee0, this);
|
|
2417
|
+
}));
|
|
2418
|
+
function getDomainSender(_x0) {
|
|
2419
|
+
return _getDomainSender.apply(this, arguments);
|
|
2420
|
+
}
|
|
2421
|
+
return getDomainSender;
|
|
2422
|
+
}()
|
|
2423
|
+
}]);
|
|
2424
|
+
}();
|
|
2425
|
+
|
|
2426
|
+
var CONNECTION_TIMEOUT_MS = 15000;
|
|
2427
|
+
var GREETING_TIMEOUT_MS = 15000;
|
|
2428
|
+
var SOCKET_TIMEOUT_MS = 30000;
|
|
2429
|
+
var SmtpEmailProvider = /*#__PURE__*/function () {
|
|
2430
|
+
function SmtpEmailProvider(config) {
|
|
2431
|
+
startPlugin._classCallCheck(this, SmtpEmailProvider);
|
|
2432
|
+
startPlugin._defineProperty(this, "name", 'custom');
|
|
2433
|
+
var auth = config.MAIL_USER && config.MAIL_PASS ? {
|
|
2434
|
+
user: config.MAIL_USER,
|
|
2435
|
+
pass: config.MAIL_PASS
|
|
2436
|
+
} : undefined;
|
|
2437
|
+
var port = config.MAIL_PORT ? Number(config.MAIL_PORT) : undefined;
|
|
2438
|
+
this.transporter = nodemailer__namespace.createTransport(startPlugin._objectSpread2(startPlugin._objectSpread2({
|
|
2439
|
+
service: config.MAIL_SERVICE,
|
|
2440
|
+
host: config.MAIL_HOST,
|
|
2441
|
+
port: port,
|
|
2442
|
+
auth: auth
|
|
2443
|
+
}, auth && port !== 465 ? {
|
|
2444
|
+
requireTLS: true
|
|
2445
|
+
} : {}), {}, {
|
|
2446
|
+
connectionTimeout: CONNECTION_TIMEOUT_MS,
|
|
2447
|
+
greetingTimeout: GREETING_TIMEOUT_MS,
|
|
2448
|
+
socketTimeout: SOCKET_TIMEOUT_MS
|
|
2449
|
+
}));
|
|
2450
|
+
}
|
|
2451
|
+
return startPlugin._createClass(SmtpEmailProvider, [{
|
|
2452
|
+
key: "send",
|
|
2453
|
+
value: function () {
|
|
2454
|
+
var _send = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(message) {
|
|
2455
|
+
var _message$cc, _message$bcc, _message$attachments;
|
|
2456
|
+
var info;
|
|
2457
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2458
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2459
|
+
case 0:
|
|
2460
|
+
_context.next = 2;
|
|
2461
|
+
return this.transporter.sendMail({
|
|
2462
|
+
from: message.from,
|
|
2463
|
+
to: message.to.join(', '),
|
|
2464
|
+
cc: (_message$cc = message.cc) !== null && _message$cc !== void 0 && _message$cc.length ? message.cc.join(', ') : undefined,
|
|
2465
|
+
bcc: (_message$bcc = message.bcc) !== null && _message$bcc !== void 0 && _message$bcc.length ? message.bcc.join(', ') : undefined,
|
|
2466
|
+
replyTo: message.replyTo,
|
|
2467
|
+
subject: message.subject,
|
|
2468
|
+
html: message.html,
|
|
2469
|
+
text: message.text,
|
|
2470
|
+
attachments: (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments.map(function (attachment) {
|
|
2471
|
+
return {
|
|
2472
|
+
filename: attachment.filename,
|
|
2473
|
+
path: attachment.path,
|
|
2474
|
+
content: attachment.content ? Buffer.from(attachment.content, 'base64') : undefined,
|
|
2475
|
+
contentType: attachment.contentType
|
|
2476
|
+
};
|
|
2477
|
+
}),
|
|
2478
|
+
headers: startPlugin._objectSpread2(startPlugin._objectSpread2({}, message.headers || {}), message.customArgs || {})
|
|
2479
|
+
});
|
|
2480
|
+
case 2:
|
|
2481
|
+
info = _context.sent;
|
|
2482
|
+
return _context.abrupt("return", {
|
|
2483
|
+
messageId: info.messageId,
|
|
2484
|
+
provider: this.name,
|
|
2485
|
+
accepted: (info.accepted || []).map(String),
|
|
2486
|
+
rejected: (info.rejected || []).map(String)
|
|
2487
|
+
});
|
|
2488
|
+
case 4:
|
|
2489
|
+
case "end":
|
|
2490
|
+
return _context.stop();
|
|
2491
|
+
}
|
|
2492
|
+
}, _callee, this);
|
|
2493
|
+
}));
|
|
2494
|
+
function send(_x) {
|
|
2495
|
+
return _send.apply(this, arguments);
|
|
2496
|
+
}
|
|
2497
|
+
return send;
|
|
2498
|
+
}()
|
|
2499
|
+
}, {
|
|
2500
|
+
key: "listSingleSenders",
|
|
2501
|
+
value: function () {
|
|
2502
|
+
var _listSingleSenders = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee2() {
|
|
2503
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2504
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2505
|
+
case 0:
|
|
2506
|
+
throw new EmailProviderNotSupportedError('custom', 'listSingleSenders');
|
|
2507
|
+
case 1:
|
|
2508
|
+
case "end":
|
|
2509
|
+
return _context2.stop();
|
|
2510
|
+
}
|
|
2511
|
+
}, _callee2);
|
|
2512
|
+
}));
|
|
2513
|
+
function listSingleSenders() {
|
|
2514
|
+
return _listSingleSenders.apply(this, arguments);
|
|
2515
|
+
}
|
|
2516
|
+
return listSingleSenders;
|
|
2517
|
+
}()
|
|
2518
|
+
}, {
|
|
2519
|
+
key: "listAuthenticatedDomains",
|
|
2520
|
+
value: function () {
|
|
2521
|
+
var _listAuthenticatedDomains = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee3() {
|
|
2522
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2523
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2524
|
+
case 0:
|
|
2525
|
+
throw new EmailProviderNotSupportedError('custom', 'listAuthenticatedDomains');
|
|
2526
|
+
case 1:
|
|
2527
|
+
case "end":
|
|
2528
|
+
return _context3.stop();
|
|
2529
|
+
}
|
|
2530
|
+
}, _callee3);
|
|
2531
|
+
}));
|
|
2532
|
+
function listAuthenticatedDomains() {
|
|
2533
|
+
return _listAuthenticatedDomains.apply(this, arguments);
|
|
2534
|
+
}
|
|
2535
|
+
return listAuthenticatedDomains;
|
|
2536
|
+
}()
|
|
2537
|
+
}, {
|
|
2538
|
+
key: "verifySingleSender",
|
|
2539
|
+
value: function () {
|
|
2540
|
+
var _verifySingleSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee4(_input) {
|
|
2541
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2542
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
2543
|
+
case 0:
|
|
2544
|
+
throw new EmailProviderNotSupportedError('custom', 'verifySingleSender');
|
|
2545
|
+
case 1:
|
|
2546
|
+
case "end":
|
|
2547
|
+
return _context4.stop();
|
|
2548
|
+
}
|
|
2549
|
+
}, _callee4);
|
|
2550
|
+
}));
|
|
2551
|
+
function verifySingleSender(_x2) {
|
|
2552
|
+
return _verifySingleSender.apply(this, arguments);
|
|
2553
|
+
}
|
|
2554
|
+
return verifySingleSender;
|
|
2555
|
+
}()
|
|
2556
|
+
}, {
|
|
2557
|
+
key: "removeSender",
|
|
2558
|
+
value: function () {
|
|
2559
|
+
var _removeSender = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee5(_id) {
|
|
2560
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
2561
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
2562
|
+
case 0:
|
|
2563
|
+
throw new EmailProviderNotSupportedError('custom', 'removeSender');
|
|
2564
|
+
case 1:
|
|
2565
|
+
case "end":
|
|
2566
|
+
return _context5.stop();
|
|
2567
|
+
}
|
|
2568
|
+
}, _callee5);
|
|
2569
|
+
}));
|
|
2570
|
+
function removeSender(_x3) {
|
|
2571
|
+
return _removeSender.apply(this, arguments);
|
|
2572
|
+
}
|
|
2573
|
+
return removeSender;
|
|
2574
|
+
}()
|
|
2575
|
+
}, {
|
|
2576
|
+
key: "authenticateDomain",
|
|
2577
|
+
value: function () {
|
|
2578
|
+
var _authenticateDomain = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee6(_domain) {
|
|
2579
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
2580
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
2581
|
+
case 0:
|
|
2582
|
+
throw new EmailProviderNotSupportedError('custom', 'authenticateDomain');
|
|
2583
|
+
case 1:
|
|
2584
|
+
case "end":
|
|
2585
|
+
return _context6.stop();
|
|
2586
|
+
}
|
|
2587
|
+
}, _callee6);
|
|
2588
|
+
}));
|
|
2589
|
+
function authenticateDomain(_x4) {
|
|
2590
|
+
return _authenticateDomain.apply(this, arguments);
|
|
2591
|
+
}
|
|
2592
|
+
return authenticateDomain;
|
|
2593
|
+
}()
|
|
2594
|
+
}, {
|
|
2595
|
+
key: "validateDomain",
|
|
2596
|
+
value: function () {
|
|
2597
|
+
var _validateDomain = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee7(_id) {
|
|
2598
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2599
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
2600
|
+
case 0:
|
|
2601
|
+
throw new EmailProviderNotSupportedError('custom', 'validateDomain');
|
|
2602
|
+
case 1:
|
|
2603
|
+
case "end":
|
|
2604
|
+
return _context7.stop();
|
|
2605
|
+
}
|
|
2606
|
+
}, _callee7);
|
|
2607
|
+
}));
|
|
2608
|
+
function validateDomain(_x5) {
|
|
2609
|
+
return _validateDomain.apply(this, arguments);
|
|
2610
|
+
}
|
|
2611
|
+
return validateDomain;
|
|
2612
|
+
}()
|
|
2613
|
+
}]);
|
|
2614
|
+
}();
|
|
2615
|
+
|
|
2616
|
+
var resolveEmailProviderName = function resolveEmailProviderName(config) {
|
|
2617
|
+
var value = (config.DEFAULT_EMAIL_SERVICE || '').trim();
|
|
2618
|
+
if (value.toLowerCase() === 'sendgrid') {
|
|
2619
|
+
return 'sendgrid';
|
|
2620
|
+
}
|
|
2621
|
+
if (value.toLowerCase() === 'custom') {
|
|
2622
|
+
return 'custom';
|
|
2623
|
+
}
|
|
2624
|
+
if (value.toUpperCase() === 'SES') {
|
|
2625
|
+
return 'SES';
|
|
2626
|
+
}
|
|
2627
|
+
return DEFAULT_EMAIL_PROVIDER;
|
|
2628
|
+
};
|
|
2629
|
+
var createEmailProvider = function createEmailProvider(config) {
|
|
2630
|
+
switch (resolveEmailProviderName(config)) {
|
|
2631
|
+
case 'sendgrid':
|
|
2632
|
+
return new SendgridEmailProvider(config);
|
|
2633
|
+
case 'custom':
|
|
2634
|
+
return new SmtpEmailProvider(config);
|
|
2635
|
+
default:
|
|
2636
|
+
return new SesEmailProvider(config);
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2639
|
+
var providerCache = new Map();
|
|
2640
|
+
var getEmailProvider = function getEmailProvider(cacheKey, config) {
|
|
2641
|
+
var fingerprint = getEmailProviderConfigFingerprint(config);
|
|
2642
|
+
var cached = providerCache.get(cacheKey);
|
|
2643
|
+
if (cached && cached.fingerprint === fingerprint) {
|
|
2644
|
+
return cached.provider;
|
|
2645
|
+
}
|
|
2646
|
+
var provider = createEmailProvider(config);
|
|
2647
|
+
providerCache.set(cacheKey, {
|
|
2648
|
+
fingerprint: fingerprint,
|
|
2649
|
+
provider: provider
|
|
2650
|
+
});
|
|
2651
|
+
return provider;
|
|
2652
|
+
};
|
|
2653
|
+
var clearEmailProviderCache = function clearEmailProviderCache(cacheKey) {
|
|
2654
|
+
if (cacheKey) {
|
|
2655
|
+
providerCache["delete"](cacheKey);
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
providerCache.clear();
|
|
2659
|
+
};
|
|
2660
|
+
|
|
2661
|
+
var EMAIL_DELIVERY_ID_KEY = 'EmailDeliveryId';
|
|
2662
|
+
var EMAIL_SUBDOMAIN_KEY = 'Subdomain';
|
|
2663
|
+
var toDeliveryLogProvider = function toDeliveryLogProvider(name) {
|
|
2664
|
+
if (name === 'sendgrid') {
|
|
2665
|
+
return 'sendgrid';
|
|
2666
|
+
}
|
|
2667
|
+
if (name === 'SES') {
|
|
2668
|
+
return 'ses';
|
|
2669
|
+
}
|
|
2670
|
+
return 'smtp';
|
|
2671
|
+
};
|
|
2672
|
+
var toErrorMessage = function toErrorMessage(error) {
|
|
2673
|
+
return error instanceof Error ? error.message : String(error);
|
|
2674
|
+
};
|
|
2675
|
+
var deliverEmail = /*#__PURE__*/function () {
|
|
2676
|
+
var _ref2 = startPlugin._asyncToGenerator(/*#__PURE__*/startPlugin._regeneratorRuntime().mark(function _callee(_ref) {
|
|
2677
|
+
var cacheKey, config, message, log, suppression, meta, provider, recipients, suppressed, closed, to, deliveryId, tracking, outbound, result;
|
|
2678
|
+
return startPlugin._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2679
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2680
|
+
case 0:
|
|
2681
|
+
cacheKey = _ref.cacheKey, config = _ref.config, message = _ref.message, log = _ref.log, suppression = _ref.suppression, meta = _ref.meta;
|
|
2682
|
+
provider = getEmailProvider(cacheKey, config);
|
|
2683
|
+
recipients = message;
|
|
2684
|
+
suppressed = [];
|
|
2685
|
+
if (!suppression) {
|
|
2686
|
+
_context.next = 14;
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2689
|
+
_context.next = 7;
|
|
2690
|
+
return suppression.blocked([].concat(startPlugin._toConsumableArray(message.to), startPlugin._toConsumableArray(message.cc || []), startPlugin._toConsumableArray(message.bcc || [])), meta === null || meta === void 0 ? void 0 : meta.source);
|
|
2691
|
+
case 7:
|
|
2692
|
+
suppressed = _context.sent;
|
|
2693
|
+
if (!suppressed.length) {
|
|
2694
|
+
_context.next = 14;
|
|
2695
|
+
break;
|
|
2696
|
+
}
|
|
2697
|
+
closed = new Set(suppressed);
|
|
2698
|
+
to = message.to.filter(function (email) {
|
|
2699
|
+
return !closed.has(email);
|
|
2700
|
+
});
|
|
2701
|
+
if (to.length) {
|
|
2702
|
+
_context.next = 13;
|
|
2703
|
+
break;
|
|
2704
|
+
}
|
|
2705
|
+
return _context.abrupt("return", {
|
|
2706
|
+
messageId: '',
|
|
2707
|
+
provider: provider.name,
|
|
2708
|
+
accepted: [],
|
|
2709
|
+
rejected: [],
|
|
2710
|
+
skipped: true,
|
|
2711
|
+
suppressed: suppressed
|
|
2712
|
+
});
|
|
2713
|
+
case 13:
|
|
2714
|
+
recipients = startPlugin._objectSpread2(startPlugin._objectSpread2({}, message), {}, {
|
|
2715
|
+
to: to,
|
|
2716
|
+
cc: (message.cc || []).filter(function (email) {
|
|
2717
|
+
return !closed.has(email);
|
|
2718
|
+
}),
|
|
2719
|
+
bcc: (message.bcc || []).filter(function (email) {
|
|
2720
|
+
return !closed.has(email);
|
|
2721
|
+
})
|
|
2722
|
+
});
|
|
2723
|
+
case 14:
|
|
2724
|
+
if (!log) {
|
|
2725
|
+
_context.next = 24;
|
|
2726
|
+
break;
|
|
2727
|
+
}
|
|
2728
|
+
_context.prev = 15;
|
|
2729
|
+
_context.next = 18;
|
|
2730
|
+
return log.create({
|
|
2731
|
+
toEmails: recipients.to,
|
|
2732
|
+
ccEmails: recipients.cc,
|
|
2733
|
+
from: recipients.from,
|
|
2734
|
+
subject: recipients.subject,
|
|
2735
|
+
provider: provider.name,
|
|
2736
|
+
source: meta === null || meta === void 0 ? void 0 : meta.source,
|
|
2737
|
+
sourceId: meta === null || meta === void 0 ? void 0 : meta.sourceId,
|
|
2738
|
+
userId: meta === null || meta === void 0 ? void 0 : meta.userId,
|
|
2739
|
+
notificationId: meta === null || meta === void 0 ? void 0 : meta.notificationId
|
|
2740
|
+
});
|
|
2741
|
+
case 18:
|
|
2742
|
+
deliveryId = _context.sent;
|
|
2743
|
+
_context.next = 24;
|
|
2744
|
+
break;
|
|
2745
|
+
case 21:
|
|
2746
|
+
_context.prev = 21;
|
|
2747
|
+
_context.t0 = _context["catch"](15);
|
|
2748
|
+
console.error("Failed to record email delivery: ".concat(toErrorMessage(_context.t0)));
|
|
2749
|
+
case 24:
|
|
2750
|
+
tracking = startPlugin._objectSpread2(startPlugin._objectSpread2({}, deliveryId ? startPlugin._defineProperty({}, EMAIL_DELIVERY_ID_KEY, deliveryId) : {}), meta !== null && meta !== void 0 && meta.subdomain ? startPlugin._defineProperty({}, EMAIL_SUBDOMAIN_KEY, meta.subdomain) : {});
|
|
2751
|
+
outbound = Object.keys(tracking).length ? startPlugin._objectSpread2(startPlugin._objectSpread2({}, recipients), {}, {
|
|
2752
|
+
customArgs: startPlugin._objectSpread2(startPlugin._objectSpread2({}, recipients.customArgs || {}), tracking)
|
|
2753
|
+
}) : recipients;
|
|
2754
|
+
_context.prev = 26;
|
|
2755
|
+
_context.next = 29;
|
|
2756
|
+
return provider.send(outbound);
|
|
2757
|
+
case 29:
|
|
2758
|
+
result = _context.sent;
|
|
2759
|
+
if (!(log && deliveryId)) {
|
|
2760
|
+
_context.next = 33;
|
|
2761
|
+
break;
|
|
2762
|
+
}
|
|
2763
|
+
_context.next = 33;
|
|
2764
|
+
return log.update(deliveryId, {
|
|
2765
|
+
status: 'sent',
|
|
2766
|
+
sentAt: new Date(),
|
|
2767
|
+
messageId: result.messageId,
|
|
2768
|
+
rejected: result.rejected
|
|
2769
|
+
})["catch"](function (error) {
|
|
2770
|
+
console.error("Failed to update email delivery: ".concat(toErrorMessage(error)));
|
|
2771
|
+
});
|
|
2772
|
+
case 33:
|
|
2773
|
+
return _context.abrupt("return", startPlugin._objectSpread2(startPlugin._objectSpread2({}, result), {}, {
|
|
2774
|
+
deliveryId: deliveryId,
|
|
2775
|
+
suppressed: suppressed.length ? suppressed : undefined
|
|
2776
|
+
}));
|
|
2777
|
+
case 36:
|
|
2778
|
+
_context.prev = 36;
|
|
2779
|
+
_context.t1 = _context["catch"](26);
|
|
2780
|
+
if (!(log && deliveryId)) {
|
|
2781
|
+
_context.next = 41;
|
|
2782
|
+
break;
|
|
2783
|
+
}
|
|
2784
|
+
_context.next = 41;
|
|
2785
|
+
return log.update(deliveryId, {
|
|
2786
|
+
status: 'failed',
|
|
2787
|
+
sentAt: new Date(),
|
|
2788
|
+
error: toErrorMessage(_context.t1)
|
|
2789
|
+
})["catch"](function () {
|
|
2790
|
+
return undefined;
|
|
2791
|
+
});
|
|
2792
|
+
case 41:
|
|
2793
|
+
throw _context.t1;
|
|
2794
|
+
case 42:
|
|
2795
|
+
case "end":
|
|
2796
|
+
return _context.stop();
|
|
2797
|
+
}
|
|
2798
|
+
}, _callee, null, [[15, 21], [26, 36]]);
|
|
2799
|
+
}));
|
|
2800
|
+
return function deliverEmail(_x) {
|
|
2801
|
+
return _ref2.apply(this, arguments);
|
|
2802
|
+
};
|
|
2803
|
+
}();
|
|
2804
|
+
|
|
2805
|
+
exports.AGENT_TOOL_DEFAULT_MAX_RESPONSE_BYTES = startPlugin.AGENT_TOOL_DEFAULT_MAX_RESPONSE_BYTES;
|
|
2806
|
+
exports.DEFAULT_JOB_OPTIONS = startPlugin.DEFAULT_JOB_OPTIONS;
|
|
2807
|
+
exports.EXPECTED_ERROR_NAME = startPlugin.EXPECTED_ERROR_NAME;
|
|
2808
|
+
exports.ExpectedError = startPlugin.ExpectedError;
|
|
2809
|
+
exports.HEADER_SIZE_WARN_BYTES = startPlugin.HEADER_SIZE_WARN_BYTES;
|
|
2810
|
+
exports.MAX_HEADER_BYTES = startPlugin.MAX_HEADER_BYTES;
|
|
2811
|
+
exports.ORGANIZATION_ID_MAPPING = startPlugin.ORGANIZATION_ID_MAPPING;
|
|
2812
|
+
exports.TBeforeResolversProducers = startPlugin.TBeforeResolversProducers;
|
|
2813
|
+
exports.USER_HEADER_OMITTED_FIELDS = startPlugin.USER_HEADER_OMITTED_FIELDS;
|
|
2814
|
+
exports.agentToolResponseTooLargeError = startPlugin.agentToolResponseTooLargeError;
|
|
2815
|
+
exports.agentToolsAuthHeaderName = startPlugin.agentToolsAuthHeaderName;
|
|
2816
|
+
exports.apolloCustomScalars = startPlugin.apolloCustomScalars;
|
|
2817
|
+
exports.applyTrustProxy = startPlugin.applyTrustProxy;
|
|
2818
|
+
exports.authCookieOptions = startPlugin.authCookieOptions;
|
|
2819
|
+
exports.buildAgentToolManifest = startPlugin.buildAgentToolManifest;
|
|
2820
|
+
exports.buildCursorQuery = startPlugin.buildCursorQuery;
|
|
2821
|
+
exports.buildSearchTokenFilter = startPlugin.buildSearchTokenFilter;
|
|
2822
|
+
exports.checkBeforeResolvers = startPlugin.checkBeforeResolvers;
|
|
2823
|
+
exports.checkCollectionCodeDuplication = startPlugin.checkCollectionCodeDuplication;
|
|
2824
|
+
exports.checkServiceRunning = startPlugin.checkServiceRunning;
|
|
2825
|
+
exports.checkUserIds = startPlugin.checkUserIds;
|
|
2826
|
+
exports.chunkArray = startPlugin.chunkArray;
|
|
2827
|
+
exports.classifyError = startPlugin.classifyError;
|
|
2828
|
+
exports.cleanHtml = startPlugin.cleanHtml;
|
|
2829
|
+
exports.clearServiceDiscoveryCache = startPlugin.clearServiceDiscoveryCache;
|
|
2830
|
+
exports.clientPortalHeaderName = startPlugin.clientPortalHeaderName;
|
|
2831
|
+
exports.closeMongooose = startPlugin.closeMongooose;
|
|
2832
|
+
exports.compactUserForHeader = startPlugin.compactUserForHeader;
|
|
2833
|
+
exports.configureSchemaSearchTokens = startPlugin.configureSchemaSearchTokens;
|
|
2834
|
+
exports.connect = startPlugin.connect;
|
|
2835
|
+
exports.connectionOptions = startPlugin.connectionOptions;
|
|
2836
|
+
Object.defineProperty(exports, 'coreModelAddons', {
|
|
2837
|
+
enumerable: true,
|
|
2838
|
+
get: function () { return startPlugin.coreModelAddons; }
|
|
2839
|
+
});
|
|
2840
|
+
Object.defineProperty(exports, 'coreModelBundles', {
|
|
2841
|
+
enumerable: true,
|
|
2842
|
+
get: function () { return startPlugin.coreModelBundles; }
|
|
2843
|
+
});
|
|
2844
|
+
Object.defineProperty(exports, 'coreModelEndpoints', {
|
|
2845
|
+
enumerable: true,
|
|
2846
|
+
get: function () { return startPlugin.coreModelEndpoints; }
|
|
2847
|
+
});
|
|
2848
|
+
Object.defineProperty(exports, 'coreModelExperiences', {
|
|
2849
|
+
enumerable: true,
|
|
2850
|
+
get: function () { return startPlugin.coreModelExperiences; }
|
|
2851
|
+
});
|
|
2852
|
+
Object.defineProperty(exports, 'coreModelInstallations', {
|
|
2853
|
+
enumerable: true,
|
|
2854
|
+
get: function () { return startPlugin.coreModelInstallations; }
|
|
2855
|
+
});
|
|
2856
|
+
Object.defineProperty(exports, 'coreModelOrganizationPlanHistories', {
|
|
2857
|
+
enumerable: true,
|
|
2858
|
+
get: function () { return startPlugin.coreModelOrganizationPlanHistories; }
|
|
2859
|
+
});
|
|
2860
|
+
Object.defineProperty(exports, 'coreModelOrganizations', {
|
|
2861
|
+
enumerable: true,
|
|
2862
|
+
get: function () { return startPlugin.coreModelOrganizations; }
|
|
2863
|
+
});
|
|
2864
|
+
Object.defineProperty(exports, 'coreModelPlugins', {
|
|
2865
|
+
enumerable: true,
|
|
2866
|
+
get: function () { return startPlugin.coreModelPlugins; }
|
|
2867
|
+
});
|
|
2868
|
+
Object.defineProperty(exports, 'coreModelPromoCodes', {
|
|
2869
|
+
enumerable: true,
|
|
2870
|
+
get: function () { return startPlugin.coreModelPromoCodes; }
|
|
2871
|
+
});
|
|
2872
|
+
Object.defineProperty(exports, 'coreModelUsers', {
|
|
2873
|
+
enumerable: true,
|
|
2874
|
+
get: function () { return startPlugin.coreModelUsers; }
|
|
2875
|
+
});
|
|
2876
|
+
exports.cpUserHeaderName = startPlugin.cpUserHeaderName;
|
|
2877
|
+
exports.createExpectedError = startPlugin.createExpectedError;
|
|
2878
|
+
exports.createHealthRoute = startPlugin.createHealthRoute;
|
|
2879
|
+
exports.createMQWorkerWithListeners = startPlugin.createMQWorkerWithListeners;
|
|
2880
|
+
exports.createPluginTRPCContext = startPlugin.createPluginTRPCContext;
|
|
2881
|
+
exports.createTRPCContext = startPlugin.createTRPCContext;
|
|
2882
|
+
exports.cursorPaginate = startPlugin.cursorPaginate;
|
|
2883
|
+
exports.cursorPaginateAggregation = startPlugin.cursorPaginateAggregation;
|
|
2884
|
+
exports.dateToShortStr = startPlugin.dateToShortStr;
|
|
2885
|
+
exports.decodeAgentToolsAuthHeader = startPlugin.decodeAgentToolsAuthHeader;
|
|
2886
|
+
exports.decodeCursor = startPlugin.decodeCursor;
|
|
2887
|
+
exports.decodeTRPCContextHeader = startPlugin.decodeTRPCContextHeader;
|
|
2888
|
+
exports.defaultPaginate = startPlugin.defaultPaginate;
|
|
2889
|
+
exports.encodeAgentToolsAuthHeader = startPlugin.encodeAgentToolsAuthHeader;
|
|
2890
|
+
exports.encodeCursor = startPlugin.encodeCursor;
|
|
2891
|
+
exports.encodeTRPCContextHeader = startPlugin.encodeTRPCContextHeader;
|
|
2892
|
+
exports.err = startPlugin.err;
|
|
2893
|
+
exports.escapeRegExp = startPlugin.escapeRegExp;
|
|
2894
|
+
exports.expectedErrorPlugin = startPlugin.expectedErrorPlugin;
|
|
2895
|
+
exports.extractCPUserFromHeader = startPlugin.extractCPUserFromHeader;
|
|
2896
|
+
exports.extractClientPortalFromHeader = startPlugin.extractClientPortalFromHeader;
|
|
2897
|
+
exports.extractMessage = startPlugin.extractMessage;
|
|
2898
|
+
exports.extractUserFromHeader = startPlugin.extractUserFromHeader;
|
|
2899
|
+
exports.fixDate = startPlugin.fixDate;
|
|
2900
|
+
exports.fixNum = startPlugin.fixNum;
|
|
2901
|
+
exports.flattenObject = startPlugin.flattenObject;
|
|
2902
|
+
exports.generateApolloContext = startPlugin.generateApolloContext;
|
|
2903
|
+
exports.generateConfiguredSearchTokens = startPlugin.generateConfiguredSearchTokens;
|
|
2904
|
+
exports.generateRequestProcess = startPlugin.generateRequestProcess;
|
|
2905
|
+
exports.getActivePlugins = startPlugin.getActivePlugins;
|
|
2906
|
+
exports.getAgentToolMaxResponseBytes = startPlugin.getAgentToolMaxResponseBytes;
|
|
2907
|
+
exports.getAvailablePlugins = startPlugin.getAvailablePlugins;
|
|
2908
|
+
exports.getCoreDomain = startPlugin.getCoreDomain;
|
|
2909
|
+
exports.getDate = startPlugin.getDate;
|
|
2910
|
+
exports.getDiffObjects = startPlugin.getDiffObjects;
|
|
2911
|
+
exports.getEnv = startPlugin.getEnv;
|
|
2912
|
+
exports.getFullDate = startPlugin.getFullDate;
|
|
2913
|
+
exports.getNextMonth = startPlugin.getNextMonth;
|
|
2914
|
+
exports.getPlugin = startPlugin.getPlugin;
|
|
2915
|
+
exports.getPluginAddress = startPlugin.getPluginAddress;
|
|
2916
|
+
exports.getPlugins = startPlugin.getPlugins;
|
|
2917
|
+
exports.getPureDate = startPlugin.getPureDate;
|
|
2918
|
+
exports.getSaasCoreConnection = startPlugin.getSaasCoreConnection;
|
|
2919
|
+
exports.getSaasOrgPromoCodes = startPlugin.getSaasOrgPromoCodes;
|
|
2920
|
+
exports.getSaasOrganizationActiveAddons = startPlugin.getSaasOrganizationActiveAddons;
|
|
2921
|
+
exports.getSaasOrganizationByHelpCenterDomain = startPlugin.getSaasOrganizationByHelpCenterDomain;
|
|
2922
|
+
exports.getSaasOrganizationDetail = startPlugin.getSaasOrganizationDetail;
|
|
2923
|
+
exports.getSaasOrganizationHelpCenterDomains = startPlugin.getSaasOrganizationHelpCenterDomains;
|
|
2924
|
+
exports.getSaasOrganizationIdBySubdomain = startPlugin.getSaasOrganizationIdBySubdomain;
|
|
2925
|
+
exports.getSaasOrganizationPlanHistories = startPlugin.getSaasOrganizationPlanHistories;
|
|
2926
|
+
exports.getSaasOrganizations = startPlugin.getSaasOrganizations;
|
|
2927
|
+
exports.getSaasOrganizationsByFilter = startPlugin.getSaasOrganizationsByFilter;
|
|
2928
|
+
exports.getSaasOrganizationsWithPendingHelpCenterDomain = startPlugin.getSaasOrganizationsWithPendingHelpCenterDomain;
|
|
2929
|
+
exports.getSaasOrgsCache = startPlugin.getSaasOrgsCache;
|
|
2930
|
+
exports.getSaasPlugin = startPlugin.getSaasPlugin;
|
|
2931
|
+
exports.getSaasPlugins = startPlugin.getSaasPlugins;
|
|
2932
|
+
exports.getSaasPromoCodes = startPlugin.getSaasPromoCodes;
|
|
2933
|
+
exports.getSchemaSearchTokenConfig = startPlugin.getSchemaSearchTokenConfig;
|
|
2934
|
+
exports.getSubdomain = startPlugin.getSubdomain;
|
|
2935
|
+
exports.getToday = startPlugin.getToday;
|
|
2936
|
+
exports.getTomorrow = startPlugin.getTomorrow;
|
|
2937
|
+
exports.getTrustProxySetting = startPlugin.getTrustProxySetting;
|
|
2938
|
+
exports.getUniqueValue = startPlugin.getUniqueValue;
|
|
2939
|
+
exports.graphqlPubsub = startPlugin.graphqlPubsub;
|
|
2940
|
+
exports.helpCenterDomainsOf = startPlugin.helpCenterDomainsOf;
|
|
2941
|
+
exports.initErxesSentry = startPlugin.initErxesSentry;
|
|
2942
|
+
exports.initializePluginConfig = startPlugin.initializePluginConfig;
|
|
2943
|
+
exports.isDev = startPlugin.isDev;
|
|
2944
|
+
exports.isEnabled = startPlugin.isEnabled;
|
|
2945
|
+
exports.isExpectedError = startPlugin.isExpectedError;
|
|
2946
|
+
exports.isImage = startPlugin.isImage;
|
|
2947
|
+
exports.isValidURL = startPlugin.isValidURL;
|
|
2948
|
+
exports.isVideo = startPlugin.isVideo;
|
|
2949
|
+
exports.joinErxesGateway = startPlugin.joinErxesGateway;
|
|
2950
|
+
exports.keyForConfig = startPlugin.keyForConfig;
|
|
2951
|
+
exports.leaveErxesGateway = startPlugin.leaveErxesGateway;
|
|
2952
|
+
exports.logHandler = startPlugin.logHandler;
|
|
2953
|
+
exports.markResolvers = startPlugin.markResolvers;
|
|
2954
|
+
exports.mongoStringRequired = startPlugin.mongoStringRequired;
|
|
2955
|
+
exports.mongooseConnectionOptions = startPlugin.mongooseConnectionOptions;
|
|
2956
|
+
exports.mongooseField = startPlugin.mongooseField;
|
|
2957
|
+
exports.mongooseStringNonBlank = startPlugin.mongooseStringNonBlank;
|
|
2958
|
+
exports.mongooseStringRandomId = startPlugin.mongooseStringRandomId;
|
|
2959
|
+
exports.mongooseStringRequiredNonBlank = startPlugin.mongooseStringRequiredNonBlank;
|
|
2960
|
+
exports.mountAgentTools = startPlugin.mountAgentTools;
|
|
2961
|
+
exports.ok = startPlugin.ok;
|
|
2962
|
+
exports.oversizedAgentToolResultBytes = startPlugin.oversizedAgentToolResultBytes;
|
|
2963
|
+
exports.paginate = startPlugin.paginate;
|
|
2964
|
+
exports.pluralFormation = startPlugin.pluralFormation;
|
|
2965
|
+
exports.random = startPlugin.random;
|
|
2966
|
+
exports.randomAlphanumeric = startPlugin.randomAlphanumeric;
|
|
2967
|
+
exports.randomLowercase = startPlugin.randomLowercase;
|
|
2968
|
+
exports.readFileFromStorage = startPlugin.readFileFromStorage;
|
|
2969
|
+
exports.readFileStreamFromStorage = startPlugin.readFileStreamFromStorage;
|
|
2970
|
+
exports.readFileUrl = startPlugin.readFileUrl;
|
|
2971
|
+
exports.redis = startPlugin.redis;
|
|
2972
|
+
exports.regexSearchText = startPlugin.regexSearchText;
|
|
2973
|
+
exports.removeExtraSpaces = startPlugin.removeExtraSpaces;
|
|
2974
|
+
exports.removeLastTrailingSlash = startPlugin.removeLastTrailingSlash;
|
|
2975
|
+
exports.removeOrgsCache = startPlugin.removeOrgsCache;
|
|
2976
|
+
exports.removeSaasOrganizationHelpCenterDomain = startPlugin.removeSaasOrganizationHelpCenterDomain;
|
|
2977
|
+
exports.resetConfigsCache = startPlugin.resetConfigsCache;
|
|
2978
|
+
exports.runBeforeResolvers = startPlugin.runBeforeResolvers;
|
|
2979
|
+
exports.sanitizeFilename = startPlugin.sanitizeFilename;
|
|
2980
|
+
exports.sanitizeKey = startPlugin.sanitizeKey;
|
|
2981
|
+
exports.saveSaasOrganizationHelpCenterDomain = startPlugin.saveSaasOrganizationHelpCenterDomain;
|
|
2982
|
+
exports.schemaWrapper = startPlugin.schemaWrapper;
|
|
2983
|
+
exports.sendCoreModuleProducer = startPlugin.sendCoreModuleProducer;
|
|
2984
|
+
exports.sendTRPCMessage = startPlugin.sendTRPCMessage;
|
|
2985
|
+
exports.sendWorkerMessage = startPlugin.sendWorkerMessage;
|
|
2986
|
+
exports.sendWorkerQueue = startPlugin.sendWorkerQueue;
|
|
2987
|
+
exports.sentryExpectedErrorFilter = startPlugin.sentryExpectedErrorFilter;
|
|
2988
|
+
exports.setActivePlugins = startPlugin.setActivePlugins;
|
|
2989
|
+
exports.setCPUserHeader = startPlugin.setCPUserHeader;
|
|
2990
|
+
exports.setClientPortalHeader = startPlugin.setClientPortalHeader;
|
|
2991
|
+
exports.setUserHeader = startPlugin.setUserHeader;
|
|
2992
|
+
exports.shortStrToDate = startPlugin.shortStrToDate;
|
|
2993
|
+
exports.splitSearchWords = startPlugin.splitSearchWords;
|
|
2994
|
+
exports.splitStr = startPlugin.splitStr;
|
|
2995
|
+
exports.startAfterProcess = startPlugin.startAfterProcess;
|
|
2996
|
+
exports.startBeforeResolvers = startPlugin.startBeforeResolvers;
|
|
2997
|
+
exports.startPlugin = startPlugin.startPlugin;
|
|
2998
|
+
exports.stripAnsi = startPlugin.stripAnsi;
|
|
2999
|
+
exports.toSerializablePayload = startPlugin.toSerializablePayload;
|
|
3000
|
+
exports.trpcContextHeaderName = startPlugin.trpcContextHeaderName;
|
|
3001
|
+
exports.updateMongoDocumentOrder = startPlugin.updateMongoDocumentOrder;
|
|
3002
|
+
exports.updateOrder = startPlugin.updateOrder;
|
|
3003
|
+
exports.updateSaasOrganization = startPlugin.updateSaasOrganization;
|
|
3004
|
+
exports.uploadFileToStorage = startPlugin.uploadFileToStorage;
|
|
3005
|
+
exports.userHeaderName = startPlugin.userHeaderName;
|
|
3006
|
+
exports.validSearchText = startPlugin.validSearchText;
|
|
3007
|
+
exports.wrapApolloResolvers = startPlugin.wrapApolloResolvers;
|
|
3008
|
+
exports.CONFORMITY_TYPE = CONFORMITY_TYPE;
|
|
3009
|
+
exports.DEFAULT_EMAIL_PROVIDER = DEFAULT_EMAIL_PROVIDER;
|
|
3010
|
+
exports.DEFAULT_SEX_CHOICES = DEFAULT_SEX_CHOICES;
|
|
3011
|
+
exports.DEFAULT_SOCIAL_LINKS = DEFAULT_SOCIAL_LINKS;
|
|
3012
|
+
exports.EMAIL_DELIVERY_ID_KEY = EMAIL_DELIVERY_ID_KEY;
|
|
3013
|
+
exports.EMAIL_PROVIDER_CONFIG_CODES = EMAIL_PROVIDER_CONFIG_CODES;
|
|
3014
|
+
exports.EMAIL_SUBDOMAIN_KEY = EMAIL_SUBDOMAIN_KEY;
|
|
3015
|
+
exports.EditorAttributeUtil = EditorAttributeUtil;
|
|
3016
|
+
exports.EmailProviderConfigError = EmailProviderConfigError;
|
|
3017
|
+
exports.EmailProviderNotSupportedError = EmailProviderNotSupportedError;
|
|
3018
|
+
exports.EmailProviderRequestError = EmailProviderRequestError;
|
|
3019
|
+
exports.GQL_CURSOR_PARAM_DEFS = GQL_CURSOR_PARAM_DEFS;
|
|
3020
|
+
exports.GQL_OFFSET_PARAM_DEFS = GQL_OFFSET_PARAM_DEFS;
|
|
3021
|
+
exports.LOG_STATUSES = LOG_STATUSES;
|
|
3022
|
+
exports.PERMISSION_ROLES = PERMISSION_ROLES;
|
|
3023
|
+
exports.SENDGRID_API_BASE_URL = SENDGRID_API_BASE_URL;
|
|
3024
|
+
exports.SENDGRID_SIGNATURE_HEADER = SENDGRID_SIGNATURE_HEADER;
|
|
3025
|
+
exports.SENDGRID_TIMESTAMP_HEADER = SENDGRID_TIMESTAMP_HEADER;
|
|
3026
|
+
exports.SES_DKIM_CNAME_SUFFIX = SES_DKIM_CNAME_SUFFIX;
|
|
3027
|
+
exports.SEX_OPTIONS = SEX_OPTIONS;
|
|
3028
|
+
exports.SOCIAL_LINKS = SOCIAL_LINKS;
|
|
3029
|
+
exports.STATUSES = STATUSES;
|
|
3030
|
+
exports.SendgridEmailProvider = SendgridEmailProvider;
|
|
3031
|
+
exports.SesEmailProvider = SesEmailProvider;
|
|
3032
|
+
exports.SmtpEmailProvider = SmtpEmailProvider;
|
|
3033
|
+
exports.USER_ROLES = USER_ROLES;
|
|
3034
|
+
exports.alignSender = alignSender;
|
|
3035
|
+
exports.apolloCommonTypes = apolloCommonTypes;
|
|
3036
|
+
exports.buildKnowledgeSourceType = buildKnowledgeSourceType;
|
|
3037
|
+
exports.clearEmailProviderCache = clearEmailProviderCache;
|
|
3038
|
+
exports.createEmailProvider = createEmailProvider;
|
|
3039
|
+
exports.createGenerateModels = createGenerateModels;
|
|
3040
|
+
exports.deliverEmail = deliverEmail;
|
|
3041
|
+
exports.enqueueAiKnowledgeSourceRefreshJob = enqueueAiKnowledgeSourceRefreshJob;
|
|
3042
|
+
exports.enqueueKnowledgeIndexJob = enqueueKnowledgeIndexJob;
|
|
3043
|
+
exports.erxesSubdomainHeaderName = erxesSubdomainHeaderName;
|
|
3044
|
+
exports.getCustomerName = getCustomerName;
|
|
3045
|
+
exports.getEmailProvider = getEmailProvider;
|
|
3046
|
+
exports.getEmailProviderConfigFingerprint = getEmailProviderConfigFingerprint;
|
|
3047
|
+
exports.getHostnameZeroTrust = getHostnameZeroTrust;
|
|
3048
|
+
exports.getSubomdainHeader = getSubomdainHeader;
|
|
3049
|
+
exports.graphqlAttachmentInput = graphqlAttachmentInput;
|
|
3050
|
+
exports.graphqlAttachmentType = graphqlAttachmentType;
|
|
3051
|
+
exports.graphqlPaginationInfo = graphqlPaginationInfo;
|
|
3052
|
+
exports.graphqlPdfAttachmentInput = graphqlPdfAttachmentInput;
|
|
3053
|
+
exports.graphqlPdfAttachmentType = graphqlPdfAttachmentType;
|
|
3054
|
+
exports.loadEmailProviderConfig = loadEmailProviderConfig;
|
|
3055
|
+
exports.normalizeEmail = normalizeEmail;
|
|
3056
|
+
exports.parseAddress = parseAddress;
|
|
3057
|
+
exports.resolveDefaultSenderEmail = resolveDefaultSenderEmail;
|
|
3058
|
+
exports.resolveEmailProviderName = resolveEmailProviderName;
|
|
3059
|
+
exports.runReplacersOn = runReplacersOn;
|
|
3060
|
+
exports.sanitizeHeaders = sanitizeHeaders;
|
|
3061
|
+
exports.stream = stream;
|
|
3062
|
+
exports.toBase64Attachment = toBase64Attachment;
|
|
3063
|
+
exports.toBase64Attachments = toBase64Attachments;
|
|
3064
|
+
exports.toDeliveryLogProvider = toDeliveryLogProvider;
|
|
3065
|
+
exports.verifySendgridSignature = verifySendgridSignature;
|
|
3066
|
+
exports.wrapApolloMutations = wrapApolloMutations;
|