hysteria-orm 10.0.9 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -179,5 +179,5 @@ export default class extends Migration {
179
179
  id INTEGER PRIMARY KEY AUTOINCREMENT,
180
180
  name TEXT NOT NULL,
181
181
  timestamp TEXT NOT NULL DEFAULT '${new Date().toISOString()}'
182
- );`}},Ee=new ys;var Kd=async(i,t)=>{if(i.endsWith(".ts"))return await import('typescript').catch(()=>{throw new u("MigrationUtils::importMigrationFile In order to use TypeScript migrations, you must have `typeScript` installed in your project. Please install it with `npm install typescript --save-dev`, if you're in a production environment, it's recommended to transpile your migrations to JavaScript before running the application.","MIGRATION_MODULE_NOT_FOUND")}),await import('esbuild').catch(()=>{throw new u("MigrationUtils::importMigrationFile In order to use TypeScript migrations, you must have `esbuild` installed in your project. Please install it with `npm install esbuild --save-dev`, if you're in a production environment, it's recommended to transpile your migrations to JavaScript before running the application.","MIGRATION_MODULE_NOT_FOUND")}),await import('bundle-require').catch(()=>{throw new u("MigrationUtils::importMigrationFile In order to use TypeScript migrations, you must have `bundle-require` installed in your project. Please install it with `npm install bundle-require --save-dev`, if you're in a production environment, it's recommended to transpile your migrations to JavaScript before running the application.","MIGRATION_MODULE_NOT_FOUND")}),Il(i);try{return import(url.pathToFileURL(i).href)}catch{let o=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));try{let n=o(i);return {default:n.default||n,...n}}catch{throw new u(`MigrationUtils::importMigrationFile Failed to import migration file: ${i}. Both ESM and CommonJS imports failed.`,"MIGRATION_MODULE_NOT_FOUND")}}};async function pr(i,t){switch(i){case "mariadb":case "mysql":let e=t;return await e.query(Ee.migrationTableTemplateMysql()),(await e.query(Ee.selectAllFromMigrationsTemplate()))[0];case "postgres":case "cockroachdb":let o=t;return await o.query(Ee.migrationTableTemplatePg()),(await o.query(Ee.selectAllFromMigrationsTemplate())).rows;case "sqlite":return await Bl(Ee.migrationTableTemplateSQLite(),[],t),await Bl(Ee.selectAllFromMigrationsTemplate(),[],t)||[];default:throw new u("MigrationUtils::getMigrationTable Unsupported database type","DEVELOPMENT_ERROR")}}async function yr(i,t,e){let r=Fd(t),o=[];for(let n of r){let s=await kd(n,t),a=new s(i||M.DB_TYPE);a.migrationName=n,o.push(a);}return o}async function Qd(i,t){let e=await Kd(i);if(!e.default)throw new u("MigrationUtils::loadMigrationModule Migration module does not have a default export","MIGRATION_MODULE_NOT_FOUND");return e.default}async function kd(i,t=M.MIGRATION_PATH||"database/migrations",e){t=ut.join(t,i);let r=ut__default.default.resolve(process.cwd(),t),o=await Qd(r);if(!o)throw new u("MigrationUtils::findMigrationModule migrations module not found for migration: "+i,"MIGRATION_MODULE_NOT_FOUND");return o}function Fd(i){let t=process.cwd(),e=ut__default.default.resolve(i||M.MIGRATION_PATH||"database/migrations"),r=ut__default.default.resolve(t,e);try{let o=ml__default.default.readdirSync(r).filter(n=>{let s=ut__default.default.extname(n),a=ut__default.default.join(r,n);return ml__default.default.statSync(a).isFile()&&(s===".ts"||s===".js")});if(o.length)return o;throw new u("MigrationUtils::findMigrationNames No database migration files found on path: "+r,"MIGRATION_MODULE_NOT_FOUND")}catch{throw new u("MigrationUtils::findMigrationNames No database migration files found on path: "+r,"MIGRATION_MODULE_NOT_FOUND")}}async function Bl(i,t,e){return new Promise((r,o)=>{e.all(i,t,(n,s)=>{n&&o(n),r(s);});})}async function fs(i,t,e,r,o){let n=i.getDbType(),s=null;N.info("Rolling back migrations for database type: "+n);try{let a=await pr(n,i.getPool()),l=await yr(n,e,r),d=a.map(c=>c.name),m=l.filter(c=>d.includes(c.migrationName));if(m.length===0){N.info("No pending migrations.");return}if(t);let p=new _e(i);o&&(s=await i.startTransaction(),i=s.sql),await p.downMigrations(m),o&&await s?.commit();}catch(a){throw a}N.info("Migrations rolled back successfully");}async function hs(i,t,e,r,o){let n=i.getDbType(),s=null;N.info("Running migrations for database type: "+n);try{let a=await pr(n,i.getPool()),d=(await yr(n,e,r)).filter(p=>!a.map(c=>c.name).includes(p.migrationName));if(!d.length){N.info("No pending migrations.");return}if(t);let m=new _e(i);o&&(s=await i.startTransaction(),i=s.sql),await m.upMigrations(d),o&&await s?.commit();}catch(a){throw a}N.info("Migrations ran successfully");}var _e=class{constructor(t){this.migrationTable="migrations";this.sql=t||ne.getInstance();}async upMigrations(t){for(let e of t){N.info(`Running migration ${e.migrationName}`),await e.up();let r=e.schema.queryStatements;for(let o of r)o&&await this.sql.rawQuery(o);await this.addMigrationToMigrationTable(e),e.afterMigration&&await e.afterMigration(this.sql);}}async downMigrations(t){t=t.reverse();for(let e of t){N.info(`Rolling back migration ${e.migrationName}`),await e.down();let r=e.schema.queryStatements;for(let o of r)o&&await this.sql.rawQuery(o);await this.deleteMigrationFromMigrationTable(e),e.afterMigration&&await e.afterMigration(this.sql);}}async addMigrationToMigrationTable(t){let r=new Date().toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"");await this.sql.query(this.migrationTable).insert({name:t.migrationName,timestamp:r});}async deleteMigrationFromMigrationTable(t){await this.sql.query(this.migrationTable).where("name",t.migrationName).delete();}},gs=class{constructor(t=M.MIGRATION_PATH||"database/migrations",e){this.migrationPath=t,this.sqlDataSourceInput=e;}async up(){return this.migrate("up")}async down(){return this.migrate("down")}async migrate(t){M.MIGRATION_PATH=this.migrationPath;let e=this.sqlDataSourceInput instanceof ne?this.sqlDataSourceInput:await ne.connect({...this.sqlDataSourceInput});return t==="up"?hs(e,void 0,this.migrationPath):fs(e,void 0,this.migrationPath)}},Ld=(i,t)=>new gs(i,t);exports.AutogeneratedModel=cs;exports.Collection=Ue;exports.HysteriaError=u;exports.Migration=ps;exports.Model=Z;exports.ModelQueryBuilder=We;exports.MongoDataSource=dt;exports.TimestampedModel=lt;exports.User=Pe;exports.UuidModel=us;exports.belongsTo=Sl;exports.column=A;exports.createModelFactory=Dd;exports.defineMigrator=Ld;exports.generateOpenApiModel=hu;exports.generateOpenApiModelSchema=gu;exports.generateOpenApiModelWithMetadata=Cs;exports.getCollectionProperties=bs;exports.getIndexes=_l;exports.getModelColumns=ft;exports.getPrimaryKey=Rl;exports.getRelations=Wt;exports.getRelationsMetadata=Cl;exports.getUniques=Ol;exports.hasMany=Ml;exports.hasOne=Nl;exports.index=cR;exports.logger=N;exports.manyToMany=ql;exports.mongo=dt;exports.property=gr;exports.redis=ms;exports.sql=ne;exports.unique=mR;exports.view=pR;exports.withPerformance=B;//# sourceMappingURL=index.cjs.map
182
+ );`}},Ee=new ys;var Kd=async(i,t)=>{if(i.endsWith(".ts"))return await import('typescript').catch(()=>{throw new u("MigrationUtils::importMigrationFile In order to use TypeScript migrations, you must have `typeScript` installed in your project. Please install it with `npm install typescript --save-dev`, if you're in a production environment, it's recommended to transpile your migrations to JavaScript before running the application.","MIGRATION_MODULE_NOT_FOUND")}),await import('esbuild').catch(()=>{throw new u("MigrationUtils::importMigrationFile In order to use TypeScript migrations, you must have `esbuild` installed in your project. Please install it with `npm install esbuild --save-dev`, if you're in a production environment, it's recommended to transpile your migrations to JavaScript before running the application.","MIGRATION_MODULE_NOT_FOUND")}),await import('bundle-require').catch(()=>{throw new u("MigrationUtils::importMigrationFile In order to use TypeScript migrations, you must have `bundle-require` installed in your project. Please install it with `npm install bundle-require --save-dev`, if you're in a production environment, it's recommended to transpile your migrations to JavaScript before running the application.","MIGRATION_MODULE_NOT_FOUND")}),Il(i);try{return import(url.pathToFileURL(i).href)}catch{let o=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));try{let n=o(i);return {default:n.default||n,...n}}catch{throw new u(`MigrationUtils::importMigrationFile Failed to import migration file: ${i}. Both ESM and CommonJS imports failed.`,"MIGRATION_MODULE_NOT_FOUND")}}};async function pr(i,t){switch(i){case "mariadb":case "mysql":let e=t;return await e.query(Ee.migrationTableTemplateMysql()),(await e.query(Ee.selectAllFromMigrationsTemplate()))[0];case "postgres":case "cockroachdb":let o=t;return await o.query(Ee.migrationTableTemplatePg()),(await o.query(Ee.selectAllFromMigrationsTemplate())).rows;case "sqlite":return await Bl(Ee.migrationTableTemplateSQLite(),[],t),await Bl(Ee.selectAllFromMigrationsTemplate(),[],t)||[];default:throw new u("MigrationUtils::getMigrationTable Unsupported database type","DEVELOPMENT_ERROR")}}async function yr(i,t,e){let r=Fd(t),o=[];for(let n of r){let s=await kd(n,t),a=new s(i||M.DB_TYPE);a.migrationName=n,o.push(a);}return o}async function Qd(i,t){let e=await Kd(i);if(!e.default)throw new u("MigrationUtils::loadMigrationModule Migration module does not have a default export","MIGRATION_MODULE_NOT_FOUND");return e.default}async function kd(i,t=M.MIGRATION_PATH||"database/migrations",e){t=ut.join(t,i);let r=ut__default.default.resolve(process.cwd(),t),o=await Qd(r);if(!o)throw new u("MigrationUtils::findMigrationModule migrations module not found for migration: "+i,"MIGRATION_MODULE_NOT_FOUND");return o}function Fd(i){let t=process.cwd(),e=ut__default.default.resolve(i||M.MIGRATION_PATH||"database/migrations"),r=ut__default.default.resolve(t,e);try{let o=ml__default.default.readdirSync(r).filter(n=>{let s=ut__default.default.extname(n),a=ut__default.default.join(r,n);return ml__default.default.statSync(a).isFile()&&(s===".ts"||s===".js")});if(o.length)return o;throw new u("MigrationUtils::findMigrationNames No database migration files found on path: "+r,"MIGRATION_MODULE_NOT_FOUND")}catch{throw new u("MigrationUtils::findMigrationNames No database migration files found on path: "+r,"MIGRATION_MODULE_NOT_FOUND")}}async function Bl(i,t,e){return new Promise((r,o)=>{e.all(i,t,(n,s)=>{n&&o(n),r(s);});})}async function fs(i,t,e,r,o){let n=i.getDbType(),s=null;N.info("Rolling back migrations for database type: "+n);try{let a=await pr(n,i.getPool()),l=await yr(n,e,r),d=a.map(c=>c.name),m=l.filter(c=>d.includes(c.migrationName));if(m.length===0){N.info("No pending migrations.");return}if(t);let p=new _e(i);o&&(s=await i.startTransaction(),i=s.sql),await p.downMigrations(m),o&&await s?.commit();}catch(a){throw a}N.info("Migrations rolled back successfully");}async function hs(i,t,e,r,o){let n=i.getDbType(),s=null;N.info("Running migrations for database type: "+n);try{let a=await pr(n,i.getPool()),d=(await yr(n,e,r)).filter(p=>!a.map(c=>c.name).includes(p.migrationName));if(!d.length){N.info("No pending migrations.");return}if(t);let m=new _e(i);o&&(s=await i.startTransaction(),i=s.sql),await m.upMigrations(d),o&&await s?.commit();}catch(a){throw a}N.info("Migrations ran successfully");}var _e=class{constructor(t){this.migrationTable="migrations";this.sql=t||ne.getInstance();}async upMigrations(t){for(let e of t){N.info(`Running migration ${e.migrationName}`),await e.up();let r=e.schema.queryStatements;for(let o of r)o&&await this.sql.rawQuery(o);await this.addMigrationToMigrationTable(e),e.afterMigration&&await e.afterMigration(this.sql);}}async downMigrations(t){t=t.reverse();for(let e of t){N.info(`Rolling back migration ${e.migrationName}`),await e.down();let r=e.schema.queryStatements;for(let o of r)o&&await this.sql.rawQuery(o);await this.deleteMigrationFromMigrationTable(e),e.afterMigration&&await e.afterMigration(this.sql);}}async addMigrationToMigrationTable(t){let r=new Date().toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"");await this.sql.query(this.migrationTable).insert({name:t.migrationName,timestamp:r});}async deleteMigrationFromMigrationTable(t){await this.sql.query(this.migrationTable).where("name",t.migrationName).delete();}},gs=class{constructor(t=M.MIGRATION_PATH||"database/migrations",e){this.migrationPath=t,this.sqlDataSourceInput=e;}async up(){return this.migrate("up")}async down(){return this.migrate("down")}async migrate(t){M.MIGRATION_PATH=this.migrationPath;let e=this.sqlDataSourceInput instanceof ne?this.sqlDataSourceInput:await ne.connect({...this.sqlDataSourceInput});return t==="up"?hs(e,void 0,this.migrationPath):fs(e,void 0,this.migrationPath)}},Ld=(i,t)=>new gs(i,t);exports.AutogeneratedModel=cs;exports.Collection=Ue;exports.HysteriaError=u;exports.Migration=ps;exports.Model=Z;exports.ModelQueryBuilder=We;exports.MongoDataSource=dt;exports.TimestampedModel=lt;exports.UserMixin=Pe;exports.UuidModel=us;exports.belongsTo=Sl;exports.column=A;exports.createModelFactory=Dd;exports.defineMigrator=Ld;exports.generateOpenApiModel=hu;exports.generateOpenApiModelSchema=gu;exports.generateOpenApiModelWithMetadata=Cs;exports.getCollectionProperties=bs;exports.getIndexes=_l;exports.getModelColumns=ft;exports.getPrimaryKey=Rl;exports.getRelations=Wt;exports.getRelationsMetadata=Cl;exports.getUniques=Ol;exports.hasMany=Ml;exports.hasOne=Nl;exports.index=cR;exports.logger=N;exports.manyToMany=ql;exports.mongo=dt;exports.property=gr;exports.redis=ms;exports.sql=ne;exports.unique=mR;exports.view=pR;exports.withPerformance=B;//# sourceMappingURL=index.cjs.map
183
183
  //# sourceMappingURL=index.cjs.map