@danielfgray/pg-sourcerer 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 (145) hide show
  1. package/dist/cli.d.ts +3 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +104 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/config.d.ts +133 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +47 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/errors.d.ts +129 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +41 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/generate.d.ts +75 -0
  14. package/dist/generate.d.ts.map +1 -0
  15. package/dist/generate.js +183 -0
  16. package/dist/generate.js.map +1 -0
  17. package/dist/index.d.ts +35 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +62 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/init.d.ts +4 -0
  22. package/dist/init.d.ts.map +1 -0
  23. package/dist/init.js +229 -0
  24. package/dist/init.js.map +1 -0
  25. package/dist/ir/index.d.ts +7 -0
  26. package/dist/ir/index.d.ts.map +1 -0
  27. package/dist/ir/index.js +7 -0
  28. package/dist/ir/index.js.map +1 -0
  29. package/dist/ir/relation-graph.d.ts +113 -0
  30. package/dist/ir/relation-graph.d.ts.map +1 -0
  31. package/dist/ir/relation-graph.js +232 -0
  32. package/dist/ir/relation-graph.js.map +1 -0
  33. package/dist/ir/semantic-ir.d.ts +448 -0
  34. package/dist/ir/semantic-ir.d.ts.map +1 -0
  35. package/dist/ir/semantic-ir.js +138 -0
  36. package/dist/ir/semantic-ir.js.map +1 -0
  37. package/dist/ir/smart-tags.d.ts +24 -0
  38. package/dist/ir/smart-tags.d.ts.map +1 -0
  39. package/dist/ir/smart-tags.js +30 -0
  40. package/dist/ir/smart-tags.js.map +1 -0
  41. package/dist/lib/conjure.d.ts +431 -0
  42. package/dist/lib/conjure.d.ts.map +1 -0
  43. package/dist/lib/conjure.js +697 -0
  44. package/dist/lib/conjure.js.map +1 -0
  45. package/dist/lib/field-utils.d.ts +61 -0
  46. package/dist/lib/field-utils.d.ts.map +1 -0
  47. package/dist/lib/field-utils.js +132 -0
  48. package/dist/lib/field-utils.js.map +1 -0
  49. package/dist/lib/hex.d.ts +117 -0
  50. package/dist/lib/hex.d.ts.map +1 -0
  51. package/dist/lib/hex.js +185 -0
  52. package/dist/lib/hex.js.map +1 -0
  53. package/dist/plugins/arktype.d.ts +11 -0
  54. package/dist/plugins/arktype.d.ts.map +1 -0
  55. package/dist/plugins/arktype.js +207 -0
  56. package/dist/plugins/arktype.js.map +1 -0
  57. package/dist/plugins/effect-model.d.ts +10 -0
  58. package/dist/plugins/effect-model.d.ts.map +1 -0
  59. package/dist/plugins/effect-model.js +261 -0
  60. package/dist/plugins/effect-model.js.map +1 -0
  61. package/dist/plugins/kysely-queries.d.ts +7 -0
  62. package/dist/plugins/kysely-queries.d.ts.map +1 -0
  63. package/dist/plugins/kysely-queries.js +380 -0
  64. package/dist/plugins/kysely-queries.js.map +1 -0
  65. package/dist/plugins/sql-queries.d.ts +6 -0
  66. package/dist/plugins/sql-queries.d.ts.map +1 -0
  67. package/dist/plugins/sql-queries.js +249 -0
  68. package/dist/plugins/sql-queries.js.map +1 -0
  69. package/dist/plugins/types.d.ts +18 -0
  70. package/dist/plugins/types.d.ts.map +1 -0
  71. package/dist/plugins/types.js +263 -0
  72. package/dist/plugins/types.js.map +1 -0
  73. package/dist/plugins/zod.d.ts +11 -0
  74. package/dist/plugins/zod.d.ts.map +1 -0
  75. package/dist/plugins/zod.js +180 -0
  76. package/dist/plugins/zod.js.map +1 -0
  77. package/dist/services/artifact-store.d.ts +55 -0
  78. package/dist/services/artifact-store.d.ts.map +1 -0
  79. package/dist/services/artifact-store.js +51 -0
  80. package/dist/services/artifact-store.js.map +1 -0
  81. package/dist/services/config-loader.d.ts +45 -0
  82. package/dist/services/config-loader.d.ts.map +1 -0
  83. package/dist/services/config-loader.js +113 -0
  84. package/dist/services/config-loader.js.map +1 -0
  85. package/dist/services/emissions.d.ts +89 -0
  86. package/dist/services/emissions.d.ts.map +1 -0
  87. package/dist/services/emissions.js +194 -0
  88. package/dist/services/emissions.js.map +1 -0
  89. package/dist/services/file-builder.d.ts +81 -0
  90. package/dist/services/file-builder.d.ts.map +1 -0
  91. package/dist/services/file-builder.js +112 -0
  92. package/dist/services/file-builder.js.map +1 -0
  93. package/dist/services/file-writer.d.ts +57 -0
  94. package/dist/services/file-writer.d.ts.map +1 -0
  95. package/dist/services/file-writer.js +76 -0
  96. package/dist/services/file-writer.js.map +1 -0
  97. package/dist/services/inflection.d.ts +227 -0
  98. package/dist/services/inflection.d.ts.map +1 -0
  99. package/dist/services/inflection.js +350 -0
  100. package/dist/services/inflection.js.map +1 -0
  101. package/dist/services/introspection.d.ts +46 -0
  102. package/dist/services/introspection.d.ts.map +1 -0
  103. package/dist/services/introspection.js +99 -0
  104. package/dist/services/introspection.js.map +1 -0
  105. package/dist/services/ir-builder.d.ts +46 -0
  106. package/dist/services/ir-builder.d.ts.map +1 -0
  107. package/dist/services/ir-builder.js +923 -0
  108. package/dist/services/ir-builder.js.map +1 -0
  109. package/dist/services/ir.d.ts +28 -0
  110. package/dist/services/ir.d.ts.map +1 -0
  111. package/dist/services/ir.js +25 -0
  112. package/dist/services/ir.js.map +1 -0
  113. package/dist/services/pg-types.d.ts +197 -0
  114. package/dist/services/pg-types.d.ts.map +1 -0
  115. package/dist/services/pg-types.js +274 -0
  116. package/dist/services/pg-types.js.map +1 -0
  117. package/dist/services/plugin-meta.d.ts +33 -0
  118. package/dist/services/plugin-meta.d.ts.map +1 -0
  119. package/dist/services/plugin-meta.js +24 -0
  120. package/dist/services/plugin-meta.js.map +1 -0
  121. package/dist/services/plugin-runner.d.ts +52 -0
  122. package/dist/services/plugin-runner.d.ts.map +1 -0
  123. package/dist/services/plugin-runner.js +182 -0
  124. package/dist/services/plugin-runner.js.map +1 -0
  125. package/dist/services/plugin.d.ts +286 -0
  126. package/dist/services/plugin.d.ts.map +1 -0
  127. package/dist/services/plugin.js +132 -0
  128. package/dist/services/plugin.js.map +1 -0
  129. package/dist/services/smart-tags-parser.d.ts +37 -0
  130. package/dist/services/smart-tags-parser.d.ts.map +1 -0
  131. package/dist/services/smart-tags-parser.js +79 -0
  132. package/dist/services/smart-tags-parser.js.map +1 -0
  133. package/dist/services/symbols.d.ts +85 -0
  134. package/dist/services/symbols.d.ts.map +1 -0
  135. package/dist/services/symbols.js +128 -0
  136. package/dist/services/symbols.js.map +1 -0
  137. package/dist/services/type-hints.d.ts +62 -0
  138. package/dist/services/type-hints.d.ts.map +1 -0
  139. package/dist/services/type-hints.js +117 -0
  140. package/dist/services/type-hints.js.map +1 -0
  141. package/dist/testing.d.ts +77 -0
  142. package/dist/testing.d.ts.map +1 -0
  143. package/dist/testing.js +84 -0
  144. package/dist/testing.js.map +1 -0
  145. package/package.json +74 -0
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * pg-sourcerer CLI
4
+ *
5
+ * Command-line interface for code generation from PostgreSQL schema.
6
+ *
7
+ * Log verbosity is controlled via the built-in --log-level flag:
8
+ * --log-level debug Show detailed output (table names, file paths)
9
+ * --log-level info Default - show progress messages
10
+ * --log-level none Suppress all output except errors
11
+ */
12
+ import { Command, Options } from "@effect/cli";
13
+ import { NodeContext, NodeRuntime } from "@effect/platform-node";
14
+ import { Console, Effect } from "effect";
15
+ import { runGenerate } from "./generate.js";
16
+ import { runInit } from "./init.js";
17
+ // ============================================================================
18
+ // Options
19
+ // ============================================================================
20
+ const configPath = Options.file("config").pipe(Options.withAlias("c"), Options.withDescription("Path to config file"), Options.optional);
21
+ const outputDir = Options.directory("output").pipe(Options.withAlias("o"), Options.withDescription("Override output directory"), Options.optional);
22
+ const dryRun = Options.boolean("dry-run").pipe(Options.withAlias("n"), Options.withDescription("Show what would be generated without writing files"), Options.withDefault(false));
23
+ // ============================================================================
24
+ // Generate Command
25
+ // ============================================================================
26
+ const generateCommand = Command.make("generate", { configPath, outputDir, dryRun }, args => {
27
+ // Build options object, only including defined values
28
+ const opts = {
29
+ dryRun: args.dryRun,
30
+ };
31
+ if (args.configPath._tag === "Some") {
32
+ opts.configPath = args.configPath.value;
33
+ }
34
+ if (args.outputDir._tag === "Some") {
35
+ opts.outputDir = args.outputDir.value;
36
+ }
37
+ const logSuccess = (result) => {
38
+ const written = result.writeResults.filter(r => r.written).length;
39
+ const total = result.writeResults.length;
40
+ const suffix = args.dryRun ? " (dry run)" : "";
41
+ return Console.log(`\n✓ Generated ${args.dryRun ? total : written} files${suffix}`);
42
+ };
43
+ return Effect.gen(function* () {
44
+ const result = yield* runGenerate(opts);
45
+ yield* logSuccess(result);
46
+ }).pipe(
47
+ // Handle ConfigNotFound specially - offer to run init
48
+ Effect.catchTag("ConfigNotFound", error => Effect.gen(function* () {
49
+ yield* Console.error(`\n✗ No config file found`);
50
+ yield* Console.error(` Searched: ${error.searchPaths.join(", ")}`);
51
+ // // Ask if user wants to create config - if they quit (Ctrl+C), just fail
52
+ // const shouldInit = yield* Prompt.confirm({
53
+ // message: "Would you like to create one now?",
54
+ // initial: true,
55
+ // }).pipe(Effect.catchTag("QuitException", () => Effect.succeed(false)))
56
+ //
57
+ // if (!shouldInit) {
58
+ // yield* Console.log("\nRun 'pgsourcerer init' to create a config file.")
59
+ // return yield* Effect.fail(error)
60
+ // }
61
+ // Run init, catching any errors (user quit, validation, etc.)
62
+ const initResult = yield* runInit.pipe(Effect.map(() => true), Effect.catchAll(() => Effect.succeed(false)));
63
+ if (!initResult) {
64
+ return yield* Effect.fail(error);
65
+ }
66
+ })),
67
+ // Handle other errors
68
+ Effect.catchAll((error) => Effect.gen(function* () {
69
+ yield* Console.error(`\n✗ Error: ${error._tag}`);
70
+ yield* Console.error(` ${error.message}`);
71
+ if (error._tag === "ConfigInvalid") {
72
+ for (const e of error.errors) {
73
+ yield* Console.error(` - ${e}`);
74
+ }
75
+ }
76
+ else if (error._tag === "PluginConfigInvalid") {
77
+ for (const e of error.errors) {
78
+ yield* Console.error(` - ${e}`);
79
+ }
80
+ }
81
+ else if (error._tag === "CapabilityCycle") {
82
+ yield* Console.error(` Cycle: ${error.cycle.join(" → ")}`);
83
+ }
84
+ yield* Effect.fail(error);
85
+ })));
86
+ });
87
+ // ============================================================================
88
+ // Init Command
89
+ // ============================================================================
90
+ const initCommand = Command.make("init", {}, () => runInit);
91
+ // ============================================================================
92
+ // Root Command
93
+ // ============================================================================
94
+ const rootCommand = Command.make("pgsourcerer", {}, () => Console.log("pg-sourcerer - Generate TypeScript from PostgreSQL\n\nRun 'pgsourcerer --help' for usage.")).pipe(Command.withSubcommands([generateCommand, initCommand]));
95
+ // ============================================================================
96
+ // CLI App
97
+ // ============================================================================
98
+ const cli = Command.run(rootCommand, {
99
+ name: "pgsourcerer",
100
+ version: "0.0.1",
101
+ });
102
+ // Run with Node.js platform
103
+ cli(process.argv).pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);
104
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAU,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,WAAW,EAAsB,MAAM,eAAe,CAAC;AACh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9D,CAAC;QAED,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAC,CACH,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5D,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE,CACvD,OAAO,CAAC,GAAG,CACT,2FAA2F,CAC5F,CACF,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AAEhE,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;IACnC,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,4BAA4B;AAC5B,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Configuration schema for pg-sourcerer
3
+ */
4
+ import { Schema as S } from "effect";
5
+ import type { InflectionConfig } from "./services/inflection.js";
6
+ /**
7
+ * Type hint match criteria
8
+ */
9
+ export declare const TypeHintMatch: S.Struct<{
10
+ schema: S.optional<typeof S.String>;
11
+ table: S.optional<typeof S.String>;
12
+ column: S.optional<typeof S.String>;
13
+ pgType: S.optional<typeof S.String>;
14
+ }>;
15
+ export type TypeHintMatch = S.Schema.Type<typeof TypeHintMatch>;
16
+ /**
17
+ * Type hint - user-configured type override
18
+ */
19
+ export declare const TypeHint: S.Struct<{
20
+ match: S.Struct<{
21
+ schema: S.optional<typeof S.String>;
22
+ table: S.optional<typeof S.String>;
23
+ column: S.optional<typeof S.String>;
24
+ pgType: S.optional<typeof S.String>;
25
+ }>;
26
+ hints: S.Record$<typeof S.String, typeof S.Unknown>;
27
+ }>;
28
+ export type TypeHint = S.Schema.Type<typeof TypeHint>;
29
+ /**
30
+ * Main configuration schema
31
+ *
32
+ * Note: `inflection` and `plugins` are typed as S.Any in the schema since
33
+ * they contain complex types that can't be fully validated at runtime.
34
+ * Use `ConfigInput` for typed user-facing config and `ResolvedConfig` for
35
+ * the fully resolved configuration.
36
+ */
37
+ export declare const Config: S.Struct<{
38
+ /** Database connection string */
39
+ connectionString: typeof S.String;
40
+ /** PostgreSQL role to assume during introspection (for RLS-aware generation) */
41
+ role: S.optional<typeof S.String>;
42
+ /** PostgreSQL schemas to introspect */
43
+ schemas: S.optionalWith<S.Array$<typeof S.String>, {
44
+ default: () => string[];
45
+ }>;
46
+ /** Output directory root */
47
+ outputDir: S.optionalWith<typeof S.String, {
48
+ default: () => string;
49
+ }>;
50
+ /** Type hints for custom type mapping */
51
+ typeHints: S.optionalWith<S.Array$<S.Struct<{
52
+ match: S.Struct<{
53
+ schema: S.optional<typeof S.String>;
54
+ table: S.optional<typeof S.String>;
55
+ column: S.optional<typeof S.String>;
56
+ pgType: S.optional<typeof S.String>;
57
+ }>;
58
+ hints: S.Record$<typeof S.String, typeof S.Unknown>;
59
+ }>>, {
60
+ default: () => never[];
61
+ }>;
62
+ /** Inflection configuration (validated as Any, properly typed in ConfigInput) */
63
+ inflection: S.optional<typeof S.Any>;
64
+ /** Plugins to run (validated individually per plugin) */
65
+ plugins: S.Array$<typeof S.Any>;
66
+ /** Formatter callback to transform generated code before writing (validated as Any, properly typed in ConfigInput) */
67
+ formatter: S.optional<typeof S.String>;
68
+ }>;
69
+ export type Config = S.Schema.Type<typeof Config>;
70
+ /**
71
+ * User-facing configuration input type.
72
+ *
73
+ * This provides proper TypeScript types for `inflection` and `plugins`
74
+ * which are stored as `S.Any` in the schema for runtime flexibility.
75
+ * Use this type for `defineConfig()` to give users proper autocomplete.
76
+ */
77
+ export interface ConfigInput {
78
+ /** Database connection string */
79
+ readonly connectionString: string;
80
+ /** PostgreSQL role to assume during introspection (for RLS-aware generation) */
81
+ readonly role?: string;
82
+ /** PostgreSQL schemas to introspect (default: ["public"]) */
83
+ readonly schemas?: readonly string[];
84
+ /** Output directory root (default: "src/generated") */
85
+ readonly outputDir?: string;
86
+ /** Type hints for custom type mapping */
87
+ readonly typeHints?: readonly TypeHint[];
88
+ /**
89
+ * Inflection configuration for customizing naming conventions.
90
+ * Each property is a function that transforms a name.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * import { inflect } from "pg-sourcerer"
95
+ *
96
+ * inflection: {
97
+ * entityName: (name) => inflect.pascalCase(inflect.singularize(name)), // users → User
98
+ * fieldName: inflect.camelCase, // created_at → createdAt
99
+ * enumName: inflect.pascalCase, // user_status → UserStatus
100
+ * }
101
+ * ```
102
+ */
103
+ readonly inflection?: InflectionConfig;
104
+ /** Plugins to run */
105
+ readonly plugins: readonly unknown[];
106
+ /**
107
+ * Formatter command to run on generated files after writing.
108
+ * The command will be run with the output directory as the argument.
109
+ * Errors will fail generation.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * formatter: "prettier --write"
114
+ * // or
115
+ * formatter: "biome format --write"
116
+ * ```
117
+ */
118
+ readonly formatter?: string;
119
+ }
120
+ /**
121
+ * Resolved configuration with all defaults applied
122
+ */
123
+ export interface ResolvedConfig {
124
+ readonly connectionString: string;
125
+ readonly role?: string;
126
+ readonly schemas: readonly string[];
127
+ readonly outputDir: string;
128
+ readonly typeHints: readonly TypeHint[];
129
+ readonly inflection?: InflectionConfig;
130
+ readonly plugins: readonly unknown[];
131
+ readonly formatter?: string;
132
+ }
133
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+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,EAAE,gBAAgB,CAAA;IAEtC,qBAAqB;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,CAAA;IAEpC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAA;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,CAAA;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B"}
package/dist/config.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Configuration schema for pg-sourcerer
3
+ */
4
+ import { Schema as S } from "effect";
5
+ /**
6
+ * Type hint match criteria
7
+ */
8
+ export const TypeHintMatch = S.Struct({
9
+ schema: S.optional(S.String),
10
+ table: S.optional(S.String),
11
+ column: S.optional(S.String),
12
+ pgType: S.optional(S.String),
13
+ });
14
+ /**
15
+ * Type hint - user-configured type override
16
+ */
17
+ export const TypeHint = S.Struct({
18
+ match: TypeHintMatch,
19
+ hints: S.Record({ key: S.String, value: S.Unknown }),
20
+ });
21
+ /**
22
+ * Main configuration schema
23
+ *
24
+ * Note: `inflection` and `plugins` are typed as S.Any in the schema since
25
+ * they contain complex types that can't be fully validated at runtime.
26
+ * Use `ConfigInput` for typed user-facing config and `ResolvedConfig` for
27
+ * the fully resolved configuration.
28
+ */
29
+ export const Config = S.Struct({
30
+ /** Database connection string */
31
+ connectionString: S.String,
32
+ /** PostgreSQL role to assume during introspection (for RLS-aware generation) */
33
+ role: S.optional(S.String),
34
+ /** PostgreSQL schemas to introspect */
35
+ schemas: S.optionalWith(S.Array(S.String), { default: () => ["public"] }),
36
+ /** Output directory root */
37
+ outputDir: S.optionalWith(S.String, { default: () => "src/generated" }),
38
+ /** Type hints for custom type mapping */
39
+ typeHints: S.optionalWith(S.Array(TypeHint), { default: () => [] }),
40
+ /** Inflection configuration (validated as Any, properly typed in ConfigInput) */
41
+ inflection: S.optional(S.Any),
42
+ /** Plugins to run (validated individually per plugin) */
43
+ plugins: S.Array(S.Any),
44
+ /** Formatter callback to transform generated code before writing (validated as Any, properly typed in ConfigInput) */
45
+ formatter: S.optional(S.String),
46
+ });
47
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAGpC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;CAC7B,CAAC,CAAA;AAGF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;CACrD,CAAC,CAAA;AAGF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,iCAAiC;IACjC,gBAAgB,EAAE,CAAC,CAAC,MAAM;IAE1B,gFAAgF;IAChF,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAE1B,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IAEzE,4BAA4B;IAC5B,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC;IAEvE,yCAAyC;IACzC,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAEnE,iFAAiF;IACjF,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;IAE7B,yDAAyD;IACzD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAEvB,sHAAsH;IACtH,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;CAChC,CAAC,CAAA"}
@@ -0,0 +1,129 @@
1
+ interface ErrorBase {
2
+ readonly message: string;
3
+ }
4
+ declare const ConfigNotFound_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
5
+ readonly _tag: "ConfigNotFound";
6
+ } & Readonly<A>;
7
+ export declare class ConfigNotFound extends ConfigNotFound_base<ErrorBase & {
8
+ readonly searchPaths: readonly string[];
9
+ }> {
10
+ }
11
+ declare const ConfigInvalid_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
12
+ readonly _tag: "ConfigInvalid";
13
+ } & Readonly<A>;
14
+ export declare class ConfigInvalid extends ConfigInvalid_base<ErrorBase & {
15
+ readonly path: string;
16
+ readonly errors: readonly string[];
17
+ }> {
18
+ }
19
+ declare const ConnectionFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
20
+ readonly _tag: "ConnectionFailed";
21
+ } & Readonly<A>;
22
+ export declare class ConnectionFailed extends ConnectionFailed_base<ErrorBase & {
23
+ readonly connectionString: string;
24
+ readonly cause: unknown;
25
+ }> {
26
+ }
27
+ declare const IntrospectionFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
28
+ readonly _tag: "IntrospectionFailed";
29
+ } & Readonly<A>;
30
+ export declare class IntrospectionFailed extends IntrospectionFailed_base<ErrorBase & {
31
+ readonly schema: string;
32
+ readonly cause: unknown;
33
+ }> {
34
+ }
35
+ declare const TagParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
36
+ readonly _tag: "TagParseError";
37
+ } & Readonly<A>;
38
+ export declare class TagParseError extends TagParseError_base<ErrorBase & {
39
+ readonly objectType: "table" | "column" | "constraint" | "type";
40
+ readonly objectName: string;
41
+ readonly comment: string;
42
+ readonly cause: unknown;
43
+ }> {
44
+ }
45
+ declare const DuplicatePlugin_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
46
+ readonly _tag: "DuplicatePlugin";
47
+ } & Readonly<A>;
48
+ export declare class DuplicatePlugin extends DuplicatePlugin_base<ErrorBase & {
49
+ readonly plugin: string;
50
+ }> {
51
+ }
52
+ declare const CapabilityNotSatisfied_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
53
+ readonly _tag: "CapabilityNotSatisfied";
54
+ } & Readonly<A>;
55
+ export declare class CapabilityNotSatisfied extends CapabilityNotSatisfied_base<ErrorBase & {
56
+ readonly required: string;
57
+ readonly requiredBy: string;
58
+ }> {
59
+ }
60
+ declare const CapabilityConflict_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
61
+ readonly _tag: "CapabilityConflict";
62
+ } & Readonly<A>;
63
+ export declare class CapabilityConflict extends CapabilityConflict_base<ErrorBase & {
64
+ readonly capability: string;
65
+ readonly providers: readonly string[];
66
+ }> {
67
+ }
68
+ declare const CapabilityCycle_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
69
+ readonly _tag: "CapabilityCycle";
70
+ } & Readonly<A>;
71
+ export declare class CapabilityCycle extends CapabilityCycle_base<ErrorBase & {
72
+ readonly cycle: readonly string[];
73
+ }> {
74
+ }
75
+ declare const PluginConfigInvalid_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
76
+ readonly _tag: "PluginConfigInvalid";
77
+ } & Readonly<A>;
78
+ export declare class PluginConfigInvalid extends PluginConfigInvalid_base<ErrorBase & {
79
+ readonly plugin: string;
80
+ readonly errors: readonly string[];
81
+ }> {
82
+ }
83
+ declare const PluginExecutionFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
84
+ readonly _tag: "PluginExecutionFailed";
85
+ } & Readonly<A>;
86
+ export declare class PluginExecutionFailed extends PluginExecutionFailed_base<ErrorBase & {
87
+ readonly plugin: string;
88
+ readonly entity?: string;
89
+ readonly field?: string;
90
+ readonly cause: unknown;
91
+ readonly hint?: string;
92
+ }> {
93
+ }
94
+ declare const EmitConflict_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
95
+ readonly _tag: "EmitConflict";
96
+ } & Readonly<A>;
97
+ export declare class EmitConflict extends EmitConflict_base<ErrorBase & {
98
+ readonly path: string;
99
+ readonly plugins: readonly string[];
100
+ }> {
101
+ }
102
+ declare const SymbolConflict_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
103
+ readonly _tag: "SymbolConflict";
104
+ } & Readonly<A>;
105
+ export declare class SymbolConflict extends SymbolConflict_base<ErrorBase & {
106
+ readonly symbol: string;
107
+ readonly file: string;
108
+ readonly plugins: readonly string[];
109
+ }> {
110
+ }
111
+ declare const WriteError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
112
+ readonly _tag: "WriteError";
113
+ } & Readonly<A>;
114
+ export declare class WriteError extends WriteError_base<ErrorBase & {
115
+ readonly path: string;
116
+ readonly cause: unknown;
117
+ }> {
118
+ }
119
+ declare const FormatError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
120
+ readonly _tag: "FormatError";
121
+ } & Readonly<A>;
122
+ export declare class FormatError extends FormatError_base<ErrorBase & {
123
+ readonly path: string;
124
+ readonly cause: unknown;
125
+ }> {
126
+ }
127
+ export type SourcererError = ConfigNotFound | ConfigInvalid | ConnectionFailed | IntrospectionFailed | TagParseError | DuplicatePlugin | CapabilityNotSatisfied | CapabilityConflict | CapabilityCycle | PluginConfigInvalid | PluginExecutionFailed | EmitConflict | SymbolConflict | WriteError | FormatError;
128
+ export {};
129
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAOA,UAAU,SAAS;IACjB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;;;;AAGD,qBAAa,cAAe,SAAQ,oBAClC,SAAS,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CACxD;CAAG;;;;AAEJ,qBAAa,aAAc,SAAQ,mBACjC,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAC1E;CAAG;;;;AAGJ,qBAAa,gBAAiB,SAAQ,sBACpC,SAAS,GAAG;IAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC3E;CAAG;;;;AAEJ,qBAAa,mBAAoB,SAAQ,yBACvC,SAAS,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,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AC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB,CACF;CAAG;;;;AAGJ,qBAAa,YAAa,SAAQ,kBAChC,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAC3E;CAAG;;;;AAEJ,qBAAa,cAAe,SAAQ,oBAClC,SAAS,GAAG;IACV,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CACpC,CACF;CAAG;;;;AAEJ,qBAAa,UAAW,SAAQ,gBAC9B,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC/D;CAAG;;;;AAEJ,qBAAa,WAAY,SAAQ,iBAC/B,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC/D;CAAG;AAGJ,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,aAAa,GACb,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,qBAAqB,GACrB,YAAY,GACZ,cAAc,GACd,UAAU,GACV,WAAW,CAAA"}
package/dist/errors.js ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Core error types for pg-sourcerer
3
+ * Using Effect's Data.TaggedEnum for typed error handling
4
+ */
5
+ import { Data } from "effect";
6
+ // Configuration errors
7
+ export class ConfigNotFound extends Data.TaggedError("ConfigNotFound") {
8
+ }
9
+ export class ConfigInvalid extends Data.TaggedError("ConfigInvalid") {
10
+ }
11
+ // Database errors
12
+ export class ConnectionFailed extends Data.TaggedError("ConnectionFailed") {
13
+ }
14
+ export class IntrospectionFailed extends Data.TaggedError("IntrospectionFailed") {
15
+ }
16
+ // Smart tags errors
17
+ export class TagParseError extends Data.TaggedError("TagParseError") {
18
+ }
19
+ // Plugin errors
20
+ export class DuplicatePlugin extends Data.TaggedError("DuplicatePlugin") {
21
+ }
22
+ export class CapabilityNotSatisfied extends Data.TaggedError("CapabilityNotSatisfied") {
23
+ }
24
+ export class CapabilityConflict extends Data.TaggedError("CapabilityConflict") {
25
+ }
26
+ export class CapabilityCycle extends Data.TaggedError("CapabilityCycle") {
27
+ }
28
+ export class PluginConfigInvalid extends Data.TaggedError("PluginConfigInvalid") {
29
+ }
30
+ export class PluginExecutionFailed extends Data.TaggedError("PluginExecutionFailed") {
31
+ }
32
+ // Emission errors
33
+ export class EmitConflict extends Data.TaggedError("EmitConflict") {
34
+ }
35
+ export class SymbolConflict extends Data.TaggedError("SymbolConflict") {
36
+ }
37
+ export class WriteError extends Data.TaggedError("WriteError") {
38
+ }
39
+ export class FormatError extends Data.TaggedError("FormatError") {
40
+ }
41
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAO7B,uBAAuB;AACvB,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAEpE;CAAG;AAEJ,MAAM,OAAO,aAAc,SAAQ,IAAI,CAAC,WAAW,CAAC,eAAe,CAElE;CAAG;AAEJ,kBAAkB;AAClB,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAExE;CAAG;AAEJ,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAE9E;CAAG;AAEJ,oBAAoB;AACpB,MAAM,OAAO,aAAc,SAAQ,IAAI,CAAC,WAAW,CAAC,eAAe,CAOlE;CAAG;AAEJ,gBAAgB;AAChB,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAEtE;CAAG;AAEJ,MAAM,OAAO,sBAAuB,SAAQ,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAEpF;CAAG;AAEJ,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAE5E;CAAG;AAEJ,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAEtE;CAAG;AAEJ,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAE9E;CAAG;AAEJ,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAQlF;CAAG;AAEJ,kBAAkB;AAClB,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,WAAW,CAAC,cAAc,CAEhE;CAAG;AAEJ,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAMpE;CAAG;AAEJ,MAAM,OAAO,UAAW,SAAQ,IAAI,CAAC,WAAW,CAAC,YAAY,CAE5D;CAAG;AAEJ,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAE9D;CAAG"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Generate Orchestration Function
3
+ *
4
+ * Threads together the full code generation pipeline:
5
+ * 1. Load config
6
+ * 2. Introspect database
7
+ * 3. Build IR
8
+ * 4. Prepare and run plugins
9
+ * 5. Write files
10
+ *
11
+ * Logging:
12
+ * - Effect.log (INFO) - Progress messages shown by default
13
+ * - Effect.logDebug (DEBUG) - Detailed info (entity names, file lists)
14
+ *
15
+ * Configure via Logger.withMinimumLogLevel at the call site.
16
+ */
17
+ import { Effect, Layer } from "effect";
18
+ import { FileSystem, Path, CommandExecutor } from "@effect/platform";
19
+ import type { ResolvedConfig } from "./config.js";
20
+ import type { RunResult } from "./services/plugin-runner.js";
21
+ import { ConfigLoaderService } from "./services/config-loader.js";
22
+ import { DatabaseIntrospectionService } from "./services/introspection.js";
23
+ import { type WriteResult } from "./services/file-writer.js";
24
+ import { type SemanticIR } from "./ir/semantic-ir.js";
25
+ import { ConfigNotFound, ConfigInvalid, ConnectionFailed, IntrospectionFailed, TagParseError, CapabilityConflict, CapabilityCycle, CapabilityNotSatisfied, DuplicatePlugin, PluginConfigInvalid, PluginExecutionFailed, EmitConflict, SymbolConflict, WriteError, FormatError } from "./errors.js";
26
+ /**
27
+ * Options for the generate function
28
+ */
29
+ export interface GenerateOptions {
30
+ /** Path to config file (optional - will search if not provided) */
31
+ readonly configPath?: string;
32
+ /** Directory to search for config from (default: cwd) */
33
+ readonly searchFrom?: string;
34
+ /** Override output directory from config */
35
+ readonly outputDir?: string;
36
+ /** Dry run - don't write files, just return what would be written */
37
+ readonly dryRun?: boolean;
38
+ }
39
+ /**
40
+ * Result of a generate operation
41
+ */
42
+ export interface GenerateResult {
43
+ /** The loaded configuration */
44
+ readonly config: ResolvedConfig;
45
+ /** The built semantic IR */
46
+ readonly ir: SemanticIR;
47
+ /** Plugin execution results */
48
+ readonly pluginResult: RunResult;
49
+ /** File write results */
50
+ readonly writeResults: readonly WriteResult[];
51
+ }
52
+ /**
53
+ * All possible errors from the generate pipeline
54
+ */
55
+ export type GenerateError = ConfigNotFound | ConfigInvalid | ConnectionFailed | IntrospectionFailed | TagParseError | CapabilityConflict | CapabilityCycle | CapabilityNotSatisfied | DuplicatePlugin | PluginConfigInvalid | PluginExecutionFailed | EmitConflict | SymbolConflict | WriteError | FormatError;
56
+ /**
57
+ * The main generate pipeline
58
+ */
59
+ export declare const generate: (options?: GenerateOptions) => Effect.Effect<GenerateResult, GenerateError, ConfigLoaderService | DatabaseIntrospectionService | FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor>;
60
+ /**
61
+ * Layer that provides all services needed for generate()
62
+ *
63
+ * Note: PluginRunner is NOT included here because it needs to be
64
+ * created with the user's inflection config (from loaded config).
65
+ * The generate() function creates the PluginRunner internally.
66
+ */
67
+ export declare const GenerateLive: Layer.Layer<ConfigLoaderService | DatabaseIntrospectionService, never, never>;
68
+ /**
69
+ * Run generate with all dependencies provided
70
+ *
71
+ * This is the main entry point for programmatic usage.
72
+ * Requires FileSystem, Path, and CommandExecutor from @effect/platform.
73
+ */
74
+ export declare const runGenerate: (options?: GenerateOptions) => Effect.Effect<GenerateResult, GenerateError, FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor>;
75
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAW,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EACL,mBAAmB,EAEpB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,4BAA4B,EAE7B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAG9E,OAAO,EAA8E,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACjI,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,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