@prismicio/client 7.21.2 → 7.21.3-pr.431.23cc5c6
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/iac/customType.cjs +54 -0
- package/dist/iac/customType.cjs.map +1 -0
- package/dist/iac/customType.d.cts +43 -0
- package/dist/iac/customType.d.cts.map +1 -0
- package/dist/iac/customType.d.ts +43 -0
- package/dist/iac/customType.d.ts.map +1 -0
- package/dist/iac/customType.js +53 -0
- package/dist/iac/customType.js.map +1 -0
- package/dist/iac/fields/boolean.cjs +38 -0
- package/dist/iac/fields/boolean.cjs.map +1 -0
- package/dist/iac/fields/boolean.d.cts +22 -0
- package/dist/iac/fields/boolean.d.cts.map +1 -0
- package/dist/iac/fields/boolean.d.ts +22 -0
- package/dist/iac/fields/boolean.d.ts.map +1 -0
- package/dist/iac/fields/boolean.js +38 -0
- package/dist/iac/fields/boolean.js.map +1 -0
- package/dist/iac/fields/color.cjs +29 -0
- package/dist/iac/fields/color.cjs.map +1 -0
- package/dist/iac/fields/color.d.cts +11 -0
- package/dist/iac/fields/color.d.cts.map +1 -0
- package/dist/iac/fields/color.d.ts +11 -0
- package/dist/iac/fields/color.d.ts.map +1 -0
- package/dist/iac/fields/color.js +29 -0
- package/dist/iac/fields/color.js.map +1 -0
- package/dist/iac/fields/contentRelationship.cjs +50 -0
- package/dist/iac/fields/contentRelationship.cjs.map +1 -0
- package/dist/iac/fields/contentRelationship.d.cts +23 -0
- package/dist/iac/fields/contentRelationship.d.cts.map +1 -0
- package/dist/iac/fields/contentRelationship.d.ts +23 -0
- package/dist/iac/fields/contentRelationship.d.ts.map +1 -0
- package/dist/iac/fields/contentRelationship.js +50 -0
- package/dist/iac/fields/contentRelationship.js.map +1 -0
- package/dist/iac/fields/date.cjs +29 -0
- package/dist/iac/fields/date.cjs.map +1 -0
- package/dist/iac/fields/date.d.cts +11 -0
- package/dist/iac/fields/date.d.cts.map +1 -0
- package/dist/iac/fields/date.d.ts +11 -0
- package/dist/iac/fields/date.d.ts.map +1 -0
- package/dist/iac/fields/date.js +29 -0
- package/dist/iac/fields/date.js.map +1 -0
- package/dist/iac/fields/embed.cjs +29 -0
- package/dist/iac/fields/embed.cjs.map +1 -0
- package/dist/iac/fields/embed.d.cts +11 -0
- package/dist/iac/fields/embed.d.cts.map +1 -0
- package/dist/iac/fields/embed.d.ts +11 -0
- package/dist/iac/fields/embed.d.ts.map +1 -0
- package/dist/iac/fields/embed.js +29 -0
- package/dist/iac/fields/embed.js.map +1 -0
- package/dist/iac/fields/geoPoint.cjs +26 -0
- package/dist/iac/fields/geoPoint.cjs.map +1 -0
- package/dist/iac/fields/geoPoint.d.cts +10 -0
- package/dist/iac/fields/geoPoint.d.cts.map +1 -0
- package/dist/iac/fields/geoPoint.d.ts +10 -0
- package/dist/iac/fields/geoPoint.d.ts.map +1 -0
- package/dist/iac/fields/geoPoint.js +26 -0
- package/dist/iac/fields/geoPoint.js.map +1 -0
- package/dist/iac/fields/group.cjs +38 -0
- package/dist/iac/fields/group.cjs.map +1 -0
- package/dist/iac/fields/group.d.cts +17 -0
- package/dist/iac/fields/group.d.cts.map +1 -0
- package/dist/iac/fields/group.d.ts +17 -0
- package/dist/iac/fields/group.d.ts.map +1 -0
- package/dist/iac/fields/group.js +38 -0
- package/dist/iac/fields/group.js.map +1 -0
- package/dist/iac/fields/image.cjs +48 -0
- package/dist/iac/fields/image.cjs.map +1 -0
- package/dist/iac/fields/image.d.cts +21 -0
- package/dist/iac/fields/image.d.cts.map +1 -0
- package/dist/iac/fields/image.d.ts +21 -0
- package/dist/iac/fields/image.d.ts.map +1 -0
- package/dist/iac/fields/image.js +48 -0
- package/dist/iac/fields/image.js.map +1 -0
- package/dist/iac/fields/integration.cjs +33 -0
- package/dist/iac/fields/integration.cjs.map +1 -0
- package/dist/iac/fields/integration.d.cts +15 -0
- package/dist/iac/fields/integration.d.cts.map +1 -0
- package/dist/iac/fields/integration.d.ts +15 -0
- package/dist/iac/fields/integration.d.ts.map +1 -0
- package/dist/iac/fields/integration.js +33 -0
- package/dist/iac/fields/integration.js.map +1 -0
- package/dist/iac/fields/link.cjs +45 -0
- package/dist/iac/fields/link.cjs.map +1 -0
- package/dist/iac/fields/link.d.cts +39 -0
- package/dist/iac/fields/link.d.cts.map +1 -0
- package/dist/iac/fields/link.d.ts +39 -0
- package/dist/iac/fields/link.d.ts.map +1 -0
- package/dist/iac/fields/link.js +45 -0
- package/dist/iac/fields/link.js.map +1 -0
- package/dist/iac/fields/linkToMedia.cjs +31 -0
- package/dist/iac/fields/linkToMedia.cjs.map +1 -0
- package/dist/iac/fields/linkToMedia.d.cts +11 -0
- package/dist/iac/fields/linkToMedia.d.cts.map +1 -0
- package/dist/iac/fields/linkToMedia.d.ts +11 -0
- package/dist/iac/fields/linkToMedia.d.ts.map +1 -0
- package/dist/iac/fields/linkToMedia.js +31 -0
- package/dist/iac/fields/linkToMedia.js.map +1 -0
- package/dist/iac/fields/number.cjs +29 -0
- package/dist/iac/fields/number.cjs.map +1 -0
- package/dist/iac/fields/number.d.cts +11 -0
- package/dist/iac/fields/number.d.cts.map +1 -0
- package/dist/iac/fields/number.d.ts +11 -0
- package/dist/iac/fields/number.d.ts.map +1 -0
- package/dist/iac/fields/number.js +29 -0
- package/dist/iac/fields/number.js.map +1 -0
- package/dist/iac/fields/richText.cjs +49 -0
- package/dist/iac/fields/richText.cjs.map +1 -0
- package/dist/iac/fields/richText.d.cts +33 -0
- package/dist/iac/fields/richText.d.cts.map +1 -0
- package/dist/iac/fields/richText.d.ts +33 -0
- package/dist/iac/fields/richText.d.ts.map +1 -0
- package/dist/iac/fields/richText.js +49 -0
- package/dist/iac/fields/richText.js.map +1 -0
- package/dist/iac/fields/select.cjs +46 -0
- package/dist/iac/fields/select.cjs.map +1 -0
- package/dist/iac/fields/select.d.cts +15 -0
- package/dist/iac/fields/select.d.cts.map +1 -0
- package/dist/iac/fields/select.d.ts +15 -0
- package/dist/iac/fields/select.d.ts.map +1 -0
- package/dist/iac/fields/select.js +46 -0
- package/dist/iac/fields/select.js.map +1 -0
- package/dist/iac/fields/sliceZone.cjs +37 -0
- package/dist/iac/fields/sliceZone.cjs.map +1 -0
- package/dist/iac/fields/sliceZone.d.cts +30 -0
- package/dist/iac/fields/sliceZone.d.cts.map +1 -0
- package/dist/iac/fields/sliceZone.d.ts +30 -0
- package/dist/iac/fields/sliceZone.d.ts.map +1 -0
- package/dist/iac/fields/sliceZone.js +37 -0
- package/dist/iac/fields/sliceZone.js.map +1 -0
- package/dist/iac/fields/table.cjs +26 -0
- package/dist/iac/fields/table.cjs.map +1 -0
- package/dist/iac/fields/table.d.cts +10 -0
- package/dist/iac/fields/table.d.cts.map +1 -0
- package/dist/iac/fields/table.d.ts +10 -0
- package/dist/iac/fields/table.d.ts.map +1 -0
- package/dist/iac/fields/table.js +26 -0
- package/dist/iac/fields/table.js.map +1 -0
- package/dist/iac/fields/text.cjs +29 -0
- package/dist/iac/fields/text.cjs.map +1 -0
- package/dist/iac/fields/text.d.cts +11 -0
- package/dist/iac/fields/text.d.cts.map +1 -0
- package/dist/iac/fields/text.d.ts +11 -0
- package/dist/iac/fields/text.d.ts.map +1 -0
- package/dist/iac/fields/text.js +29 -0
- package/dist/iac/fields/text.js.map +1 -0
- package/dist/iac/fields/timestamp.cjs +29 -0
- package/dist/iac/fields/timestamp.cjs.map +1 -0
- package/dist/iac/fields/timestamp.d.cts +11 -0
- package/dist/iac/fields/timestamp.d.cts.map +1 -0
- package/dist/iac/fields/timestamp.d.ts +11 -0
- package/dist/iac/fields/timestamp.d.ts.map +1 -0
- package/dist/iac/fields/timestamp.js +29 -0
- package/dist/iac/fields/timestamp.js.map +1 -0
- package/dist/iac/fields/uid.cjs +29 -0
- package/dist/iac/fields/uid.cjs.map +1 -0
- package/dist/iac/fields/uid.d.cts +11 -0
- package/dist/iac/fields/uid.d.cts.map +1 -0
- package/dist/iac/fields/uid.d.ts +11 -0
- package/dist/iac/fields/uid.d.ts.map +1 -0
- package/dist/iac/fields/uid.js +29 -0
- package/dist/iac/fields/uid.js.map +1 -0
- package/dist/iac/sharedSlice.cjs +54 -0
- package/dist/iac/sharedSlice.cjs.map +1 -0
- package/dist/iac/sharedSlice.d.cts +28 -0
- package/dist/iac/sharedSlice.d.cts.map +1 -0
- package/dist/iac/sharedSlice.d.ts +28 -0
- package/dist/iac/sharedSlice.d.ts.map +1 -0
- package/dist/iac/sharedSlice.js +54 -0
- package/dist/iac/sharedSlice.js.map +1 -0
- package/dist/iac/variation.cjs +45 -0
- package/dist/iac/variation.cjs.map +1 -0
- package/dist/iac/variation.d.cts +46 -0
- package/dist/iac/variation.d.cts.map +1 -0
- package/dist/iac/variation.d.ts +46 -0
- package/dist/iac/variation.d.ts.map +1 -0
- package/dist/iac/variation.js +44 -0
- package/dist/iac/variation.js.map +1 -0
- package/dist/iac.cjs +86 -0
- package/dist/iac.cjs.map +1 -0
- package/dist/iac.d.cts +109 -0
- package/dist/iac.d.cts.map +1 -0
- package/dist/iac.d.ts +110 -0
- package/dist/iac.d.ts.map +1 -0
- package/dist/iac.js +86 -0
- package/dist/iac.js.map +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/types/model/types.d.cts +2 -2
- package/dist/types/model/types.d.ts +2 -2
- package/package.json +9 -2
- package/src/iac/customType.ts +98 -0
- package/src/iac/fields/boolean.ts +55 -0
- package/src/iac/fields/color.ts +33 -0
- package/src/iac/fields/contentRelationship.ts +74 -0
- package/src/iac/fields/date.ts +33 -0
- package/src/iac/fields/embed.ts +33 -0
- package/src/iac/fields/geoPoint.ts +33 -0
- package/src/iac/fields/group.ts +58 -0
- package/src/iac/fields/image.ts +65 -0
- package/src/iac/fields/index.ts +62 -0
- package/src/iac/fields/integration.ts +43 -0
- package/src/iac/fields/link.ts +79 -0
- package/src/iac/fields/linkToMedia.ts +37 -0
- package/src/iac/fields/number.ts +35 -0
- package/src/iac/fields/richText.ts +84 -0
- package/src/iac/fields/select.ts +63 -0
- package/src/iac/fields/sliceZone.ts +82 -0
- package/src/iac/fields/table.ts +31 -0
- package/src/iac/fields/text.ts +33 -0
- package/src/iac/fields/timestamp.ts +35 -0
- package/src/iac/fields/uid.ts +33 -0
- package/src/iac/index.ts +122 -0
- package/src/iac/sharedSlice.ts +81 -0
- package/src/iac/variation.ts +107 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CustomTypeModelBooleanField } from "../../types/model/boolean"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a boolean field.
|
|
6
|
+
*/
|
|
7
|
+
export interface BooleanFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
/**
|
|
10
|
+
* Default value for the boolean field.
|
|
11
|
+
*/
|
|
12
|
+
default_value?: boolean
|
|
13
|
+
/**
|
|
14
|
+
* Placeholder text shown when the value is true.
|
|
15
|
+
*/
|
|
16
|
+
placeholder_true?: string
|
|
17
|
+
/**
|
|
18
|
+
* Placeholder text shown when the value is false.
|
|
19
|
+
*/
|
|
20
|
+
placeholder_false?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a boolean field model.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* model.boolean({ label: "Featured" })
|
|
30
|
+
*
|
|
31
|
+
* model.boolean({
|
|
32
|
+
* label: "Published",
|
|
33
|
+
* default_value: false,
|
|
34
|
+
* placeholder_true: "Published",
|
|
35
|
+
* placeholder_false: "Draft"
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param config - Configuration for the field.
|
|
40
|
+
*
|
|
41
|
+
* @returns A boolean field model.
|
|
42
|
+
*/
|
|
43
|
+
export const boolean = (
|
|
44
|
+
config?: BooleanFieldConfig,
|
|
45
|
+
): CustomTypeModelBooleanField => {
|
|
46
|
+
return {
|
|
47
|
+
type: CustomTypeModelFieldType.Boolean,
|
|
48
|
+
config: {
|
|
49
|
+
label: config?.label ?? null,
|
|
50
|
+
default_value: config?.default_value,
|
|
51
|
+
placeholder_true: config?.placeholder_true,
|
|
52
|
+
placeholder_false: config?.placeholder_false,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CustomTypeModelColorField } from "../../types/model/color"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a color field.
|
|
6
|
+
*/
|
|
7
|
+
export interface ColorFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
placeholder?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a color field model.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* model.color({ label: "Background Color" })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param config - Configuration for the field.
|
|
22
|
+
*
|
|
23
|
+
* @returns A color field model.
|
|
24
|
+
*/
|
|
25
|
+
export const color = (config?: ColorFieldConfig): CustomTypeModelColorField => {
|
|
26
|
+
return {
|
|
27
|
+
type: CustomTypeModelFieldType.Color,
|
|
28
|
+
config: {
|
|
29
|
+
label: config?.label ?? null,
|
|
30
|
+
placeholder: config?.placeholder,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CustomTypeModelContentRelationshipField } from "../../types/model/contentRelationship"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
import { CustomTypeModelLinkSelectType } from "../../types/model/link"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for a content relationship field.
|
|
7
|
+
*/
|
|
8
|
+
export interface ContentRelationshipFieldConfig<
|
|
9
|
+
CustomTypes extends string = string,
|
|
10
|
+
Tags extends string = string,
|
|
11
|
+
> {
|
|
12
|
+
label?: string | null
|
|
13
|
+
placeholder?: string
|
|
14
|
+
/**
|
|
15
|
+
* Custom types to allow linking to.
|
|
16
|
+
*
|
|
17
|
+
* @example ["blog_post", "author"] as const
|
|
18
|
+
*/
|
|
19
|
+
customtypes?: readonly CustomTypes[]
|
|
20
|
+
/**
|
|
21
|
+
* Tags to filter by.
|
|
22
|
+
*
|
|
23
|
+
* @example ["featured"] as const
|
|
24
|
+
*/
|
|
25
|
+
tags?: readonly Tags[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a content relationship field model.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* // Any document
|
|
35
|
+
* model.contentRelationship({ label: "Related Content" })
|
|
36
|
+
*
|
|
37
|
+
* // Specific custom types (type-safe)
|
|
38
|
+
* model.contentRelationship({
|
|
39
|
+
* label: "Author",
|
|
40
|
+
* customtypes: ["author", "contributor"] as const
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* // With tag filtering
|
|
44
|
+
* model.contentRelationship({
|
|
45
|
+
* label: "Featured Post",
|
|
46
|
+
* customtypes: ["blog_post"] as const,
|
|
47
|
+
* tags: ["featured"] as const
|
|
48
|
+
* })
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @typeParam CustomTypes - Custom type ID literals for type inference.
|
|
52
|
+
* @typeParam Tags - Tag literals for type inference.
|
|
53
|
+
*
|
|
54
|
+
* @param config - Configuration for the field.
|
|
55
|
+
*
|
|
56
|
+
* @returns A content relationship field model.
|
|
57
|
+
*/
|
|
58
|
+
export const contentRelationship = <
|
|
59
|
+
CustomTypes extends string = string,
|
|
60
|
+
Tags extends string = string,
|
|
61
|
+
>(
|
|
62
|
+
config?: ContentRelationshipFieldConfig<CustomTypes, Tags>,
|
|
63
|
+
): CustomTypeModelContentRelationshipField<CustomTypes, Tags> => {
|
|
64
|
+
return {
|
|
65
|
+
type: CustomTypeModelFieldType.Link,
|
|
66
|
+
config: {
|
|
67
|
+
label: config?.label ?? null,
|
|
68
|
+
placeholder: config?.placeholder,
|
|
69
|
+
select: CustomTypeModelLinkSelectType.Document,
|
|
70
|
+
customtypes: config?.customtypes,
|
|
71
|
+
tags: config?.tags,
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CustomTypeModelDateField } from "../../types/model/date"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a date field.
|
|
6
|
+
*/
|
|
7
|
+
export interface DateFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
placeholder?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a date field model.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* model.date({ label: "Publication Date" })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param config - Configuration for the field.
|
|
22
|
+
*
|
|
23
|
+
* @returns A date field model.
|
|
24
|
+
*/
|
|
25
|
+
export const date = (config?: DateFieldConfig): CustomTypeModelDateField => {
|
|
26
|
+
return {
|
|
27
|
+
type: CustomTypeModelFieldType.Date,
|
|
28
|
+
config: {
|
|
29
|
+
label: config?.label ?? null,
|
|
30
|
+
placeholder: config?.placeholder,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CustomTypeModelEmbedField } from "../../types/model/embed"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for an embed field.
|
|
6
|
+
*/
|
|
7
|
+
export interface EmbedFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
placeholder?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates an embed field model.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* model.embed({ label: "Video" })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param config - Configuration for the field.
|
|
22
|
+
*
|
|
23
|
+
* @returns An embed field model.
|
|
24
|
+
*/
|
|
25
|
+
export const embed = (config?: EmbedFieldConfig): CustomTypeModelEmbedField => {
|
|
26
|
+
return {
|
|
27
|
+
type: CustomTypeModelFieldType.Embed,
|
|
28
|
+
config: {
|
|
29
|
+
label: config?.label ?? null,
|
|
30
|
+
placeholder: config?.placeholder,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CustomTypeModelGeoPointField } from "../../types/model/geoPoint"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a geo point field.
|
|
6
|
+
*/
|
|
7
|
+
export interface GeoPointFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a geo point field model.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* model.geoPoint({ label: "Location" })
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param config - Configuration for the field.
|
|
21
|
+
*
|
|
22
|
+
* @returns A geo point field model.
|
|
23
|
+
*/
|
|
24
|
+
export const geoPoint = (
|
|
25
|
+
config?: GeoPointFieldConfig,
|
|
26
|
+
): CustomTypeModelGeoPointField => {
|
|
27
|
+
return {
|
|
28
|
+
type: CustomTypeModelFieldType.GeoPoint,
|
|
29
|
+
config: {
|
|
30
|
+
label: config?.label ?? null,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CustomTypeModelGroupField } from "../../types/model/group"
|
|
2
|
+
import type { CustomTypeModelFieldForGroup } from "../../types/model/types"
|
|
3
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for a group field.
|
|
7
|
+
*/
|
|
8
|
+
export interface GroupFieldConfig<
|
|
9
|
+
Fields extends Record<string, CustomTypeModelFieldForGroup> = Record<
|
|
10
|
+
string,
|
|
11
|
+
CustomTypeModelFieldForGroup
|
|
12
|
+
>,
|
|
13
|
+
> {
|
|
14
|
+
label?: string | null
|
|
15
|
+
/**
|
|
16
|
+
* Fields within the group.
|
|
17
|
+
*/
|
|
18
|
+
fields?: Fields
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a group field model.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* model.group({
|
|
28
|
+
* label: "Items",
|
|
29
|
+
* fields: {
|
|
30
|
+
* title: model.text({ label: "Title" }),
|
|
31
|
+
* image: model.image({ label: "Image" }),
|
|
32
|
+
* link: model.link({ label: "Link" })
|
|
33
|
+
* }
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @typeParam Fields - Field definitions for type inference.
|
|
38
|
+
*
|
|
39
|
+
* @param config - Configuration for the field.
|
|
40
|
+
*
|
|
41
|
+
* @returns A group field model.
|
|
42
|
+
*/
|
|
43
|
+
export const group = <
|
|
44
|
+
Fields extends Record<string, CustomTypeModelFieldForGroup> = Record<
|
|
45
|
+
string,
|
|
46
|
+
CustomTypeModelFieldForGroup
|
|
47
|
+
>,
|
|
48
|
+
>(
|
|
49
|
+
config?: GroupFieldConfig<Fields>,
|
|
50
|
+
): CustomTypeModelGroupField<Fields> => {
|
|
51
|
+
return {
|
|
52
|
+
type: CustomTypeModelFieldType.Group,
|
|
53
|
+
config: {
|
|
54
|
+
label: config?.label ?? null,
|
|
55
|
+
fields: config?.fields,
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomTypeModelImageConstraint,
|
|
3
|
+
CustomTypeModelImageField,
|
|
4
|
+
CustomTypeModelImageThumbnail,
|
|
5
|
+
} from "../../types/model/image"
|
|
6
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for an image field.
|
|
10
|
+
*/
|
|
11
|
+
export interface ImageFieldConfig<ThumbnailNames extends string = string> {
|
|
12
|
+
label?: string | null
|
|
13
|
+
/**
|
|
14
|
+
* Dimension constraints for the image.
|
|
15
|
+
*/
|
|
16
|
+
constraint?: CustomTypeModelImageConstraint
|
|
17
|
+
/**
|
|
18
|
+
* Thumbnails (responsive views) for the image.
|
|
19
|
+
*/
|
|
20
|
+
thumbnails?: readonly CustomTypeModelImageThumbnail<ThumbnailNames>[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates an image field model.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Simple image
|
|
30
|
+
* model.image({ label: "Hero Image" })
|
|
31
|
+
*
|
|
32
|
+
* // With constraints
|
|
33
|
+
* model.image({
|
|
34
|
+
* label: "Banner",
|
|
35
|
+
* constraint: { width: 1920, height: 1080 }
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* // With thumbnails (type-safe names)
|
|
39
|
+
* model.image({
|
|
40
|
+
* label: "Photo",
|
|
41
|
+
* thumbnails: [
|
|
42
|
+
* { name: "mobile", width: 640, height: 360 },
|
|
43
|
+
* { name: "tablet", width: 1024, height: 576 }
|
|
44
|
+
* ] as const
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @typeParam ThumbnailNames - Thumbnail name literals for type inference.
|
|
49
|
+
*
|
|
50
|
+
* @param config - Configuration for the field.
|
|
51
|
+
*
|
|
52
|
+
* @returns An image field model.
|
|
53
|
+
*/
|
|
54
|
+
export const image = <ThumbnailNames extends string = string>(
|
|
55
|
+
config?: ImageFieldConfig<ThumbnailNames>,
|
|
56
|
+
): CustomTypeModelImageField<ThumbnailNames> => {
|
|
57
|
+
return {
|
|
58
|
+
type: CustomTypeModelFieldType.Image,
|
|
59
|
+
config: {
|
|
60
|
+
label: config?.label ?? null,
|
|
61
|
+
constraint: config?.constraint,
|
|
62
|
+
thumbnails: config?.thumbnails,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Simple fields
|
|
2
|
+
export { boolean } from "./boolean"
|
|
3
|
+
export type { BooleanFieldConfig } from "./boolean"
|
|
4
|
+
|
|
5
|
+
export { color } from "./color"
|
|
6
|
+
export type { ColorFieldConfig } from "./color"
|
|
7
|
+
|
|
8
|
+
export { date } from "./date"
|
|
9
|
+
export type { DateFieldConfig } from "./date"
|
|
10
|
+
|
|
11
|
+
export { timestamp } from "./timestamp"
|
|
12
|
+
export type { TimestampFieldConfig } from "./timestamp"
|
|
13
|
+
|
|
14
|
+
export { number } from "./number"
|
|
15
|
+
export type { NumberFieldConfig } from "./number"
|
|
16
|
+
|
|
17
|
+
export { geoPoint } from "./geoPoint"
|
|
18
|
+
export type { GeoPointFieldConfig } from "./geoPoint"
|
|
19
|
+
|
|
20
|
+
export { embed } from "./embed"
|
|
21
|
+
export type { EmbedFieldConfig } from "./embed"
|
|
22
|
+
|
|
23
|
+
export { table } from "./table"
|
|
24
|
+
export type { TableFieldConfig } from "./table"
|
|
25
|
+
|
|
26
|
+
// Text fields
|
|
27
|
+
export { text } from "./text"
|
|
28
|
+
export type { TextFieldConfig } from "./text"
|
|
29
|
+
|
|
30
|
+
export { richText } from "./richText"
|
|
31
|
+
export type { RichTextFieldConfig } from "./richText"
|
|
32
|
+
|
|
33
|
+
// Media fields
|
|
34
|
+
export { image } from "./image"
|
|
35
|
+
export type { ImageFieldConfig } from "./image"
|
|
36
|
+
|
|
37
|
+
export { linkToMedia } from "./linkToMedia"
|
|
38
|
+
export type { LinkToMediaFieldConfig } from "./linkToMedia"
|
|
39
|
+
|
|
40
|
+
// Link fields
|
|
41
|
+
export { link } from "./link"
|
|
42
|
+
export type { LinkFieldConfig } from "./link"
|
|
43
|
+
|
|
44
|
+
export { contentRelationship } from "./contentRelationship"
|
|
45
|
+
export type { ContentRelationshipFieldConfig } from "./contentRelationship"
|
|
46
|
+
|
|
47
|
+
// Special fields
|
|
48
|
+
export { select } from "./select"
|
|
49
|
+
export type { SelectFieldConfig } from "./select"
|
|
50
|
+
|
|
51
|
+
export { uid } from "./uid"
|
|
52
|
+
export type { UIDFieldConfig } from "./uid"
|
|
53
|
+
|
|
54
|
+
export { integration } from "./integration"
|
|
55
|
+
export type { IntegrationFieldConfig } from "./integration"
|
|
56
|
+
|
|
57
|
+
// Structural fields
|
|
58
|
+
export { group } from "./group"
|
|
59
|
+
export type { GroupFieldConfig } from "./group"
|
|
60
|
+
|
|
61
|
+
export { sliceZone } from "./sliceZone"
|
|
62
|
+
export type { SliceZoneFieldConfig } from "./sliceZone"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CustomTypeModelIntegrationField } from "../../types/model/integration"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for an integration field.
|
|
6
|
+
*/
|
|
7
|
+
export interface IntegrationFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
placeholder?: string
|
|
10
|
+
/**
|
|
11
|
+
* The catalog ID for the integration.
|
|
12
|
+
*/
|
|
13
|
+
catalog?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates an integration field model.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* model.integration({
|
|
23
|
+
* label: "Product",
|
|
24
|
+
* catalog: "my-catalog-id"
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param config - Configuration for the field.
|
|
29
|
+
*
|
|
30
|
+
* @returns An integration field model.
|
|
31
|
+
*/
|
|
32
|
+
export const integration = (
|
|
33
|
+
config?: IntegrationFieldConfig,
|
|
34
|
+
): CustomTypeModelIntegrationField => {
|
|
35
|
+
return {
|
|
36
|
+
type: CustomTypeModelFieldType.Integration,
|
|
37
|
+
config: {
|
|
38
|
+
label: config?.label ?? null,
|
|
39
|
+
placeholder: config?.placeholder,
|
|
40
|
+
catalog: config?.catalog,
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomTypeModelLinkField,
|
|
3
|
+
CustomTypeModelLinkSelectType,
|
|
4
|
+
} from "../../types/model/link"
|
|
5
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for a link field.
|
|
9
|
+
*/
|
|
10
|
+
export interface LinkFieldConfig {
|
|
11
|
+
label?: string | null
|
|
12
|
+
placeholder?: string
|
|
13
|
+
/**
|
|
14
|
+
* Restrict the link type.
|
|
15
|
+
*
|
|
16
|
+
* - `"document"` - Only allow content relationship links.
|
|
17
|
+
* - `"media"` - Only allow media links.
|
|
18
|
+
* - `"web"` - Only allow web links.
|
|
19
|
+
* - `null` or `undefined` - Allow all link types.
|
|
20
|
+
*/
|
|
21
|
+
select?:
|
|
22
|
+
| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]
|
|
23
|
+
| null
|
|
24
|
+
/**
|
|
25
|
+
* Allow custom link text.
|
|
26
|
+
*/
|
|
27
|
+
allowText?: boolean
|
|
28
|
+
/**
|
|
29
|
+
* Allow opening links in a new tab.
|
|
30
|
+
*/
|
|
31
|
+
allowTargetBlank?: boolean
|
|
32
|
+
/**
|
|
33
|
+
* Allow multiple links (repeatable).
|
|
34
|
+
*/
|
|
35
|
+
repeat?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* Link variants.
|
|
38
|
+
*/
|
|
39
|
+
variants?: string[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Creates a link field model.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Any link type
|
|
49
|
+
* model.link({ label: "CTA Link" })
|
|
50
|
+
*
|
|
51
|
+
* // Web links only
|
|
52
|
+
* model.link({ label: "External Link", select: "web" })
|
|
53
|
+
*
|
|
54
|
+
* // With custom text and target blank
|
|
55
|
+
* model.link({
|
|
56
|
+
* label: "Button Link",
|
|
57
|
+
* allowText: true,
|
|
58
|
+
* allowTargetBlank: true
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param config - Configuration for the field.
|
|
63
|
+
*
|
|
64
|
+
* @returns A link field model.
|
|
65
|
+
*/
|
|
66
|
+
export const link = (config?: LinkFieldConfig): CustomTypeModelLinkField => {
|
|
67
|
+
return {
|
|
68
|
+
type: CustomTypeModelFieldType.Link,
|
|
69
|
+
config: {
|
|
70
|
+
label: config?.label ?? null,
|
|
71
|
+
placeholder: config?.placeholder,
|
|
72
|
+
select: config?.select,
|
|
73
|
+
allowText: config?.allowText,
|
|
74
|
+
allowTargetBlank: config?.allowTargetBlank,
|
|
75
|
+
repeat: config?.repeat,
|
|
76
|
+
variants: config?.variants,
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CustomTypeModelLinkToMediaField } from "../../types/model/linkToMedia"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
import { CustomTypeModelLinkSelectType } from "../../types/model/link"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for a link to media field.
|
|
7
|
+
*/
|
|
8
|
+
export interface LinkToMediaFieldConfig {
|
|
9
|
+
label?: string | null
|
|
10
|
+
placeholder?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates a link to media field model.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* model.linkToMedia({ label: "Download File" })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param config - Configuration for the field.
|
|
23
|
+
*
|
|
24
|
+
* @returns A link to media field model.
|
|
25
|
+
*/
|
|
26
|
+
export const linkToMedia = (
|
|
27
|
+
config?: LinkToMediaFieldConfig,
|
|
28
|
+
): CustomTypeModelLinkToMediaField => {
|
|
29
|
+
return {
|
|
30
|
+
type: CustomTypeModelFieldType.Link,
|
|
31
|
+
config: {
|
|
32
|
+
label: config?.label ?? null,
|
|
33
|
+
placeholder: config?.placeholder,
|
|
34
|
+
select: CustomTypeModelLinkSelectType.Media,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CustomTypeModelNumberField } from "../../types/model/number"
|
|
2
|
+
import { CustomTypeModelFieldType } from "../../types/model/types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a number field.
|
|
6
|
+
*/
|
|
7
|
+
export interface NumberFieldConfig {
|
|
8
|
+
label?: string | null
|
|
9
|
+
placeholder?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a number field model.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* model.number({ label: "Price" })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param config - Configuration for the field.
|
|
22
|
+
*
|
|
23
|
+
* @returns A number field model.
|
|
24
|
+
*/
|
|
25
|
+
export const number = (
|
|
26
|
+
config?: NumberFieldConfig,
|
|
27
|
+
): CustomTypeModelNumberField => {
|
|
28
|
+
return {
|
|
29
|
+
type: CustomTypeModelFieldType.Number,
|
|
30
|
+
config: {
|
|
31
|
+
label: config?.label ?? null,
|
|
32
|
+
placeholder: config?.placeholder,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|