@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-meta.js","sourceRoot":"","sources":["../../src/services/plugin-meta.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAUhC;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAA8B;CAAG"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Plugin Runner Service
3
+ *
4
+ * Orchestrates plugin execution: capability resolution, ordering, and execution.
5
+ *
6
+ * Functional Effect patterns:
7
+ * - Method-style .pipe() for Effect chains
8
+ * - pipe() from effect only for pure data transformations
9
+ * - HashMap/Array for immutable collections
10
+ * - Effect.reduce for foldable operations with failure
11
+ * - Graph module for dependency algorithms
12
+ */
13
+ import { Effect, Layer } from "effect";
14
+ import type { SemanticIR, CapabilityKey, Artifact } from "../ir/index.js";
15
+ import type { ConfiguredPlugin } from "./plugin.js";
16
+ import { CapabilityConflict, CapabilityCycle, CapabilityNotSatisfied, DuplicatePlugin, EmitConflict, PluginConfigInvalid, PluginExecutionFailed, SymbolConflict } from "../errors.js";
17
+ import { type EmissionBuffer } from "./emissions.js";
18
+ import { type SymbolRegistry } from "./symbols.js";
19
+ import { TypeHints } from "./type-hints.js";
20
+ import { Inflection } from "./inflection.js";
21
+ export type { Plugin, ConfiguredPlugin, PluginInflection } from "./plugin.js";
22
+ /**
23
+ * Result of running plugins - contains all outputs for validation and writing
24
+ */
25
+ export interface RunResult {
26
+ /** Emission buffer containing all emitted code */
27
+ readonly emissions: EmissionBuffer;
28
+ /** Symbol registry for import resolution */
29
+ readonly symbols: SymbolRegistry;
30
+ /** Artifacts produced by plugins, keyed by capability */
31
+ readonly artifacts: ReadonlyMap<CapabilityKey, Artifact>;
32
+ }
33
+ declare const PluginRunner_base: Effect.Service.Class<PluginRunner, "PluginRunner", {
34
+ readonly effect: Effect.Effect<{
35
+ prepare: (plugins: readonly ConfiguredPlugin[]) => Effect.Effect<readonly ConfiguredPlugin[], CapabilityConflict | CapabilityCycle | CapabilityNotSatisfied | DuplicatePlugin | PluginConfigInvalid>;
36
+ run: (plugins: readonly ConfiguredPlugin[], ir: SemanticIR) => Effect.Effect<RunResult, PluginExecutionFailed | EmitConflict | SymbolConflict, TypeHints>;
37
+ }, never, Inflection>;
38
+ readonly dependencies: readonly [Layer.Layer<Inflection, never, never>];
39
+ }>;
40
+ /**
41
+ * PluginRunner service - orchestrates plugin execution.
42
+ *
43
+ * Depends on Inflection service (captured at construction time via layer).
44
+ *
45
+ * Usage:
46
+ * const runner = yield* PluginRunner
47
+ * const prepared = yield* runner.prepare(plugins)
48
+ * const result = yield* runner.run(prepared, ir)
49
+ */
50
+ export declare class PluginRunner extends PluginRunner_base {
51
+ }
52
+ //# sourceMappingURL=plugin-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-runner.d.ts","sourceRoot":"","sources":["../../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AjBjG;;;;;;;;;GASG;AACH,qBAAa,YAAa,SAAQ,iBAmFhC;CAAG"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Plugin Runner Service
3
+ *
4
+ * Orchestrates plugin execution: capability resolution, ordering, and execution.
5
+ *
6
+ * Functional Effect patterns:
7
+ * - Method-style .pipe() for Effect chains
8
+ * - pipe() from effect only for pure data transformations
9
+ * - HashMap/Array for immutable collections
10
+ * - Effect.reduce for foldable operations with failure
11
+ * - Graph module for dependency algorithms
12
+ */
13
+ import { Effect, HashMap, Array as Arr, pipe, Graph, Option, Schema as S, ParseResult, Layer } from "effect";
14
+ import { CapabilityConflict, CapabilityCycle, CapabilityNotSatisfied, DuplicatePlugin, PluginConfigInvalid, SymbolConflict, } from "../errors.js";
15
+ import { Emissions, createEmissionBuffer } from "./emissions.js";
16
+ import { Symbols, createSymbolRegistry } from "./symbols.js";
17
+ import { TypeHints } from "./type-hints.js";
18
+ import { Inflection, InflectionLive, composeInflection } from "./inflection.js";
19
+ import { IR } from "./ir.js";
20
+ import { ArtifactStore, createArtifactStore } from "./artifact-store.js";
21
+ import { PluginMeta } from "./plugin-meta.js";
22
+ import { conjure } from "../lib/conjure.js";
23
+ // ============================================================================
24
+ // Pure Functions (use pipe for data transformations)
25
+ // ============================================================================
26
+ /** Expand "a:b:c" → ["a:b:c", "a:b", "a"] */
27
+ const expandCapability = (cap) => pipe(Arr.range(1, cap.split(":").length), Arr.map(n => cap.split(":").slice(0, n).join(":")));
28
+ /** Extract (capability, pluginName) pairs from plugins with expansion */
29
+ const capabilityPairs = (plugins) => plugins.flatMap(({ plugin }) => plugin.provides.flatMap(expandCapability).map(cap => [cap, plugin.name]));
30
+ /** Extract (required, pluginName) pairs from plugins */
31
+ const requirementPairs = (plugins) => plugins.flatMap(({ plugin }) => (plugin.requires ?? []).map(req => [req, plugin.name]));
32
+ /** Build directed graph from plugins and their dependencies (pure) */
33
+ const buildGraph = (plugins, providers) => {
34
+ const names = Arr.map(plugins, ({ plugin }) => plugin.name);
35
+ const edges = plugins.flatMap(({ plugin }) => Arr.filterMap(plugin.requires ?? [], req => HashMap.get(providers, req).pipe(Option.filter(provider => provider !== plugin.name), Option.map(provider => [provider, plugin.name]))));
36
+ // Mutation confined to Graph.directed callback
37
+ return Graph.directed(g => {
38
+ const indices = Object.fromEntries(names.map(name => [name, Graph.addNode(g, name)]));
39
+ edges.forEach(([from, to]) => {
40
+ Graph.addEdge(g, indices[from], indices[to], undefined);
41
+ });
42
+ });
43
+ };
44
+ /** Extract cycle from graph's strongly connected components */
45
+ const extractCycle = (graph) => pipe(Graph.stronglyConnectedComponents(graph), Arr.findFirst(scc => scc.length > 1), Option.getOrElse(() => []), Arr.map(idx => Graph.getNode(graph, idx).pipe(Option.getOrElse(() => "unknown"))));
46
+ // ============================================================================
47
+ // Effectful Operations (use .pipe() method on Effects)
48
+ // ============================================================================
49
+ /** Check for duplicate plugin names */
50
+ const checkDuplicates = (plugins) => Effect.reduce(plugins.map(({ plugin }) => plugin.name), new Set(), (seen, name) => seen.has(name)
51
+ ? Effect.fail(new DuplicatePlugin({
52
+ message: `Plugin "${name}" is registered multiple times`,
53
+ plugin: name,
54
+ }))
55
+ : Effect.succeed(new Set([...seen, name]))).pipe(Effect.asVoid);
56
+ /** Validate a single plugin's config against its schema */
57
+ const validatePluginConfig = (cp) => S.decodeUnknown(cp.plugin.configSchema)(cp.config).pipe(Effect.map(validatedConfig => ({
58
+ plugin: cp.plugin,
59
+ config: validatedConfig,
60
+ })), Effect.mapError(parseError => {
61
+ const formatted = ParseResult.ArrayFormatter.formatErrorSync(parseError);
62
+ const errors = formatted.map(e => {
63
+ const path = e.path.length > 0 ? `${e.path.join(".")}: ` : "";
64
+ return `${path}${e.message}`;
65
+ });
66
+ return new PluginConfigInvalid({
67
+ message: `Invalid config for plugin "${cp.plugin.name}": ${errors.join("; ")}`,
68
+ plugin: cp.plugin.name,
69
+ errors,
70
+ });
71
+ }));
72
+ /** Validate all plugin configs, failing on first invalid */
73
+ const validateConfigs = (plugins) => Effect.forEach(plugins, validatePluginConfig);
74
+ /**
75
+ * Build capability → provider map, failing on first conflict.
76
+ * Single-pass fold that validates during construction.
77
+ */
78
+ const buildProviderMap = (plugins) => Effect.reduce(capabilityPairs(plugins), HashMap.empty(), (map, [cap, name]) => pipe(HashMap.get(map, cap), Option.match({
79
+ onNone: () => Effect.succeed(HashMap.set(map, cap, name)),
80
+ onSome: existing => existing === name
81
+ ? Effect.succeed(map)
82
+ : Effect.fail(new CapabilityConflict({
83
+ message: `Capability "${cap}" provided by multiple plugins: ${existing}, ${name}`,
84
+ capability: cap,
85
+ providers: [existing, name],
86
+ })),
87
+ })));
88
+ /** Verify all requirements are satisfiable */
89
+ const checkRequirements = (plugins, providers) => pipe(requirementPairs(plugins), Arr.findFirst(([req]) => !HashMap.has(providers, req)), Option.match({
90
+ onNone: () => Effect.void,
91
+ onSome: ([req, name]) => Effect.fail(new CapabilityNotSatisfied({
92
+ message: `Plugin "${name}" requires "${req}" but no plugin provides it`,
93
+ required: req,
94
+ requiredBy: name,
95
+ })),
96
+ }));
97
+ /** Sort plugins topologically, detecting cycles */
98
+ const topoSort = (plugins, graph) => {
99
+ const byName = Arr.groupBy(plugins, cp => cp.plugin.name);
100
+ return Effect.if(Graph.isAcyclic(graph), {
101
+ onTrue: () => Effect.succeed(Array.from(Graph.values(Graph.topo(graph))).flatMap(n => byName[n])),
102
+ onFalse: () => Effect.fail(new CapabilityCycle({
103
+ message: `Circular dependency: ${extractCycle(graph).join(" → ")}`,
104
+ cycle: extractCycle(graph),
105
+ })),
106
+ });
107
+ };
108
+ // ============================================================================
109
+ // Prepare (standalone - no dependencies)
110
+ // ============================================================================
111
+ const prepare = (plugins) => Effect.if(plugins.length === 0, {
112
+ onTrue: () => Effect.succeed(plugins),
113
+ onFalse: () => checkDuplicates(plugins).pipe(Effect.andThen(validateConfigs(plugins)), Effect.flatMap(validatedPlugins => buildProviderMap(validatedPlugins).pipe(Effect.tap(providers => checkRequirements(validatedPlugins, providers)), Effect.flatMap(providers => topoSort(validatedPlugins, buildGraph(validatedPlugins, providers)))))),
114
+ });
115
+ // ============================================================================
116
+ // PluginRunner Service
117
+ // ============================================================================
118
+ /**
119
+ * PluginRunner service - orchestrates plugin execution.
120
+ *
121
+ * Depends on Inflection service (captured at construction time via layer).
122
+ *
123
+ * Usage:
124
+ * const runner = yield* PluginRunner
125
+ * const prepared = yield* runner.prepare(plugins)
126
+ * const result = yield* runner.run(prepared, ir)
127
+ */
128
+ export class PluginRunner extends Effect.Service()("PluginRunner", {
129
+ effect: Effect.gen(function* () {
130
+ const inflection = yield* Inflection;
131
+ const run = (plugins, ir) => Effect.gen(function* () {
132
+ // Create shared state for all plugins in this run
133
+ const emissions = createEmissionBuffer();
134
+ const symbols = createSymbolRegistry();
135
+ // Yield TypeHints from context - caller must provide via layer
136
+ const typeHints = yield* TypeHints;
137
+ // Create artifact store instance once (it's stateful)
138
+ const artifactStore = createArtifactStore();
139
+ // Build shared layers for this run - all using the same instances
140
+ // Note: Inflection is NOT in shared layers - it's per-plugin (composed)
141
+ const sharedLayers = Layer.mergeAll(Layer.succeed(IR, ir), Layer.succeed(Emissions, emissions), Layer.succeed(Symbols, symbols), Layer.succeed(TypeHints, typeHints), Layer.succeed(ArtifactStore, artifactStore));
142
+ // Execute plugins sequentially, stopping on first failure
143
+ // Each plugin gets:
144
+ // - Fresh PluginMeta layer with its name
145
+ // - Composed inflection (plugin defaults + base inflection)
146
+ // - Logging annotations for structured logging
147
+ yield* Effect.forEach(plugins, ({ plugin, config }) => {
148
+ const pluginMetaLayer = Layer.succeed(PluginMeta, { name: plugin.name });
149
+ // Compose inflection: plugin defaults applied first, then base inflection
150
+ const composedInflection = composeInflection(inflection, plugin.inflectionDefaults);
151
+ const inflectionLayer = Layer.succeed(Inflection, composedInflection);
152
+ const allLayers = Layer.mergeAll(sharedLayers, pluginMetaLayer, inflectionLayer);
153
+ return plugin.run(config).pipe(Effect.provide(allLayers),
154
+ // Add plugin name as log annotation for Effect-native plugins
155
+ Effect.annotateLogs("plugin", plugin.name));
156
+ }, { discard: true });
157
+ // Serialize AST emissions to string content (with import resolution)
158
+ emissions.serializeAst(conjure.print, symbols);
159
+ // Validate emissions for conflicts
160
+ yield* emissions.validate();
161
+ // Validate symbols for collisions
162
+ const collisions = symbols.validate();
163
+ if (collisions.length > 0) {
164
+ yield* Effect.fail(new SymbolConflict({
165
+ message: `Symbol collision: "${collisions[0].symbol}" in ${collisions[0].file} from plugins: ${collisions[0].plugins.join(", ")}`,
166
+ symbol: collisions[0].symbol,
167
+ file: collisions[0].file,
168
+ plugins: collisions[0].plugins,
169
+ }));
170
+ }
171
+ return {
172
+ emissions,
173
+ symbols,
174
+ artifacts: artifactStore.getAll(),
175
+ };
176
+ });
177
+ return { prepare, run };
178
+ }),
179
+ dependencies: [InflectionLive],
180
+ }) {
181
+ }
182
+ //# sourceMappingURL=plugin-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-runner.js","sourceRoot":"","sources":["../../src/services/plugin-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG7G,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,eAAe,EAEf,mBAAmB,EAEnB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAuB,SAAS,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAuB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAA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AAI,CAAC,EAAE;oBACpI,MAAM,EAAE,UAAU,CAAC,CAAC,CAAE,CAAC,MAAM;oBAC7B,IAAI,EAAE,UAAU,CAAC,CAAC,CAAE,CAAC,IAAI;oBACzB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAE,CAAC,OAAO;iBAChC,CAAC,CACH,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,SAAS;gBACT,OAAO;gBACP,SAAS,EAAE,aAAa,CAAC,MAAM,EAAE;aAClC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;IAC1B,CAAC,CAAC;IACF,YAAY,EAAE,CAAC,cAAc,CAAC;CAC/B,CAAC;CAAG"}
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Plugin Types
3
+ *
4
+ * Defines the Effect-native plugin interface where plugins are Effects
5
+ * that yield the services they need from context.
6
+ */
7
+ import { Effect, Schema as S } from "effect";
8
+ import type { namedTypes as n } from "ast-types";
9
+ import type { Artifact, CapabilityKey, SemanticIR, Entity } from "../ir/semantic-ir.js";
10
+ import { PluginExecutionFailed } from "../errors.js";
11
+ import type { CoreInflection, InflectionConfig } from "./inflection.js";
12
+ import type { SymbolRegistry } from "./symbols.js";
13
+ import type { TypeHintRegistry } from "./type-hints.js";
14
+ import type { FileBuilder } from "./file-builder.js";
15
+ import { IR } from "./ir.js";
16
+ import { ArtifactStore } from "./artifact-store.js";
17
+ import { PluginMeta } from "./plugin-meta.js";
18
+ import { Inflection } from "./inflection.js";
19
+ import { Emissions } from "./emissions.js";
20
+ import { Symbols } from "./symbols.js";
21
+ import { TypeHints } from "./type-hints.js";
22
+ /**
23
+ * Context provided to fileName function for output file path generation.
24
+ *
25
+ * This gives plugins full programmatic control over file naming,
26
+ * with access to entity info and inflection utilities.
27
+ */
28
+ export interface FileNameContext {
29
+ /** Already-inflected entity name */
30
+ readonly entityName: string;
31
+ /** Raw PostgreSQL object name (table, view, or type name) */
32
+ readonly pgName: string;
33
+ /** Schema name */
34
+ readonly schema: string;
35
+ /** Inflection utilities (singularize, pluralize, etc.) */
36
+ readonly inflection: CoreInflection;
37
+ /** Full entity from IR for advanced use cases */
38
+ readonly entity: Entity;
39
+ }
40
+ /**
41
+ * Plugin-specific inflection for output file and symbol naming
42
+ */
43
+ export interface PluginInflection {
44
+ /**
45
+ * Generate output file path for an entity.
46
+ *
47
+ * @param ctx - Context with entity info and inflection utilities
48
+ * @returns File path relative to outputDir (include extension)
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // Default: entity name as file
53
+ * fileName: (ctx) => `${ctx.entityName}.ts`
54
+ *
55
+ * // Lowercase files
56
+ * fileName: (ctx) => `${ctx.entityName.toLowerCase()}.ts`
57
+ *
58
+ * // Singular lowercase
59
+ * fileName: (ctx) => `${ctx.inflection.singularize(ctx.entityName).toLowerCase()}.ts`
60
+ *
61
+ * // Schema-scoped
62
+ * fileName: (ctx) => `${ctx.schema}/${ctx.entityName}.ts`
63
+ *
64
+ * // Single file for all entities
65
+ * fileName: () => `all-models.ts`
66
+ * ```
67
+ */
68
+ readonly outputFile: (ctx: FileNameContext) => string;
69
+ readonly symbolName: (entityName: string, artifactKind: string) => string;
70
+ }
71
+ /**
72
+ * Union of all service tags available to plugins.
73
+ *
74
+ * Plugins can yield any of these from Effect context:
75
+ * ```typescript
76
+ * const ir = yield* IR
77
+ * const inflection = yield* Inflection
78
+ * ```
79
+ */
80
+ export type PluginServices = IR | Inflection | Emissions | Symbols | TypeHints | ArtifactStore | PluginMeta;
81
+ /**
82
+ * Effect-native Plugin interface
83
+ *
84
+ * Plugins are Effects that yield the services they need from context.
85
+ * The PluginRunner provides all services via layers.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const myPlugin: Plugin<MyConfig> = {
90
+ * name: "my-plugin",
91
+ * provides: ["types:row"],
92
+ * configSchema: MyConfigSchema,
93
+ * inflection: { ... },
94
+ *
95
+ * run: (config) => Effect.gen(function* () {
96
+ * const ir = yield* IR
97
+ * const emissions = yield* Emissions
98
+ * const meta = yield* PluginMeta
99
+ *
100
+ * for (const entity of ir.entities.values()) {
101
+ * emissions.emit(`types/${entity.name}.ts`, generateType(entity), meta.name)
102
+ * }
103
+ * })
104
+ * }
105
+ * ```
106
+ */
107
+ export interface Plugin<TConfig = unknown> {
108
+ /** Unique plugin name */
109
+ readonly name: string;
110
+ /** Capabilities this plugin requires (must be provided by earlier plugins) */
111
+ readonly requires?: readonly CapabilityKey[];
112
+ /** Capabilities this plugin provides */
113
+ readonly provides: readonly CapabilityKey[];
114
+ /** Configuration schema (Effect Schema) - Schema<TConfig> or Schema<TConfig, Encoded> */
115
+ readonly configSchema: S.Schema<TConfig>;
116
+ /** Plugin-specific inflection for file and symbol naming */
117
+ readonly inflection: PluginInflection;
118
+ /**
119
+ * Plugin's default inflection transforms.
120
+ *
121
+ * These are applied BEFORE user-configured inflection, allowing composition:
122
+ * - Plugin sets baseline (e.g., entityName: inflect.pascalCase → "users" → "Users")
123
+ * - User config refines (e.g., entityName: inflect.singularize → "Users" → "User")
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * import { inflect } from "pg-sourcerer"
128
+ *
129
+ * inflectionDefaults: {
130
+ * entityName: inflect.pascalCase, // Plugin wants PascalCase class names
131
+ * // fieldName not set = plugin preserves field names as-is
132
+ * }
133
+ * ```
134
+ */
135
+ readonly inflectionDefaults?: InflectionConfig;
136
+ /**
137
+ * Plugin execution - returns Effect that yields services from context.
138
+ *
139
+ * Services available:
140
+ * - IR: SemanticIR (read-only)
141
+ * - Inflection: CoreInflection (composed: plugin defaults + user config)
142
+ * - Emissions: EmissionBuffer
143
+ * - Symbols: SymbolRegistry
144
+ * - TypeHints: TypeHintRegistry
145
+ * - ArtifactStore: plugin-to-plugin data
146
+ * - PluginMeta: current plugin name
147
+ */
148
+ readonly run: (config: TConfig) => Effect.Effect<void, PluginExecutionFailed, IR | Inflection | Emissions | Symbols | TypeHints | ArtifactStore | PluginMeta>;
149
+ }
150
+ /**
151
+ * A plugin factory function that creates ConfiguredPlugin instances.
152
+ *
153
+ * The factory also exposes the underlying plugin for inspection:
154
+ * - `factory.plugin` - The Plugin object with name, provides, requires, etc.
155
+ */
156
+ export interface PluginFactory<TConfig> {
157
+ (config: TConfig): ConfiguredPlugin;
158
+ /** The underlying plugin definition */
159
+ readonly plugin: Plugin<TConfig>;
160
+ }
161
+ /**
162
+ * A plugin with its validated configuration
163
+ */
164
+ export interface ConfiguredPlugin {
165
+ readonly plugin: Plugin<unknown>;
166
+ readonly config: unknown;
167
+ }
168
+ /**
169
+ * Logger interface for simple plugins
170
+ */
171
+ export interface SimplePluginLogger {
172
+ readonly debug: (message: string) => void;
173
+ readonly info: (message: string) => void;
174
+ readonly warn: (message: string) => void;
175
+ }
176
+ /**
177
+ * Context object provided to simple plugins.
178
+ *
179
+ * This is a convenience wrapper around the Effect services,
180
+ * providing a plain object API for plugins that don't need
181
+ * full Effect capabilities.
182
+ */
183
+ export interface SimplePluginContext {
184
+ /** Read-only access to the IR */
185
+ readonly ir: SemanticIR;
186
+ /** Core inflection service */
187
+ readonly inflection: CoreInflection;
188
+ /** Symbol registry for cross-file imports */
189
+ readonly symbols: SymbolRegistry;
190
+ /** Type hints registry */
191
+ readonly typeHints: TypeHintRegistry;
192
+ /** Emit string content to a file (buffered) */
193
+ readonly emit: (path: string, content: string) => void;
194
+ /**
195
+ * Emit an AST program to a file (buffered).
196
+ * The plugin runner handles serialization after all plugins run.
197
+ *
198
+ * @param path - Output file path
199
+ * @param ast - The AST program node to emit
200
+ * @param header - Optional header to prepend (e.g., imports that can't be in AST)
201
+ */
202
+ readonly emitAst: (path: string, ast: n.Program, header?: string) => void;
203
+ /** Append to an already-emitted file */
204
+ readonly appendEmit: (path: string, content: string) => void;
205
+ /** Get an artifact from a previous plugin */
206
+ readonly getArtifact: (capability: CapabilityKey) => Artifact | undefined;
207
+ /** Store an artifact for downstream plugins */
208
+ readonly setArtifact: (capability: CapabilityKey, data: unknown) => void;
209
+ /** Logging */
210
+ readonly log: SimplePluginLogger;
211
+ /** Current plugin name */
212
+ readonly pluginName: string;
213
+ /** Plugin's inflection for file and symbol naming */
214
+ readonly pluginInflection: PluginInflection;
215
+ /**
216
+ * Create a FileBuilder for structured file emission.
217
+ *
218
+ * Use this for AST-based code generation with automatic symbol registration:
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * ctx.file("types/User.ts")
223
+ * .header("// Auto-generated")
224
+ * .import({ kind: "package", names: ["z"], from: "zod" })
225
+ * .ast(symbolProgram(...))
226
+ * .emit()
227
+ * ```
228
+ */
229
+ readonly file: (path: string) => FileBuilder;
230
+ }
231
+ /**
232
+ * Definition for a simple plugin (no Effect knowledge required)
233
+ */
234
+ export interface SimplePluginDef<TConfig = unknown> {
235
+ /** Unique plugin name */
236
+ readonly name: string;
237
+ /** Capabilities this plugin requires */
238
+ readonly requires?: readonly CapabilityKey[];
239
+ /** Capabilities this plugin provides */
240
+ readonly provides: readonly CapabilityKey[];
241
+ /** Configuration schema */
242
+ readonly configSchema: S.Schema<TConfig>;
243
+ /** Plugin-specific inflection for file and symbol naming */
244
+ readonly inflection: PluginInflection;
245
+ /**
246
+ * Plugin's default inflection transforms.
247
+ *
248
+ * These are applied BEFORE user-configured inflection, allowing composition:
249
+ * - Plugin sets baseline (e.g., entityName: inflect.pascalCase → "users" → "Users")
250
+ * - User config refines (e.g., entityName: inflect.singularize → "Users" → "User")
251
+ */
252
+ readonly inflectionDefaults?: InflectionConfig;
253
+ /**
254
+ * Plugin execution function.
255
+ * Can be sync or async (return void or Promise<void>).
256
+ */
257
+ readonly run: (ctx: SimplePluginContext, config: TConfig) => void | Promise<void>;
258
+ }
259
+ /**
260
+ * Create a plugin factory from a simple function-based definition.
261
+ *
262
+ * Returns a curried function that accepts config and returns a ConfiguredPlugin.
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * const myPlugin = definePlugin({
267
+ * name: "my-plugin",
268
+ * provides: ["types:row"],
269
+ * configSchema: S.Struct({ outputDir: S.String }),
270
+ * inflection: { ... },
271
+ *
272
+ * run: (ctx, config) => {
273
+ * for (const entity of ctx.ir.entities.values()) {
274
+ * ctx.emit(`${config.outputDir}/${entity.name}.ts`, generateType(entity))
275
+ * }
276
+ * }
277
+ * })
278
+ *
279
+ * // Usage in config:
280
+ * plugins: [
281
+ * myPlugin({ outputDir: "types" }),
282
+ * ]
283
+ * ```
284
+ */
285
+ export declare function definePlugin<TConfig>(def: SimplePluginDef<TConfig>): PluginFactory<TConfig>;
286
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/services/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,IAAI,CAAC,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAIpD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;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