Repository navigation
Releases: thinknimble/tn-models
Release list
v5.0.0
Major Changes
-
Migrate from Zod 3 to Zod 4.
Breaking: the peer dependency is now
zod@^4.0.0. Consumers must upgrade to Zod 4. No public API changes beyond the peer requirement — seeMIGRATION.mdfor the upgrade path.- Update peer dependency to
zod@^4.0.0 - Type guards (
isZod*) discriminate on Zod 4'sschema.typestrings instead of_def.typeName/ZodFirstPartyTypeKind - Recursive snake/camel conversion updated for Zod 4 internals (catchall-based passthrough detection, raw
defaultValue, transparent branding) - TypeScript types move from
z.ZodTypeAnytoz.ZodType/z.core.SomeType - Inferred shape types preserve optional (
?) keys and enum primitives
- Update peer dependency to
v4.2.0
Minor Changes
- f61869a:
createApinow accepts any axios-like HTTP client via a structuralAxiosLikecontract, not only a concreteAxiosInstance. Existing axios consumers are unaffected (anAxiosInstancestill satisfiesAxiosLike); fetch-style wrappers and other clients with their own config/response types are now assignable as well. TheStringTrailingSlashURL brand is retained to guard against DjangoAPPEND_SLASHredirects.
v4.1.3
Patch Changes
- 36dbb7a: Correct the import examples in the README. Two of them told readers to import from
@thinknimble/tn-models-fp, which is deprecated on npm and frozen at 2.14.0. The README ships in the package, so the npm page showed those examples too.
v4.1.2
Patch Changes
- bbb4ed0: Point
repositoryandhomepageat the tn-models repository. Both still named the old tn-models-fp repository, so the links on the npm page sent readers to the previous name.
v4.0.1
v4.0.0
Major Changes
-
03d0b2f: # Breaking changes
Remove
readonlylibrary util in favor of nativez.ZodReadonly.Upgrades should remove the library
readonlysince it is not going to be handled anymore.Reasoning
Zod recently released a native way of handling readonly. Although this readonly is not exactly the same as what we call "readonly" from our db resources. It does allow us to mark fields as readonly and we can take advantage of this mark and make the corresponding type inferences to treat these fields as our own readonly.
Migration guide
- Upgrade Zod to >=3.23.8
- Remove any
import {readonly} from '@thinknimble/tn-models' - Replace any
readonly(zod)withzod.readonly()which is the native way of doing this with zod - That should be it!
v3.1.2
Patch Changes
- 187e807: Fix issue on
createCustomServiceCallwhere outputShapes with nested ZodBranded fields would cause the types for the resulting service call function to break.
v3.1.1
Patch Changes
- 35fb8f8: Add boolean to accepted types for filters
v3.1.0
Minor Changes
- 986108e: - Allow disabling warning logs with
disableLoggingWarningoption- Try-catch all
parsecalls so that users don't just get the intelligible zod error in console.
- Try-catch all
v3.0.0
Major Changes
-
2f61919: ## Migration Guide v2 - v3
What's new?
- Now all functions accept a single object as parameter. No more secondary parameters.
- Improvements on the type layer ( non perceptible from user perspective). Removed all overloads for functions which were a pain to maintain. Now a single function definition makes the inference for all possibilities.
How to migrate from v2
For a full fledged example on how to migrate you can check the test file changes on the v3 PR.
The summary is as follows:
createCustomServiceCall- The callback no longer is in the second parameter. Instead we provide it in the first parameter as a
cbfield
const testPost = createCustomServiceCall( { inputShape, outputShape, + cb: async ({ client, input, utils, slashEndingBaseUri }) => { + const toApiInput = utils.toApi(input) + const res = await client.post(slashEndingBaseUri, toApiInput) + const parsed = utils.fromApi(res.data) + return parsed + }, -async ({ client, input, utils, slashEndingBaseUri }) => { - const toApiInput = utils.toApi(input) - const res = await client.post(slashEndingBaseUri, toApiInput) - const parsed = utils.fromApi(res.data) - return parsed -} })createPaginatedServiceCall
- options (
uriandhttpMethod) are no longer in the second parameter. Instead we pass them in anoptsfield in the first parameter.
const paginatedServiceCall = createPaginatedServiceCall( { outputShape, inputShape, + opts: { + httpMethod: "post" + } }, - { httpMethod: "post" } )createApi- If you don't have any custom calls in the
createApicall then you should be good ✅ - If you do have custom calls, move the second parameter into a
customCallsfield in the first parameter.
const testApi = createApi( { baseUri, client: mockedAxios, + customCalls: { + testPost + } }, - { - testPost, - } )