@bungres/kit 0.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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +2435 -0
  6. package/dist/commands/drop.d.ts +5 -0
  7. package/dist/commands/drop.d.ts.map +1 -0
  8. package/dist/commands/fresh.d.ts +3 -0
  9. package/dist/commands/fresh.d.ts.map +1 -0
  10. package/dist/commands/generate.d.ts +3 -0
  11. package/dist/commands/generate.d.ts.map +1 -0
  12. package/dist/commands/migrate.d.ts +3 -0
  13. package/dist/commands/migrate.d.ts.map +1 -0
  14. package/dist/commands/pull.d.ts +29 -0
  15. package/dist/commands/pull.d.ts.map +1 -0
  16. package/dist/commands/push.d.ts +5 -0
  17. package/dist/commands/push.d.ts.map +1 -0
  18. package/dist/commands/refresh.d.ts +3 -0
  19. package/dist/commands/refresh.d.ts.map +1 -0
  20. package/dist/commands/seed.d.ts +3 -0
  21. package/dist/commands/seed.d.ts.map +1 -0
  22. package/dist/commands/status.d.ts +3 -0
  23. package/dist/commands/status.d.ts.map +1 -0
  24. package/dist/commands/studio.d.ts +3 -0
  25. package/dist/commands/studio.d.ts.map +1 -0
  26. package/dist/commands/tusky.d.ts +3 -0
  27. package/dist/commands/tusky.d.ts.map +1 -0
  28. package/dist/config.d.ts +44 -0
  29. package/dist/config.d.ts.map +1 -0
  30. package/dist/differ.d.ts +11 -0
  31. package/dist/differ.d.ts.map +1 -0
  32. package/dist/ensure-db.d.ts +2 -0
  33. package/dist/ensure-db.d.ts.map +1 -0
  34. package/dist/index.d.ts +13 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +1720 -0
  37. package/dist/schema-loader.d.ts +9 -0
  38. package/dist/schema-loader.d.ts.map +1 -0
  39. package/dist/utils/colors.d.ts +2 -0
  40. package/dist/utils/colors.d.ts.map +1 -0
  41. package/package.json +43 -0
  42. package/src/cli.ts +162 -0
  43. package/src/commands/drop.ts +92 -0
  44. package/src/commands/fresh.ts +17 -0
  45. package/src/commands/generate.ts +151 -0
  46. package/src/commands/migrate.ts +84 -0
  47. package/src/commands/pull.ts +339 -0
  48. package/src/commands/push.ts +105 -0
  49. package/src/commands/refresh.ts +37 -0
  50. package/src/commands/seed.ts +41 -0
  51. package/src/commands/status.ts +64 -0
  52. package/src/commands/studio.ts +471 -0
  53. package/src/commands/tusky.ts +83 -0
  54. package/src/config.ts +102 -0
  55. package/src/differ.ts +236 -0
  56. package/src/ensure-db.ts +32 -0
  57. package/src/index.ts +21 -0
  58. package/src/schema-loader.ts +50 -0
  59. package/src/utils/colors.ts +4 -0
@@ -0,0 +1,5 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runDrop(config: ResolvedConfig, opts?: {
3
+ force?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=drop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop.d.ts","sourceRoot":"","sources":["../../src/commands/drop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AASnD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7B,OAAO,CAAC,IAAI,CAAC,CA8Ef"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runFresh(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=fresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fresh.d.ts","sourceRoot":"","sources":["../../src/commands/fresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQnD,wBAAsB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpE"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runGenerate(config: ResolvedConfig, name?: string): Promise<void>;
3
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAgBnD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAgGf"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runMigrate(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAiBnD,wBAAsB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiEtE"}
@@ -0,0 +1,29 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ interface PgIndex {
3
+ tablename: string;
4
+ indexname: string;
5
+ indexdef: string;
6
+ }
7
+ export declare function introspectDb(sql: any, // Bun.SQL
8
+ dbSchema: string): Promise<Map<string, TableInfo>>;
9
+ export declare function runPull(config: ResolvedConfig): Promise<void>;
10
+ export interface TableInfo {
11
+ tableName: string;
12
+ columns: Array<{
13
+ name: string;
14
+ dataType: string;
15
+ udtName: string;
16
+ isNullable: boolean;
17
+ columnDefault: string | null;
18
+ maxLength: number | null;
19
+ isPrimary: boolean;
20
+ isUnique: boolean;
21
+ foreignTable: string | undefined;
22
+ foreignColumn: string | undefined;
23
+ deleteRule: string | undefined;
24
+ updateRule: string | undefined;
25
+ }>;
26
+ indexes: PgIndex[];
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=pull.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA2BnD,UAAU,OAAO;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,GAAG,EAAE,UAAU;AACpB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAoDjC;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BnE;AAMD,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,OAAO,CAAC;QAClB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;QAClC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB"}
@@ -0,0 +1,5 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runPush(config: ResolvedConfig, opts?: {
3
+ force?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/commands/push.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUnD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7B,OAAO,CAAC,IAAI,CAAC,CAoFf"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runRefresh(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=refresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/commands/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQnD,wBAAsB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BtE"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runSeed(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/commands/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAOnD,wBAAsB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCnE"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runStatus(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AASnD,wBAAsB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDrE"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runStudio(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=studio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../src/commands/studio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AASnD,wBAAsB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAqGrE"}
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from "../config.js";
2
+ export declare function runTusky(config: ResolvedConfig): Promise<void>;
3
+ //# sourceMappingURL=tusky.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tusky.d.ts","sourceRoot":"","sources":["../../src/commands/tusky.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAOnD,wBAAsB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAyEpE"}
@@ -0,0 +1,44 @@
1
+ export interface BungresKitConfig {
2
+ /**
3
+ * Glob pattern(s) pointing to your schema file(s).
4
+ * e.g. "./src/db/schema.ts" or "./src/db/schema/index.ts"
5
+ */
6
+ schema: string | string[];
7
+ /**
8
+ * Path to the seed file to execute with `bungres seed`.
9
+ * e.g. "./src/db/seed.ts"
10
+ */
11
+ seed?: string;
12
+ /**
13
+ * Output directory for generated migration .sql files.
14
+ * Equivalent to drizzle's `out`. Default: "./migrations"
15
+ */
16
+ out?: string;
17
+ /**
18
+ * Postgres connection credentials.
19
+ * URL can also come from the DATABASE_URL environment variable.
20
+ */
21
+ dbCredentials?: {
22
+ url: string;
23
+ };
24
+ /**
25
+ * Postgres schema name to introspect with `bungres pull`.
26
+ * Default: "public"
27
+ */
28
+ dbSchema?: string;
29
+ /** Print every SQL statement executed. Default: false */
30
+ verbose?: boolean;
31
+ }
32
+ export interface ResolvedConfig {
33
+ schema: string | string[];
34
+ seed: string;
35
+ out: string;
36
+ dbUrl: string;
37
+ dbSchema: string;
38
+ /** @deprecated use out — kept internally for compat */
39
+ migrationsDir: string;
40
+ outDir: string;
41
+ verbose: boolean;
42
+ }
43
+ export declare function loadConfig(cwd?: string): Promise<ResolvedConfig>;
44
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,aAAa,CAAC,EAAE;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IAEF;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AASD,wBAAsB,UAAU,CAAC,GAAG,SAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuC7E"}
@@ -0,0 +1,11 @@
1
+ import type { TableConfig } from "@bungres/orm";
2
+ /** Snapshot stored on disk after each generate */
3
+ export type SchemaSnapshot = Record<string, TableConfig>;
4
+ export interface DiffResult {
5
+ statements: string[];
6
+ summary: string[];
7
+ warnings: string[];
8
+ }
9
+ export declare function diffSchemas(prev: SchemaSnapshot, next: SchemaSnapshot): DiffResult;
10
+ export declare function topoSortConfigs(tables: TableConfig[]): TableConfig[];
11
+ //# sourceMappingURL=differ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differ.d.ts","sourceRoot":"","sources":["../src/differ.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ9D,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEzD,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,cAAc,GACnB,UAAU,CAwIZ;AAMD,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAsBpE"}
@@ -0,0 +1,2 @@
1
+ export declare function ensureDatabase(dbUrl: string): Promise<void>;
2
+ //# sourceMappingURL=ensure-db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-db.d.ts","sourceRoot":"","sources":["../src/ensure-db.ts"],"names":[],"mappings":"AAAA,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BjE"}
@@ -0,0 +1,13 @@
1
+ export { loadConfig } from "./config.js";
2
+ export type { BungresKitConfig, ResolvedConfig } from "./config.js";
3
+ /** Identity helper for type-safe config — mirrors drizzle-kit's defineConfig */
4
+ export declare function defineConfig(config: import("./config.js").BungresKitConfig): import("./config.js").BungresKitConfig;
5
+ export { loadSchemas } from "./schema-loader.js";
6
+ export type { SchemaEntry } from "./schema-loader.js";
7
+ export { runPush } from "./commands/push.js";
8
+ export { runGenerate } from "./commands/generate.js";
9
+ export { runMigrate } from "./commands/migrate.js";
10
+ export { runPull } from "./commands/pull.js";
11
+ export { runStatus } from "./commands/status.js";
12
+ export { runDrop } from "./commands/drop.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEpE,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,aAAa,EAAE,gBAAgB,0CAE1E;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}