@sensinum/strapi-plugin-multi-domain 5.2.2 → 5.3.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/dist/{_chunks/About-BwHHM2-e.mjs → admin/About-DfCon-RP.mjs} +5 -5
- package/dist/{_chunks/About-BMKe8Nmq.js → admin/About-DfcPwQ3q.js} +2 -2
- package/dist/admin/QueryProvider-CCX1cgmZ.js +1 -0
- package/dist/{_chunks/QueryProvider-DLzv0qqi.mjs → admin/QueryProvider-oO97LaUB.mjs} +2 -2
- package/dist/{_chunks/Settings-v1cjVAKt.mjs → admin/Settings-Dj3h2ayB.mjs} +3 -3
- package/dist/{_chunks/Settings-dlu3XY5j.js → admin/Settings-tt-Wetcr.js} +1 -1
- package/dist/{_chunks/TenantCustomField-cjk2h9Sy.js → admin/TenantCustomField-Bf6uUoKE.js} +1 -1
- package/dist/{_chunks/TenantCustomField-Cc17Wct3.mjs → admin/TenantCustomField-CS8x0CkO.mjs} +24 -24
- package/dist/admin/TenantEdit-BT3-tB_B.js +1 -0
- package/dist/admin/TenantEdit-BY_7PPAr.mjs +490 -0
- package/dist/admin/TenantList-DrfJNPpi.js +1 -0
- package/dist/{_chunks/TenantList-CONeayj-.mjs → admin/TenantList-dIxGcZPl.mjs} +43 -45
- package/dist/{_chunks/index-D6ydxf5B.mjs → admin/index-7tHbI_K_.mjs} +55 -54
- package/dist/admin/index-Cci_046h.js +1 -0
- package/dist/admin/index-Doprxev-.mjs +187 -0
- package/dist/admin/index-oNXgzV7S.js +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/{_chunks/useGetMessage-B8BN0qvw.mjs → admin/useGetMessage-CTdHvgbI.mjs} +1 -1
- package/dist/admin/useGetMessage-DS88gOrN.js +1 -0
- package/dist/admin/useSettings-C7vR1hfw.js +1 -0
- package/dist/{_chunks/useSettings-CimYpZ4J.mjs → admin/useSettings-bLTyn7Pl.mjs} +2 -2
- package/dist/{_chunks/useTenants-DezjZnH2.mjs → admin/useTenants-Da8khjOe.mjs} +4 -4
- package/dist/admin/useTenants-vVkOIEvT.js +1 -0
- package/dist/server/index.js +4 -6
- package/dist/server/index.mjs +3396 -7192
- package/package.json +20 -21
- package/dist/_chunks/QueryProvider-DUoM4JhC.js +0 -1
- package/dist/_chunks/TenantEdit-BTFMfW4k.js +0 -1
- package/dist/_chunks/TenantEdit-CVAR1Ief.mjs +0 -494
- package/dist/_chunks/TenantList-D2kRXKow.js +0 -1
- package/dist/_chunks/index-Bmegt3iZ.js +0 -1
- package/dist/_chunks/index-BoaWY6pN.js +0 -1
- package/dist/_chunks/index-DMvlWHGg.mjs +0 -182
- package/dist/_chunks/useGetMessage-Qu_lnA6t.js +0 -1
- package/dist/_chunks/useSettings-Bvg8rV47.js +0 -1
- package/dist/_chunks/useTenants-BWUvXqt6.js +0 -1
- package/dist/shared/config.d.ts +0 -7
- package/dist/shared/config.d.ts.map +0 -1
- package/dist/shared/permissions.d.ts +0 -35
- package/dist/shared/permissions.d.ts.map +0 -1
- package/dist/shared/pluginIds.d.ts +0 -9
- package/dist/shared/pluginIds.d.ts.map +0 -1
- package/dist/shared/schemas/admin.d.ts +0 -26
- package/dist/shared/schemas/admin.d.ts.map +0 -1
- package/dist/shared/schemas/index.d.ts +0 -8
- package/dist/shared/schemas/index.d.ts.map +0 -1
- package/dist/shared/schemas/permision.schema.d.ts +0 -28
- package/dist/shared/schemas/permision.schema.d.ts.map +0 -1
- package/dist/shared/schemas/query-params.schema.d.ts +0 -19
- package/dist/shared/schemas/query-params.schema.d.ts.map +0 -1
- package/dist/shared/schemas/role.schema.d.ts +0 -101
- package/dist/shared/schemas/role.schema.d.ts.map +0 -1
- package/dist/shared/schemas/tenant.schema.d.ts +0 -428
- package/dist/shared/schemas/tenant.schema.d.ts.map +0 -1
- package/dist/shared/schemas/token.schema.d.ts +0 -13
- package/dist/shared/schemas/token.schema.d.ts.map +0 -1
- package/dist/shared/schemas/uniq-validation.schema.d.ts +0 -18
- package/dist/shared/schemas/uniq-validation.schema.d.ts.map +0 -1
- package/dist/shared/schemas/utils.d.ts +0 -3
- package/dist/shared/schemas/utils.d.ts.map +0 -1
- /package/dist/{_chunks → admin}/en-Cf69p5po.mjs +0 -0
- /package/dist/{_chunks → admin}/en-hAVH8fH0.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),m=require("@strapi/icons"),a=require("@strapi/strapi/admin"),k=require("react"),q=require("react-router-dom"),x=require("./index-oNXgzV7S.js"),p=require("./useTenants-vVkOIEvT.js"),W=require("styled-components"),P=require("./useGetMessage-DS88gOrN.js"),G=require("./useSettings-C7vR1hfw.js"),A=n=>n&&n.__esModule?n:{default:n},H=A(k),O=A(W),Q=({isOpen:n,onClose:i,onConfirm:l,target:r})=>e.jsx(t.Dialog.Root,{open:n,onOpenChange:i,children:e.jsxs(t.Dialog.Content,{children:[e.jsx(t.Dialog.Header,{children:"Confirmation"}),e.jsx(t.Dialog.Body,{icon:e.jsx(m.Trash,{}),children:e.jsx(t.Dialog.Description,{textAlign:"center",children:e.jsxs(t.Flex,{gap:2,direction:"column",children:[e.jsx(m.WarningCircle,{fill:"danger600",width:"24",height:"24"}),"Are you sure you want to delete this ",r,"?",e.jsx("br",{}),"All your modifications will be lost"]})})}),e.jsxs(t.Dialog.Footer,{children:[e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:i,variant:"tertiary",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Cancel"})})}),e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:l,variant:"danger",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Confirm"})})})]})]})}),U=({isDisplayed:n,direction:i})=>n?i==="asc"?e.jsx(m.ArrowUp,{}):e.jsx(m.ArrowDown,{}):null,D=({label:n,field:i,sort:l,onSort:r})=>{const[c,h]=l.split(":");return e.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>r(i)(h==="asc"?"desc":"asc"),children:[e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:n}),e.jsx("span",{style:{marginLeft:4},children:e.jsx(U,{isDisplayed:i===c,direction:h})})]})},J=O.default(t.Tr)(()=>({cursor:"pointer"})),K=({tenant:n,selectedTenants:i,handleSelectTenant:l,onDeleteTenant:r,isDeletePending:c=!1})=>{const h=q.useNavigate(),s=P.useGetMessage(),y=u=>()=>h(`/settings/${x.pluginId}/${x.modelRoute}/${u.id}`);return e.jsxs(J,{onClick:y(n),children:[e.jsx(t.Td,{children:e.jsx(t.Checkbox,{checked:i.includes(n.id),onCheckedChange:u=>l(n.id,u)})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:n.id})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:n.name})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{textColor:"neutral800",children:n.code})}),e.jsx(t.Td,{children:n.role?e.jsx(t.Badge,{textColor:"neutral800",backgroundColor:"neutral100",children:n.role.name}):e.jsx(t.Typography,{textColor:"neutral600",children:"-"})}),e.jsx(t.Td,{children:e.jsxs(t.Flex,{gap:1,children:[e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.edit,children:e.jsx(t.IconButton,{onClick:y(n),label:s("common.edit"),children:e.jsx(m.Pencil,{})})}),e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.delete,children:e.jsx(t.IconButton,{onClick:r(n),label:s("common.delete"),disabled:c,children:e.jsx(m.Trash,{})})})]})})]})},V=()=>{const n=q.useNavigate(),{toggleNotification:i}=a.useNotification(),[l,r]=k.useState([]),[c,h]=k.useState(),s=P.useGetMessage(),y=p.useDeleteTenant(),{data:u,isLoading:w}=G.useSettings(),[{query:j},L]=a.useQueryParams({sort:"name:asc",_q:"",page:1,pageSize:10}),{sort:f,_q:M,page:R,pageSize:_}={...j,sort:j.sort||"name:asc",_q:j._q||"",page:j.page||1,pageSize:j.pageSize||10},{data:v,isLoading:B,error:T}=p.useTenants({sort:f,search:M,page:R,pageSize:_}),g=v?.results||[],C=v?.pagination||{pageCount:1,total:0};H.default.useEffect(()=>{T&&i({type:"danger",message:T instanceof Error?T.message:"An error occurred while fetching tenants"})},[T,i]);const I=o=>{r(o===!0?g.map(d=>d.id):[])},z=(o,d)=>{r(d?b=>[...b,o]:b=>b.filter(N=>N!==o))},S=o=>d=>{L({...j,sort:`${o}:${d}`})},$=o=>async d=>{d.stopPropagation(),h(o)},E=async()=>{if(c)try{await y.mutateAsync(c.id),i({type:"success",message:s("domain.notifications.deleted",{values:{name:c.name}})}),h(void 0),r(o=>o.filter(d=>d!==c.id))}catch{i({type:"danger",message:s("domain.notifications.deleteError")})}},F=()=>{h(void 0)};return B||w?e.jsx(a.Page.Main,{children:e.jsx(a.Layouts.Content,{children:e.jsx(t.Loader,{children:s("domain.list.loading")})})}):e.jsxs(e.Fragment,{children:[e.jsx(a.Page.Title,{children:"Tenants"}),e.jsxs(a.Page.Main,{children:[e.jsx(a.Layouts.Header,{title:s("domain.list.title"),subtitle:s("domain.list.subtitle",{values:{count:g.length}})}),e.jsx(a.Layouts.Action,{startActions:e.jsx(e.Fragment,{children:e.jsx(a.SearchInput,{label:s("domain.list.search",{defaultMessage:"Search domains"})})}),endActions:e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.create,children:e.jsx(t.Button,{startIcon:e.jsx(m.Plus,{}),onClick:()=>{if(!u?.features?.unlimited&&u?.features?.domains!=null&&u?.features?.domains<=C.total)return i({type:"warning",message:s("domain.list.limitReached",{values:{limit:u?.features.domains||0}})});n(`/settings/${x.pluginId}/${x.modelRoute}/new`)},children:s("common.create")})})}),e.jsx(a.Layouts.Content,{children:g.length===0?e.jsx(t.EmptyStateLayout,{icon:e.jsx(m.Search,{}),content:s("domain.list.emptyState",{defaultMessage:"No domains found matching your search criteria"})}):e.jsxs(e.Fragment,{children:[e.jsxs(t.Table,{colCount:6,rowCount:g.length+1,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:e.jsx(t.Checkbox,{checked:l.length>0&&l.length<g.length?"indeterminate":l.length===g.length&&g.length>0,onCheckedChange:I})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.id"),field:"id",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.name"),field:"name",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.code"),field:"code",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s("domain.list.table.headers.role")})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s("domain.list.table.headers.actions")})})]})}),e.jsx(t.Tbody,{children:g.map(o=>e.jsx(K,{tenant:o,selectedTenants:l,handleSelectTenant:z,onDeleteTenant:$},o.id))})]}),e.jsx(t.Box,{paddingTop:4,children:e.jsxs(a.Pagination.Root,{pageCount:C.pageCount,total:C.total,children:[e.jsx(a.Pagination.PageSize,{}),e.jsx(a.Pagination.Links,{})]})})]})})]}),e.jsx(Q,{isOpen:!!c,onClose:F,onConfirm:E,target:c?.name||x.modelId})]})};exports.default=V;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as A } from "react/jsx-runtime";
|
|
2
|
-
import { Dialog as u, Flex as q, Button as L, Typography as d, Td as f, Checkbox as I, Badge as
|
|
2
|
+
import { Dialog as u, Flex as q, Button as L, Typography as d, Td as f, Checkbox as I, Badge as te, IconButton as R, Tr as E, Loader as ne, EmptyStateLayout as ie, Table as oe, Thead as ae, Th as C, Tbody as re, Box as le } from "@strapi/design-system";
|
|
3
3
|
import { WarningCircle as se, Trash as W, ArrowUp as ce, ArrowDown as de, Pencil as he, Plus as me, Search as ge } from "@strapi/icons";
|
|
4
4
|
import { useNotification as ue, useQueryParams as pe, Page as D, Layouts as b, SearchInput as fe, Pagination as w } from "@strapi/strapi/admin";
|
|
5
5
|
import Ce, { useState as $ } from "react";
|
|
6
6
|
import { useNavigate as N } from "react-router-dom";
|
|
7
|
-
import { b as M, p as _, m as H, c as ye } from "./index-
|
|
8
|
-
import { C as z, u as Se, a as Te } from "./useTenants-
|
|
7
|
+
import { b as M, p as _, m as H, c as ye } from "./index-7tHbI_K_.mjs";
|
|
8
|
+
import { C as z, u as Se, a as Te } from "./useTenants-Da8khjOe.mjs";
|
|
9
9
|
import be from "styled-components";
|
|
10
|
-
import { u as j } from "./useGetMessage-
|
|
11
|
-
import { u as ve } from "./useSettings-
|
|
10
|
+
import { u as j } from "./useGetMessage-CTdHvgbI.mjs";
|
|
11
|
+
import { u as ve } from "./useSettings-bLTyn7Pl.mjs";
|
|
12
12
|
const ke = ({
|
|
13
|
-
isOpen:
|
|
13
|
+
isOpen: t,
|
|
14
14
|
onClose: i,
|
|
15
15
|
onConfirm: l,
|
|
16
16
|
target: r
|
|
17
|
-
}) => /* @__PURE__ */ e(u.Root, { open:
|
|
17
|
+
}) => /* @__PURE__ */ e(u.Root, { open: t, onOpenChange: i, children: /* @__PURE__ */ a(u.Content, { children: [
|
|
18
18
|
/* @__PURE__ */ e(u.Header, { children: "Confirmation" }),
|
|
19
19
|
/* @__PURE__ */ e(u.Body, { icon: /* @__PURE__ */ e(W, {}), children: /* @__PURE__ */ e(u.Description, { textAlign: "center", children: /* @__PURE__ */ a(q, { gap: 2, direction: "column", children: [
|
|
20
20
|
/* @__PURE__ */ e(se, { fill: "danger600", width: "24", height: "24" }),
|
|
@@ -29,10 +29,10 @@ const ke = ({
|
|
|
29
29
|
/* @__PURE__ */ e(u.Action, { children: /* @__PURE__ */ e(L, { fullWidth: !0, onClick: l, variant: "danger", size: "S", children: /* @__PURE__ */ e(d, { variant: "omega", children: "Confirm" }) }) })
|
|
30
30
|
] })
|
|
31
31
|
] }) }), xe = ({
|
|
32
|
-
isDisplayed:
|
|
32
|
+
isDisplayed: t,
|
|
33
33
|
direction: i
|
|
34
|
-
}) =>
|
|
35
|
-
label:
|
|
34
|
+
}) => t ? i === "asc" ? /* @__PURE__ */ e(ce, {}) : /* @__PURE__ */ e(de, {}) : null, P = ({
|
|
35
|
+
label: t,
|
|
36
36
|
field: i,
|
|
37
37
|
sort: l,
|
|
38
38
|
onSort: r
|
|
@@ -44,7 +44,7 @@ const ke = ({
|
|
|
44
44
|
style: { display: "flex", alignItems: "center", cursor: "pointer" },
|
|
45
45
|
onClick: () => r(i)(h === "asc" ? "desc" : "asc"),
|
|
46
46
|
children: [
|
|
47
|
-
/* @__PURE__ */ e(d, { variant: "sigma", textColor: "neutral600", children:
|
|
47
|
+
/* @__PURE__ */ e(d, { variant: "sigma", textColor: "neutral600", children: t }),
|
|
48
48
|
/* @__PURE__ */ e("span", { style: { marginLeft: 4 }, children: /* @__PURE__ */ e(xe, { isDisplayed: i === s, direction: h }) })
|
|
49
49
|
]
|
|
50
50
|
}
|
|
@@ -52,39 +52,39 @@ const ke = ({
|
|
|
52
52
|
}, Ae = be(E)(() => ({
|
|
53
53
|
cursor: "pointer"
|
|
54
54
|
})), De = ({
|
|
55
|
-
tenant:
|
|
55
|
+
tenant: t,
|
|
56
56
|
selectedTenants: i,
|
|
57
57
|
handleSelectTenant: l,
|
|
58
58
|
onDeleteTenant: r,
|
|
59
59
|
isDeletePending: s = !1
|
|
60
60
|
}) => {
|
|
61
|
-
const h = N(),
|
|
62
|
-
return /* @__PURE__ */ a(Ae, { onClick: y(
|
|
61
|
+
const h = N(), n = j(), y = (m) => () => h(`/settings/${_}/${H}/${m.id}`);
|
|
62
|
+
return /* @__PURE__ */ a(Ae, { onClick: y(t), children: [
|
|
63
63
|
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(
|
|
64
64
|
I,
|
|
65
65
|
{
|
|
66
|
-
checked: i.includes(
|
|
67
|
-
onCheckedChange: (m) => l(
|
|
66
|
+
checked: i.includes(t.id),
|
|
67
|
+
onCheckedChange: (m) => l(t.id, m)
|
|
68
68
|
}
|
|
69
69
|
) }),
|
|
70
|
-
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(d, { fontWeight: "semiBold", textColor: "neutral800", children:
|
|
71
|
-
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(d, { fontWeight: "semiBold", textColor: "neutral800", children:
|
|
72
|
-
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(d, { textColor: "neutral800", children:
|
|
73
|
-
/* @__PURE__ */ e(f, { children:
|
|
70
|
+
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(d, { fontWeight: "semiBold", textColor: "neutral800", children: t.id }) }),
|
|
71
|
+
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(d, { fontWeight: "semiBold", textColor: "neutral800", children: t.name }) }),
|
|
72
|
+
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(d, { textColor: "neutral800", children: t.code }) }),
|
|
73
|
+
/* @__PURE__ */ e(f, { children: t.role ? /* @__PURE__ */ e(te, { textColor: "neutral800", backgroundColor: "neutral100", children: t.role.name }) : /* @__PURE__ */ e(d, { textColor: "neutral600", children: "-" }) }),
|
|
74
74
|
/* @__PURE__ */ e(f, { children: /* @__PURE__ */ a(q, { gap: 1, children: [
|
|
75
75
|
/* @__PURE__ */ e(z, { permissions: M.admin.edit, children: /* @__PURE__ */ e(
|
|
76
76
|
R,
|
|
77
77
|
{
|
|
78
|
-
onClick: y(
|
|
79
|
-
label:
|
|
78
|
+
onClick: y(t),
|
|
79
|
+
label: n("common.edit"),
|
|
80
80
|
children: /* @__PURE__ */ e(he, {})
|
|
81
81
|
}
|
|
82
82
|
) }),
|
|
83
83
|
/* @__PURE__ */ e(z, { permissions: M.admin.delete, children: /* @__PURE__ */ e(
|
|
84
84
|
R,
|
|
85
85
|
{
|
|
86
|
-
onClick: r(
|
|
87
|
-
label:
|
|
86
|
+
onClick: r(t),
|
|
87
|
+
label: n("common.delete"),
|
|
88
88
|
disabled: s,
|
|
89
89
|
children: /* @__PURE__ */ e(W, {})
|
|
90
90
|
}
|
|
@@ -92,7 +92,7 @@ const ke = ({
|
|
|
92
92
|
] }) })
|
|
93
93
|
] });
|
|
94
94
|
}, We = () => {
|
|
95
|
-
const
|
|
95
|
+
const t = N(), { toggleNotification: i } = ue(), [l, r] = $([]), [s, h] = $(), n = j(), y = Se(), { data: m, isLoading: F } = ve(), [{ query: p }, O] = pe({
|
|
96
96
|
sort: "name:asc",
|
|
97
97
|
_q: "",
|
|
98
98
|
page: 1,
|
|
@@ -111,7 +111,7 @@ const ke = ({
|
|
|
111
111
|
});
|
|
112
112
|
}, [T, i]);
|
|
113
113
|
const K = (o) => {
|
|
114
|
-
r(o ? g.map((c) => c.id) : []);
|
|
114
|
+
r(o === !0 ? g.map((c) => c.id) : []);
|
|
115
115
|
}, V = (o, c) => {
|
|
116
116
|
r(c ? (x) => [...x, o] : (x) => x.filter((ee) => ee !== o));
|
|
117
117
|
}, k = (o) => (c) => {
|
|
@@ -126,30 +126,29 @@ const ke = ({
|
|
|
126
126
|
try {
|
|
127
127
|
await y.mutateAsync(s.id), i({
|
|
128
128
|
type: "success",
|
|
129
|
-
message:
|
|
129
|
+
message: n("domain.notifications.deleted", {
|
|
130
130
|
values: { name: s.name }
|
|
131
131
|
})
|
|
132
132
|
}), h(void 0), r((o) => o.filter((c) => c !== s.id));
|
|
133
133
|
} catch {
|
|
134
134
|
i({
|
|
135
135
|
type: "danger",
|
|
136
|
-
message:
|
|
136
|
+
message: n("domain.notifications.deleteError")
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}, Z = () => {
|
|
140
140
|
h(void 0);
|
|
141
141
|
};
|
|
142
|
-
return J || F ? /* @__PURE__ */ e(D.Main, { children: /* @__PURE__ */ e(b.Content, { children: /* @__PURE__ */ e(
|
|
142
|
+
return J || F ? /* @__PURE__ */ e(D.Main, { children: /* @__PURE__ */ e(b.Content, { children: /* @__PURE__ */ e(ne, { children: n("domain.list.loading") }) }) }) : /* @__PURE__ */ a(A, { children: [
|
|
143
143
|
/* @__PURE__ */ e(D.Title, { children: "Tenants" }),
|
|
144
144
|
/* @__PURE__ */ a(D.Main, { children: [
|
|
145
145
|
/* @__PURE__ */ e(
|
|
146
146
|
b.Header,
|
|
147
147
|
{
|
|
148
|
-
title:
|
|
149
|
-
subtitle:
|
|
148
|
+
title: n("domain.list.title"),
|
|
149
|
+
subtitle: n("domain.list.subtitle", {
|
|
150
150
|
values: { count: g.length }
|
|
151
|
-
})
|
|
152
|
-
as: "h2"
|
|
151
|
+
})
|
|
153
152
|
}
|
|
154
153
|
),
|
|
155
154
|
/* @__PURE__ */ e(
|
|
@@ -158,7 +157,7 @@ const ke = ({
|
|
|
158
157
|
startActions: /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(
|
|
159
158
|
fe,
|
|
160
159
|
{
|
|
161
|
-
label:
|
|
160
|
+
label: n("domain.list.search", {
|
|
162
161
|
defaultMessage: "Search domains"
|
|
163
162
|
})
|
|
164
163
|
}
|
|
@@ -171,15 +170,15 @@ const ke = ({
|
|
|
171
170
|
if (!m?.features?.unlimited && m?.features?.domains != null && m?.features?.domains <= v.total)
|
|
172
171
|
return i({
|
|
173
172
|
type: "warning",
|
|
174
|
-
message:
|
|
173
|
+
message: n("domain.list.limitReached", {
|
|
175
174
|
values: {
|
|
176
175
|
limit: m?.features.domains || 0
|
|
177
176
|
}
|
|
178
177
|
})
|
|
179
178
|
});
|
|
180
|
-
|
|
179
|
+
t(`/settings/${_}/${H}/new`);
|
|
181
180
|
},
|
|
182
|
-
children:
|
|
181
|
+
children: n("common.create")
|
|
183
182
|
}
|
|
184
183
|
) })
|
|
185
184
|
}
|
|
@@ -188,7 +187,7 @@ const ke = ({
|
|
|
188
187
|
ie,
|
|
189
188
|
{
|
|
190
189
|
icon: /* @__PURE__ */ e(ge, {}),
|
|
191
|
-
content:
|
|
190
|
+
content: n("domain.list.emptyState", {
|
|
192
191
|
defaultMessage: "No domains found matching your search criteria"
|
|
193
192
|
})
|
|
194
193
|
}
|
|
@@ -198,15 +197,14 @@ const ke = ({
|
|
|
198
197
|
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(
|
|
199
198
|
I,
|
|
200
199
|
{
|
|
201
|
-
checked: l.length === g.length && g.length > 0,
|
|
202
|
-
indeterminate: l.length > 0 ? l.length < g.length : void 0,
|
|
200
|
+
checked: l.length > 0 && l.length < g.length ? "indeterminate" : l.length === g.length && g.length > 0,
|
|
203
201
|
onCheckedChange: K
|
|
204
202
|
}
|
|
205
203
|
) }),
|
|
206
204
|
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(
|
|
207
205
|
P,
|
|
208
206
|
{
|
|
209
|
-
label:
|
|
207
|
+
label: n("domain.list.table.headers.id"),
|
|
210
208
|
field: "id",
|
|
211
209
|
sort: S,
|
|
212
210
|
onSort: k
|
|
@@ -215,7 +213,7 @@ const ke = ({
|
|
|
215
213
|
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(
|
|
216
214
|
P,
|
|
217
215
|
{
|
|
218
|
-
label:
|
|
216
|
+
label: n("domain.list.table.headers.name"),
|
|
219
217
|
field: "name",
|
|
220
218
|
sort: S,
|
|
221
219
|
onSort: k
|
|
@@ -224,14 +222,14 @@ const ke = ({
|
|
|
224
222
|
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(
|
|
225
223
|
P,
|
|
226
224
|
{
|
|
227
|
-
label:
|
|
225
|
+
label: n("domain.list.table.headers.code"),
|
|
228
226
|
field: "code",
|
|
229
227
|
sort: S,
|
|
230
228
|
onSort: k
|
|
231
229
|
}
|
|
232
230
|
) }),
|
|
233
|
-
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { variant: "sigma", textColor: "neutral600", children:
|
|
234
|
-
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { variant: "sigma", textColor: "neutral600", children:
|
|
231
|
+
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { variant: "sigma", textColor: "neutral600", children: n("domain.list.table.headers.role") }) }),
|
|
232
|
+
/* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { variant: "sigma", textColor: "neutral600", children: n("domain.list.table.headers.actions") }) })
|
|
235
233
|
] }) }),
|
|
236
234
|
/* @__PURE__ */ e(re, { children: g.map((o) => /* @__PURE__ */ e(
|
|
237
235
|
De,
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { toSnakeCase as W, funnel as V } from "remeda";
|
|
2
2
|
import { z as J } from "zod";
|
|
3
3
|
import { jsx as o, jsxs as m } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
5
|
-
import X, { useRef as Y, useEffect as Z, useState as x } from "react";
|
|
4
|
+
import G, { useRef as K, useEffect as X, useState as x } from "react";
|
|
6
5
|
import { CookiesProvider as R, useCookies as D } from "react-cookie";
|
|
7
|
-
import {
|
|
6
|
+
import { useParams as Y } from "react-router-dom";
|
|
7
|
+
import { getFetchClient as Z } from "@strapi/strapi/admin";
|
|
8
|
+
import { Avatar as k, Modal as h, Box as L, Field as P, Searchbar as ee, EmptyStateLayout as te, Table as ne, Thead as oe, Tr as M, Th as C, Typography as S, Tbody as ie, Td as T, Checkbox as ae, Button as I, DesignSystemProvider as re, lightTheme as se, darkTheme as ce } from "@strapi/design-system";
|
|
8
9
|
import { createRoot as le } from "react-dom/client";
|
|
9
10
|
import { Search as de } from "@strapi/icons";
|
|
10
11
|
import { QueryClient as ue, QueryClientProvider as me } from "@tanstack/react-query";
|
|
11
|
-
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.
|
|
12
|
-
name: "multi-domain"
|
|
13
|
-
}, je = {
|
|
12
|
+
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.3.2", ge = "https://www.sensinum.com/contact", fe = "hello@sensinum.com", ye = { name: "multi-domain" }, Fe = {
|
|
14
13
|
name: he,
|
|
15
14
|
version: pe,
|
|
16
15
|
homepage: ge,
|
|
@@ -36,13 +35,13 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
36
35
|
const t = `/admin/content-manager/collection-types/${e}/create`, n = document.querySelector(`a[href*="${t}"]`);
|
|
37
36
|
n && (n.style.display = "none");
|
|
38
37
|
}, Se = () => {
|
|
39
|
-
const [{ [p]: e }] = D([p]), t = U(e), { slug: n } =
|
|
40
|
-
return
|
|
41
|
-
(t || !e) && Ce(n);
|
|
38
|
+
const [{ [p]: e }] = D([p]), t = U(e), { slug: n } = Y();
|
|
39
|
+
return G.useEffect(() => {
|
|
40
|
+
n && (t || !e) && Ce(n);
|
|
42
41
|
}, [t, e, n]), null;
|
|
43
42
|
}, Te = () => /* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(Se, {}) }), ve = ({ setPlugin: e }) => {
|
|
44
|
-
const t =
|
|
45
|
-
return
|
|
43
|
+
const t = K(e);
|
|
44
|
+
return X(() => {
|
|
46
45
|
t.current(a);
|
|
47
46
|
}, []), null;
|
|
48
47
|
}, B = {
|
|
@@ -58,32 +57,34 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
58
57
|
const r = t.length ? `${t}.` : "";
|
|
59
58
|
return typeof e[i] == "object" && e[i] !== null && !Array.isArray(e[i]) ? Object.assign(n, A(e[i], r + i)) : n[r + i] = e[i], n;
|
|
60
59
|
}, {}), Ee = ({ onClose: e, userData: t }) => {
|
|
61
|
-
const [{ [p]: n }, i] = D([p]), [r, d] = x(""), [
|
|
62
|
-
(
|
|
63
|
-
), y = (
|
|
64
|
-
u(
|
|
60
|
+
const [{ [p]: n }, i] = D([p]), [r, d] = x(""), [c, u] = x(n || null), l = (t[E] || []).filter(
|
|
61
|
+
(s) => s.name.toLowerCase().includes(r.toLowerCase())
|
|
62
|
+
), y = (s) => {
|
|
63
|
+
u(c?.id === s.id ? null : s);
|
|
65
64
|
}, Q = () => {
|
|
66
|
-
|
|
65
|
+
c && (i(p, JSON.stringify(c), {
|
|
67
66
|
path: "/",
|
|
68
|
-
maxAge:
|
|
67
|
+
maxAge: 3600 * 24 * 30,
|
|
69
68
|
// 30 days
|
|
70
69
|
domain: window.location.hostname
|
|
71
70
|
}), window.location.reload());
|
|
72
71
|
};
|
|
73
|
-
return console.log("Avatar",
|
|
72
|
+
return console.log("Avatar", k), /* @__PURE__ */ o(h.Root, { defaultOpen: !0, onOpenChange: e, children: /* @__PURE__ */ m(h.Content, { children: [
|
|
74
73
|
/* @__PURE__ */ o(h.Header, { children: /* @__PURE__ */ o(h.Title, { children: "Select Domain" }) }),
|
|
75
74
|
/* @__PURE__ */ m(h.Body, { children: [
|
|
76
|
-
/* @__PURE__ */ o(
|
|
77
|
-
/* @__PURE__ */ o(
|
|
75
|
+
/* @__PURE__ */ o(L, { paddingBottom: 4, children: /* @__PURE__ */ m(P.Root, { name: "tenant-search", children: [
|
|
76
|
+
/* @__PURE__ */ o(P.Label, { children: "Search domains" }),
|
|
78
77
|
/* @__PURE__ */ o(
|
|
79
78
|
ee,
|
|
80
79
|
{
|
|
81
80
|
name: "tenant-search",
|
|
82
81
|
onClear: () => d(""),
|
|
83
82
|
value: r,
|
|
84
|
-
onChange: (
|
|
83
|
+
onChange: (s) => d(s.target.value),
|
|
85
84
|
placeholder: "Search domains...",
|
|
86
|
-
size: "S"
|
|
85
|
+
size: "S",
|
|
86
|
+
clearLabel: "Clear search",
|
|
87
|
+
children: "Search domains"
|
|
87
88
|
}
|
|
88
89
|
)
|
|
89
90
|
] }) }),
|
|
@@ -93,29 +94,29 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
93
94
|
icon: /* @__PURE__ */ o(de, {}),
|
|
94
95
|
content: "No domains found matching your search criteria"
|
|
95
96
|
}
|
|
96
|
-
) : /* @__PURE__ */ o(
|
|
97
|
-
/* @__PURE__ */ o(oe, { children: /* @__PURE__ */ m(
|
|
97
|
+
) : /* @__PURE__ */ o(L, { maxHeight: "400px", overflow: "auto", children: /* @__PURE__ */ m(ne, { colCount: 2, rowCount: l.length + 1, children: [
|
|
98
|
+
/* @__PURE__ */ o(oe, { children: /* @__PURE__ */ m(M, { children: [
|
|
98
99
|
/* @__PURE__ */ o(C, { width: "60px", children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Select" }) }),
|
|
99
|
-
/* @__PURE__ */ o(C, { width: "40px" }),
|
|
100
|
+
/* @__PURE__ */ o(C, { width: "40px", children: null }),
|
|
100
101
|
/* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Domain name" }) })
|
|
101
102
|
] }) }),
|
|
102
|
-
/* @__PURE__ */ o(ie, { children: l.map((
|
|
103
|
+
/* @__PURE__ */ o(ie, { children: l.map((s) => /* @__PURE__ */ m(M, { children: [
|
|
103
104
|
/* @__PURE__ */ o(T, { width: "60px", children: /* @__PURE__ */ o(
|
|
104
105
|
ae,
|
|
105
106
|
{
|
|
106
|
-
checked:
|
|
107
|
-
onCheckedChange: () => y(
|
|
108
|
-
name: `tenant-${
|
|
107
|
+
checked: c?.id === s.id,
|
|
108
|
+
onCheckedChange: () => y(s),
|
|
109
|
+
name: `tenant-${s.id}`
|
|
109
110
|
}
|
|
110
111
|
) }),
|
|
111
|
-
/* @__PURE__ */ o(T, { width: "40px", children:
|
|
112
|
-
/* @__PURE__ */ o(T, { children: /* @__PURE__ */ o(S, { fontWeight: "semiBold", textColor: "neutral800", children:
|
|
113
|
-
] },
|
|
112
|
+
/* @__PURE__ */ o(T, { width: "40px", children: s.logo?.url && /* @__PURE__ */ o(k.Item, { src: s.logo.url, alt: s.name, preview: !1, fallback: s.name[0] }) }),
|
|
113
|
+
/* @__PURE__ */ o(T, { children: /* @__PURE__ */ o(S, { fontWeight: "semiBold", textColor: "neutral800", children: s.name }) })
|
|
114
|
+
] }, s.id)) })
|
|
114
115
|
] }) })
|
|
115
116
|
] }),
|
|
116
117
|
/* @__PURE__ */ m(h.Footer, { children: [
|
|
117
118
|
/* @__PURE__ */ o(h.Close, { children: /* @__PURE__ */ o(I, { onClick: e, variant: "tertiary", children: "Cancel" }) }),
|
|
118
|
-
/* @__PURE__ */ o(I, { onClick: Q, disabled: !
|
|
119
|
+
/* @__PURE__ */ o(I, { onClick: Q, disabled: !c, children: "Select domain" })
|
|
119
120
|
] })
|
|
120
121
|
] }) });
|
|
121
122
|
}, Ae = new ue({
|
|
@@ -135,7 +136,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
135
136
|
/* @__PURE__ */ o(re, { theme: i === "light" ? se : ce, children: /* @__PURE__ */ o(me, { client: Ae, children: /* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(Ee, { onClose: d, userData: n }) }) }) })
|
|
136
137
|
);
|
|
137
138
|
}, w = (e, t) => new Promise((n, i) => {
|
|
138
|
-
const
|
|
139
|
+
const c = (u = 0) => {
|
|
139
140
|
if (u > 50) {
|
|
140
141
|
i(new Error("Button not found after 50 attempts"));
|
|
141
142
|
return;
|
|
@@ -145,9 +146,9 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
145
146
|
n(l);
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
|
-
setTimeout(() =>
|
|
149
|
+
setTimeout(() => c(u + 1), 250);
|
|
149
150
|
};
|
|
150
|
-
|
|
151
|
+
c();
|
|
151
152
|
}), j = () => {
|
|
152
153
|
try {
|
|
153
154
|
const t = document.cookie.split(";").find((n) => n.trim().startsWith(`${p}=`));
|
|
@@ -176,7 +177,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
176
177
|
}
|
|
177
178
|
}, $ = async () => {
|
|
178
179
|
try {
|
|
179
|
-
const e =
|
|
180
|
+
const e = Z(), {
|
|
180
181
|
data: { data: t }
|
|
181
182
|
} = await e.get("/admin/users/me");
|
|
182
183
|
return t;
|
|
@@ -188,12 +189,12 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
188
189
|
document.body.appendChild(t);
|
|
189
190
|
const n = await w('nav button[aria-haspopup="menu"]'), i = "aria-expanded";
|
|
190
191
|
new MutationObserver(async (d) => {
|
|
191
|
-
if (d.some((
|
|
192
|
-
const
|
|
193
|
-
if (!(
|
|
192
|
+
if (d.some((c) => c.attributeName === i) && n.getAttribute(i) === "true") {
|
|
193
|
+
const c = await w("[data-radix-menu-content]");
|
|
194
|
+
if (!(c instanceof HTMLElement))
|
|
194
195
|
return;
|
|
195
|
-
xe(
|
|
196
|
-
const u = await w('[role="menuitem"]',
|
|
196
|
+
xe(c);
|
|
197
|
+
const u = await w('[role="menuitem"]', c), l = u.cloneNode(!0);
|
|
197
198
|
if (e?.[E] && e?.[E].length > 1) {
|
|
198
199
|
if (!(l instanceof HTMLElement))
|
|
199
200
|
return;
|
|
@@ -204,7 +205,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
204
205
|
}), l.addEventListener("click", (y) => {
|
|
205
206
|
y.preventDefault(), y.stopPropagation(), $e(
|
|
206
207
|
t,
|
|
207
|
-
|
|
208
|
+
c,
|
|
208
209
|
e,
|
|
209
210
|
localStorage.getItem("STRAPI_THEME") || "dark"
|
|
210
211
|
);
|
|
@@ -214,7 +215,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
214
215
|
}).observe(n, {
|
|
215
216
|
attributes: !0
|
|
216
217
|
});
|
|
217
|
-
}, _ = () => window.location.pathname === "/admin/auth/login",
|
|
218
|
+
}, _ = () => window.location.pathname === "/admin/auth/login", ke = () => window.location.pathname.startsWith("/admin/plugins/upload"), Le = () => {
|
|
218
219
|
const e = j(), t = document.querySelector('[data-strapi-header="true"]');
|
|
219
220
|
if (!e || U(e)) {
|
|
220
221
|
const n = t?.querySelectorAll("button");
|
|
@@ -222,13 +223,13 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
222
223
|
i.style.display = "none";
|
|
223
224
|
});
|
|
224
225
|
}
|
|
225
|
-
}, O = V(
|
|
226
|
+
}, O = V(Le, {
|
|
226
227
|
minQuietPeriodMs: 250
|
|
227
228
|
}), z = async () => {
|
|
228
229
|
const e = await w('nav ul > li a[href="/admin/plugins/upload"]');
|
|
229
230
|
e && e.addEventListener("click", () => {
|
|
230
231
|
O.call();
|
|
231
|
-
}),
|
|
232
|
+
}), ke() && O.call();
|
|
232
233
|
}, v = async () => {
|
|
233
234
|
if (_()) {
|
|
234
235
|
document.body.removeAttribute(f);
|
|
@@ -239,9 +240,9 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
242
|
document.body.removeAttribute(f);
|
|
242
|
-
},
|
|
243
|
+
}, Pe = async () => {
|
|
243
244
|
_() || !await $() || (document.body.setAttribute(f, "true"), await Promise.all([F(), z()]));
|
|
244
|
-
},
|
|
245
|
+
}, _e = {
|
|
245
246
|
register(e) {
|
|
246
247
|
e.registerPlugin({
|
|
247
248
|
id: a,
|
|
@@ -261,7 +262,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
261
262
|
defaultMessage: "Ensures the value is unique within the domain."
|
|
262
263
|
},
|
|
263
264
|
components: {
|
|
264
|
-
Input: () => import("./TenantCustomField-
|
|
265
|
+
Input: () => import("./TenantCustomField-CS8x0CkO.mjs")
|
|
265
266
|
}
|
|
266
267
|
}), e.router.addSettingsLink({
|
|
267
268
|
id: `${a}.settings`,
|
|
@@ -277,7 +278,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
277
278
|
defaultMessage: "About"
|
|
278
279
|
},
|
|
279
280
|
to: `/settings/${a}/about`,
|
|
280
|
-
Component: () => import("./About-
|
|
281
|
+
Component: () => import("./About-DfCon-RP.mjs"),
|
|
281
282
|
permissions: N.admin.access
|
|
282
283
|
},
|
|
283
284
|
{
|
|
@@ -287,7 +288,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
287
288
|
defaultMessage: "General Settings"
|
|
288
289
|
},
|
|
289
290
|
to: `/settings/${a}/${be}`,
|
|
290
|
-
Component: () => import("./Settings-
|
|
291
|
+
Component: () => import("./Settings-Dj3h2ayB.mjs"),
|
|
291
292
|
permissions: N.admin.access
|
|
292
293
|
}
|
|
293
294
|
]
|
|
@@ -318,14 +319,14 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
318
319
|
n.apply(history, r), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
319
320
|
}, history.replaceState = function(...r) {
|
|
320
321
|
i.apply(history, r), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
321
|
-
}, await
|
|
322
|
+
}, await Pe();
|
|
322
323
|
}
|
|
323
324
|
};
|
|
324
325
|
export {
|
|
325
|
-
|
|
326
|
+
Fe as a,
|
|
326
327
|
N as b,
|
|
327
328
|
g as c,
|
|
328
|
-
|
|
329
|
+
_e as d,
|
|
329
330
|
be as m,
|
|
330
331
|
a as p
|
|
331
332
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var f=(o,t,n)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var m=(o,t,n)=>f(o,typeof t!="symbol"?t+"":t,n);const z=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-oNXgzV7S.js"),b=o=>o&&o.__esModule?o:{default:o},a=b(e);e.z.object({name:e.z.string().min(1,"Name is required").max(255,"Name must be less than 255 characters"),code:e.z.string().min(1,"Code is required").max(100,"Code must be less than 100 characters").regex(/^[a-z0-9-]+$/,"Code must contain only lowercase letters, numbers, and hyphens")});e.z.object({isValid:e.z.boolean(),message:e.z.string().optional(),field:e.z.enum(["name","code"]).optional()});const s=a.default.union([a.default.string(),a.default.number()]).transform(o=>{const t=parseInt(o.toString(),10);if(isNaN(t)||t<=0)throw new a.default.ZodError([{message:"ID must be a positive integer",code:"custom",path:["id"]}]);return t}),y=e.z.object({id:s,documentId:e.z.string().min(1,"Document ID is required"),action:e.z.string().min(1,"Action is required"),actionParameters:e.z.record(e.z.any()).optional(),subject:e.z.string().min(1,"Subject is required").nullable().optional(),properties:e.z.record(e.z.any()).optional(),conditions:e.z.array(e.z.record(e.z.any())).optional()});e.z.object({sort:e.z.string().optional(),search:e.z.string().optional(),page:e.z.coerce.number().int().positive().optional(),pageSize:e.z.coerce.number().int().positive().optional()});const w=e.z.object({name:e.z.string().min(1,"Name is required"),code:e.z.string().min(1,"Code is required"),description:e.z.string().optional()}),c=w.merge(e.z.object({id:s,documentId:e.z.string().min(1,"Document ID is required")}));c.merge(e.z.object({permissions:y.array()}));const p=e.z.object({id:s,name:e.z.string().min(1,"Name is required")}),$=a.default.object({id:a.default.number(),name:a.default.string(),url:a.default.string(),width:a.default.number(),height:a.default.number(),ext:a.default.string(),size:a.default.number()}).passthrough(),h=a.default.object({name:a.default.string().min(1,"Name is required"),code:a.default.string().min(1,"Code is required"),customFields:a.default.record(a.default.any()).optional().nullable(),damRootDirectory:a.default.string().optional().nullable(),logo:$.optional().nullable()}),d=h.extend({id:s,documentId:a.default.string()});d.extend({role:c.optional().nullable()});const I=h.extend({role:s.optional().nullable(),tokens:a.default.array(s).optional().nullable()}),C=d.omit({id:!0,documentId:!0}).extend({role:s.optional().nullable(),tokens:a.default.array(s).optional().nullable()}),S=a.default.object({page:a.default.number(),pageCount:a.default.number(),pageSize:a.default.number(),total:a.default.number()}),j=e.z.object({results:e.z.array(d),pagination:S}),u=d.extend({role:c.optional().nullable(),tokens:e.z.array(p).optional().nullable()});class q{constructor(){m(this,"fetchClient",z.getFetchClient())}async validateTenant(t){try{const n=await this.fetchClient.post(`/${r.pluginId}/validate`,t);return console.log("response.data",n.data),n.data}catch(n){throw n instanceof e.z.ZodError?new Error(`Validation error: ${n.errors.map(i=>i.message).join(", ")}`):n}}async getTenants(t){try{const n=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}`,{params:t});return j.parse(n.data)}catch{throw new Error("Failed to fetch tenants")}}async getTenant(t){try{const n=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}/${t}`);return u.parseAsync(n.data)}catch{throw new Error("Failed to fetch tenant")}}async createTenant(t){try{const n=I.parse(t),i=await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}`,n);return u.parseAsync(i.data)}catch(n){throw console.log("error",n),n instanceof e.z.ZodError?new Error(`Validation error: ${n.errors.map(i=>i.message).join(", ")}`):n}}async updateTenant(t,n){try{const i=C.parse(n),l=await this.fetchClient.put(`/${r.pluginId}/${r.modelRoute}/${t}`,i);return u.parseAsync(l.data)}catch(i){throw i instanceof e.z.ZodError?new Error(`Validation error: ${i.errors.map(l=>l.message).join(", ")}`):new Error("Failed to update domain")}}async deleteTenant(t){try{await this.fetchClient.del(`/${r.pluginId}/${r.modelRoute}/${t}`)}catch{throw new Error("Failed to delete tenant")}}async getRoles(){try{const t=await this.fetchClient.get("/admin/roles");return e.z.array(c).parse(t.data.data)}catch{throw new Error("Failed to fetch roles")}}async getTokens(){try{const t=await this.fetchClient.get("/admin/api-tokens");return e.z.array(p).parse(t.data.data)}catch{throw new Error("Failed to fetch roles")}}async validateCustomField({model:t,documentId:n,field:i,value:l}){return(await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}/${t}/validate`,{documentId:n,field:i,value:l})).data}async getSettings(){return(await this.fetchClient.get(`/${r.pluginId}/license`)).data}}const E=new q;exports.api=E;
|