@dev.smartpricing/message-composer-layer 4.1.3 → 4.2.2
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/app/api/client.ts +17 -13
- package/app/composables/composerContext.ts +4 -5
- package/app/stores/appContext.ts +3 -10
- package/app/stores/emailComposer.ts +0 -1
- package/nuxt.config.ts +5 -5
- package/package.json +4 -6
package/app/api/client.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ofetch } from 'ofetch'
|
|
2
1
|
import type { AppError } from '@dev.smartpricing/message-composer-utils/types'
|
|
3
2
|
import { useAppContextStore } from '@/stores/appContext'
|
|
4
3
|
|
|
@@ -12,16 +11,25 @@ function assertAppError(data: unknown): data is AppError {
|
|
|
12
11
|
return false
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export const apiClient =
|
|
16
|
-
baseURL: useRuntimeConfig().public.COMPOSER_API_URL,
|
|
14
|
+
export const apiClient = createApiClient({
|
|
15
|
+
baseURL: useRuntimeConfig().public.COMPOSER_API_URL as string,
|
|
16
|
+
csrf: {
|
|
17
|
+
cookieName: (useRuntimeConfig().public.ENV_CSRF_COOKIE_NAME as string) || 'smt_csrf',
|
|
18
|
+
},
|
|
19
|
+
auth: {
|
|
20
|
+
refreshBaseURL:
|
|
21
|
+
(useRuntimeConfig().public.BACKEND_BASE_URL as string) ||
|
|
22
|
+
(useRuntimeConfig().public.PLATFORM_URL as string),
|
|
23
|
+
platformURL: useRuntimeConfig().public.PLATFORM_URL as string,
|
|
24
|
+
onRefreshFailed: () => {
|
|
25
|
+
useNuxtApp().callHook('composer:auth-error', { statusCode: 401 })
|
|
26
|
+
},
|
|
27
|
+
},
|
|
17
28
|
onRequest({ options }) {
|
|
18
29
|
const store = useAppContextStore()
|
|
19
30
|
|
|
20
|
-
if (store.
|
|
21
|
-
options.headers.set('
|
|
22
|
-
}
|
|
23
|
-
if (store.owner_id) {
|
|
24
|
-
options.headers.set('sm-owner', store.owner_id)
|
|
31
|
+
if (store.organization_id) {
|
|
32
|
+
options.headers.set('sm-organization-id', store.organization_id)
|
|
25
33
|
}
|
|
26
34
|
if (store.metaWabaId) {
|
|
27
35
|
options.headers.set('x-meta-waba-id', store.metaWabaId)
|
|
@@ -33,11 +41,7 @@ export const apiClient = ofetch.create({
|
|
|
33
41
|
options.headers.set('sm-default-tags', store.default_tags.join(','))
|
|
34
42
|
}
|
|
35
43
|
},
|
|
36
|
-
|
|
37
|
-
if (response.status === 401) {
|
|
38
|
-
await useNuxtApp().callHook('composer:auth-error', { statusCode: 401 })
|
|
39
|
-
}
|
|
40
|
-
|
|
44
|
+
onResponseError({ response }) {
|
|
41
45
|
const error = response._data
|
|
42
46
|
if (assertAppError(error)) {
|
|
43
47
|
useToast().add({
|
|
@@ -6,8 +6,9 @@ export interface OrganizationData {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface ComposerContext {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/** @deprecated No longer used — auth is cookie-based via platform layer */
|
|
10
|
+
authenticationToken?: Ref<string>
|
|
11
|
+
organization_id?: Ref<string>
|
|
11
12
|
product?: Ref<AppContextConfig['product']>
|
|
12
13
|
strategy?: Ref<AppContextConfig['strategy']>
|
|
13
14
|
channels?: Ref<AppContextConfig['channels']>
|
|
@@ -29,9 +30,7 @@ export function defineComposerContext(context: ComposerContext): void {
|
|
|
29
30
|
useNuxtApp().vueApp.provide(COMPOSER_CONTEXT_KEY, context)
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
const SERVER_FALLBACK: ComposerContext = {
|
|
33
|
-
authenticationToken: ref(''),
|
|
34
|
-
}
|
|
33
|
+
const SERVER_FALLBACK: ComposerContext = {}
|
|
35
34
|
|
|
36
35
|
export function useComposerContext(): ComposerContext {
|
|
37
36
|
if (import.meta.server) return SERVER_FALLBACK
|
package/app/stores/appContext.ts
CHANGED
|
@@ -10,8 +10,7 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
10
10
|
const isInitialized = ref<boolean>(false)
|
|
11
11
|
|
|
12
12
|
// Proxy from injection with defaults (same interface as before)
|
|
13
|
-
const
|
|
14
|
-
const owner_id = computed(() => ctx.owner_id?.value ?? '')
|
|
13
|
+
const organization_id = computed(() => ctx.organization_id?.value ?? '')
|
|
15
14
|
const product = computed<NonNullable<AppContextConfig['product']>>(
|
|
16
15
|
() => ctx.product?.value ?? 'browser',
|
|
17
16
|
)
|
|
@@ -44,7 +43,6 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
44
43
|
|
|
45
44
|
// Computed context object for convenience
|
|
46
45
|
const context = computed<AppContextState>(() => ({
|
|
47
|
-
authenticationToken: authenticationToken.value,
|
|
48
46
|
product: product.value,
|
|
49
47
|
strategy: strategy.value,
|
|
50
48
|
channels: channels.value,
|
|
@@ -52,7 +50,7 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
52
50
|
mainLanguage: mainLanguage.value,
|
|
53
51
|
metaWabaId: metaWabaId.value,
|
|
54
52
|
metaAccessToken: metaAccessToken.value,
|
|
55
|
-
|
|
53
|
+
organization_id: organization_id.value,
|
|
56
54
|
default_tags: default_tags.value,
|
|
57
55
|
initializationSource: 'injection',
|
|
58
56
|
}))
|
|
@@ -61,10 +59,6 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
61
59
|
const validationErrors = computed<Record<string, string>>(() => {
|
|
62
60
|
const errors: Record<string, string> = {}
|
|
63
61
|
|
|
64
|
-
if (!authenticationToken.value) {
|
|
65
|
-
errors.authenticationToken = 'Authentication token is required'
|
|
66
|
-
}
|
|
67
|
-
|
|
68
62
|
if (channels.value?.includes('whatsapp') && !metaWabaId.value) {
|
|
69
63
|
errors.metaConfig = 'Meta WABA ID is required for WhatsApp'
|
|
70
64
|
}
|
|
@@ -78,7 +72,6 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
78
72
|
}
|
|
79
73
|
|
|
80
74
|
return {
|
|
81
|
-
authenticationToken,
|
|
82
75
|
product,
|
|
83
76
|
strategy,
|
|
84
77
|
channels,
|
|
@@ -87,7 +80,7 @@ export const useAppContextStore = defineStore('appContext', () => {
|
|
|
87
80
|
dinamicValues,
|
|
88
81
|
metaWabaId,
|
|
89
82
|
metaAccessToken,
|
|
90
|
-
|
|
83
|
+
organization_id,
|
|
91
84
|
default_tags,
|
|
92
85
|
isAdmin,
|
|
93
86
|
|
|
@@ -34,7 +34,6 @@ export const useEmailComposerStore = defineStore('emailComposer', () => {
|
|
|
34
34
|
|
|
35
35
|
// ── Computed ──────────────────────────────────────────────────────
|
|
36
36
|
const messageGroupData = computed(() => ({
|
|
37
|
-
user_id: '',
|
|
38
37
|
name: name.value,
|
|
39
38
|
category: category.value,
|
|
40
39
|
visibility: isInternal.value ? 'internal' : 'public',
|
package/nuxt.config.ts
CHANGED
|
@@ -5,11 +5,10 @@ export default defineNuxtConfig({
|
|
|
5
5
|
viteEnvironmentApi: true,
|
|
6
6
|
},
|
|
7
7
|
devtools: { enabled: true },
|
|
8
|
-
modules: ['@pinia/nuxt', '@nuxtjs/i18n', '@pinia/colada-nuxt'],
|
|
9
8
|
imports: {
|
|
10
9
|
dirs: ['stores', 'queries'],
|
|
11
10
|
},
|
|
12
|
-
extends: ['
|
|
11
|
+
extends: ['@dev.smartpricing/platform-layer'],
|
|
13
12
|
i18n: {
|
|
14
13
|
strategy: 'no_prefix',
|
|
15
14
|
locales: [
|
|
@@ -46,11 +45,9 @@ export default defineNuxtConfig({
|
|
|
46
45
|
],
|
|
47
46
|
detectBrowserLanguage: {
|
|
48
47
|
useCookie: true,
|
|
49
|
-
cookieKey: '
|
|
48
|
+
cookieKey: 'smt_lang',
|
|
50
49
|
fallbackLocale: 'en',
|
|
51
50
|
cookieDomain: process.env.NUXT_PUBLIC_COOKIE_DOMAIN || undefined,
|
|
52
|
-
cookieCrossOrigin: true,
|
|
53
|
-
cookieSecure: false,
|
|
54
51
|
},
|
|
55
52
|
defaultLocale: 'en',
|
|
56
53
|
compilation: {
|
|
@@ -60,6 +57,9 @@ export default defineNuxtConfig({
|
|
|
60
57
|
runtimeConfig: {
|
|
61
58
|
public: {
|
|
62
59
|
COMPOSER_API_URL: '',
|
|
60
|
+
BACKEND_BASE_URL: '',
|
|
61
|
+
PLATFORM_URL: '',
|
|
62
|
+
ENV_CSRF_COOKIE_NAME: 'smt_csrf',
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
65
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.smartpricing/message-composer-layer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -12,11 +12,9 @@
|
|
|
12
12
|
"app.config.ts"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@dev.smartpricing/platform-layer": "^0.0.9",
|
|
15
16
|
"@formkit/drag-and-drop": "^0.5.3",
|
|
16
|
-
"@nuxtjs/i18n": "^10.3.0",
|
|
17
17
|
"@pinia/colada": "^1.3.0",
|
|
18
|
-
"@pinia/colada-nuxt": "^1.0.1",
|
|
19
|
-
"@pinia/nuxt": "^0.11.3",
|
|
20
18
|
"@tiptap/extension-character-count": "^3.23.4",
|
|
21
19
|
"@tiptap/extension-emoji": "^3.23.4",
|
|
22
20
|
"@tiptap/extension-link": "^3.23.4",
|
|
@@ -38,14 +36,14 @@
|
|
|
38
36
|
"vue-router": "^5.0.7",
|
|
39
37
|
"vue3-emoji-picker": "^1.1.8",
|
|
40
38
|
"zod": "^4.4.3",
|
|
41
|
-
"@dev.smartpricing/message-composer-utils": "4.
|
|
39
|
+
"@dev.smartpricing/message-composer-utils": "4.2.2"
|
|
42
40
|
},
|
|
43
41
|
"devDependencies": {
|
|
44
42
|
"@nuxt/eslint": "^1.15.2",
|
|
45
43
|
"@nuxt/test-utils": "^4.0.3",
|
|
46
44
|
"@playwright/test": "^1.60.0",
|
|
47
45
|
"dotenv": "^17.4.2",
|
|
48
|
-
"nuxt-ui-layer": "git+ssh://git@github.com:smartpricing/smartness-nuxt-ui#v1.
|
|
46
|
+
"nuxt-ui-layer": "git+ssh://git@github.com:smartpricing/smartness-nuxt-ui#v1.7.2",
|
|
49
47
|
"vue-tsc": "^3.2.9"
|
|
50
48
|
},
|
|
51
49
|
"peerDependencies": {
|