prismicio / prismic-types

Type definitions for Prismic content, models, and APIs
https://prismic.io/docs/technologies/javascript
Apache License 2.0
11 stars 4 forks source link

Add LinkResolver, ResolvedApi, ApiSearchResponse types #21

Closed Joaovsa7 closed 2 years ago

Joaovsa7 commented 2 years ago

Is your feature request related to a problem? Please describe.

Hey people, i wish you all well.

I have a internal package on company to make some queries that isn't available on @prismicio/client and other queries that are used by a lot of projects. We created this package to unify the code on a unique place.

So, i updated the @prismicio/client to v6 and added @prismicio/types and i realized that some types had gone.

Some of them:

LinkResolver, ResolvedApi, ApiSearchRespons, QueryOptions

Describe the solution you'd like

I would like to know why these types were removed on v6 because i

Describe alternatives you've considered

Open a issue on this repository ;)

lihbr commented 2 years ago

Hey @Joaovsa7, thanks for your contribution and glad you're using types!

We try to have types being emitted by their responsible package, usually it goes like this:

With that in mind, this only concerns new kits (@prismicio/client@6, @prismicio/helpers@2, etc.) and that's why older kits like @prismicio/client@5 were containing some types they weren't responsible for (e.g. LinkResolver in @prismicio/client@5)

To learn more about these new kits:

Where are the new types?

Here's to help you where you can find replacements (and overall more complete) types that you're looking for (OldType > Equivalent using new kits):

Let us know if that answers your question, if not feel free to reopen ☺️

Joaovsa7 commented 2 years ago

Hey @Joaovsa7, thanks for your contribution and glad you're using types!

We try to have types being emitted by their responsible package, usually it goes like this:

  • Something from the API? > @prismicio/types (e.g. ResolvedApi would be in @prismicio/types)
  • Something introduced by a package? > said-package (e.g. LinkResolver would be @prismicio/helpers (formerly prismic-dom))

With that in mind, this only concerns new kits (@prismicio/client@6, @prismicio/helpers@2, etc.) and that's why older kits like @prismicio/client@5 were containing some types they weren't responsible for (e.g. LinkResolver in @prismicio/client@5)

To learn more about these new kits:

Where are the new types?

Here's to help you where you can find replacements (and overall more complete) types that you're looking for (OldType > Equivalent using new kits):

  • LinkResolver > import { LinkResolverFunction } from "@prismicio/helpers";
  • ResolvedApi > import { Repository } from "@prismicio/types";
  • ApiSearchRespons > import { Query } from "@prismicio/types";
  • QueryOptions > import { BuildQueryURLArgs } from "@prismicio/client";

Let us know if that answers your question, if not feel free to reopen ☺️

Hey @lihbr,

Thank you soooo much for your reply & help!

The prismicio/types is a awesome package and it save a lot of time on my team, bc we don't need to write all of prismic types.

Thank you so much :)