@oktis-works/admin 0.4.13 → 0.4.15

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 (127) hide show
  1. package/dist/client/_astro/{ActivityWidget.DeayROhc.js → ActivityWidget.B83CLwGG.js} +2 -2
  2. package/dist/client/_astro/AdminBar.BNESswxs.js +253 -0
  3. package/dist/client/_astro/{AtGlanceWidget.CDFVi_eX.js → AtGlanceWidget.Cqbb9anJ.js} +3 -3
  4. package/dist/client/_astro/BaseLayout.B3A9-IS6.css +1 -0
  5. package/dist/client/_astro/ContentEditor.CBH227Ni.js +1 -0
  6. package/dist/client/_astro/ContentList.hmLCz5_S.js +1 -0
  7. package/dist/client/_astro/CustomFieldsManager.Dzhp_sZl.js +3 -0
  8. package/dist/client/_astro/DashboardHome.DawF-CZ9.js +1 -0
  9. package/dist/client/_astro/DashboardLayout.CEvRGr78.css +1 -0
  10. package/dist/client/_astro/DashboardLayout.astro_astro_type_script_index_0_lang.Ckp0okyg.js +1 -0
  11. package/dist/client/_astro/FieldTypePicker.BEuYPzV8.js +1 -0
  12. package/dist/client/_astro/{Footer.KkyZkNxH.js → Footer.dcA-nmBA.js} +10 -12
  13. package/dist/client/_astro/GeneralSettings.DdAwp-oL.js +1 -0
  14. package/dist/client/_astro/MediaLibrary.B9SPVPYH.js +1 -0
  15. package/dist/client/_astro/PluginManager.DN5xhAsV.js +93 -0
  16. package/dist/client/_astro/PostTypesManager.BZH1eM3c.js +1 -0
  17. package/dist/client/_astro/{QuickDraftWidget.Drp_cL_D.js → QuickDraftWidget.DBvLubay.js} +2 -2
  18. package/dist/client/_astro/ResourceHubs.BvrE39A0.js +1 -0
  19. package/dist/client/_astro/TaxonomiesManager.BrjG05jb.js +1 -0
  20. package/dist/client/_astro/ThemeManager.CsrK3HXj.js +129 -0
  21. package/dist/client/_astro/UserCreateForm.Dxq80Bqx.js +1 -0
  22. package/dist/client/_astro/UsersManager.DmBadxWw.js +1 -0
  23. package/dist/client/_astro/api.BfxYC8bU.js +1 -0
  24. package/dist/client/_astro/ar.DsV0P0EN.js +1 -0
  25. package/dist/client/_astro/{client.C7p516_9.js → client.BY0Z100j.js} +1 -1
  26. package/dist/client/_astro/custom-fields.IjuRIdAC.css +1 -0
  27. package/dist/client/_astro/es-ES.etPSaiLd.js +1 -0
  28. package/dist/client/_astro/extensions.C6GOqTCd.js +1 -0
  29. package/dist/client/_astro/he.U1Vtp3zT.js +1 -0
  30. package/dist/client/_astro/i18n.B4BuieMb.js +1 -0
  31. package/dist/client/_astro/it.DJuI8oO_.js +1 -0
  32. package/dist/client/_astro/ja.Cw8I_NUV.js +1 -0
  33. package/dist/client/_astro/{login.astro_astro_type_script_index_0_lang.D6nHqYm6.js → login.astro_astro_type_script_index_0_lang.yH8kNMtD.js} +1 -1
  34. package/dist/client/_astro/pl.Dsz-4G_z.js +1 -0
  35. package/dist/client/_astro/pt-BR.CyQAHnXs.js +1 -0
  36. package/dist/client/_astro/ru.CwIIcTdy.js +1 -0
  37. package/dist/client/_astro/src.HVGUo-fm.js +1 -0
  38. package/dist/client/_astro/sw.DwpL3sb6.js +1 -0
  39. package/dist/client/_astro/tr.CY2JWJ7Y.js +1 -0
  40. package/dist/client/_astro/uk.BudEWIU8.js +1 -0
  41. package/dist/client/_astro/{version.C0f0jrCn.js → version.CilNJ_fk.js} +1 -1
  42. package/dist/client/_astro/{web.D1H9RxZL.js → web.D_vCtCLj.js} +1 -1
  43. package/dist/client/_astro/yo.BmoZs0fO.js +1 -0
  44. package/dist/client/_astro/zh-CN.khaXV6fv.js +1 -0
  45. package/dist/server/chunks/{BaseLayout_BsR68tOH.mjs → BaseLayout_BmkfK9tu.mjs} +19 -2
  46. package/dist/server/chunks/{ContentEditor_BtclxOqH.mjs → ContentEditor_C-kz5cS4.mjs} +31 -101
  47. package/dist/server/chunks/{DashboardLayout_B9pE8ZBQ.mjs → DashboardLayout_KIUq60Dv.mjs} +52 -566
  48. package/dist/server/chunks/FieldTypePicker_CXwpmcQ3.mjs +79 -0
  49. package/dist/server/chunks/{MediaLibrary_DLO2K_4d.mjs → MediaLibrary_C-lJBpPG.mjs} +2 -2
  50. package/dist/server/chunks/ResourceHubs_T-WuZoVF.mjs +453 -0
  51. package/dist/server/chunks/{_slug__yqDK_Ow8.mjs → _slug__DjcyD19w.mjs} +1 -1
  52. package/dist/server/chunks/access_Bjuw_Gvp.mjs +34 -0
  53. package/dist/server/chunks/{ar_DBjdWIJ0.mjs → ar_DMC8HaoP.mjs} +3 -1
  54. package/dist/server/chunks/custom-fields_CxntKU56.mjs +488 -0
  55. package/dist/server/chunks/{edit_0bCUPzfW.mjs → edit_CFKKfQux.mjs} +2 -2
  56. package/dist/server/chunks/{es-ES_TJ4oK1yi.mjs → es-ES_DZvHskAD.mjs} +3 -1
  57. package/dist/server/chunks/{general_D-MMl9p8.mjs → general_CVsJAP2e.mjs} +6 -6
  58. package/dist/server/chunks/{he_TWsuTphz.mjs → he_zy3stNhR.mjs} +3 -1
  59. package/dist/server/chunks/i18n_CH59YTvE.mjs +1406 -0
  60. package/dist/server/chunks/{index_Z7GukanS.mjs → index_2Y9ZC7Gs.mjs} +8 -6
  61. package/dist/server/chunks/{index_CTpEX5iK.mjs → index_Bb3w_UqS.mjs} +2 -2
  62. package/dist/server/chunks/{index_DB6MLU0v.mjs → index_BqyoH4bc.mjs} +3 -3
  63. package/dist/server/chunks/{index_CALAZTDB.mjs → index_G7lx2uke.mjs} +2 -2
  64. package/dist/server/chunks/{index_Bq7o-ZHF.mjs → index_TyNyWm6y.mjs} +1 -1
  65. package/dist/server/chunks/{it_CEVFVWh1.mjs → it_BiUDLszZ.mjs} +3 -1
  66. package/dist/server/chunks/{ja_CqDirMqf.mjs → ja_DjFAG7hL.mjs} +3 -1
  67. package/dist/server/chunks/{login_BcWk_36h.mjs → login_BCjtaOE9.mjs} +1 -2
  68. package/dist/server/chunks/{new_DlqbYYA1.mjs → new_BZOJIQfZ.mjs} +2 -2
  69. package/dist/server/chunks/{new_BbKoexYG.mjs → new_DkHY3O0r.mjs} +2 -2
  70. package/dist/server/chunks/operations_DYc6rwSI.mjs +34 -0
  71. package/dist/server/chunks/{pl_ChIKxfZG.mjs → pl_0Xe9Qom2.mjs} +3 -1
  72. package/dist/server/chunks/{plugins_BLJAzLX4.mjs → plugins_p805vlEb.mjs} +55 -22
  73. package/dist/server/chunks/{post-types_BvVl0hZs.mjs → post-types_C7YAi_V0.mjs} +6 -6
  74. package/dist/server/chunks/{pt-BR_4d4jZWL0.mjs → pt-BR_DIZpU2Mk.mjs} +206 -2
  75. package/dist/server/chunks/resources_BVP5krU_.mjs +34 -0
  76. package/dist/server/chunks/{ru_CIc6O5Q7.mjs → ru_DFvIxd0Y.mjs} +3 -1
  77. package/dist/server/chunks/{sw_Bs3iYVDM.mjs → sw_CmaPgGYa.mjs} +3 -1
  78. package/dist/server/chunks/{taxonomies_Dkx7d-vc.mjs → taxonomies_CWhPYZDq.mjs} +2 -2
  79. package/dist/server/chunks/themes_iwb1637h.mjs +155 -0
  80. package/dist/server/chunks/{tr_C7JbXuoQ.mjs → tr_B_acwl2e.mjs} +3 -1
  81. package/dist/server/chunks/{uk_Dibs8Wkc.mjs → uk_DXnk4imL.mjs} +3 -1
  82. package/dist/server/chunks/{upload_CpGGKDEH.mjs → upload_BE7qzxe7.mjs} +2 -2
  83. package/dist/server/chunks/{yo_B6MPvz_U.mjs → yo_DDQ8a-0v.mjs} +3 -1
  84. package/dist/server/chunks/{zh-CN_G1Dc2b28.mjs → zh-CN_763uzTMQ.mjs} +3 -1
  85. package/dist/server/entry.mjs +149 -25
  86. package/dist/server/virtual_astro_middleware.mjs +6 -3
  87. package/package.json +1 -1
  88. package/dist/client/_astro/AdminBar.DQilvzQe.js +0 -234
  89. package/dist/client/_astro/BaseLayout.B2MfKf6B.css +0 -1
  90. package/dist/client/_astro/ContentEditor.WyLHMY9o.js +0 -1
  91. package/dist/client/_astro/ContentList.BWtiYbDy.js +0 -1
  92. package/dist/client/_astro/DashboardHome.-0s3t1kG.js +0 -1
  93. package/dist/client/_astro/DashboardLayout.DWuCsemN.css +0 -1
  94. package/dist/client/_astro/DashboardLayout.astro_astro_type_script_index_0_lang.Bm7kqhGo.js +0 -1
  95. package/dist/client/_astro/GeneralSettings.CaEyAV2f.js +0 -1
  96. package/dist/client/_astro/HelpTabs.99giF0f1.js +0 -103
  97. package/dist/client/_astro/LanguageSelector.DPBYaSN4.js +0 -14
  98. package/dist/client/_astro/MediaLibrary.DBfw3BM0.js +0 -1
  99. package/dist/client/_astro/PluginManager.BFoAz05U.js +0 -93
  100. package/dist/client/_astro/PostTypesManager.y9aB2d3_.js +0 -1
  101. package/dist/client/_astro/ScreenOptions.C8K8Bufc.js +0 -70
  102. package/dist/client/_astro/TaxonomiesManager.Cj54HB7P.js +0 -1
  103. package/dist/client/_astro/ThemeManager.BuULAG8h.js +0 -124
  104. package/dist/client/_astro/UserCreateForm.BMWIRfb2.js +0 -1
  105. package/dist/client/_astro/UsersManager.BogkOfCQ.js +0 -1
  106. package/dist/client/_astro/api.PfLklAa1.js +0 -1
  107. package/dist/client/_astro/ar.CzsjUutD.js +0 -1
  108. package/dist/client/_astro/en.DmN7xy_a.js +0 -1
  109. package/dist/client/_astro/es-ES.p2TLEMlZ.js +0 -1
  110. package/dist/client/_astro/extensions.DfxrGzbo.js +0 -1
  111. package/dist/client/_astro/he.BnYHiYpn.js +0 -1
  112. package/dist/client/_astro/i18n.BMDVwjZM.js +0 -1
  113. package/dist/client/_astro/it.WrWKBEAD.js +0 -1
  114. package/dist/client/_astro/ja.DxnfhIdt.js +0 -1
  115. package/dist/client/_astro/pl.jUj-RfZS.js +0 -1
  116. package/dist/client/_astro/pt-BR.DtNwEO0i.js +0 -1
  117. package/dist/client/_astro/ru.KFSfdjWn.js +0 -1
  118. package/dist/client/_astro/src.Cgonpfb5.js +0 -1
  119. package/dist/client/_astro/sw.3jlAOLOv.js +0 -1
  120. package/dist/client/_astro/tr.tnLMnGPg.js +0 -1
  121. package/dist/client/_astro/uk.VquHY_xc.js +0 -1
  122. package/dist/client/_astro/yo.Cr8hCb5u.js +0 -1
  123. package/dist/client/_astro/zh-CN.E32QqP4v.js +0 -1
  124. package/dist/server/chunks/en_C750mYKk.mjs +0 -408
  125. package/dist/server/chunks/i18n_Dj2ieo-N.mjs +0 -548
  126. package/dist/server/chunks/script_CPGt5jAh.mjs +0 -19
  127. package/dist/server/chunks/themes_CCDPOhVZ.mjs +0 -127
@@ -1,548 +0,0 @@
1
- import { createSignal, onMount } from "solid-js";
2
- //#region src/i18n/config.ts
3
- var SUPPORTED_LOCALES = [
4
- "pt-BR",
5
- "en",
6
- "es-ES",
7
- "ru",
8
- "uk",
9
- "tr",
10
- "he",
11
- "it",
12
- "pl",
13
- "zh-CN",
14
- "ja",
15
- "ar",
16
- "sw",
17
- "yo",
18
- "zu",
19
- "am",
20
- "ha",
21
- "ig"
22
- ];
23
- var RTL_LOCALES = ["he", "ar"];
24
- var LOCALE_LABELS = {
25
- "pt-BR": "Português (Brasil)",
26
- "en": "English",
27
- "es-ES": "Español",
28
- "ru": "Русский",
29
- "uk": "Українська",
30
- "tr": "Türkçe",
31
- "he": "עברית",
32
- "it": "Italiano",
33
- "pl": "Polski",
34
- "zh-CN": "中文 (简体)",
35
- "ja": "日本語",
36
- "ar": "العربية",
37
- "sw": "Kiswahili",
38
- "yo": "Yorùbá",
39
- "zu": "isiZulu",
40
- "am": "አማርኛ",
41
- "ha": "Hausa",
42
- "ig": "Igbo"
43
- };
44
- var LOCALE_FLAGS = {
45
- "pt-BR": "🇧🇷",
46
- "en": "🇺🇸",
47
- "es-ES": "🇪🇸",
48
- "ru": "🇷🇺",
49
- "uk": "🇺🇦",
50
- "tr": "🇹🇷",
51
- "he": "🇮🇱",
52
- "it": "🇮🇹",
53
- "pl": "🇵🇱",
54
- "zh-CN": "🇨🇳",
55
- "ja": "🇯🇵",
56
- "ar": "🇸🇦",
57
- "sw": "🇹🇿",
58
- "yo": "🇳🇬",
59
- "zu": "🇿🇦",
60
- "am": "🇪🇹",
61
- "ha": "🇳🇬",
62
- "ig": "🇳🇬"
63
- };
64
- function isRTLLocale(locale) {
65
- return RTL_LOCALES.includes(locale);
66
- }
67
- //#endregion
68
- //#region \0rolldown_dynamic_import_helper.js
69
- var _rolldown_dynamic_import_helper_default = (glob, path, segments) => {
70
- const query = path.lastIndexOf("?");
71
- const v = glob[query === -1 || query < path.lastIndexOf("/") ? path : path.slice(0, query)];
72
- if (v) return typeof v === "function" ? v() : Promise.resolve(v);
73
- return new Promise((_, reject) => {
74
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + path + (path.split("/").length !== segments ? ". Note that variables only represent file names one level deep." : ""))));
75
- });
76
- };
77
- //#endregion
78
- //#region src/i18n/loaders.ts
79
- var localeCache = /* @__PURE__ */ new Map();
80
- /** Carrega arquivo JSON de locale */
81
- async function loadLocale(locale) {
82
- if (localeCache.has(locale)) return localeCache.get(locale);
83
- try {
84
- const module = await _rolldown_dynamic_import_helper_default(/* #__PURE__ */ Object.assign({
85
- "./locales/ar.json": () => import("./ar_DBjdWIJ0.mjs"),
86
- "./locales/en.json": () => import("./en_C750mYKk.mjs"),
87
- "./locales/es-ES.json": () => import("./es-ES_TJ4oK1yi.mjs"),
88
- "./locales/he.json": () => import("./he_TWsuTphz.mjs"),
89
- "./locales/it.json": () => import("./it_CEVFVWh1.mjs"),
90
- "./locales/ja.json": () => import("./ja_CqDirMqf.mjs"),
91
- "./locales/pl.json": () => import("./pl_ChIKxfZG.mjs"),
92
- "./locales/pt-BR.json": () => import("./pt-BR_4d4jZWL0.mjs"),
93
- "./locales/ru.json": () => import("./ru_CIc6O5Q7.mjs"),
94
- "./locales/sw.json": () => import("./sw_Bs3iYVDM.mjs"),
95
- "./locales/tr.json": () => import("./tr_C7JbXuoQ.mjs"),
96
- "./locales/uk.json": () => import("./uk_Dibs8Wkc.mjs"),
97
- "./locales/yo.json": () => import("./yo_B6MPvz_U.mjs"),
98
- "./locales/zh-CN.json": () => import("./zh-CN_G1Dc2b28.mjs")
99
- }), `./locales/${locale}.json`, 3);
100
- const translations = module.default ?? module;
101
- localeCache.set(locale, translations);
102
- return translations;
103
- } catch {
104
- if (locale !== "en") return loadLocale("en");
105
- return {};
106
- }
107
- }
108
- //#endregion
109
- //#region src/lib/api.ts
110
- var API_BASE = "http://localhost:3000";
111
- var ApiClient = class {
112
- baseUrl;
113
- csrfToken = null;
114
- isRefreshing = false;
115
- constructor(baseUrl = API_BASE) {
116
- this.baseUrl = baseUrl;
117
- }
118
- /** Inicializa lendo CSRF do cookie (chamado no boot da app) */
119
- async init() {
120
- try {
121
- await fetch(`${this.baseUrl}/api/v1/auth/me`, { credentials: "include" });
122
- } catch {}
123
- }
124
- /** Sessão válida — verifica via /me (usa cookies HttpOnly automaticamente) */
125
- async isLoggedIn() {
126
- try {
127
- return (await fetch(`${this.baseUrl}/api/v1/auth/me`, { credentials: "include" })).ok;
128
- } catch {
129
- return false;
130
- }
131
- }
132
- /** Obtém tenantId do backend via /me */
133
- async getTenantId() {
134
- try {
135
- const res = await fetch(`${this.baseUrl}/api/v1/auth/me`, { credentials: "include" });
136
- if (!res.ok) return null;
137
- return (await res.json()).tenantId ?? null;
138
- } catch {
139
- return null;
140
- }
141
- }
142
- /** Obtém locale do usuário logado via /me/locale */
143
- async getUserLocale() {
144
- try {
145
- const res = await fetch(`${this.baseUrl}/api/v1/users/me/locale`, { credentials: "include" });
146
- if (!res.ok) return "pt-BR";
147
- return (await res.json()).locale ?? "pt-BR";
148
- } catch {
149
- return "pt-BR";
150
- }
151
- }
152
- /** Salva locale do usuário via /me/locale */
153
- async setUserLocale(locale) {
154
- await this.request("PUT", "/api/v1/users/me/locale", { locale });
155
- }
156
- /** Sessão atual (/auth/me) — usuário + tenant + papéis (alimenta o admin bar) */
157
- async getMe() {
158
- return this.request("GET", "/api/v1/auth/me");
159
- }
160
- /** Auditoria recente — notificações reais do sino no admin bar */
161
- async getAuditLogs(limit = 8) {
162
- return this.request("GET", `/api/v1/audit-logs?limit=${limit}`);
163
- }
164
- /** Login — o backend seta cookies HttpOnly e CSRF; retorna user + tenantId */
165
- async login(input) {
166
- return await this.request("POST", "/api/v1/auth/login", input);
167
- }
168
- /** Logout — limpa cookies no backend */
169
- async logout() {
170
- await this.request("POST", "/api/v1/auth/logout", {});
171
- this.csrfToken = null;
172
- }
173
- /** Refresh de access token via cookie refresh_token */
174
- async refreshTokens() {
175
- if (this.isRefreshing) return;
176
- this.isRefreshing = true;
177
- try {
178
- await this.request("POST", "/api/v1/auth/refresh", {});
179
- } finally {
180
- this.isRefreshing = false;
181
- }
182
- }
183
- /** Requisição genérica com:
184
- * - credentials: 'include' (envia cookies HttpOnly)
185
- * - auto-refresh em 401
186
- * - CSRF header para mutações
187
- */
188
- async request(method, path, body, headers) {
189
- const url = `${this.baseUrl}${path}`;
190
- const requestHeaders = {
191
- "Content-Type": "application/json",
192
- ...headers
193
- };
194
- if (![
195
- "GET",
196
- "HEAD",
197
- "OPTIONS"
198
- ].includes(method.toUpperCase())) {
199
- const csrf = this.getCsrfToken();
200
- if (csrf) requestHeaders["x-csrf-token"] = csrf;
201
- }
202
- let response = await fetch(url, {
203
- method,
204
- headers: requestHeaders,
205
- credentials: "include",
206
- body: body ? JSON.stringify(body) : void 0
207
- });
208
- if (response.status === 401 && !path.includes("/auth/refresh") && !path.includes("/auth/logout")) {
209
- await this.refreshTokens();
210
- response = await fetch(url, {
211
- method,
212
- headers: requestHeaders,
213
- credentials: "include",
214
- body: body ? JSON.stringify(body) : void 0
215
- });
216
- }
217
- if (!response.ok) {
218
- const error = await response.json().catch(() => ({ error: "Request failed" }));
219
- throw new Error(error.error ?? `Request failed: ${response.status}`);
220
- }
221
- const setCookie = response.headers.get("set-cookie");
222
- if (setCookie) {
223
- const csrfMatch = setCookie.match(/csrf_token=([^;]+)/);
224
- if (csrfMatch?.[1]) this.csrfToken = csrfMatch[1];
225
- }
226
- return response.json();
227
- }
228
- /** Lê CSRF token do cookie (document.cookie) */
229
- getCsrfToken() {
230
- if (this.csrfToken) return this.csrfToken;
231
- if (typeof document !== "undefined") {
232
- const match = document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/);
233
- if (match?.[1]) return match[1];
234
- }
235
- return null;
236
- }
237
- async getContent(options) {
238
- const params = new URLSearchParams();
239
- if (options?.page) params.set("page", String(options.page));
240
- if (options?.limit) params.set("limit", String(options.limit));
241
- if (options?.type) params.set("type", options.type);
242
- if (options?.status) params.set("status", options.status);
243
- if (options?.search) params.set("search", options.search);
244
- return this.request("GET", `/api/v1/content?${params.toString()}`);
245
- }
246
- async getContentById(id) {
247
- return this.request("GET", `/api/v1/content/${id}`);
248
- }
249
- async createContent(data) {
250
- return this.request("POST", `/api/v1/content`, data);
251
- }
252
- async updateContent(id, data) {
253
- return this.request("PUT", `/api/v1/content/${id}`, data);
254
- }
255
- async deleteContent(id) {
256
- await this.request("DELETE", `/api/v1/content/${id}`);
257
- }
258
- /** A2: publica via rota real do publisher (eventBus + cache + revisions). */
259
- async publishContent(id) {
260
- return this.request("POST", `/api/v1/content/${id}/publish`);
261
- }
262
- /** A2: despublica via rota real do publisher. */
263
- async unpublishContent(id) {
264
- return this.request("POST", `/api/v1/content/${id}/unpublish`);
265
- }
266
- /** Atalho usado pela ContentList: publish/unpublish conforme status atual. */
267
- async publishToggle(id, isPublished) {
268
- return isPublished ? this.unpublishContent(id) : this.publishContent(id);
269
- }
270
- async getContentTypes() {
271
- return this.request("GET", "/api/v1/content-types");
272
- }
273
- async createContentType(data) {
274
- return this.request("POST", "/api/v1/content-types", data);
275
- }
276
- async updateContentType(slug, data) {
277
- return this.request("PUT", `/api/v1/content-types/${slug}`, data);
278
- }
279
- async deleteContentType(slug) {
280
- await this.request("DELETE", `/api/v1/content-types/${slug}`);
281
- }
282
- async getTaxonomies() {
283
- return this.request("GET", "/api/v1/taxonomies");
284
- }
285
- async createTaxonomy(data) {
286
- return this.request("POST", "/api/v1/taxonomies", data);
287
- }
288
- async attachTaxonomy(slug, contentType) {
289
- await this.request("POST", `/api/v1/taxonomies/${slug}/attach`, { contentType });
290
- }
291
- async detachTaxonomy(slug, contentType) {
292
- await this.request("POST", `/api/v1/taxonomies/${slug}/detach`, { contentType });
293
- }
294
- async deleteTaxonomy(slug) {
295
- await this.request("DELETE", `/api/v1/taxonomies/${slug}`);
296
- }
297
- async getFieldGroups(context) {
298
- if (context?.type) {
299
- const qs = new URLSearchParams({ type: context.type });
300
- for (const [key, value] of Object.entries(context)) if (key !== "type" && value) qs.set(key, value);
301
- return this.request("GET", `/api/v1/field-groups?${qs.toString()}`);
302
- }
303
- return this.request("GET", "/api/v1/field-groups");
304
- }
305
- async getFieldGroup(id) {
306
- return this.request("GET", `/api/v1/field-groups/${id}`);
307
- }
308
- async createFieldGroup(data) {
309
- return this.request("POST", "/api/v1/field-groups", data);
310
- }
311
- async getFieldTypes(category) {
312
- const query = category ? `?category=${encodeURIComponent(category)}` : "";
313
- return this.request("GET", `/api/v1/field-types${query}`);
314
- }
315
- async listMedia(options) {
316
- const params = new URLSearchParams();
317
- if (options?.page) params.set("page", String(options.page));
318
- if (options?.limit) params.set("limit", String(options.limit));
319
- if (options?.mimeType) params.set("mimeType", options.mimeType);
320
- if (options?.search) params.set("search", options.search);
321
- return this.request("GET", `/api/v1/media?${params.toString()}`);
322
- }
323
- async getMedia(id) {
324
- return this.request("GET", `/api/v1/media/${id}`);
325
- }
326
- /** Upload multipart — NÃO seta Content-Type (o fetch precisa do boundary). */
327
- async uploadMedia(file, options) {
328
- const formData = new FormData();
329
- formData.append("file", file);
330
- if (options?.alt) formData.append("alt", options.alt);
331
- if (options?.caption) formData.append("caption", options.caption);
332
- const url = `${this.baseUrl}/api/v1/media/upload`;
333
- const requestHeaders = {};
334
- const csrf = this.getCsrfToken();
335
- if (csrf) requestHeaders["x-csrf-token"] = csrf;
336
- const response = await fetch(url, {
337
- method: "POST",
338
- headers: requestHeaders,
339
- credentials: "include",
340
- body: formData
341
- });
342
- if (!response.ok) {
343
- const error = await response.json().catch(() => ({ error: `Upload failed: ${response.status}` }));
344
- throw new Error(error.error ?? `Upload failed: ${response.status}`);
345
- }
346
- return response.json();
347
- }
348
- async updateMedia(id, data) {
349
- return this.request("PUT", `/api/v1/media/${id}`, data);
350
- }
351
- async deleteMedia(id) {
352
- await this.request("DELETE", `/api/v1/media/${id}`);
353
- }
354
- async listUsers(options) {
355
- const params = new URLSearchParams();
356
- if (options?.page) params.set("page", String(options.page));
357
- if (options?.limit) params.set("limit", String(options.limit));
358
- if (options?.search) params.set("search", options.search);
359
- if (options?.status) params.set("status", options.status);
360
- return this.request("GET", `/api/v1/users?${params.toString()}`);
361
- }
362
- async getUser(id) {
363
- return this.request("GET", `/api/v1/users/${id}`);
364
- }
365
- async createUser(data) {
366
- return this.request("POST", "/api/v1/users", data);
367
- }
368
- async updateUser(id, data) {
369
- return this.request("PUT", `/api/v1/users/${id}`, data);
370
- }
371
- async deleteUser(id) {
372
- await this.request("DELETE", `/api/v1/users/${id}`);
373
- }
374
- async setUserPassword(id, password) {
375
- await this.request("PUT", `/api/v1/users/${id}/password`, { password });
376
- }
377
- async assignRole(userId, roleId) {
378
- return this.request("POST", `/api/v1/users/${userId}/roles`, { roleId });
379
- }
380
- async removeRole(userId, roleId) {
381
- return this.request("DELETE", `/api/v1/users/${userId}/roles/${roleId}`);
382
- }
383
- async listRoles() {
384
- return this.request("GET", "/api/v1/roles");
385
- }
386
- async getSettings(group) {
387
- const query = group ? `?group=${encodeURIComponent(group)}` : "";
388
- return this.request("GET", `/api/v1/settings${query}`);
389
- }
390
- async updateSettings(items) {
391
- await this.request("PUT", "/api/v1/settings", items);
392
- }
393
- async healthCheck() {
394
- return this.request("GET", "/health");
395
- }
396
- async getThemes() {
397
- return (await this.request("GET", "/api/v1/themes")).map((theme) => ({
398
- id: String(theme["id"] ?? ""),
399
- name: String(theme["name"] ?? ""),
400
- version: theme["version"] ? String(theme["version"]) : void 0,
401
- status: String(theme["status"] ?? "INSTALLED"),
402
- manifest: theme["manifest"] ?? null
403
- }));
404
- }
405
- async activateTheme(id) {
406
- return this.request("POST", `/api/v1/themes/${id}/activate`);
407
- }
408
- async deactivateTheme(id) {
409
- return this.request("POST", `/api/v1/themes/${id}/deactivate`);
410
- }
411
- async getPlugins() {
412
- return (await this.request("GET", "/api/v1/plugins")).map((plugin) => ({
413
- id: String(plugin["id"] ?? ""),
414
- name: String(plugin["name"] ?? ""),
415
- version: String(plugin["version"] ?? ""),
416
- status: String(plugin["status"] ?? "INSTALLED"),
417
- manifest: plugin["manifest"] ?? null
418
- }));
419
- }
420
- async activatePlugin(id) {
421
- return this.request("POST", `/api/v1/plugins/${id}/activate`);
422
- }
423
- async deactivatePlugin(id) {
424
- return this.request("POST", `/api/v1/plugins/${id}/deactivate`);
425
- }
426
- };
427
- var apiClient = new ApiClient();
428
- //#endregion
429
- //#region src/i18n/locale.ts
430
- var LOCALE_COOKIE = "admin_locale";
431
- /** Obtém locale do cookie */
432
- function getCookieLocale() {
433
- if (typeof document === "undefined") return null;
434
- const match = document.cookie.match(new RegExp(`(?:^|; )${LOCALE_COOKIE}=([^;]+)`));
435
- if (match?.[1] && SUPPORTED_LOCALES.includes(match[1])) return match[1];
436
- return null;
437
- }
438
- /** Define locale no cookie (1 ano) */
439
- function setCookieLocale(locale) {
440
- if (typeof document === "undefined") return;
441
- document.cookie = `${LOCALE_COOKIE}=${locale}; path=/; max-age=31536000; SameSite=Lax`;
442
- }
443
- /** Obtém locale do Accept-Language header */
444
- function getBrowserLocale() {
445
- if (typeof navigator === "undefined") return "en";
446
- const lang = navigator.language?.split("-")[0]?.toLowerCase();
447
- const fullLang = navigator.language?.toLowerCase();
448
- for (const locale of SUPPORTED_LOCALES) if (locale.toLowerCase() === fullLang || locale.split("-")[0] === lang) return locale;
449
- return "en";
450
- }
451
- /** Obtém locale do usuário logado via API */
452
- async function getUserLocaleFromAPI() {
453
- try {
454
- const locale = await apiClient.getUserLocale();
455
- if (locale && SUPPORTED_LOCALES.includes(locale)) return locale;
456
- } catch {}
457
- return null;
458
- }
459
- /** Salva locale do usuário via API */
460
- async function setUserLocaleInAPI(locale) {
461
- await apiClient.setUserLocale(locale);
462
- }
463
- /** Resolve locale final com prioridade: cookie → user API → browser → default */
464
- async function resolveLocale() {
465
- const cookie = getCookieLocale();
466
- if (cookie) return cookie;
467
- const user = await getUserLocaleFromAPI();
468
- if (user) return user;
469
- const browser = getBrowserLocale();
470
- if (browser) return browser;
471
- return "en";
472
- }
473
- /** Muda locale (salva no cookie + API se logado) */
474
- async function changeLocale(locale) {
475
- setCookieLocale(locale);
476
- try {
477
- await setUserLocaleInAPI(locale);
478
- } catch {}
479
- }
480
- //#endregion
481
- //#region src/i18n/index.ts
482
- var tFunctionCache = /* @__PURE__ */ new Map();
483
- /** Cria função de tradução para um locale */
484
- function createTFunction(translations, fallback) {
485
- return function t(key, params) {
486
- const keys = key.split(".");
487
- let value = translations;
488
- for (const k of keys) if (value && typeof value === "object" && k in value) value = value[k];
489
- else {
490
- value = fallback;
491
- for (const k of keys) if (value && typeof value === "object" && k in value) value = value[k];
492
- else return key;
493
- break;
494
- }
495
- if (typeof value !== "string") return key;
496
- if (params) return value.replace(/\{(\w+)\}/g, (_, param) => String(params[param] ?? ""));
497
- return value;
498
- };
499
- }
500
- /** Obtém ou cria função de tradução para locale */
501
- async function getTFunction(locale) {
502
- if (tFunctionCache.has(locale)) return tFunctionCache.get(locale);
503
- const [translations, fallback] = await Promise.all([loadLocale(locale), loadLocale("en")]);
504
- const fn = createTFunction(translations, fallback);
505
- tFunctionCache.set(locale, fn);
506
- return fn;
507
- }
508
- var currentTFunction = (key) => key;
509
- var currentLocale = "en";
510
- var isLoading = true;
511
- /** Hook Solid para usar traduções em componentes */
512
- function useTranslation(initialLocale) {
513
- const [, forceUpdate] = createSignal(0);
514
- onMount(async () => {
515
- if (isLoading) {
516
- const resolvedLocale = initialLocale ?? await resolveLocale();
517
- currentLocale = resolvedLocale;
518
- currentTFunction = await getTFunction(resolvedLocale);
519
- isLoading = false;
520
- forceUpdate((n) => n + 1);
521
- }
522
- });
523
- const changeLocaleFn = async (newLocale) => {
524
- isLoading = true;
525
- await changeLocale(newLocale);
526
- currentLocale = newLocale;
527
- currentTFunction = await getTFunction(newLocale);
528
- isLoading = false;
529
- forceUpdate((n) => n + 1);
530
- };
531
- const translate = (key, params) => currentTFunction(key, params);
532
- return {
533
- t: translate,
534
- get locale() {
535
- return currentLocale;
536
- },
537
- changeLocale: changeLocaleFn,
538
- get loading() {
539
- return isLoading;
540
- }
541
- };
542
- }
543
- /** Carrega traduções para uso em Astro middleware/pages */
544
- async function getTranslationsForLocale(locale) {
545
- return loadLocale(locale);
546
- }
547
- //#endregion
548
- export { LOCALE_LABELS as a, LOCALE_FLAGS as i, useTranslation as n, SUPPORTED_LOCALES as o, apiClient as r, isRTLLocale as s, getTranslationsForLocale as t };
@@ -1,19 +0,0 @@
1
- import { m as createRenderInstruction } from "./server_B5N27szj.mjs";
2
- //#region ../../node_modules/.bun/astro@7.3.5+3335b8e0b249efdf/node_modules/astro/dist/runtime/server/render/script.js
3
- async function renderScript(result, id) {
4
- const inlined = result.inlinedScripts.get(id);
5
- let content = "";
6
- if (inlined != null) {
7
- if (inlined) content = `<script type="module">${inlined}<\/script>`;
8
- } else {
9
- const resolved = await result.resolve(id);
10
- content = `<script type="module" src="${result.userAssetsBase ? (result.base === "/" ? "" : result.base) + result.userAssetsBase : ""}${resolved}"><\/script>`;
11
- }
12
- return createRenderInstruction({
13
- type: "script",
14
- id,
15
- content
16
- });
17
- }
18
- //#endregion
19
- export { renderScript as t };