@prismicio/client 7.14.0-alpha.0 → 7.14.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/Migration.cjs +9 -6
  2. package/dist/Migration.cjs.map +1 -1
  3. package/dist/Migration.js +9 -6
  4. package/dist/Migration.js.map +1 -1
  5. package/dist/lib/getOptionalLinkProperties.cjs +14 -0
  6. package/dist/lib/getOptionalLinkProperties.cjs.map +1 -0
  7. package/dist/lib/getOptionalLinkProperties.d.ts +12 -0
  8. package/dist/lib/getOptionalLinkProperties.js +14 -0
  9. package/dist/lib/getOptionalLinkProperties.js.map +1 -0
  10. package/dist/lib/isMigrationValue.cjs.map +1 -1
  11. package/dist/lib/isMigrationValue.d.ts +11 -2
  12. package/dist/lib/isMigrationValue.js.map +1 -1
  13. package/dist/lib/isValue.cjs.map +1 -1
  14. package/dist/lib/isValue.d.ts +7 -1
  15. package/dist/lib/isValue.js.map +1 -1
  16. package/dist/lib/resolveMigrationDocumentData.cjs +22 -11
  17. package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
  18. package/dist/lib/resolveMigrationDocumentData.d.ts +4 -2
  19. package/dist/lib/resolveMigrationDocumentData.js +22 -11
  20. package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
  21. package/dist/package.json.cjs +1 -1
  22. package/dist/package.json.js +1 -1
  23. package/dist/types/migration/Asset.cjs.map +1 -1
  24. package/dist/types/migration/Asset.d.ts +2 -3
  25. package/dist/types/migration/Asset.js.map +1 -1
  26. package/dist/types/migration/ContentRelationship.d.ts +3 -4
  27. package/dist/types/migration/Link.d.ts +19 -0
  28. package/dist/types/model/contentRelationship.d.ts +0 -1
  29. package/dist/types/model/link.cjs.map +1 -1
  30. package/dist/types/model/link.d.ts +1 -1
  31. package/dist/types/model/link.js.map +1 -1
  32. package/dist/types/model/linkToMedia.d.ts +1 -0
  33. package/dist/types/value/contentRelationship.d.ts +5 -5
  34. package/dist/types/value/link.cjs.map +1 -1
  35. package/dist/types/value/link.d.ts +39 -22
  36. package/dist/types/value/link.js.map +1 -1
  37. package/dist/types/value/linkToMedia.d.ts +9 -7
  38. package/dist/types/value/richText.cjs.map +1 -1
  39. package/dist/types/value/richText.d.ts +3 -5
  40. package/dist/types/value/richText.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/Migration.ts +8 -3
  43. package/src/lib/getOptionalLinkProperties.ts +27 -0
  44. package/src/lib/isMigrationValue.ts +11 -2
  45. package/src/lib/isValue.ts +7 -1
  46. package/src/lib/resolveMigrationDocumentData.ts +32 -13
  47. package/src/types/migration/Asset.ts +9 -11
  48. package/src/types/migration/ContentRelationship.ts +11 -9
  49. package/src/types/migration/Link.ts +19 -0
  50. package/src/types/model/contentRelationship.ts +0 -1
  51. package/src/types/model/link.ts +1 -1
  52. package/src/types/model/linkToMedia.ts +1 -0
  53. package/src/types/value/contentRelationship.ts +6 -5
  54. package/src/types/value/link.ts +63 -33
  55. package/src/types/value/linkToMedia.ts +9 -9
  56. package/src/types/value/richText.ts +3 -11
@@ -1,8 +1,8 @@
1
1
  import type { AnyRegularField, FieldState } from "./types"
2
2
 
3
- import type { ContentRelationshipField } from "./contentRelationship"
3
+ import type { FilledContentRelationshipField } from "./contentRelationship"
4
4
  import type { GroupField } from "./group"
5
- import type { LinkToMediaField } from "./linkToMedia"
5
+ import type { FilledLinkToMediaField } from "./linkToMedia"
6
6
  import type { SliceZone } from "./sliceZone"
7
7
 
8
8
  /**
@@ -15,37 +15,13 @@ export const LinkType = {
15
15
  Web: "Web",
16
16
  } as const
17
17
 
18
- /**
19
- * For link fields that haven't been filled
20
- *
21
- * @typeParam Type - The type of link.
22
- */
23
- export type EmptyLinkField<
24
- Type extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,
25
- > = {
26
- link_type: Type | string
27
- text?: string
28
- variant?: string
29
- }
30
-
31
- /**
32
- * Link that points to external website
33
- */
34
- export interface FilledLinkToWebField {
35
- link_type: typeof LinkType.Web
36
- url: string
37
- target?: string
38
- text?: string
39
- variant?: string
40
- }
41
-
42
18
  /**
43
19
  * A link field.
44
20
  *
45
21
  * @typeParam TypeEnum - Type API ID of the document.
46
22
  * @typeParam LangEnum - Language API ID of the document.
47
- * @typeParam DataInterface - Data fields for the document (filled in via
48
- * GraphQuery of `fetchLinks`).
23
+ * @typeParam DataInterface - Data fields for the document (filled via the
24
+ * `fetchLinks` or `graphQuery` query parameter).
49
25
  * @typeParam State - State of the field which determines its shape.
50
26
  */
51
27
  export type LinkField<
@@ -56,8 +32,62 @@ export type LinkField<
56
32
  | unknown = unknown,
57
33
  State extends FieldState = FieldState,
58
34
  > = State extends "empty"
59
- ? EmptyLinkField<typeof LinkType.Any>
60
- :
61
- | ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
62
- | FilledLinkToWebField
63
- | LinkToMediaField<State>
35
+ ? EmptyLinkField
36
+ : FilledLinkField<TypeEnum, LangEnum, DataInterface>
37
+
38
+ /**
39
+ * A link field that is filled.
40
+ *
41
+ * @typeParam TypeEnum - Type API ID of the document.
42
+ * @typeParam LangEnum - Language API ID of the document.
43
+ * @typeParam DataInterface - Data fields for the document (filled via the
44
+ * `fetchLinks` or `graphQuery` query parameter).
45
+ */
46
+ export type FilledLinkField<
47
+ TypeEnum = string,
48
+ LangEnum = string,
49
+ DataInterface extends
50
+ | Record<string, AnyRegularField | GroupField | SliceZone>
51
+ | unknown = unknown,
52
+ > = (
53
+ | FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>
54
+ | FilledLinkToMediaField
55
+ | FilledLinkToWebField
56
+ ) &
57
+ OptionalLinkProperties
58
+
59
+ /**
60
+ * A link field that is not filled.
61
+ *
62
+ * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,
63
+ * **please remove it**.
64
+ */
65
+ export type EmptyLinkField<
66
+ _Unused extends
67
+ (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,
68
+ > = {
69
+ link_type: "Any"
70
+ } & OptionalLinkProperties
71
+
72
+ /**
73
+ * A link field pointing to a relative or absolute URL.
74
+ */
75
+ export type FilledLinkToWebField = {
76
+ link_type: "Web"
77
+ url: string
78
+ target?: string
79
+ } & OptionalLinkProperties
80
+
81
+ /**
82
+ * Optional properties available to link fields. It is used to augment existing
83
+ * link-like fields (like content relationship fields) with field-specific
84
+ * properties.
85
+ *
86
+ * @internal
87
+ */
88
+ // Remember to update the `getOptionalLinkProperties()` function when updating
89
+ // this type. The function should check for every property.
90
+ export type OptionalLinkProperties = {
91
+ text?: string
92
+ variant?: string
93
+ }
@@ -1,6 +1,6 @@
1
1
  import type { FieldState } from "./types"
2
2
 
3
- import type { EmptyLinkField, LinkType } from "./link"
3
+ import type { OptionalLinkProperties } from "./link"
4
4
 
5
5
  /**
6
6
  * A link field that points to media.
@@ -8,22 +8,22 @@ import type { EmptyLinkField, LinkType } from "./link"
8
8
  * @typeParam State - State of the field which determines its shape.
9
9
  */
10
10
  export type LinkToMediaField<State extends FieldState = FieldState> =
11
- State extends "empty"
12
- ? EmptyLinkField<typeof LinkType.Media>
13
- : FilledLinkToMediaField
11
+ State extends "empty" ? EmptyLinkToMediaField : FilledLinkToMediaField
12
+
13
+ type EmptyLinkToMediaField = {
14
+ link_type: "Any"
15
+ } & OptionalLinkProperties
14
16
 
15
17
  /**
16
18
  * A link that points to media.
17
19
  */
18
- export interface FilledLinkToMediaField {
20
+ export type FilledLinkToMediaField = {
19
21
  id: string
20
- link_type: typeof LinkType.Media
22
+ link_type: "Media"
21
23
  name: string
22
24
  kind: string
23
25
  url: string
24
26
  size: string
25
27
  height?: string | null
26
28
  width?: string | null
27
- text?: string
28
- variant?: string
29
- }
29
+ } & OptionalLinkProperties
@@ -1,9 +1,7 @@
1
1
  import type { FieldState } from "./types"
2
2
 
3
- import type { FilledContentRelationshipField } from "./contentRelationship"
4
3
  import type { EmbedField } from "./embed"
5
- import type { FilledLinkToWebField } from "./link"
6
- import type { FilledLinkToMediaField } from "./linkToMedia"
4
+ import type { FilledLinkField } from "./link"
7
5
 
8
6
  /**
9
7
  * Types enum for RichTextNodes
@@ -176,10 +174,7 @@ export type RTImageNode = {
176
174
  zoom: number
177
175
  background: string
178
176
  }
179
- linkTo?:
180
- | FilledContentRelationshipField
181
- | FilledLinkToWebField
182
- | FilledLinkToMediaField
177
+ linkTo?: FilledLinkField
183
178
  }
184
179
 
185
180
  /**
@@ -199,10 +194,7 @@ export type RTEmbedNode = {
199
194
  */
200
195
  export interface RTLinkNode extends RTSpanNodeBase {
201
196
  type: typeof RichTextNodeType.hyperlink
202
- data:
203
- | FilledContentRelationshipField
204
- | FilledLinkToWebField
205
- | FilledLinkToMediaField
197
+ data: FilledLinkField
206
198
  }
207
199
 
208
200
  // Serialization related nodes