@oktis-works/admin 0.2.1 → 0.3.1

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 (43) hide show
  1. package/bin/admin.js +8 -30
  2. package/dist/client/_astro/{ContentEditor.C9TSxsGW.js → ContentEditor.Cz572tRv.js} +1 -1
  3. package/dist/client/_astro/{ContentList.e1datweV.js → ContentList.DiB9vOGJ.js} +1 -1
  4. package/dist/client/_astro/{DashboardHome.CqnldWlv.js → DashboardHome.DKuoH-SO.js} +1 -1
  5. package/dist/client/_astro/{DashboardLayout.astro_astro_type_script_index_0_lang.sNve10RH.js → DashboardLayout.astro_astro_type_script_index_0_lang.DfB7XHS-.js} +1 -1
  6. package/dist/client/_astro/{GeneralSettings.D-ALN9_r.js → GeneralSettings.CNwCgPqo.js} +1 -1
  7. package/dist/client/_astro/{MediaLibrary.NQ1lF95i.js → MediaLibrary.Cq9XsGhv.js} +1 -1
  8. package/dist/client/_astro/{PostTypesManager.CdMx_Nxn.js → PostTypesManager.6GQ4vWY1.js} +1 -1
  9. package/dist/client/_astro/{TaxonomiesManager.BU7A02Ay.js → TaxonomiesManager.B25xOjSO.js} +1 -1
  10. package/dist/client/_astro/{UserCreateForm.BvDn97aZ.js → UserCreateForm.DtBifGTo.js} +1 -1
  11. package/dist/client/_astro/{UsersManager.CFBCKO-t.js → UsersManager.CpYTrwb-.js} +1 -1
  12. package/dist/client/_astro/api.BEC1o0dT.js +1 -0
  13. package/dist/client/_astro/{login.astro_astro_type_script_index_0_lang.BZaUVRCc.js → login.astro_astro_type_script_index_0_lang.CWNQruNb.js} +1 -1
  14. package/dist/server/chunks/{BaseLayout_C41_wW4F.mjs → BaseLayout_CcUFilW5.mjs} +3 -3
  15. package/dist/server/chunks/{ContentEditor_CrO12IkK.mjs → ContentEditor_D-viRUSq.mjs} +2 -2
  16. package/dist/server/chunks/{DashboardLayout_h9iqOf7E.mjs → DashboardLayout_BcJfVITA.mjs} +3 -3
  17. package/dist/server/chunks/{MediaLibrary_Ctc5H6Od.mjs → MediaLibrary_B_iV_iG_.mjs} +2 -2
  18. package/dist/server/chunks/{_slug__FVgVdi48.mjs → _slug__Drk3SGVA.mjs} +3 -3
  19. package/dist/server/chunks/{api_C1VC3OiH.mjs → api_i8T-MI6L.mjs} +1 -9
  20. package/dist/server/chunks/{compiler_CYjwXhLT.mjs → compiler_O7J1rlsi.mjs} +3 -3
  21. package/dist/server/chunks/{console_tZnymcoE.mjs → console_B_CnzVJ2.mjs} +4 -4
  22. package/dist/server/chunks/{edit_Dau0tASP.mjs → edit_C2JhI_4N.mjs} +4 -4
  23. package/dist/server/chunks/{errors_mm28nMpQ.mjs → errors_Bf5VCr3E.mjs} +4 -4
  24. package/dist/server/chunks/{general_DOXmhv-h.mjs → general_P495Ufsz.mjs} +4 -4
  25. package/dist/server/chunks/{index_Owj31XBA.mjs → index_B6CCj15C.mjs} +4 -4
  26. package/dist/server/chunks/{index_oZK1qJym.mjs → index_BXXETvZ4.mjs} +4 -4
  27. package/dist/server/chunks/{index_B26K6w42.mjs → index_Btnu1IuS.mjs} +4 -4
  28. package/dist/server/chunks/{index_BYBvZsat.mjs → index_SwfYHct5.mjs} +3 -3
  29. package/dist/server/chunks/{index_D9OGVvPs.mjs → index_TjQB6YGE.mjs} +4 -4
  30. package/dist/server/chunks/{login_BH67N4b1.mjs → login_BTd7KCCx.mjs} +3 -3
  31. package/dist/server/chunks/{new_2mb-n_fU.mjs → new_D524jTif.mjs} +4 -4
  32. package/dist/server/chunks/{new_BhA9pTES.mjs → new_ES56yNLA.mjs} +4 -4
  33. package/dist/server/chunks/{node_C0YbdEL-.mjs → node_BafXIcNi.mjs} +52 -52
  34. package/dist/server/chunks/{post-types_B4rrV0WI.mjs → post-types_fjRQBp-g.mjs} +4 -4
  35. package/dist/server/chunks/{server_CnzC2Y0K.mjs → server_B5N27szj.mjs} +40 -40
  36. package/dist/server/chunks/{sharp_CfXj7Ul-.mjs → sharp_C91d8fsK.mjs} +3 -3
  37. package/dist/server/chunks/{taxonomies_Bdxv94jK.mjs → taxonomies_sqdg4QrC.mjs} +4 -4
  38. package/dist/server/chunks/{upload_RgdwSWbY.mjs → upload_ILNZTf3l.mjs} +4 -4
  39. package/dist/server/entry.mjs +119 -119
  40. package/package.json +5 -5
  41. package/bin/listen-log.d.ts +0 -8
  42. package/bin/listen-log.js +0 -66
  43. package/dist/client/_astro/api.DCaprPaL.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oktis-works/admin",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "okcms-admin": "./bin/admin.js"
@@ -18,10 +18,10 @@
18
18
  "clean": "rm -rf dist .astro tsconfig.tsbuildinfo"
19
19
  },
20
20
  "dependencies": {
21
- "@oktis-works/types": "^0.2.1",
22
- "@oktis-works/validation": "^0.2.1",
23
- "@oktis-works/plugin-sdk": "^0.2.1",
24
- "@oktis-works/ui": "^0.2.1",
21
+ "@oktis-works/types": "^0.3.1",
22
+ "@oktis-works/validation": "^0.3.1",
23
+ "@oktis-works/plugin-sdk": "^0.3.1",
24
+ "@oktis-works/ui": "^0.3.1",
25
25
  "@astrojs/solid-js": "7.0.2",
26
26
  "@astrojs/node": "11.1.6",
27
27
  "astro": "7.3.5",
@@ -1,8 +0,0 @@
1
- export declare function looksLikeListenLog(text: string): boolean;
2
- export declare function rewriteListenChunk(text: string, isWsl: boolean): string | null;
3
- export declare function wrapLogMethod(
4
- owner: Record<string, unknown>,
5
- name: string,
6
- isWsl: boolean,
7
- ): (...args: unknown[]) => unknown;
8
- export declare function installListenLogRewrite(consoleLike: Record<string, unknown>, isWsl: boolean): void;
package/bin/listen-log.js DELETED
@@ -1,66 +0,0 @@
1
- // @oktis-works/admin - Reescrita do aviso "Server listening on" do @astrojs/node
2
- //
3
- // O adapter decide o protocolo com `server instanceof https.Server`, e sob Bun
4
- // isso responde true até pra http.Server — o log sai "https://" mesmo o
5
- // servidor sendo HTTP puro (quem copia a URL leva ERR_SSL_PROTOCOL_ERROR).
6
- // Em WSL o "network:" aponta um IP interno (ex.: 10.255.255.254) que não
7
- // responde do Windows (ERR_CONNECTION_TIMED_OUT). Funções puras, testadas em
8
- // apps/admin/tests/listen-log.test.ts.
9
-
10
- const LISTEN_LOCAL_NETWORK = /^[ \t]+(?:local|network):/m;
11
-
12
- /** true se o texto é (parte de) o aviso de listen do adapter. */
13
- export function looksLikeListenLog(text) {
14
- return text.includes('Server listening on') || LISTEN_LOCAL_NETWORK.test(text);
15
- }
16
-
17
- /**
18
- * Reescreve um chunk do aviso de listen:
19
- * - `https://` → `http://` (protocolo real do servidor standalone);
20
- * - em WSL, remove a linha `network:` (IP interno inalcançável do Windows);
21
- * um chunk que SÓ é a linha `network:` vira null (suprima a escrita).
22
- * Texto fora do aviso volta intacto.
23
- */
24
- export function rewriteListenChunk(text, isWsl) {
25
- if (!looksLikeListenLog(text)) return text;
26
- const fixed = text.replace(/https:\/\//g, 'http://');
27
- if (!isWsl) return fixed;
28
- if (/^[ \t]*network:/m.test(fixed) && !fixed.includes('local:')) return null;
29
- return fixed.replace(/\n[ \t]*network:[^\n]*/g, '');
30
- }
31
-
32
- /**
33
- * Substitui owner[name] por um wrapper que reescreve os argumentos-string.
34
- * O logger do Astro escreve o listen via console.info (nível info) e erros via
35
- * console.error — embrulha todos os métodos de log pra não perder nenhum.
36
- */
37
- export function wrapLogMethod(owner, name, isWsl) {
38
- const original = owner[name];
39
- const wrapped = (...args) => {
40
- const out = [];
41
- let dropped = 0;
42
- for (const arg of args) {
43
- if (typeof arg !== 'string') {
44
- out.push(arg);
45
- continue;
46
- }
47
- const rewritten = rewriteListenChunk(arg, isWsl);
48
- if (rewritten === null) {
49
- dropped++;
50
- continue;
51
- }
52
- out.push(rewritten);
53
- }
54
- if (args.length > 0 && out.length === 0 && dropped > 0) return undefined;
55
- return original.apply(owner, out);
56
- };
57
- owner[name] = wrapped;
58
- return wrapped;
59
- }
60
-
61
- /** Instala a reescrita em log/info/warn/error do console-like dado. */
62
- export function installListenLogRewrite(consoleLike, isWsl) {
63
- for (const name of ['log', 'info', 'warn', 'error']) {
64
- if (typeof consoleLike[name] === 'function') wrapLogMethod(consoleLike, name, isWsl);
65
- }
66
- }
@@ -1 +0,0 @@
1
- var e={ASSETS_PREFIX:void 0,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SITE:void 0,SSR:!1}.PUBLIC_API_URL??`http://localhost:3000`,t=new class{baseUrl;csrfToken=null;isRefreshing=!1;constructor(t=e){this.baseUrl=t}async init(){try{await fetch(`${this.baseUrl}/api/v1/auth/me`,{credentials:`include`})}catch{}}async isLoggedIn(){try{return(await fetch(`${this.baseUrl}/api/v1/auth/me`,{credentials:`include`})).ok}catch{return!1}}async getTenantId(){try{let e=await fetch(`${this.baseUrl}/api/v1/auth/me`,{credentials:`include`});return e.ok?(await e.json()).tenantId??null:null}catch{return null}}async login(e){return await this.request(`POST`,`/api/v1/auth/login`,e)}async logout(){await this.request(`POST`,`/api/v1/auth/logout`,{}),this.csrfToken=null}async refreshTokens(){if(!this.isRefreshing){this.isRefreshing=!0;try{await this.request(`POST`,`/api/v1/auth/refresh`,{})}finally{this.isRefreshing=!1}}}async request(e,t,n,r){let i=`${this.baseUrl}${t}`,a={"Content-Type":`application/json`,...r};if(![`GET`,`HEAD`,`OPTIONS`].includes(e.toUpperCase())){let e=this.getCsrfToken();e&&(a[`x-csrf-token`]=e)}let o=await fetch(i,{method:e,headers:a,credentials:`include`,body:n?JSON.stringify(n):void 0});if(o.status===401&&!t.includes(`/auth/refresh`)&&!t.includes(`/auth/logout`)&&(await this.refreshTokens(),o=await fetch(i,{method:e,headers:a,credentials:`include`,body:n?JSON.stringify(n):void 0})),!o.ok){let e=await o.json().catch(()=>({error:`Request failed`}));throw Error(e.error??`Request failed: ${o.status}`)}let s=o.headers.get(`set-cookie`);if(s){let e=s.match(/csrf_token=([^;]+)/);e?.[1]&&(this.csrfToken=e[1])}return o.json()}getCsrfToken(){if(this.csrfToken)return this.csrfToken;if(typeof document<`u`){let e=document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/);if(e?.[1])return e[1]}return null}async getContent(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.type&&t.set(`type`,e.type),e?.status&&t.set(`status`,e.status),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/content?${t.toString()}`)}async getContentById(e){return this.request(`GET`,`/api/v1/content/${e}`)}async createContent(e){return this.request(`POST`,`/api/v1/content`,e)}async updateContent(e,t){return this.request(`PUT`,`/api/v1/content/${e}`,t)}async deleteContent(e){await this.request(`DELETE`,`/api/v1/content/${e}`)}async publishContent(e){return this.request(`POST`,`/api/v1/content/${e}/publish`)}async unpublishContent(e){return this.request(`POST`,`/api/v1/content/${e}/unpublish`)}async publishToggle(e,t){return t?this.unpublishContent(e):this.publishContent(e)}async getContentTypes(){return this.request(`GET`,`/api/v1/content-types`)}async createContentType(e){return this.request(`POST`,`/api/v1/content-types`,e)}async updateContentType(e,t){return this.request(`PUT`,`/api/v1/content-types/${e}`,t)}async deleteContentType(e){await this.request(`DELETE`,`/api/v1/content-types/${e}`)}async getTaxonomies(){return this.request(`GET`,`/api/v1/taxonomies`)}async createTaxonomy(e){return this.request(`POST`,`/api/v1/taxonomies`,e)}async attachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/attach`,{contentType:t})}async detachTaxonomy(e,t){await this.request(`POST`,`/api/v1/taxonomies/${e}/detach`,{contentType:t})}async deleteTaxonomy(e){await this.request(`DELETE`,`/api/v1/taxonomies/${e}`)}async getFieldGroups(e){if(e?.type){let t=new URLSearchParams({type:e.type});for(let[n,r]of Object.entries(e))n!==`type`&&r&&t.set(n,r);return this.request(`GET`,`/api/v1/field-groups?${t.toString()}`)}return this.request(`GET`,`/api/v1/field-groups`)}async getFieldGroup(e){return this.request(`GET`,`/api/v1/field-groups/${e}`)}async createFieldGroup(e){return this.request(`POST`,`/api/v1/field-groups`,e)}async getFieldTypes(e){let t=e?`?category=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/field-types${t}`)}async listMedia(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.mimeType&&t.set(`mimeType`,e.mimeType),e?.search&&t.set(`search`,e.search),this.request(`GET`,`/api/v1/media?${t.toString()}`)}async getMedia(e){return this.request(`GET`,`/api/v1/media/${e}`)}async uploadMedia(e,t){let n=new FormData;n.append(`file`,e),t?.alt&&n.append(`alt`,t.alt),t?.caption&&n.append(`caption`,t.caption);let r=`${this.baseUrl}/api/v1/media/upload`,i={},a=this.getCsrfToken();a&&(i[`x-csrf-token`]=a);let o=await fetch(r,{method:`POST`,headers:i,credentials:`include`,body:n});if(!o.ok){let e=await o.json().catch(()=>({error:`Upload failed: ${o.status}`}));throw Error(e.error??`Upload failed: ${o.status}`)}return o.json()}async updateMedia(e,t){return this.request(`PUT`,`/api/v1/media/${e}`,t)}async deleteMedia(e){await this.request(`DELETE`,`/api/v1/media/${e}`)}async listUsers(e){let t=new URLSearchParams;return e?.page&&t.set(`page`,String(e.page)),e?.limit&&t.set(`limit`,String(e.limit)),e?.search&&t.set(`search`,e.search),e?.status&&t.set(`status`,e.status),this.request(`GET`,`/api/v1/users?${t.toString()}`)}async getUser(e){return this.request(`GET`,`/api/v1/users/${e}`)}async createUser(e){return this.request(`POST`,`/api/v1/users`,e)}async updateUser(e,t){return this.request(`PUT`,`/api/v1/users/${e}`,t)}async deleteUser(e){await this.request(`DELETE`,`/api/v1/users/${e}`)}async setUserPassword(e,t){await this.request(`PUT`,`/api/v1/users/${e}/password`,{password:t})}async assignRole(e,t){return this.request(`POST`,`/api/v1/users/${e}/roles`,{roleId:t})}async removeRole(e,t){return this.request(`DELETE`,`/api/v1/users/${e}/roles/${t}`)}async listRoles(){return this.request(`GET`,`/api/v1/roles`)}async getSettings(e){let t=e?`?group=${encodeURIComponent(e)}`:``;return this.request(`GET`,`/api/v1/settings${t}`)}async updateSettings(e){await this.request(`PUT`,`/api/v1/settings`,e)}async healthCheck(){return this.request(`GET`,`/health`)}async getThemes(){return(await this.request(`GET`,`/api/v1/themes`)).map(e=>({id:String(e.id??``),name:String(e.name??``),version:e.version?String(e.version):void 0,status:String(e.status??`INSTALLED`),manifest:e.manifest??null}))}};export{t};