@dev.smartpricing/message-composer-layer 4.5.1-next.4 → 4.5.1-next.5

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 (81) hide show
  1. package/README.md +4 -133
  2. package/app/api/index.ts +0 -1
  3. package/app/api/messageGroups.ts +1 -5
  4. package/app/api/meta.ts +36 -0
  5. package/app/components/Common/MessageGroupSelect.vue +1 -30
  6. package/app/components/Composer/EmailComposer.vue +1 -5
  7. package/app/components/Composer/MessageLibrary.vue +8 -0
  8. package/app/components/Composer/WabaSelectModal.vue +1 -3
  9. package/app/components/Composer/WhatsappComposer.vue +1 -5
  10. package/app/components/Layout/BasePage.vue +0 -2
  11. package/app/components/MetaImport/Button.vue +50 -0
  12. package/app/components/MetaImport/Dialog.vue +261 -0
  13. package/app/components/MetaImport/Outcome.vue +136 -0
  14. package/app/components/MetaImport/ProposalList.vue +192 -0
  15. package/app/components/TemplateList/BaseTable.vue +22 -1
  16. package/app/composables/apiErrorMessages.ts +0 -1
  17. package/app/composables/composerContext.ts +3 -3
  18. package/app/composables/useMessageGroupWaba.ts +10 -7
  19. package/app/composables/useTemplateOperations.ts +3 -8
  20. package/app/pages/index.vue +5 -1
  21. package/app/pages/template/email/[id].vue +0 -5
  22. package/app/pages/template/email/create.vue +0 -5
  23. package/app/pages/template/whatsapp/[id].vue +0 -5
  24. package/app/pages/template/whatsapp/create.vue +0 -5
  25. package/app/queries/index.ts +0 -1
  26. package/app/queries/messageGroups.ts +29 -20
  27. package/app/queries/meta.ts +91 -1
  28. package/app/stores/appContext.ts +1 -1
  29. package/app/types/app-config.d.ts +0 -3
  30. package/app/types/tracking.ts +0 -33
  31. package/app/utils/testIds.const.ts +1 -107
  32. package/app.config.ts +5 -0
  33. package/i18n/locales/de.ts +64 -269
  34. package/i18n/locales/en.ts +61 -255
  35. package/i18n/locales/es.ts +62 -258
  36. package/i18n/locales/fr.ts +63 -264
  37. package/i18n/locales/it.ts +65 -260
  38. package/package.json +4 -4
  39. package/app/api/automations.ts +0 -74
  40. package/app/app.config.ts +0 -10
  41. package/app/components/Automations/ActionCard.vue +0 -174
  42. package/app/components/Automations/ActionEditor.vue +0 -398
  43. package/app/components/Automations/Actions.vue +0 -148
  44. package/app/components/Automations/CloneModal.vue +0 -78
  45. package/app/components/Automations/Conditions.vue +0 -155
  46. package/app/components/Automations/Create.vue +0 -114
  47. package/app/components/Automations/Data.vue +0 -46
  48. package/app/components/Automations/DeleteModal.vue +0 -80
  49. package/app/components/Automations/Edit.vue +0 -145
  50. package/app/components/Automations/Form.vue +0 -282
  51. package/app/components/Automations/List.vue +0 -370
  52. package/app/components/Automations/PageGate.vue +0 -50
  53. package/app/components/Automations/SaveProblems.vue +0 -54
  54. package/app/components/Automations/Unavailable.vue +0 -71
  55. package/app/components/Automations/UnavailableBadge.vue +0 -35
  56. package/app/components/Filters/DateInput.vue +0 -57
  57. package/app/components/Filters/Editor.vue +0 -163
  58. package/app/components/Filters/Row.vue +0 -119
  59. package/app/components/Filters/Summary.vue +0 -215
  60. package/app/components/Filters/UnavailableRow.vue +0 -74
  61. package/app/components/Filters/ValueInput.vue +0 -215
  62. package/app/composables/automationsContext.ts +0 -42
  63. package/app/composables/useAutomationClone.ts +0 -33
  64. package/app/composables/useAutomationEditorTrip.ts +0 -77
  65. package/app/composables/useAutomationSaveProblems.ts +0 -82
  66. package/app/composables/useAutomationUnavailable.ts +0 -98
  67. package/app/composables/useAutomationsGate.ts +0 -68
  68. package/app/composables/useBuiltInOptionLists.ts +0 -44
  69. package/app/composables/useEditorTripBack.ts +0 -15
  70. package/app/middleware/automations-enabled.ts +0 -12
  71. package/app/pages/automations/[id].vue +0 -87
  72. package/app/pages/automations/index.vue +0 -28
  73. package/app/pages/automations/new.vue +0 -53
  74. package/app/queries/automations.ts +0 -206
  75. package/app/stores/editorTrip.ts +0 -67
  76. package/app/utils/automations/form.ts +0 -389
  77. package/app/utils/automations/metadata.ts +0 -71
  78. package/app/utils/automations/unavailable.ts +0 -90
  79. package/app/utils/filters/data/countries.json +0 -998
  80. package/app/utils/filters/data/languages.json +0 -754
  81. package/app/utils/filters/rows.ts +0 -367
@@ -1,71 +0,0 @@
1
- import type { Automation } from '@dev.smartpricing/message-composer-utils/types'
2
-
3
- /**
4
- * What the pages read of an Automation's `metadata`, the Automation Engine's
5
- * free JSON: whether it is a System Automation, and the values it asks its
6
- * user for.
7
- */
8
-
9
- type AutomationMetadata = Automation['metadata']
10
-
11
- /**
12
- * Whether the Automation is a System Automation: one its Host created, whose
13
- * user can only activate its Actions and fill in what it asks for (ADR 0016).
14
- * The one place in the layer that reads the marker.
15
- */
16
- export function isSystemAutomation(automation: { metadata?: AutomationMetadata }): boolean {
17
- return automation.metadata?.locked === true
18
- }
19
-
20
- /**
21
- * One value an Automation asks its user for. Its label is the Host's text,
22
- * or a key of the Host's translations, and whatever its stored `type` it is a line of text, as in Smartconnect.
23
- */
24
- export interface AutomationMetadataFormField {
25
- /** The metadata key the value is stored under. */
26
- key: string
27
- label: string
28
- /** Shown on the field. Nothing stops a save over it, as in Smartconnect. */
29
- required: boolean
30
- }
31
-
32
- export interface AutomationMetadataForm {
33
- description?: string
34
- fields: AutomationMetadataFormField[]
35
- }
36
-
37
- /**
38
- * The stored `metadata.form`, or `undefined` when the Automation asks for
39
- * nothing. Whoever seeded the Automation wrote it: what is not a field with a
40
- * key is skipped, not refused.
41
- */
42
- export function automationMetadataForm(
43
- metadata: AutomationMetadata,
44
- ): AutomationMetadataForm | undefined {
45
- const form = metadata?.form as { description?: unknown; fields?: unknown } | null | undefined
46
- if (typeof form !== 'object' || form === null || !Array.isArray(form.fields)) return undefined
47
-
48
- const fields = form.fields.flatMap((field: unknown): AutomationMetadataFormField[] => {
49
- const { key, label, required } = (field ?? {}) as Record<string, unknown>
50
- if (typeof key !== 'string' || !key) return []
51
- return [
52
- {
53
- key,
54
- label: typeof label === 'string' ? label : key,
55
- required: required === true,
56
- },
57
- ]
58
- })
59
- if (fields.length === 0) return undefined
60
-
61
- return {
62
- description: typeof form.description === 'string' ? form.description : undefined,
63
- fields,
64
- }
65
- }
66
-
67
- /** A stored value as the form's text input shows it; empty when there is none. */
68
- export function metadataFormValue(metadata: AutomationMetadata, key: string): string {
69
- const value = metadata?.[key]
70
- return value === undefined || value === null ? '' : String(value)
71
- }
@@ -1,90 +0,0 @@
1
- import type {
2
- AutomationChannel,
3
- AutomationTrigger,
4
- } from '@dev.smartpricing/message-composer-utils/types'
5
- import type { AutomationFormAction } from './form'
6
-
7
- /**
8
- * What an Automation can hold that is no longer available, and which of it
9
- * stops a save. Nothing is dropped or rewritten: a thing that only stays is
10
- * "kept", and the user is told.
11
- */
12
-
13
- export type AutomationUnavailableKind =
14
- | 'trigger'
15
- | 'date_reference'
16
- | 'condition_unknown_field'
17
- | 'condition_not_editable'
18
- | 'option'
19
- | 'channel'
20
- | 'message_group_inactive'
21
- | 'message_group_active'
22
-
23
- /** The kinds a save does not go through with. Every other one is kept. */
24
- const BLOCKING_KINDS: readonly AutomationUnavailableKind[] = [
25
- 'trigger',
26
- 'date_reference',
27
- 'condition_unknown_field',
28
- 'message_group_active',
29
- ]
30
-
31
- export function unavailableBlocks(kind: AutomationUnavailableKind): boolean {
32
- return BLOCKING_KINDS.includes(kind)
33
- }
34
-
35
- /** One unavailable thing, as the alert lists it and as its badge says it. */
36
- export interface AutomationUnavailableItem {
37
- /** Tells the items of one list apart. */
38
- key: string
39
- kind: AutomationUnavailableKind
40
- blocks: boolean
41
- /** Where the thing is: "Trigger", `Message "Welcome"`. */
42
- where: string
43
- /** The full sentence: what is wrong and what to do. */
44
- text: string
45
- /** The id of the element the thing is at. */
46
- target?: string
47
- /** The thing is a Condition: showing it opens the filter editor. */
48
- inFilters?: boolean
49
- }
50
-
51
- /** What tells whether an Action holds something unavailable. */
52
- export interface ActionAvailability {
53
- trigger: AutomationTrigger
54
- /** The Channels the Organization cannot use. */
55
- unusableChannels: readonly AutomationChannel[]
56
- /**
57
- * Whether a Message Group is approved in every language, by its id in lower
58
- * case. One that is not in there is not known yet, or could not be read:
59
- * it is not taken for unapproved.
60
- */
61
- approvals: ReadonlyMap<string, boolean> | undefined
62
- }
63
-
64
- export function isDateReferenceListed(
65
- action: AutomationFormAction,
66
- trigger: AutomationTrigger,
67
- ): boolean {
68
- return trigger.date_references.some(({ key }) => key === action.dateReference)
69
- }
70
-
71
- /** The unavailable things one Action holds, in the order they are shown. */
72
- export function actionUnavailableKinds(
73
- action: AutomationFormAction,
74
- { trigger, unusableChannels, approvals }: ActionAvailability,
75
- ): AutomationUnavailableKind[] {
76
- const kinds: AutomationUnavailableKind[] = []
77
-
78
- if (!isDateReferenceListed(action, trigger)) kinds.push('date_reference')
79
-
80
- // An Action on a Channel that cannot be used is not sent and shows as not
81
- // Active, with a switch that does not work: it is never asked to be turned off.
82
- const unusableChannel = unusableChannels.includes(action.channel)
83
- if (unusableChannel) kinds.push('channel')
84
- if (approvals?.get(action.messageGroupId.toLowerCase()) === false) {
85
- const active = action.status === 'active' && !unusableChannel
86
- kinds.push(active ? 'message_group_active' : 'message_group_inactive')
87
- }
88
-
89
- return kinds
90
- }