@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.
- package/dist/Migration.cjs +9 -6
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.js +9 -6
- package/dist/Migration.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs +14 -0
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -0
- package/dist/lib/getOptionalLinkProperties.d.ts +12 -0
- package/dist/lib/getOptionalLinkProperties.js +14 -0
- package/dist/lib/getOptionalLinkProperties.js.map +1 -0
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.d.ts +11 -2
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.d.ts +7 -1
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +22 -11
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.d.ts +4 -2
- package/dist/lib/resolveMigrationDocumentData.js +22 -11
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.ts +2 -3
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.ts +3 -4
- package/dist/types/migration/Link.d.ts +19 -0
- package/dist/types/model/contentRelationship.d.ts +0 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.ts +1 -1
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +1 -0
- package/dist/types/value/contentRelationship.d.ts +5 -5
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.ts +39 -22
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +9 -7
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.ts +3 -5
- package/dist/types/value/richText.js.map +1 -1
- package/package.json +2 -2
- package/src/Migration.ts +8 -3
- package/src/lib/getOptionalLinkProperties.ts +27 -0
- package/src/lib/isMigrationValue.ts +11 -2
- package/src/lib/isValue.ts +7 -1
- package/src/lib/resolveMigrationDocumentData.ts +32 -13
- package/src/types/migration/Asset.ts +9 -11
- package/src/types/migration/ContentRelationship.ts +11 -9
- package/src/types/migration/Link.ts +19 -0
- package/src/types/model/contentRelationship.ts +0 -1
- package/src/types/model/link.ts +1 -1
- package/src/types/model/linkToMedia.ts +1 -0
- package/src/types/value/contentRelationship.ts +6 -5
- package/src/types/value/link.ts +63 -33
- package/src/types/value/linkToMedia.ts +9 -9
- package/src/types/value/richText.ts +3 -11
package/src/types/value/link.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AnyRegularField, FieldState } from "./types"
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { FilledContentRelationshipField } from "./contentRelationship"
|
|
4
4
|
import type { GroupField } from "./group"
|
|
5
|
-
import type {
|
|
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
|
|
48
|
-
*
|
|
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
|
|
60
|
-
:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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 {
|
|
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
|
-
|
|
13
|
-
|
|
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
|
|
20
|
+
export type FilledLinkToMediaField = {
|
|
19
21
|
id: string
|
|
20
|
-
link_type:
|
|
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
|
-
|
|
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 {
|
|
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
|