@dev.smartpricing/message-composer-layer 4.5.1-next.2 → 4.5.1-next.3
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/README.md +2 -2
- package/app/components/Composer/WabaSelectModal.vue +1 -3
- package/app/components/TemplateList/BaseTable.vue +11 -1
- package/app/composables/composerContext.ts +3 -9
- package/app/composables/useMessageGroupWaba.ts +12 -12
- package/app/stores/appContext.ts +1 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -85,14 +85,14 @@ watch(
|
|
|
85
85
|
)
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
**WABA.** The Host does not supply the WABA: the WABAs follow the Organization and the backend resolves them (ADR [0015](../../docs/adr/0015-message-group-waba-fixed-at-first-submission.md)). WhatsApp is configured when the Host's `channels` include `whatsapp` and the Organization has at least one WABA. A Message Group is submitted to one WABA, chosen at its first submission and fixed from then on; with several WABAs
|
|
88
|
+
**WABA.** The Host does not have to supply the WABA: the WABAs follow the Organization and the backend resolves them (ADR [0015](../../docs/adr/0015-message-group-waba-fixed-at-first-submission.md)). WhatsApp is configured when the Host's `channels` include `whatsapp` and the Organization has at least one WABA. A Message Group is submitted to one WABA, chosen at its first submission and fixed from then on; with several WABAs it is the `metaWabaId` the Host passed, when that is one of them, and otherwise the user picks one when requesting approval. `metaWabaId` in the context is optional.
|
|
89
89
|
|
|
90
90
|
### Upgrading to 4.5.0
|
|
91
91
|
|
|
92
92
|
Nothing is required: a Host that keeps passing `organization_id` and `metaWabaId` behaves as before.
|
|
93
93
|
|
|
94
94
|
- **Removed** from `ComposerContext` and from `AppContextConfig` in utils (no code read them): `authenticationToken`, `strategy`, `metaAccessToken`, `dinamicValues`. Remove them from the `defineComposerContext()` call. The utils types `AppContextState` and `ContextSource` are gone too.
|
|
95
|
-
- **Changed**: `metaWabaId` no longer decides where a WhatsApp submission goes and is no longer required for the WhatsApp channel; it
|
|
95
|
+
- **Changed**: `metaWabaId` no longer decides where a WhatsApp submission goes and is no longer required for the WhatsApp channel; with several WABAs on the Organization it names the one a new Message Group is submitted to, and the user is asked only without it.
|
|
96
96
|
- **Deprecated**, removed in 5.0.0: the `sm-organization-id` and `x-meta-waba-id` request headers. The layer no longer sends them; the backend still accepts them from Hosts on an older layer.
|
|
97
97
|
- **New**: `organization_id` is optional, the Organization selector, `useEffectiveOrganization()`, and the `organizationId` and `wabaId` props of the Message Send Flow.
|
|
98
98
|
|
|
@@ -8,13 +8,11 @@ import type { OrganizationWaba } from '@dev.smartpricing/message-composer-utils/
|
|
|
8
8
|
*/
|
|
9
9
|
const props = defineProps<{
|
|
10
10
|
wabas: OrganizationWaba[]
|
|
11
|
-
/** The Host's WABA, already checked to be one of `wabas`. */
|
|
12
|
-
preselected?: string
|
|
13
11
|
}>()
|
|
14
12
|
|
|
15
13
|
const emit = defineEmits<{ close: [wabaId?: string] }>()
|
|
16
14
|
|
|
17
|
-
const selected = ref<string
|
|
15
|
+
const selected = ref<string>()
|
|
18
16
|
|
|
19
17
|
const items = computed(() =>
|
|
20
18
|
props.wabas.map((waba) => ({
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
MESSAGE_GROUP_PRODUCTS,
|
|
6
6
|
MESSAGE_STATUS,
|
|
7
7
|
type MessageGroupListSort,
|
|
8
|
+
type MessageGroupProduct,
|
|
8
9
|
type MessageGroupWithMessageSummary,
|
|
9
10
|
type PaginationMeta,
|
|
10
11
|
type RenderType,
|
|
@@ -203,8 +204,17 @@ const categoryItems = computed(() =>
|
|
|
203
204
|
toSelectItems(MESSAGE_GROUP_CATEGORIES, 'categories', t('common.all')),
|
|
204
205
|
)
|
|
205
206
|
const statusItems = computed(() => toSelectItems(MESSAGE_STATUS, 'status', t('common.all')))
|
|
207
|
+
// Only the Products that have Message Groups today. The Host's own Product
|
|
208
|
+
// is always offered, since the filter starts on it.
|
|
209
|
+
const PRODUCTS_WITH_MESSAGES: readonly MessageGroupProduct[] = ['connect', 'chat']
|
|
206
210
|
const productItems = computed(() =>
|
|
207
|
-
toSelectItems(
|
|
211
|
+
toSelectItems(
|
|
212
|
+
MESSAGE_GROUP_PRODUCTS.filter(
|
|
213
|
+
(product) => PRODUCTS_WITH_MESSAGES.includes(product) || product === appContext.product,
|
|
214
|
+
),
|
|
215
|
+
'products',
|
|
216
|
+
t('pages.message_library.all_products'),
|
|
217
|
+
),
|
|
208
218
|
)
|
|
209
219
|
|
|
210
220
|
const visibilityItems = computed(() =>
|
|
@@ -17,17 +17,11 @@ export interface ComposerContext {
|
|
|
17
17
|
mainLanguage?: Ref<string>
|
|
18
18
|
default_tags?: Ref<string[]>
|
|
19
19
|
/**
|
|
20
|
-
* The WABA the Host works on.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* The WABA the Host works on. A new Message Group is submitted to it and
|
|
21
|
+
* the user is not asked, as long as it is one of the Organization's
|
|
22
|
+
* (ADR 0015). Without it the user picks when there are several.
|
|
23
23
|
*/
|
|
24
24
|
metaWabaId?: Ref<string>
|
|
25
|
-
/**
|
|
26
|
-
* The Host works on `metaWabaId` only (Smartconnect): a new Message Group
|
|
27
|
-
* is submitted to it and the user is not asked. Applies while `metaWabaId`
|
|
28
|
-
* is one of the Organization's WABAs; otherwise the choice stays the user's.
|
|
29
|
-
*/
|
|
30
|
-
metaWabaLocked?: Ref<boolean>
|
|
31
25
|
isAdmin?: Ref<boolean>
|
|
32
26
|
organizationData?: Ref<OrganizationData>
|
|
33
27
|
}
|
|
@@ -9,7 +9,7 @@ import WabaSelectModal from '~/components/Composer/WabaSelectModal.vue'
|
|
|
9
9
|
*/
|
|
10
10
|
export function useMessageGroupWaba(storedWabaId: MaybeRefOrGetter<string | null | undefined>) {
|
|
11
11
|
const { data: wabas, refresh } = useOrganizationWabasQuery()
|
|
12
|
-
const { metaWabaId
|
|
12
|
+
const { metaWabaId } = storeToRefs(useAppContextStore())
|
|
13
13
|
const modal = useOverlay().create(WabaSelectModal)
|
|
14
14
|
|
|
15
15
|
// A submission of one language does not read the Message Group again: its
|
|
@@ -43,12 +43,12 @@ export function useMessageGroupWaba(storedWabaId: MaybeRefOrGetter<string | null
|
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* The WABA to name in a submission.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
46
|
+
* The WABA to name in a submission. At the first submission of a Message
|
|
47
|
+
* Group whose Organization has several WABAs, it is the Host's when the
|
|
48
|
+
* Host passed one of them, otherwise the user is asked. In every other
|
|
49
|
+
* case none is named and the backend resolves it. A lookup that has not
|
|
50
|
+
* answered yet is waited for; one that failed leaves it to the backend.
|
|
51
|
+
* Returns null when the user gives up.
|
|
52
52
|
*/
|
|
53
53
|
async function chooseWaba(): Promise<{ wabaId?: string } | null> {
|
|
54
54
|
if (wabaId.value) return {}
|
|
@@ -56,12 +56,12 @@ export function useMessageGroupWaba(storedWabaId: MaybeRefOrGetter<string | null
|
|
|
56
56
|
const candidates = wabas.value
|
|
57
57
|
if (!candidates || candidates.length < 2) return {}
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
:
|
|
62
|
-
|
|
59
|
+
const hostWabaId = metaWabaId.value
|
|
60
|
+
if (hostWabaId && candidates.some((candidate) => candidate.id === hostWabaId)) {
|
|
61
|
+
return { wabaId: hostWabaId }
|
|
62
|
+
}
|
|
63
63
|
|
|
64
|
-
const chosen = await modal.open({ wabas: candidates
|
|
64
|
+
const chosen = await modal.open({ wabas: candidates }).result
|
|
65
65
|
|
|
66
66
|
return chosen ? { wabaId: chosen } : null
|
|
67
67
|
}
|
package/app/stores/appContext.ts
CHANGED
|
@@ -23,10 +23,8 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
23
23
|
const mainLanguage = computed(() => ctx.mainLanguage?.value ?? 'en')
|
|
24
24
|
const default_tags = computed<string[]>(() => ctx.default_tags?.value ?? [])
|
|
25
25
|
const isAdmin = computed(() => ctx.isAdmin?.value ?? false)
|
|
26
|
-
// The Host
|
|
26
|
+
// The WABA the Host works on: the target of a new Message Group (ADR 0015).
|
|
27
27
|
const metaWabaId = computed(() => ctx.metaWabaId?.value || undefined)
|
|
28
|
-
// The Host's WABA is the only one it works on: no choice is offered.
|
|
29
|
-
const metaWabaLocked = computed(() => ctx.metaWabaLocked?.value ?? false)
|
|
30
28
|
|
|
31
29
|
// Sync i18n locale when mainLanguage changes
|
|
32
30
|
watch(
|
|
@@ -60,7 +58,6 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
60
58
|
default_tags,
|
|
61
59
|
isAdmin,
|
|
62
60
|
metaWabaId,
|
|
63
|
-
metaWabaLocked,
|
|
64
61
|
|
|
65
62
|
validationErrors,
|
|
66
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.smartpricing/message-composer-layer",
|
|
3
|
-
"version": "4.5.1-next.
|
|
3
|
+
"version": "4.5.1-next.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"vue-router": "^5.0.7",
|
|
36
36
|
"vue3-emoji-picker": "^1.1.8",
|
|
37
37
|
"zod": "^4.4.3",
|
|
38
|
-
"@dev.smartpricing/message-composer-utils": "4.5.1-next.
|
|
38
|
+
"@dev.smartpricing/message-composer-utils": "4.5.1-next.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@dev.smartpricing/platform-layer": "^0.0.23",
|