@aglyn/plugins-workflows 1.0.0-beta.222 → 1.0.0-beta.224

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 (40) hide show
  1. package/package.json +12 -12
  2. package/src/lib/components/automation-step-fields.component.d.ts +16 -2
  3. package/src/lib/components/automation-step-fields.component.js +53 -2
  4. package/src/lib/components/automation-step-fields.component.js.map +1 -1
  5. package/src/lib/components/automation-trigger-conditions.component.d.ts +23 -2
  6. package/src/lib/components/automation-trigger-conditions.component.js +89 -10
  7. package/src/lib/components/automation-trigger-conditions.component.js.map +1 -1
  8. package/src/lib/components/host-actions-card.component.js +64 -30
  9. package/src/lib/components/host-actions-card.component.js.map +1 -1
  10. package/src/lib/components/host-workflows-card.component.js +31 -10
  11. package/src/lib/components/host-workflows-card.component.js.map +1 -1
  12. package/src/lib/components/org-automation-editor.component.d.ts +1 -1
  13. package/src/lib/components/org-automation-editor.component.js +20 -11
  14. package/src/lib/components/org-automation-editor.component.js.map +1 -1
  15. package/src/lib/engine/email-merge.d.ts +69 -0
  16. package/src/lib/engine/email-merge.js +98 -0
  17. package/src/lib/engine/email-merge.js.map +1 -0
  18. package/src/lib/engine/run-event-actions.d.ts +30 -0
  19. package/src/lib/engine/run-event-actions.js +158 -54
  20. package/src/lib/engine/run-event-actions.js.map +1 -1
  21. package/src/lib/engine/run-event-workflows.js +44 -8
  22. package/src/lib/engine/run-event-workflows.js.map +1 -1
  23. package/src/lib/engine/run-org-automations.js +3 -1
  24. package/src/lib/engine/run-org-automations.js.map +1 -1
  25. package/src/lib/engine/triggered-docs.d.ts +39 -0
  26. package/src/lib/engine/triggered-docs.js +47 -0
  27. package/src/lib/engine/triggered-docs.js.map +1 -0
  28. package/src/lib/model/host-actions.d.ts +53 -0
  29. package/src/lib/model/host-actions.js +50 -2
  30. package/src/lib/model/host-actions.js.map +1 -1
  31. package/src/lib/model/org-automations.d.ts +6 -4
  32. package/src/lib/model/org-automations.js +8 -5
  33. package/src/lib/model/org-automations.js.map +1 -1
  34. package/src/lib/server-automation-drafts.js +2 -1
  35. package/src/lib/server-automation-drafts.js.map +1 -1
  36. package/src/lib/testing/stand-in-crm-steps.js +1 -1
  37. package/src/lib/testing/stand-in-crm-steps.js.map +1 -1
  38. package/src/lib/testing/stand-in-recipes.d.ts +3 -2
  39. package/src/lib/testing/stand-in-recipes.js +17 -12
  40. package/src/lib/testing/stand-in-recipes.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-workflows",
3
- "version": "1.0.0-beta.222",
3
+ "version": "1.0.0-beta.224",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,17 +25,17 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.222",
29
- "@aglyn/shared-data-mdi": "1.0.0-beta.222",
30
- "@aglyn/shared-ui-jsx": "1.0.0-beta.222",
31
- "@aglyn/shared-ui-next": "1.0.0-beta.222",
32
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.222",
33
- "@aglyn/shared-util-email": "1.0.0-beta.222",
34
- "@aglyn/shared-util-http": "1.0.0-beta.222",
35
- "@aglyn/shared-util-timestamp": "1.0.0-beta.222",
36
- "@aglyn/tenant-data-admin": "1.0.0-beta.222",
37
- "@aglyn/tenant-feature-instance": "1.0.0-beta.222",
38
- "@aglyn/tenant-runtime": "1.0.0-beta.222",
28
+ "@aglyn/aglyn": "1.0.0-beta.224",
29
+ "@aglyn/shared-data-mdi": "1.0.0-beta.224",
30
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.224",
31
+ "@aglyn/shared-ui-next": "1.0.0-beta.224",
32
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.224",
33
+ "@aglyn/shared-util-email": "1.0.0-beta.224",
34
+ "@aglyn/shared-util-http": "1.0.0-beta.224",
35
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.224",
36
+ "@aglyn/tenant-data-admin": "1.0.0-beta.224",
37
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.224",
38
+ "@aglyn/tenant-runtime": "1.0.0-beta.224",
39
39
  "@swc/helpers": "0.5.23"
40
40
  },
41
41
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { HostActionStep, HostActionStepType } from '../model/host-actions';
2
+ import { type HostActionStep, type HostActionStepType } from '../model/host-actions';
3
3
  /**
4
4
  * What a field holding a placeholder shows: an error state and what to do
5
5
  * about it. A placeholder is a value a person still has to supply, written in
@@ -52,9 +52,23 @@ export interface AutomationStepFieldsProps {
52
52
  * step and a function call is not one.
53
53
  */
54
54
  fields?: ReactNode;
55
+ /**
56
+ * Where the step sits (AGL-3458): the automation's trigger event and
57
+ * whether a wait comes before it — what decides whether a `sendEmail` step
58
+ * can be a transactional reply. Absent, the email step shows no switch.
59
+ */
60
+ replyContext?: {
61
+ event: string | null | undefined;
62
+ afterWait: boolean;
63
+ };
55
64
  }
65
+ /**
66
+ * What the email step says about its merge tags (AGL-3458): both spellings
67
+ * the run fills, from the contact or the lead the event is about.
68
+ */
69
+ export declare const SEND_EMAIL_MERGE_HELP: string;
56
70
  /**
57
71
  * One step's row: its number, what it does, the fields that kind takes, and
58
72
  * the condition that gates it.
59
73
  */
60
- export declare function AutomationStepFields({ step, index, kind, kinds, stepForKind, pickers, onSteps, fields, }: AutomationStepFieldsProps): import("react").JSX.Element;
74
+ export declare function AutomationStepFields({ step, index, kind, kinds, stepForKind, pickers, onSteps, fields, replyContext, }: AutomationStepFieldsProps): import("react").JSX.Element;
@@ -31,7 +31,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
31
31
  * allowed, and what a kind the Actions vocabulary does not hold looks like —
32
32
  * a workflow's function call, handed in as `fields`.
33
33
  */ import { CONTACT_LIFECYCLE_STAGE_LABELS, CONTACT_LIFECYCLE_STAGES, CONTACT_TAG_MAX_LENGTH, CRM_ACTIVITY_DIRECTION_LABELS, CRM_ACTIVITY_DIRECTIONS, CRM_ACTIVITY_KIND_LABELS, CRM_ACTIVITY_KINDS, CRM_TASK_KIND_LABELS, CRM_TASK_KINDS, CRM_TASK_MAX_DUE_DAYS, HOST_EVENT_TYPES, hostEventLabel, isInteractionAttributeAllowed } from "@aglyn/aglyn";
34
- import { IconButton, MenuItem, Stack, TextField, Typography } from "@mui/material";
34
+ import { FormControlLabel, FormHelperText, IconButton, MenuItem, Stack, Switch, TextField, Typography } from "@mui/material";
35
+ import { SEND_EMAIL_REPLY_INELIGIBLE_REASONS, sendEmailIsTransactionalReply, sendEmailReplyIneligibility } from "../model/host-actions.js";
35
36
  import { draftPlaceholderIn } from "@aglyn/aglyn/app-utils/draft-placeholders";
36
37
  /** A task's priorities, by meaning, as the create-task step offers them (AGL-3517). */ const TASK_PRIORITY_OPTIONS = [
37
38
  {
@@ -338,10 +339,50 @@ export function defaultStep(type) {
338
339
  };
339
340
  }
340
341
  }
342
+ /**
343
+ * The email step's TRANSACTIONAL REPLY switch (AGL-3458) — visible on every
344
+ * email step, so which kind of message it sends is never a guess.
345
+ *
346
+ * On by default for a step that qualifies: the trigger is the recipient's own
347
+ * form submission, booking or sign-up, nothing waits before the step, and it
348
+ * goes to the address the event carries. Such a reply leaves with no
349
+ * unsubscribe header and no unsubscribe link. A step that does not qualify
350
+ * shows the switch off and disabled, saying why, because it is a mailing and
351
+ * keeps its unsubscribe whatever it says.
352
+ */ function SendEmailReplySwitch({ step, context, onChange }) {
353
+ const ineligible = sendEmailReplyIneligibility(step, context);
354
+ const on = sendEmailIsTransactionalReply(step, context);
355
+ return /*#__PURE__*/ _jsxs(Stack, {
356
+ sx: {
357
+ pl: 3
358
+ },
359
+ children: [
360
+ /*#__PURE__*/ _jsx(FormControlLabel, {
361
+ control: /*#__PURE__*/ _jsx(Switch, {
362
+ size: "small",
363
+ checked: on,
364
+ disabled: ineligible !== null,
365
+ onChange: (event)=>onChange(event.target.checked)
366
+ }),
367
+ label: "Transactional reply (no unsubscribe)"
368
+ }),
369
+ /*#__PURE__*/ _jsx(FormHelperText, {
370
+ sx: {
371
+ mt: 0
372
+ },
373
+ children: ineligible ? `Sent as a mailing with an unsubscribe link: ${SEND_EMAIL_REPLY_INELIGIBLE_REASONS[ineligible]}.` : on ? 'Answers what this person just did, so it goes without an unsubscribe ' + 'link or header. Bounced, complaining and unsubscribed addresses are still skipped.' : 'Sent as a mailing, with an unsubscribe link and header.'
374
+ })
375
+ ]
376
+ });
377
+ }
378
+ /**
379
+ * What the email step says about its merge tags (AGL-3458): both spellings
380
+ * the run fills, from the contact or the lead the event is about.
381
+ */ export const SEND_EMAIL_MERGE_HELP = 'Merge tags: {{firstName|there}}, {{name}}, {{email}}, or {{contact.firstName}}, ' + '{{lead.company}}, {{site.name}} — filled from the contact or lead the event is ' + 'about; the text after | is used when there is no value.';
341
382
  /**
342
383
  * One step's row: its number, what it does, the fields that kind takes, and
343
384
  * the condition that gates it.
344
- */ export function AutomationStepFields({ step, index, kind, kinds, stepForKind, pickers, onSteps, fields }) {
385
+ */ export function AutomationStepFields({ step, index, kind, kinds, stepForKind, pickers, onSteps, fields, replyContext }) {
345
386
  var _ref, _step_workflowId, _step_severity, _ref1, _step_webhookId, _ref2, _step_datasetId, _step_overlayId, _step_selector, _step_selector1, _step_className, _step_selector2, _step_selector3, _step_offsetPx, _step_selector4, _step_name, _step_value, _step_drawerNodeId, _step_menuNodeId, _step_html, _step_code, _step_url, _step_eventName, _step_subject, _step_body, _step_title, _step_listId, _step_campaignId, _step_lifecycleStage, _step_tag, _step_title1, _step_kind, _step_priority, _step_dueInDays, _step_kind1, _step_direction, _CRM_ACTIVITY_DIRECTIONS_step_kind, _step_body1, _step_eventName1, _step_timeoutMinutes, _step_delayMinutes, _ref3, _step_when_conditions__field, _step_when_conditions__value;
346
387
  var _workflowOptions_find, _webhookOptions_find, _datasetOptions_find, _CRM_ACTIVITY_DIRECTIONS_step_kind1, _step_when_conditions_, _step_when_conditions, _step_when, _step_when_conditions_1, _step_when_conditions1, _step_when1, _step_when_conditions_2, _step_when_conditions2, _step_when2, _step_when_conditions_3, _step_when_conditions3, _step_when3;
347
388
  const { workflowOptions, datasetOptions, overlayOptions, listOptions, campaignOptions, webhookOptions } = pickers;
@@ -789,6 +830,7 @@ export function defaultStep(type) {
789
830
  size: "small",
790
831
  multiline: true,
791
832
  maxRows: 3,
833
+ helperText: SEND_EMAIL_MERGE_HELP,
792
834
  sx: {
793
835
  flex: 1
794
836
  }
@@ -1186,6 +1228,15 @@ export function defaultStep(type) {
1186
1228
  })
1187
1229
  ]
1188
1230
  }),
1231
+ !fields && step.type === 'sendEmail' && replyContext ? /*#__PURE__*/ _jsx(SendEmailReplySwitch, {
1232
+ step: step,
1233
+ context: replyContext,
1234
+ onChange: (transactional)=>patch((previous)=>_extends({}, previous, {
1235
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
1236
+ transactional
1237
+ }) : s)
1238
+ }))
1239
+ }) : null,
1189
1240
  fields ? null : /*#__PURE__*/ _jsxs(Stack, {
1190
1241
  direction: "row",
1191
1242
  spacing: 1,