@greatapps/common 1.1.580 → 1.1.582
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/dist/components/embeds/EmbedWidgets.mjs +8 -4
- package/dist/components/embeds/EmbedWidgets.mjs.map +1 -1
- package/dist/modules/auth/utils/assert-management-permission.mjs +3 -1
- package/dist/modules/auth/utils/assert-management-permission.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/embeds/EmbedWidgets.tsx +14 -4
- package/src/modules/auth/utils/assert-management-permission.ts +3 -1
|
@@ -30,15 +30,19 @@ function useHideCrispOnExcludedRoutes(isExcluded) {
|
|
|
30
30
|
}
|
|
31
31
|
}, [isExcluded]);
|
|
32
32
|
}
|
|
33
|
-
function EmbedWidgets(
|
|
33
|
+
function EmbedWidgets({
|
|
34
|
+
frill = true,
|
|
35
|
+
crisp = true,
|
|
36
|
+
clarity = true
|
|
37
|
+
} = {}) {
|
|
34
38
|
const pathname = usePathname();
|
|
35
39
|
const isExcluded = EXCLUDED_ROUTES.some((route) => pathname.startsWith(route));
|
|
36
40
|
useHideCrispOnExcludedRoutes(isExcluded);
|
|
37
41
|
if (isExcluded) return null;
|
|
38
42
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
-
/* @__PURE__ */ jsx(FrillEmbed, {}),
|
|
40
|
-
/* @__PURE__ */ jsx(CrispEmbed, {}),
|
|
41
|
-
/* @__PURE__ */ jsx(ClarityEmbed, {})
|
|
43
|
+
frill && /* @__PURE__ */ jsx(FrillEmbed, {}),
|
|
44
|
+
crisp && /* @__PURE__ */ jsx(CrispEmbed, {}),
|
|
45
|
+
clarity && /* @__PURE__ */ jsx(ClarityEmbed, {})
|
|
42
46
|
] });
|
|
43
47
|
}
|
|
44
48
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/embeds/EmbedWidgets.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { FrillEmbed } from './FrillEmbed';\nimport { CrispEmbed } from './CrispEmbed';\nimport { ClarityEmbed } from './ClarityEmbed';\n\nconst EXCLUDED_ROUTES = ['/login', '/forgot-password', '/register'];\n\nfunction getCrisp(): unknown[] | null {\n try {\n const key = '$crisp';\n if (!(key in window)) return null;\n const value = window[key];\n return Array.isArray(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction useHideCrispOnExcludedRoutes(isExcluded: boolean) {\n useEffect(() => {\n try {\n const $crisp = getCrisp();\n if (!$crisp) return;\n\n if (isExcluded) {\n $crisp.push(['do', 'chat:hide']);\n } else {\n $crisp.push(['do', 'chat:show']);\n }\n } catch {}\n }, [isExcluded]);\n}\n\nexport function EmbedWidgets() {\n const pathname = usePathname();\n const isExcluded = EXCLUDED_ROUTES.some((route) => pathname.startsWith(route));\n\n useHideCrispOnExcludedRoutes(isExcluded);\n\n if (isExcluded) return null;\n\n return (\n <>\n <FrillEmbed
|
|
1
|
+
{"version":3,"sources":["../../../src/components/embeds/EmbedWidgets.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { FrillEmbed } from './FrillEmbed';\nimport { CrispEmbed } from './CrispEmbed';\nimport { ClarityEmbed } from './ClarityEmbed';\n\nconst EXCLUDED_ROUTES = ['/login', '/forgot-password', '/register'];\n\nfunction getCrisp(): unknown[] | null {\n try {\n const key = '$crisp';\n if (!(key in window)) return null;\n const value = window[key];\n return Array.isArray(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction useHideCrispOnExcludedRoutes(isExcluded: boolean) {\n useEffect(() => {\n try {\n const $crisp = getCrisp();\n if (!$crisp) return;\n\n if (isExcluded) {\n $crisp.push(['do', 'chat:hide']);\n } else {\n $crisp.push(['do', 'chat:show']);\n }\n } catch {}\n }, [isExcluded]);\n}\n\ntype EmbedWidgetsProps = {\n frill?: boolean;\n crisp?: boolean;\n clarity?: boolean;\n};\n\nexport function EmbedWidgets({\n frill = true,\n crisp = true,\n clarity = true,\n}: EmbedWidgetsProps = {}) {\n const pathname = usePathname();\n const isExcluded = EXCLUDED_ROUTES.some((route) => pathname.startsWith(route));\n\n useHideCrispOnExcludedRoutes(isExcluded);\n\n if (isExcluded) return null;\n\n return (\n <>\n {frill && <FrillEmbed />}\n {crisp && <CrispEmbed />}\n {clarity && <ClarityEmbed />}\n </>\n );\n}\n"],"mappings":";AAuDI,mBACY,KADZ;AArDJ,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAE7B,MAAM,kBAAkB,CAAC,UAAU,oBAAoB,WAAW;AAElE,SAAS,WAA6B;AACpC,MAAI;AACF,UAAM,MAAM;AACZ,QAAI,EAAE,OAAO,QAAS,QAAO;AAC7B,UAAM,QAAQ,OAAO,GAAG;AACxB,WAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ;AAAA,EACxC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,6BAA6B,YAAqB;AACzD,YAAU,MAAM;AACd,QAAI;AACF,YAAM,SAAS,SAAS;AACxB,UAAI,CAAC,OAAQ;AAEb,UAAI,YAAY;AACd,eAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAAA,MACjC,OAAO;AACL,eAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAAA,MACjC;AAAA,IACF,QAAQ;AAAA,IAAC;AAAA,EACX,GAAG,CAAC,UAAU,CAAC;AACjB;AAQO,SAAS,aAAa;AAAA,EAC3B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ,IAAuB,CAAC,GAAG;AACzB,QAAM,WAAW,YAAY;AAC7B,QAAM,aAAa,gBAAgB,KAAK,CAAC,UAAU,SAAS,WAAW,KAAK,CAAC;AAE7E,+BAA6B,UAAU;AAEvC,MAAI,WAAY,QAAO;AAEvB,SACE,iCACG;AAAA,aAAS,oBAAC,cAAW;AAAA,IACrB,SAAS,oBAAC,cAAW;AAAA,IACrB,WAAW,oBAAC,gBAAa;AAAA,KAC5B;AAEJ;","names":[]}
|
|
@@ -41,7 +41,9 @@ async function assertManagementPermission(permission) {
|
|
|
41
41
|
default:
|
|
42
42
|
throw new ApiError("Permiss\xE3o inv\xE1lida", "INVALID_PERMISSION", 500);
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
if (permission !== "manage_subscriptions") {
|
|
45
|
+
await assertManagementSubscription();
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
48
|
export {
|
|
47
49
|
assertManagementPermission
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/utils/assert-management-permission.ts"],"sourcesContent":["import 'server-only';\n\nimport { UserProfile } from '../../users/schema';\nimport { findUserById } from '../../users/action/find-user-by-id.action';\nimport { ApiError } from '../../../infra/api/types';\nimport { assertManagementSubscription } from './assert-management-subscription';\nimport type { ManagementPermission } from '../types/management-permission.type';\n\nasync function getCurrentUserProfile() {\n const result = await findUserById();\n\n if (!result.success || !result.data) {\n throw new ApiError(\n ('error' in result && result.error) || 'Não foi possível identificar o usuário autenticado',\n 'USER_CONTEXT_FAILED',\n 403\n );\n }\n\n return result.data.profile;\n}\n\nexport async function assertManagementPermission(permission: ManagementPermission) {\n const profile = await getCurrentUserProfile();\n\n switch (permission) {\n case 'manage_pages':\n case 'manage_redirects':\n case 'manage_domains':\n case 'manage_ab_tests':\n case 'restore_pages':\n if (profile === UserProfile.viewer) {\n throw new ApiError('Você não tem permissão para executar esta ação', 'FORBIDDEN', 403);\n }\n break;\n case 'manage_projects':\n case 'create_pages':\n case 'update_pages':\n case 'delete_pages':\n case 'delete_leads':\n case 'view_cards':\n case 'manage_cards':\n case 'manage_subscriptions':\n if (profile !== UserProfile.owner && profile !== UserProfile.admin) {\n throw new ApiError('Você não tem permissão para executar esta ação', 'FORBIDDEN', 403);\n }\n break;\n default:\n throw new ApiError('Permissão inválida', 'INVALID_PERMISSION', 500);\n }\n\n await assertManagementSubscription();\n}\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,oCAAoC;AAG7C,eAAe,wBAAwB;AACrC,QAAM,SAAS,MAAM,aAAa;AAElC,MAAI,CAAC,OAAO,WAAW,CAAC,OAAO,MAAM;AACnC,UAAM,IAAI;AAAA,MACP,WAAW,UAAU,OAAO,SAAU;AAAA,MACvC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,KAAK;AACrB;AAEA,eAAsB,2BAA2B,YAAkC;AACjF,QAAM,UAAU,MAAM,sBAAsB;AAE5C,UAAQ,YAAY;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,UAAI,YAAY,YAAY,QAAQ;AAClC,cAAM,IAAI,SAAS,iEAAkD,aAAa,GAAG;AAAA,MACvF;AACA;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,UAAI,YAAY,YAAY,SAAS,YAAY,YAAY,OAAO;AAClE,cAAM,IAAI,SAAS,iEAAkD,aAAa,GAAG;AAAA,MACvF;AACA;AAAA,IACF;AACE,YAAM,IAAI,SAAS,4BAAsB,sBAAsB,GAAG;AAAA,EACtE;AAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/utils/assert-management-permission.ts"],"sourcesContent":["import 'server-only';\n\nimport { UserProfile } from '../../users/schema';\nimport { findUserById } from '../../users/action/find-user-by-id.action';\nimport { ApiError } from '../../../infra/api/types';\nimport { assertManagementSubscription } from './assert-management-subscription';\nimport type { ManagementPermission } from '../types/management-permission.type';\n\nasync function getCurrentUserProfile() {\n const result = await findUserById();\n\n if (!result.success || !result.data) {\n throw new ApiError(\n ('error' in result && result.error) || 'Não foi possível identificar o usuário autenticado',\n 'USER_CONTEXT_FAILED',\n 403\n );\n }\n\n return result.data.profile;\n}\n\nexport async function assertManagementPermission(permission: ManagementPermission) {\n const profile = await getCurrentUserProfile();\n\n switch (permission) {\n case 'manage_pages':\n case 'manage_redirects':\n case 'manage_domains':\n case 'manage_ab_tests':\n case 'restore_pages':\n if (profile === UserProfile.viewer) {\n throw new ApiError('Você não tem permissão para executar esta ação', 'FORBIDDEN', 403);\n }\n break;\n case 'manage_projects':\n case 'create_pages':\n case 'update_pages':\n case 'delete_pages':\n case 'delete_leads':\n case 'view_cards':\n case 'manage_cards':\n case 'manage_subscriptions':\n if (profile !== UserProfile.owner && profile !== UserProfile.admin) {\n throw new ApiError('Você não tem permissão para executar esta ação', 'FORBIDDEN', 403);\n }\n break;\n default:\n throw new ApiError('Permissão inválida', 'INVALID_PERMISSION', 500);\n }\n\n if (permission !== 'manage_subscriptions') {\n await assertManagementSubscription();\n }\n}\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,oCAAoC;AAG7C,eAAe,wBAAwB;AACrC,QAAM,SAAS,MAAM,aAAa;AAElC,MAAI,CAAC,OAAO,WAAW,CAAC,OAAO,MAAM;AACnC,UAAM,IAAI;AAAA,MACP,WAAW,UAAU,OAAO,SAAU;AAAA,MACvC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,KAAK;AACrB;AAEA,eAAsB,2BAA2B,YAAkC;AACjF,QAAM,UAAU,MAAM,sBAAsB;AAE5C,UAAQ,YAAY;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,UAAI,YAAY,YAAY,QAAQ;AAClC,cAAM,IAAI,SAAS,iEAAkD,aAAa,GAAG;AAAA,MACvF;AACA;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,UAAI,YAAY,YAAY,SAAS,YAAY,YAAY,OAAO;AAClE,cAAM,IAAI,SAAS,iEAAkD,aAAa,GAAG;AAAA,MACvF;AACA;AAAA,IACF;AACE,YAAM,IAAI,SAAS,4BAAsB,sBAAsB,GAAG;AAAA,EACtE;AAEA,MAAI,eAAe,wBAAwB;AACzC,UAAM,6BAA6B;AAAA,EACrC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -34,7 +34,17 @@ function useHideCrispOnExcludedRoutes(isExcluded: boolean) {
|
|
|
34
34
|
}, [isExcluded]);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
type EmbedWidgetsProps = {
|
|
38
|
+
frill?: boolean;
|
|
39
|
+
crisp?: boolean;
|
|
40
|
+
clarity?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export function EmbedWidgets({
|
|
44
|
+
frill = true,
|
|
45
|
+
crisp = true,
|
|
46
|
+
clarity = true,
|
|
47
|
+
}: EmbedWidgetsProps = {}) {
|
|
38
48
|
const pathname = usePathname();
|
|
39
49
|
const isExcluded = EXCLUDED_ROUTES.some((route) => pathname.startsWith(route));
|
|
40
50
|
|
|
@@ -44,9 +54,9 @@ export function EmbedWidgets() {
|
|
|
44
54
|
|
|
45
55
|
return (
|
|
46
56
|
<>
|
|
47
|
-
<FrillEmbed />
|
|
48
|
-
<CrispEmbed />
|
|
49
|
-
<ClarityEmbed />
|
|
57
|
+
{frill && <FrillEmbed />}
|
|
58
|
+
{crisp && <CrispEmbed />}
|
|
59
|
+
{clarity && <ClarityEmbed />}
|
|
50
60
|
</>
|
|
51
61
|
);
|
|
52
62
|
}
|
|
@@ -49,5 +49,7 @@ export async function assertManagementPermission(permission: ManagementPermissio
|
|
|
49
49
|
throw new ApiError('Permissão inválida', 'INVALID_PERMISSION', 500);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
if (permission !== 'manage_subscriptions') {
|
|
53
|
+
await assertManagementSubscription();
|
|
54
|
+
}
|
|
53
55
|
}
|