@codewithagents/api-errors 1.2.0 → 1.2.1

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/README.md CHANGED
@@ -5,15 +5,19 @@
5
5
  [![codecov](https://codecov.io/gh/codewithagents/openapi-zod-ts/graph/badge.svg?flag=api-errors)](https://codecov.io/gh/codewithagents/openapi-zod-ts)
6
6
  [![CodeQL](https://github.com/codewithagents/openapi-zod-ts/actions/workflows/codeql.yml/badge.svg)](https://github.com/codewithagents/openapi-zod-ts/actions/workflows/codeql.yml)
7
7
 
8
- 📖 **[Full documentation](https://openapi.codewithagents.de/api-errors)**
8
+ **[Full documentation](https://openapi.codewithagents.de/api-errors)**
9
9
 
10
- Backend API errors don't automatically map to form field errors. Every project writes the same boilerplate from scratch: catch the error, inspect its shape, figure out which field each message belongs to, then call your form library's error setter. This package does that for you: a framework-agnostic core with a first-class React Hook Form adapter.
10
+ `@codewithagents/api-errors` maps backend API error responses to form field errors in one call: it auto-detects RFC 9457 Problem Details, Spring Boot, Laravel, Zod, JSON:API, and ten other error shapes, then wires the result to React Hook Form, Formik, or TanStack Form with zero runtime dependencies.
11
11
 
12
- - **Framework-agnostic core**: `extractFieldErrors(error)` returns normalized `{ field, message }` pairs from any error shape. Works with any form library or plain JavaScript.
13
- - **React Hook Form adapter**: `mapApiErrors(error, setError)` wires directly to RHF's `setError`. One call at the catch site, no mapping loop.
14
- - **Multiple error formats**: RFC 7807 Problem Details, Spring Boot validation format, flat `{ field, message }` arrays, and more.
15
- - **Response unwrapping**: detects `error.response.data` (Axios), `{ status, body }` (generated client's `ApiError`), and nested `{ data }` wrappers automatically.
16
- - **Zero runtime dependencies**: pure TypeScript, nothing added to your bundle.
12
+ It is the runtime helper in the [openapi-zod-ts toolchain](#ecosystem): the four generators emit your types, client, hooks, and mocks, and `api-errors` maps the error responses those servers return back onto your form fields at runtime.
13
+
14
+ - **Framework-agnostic core.** `extractFieldErrors(error)` returns normalized `{ field, message }` pairs from any supported error shape. `extractErrors(error)` returns the richer `{ fieldErrors, formErrors, format }` result with a separate channel for global (non-field) messages.
15
+ - **Form adapters.** React Hook Form (`mapApiErrors`), Formik (`mapApiErrorsFormik`), TanStack Form v1 (`mapApiErrorsTanstack`), and a plain record (`mapApiErrorsToRecord`). Each is one call at the catch site, no mapping loop. The adapters use structural typing, so no form-library import or peer dependency is required.
16
+ - **Ten built-in parsers.** RFC 7807 / RFC 9457 Problem Details (`errors` map, `violations`, `invalid-params`, top-level `detail`), JSON:API, GraphQL `extensions`, Spring Boot validation, Laravel / DRF field maps, Zod `.flatten()`, and flat object / array shapes. The format is detected automatically. Register your own with the `parsers` option.
17
+ - **Response unwrapping.** Detects `{ status, body }` (`ApiError` from `openapi-zod-ts`), `error.response.data` (Axios), and generic `{ data }` wrappers automatically.
18
+ - **i18n and status filtering.** `resolveMessage` translates every message before it is returned; `statusCodes` restricts parsing to specific HTTP status codes.
19
+ - **Never throws.** All functions return empty results for unrecognized or null input.
20
+ - **Zero runtime dependencies.** Pure TypeScript, full type declarations, nothing third-party added to your bundle.
17
21
 
18
22
  ## Installation
19
23
 
@@ -21,6 +25,19 @@ Backend API errors don't automatically map to form field errors. Every project w
21
25
  npm install @codewithagents/api-errors
22
26
  ```
23
27
 
28
+ ## Public API
29
+
30
+ Six functions cover every use case. The core pair parses any error shape; the adapters wrap it for a specific form library.
31
+
32
+ | Function | What it does |
33
+ | --- | --- |
34
+ | `extractErrors(error, options?)` | Parses any error shape. Returns `{ fieldErrors, formErrors, format }`. Keeps global errors in a dedicated `formErrors` channel and reports the matched `format`. Recommended for new code. |
35
+ | `extractFieldErrors(error, options?)` | Parses any error shape. Returns normalized `FieldError[]`. Global errors fall back to `fallbackField`. Framework-agnostic. |
36
+ | `mapApiErrors(error, setError, options?)` | React Hook Form adapter. Calls `setError` once per field with `type: 'server'`. |
37
+ | `mapApiErrorsToRecord(error, options?)` | Vanilla adapter. Returns a `Record<field, message>` of each field's first message. |
38
+ | `mapApiErrorsFormik(error, setErrors, options?)` | Formik adapter. Calls `setErrors` with the record from `mapApiErrorsToRecord`. |
39
+ | `mapApiErrorsTanstack(error, form, options?)` | TanStack Form v1 adapter. Calls `form.setFieldMeta` per field to inject server errors. |
40
+
24
41
  ## Usage
25
42
 
26
43
  ### With React Hook Form
@@ -51,9 +68,7 @@ function SignupForm() {
51
68
  }
52
69
  ```
53
70
 
54
- ### With typed React Hook Form forms
55
-
56
- `mapApiErrors` accepts any function matching `(field: string, error: { type: string; message: string }) => void`, which is compatible with RHF's `UseFormSetError<T>`. No casting needed:
71
+ `mapApiErrors` accepts any function matching `(field: string, error: { type: string; message: string }) => void`, which is compatible with RHF's `UseFormSetError<T>`. No casting needed for typed forms:
57
72
 
58
73
  ```tsx
59
74
  type FormValues = { email: string; name: string }
@@ -64,6 +79,40 @@ const { setError } = useForm<FormValues>()
64
79
  mapApiErrors(error, setError)
65
80
  ```
66
81
 
82
+ ### With Formik
83
+
84
+ No Formik import is required. The `setErrors` parameter is typed by shape only.
85
+
86
+ ```tsx
87
+ import { useFormik } from 'formik'
88
+ import { mapApiErrorsFormik } from '@codewithagents/api-errors'
89
+
90
+ const formik = useFormik({
91
+ initialValues: { email: '', name: '' },
92
+ onSubmit: async (values, { setErrors }) => {
93
+ try {
94
+ await createUser(values)
95
+ } catch (error) {
96
+ mapApiErrorsFormik(error, setErrors)
97
+ }
98
+ },
99
+ })
100
+ ```
101
+
102
+ ### With TanStack Form v1
103
+
104
+ No TanStack Form import is required. The `form` parameter is typed by shape only.
105
+
106
+ ```ts
107
+ import { mapApiErrorsTanstack } from '@codewithagents/api-errors'
108
+
109
+ try {
110
+ await form.handleSubmit()
111
+ } catch (error) {
112
+ mapApiErrorsTanstack(error, form)
113
+ }
114
+ ```
115
+
67
116
  ### With native `fetch` (no Axios)
68
117
 
69
118
  Pass the parsed response body directly to `extractFieldErrors`:
@@ -83,7 +132,7 @@ if (!res.ok) {
83
132
 
84
133
  ### Standalone with `extractFieldErrors`
85
134
 
86
- Use `extractFieldErrors` when you need the normalized error list without a form library:
135
+ Use `extractFieldErrors` when you need the normalized list without a form library:
87
136
 
88
137
  ```ts
89
138
  import { extractFieldErrors } from '@codewithagents/api-errors'
@@ -99,69 +148,167 @@ try {
99
148
  }
100
149
  ```
101
150
 
102
- ### Options
151
+ ### Separating global errors with `extractErrors`
152
+
153
+ `extractFieldErrors` folds non-field messages into `fallbackField`. When you want to render global errors (for example "You do not have permission") in their own banner, use `extractErrors`. It keeps them in a separate `formErrors` channel and reports the matched `format`, so you can distinguish an unrecognized body (`format` is `null`) from a recognized body with no errors.
154
+
155
+ ```ts
156
+ import { extractErrors } from '@codewithagents/api-errors'
157
+
158
+ try {
159
+ await createUser(data)
160
+ } catch (error) {
161
+ const { fieldErrors, formErrors, format } = extractErrors(error)
162
+
163
+ if (format === null) {
164
+ // Unrecognized shape: show a generic banner
165
+ showBanner('An unexpected error occurred.')
166
+ return
167
+ }
168
+
169
+ for (const { field, message } of fieldErrors) {
170
+ setError(field, { type: 'server', message })
171
+ }
172
+
173
+ if (formErrors.length > 0) {
174
+ setFormBanner(formErrors.join(' '))
175
+ }
176
+ }
177
+ ```
178
+
179
+ `ExtractResult` is the shape returned by `extractErrors`:
180
+
181
+ ```ts
182
+ interface ExtractResult {
183
+ fieldErrors: FieldError[]
184
+ formErrors: string[]
185
+ format: ErrorFormat | null
186
+ }
187
+ ```
188
+
189
+ ## Options
190
+
191
+ Every function accepts a `MapApiErrorsOptions` object.
103
192
 
104
- Both `extractFieldErrors` and `mapApiErrors` accept an options object:
193
+ | Option | Type | Behaviour |
194
+ | --- | --- | --- |
195
+ | `fallbackField` | `string` | Field name used when no field can be determined. Defaults to `'root'`. |
196
+ | `transformField` | `(field: string) => string` | Applied to every resolved field name, and to `fallbackField`. Maps backend camelCase to nested RHF dot-paths. |
197
+ | `statusCodes` | `number[]` | Restricts parsing to these HTTP status codes. If a detectable status is not in the list, the call returns empty immediately. If no status is detectable, parsing proceeds normally. |
198
+ | `resolveMessage` | `(message: string, field: string \| null) => string` | i18n / message reformat hook. Called for every field and form error before it is returned. `field` is `null` for global errors. |
199
+ | `parsers` | `ReadonlyArray<CustomParser>` | Custom parsers tried before the built-in ones, in order. The first non-null result wins. They receive the already-unwrapped body. |
105
200
 
106
201
  ```ts
107
202
  const fieldErrors = extractFieldErrors(error, {
108
203
  // Field name used when no field can be determined (default: 'root')
109
204
  fallbackField: 'serverError',
110
205
 
111
- // Transform field names, e.g. camelCase backend → dot.path for nested RHF fields
206
+ // Transform field names, e.g. camelCase backend to dot.path for nested RHF fields
112
207
  transformField: (f) => f.replace(/([A-Z])/g, '.$1').toLowerCase(),
113
208
  })
114
209
 
115
- // Options work on mapApiErrors too
116
- mapApiErrors(error, setError, { fallbackField: 'root' })
210
+ // Options work on every function
211
+ mapApiErrors(error, setError, { statusCodes: [422] })
212
+ ```
213
+
214
+ > **Note:** `transformField` is also applied to `fallbackField`. If you transform `emailAddress` to `email.address`, the fallback field name is transformed the same way.
215
+
216
+ ### Localizing messages with `resolveMessage`
217
+
218
+ ```ts
219
+ import { extractErrors } from '@codewithagents/api-errors'
220
+
221
+ extractErrors(error, {
222
+ resolveMessage: (msg, field) => t(`errors.${msg}`, { defaultValue: msg }),
223
+ })
117
224
  ```
118
225
 
119
- > **Note:** `transformField` is also applied to `fallbackField`. If you transform `emailAddress` → `email.address`, the fallback field name is transformed the same way.
226
+ ### Custom parsers
120
227
 
121
- ## Supported Error Formats
228
+ Register parsers for application-specific shapes. They run before the built-in parsers; return `null` to let the next one try.
122
229
 
123
- See the [full format reference](https://openapi.codewithagents.de/api-errors#supported-error-formats) in the docs for the complete parser-precedence rules and all edge cases.
230
+ ```ts
231
+ import { extractErrors } from '@codewithagents/api-errors'
232
+ import type { CustomParser, ParsedErrors } from '@codewithagents/api-errors'
233
+
234
+ const myParser: CustomParser = (body): ParsedErrors | null => {
235
+ if (typeof body !== 'object' || body === null || !('myErrors' in body)) return null
236
+ const fieldErrors = (body as any).myErrors.map((e: any) => ({ field: e.key, message: e.text }))
237
+ return { fieldErrors, formErrors: [] }
238
+ }
239
+
240
+ extractErrors(error, { parsers: [myParser] })
241
+ ```
124
242
 
125
- **RFC 7807 Problem Details** (Spring Boot 3+, standard):
243
+ ## Supported error formats
244
+
245
+ The format is detected automatically. Custom parsers run first; if the body is an array, the flat-array parser runs; otherwise the built-in object parsers are tried in order until the first match. See the [full format reference](https://openapi.codewithagents.de/api-errors#supported-error-formats) for the complete precedence rules and edge cases.
246
+
247
+ | Format | Recognized by |
248
+ | --- | --- |
249
+ | RFC 7807 / RFC 9457 Problem Details | `errors` object map of `field -> string \| string[]` (Spring Boot 3+, standard Problem Details) |
250
+ | RFC 9457 `violations` | `violations: [{ field, message }]` array |
251
+ | RFC 9457 `invalid-params` | `"invalid-params": [{ name, reason }]` array |
252
+ | RFC 9457 `detail` | top-level `detail` string (last-resort fallback) |
253
+ | JSON:API | `errors: [{ source: { pointer }, detail }]` array |
254
+ | GraphQL | `errors: [{ message, extensions: { field \| path } }]` array |
255
+ | Spring Boot (pre-3) | `errors: [{ field, defaultMessage }]` array |
256
+ | Laravel / DRF | top-level field map `{ field: string \| string[] }` |
257
+ | Zod `.flatten()` | `{ fieldErrors: { field: string[] }, formErrors: string[] }` |
258
+ | Flat object / array | `{ field, message }` or `[{ field, message }]` |
259
+
260
+ **RFC 7807 / RFC 9457 Problem Details with an `errors` map:**
126
261
  ```json
127
262
  {
128
- "type": "...",
263
+ "type": "https://example.com/errors/validation",
129
264
  "title": "Validation failed",
130
265
  "status": 400,
131
266
  "errors": {
132
267
  "email": ["must not be blank"],
133
- "name": ["too short"]
268
+ "name": ["too short", "must not contain numbers"]
134
269
  }
135
270
  }
136
271
  ```
137
272
 
138
- **Spring Boot default validation format** (older):
273
+ **RFC 9457 `violations` array:**
274
+ ```json
275
+ {
276
+ "status": 422,
277
+ "violations": [{ "field": "email", "message": "must not be blank" }]
278
+ }
279
+ ```
280
+
281
+ **Spring Boot default validation format (pre-3):**
139
282
  ```json
140
283
  {
141
284
  "status": 400,
142
- "errors": [
143
- { "field": "email", "defaultMessage": "must not be blank" }
144
- ]
285
+ "errors": [{ "field": "email", "defaultMessage": "must not be blank" }]
145
286
  }
146
287
  ```
147
288
 
148
- **Simple flat format** (custom APIs):
289
+ **Zod `.flatten()` output:**
149
290
  ```json
150
- { "field": "email", "message": "Invalid email" }
291
+ {
292
+ "fieldErrors": { "email": ["Invalid email"] },
293
+ "formErrors": ["At least one field must be provided."]
294
+ }
151
295
  ```
152
296
 
153
- **Array of flat objects:**
297
+ **Simple flat formats (custom APIs):**
298
+ ```json
299
+ { "field": "email", "message": "Invalid email" }
300
+ ```
154
301
  ```json
155
302
  [{ "field": "email", "message": "Invalid email" }]
156
303
  ```
157
304
 
158
- Response wrappers are automatically unwrapped: Axios-style `error.response.data` and generic `{ data: { ... } }` shapes are both handled.
305
+ Response wrappers are unwrapped before parsing: `{ status, body }` (`ApiError` from `openapi-zod-ts`), Axios-style `error.response.data`, and generic `{ data: { ... } }` shapes (only when `data` is a plain object).
159
306
 
160
307
  ## Known behaviour: multiple errors for the same field
161
308
 
162
309
  See the [multiple errors per field](https://openapi.codewithagents.de/api-errors#multiple-errors-per-field) section in the docs for a full example including grouping with `Map.groupBy`.
163
310
 
164
- When a backend returns multiple errors for the same field (e.g. in the flat array format), `extractFieldErrors` returns all of them. If you pass them all to React Hook Form's `setError`, the **last call wins**; only the last message is displayed. If you need to show all messages, collect them before calling `setError`:
311
+ When a backend returns multiple errors for the same field, `extractFieldErrors` returns all of them. If you pass them all to React Hook Form's `setError`, the **last call wins**; only the last message is displayed. To show all messages, group them before calling `setError`:
165
312
 
166
313
  ```ts
167
314
  const fieldErrors = extractFieldErrors(error)
@@ -172,10 +319,32 @@ for (const [field, errs] of grouped) {
172
319
  }
173
320
  ```
174
321
 
322
+ `mapApiErrorsToRecord` (and therefore the Formik and TanStack adapters) keeps each field's **first** message instead.
323
+
324
+ ## Ecosystem
325
+
326
+ `api-errors` is the runtime helper in the [openapi-zod-ts](https://github.com/codewithagents/openapi-zod-ts) toolchain. The four generators turn one OpenAPI 3.1 spec into the types, client, hooks, and mocks your app uses; `api-errors` maps the error envelopes those servers return back onto your form fields.
327
+
328
+ | Package | Role |
329
+ | --- | --- |
330
+ | [`openapi-zod-ts`](https://www.npmjs.com/package/openapi-zod-ts) | Generator: TypeScript models, native fetch client, and Zod schemas. Emits the `ApiError` class that `api-errors` unwraps automatically. |
331
+ | [`@codewithagents/openapi-server`](https://www.npmjs.com/package/@codewithagents/openapi-server) | Generator: framework-agnostic service interface plus optional `hono \| express \| fastify \| none` router. Emits the RFC 7807 / RFC 9457 envelopes `api-errors` parses. |
332
+ | [`@codewithagents/openapi-react-query`](https://www.npmjs.com/package/@codewithagents/openapi-react-query) | Generator: typed React Query v5 hooks. Call `mapApiErrors` in a `useMutation` `onError` to wire server validation to form fields. |
333
+ | [`@codewithagents/openapi-msw`](https://www.npmjs.com/package/@codewithagents/openapi-msw) | Generator: MSW v2 handlers with seeded Faker mock data, including error responses to exercise this package against. |
334
+ | **`@codewithagents/api-errors`** | Runtime helper (this package): maps server error envelopes to form-field errors. |
335
+
336
+ See the [petstore-fastify demo](https://github.com/codewithagents/openapi-zod-ts/tree/main/packages/petstore-fastify) for the canonical full-stack example that wires these together, including a cross-field validation error round-tripped from the server onto a form field.
337
+
175
338
  ## TypeScript
176
339
 
177
340
  This package is written in TypeScript and ships full type declarations. No `@types` package needed.
178
341
 
179
342
  ```ts
180
- import type { FieldError, MapApiErrorsOptions } from '@codewithagents/api-errors'
343
+ import type {
344
+ FieldError,
345
+ MapApiErrorsOptions,
346
+ ExtractResult,
347
+ ErrorFormat,
348
+ CustomParser,
349
+ } from '@codewithagents/api-errors'
181
350
  ```
@@ -72,9 +72,7 @@ function extractField(item) {
72
72
  // Fall back to extensions.path (array joined with `.`).
73
73
  const path = extensions['path'];
74
74
  if (Array.isArray(path) && path.length > 0) {
75
- const segments = path
76
- .filter((s) => typeof s === 'string' || typeof s === 'number')
77
- .map(String);
75
+ const segments = path.filter((s) => typeof s === 'string' || typeof s === 'number').map(String);
78
76
  if (segments.length > 0)
79
77
  return segments.join('.');
80
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graphql-extensions.js","sourceRoot":"","sources":["../../src/parsers/graphql-extensions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAA6B;IACrE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IAEvC,gGAAgG;IAChG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAAE,OAAO,IAAI,CAAA;IAEjD,MAAM,WAAW,GAAiB,EAAE,CAAA;IACpC,MAAM,UAAU,GAAa,EAAE,CAAA;IAE/B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAQ;QAC7B,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC5E,IAAI,OAAO,KAAK,IAAI;YAAE,SAAQ;QAE9B,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAChC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;QACtC,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAA;AACpC,CAAC;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;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC/F,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/parsers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE1D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,EAAE,CAE/D;AAeD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,CAgBpG;AA0BD,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAG3D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/parsers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE1D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,EAAE,CAE/D;AA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D,OAAO,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAChF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codewithagents/api-errors",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Map backend API errors to form field errors. Framework-agnostic core with React Hook Form adapter.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,6 +31,7 @@
31
31
  "zod",
32
32
  "field-errors"
33
33
  ],
34
+ "funding": "https://github.com/sponsors/codewithagents",
34
35
  "license": "MIT",
35
36
  "repository": {
36
37
  "type": "git",
@@ -41,6 +42,9 @@
41
42
  "url": "https://github.com/codewithagents/openapi-zod-ts/issues"
42
43
  },
43
44
  "author": "CodeWithAgents (https://codewithagents.de)",
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
44
48
  "devDependencies": {
45
49
  "@stryker-mutator/core": "catalog:",
46
50
  "@stryker-mutator/vitest-runner": "catalog:",