@erxes/api-shared 3.2.21-1 → 3.2.22-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.
Files changed (29) hide show
  1. package/core-modules/dist/erxes-api-shared-core-modules.cjs.dev.js +512 -8
  2. package/core-modules/dist/erxes-api-shared-core-modules.cjs.prod.js +512 -8
  3. package/core-modules/dist/erxes-api-shared-core-modules.esm.js +507 -10
  4. package/dist/declarations/src/core-modules/automations/conditionals.d.ts +59 -0
  5. package/dist/declarations/src/core-modules/automations/conditionals.d.ts.map +1 -0
  6. package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts +10 -0
  7. package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts.map +1 -1
  8. package/dist/declarations/src/core-modules/automations/index.d.ts +1 -0
  9. package/dist/declarations/src/core-modules/automations/index.d.ts.map +1 -1
  10. package/dist/declarations/src/core-modules/automations/zodTypes.d.ts +40 -0
  11. package/dist/declarations/src/core-modules/automations/zodTypes.d.ts.map +1 -1
  12. package/dist/declarations/src/core-modules/common/eventHandlers/createEventHandlers.d.ts.map +1 -1
  13. package/dist/declarations/src/core-modules/segments/joinChanges.d.ts +5 -1
  14. package/dist/declarations/src/core-modules/segments/joinChanges.d.ts.map +1 -1
  15. package/dist/{start-plugin-a2f6eca9.esm.js → start-plugin-2b3e89f5.esm.js} +73 -59
  16. package/dist/{start-plugin-b095acca.cjs.prod.js → start-plugin-46baacee.cjs.prod.js} +73 -58
  17. package/dist/{start-plugin-7dc096bc.cjs.dev.js → start-plugin-6687b329.cjs.dev.js} +73 -58
  18. package/package.json +1 -1
  19. package/src/core-modules/automations/conditionals.test.ts +302 -0
  20. package/src/core-modules/automations/conditionals.ts +403 -0
  21. package/src/core-modules/automations/definitions/executions.ts +3 -0
  22. package/src/core-modules/automations/index.ts +1 -0
  23. package/src/core-modules/automations/zodTypes.ts +1 -0
  24. package/src/core-modules/common/eventHandlers/createEventHandlers.ts +20 -2
  25. package/src/core-modules/segments/joinChanges.test.ts +62 -0
  26. package/src/core-modules/segments/joinChanges.ts +26 -11
  27. package/utils/dist/erxes-api-shared-utils.cjs.dev.js +1 -1
  28. package/utils/dist/erxes-api-shared-utils.cjs.prod.js +1 -1
  29. package/utils/dist/erxes-api-shared-utils.esm.js +2 -2
@@ -8904,6 +8904,7 @@ var AutomationExecActionInput = z.object({
8904
8904
  nextActionId: z.string().optional(),
8905
8905
  result: z.any().optional(),
8906
8906
  skipReason: z.string().optional(),
8907
+ conditionalMatches: z.record(z.string()).optional(),
8907
8908
  attempt: z.number().optional(),
8908
8909
  jobId: z.string().optional(),
8909
8910
  // Dates arrive serialized across the producer boundary, but stay Date
@@ -9609,6 +9610,9 @@ var execActionSchema = new Schema({
9609
9610
  childExecutionId: {
9610
9611
  type: String
9611
9612
  },
9613
+ conditionalMatches: {
9614
+ type: Object
9615
+ },
9612
9616
  errorCode: {
9613
9617
  type: String
9614
9618
  },
@@ -11021,87 +11025,89 @@ var at = function at(source, path) {
11021
11025
  var isBothSides = function isBothSides(value) {
11022
11026
  return Boolean(value) && _typeof(value) === 'object' && ('prev' in value || 'current' in value);
11023
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
+ };
11024
11038
  var segmentJoinChanges = /*#__PURE__*/function () {
11025
11039
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(contentType, diff) {
11026
- 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;
11027
11054
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11028
11055
  while (1) switch (_context.prev = _context.next) {
11029
11056
  case 0:
11030
- if (diff) {
11031
- _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;
11032
11060
  break;
11033
11061
  }
11034
11062
  return _context.abrupt("return", undefined);
11035
- case 2:
11036
- _context.prev = 2;
11037
- _context.next = 5;
11063
+ case 3:
11064
+ _context.prev = 3;
11065
+ _context.next = 6;
11038
11066
  return gatherSegmentJoinPaths();
11039
- case 5:
11067
+ case 6:
11040
11068
  _context.t0 = _context.sent.get(contentType);
11041
11069
  if (_context.t0) {
11042
- _context.next = 8;
11070
+ _context.next = 9;
11043
11071
  break;
11044
11072
  }
11045
11073
  _context.t0 = [];
11046
- case 8:
11074
+ case 9:
11047
11075
  paths = _context.t0;
11048
- _context.next = 14;
11076
+ _context.next = 15;
11049
11077
  break;
11050
- case 11:
11051
- _context.prev = 11;
11052
- _context.t1 = _context["catch"](2);
11078
+ case 12:
11079
+ _context.prev = 12;
11080
+ _context.t1 = _context["catch"](3);
11053
11081
  return _context.abrupt("return", undefined);
11054
- case 14:
11082
+ case 15:
11055
11083
  changes = {};
11056
11084
  _iterator = _createForOfIteratorHelper(paths);
11057
- _context.prev = 16;
11058
- _iterator.s();
11059
- case 18:
11060
- if ((_step = _iterator.n()).done) {
11061
- _context.next = 29;
11062
- break;
11063
- }
11064
- path = _step.value;
11065
- updated = at(diff.updated, path);
11066
- if (!isBothSides(updated)) {
11067
- _context.next = 24;
11068
- break;
11069
- }
11070
- changes[path] = {
11071
- prev: updated.prev,
11072
- next: updated.current
11073
- };
11074
- return _context.abrupt("continue", 27);
11075
- case 24:
11076
- added = at(diff.added, path);
11077
- removed = at(diff.removed, path);
11078
- if (added !== undefined || removed !== undefined) {
11079
- changes[path] = {
11080
- prev: removed,
11081
- next: added
11082
- };
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();
11083
11104
  }
11084
- case 27:
11085
- _context.next = 18;
11086
- break;
11087
- case 29:
11088
- _context.next = 34;
11089
- break;
11090
- case 31:
11091
- _context.prev = 31;
11092
- _context.t2 = _context["catch"](16);
11093
- _iterator.e(_context.t2);
11094
- case 34:
11095
- _context.prev = 34;
11096
- _iterator.f();
11097
- return _context.finish(34);
11098
- case 37:
11099
11105
  return _context.abrupt("return", Object.keys(changes).length ? changes : undefined);
11100
- case 38:
11106
+ case 19:
11101
11107
  case "end":
11102
11108
  return _context.stop();
11103
11109
  }
11104
- }, _callee, null, [[2, 11], [16, 31, 34, 37]]);
11110
+ }, _callee, null, [[3, 12]]);
11105
11111
  }));
11106
11112
  return function segmentJoinChanges(_x, _x2) {
11107
11113
  return _ref.apply(this, arguments);
@@ -11928,6 +11934,14 @@ var toIdList = function toIdList(ids) {
11928
11934
  });
11929
11935
  };
11930
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
+
11931
11945
  /**
11932
11946
  * Create an event dispatcher instance with methods for logging and automation triggers
11933
11947
  * @param params - Configuration object for the event dispatcher
@@ -11985,7 +11999,7 @@ function createEventHandlers(params) {
11985
11999
  console.error('sendDbEventLog queue.add failed', err);
11986
12000
  });
11987
12001
  var docIds = toIdList((_eventPayload$docIds = eventPayload.docIds) !== null && _eventPayload$docIds !== void 0 ? _eventPayload$docIds : eventPayload.docId);
11988
- 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) {
11989
12003
  return sendSegmentChanged({
11990
12004
  subdomain: subdomain,
11991
12005
  contentType: contentType,
@@ -23069,4 +23083,4 @@ function _startPlugin() {
23069
23083
  return _startPlugin.apply(this, arguments);
23070
23084
  }
23071
23085
 
23072
- export { setClientPortalHeader as $, wrapApolloResolvers as A, markResolvers as B, startBeforeResolvers as C, checkBeforeResolvers as D, expectedErrorPlugin as E, agentToolsAuthHeaderName as F, encodeAgentToolsAuthHeader as G, decodeAgentToolsAuthHeader as H, buildAgentToolManifest as I, mountAgentTools as J, AGENT_TOOL_DEFAULT_MAX_RESPONSE_BYTES as K, getAgentToolMaxResponseBytes as L, oversizedAgentToolResultBytes as M, agentToolResponseTooLargeError as N, graphqlPubsub as O, clientPortalHeaderName as P, cpUserHeaderName as Q, extractUserFromHeader as R, extractCPUserFromHeader as S, TBeforeResolversProducers as T, extractClientPortalFromHeader as U, USER_HEADER_OMITTED_FIELDS as V, HEADER_SIZE_WARN_BYTES as W, compactUserForHeader as X, setUserHeader as Y, setCPUserHeader as Z, _asyncToGenerator as _, _regeneratorRuntime as a, isDev as a$, startAfterProcess as a0, mongooseStringRandomId as a1, mongooseStringNonBlank as a2, mongoStringRequired as a3, mongooseStringRequiredNonBlank as a4, mongooseField as a5, updateMongoDocumentOrder as a6, defaultPaginate as a7, cursorPaginate as a8, cursorPaginateAggregation as a9, ORGANIZATION_ID_MAPPING as aA, getSaasOrganizationIdBySubdomain as aB, getSaasOrgsCache as aC, getSaasOrganizations as aD, getSaasOrganizationsByFilter as aE, updateSaasOrganization as aF, helpCenterDomainsOf as aG, getSaasOrganizationByHelpCenterDomain as aH, getSaasOrganizationHelpCenterDomains as aI, getSaasOrganizationsWithPendingHelpCenterDomain as aJ, saveSaasOrganizationHelpCenterDomain as aK, removeSaasOrganizationHelpCenterDomain as aL, getSaasOrganizationDetail as aM, getSaasOrganizationPlanHistories as aN, getSaasOrganizationActiveAddons as aO, removeOrgsCache as aP, getSaasPlugins as aQ, getSaasPlugin as aR, getSaasPromoCodes as aS, getSaasOrgPromoCodes as aT, GP_STATUS as aU, isGlobalProfileV2 as aV, pluginsOfStripeItem as aW, pluginsFromStripe as aX, getGlobalProfileV2Plugins as aY, sanitizeFilename as aZ, sanitizeKey as a_, checkCollectionCodeDuplication as aa, schemaWrapper as ab, mongooseConnectionOptions as ac, closeMongooose as ad, splitSearchWords as ae, generateConfiguredSearchTokens as af, buildSearchTokenFilter as ag, configureSchemaSearchTokens as ah, getSchemaSearchTokenConfig as ai, toSerializablePayload as aj, DEFAULT_JOB_OPTIONS as ak, createMQWorkerWithListeners as al, sendWorkerMessage as am, randomAlphanumeric as an, randomLowercase as ao, redis as ap, resetConfigsCache as aq, coreModelAddons as ar, coreModelBundles as as, coreModelInstallations as at, coreModelUsers as au, coreModelEndpoints as av, coreModelPromoCodes as aw, coreModelPlugins as ax, coreModelExperiences as ay, coreModelOrganizationPlanHistories as az, coreModelOrganizations as b, cleanHtml as b$, keyForConfig as b0, getPlugins as b1, setActivePlugins as b2, getActivePlugins as b3, getAvailablePlugins as b4, clearServiceDiscoveryCache as b5, getPlugin as b6, joinErxesGateway as b7, leaveErxesGateway as b8, isEnabled as b9, getDate as bA, getToday as bB, getFullDate as bC, getPureDate as bD, getTomorrow as bE, getNextMonth as bF, fixNum as bG, dateToShortStr as bH, shortStrToDate as bI, isImage as bJ, isVideo as bK, createHealthRoute as bL, checkServiceRunning as bM, generateRequestProcess as bN, getDiffObjects as bO, flattenObject as bP, readFileUrl as bQ, readFileFromStorage as bR, readFileStreamFromStorage as bS, uploadFileToStorage as bT, encodeCursor as bU, decodeCursor as bV, buildCursorQuery as bW, stripAnsi as bX, removeLastTrailingSlash as bY, removeExtraSpaces as bZ, splitStr as b_, getPluginAddress as ba, initializePluginConfig as bb, MAX_HEADER_BYTES as bc, startPlugin as bd, trpcContextHeaderName as be, encodeTRPCContextHeader as bf, decodeTRPCContextHeader as bg, createPluginTRPCContext as bh, createTRPCContext as bi, ok as bj, err as bk, sendCoreModuleProducer as bl, getTrustProxySetting as bm, applyTrustProxy as bn, connectionOptions as bo, authCookieOptions as bp, paginate as bq, validSearchText as br, regexSearchText as bs, getCoreDomain as bt, escapeRegExp as bu, updateOrder as bv, pluralFormation as bw, fixDate as bx, checkUserIds as by, getUniqueValue as bz, connect as c, userMovemmentSchema as c$, random as c0, EXPECTED_ERROR_NAME as c1, ExpectedError as c2, createExpectedError as c3, classifyError as c4, isExpectedError as c5, extractMessage as c6, sentryExpectedErrorFilter as c7, initErxesSentry as c8, isSameRecordReferenceType as c9, compileSegmentMongoFilter as cA, gatherSegmentRelations as cB, mergePropertyRowConditions as cC, parsePropertyColumnKey as cD, isPropertyGroupKey as cE, propertyGroupIdFromKey as cF, toPropertyRowColumnKey as cG, PROPERTIES_DATA as cH, logActivityLogError as cI, matchesFieldPattern as cJ, findResolver as cK, getSnapshot as cL, detectAssignmentDelta as cM, permissionGroupSchema as cN, userGroupSchema as cO, permissionSchema as cP, roleSchema as cQ, checkLogin as cR, wrapPermission as cS, getGroupActionsMap as cT, clearGroupActionsCache as cU, canGroup as cV, hasDeclaredOAuthScopes as cW, resolveActionOAuthScopes as cX, checkPermissionGroup as cY, wrapPublicResolver as cZ, userSchema as c_, normalizeRecordReferenceTypes as ca, normalizeRecordReferenceExtensions as cb, propertyDataPath as cc, toPropertyRowKey as cd, getLocalRecordReferenceType as ce, getRecordReferencePluginName as cf, _typeof as cg, resolveRecordReferenceValue as ch, _toArray as ci, AUTOMATION_ERROR_CODES as cj, SEGMENT_MEMBERSHIP_FIELD as ck, parsePropertyDataKey as cl, toPropertyGroupKey as cm, walkSegmentNodes as cn, segmentFieldRef as co, segmentReferenceRef as cp, segmentRelationRef as cq, DEFAULT_SEGMENT_TIME_ZONE as cr, normalizeSegmentOperator as cs, SegmentOperator as ct, PERIOD_OPERATORS as cu, zonedPeriodRange as cv, shiftZonedDays as cw, zonedDate as cx, isAnniversary as cy, _objectWithoutProperties as cz, getSubdomain as d, getAutomationNodeType as d$, STATUSES as d0, COMPANY_BUSINESS_TYPES as d1, DEFAULT_COMPANY_INDUSTRY_TYPES as d2, COMPANY_INDUSTRY_TYPES as d3, DEFAULT_SOCIAL_LINKS as d4, SOCIAL_LINKS as d5, DEFAULT_SEX_CHOICES as d6, SEX_OPTIONS as d7, DEFAULT_CONSTANT_VALUES as d8, USER_ROLES as d9, AUTOMATION_STATUSES as dA, AUTOMATION_CORE_ACTIONS as dB, AUTOMATION_CORE_TRIGGER_TYPES as dC, TAutomationFindObjectType as dD, AUTOMATION_EMAIL_RECIPIENTS_TYPES as dE, AUTOMATION_NON_DEFERRABLE_CORE_ACTIONS as dF, AUTOMATION_CORE_ACTION_DEFERRED as dG, AUTOMATION_DEFERRED_TIMEOUT as dH, BROADCAST_TRIGGER_TYPE as dI, BROADCAST_TARGET_TYPE as dJ, getTriggerTargetType as dK, EXECUTE_WAIT_TYPES as dL, TAutomationProducers as dM, TAutomationActionFolks as dN, automationSchema as dO, AUTOMATION_EXECUTION_STATUS as dP, automationExecutionSchema as dQ, aiAgentSchema as dR, resolveFromSourceField as dS, matchAutomationResolverKey as dT, getValueByPath as dU, AUTOMATION_OUTPUT_ITEM_COUNT as dV, isReEnrollableTrigger as dW, isReEnrollingTrigger as dX, resolveAutomationActionInputs as dY, resolveOutputPathsByNodeType as dZ, replaceOutputPlaceholders as d_, USER_PROPERTIES_INFO as da, STRUCTURE_STATUSES as db, USER_MOVEMENT_STATUSES as dc, CUSTOMER_SELECT_OPTIONS as dd, USER_EXTENDED_FIELDS as de, USER_EXPORT_EXTENDED_FIELDS as df, INPUT_TYPE as dg, customFieldSchema as dh, ruleSchema as di, attachmentSchema as dj, initRecordReferences as dk, createEventHandlers as dl, setEventHandlerRuntimeContext as dm, generateEventHandlersFromRequest as dn, appSchema as dp, buildSetPropertyModifier as dq, getSetPropertySelector as dr, setProperty as ds, getContentType as dt, getModuleName as du, getPluginName as dv, splitType as dw, startAutomations as dx, AUTOMATION_PROPERTY_OPERATORS as dy, STATIC_PLACEHOLDER as dz, getSaasCoreConnection as e, EvaluateFieldsInput as e$, toTransportOutput as e0, normalizeAutomationConstantsForTransport as e1, buildRuntimeOutputsIndex as e2, AutomationBaseInput as e3, AutomationExecActionInput as e4, AutomationExecutionInput as e5, AutomationActionInput as e6, ReceiveActionsInputData as e7, ReceiveActionsInput as e8, CheckCustomTriggerInputData as e9, segmentQueueFor as eA, scheduleSegmentReconcile as eB, sendSegmentChanged as eC, sendSegmentReconcile as eD, sendSegmentRebuild as eE, sendSegmentForget as eF, segmentJoinChanges as eG, gatherSegmentEventTypes as eH, gatherSegmentRecordTypes as eI, gatherSegmentFieldSources as eJ, gatherSegmentJoinPaths as eK, zonedDayStart as eL, isLeapYear as eM, anniversaryRanges as eN, collectSegmentValueRefs as eO, collectSegmentReferences as eP, hasSegmentReferenceInRelation as eQ, DEFAULT_SEGMENT_VALUE_FIELD as eR, resolveSegmentFieldOperators as eS, resolveSegmentFieldDependencies as eT, resolveSegmentValueField as eU, SEGMENT_OPERATOR_SPECS as eV, SEGMENT_IMPLICIT_OPERATORS as eW, initSegmentProducers as eX, TSegmentProducers as eY, SegmentNodeSchema as eZ, SegmentBaseInput as e_, FindObjectInputData as ea, ResolveOutputPathsInputData as eb, SetPropertiesInputData as ec, GenerateAiContextInputData as ed, LoadAiKnowledgeDocumentBatchInputData as ee, LookupAiToolInputData as ef, CheckCustomTriggerInput as eg, FindObjectInput as eh, ResolveOutputPathsInput as ei, SetPropertiesInput as ej, GenerateAiContextInput as ek, LoadAiKnowledgeDocumentBatchInput as el, LookupAiToolInput as em, sendAutomationTrigger as en, sendAutomationRun as eo, sendAutomationDeferredCompletion as ep, SEGMENT_TEXT_OPERATORS as eq, SEGMENT_ID_OPERATORS as er, SEGMENT_NUMBER_OPERATORS as es, SEGMENT_DATE_OPERATORS as et, SEGMENT_BOOLEAN_OPERATORS as eu, SegmentField as ev, segmentDependencyKey as ew, segmentDependencies as ex, segmentDependsOnClock as ey, SEGMENT_QUEUES as ez, createScopedEventHandlers as f, InsertImportRowsInputSchema as f$, ListSegmentMembersInput as f0, CountSegmentMembersInput as f1, ApplyMembershipInput as f2, PROPERTY_GROUP_KEY_PREFIX as f3, PROPERTY_ROW_KEY_SEP as f4, PROPERTY_ANY_ROW_KEY_SEP as f5, isPropertyDataPath as f6, fieldIdFromPropertyDataPath as f7, propertyDataExistsFilter as f8, propertyDataRegexFilter as f9, normalizeApprovalConfig as fA, initApproval as fB, APPROVAL_LOCK_STATUSES as fC, APPROVAL_APPROVER_SCOPES as fD, APPROVAL_MODES as fE, APPROVAL_REQUEST_STATUSES as fF, APPROVAL_REQUEST_KINDS as fG, APPROVAL_DECISIONS as fH, APPROVAL_NOTIFICATION_CONTENT_TYPE as fI, APPROVAL_NOTIFICATION_ACTIONS as fJ, TApprovalChangeProducers as fK, approvalLockCheckInputSchema as fL, approvalLockStatesInputSchema as fM, approvalLockCreateInputSchema as fN, approvalRequestCreateInputSchema as fO, approvalChangeApplyInputSchema as fP, clientPortalSchema as fQ, cpNotificationConfigUserSchema as fR, cpTwoFactor as fS, cpNotificationSettingsSchema as fT, refreshTokenSchema as fU, socialAuthProviderSchema as fV, fcmDeviceSchema as fW, cpUserSchema as fX, USER_TYPES as fY, commentSchema as fZ, cpNotificationSchema as f_, PROPERTY_ROW_INDEX_SEP as fa, initPropertyProducers as fb, TPropertyProducers as fc, PropertyValueUsageInput as fd, UNKNOWN_VALUE_SAMPLES as fe, UNKNOWN_VALUE_COUNTS as ff, unknownValueUsage as fg, measurePropertyValueSamples as fh, measurePropertyValueCounts as fi, measurePropertyValueUsage as fj, logsSchema as fk, activityLogsSchema as fl, EMAIL_LANES as fm, emailAddressSchema as fn, emailDeliverySchema as fo, EMAIL_RAMP_ID as fp, emailRampSchema as fq, emailSenderSchema as fr, notificationSchema as fs, notificationSettingsSchema as ft, notificationZTypeSchema as fu, sendNotification as fv, sendNotificationChannels as fw, approvalChangePluginName as fx, normalizeApprovalChangeType as fy, localApprovalChangeType as fz, getEnv as g, TImportExportProducers as g0, startImportExportWorker as g1, InsertImportRowsInput as g2, GetExportHeadersInput as g3, BatchSkipRowInput as g4, GetExportDataInput as g5, InsertImportRowsOutput as g6, GetImportHeadersInput as g7, GetImportHeadersOutput as g8, getImportExportJobOptions as g9, toTerminalImportExportError as ga, logImportExportEvent as gb, safeCleanup as gc, AUTO_MATCH_CONFIDENCE as gd, SUGGEST_CONFIDENCE as ge, normalizeHeader as gf, matchImportHeaders as gg, processCSVStream as gh, countCsvDataRows as gi, _slicedToArray as h, _objectSpread2 as i, chunkArray as j, _createForOfIteratorHelper as k, logHandler as l, _createClass as m, _classCallCheck as n, isValidURL as o, sendTRPCMessage as p, _inherits as q, runBeforeResolvers as r, sendWorkerQueue as s, _wrapNativeSuper as t, userHeaderName as u, _callSuper as v, _defineProperty as w, _toConsumableArray as x, apolloCustomScalars as y, generateApolloContext as z };
23086
+ export { setClientPortalHeader as $, wrapApolloResolvers as A, markResolvers as B, startBeforeResolvers as C, checkBeforeResolvers as D, expectedErrorPlugin as E, agentToolsAuthHeaderName as F, encodeAgentToolsAuthHeader as G, decodeAgentToolsAuthHeader as H, buildAgentToolManifest as I, mountAgentTools as J, AGENT_TOOL_DEFAULT_MAX_RESPONSE_BYTES as K, getAgentToolMaxResponseBytes as L, oversizedAgentToolResultBytes as M, agentToolResponseTooLargeError as N, graphqlPubsub as O, clientPortalHeaderName as P, cpUserHeaderName as Q, extractUserFromHeader as R, extractCPUserFromHeader as S, TBeforeResolversProducers as T, extractClientPortalFromHeader as U, USER_HEADER_OMITTED_FIELDS as V, HEADER_SIZE_WARN_BYTES as W, compactUserForHeader as X, setUserHeader as Y, setCPUserHeader as Z, _asyncToGenerator as _, _regeneratorRuntime as a, isDev as a$, startAfterProcess as a0, mongooseStringRandomId as a1, mongooseStringNonBlank as a2, mongoStringRequired as a3, mongooseStringRequiredNonBlank as a4, mongooseField as a5, updateMongoDocumentOrder as a6, defaultPaginate as a7, cursorPaginate as a8, cursorPaginateAggregation as a9, ORGANIZATION_ID_MAPPING as aA, getSaasOrganizationIdBySubdomain as aB, getSaasOrgsCache as aC, getSaasOrganizations as aD, getSaasOrganizationsByFilter as aE, updateSaasOrganization as aF, helpCenterDomainsOf as aG, getSaasOrganizationByHelpCenterDomain as aH, getSaasOrganizationHelpCenterDomains as aI, getSaasOrganizationsWithPendingHelpCenterDomain as aJ, saveSaasOrganizationHelpCenterDomain as aK, removeSaasOrganizationHelpCenterDomain as aL, getSaasOrganizationDetail as aM, getSaasOrganizationPlanHistories as aN, getSaasOrganizationActiveAddons as aO, removeOrgsCache as aP, getSaasPlugins as aQ, getSaasPlugin as aR, getSaasPromoCodes as aS, getSaasOrgPromoCodes as aT, GP_STATUS as aU, isGlobalProfileV2 as aV, pluginsOfStripeItem as aW, pluginsFromStripe as aX, getGlobalProfileV2Plugins as aY, sanitizeFilename as aZ, sanitizeKey as a_, checkCollectionCodeDuplication as aa, schemaWrapper as ab, mongooseConnectionOptions as ac, closeMongooose as ad, splitSearchWords as ae, generateConfiguredSearchTokens as af, buildSearchTokenFilter as ag, configureSchemaSearchTokens as ah, getSchemaSearchTokenConfig as ai, toSerializablePayload as aj, DEFAULT_JOB_OPTIONS as ak, createMQWorkerWithListeners as al, sendWorkerMessage as am, randomAlphanumeric as an, randomLowercase as ao, redis as ap, resetConfigsCache as aq, coreModelAddons as ar, coreModelBundles as as, coreModelInstallations as at, coreModelUsers as au, coreModelEndpoints as av, coreModelPromoCodes as aw, coreModelPlugins as ax, coreModelExperiences as ay, coreModelOrganizationPlanHistories as az, coreModelOrganizations as b, cleanHtml as b$, keyForConfig as b0, getPlugins as b1, setActivePlugins as b2, getActivePlugins as b3, getAvailablePlugins as b4, clearServiceDiscoveryCache as b5, getPlugin as b6, joinErxesGateway as b7, leaveErxesGateway as b8, isEnabled as b9, getDate as bA, getToday as bB, getFullDate as bC, getPureDate as bD, getTomorrow as bE, getNextMonth as bF, fixNum as bG, dateToShortStr as bH, shortStrToDate as bI, isImage as bJ, isVideo as bK, createHealthRoute as bL, checkServiceRunning as bM, generateRequestProcess as bN, getDiffObjects as bO, flattenObject as bP, readFileUrl as bQ, readFileFromStorage as bR, readFileStreamFromStorage as bS, uploadFileToStorage as bT, encodeCursor as bU, decodeCursor as bV, buildCursorQuery as bW, stripAnsi as bX, removeLastTrailingSlash as bY, removeExtraSpaces as bZ, splitStr as b_, getPluginAddress as ba, initializePluginConfig as bb, MAX_HEADER_BYTES as bc, startPlugin as bd, trpcContextHeaderName as be, encodeTRPCContextHeader as bf, decodeTRPCContextHeader as bg, createPluginTRPCContext as bh, createTRPCContext as bi, ok as bj, err as bk, sendCoreModuleProducer as bl, getTrustProxySetting as bm, applyTrustProxy as bn, connectionOptions as bo, authCookieOptions as bp, paginate as bq, validSearchText as br, regexSearchText as bs, getCoreDomain as bt, escapeRegExp as bu, updateOrder as bv, pluralFormation as bw, fixDate as bx, checkUserIds as by, getUniqueValue as bz, connect as c, wrapPublicResolver as c$, random as c0, EXPECTED_ERROR_NAME as c1, ExpectedError as c2, createExpectedError as c3, classifyError as c4, isExpectedError as c5, extractMessage as c6, sentryExpectedErrorFilter as c7, initErxesSentry as c8, isSameRecordReferenceType as c9, zonedDate as cA, isAnniversary as cB, compileSegmentMongoFilter as cC, gatherSegmentRelations as cD, mergePropertyRowConditions as cE, parsePropertyColumnKey as cF, isPropertyGroupKey as cG, propertyGroupIdFromKey as cH, toPropertyRowColumnKey as cI, PROPERTIES_DATA as cJ, logActivityLogError as cK, matchesFieldPattern as cL, findResolver as cM, getSnapshot as cN, detectAssignmentDelta as cO, permissionGroupSchema as cP, userGroupSchema as cQ, permissionSchema as cR, roleSchema as cS, checkLogin as cT, wrapPermission as cU, getGroupActionsMap as cV, clearGroupActionsCache as cW, canGroup as cX, hasDeclaredOAuthScopes as cY, resolveActionOAuthScopes as cZ, checkPermissionGroup as c_, normalizeRecordReferenceTypes as ca, normalizeRecordReferenceExtensions as cb, propertyDataPath as cc, toPropertyRowKey as cd, getLocalRecordReferenceType as ce, getRecordReferencePluginName as cf, _typeof as cg, resolveRecordReferenceValue as ch, _toArray as ci, AUTOMATION_ERROR_CODES as cj, _objectWithoutProperties as ck, _toPropertyKey as cl, replaceOutputPlaceholders as cm, SEGMENT_MEMBERSHIP_FIELD as cn, parsePropertyDataKey as co, toPropertyGroupKey as cp, walkSegmentNodes as cq, segmentFieldRef as cr, segmentReferenceRef as cs, segmentRelationRef as ct, DEFAULT_SEGMENT_TIME_ZONE as cu, normalizeSegmentOperator as cv, SegmentOperator as cw, PERIOD_OPERATORS as cx, zonedPeriodRange as cy, shiftZonedDays as cz, getSubdomain as d, resolveOutputPathsByNodeType as d$, userSchema as d0, userMovemmentSchema as d1, STATUSES as d2, COMPANY_BUSINESS_TYPES as d3, DEFAULT_COMPANY_INDUSTRY_TYPES as d4, COMPANY_INDUSTRY_TYPES as d5, DEFAULT_SOCIAL_LINKS as d6, SOCIAL_LINKS as d7, DEFAULT_SEX_CHOICES as d8, SEX_OPTIONS as d9, AUTOMATION_PROPERTY_OPERATORS as dA, STATIC_PLACEHOLDER as dB, AUTOMATION_STATUSES as dC, AUTOMATION_CORE_ACTIONS as dD, AUTOMATION_CORE_TRIGGER_TYPES as dE, TAutomationFindObjectType as dF, AUTOMATION_EMAIL_RECIPIENTS_TYPES as dG, AUTOMATION_NON_DEFERRABLE_CORE_ACTIONS as dH, AUTOMATION_CORE_ACTION_DEFERRED as dI, AUTOMATION_DEFERRED_TIMEOUT as dJ, BROADCAST_TRIGGER_TYPE as dK, BROADCAST_TARGET_TYPE as dL, getTriggerTargetType as dM, EXECUTE_WAIT_TYPES as dN, TAutomationProducers as dO, TAutomationActionFolks as dP, automationSchema as dQ, AUTOMATION_EXECUTION_STATUS as dR, automationExecutionSchema as dS, aiAgentSchema as dT, resolveFromSourceField as dU, matchAutomationResolverKey as dV, getValueByPath as dW, AUTOMATION_OUTPUT_ITEM_COUNT as dX, isReEnrollableTrigger as dY, isReEnrollingTrigger as dZ, resolveAutomationActionInputs as d_, DEFAULT_CONSTANT_VALUES as da, USER_ROLES as db, USER_PROPERTIES_INFO as dc, STRUCTURE_STATUSES as dd, USER_MOVEMENT_STATUSES as de, CUSTOMER_SELECT_OPTIONS as df, USER_EXTENDED_FIELDS as dg, USER_EXPORT_EXTENDED_FIELDS as dh, INPUT_TYPE as di, customFieldSchema as dj, ruleSchema as dk, attachmentSchema as dl, initRecordReferences as dm, createEventHandlers as dn, setEventHandlerRuntimeContext as dp, generateEventHandlersFromRequest as dq, appSchema as dr, buildSetPropertyModifier as ds, getSetPropertySelector as dt, setProperty as du, getContentType as dv, getModuleName as dw, getPluginName as dx, splitType as dy, startAutomations as dz, getSaasCoreConnection as e, SegmentBaseInput as e$, getAutomationNodeType as e0, toTransportOutput as e1, normalizeAutomationConstantsForTransport as e2, buildRuntimeOutputsIndex as e3, AutomationBaseInput as e4, AutomationExecActionInput as e5, AutomationExecutionInput as e6, AutomationActionInput as e7, ReceiveActionsInputData as e8, ReceiveActionsInput as e9, SEGMENT_QUEUES as eA, segmentQueueFor as eB, scheduleSegmentReconcile as eC, sendSegmentChanged as eD, sendSegmentReconcile as eE, sendSegmentRebuild as eF, sendSegmentForget as eG, segmentJoinChanges as eH, gatherSegmentEventTypes as eI, gatherSegmentRecordTypes as eJ, gatherSegmentFieldSources as eK, gatherSegmentJoinPaths as eL, zonedDayStart as eM, isLeapYear as eN, anniversaryRanges as eO, collectSegmentValueRefs as eP, collectSegmentReferences as eQ, hasSegmentReferenceInRelation as eR, DEFAULT_SEGMENT_VALUE_FIELD as eS, resolveSegmentFieldOperators as eT, resolveSegmentFieldDependencies as eU, resolveSegmentValueField as eV, SEGMENT_OPERATOR_SPECS as eW, SEGMENT_IMPLICIT_OPERATORS as eX, initSegmentProducers as eY, TSegmentProducers as eZ, SegmentNodeSchema as e_, CheckCustomTriggerInputData as ea, FindObjectInputData as eb, ResolveOutputPathsInputData as ec, SetPropertiesInputData as ed, GenerateAiContextInputData as ee, LoadAiKnowledgeDocumentBatchInputData as ef, LookupAiToolInputData as eg, CheckCustomTriggerInput as eh, FindObjectInput as ei, ResolveOutputPathsInput as ej, SetPropertiesInput as ek, GenerateAiContextInput as el, LoadAiKnowledgeDocumentBatchInput as em, LookupAiToolInput as en, sendAutomationTrigger as eo, sendAutomationRun as ep, sendAutomationDeferredCompletion as eq, SEGMENT_TEXT_OPERATORS as er, SEGMENT_ID_OPERATORS as es, SEGMENT_NUMBER_OPERATORS as et, SEGMENT_DATE_OPERATORS as eu, SEGMENT_BOOLEAN_OPERATORS as ev, SegmentField as ew, segmentDependencyKey as ex, segmentDependencies as ey, segmentDependsOnClock as ez, createScopedEventHandlers as f, cpNotificationSchema as f$, EvaluateFieldsInput as f0, ListSegmentMembersInput as f1, CountSegmentMembersInput as f2, ApplyMembershipInput as f3, PROPERTY_GROUP_KEY_PREFIX as f4, PROPERTY_ROW_KEY_SEP as f5, PROPERTY_ANY_ROW_KEY_SEP as f6, isPropertyDataPath as f7, fieldIdFromPropertyDataPath as f8, propertyDataExistsFilter as f9, localApprovalChangeType as fA, normalizeApprovalConfig as fB, initApproval as fC, APPROVAL_LOCK_STATUSES as fD, APPROVAL_APPROVER_SCOPES as fE, APPROVAL_MODES as fF, APPROVAL_REQUEST_STATUSES as fG, APPROVAL_REQUEST_KINDS as fH, APPROVAL_DECISIONS as fI, APPROVAL_NOTIFICATION_CONTENT_TYPE as fJ, APPROVAL_NOTIFICATION_ACTIONS as fK, TApprovalChangeProducers as fL, approvalLockCheckInputSchema as fM, approvalLockStatesInputSchema as fN, approvalLockCreateInputSchema as fO, approvalRequestCreateInputSchema as fP, approvalChangeApplyInputSchema as fQ, clientPortalSchema as fR, cpNotificationConfigUserSchema as fS, cpTwoFactor as fT, cpNotificationSettingsSchema as fU, refreshTokenSchema as fV, socialAuthProviderSchema as fW, fcmDeviceSchema as fX, cpUserSchema as fY, USER_TYPES as fZ, commentSchema as f_, propertyDataRegexFilter as fa, PROPERTY_ROW_INDEX_SEP as fb, initPropertyProducers as fc, TPropertyProducers as fd, PropertyValueUsageInput as fe, UNKNOWN_VALUE_SAMPLES as ff, UNKNOWN_VALUE_COUNTS as fg, unknownValueUsage as fh, measurePropertyValueSamples as fi, measurePropertyValueCounts as fj, measurePropertyValueUsage as fk, logsSchema as fl, activityLogsSchema as fm, EMAIL_LANES as fn, emailAddressSchema as fo, emailDeliverySchema as fp, EMAIL_RAMP_ID as fq, emailRampSchema as fr, emailSenderSchema as fs, notificationSchema as ft, notificationSettingsSchema as fu, notificationZTypeSchema as fv, sendNotification as fw, sendNotificationChannels as fx, approvalChangePluginName as fy, normalizeApprovalChangeType as fz, getEnv as g, InsertImportRowsInputSchema as g0, TImportExportProducers as g1, startImportExportWorker as g2, InsertImportRowsInput as g3, GetExportHeadersInput as g4, BatchSkipRowInput as g5, GetExportDataInput as g6, InsertImportRowsOutput as g7, GetImportHeadersInput as g8, GetImportHeadersOutput as g9, getImportExportJobOptions as ga, toTerminalImportExportError as gb, logImportExportEvent as gc, safeCleanup as gd, AUTO_MATCH_CONFIDENCE as ge, SUGGEST_CONFIDENCE as gf, normalizeHeader as gg, matchImportHeaders as gh, processCSVStream as gi, countCsvDataRows as gj, _slicedToArray as h, _objectSpread2 as i, chunkArray as j, _createForOfIteratorHelper as k, logHandler as l, _createClass as m, _classCallCheck as n, isValidURL as o, sendTRPCMessage as p, _inherits as q, runBeforeResolvers as r, sendWorkerQueue as s, _wrapNativeSuper as t, userHeaderName as u, _callSuper as v, _defineProperty as w, _toConsumableArray as x, apolloCustomScalars as y, generateApolloContext as z };
@@ -8945,6 +8945,7 @@ var AutomationExecActionInput = zod.z.object({
8945
8945
  nextActionId: zod.z.string().optional(),
8946
8946
  result: zod.z.any().optional(),
8947
8947
  skipReason: zod.z.string().optional(),
8948
+ conditionalMatches: zod.z.record(zod.z.string()).optional(),
8948
8949
  attempt: zod.z.number().optional(),
8949
8950
  jobId: zod.z.string().optional(),
8950
8951
  // Dates arrive serialized across the producer boundary, but stay Date
@@ -9650,6 +9651,9 @@ var execActionSchema = new mongoose.Schema({
9650
9651
  childExecutionId: {
9651
9652
  type: String
9652
9653
  },
9654
+ conditionalMatches: {
9655
+ type: Object
9656
+ },
9653
9657
  errorCode: {
9654
9658
  type: String
9655
9659
  },
@@ -11062,87 +11066,89 @@ var at = function at(source, path) {
11062
11066
  var isBothSides = function isBothSides(value) {
11063
11067
  return Boolean(value) && _typeof(value) === 'object' && ('prev' in value || 'current' in value);
11064
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
+ };
11065
11079
  var segmentJoinChanges = /*#__PURE__*/function () {
11066
11080
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(contentType, diff) {
11067
- 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;
11068
11095
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11069
11096
  while (1) switch (_context.prev = _context.next) {
11070
11097
  case 0:
11071
- if (diff) {
11072
- _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;
11073
11101
  break;
11074
11102
  }
11075
11103
  return _context.abrupt("return", undefined);
11076
- case 2:
11077
- _context.prev = 2;
11078
- _context.next = 5;
11104
+ case 3:
11105
+ _context.prev = 3;
11106
+ _context.next = 6;
11079
11107
  return gatherSegmentJoinPaths();
11080
- case 5:
11108
+ case 6:
11081
11109
  _context.t0 = _context.sent.get(contentType);
11082
11110
  if (_context.t0) {
11083
- _context.next = 8;
11111
+ _context.next = 9;
11084
11112
  break;
11085
11113
  }
11086
11114
  _context.t0 = [];
11087
- case 8:
11115
+ case 9:
11088
11116
  paths = _context.t0;
11089
- _context.next = 14;
11117
+ _context.next = 15;
11090
11118
  break;
11091
- case 11:
11092
- _context.prev = 11;
11093
- _context.t1 = _context["catch"](2);
11119
+ case 12:
11120
+ _context.prev = 12;
11121
+ _context.t1 = _context["catch"](3);
11094
11122
  return _context.abrupt("return", undefined);
11095
- case 14:
11123
+ case 15:
11096
11124
  changes = {};
11097
11125
  _iterator = _createForOfIteratorHelper(paths);
11098
- _context.prev = 16;
11099
- _iterator.s();
11100
- case 18:
11101
- if ((_step = _iterator.n()).done) {
11102
- _context.next = 29;
11103
- break;
11104
- }
11105
- path = _step.value;
11106
- updated = at(diff.updated, path);
11107
- if (!isBothSides(updated)) {
11108
- _context.next = 24;
11109
- break;
11110
- }
11111
- changes[path] = {
11112
- prev: updated.prev,
11113
- next: updated.current
11114
- };
11115
- return _context.abrupt("continue", 27);
11116
- case 24:
11117
- added = at(diff.added, path);
11118
- removed = at(diff.removed, path);
11119
- if (added !== undefined || removed !== undefined) {
11120
- changes[path] = {
11121
- prev: removed,
11122
- next: added
11123
- };
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();
11124
11145
  }
11125
- case 27:
11126
- _context.next = 18;
11127
- break;
11128
- case 29:
11129
- _context.next = 34;
11130
- break;
11131
- case 31:
11132
- _context.prev = 31;
11133
- _context.t2 = _context["catch"](16);
11134
- _iterator.e(_context.t2);
11135
- case 34:
11136
- _context.prev = 34;
11137
- _iterator.f();
11138
- return _context.finish(34);
11139
- case 37:
11140
11146
  return _context.abrupt("return", Object.keys(changes).length ? changes : undefined);
11141
- case 38:
11147
+ case 19:
11142
11148
  case "end":
11143
11149
  return _context.stop();
11144
11150
  }
11145
- }, _callee, null, [[2, 11], [16, 31, 34, 37]]);
11151
+ }, _callee, null, [[3, 12]]);
11146
11152
  }));
11147
11153
  return function segmentJoinChanges(_x, _x2) {
11148
11154
  return _ref.apply(this, arguments);
@@ -11969,6 +11975,14 @@ var toIdList = function toIdList(ids) {
11969
11975
  });
11970
11976
  };
11971
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
+
11972
11986
  /**
11973
11987
  * Create an event dispatcher instance with methods for logging and automation triggers
11974
11988
  * @param params - Configuration object for the event dispatcher
@@ -12026,7 +12040,7 @@ function createEventHandlers(params) {
12026
12040
  console.error('sendDbEventLog queue.add failed', err);
12027
12041
  });
12028
12042
  var docIds = toIdList((_eventPayload$docIds = eventPayload.docIds) !== null && _eventPayload$docIds !== void 0 ? _eventPayload$docIds : eventPayload.docId);
12029
- 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) {
12030
12044
  return sendSegmentChanged({
12031
12045
  subdomain: subdomain,
12032
12046
  contentType: contentType,
@@ -23241,6 +23255,7 @@ exports._regeneratorRuntime = _regeneratorRuntime;
23241
23255
  exports._slicedToArray = _slicedToArray;
23242
23256
  exports._toArray = _toArray;
23243
23257
  exports._toConsumableArray = _toConsumableArray;
23258
+ exports._toPropertyKey = _toPropertyKey;
23244
23259
  exports._typeof = _typeof;
23245
23260
  exports._wrapNativeSuper = _wrapNativeSuper;
23246
23261
  exports.activityLogsSchema = activityLogsSchema;
@@ -8947,6 +8947,7 @@ var AutomationExecActionInput = zod.z.object({
8947
8947
  nextActionId: zod.z.string().optional(),
8948
8948
  result: zod.z.any().optional(),
8949
8949
  skipReason: zod.z.string().optional(),
8950
+ conditionalMatches: zod.z.record(zod.z.string()).optional(),
8950
8951
  attempt: zod.z.number().optional(),
8951
8952
  jobId: zod.z.string().optional(),
8952
8953
  // Dates arrive serialized across the producer boundary, but stay Date
@@ -9652,6 +9653,9 @@ var execActionSchema = new mongoose.Schema({
9652
9653
  childExecutionId: {
9653
9654
  type: String
9654
9655
  },
9656
+ conditionalMatches: {
9657
+ type: Object
9658
+ },
9655
9659
  errorCode: {
9656
9660
  type: String
9657
9661
  },
@@ -11064,87 +11068,89 @@ var at = function at(source, path) {
11064
11068
  var isBothSides = function isBothSides(value) {
11065
11069
  return Boolean(value) && _typeof(value) === 'object' && ('prev' in value || 'current' in value);
11066
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
+ };
11067
11081
  var segmentJoinChanges = /*#__PURE__*/function () {
11068
11082
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(contentType, diff) {
11069
- 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;
11070
11097
  return _regeneratorRuntime().wrap(function _callee$(_context) {
11071
11098
  while (1) switch (_context.prev = _context.next) {
11072
11099
  case 0:
11073
- if (diff) {
11074
- _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;
11075
11103
  break;
11076
11104
  }
11077
11105
  return _context.abrupt("return", undefined);
11078
- case 2:
11079
- _context.prev = 2;
11080
- _context.next = 5;
11106
+ case 3:
11107
+ _context.prev = 3;
11108
+ _context.next = 6;
11081
11109
  return gatherSegmentJoinPaths();
11082
- case 5:
11110
+ case 6:
11083
11111
  _context.t0 = _context.sent.get(contentType);
11084
11112
  if (_context.t0) {
11085
- _context.next = 8;
11113
+ _context.next = 9;
11086
11114
  break;
11087
11115
  }
11088
11116
  _context.t0 = [];
11089
- case 8:
11117
+ case 9:
11090
11118
  paths = _context.t0;
11091
- _context.next = 14;
11119
+ _context.next = 15;
11092
11120
  break;
11093
- case 11:
11094
- _context.prev = 11;
11095
- _context.t1 = _context["catch"](2);
11121
+ case 12:
11122
+ _context.prev = 12;
11123
+ _context.t1 = _context["catch"](3);
11096
11124
  return _context.abrupt("return", undefined);
11097
- case 14:
11125
+ case 15:
11098
11126
  changes = {};
11099
11127
  _iterator = _createForOfIteratorHelper(paths);
11100
- _context.prev = 16;
11101
- _iterator.s();
11102
- case 18:
11103
- if ((_step = _iterator.n()).done) {
11104
- _context.next = 29;
11105
- break;
11106
- }
11107
- path = _step.value;
11108
- updated = at(diff.updated, path);
11109
- if (!isBothSides(updated)) {
11110
- _context.next = 24;
11111
- break;
11112
- }
11113
- changes[path] = {
11114
- prev: updated.prev,
11115
- next: updated.current
11116
- };
11117
- return _context.abrupt("continue", 27);
11118
- case 24:
11119
- added = at(diff.added, path);
11120
- removed = at(diff.removed, path);
11121
- if (added !== undefined || removed !== undefined) {
11122
- changes[path] = {
11123
- prev: removed,
11124
- next: added
11125
- };
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();
11126
11147
  }
11127
- case 27:
11128
- _context.next = 18;
11129
- break;
11130
- case 29:
11131
- _context.next = 34;
11132
- break;
11133
- case 31:
11134
- _context.prev = 31;
11135
- _context.t2 = _context["catch"](16);
11136
- _iterator.e(_context.t2);
11137
- case 34:
11138
- _context.prev = 34;
11139
- _iterator.f();
11140
- return _context.finish(34);
11141
- case 37:
11142
11148
  return _context.abrupt("return", Object.keys(changes).length ? changes : undefined);
11143
- case 38:
11149
+ case 19:
11144
11150
  case "end":
11145
11151
  return _context.stop();
11146
11152
  }
11147
- }, _callee, null, [[2, 11], [16, 31, 34, 37]]);
11153
+ }, _callee, null, [[3, 12]]);
11148
11154
  }));
11149
11155
  return function segmentJoinChanges(_x, _x2) {
11150
11156
  return _ref.apply(this, arguments);
@@ -11971,6 +11977,14 @@ var toIdList = function toIdList(ids) {
11971
11977
  });
11972
11978
  };
11973
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
+
11974
11988
  /**
11975
11989
  * Create an event dispatcher instance with methods for logging and automation triggers
11976
11990
  * @param params - Configuration object for the event dispatcher
@@ -12028,7 +12042,7 @@ function createEventHandlers(params) {
12028
12042
  console.error('sendDbEventLog queue.add failed', err);
12029
12043
  });
12030
12044
  var docIds = toIdList((_eventPayload$docIds = eventPayload.docIds) !== null && _eventPayload$docIds !== void 0 ? _eventPayload$docIds : eventPayload.docId);
12031
- 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) {
12032
12046
  return sendSegmentChanged({
12033
12047
  subdomain: subdomain,
12034
12048
  contentType: contentType,
@@ -23243,6 +23257,7 @@ exports._regeneratorRuntime = _regeneratorRuntime;
23243
23257
  exports._slicedToArray = _slicedToArray;
23244
23258
  exports._toArray = _toArray;
23245
23259
  exports._toConsumableArray = _toConsumableArray;
23260
+ exports._toPropertyKey = _toPropertyKey;
23246
23261
  exports._typeof = _typeof;
23247
23262
  exports._wrapNativeSuper = _wrapNativeSuper;
23248
23263
  exports.activityLogsSchema = activityLogsSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/api-shared",
3
- "version": "3.2.21-1",
3
+ "version": "3.2.22-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": {