Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for text property in link fields #348

Merged
merged 21 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [7.9.0-alpha.0](https://github.com/prismicio/prismic-client/compare/v7.8.0...v7.9.0-alpha.0) (2024-08-14)


### Features

* add text property to link models ([40d0e0b](https://github.com/prismicio/prismic-client/commit/40d0e0be3ce8038cd36e8cdf3350ffa9893ada98))
* add text to link value models ([8459d75](https://github.com/prismicio/prismic-client/commit/8459d75608c1af8319adafd2b3bf73555569a434))


### Chore

* update package version ([c06b383](https://github.com/prismicio/prismic-client/commit/c06b383ff41f01e253641c7852a4e9701725bdba))

## [7.8.0](https://github.com/prismicio/prismic-client/compare/v7.7.4...v7.8.0) (2024-08-01)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prismicio/client",
"version": "7.8.0",
"version": "7.9.0-alpha.0",
"description": "The official JavaScript + TypeScript client library for Prismic",
"keywords": [
"typescript",
Expand Down
2 changes: 2 additions & 0 deletions src/types/model/contentRelationship.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CustomTypeModelFieldType } from "./types"

import type { CustomTypeModelKeyTextField } from "./keyText"
import type { CustomTypeModelLinkSelectType } from "./link"

/**
Expand All @@ -18,5 +19,6 @@ export interface CustomTypeModelContentRelationshipField<
select: typeof CustomTypeModelLinkSelectType.Document
customtypes?: readonly CustomTypeIDs[]
tags?: readonly Tags[]
text?: CustomTypeModelKeyTextField
}
}
3 changes: 3 additions & 0 deletions src/types/model/link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { CustomTypeModelFieldType } from "./types"

import type { CustomTypeModelKeyTextField } from "./keyText"

/**
* A link custom type field.
*
Expand All @@ -13,6 +15,7 @@ export interface CustomTypeModelLinkField {
select?:
| null
| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]
text?: CustomTypeModelKeyTextField
allowTargetBlank?: boolean
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/types/model/linkToMedia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CustomTypeModelFieldType } from "./types"

import type { CustomTypeModelKeyTextField } from "./keyText"
import type { CustomTypeModelLinkSelectType } from "./link"

/**
Expand All @@ -13,5 +14,6 @@ export interface CustomTypeModelLinkToMediaField {
label?: string | null
placeholder?: string
select: typeof CustomTypeModelLinkSelectType.Media
text?: CustomTypeModelKeyTextField
}
}
1 change: 1 addition & 0 deletions src/types/value/contentRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ export interface FilledContentRelationshipField<
slug?: string
isBroken?: boolean
data?: DataInterface
text?: string
levimykel marked this conversation as resolved.
Show resolved Hide resolved
dani-mp marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions src/types/value/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface FilledLinkToWebField {
link_type: typeof LinkType.Web
url: string
target?: string
text?: string
levimykel marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/types/value/linkToMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export interface FilledLinkToMediaField {
size: string
height?: string | null
width?: string | null
text?: string
levimykel marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 14 additions & 0 deletions test/types/customType-contentRelationship.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ expectType<prismic.CustomTypeModelContentRelationshipField<string, "foo">>({
},
})

/**
* Supports optional `text` property.
*/
expectType<prismic.CustomTypeModelContentRelationshipField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Document,
text: {
type: prismic.CustomTypeModelFieldType.Text,
},
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
13 changes: 13 additions & 0 deletions test/types/customType-link.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ expectType<prismic.CustomTypeModelLinkField>({
},
})

/**
* Supports optional `text` property.
*/
expectType<prismic.CustomTypeModelLinkField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
text: {
type: prismic.CustomTypeModelFieldType.Text,
},
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
14 changes: 14 additions & 0 deletions test/types/customType-linkToMedia.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ expectType<prismic.CustomTypeModelLinkToMediaField>({
},
})

/**
* Supports optional `text` property.
*/
expectType<prismic.CustomTypeModelLinkToMediaField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Media,
text: {
type: prismic.CustomTypeModelFieldType.Text,
},
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
3 changes: 3 additions & 0 deletions test/types/fields-contentRelationship.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ expectType<prismic.ContentRelationshipField>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})
expectType<prismic.ContentRelationshipField<string, string, never, "filled">>({
link_type: prismic.LinkType.Document,
Expand All @@ -44,6 +45,7 @@ expectType<prismic.ContentRelationshipField<string, string, never, "filled">>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})
expectType<prismic.ContentRelationshipField<string, string, never, "empty">>({
link_type: prismic.LinkType.Document,
Expand All @@ -57,6 +59,7 @@ expectType<prismic.ContentRelationshipField<string, string, never, "empty">>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})

/**
Expand Down
5 changes: 5 additions & 0 deletions test/types/fields-link.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ expectType<prismic.LinkField>({
link_type: prismic.LinkType.Web,
url: "string",
target: "string",
text: "string",
})
// Content relationship link
expectType<prismic.LinkField>({
Expand All @@ -54,6 +55,7 @@ expectType<prismic.LinkField>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})
// Media link
expectType<prismic.LinkField>({
Expand All @@ -64,17 +66,20 @@ expectType<prismic.LinkField>({
size: "string",
height: "string",
width: "string",
text: "string",
})
expectType<prismic.LinkField<string, string, never, "filled">>({
link_type: prismic.LinkType.Web,
url: "string",
target: "string",
text: "string",
})
expectType<prismic.LinkField<string, string, never, "empty">>({
link_type: prismic.LinkType.Web,
// @ts-expect-error - Empty fields cannot contain a filled value.
url: "string",
target: "string",
text: "string",
})

/**
Expand Down
3 changes: 3 additions & 0 deletions test/types/fields-linkToMedia.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ expectType<prismic.LinkToMediaField>({
size: "string",
height: "string",
width: "string",
text: "string",
})
expectType<prismic.LinkToMediaField<"filled">>({
id: "string",
Expand All @@ -40,6 +41,7 @@ expectType<prismic.LinkToMediaField<"filled">>({
size: "string",
height: "string",
width: "string",
text: "string",
})
expectType<prismic.LinkToMediaField<"empty">>({
link_type: prismic.LinkType.Media,
Expand All @@ -51,6 +53,7 @@ expectType<prismic.LinkToMediaField<"empty">>({
size: "string",
height: "string",
width: "string",
text: "string",
})

/**
Expand Down
Loading