@dataramen/cli 0.0.41 → 0.0.43
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/bin/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var G=Object.create;var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(e,t,r,
|
|
3
|
-
`);for(let n of
|
|
2
|
+
var G=Object.create;var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of q(t))!Q.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(a=U(t,n))||a.enumerable});return e};var l=(e,t,r)=>(r=e!=null?G(z(e)):{},X(t||!e||!e.__esModule?x(r,"default",{value:e,enumerable:!0}):r,e));var D=l(require("yargs")),B=require("yargs/helpers");var T=require("node:os"),V=require("node:path"),Z=(0,T.homedir)(),c="@dataramen/server",i=(0,V.join)(Z,".dataramen",".runtime","server");var K=require("node:path"),Y=l(require("fs-extra")),L=require("node:child_process");var C=l(require("fs-extra")),w=require("node:path");function A(e){let t;function r(){try{return t||(t=C.readJsonSync(e)),t}catch{return}}return r}var N=A((0,w.join)(__dirname,"..","package.json")),v=A((0,w.join)(i,"package.json"));var f=l(require("fs-extra")),p=require("node:path"),k=require("node:child_process"),M=require("node:util"),E=l(require("yocto-spinner")),g=(0,M.promisify)(k.exec);function $(){try{let e=v();if(!e)return!0;let t=f.readJsonSync((0,p.join)(__dirname,"..","dist","package.json"));return e.version!==t.version}catch{return!0}}async function W(){let e=(0,E.default)({text:"Checking if PM2 is installed"}).start();try{return await g("pm2 -v"),e.success("PM2 already installed"),!0}catch{return e.warning("PM2 not installed"),!1}}async function j(){let e=(0,E.default)({text:"Installing PM2"}).start();try{await g("npm i -g pm2"),e.success("Installed PM2")}catch{e.error("Failed to install PM2"),process.exit(1)}}async function R(){let e=(0,E.default)({text:"Stop running instances of "+c}).start();try{await g(`pm2 stop "${c}"`),e.warning("Stopped "+c)}catch{e.success("No running instances of "+c+" found")}}async function I(){let e=(0,E.default)({text:"Create local server"}).start();f.removeSync((0,p.join)(i,"code")),f.copySync((0,p.join)(__dirname,"..","dist","code"),(0,p.join)(i,"code")),f.copySync((0,p.join)(__dirname,"..","dist","package.json"),(0,p.join)(i,"package.json")),e.text="Install local server dependencies",await g("npm i",{cwd:i}),e.success("Local server installed")}var P=l(require("yocto-spinner")),_=l(require("open"));var J=require("node:net");async function H(e){return new Promise(t=>{let r=(0,J.createServer)().once("error",()=>{t(!1)}).once("listening",()=>{r.close()}).once("close",()=>t(!0)).listen(e,"127.0.0.1")})}var h=l(require("node:crypto"));var S=require("fs-extra"),b=require("node:path");function ee(e){try{return(0,S.readFileSync)((0,b.join)(i,e),"utf-8")}catch{return}}function te(e){let t={},r=ee(e);if(r){let a=r.split(`
|
|
3
|
+
`);for(let n of a){let s=n.trim();if(!s||s.startsWith("#"))continue;let d=s.indexOf("=");if(d===-1)continue;let y=s.slice(0,d).trim(),u=s.slice(d+1).trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),t[y]=u}}return t}function ne(){let e={customValues:{},fileName:".env"};function t(){e.customValues=te(e.fileName)}function r(){let s=Object.entries(e.customValues).map(([d,y])=>`${d}=${y}`).join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`;(0,S.writeFileSync)((0,b.join)(i,e.fileName),
|
|
5
|
+
`;(0,S.writeFileSync)((0,b.join)(i,e.fileName),s,{encoding:"utf8"})}function a(n){if(e.customValues[n])return e.customValues[n]}return t(),{getNumber:n=>re(a(n)),getString:n=>oe(a(n)),getBoolean:n=>se(a(n)),flush:r,set:(n,s)=>{e.customValues[n]=s},unset:n=>{delete e.customValues[n]}}}function re(e){if(!e)return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;throw new Error("Wrong env value type")}function oe(e){if(e){if(typeof e=="string")return e;throw new Error("Wrong env value type")}}function se(e){if(!e)return;let t=e.toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new Error("Wrong env value type")}var o=ne();function O(){let e=!1;if(!o.getString("SYMM_ENCRYPTION_KEY")){let t=h.randomBytes(32).toString("hex");o.set("SYMM_ENCRYPTION_KEY",t),console.log("Generated random SYMM_ENCRYPTION_KEY"),e=!0}if(!o.getString("JWT_SECRET")){let t=h.randomBytes(32).toString("hex");o.set("JWT_SECRET",t),console.log("Generated random JWT_SECRET"),e=!0}if(!o.getString("JWT_REFRESH_SECRET")){let t=h.randomBytes(32).toString("hex");o.set("JWT_REFRESH_SECRET",t),console.log("Generated random JWT_REFRESH_SECRET"),e=!0}e&&o.flush()}var ie=async e=>{try{return(await fetch(e,{method:"GET",signal:AbortSignal.timeout(5e3)})).status===200}catch{return!1}},F=async(e,t,r)=>{let a=Date.now();for(;Date.now()-a<t;){if(await ie(e))return!0;await new Promise(s=>setTimeout(s,r))}return!1};async function le(){await W()||await j(),await R();try{$()&&await I(),O();let t=o.getNumber("PORT")||4466;if(!t)throw new Error("PORT env variable not found");if(!await H(t))throw new Error(`Port ${t} is occupied by another process`);let a=(0,P.default)({text:"Starting new instance of "+c}).start(),n=Y.readJsonSync((0,K.join)(i,"package.json"));await g(`pm2 start "${n.main}" --name "${c}" --no-autorestart -- "${i}/.env"`,{cwd:i}),a.success("Local server will be available in a couple of seconds");let s=(0,P.default)({text:"Waiting for the server to become available"}).start();await F(`http://localhost:${t}/api/status`,3e4,1e3)?(await(0,_.default)(`http://localhost:${t}`),s.success(`App is running at http://localhost:${t}`)):s.error("Server failed to become available in time")}catch(t){console.error("Failed to start local server",t)}}async function me(){(0,L.execSync)(`pm2 logs ${c}`,{stdio:"inherit"})}async function ue(){await R()}function pe(){console.log(`DataRamen CLI version: ${N().version}`),console.log(`DataRamen local server version: ${v().version}`)}async function fe(){let e=o.getNumber("PORT");await(0,_.default)(`http://localhost:${e}`)}function de(e){o.set(e.prop,e.value),o.flush(),console.log(`Environment property set: ${e.prop}`)}function ge(e){o.unset(e.prop),o.flush(),console.log(`Environment property unset: ${e.prop}`)}var m={start:le,logs:me,stop:ue,version:pe,open:fe,setEnvVariable:de,unsetEnvVariable:ge};(0,D.default)((0,B.hideBin)(process.argv)).command({command:"start",describe:"Start local server, restarts if already running",handler:m.start}).command({command:"logs",describe:"Listen for logs",handler:m.logs}).command({command:"stop",describe:"Stop the server",handler:m.stop}).command({command:"open",describe:"Stop the server",handler:m.open}).command({command:"set [prop] [value]",describe:"Set env value",handler:m.setEnvVariable}).command({command:"unset [prop]",describe:"Remove env value",handler:m.unsetEnvVariable}).command({command:"version",describe:"Show version",handler:m.version}).parse();
|
package/dist/code/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var G=Object.create;var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(e,t,r,
|
|
3
|
-
`);for(let n of
|
|
2
|
+
var G=Object.create;var x=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of q(t))!Q.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(a=U(t,n))||a.enumerable});return e};var l=(e,t,r)=>(r=e!=null?G(z(e)):{},X(t||!e||!e.__esModule?x(r,"default",{value:e,enumerable:!0}):r,e));var D=l(require("yargs")),B=require("yargs/helpers");var T=require("node:os"),V=require("node:path"),Z=(0,T.homedir)(),c="@dataramen/server",i=(0,V.join)(Z,".dataramen",".runtime","server");var K=require("node:path"),Y=l(require("fs-extra")),L=require("node:child_process");var C=l(require("fs-extra")),w=require("node:path");function A(e){let t;function r(){try{return t||(t=C.readJsonSync(e)),t}catch{return}}return r}var N=A((0,w.join)(__dirname,"..","package.json")),v=A((0,w.join)(i,"package.json"));var f=l(require("fs-extra")),p=require("node:path"),k=require("node:child_process"),M=require("node:util"),E=l(require("yocto-spinner")),g=(0,M.promisify)(k.exec);function $(){try{let e=v();if(!e)return!0;let t=f.readJsonSync((0,p.join)(__dirname,"..","dist","package.json"));return e.version!==t.version}catch{return!0}}async function W(){let e=(0,E.default)({text:"Checking if PM2 is installed"}).start();try{return await g("pm2 -v"),e.success("PM2 already installed"),!0}catch{return e.warning("PM2 not installed"),!1}}async function j(){let e=(0,E.default)({text:"Installing PM2"}).start();try{await g("npm i -g pm2"),e.success("Installed PM2")}catch{e.error("Failed to install PM2"),process.exit(1)}}async function R(){let e=(0,E.default)({text:"Stop running instances of "+c}).start();try{await g(`pm2 stop "${c}"`),e.warning("Stopped "+c)}catch{e.success("No running instances of "+c+" found")}}async function I(){let e=(0,E.default)({text:"Create local server"}).start();f.removeSync((0,p.join)(i,"code")),f.copySync((0,p.join)(__dirname,"..","dist","code"),(0,p.join)(i,"code")),f.copySync((0,p.join)(__dirname,"..","dist","package.json"),(0,p.join)(i,"package.json")),e.text="Install local server dependencies",await g("npm i",{cwd:i}),e.success("Local server installed")}var P=l(require("yocto-spinner")),_=l(require("open"));var J=require("node:net");async function H(e){return new Promise(t=>{let r=(0,J.createServer)().once("error",()=>{t(!1)}).once("listening",()=>{r.close()}).once("close",()=>t(!0)).listen(e,"127.0.0.1")})}var h=l(require("node:crypto"));var S=require("fs-extra"),b=require("node:path");function ee(e){try{return(0,S.readFileSync)((0,b.join)(i,e),"utf-8")}catch{return}}function te(e){let t={},r=ee(e);if(r){let a=r.split(`
|
|
3
|
+
`);for(let n of a){let s=n.trim();if(!s||s.startsWith("#"))continue;let d=s.indexOf("=");if(d===-1)continue;let y=s.slice(0,d).trim(),u=s.slice(d+1).trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),t[y]=u}}return t}function ne(){let e={customValues:{},fileName:".env"};function t(){e.customValues=te(e.fileName)}function r(){let s=Object.entries(e.customValues).map(([d,y])=>`${d}=${y}`).join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`;(0,S.writeFileSync)((0,b.join)(i,e.fileName),
|
|
5
|
+
`;(0,S.writeFileSync)((0,b.join)(i,e.fileName),s,{encoding:"utf8"})}function a(n){if(e.customValues[n])return e.customValues[n]}return t(),{getNumber:n=>re(a(n)),getString:n=>oe(a(n)),getBoolean:n=>se(a(n)),flush:r,set:(n,s)=>{e.customValues[n]=s},unset:n=>{delete e.customValues[n]}}}function re(e){if(!e)return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;throw new Error("Wrong env value type")}function oe(e){if(e){if(typeof e=="string")return e;throw new Error("Wrong env value type")}}function se(e){if(!e)return;let t=e.toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new Error("Wrong env value type")}var o=ne();function O(){let e=!1;if(!o.getString("SYMM_ENCRYPTION_KEY")){let t=h.randomBytes(32).toString("hex");o.set("SYMM_ENCRYPTION_KEY",t),console.log("Generated random SYMM_ENCRYPTION_KEY"),e=!0}if(!o.getString("JWT_SECRET")){let t=h.randomBytes(32).toString("hex");o.set("JWT_SECRET",t),console.log("Generated random JWT_SECRET"),e=!0}if(!o.getString("JWT_REFRESH_SECRET")){let t=h.randomBytes(32).toString("hex");o.set("JWT_REFRESH_SECRET",t),console.log("Generated random JWT_REFRESH_SECRET"),e=!0}e&&o.flush()}var ie=async e=>{try{return(await fetch(e,{method:"GET",signal:AbortSignal.timeout(5e3)})).status===200}catch{return!1}},F=async(e,t,r)=>{let a=Date.now();for(;Date.now()-a<t;){if(await ie(e))return!0;await new Promise(s=>setTimeout(s,r))}return!1};async function le(){await W()||await j(),await R();try{$()&&await I(),O();let t=o.getNumber("PORT")||4466;if(!t)throw new Error("PORT env variable not found");if(!await H(t))throw new Error(`Port ${t} is occupied by another process`);let a=(0,P.default)({text:"Starting new instance of "+c}).start(),n=Y.readJsonSync((0,K.join)(i,"package.json"));await g(`pm2 start "${n.main}" --name "${c}" --no-autorestart -- "${i}/.env"`,{cwd:i}),a.success("Local server will be available in a couple of seconds");let s=(0,P.default)({text:"Waiting for the server to become available"}).start();await F(`http://localhost:${t}/api/status`,3e4,1e3)?(await(0,_.default)(`http://localhost:${t}`),s.success(`App is running at http://localhost:${t}`)):s.error("Server failed to become available in time")}catch(t){console.error("Failed to start local server",t)}}async function me(){(0,L.execSync)(`pm2 logs ${c}`,{stdio:"inherit"})}async function ue(){await R()}function pe(){console.log(`DataRamen CLI version: ${N().version}`),console.log(`DataRamen local server version: ${v().version}`)}async function fe(){let e=o.getNumber("PORT");await(0,_.default)(`http://localhost:${e}`)}function de(e){o.set(e.prop,e.value),o.flush(),console.log(`Environment property set: ${e.prop}`)}function ge(e){o.unset(e.prop),o.flush(),console.log(`Environment property unset: ${e.prop}`)}var m={start:le,logs:me,stop:ue,version:pe,open:fe,setEnvVariable:de,unsetEnvVariable:ge};(0,D.default)((0,B.hideBin)(process.argv)).command({command:"start",describe:"Start local server, restarts if already running",handler:m.start}).command({command:"logs",describe:"Listen for logs",handler:m.logs}).command({command:"stop",describe:"Stop the server",handler:m.stop}).command({command:"open",describe:"Stop the server",handler:m.open}).command({command:"set [prop] [value]",describe:"Set env value",handler:m.setEnvVariable}).command({command:"unset [prop]",describe:"Remove env value",handler:m.unsetEnvVariable}).command({command:"version",describe:"Show version",handler:m.version}).parse();
|
package/dist/code/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var kt=Object.create;var Se=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var Gt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ht(t))!Wt.call(e,a)&&a!==r&&Se(e,a,{get:()=>t[a],enumerable:!(o=$t(t,a))||o.enumerable});return e};var O=(e,t,r)=>(r=e!=null?kt(Yt(e)):{},Gt(t||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e));var j=require("dotenv"),K=require("node:path"),be=require("node:fs"),jt=(()=>{try{let e=(0,be.readFileSync)((0,K.join)(__dirname,"..","package.json"),"utf8");return JSON.parse(e)}catch{return{version:"0.0.0"}}})(),Ce=[];process.argv[2]&&Ce.push((0,K.resolve)(process.argv[2]));(0,j.config)({path:Ce});
|
|
1
|
+
"use strict";var kt=Object.create;var Se=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var Gt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ht(t))!Wt.call(e,a)&&a!==r&&Se(e,a,{get:()=>t[a],enumerable:!(o=$t(t,a))||o.enumerable});return e};var O=(e,t,r)=>(r=e!=null?kt(Yt(e)):{},Gt(t||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e));var j=require("dotenv"),K=require("node:path"),be=require("node:fs"),jt=(()=>{try{let e=(0,be.readFileSync)((0,K.join)(__dirname,"..","package.json"),"utf8");return JSON.parse(e)}catch{return{version:"0.0.0"}}})(),Ce=[];process.argv[2]&&Ce.push((0,K.resolve)(process.argv[2]));(0,j.config)({path:Ce});(0,j.populate)(process.env,{SERVER_VERSION:jt.version,APP_DB_TYPE:"sqlite",APP_DB_DATABASE:"<home>/.dataramen/.runtime/db.sqlite3",PROD:"true"},{override:!1});var Kt=["SYMM_ENCRYPTION_KEY","JWT_SECRET","JWT_REFRESH_SECRET"],Ne=()=>{let e=[];for(let t of Kt)process.env[t]||e.push(t);if(e.length>0)throw new Error("Following env variables are required but not provided: "+e.join(", "))};function Vt(e,t=void 0){return process.env[e]||t}function zt(e,t=void 0){let r=process.env[e];if(!r)return t;let o=Number(r);return!isNaN(o)&&r.trim()!==""?o:t}function Jt(e){return process.env[e]==="true"||process.env[e]==="TRUE"||process.env[e]==="1"}var d={str:Vt,num:zt,bool:Jt};var ms=require("reflect-metadata"),vt=O(require("fastify")),Mt=O(require("@fastify/cors")),Lt=O(require("@fastify/static"));var s=class extends Error{constructor(r,o){super(o);this.status=r;this.message=o}};var xe=require("typeorm");var Ie=require("typeorm");var h=d.str("APP_DB_TYPE")==="sqlite"?"datetime":"timestamp";var ae=new Ie.EntitySchema({name:"DatabaseInspection",tableName:"db_inspection",columns:{id:{type:String,unique:!0,primary:!0,generated:"uuid"},tableName:{nullable:!0,type:String},columns:{type:"json",nullable:!0},createdAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},updatedAt:{type:h,default:()=>"CURRENT_TIMESTAMP"}},relations:{datasource:{target:()=>"DataSource",type:"many-to-one",joinTable:!1,cascade:!0}}});var Oe=require("typeorm");var ne=new Oe.EntitySchema({name:"Team",tableName:"teams",columns:{id:{type:"uuid",primary:!0,generated:"uuid"},name:{type:String},createdAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},updatedAt:{type:h,default:()=>"CURRENT_TIMESTAMP"}},relations:{users:{type:"one-to-many",target:()=>"UsersToTeams",inverseSide:"team"},queries:{type:"one-to-many",target:()=>"Query",inverseSide:"team"},datasources:{type:"one-to-many",target:()=>"DataSource",inverseSide:"team"}}});var Ae=require("typeorm");var se=new Ae.EntitySchema({name:"User",tableName:"users",columns:{id:{type:"uuid",primary:!0,generated:"uuid"},createdAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},updatedAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},username:{type:String,unique:!0},password:{type:String}},relations:{teams:{type:"one-to-many",target:()=>"UsersToTeams",inverseSide:"user"},settings:{type:"one-to-one",target:()=>"UserSettings",inverseSide:"user"},currentTeam:{type:"one-to-one",target:()=>"UsersToTeams",inverseSide:"user",joinColumn:!0}}});var _e=require("typeorm");var ie=new _e.EntitySchema({name:"UserSettings",tableName:"user_settings",columns:{id:{type:"uuid",primary:!0,generated:"uuid"},createdAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},updatedAt:{type:h,default:()=>"CURRENT_TIMESTAMP"}},relations:{user:{type:"one-to-one",target:()=>"User",inverseSide:"settings",joinColumn:!0}}});var Pe=require("typeorm");var ue=new Pe.EntitySchema({name:"DataSource",tableName:"data_sources",columns:{id:{type:"uuid",primary:!0,generated:"uuid"},dbUrl:{type:String},dbPort:{type:Number,nullable:!0},dbUser:{type:String},dbPassword:{type:String,nullable:!0,select:!1},dbPasswordIv:{type:String,nullable:!0,select:!1},dbPasswordTag:{type:String,nullable:!0,select:!1},dbType:{type:String},createdAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},updatedAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},name:{type:String},description:{type:String,nullable:!0},dbDatabase:{type:String},dbSchema:{type:String,nullable:!0},allowInsert:{type:Boolean,default:!1},allowUpdate:{type:Boolean,default:!1},lastInspected:{type:h,nullable:!0,default:null},status:{type:String,nullable:!0}},relations:{team:{type:"many-to-one",target:()=>"Team",inverseSide:"datasources",joinColumn:!0},inspections:{type:"one-to-many",target:()=>"DatabaseInspection",inverseSide:"datasource"},queries:{type:"one-to-many",target:()=>"Query",inverseSide:"dataSource"},owner:{type:"many-to-one",target:()=>"User",joinColumn:!0}}});var ve=O(require("node:os")),Me=require("node:path");var De=require("typeorm");var ce=new De.EntitySchema({name:"Query",tableName:"query",columns:{id:{type:"uuid",primary:!0,generated:"uuid"},name:{type:String},opts:{type:"json",default:"{}"},isTrash:{type:Boolean,default:!1,nullable:!0},createdAt:{type:h,default:()=>"CURRENT_TIMESTAMP"},updatedAt:{type:h,default:()=>"CURRENT_TIMESTAMP",onUpdate:"CURRENT_TIMESTAMP"}},relations:{team:{type:"many-to-one",target:()=>"Team",inverseSide:"queries",joinColumn:!0},dataSource:{type:"many-to-one",target:()=>"DataSource",inverseSide:"datasources",joinColumn:!0}}});var Ue=require("typeorm"),le=new Ue.EntitySchema({name:"UsersToTeams",tableName:"users_to_teams",columns:{id:{type:"uuid",primary:!0,generated:"uuid"},role:{type:"varchar",default:"admin",nullable:!1}},relations:{team:{type:"many-to-one",target:()=>"Team",inverseSide:"users"},user:{type:"many-to-one",target:()=>"User",inverseSide:"teams"}}});function Xt(){let e=d.str("APP_DB_DATABASE");if(!e)throw new Error("Bad value for TYPEORM_DATABASE. Please check your config!");return e.startsWith("<home>")&&(e=e.replace("<home>",ve.default.homedir())),e}var g=new xe.DataSource({type:d.str("APP_DB_TYPE"),database:Xt(),host:d.str("APP_DB_HOST"),username:d.str("APP_DB_USERNAME"),password:d.str("APP_DB_PASSWORD"),port:d.num("APP_DB_PORT"),schema:d.str("APP_DB_SCHEMA"),logging:d.bool("APP_DB_LOGGING"),migrationsRun:!0,migrations:[Me.posix.join(__dirname,"migrations","*.js")],entities:[ae,ue,ne,se,le,ie,ce]}),Le=async()=>{if(!g.isInitialized)return g.initialize();throw new Error("Already initialized")},P=g.getRepository(ae),f=g.getRepository(ue),x=g.getRepository(ne),R=g.getRepository(se),b=g.getRepository(le),F=g.getRepository(ie),I=g.getRepository(ce);var me=O(require("node:fs/promises")),qe=require("node:path"),Fe=O(require("node:os")),Zt=Fe.default.homedir(),Be=(0,qe.join)(Zt,".dataramen",".runtime","files"),Qe=async()=>{await er()||await me.default.mkdir(Be,{recursive:!0})};async function er(){try{return(await me.default.lstat(Be)).isDirectory()}catch{return!1}}var w=e=>(t,r,o)=>{e(t),o()};var k=require("jose");var ke=new TextEncoder,$e=ke.encode(d.str("JWT_SECRET")),He=ke.encode(d.str("JWT_REFRESH_SECRET")),de=async({userId:e})=>new k.SignJWT({sub:e}).setProtectedHeader({alg:"HS256"}).setExpirationTime("1h").sign($e),pe=async({userId:e})=>new k.SignJWT({sub:e}).setProtectedHeader({alg:"HS256"}).setExpirationTime("10d").sign(He),Ye=async(e,t)=>{try{let{payload:r}=await(0,k.jwtVerify)(e,t);if(!r.sub)throw new s(401,"Failed to verify access token");return{userId:r.sub}}catch(r){throw r instanceof s?r:r instanceof Error?new s(401,r.message):new s(401,"Failed to verify refresh token")}},We=async e=>Ye(e,$e),Ge=async e=>Ye(e,He);var y=(e,t)=>{let r=e.body;return t&&t(r),r},v=(e,t)=>{let r=e.query;return t&&t(r),r},S=(e,t)=>{let r=e.params;return t&&t(r),r};var Ke=O(require("bcryptjs"));var je=e=>{if(!e?.username)throw new s(400,"Username is required");if(!e?.password)throw new s(400,"Password is required")};var V="DATARAMEN_refresh_token",fe={httpOnly:!0,secure:d.bool("PROD"),sameSite:d.bool("PROD"),path:"/",maxAge:10*24*60*60},Ve=w(e=>{e.route({method:"post",url:"/login",config:{isPublic:!0},handler:async(t,r)=>{let{username:o,password:a}=y(t,je),n=await R.findOne({where:{username:o}});if(!n||!Ke.default.compareSync(a,n.password))throw new s(401,"Invalid credentials");let[i,u]=await Promise.all([de({userId:n?.id}),pe({userId:n?.id})]);return r.setCookie(V,u,fe),{data:{accessToken:i}}}}),e.route({method:"post",url:"/refresh",config:{isPublic:!0},handler:async(t,r)=>{let o=t.cookies[V];if(!o)return r.code(401).send({message:"Missing refresh token"});let{userId:a}=await Ge(o),[n,i]=await Promise.all([de({userId:a}),pe({userId:a})]);return r.setCookie(V,i,fe),{data:{accessToken:n}}}}),e.route({method:"post",url:"/logout",config:{isPublic:!0},handler:async(t,r)=>(r.clearCookie(V,fe),{data:!0})})});var ze=e=>{if(!e.dbUrl)throw new s(400,"url is required");if(!e.dbUser)throw new s(400,"user is required");if(!e.dbType)throw new s(400,"type is required");if(!e.name)throw new s(400,"name is required");if(!e.dbDatabase)throw new s(400,"database is required")};var Xe=O(require("mysql2/promise"));var tr=({database:e,password:t,user:r,url:o})=>Xe.default.createConnection({host:o,user:r,database:e,password:t}),rr=async e=>{let t=`
|
|
2
2
|
SELECT TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION
|
|
3
3
|
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
|
4
4
|
WHERE CONSTRAINT_NAME = 'PRIMARY'
|
|
@@ -264,7 +264,7 @@ to {
|
|
|
264
264
|
`}),i}function Mb(e){let n=0,i=e.charCodeAt(n);for(;i===9||i===32;)n++,i=e.charCodeAt(n);return e.slice(n)}function Lb(e,n){const i=E8(e,n),l=i.one(e,void 0),s=S8(i),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
|
|
265
265
|
`},s),o}function N8(e,n){return e&&"run"in e?async function(i,l){const s=Lb(i,{file:l,...n});await e.run(s,l)}:function(i,l){return Lb(i,{file:l,...e||n})}}function zb(e){if(e)throw e}var wh,Ub;function R8(){if(Ub)return wh;Ub=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):n.call(h)==="[object Array]"},o=function(h){if(!h||n.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!g)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},c=function(h,m){i&&m.name==="__proto__"?i(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},f=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(l)return l(h,m).value}else return;return h[m]};return wh=function d(){var h,m,g,x,v,w,A=arguments[0],_=1,k=arguments.length,O=!1;for(typeof A=="boolean"&&(O=A,A=arguments[1]||{},_=2),(A==null||typeof A!="object"&&typeof A!="function")&&(A={});_<k;++_)if(h=arguments[_],h!=null)for(m in h)g=f(A,m),x=f(h,m),A!==x&&(O&&x&&(o(x)||(v=s(x)))?(v?(v=!1,w=g&&s(g)?g:[]):w=g&&o(g)?g:{},c(A,{name:m,newValue:d(O,w,x)})):typeof x<"u"&&c(A,{name:m,newValue:x}));return A},wh}var O8=R8();const Sh=Ca(O8);function up(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function j8(){const e=[],n={run:i,use:l};return n;function i(...s){let o=-1;const c=s.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);f(null,...s);function f(d,...h){const m=e[++o];let g=-1;if(d){c(d);return}for(;++g<s.length;)(h[g]===null||h[g]===void 0)&&(h[g]=s[g]);s=h,m?D8(m,f)(...h):c(null,...h)}}function l(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),n}}function D8(e,n){let i;return l;function l(...c){const f=e.length>c.length;let d;f&&c.push(s);try{d=e.apply(this,c)}catch(h){const m=h;if(f&&i)throw m;return s(m)}f||(d&&d.then&&typeof d.then=="function"?d.then(o,s):d instanceof Error?s(d):o(d))}function s(c,...f){i||(i=!0,n(c,...f))}function o(c){s(null,c)}}const wr={basename:M8,dirname:L8,extname:z8,join:U8,sep:"/"};function M8(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');go(e);let i=0,l=-1,s=e.length,o;if(n===void 0||n.length===0||n.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){i=s+1;break}}else l<0&&(o=!0,l=s+1);return l<0?"":e.slice(i,l)}if(n===e)return"";let c=-1,f=n.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){i=s+1;break}}else c<0&&(o=!0,c=s+1),f>-1&&(e.codePointAt(s)===n.codePointAt(f--)?f<0&&(l=s):(f=-1,l=c));return i===l?l=c:l<0&&(l=e.length),e.slice(i,l)}function L8(e){if(go(e),e.length===0)return".";let n=-1,i=e.length,l;for(;--i;)if(e.codePointAt(i)===47){if(l){n=i;break}}else l||(l=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function z8(e){go(e);let n=e.length,i=-1,l=0,s=-1,o=0,c;for(;n--;){const f=e.codePointAt(n);if(f===47){if(c){l=n+1;break}continue}i<0&&(c=!0,i=n+1),f===46?s<0?s=n:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||i<0||o===0||o===1&&s===i-1&&s===l+1?"":e.slice(s,i)}function U8(...e){let n=-1,i;for(;++n<e.length;)go(e[n]),e[n]&&(i=i===void 0?e[n]:i+"/"+e[n]);return i===void 0?".":B8(i)}function B8(e){go(e);const n=e.codePointAt(0)===47;let i=q8(e,!n);return i.length===0&&!n&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),n?"/"+i:i}function q8(e,n){let i="",l=0,s=-1,o=0,c=-1,f,d;for(;++c<=e.length;){if(c<e.length)f=e.codePointAt(c);else{if(f===47)break;f=47}if(f===47){if(!(s===c-1||o===1))if(s!==c-1&&o===2){if(i.length<2||l!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(d=i.lastIndexOf("/"),d!==i.length-1){d<0?(i="",l=0):(i=i.slice(0,d),l=i.length-1-i.lastIndexOf("/")),s=c,o=0;continue}}else if(i.length>0){i="",l=0,s=c,o=0;continue}}n&&(i=i.length>0?i+"/..":"..",l=2)}else i.length>0?i+="/"+e.slice(s+1,c):i=e.slice(s+1,c),l=c-s-1;s=c,o=0}else f===46&&o>-1?o++:o=-1}return i}function go(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const H8={cwd:F8};function F8(){return"/"}function cp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function P8(e){if(typeof e=="string")e=new URL(e);else if(!cp(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Q8(e)}function Q8(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const n=e.pathname;let i=-1;for(;++i<n.length;)if(n.codePointAt(i)===37&&n.codePointAt(i+1)===50){const l=n.codePointAt(i+2);if(l===70||l===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}const Ch=["history","path","basename","stem","extname","dirname"];class Dw{constructor(n){let i;n?cp(n)?i={path:n}:typeof n=="string"||I8(n)?i={value:n}:i=n:i={},this.cwd="cwd"in i?"":H8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Ch.length;){const o=Ch[l];o in i&&i[o]!==void 0&&i[o]!==null&&(this[o]=o==="history"?[...i[o]]:i[o])}let s;for(s in i)Ch.includes(s)||(this[s]=i[s])}get basename(){return typeof this.path=="string"?wr.basename(this.path):void 0}set basename(n){Ah(n,"basename"),Eh(n,"basename"),this.path=wr.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?wr.dirname(this.path):void 0}set dirname(n){Bb(this.basename,"dirname"),this.path=wr.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?wr.extname(this.path):void 0}set extname(n){if(Eh(n,"extname"),Bb(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=wr.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){cp(n)&&(n=P8(n)),Ah(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?wr.basename(this.path,this.extname):void 0}set stem(n){Ah(n,"stem"),Eh(n,"stem"),this.path=wr.join(this.dirname||"",n+(this.extname||""))}fail(n,i,l){const s=this.message(n,i,l);throw s.fatal=!0,s}info(n,i,l){const s=this.message(n,i,l);return s.fatal=void 0,s}message(n,i,l){const s=new nn(n,i,l);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function Eh(e,n){if(e&&e.includes(wr.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+wr.sep+"`")}function Ah(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Bb(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function I8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const V8=function(e){const l=this.constructor.prototype,s=l[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,l),o},$8={}.hasOwnProperty;class rm extends V8{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=j8()}copy(){const n=new rm;let i=-1;for(;++i<this.attachers.length;){const l=this.attachers[i];n.use(...l)}return n.data(Sh(!0,{},this.namespace)),n}data(n,i){return typeof n=="string"?arguments.length===2?(_h("data",this.frozen),this.namespace[n]=i,this):$8.call(this.namespace,n)&&this.namespace[n]||void 0:n?(_h("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const s=i.call(n,...l);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const i=Mu(n),l=this.parser||this.Parser;return Th("parse",l),l(String(i),i)}process(n,i){const l=this;return this.freeze(),Th("process",this.parser||this.Parser),kh("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(o,c){const f=Mu(n),d=l.parse(f);l.run(d,f,function(m,g,x){if(m||!g||!x)return h(m);const v=g,w=l.stringify(v,x);G8(w)?x.value=w:x.result=w,h(m,x)});function h(m,g){m||!g?c(m):o?o(g):i(void 0,g)}}}processSync(n){let i=!1,l;return this.freeze(),Th("processSync",this.parser||this.Parser),kh("processSync",this.compiler||this.Compiler),this.process(n,s),Hb("processSync","process",i),l;function s(o,c){i=!0,zb(o),l=c}}run(n,i,l){qb(n),this.freeze();const s=this.transformers;return!l&&typeof i=="function"&&(l=i,i=void 0),l?o(void 0,l):new Promise(o);function o(c,f){const d=Mu(i);s.run(n,d,h);function h(m,g,x){const v=g||n;m?f(m):c?c(v):l(void 0,v,x)}}}runSync(n,i){let l=!1,s;return this.run(n,i,o),Hb("runSync","run",l),s;function o(c,f){zb(c),s=f,l=!0}}stringify(n,i){this.freeze();const l=Mu(i),s=this.compiler||this.Compiler;return kh("stringify",s),qb(n),s(n,l)}use(n,...i){const l=this.attachers,s=this.namespace;if(_h("use",this.frozen),n!=null)if(typeof n=="function")d(n,i);else if(typeof n=="object")Array.isArray(n)?f(n):c(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...g]=h;d(m,g)}else c(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function c(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(h.plugins),h.settings&&(s.settings=Sh(!0,s.settings,h.settings))}function f(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const g=h[m];o(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let g=-1,x=-1;for(;++g<l.length;)if(l[g][0]===h){x=g;break}if(x===-1)l.push([h,...m]);else if(m.length>0){let[v,...w]=m;const A=l[x][1];up(A)&&up(v)&&(v=Sh(!0,A,v)),l[x]=[h,v,...w]}}}}const Y8=new rm().freeze();function Th(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function kh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function _h(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function qb(e){if(!up(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Hb(e,n,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Mu(e){return K8(e)?e:new Dw(e)}function K8(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function G8(e){return typeof e=="string"||X8(e)}function X8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Z8="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Fb=[],Pb={allowDangerousHtml:!0},J8=/^(https?|ircs?|mailto|xmpp)$/i,W8=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function eM(e){const n=tM(e),i=nM(e);return rM(n.runSync(n.parse(i),i),e)}function tM(e){const n=e.rehypePlugins||Fb,i=e.remarkPlugins||Fb,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Pb}:Pb;return Y8().use(QD).use(i).use(N8,l).use(n)}function nM(e){const n=e.children||"",i=new Dw;return typeof n=="string"&&(i.value=n),i}function rM(e,n){const i=n.allowedElements,l=n.allowElement,s=n.components,o=n.disallowedElements,c=n.skipHtml,f=n.unwrapDisallowed,d=n.urlTransform||iM;for(const m of W8)Object.hasOwn(n,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+Z8+m.id,void 0);return Fp(e,h),Z5(e,{Fragment:b.Fragment,components:s,ignoreInvalidStyle:!0,jsx:b.jsx,jsxs:b.jsxs,passKeys:!0,passNode:!0});function h(m,g,x){if(m.type==="raw"&&x&&typeof g=="number")return c?x.children.splice(g,1):x.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let v;for(v in xh)if(Object.hasOwn(xh,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],A=xh[v];(A===null||A.includes(m.tagName))&&(m.properties[v]=d(String(w||""),v,m))}}if(m.type==="element"){let v=i?!i.includes(m.tagName):o?o.includes(m.tagName):!1;if(!v&&l&&typeof g=="number"&&(v=!l(m,g,x)),v&&x&&typeof g=="number")return f&&m.children?x.children.splice(g,1,...m.children):x.children.splice(g,1),g}}}function iM(e){const n=e.indexOf(":"),i=e.indexOf("?"),l=e.indexOf("#"),s=e.indexOf("/");return n===-1||s!==-1&&n>s||i!==-1&&n>i||l!==-1&&n>l||J8.test(e.slice(0,n))?e:""}const lM=({children:e,...n})=>b.jsx("code",{className:"bg-gray-100 text-gray-600 px-1.5 py-0.5 rounded text-sm font-mono",...n,children:e}),aM=e=>Array.isArray(e)&&typeof e[0]=="string"?e[0]:typeof e=="string"?e:"",sM=({getText:e})=>{const n=async()=>{await navigator.clipboard.writeText(e()),un.success("Copied!")};return b.jsx("button",{onClick:n,className:"text-xs text-white px-2 py-1 rounded hover:bg-gray-600 cursor-pointer",children:"📋"})},oM=({children:e,className:n,...i})=>{const l=(n==null?void 0:n.replace("language-",""))||"";return b.jsxs("div",{className:"mb-4 not-prose",children:[l&&b.jsxs("div",{className:"bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono rounded-t-md flex justify-between items-center",children:[b.jsx("span",{children:l}),b.jsx(sM,{getText:()=>aM(e).trim()})]}),b.jsx("pre",{className:`bg-gray-900 text-gray-100 p-4 overflow-x-auto ${l?"rounded-b-md":"rounded-md"}`,...i,children:b.jsx("code",{className:"font-mono text-sm",children:e})})]})},uM={code:({className:e,children:n,...i})=>e?b.jsx(oM,{className:e,...i,children:n}):b.jsx(lM,{...i,children:n}),pre:({children:e})=>b.jsx(b.Fragment,{children:e})},cM=({content:e})=>b.jsx("div",{className:"prose max-w-none",children:b.jsx(eM,{remarkPlugins:[S5],components:uM,children:e})}),fM=`### ⚠️ You are running an outdated local server version.
|
|
266
266
|
|
|
267
|
-
Please update your local server version to **0.0.
|
|
267
|
+
Please update your local server version to **0.0.66**
|
|
268
268
|
|
|
269
269
|
### 🔧 Update Command
|
|
270
270
|
|
|
@@ -281,4 +281,4 @@ dataramen start
|
|
|
281
281
|
\`\`\`
|
|
282
282
|
|
|
283
283
|
Once done, click on the "Check again" button below or refresh the page.
|
|
284
|
-
`,dM=()=>{const{data:e,refetch:n}=DR();return!(e!=null&&e.active)||MR(e.version,"0.0.64")===0?null:b.jsx(tn,{isVisible:!0,onClose:()=>null,children:b.jsxs("div",{children:[b.jsx(cM,{content:fM}),b.jsx("div",{className:"flex justify-end mt-2",children:b.jsx("button",{className:"button primary",onClick:()=>n(),children:"Check again"})})]})})},[hM,Mw]=zn(!1),Nh=()=>Mw(!1),pM=()=>Mw(!0),mM=({repeatPassword:e,password:n})=>n.length<1?null:n.length<8?b.jsx(gn,{variant:"warning",children:"New password should be at least 8 characters long"}):n!==e?b.jsx(gn,{variant:"warning",children:"Repeat password should match new password"}):null,yM=()=>{const e=hM(),{data:n}=kr(),{mutateAsync:i,isLoading:l}=jA(),s=Tr(),[{password:o,repeatPassword:c},{change:f,touched:d,reset:h}]=oo({password:"",repeatPassword:""}),m=()=>{s("/"),ao.logout().then(()=>{Nh()})},g=()=>{i({password:o}).then(()=>{h(),un.success("Password successfully updated!")})},x=o.length<8||o!==c||l,v=d.includes("password");return b.jsxs(tn,{isVisible:e,onClose:Nh,children:[b.jsx(er,{onClick:Nh}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[b.jsx(nx,{children:"Account settings"}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),b.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:n==null?void 0:n.username})]}),b.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),b.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:o,onChange:f("password")})]}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),b.jsx("input",{className:"input w-full",type:"password",value:c,onChange:f("repeatPassword")})]})]}),v&&b.jsx(mM,{password:o,repeatPassword:c}),b.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[b.jsx("button",{className:"button tertiary",disabled:x,onClick:g,children:"Update password"}),b.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[gM,Lw]=zn(!1),bM=()=>Lw(!0),Qb=()=>Lw(!1),vM=e=>Wn({queryKey:["team-users"],queryFn:async()=>{const{data:n}=await at.get("/teams/"+e+"/users");return n.data},enabled:!!e}),xM=()=>Jn({mutationFn:async({role:e,teamId:n,userId:i})=>(await at.patch("/teams/"+n+"/user-role",{role:e,userId:i}),!0),onSuccess:()=>{xt.invalidateQueries({queryKey:["team-users"]})}}),wM=()=>Jn({mutationFn:async({teamId:e,userId:n})=>(await at.delete("/teams/"+e,{params:{userId:n}}),!0),onSuccess:()=>{xt.invalidateQueries({queryKey:["team-users"]})}}),SM="_user-entry_n81ze_2",CM={userEntry:SM},EM=()=>{const e=gM(),{data:n}=kr(),{data:i}=vM(n==null?void 0:n.teamId),{mutate:l,isLoading:s}=DA(),{mutate:o,isLoading:c}=xM(),{mutate:f,isLoading:d}=wM(),[h,{change:m,reset:g}]=oo({password:"",username:""}),x=()=>{l({username:h.username,password:h.password,teamId:(n==null?void 0:n.teamId)||""}),g()},v=(k,O)=>{o({teamId:n.teamId,role:O,userId:k})},w=k=>{rx("Are you sure you want to remove this user?").then(O=>{O&&f({userId:k,teamId:n.teamId})})},A=Da(sn.ADMIN),_=s||c||d;return b.jsxs(tn,{isVisible:e,onClose:Qb,backdropClose:!0,children:[b.jsx(er,{onClick:Qb}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[b.jsx(nx,{children:"Manage users"}),Nc(i==null?void 0:i.length,0)&&b.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:i.map(k=>b.jsxs("div",{className:CM.userEntry,children:[b.jsxs("select",{className:"input",value:k.role,disabled:!A||_,onChange:O=>v(k.id,O.currentTarget.value),children:[b.jsx("option",{value:sn.OWNER,children:"Owner"}),b.jsx("option",{value:sn.ADMIN,children:"Admin"}),b.jsx("option",{value:sn.EDITOR,children:"Editor"}),b.jsx("option",{value:sn.READ_ONLY,children:"Reader"})]}),b.jsx("p",{className:"flex-1 mx-2",children:k.name}),A&&b.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>w(k.id),children:"❌"})]},k.id))}),A&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold",children:"Create new user"}),b.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[b.jsx("input",{className:"input flex-1",onChange:m("username"),value:h.username,placeholder:"Username",disabled:_}),b.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:_}),b.jsx("button",{className:"button primary",onClick:x,disabled:_,children:"Create user"})]}),b.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},AM=()=>{const[e,n]=E.useState(""),[i,l]=E.useState(""),[s,o]=E.useState(),[c,f]=E.useState(!1),d=Tr(),h=m=>{m.preventDefault(),o(void 0),ao.login({password:i,username:e}).then(()=>{d("/",{replace:!0})}).catch(o)};return b.jsx("div",{className:"page-container bg-(--bg) h-screen",children:b.jsx("div",{className:"page-content items-center",children:b.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:h,children:[b.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),s&&b.jsx(gn,{variant:"danger",children:"Failed to login. Please verify your credentials"}),b.jsx("input",{value:e,onChange:m=>n(m.currentTarget.value),className:"input",placeholder:"User name"}),b.jsx("input",{value:i,onChange:m=>l(m.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),b.jsx("button",{type:"submit",className:"button primary",children:"Login"}),c?b.jsxs(gn,{className:"w-full border border-blue-500",children:[b.jsx("p",{children:"If this is your first login, the default credentials are:"}),b.jsxs("ul",{className:"mt-2",children:[b.jsxs("li",{children:["Username: ",b.jsx("strong",{children:"admin"})]}),b.jsxs("li",{children:["Password: ",b.jsx("strong",{children:"admin"})]})]}),b.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):b.jsx("button",{className:"button tertiary",onClick:()=>f(!0),children:"First login?"})]})})})},TM=()=>{const e=Tr(),{pathname:n}=Ln(),{data:i,isLoading:l}=Xv();E.useEffect(()=>{!i&&!l&&n!==pt.login.path&&e(pt.login.path)},[i,l,e,n])};function kM(){return Y_(),NR(),TM(),b.jsxs(b.Fragment,{children:[b.jsxs(IC,{children:[b.jsx(Lu,{path:pt.home.path,element:b.jsx(RT,{})}),b.jsx(Lu,{path:pt.workbench.path,element:b.jsx(aR,{})}),b.jsx(Lu,{path:pt.login.path,element:b.jsx(AM,{})})]}),b.jsx(sR,{}),b.jsx(IT,{}),b.jsx(ek,{}),b.jsx(hk,{}),b.jsx(xR,{}),b.jsx(_R,{}),b.jsx(dM,{}),b.jsx(yM,{}),b.jsx(EM,{}),b.jsx(ok,{}),b.jsx(rk,{})]})}const _M="_desktop-layout_w5s05_2",NM="_mobile-layout_w5s05_2",RM="_nav_w5s05_2",OM="_main_w5s05_2",jM="_footer_w5s05_2",Sa={desktopLayout:_M,mobileLayout:NM,nav:RM,main:OM,footer:jM},DM="_container_1220i_2",MM="_file_1220i_2",LM="_menu_1220i_2",pa={container:DM,file:MM,menu:LM},zM=({name:e,id:n,onRename:i,onDelete:l,onOpen:s})=>{const o=lx();return b.jsxs("button",{className:pa.file,onContextMenu:o.open,onClick:()=>s(n),children:[b.jsx(ox,{handler:o,children:b.jsxs("div",{className:"context-menu-container",children:[b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),i(n)},className:"context-menu-item",children:"✏️ Rename"}),b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),l(n)},className:"context-menu-item",children:"🗑️ Delete"})]})}),b.jsxs("span",{children:["📖 ",e]})]})},UM=({name:e,id:n,index:i})=>{const l=`📦 ${e}`,s=()=>{ba(n)};return Sr(i.toString(),()=>{ba(o=>{if(o!==n)return n})},l),b.jsxs("button",{className:pa.menu,onClick:s,children:[b.jsx("span",{className:"truncate",children:l}),b.jsx("span",{className:"hotkey",children:i})]})},BM=()=>{const e=Tc(w=>w.length>0),n=Tr(),i=Ln(),l=_p("Sidebar"),{data:s}=kr(),{data:o}=CA(s==null?void 0:s.teamId),c=I_(),f=w=>{tx(w).then(A=>{Xs(A.name,ga(A.opts),!0),i.pathname!==pt.workbench.path&&n(pt.workbench.path)})},d=async w=>{const A=o==null?void 0:o.find(k=>k.id===w),_=await Ui("New name?",A==null?void 0:A.name);_&&c.mutate({id:w,payload:{name:_}})},h=w=>{c.mutate({id:w,payload:{isTrash:!0}})},m=()=>{e?i.pathname!==pt.workbench.path&&n(pt.workbench.path):l()},g=()=>{Wh(),l()},x=()=>{Wh(),n(pt.home.path)};let v=1;return b.jsxs("div",{className:pa.container,children:[b.jsxs("div",{className:"mb-4",children:[b.jsxs("button",{onClick:x,className:pa.menu,children:[b.jsx("span",{children:pt.home.name}),b.jsx("span",{className:"hotkey",children:"H"})]}),b.jsxs("button",{disabled:!s,onClick:g,className:pa.menu,children:[b.jsx("span",{children:"🔎 Start new query"}),b.jsx("span",{className:"hotkey",children:"N"})]}),b.jsxs("button",{disabled:!s,onClick:m,className:pa.menu,children:[b.jsx("span",{children:"🛠️ Workbench"}),b.jsx("span",{className:"hotkey",children:"W"})]})]}),b.jsx("div",{className:"flex-1 overflow-y-auto",children:o==null?void 0:o.map(w=>{switch(w.type){case"query":return b.jsx(zM,{onDelete:h,onRename:d,onOpen:f,name:w.name,id:w.id},w.id);case"dataSource":return b.jsx(UM,{name:w.name,id:w.id,index:v++},w.id);default:return null}})})]})},qM=({resizeDirection:e,onSizeChange:n})=>{const i=E.useRef(null),l=E.useRef(null);return E.useEffect(()=>{var o;function s(c){const f=i.current.getBoundingClientRect(),d={x:c.pageX,y:c.pageY};function h(g){{let x;x=g.pageX-d.x,i.current.style.width=`${f.width+x}px`}n&&i.current&&n(i.current)}function m(){document.body.removeEventListener("mousemove",h),document.body.removeEventListener("mouseleave",h)}document.body.addEventListener("mousemove",h),document.body.addEventListener("mouseup",m),document.body.addEventListener("mouseleave",m)}(o=l==null?void 0:l.current)==null||o.addEventListener("mousedown",s),n&&i.current&&n(i.current)}),{elementRef:i,handleRef:l}},zw=()=>{const{elementRef:e,handleRef:n}=qM({resizeDirection:"horizontal-r"}),{data:i}=kr();return b.jsxs("nav",{className:Sa.nav,ref:e,children:[b.jsx("div",{ref:n,className:"hr-slide"}),b.jsx(BM,{}),i&&b.jsxs("div",{className:Sa.footer,children:[b.jsxs("button",{onClick:pM,children:["🪪 ",i.username]}),b.jsx("button",{onClick:bM,children:"👥 Manage users"})]})]})},HM=({children:e})=>b.jsxs("div",{className:Sa.desktopLayout,children:[b.jsx(Nx,{id:"default",className:"z-100"}),b.jsx(zw,{}),b.jsx("main",{className:Sa.main,children:e})]}),FM=({children:e})=>{const n=rR(),i=()=>qp(!1);return b.jsxs("div",{className:Sa.mobileLayout,children:[b.jsx(px,{isVisible:n,onClose:i,backdropClose:!0,contentClassName:"flex",children:b.jsx(zw,{})}),b.jsx("main",{className:Sa.main,children:e})]})},PM=({children:e})=>Rc(uo.laptop)?b.jsx(HM,{children:e}):b.jsx(FM,{children:e});J2.createRoot(document.getElementById("root")).render(b.jsxs(nt.StrictMode,{children:[b.jsx(xA,{}),b.jsx(KE,{client:xt,children:b.jsx(pE,{children:b.jsx(PM,{children:b.jsx(kM,{})})})})]}));
|
|
284
|
+
`,dM=()=>{const{data:e,refetch:n}=DR();return!(e!=null&&e.active)||MR(e.version,"0.0.66")===0?null:b.jsx(tn,{isVisible:!0,onClose:()=>null,children:b.jsxs("div",{children:[b.jsx(cM,{content:fM}),b.jsx("div",{className:"flex justify-end mt-2",children:b.jsx("button",{className:"button primary",onClick:()=>n(),children:"Check again"})})]})})},[hM,Mw]=zn(!1),Nh=()=>Mw(!1),pM=()=>Mw(!0),mM=({repeatPassword:e,password:n})=>n.length<1?null:n.length<8?b.jsx(gn,{variant:"warning",children:"New password should be at least 8 characters long"}):n!==e?b.jsx(gn,{variant:"warning",children:"Repeat password should match new password"}):null,yM=()=>{const e=hM(),{data:n}=kr(),{mutateAsync:i,isLoading:l}=jA(),s=Tr(),[{password:o,repeatPassword:c},{change:f,touched:d,reset:h}]=oo({password:"",repeatPassword:""}),m=()=>{s("/"),ao.logout().then(()=>{Nh()})},g=()=>{i({password:o}).then(()=>{h(),un.success("Password successfully updated!")})},x=o.length<8||o!==c||l,v=d.includes("password");return b.jsxs(tn,{isVisible:e,onClose:Nh,children:[b.jsx(er,{onClick:Nh}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[b.jsx(nx,{children:"Account settings"}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),b.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:n==null?void 0:n.username})]}),b.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),b.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:o,onChange:f("password")})]}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),b.jsx("input",{className:"input w-full",type:"password",value:c,onChange:f("repeatPassword")})]})]}),v&&b.jsx(mM,{password:o,repeatPassword:c}),b.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[b.jsx("button",{className:"button tertiary",disabled:x,onClick:g,children:"Update password"}),b.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[gM,Lw]=zn(!1),bM=()=>Lw(!0),Qb=()=>Lw(!1),vM=e=>Wn({queryKey:["team-users"],queryFn:async()=>{const{data:n}=await at.get("/teams/"+e+"/users");return n.data},enabled:!!e}),xM=()=>Jn({mutationFn:async({role:e,teamId:n,userId:i})=>(await at.patch("/teams/"+n+"/user-role",{role:e,userId:i}),!0),onSuccess:()=>{xt.invalidateQueries({queryKey:["team-users"]})}}),wM=()=>Jn({mutationFn:async({teamId:e,userId:n})=>(await at.delete("/teams/"+e,{params:{userId:n}}),!0),onSuccess:()=>{xt.invalidateQueries({queryKey:["team-users"]})}}),SM="_user-entry_n81ze_2",CM={userEntry:SM},EM=()=>{const e=gM(),{data:n}=kr(),{data:i}=vM(n==null?void 0:n.teamId),{mutate:l,isLoading:s}=DA(),{mutate:o,isLoading:c}=xM(),{mutate:f,isLoading:d}=wM(),[h,{change:m,reset:g}]=oo({password:"",username:""}),x=()=>{l({username:h.username,password:h.password,teamId:(n==null?void 0:n.teamId)||""}),g()},v=(k,O)=>{o({teamId:n.teamId,role:O,userId:k})},w=k=>{rx("Are you sure you want to remove this user?").then(O=>{O&&f({userId:k,teamId:n.teamId})})},A=Da(sn.ADMIN),_=s||c||d;return b.jsxs(tn,{isVisible:e,onClose:Qb,backdropClose:!0,children:[b.jsx(er,{onClick:Qb}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[b.jsx(nx,{children:"Manage users"}),Nc(i==null?void 0:i.length,0)&&b.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:i.map(k=>b.jsxs("div",{className:CM.userEntry,children:[b.jsxs("select",{className:"input",value:k.role,disabled:!A||_,onChange:O=>v(k.id,O.currentTarget.value),children:[b.jsx("option",{value:sn.OWNER,children:"Owner"}),b.jsx("option",{value:sn.ADMIN,children:"Admin"}),b.jsx("option",{value:sn.EDITOR,children:"Editor"}),b.jsx("option",{value:sn.READ_ONLY,children:"Reader"})]}),b.jsx("p",{className:"flex-1 mx-2",children:k.name}),A&&b.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>w(k.id),children:"❌"})]},k.id))}),A&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold",children:"Create new user"}),b.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[b.jsx("input",{className:"input flex-1",onChange:m("username"),value:h.username,placeholder:"Username",disabled:_}),b.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:_}),b.jsx("button",{className:"button primary",onClick:x,disabled:_,children:"Create user"})]}),b.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},AM=()=>{const[e,n]=E.useState(""),[i,l]=E.useState(""),[s,o]=E.useState(),[c,f]=E.useState(!1),d=Tr(),h=m=>{m.preventDefault(),o(void 0),ao.login({password:i,username:e}).then(()=>{d("/",{replace:!0})}).catch(o)};return b.jsx("div",{className:"page-container bg-(--bg) h-screen",children:b.jsx("div",{className:"page-content items-center",children:b.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:h,children:[b.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),s&&b.jsx(gn,{variant:"danger",children:"Failed to login. Please verify your credentials"}),b.jsx("input",{value:e,onChange:m=>n(m.currentTarget.value),className:"input",placeholder:"User name"}),b.jsx("input",{value:i,onChange:m=>l(m.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),b.jsx("button",{type:"submit",className:"button primary",children:"Login"}),c?b.jsxs(gn,{className:"w-full border border-blue-500",children:[b.jsx("p",{children:"If this is your first login, the default credentials are:"}),b.jsxs("ul",{className:"mt-2",children:[b.jsxs("li",{children:["Username: ",b.jsx("strong",{children:"admin"})]}),b.jsxs("li",{children:["Password: ",b.jsx("strong",{children:"admin"})]})]}),b.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):b.jsx("button",{className:"button tertiary",onClick:()=>f(!0),children:"First login?"})]})})})},TM=()=>{const e=Tr(),{pathname:n}=Ln(),{data:i,isLoading:l}=Xv();E.useEffect(()=>{!i&&!l&&n!==pt.login.path&&e(pt.login.path)},[i,l,e,n])};function kM(){return Y_(),NR(),TM(),b.jsxs(b.Fragment,{children:[b.jsxs(IC,{children:[b.jsx(Lu,{path:pt.home.path,element:b.jsx(RT,{})}),b.jsx(Lu,{path:pt.workbench.path,element:b.jsx(aR,{})}),b.jsx(Lu,{path:pt.login.path,element:b.jsx(AM,{})})]}),b.jsx(sR,{}),b.jsx(IT,{}),b.jsx(ek,{}),b.jsx(hk,{}),b.jsx(xR,{}),b.jsx(_R,{}),b.jsx(dM,{}),b.jsx(yM,{}),b.jsx(EM,{}),b.jsx(ok,{}),b.jsx(rk,{})]})}const _M="_desktop-layout_w5s05_2",NM="_mobile-layout_w5s05_2",RM="_nav_w5s05_2",OM="_main_w5s05_2",jM="_footer_w5s05_2",Sa={desktopLayout:_M,mobileLayout:NM,nav:RM,main:OM,footer:jM},DM="_container_1220i_2",MM="_file_1220i_2",LM="_menu_1220i_2",pa={container:DM,file:MM,menu:LM},zM=({name:e,id:n,onRename:i,onDelete:l,onOpen:s})=>{const o=lx();return b.jsxs("button",{className:pa.file,onContextMenu:o.open,onClick:()=>s(n),children:[b.jsx(ox,{handler:o,children:b.jsxs("div",{className:"context-menu-container",children:[b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),i(n)},className:"context-menu-item",children:"✏️ Rename"}),b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),l(n)},className:"context-menu-item",children:"🗑️ Delete"})]})}),b.jsxs("span",{children:["📖 ",e]})]})},UM=({name:e,id:n,index:i})=>{const l=`📦 ${e}`,s=()=>{ba(n)};return Sr(i.toString(),()=>{ba(o=>{if(o!==n)return n})},l),b.jsxs("button",{className:pa.menu,onClick:s,children:[b.jsx("span",{className:"truncate",children:l}),b.jsx("span",{className:"hotkey",children:i})]})},BM=()=>{const e=Tc(w=>w.length>0),n=Tr(),i=Ln(),l=_p("Sidebar"),{data:s}=kr(),{data:o}=CA(s==null?void 0:s.teamId),c=I_(),f=w=>{tx(w).then(A=>{Xs(A.name,ga(A.opts),!0),i.pathname!==pt.workbench.path&&n(pt.workbench.path)})},d=async w=>{const A=o==null?void 0:o.find(k=>k.id===w),_=await Ui("New name?",A==null?void 0:A.name);_&&c.mutate({id:w,payload:{name:_}})},h=w=>{c.mutate({id:w,payload:{isTrash:!0}})},m=()=>{e?i.pathname!==pt.workbench.path&&n(pt.workbench.path):l()},g=()=>{Wh(),l()},x=()=>{Wh(),n(pt.home.path)};let v=1;return b.jsxs("div",{className:pa.container,children:[b.jsxs("div",{className:"mb-4",children:[b.jsxs("button",{onClick:x,className:pa.menu,children:[b.jsx("span",{children:pt.home.name}),b.jsx("span",{className:"hotkey",children:"H"})]}),b.jsxs("button",{disabled:!s,onClick:g,className:pa.menu,children:[b.jsx("span",{children:"🔎 Start new query"}),b.jsx("span",{className:"hotkey",children:"N"})]}),b.jsxs("button",{disabled:!s,onClick:m,className:pa.menu,children:[b.jsx("span",{children:"🛠️ Workbench"}),b.jsx("span",{className:"hotkey",children:"W"})]})]}),b.jsx("div",{className:"flex-1 overflow-y-auto",children:o==null?void 0:o.map(w=>{switch(w.type){case"query":return b.jsx(zM,{onDelete:h,onRename:d,onOpen:f,name:w.name,id:w.id},w.id);case"dataSource":return b.jsx(UM,{name:w.name,id:w.id,index:v++},w.id);default:return null}})})]})},qM=({resizeDirection:e,onSizeChange:n})=>{const i=E.useRef(null),l=E.useRef(null);return E.useEffect(()=>{var o;function s(c){const f=i.current.getBoundingClientRect(),d={x:c.pageX,y:c.pageY};function h(g){{let x;x=g.pageX-d.x,i.current.style.width=`${f.width+x}px`}n&&i.current&&n(i.current)}function m(){document.body.removeEventListener("mousemove",h),document.body.removeEventListener("mouseleave",h)}document.body.addEventListener("mousemove",h),document.body.addEventListener("mouseup",m),document.body.addEventListener("mouseleave",m)}(o=l==null?void 0:l.current)==null||o.addEventListener("mousedown",s),n&&i.current&&n(i.current)}),{elementRef:i,handleRef:l}},zw=()=>{const{elementRef:e,handleRef:n}=qM({resizeDirection:"horizontal-r"}),{data:i}=kr();return b.jsxs("nav",{className:Sa.nav,ref:e,children:[b.jsx("div",{ref:n,className:"hr-slide"}),b.jsx(BM,{}),i&&b.jsxs("div",{className:Sa.footer,children:[b.jsxs("button",{onClick:pM,children:["🪪 ",i.username]}),b.jsx("button",{onClick:bM,children:"👥 Manage users"})]})]})},HM=({children:e})=>b.jsxs("div",{className:Sa.desktopLayout,children:[b.jsx(Nx,{id:"default",className:"z-100"}),b.jsx(zw,{}),b.jsx("main",{className:Sa.main,children:e})]}),FM=({children:e})=>{const n=rR(),i=()=>qp(!1);return b.jsxs("div",{className:Sa.mobileLayout,children:[b.jsx(px,{isVisible:n,onClose:i,backdropClose:!0,contentClassName:"flex",children:b.jsx(zw,{})}),b.jsx("main",{className:Sa.main,children:e})]})},PM=({children:e})=>Rc(uo.laptop)?b.jsx(HM,{children:e}):b.jsx(FM,{children:e});J2.createRoot(document.getElementById("root")).render(b.jsxs(nt.StrictMode,{children:[b.jsx(xA,{}),b.jsx(KE,{client:xt,children:b.jsx(pE,{children:b.jsx(PM,{children:b.jsx(kM,{})})})})]}));
|
package/dist/code/web/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<title>DataRamen | Lightweight GUI for MySQL & PostgreSQL</title>
|
|
8
8
|
<meta name="description" content="Designed for speed, DataRamen makes navigating MySQL and PostgreSQL data effortless with a clean, high-performance interface." />
|
|
9
9
|
<meta name="robots" content="noindex, nofollow">
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-DEJ3NmGf.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-DcFOqbgf.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@dataramen/server","version":"0.0.
|
|
1
|
+
{"name":"@dataramen/server","version":"0.0.66","license":"MIT","main":"code/server.js","dependencies":{"@fastify/cors":"^11.0.1","@fastify/static":"^8.2.0","@fastify/cookie":"^11.0.2","dotenv":"^16.5.0","fast-glob":"^3.3.3","fastify":"^5.3.2","mysql2":"^3.14.1","pg":"^8.15.6","sqlite3":"^5.1.7","typeorm":"^0.3.23","bcryptjs":"^3.0.2","jose":"^6.0.12","reflect-metadata":"^0.2.2"},"devDependencies":{"fs-extra":"^11.3.0","open":"^10.2.0","yargs":"^18.0.0","yocto-spinner":"^1.0.0"}}
|