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

refactor(fields): use oembed specs for embed field #24

Closed lihbr closed 2 years ago

lihbr commented 2 years ago

Types of changes

Description

Since the API follows carefully the oEmbed spec, this PR refactors the embed field definition to follow the specification and allow for better type guarding. See:

Have been deprecated:

I changed EmbedField first generic to extend AnyOEmbed (previously Record<string, unknown>) to enforce provided type to extend a valid oEmbed response. This is technically a breaking change for TypeScript users that were using that generic, however, as long as they were extending CommonEmbedData they won't face any issue. Given the specificity of it we can consider it as a minor one I think, more of a bug fix.

Fixes: https://github.com/prismicio/prismic-client/issues/216 (if this PR lands, you might need to update your comment there for the posterity of that question @angeloashmore)

Checklist:

🦩

codecov-commenter commented 2 years ago

Codecov Report

Merging #24 (ca708f2) into master (71035a2) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #24   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           15        17    +2     
=========================================
+ Hits            15        17    +2     
Impacted Files Coverage Δ
src/fields.ts 100.00% <100.00%> (ø)
src/index.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 71035a2...ca708f2. Read the comment docs.

lihbr commented 2 years ago

Alright, should be good, let me know 👌

angeloashmore commented 2 years ago

Awesome, updates look good to me!