@prismicio/client 7.0.0-alpha.0 → 7.0.0-alpha.1
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/README.md +4 -4
- package/dist/buildQueryURL.cjs +26 -8
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.ts +207 -130
- package/dist/buildQueryURL.js +25 -7
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs +1 -1
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.d.ts +5 -5
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +1142 -0
- package/dist/createClient.cjs.map +1 -0
- package/dist/{client.d.ts → createClient.d.ts} +980 -908
- package/dist/createClient.js +1142 -0
- package/dist/createClient.js.map +1 -0
- package/dist/{ForbiddenError.cjs → errors/ForbiddenError.cjs} +1 -1
- package/dist/errors/ForbiddenError.cjs.map +1 -0
- package/dist/{ForbiddenError.d.ts → errors/ForbiddenError.d.ts} +11 -11
- package/dist/errors/ForbiddenError.js.map +1 -0
- package/dist/{NotFoundError.cjs → errors/NotFoundError.cjs} +1 -1
- package/dist/errors/NotFoundError.cjs.map +1 -0
- package/dist/{NotFoundError.d.ts → errors/NotFoundError.d.ts} +3 -3
- package/dist/errors/NotFoundError.js.map +1 -0
- package/dist/{ParsingError.cjs → errors/ParsingError.cjs} +1 -1
- package/dist/errors/ParsingError.cjs.map +1 -0
- package/dist/{ParsingError.d.ts → errors/ParsingError.d.ts} +12 -12
- package/dist/errors/ParsingError.js.map +1 -0
- package/dist/{PrismicError.cjs → errors/PrismicError.cjs} +1 -1
- package/dist/errors/PrismicError.cjs.map +1 -0
- package/dist/{PrismicError.d.ts → errors/PrismicError.d.ts} +5 -5
- package/dist/errors/PrismicError.js.map +1 -0
- package/dist/filter.cjs +247 -0
- package/dist/filter.cjs.map +1 -0
- package/dist/filter.d.ts +209 -0
- package/dist/filter.js +247 -0
- package/dist/filter.js.map +1 -0
- package/dist/getGraphQLEndpoint.cjs +2 -2
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.ts +9 -9
- package/dist/getGraphQLEndpoint.js +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs +2 -2
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts +10 -10
- package/dist/getRepositoryEndpoint.js +1 -1
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs +2 -2
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.ts +13 -13
- package/dist/getRepositoryName.js +1 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs +13 -0
- package/dist/getToolbarSrc.cjs.map +1 -0
- package/dist/getToolbarSrc.d.ts +34 -0
- package/dist/getToolbarSrc.js +13 -0
- package/dist/getToolbarSrc.js.map +1 -0
- package/dist/helpers/asDate.cjs +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.ts +16 -16
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +7 -6
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.ts +77 -20
- package/dist/helpers/asHTML.js +6 -5
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +52 -52
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +27 -27
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +19 -14
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +60 -60
- package/dist/helpers/asImageWidthSrcSet.js +18 -13
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs +8 -2
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.ts +34 -24
- package/dist/helpers/asLink.js +7 -1
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs +28 -0
- package/dist/helpers/asLinkAttrs.cjs.map +1 -0
- package/dist/helpers/asLinkAttrs.d.ts +63 -0
- package/dist/helpers/asLinkAttrs.js +28 -0
- package/dist/helpers/asLinkAttrs.js.map +1 -0
- package/dist/helpers/asText.cjs +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.ts +16 -16
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +12 -5
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts +15 -15
- package/dist/helpers/documentToLinkField.js +11 -4
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +1 -1
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.ts +172 -175
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/index.cjs +20 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +138 -92
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.ts +10 -10
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs +1 -1
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.ts +9 -9
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/appendFilters.cjs +11 -0
- package/dist/lib/appendFilters.cjs.map +1 -0
- package/dist/lib/appendFilters.d.ts +18 -0
- package/dist/lib/appendFilters.js +11 -0
- package/dist/lib/appendFilters.js.map +1 -0
- package/dist/lib/castArray.cjs +4 -2
- package/dist/lib/castArray.cjs.map +1 -1
- package/dist/lib/castArray.d.ts +11 -11
- package/dist/lib/castArray.js +3 -1
- package/dist/lib/castArray.js.map +1 -1
- package/dist/lib/castThunk.cjs +4 -2
- package/dist/lib/castThunk.cjs.map +1 -1
- package/dist/lib/castThunk.d.ts +10 -10
- package/dist/lib/castThunk.js +3 -1
- package/dist/lib/castThunk.js.map +1 -1
- package/dist/lib/devMsg.cjs +8 -0
- package/dist/lib/devMsg.cjs.map +1 -0
- package/dist/lib/devMsg.d.ts +16 -0
- package/dist/lib/devMsg.js +8 -0
- package/dist/lib/devMsg.js.map +1 -0
- package/dist/lib/escapeHTML.cjs +43 -0
- package/dist/lib/escapeHTML.cjs.map +1 -0
- package/dist/lib/escapeHTML.d.ts +1 -0
- package/dist/lib/escapeHTML.js +43 -0
- package/dist/lib/escapeHTML.js.map +1 -0
- package/dist/lib/everyTagFilter.cjs +9 -0
- package/dist/lib/everyTagFilter.cjs.map +1 -0
- package/dist/lib/everyTagFilter.d.ts +9 -0
- package/dist/lib/everyTagFilter.js +9 -0
- package/dist/lib/everyTagFilter.js.map +1 -0
- package/dist/lib/findMasterRef.cjs +1 -1
- package/dist/lib/findMasterRef.cjs.map +1 -1
- package/dist/lib/findMasterRef.d.ts +10 -10
- package/dist/lib/findMasterRef.js.map +1 -1
- package/dist/lib/findRef.cjs +4 -4
- package/dist/lib/findRef.cjs.map +1 -1
- package/dist/lib/findRef.d.ts +13 -13
- package/dist/lib/findRef.js +3 -3
- package/dist/lib/findRef.js.map +1 -1
- package/dist/lib/findRefByID.cjs +1 -1
- package/dist/lib/findRefByID.cjs.map +1 -1
- package/dist/lib/findRefByID.d.ts +11 -11
- package/dist/lib/findRefByID.js.map +1 -1
- package/dist/lib/findRefByLabel.cjs +1 -1
- package/dist/lib/findRefByLabel.cjs.map +1 -1
- package/dist/lib/findRefByLabel.d.ts +11 -11
- package/dist/lib/findRefByLabel.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs +1 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.d.ts +9 -9
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs +9 -0
- package/dist/lib/isInternalURL.cjs.map +1 -0
- package/dist/lib/isInternalURL.d.ts +8 -0
- package/dist/lib/isInternalURL.js +9 -0
- package/dist/lib/isInternalURL.js.map +1 -0
- package/dist/lib/minifyGraphQLQuery.cjs +1 -1
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
- package/dist/lib/minifyGraphQLQuery.d.ts +8 -8
- package/dist/lib/minifyGraphQLQuery.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +7 -9
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.d.ts +9 -9
- package/dist/lib/serializerHelpers.js +6 -6
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/someTagsFilter.cjs +9 -0
- package/dist/lib/someTagsFilter.cjs.map +1 -0
- package/dist/lib/someTagsFilter.d.ts +9 -0
- package/dist/lib/someTagsFilter.js +9 -0
- package/dist/lib/someTagsFilter.js.map +1 -0
- package/dist/lib/typeFilter.cjs +8 -0
- package/dist/lib/typeFilter.cjs.map +1 -0
- package/dist/lib/typeFilter.d.ts +8 -0
- package/dist/lib/typeFilter.js +8 -0
- package/dist/lib/typeFilter.js.map +1 -0
- package/dist/package.json.cjs +5 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +5 -0
- package/dist/package.json.js.map +1 -0
- package/dist/types/api/query.d.ts +42 -42
- package/dist/types/api/ref.d.ts +32 -32
- package/dist/types/api/release.d.ts +10 -10
- package/dist/types/api/repository.d.ts +100 -100
- package/dist/types/api/tags.d.ts +8 -8
- package/dist/types/model/boolean.d.ts +15 -15
- package/dist/types/model/color.d.ts +13 -13
- package/dist/types/model/contentRelationship.d.ts +18 -18
- package/dist/types/model/customType.d.ts +42 -42
- package/dist/types/model/date.d.ts +14 -14
- package/dist/types/model/embed.d.ts +13 -13
- package/dist/types/model/geoPoint.d.ts +12 -12
- package/dist/types/model/group.d.ts +15 -15
- package/dist/types/model/image.d.ts +31 -31
- package/dist/types/model/integrationFields.d.ts +14 -14
- package/dist/types/model/keyText.d.ts +13 -13
- package/dist/types/model/link.cjs +1 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.ts +27 -27
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +16 -16
- package/dist/types/model/number.d.ts +15 -15
- package/dist/types/model/range.d.ts +14 -14
- package/dist/types/model/richText.d.ts +35 -35
- package/dist/types/model/select.d.ts +18 -18
- package/dist/types/model/separator.d.ts +10 -10
- package/dist/types/model/sharedSlice.d.ts +16 -19
- package/dist/types/model/sharedSliceVariation.d.ts +19 -22
- package/dist/types/model/slice.cjs +1 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.ts +33 -33
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs +1 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.ts +41 -44
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/timestamp.d.ts +14 -14
- package/dist/types/model/title.d.ts +7 -7
- package/dist/types/model/types.cjs +10 -1
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.ts +62 -62
- package/dist/types/model/types.js +9 -0
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/model/uid.d.ts +13 -13
- package/dist/types/value/boolean.d.ts +6 -6
- package/dist/types/value/color.d.ts +8 -8
- package/dist/types/value/contentRelationship.d.ts +29 -29
- package/dist/types/value/date.d.ts +8 -8
- package/dist/types/value/document.d.ts +113 -113
- package/dist/types/value/embed.cjs +1 -1
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.ts +167 -167
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.ts +11 -11
- package/dist/types/value/group.d.ts +7 -7
- package/dist/types/value/image.d.ts +36 -36
- package/dist/types/value/integrationFields.d.ts +9 -9
- package/dist/types/value/keyText.d.ts +8 -8
- package/dist/types/value/link.cjs +1 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.ts +40 -40
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +20 -20
- package/dist/types/value/number.d.ts +8 -8
- package/dist/types/value/richText.cjs +1 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.ts +203 -203
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.ts +9 -9
- package/dist/types/value/sharedSlice.d.ts +11 -11
- package/dist/types/value/sharedSliceVariation.d.ts +7 -7
- package/dist/types/value/slice.d.ts +13 -13
- package/dist/types/value/sliceZone.d.ts +12 -12
- package/dist/types/value/timestamp.d.ts +8 -8
- package/dist/types/value/title.d.ts +12 -12
- package/dist/types/value/types.d.ts +40 -40
- package/dist/types/webhook/apiUpdate.d.ts +52 -52
- package/dist/types/webhook/testTrigger.d.ts +9 -9
- package/dist/types/webhook/types.cjs +1 -1
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.ts +18 -18
- package/dist/types/webhook/types.js.map +1 -1
- package/package.json +23 -24
- package/src/buildQueryURL.ts +179 -33
- package/src/{client.ts → createClient.ts} +214 -110
- package/src/filter.ts +356 -0
- package/src/getGraphQLEndpoint.ts +2 -1
- package/src/getRepositoryEndpoint.ts +2 -1
- package/src/getRepositoryName.ts +1 -1
- package/src/getToolbarSrc.ts +50 -0
- package/src/helpers/asDate.ts +3 -3
- package/src/helpers/asHTML.ts +122 -27
- package/src/helpers/asImagePixelDensitySrcSet.ts +1 -1
- package/src/helpers/asImageSrc.ts +1 -1
- package/src/helpers/asImageWidthSrcSet.ts +1 -1
- package/src/helpers/asLink.ts +37 -18
- package/src/helpers/asLinkAttrs.ts +127 -0
- package/src/helpers/asText.ts +4 -4
- package/src/helpers/documentToLinkField.ts +3 -3
- package/src/helpers/isFilled.ts +9 -11
- package/src/index.ts +59 -29
- package/src/lib/appendFilters.ts +26 -0
- package/src/lib/castArray.ts +3 -1
- package/src/lib/castThunk.ts +3 -2
- package/src/lib/devMsg.ts +20 -0
- package/src/lib/escapeHTML.ts +51 -0
- package/src/lib/everyTagFilter.ts +15 -0
- package/src/lib/findRef.ts +5 -5
- package/src/lib/isInternalURL.ts +14 -0
- package/src/lib/serializerHelpers.ts +20 -15
- package/src/lib/someTagsFilter.ts +15 -0
- package/src/lib/typeFilter.ts +12 -0
- package/src/types/api/query.ts +1 -1
- package/src/types/api/ref.ts +2 -2
- package/src/types/api/release.ts +1 -1
- package/src/types/api/repository.ts +1 -1
- package/src/types/api/tags.ts +1 -1
- package/src/types/model/boolean.ts +1 -1
- package/src/types/model/color.ts +1 -1
- package/src/types/model/contentRelationship.ts +2 -1
- package/src/types/model/date.ts +1 -1
- package/src/types/model/embed.ts +1 -1
- package/src/types/model/geoPoint.ts +1 -1
- package/src/types/model/group.ts +2 -2
- package/src/types/model/image.ts +3 -3
- package/src/types/model/integrationFields.ts +1 -1
- package/src/types/model/keyText.ts +1 -1
- package/src/types/model/link.ts +3 -3
- package/src/types/model/linkToMedia.ts +2 -1
- package/src/types/model/number.ts +1 -1
- package/src/types/model/richText.ts +3 -3
- package/src/types/model/select.ts +1 -1
- package/src/types/model/sharedSlice.ts +2 -5
- package/src/types/model/sharedSliceVariation.ts +1 -4
- package/src/types/model/slice.ts +5 -4
- package/src/types/model/sliceZone.ts +5 -7
- package/src/types/model/timestamp.ts +1 -1
- package/src/types/model/title.ts +1 -1
- package/src/types/model/types.ts +12 -16
- package/src/types/model/uid.ts +1 -1
- package/src/types/value/boolean.ts +1 -1
- package/src/types/value/color.ts +1 -1
- package/src/types/value/contentRelationship.ts +8 -9
- package/src/types/value/date.ts +1 -1
- package/src/types/value/document.ts +6 -5
- package/src/types/value/embed.ts +2 -2
- package/src/types/value/geoPoint.ts +1 -1
- package/src/types/value/group.ts +2 -2
- package/src/types/value/image.ts +1 -1
- package/src/types/value/integrationFields.ts +1 -1
- package/src/types/value/keyText.ts +1 -1
- package/src/types/value/link.ts +8 -8
- package/src/types/value/linkToMedia.ts +2 -1
- package/src/types/value/number.ts +1 -1
- package/src/types/value/richText.ts +6 -5
- package/src/types/value/select.ts +1 -1
- package/src/types/value/sharedSlice.ts +1 -1
- package/src/types/value/slice.ts +1 -1
- package/src/types/value/sliceZone.ts +2 -1
- package/src/types/value/timestamp.ts +1 -0
- package/src/types/value/title.ts +2 -1
- package/src/types/value/types.ts +9 -11
- package/src/types/webhook/apiUpdate.ts +4 -4
- package/src/types/webhook/testTrigger.ts +1 -1
- package/src/types/webhook/types.ts +2 -2
- package/dist/ForbiddenError.cjs.map +0 -1
- package/dist/ForbiddenError.js.map +0 -1
- package/dist/NotFoundError.cjs.map +0 -1
- package/dist/NotFoundError.js.map +0 -1
- package/dist/ParsingError.cjs.map +0 -1
- package/dist/ParsingError.js.map +0 -1
- package/dist/PrismicError.cjs.map +0 -1
- package/dist/PrismicError.js.map +0 -1
- package/dist/client.cjs +0 -414
- package/dist/client.cjs.map +0 -1
- package/dist/client.js +0 -414
- package/dist/client.js.map +0 -1
- package/dist/lib/appendPredicates.cjs +0 -14
- package/dist/lib/appendPredicates.cjs.map +0 -1
- package/dist/lib/appendPredicates.d.ts +0 -18
- package/dist/lib/appendPredicates.js +0 -14
- package/dist/lib/appendPredicates.js.map +0 -1
- package/dist/predicate.cjs +0 -68
- package/dist/predicate.cjs.map +0 -1
- package/dist/predicate.d.ts +0 -209
- package/dist/predicate.js +0 -68
- package/dist/predicate.js.map +0 -1
- package/dist/types/client.d.ts +0 -128
- package/dist/types/helpers.d.ts +0 -63
- package/dist/types/utils.d.ts +0 -28
- package/src/lib/appendPredicates.ts +0 -29
- package/src/predicate.ts +0 -359
- package/src/types/client.ts +0 -157
- package/src/types/helpers.ts +0 -103
- package/src/types/utils.ts +0 -34
- /package/dist/{ForbiddenError.js → errors/ForbiddenError.js} +0 -0
- /package/dist/{NotFoundError.js → errors/NotFoundError.js} +0 -0
- /package/dist/{ParsingError.js → errors/ParsingError.js} +0 -0
- /package/dist/{PrismicError.js → errors/PrismicError.js} +0 -0
- /package/src/{ForbiddenError.ts → errors/ForbiddenError.ts} +0 -0
- /package/src/{NotFoundError.ts → errors/NotFoundError.ts} +0 -0
- /package/src/{ParsingError.ts → errors/ParsingError.ts} +0 -0
- /package/src/{PrismicError.ts → errors/PrismicError.ts} +0 -0
package/dist/predicate.cjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const formatValue = (value) => {
|
|
4
|
-
if (Array.isArray(value)) {
|
|
5
|
-
return `[${value.map(formatValue).join(", ")}]`;
|
|
6
|
-
}
|
|
7
|
-
if (typeof value === "string") {
|
|
8
|
-
return `"${value}"`;
|
|
9
|
-
}
|
|
10
|
-
if (value instanceof Date) {
|
|
11
|
-
return `${value.getTime()}`;
|
|
12
|
-
}
|
|
13
|
-
return `${value}`;
|
|
14
|
-
};
|
|
15
|
-
const pathWithArgsPredicate = (name) => {
|
|
16
|
-
const fn = (path, ...args) => {
|
|
17
|
-
const formattedArgs = args.map(formatValue).join(", ");
|
|
18
|
-
const joiner = path && args.length ? ", " : "";
|
|
19
|
-
return `[${name}(${path}${joiner}${formattedArgs})]`;
|
|
20
|
-
};
|
|
21
|
-
return fn;
|
|
22
|
-
};
|
|
23
|
-
const pathPredicate = (name) => {
|
|
24
|
-
const predicateFn = pathWithArgsPredicate(name);
|
|
25
|
-
const fn = (path) => {
|
|
26
|
-
return predicateFn(path);
|
|
27
|
-
};
|
|
28
|
-
return fn;
|
|
29
|
-
};
|
|
30
|
-
const argsPredicate = (name) => {
|
|
31
|
-
const predicateFn = pathWithArgsPredicate(name);
|
|
32
|
-
const fn = (...args) => {
|
|
33
|
-
return predicateFn("", ...args);
|
|
34
|
-
};
|
|
35
|
-
return fn;
|
|
36
|
-
};
|
|
37
|
-
const predicate = {
|
|
38
|
-
at: pathWithArgsPredicate("at"),
|
|
39
|
-
not: pathWithArgsPredicate("not"),
|
|
40
|
-
any: pathWithArgsPredicate("any"),
|
|
41
|
-
in: pathWithArgsPredicate("in"),
|
|
42
|
-
fulltext: pathWithArgsPredicate("fulltext"),
|
|
43
|
-
has: pathPredicate("has"),
|
|
44
|
-
missing: pathPredicate("missing"),
|
|
45
|
-
similar: argsPredicate("similar"),
|
|
46
|
-
geopointNear: pathWithArgsPredicate("geopoint.near"),
|
|
47
|
-
numberLessThan: pathWithArgsPredicate("number.lt"),
|
|
48
|
-
numberGreaterThan: pathWithArgsPredicate("number.gt"),
|
|
49
|
-
numberInRange: pathWithArgsPredicate("number.inRange"),
|
|
50
|
-
dateAfter: pathWithArgsPredicate("date.after"),
|
|
51
|
-
dateBefore: pathWithArgsPredicate("date.before"),
|
|
52
|
-
dateBetween: pathWithArgsPredicate("date.between"),
|
|
53
|
-
dateDayOfMonth: pathWithArgsPredicate("date.day-of-month"),
|
|
54
|
-
dateDayOfMonthAfter: pathWithArgsPredicate("date.day-of-month-after"),
|
|
55
|
-
dateDayOfMonthBefore: pathWithArgsPredicate("date.day-of-month-before"),
|
|
56
|
-
dateDayOfWeek: pathWithArgsPredicate("date.day-of-week"),
|
|
57
|
-
dateDayOfWeekAfter: pathWithArgsPredicate("date.day-of-week-after"),
|
|
58
|
-
dateDayOfWeekBefore: pathWithArgsPredicate("date.day-of-week-before"),
|
|
59
|
-
dateMonth: pathWithArgsPredicate("date.month"),
|
|
60
|
-
dateMonthAfter: pathWithArgsPredicate("date.month-after"),
|
|
61
|
-
dateMonthBefore: pathWithArgsPredicate("date.month-before"),
|
|
62
|
-
dateYear: pathWithArgsPredicate("date.year"),
|
|
63
|
-
dateHour: pathWithArgsPredicate("date.hour"),
|
|
64
|
-
dateHourAfter: pathWithArgsPredicate("date.hour-after"),
|
|
65
|
-
dateHourBefore: pathWithArgsPredicate("date.hour-before")
|
|
66
|
-
};
|
|
67
|
-
exports.predicate = predicate;
|
|
68
|
-
//# sourceMappingURL=predicate.cjs.map
|
package/dist/predicate.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.cjs","sources":["../src/predicate.ts"],"sourcesContent":["/**\n * Formats the value of a predicate element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a predicate builder function for predicates with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the predicate.\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst pathWithArgsPredicate = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a predicate builder function for predicates with only a path.\n *\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst pathPredicate = (name: string) => {\n\tconst predicateFn = pathWithArgsPredicate(name);\n\n\t/**\n\t * @param path - Path for the predicate.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn predicateFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a predicate builder function for predicates with only arguments and\n * no path.\n *\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst argsPredicate = <Args extends unknown[]>(name: string) => {\n\tconst predicateFn = pathWithArgsPredicate<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the predicate.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn predicateFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const predicate = {\n\t/**\n\t * The `at` predicate checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}\n\t */\n\tat: pathWithArgsPredicate<\n\t\t[value: string | number | boolean | Date | string[]]\n\t>(\"at\"),\n\n\t/**\n\t * The `not` predicate checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}\n\t */\n\tnot: pathWithArgsPredicate<\n\t\t[value: string | number | boolean | Date | string[]]\n\t>(\"not\"),\n\n\t/**\n\t * The `any` predicate takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}\n\t */\n\tany: pathWithArgsPredicate<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` predicate is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This predicate is much more efficient at this than\n\t * the any predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}\n\t */\n\tin: pathWithArgsPredicate<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` predicate provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}\n\t */\n\tfulltext: pathWithArgsPredicate<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` predicate checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}\n\t */\n\thas: pathPredicate(\"has\"),\n\n\t/**\n\t * The `missing` predicate checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}\n\t */\n\tmissing: pathPredicate(\"missing\"),\n\n\t/**\n\t * The `similar` predicate takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}\n\t */\n\tsimilar: argsPredicate<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` predicate checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This predicate will only work for a GeoPoint field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsPredicate<\n\t\t\t[latitude: number, longitude: number, radius: number]\n\t\t>(\"geopoint.near\"),\n\n\t/**\n\t * The `number.lt` predicate checks that the value in the number field is less\n\t * than the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}\n\t */\n\tnumberLessThan: pathWithArgsPredicate<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` predicate checks that the value in the number field is\n\t * greater than the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}\n\t */\n\tnumberGreaterThan: pathWithArgsPredicate<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` predicate checks that the value in the path is within\n\t * the two values passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsPredicate<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` predicate checks that the value in the path is after the\n\t * date value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}\n\t */\n\tdateAfter:\n\t\tpathWithArgsPredicate<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` predicate checks that the value in the path is before the\n\t * date value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}\n\t */\n\tdateBefore:\n\t\tpathWithArgsPredicate<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` predicate checks that the value in the path is within\n\t * the date values passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}\n\t */\n\tdateBetween:\n\t\tpathWithArgsPredicate<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` predicate checks that the value in the path is\n\t * equal to the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}\n\t */\n\tdateDayOfMonth: pathWithArgsPredicate<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` predicate checks that the value in the path\n\t * is after the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsPredicate<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` predicate checks that the value in the path\n\t * is before the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsPredicate<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` predicate checks that the value in the path is equal\n\t * to the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}\n\t */\n\tdateDayOfWeek:\n\t\tpathWithArgsPredicate<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` predicate checks that the value in the path is\n\t * after the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsPredicate<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before predicate checks that the value in the path is\n\t * before the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsPredicate<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` predicate checks that the value in the path occurs in the\n\t * month value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}\n\t */\n\tdateMonth: pathWithArgsPredicate<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` predicate checks that the value in the path occurs\n\t * in any month after the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsPredicate<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` predicate checks that the value in the path occurs\n\t * in any month before the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsPredicate<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` predicate checks that the value in the path occurs in the\n\t * year value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}\n\t */\n\tdateYear: pathWithArgsPredicate<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` predicate checks that the value in the path occurs within\n\t * the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}\n\t */\n\tdateHour: pathWithArgsPredicate<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` predicate checks that the value in the path occurs\n\t * after the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}\n\t */\n\tdateHourAfter: pathWithArgsPredicate<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` predicate checks that the value in the path occurs\n\t * before the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}\n\t */\n\tdateHourBefore: pathWithArgsPredicate<[hour: number]>(\"date.hour-before\"),\n};\n"],"names":[],"mappings":";;AAQA,MAAM,cAAc,CACnB,UAMW;AACP,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,IAAI,MAAM,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAC3C;AAEG,MAAA,OAAO,UAAU,UAAU;AAC9B,WAAO,IAAI;AAAA,EACX;AAED,MAAI,iBAAiB,MAAM;AACnB,WAAA,GAAG,MAAM,QAAO;AAAA,EACvB;AAED,SAAO,GAAG;AACX;AAWA,MAAM,wBAAwB,CAAyB,SAAgB;AAIhE,QAAA,KAAK,CAAC,SAAiB,SAAsB;AAClD,UAAM,gBAAgB,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI;AACrD,UAAM,SAAS,QAAQ,KAAK,SAAS,OAAO;AAErC,WAAA,IAAI,QAAQ,OAAO,SAAS;AAAA,EAAA;AAG7B,SAAA;AACR;AASA,MAAM,gBAAgB,CAAC,SAAgB;AAChC,QAAA,cAAc,sBAAsB,IAAI;AAKxC,QAAA,KAAK,CAAC,SAAwB;AACnC,WAAO,YAAY,IAAI;AAAA,EAAA;AAGjB,SAAA;AACR;AAUA,MAAM,gBAAgB,CAAyB,SAAgB;AACxD,QAAA,cAAc,sBAA4B,IAAI;AAK9C,QAAA,KAAK,IAAI,SAAsB;AAC7B,WAAA,YAAY,IAAI,GAAG,IAAI;AAAA,EAAA;AAGxB,SAAA;AACR;AAEO,MAAM,YAAY;AAAA,EAOxB,IAAI,sBAEF,IAAI;AAAA,EAQN,KAAK,sBAEH,KAAK;AAAA,EASP,KAAK,sBACJ,KAAK;AAAA,EAUN,IAAI,sBAA0C,IAAI;AAAA,EAYlD,UAAU,sBAA6C,UAAU;AAAA,EASjE,KAAK,cAAc,KAAK;AAAA,EASxB,SAAS,cAAc,SAAS;AAAA,EAShC,SAAS,cAA2C,SAAS;AAAA,EAU7D,cACC,sBAEE,eAAe;AAAA,EAQlB,gBAAgB,sBAAuC,WAAW;AAAA,EAQlE,mBAAmB,sBAAuC,WAAW;AAAA,EAQrE,eACC,sBACC,gBAAgB;AAAA,EASlB,WACC,sBAAsD,YAAY;AAAA,EAQnE,YACC,sBAAsD,aAAa;AAAA,EAQpE,aACC,sBAEE,cAAc;AAAA,EAQjB,gBAAgB,sBAAqC,mBAAmB;AAAA,EAQxE,qBAAqB,sBACpB,yBAAyB;AAAA,EAS1B,sBAAsB,sBACrB,0BAA0B;AAAA,EAS3B,eACC,sBAA8C,kBAAkB;AAAA,EAQjE,oBAAoB,sBACnB,wBAAwB;AAAA,EASzB,qBAAqB,sBACpB,yBAAyB;AAAA,EAS1B,WAAW,sBAAgD,YAAY;AAAA,EAQvE,gBACC,sBAAgD,kBAAkB;AAAA,EAQnE,iBACC,sBAAgD,mBAAmB;AAAA,EAQpE,UAAU,sBAAsC,WAAW;AAAA,EAQ3D,UAAU,sBAAsC,WAAW;AAAA,EAQ3D,eAAe,sBAAsC,iBAAiB;AAAA,EAQtE,gBAAgB,sBAAsC,kBAAkB;;;"}
|
package/dist/predicate.d.ts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
export declare const predicate: {
|
|
2
|
-
/**
|
|
3
|
-
* The `at` predicate checks that the path matches the described value
|
|
4
|
-
* exactly. It takes a single value for a field or an array (only for tags).
|
|
5
|
-
*
|
|
6
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
|
|
7
|
-
*/
|
|
8
|
-
at: (path: string, value: string | number | boolean | string[] | Date) => string;
|
|
9
|
-
/**
|
|
10
|
-
* The `not` predicate checks that the path doesn't match the provided value
|
|
11
|
-
* exactly. It takes a single value for a field or an array (only for tags).
|
|
12
|
-
*
|
|
13
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
|
|
14
|
-
*/
|
|
15
|
-
not: (path: string, value: string | number | boolean | string[] | Date) => string;
|
|
16
|
-
/**
|
|
17
|
-
* The `any` predicate takes an array of values. It works exactly the same way
|
|
18
|
-
* as the `at` operator, but checks whether the fragment matches any of the
|
|
19
|
-
* values in the array.
|
|
20
|
-
*
|
|
21
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
|
|
22
|
-
*/
|
|
23
|
-
any: (path: string, values: (string | number | boolean | Date)[]) => string;
|
|
24
|
-
/**
|
|
25
|
-
* The `in` predicate is used specifically to retrieve an array of documents
|
|
26
|
-
* by their IDs or UIDs. This predicate is much more efficient at this than
|
|
27
|
-
* the any predicate.
|
|
28
|
-
*
|
|
29
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
|
|
30
|
-
*/
|
|
31
|
-
in: (path: string, values: string[]) => string;
|
|
32
|
-
/**
|
|
33
|
-
* The `fulltext` predicate provides two capabilities:
|
|
34
|
-
*
|
|
35
|
-
* 1. Checking if a certain string is anywhere inside a document (this is what
|
|
36
|
-
* you should use to make your project's search engine feature)
|
|
37
|
-
* 2. Checking if the string is contained inside a specific custom type’s Rich
|
|
38
|
-
* Text or Key Text fragment.
|
|
39
|
-
*
|
|
40
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
|
|
41
|
-
*/
|
|
42
|
-
fulltext: (path: string, searchTerms: string) => string;
|
|
43
|
-
/**
|
|
44
|
-
* The `has` predicate checks whether a fragment has a value. It will return
|
|
45
|
-
* all the documents of the specified type that contain a value for the
|
|
46
|
-
* specified field.
|
|
47
|
-
*
|
|
48
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}
|
|
49
|
-
*/
|
|
50
|
-
has: (path: string) => string;
|
|
51
|
-
/**
|
|
52
|
-
* The `missing` predicate checks if a fragment doesn't have a value. It will
|
|
53
|
-
* return all the documents of the specified type that do not contain a value
|
|
54
|
-
* for the specified field.
|
|
55
|
-
*
|
|
56
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}
|
|
57
|
-
*/
|
|
58
|
-
missing: (path: string) => string;
|
|
59
|
-
/**
|
|
60
|
-
* The `similar` predicate takes the ID of a document, and returns a list of
|
|
61
|
-
* documents with similar content. This allows you to build an automated
|
|
62
|
-
* content discovery feature (for example, a "Related posts" section).
|
|
63
|
-
*
|
|
64
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}
|
|
65
|
-
*/
|
|
66
|
-
similar: (id: string, value: number) => string;
|
|
67
|
-
/**
|
|
68
|
-
* The `geopoint.near` predicate checks that the value in the path is within
|
|
69
|
-
* the radius of the given coordinates.
|
|
70
|
-
*
|
|
71
|
-
* This predicate will only work for a GeoPoint field.
|
|
72
|
-
*
|
|
73
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}
|
|
74
|
-
*/
|
|
75
|
-
geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
|
|
76
|
-
/**
|
|
77
|
-
* The `number.lt` predicate checks that the value in the number field is less
|
|
78
|
-
* than the value passed into the predicate.
|
|
79
|
-
*
|
|
80
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}
|
|
81
|
-
*/
|
|
82
|
-
numberLessThan: (path: string, value: number) => string;
|
|
83
|
-
/**
|
|
84
|
-
* The `number.gt` predicate checks that the value in the number field is
|
|
85
|
-
* greater than the value passed into the predicate.
|
|
86
|
-
*
|
|
87
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}
|
|
88
|
-
*/
|
|
89
|
-
numberGreaterThan: (path: string, value: number) => string;
|
|
90
|
-
/**
|
|
91
|
-
* The `number.inRange` predicate checks that the value in the path is within
|
|
92
|
-
* the two values passed into the predicate.
|
|
93
|
-
*
|
|
94
|
-
* {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}
|
|
95
|
-
*/
|
|
96
|
-
numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
|
|
97
|
-
/**
|
|
98
|
-
* The `date.after` predicate checks that the value in the path is after the
|
|
99
|
-
* date value passed into the predicate.
|
|
100
|
-
*
|
|
101
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}
|
|
102
|
-
*/
|
|
103
|
-
dateAfter: (path: string, date: string | number | Date) => string;
|
|
104
|
-
/**
|
|
105
|
-
* The `date.before` predicate checks that the value in the path is before the
|
|
106
|
-
* date value passed into the predicate.
|
|
107
|
-
*
|
|
108
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}
|
|
109
|
-
*/
|
|
110
|
-
dateBefore: (path: string, date: string | number | Date) => string;
|
|
111
|
-
/**
|
|
112
|
-
* The `date.between` predicate checks that the value in the path is within
|
|
113
|
-
* the date values passed into the predicate.
|
|
114
|
-
*
|
|
115
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}
|
|
116
|
-
*/
|
|
117
|
-
dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
|
|
118
|
-
/**
|
|
119
|
-
* The `date.day-of-month` predicate checks that the value in the path is
|
|
120
|
-
* equal to the day of the month passed into the predicate.
|
|
121
|
-
*
|
|
122
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}
|
|
123
|
-
*/
|
|
124
|
-
dateDayOfMonth: (path: string, day: number) => string;
|
|
125
|
-
/**
|
|
126
|
-
* The `date.day-of-month-after` predicate checks that the value in the path
|
|
127
|
-
* is after the day of the month passed into the predicate.
|
|
128
|
-
*
|
|
129
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}
|
|
130
|
-
*/
|
|
131
|
-
dateDayOfMonthAfter: (path: string, day: number) => string;
|
|
132
|
-
/**
|
|
133
|
-
* The `date.day-of-month-before` predicate checks that the value in the path
|
|
134
|
-
* is before the day of the month passed into the predicate.
|
|
135
|
-
*
|
|
136
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}
|
|
137
|
-
*/
|
|
138
|
-
dateDayOfMonthBefore: (path: string, day: number) => string;
|
|
139
|
-
/**
|
|
140
|
-
* The `date.day-of-week` predicate checks that the value in the path is equal
|
|
141
|
-
* to the day of the week passed into the predicate.
|
|
142
|
-
*
|
|
143
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}
|
|
144
|
-
*/
|
|
145
|
-
dateDayOfWeek: (path: string, day: string | number) => string;
|
|
146
|
-
/**
|
|
147
|
-
* The `date.day-of-week-after` predicate checks that the value in the path is
|
|
148
|
-
* after the day of the week passed into the predicate.
|
|
149
|
-
*
|
|
150
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}
|
|
151
|
-
*/
|
|
152
|
-
dateDayOfWeekAfter: (path: string, day: string | number) => string;
|
|
153
|
-
/**
|
|
154
|
-
* The date.day-of-week-before predicate checks that the value in the path is
|
|
155
|
-
* before the day of the week passed into the predicate.
|
|
156
|
-
*
|
|
157
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}
|
|
158
|
-
*/
|
|
159
|
-
dateDayOfWeekBefore: (path: string, day: string | number) => string;
|
|
160
|
-
/**
|
|
161
|
-
* The `date.month` predicate checks that the value in the path occurs in the
|
|
162
|
-
* month value passed into the predicate.
|
|
163
|
-
*
|
|
164
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}
|
|
165
|
-
*/
|
|
166
|
-
dateMonth: (path: string, month: string | number) => string;
|
|
167
|
-
/**
|
|
168
|
-
* The `date.month-after` predicate checks that the value in the path occurs
|
|
169
|
-
* in any month after the value passed into the predicate.
|
|
170
|
-
*
|
|
171
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}
|
|
172
|
-
*/
|
|
173
|
-
dateMonthAfter: (path: string, month: string | number) => string;
|
|
174
|
-
/**
|
|
175
|
-
* The `date.month-before` predicate checks that the value in the path occurs
|
|
176
|
-
* in any month before the value passed into the predicate.
|
|
177
|
-
*
|
|
178
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}
|
|
179
|
-
*/
|
|
180
|
-
dateMonthBefore: (path: string, month: string | number) => string;
|
|
181
|
-
/**
|
|
182
|
-
* The `date.year` predicate checks that the value in the path occurs in the
|
|
183
|
-
* year value passed into the predicate.
|
|
184
|
-
*
|
|
185
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}
|
|
186
|
-
*/
|
|
187
|
-
dateYear: (path: string, year: number) => string;
|
|
188
|
-
/**
|
|
189
|
-
* The `date.hour` predicate checks that the value in the path occurs within
|
|
190
|
-
* the hour value passed into the predicate.
|
|
191
|
-
*
|
|
192
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}
|
|
193
|
-
*/
|
|
194
|
-
dateHour: (path: string, hour: number) => string;
|
|
195
|
-
/**
|
|
196
|
-
* The `date.hour-after` predicate checks that the value in the path occurs
|
|
197
|
-
* after the hour value passed into the predicate.
|
|
198
|
-
*
|
|
199
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}
|
|
200
|
-
*/
|
|
201
|
-
dateHourAfter: (path: string, hour: number) => string;
|
|
202
|
-
/**
|
|
203
|
-
* The `date.hour-before` predicate checks that the value in the path occurs
|
|
204
|
-
* before the hour value passed into the predicate.
|
|
205
|
-
*
|
|
206
|
-
* {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}
|
|
207
|
-
*/
|
|
208
|
-
dateHourBefore: (path: string, hour: number) => string;
|
|
209
|
-
};
|
package/dist/predicate.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const formatValue = (value) => {
|
|
2
|
-
if (Array.isArray(value)) {
|
|
3
|
-
return `[${value.map(formatValue).join(", ")}]`;
|
|
4
|
-
}
|
|
5
|
-
if (typeof value === "string") {
|
|
6
|
-
return `"${value}"`;
|
|
7
|
-
}
|
|
8
|
-
if (value instanceof Date) {
|
|
9
|
-
return `${value.getTime()}`;
|
|
10
|
-
}
|
|
11
|
-
return `${value}`;
|
|
12
|
-
};
|
|
13
|
-
const pathWithArgsPredicate = (name) => {
|
|
14
|
-
const fn = (path, ...args) => {
|
|
15
|
-
const formattedArgs = args.map(formatValue).join(", ");
|
|
16
|
-
const joiner = path && args.length ? ", " : "";
|
|
17
|
-
return `[${name}(${path}${joiner}${formattedArgs})]`;
|
|
18
|
-
};
|
|
19
|
-
return fn;
|
|
20
|
-
};
|
|
21
|
-
const pathPredicate = (name) => {
|
|
22
|
-
const predicateFn = pathWithArgsPredicate(name);
|
|
23
|
-
const fn = (path) => {
|
|
24
|
-
return predicateFn(path);
|
|
25
|
-
};
|
|
26
|
-
return fn;
|
|
27
|
-
};
|
|
28
|
-
const argsPredicate = (name) => {
|
|
29
|
-
const predicateFn = pathWithArgsPredicate(name);
|
|
30
|
-
const fn = (...args) => {
|
|
31
|
-
return predicateFn("", ...args);
|
|
32
|
-
};
|
|
33
|
-
return fn;
|
|
34
|
-
};
|
|
35
|
-
const predicate = {
|
|
36
|
-
at: pathWithArgsPredicate("at"),
|
|
37
|
-
not: pathWithArgsPredicate("not"),
|
|
38
|
-
any: pathWithArgsPredicate("any"),
|
|
39
|
-
in: pathWithArgsPredicate("in"),
|
|
40
|
-
fulltext: pathWithArgsPredicate("fulltext"),
|
|
41
|
-
has: pathPredicate("has"),
|
|
42
|
-
missing: pathPredicate("missing"),
|
|
43
|
-
similar: argsPredicate("similar"),
|
|
44
|
-
geopointNear: pathWithArgsPredicate("geopoint.near"),
|
|
45
|
-
numberLessThan: pathWithArgsPredicate("number.lt"),
|
|
46
|
-
numberGreaterThan: pathWithArgsPredicate("number.gt"),
|
|
47
|
-
numberInRange: pathWithArgsPredicate("number.inRange"),
|
|
48
|
-
dateAfter: pathWithArgsPredicate("date.after"),
|
|
49
|
-
dateBefore: pathWithArgsPredicate("date.before"),
|
|
50
|
-
dateBetween: pathWithArgsPredicate("date.between"),
|
|
51
|
-
dateDayOfMonth: pathWithArgsPredicate("date.day-of-month"),
|
|
52
|
-
dateDayOfMonthAfter: pathWithArgsPredicate("date.day-of-month-after"),
|
|
53
|
-
dateDayOfMonthBefore: pathWithArgsPredicate("date.day-of-month-before"),
|
|
54
|
-
dateDayOfWeek: pathWithArgsPredicate("date.day-of-week"),
|
|
55
|
-
dateDayOfWeekAfter: pathWithArgsPredicate("date.day-of-week-after"),
|
|
56
|
-
dateDayOfWeekBefore: pathWithArgsPredicate("date.day-of-week-before"),
|
|
57
|
-
dateMonth: pathWithArgsPredicate("date.month"),
|
|
58
|
-
dateMonthAfter: pathWithArgsPredicate("date.month-after"),
|
|
59
|
-
dateMonthBefore: pathWithArgsPredicate("date.month-before"),
|
|
60
|
-
dateYear: pathWithArgsPredicate("date.year"),
|
|
61
|
-
dateHour: pathWithArgsPredicate("date.hour"),
|
|
62
|
-
dateHourAfter: pathWithArgsPredicate("date.hour-after"),
|
|
63
|
-
dateHourBefore: pathWithArgsPredicate("date.hour-before")
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
predicate
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=predicate.js.map
|
package/dist/predicate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sources":["../src/predicate.ts"],"sourcesContent":["/**\n * Formats the value of a predicate element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a predicate builder function for predicates with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the predicate.\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst pathWithArgsPredicate = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a predicate builder function for predicates with only a path.\n *\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst pathPredicate = (name: string) => {\n\tconst predicateFn = pathWithArgsPredicate(name);\n\n\t/**\n\t * @param path - Path for the predicate.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn predicateFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a predicate builder function for predicates with only arguments and\n * no path.\n *\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst argsPredicate = <Args extends unknown[]>(name: string) => {\n\tconst predicateFn = pathWithArgsPredicate<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the predicate.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn predicateFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const predicate = {\n\t/**\n\t * The `at` predicate checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}\n\t */\n\tat: pathWithArgsPredicate<\n\t\t[value: string | number | boolean | Date | string[]]\n\t>(\"at\"),\n\n\t/**\n\t * The `not` predicate checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}\n\t */\n\tnot: pathWithArgsPredicate<\n\t\t[value: string | number | boolean | Date | string[]]\n\t>(\"not\"),\n\n\t/**\n\t * The `any` predicate takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}\n\t */\n\tany: pathWithArgsPredicate<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` predicate is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This predicate is much more efficient at this than\n\t * the any predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}\n\t */\n\tin: pathWithArgsPredicate<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` predicate provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}\n\t */\n\tfulltext: pathWithArgsPredicate<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` predicate checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}\n\t */\n\thas: pathPredicate(\"has\"),\n\n\t/**\n\t * The `missing` predicate checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}\n\t */\n\tmissing: pathPredicate(\"missing\"),\n\n\t/**\n\t * The `similar` predicate takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}\n\t */\n\tsimilar: argsPredicate<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` predicate checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This predicate will only work for a GeoPoint field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsPredicate<\n\t\t\t[latitude: number, longitude: number, radius: number]\n\t\t>(\"geopoint.near\"),\n\n\t/**\n\t * The `number.lt` predicate checks that the value in the number field is less\n\t * than the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}\n\t */\n\tnumberLessThan: pathWithArgsPredicate<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` predicate checks that the value in the number field is\n\t * greater than the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}\n\t */\n\tnumberGreaterThan: pathWithArgsPredicate<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` predicate checks that the value in the path is within\n\t * the two values passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsPredicate<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` predicate checks that the value in the path is after the\n\t * date value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}\n\t */\n\tdateAfter:\n\t\tpathWithArgsPredicate<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` predicate checks that the value in the path is before the\n\t * date value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}\n\t */\n\tdateBefore:\n\t\tpathWithArgsPredicate<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` predicate checks that the value in the path is within\n\t * the date values passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}\n\t */\n\tdateBetween:\n\t\tpathWithArgsPredicate<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` predicate checks that the value in the path is\n\t * equal to the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}\n\t */\n\tdateDayOfMonth: pathWithArgsPredicate<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` predicate checks that the value in the path\n\t * is after the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsPredicate<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` predicate checks that the value in the path\n\t * is before the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsPredicate<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` predicate checks that the value in the path is equal\n\t * to the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}\n\t */\n\tdateDayOfWeek:\n\t\tpathWithArgsPredicate<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` predicate checks that the value in the path is\n\t * after the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsPredicate<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before predicate checks that the value in the path is\n\t * before the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsPredicate<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` predicate checks that the value in the path occurs in the\n\t * month value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}\n\t */\n\tdateMonth: pathWithArgsPredicate<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` predicate checks that the value in the path occurs\n\t * in any month after the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsPredicate<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` predicate checks that the value in the path occurs\n\t * in any month before the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsPredicate<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` predicate checks that the value in the path occurs in the\n\t * year value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}\n\t */\n\tdateYear: pathWithArgsPredicate<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` predicate checks that the value in the path occurs within\n\t * the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}\n\t */\n\tdateHour: pathWithArgsPredicate<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` predicate checks that the value in the path occurs\n\t * after the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}\n\t */\n\tdateHourAfter: pathWithArgsPredicate<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` predicate checks that the value in the path occurs\n\t * before the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}\n\t */\n\tdateHourBefore: pathWithArgsPredicate<[hour: number]>(\"date.hour-before\"),\n};\n"],"names":[],"mappings":"AAQA,MAAM,cAAc,CACnB,UAMW;AACP,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,IAAI,MAAM,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAC3C;AAEG,MAAA,OAAO,UAAU,UAAU;AAC9B,WAAO,IAAI;AAAA,EACX;AAED,MAAI,iBAAiB,MAAM;AACnB,WAAA,GAAG,MAAM,QAAO;AAAA,EACvB;AAED,SAAO,GAAG;AACX;AAWA,MAAM,wBAAwB,CAAyB,SAAgB;AAIhE,QAAA,KAAK,CAAC,SAAiB,SAAsB;AAClD,UAAM,gBAAgB,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI;AACrD,UAAM,SAAS,QAAQ,KAAK,SAAS,OAAO;AAErC,WAAA,IAAI,QAAQ,OAAO,SAAS;AAAA,EAAA;AAG7B,SAAA;AACR;AASA,MAAM,gBAAgB,CAAC,SAAgB;AAChC,QAAA,cAAc,sBAAsB,IAAI;AAKxC,QAAA,KAAK,CAAC,SAAwB;AACnC,WAAO,YAAY,IAAI;AAAA,EAAA;AAGjB,SAAA;AACR;AAUA,MAAM,gBAAgB,CAAyB,SAAgB;AACxD,QAAA,cAAc,sBAA4B,IAAI;AAK9C,QAAA,KAAK,IAAI,SAAsB;AAC7B,WAAA,YAAY,IAAI,GAAG,IAAI;AAAA,EAAA;AAGxB,SAAA;AACR;AAEO,MAAM,YAAY;AAAA,EAOxB,IAAI,sBAEF,IAAI;AAAA,EAQN,KAAK,sBAEH,KAAK;AAAA,EASP,KAAK,sBACJ,KAAK;AAAA,EAUN,IAAI,sBAA0C,IAAI;AAAA,EAYlD,UAAU,sBAA6C,UAAU;AAAA,EASjE,KAAK,cAAc,KAAK;AAAA,EASxB,SAAS,cAAc,SAAS;AAAA,EAShC,SAAS,cAA2C,SAAS;AAAA,EAU7D,cACC,sBAEE,eAAe;AAAA,EAQlB,gBAAgB,sBAAuC,WAAW;AAAA,EAQlE,mBAAmB,sBAAuC,WAAW;AAAA,EAQrE,eACC,sBACC,gBAAgB;AAAA,EASlB,WACC,sBAAsD,YAAY;AAAA,EAQnE,YACC,sBAAsD,aAAa;AAAA,EAQpE,aACC,sBAEE,cAAc;AAAA,EAQjB,gBAAgB,sBAAqC,mBAAmB;AAAA,EAQxE,qBAAqB,sBACpB,yBAAyB;AAAA,EAS1B,sBAAsB,sBACrB,0BAA0B;AAAA,EAS3B,eACC,sBAA8C,kBAAkB;AAAA,EAQjE,oBAAoB,sBACnB,wBAAwB;AAAA,EASzB,qBAAqB,sBACpB,yBAAyB;AAAA,EAS1B,WAAW,sBAAgD,YAAY;AAAA,EAQvE,gBACC,sBAAgD,kBAAkB;AAAA,EAQnE,iBACC,sBAAgD,mBAAmB;AAAA,EAQpE,UAAU,sBAAsC,WAAW;AAAA,EAQ3D,UAAU,sBAAsC,WAAW;AAAA,EAQ3D,eAAe,sBAAsC,iBAAiB;AAAA,EAQtE,gBAAgB,sBAAsC,kBAAkB;;"}
|
package/dist/types/client.d.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { PrismicDocument } from "./value/document";
|
|
2
|
-
import { ExtractOrFallback } from "./utils";
|
|
3
|
-
/**
|
|
4
|
-
* Extracts one or more Prismic document types that match a given Prismic
|
|
5
|
-
* document type. If no matches are found, no extraction is performed and the
|
|
6
|
-
* union of all provided Prismic document types are returned.
|
|
7
|
-
*
|
|
8
|
-
* @typeParam TDocuments - Prismic document types from which to extract.
|
|
9
|
-
* @typeParam TDocumentType - Type(s) to match `TDocuments` against.
|
|
10
|
-
*/
|
|
11
|
-
export declare type ExtractDocumentType<TDocuments extends PrismicDocument, TDocumentType extends TDocuments["type"]> = ExtractOrFallback<TDocuments, {
|
|
12
|
-
type: TDocumentType;
|
|
13
|
-
}>;
|
|
14
|
-
/**
|
|
15
|
-
* A universal API to make network requests. A subset of the `fetch()` API.
|
|
16
|
-
*
|
|
17
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
|
|
18
|
-
*/
|
|
19
|
-
export declare type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
|
|
20
|
-
/**
|
|
21
|
-
* An object that allows you to abort a `fetch()` request if needed via an
|
|
22
|
-
* `AbortController` object
|
|
23
|
-
*
|
|
24
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
25
|
-
*/
|
|
26
|
-
export declare type AbortSignalLike = any;
|
|
27
|
-
/**
|
|
28
|
-
* The minimum required properties from RequestInit.
|
|
29
|
-
*/
|
|
30
|
-
export interface RequestInitLike {
|
|
31
|
-
headers?: Record<string, string>;
|
|
32
|
-
/**
|
|
33
|
-
* An object that allows you to abort a `fetch()` request if needed via an
|
|
34
|
-
* `AbortController` object
|
|
35
|
-
*
|
|
36
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
37
|
-
*/
|
|
38
|
-
signal?: AbortSignalLike;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The minimum required properties from Response.
|
|
42
|
-
*/
|
|
43
|
-
export interface ResponseLike {
|
|
44
|
-
status: number;
|
|
45
|
-
json(): Promise<any>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The minimum required properties to treat as an HTTP Request for automatic
|
|
49
|
-
* Prismic preview support.
|
|
50
|
-
*/
|
|
51
|
-
export declare type HttpRequestLike = /**
|
|
52
|
-
* Web API Request
|
|
53
|
-
*
|
|
54
|
-
* @see http://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
55
|
-
*/ {
|
|
56
|
-
headers?: {
|
|
57
|
-
get(name: string): string | null;
|
|
58
|
-
};
|
|
59
|
-
url?: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Express-style Request
|
|
63
|
-
*/
|
|
64
|
-
| {
|
|
65
|
-
headers?: {
|
|
66
|
-
cookie?: string;
|
|
67
|
-
};
|
|
68
|
-
query?: Record<string, unknown>;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* An `orderings` parameter that orders the results by the specified field.
|
|
72
|
-
*
|
|
73
|
-
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
|
|
74
|
-
*/
|
|
75
|
-
export interface Ordering {
|
|
76
|
-
field: string;
|
|
77
|
-
direction?: "asc" | "desc";
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* A `routes` parameter that determines how a document's URL field is resolved.
|
|
81
|
-
*
|
|
82
|
-
* @example With a document's UID field.
|
|
83
|
-
*
|
|
84
|
-
* ```ts
|
|
85
|
-
* {
|
|
86
|
-
* "type": "page",
|
|
87
|
-
* "path": "/:uid"
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* @example With a Content Relationship `parent` field.
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* {
|
|
95
|
-
* "type": "page",
|
|
96
|
-
* "path": "/:parent?/:uid",
|
|
97
|
-
* "resolvers": {
|
|
98
|
-
* "parent": "parent"
|
|
99
|
-
* }
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
104
|
-
*/
|
|
105
|
-
export interface Route {
|
|
106
|
-
/**
|
|
107
|
-
* The Custom Type of the document.
|
|
108
|
-
*/
|
|
109
|
-
type: string;
|
|
110
|
-
/**
|
|
111
|
-
* A specific UID to which this route definition is scoped. The route is only
|
|
112
|
-
* defined for the document whose UID matches the given UID.
|
|
113
|
-
*/
|
|
114
|
-
uid?: string;
|
|
115
|
-
/**
|
|
116
|
-
* A specific language to which this route definition is scoped. The route is
|
|
117
|
-
* only defined for documents whose language matches the given language.
|
|
118
|
-
*/
|
|
119
|
-
lang?: string;
|
|
120
|
-
/**
|
|
121
|
-
* The resolved path of the document with optional placeholders.
|
|
122
|
-
*/
|
|
123
|
-
path: string;
|
|
124
|
-
/**
|
|
125
|
-
* An object that lists the API IDs of the Content Relationships in the route.
|
|
126
|
-
*/
|
|
127
|
-
resolvers?: Record<string, string>;
|
|
128
|
-
}
|
package/dist/types/helpers.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction } from "@prismicio/richtext";
|
|
2
|
-
import { FilledContentRelationshipField } from "./value/contentRelationship";
|
|
3
|
-
/**
|
|
4
|
-
* Resolves a link to a Prismic document to a URL
|
|
5
|
-
*
|
|
6
|
-
* @typeParam ReturnType - Return type of your link resolver function, useful if
|
|
7
|
-
* you prefer to return a complex object
|
|
8
|
-
* @param linkToDocumentField - A document link field to resolve
|
|
9
|
-
*
|
|
10
|
-
* @returns Resolved URL
|
|
11
|
-
* @see Prismic link resolver documentation: {@link https://prismic.io/docs/technologies/link-resolver-javascript}
|
|
12
|
-
*/
|
|
13
|
-
export declare type LinkResolverFunction<ReturnType = string> = (linkToDocumentField: FilledContentRelationshipField) => ReturnType;
|
|
14
|
-
/**
|
|
15
|
-
* Serializes a node from a rich text or title field with a function to HTML
|
|
16
|
-
*
|
|
17
|
-
* Unlike a typical `@prismicio/richtext` function serializer, this serializer
|
|
18
|
-
* converts the `children` argument to a single string rather than an array of
|
|
19
|
-
* strings.
|
|
20
|
-
*
|
|
21
|
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
22
|
-
*/
|
|
23
|
-
export declare type HTMLFunctionSerializer = (type: Parameters<RichTextFunctionSerializer<string>>[0], node: Parameters<RichTextFunctionSerializer<string>>[1], text: Parameters<RichTextFunctionSerializer<string>>[2], children: Parameters<RichTextFunctionSerializer<string>>[3][number], key: Parameters<RichTextFunctionSerializer<string>>[4]) => string | null | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Serializes a node from a rich text or title field with a map to HTML
|
|
26
|
-
*
|
|
27
|
-
* Unlike a typical `@prismicio/richtext` map serializer, this serializer
|
|
28
|
-
* converts the `children` property to a single string rather than an array of
|
|
29
|
-
* strings.
|
|
30
|
-
*
|
|
31
|
-
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
32
|
-
*/
|
|
33
|
-
export declare type HTMLMapSerializer = {
|
|
34
|
-
[P in keyof RichTextMapSerializer<string>]: (payload: {
|
|
35
|
-
type: Parameters<HTMLMapSerializerFunction<P>>[0]["type"];
|
|
36
|
-
node: Parameters<HTMLMapSerializerFunction<P>>[0]["node"];
|
|
37
|
-
text: Parameters<HTMLMapSerializerFunction<P>>[0]["text"];
|
|
38
|
-
children: Parameters<HTMLMapSerializerFunction<P>>[0]["children"][number];
|
|
39
|
-
key: Parameters<HTMLMapSerializerFunction<P>>[0]["key"];
|
|
40
|
-
}) => string | null | undefined;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* A {@link RichTextMapSerializerFunction} type specifically for
|
|
44
|
-
* {@link HTMLMapSerializer}.
|
|
45
|
-
*
|
|
46
|
-
* @typeParam BlockName - The serializer's Rich Text block type.
|
|
47
|
-
*/
|
|
48
|
-
declare type HTMLMapSerializerFunction<BlockType extends keyof RichTextMapSerializer<string>> = RichTextMapSerializerFunction<string, ExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>, ExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>>;
|
|
49
|
-
/**
|
|
50
|
-
* Returns the `Node` generic from {@link RichTextMapSerializerFunction}.
|
|
51
|
-
*
|
|
52
|
-
* @typeParam T - The `RichTextMapSerializerFunction` containing the needed
|
|
53
|
-
* `Node` generic.
|
|
54
|
-
*/
|
|
55
|
-
declare type ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<any, infer U, any> ? U : never;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.
|
|
58
|
-
*
|
|
59
|
-
* @typeParam T - The `RichTextMapSerializerFunction` containing the needed
|
|
60
|
-
* `TextType` generic.
|
|
61
|
-
*/
|
|
62
|
-
declare type ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<any, any, infer U> ? U : never;
|
|
63
|
-
export {};
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a union of the given object's values, and optionally specify which
|
|
3
|
-
* keys to get the values from.
|
|
4
|
-
*
|
|
5
|
-
* Taken from the `type-fest` package.
|
|
6
|
-
*
|
|
7
|
-
* See:
|
|
8
|
-
* https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts
|
|
9
|
-
*/
|
|
10
|
-
export declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
11
|
-
/**
|
|
12
|
-
* Functions like TypeScript's native `Extract` utility type with added support
|
|
13
|
-
* to fall back to a value if the resulting union is `never`.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* ExtractOrFallback<"a" | "b", "a">; // => "a"
|
|
19
|
-
* ExtractOrFallback<"a" | "b", "c">; // => "a" | "b"
|
|
20
|
-
* ExtractOrFallback<"a" | "b", "c", "foo">; // => "foo"
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @typeParam T - The union from which values will be extracted.
|
|
24
|
-
* @typeParam U - The extraction condition.
|
|
25
|
-
* @typeParam Fallback - The value to return if the resulting union is `never`.
|
|
26
|
-
* Defaults to `T`.
|
|
27
|
-
*/
|
|
28
|
-
export declare type ExtractOrFallback<T, U, Fallback = T> = Extract<T, U> extends never ? Fallback : Extract<T, U>;
|