@tachybase/plugin-log-viewer 1.3.20 → 1.3.22

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.
@@ -1,3 +1,3 @@
1
- (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("ahooks"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react-i18next","react/jsx-runtime","react","@ant-design/icons","ahooks","antd"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@tachybase/plugin-log-viewer"]={},e["@tachybase/client"],e["react-i18next"],e.jsxRuntime,e.react,e["@ant-design/icons"],e.ahooks,e.antd))})(this,function(e,t,i,r,a,v,C,c){"use strict";var re=Object.defineProperty,se=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var J=(e,t,i)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,_=(e,t)=>{for(var i in t||(t={}))oe.call(t,i)&&J(e,i,t[i]);if(Q)for(var i of Q(t))ie.call(t,i)&&J(e,i,t[i]);return e},j=(e,t)=>se(e,ne(t));var W=(e,t,i)=>new Promise((r,a)=>{var v=g=>{try{c(i.next(g))}catch(w){a(w)}},C=g=>{try{c(i.throw(g))}catch(w){a(w)}},c=g=>g.done?r(g.value):Promise.resolve(g.value).then(v,C);c((i=i.apply(e,t)).next())});const g="log-viewer";function w(p){return t.i18n.t(p,{ns:[g,"core"]})}function I(){return i.useTranslation([g,"core"])}const{Paragraph:L,Text:E}=c.Typography,B=a.memo(()=>{const{t:p}=I();return r.jsxs(c.Typography,{children:[r.jsxs(L,{children:[r.jsx(E,{code:!0,children:"[app]/request_*.log"})," - ",p("API request and response logs")]}),r.jsxs(L,{children:[r.jsx(E,{code:!0,children:"[app]/system_*.log"})," -"," ",p("Application, database, plugins and other system logs, the error level logs will be sent to")," ",r.jsx(E,{code:!0,children:"[app]/system_error_*.log"})]}),r.jsxs(L,{children:[r.jsx(E,{code:!0,children:"[app]/sql_*.log"})," -"," ",p("SQL execution logs, printed by Sequelize when the db logging is enabled")]})]})});B.displayName="Tips";const O=a.memo(p=>{const{token:f}=c.theme.useToken(),{t:y}=I(),x=C.useMemoizedFn(y),k=t.useAPIClient(),[b,m]=a.useState(["0"]),[T,X]=a.useState(""),[Y,D]=a.useState(!0),[$,F]=a.useState([]),[P,H]=a.useState(),{data:K}=t.useRequest(()=>k.resource("logger").list().then(o=>{var d;return(d=o.data)==null?void 0:d.data})),{data:A,run:Z}=t.useRequest({url:"logger:preview",method:"post",data:{file:P}},{manual:!0});a.useEffect(()=>{P&&Z()},[P]);const M=a.useCallback((o,d)=>o.map((n,u)=>{const s=`${d}-${u}`;return typeof n=="string"?{title:n,key:s,icon:r.jsx(v.FileOutlined,{})}:{title:n.name,key:s,icon:r.jsx(v.FolderOutlined,{}),children:M(n.files,s)}}),[]),S=a.useMemo(()=>{const o=K||[];return[{title:x("All"),key:"0",children:M(o,"0")}]},[K,M,x]),R=o=>{m(o),D(!1)},ee=o=>{const{value:d}=o.target,n=s=>s.reduce((l,h)=>{var q;return(q=h.title)!=null&&q.includes(d)&&l.push(h),h.children?[...l,...n(h.children)]:l},[]),u=n(S).map(s=>s.key);m(u),X(d),D(!0),F([])},N=a.useMemo(()=>{if(!T)return S;const o=d=>{const n=[];for(const u of d){const s=u.title,l=s.indexOf(T),h=s.substring(0,l),q=s.substring(l+T.length),U=l>-1?r.jsxs("span",{children:[h,r.jsx("span",{style:{color:f.colorPrimary},children:T}),q]}):r.jsx("span",{children:s});if(l>-1)n.push(j(_({},u),{title:U}));else if(u.children){const G=o(u.children);G.length&&n.push(j(_({},u),{title:U,children:G}))}}return n};return o(S)},[T,S,f.colorPrimary]),te=()=>{const o=(n,u)=>n.reduce((s,l)=>{let h=l.title;return h=l.key==="0"?h:`${u}/${h}`,l.children?[...s,...o(l.children,l.key==="0"?"":h)]:($.includes(l.key)&&l.key!=="0"&&s.push(h),s)},[]),d=o(S,"");d.length&&k.request({url:"logger:download",method:"post",responseType:"blob",data:{files:d}}).then(n=>{const u=window.URL.createObjectURL(new Blob([n.data],{type:"application/gzip"})),s=document.createElement("a");s.setAttribute("href",u),s.setAttribute("download","logs.tar.gz"),s.click(),s.remove()}).catch(n=>{console.log(n)})};return r.jsxs(c.Card,{style:{minHeight:"700px"},children:[r.jsx(c.Alert,{message:"",description:r.jsx(B,{}),type:"info",showIcon:!0}),r.jsx(c.Input.Search,{style:{marginTop:16,width:"450px"},placeholder:x("Search"),onChange:ee}),r.jsxs("div",{className:t.css`
1
+ (function(e,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("@tego/client"),require("ahooks"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react-i18next","react/jsx-runtime","react","@ant-design/icons","@tego/client","ahooks","antd"],r):(e=typeof globalThis!="undefined"?globalThis:e||self,r(e["@tachybase/plugin-log-viewer"]={},e["@tachybase/client"],e["react-i18next"],e.jsxRuntime,e.react,e["@ant-design/icons"],e["@tego/client"],e.ahooks,e.antd))})(this,function(e,r,l,t,a,v,C,w,i){"use strict";var se=Object.defineProperty,ne=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var J=(e,r,l)=>r in e?se(e,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[r]=l,_=(e,r)=>{for(var l in r||(r={}))ie.call(r,l)&&J(e,l,r[l]);if(Q)for(var l of Q(r))le.call(r,l)&&J(e,l,r[l]);return e},j=(e,r)=>ne(e,oe(r));var W=(e,r,l)=>new Promise((t,a)=>{var v=i=>{try{w(l.next(i))}catch(f){a(f)}},C=i=>{try{w(l.throw(i))}catch(f){a(f)}},w=i=>i.done?t(i.value):Promise.resolve(i.value).then(v,C);w((l=l.apply(e,r)).next())});const f="log-viewer";function X(p){return r.i18n.t(p,{ns:[f,"core"]})}function I(){return l.useTranslation([f,"core"])}const{Paragraph:L,Text:E}=i.Typography,B=a.memo(()=>{const{t:p}=I();return t.jsxs(i.Typography,{children:[t.jsxs(L,{children:[t.jsx(E,{code:!0,children:"[app]/request_*.log"})," - ",p("API request and response logs")]}),t.jsxs(L,{children:[t.jsx(E,{code:!0,children:"[app]/system_*.log"})," -"," ",p("Application, database, plugins and other system logs, the error level logs will be sent to")," ",t.jsx(E,{code:!0,children:"[app]/system_error_*.log"})]}),t.jsxs(L,{children:[t.jsx(E,{code:!0,children:"[app]/sql_*.log"})," -"," ",p("SQL execution logs, printed by Sequelize when the db logging is enabled")]})]})});B.displayName="Tips";const O=a.memo(p=>{const{token:g}=i.theme.useToken(),{t:y}=I(),x=w.useMemoizedFn(y),k=r.useAPIClient(),[T,m]=a.useState(["0"]),[b,Y]=a.useState(""),[Z,D]=a.useState(!0),[$,F]=a.useState([]),[q,H]=a.useState(),{data:K}=r.useRequest(()=>k.resource("logger").list().then(o=>{var d;return(d=o.data)==null?void 0:d.data})),{data:A,run:R}=r.useRequest({url:"logger:preview",method:"post",data:{file:q}},{manual:!0});a.useEffect(()=>{q&&R()},[q]);const M=a.useCallback((o,d)=>o.map((n,u)=>{const s=`${d}-${u}`;return typeof n=="string"?{title:n,key:s,icon:t.jsx(v.FileOutlined,{})}:{title:n.name,key:s,icon:t.jsx(v.FolderOutlined,{}),children:M(n.files,s)}}),[]),S=a.useMemo(()=>{const o=K||[];return[{title:x("All"),key:"0",children:M(o,"0")}]},[K,M,x]),ee=o=>{m(o),D(!1)},te=o=>{const{value:d}=o.target,n=s=>s.reduce((c,h)=>{var P;return(P=h.title)!=null&&P.includes(d)&&c.push(h),h.children?[...c,...n(h.children)]:c},[]),u=n(S).map(s=>s.key);m(u),Y(d),D(!0),F([])},N=a.useMemo(()=>{if(!b)return S;const o=d=>{const n=[];for(const u of d){const s=u.title,c=s.indexOf(b),h=s.substring(0,c),P=s.substring(c+b.length),U=c>-1?t.jsxs("span",{children:[h,t.jsx("span",{style:{color:g.colorPrimary},children:b}),P]}):t.jsx("span",{children:s});if(c>-1)n.push(j(_({},u),{title:U}));else if(u.children){const G=o(u.children);G.length&&n.push(j(_({},u),{title:U,children:G}))}}return n};return o(S)},[b,S,g.colorPrimary]),re=()=>{const o=(n,u)=>n.reduce((s,c)=>{let h=c.title;return h=c.key==="0"?h:`${u}/${h}`,c.children?[...s,...o(c.children,c.key==="0"?"":h)]:($.includes(c.key)&&c.key!=="0"&&s.push(h),s)},[]),d=o(S,"");d.length&&k.request({url:"logger:download",method:"post",responseType:"blob",data:{files:d}}).then(n=>{const u=window.URL.createObjectURL(new Blob([n.data],{type:"application/gzip"})),s=document.createElement("a");s.setAttribute("href",u),s.setAttribute("download","logs.tar.gz"),s.click(),s.remove()}).catch(n=>{console.log(n)})};return t.jsxs(i.Card,{style:{minHeight:"700px"},children:[t.jsx(i.Alert,{message:"",description:t.jsx(B,{}),type:"info",showIcon:!0}),t.jsx(i.Input.Search,{style:{marginTop:16,width:"450px"},placeholder:x("Search"),onChange:te}),t.jsxs("div",{className:r.css`
2
2
  display: flex;
3
- `,children:[r.jsx("div",{style:{maxHeight:"400px",width:"450px",overflow:"auto",border:"1px solid",marginTop:"6px",marginBottom:"10px",borderColor:f.colorBorder},children:N.length?r.jsx(c.Tree,{checkable:!0,showIcon:!0,showLine:!0,checkedKeys:$,expandedKeys:b,autoExpandParent:Y,onExpand:R,onCheck:o=>F(o),treeData:N,selectable:!0,onSelect:(o,d)=>{if(!d.node.children){const n=V(N,o[0],0,"");H(n||void 0)}}}):r.jsx(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE})}),r.jsx("div",{style:{maxHeight:"400px",overflow:"auto",border:"1px solid",marginTop:"6px",marginBottom:"10px",borderColor:f.colorBorder,width:"1005px",marginLeft:"10px"},children:P?r.jsx(t.CodeMirror,{value:A==null?void 0:A.data,width:"1000px",height:"398px"}):null})]}),r.jsxs(c.Button,{type:"primary",onClick:te,children:[x("Download")," (.tar.gz)"]})]})});O.displayName="LogsDownloader";const V=(p,f,y,x)=>{const k=f.split("-"),b=k[y];let m=x;if(y>0&&(m+=`/${p[b].title}`),y===k.length-1)return m;if(p[b].children)return V(p[b].children,f,y+1,m)};class z extends t.Plugin{load(){return W(this,null,function*(){this.app.systemSettingsManager.add("system-services.log-viewer",{title:w("Log Viewer"),icon:"FileTextOutlined",Component:O,aclSnippet:"pm.system-services.log-viewer"})})}}e.PluginLogViewer=z,e.default=z,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
3
+ `,children:[t.jsx("div",{style:{maxHeight:"400px",width:"450px",overflow:"auto",border:"1px solid",marginTop:"6px",marginBottom:"10px",borderColor:g.colorBorder},children:N.length?t.jsx(i.Tree,{checkable:!0,showIcon:!0,showLine:!0,checkedKeys:$,expandedKeys:T,autoExpandParent:Z,onExpand:ee,onCheck:o=>F(o),treeData:N,selectable:!0,onSelect:(o,d)=>{if(!d.node.children){const n=V(N,o[0],0,"");H(n||void 0)}}}):t.jsx(i.Empty,{image:i.Empty.PRESENTED_IMAGE_SIMPLE})}),t.jsx("div",{style:{maxHeight:"400px",overflow:"auto",border:"1px solid",marginTop:"6px",marginBottom:"10px",borderColor:g.colorBorder,width:"1005px",marginLeft:"10px"},children:q?t.jsx(C.CodeMirror,{value:A==null?void 0:A.data,width:"1000px",height:"398px"}):null})]}),t.jsxs(i.Button,{type:"primary",onClick:re,children:[x("Download")," (.tar.gz)"]})]})});O.displayName="LogsDownloader";const V=(p,g,y,x)=>{const k=g.split("-"),T=k[y];let m=x;if(y>0&&(m+=`/${p[T].title}`),y===k.length-1)return m;if(p[T].children)return V(p[T].children,g,y+1,m)};class z extends r.Plugin{load(){return W(this,null,function*(){this.app.systemSettingsManager.add("system-services.log-viewer",{title:X("Log Viewer"),icon:"FileTextOutlined",Component:O,aclSnippet:"pm.system-services.log-viewer"})})}}e.PluginLogViewer=z,e.default=z,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,11 +1,10 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.20",
4
- "@ant-design/icons": "5.5.2",
3
+ "@tachybase/client": "1.3.22",
4
+ "@ant-design/icons": "5.6.1",
5
+ "@tego/client": "1.3.39",
5
6
  "ahooks": "3.9.0",
6
7
  "antd": "5.22.5",
7
- "@tachybase/server": "1.3.20",
8
- "react-i18next": "15.2.0",
9
- "@tachybase/actions": "1.3.20",
10
- "@tachybase/logger": "1.3.20"
8
+ "@tego/server": "1.3.39",
9
+ "react-i18next": "15.2.0"
11
10
  };
@@ -1 +1 @@
1
- {"name":"tar-fs","version":"3.1.0","description":"filesystem bindings for tar-stream","dependencies":{"pump":"^3.0.0","tar-stream":"^3.1.5"},"optionalDependencies":{"bare-fs":"^4.0.1","bare-path":"^3.0.0"},"imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"files":["index.js"],"standard":{"ignore":["test/fixtures/**"]},"keywords":["tar","fs","file","tarball","directory","stream"],"devDependencies":{"brittle":"^3.1.3","rimraf":"^2.6.3","standard":"^17.0.1"},"scripts":{"test":"standard && brittle test/index.js"},"bugs":{"url":"https://github.com/mafintosh/tar-fs/issues"},"homepage":"https://github.com/mafintosh/tar-fs","main":"index.js","directories":{"test":"test"},"author":"Mathias Buus","license":"MIT","repository":{"type":"git","url":"https://github.com/mafintosh/tar-fs.git"},"_lastModified":"2025-07-24T06:28:22.713Z"}
1
+ {"name":"tar-fs","version":"3.1.0","description":"filesystem bindings for tar-stream","dependencies":{"pump":"^3.0.0","tar-stream":"^3.1.5"},"optionalDependencies":{"bare-fs":"^4.0.1","bare-path":"^3.0.0"},"imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"files":["index.js"],"standard":{"ignore":["test/fixtures/**"]},"keywords":["tar","fs","file","tarball","directory","stream"],"devDependencies":{"brittle":"^3.1.3","rimraf":"^2.6.3","standard":"^17.0.1"},"scripts":{"test":"standard && brittle test/index.js"},"bugs":{"url":"https://github.com/mafintosh/tar-fs/issues"},"homepage":"https://github.com/mafintosh/tar-fs","main":"index.js","directories":{"test":"test"},"author":"Mathias Buus","license":"MIT","repository":{"type":"git","url":"https://github.com/mafintosh/tar-fs.git"},"_lastModified":"2025-07-29T06:19:51.614Z"}
@@ -1,4 +1,4 @@
1
- import { InstallOptions, Plugin } from '@tachybase/server';
1
+ import { InstallOptions, Plugin } from '@tego/server';
2
2
  export declare class PluginLogViewerServer extends Plugin {
3
3
  afterAdd(): void;
4
4
  beforeLoad(): void;
@@ -31,7 +31,7 @@ __export(plugin_exports, {
31
31
  default: () => plugin_default
32
32
  });
33
33
  module.exports = __toCommonJS(plugin_exports);
34
- var import_server = require("@tachybase/server");
34
+ var import_server = require("@tego/server");
35
35
  var import_logger = __toESM(require("./resourcer/logger"));
36
36
  class PluginLogViewerServer extends import_server.Plugin {
37
37
  afterAdd() {
@@ -1,4 +1,4 @@
1
- import { Context, Next } from '@tachybase/actions';
1
+ import { Context, Next } from '@tego/server';
2
2
  declare const _default: {
3
3
  name: string;
4
4
  actions: {
@@ -30,17 +30,17 @@ __export(logger_exports, {
30
30
  default: () => logger_default
31
31
  });
32
32
  module.exports = __toCommonJS(logger_exports);
33
- var import_promises = require("fs/promises");
34
- var import_path = require("path");
35
- var import_stream = __toESM(require("stream"));
36
- var import_zlib = __toESM(require("zlib"));
37
- var import_logger = require("@tachybase/logger");
33
+ var import_promises = require("node:fs/promises");
34
+ var import_node_path = require("node:path");
35
+ var import_node_stream = __toESM(require("node:stream"));
36
+ var import_node_zlib = __toESM(require("node:zlib"));
37
+ var import_server = require("@tego/server");
38
38
  var import_tar_fs = require("tar-fs");
39
39
  const tarFiles = (files) => {
40
40
  return new Promise((resolve, reject) => {
41
- const passthrough = new import_stream.default.PassThrough();
42
- const gz = import_zlib.default.createGzip();
43
- (0, import_tar_fs.pack)((0, import_logger.getLoggerFilePath)(), {
41
+ const passthrough = new import_node_stream.default.PassThrough();
42
+ const gz = import_node_zlib.default.createGzip();
43
+ (0, import_tar_fs.pack)((0, import_server.getLoggerFilePath)(), {
44
44
  entries: files
45
45
  }).on("data", (chunk) => {
46
46
  passthrough.write(chunk);
@@ -64,7 +64,7 @@ var logger_default = {
64
64
  if (!appName) {
65
65
  ctx.throw(400, ctx.t("App not found"));
66
66
  }
67
- const path = (0, import_logger.getLoggerFilePath)();
67
+ const path = (0, import_server.getLoggerFilePath)();
68
68
  const readDir = async (path2, hasPermission) => {
69
69
  const fileTree = [];
70
70
  try {
@@ -75,7 +75,7 @@ var logger_default = {
75
75
  if (hasSubDirPermission === void 0) {
76
76
  hasSubDirPermission = appName === "main" || file.name === appName;
77
77
  }
78
- const subFiles = await readDir((0, import_path.join)(path2, file.name), hasSubDirPermission);
78
+ const subFiles = await readDir((0, import_node_path.join)(path2, file.name), hasSubDirPermission);
79
79
  if (!subFiles.length) {
80
80
  continue;
81
81
  }
@@ -145,8 +145,8 @@ var logger_default = {
145
145
  ctx.throw(401, ctx.t("Permission denied"));
146
146
  }
147
147
  try {
148
- const path = (0, import_logger.getLoggerFilePath)();
149
- ctx.body = await (0, import_promises.readFile)((0, import_path.join)(path, file), { encoding: "utf8" });
148
+ const path = (0, import_server.getLoggerFilePath)();
149
+ ctx.body = await (0, import_promises.readFile)((0, import_node_path.join)(path, file), { encoding: "utf8" });
150
150
  } catch (err) {
151
151
  ctx.log.error(`preview error: ${err.message}`, { file, err: err.stack });
152
152
  ctx.throw(500, ctx.t("Preview logs failed."));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-log-viewer",
3
3
  "displayName": "Logger",
4
- "version": "1.3.20",
4
+ "version": "1.3.22",
5
5
  "description": "Server-side logs, mainly including API request logs and system runtime logs, and allows to package and download log files.",
6
6
  "keywords": [
7
7
  "Logging and monitoring"
@@ -10,23 +10,18 @@
10
10
  "main": "dist/server/index.js",
11
11
  "dependencies": {},
12
12
  "devDependencies": {
13
- "@ant-design/icons": "^5.5.2",
13
+ "@ant-design/icons": "^5.6.1",
14
+ "@tachybase/test": "^1.3.39",
15
+ "@tego/client": "^1.3.39",
16
+ "@tego/server": "^1.3.39",
14
17
  "@types/tar-fs": "^2.0.4",
15
18
  "ahooks": "^3.9.0",
16
19
  "antd": "5.22.5",
17
- "react-i18next": "^15.2.0",
18
- "tar-fs": "^3.1.0"
19
- },
20
- "peerDependencies": {
21
- "@tachybase/actions": "1.3.20",
22
- "@tachybase/client": "1.3.20",
23
- "@tachybase/logger": "1.3.20",
24
- "@tachybase/server": "1.3.20",
25
- "@tachybase/test": "1.3.20"
20
+ "react-i18next": "15.2.0",
21
+ "tar-fs": "^3.1.0",
22
+ "@tachybase/client": "1.3.22"
26
23
  },
27
24
  "description.zh-CN": "服务端日志,主要包括接口请求日志和系统运行日志,并支持打包和下载日志文件。",
28
25
  "displayName.zh-CN": "日志",
29
- "scripts": {
30
- "build": "tachybase-build --no-dts @tachybase/plugin-log-viewer"
31
- }
26
+ "scripts": {}
32
27
  }