Skip to content

Releases: thinknimble/tn-models

v5.0.0

Choose a tag to compare

@github-actions github-actions released this 04 Sep 19:35
9ac7277

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 — see MIGRATION.md for the upgrade path.

    • Update peer dependency to zod@^4.0.0
    • Type guards (isZod*) discriminate on Zod 4's schema.type strings 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.ZodTypeAny to z.ZodType / z.core.SomeType
    • Inferred shape types preserve optional (?) keys and enum primitives

v4.2.0

Choose a tag to compare

@github-actions github-actions released this 04 Sep 18:18

Minor Changes

  • f61869a: createApi now accepts any axios-like HTTP client via a structural AxiosLike contract, not only a concrete AxiosInstance. Existing axios consumers are unaffected (an AxiosInstance still satisfies AxiosLike); fetch-style wrappers and other clients with their own config/response types are now assignable as well. The StringTrailingSlash URL brand is retained to guard against Django APPEND_SLASH redirects.

v4.1.3

Choose a tag to compare

@github-actions github-actions released this 18 Aug 22:09
8fad2b3

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

Choose a tag to compare

@github-actions github-actions released this 18 Aug 22:04
b429239

Patch Changes

  • bbb4ed0: Point repository and homepage at 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

Choose a tag to compare

@github-actions github-actions released this 05 Mar 11:59
b9dd30a

Patch Changes

  • 62e6ff9: Fix issue with custom calls returning readonly fields which would cause unnecessary type issues on end users of the library.
  • 403194d: Swap strip with unwrap
  • 9c894a9: Remove readonly from custom call outputs

v4.0.0

Choose a tag to compare

@github-actions github-actions released this 21 Nov 17:09
eb7f99b

Major Changes

  • 03d0b2f: # Breaking changes

    Remove readonly library util in favor of native z.ZodReadonly.

    Upgrades should remove the library readonly since 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) with zod.readonly() which is the native way of doing this with zod
    • That should be it!

v3.1.2

Choose a tag to compare

@github-actions github-actions released this 18 Oct 21:44
4d5274a

Patch Changes

  • 187e807: Fix issue on createCustomServiceCall where outputShapes with nested ZodBranded fields would cause the types for the resulting service call function to break.

v3.1.1

Choose a tag to compare

@github-actions github-actions released this 12 Sep 15:38
70311ba

Patch Changes

  • 35fb8f8: Add boolean to accepted types for filters

v3.1.0

Choose a tag to compare

@github-actions github-actions released this 29 May 09:45
6280b8d

Minor Changes

  • 986108e: - Allow disabling warning logs with disableLoggingWarning option
    • Try-catch all parse calls so that users don't just get the intelligible zod error in console.

v3.0.0

Choose a tag to compare

@github-actions github-actions released this 28 Apr 15:11
a9a123d

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 cb field
    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 (uri and httpMethod) are no longer in the second parameter. Instead we pass them in an opts field 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 createApi call then you should be good ✅
    • If you do have custom calls, move the second parameter into a customCalls field in the first parameter.
    const testApi = createApi(
      {
        baseUri,
        client: mockedAxios,
    +   customCalls: {
    +     testPost
    +   }
      },
    -  {
    -    testPost,
    -  }
    )