@prismicio/client 7.12.0-alpha.0 → 7.13.0-alpha.0
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/Client.cjs +47 -7
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.ts +20 -2
- package/dist/Client.js +47 -7
- package/dist/Client.js.map +1 -1
- package/dist/helpers/asLink.cjs +7 -9
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.js +7 -9
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/isFilled.cjs +4 -3
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.ts +11 -3
- package/dist/helpers/isFilled.js +4 -3
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +1 -6
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +1 -6
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +3 -0
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +3 -0
- package/dist/lib/serializerHelpers.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 +3 -3
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +0 -1
- package/dist/types/model/linkToMedia.d.ts +0 -1
- package/dist/types/value/contentRelationship.d.ts +1 -24
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.ts +3 -26
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +1 -13
- package/dist/types/value/types.d.ts +5 -1
- package/package.json +9 -9
- package/src/Client.ts +74 -7
- package/src/helpers/asLink.ts +8 -11
- package/src/helpers/isFilled.ts +16 -7
- package/src/index.ts +1 -1
- package/src/lib/resolveMigrationDocumentData.ts +3 -10
- package/src/lib/serializerHelpers.ts +5 -0
- package/src/types/migration/Asset.ts +4 -7
- package/src/types/model/contentRelationship.ts +0 -1
- package/src/types/model/linkToMedia.ts +0 -1
- package/src/types/value/contentRelationship.ts +2 -45
- package/src/types/value/link.ts +6 -49
- package/src/types/value/linkToMedia.ts +2 -21
- package/src/types/value/types.ts +9 -0
|
@@ -5,7 +5,7 @@ import type { EmptyLinkField, LinkType } from "./link"
|
|
|
5
5
|
import type { SliceZone } from "./sliceZone"
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Field for related documents
|
|
9
9
|
*
|
|
10
10
|
* @typeParam TypeEnum - Type API ID of the document.
|
|
11
11
|
* @typeParam LangEnum - Language API ID of the document.
|
|
@@ -13,7 +13,7 @@ import type { SliceZone } from "./sliceZone"
|
|
|
13
13
|
* GraphQuery of `fetchLinks`).
|
|
14
14
|
* @typeParam State - State of the field which determines its shape.
|
|
15
15
|
*/
|
|
16
|
-
export type
|
|
16
|
+
export type ContentRelationshipField<
|
|
17
17
|
TypeEnum = string,
|
|
18
18
|
LangEnum = string,
|
|
19
19
|
DataInterface extends
|
|
@@ -24,49 +24,6 @@ export type SingleContentRelationshipField<
|
|
|
24
24
|
? EmptyLinkField<typeof LinkType.Document>
|
|
25
25
|
: FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* Repeatable field value for related documents
|
|
29
|
-
*
|
|
30
|
-
* @typeParam TypeEnum - Type API ID of the document.
|
|
31
|
-
* @typeParam LangEnum - Language API ID of the document.
|
|
32
|
-
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
33
|
-
* GraphQuery of `fetchLinks`).
|
|
34
|
-
* @typeParam State - State of the field which determines its shape.
|
|
35
|
-
*/
|
|
36
|
-
export type RepeatableContentRelationshipField<
|
|
37
|
-
TypeEnum = string,
|
|
38
|
-
LangEnum = string,
|
|
39
|
-
DataInterface extends
|
|
40
|
-
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
41
|
-
| unknown = unknown,
|
|
42
|
-
State extends FieldState = FieldState,
|
|
43
|
-
> = State extends "empty"
|
|
44
|
-
? []
|
|
45
|
-
: [
|
|
46
|
-
SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface>,
|
|
47
|
-
...SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface>[],
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Field for related documents
|
|
52
|
-
*
|
|
53
|
-
* @typeParam TypeEnum - Type API ID of the document.
|
|
54
|
-
* @typeParam LangEnum - Language API ID of the document.
|
|
55
|
-
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
56
|
-
* GraphQuery of `fetchLinks`).
|
|
57
|
-
* @typeParam State - State of the field which determines its shape.
|
|
58
|
-
*/
|
|
59
|
-
export type ContentRelationshipField<
|
|
60
|
-
TypeEnum = string,
|
|
61
|
-
LangEnum = string,
|
|
62
|
-
DataInterface extends
|
|
63
|
-
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
64
|
-
| unknown = unknown,
|
|
65
|
-
State extends FieldState = FieldState,
|
|
66
|
-
> =
|
|
67
|
-
| SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
68
|
-
| RepeatableContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
69
|
-
|
|
70
27
|
/**
|
|
71
28
|
* Links that refer to documents
|
|
72
29
|
*/
|
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 { ContentRelationshipField } from "./contentRelationship"
|
|
4
4
|
import type { GroupField } from "./group"
|
|
5
|
-
import type {
|
|
5
|
+
import type { LinkToMediaField } from "./linkToMedia"
|
|
6
6
|
import type { SliceZone } from "./sliceZone"
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -38,7 +38,7 @@ export interface FilledLinkToWebField {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* A
|
|
41
|
+
* A link field.
|
|
42
42
|
*
|
|
43
43
|
* @typeParam TypeEnum - Type API ID of the document.
|
|
44
44
|
* @typeParam LangEnum - Language API ID of the document.
|
|
@@ -46,7 +46,7 @@ export interface FilledLinkToWebField {
|
|
|
46
46
|
* GraphQuery of `fetchLinks`).
|
|
47
47
|
* @typeParam State - State of the field which determines its shape.
|
|
48
48
|
*/
|
|
49
|
-
export type
|
|
49
|
+
export type LinkField<
|
|
50
50
|
TypeEnum = string,
|
|
51
51
|
LangEnum = string,
|
|
52
52
|
DataInterface extends
|
|
@@ -56,49 +56,6 @@ export type SingleLinkField<
|
|
|
56
56
|
> = State extends "empty"
|
|
57
57
|
? EmptyLinkField<typeof LinkType.Any>
|
|
58
58
|
:
|
|
59
|
-
|
|
|
59
|
+
| ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
60
60
|
| FilledLinkToWebField
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A repeatable link field value.
|
|
65
|
-
*
|
|
66
|
-
* @typeParam TypeEnum - Type API ID of the document.
|
|
67
|
-
* @typeParam LangEnum - Language API ID of the document.
|
|
68
|
-
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
69
|
-
* GraphQuery of `fetchLinks`).
|
|
70
|
-
* @typeParam State - State of the field which determines its shape.
|
|
71
|
-
*/
|
|
72
|
-
export type RepeatableLinkFieldValue<
|
|
73
|
-
TypeEnum = string,
|
|
74
|
-
LangEnum = string,
|
|
75
|
-
DataInterface extends
|
|
76
|
-
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
77
|
-
| unknown = unknown,
|
|
78
|
-
State extends FieldState = FieldState,
|
|
79
|
-
> = State extends "empty"
|
|
80
|
-
? []
|
|
81
|
-
: [
|
|
82
|
-
SingleLinkField<TypeEnum, LangEnum, DataInterface>,
|
|
83
|
-
...SingleLinkField<TypeEnum, LangEnum, DataInterface>[],
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* A link field.
|
|
88
|
-
*
|
|
89
|
-
* @typeParam TypeEnum - Type API ID of the document.
|
|
90
|
-
* @typeParam LangEnum - Language API ID of the document.
|
|
91
|
-
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
92
|
-
* GraphQuery of `fetchLinks`).
|
|
93
|
-
* @typeParam State - State of the field which determines its shape.
|
|
94
|
-
*/
|
|
95
|
-
export type LinkField<
|
|
96
|
-
TypeEnum = string,
|
|
97
|
-
LangEnum = string,
|
|
98
|
-
DataInterface extends
|
|
99
|
-
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
100
|
-
| unknown = unknown,
|
|
101
|
-
State extends FieldState = FieldState,
|
|
102
|
-
> =
|
|
103
|
-
| SingleLinkField<TypeEnum, LangEnum, DataInterface, State>
|
|
104
|
-
| RepeatableLinkFieldValue<TypeEnum, LangEnum, DataInterface, State>
|
|
61
|
+
| LinkToMediaField<State>
|
|
@@ -3,34 +3,15 @@ import type { FieldState } from "./types"
|
|
|
3
3
|
import type { EmptyLinkField, LinkType } from "./link"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A
|
|
6
|
+
* A link field that points to media.
|
|
7
7
|
*
|
|
8
8
|
* @typeParam State - State of the field which determines its shape.
|
|
9
9
|
*/
|
|
10
|
-
export type
|
|
10
|
+
export type LinkToMediaField<State extends FieldState = FieldState> =
|
|
11
11
|
State extends "empty"
|
|
12
12
|
? EmptyLinkField<typeof LinkType.Media>
|
|
13
13
|
: FilledLinkToMediaField
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Repeatable link field values that point to media.
|
|
17
|
-
*
|
|
18
|
-
* @typeParam State - State of the field which determines its shape.
|
|
19
|
-
*/
|
|
20
|
-
export type RepeatableLinkToMediaField<State extends FieldState = FieldState> =
|
|
21
|
-
State extends "empty"
|
|
22
|
-
? []
|
|
23
|
-
: [SingleLinkToMediaField, ...SingleLinkToMediaField[]]
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A link field that points to media.
|
|
27
|
-
*
|
|
28
|
-
* @typeParam State - State of the field which determines its shape.
|
|
29
|
-
*/
|
|
30
|
-
export type LinkToMediaField<State extends FieldState = FieldState> =
|
|
31
|
-
| SingleLinkToMediaField<State>
|
|
32
|
-
| RepeatableLinkToMediaField<State>
|
|
33
|
-
|
|
34
15
|
/**
|
|
35
16
|
* A link that points to media.
|
|
36
17
|
*/
|
package/src/types/value/types.ts
CHANGED
|
@@ -35,6 +35,7 @@ export type AnyRegularField =
|
|
|
35
35
|
| ImageField
|
|
36
36
|
| ContentRelationshipField
|
|
37
37
|
| LinkField
|
|
38
|
+
| Repeatable<LinkField>
|
|
38
39
|
| LinkToMediaField
|
|
39
40
|
| EmbedField
|
|
40
41
|
| DateField
|
|
@@ -52,6 +53,14 @@ export type AnyRegularField =
|
|
|
52
53
|
*/
|
|
53
54
|
export type AnySlicePrimaryField = GroupField | AnyRegularField
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A list of repeatable fields.
|
|
58
|
+
*/
|
|
59
|
+
export type Repeatable<
|
|
60
|
+
Field extends LinkField,
|
|
61
|
+
State extends FieldState = FieldState,
|
|
62
|
+
> = State extends "empty" ? [] : [Field, ...Field[]]
|
|
63
|
+
|
|
55
64
|
/**
|
|
56
65
|
* Useful to flatten the type output to improve type hints shown in editors. And
|
|
57
66
|
* also to transform an interface into a type to aide with assignability.
|