Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getRepositoryEndpoint(), getRepositoryName(), isRepositoryName(), isRepositoryEndpoint(); deprecate getEndpoint() #222

Merged
merged 7 commits into from
Feb 16, 2022

Conversation

angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Feb 11, 2022

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR adds the following repository endpoint helpers:

  • getRepositoryEndpoint(): Rename of getEndpoint()
  • getRepositoryName(): Extracts the repository name from a standard Prismic Rest API V2 endpoint
  • isRepositoryEndpoint(): Determines if an input is a valid repository endpoint
  • isRepositoryName(): Determines if an input is a valid repository name

See each helper's TSDocs for more in-depth descriptions.

This PR also introduces the following deprecations:

  • getEndpoint(): Replaced by getRepositoryEndpoint(). getEndpoint() will be removed in a future major release.

Related: prismicio/prismic-helpers#42

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

🐴

`getEndpoint()` is now deprecated and will be removed in a future major release.
…ndpoint()`

`getRepositoryEndpoint()` and `getGraphQLEndpoint()` use
`isRepositoryName()` to more safely construct the endpoints.
@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2022

Codecov Report

Merging #222 (428a35a) into master (283d5f0) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #222   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        23    +3     
  Lines          328       352   +24     
  Branches        63        65    +2     
=========================================
+ Hits           328       352   +24     
Impacted Files Coverage Δ
src/client.ts 100.00% <ø> (ø)
src/getGraphQLEndpoint.ts 100.00% <100.00%> (ø)
src/getRepositoryEndpoint.ts 100.00% <100.00%> (ø)
src/getRepositoryName.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)
src/isRepositoryEndpoint.ts 100.00% <100.00%> (ø)
src/isRepositoryName.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 283d5f0...428a35a. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Feb 11, 2022

size-limit report 📦

Path Size
dist/index.js 3.98 KB (+3.57% 🔺)
dist/index.cjs 6.79 KB (+2.27% 🔺)

@angeloashmore angeloashmore changed the title feat: add getRepositoryEndpoint(), getRepositoryName(), isRepositoryName(), isRepositoryEndpoint(); deprecate getEndpoint()` feat: add getRepositoryEndpoint(), getRepositoryName(), isRepositoryName(), isRepositoryEndpoint(); deprecate getEndpoint() Feb 11, 2022
@angeloashmore angeloashmore added the enhancement New feature or request label Feb 11, 2022
Copy link
Member

@lihbr lihbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just two very minor things, great job!

test/index.test.ts Outdated Show resolved Hide resolved
test/isRepositoryEndpoint.test.ts Outdated Show resolved Hide resolved
@samlfair
Copy link

@angeloashmore Should we change getEndpoint() to getRepositoryEndpoint() through the docs?

@lihbr
Copy link
Member

lihbr commented Feb 11, 2022

@angeloashmore Should we change getEndpoint() to getRepositoryEndpoint() through the docs?

Once this lands:

  • In technical references: yes
  • In guides: we can just remove them and teach user to just go createClient("my-repo-name") (createClient("https://my-repo-name.cdn.prismic.io/api/v2") also working but not recommended to teach this way as users might forget .cdn or use /api)

@samlfair
Copy link

@lihbr @angeloashmore Do you have an estimated timeline for this?

@lihbr
Copy link
Member

lihbr commented Feb 18, 2022

It has been shipped :) So we can start updating the doc accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants