Commit c5f7369
committed
fix(codegen/cli): make autoEmbedWhere/autoEmbedInput generic in embedder template
The CLI codegen emits calls like `findManyArgs.where = await autoEmbedWhere(findManyArgs.where ?? {}, ['embedding'], embedder)` and `await autoEmbedInput(cleanedData, ['embedding'], embedder)` where the first argument is a concrete `*Filter` / `*Patch` type produced by `input-types.ts`. Those generated types don't have a string index signature, so under strict `tsc` every call site errors with:
error TS2345: Argument of type 'XxxFilter' is not assignable to
parameter of type 'Record<string, unknown>'. Index signature for
type 'string' is missing in type 'XxxFilter'.
CI for consumers (agentic-db et al.) passes via `ts-jest`, which is lenient about index-signature / excess-property checks, but `makage build` on publish is strict and fails across all generated `commands/*.ts` files.
Make both helpers generic (`<T extends object>(x: T, ...): Promise<T>`) and cast to `Record<string, unknown>` internally for the field-name indexing. Runtime behavior is unchanged (mutation in place, same return semantics), and call sites now type-check as-is without any generator change.
Consumer-side point fix already landed in constructive-io/agentic-db#29; this PR fixes the upstream template so the next `pnpm generate:all` in any consumer emits a correctly-typed `embedder.ts`.1 parent da90c33 commit c5f7369
1 file changed
Lines changed: 12 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
| 116 | + | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
121 | 122 | | |
122 | | - | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
135 | | - | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | | - | |
| 161 | + | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | | - | |
| 168 | + | |
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
170 | | - | |
| 172 | + | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
| |||
0 commit comments