bitsnap-automations 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ Published to npm as `bitsnap-automations`. SemVer: while the version is `0.x.y`,
4
4
  breaks the contract (a removed or renamed export, prop or label, a prop that becomes required, a
5
5
  changed meaning) bumps `x`; everything else bumps `y`.
6
6
 
7
+ ## 0.1.1
8
+
9
+ - Additive: scenario filters beyond products (customer personas). `ScenarioDraft` gains the optional
10
+ `formIds`, `personaIds` and `skipNegativePersona`; `emptyScenarioDraft()` starts with no filter and
11
+ `skipNegativePersona: true` (an explicit choice for a new scenario, not a server default).
12
+ - Additive: `ScenarioEditor` props `filters` (`ScenarioFilterSources`: forms, personas, `personasHref`) for the
13
+ "Formularz" filter on events that carry a form, the "Persona" filter and "Pomiń personę negatywną", and
14
+ `onDraftChange`. A host without `filters` sees no change.
15
+ - Additive: `placeholders` and `checkEmailText` get the picked forms as a last argument
16
+ (`PlaceholderFilterContext`); `EmailPlaceholder.group` (`"persona" | "answers"`) shows those chips under their
17
+ own heading in "Wyślij e-mail".
18
+ - Additive logic: `eventHasForm`, `withTriggerEvent` (a new event without a form drops the picked forms).
19
+ - Additive: picking the negative persona in the persona filter turns "Pomiń personę negatywną" off, locks it with a
20
+ one-line note, and saves `false` (`withNegativePersonaRule`, `picksNegativePersona`).
21
+ - Additive: a picked form or persona the host's list no longer names shows as a removable "Usunięty formularz" /
22
+ "Usunięta persona" chip. `ScenarioFilterSources.answersFailed` (optional) says that a picked form's questions did
23
+ not load; "Wyślij e-mail" keeps the answer chips of the forms that did load and says so.
24
+ - New labels, all **optional**: `sheet.forms*`, `sheet.formDeleted`, `sheet.persona*`, `sheet.personaDeleted`,
25
+ `sheet.skipNegative*` (with `skipNegativePicked`), `actions.sendEmail.insertPersona*`, `insertAnswers*` (with
26
+ `insertAnswersFailed`, `insertAnswersHint`), and the error labels `formsNotApplicable`, `formsInvalid`,
27
+ `formUnknown`, `personasInvalid`, `personaUnknown` (`FilterErrorCode`). `createAutomationsLabels` fills them
28
+ from the host's translations; a host that builds `labels` by hand needs no change and gets the Polish defaults.
29
+
7
30
  ## 0.1.0
8
31
 
9
32
  First release: `npm install bitsnap-automations`.
@@ -125,7 +125,8 @@ const EVENT_GROUP_ORDER = [
125
125
  "access",
126
126
  "cart",
127
127
  "testimonials",
128
- "configurators"
128
+ "configurators",
129
+ "personas"
129
130
  ];
130
131
  const AI_DECISION_MODES = [
131
132
  "learning",
@@ -231,9 +232,32 @@ function emptyScenarioDraft() {
231
232
  variantIds: [],
232
233
  active: true,
233
234
  actions: [],
234
- legacy: false
235
+ legacy: false,
236
+ formIds: [],
237
+ personaIds: [],
238
+ skipNegativePersona: true
235
239
  };
236
240
  }
241
+ function eventHasForm(event) {
242
+ return event?.group === "configurators";
243
+ }
244
+ function withTriggerEvent(draft, name, events) {
245
+ const keepForms = eventHasForm(events.find((candidate) => candidate.name === name));
246
+ return {
247
+ ...draft,
248
+ triggerEvent: name,
249
+ ...draft.formIds && draft.formIds.length > 0 && !keepForms ? { formIds: [] } : {}
250
+ };
251
+ }
252
+ function withNegativePersonaRule(draft, negativeIds) {
253
+ return draft.skipNegativePersona && picksNegativePersona(draft, negativeIds) ? {
254
+ ...draft,
255
+ skipNegativePersona: false
256
+ } : draft;
257
+ }
258
+ function picksNegativePersona(draft, negativeIds) {
259
+ return (draft.personaIds ?? []).some((id) => negativeIds.includes(id));
260
+ }
237
261
  function delayFromSeconds(seconds) {
238
262
  if (seconds > 0 && seconds % UNIT_SECONDS.days === 0) return {
239
263
  amount: String(seconds / UNIT_SECONDS.days),
@@ -614,7 +638,12 @@ const ERROR_CODES = {
614
638
  aiFinal: true,
615
639
  appNotConnected: true,
616
640
  permissionDenied: true,
617
- notFound: true
641
+ notFound: true,
642
+ formsNotApplicable: true,
643
+ formsInvalid: true,
644
+ formUnknown: true,
645
+ personasInvalid: true,
646
+ personaUnknown: true
618
647
  };
619
648
  function buildCommonLabels(tx) {
620
649
  return {
@@ -869,6 +898,12 @@ function buildScenarioEditorLabels(tx, locale, env) {
869
898
  insert: tx("actions.sendEmail.insert"),
870
899
  insertLabel: (placeholder) => tx("actions.sendEmail.insertLabel", { placeholder }),
871
900
  insertNone: tx("actions.sendEmail.insertNone"),
901
+ insertPersona: tx("actions.sendEmail.insertPersona"),
902
+ insertPersonaHint: tx("actions.sendEmail.insertPersonaHint"),
903
+ insertAnswers: tx("actions.sendEmail.insertAnswers"),
904
+ insertAnswersNeedForm: tx("actions.sendEmail.insertAnswersNeedForm"),
905
+ insertAnswersFailed: tx("actions.sendEmail.insertAnswersFailed"),
906
+ insertAnswersHint: tx("actions.sendEmail.insertAnswersHint"),
872
907
  replyTo: tx("actions.sendEmail.replyTo"),
873
908
  replyToPlaceholder: tx("actions.sendEmail.replyToPlaceholder"),
874
909
  content: tx("actions.sendEmail.content"),
@@ -975,6 +1010,30 @@ function buildScenarioEditorLabels(tx, locale, env) {
975
1010
  productsNotApplicable: tx("sheet.productsNotApplicable"),
976
1011
  variants: tx("sheet.variants"),
977
1012
  variantsHint: tx("sheet.variantsHint"),
1013
+ forms: tx("sheet.forms"),
1014
+ formsAll: tx("sheet.formsAll"),
1015
+ formsHint: tx("sheet.formsHint"),
1016
+ formSearch: tx("sheet.formSearch"),
1017
+ formNone: tx("sheet.formNone"),
1018
+ formRemove: (name) => tx("sheet.formRemove", { name }),
1019
+ formsLoadFailed: tx("sheet.formsLoadFailed"),
1020
+ formDeleted: tx("sheet.formDeleted"),
1021
+ personas: tx("sheet.personas"),
1022
+ personasAll: tx("sheet.personasAll"),
1023
+ personasHint: tx("sheet.personasHint"),
1024
+ personasRulesOnly: tx("sheet.personasRulesOnly"),
1025
+ personaSearch: tx("sheet.personaSearch"),
1026
+ personaNone: tx("sheet.personaNone"),
1027
+ personaRemove: (name) => tx("sheet.personaRemove", { name }),
1028
+ personasLoadFailed: tx("sheet.personasLoadFailed"),
1029
+ personasEmpty: tx("sheet.personasEmpty"),
1030
+ personasEmptyLink: tx("sheet.personasEmptyLink"),
1031
+ personaNegative: tx("sheet.personaNegative"),
1032
+ personaInactive: (name) => tx("sheet.personaInactive", { name }),
1033
+ personaDeleted: tx("sheet.personaDeleted"),
1034
+ skipNegative: tx("sheet.skipNegative"),
1035
+ skipNegativeHint: (name) => tx("sheet.skipNegativeHint", { name }),
1036
+ skipNegativePicked: (name) => tx("sheet.skipNegativePicked", { name }),
978
1037
  active: tx("sheet.active"),
979
1038
  activeHint: tx("sheet.activeHint"),
980
1039
  actions: tx("sheet.actions"),
@@ -1096,4 +1155,4 @@ function buildAiLearningLabels(tx, env) {
1096
1155
  date: (iso) => env.format.dateTime(new Date(iso).getTime())
1097
1156
  };
1098
1157
  }
1099
- export { unknownActionDraft as A, DELAY_MAX_SECONDS as B, parsePlaceholderError as C, sameDraft as D, rootProductId as E, learningProgressKey as F, PICKER_APPS as G, EVENT_GROUP_ORDER as H, ruleDestination as I, actionApp as J, RUN_STATUSES as K, validateAiDecisionConfig as L, validateDelay as M, validateScenarioDraft as N, sameEmailTemplateRef as O, AI_DECISION_MODES as P, ACTION_CATALOG as R, parseFieldPath as S, productNameFrom as T, FILTER_APPS as U, DELAY_MIN_SECONDS as V, MAX_ACTIONS_PER_SCENARIO as W, actionDefinition as Y, groupEvents as _, presentCategories as a, moveItem as b, templatesInCategory as c, baseProductName as d, delayFromSeconds as f, firstActionWithError as g, emptyScenarioDraft as h, hasActiveFilters as i, urlHost as j, unitSeconds as k, actionErrors as l, emptyActionDraft as m, createLabelDateFormat as n, templateMatches as o, delayToSeconds as p, RUN_STATUS_FILTERS as q, DEFAULT_SCENARIO_FILTERS as r, templateRequirements as s, createAutomationsLabels as t, availablePlaceholders as u, groupProductResults as v, placeholderErrorFromDetail as w, ownTextFromTemplate as x, insertAt as y, ACTION_KINDS as z };
1158
+ export { actionDefinition as $, sameEmailTemplateRef as A, ruleDestination as B, parseFieldPath as C, productNameFrom as D, placeholderErrorFromDetail as E, validateScenarioDraft as F, DELAY_MIN_SECONDS as G, ACTION_CATALOG as H, withNegativePersonaRule as I, MAX_ACTIONS_PER_SCENARIO as J, EVENT_GROUP_ORDER as K, withTriggerEvent as L, unknownActionDraft as M, urlHost as N, rootProductId as O, validateDelay as P, actionApp as Q, AI_DECISION_MODES as R, ownTextFromTemplate as S, picksNegativePersona as T, ACTION_KINDS as U, validateAiDecisionConfig as V, DELAY_MAX_SECONDS as W, RUN_STATUSES as X, PICKER_APPS as Y, RUN_STATUS_FILTERS as Z, firstActionWithError as _, presentCategories as a, insertAt as b, templatesInCategory as c, baseProductName as d, delayFromSeconds as f, eventHasForm as g, emptyScenarioDraft as h, hasActiveFilters as i, unitSeconds as j, sameDraft as k, actionErrors as l, emptyActionDraft as m, createLabelDateFormat as n, templateMatches as o, delayToSeconds as p, FILTER_APPS as q, DEFAULT_SCENARIO_FILTERS as r, templateRequirements as s, createAutomationsLabels as t, availablePlaceholders as u, groupEvents as v, parsePlaceholderError as w, moveItem as x, groupProductResults as y, learningProgressKey as z };