@oktis-works/admin 0.1.0

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 (29) hide show
  1. package/bin/admin.js +19 -0
  2. package/dist/client/_astro/ContentEditor.A5N-aCxT.js +1 -0
  3. package/dist/client/_astro/PostTypesManager.w66_1tDh.js +1 -0
  4. package/dist/client/_astro/TaxonomiesManager.Dv_OOCEw.js +1 -0
  5. package/dist/client/_astro/api.GqKwASBH.js +1 -0
  6. package/dist/client/_astro/client.CCQ0X2AX.js +1 -0
  7. package/dist/client/_astro/edit.B4LyOiwH.css +1 -0
  8. package/dist/client/_astro/hoisted.SqllSTyr.js +1 -0
  9. package/dist/client/_astro/web.D5F0ytYW.js +1 -0
  10. package/dist/server/_empty-middleware.mjs +3 -0
  11. package/dist/server/chunks/astro/assets-service_BADPYD54.mjs +438 -0
  12. package/dist/server/chunks/astro_C5DJOQ1V.mjs +2038 -0
  13. package/dist/server/chunks/edit_CLlDPSWF.mjs +6 -0
  14. package/dist/server/chunks/index_By1s_hvq.mjs +6 -0
  15. package/dist/server/chunks/index_CAPo3ste.mjs +6 -0
  16. package/dist/server/chunks/login_GjNKFqRH.mjs +6 -0
  17. package/dist/server/chunks/node_CZILS-L9.mjs +6 -0
  18. package/dist/server/chunks/pages/edit_DSkfb6lH.mjs +2173 -0
  19. package/dist/server/chunks/pages/index_7XvpCth_.mjs +61 -0
  20. package/dist/server/chunks/pages/login_BKgn8hvS.mjs +12 -0
  21. package/dist/server/chunks/pages/node_CxUkTckt.mjs +268 -0
  22. package/dist/server/chunks/pages/post-types_BeBr92jW.mjs +246 -0
  23. package/dist/server/chunks/pages/taxonomies_B0jngTat.mjs +69 -0
  24. package/dist/server/chunks/post-types_CVELl9a2.mjs +6 -0
  25. package/dist/server/chunks/taxonomies_D8nuzf2R.mjs +6 -0
  26. package/dist/server/entry.mjs +9777 -0
  27. package/dist/server/manifest_BgSBppnI.mjs +455 -0
  28. package/dist/server/renderers.mjs +101 -0
  29. package/package.json +43 -0
@@ -0,0 +1,246 @@
1
+ import { e as createComponent$1, k as renderComponent, r as renderTemplate, m as maybeRenderHead } from '../astro_C5DJOQ1V.mjs';
2
+ import { $ as $$DashboardLayout } from './index_7XvpCth_.mjs';
3
+ import { ssr, ssrHydrationKey, escape, createComponent, ssrAttribute } from 'solid-js/web';
4
+ import { createSignal, onMount, Show, For } from 'solid-js';
5
+ /* empty css */
6
+
7
+ const __vite_import_meta_env__ = {"ASSETS_PREFIX": undefined, "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SITE": undefined, "SSR": true};
8
+ const API_BASE = Object.assign(__vite_import_meta_env__, { _: process.env._ })["PUBLIC_API_URL"] ?? "http://localhost:3000";
9
+ class ApiClient {
10
+ constructor(baseUrl = API_BASE) {
11
+ this.baseUrl = baseUrl;
12
+ }
13
+ accessToken = null;
14
+ refreshTokenValue = null;
15
+ setTokens(accessToken, refreshToken) {
16
+ this.accessToken = accessToken;
17
+ this.refreshTokenValue = refreshToken;
18
+ if (typeof window !== "undefined") {
19
+ localStorage.setItem("accessToken", accessToken);
20
+ localStorage.setItem("refreshToken", refreshToken);
21
+ }
22
+ }
23
+ loadTokens() {
24
+ if (typeof window !== "undefined") {
25
+ this.accessToken = localStorage.getItem("accessToken");
26
+ this.refreshTokenValue = localStorage.getItem("refreshToken");
27
+ }
28
+ }
29
+ clearTokens() {
30
+ this.accessToken = null;
31
+ this.refreshTokenValue = null;
32
+ if (typeof window !== "undefined") {
33
+ localStorage.removeItem("accessToken");
34
+ localStorage.removeItem("refreshToken");
35
+ }
36
+ }
37
+ async request(method, path, body, headers) {
38
+ const url = `${this.baseUrl}${path}`;
39
+ const requestHeaders = {
40
+ "Content-Type": "application/json",
41
+ ...headers
42
+ };
43
+ if (this.accessToken) {
44
+ requestHeaders["Authorization"] = `Bearer ${this.accessToken}`;
45
+ }
46
+ const response = await fetch(url, {
47
+ method,
48
+ headers: requestHeaders,
49
+ body: body ? JSON.stringify(body) : void 0
50
+ });
51
+ if (!response.ok) {
52
+ const error = await response.json().catch(() => ({ error: "Request failed" }));
53
+ throw new Error(error.error ?? "Request failed");
54
+ }
55
+ return response.json();
56
+ }
57
+ // Auth
58
+ async login(input) {
59
+ const response = await this.request("POST", "/api/v1/auth/login", input);
60
+ this.setTokens(response.accessToken, response.refreshToken);
61
+ return response;
62
+ }
63
+ async logout() {
64
+ if (this.refreshTokenValue) {
65
+ await this.request("POST", "/api/v1/auth/logout", { token: this.refreshTokenValue });
66
+ }
67
+ this.clearTokens();
68
+ }
69
+ async refreshTokens() {
70
+ if (!this.refreshTokenValue) throw new Error("No refresh token");
71
+ const response = await this.request(
72
+ "POST",
73
+ "/api/v1/auth/refresh",
74
+ { refreshToken: this.refreshTokenValue }
75
+ );
76
+ this.setTokens(response.accessToken, response.refreshToken);
77
+ }
78
+ // Content
79
+ async getContent(options) {
80
+ const params = new URLSearchParams();
81
+ if (options?.page) params.set("page", String(options.page));
82
+ if (options?.limit) params.set("limit", String(options.limit));
83
+ if (options?.type) params.set("type", options.type);
84
+ if (options?.status) params.set("status", options.status);
85
+ if (options?.search) params.set("search", options.search);
86
+ return this.request("GET", `/api/v1/content?${params.toString()}`);
87
+ }
88
+ async getContentById(id) {
89
+ return this.request("GET", `/api/v1/content/${id}`);
90
+ }
91
+ async createContent(data) {
92
+ return this.request("POST", "/api/v1/content", data);
93
+ }
94
+ async updateContent(id, data) {
95
+ return this.request("PUT", `/api/v1/content/${id}`, data);
96
+ }
97
+ async deleteContent(id) {
98
+ await this.request("DELETE", `/api/v1/content/${id}`);
99
+ }
100
+ // Content Types (CPTs)
101
+ async getContentTypes() {
102
+ return this.request("GET", "/api/v1/content-types");
103
+ }
104
+ async createContentType(data) {
105
+ return this.request("POST", "/api/v1/content-types", data);
106
+ }
107
+ async updateContentType(slug, data) {
108
+ return this.request("PUT", `/api/v1/content-types/${slug}`, data);
109
+ }
110
+ async deleteContentType(slug) {
111
+ await this.request("DELETE", `/api/v1/content-types/${slug}`);
112
+ }
113
+ // Taxonomies
114
+ async getTaxonomies() {
115
+ return this.request("GET", "/api/v1/taxonomies");
116
+ }
117
+ async createTaxonomy(data) {
118
+ return this.request("POST", "/api/v1/taxonomies", data);
119
+ }
120
+ async attachTaxonomy(slug, contentType) {
121
+ await this.request("POST", `/api/v1/taxonomies/${slug}/attach`, { contentType });
122
+ }
123
+ async detachTaxonomy(slug, contentType) {
124
+ await this.request("POST", `/api/v1/taxonomies/${slug}/detach`, { contentType });
125
+ }
126
+ async deleteTaxonomy(slug) {
127
+ await this.request("DELETE", `/api/v1/taxonomies/${slug}`);
128
+ }
129
+ // Field Groups & Types
130
+ async getFieldGroups(context) {
131
+ if (context?.type) {
132
+ const qs = new URLSearchParams({ type: context.type });
133
+ for (const [key, value] of Object.entries(context)) {
134
+ if (key !== "type" && value) qs.set(key, value);
135
+ }
136
+ return this.request("GET", `/api/v1/field-groups?${qs.toString()}`);
137
+ }
138
+ return this.request("GET", "/api/v1/field-groups");
139
+ }
140
+ async getFieldGroup(id) {
141
+ return this.request("GET", `/api/v1/field-groups/${id}`);
142
+ }
143
+ async createFieldGroup(data) {
144
+ return this.request("POST", "/api/v1/field-groups", data);
145
+ }
146
+ async getFieldTypes(category) {
147
+ const query = category ? `?category=${encodeURIComponent(category)}` : "";
148
+ return this.request("GET", `/api/v1/field-types${query}`);
149
+ }
150
+ // Health
151
+ async healthCheck() {
152
+ return this.request("GET", "/health");
153
+ }
154
+ // Themes (para layout override no editor)
155
+ async getThemes() {
156
+ const themes = await this.request("GET", "/api/v1/themes");
157
+ return themes.map((theme) => ({
158
+ id: String(theme["id"] ?? ""),
159
+ name: String(theme["name"] ?? ""),
160
+ version: theme["version"] ? String(theme["version"]) : void 0,
161
+ status: String(theme["status"] ?? "INSTALLED"),
162
+ manifest: theme["manifest"] ?? null
163
+ }));
164
+ }
165
+ }
166
+ const apiClient = new ApiClient();
167
+
168
+ var _tmpl$ = ["<div", ' class="notice notice--error">', "</div>"], _tmpl$2 = ["<div", ' class="post-types-manager"><!--$-->', '<!--/--><form class="card"><h3>Criar Content Type</h3><div class="form-grid"><label>Slug (singular, ex.: portfolio)<input class="input" required pattern="[a-z0-9_]+" title="Apenas letras minúsculas, números e underscore"', '></label><label>Nome no singular<input class="input" required', '></label><label>Nome no plural<input class="input" required', '></label></div><fieldset class="supports"><legend>Suporta</legend><!--$-->', '<!--/--><label><input type="checkbox"', '> Possui arquivo público (/slug)</label></fieldset><button type="submit" class="btn btn-primary"', '>Criar</button></form><table class="table"><thead><tr><th>Slug</th><th>Singular</th><th>Plural</th><th>Origem</th><th>Suporta</th><th>Arquivo</th><th></th></tr></thead><tbody>', "</tbody></table></div>"], _tmpl$3 = ["<label", '><input type="checkbox"', "> <!--$-->", "<!--/--></label>"], _tmpl$4 = ["<button", ' type="button" class="btn btn-danger">Remover</button>'], _tmpl$5 = ["<tr", "><td>", "</td><td>", "</td><td>", "</td><td>", "</td><td>", "</td><td>", "</td><td>", "</td></tr>"];
169
+ const SUPPORTS_OPTIONS = [{
170
+ value: "title",
171
+ label: "Título"
172
+ }, {
173
+ value: "editor",
174
+ label: "Editor"
175
+ }, {
176
+ value: "thumbnail",
177
+ label: "Imagem destacada"
178
+ }, {
179
+ value: "excerpt",
180
+ label: "Resumo"
181
+ }, {
182
+ value: "revisions",
183
+ label: "Revisões"
184
+ }];
185
+ function PostTypesManager() {
186
+ const [types, setTypes] = createSignal([]);
187
+ const [error, setError] = createSignal("");
188
+ const [saving, setSaving] = createSignal(false);
189
+ const [form, setForm] = createSignal({
190
+ name: "",
191
+ slug: "",
192
+ singularLabel: "",
193
+ pluralLabel: "",
194
+ hasArchive: false,
195
+ supports: ["title", "editor"]
196
+ });
197
+ const load = async () => {
198
+ try {
199
+ setTypes(await apiClient.getContentTypes());
200
+ } catch (err) {
201
+ setError(err instanceof Error ? err.message : String(err));
202
+ }
203
+ };
204
+ onMount(load);
205
+ return ssr(_tmpl$2, ssrHydrationKey(), escape(createComponent(Show, {
206
+ get when() {
207
+ return error();
208
+ },
209
+ get children() {
210
+ return ssr(_tmpl$, ssrHydrationKey(), escape(error()));
211
+ }
212
+ })), ssrAttribute("value", escape(form().slug, true), false), ssrAttribute("value", escape(form().singularLabel, true), false), ssrAttribute("value", escape(form().pluralLabel, true), false), escape(createComponent(For, {
213
+ get each() {
214
+ return [...SUPPORTS_OPTIONS];
215
+ },
216
+ children: (option) => ssr(_tmpl$3, ssrHydrationKey(), ssrAttribute("checked", form().supports.includes(option.value), true), escape(option.label))
217
+ })), ssrAttribute("checked", form().hasArchive, true), ssrAttribute("disabled", saving(), true), escape(createComponent(For, {
218
+ get each() {
219
+ return types();
220
+ },
221
+ children: (type) => ssr(_tmpl$5, ssrHydrationKey(), escape(type.slug), escape(type.singularLabel), escape(type.pluralLabel), escape(type.source ?? "ADMIN"), escape((type.supports ?? []).join(", ")), type.hasArchive ? "Sim" : "Não", escape(createComponent(Show, {
222
+ get when() {
223
+ return type.source !== "CORE";
224
+ },
225
+ get children() {
226
+ return ssr(_tmpl$4, ssrHydrationKey());
227
+ }
228
+ })))
229
+ })));
230
+ }
231
+
232
+ const $$PostTypes = createComponent$1(($$result, $$props, $$slots) => {
233
+ return renderTemplate`${renderComponent($$result, "DashboardLayout", $$DashboardLayout, { "title": "Post Types", "data-astro-cid-f6czuk7s": true }, { "default": ($$result2) => renderTemplate` ${maybeRenderHead()}<div class="settings-page" data-astro-cid-f6czuk7s> <div class="page-header" data-astro-cid-f6czuk7s> <h2 data-astro-cid-f6czuk7s>Content Types</h2> <p data-astro-cid-f6czuk7s>Crie tipos de conteúdo personalizados (CPTs) além de Posts e Páginas.</p> </div> ${renderComponent($$result2, "PostTypesManager", PostTypesManager, { "client:load": true, "client:component-hydration": "load", "client:component-path": "/home/judah/projetos/blacklotuscms-v2/apps/admin/src/components/apps/settings/PostTypesManager", "client:component-export": "PostTypesManager", "data-astro-cid-f6czuk7s": true })} </div> ` })} `;
234
+ }, "/home/judah/projetos/blacklotuscms-v2/apps/admin/src/pages/settings/post-types.astro", void 0);
235
+
236
+ const $$file = "/home/judah/projetos/blacklotuscms-v2/apps/admin/src/pages/settings/post-types.astro";
237
+ const $$url = "/settings/post-types";
238
+
239
+ const postTypes = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
240
+ __proto__: null,
241
+ default: $$PostTypes,
242
+ file: $$file,
243
+ url: $$url
244
+ }, Symbol.toStringTag, { value: 'Module' }));
245
+
246
+ export { apiClient as a, postTypes as p };
@@ -0,0 +1,69 @@
1
+ import { e as createComponent$1, k as renderComponent, r as renderTemplate, m as maybeRenderHead } from '../astro_C5DJOQ1V.mjs';
2
+ import { $ as $$DashboardLayout } from './index_7XvpCth_.mjs';
3
+ import { ssr, ssrHydrationKey, escape, createComponent, ssrAttribute, ssrStyleProperty } from 'solid-js/web';
4
+ import { createSignal, onMount, Show, For } from 'solid-js';
5
+ import { a as apiClient } from './post-types_BeBr92jW.mjs';
6
+ /* empty css */
7
+
8
+ var _tmpl$ = ["<div", ' class="notice notice--error">', "</div>"], _tmpl$2 = ["<div", ' class="taxonomies-manager"><!--$-->', '<!--/--><form class="card"><h3>Criar Taxonomia</h3><div class="form-grid"><label>Nome (ex.: Gênero)<input class="input" required', '></label><label>Slug (opcional, gerado do nome)<input class="input" pattern="[a-z0-9_]*" title="Apenas letras minúsculas, números e underscore"', '></label><label><input type="checkbox"', "> Hierárquica (permite termos pai/filho)</label></div><fieldset><legend>Vincular aos content types</legend><!--$-->", '<!--/--></fieldset><button type="submit" class="btn btn-primary"', '>Criar</button></form><table class="table"><thead><tr><th>Taxonomia</th><th>Hierárquica</th><th>Content types vinculados</th><th></th></tr></thead><tbody>', "</tbody></table></div>"], _tmpl$3 = ["<label", '><input type="checkbox"', "> <!--$-->", "<!--/--> (<!--$-->", "<!--/-->)</label>"], _tmpl$4 = ["<button", ' type="button" class="btn btn-danger">Remover</button>'], _tmpl$5 = ["<tr", "><td><!--$-->", "<!--/--> (<!--$-->", "<!--/-->)</td><td>", "</td><td>", "</td><td>", "</td></tr>"], _tmpl$6 = ["<label", ' style="', '"><input type="checkbox"', "> <!--$-->", "<!--/--></label>"];
9
+ function TaxonomiesManager() {
10
+ const [taxonomies, setTaxonomies] = createSignal([]);
11
+ const [contentTypes, setContentTypes] = createSignal([]);
12
+ const [error, setError] = createSignal("");
13
+ const [saving, setSaving] = createSignal(false);
14
+ const [form, setForm] = createSignal({
15
+ name: "",
16
+ slug: "",
17
+ hierarchical: false,
18
+ attachTo: []
19
+ });
20
+ const load = async () => {
21
+ try {
22
+ const [taxonomyList, typeList] = await Promise.all([apiClient.getTaxonomies(), apiClient.getContentTypes()]);
23
+ setTaxonomies(taxonomyList);
24
+ setContentTypes(typeList);
25
+ } catch (err) {
26
+ setError(err instanceof Error ? err.message : String(err));
27
+ }
28
+ };
29
+ onMount(load);
30
+ return ssr(_tmpl$2, ssrHydrationKey(), escape(createComponent(Show, {
31
+ get when() {
32
+ return error();
33
+ },
34
+ get children() {
35
+ return ssr(_tmpl$, ssrHydrationKey(), escape(error()));
36
+ }
37
+ })), ssrAttribute("value", escape(form().name, true), false), ssrAttribute("value", escape(form().slug, true), false), ssrAttribute("checked", form().hierarchical, true), escape(createComponent(For, {
38
+ get each() {
39
+ return contentTypes();
40
+ },
41
+ children: (type) => ssr(_tmpl$3, ssrHydrationKey(), ssrAttribute("checked", form().attachTo.includes(type.slug), true), escape(type.pluralLabel), escape(type.slug))
42
+ })), ssrAttribute("disabled", saving(), true), escape(createComponent(For, {
43
+ get each() {
44
+ return taxonomies();
45
+ },
46
+ children: (taxonomy) => ssr(_tmpl$5, ssrHydrationKey(), escape(taxonomy.name), escape(taxonomy.slug), taxonomy.hierarchical ? "Sim" : "Não", escape(createComponent(For, {
47
+ get each() {
48
+ return contentTypes();
49
+ },
50
+ children: (type) => ssr(_tmpl$6, ssrHydrationKey(), ssrStyleProperty("margin-right:", "0.75rem"), ssrAttribute("checked", taxonomy.attachTo?.includes(type.slug) ?? false, true), escape(type.slug))
51
+ })), escape(createComponent(Show, {
52
+ get when() {
53
+ return taxonomy.source !== "CORE";
54
+ },
55
+ get children() {
56
+ return ssr(_tmpl$4, ssrHydrationKey());
57
+ }
58
+ })))
59
+ })));
60
+ }
61
+
62
+ const $$Taxonomies = createComponent$1(($$result, $$props, $$slots) => {
63
+ return renderTemplate`${renderComponent($$result, "DashboardLayout", $$DashboardLayout, { "title": "Taxonomias", "data-astro-cid-fpxil6ue": true }, { "default": ($$result2) => renderTemplate` ${maybeRenderHead()}<div class="settings-page" data-astro-cid-fpxil6ue> <div class="page-header" data-astro-cid-fpxil6ue> <h2 data-astro-cid-fpxil6ue>Taxonomias</h2> <p data-astro-cid-fpxil6ue>Crie taxonomias personalizadas e vincule-as aos content types.</p> </div> ${renderComponent($$result2, "TaxonomiesManager", TaxonomiesManager, { "client:load": true, "client:component-hydration": "load", "client:component-path": "/home/judah/projetos/blacklotuscms-v2/apps/admin/src/components/apps/settings/TaxonomiesManager", "client:component-export": "TaxonomiesManager", "data-astro-cid-fpxil6ue": true })} </div> ` })} `;
64
+ }, "/home/judah/projetos/blacklotuscms-v2/apps/admin/src/pages/settings/taxonomies.astro", void 0);
65
+
66
+ const $$file = "/home/judah/projetos/blacklotuscms-v2/apps/admin/src/pages/settings/taxonomies.astro";
67
+ const $$url = "/settings/taxonomies";
68
+
69
+ export { $$Taxonomies as default, $$file as file, $$url as url };
@@ -0,0 +1,6 @@
1
+ export { renderers } from '../renderers.mjs';
2
+ export { onRequest } from '../_empty-middleware.mjs';
3
+
4
+ const page = () => import('./pages/post-types_BeBr92jW.mjs').then(n => n.p);
5
+
6
+ export { page };
@@ -0,0 +1,6 @@
1
+ export { renderers } from '../renderers.mjs';
2
+ export { onRequest } from '../_empty-middleware.mjs';
3
+
4
+ const page = () => import('./pages/taxonomies_B0jngTat.mjs');
5
+
6
+ export { page };