@izumisy/kyrage 0.4.0 → 0.5.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/dist/chunk-EY62Q3Z2.js +1 -0
- package/dist/index.d.ts +21 -58
- package/dist/index.js +1 -1
- package/dist/main.js +24 -4
- package/package.json +8 -4
- package/dist/chunk-TKOG352H.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=(c,a)=>(a=Symbol[c])?a:Symbol.for("Symbol."+c),l=c=>{throw TypeError(c)};var m=(c,a,d)=>{if(a!=null){typeof a!="object"&&typeof a!="function"&&l("Object expected");var e,f;d&&(e=a[k("asyncDispose")]),e===void 0&&(e=a[k("dispose")],d&&(f=e)),typeof e!="function"&&l("Object not disposable"),f&&(e=function(){try{f.call(this)}catch(g){return Promise.reject(g)}}),c.push([d,e,a])}else d&&c.push([d]);return a},n=(c,a,d)=>{var e=typeof SuppressedError=="function"?SuppressedError:function(b,j,h,i){return i=Error(h),i.name="SuppressedError",i.error=b,i.suppressed=j,i},f=b=>a=d?new e(b,a,"An error was suppressed during disposal"):(d=!0,b),g=b=>{for(;b=c.pop();)try{var j=b[1]&&b[1].call(b[2]);if(b[0])return Promise.resolve(j).then(g,h=>(f(h),g()))}catch(h){f(h)}if(d)throw a};return g()};export{m as a,n as b};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,76 +7,39 @@ declare const columnSchema: z.ZodObject<{
|
|
|
7
7
|
notNull: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
8
|
unique: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
9
9
|
defaultSql: z.ZodOptional<z.ZodString>;
|
|
10
|
-
checkSql: z.ZodOptional<z.ZodString>;
|
|
11
10
|
}, z.core.$strip>;
|
|
12
|
-
type
|
|
13
|
-
declare const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
connectionString: z.ZodString;
|
|
22
|
-
}, z.core.$strip>;
|
|
23
|
-
tables: z.ZodArray<z.ZodObject<{
|
|
24
|
-
tableName: z.ZodString;
|
|
25
|
-
columns: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
26
|
-
type: z.ZodString;
|
|
27
|
-
primaryKey: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
28
|
-
notNull: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
29
|
-
unique: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
30
|
-
defaultSql: z.ZodOptional<z.ZodString>;
|
|
31
|
-
checkSql: z.ZodOptional<z.ZodString>;
|
|
32
|
-
}, z.core.$strip>>;
|
|
33
|
-
}, z.core.$strip>>;
|
|
34
|
-
indexes: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
35
|
-
table: z.ZodString;
|
|
36
|
-
columns: z.ZodArray<z.ZodString>;
|
|
37
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
-
}, z.core.$strip>>>>;
|
|
11
|
+
type ColumnValue = z.infer<typeof columnSchema>;
|
|
12
|
+
declare const databaseSchema: z.ZodObject<{
|
|
13
|
+
dialect: z.ZodEnum<{
|
|
14
|
+
postgres: "postgres";
|
|
15
|
+
cockroachdb: "cockroachdb";
|
|
16
|
+
mysql: "mysql";
|
|
17
|
+
sqlite: "sqlite";
|
|
18
|
+
}>;
|
|
19
|
+
connectionString: z.ZodString;
|
|
39
20
|
}, z.core.$strip>;
|
|
40
|
-
type
|
|
21
|
+
type DatabaseValue = z.infer<typeof databaseSchema>;
|
|
41
22
|
|
|
42
|
-
type
|
|
43
|
-
declare const column: (type: ColumnDataType, options?: ColumnOptions) => {
|
|
23
|
+
declare const column: (type: ColumnDataType, options?: Partial<Omit<ColumnValue, "type">>) => {
|
|
44
24
|
type: ColumnDataType;
|
|
45
25
|
notNull: boolean | undefined;
|
|
46
26
|
primaryKey: boolean | undefined;
|
|
47
27
|
unique: boolean | undefined;
|
|
48
28
|
defaultSql: string | undefined;
|
|
49
|
-
checkSql: string | undefined;
|
|
50
29
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} & ColumnOptions>>(name: string, columns: T) => {
|
|
30
|
+
type DefinedColumn = ReturnType<typeof column>;
|
|
31
|
+
declare const defineTable: <T extends Record<string, DefinedColumn>>(name: string, columns: T) => {
|
|
54
32
|
tableName: string;
|
|
55
33
|
columns: T;
|
|
56
34
|
};
|
|
57
35
|
type DefinedTable = ReturnType<typeof defineTable>;
|
|
58
|
-
|
|
59
|
-
declare const defineConfig: (config:
|
|
60
|
-
database:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
tables:
|
|
65
|
-
tableName: string;
|
|
66
|
-
columns: Record<string, {
|
|
67
|
-
type: string;
|
|
68
|
-
primaryKey: boolean;
|
|
69
|
-
notNull: boolean;
|
|
70
|
-
unique: boolean;
|
|
71
|
-
defaultSql?: string | undefined;
|
|
72
|
-
checkSql?: string | undefined;
|
|
73
|
-
}>;
|
|
74
|
-
}[];
|
|
75
|
-
indexes?: Record<string, {
|
|
76
|
-
table: string;
|
|
77
|
-
columns: string[];
|
|
78
|
-
unique?: boolean | undefined;
|
|
79
|
-
}>[] | undefined;
|
|
36
|
+
type DefinedTables = Array<DefinedTable>;
|
|
37
|
+
declare const defineConfig: (config: {
|
|
38
|
+
database: DatabaseValue;
|
|
39
|
+
tables: DefinedTable[];
|
|
40
|
+
}) => {
|
|
41
|
+
database: DatabaseValue;
|
|
42
|
+
tables: DefinedTable[];
|
|
80
43
|
};
|
|
81
44
|
|
|
82
|
-
export { type DefinedTable, column, defineConfig, defineTable };
|
|
45
|
+
export { type DefinedTable, type DefinedTables, column, defineConfig, defineTable };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./chunk-EY62Q3Z2.js";var t=(a,e)=>({type:a,notNull:e?.notNull,primaryKey:e?.primaryKey,unique:e?.unique,defaultSql:e?.defaultSql}),l=(a,e)=>({tableName:a,columns:e}),n=a=>a;export{t as column,n as defineConfig,l as defineTable};
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import{a as y,b as h}from"./chunk-EY62Q3Z2.js";import{defineCommand as q,runMain as we}from"citty";import{Kysely as Y,MysqlDialect as G,PostgresDialect as W,SqliteDialect as H}from"kysely";import{Pool as I}from"pg";import{createPool as X}from"mysql2";import Z from"better-sqlite3";import{PostgresAdapter as V,PostgresDialect as J}from"kysely";var v=class extends V{async acquireMigrationLock(t,n){await t.selectFrom(n.lockTable).selectAll().forUpdate().execute()}},N=class extends J{createAdapter(){return new v}};import{DummyDriver as z}from"kysely";var D=class extends z{constructor(n){super();this.queries=n}async acquireConnection(){return new P(this.queries)}},P=class{constructor(t){this.queries=t}async executeQuery(t){let n=t.query.kind;if(n==="CreateTableNode"||n==="DropTableNode"||n==="AlterTableNode"){if(t.query.table.table.identifier.name.startsWith("kysely_migration"))return{rows:[]};this.queries.push(t)}return{rows:[]}}async*streamQuery(){}};var ee=e=>{switch(e.dialect){case"cockroachdb":return new N({pool:new I({connectionString:e.connectionString})});case"postgres":return new W({pool:new I({connectionString:e.connectionString})});case"mysql":return new G({pool:X(e.connectionString)});case"sqlite":return new H({database:new Z(e.connectionString)});default:throw new Error(`Unsupported dialect: ${e.dialect}`)}},S=e=>new E({databaseProps:e.database,options:e.options}),E=class{constructor(t){this.constructorProps=t;this.plannedQueries=[]}getDB(t){let n=ee(this.constructorProps.databaseProps),a=t?.plan===!0;return new Y({dialect:{createAdapter:()=>n.createAdapter(),createDriver:()=>a?new D(this.plannedQueries):n.createDriver(),createIntrospector:i=>n.createIntrospector(i),createQueryCompiler:()=>n.createQueryCompiler()}})}getPlannedQueries(){return this.plannedQueries}getDialect(){return this.constructorProps.databaseProps.dialect}};var O="0.5.0";import{z as c}from"zod";var ae=c.object({type:c.string(),primaryKey:c.boolean().optional().default(!1),notNull:c.boolean().optional().default(!1),unique:c.boolean().optional().default(!1),defaultSql:c.string().optional()}),oe=c.object({tableName:c.string(),columns:c.record(c.string(),ae)}),re=c.object({table:c.string(),columns:c.array(c.string()),unique:c.boolean().optional()}),ie=c.enum(["postgres","cockroachdb","mysql","sqlite"]),se=c.object({dialect:ie,connectionString:c.string()}),R=c.object({database:se,tables:c.array(oe),indexes:c.array(re).optional()}),j=c.object({id:c.string(),version:c.string(),diff:c.any()});import{Migrator as ge}from"kysely";import{isColumnDataType as le,sql as $}from"kysely";import{readdir as ce,readFile as me}from"fs/promises";import{join as pe}from"path";var w="migrations",M=async()=>{try{let t=(await ce(w)).filter(n=>n.endsWith(".json")).map(async n=>j.parse(JSON.parse(await me(pe(w,n),"utf-8"))));return await Promise.all(t)}catch(e){if(e instanceof Object&&"code"in e&&e.code==="ENOENT")return[];throw e}},Q=e=>({getMigrations:async()=>{let t=await M(),n={};return t.forEach(a=>{n[a.id]={up:async()=>{await ue(e.db,a.diff)}}}),n}});async function ue(e,t){for(let n of t.addedTables){let a=e.schema.createTable(n.table);for(let[i,s]of Object.entries(n.columns)){let l=s.type;k(l),a=a.addColumn(i,l,g=>{let o=g;return s.notNull&&(o=o.notNull()),s.primaryKey&&(o=o.primaryKey()),s.unique&&(o=o.unique()),s.defaultSql&&(o=o.defaultTo($.raw(s.defaultSql))),o})}await a.execute()}for(let n of t.removedTables)await e.schema.dropTable(n).execute();for(let n of t.changedTables){for(let a of n.addedColumns){let i=a.attributes.type;k(i),await e.schema.alterTable(n.table).addColumn(a.column,i,s=>{let l=s;return a.attributes.notNull&&(l=l.notNull()),a.attributes.primaryKey&&(l=l.primaryKey()),a.attributes.unique&&(l=l.unique()),a.attributes.defaultSql&&(l=l.defaultTo($.raw(a.attributes.defaultSql))),l}).execute()}for(let a of n.removedColumns)await e.schema.alterTable(n.table).dropColumn(a.column).execute();for(let a of n.changedColumns){if(a.before.type!==a.after.type){let i=a.after.type;k(i),await e.schema.alterTable(n.table).alterColumn(a.column,s=>s.setDataType(i)).execute()}a.after.notNull!==a.before.notNull&&(a.after.notNull?await e.schema.alterTable(n.table).alterColumn(a.column,i=>i.setNotNull()).execute():await e.schema.alterTable(n.table).alterColumn(a.column,i=>i.dropNotNull()).execute())}}}var k=e=>{if(!le(e))throw new Error(`Unsupported data type: ${e}`)};import{createConsola as de}from"consola";var d=de({stdout:process.stderr});var _=async e=>{var l=[];try{let t=y(l,e.client.getDB({plan:e.options.plan}),!0);let n=new ge({db:t,provider:Q({db:t,options:{plan:e.options.plan}})});let{results:a,error:i}=await n.migrateToLatest();let s=e.client.getPlannedQueries();if(s.length>0){s.forEach(r=>{console.log(r.sql)});return}a&&a.length>0?a.forEach(r=>{r.status==="Error"?d.error(`Migration failed: ${r.migrationName}`):r.status==="Success"&&d.success(`Migration applied: ${r.migrationName}`)}):d.info("No migrations to run");i&&(d.error(`Migration error: ${i}`),process.exit(1))}catch(g){var o=g,u=!0}finally{var f=h(l,o,u);f&&await f}};import{mkdir as ye,writeFile as he}from"fs/promises";function K(e){let{current:t,ideal:n}=e,a=t.map(o=>o.name),i=n.map(o=>o.name),s=n.filter(o=>!a.includes(o.name)).map(o=>({table:o.name,columns:o.columns})),l=t.filter(o=>!i.includes(o.name)).map(o=>o.name),g=t.reduce((o,u)=>{let f=n.find(m=>m.name===u.name);if(!f)return o;let r=u.columns,p=f.columns,b=Object.keys(r),T=Object.keys(p),x=T.filter(m=>!b.includes(m)).map(m=>({column:m,attributes:p[m]})),C=b.filter(m=>!T.includes(m)).map(m=>({column:m,attributes:r[m]})),A=b.filter(m=>T.includes(m)&&(r[m].type!==p[m].type||r[m].notNull!==p[m].notNull)).map(m=>({column:m,before:r[m],after:p[m]}));return(x.length>0||C.length>0||A.length>0)&&o.push({table:u.name,addedColumns:x,removedColumns:C,changedColumns:A}),o},[]);return{addedTables:s,removedTables:l,changedTables:g}}import{sql as fe}from"kysely";var B=e=>{let t=async()=>{var g=[];try{let i=e.client;let s=y(g,i.getDB(),!0);let{rows:l}=await fe`
|
|
2
|
+
SELECT
|
|
3
|
+
c.table_schema,
|
|
4
|
+
c.table_name,
|
|
5
|
+
c.column_name,
|
|
6
|
+
c.column_default,
|
|
7
|
+
c.character_maximum_length,
|
|
8
|
+
tc.constraint_name,
|
|
9
|
+
tc.constraint_type
|
|
10
|
+
FROM information_schema.columns c
|
|
11
|
+
JOIN information_schema.key_column_usage kcu
|
|
12
|
+
ON c.table_name = kcu.table_name
|
|
13
|
+
AND c.column_name = kcu.column_name
|
|
14
|
+
AND c.table_schema = kcu.table_schema
|
|
15
|
+
JOIN information_schema.table_constraints tc
|
|
16
|
+
ON kcu.constraint_name = tc.constraint_name
|
|
17
|
+
AND kcu.table_schema = tc.table_schema
|
|
18
|
+
AND tc.constraint_type IN ('UNIQUE', 'PRIMARY KEY')
|
|
19
|
+
WHERE c.table_schema = 'public'
|
|
20
|
+
ORDER BY c.table_name, c.ordinal_position;
|
|
21
|
+
`.$castTo().execute(s);return l.map(p=>({schema:p.table_schema,table:p.table_name,name:p.column_name,default:p.column_default,characterMaximumLength:p.character_maximum_length,constraint:{name:p.constraint_name,type:p.constraint_type}}))}catch(o){var u=o,f=!0}finally{var r=h(g,u,f);r&&await r}},n={bool:"boolean",int2:"smallint",int4:"integer",int8:"bigint"};return{introspect:t,convertTypeName:i=>n[i]??i}};var be=e=>{let t=e.getDialect();switch(t){case"postgres":case"cockroachdb":return B({client:e});default:throw new Error(`Unsupported dialect: ${t}`)}},F=e=>{let t=be(e);return{getTables:async()=>{var l=[];try{let a=y(l,e.getDB(),!0);let i=await a.introspection.getTables();let s=await t.introspect();return i.map(r=>{let p=Object.fromEntries(r.columns.map(b=>{let T=s.filter(C=>C.table===r.name&&C.name===b.name),x=T[0]||{};return[b.name,{schema:r.schema,table:r.name,name:b.name,dataType:t.convertTypeName(b.dataType),default:x.default??null,characterMaximumLength:x.characterMaximumLength??null,notNull:!b.isNullable,constraints:T.map(C=>C.constraint)}]}));return{schema:r.schema,name:r.name,columns:p}})}catch(g){var o=g,u=!0}finally{var f=h(l,o,u);f&&await f}}}};var L=async e=>{var s=[];try{let t=y(s,e.client.getDB(),!0);let n=e.config;if(!e.options.ignorePending){let f=await Ce(t);if(f.length>0){d.warn([`There are pending migrations: ${f.map(r=>r.id).join(", ")}`,"Please apply them first before generating a new migration.","Otherwise, use --ignore-pending to skip this check."].join(`
|
|
22
|
+
`));return}}let a=await Te({client:e.client,config:n});if(!a){d.info("No changes detected, no migration needed.");return}xe(a.diff);let i=`${w}/${a.id}.json`;await ye(w,{recursive:!0});await he(i,JSON.stringify(a,null,2));d.success(`Migration file generated: ${i}`);e.options.apply&&await _({client:e.client,options:{plan:e.options.plan}})}catch(l){var g=l,o=!0}finally{var u=h(s,g,o);u&&await u}},Ce=async e=>{let t=await e.selectFrom("kysely_migration").select(["name","timestamp"]).$narrowType().execute().catch(()=>[]);return t.length===0?[]:(await M()).filter(i=>!t.some(s=>s.name===i.id))},Te=async e=>{let{client:t,config:n}=e,s=(await F(t).getTables()).map(u=>({name:u.name,columns:Object.fromEntries(Object.entries(u.columns).map(([f,r])=>[f,{type:r.dataType,notNull:r.notNull,primaryKey:!!r.constraints.find(p=>p.type==="PRIMARY KEY"),unique:!!r.constraints.find(p=>p.type==="UNIQUE"),defaultSql:r.default??void 0}]))})),l=n.tables.map(u=>({name:u.tableName,columns:Object.fromEntries(Object.entries(u.columns).map(([f,r])=>[f,{...r,notNull:r.primaryKey||r.notNull}]))})),g=K({current:s,ideal:l});return g.addedTables.length===0&&g.removedTables.length===0&&g.changedTables.length===0?null:{version:"1",id:Date.now()+"",diff:g}},xe=e=>{e.addedTables.length>0&&e.addedTables.forEach(t=>{d.log(`-- create_table: ${t.table}`),Object.entries(t.columns).forEach(([n,a])=>{d.log(` -> column: ${n} (${JSON.stringify(a)})`)})}),e.removedTables.length>0&&e.removedTables.forEach(t=>{d.log(`-- remove_table: ${t}`)}),e.changedTables.length>0&&e.changedTables.forEach(t=>{t.addedColumns.forEach(n=>{d.log([`-- add_column: ${t.table}.${n.column}`,` -> to: ${JSON.stringify(n.attributes)}`].join(`
|
|
23
|
+
`))}),t.removedColumns.forEach(n=>{d.log(`-- remove_column: ${t.table}.${n.column})`)}),t.changedColumns.forEach(n=>{d.log([`-- change_column: ${t.table}.${n.column}`,` -> from: ${JSON.stringify(n.before)}`,` -> to: ${JSON.stringify(n.after)}`].join(`
|
|
24
|
+
`))})})};import{loadConfig as Ne}from"c12";var U=async()=>{let e=await Ne({name:"kyrage"});return R.parse(e.config)},De=q({meta:{name:"generate",description:"Generate migration files based on the current schema"},args:{apply:{type:"boolean",description:"Apply the migration after generating it",default:!1},plan:{type:"boolean",description:"Plan the migration without applying it (only for --apply)",default:!1},"ignore-pending":{type:"boolean",description:"Ignore pending migrations and generate a new one",default:!1}},run:async e=>{try{let t=await U(),n=S({database:t.database});await L({client:n,config:t,options:{ignorePending:e.args["ignore-pending"],apply:e.args.apply,plan:e.args.plan}})}catch(t){d.error(t),process.exit(1)}}}),_e=q({meta:{name:"apply",description:"Run migrations to sync database schema"},args:{plan:{name:"plan",type:"boolean",description:"Plan the migration without applying it",default:!1}},run:async e=>{try{let t=await U(),n=S({database:t.database});await _({client:n,options:{plan:e.args.plan}})}catch(t){d.error(t),process.exit(1)}}}),ve=q({meta:{name:"kyrage",version:O,description:"Kysely migration CLI with declarative schema"},subCommands:{apply:_e,generate:De}});we(ve);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@izumisy/kyrage",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.5.0",
|
|
6
6
|
"description": "A minimal, schema-based declarative migration tool for Node.js ecosystem",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
@@ -21,18 +21,22 @@
|
|
|
21
21
|
"c12": "^3.2.0",
|
|
22
22
|
"citty": "^0.1.6",
|
|
23
23
|
"consola": "^3.4.2",
|
|
24
|
-
"kysely": "^0.28.
|
|
24
|
+
"kysely": "^0.28.5",
|
|
25
25
|
"kysely-codegen": "^0.18.5",
|
|
26
26
|
"mysql2": "^3.14.3",
|
|
27
27
|
"pg": "^8.16.3",
|
|
28
|
-
"zod": "^4.0.
|
|
28
|
+
"zod": "^4.0.17"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@swc/core": "^1.13.3",
|
|
32
|
+
"@testcontainers/cockroachdb": "^11.5.1",
|
|
33
|
+
"@testcontainers/postgresql": "^11.5.1",
|
|
32
34
|
"@types/better-sqlite3": "^7.6.13",
|
|
33
|
-
"@types/node": "^24.2.
|
|
35
|
+
"@types/node": "^24.2.1",
|
|
34
36
|
"@types/pg": "^8.15.5",
|
|
37
|
+
"memfs": "^4.36.0",
|
|
35
38
|
"prettier": "^3.6.2",
|
|
39
|
+
"testcontainers": "^11.5.1",
|
|
36
40
|
"tsup": "^8.5.0",
|
|
37
41
|
"typescript": "^5.9.2",
|
|
38
42
|
"vitest": "^3.2.4"
|
package/dist/chunk-TKOG352H.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),g=n=>{throw TypeError(n)};var x=(n,e,a)=>{if(e!=null){typeof e!="object"&&typeof e!="function"&&g("Object expected");var i,r;a&&(i=e[m("asyncDispose")]),i===void 0&&(i=e[m("dispose")],a&&(r=i)),typeof i!="function"&&g("Object not disposable"),r&&(i=function(){try{r.call(this)}catch(c){return Promise.reject(c)}}),n.push([a,i,e])}else a&&n.push([a]);return e},C=(n,e,a)=>{var i=typeof SuppressedError=="function"?SuppressedError:function(t,f,l,s){return s=Error(l),s.name="SuppressedError",s.error=t,s.suppressed=f,s},r=t=>e=a?new i(t,e,"An error was suppressed during disposal"):(a=!0,t),c=t=>{for(;t=n.pop();)try{var f=t[1]&&t[1].call(t[2]);if(t[0])return Promise.resolve(f).then(c,l=>(r(l),c()))}catch(l){r(l)}if(a)throw e};return c()};import{loadConfig as h}from"c12";import{z as o}from"zod";var u=o.object({type:o.string(),primaryKey:o.boolean().optional().default(!1),notNull:o.boolean().optional().default(!1),unique:o.boolean().optional().default(!1),defaultSql:o.string().optional(),checkSql:o.string().optional()}),d=o.object({tableName:o.string(),columns:o.record(o.string(),u)}),b=o.record(o.string(),o.object({table:o.string(),columns:o.array(o.string()),unique:o.boolean().optional()})),y=o.enum(["postgres","cockroachdb","mysql","sqlite"]),S=o.object({dialect:y,connectionString:o.string()}),p=o.object({database:S,tables:o.array(d),indexes:o.array(b).optional()}),z=o.object({id:o.string(),version:o.string(),diff:o.any()});var N=async()=>{let n=await h({name:"kyrage"});return p.parse(n.config)},v=n=>n;export{x as a,C as b,z as c,N as d,v as e};
|