@erxes/api-shared 3.2.21-2 → 3.2.25-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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var startPlugin = require('../../dist/start-plugin-b6f1292f.cjs.dev.js');
5
+ var startPlugin = require('../../dist/start-plugin-6687b329.cjs.dev.js');
6
6
  var dayjs = require('dayjs');
7
7
  require('node-fetch');
8
8
  var nanoid = require('nanoid');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var startPlugin = require('../../dist/start-plugin-8812291a.cjs.prod.js');
5
+ var startPlugin = require('../../dist/start-plugin-46baacee.cjs.prod.js');
6
6
  var dayjs = require('dayjs');
7
7
  require('node-fetch');
8
8
  var nanoid = require('nanoid');
@@ -1,5 +1,5 @@
1
- import { _ as _asyncToGenerator, a as _regeneratorRuntime, x as _toConsumableArray, c9 as isSameRecordReferenceType, i as _objectSpread2, k as _createForOfIteratorHelper, ca as normalizeRecordReferenceTypes, cb as normalizeRecordReferenceExtensions, b6 as getPlugin, b1 as getPlugins, cc as propertyDataPath, cd as toPropertyRowKey, ce as getLocalRecordReferenceType, cf as getRecordReferencePluginName, cg as _typeof, h as _slicedToArray, ch as resolveRecordReferenceValue, ci as _toArray, cj as AUTOMATION_ERROR_CODES, s as sendWorkerQueue, ck as _objectWithoutProperties, cl as _toPropertyKey, cm as replaceOutputPlaceholders, ap as redis, p as sendTRPCMessage, cn as SEGMENT_MEMBERSHIP_FIELD, co as parsePropertyDataKey, cp as toPropertyGroupKey, cq as walkSegmentNodes, cr as segmentFieldRef, cs as segmentReferenceRef, ct as segmentRelationRef, cu as DEFAULT_SEGMENT_TIME_ZONE, cv as normalizeSegmentOperator, cw as SegmentOperator, cx as PERIOD_OPERATORS, cy as zonedPeriodRange, cz as shiftZonedDays, cA as zonedDate, cB as isAnniversary, w as _defineProperty, cC as compileSegmentMongoFilter, g as getEnv, cD as gatherSegmentRelations, bu as escapeRegExp, cE as mergePropertyRowConditions, cF as parsePropertyColumnKey, cG as isPropertyGroupKey, cH as propertyGroupIdFromKey, cI as toPropertyRowColumnKey, cJ as PROPERTIES_DATA, cK as logActivityLogError, cL as matchesFieldPattern$1, cM as findResolver, cN as getSnapshot, cO as detectAssignmentDelta, c2 as ExpectedError, m as _createClass, n as _classCallCheck } from '../../dist/start-plugin-6a677721.esm.js';
2
- export { fE as APPROVAL_APPROVER_SCOPES, fI as APPROVAL_DECISIONS, fD as APPROVAL_LOCK_STATUSES, fF as APPROVAL_MODES, fK as APPROVAL_NOTIFICATION_ACTIONS, fJ as APPROVAL_NOTIFICATION_CONTENT_TYPE, fH as APPROVAL_REQUEST_KINDS, fG as APPROVAL_REQUEST_STATUSES, dD as AUTOMATION_CORE_ACTIONS, dI as AUTOMATION_CORE_ACTION_DEFERRED, dE as AUTOMATION_CORE_TRIGGER_TYPES, dJ as AUTOMATION_DEFERRED_TIMEOUT, dG as AUTOMATION_EMAIL_RECIPIENTS_TYPES, cj as AUTOMATION_ERROR_CODES, dR as AUTOMATION_EXECUTION_STATUS, dH as AUTOMATION_NON_DEFERRABLE_CORE_ACTIONS, dX as AUTOMATION_OUTPUT_ITEM_COUNT, dA as AUTOMATION_PROPERTY_OPERATORS, dC as AUTOMATION_STATUSES, ge as AUTO_MATCH_CONFIDENCE, f3 as ApplyMembershipInput, e7 as AutomationActionInput, e4 as AutomationBaseInput, e5 as AutomationExecActionInput, e6 as AutomationExecutionInput, dL as BROADCAST_TARGET_TYPE, dK as BROADCAST_TRIGGER_TYPE, g5 as BatchSkipRowInput, d3 as COMPANY_BUSINESS_TYPES, d5 as COMPANY_INDUSTRY_TYPES, df as CUSTOMER_SELECT_OPTIONS, eh as CheckCustomTriggerInput, ea as CheckCustomTriggerInputData, f2 as CountSegmentMembersInput, d4 as DEFAULT_COMPANY_INDUSTRY_TYPES, da as DEFAULT_CONSTANT_VALUES, cu as DEFAULT_SEGMENT_TIME_ZONE, eS as DEFAULT_SEGMENT_VALUE_FIELD, d8 as DEFAULT_SEX_CHOICES, d6 as DEFAULT_SOCIAL_LINKS, fn as EMAIL_LANES, fq as EMAIL_RAMP_ID, dN as EXECUTE_WAIT_TYPES, f0 as EvaluateFieldsInput, ei as FindObjectInput, eb as FindObjectInputData, el as GenerateAiContextInput, ee as GenerateAiContextInputData, g6 as GetExportDataInput, g4 as GetExportHeadersInput, g8 as GetImportHeadersInput, g9 as GetImportHeadersOutput, di as INPUT_TYPE, g3 as InsertImportRowsInput, g0 as InsertImportRowsInputSchema, g7 as InsertImportRowsOutput, f1 as ListSegmentMembersInput, em as LoadAiKnowledgeDocumentBatchInput, ef as LoadAiKnowledgeDocumentBatchInputData, en as LookupAiToolInput, eg as LookupAiToolInputData, cx as PERIOD_OPERATORS, cJ as PROPERTIES_DATA, f6 as PROPERTY_ANY_ROW_KEY_SEP, f4 as PROPERTY_GROUP_KEY_PREFIX, fb as PROPERTY_ROW_INDEX_SEP, f5 as PROPERTY_ROW_KEY_SEP, fe as PropertyValueUsageInput, e9 as ReceiveActionsInput, e8 as ReceiveActionsInputData, ej as ResolveOutputPathsInput, ec as ResolveOutputPathsInputData, ev as SEGMENT_BOOLEAN_OPERATORS, eu as SEGMENT_DATE_OPERATORS, es as SEGMENT_ID_OPERATORS, eX as SEGMENT_IMPLICIT_OPERATORS, cn as SEGMENT_MEMBERSHIP_FIELD, et as SEGMENT_NUMBER_OPERATORS, eW as SEGMENT_OPERATOR_SPECS, eA as SEGMENT_QUEUES, er as SEGMENT_TEXT_OPERATORS, d9 as SEX_OPTIONS, d7 as SOCIAL_LINKS, dB as STATIC_PLACEHOLDER, d2 as STATUSES, dd as STRUCTURE_STATUSES, gf as SUGGEST_CONFIDENCE, e$ as SegmentBaseInput, ew as SegmentField, e_ as SegmentNodeSchema, cw as SegmentOperator, ek as SetPropertiesInput, ed as SetPropertiesInputData, fL as TApprovalChangeProducers, dP as TAutomationActionFolks, dF as TAutomationFindObjectType, dO as TAutomationProducers, g1 as TImportExportProducers, fd as TPropertyProducers, eZ as TSegmentProducers, fg as UNKNOWN_VALUE_COUNTS, ff as UNKNOWN_VALUE_SAMPLES, dh as USER_EXPORT_EXTENDED_FIELDS, dg as USER_EXTENDED_FIELDS, de as USER_MOVEMENT_STATUSES, dc as USER_PROPERTIES_INFO, db as USER_ROLES, fZ as USER_TYPES, fm as activityLogsSchema, dT as aiAgentSchema, eO as anniversaryRanges, dr as appSchema, fQ as approvalChangeApplyInputSchema, fy as approvalChangePluginName, fM as approvalLockCheckInputSchema, fO as approvalLockCreateInputSchema, fN as approvalLockStatesInputSchema, fP as approvalRequestCreateInputSchema, dl as attachmentSchema, dS as automationExecutionSchema, dQ as automationSchema, e3 as buildRuntimeOutputsIndex, ds as buildSetPropertyModifier, cX as canGroup, cT as checkLogin, c_ as checkPermissionGroup, cW as clearGroupActionsCache, fR as clientPortalSchema, eQ as collectSegmentReferences, eP as collectSegmentValueRefs, f_ as commentSchema, cC as compileSegmentMongoFilter, gj as countCsvDataRows, fS as cpNotificationConfigUserSchema, f$ as cpNotificationSchema, fU as cpNotificationSettingsSchema, fT as cpTwoFactor, fY as cpUserSchema, dn as createEventHandlers, f as createScopedEventHandlers, dj as customFieldSchema, cO as detectAssignmentDelta, fo as emailAddressSchema, fp as emailDeliverySchema, fr as emailRampSchema, fs as emailSenderSchema, fX as fcmDeviceSchema, f8 as fieldIdFromPropertyDataPath, cM as findResolver, eI as gatherSegmentEventTypes, eK as gatherSegmentFieldSources, eL as gatherSegmentJoinPaths, eJ as gatherSegmentRecordTypes, cD as gatherSegmentRelations, dq as generateEventHandlersFromRequest, e0 as getAutomationNodeType, dv as getContentType, cV as getGroupActionsMap, ga as getImportExportJobOptions, dw as getModuleName, dx as getPluginName, dt as getSetPropertySelector, cN as getSnapshot, dM as getTriggerTargetType, dW as getValueByPath, cY as hasDeclaredOAuthScopes, eR as hasSegmentReferenceInRelation, fC as initApproval, fc as initPropertyProducers, dm as initRecordReferences, eY as initSegmentProducers, cB as isAnniversary, eN as isLeapYear, f7 as isPropertyDataPath, cG as isPropertyGroupKey, dY as isReEnrollableTrigger, dZ as isReEnrollingTrigger, fA as localApprovalChangeType, cK as logActivityLogError, gc as logImportExportEvent, fl as logsSchema, dV as matchAutomationResolverKey, gh as matchImportHeaders, cL as matchesFieldPattern, fj as measurePropertyValueCounts, fi as measurePropertyValueSamples, fk as measurePropertyValueUsage, cE as mergePropertyRowConditions, fz as normalizeApprovalChangeType, fB as normalizeApprovalConfig, e2 as normalizeAutomationConstantsForTransport, gg as normalizeHeader, cv as normalizeSegmentOperator, ft as notificationSchema, fu as notificationSettingsSchema, fv as notificationZTypeSchema, cF as parsePropertyColumnKey, co as parsePropertyDataKey, cP as permissionGroupSchema, cR as permissionSchema, gi as processCSVStream, f9 as propertyDataExistsFilter, cc as propertyDataPath, fa as propertyDataRegexFilter, cH as propertyGroupIdFromKey, fV as refreshTokenSchema, cm as replaceOutputPlaceholders, cZ as resolveActionOAuthScopes, d_ as resolveAutomationActionInputs, dU as resolveFromSourceField, d$ as resolveOutputPathsByNodeType, ch as resolveRecordReferenceValue, eU as resolveSegmentFieldDependencies, eT as resolveSegmentFieldOperators, eV as resolveSegmentValueField, cS as roleSchema, dk as ruleSchema, gd as safeCleanup, eC as scheduleSegmentReconcile, ey as segmentDependencies, ex as segmentDependencyKey, ez as segmentDependsOnClock, cr as segmentFieldRef, eH as segmentJoinChanges, eB as segmentQueueFor, cs as segmentReferenceRef, ct as segmentRelationRef, eq as sendAutomationDeferredCompletion, ep as sendAutomationRun, eo as sendAutomationTrigger, fw as sendNotification, fx as sendNotificationChannels, eD as sendSegmentChanged, eG as sendSegmentForget, eF as sendSegmentRebuild, eE as sendSegmentReconcile, dp as setEventHandlerRuntimeContext, du as setProperty, cz as shiftZonedDays, fW as socialAuthProviderSchema, dy as splitType, dz as startAutomations, g2 as startImportExportWorker, cp as toPropertyGroupKey, cI as toPropertyRowColumnKey, cd as toPropertyRowKey, gb as toTerminalImportExportError, e1 as toTransportOutput, fh as unknownValueUsage, cQ as userGroupSchema, d1 as userMovemmentSchema, d0 as userSchema, cq as walkSegmentNodes, cU as wrapPermission, c$ as wrapPublicResolver, cA as zonedDate, eM as zonedDayStart, cy as zonedPeriodRange } from '../../dist/start-plugin-6a677721.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regeneratorRuntime, x as _toConsumableArray, c9 as isSameRecordReferenceType, i as _objectSpread2, k as _createForOfIteratorHelper, ca as normalizeRecordReferenceTypes, cb as normalizeRecordReferenceExtensions, b6 as getPlugin, b1 as getPlugins, cc as propertyDataPath, cd as toPropertyRowKey, ce as getLocalRecordReferenceType, cf as getRecordReferencePluginName, cg as _typeof, h as _slicedToArray, ch as resolveRecordReferenceValue, ci as _toArray, cj as AUTOMATION_ERROR_CODES, s as sendWorkerQueue, ck as _objectWithoutProperties, cl as _toPropertyKey, cm as replaceOutputPlaceholders, ap as redis, p as sendTRPCMessage, cn as SEGMENT_MEMBERSHIP_FIELD, co as parsePropertyDataKey, cp as toPropertyGroupKey, cq as walkSegmentNodes, cr as segmentFieldRef, cs as segmentReferenceRef, ct as segmentRelationRef, cu as DEFAULT_SEGMENT_TIME_ZONE, cv as normalizeSegmentOperator, cw as SegmentOperator, cx as PERIOD_OPERATORS, cy as zonedPeriodRange, cz as shiftZonedDays, cA as zonedDate, cB as isAnniversary, w as _defineProperty, cC as compileSegmentMongoFilter, g as getEnv, cD as gatherSegmentRelations, bu as escapeRegExp, cE as mergePropertyRowConditions, cF as parsePropertyColumnKey, cG as isPropertyGroupKey, cH as propertyGroupIdFromKey, cI as toPropertyRowColumnKey, cJ as PROPERTIES_DATA, cK as logActivityLogError, cL as matchesFieldPattern$1, cM as findResolver, cN as getSnapshot, cO as detectAssignmentDelta, c2 as ExpectedError, m as _createClass, n as _classCallCheck } from '../../dist/start-plugin-2b3e89f5.esm.js';
2
+ export { fE as APPROVAL_APPROVER_SCOPES, fI as APPROVAL_DECISIONS, fD as APPROVAL_LOCK_STATUSES, fF as APPROVAL_MODES, fK as APPROVAL_NOTIFICATION_ACTIONS, fJ as APPROVAL_NOTIFICATION_CONTENT_TYPE, fH as APPROVAL_REQUEST_KINDS, fG as APPROVAL_REQUEST_STATUSES, dD as AUTOMATION_CORE_ACTIONS, dI as AUTOMATION_CORE_ACTION_DEFERRED, dE as AUTOMATION_CORE_TRIGGER_TYPES, dJ as AUTOMATION_DEFERRED_TIMEOUT, dG as AUTOMATION_EMAIL_RECIPIENTS_TYPES, cj as AUTOMATION_ERROR_CODES, dR as AUTOMATION_EXECUTION_STATUS, dH as AUTOMATION_NON_DEFERRABLE_CORE_ACTIONS, dX as AUTOMATION_OUTPUT_ITEM_COUNT, dA as AUTOMATION_PROPERTY_OPERATORS, dC as AUTOMATION_STATUSES, ge as AUTO_MATCH_CONFIDENCE, f3 as ApplyMembershipInput, e7 as AutomationActionInput, e4 as AutomationBaseInput, e5 as AutomationExecActionInput, e6 as AutomationExecutionInput, dL as BROADCAST_TARGET_TYPE, dK as BROADCAST_TRIGGER_TYPE, g5 as BatchSkipRowInput, d3 as COMPANY_BUSINESS_TYPES, d5 as COMPANY_INDUSTRY_TYPES, df as CUSTOMER_SELECT_OPTIONS, eh as CheckCustomTriggerInput, ea as CheckCustomTriggerInputData, f2 as CountSegmentMembersInput, d4 as DEFAULT_COMPANY_INDUSTRY_TYPES, da as DEFAULT_CONSTANT_VALUES, cu as DEFAULT_SEGMENT_TIME_ZONE, eS as DEFAULT_SEGMENT_VALUE_FIELD, d8 as DEFAULT_SEX_CHOICES, d6 as DEFAULT_SOCIAL_LINKS, fn as EMAIL_LANES, fq as EMAIL_RAMP_ID, dN as EXECUTE_WAIT_TYPES, f0 as EvaluateFieldsInput, ei as FindObjectInput, eb as FindObjectInputData, el as GenerateAiContextInput, ee as GenerateAiContextInputData, g6 as GetExportDataInput, g4 as GetExportHeadersInput, g8 as GetImportHeadersInput, g9 as GetImportHeadersOutput, di as INPUT_TYPE, g3 as InsertImportRowsInput, g0 as InsertImportRowsInputSchema, g7 as InsertImportRowsOutput, f1 as ListSegmentMembersInput, em as LoadAiKnowledgeDocumentBatchInput, ef as LoadAiKnowledgeDocumentBatchInputData, en as LookupAiToolInput, eg as LookupAiToolInputData, cx as PERIOD_OPERATORS, cJ as PROPERTIES_DATA, f6 as PROPERTY_ANY_ROW_KEY_SEP, f4 as PROPERTY_GROUP_KEY_PREFIX, fb as PROPERTY_ROW_INDEX_SEP, f5 as PROPERTY_ROW_KEY_SEP, fe as PropertyValueUsageInput, e9 as ReceiveActionsInput, e8 as ReceiveActionsInputData, ej as ResolveOutputPathsInput, ec as ResolveOutputPathsInputData, ev as SEGMENT_BOOLEAN_OPERATORS, eu as SEGMENT_DATE_OPERATORS, es as SEGMENT_ID_OPERATORS, eX as SEGMENT_IMPLICIT_OPERATORS, cn as SEGMENT_MEMBERSHIP_FIELD, et as SEGMENT_NUMBER_OPERATORS, eW as SEGMENT_OPERATOR_SPECS, eA as SEGMENT_QUEUES, er as SEGMENT_TEXT_OPERATORS, d9 as SEX_OPTIONS, d7 as SOCIAL_LINKS, dB as STATIC_PLACEHOLDER, d2 as STATUSES, dd as STRUCTURE_STATUSES, gf as SUGGEST_CONFIDENCE, e$ as SegmentBaseInput, ew as SegmentField, e_ as SegmentNodeSchema, cw as SegmentOperator, ek as SetPropertiesInput, ed as SetPropertiesInputData, fL as TApprovalChangeProducers, dP as TAutomationActionFolks, dF as TAutomationFindObjectType, dO as TAutomationProducers, g1 as TImportExportProducers, fd as TPropertyProducers, eZ as TSegmentProducers, fg as UNKNOWN_VALUE_COUNTS, ff as UNKNOWN_VALUE_SAMPLES, dh as USER_EXPORT_EXTENDED_FIELDS, dg as USER_EXTENDED_FIELDS, de as USER_MOVEMENT_STATUSES, dc as USER_PROPERTIES_INFO, db as USER_ROLES, fZ as USER_TYPES, fm as activityLogsSchema, dT as aiAgentSchema, eO as anniversaryRanges, dr as appSchema, fQ as approvalChangeApplyInputSchema, fy as approvalChangePluginName, fM as approvalLockCheckInputSchema, fO as approvalLockCreateInputSchema, fN as approvalLockStatesInputSchema, fP as approvalRequestCreateInputSchema, dl as attachmentSchema, dS as automationExecutionSchema, dQ as automationSchema, e3 as buildRuntimeOutputsIndex, ds as buildSetPropertyModifier, cX as canGroup, cT as checkLogin, c_ as checkPermissionGroup, cW as clearGroupActionsCache, fR as clientPortalSchema, eQ as collectSegmentReferences, eP as collectSegmentValueRefs, f_ as commentSchema, cC as compileSegmentMongoFilter, gj as countCsvDataRows, fS as cpNotificationConfigUserSchema, f$ as cpNotificationSchema, fU as cpNotificationSettingsSchema, fT as cpTwoFactor, fY as cpUserSchema, dn as createEventHandlers, f as createScopedEventHandlers, dj as customFieldSchema, cO as detectAssignmentDelta, fo as emailAddressSchema, fp as emailDeliverySchema, fr as emailRampSchema, fs as emailSenderSchema, fX as fcmDeviceSchema, f8 as fieldIdFromPropertyDataPath, cM as findResolver, eI as gatherSegmentEventTypes, eK as gatherSegmentFieldSources, eL as gatherSegmentJoinPaths, eJ as gatherSegmentRecordTypes, cD as gatherSegmentRelations, dq as generateEventHandlersFromRequest, e0 as getAutomationNodeType, dv as getContentType, cV as getGroupActionsMap, ga as getImportExportJobOptions, dw as getModuleName, dx as getPluginName, dt as getSetPropertySelector, cN as getSnapshot, dM as getTriggerTargetType, dW as getValueByPath, cY as hasDeclaredOAuthScopes, eR as hasSegmentReferenceInRelation, fC as initApproval, fc as initPropertyProducers, dm as initRecordReferences, eY as initSegmentProducers, cB as isAnniversary, eN as isLeapYear, f7 as isPropertyDataPath, cG as isPropertyGroupKey, dY as isReEnrollableTrigger, dZ as isReEnrollingTrigger, fA as localApprovalChangeType, cK as logActivityLogError, gc as logImportExportEvent, fl as logsSchema, dV as matchAutomationResolverKey, gh as matchImportHeaders, cL as matchesFieldPattern, fj as measurePropertyValueCounts, fi as measurePropertyValueSamples, fk as measurePropertyValueUsage, cE as mergePropertyRowConditions, fz as normalizeApprovalChangeType, fB as normalizeApprovalConfig, e2 as normalizeAutomationConstantsForTransport, gg as normalizeHeader, cv as normalizeSegmentOperator, ft as notificationSchema, fu as notificationSettingsSchema, fv as notificationZTypeSchema, cF as parsePropertyColumnKey, co as parsePropertyDataKey, cP as permissionGroupSchema, cR as permissionSchema, gi as processCSVStream, f9 as propertyDataExistsFilter, cc as propertyDataPath, fa as propertyDataRegexFilter, cH as propertyGroupIdFromKey, fV as refreshTokenSchema, cm as replaceOutputPlaceholders, cZ as resolveActionOAuthScopes, d_ as resolveAutomationActionInputs, dU as resolveFromSourceField, d$ as resolveOutputPathsByNodeType, ch as resolveRecordReferenceValue, eU as resolveSegmentFieldDependencies, eT as resolveSegmentFieldOperators, eV as resolveSegmentValueField, cS as roleSchema, dk as ruleSchema, gd as safeCleanup, eC as scheduleSegmentReconcile, ey as segmentDependencies, ex as segmentDependencyKey, ez as segmentDependsOnClock, cr as segmentFieldRef, eH as segmentJoinChanges, eB as segmentQueueFor, cs as segmentReferenceRef, ct as segmentRelationRef, eq as sendAutomationDeferredCompletion, ep as sendAutomationRun, eo as sendAutomationTrigger, fw as sendNotification, fx as sendNotificationChannels, eD as sendSegmentChanged, eG as sendSegmentForget, eF as sendSegmentRebuild, eE as sendSegmentReconcile, dp as setEventHandlerRuntimeContext, du as setProperty, cz as shiftZonedDays, fW as socialAuthProviderSchema, dy as splitType, dz as startAutomations, g2 as startImportExportWorker, cp as toPropertyGroupKey, cI as toPropertyRowColumnKey, cd as toPropertyRowKey, gb as toTerminalImportExportError, e1 as toTransportOutput, fh as unknownValueUsage, cQ as userGroupSchema, d1 as userMovemmentSchema, d0 as userSchema, cq as walkSegmentNodes, cU as wrapPermission, c$ as wrapPublicResolver, cA as zonedDate, eM as zonedDayStart, cy as zonedPeriodRange } from '../../dist/start-plugin-2b3e89f5.esm.js';
3
3
  import dayjs from 'dayjs';
4
4
  import 'node-fetch';
5
5
  import { nanoid } from 'nanoid';
@@ -1 +1 @@
1
- {"version":3,"file":"createEventHandlers.d.ts","sourceRoot":"../../../../../../src/core-modules/common/eventHandlers","sources":["createEventHandlers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EAErB,0BAA0B,EAG3B,mBAAgB;AAkBjB;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,0BAA0B,GACjC,qBAAqB,CAyMvB"}
1
+ {"version":3,"file":"createEventHandlers.d.ts","sourceRoot":"../../../../../../src/core-modules/common/eventHandlers","sources":["createEventHandlers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EAErB,0BAA0B,EAG3B,mBAAgB;AAgCjB;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,0BAA0B,GACjC,qBAAqB,CA6MvB"}
@@ -7,5 +7,9 @@ export type SegmentDiff = {
7
7
  removed?: Record<string, unknown>;
8
8
  updated?: Record<string, unknown>;
9
9
  };
10
- export declare const segmentJoinChanges: (contentType: string, diff: SegmentDiff | undefined) => Promise<SegmentJoinChanges | undefined>;
10
+ export type SegmentTouched = {
11
+ prev?: unknown[];
12
+ current?: unknown[];
13
+ };
14
+ export declare const segmentJoinChanges: (contentType: string, diff: SegmentDiff | undefined, touched?: SegmentTouched) => Promise<SegmentJoinChanges | undefined>;
11
15
  //# sourceMappingURL=joinChanges.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"joinChanges.d.ts","sourceRoot":"../../../../../src/core-modules/segments","sources":["joinChanges.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACrC,MAAM,EACN;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CACnC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAoBF,eAAO,MAAM,kBAAkB,GAC7B,aAAa,MAAM,EACnB,MAAM,WAAW,GAAG,SAAS,KAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAgCxC,CAAC"}
1
+ {"version":3,"file":"joinChanges.d.ts","sourceRoot":"../../../../../src/core-modules/segments","sources":["joinChanges.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACrC,MAAM,EACN;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CACnC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAqBF,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAWvE,eAAO,MAAM,kBAAkB,GAC7B,aAAa,MAAM,EACnB,MAAM,WAAW,GAAG,SAAS,EAC7B,UAAS,cAAmB,KAC3B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAkCxC,CAAC"}
@@ -11025,87 +11025,89 @@ var at = function at(source, path) {
11025
11025
  var isBothSides = function isBothSides(value) {
11026
11026
  return Boolean(value) && _typeof(value) === 'object' && ('prev' in value || 'current' in value);
11027
11027
  };
11028
+
11029
+ // The records a change touched, as they were and as they are.
11030
+
11031
+ var valuesAt = function valuesAt(documents, path) {
11032
+ var values = (documents || []).flatMap(function (doc) {
11033
+ var value = at(doc, path);
11034
+ return value === undefined ? [] : [value].flat();
11035
+ });
11036
+ return values.length ? values : undefined;
11037
+ };
11028
11038
  var segmentJoinChanges = /*#__PURE__*/function () {
11029
11039
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(contentType, diff) {
11030
- var paths, changes, _iterator, _step, path, updated, added, removed;
11040
+ var _touched$prev, _touched$current;
11041
+ var touched,
11042
+ paths,
11043
+ changes,
11044
+ _iterator,
11045
+ _step,
11046
+ _valuesAt,
11047
+ _valuesAt2,
11048
+ path,
11049
+ updated,
11050
+ both,
11051
+ prev,
11052
+ next,
11053
+ _args = arguments;
11031
11054
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11032
11055
  while (1) switch (_context.prev = _context.next) {
11033
11056
  case 0:
11034
- if (diff) {
11035
- _context.next = 2;
11057
+ touched = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
11058
+ if (!(!diff && !((_touched$prev = touched.prev) !== null && _touched$prev !== void 0 && _touched$prev.length) && !((_touched$current = touched.current) !== null && _touched$current !== void 0 && _touched$current.length))) {
11059
+ _context.next = 3;
11036
11060
  break;
11037
11061
  }
11038
11062
  return _context.abrupt("return", undefined);
11039
- case 2:
11040
- _context.prev = 2;
11041
- _context.next = 5;
11063
+ case 3:
11064
+ _context.prev = 3;
11065
+ _context.next = 6;
11042
11066
  return gatherSegmentJoinPaths();
11043
- case 5:
11067
+ case 6:
11044
11068
  _context.t0 = _context.sent.get(contentType);
11045
11069
  if (_context.t0) {
11046
- _context.next = 8;
11070
+ _context.next = 9;
11047
11071
  break;
11048
11072
  }
11049
11073
  _context.t0 = [];
11050
- case 8:
11074
+ case 9:
11051
11075
  paths = _context.t0;
11052
- _context.next = 14;
11076
+ _context.next = 15;
11053
11077
  break;
11054
- case 11:
11055
- _context.prev = 11;
11056
- _context.t1 = _context["catch"](2);
11078
+ case 12:
11079
+ _context.prev = 12;
11080
+ _context.t1 = _context["catch"](3);
11057
11081
  return _context.abrupt("return", undefined);
11058
- case 14:
11082
+ case 15:
11059
11083
  changes = {};
11060
11084
  _iterator = _createForOfIteratorHelper(paths);
11061
- _context.prev = 16;
11062
- _iterator.s();
11063
- case 18:
11064
- if ((_step = _iterator.n()).done) {
11065
- _context.next = 29;
11066
- break;
11067
- }
11068
- path = _step.value;
11069
- updated = at(diff.updated, path);
11070
- if (!isBothSides(updated)) {
11071
- _context.next = 24;
11072
- break;
11073
- }
11074
- changes[path] = {
11075
- prev: updated.prev,
11076
- next: updated.current
11077
- };
11078
- return _context.abrupt("continue", 27);
11079
- case 24:
11080
- added = at(diff.added, path);
11081
- removed = at(diff.removed, path);
11082
- if (added !== undefined || removed !== undefined) {
11083
- changes[path] = {
11084
- prev: removed,
11085
- next: added
11086
- };
11085
+ try {
11086
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
11087
+ path = _step.value;
11088
+ updated = at(diff === null || diff === void 0 ? void 0 : diff.updated, path);
11089
+ both = isBothSides(updated); // A record reaches whoever it points at, whether or not that field moved;
11090
+ // the diff only stands in where no document was at hand.
11091
+ prev = (_valuesAt = valuesAt(touched.prev, path)) !== null && _valuesAt !== void 0 ? _valuesAt : both ? updated.prev : at(diff === null || diff === void 0 ? void 0 : diff.removed, path);
11092
+ next = (_valuesAt2 = valuesAt(touched.current, path)) !== null && _valuesAt2 !== void 0 ? _valuesAt2 : both ? updated.current : at(diff === null || diff === void 0 ? void 0 : diff.added, path);
11093
+ if (prev !== undefined || next !== undefined) {
11094
+ changes[path] = {
11095
+ prev: prev,
11096
+ next: next
11097
+ };
11098
+ }
11099
+ }
11100
+ } catch (err) {
11101
+ _iterator.e(err);
11102
+ } finally {
11103
+ _iterator.f();
11087
11104
  }
11088
- case 27:
11089
- _context.next = 18;
11090
- break;
11091
- case 29:
11092
- _context.next = 34;
11093
- break;
11094
- case 31:
11095
- _context.prev = 31;
11096
- _context.t2 = _context["catch"](16);
11097
- _iterator.e(_context.t2);
11098
- case 34:
11099
- _context.prev = 34;
11100
- _iterator.f();
11101
- return _context.finish(34);
11102
- case 37:
11103
11105
  return _context.abrupt("return", Object.keys(changes).length ? changes : undefined);
11104
- case 38:
11106
+ case 19:
11105
11107
  case "end":
11106
11108
  return _context.stop();
11107
11109
  }
11108
- }, _callee, null, [[2, 11], [16, 31, 34, 37]]);
11110
+ }, _callee, null, [[3, 12]]);
11109
11111
  }));
11110
11112
  return function segmentJoinChanges(_x, _x2) {
11111
11113
  return _ref.apply(this, arguments);
@@ -11932,6 +11934,14 @@ var toIdList = function toIdList(ids) {
11932
11934
  });
11933
11935
  };
11934
11936
 
11937
+ /** The documents an action carried, before and after. */
11938
+ var touchedOf = function touchedOf(input) {
11939
+ return {
11940
+ prev: [].concat(_toConsumableArray('prevDocument' in input && input.prevDocument ? [input.prevDocument] : []), _toConsumableArray('prevDocuments' in input ? input.prevDocuments || [] : [])),
11941
+ current: 'currentDocument' in input && input.currentDocument ? [input.currentDocument] : []
11942
+ };
11943
+ };
11944
+
11935
11945
  /**
11936
11946
  * Create an event dispatcher instance with methods for logging and automation triggers
11937
11947
  * @param params - Configuration object for the event dispatcher
@@ -11989,7 +11999,7 @@ function createEventHandlers(params) {
11989
11999
  console.error('sendDbEventLog queue.add failed', err);
11990
12000
  });
11991
12001
  var docIds = toIdList((_eventPayload$docIds = eventPayload.docIds) !== null && _eventPayload$docIds !== void 0 ? _eventPayload$docIds : eventPayload.docId);
11992
- segmentJoinChanges(contentType, payload === null || payload === void 0 ? void 0 : payload.updateDescription).then(function (changed) {
12002
+ segmentJoinChanges(contentType, payload === null || payload === void 0 ? void 0 : payload.updateDescription, touchedOf(parsed)).then(function (changed) {
11993
12003
  return sendSegmentChanged({
11994
12004
  subdomain: subdomain,
11995
12005
  contentType: contentType,
@@ -11066,87 +11066,89 @@ var at = function at(source, path) {
11066
11066
  var isBothSides = function isBothSides(value) {
11067
11067
  return Boolean(value) && _typeof(value) === 'object' && ('prev' in value || 'current' in value);
11068
11068
  };
11069
+
11070
+ // The records a change touched, as they were and as they are.
11071
+
11072
+ var valuesAt = function valuesAt(documents, path) {
11073
+ var values = (documents || []).flatMap(function (doc) {
11074
+ var value = at(doc, path);
11075
+ return value === undefined ? [] : [value].flat();
11076
+ });
11077
+ return values.length ? values : undefined;
11078
+ };
11069
11079
  var segmentJoinChanges = /*#__PURE__*/function () {
11070
11080
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(contentType, diff) {
11071
- var paths, changes, _iterator, _step, path, updated, added, removed;
11081
+ var _touched$prev, _touched$current;
11082
+ var touched,
11083
+ paths,
11084
+ changes,
11085
+ _iterator,
11086
+ _step,
11087
+ _valuesAt,
11088
+ _valuesAt2,
11089
+ path,
11090
+ updated,
11091
+ both,
11092
+ prev,
11093
+ next,
11094
+ _args = arguments;
11072
11095
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11073
11096
  while (1) switch (_context.prev = _context.next) {
11074
11097
  case 0:
11075
- if (diff) {
11076
- _context.next = 2;
11098
+ touched = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
11099
+ if (!(!diff && !((_touched$prev = touched.prev) !== null && _touched$prev !== void 0 && _touched$prev.length) && !((_touched$current = touched.current) !== null && _touched$current !== void 0 && _touched$current.length))) {
11100
+ _context.next = 3;
11077
11101
  break;
11078
11102
  }
11079
11103
  return _context.abrupt("return", undefined);
11080
- case 2:
11081
- _context.prev = 2;
11082
- _context.next = 5;
11104
+ case 3:
11105
+ _context.prev = 3;
11106
+ _context.next = 6;
11083
11107
  return gatherSegmentJoinPaths();
11084
- case 5:
11108
+ case 6:
11085
11109
  _context.t0 = _context.sent.get(contentType);
11086
11110
  if (_context.t0) {
11087
- _context.next = 8;
11111
+ _context.next = 9;
11088
11112
  break;
11089
11113
  }
11090
11114
  _context.t0 = [];
11091
- case 8:
11115
+ case 9:
11092
11116
  paths = _context.t0;
11093
- _context.next = 14;
11117
+ _context.next = 15;
11094
11118
  break;
11095
- case 11:
11096
- _context.prev = 11;
11097
- _context.t1 = _context["catch"](2);
11119
+ case 12:
11120
+ _context.prev = 12;
11121
+ _context.t1 = _context["catch"](3);
11098
11122
  return _context.abrupt("return", undefined);
11099
- case 14:
11123
+ case 15:
11100
11124
  changes = {};
11101
11125
  _iterator = _createForOfIteratorHelper(paths);
11102
- _context.prev = 16;
11103
- _iterator.s();
11104
- case 18:
11105
- if ((_step = _iterator.n()).done) {
11106
- _context.next = 29;
11107
- break;
11108
- }
11109
- path = _step.value;
11110
- updated = at(diff.updated, path);
11111
- if (!isBothSides(updated)) {
11112
- _context.next = 24;
11113
- break;
11114
- }
11115
- changes[path] = {
11116
- prev: updated.prev,
11117
- next: updated.current
11118
- };
11119
- return _context.abrupt("continue", 27);
11120
- case 24:
11121
- added = at(diff.added, path);
11122
- removed = at(diff.removed, path);
11123
- if (added !== undefined || removed !== undefined) {
11124
- changes[path] = {
11125
- prev: removed,
11126
- next: added
11127
- };
11126
+ try {
11127
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
11128
+ path = _step.value;
11129
+ updated = at(diff === null || diff === void 0 ? void 0 : diff.updated, path);
11130
+ both = isBothSides(updated); // A record reaches whoever it points at, whether or not that field moved;
11131
+ // the diff only stands in where no document was at hand.
11132
+ prev = (_valuesAt = valuesAt(touched.prev, path)) !== null && _valuesAt !== void 0 ? _valuesAt : both ? updated.prev : at(diff === null || diff === void 0 ? void 0 : diff.removed, path);
11133
+ next = (_valuesAt2 = valuesAt(touched.current, path)) !== null && _valuesAt2 !== void 0 ? _valuesAt2 : both ? updated.current : at(diff === null || diff === void 0 ? void 0 : diff.added, path);
11134
+ if (prev !== undefined || next !== undefined) {
11135
+ changes[path] = {
11136
+ prev: prev,
11137
+ next: next
11138
+ };
11139
+ }
11140
+ }
11141
+ } catch (err) {
11142
+ _iterator.e(err);
11143
+ } finally {
11144
+ _iterator.f();
11128
11145
  }
11129
- case 27:
11130
- _context.next = 18;
11131
- break;
11132
- case 29:
11133
- _context.next = 34;
11134
- break;
11135
- case 31:
11136
- _context.prev = 31;
11137
- _context.t2 = _context["catch"](16);
11138
- _iterator.e(_context.t2);
11139
- case 34:
11140
- _context.prev = 34;
11141
- _iterator.f();
11142
- return _context.finish(34);
11143
- case 37:
11144
11146
  return _context.abrupt("return", Object.keys(changes).length ? changes : undefined);
11145
- case 38:
11147
+ case 19:
11146
11148
  case "end":
11147
11149
  return _context.stop();
11148
11150
  }
11149
- }, _callee, null, [[2, 11], [16, 31, 34, 37]]);
11151
+ }, _callee, null, [[3, 12]]);
11150
11152
  }));
11151
11153
  return function segmentJoinChanges(_x, _x2) {
11152
11154
  return _ref.apply(this, arguments);
@@ -11973,6 +11975,14 @@ var toIdList = function toIdList(ids) {
11973
11975
  });
11974
11976
  };
11975
11977
 
11978
+ /** The documents an action carried, before and after. */
11979
+ var touchedOf = function touchedOf(input) {
11980
+ return {
11981
+ prev: [].concat(_toConsumableArray('prevDocument' in input && input.prevDocument ? [input.prevDocument] : []), _toConsumableArray('prevDocuments' in input ? input.prevDocuments || [] : [])),
11982
+ current: 'currentDocument' in input && input.currentDocument ? [input.currentDocument] : []
11983
+ };
11984
+ };
11985
+
11976
11986
  /**
11977
11987
  * Create an event dispatcher instance with methods for logging and automation triggers
11978
11988
  * @param params - Configuration object for the event dispatcher
@@ -12030,7 +12040,7 @@ function createEventHandlers(params) {
12030
12040
  console.error('sendDbEventLog queue.add failed', err);
12031
12041
  });
12032
12042
  var docIds = toIdList((_eventPayload$docIds = eventPayload.docIds) !== null && _eventPayload$docIds !== void 0 ? _eventPayload$docIds : eventPayload.docId);
12033
- segmentJoinChanges(contentType, payload === null || payload === void 0 ? void 0 : payload.updateDescription).then(function (changed) {
12043
+ segmentJoinChanges(contentType, payload === null || payload === void 0 ? void 0 : payload.updateDescription, touchedOf(parsed)).then(function (changed) {
12034
12044
  return sendSegmentChanged({
12035
12045
  subdomain: subdomain,
12036
12046
  contentType: contentType,
@@ -11068,87 +11068,89 @@ var at = function at(source, path) {
11068
11068
  var isBothSides = function isBothSides(value) {
11069
11069
  return Boolean(value) && _typeof(value) === 'object' && ('prev' in value || 'current' in value);
11070
11070
  };
11071
+
11072
+ // The records a change touched, as they were and as they are.
11073
+
11074
+ var valuesAt = function valuesAt(documents, path) {
11075
+ var values = (documents || []).flatMap(function (doc) {
11076
+ var value = at(doc, path);
11077
+ return value === undefined ? [] : [value].flat();
11078
+ });
11079
+ return values.length ? values : undefined;
11080
+ };
11071
11081
  var segmentJoinChanges = /*#__PURE__*/function () {
11072
11082
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(contentType, diff) {
11073
- var paths, changes, _iterator, _step, path, updated, added, removed;
11083
+ var _touched$prev, _touched$current;
11084
+ var touched,
11085
+ paths,
11086
+ changes,
11087
+ _iterator,
11088
+ _step,
11089
+ _valuesAt,
11090
+ _valuesAt2,
11091
+ path,
11092
+ updated,
11093
+ both,
11094
+ prev,
11095
+ next,
11096
+ _args = arguments;
11074
11097
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11075
11098
  while (1) switch (_context.prev = _context.next) {
11076
11099
  case 0:
11077
- if (diff) {
11078
- _context.next = 2;
11100
+ touched = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
11101
+ if (!(!diff && !((_touched$prev = touched.prev) !== null && _touched$prev !== void 0 && _touched$prev.length) && !((_touched$current = touched.current) !== null && _touched$current !== void 0 && _touched$current.length))) {
11102
+ _context.next = 3;
11079
11103
  break;
11080
11104
  }
11081
11105
  return _context.abrupt("return", undefined);
11082
- case 2:
11083
- _context.prev = 2;
11084
- _context.next = 5;
11106
+ case 3:
11107
+ _context.prev = 3;
11108
+ _context.next = 6;
11085
11109
  return gatherSegmentJoinPaths();
11086
- case 5:
11110
+ case 6:
11087
11111
  _context.t0 = _context.sent.get(contentType);
11088
11112
  if (_context.t0) {
11089
- _context.next = 8;
11113
+ _context.next = 9;
11090
11114
  break;
11091
11115
  }
11092
11116
  _context.t0 = [];
11093
- case 8:
11117
+ case 9:
11094
11118
  paths = _context.t0;
11095
- _context.next = 14;
11119
+ _context.next = 15;
11096
11120
  break;
11097
- case 11:
11098
- _context.prev = 11;
11099
- _context.t1 = _context["catch"](2);
11121
+ case 12:
11122
+ _context.prev = 12;
11123
+ _context.t1 = _context["catch"](3);
11100
11124
  return _context.abrupt("return", undefined);
11101
- case 14:
11125
+ case 15:
11102
11126
  changes = {};
11103
11127
  _iterator = _createForOfIteratorHelper(paths);
11104
- _context.prev = 16;
11105
- _iterator.s();
11106
- case 18:
11107
- if ((_step = _iterator.n()).done) {
11108
- _context.next = 29;
11109
- break;
11110
- }
11111
- path = _step.value;
11112
- updated = at(diff.updated, path);
11113
- if (!isBothSides(updated)) {
11114
- _context.next = 24;
11115
- break;
11116
- }
11117
- changes[path] = {
11118
- prev: updated.prev,
11119
- next: updated.current
11120
- };
11121
- return _context.abrupt("continue", 27);
11122
- case 24:
11123
- added = at(diff.added, path);
11124
- removed = at(diff.removed, path);
11125
- if (added !== undefined || removed !== undefined) {
11126
- changes[path] = {
11127
- prev: removed,
11128
- next: added
11129
- };
11128
+ try {
11129
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
11130
+ path = _step.value;
11131
+ updated = at(diff === null || diff === void 0 ? void 0 : diff.updated, path);
11132
+ both = isBothSides(updated); // A record reaches whoever it points at, whether or not that field moved;
11133
+ // the diff only stands in where no document was at hand.
11134
+ prev = (_valuesAt = valuesAt(touched.prev, path)) !== null && _valuesAt !== void 0 ? _valuesAt : both ? updated.prev : at(diff === null || diff === void 0 ? void 0 : diff.removed, path);
11135
+ next = (_valuesAt2 = valuesAt(touched.current, path)) !== null && _valuesAt2 !== void 0 ? _valuesAt2 : both ? updated.current : at(diff === null || diff === void 0 ? void 0 : diff.added, path);
11136
+ if (prev !== undefined || next !== undefined) {
11137
+ changes[path] = {
11138
+ prev: prev,
11139
+ next: next
11140
+ };
11141
+ }
11142
+ }
11143
+ } catch (err) {
11144
+ _iterator.e(err);
11145
+ } finally {
11146
+ _iterator.f();
11130
11147
  }
11131
- case 27:
11132
- _context.next = 18;
11133
- break;
11134
- case 29:
11135
- _context.next = 34;
11136
- break;
11137
- case 31:
11138
- _context.prev = 31;
11139
- _context.t2 = _context["catch"](16);
11140
- _iterator.e(_context.t2);
11141
- case 34:
11142
- _context.prev = 34;
11143
- _iterator.f();
11144
- return _context.finish(34);
11145
- case 37:
11146
11148
  return _context.abrupt("return", Object.keys(changes).length ? changes : undefined);
11147
- case 38:
11149
+ case 19:
11148
11150
  case "end":
11149
11151
  return _context.stop();
11150
11152
  }
11151
- }, _callee, null, [[2, 11], [16, 31, 34, 37]]);
11153
+ }, _callee, null, [[3, 12]]);
11152
11154
  }));
11153
11155
  return function segmentJoinChanges(_x, _x2) {
11154
11156
  return _ref.apply(this, arguments);
@@ -11975,6 +11977,14 @@ var toIdList = function toIdList(ids) {
11975
11977
  });
11976
11978
  };
11977
11979
 
11980
+ /** The documents an action carried, before and after. */
11981
+ var touchedOf = function touchedOf(input) {
11982
+ return {
11983
+ prev: [].concat(_toConsumableArray('prevDocument' in input && input.prevDocument ? [input.prevDocument] : []), _toConsumableArray('prevDocuments' in input ? input.prevDocuments || [] : [])),
11984
+ current: 'currentDocument' in input && input.currentDocument ? [input.currentDocument] : []
11985
+ };
11986
+ };
11987
+
11978
11988
  /**
11979
11989
  * Create an event dispatcher instance with methods for logging and automation triggers
11980
11990
  * @param params - Configuration object for the event dispatcher
@@ -12032,7 +12042,7 @@ function createEventHandlers(params) {
12032
12042
  console.error('sendDbEventLog queue.add failed', err);
12033
12043
  });
12034
12044
  var docIds = toIdList((_eventPayload$docIds = eventPayload.docIds) !== null && _eventPayload$docIds !== void 0 ? _eventPayload$docIds : eventPayload.docId);
12035
- segmentJoinChanges(contentType, payload === null || payload === void 0 ? void 0 : payload.updateDescription).then(function (changed) {
12045
+ segmentJoinChanges(contentType, payload === null || payload === void 0 ? void 0 : payload.updateDescription, touchedOf(parsed)).then(function (changed) {
12036
12046
  return sendSegmentChanged({
12037
12047
  subdomain: subdomain,
12038
12048
  contentType: contentType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/api-shared",
3
- "version": "3.2.21-2",
3
+ "version": "3.2.25-1",
4
4
  "description": "Shared platform utilities for erxes backend plugins: plugin startup, tenant-scoped models, service discovery, messaging and core types.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -15,7 +15,7 @@ import {
15
15
  } from './utils';
16
16
  import { sendAutomationTrigger } from '../../automations';
17
17
  import { sendSegmentChanged } from '../../segments/events';
18
- import { segmentJoinChanges } from '../../segments/joinChanges';
18
+ import { segmentJoinChanges, SegmentTouched } from '../../segments/joinChanges';
19
19
  import { INotificationData, sendNotification } from '../../notifications';
20
20
  import { logActivityLogError } from '../../logs/activityLog/utils';
21
21
 
@@ -25,6 +25,20 @@ const toIdList = (ids?: string | string[]): string[] =>
25
25
  (id): id is string => typeof id === 'string' && id.length > 0,
26
26
  );
27
27
 
28
+ /** The documents an action carried, before and after. */
29
+ const touchedOf = (input: LogEventInput): SegmentTouched => ({
30
+ prev: [
31
+ ...('prevDocument' in input && input.prevDocument
32
+ ? [input.prevDocument]
33
+ : []),
34
+ ...('prevDocuments' in input ? input.prevDocuments || [] : []),
35
+ ],
36
+ current:
37
+ 'currentDocument' in input && input.currentDocument
38
+ ? [input.currentDocument]
39
+ : [],
40
+ });
41
+
28
42
  /**
29
43
  * Create an event dispatcher instance with methods for logging and automation triggers
30
44
  * @param params - Configuration object for the event dispatcher
@@ -93,7 +107,11 @@ export function createEventHandlers(
93
107
  });
94
108
  const docIds = toIdList(eventPayload.docIds ?? eventPayload.docId);
95
109
 
96
- segmentJoinChanges(contentType, payload?.updateDescription)
110
+ segmentJoinChanges(
111
+ contentType,
112
+ payload?.updateDescription,
113
+ touchedOf(parsed),
114
+ )
97
115
  .then((changed) =>
98
116
  sendSegmentChanged({ subdomain, contentType, docIds, changed }),
99
117
  )
@@ -93,4 +93,66 @@ describe('segmentJoinChanges', () => {
93
93
  await segmentJoinChanges('core:contacts.customers', undefined),
94
94
  ).toBeUndefined();
95
95
  });
96
+ it('reaches the owner of a record created without a diff', async () => {
97
+ const changes = await segmentJoinChanges(
98
+ 'core:contacts.customers',
99
+ undefined,
100
+ { current: [{ _id: 'c1', ownerId: 'user_a' }] },
101
+ );
102
+
103
+ expect(changes).toEqual({ ownerId: { prev: undefined, next: ['user_a'] } });
104
+ });
105
+
106
+ it('reaches the owner when another field moved', async () => {
107
+ const changes = await segmentJoinChanges(
108
+ 'core:contacts.customers',
109
+ { updated: { primaryEmail: { prev: 'a@x.mn', current: 'b@x.mn' } } },
110
+ {
111
+ prev: [{ _id: 'c1', ownerId: 'user_a' }],
112
+ current: [{ _id: 'c1', ownerId: 'user_a' }],
113
+ },
114
+ );
115
+
116
+ expect(changes).toEqual({
117
+ ownerId: { prev: ['user_a'], next: ['user_a'] },
118
+ });
119
+ });
120
+
121
+ it('reaches both owners when the documents say it moved', async () => {
122
+ const changes = await segmentJoinChanges(
123
+ 'core:contacts.customers',
124
+ { updated: { ownerId: { prev: 'user_a', current: 'user_b' } } },
125
+ { current: [{ _id: 'c1', ownerId: 'user_b' }] },
126
+ );
127
+
128
+ expect(changes).toEqual({ ownerId: { prev: 'user_a', next: ['user_b'] } });
129
+ });
130
+
131
+ it('reaches the owner of a deleted record', async () => {
132
+ const changes = await segmentJoinChanges(
133
+ 'core:contacts.customers',
134
+ undefined,
135
+ { prev: [{ _id: 'c1', ownerId: 'user_a' }] },
136
+ );
137
+
138
+ expect(changes).toEqual({ ownerId: { prev: ['user_a'], next: undefined } });
139
+ });
140
+
141
+ it('collects every owner of a batch', async () => {
142
+ const changes = await segmentJoinChanges(
143
+ 'core:contacts.customers',
144
+ undefined,
145
+ {
146
+ current: [
147
+ { _id: 'c1', ownerId: 'user_a' },
148
+ { _id: 'c2' },
149
+ { _id: 'c3', ownerId: 'user_b' },
150
+ ],
151
+ },
152
+ );
153
+
154
+ expect(changes).toEqual({
155
+ ownerId: { prev: undefined, next: ['user_a', 'user_b'] },
156
+ });
157
+ });
96
158
  });
@@ -29,11 +29,24 @@ const isBothSides = (
29
29
  typeof value === 'object' &&
30
30
  ('prev' in (value as object) || 'current' in (value as object));
31
31
 
32
+ // The records a change touched, as they were and as they are.
33
+ export type SegmentTouched = { prev?: unknown[]; current?: unknown[] };
34
+
35
+ const valuesAt = (documents: unknown[] | undefined, path: string) => {
36
+ const values = (documents || []).flatMap((doc) => {
37
+ const value = at(doc, path);
38
+ return value === undefined ? [] : [value].flat();
39
+ });
40
+
41
+ return values.length ? values : undefined;
42
+ };
43
+
32
44
  export const segmentJoinChanges = async (
33
45
  contentType: string,
34
46
  diff: SegmentDiff | undefined,
47
+ touched: SegmentTouched = {},
35
48
  ): Promise<SegmentJoinChanges | undefined> => {
36
- if (!diff) {
49
+ if (!diff && !touched.prev?.length && !touched.current?.length) {
37
50
  return undefined;
38
51
  }
39
52
 
@@ -48,18 +61,20 @@ export const segmentJoinChanges = async (
48
61
  const changes: SegmentJoinChanges = {};
49
62
 
50
63
  for (const path of paths) {
51
- const updated = at(diff.updated, path);
52
-
53
- if (isBothSides(updated)) {
54
- changes[path] = { prev: updated.prev, next: updated.current };
55
- continue;
56
- }
64
+ const updated = at(diff?.updated, path);
65
+ const both = isBothSides(updated);
57
66
 
58
- const added = at(diff.added, path);
59
- const removed = at(diff.removed, path);
67
+ // A record reaches whoever it points at, whether or not that field moved;
68
+ // the diff only stands in where no document was at hand.
69
+ const prev =
70
+ valuesAt(touched.prev, path) ??
71
+ (both ? updated.prev : at(diff?.removed, path));
72
+ const next =
73
+ valuesAt(touched.current, path) ??
74
+ (both ? updated.current : at(diff?.added, path));
60
75
 
61
- if (added !== undefined || removed !== undefined) {
62
- changes[path] = { prev: removed, next: added };
76
+ if (prev !== undefined || next !== undefined) {
77
+ changes[path] = { prev, next };
63
78
  }
64
79
  }
65
80
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var startPlugin = require('../../dist/start-plugin-b6f1292f.cjs.dev.js');
5
+ var startPlugin = require('../../dist/start-plugin-6687b329.cjs.dev.js');
6
6
  var mongoose = require('mongoose');
7
7
  var stream$1 = require('stream');
8
8
  var _loadash = require('lodash');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var startPlugin = require('../../dist/start-plugin-8812291a.cjs.prod.js');
5
+ var startPlugin = require('../../dist/start-plugin-46baacee.cjs.prod.js');
6
6
  var mongoose = require('mongoose');
7
7
  var stream$1 = require('stream');
8
8
  var _loadash = require('lodash');
@@ -1,5 +1,5 @@
1
- import { u as userHeaderName, g as getEnv, c as connect, _ as _asyncToGenerator, a as _regeneratorRuntime, b as coreModelOrganizations, d as getSubdomain, e as getSaasCoreConnection, f as createScopedEventHandlers, h as _slicedToArray, l as logHandler, r as runBeforeResolvers, s as sendWorkerQueue, i as _objectSpread2, j as chunkArray, k as _createForOfIteratorHelper, m as _createClass, n as _classCallCheck, o as isValidURL, p as sendTRPCMessage, q as _inherits, t as _wrapNativeSuper, v as _callSuper, w as _defineProperty, x as _toConsumableArray } from '../../dist/start-plugin-6a677721.esm.js';
2
- export { K as AGENT_TOOL_DEFAULT_MAX_RESPONSE_BYTES, ak as DEFAULT_JOB_OPTIONS, c1 as EXPECTED_ERROR_NAME, c2 as ExpectedError, aU as GP_STATUS, W as HEADER_SIZE_WARN_BYTES, bc as MAX_HEADER_BYTES, aA as ORGANIZATION_ID_MAPPING, T as TBeforeResolversProducers, V as USER_HEADER_OMITTED_FIELDS, N as agentToolResponseTooLargeError, F as agentToolsAuthHeaderName, y as apolloCustomScalars, bn as applyTrustProxy, bp as authCookieOptions, I as buildAgentToolManifest, bW as buildCursorQuery, ag as buildSearchTokenFilter, D as checkBeforeResolvers, aa as checkCollectionCodeDuplication, bM as checkServiceRunning, by as checkUserIds, j as chunkArray, c4 as classifyError, b$ as cleanHtml, b5 as clearServiceDiscoveryCache, P as clientPortalHeaderName, ad as closeMongooose, X as compactUserForHeader, ah as configureSchemaSearchTokens, c as connect, bo as connectionOptions, ar as coreModelAddons, as as coreModelBundles, av as coreModelEndpoints, ay as coreModelExperiences, at as coreModelInstallations, az as coreModelOrganizationPlanHistories, b as coreModelOrganizations, ax as coreModelPlugins, aw as coreModelPromoCodes, au as coreModelUsers, Q as cpUserHeaderName, c3 as createExpectedError, bL as createHealthRoute, al as createMQWorkerWithListeners, bh as createPluginTRPCContext, bi as createTRPCContext, a8 as cursorPaginate, a9 as cursorPaginateAggregation, bH as dateToShortStr, H as decodeAgentToolsAuthHeader, bV as decodeCursor, bg as decodeTRPCContextHeader, a7 as defaultPaginate, G as encodeAgentToolsAuthHeader, bU as encodeCursor, bf as encodeTRPCContextHeader, bk as err, bu as escapeRegExp, E as expectedErrorPlugin, S as extractCPUserFromHeader, U as extractClientPortalFromHeader, c6 as extractMessage, R as extractUserFromHeader, bx as fixDate, bG as fixNum, bP as flattenObject, z as generateApolloContext, af as generateConfiguredSearchTokens, bN as generateRequestProcess, b3 as getActivePlugins, L as getAgentToolMaxResponseBytes, b4 as getAvailablePlugins, bt as getCoreDomain, bA as getDate, bO as getDiffObjects, g as getEnv, bC as getFullDate, aY as getGlobalProfileV2Plugins, bF as getNextMonth, b6 as getPlugin, ba as getPluginAddress, b1 as getPlugins, bD as getPureDate, e as getSaasCoreConnection, aT as getSaasOrgPromoCodes, aO as getSaasOrganizationActiveAddons, aH as getSaasOrganizationByHelpCenterDomain, aM as getSaasOrganizationDetail, aI as getSaasOrganizationHelpCenterDomains, aB as getSaasOrganizationIdBySubdomain, aN as getSaasOrganizationPlanHistories, aD as getSaasOrganizations, aE as getSaasOrganizationsByFilter, aJ as getSaasOrganizationsWithPendingHelpCenterDomain, aC as getSaasOrgsCache, aR as getSaasPlugin, aQ as getSaasPlugins, aS as getSaasPromoCodes, ai as getSchemaSearchTokenConfig, d as getSubdomain, bB as getToday, bE as getTomorrow, bm as getTrustProxySetting, bz as getUniqueValue, O as graphqlPubsub, aG as helpCenterDomainsOf, c8 as initErxesSentry, bb as initializePluginConfig, a$ as isDev, b9 as isEnabled, c5 as isExpectedError, aV as isGlobalProfileV2, bJ as isImage, o as isValidURL, bK as isVideo, b7 as joinErxesGateway, b0 as keyForConfig, b8 as leaveErxesGateway, l as logHandler, B as markResolvers, a3 as mongoStringRequired, ac as mongooseConnectionOptions, a5 as mongooseField, a2 as mongooseStringNonBlank, a1 as mongooseStringRandomId, a4 as mongooseStringRequiredNonBlank, J as mountAgentTools, bj as ok, M as oversizedAgentToolResultBytes, bq as paginate, aX as pluginsFromStripe, aW as pluginsOfStripeItem, bw as pluralFormation, c0 as random, an as randomAlphanumeric, ao as randomLowercase, bR as readFileFromStorage, bS as readFileStreamFromStorage, bQ as readFileUrl, ap as redis, bs as regexSearchText, bZ as removeExtraSpaces, bY as removeLastTrailingSlash, aP as removeOrgsCache, aL as removeSaasOrganizationHelpCenterDomain, aq as resetConfigsCache, r as runBeforeResolvers, aZ as sanitizeFilename, a_ as sanitizeKey, aK as saveSaasOrganizationHelpCenterDomain, ab as schemaWrapper, bl as sendCoreModuleProducer, p as sendTRPCMessage, am as sendWorkerMessage, s as sendWorkerQueue, c7 as sentryExpectedErrorFilter, b2 as setActivePlugins, Z as setCPUserHeader, $ as setClientPortalHeader, Y as setUserHeader, bI as shortStrToDate, ae as splitSearchWords, b_ as splitStr, a0 as startAfterProcess, C as startBeforeResolvers, bd as startPlugin, bX as stripAnsi, aj as toSerializablePayload, be as trpcContextHeaderName, a6 as updateMongoDocumentOrder, bv as updateOrder, aF as updateSaasOrganization, bT as uploadFileToStorage, u as userHeaderName, br as validSearchText, A as wrapApolloResolvers } from '../../dist/start-plugin-6a677721.esm.js';
1
+ import { u as userHeaderName, g as getEnv, c as connect, _ as _asyncToGenerator, a as _regeneratorRuntime, b as coreModelOrganizations, d as getSubdomain, e as getSaasCoreConnection, f as createScopedEventHandlers, h as _slicedToArray, l as logHandler, r as runBeforeResolvers, s as sendWorkerQueue, i as _objectSpread2, j as chunkArray, k as _createForOfIteratorHelper, m as _createClass, n as _classCallCheck, o as isValidURL, p as sendTRPCMessage, q as _inherits, t as _wrapNativeSuper, v as _callSuper, w as _defineProperty, x as _toConsumableArray } from '../../dist/start-plugin-2b3e89f5.esm.js';
2
+ export { K as AGENT_TOOL_DEFAULT_MAX_RESPONSE_BYTES, ak as DEFAULT_JOB_OPTIONS, c1 as EXPECTED_ERROR_NAME, c2 as ExpectedError, aU as GP_STATUS, W as HEADER_SIZE_WARN_BYTES, bc as MAX_HEADER_BYTES, aA as ORGANIZATION_ID_MAPPING, T as TBeforeResolversProducers, V as USER_HEADER_OMITTED_FIELDS, N as agentToolResponseTooLargeError, F as agentToolsAuthHeaderName, y as apolloCustomScalars, bn as applyTrustProxy, bp as authCookieOptions, I as buildAgentToolManifest, bW as buildCursorQuery, ag as buildSearchTokenFilter, D as checkBeforeResolvers, aa as checkCollectionCodeDuplication, bM as checkServiceRunning, by as checkUserIds, j as chunkArray, c4 as classifyError, b$ as cleanHtml, b5 as clearServiceDiscoveryCache, P as clientPortalHeaderName, ad as closeMongooose, X as compactUserForHeader, ah as configureSchemaSearchTokens, c as connect, bo as connectionOptions, ar as coreModelAddons, as as coreModelBundles, av as coreModelEndpoints, ay as coreModelExperiences, at as coreModelInstallations, az as coreModelOrganizationPlanHistories, b as coreModelOrganizations, ax as coreModelPlugins, aw as coreModelPromoCodes, au as coreModelUsers, Q as cpUserHeaderName, c3 as createExpectedError, bL as createHealthRoute, al as createMQWorkerWithListeners, bh as createPluginTRPCContext, bi as createTRPCContext, a8 as cursorPaginate, a9 as cursorPaginateAggregation, bH as dateToShortStr, H as decodeAgentToolsAuthHeader, bV as decodeCursor, bg as decodeTRPCContextHeader, a7 as defaultPaginate, G as encodeAgentToolsAuthHeader, bU as encodeCursor, bf as encodeTRPCContextHeader, bk as err, bu as escapeRegExp, E as expectedErrorPlugin, S as extractCPUserFromHeader, U as extractClientPortalFromHeader, c6 as extractMessage, R as extractUserFromHeader, bx as fixDate, bG as fixNum, bP as flattenObject, z as generateApolloContext, af as generateConfiguredSearchTokens, bN as generateRequestProcess, b3 as getActivePlugins, L as getAgentToolMaxResponseBytes, b4 as getAvailablePlugins, bt as getCoreDomain, bA as getDate, bO as getDiffObjects, g as getEnv, bC as getFullDate, aY as getGlobalProfileV2Plugins, bF as getNextMonth, b6 as getPlugin, ba as getPluginAddress, b1 as getPlugins, bD as getPureDate, e as getSaasCoreConnection, aT as getSaasOrgPromoCodes, aO as getSaasOrganizationActiveAddons, aH as getSaasOrganizationByHelpCenterDomain, aM as getSaasOrganizationDetail, aI as getSaasOrganizationHelpCenterDomains, aB as getSaasOrganizationIdBySubdomain, aN as getSaasOrganizationPlanHistories, aD as getSaasOrganizations, aE as getSaasOrganizationsByFilter, aJ as getSaasOrganizationsWithPendingHelpCenterDomain, aC as getSaasOrgsCache, aR as getSaasPlugin, aQ as getSaasPlugins, aS as getSaasPromoCodes, ai as getSchemaSearchTokenConfig, d as getSubdomain, bB as getToday, bE as getTomorrow, bm as getTrustProxySetting, bz as getUniqueValue, O as graphqlPubsub, aG as helpCenterDomainsOf, c8 as initErxesSentry, bb as initializePluginConfig, a$ as isDev, b9 as isEnabled, c5 as isExpectedError, aV as isGlobalProfileV2, bJ as isImage, o as isValidURL, bK as isVideo, b7 as joinErxesGateway, b0 as keyForConfig, b8 as leaveErxesGateway, l as logHandler, B as markResolvers, a3 as mongoStringRequired, ac as mongooseConnectionOptions, a5 as mongooseField, a2 as mongooseStringNonBlank, a1 as mongooseStringRandomId, a4 as mongooseStringRequiredNonBlank, J as mountAgentTools, bj as ok, M as oversizedAgentToolResultBytes, bq as paginate, aX as pluginsFromStripe, aW as pluginsOfStripeItem, bw as pluralFormation, c0 as random, an as randomAlphanumeric, ao as randomLowercase, bR as readFileFromStorage, bS as readFileStreamFromStorage, bQ as readFileUrl, ap as redis, bs as regexSearchText, bZ as removeExtraSpaces, bY as removeLastTrailingSlash, aP as removeOrgsCache, aL as removeSaasOrganizationHelpCenterDomain, aq as resetConfigsCache, r as runBeforeResolvers, aZ as sanitizeFilename, a_ as sanitizeKey, aK as saveSaasOrganizationHelpCenterDomain, ab as schemaWrapper, bl as sendCoreModuleProducer, p as sendTRPCMessage, am as sendWorkerMessage, s as sendWorkerQueue, c7 as sentryExpectedErrorFilter, b2 as setActivePlugins, Z as setCPUserHeader, $ as setClientPortalHeader, Y as setUserHeader, bI as shortStrToDate, ae as splitSearchWords, b_ as splitStr, a0 as startAfterProcess, C as startBeforeResolvers, bd as startPlugin, bX as stripAnsi, aj as toSerializablePayload, be as trpcContextHeaderName, a6 as updateMongoDocumentOrder, bv as updateOrder, aF as updateSaasOrganization, bT as uploadFileToStorage, u as userHeaderName, br as validSearchText, A as wrapApolloResolvers } from '../../dist/start-plugin-2b3e89f5.esm.js';
3
3
  import mongoose from 'mongoose';
4
4
  import { Transform } from 'stream';
5
5
  import { keyBy } from 'lodash';