@prismicio/client 6.0.0-beta.0 → 6.0.0-beta.4

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/index.d.ts CHANGED
@@ -205,11 +205,6 @@ declare type ClientConfig = {
205
205
  * with draft content.
206
206
  */
207
207
  ref?: RefStringOrThunk;
208
- /**
209
- * A string representing a version of the Prismic repository's Integration
210
- * Fields content.
211
- */
212
- integrationFieldsRef?: RefStringOrThunk;
213
208
  /**
214
209
  * A list of Route Resolver objects that define how a document's `url` field
215
210
  * is resolved.
@@ -293,12 +288,6 @@ declare class Client {
293
288
  * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
294
289
  */
295
290
  accessToken?: string;
296
- /**
297
- * The client's Integration Fields ref for fetching the latest Integration Fields data.
298
- *
299
- * {@link https://prismic.io/docs/core-concepts/integration-fields}
300
- */
301
- integrationFieldsRef?: RefStringOrThunk;
302
291
  /**
303
292
  * A list of Route Resolver objects that define how a document's `url` field
304
293
  * is resolved.
@@ -320,11 +309,15 @@ declare class Client {
320
309
  /**
321
310
  * The client's ref mode state. This determines which ref is used during queries.
322
311
  */
323
- private refMode;
312
+ private refState;
313
+ /**
314
+ * Cached repository value.
315
+ */
316
+ private cachedRepository;
324
317
  /**
325
- * Internal cache for low-level caching.
318
+ * Timestamp at which the cached repository data is considered stale.
326
319
  */
327
- private internalCache;
320
+ private cachedRepositoryExpiration;
328
321
  /**
329
322
  * Creates a Prismic client that can be used to query a repository.
330
323
  *
@@ -394,7 +387,9 @@ declare class Client {
394
387
  * @example
395
388
  *
396
389
  * ```ts
397
- * const response = await client.get();
390
+ * const response = await client.query(
391
+ * prismic.predicate.at("document.type", "page"),
392
+ * );
398
393
  * ```
399
394
  *
400
395
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -402,7 +397,7 @@ declare class Client {
402
397
  *
403
398
  * @returns A paginated response containing the result of the query.
404
399
  */
405
- query: <TDocument extends prismicT.PrismicDocument<Record<string, prismicT.AnyRegularField | prismicT.GroupField<Record<string, prismicT.AnyRegularField>> | prismicT.SliceZone<prismicT.Slice<string, Record<string, prismicT.AnyRegularField>, Record<string, prismicT.AnyRegularField>> | prismicT.SharedSlice<string, prismicT.SharedSliceVariation<string, Record<string, prismicT.AnyRegularField>, Record<string, prismicT.AnyRegularField>>>>>, string, string>>(params?: Partial<BuildQueryURLArgs> | undefined) => Promise<prismicT.Query<TDocument>>;
400
+ query<TDocument extends prismicT.PrismicDocument>(predicates: NonNullable<BuildQueryURLArgs["predicates"]>, params?: Partial<Omit<BuildQueryURLArgs, "predicates">>): Promise<prismicT.Query<TDocument>>;
406
401
  /**
407
402
  * Queries content from the Prismic repository.
408
403
  *
@@ -434,6 +429,10 @@ declare class Client {
434
429
  */
435
430
  getFirst<TDocument extends prismicT.PrismicDocument>(params?: Partial<BuildQueryURLArgs>): Promise<TDocument>;
436
431
  /**
432
+ * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
433
+ * require more resources than other methods. Prefer using other methods that
434
+ * filter by predicates such as `getAllByType`.
435
+ *
437
436
  * Queries content from the Prismic repository and returns all matching
438
437
  * content. If no predicates are provided, all documents will be fetched.
439
438
  *
@@ -442,14 +441,15 @@ declare class Client {
442
441
  * @example
443
442
  *
444
443
  * ```ts
445
- * const response = await client.getAll();
444
+ * const response = await client.dangerouslyGetAll();
446
445
  * ```
447
446
  *
448
- * @typeParam TDocument - Type of Prismic documents returned. @param params -
449
- * Parameters to filter, sort, and paginate results. @returns A list of
450
- * documents matching the query.
447
+ * @typeParam TDocument - Type of Prismic documents returned.
448
+ * @param params - Parameters to filter, sort, and paginate results.
449
+ *
450
+ * @returns A list of documents matching the query.
451
451
  */
452
- getAll<TDocument extends prismicT.PrismicDocument>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams): Promise<TDocument[]>;
452
+ dangerouslyGetAll<TDocument extends prismicT.PrismicDocument>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams): Promise<TDocument[]>;
453
453
  /**
454
454
  * Queries a document from the Prismic repository with a specific ID.
455
455
  *
@@ -688,39 +688,77 @@ declare class Client {
688
688
  */
689
689
  getAllByTag<TDocument extends prismicT.PrismicDocument>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
690
690
  /**
691
- * Queries documents from the Prismic repository with a specific tag.
691
+ * Queries documents from the Prismic repository with specific tags. A
692
+ * document must be tagged with all of the queried tags to be included.
692
693
  *
693
694
  * @example
694
695
  *
695
696
  * ```ts
696
- * const response = await client.getAllByTag("food");
697
+ * const response = await client.getByEveryTag(["food", "fruit"]);
697
698
  * ```
698
699
  *
699
700
  * @typeParam TDocument - Type of Prismic documents returned.
700
701
  * @param tags - A list of tags that must be included on a document.
701
702
  * @param params - Parameters to filter, sort, and paginate the results.
702
703
  *
703
- * @returns A paginated response containing documents with the tag.
704
+ * @returns A paginated response containing documents with the tags.
704
705
  */
705
- getByTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
706
+ getByEveryTag<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
706
707
  /**
707
- * Queries all documents from the Prismic repository with a specific tag.
708
+ * Queries documents from the Prismic repository with specific tags. A
709
+ * document must be tagged with all of the queried tags to be included.
708
710
  *
709
711
  * This method may make multiple network requests to query all matching content.
710
712
  *
711
713
  * @example
712
714
  *
713
715
  * ```ts
714
- * const response = await client.getAllByTag("food");
716
+ * const response = await client.getAllByEveryTag(["food", "fruit"]);
715
717
  * ```
716
718
  *
717
719
  * @typeParam TDocument - Type of Prismic documents returned.
718
720
  * @param tags - A list of tags that must be included on a document.
719
721
  * @param params - Parameters to filter, sort, and paginate the results.
720
722
  *
721
- * @returns A list of all documents with the tag.
723
+ * @returns A list of all documents with the tags.
724
+ */
725
+ getAllByEveryTag<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
726
+ /**
727
+ * Queries documents from the Prismic repository with specific tags. A
728
+ * document must be tagged with at least one of the queried tags to be included.
729
+ *
730
+ * @example
731
+ *
732
+ * ```ts
733
+ * const response = await client.getByEveryTag(["food", "fruit"]);
734
+ * ```
735
+ *
736
+ * @typeParam TDocument - Type of Prismic documents returned.
737
+ * @param tags - A list of tags that must be included on a document.
738
+ * @param params - Parameters to filter, sort, and paginate the results.
739
+ *
740
+ * @returns A paginated response containing documents with at least one of the tags.
722
741
  */
723
- getAllByTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
742
+ getBySomeTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<BuildQueryURLArgs>): Promise<prismicT.Query<TDocument>>;
743
+ /**
744
+ * Queries documents from the Prismic repository with specific tags. A
745
+ * document must be tagged with at least one of the queried tags to be included.
746
+ *
747
+ * This method may make multiple network requests to query all matching content.
748
+ *
749
+ * @example
750
+ *
751
+ * ```ts
752
+ * const response = await client.getAllByEveryTag(["food", "fruit"]);
753
+ * ```
754
+ *
755
+ * @typeParam TDocument - Type of Prismic documents returned.
756
+ * @param tags - A list of tags that must be included on a document.
757
+ * @param params - Parameters to filter, sort, and paginate the results.
758
+ *
759
+ * @returns A list of all documents with at least one of the tags.
760
+ */
761
+ getAllBySomeTags<TDocument extends prismicT.PrismicDocument>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">>): Promise<TDocument[]>;
724
762
  /**
725
763
  * Returns metadata about the Prismic repository, such as its refs, releases,
726
764
  * and custom types.
@@ -896,31 +934,6 @@ declare class Client {
896
934
  * @throws If a matching form cannot be found.
897
935
  */
898
936
  private getCachedRepositoryForm;
899
- /**
900
- * Returns the preview ref for the client, if one exists.
901
- *
902
- * If this method is used in the browser, the browser's cookies will be read.
903
- * If this method is used on the server, the cookies from the saved HTTP
904
- * Request will be read, if an HTTP Request was given.
905
- *
906
- * @returns The preview ref as a string, if one exists.
907
- */
908
- private getPreviewRefString;
909
- /**
910
- * Returns the Integration Fields ref for the client, if one exists. This ref
911
- * is used to fetch the latest content from a Integration Field's API.
912
- *
913
- * @returns The repository's Integration Fields ref.
914
- */
915
- private getIntegrationFieldsRef;
916
- /**
917
- * Returns the Integration Fields ref neeed to query based on the client's
918
- * configuration. This method may make a network request to fetch a ref or
919
- * resolve the user's Integration Field ref thunk.
920
- *
921
- * @returns The repository's Integration Fields ref, if one is available.
922
- */
923
- private getResolvedIntegrationFieldsRef;
924
937
  /**
925
938
  * Returns the ref needed to query based on the client's current state. This
926
939
  * method may make a network request to fetch a ref or resolve the user's ref thunk.
@@ -943,16 +956,6 @@ declare class Client {
943
956
  * @returns The ref to use during a query.
944
957
  */
945
958
  private getResolvedRefString;
946
- /**
947
- * Returns the network request options required by the Prismic repository.
948
- *
949
- * It currently only includes an Authorization header if an access token is provided.
950
- *
951
- * @param params - Parameters for the query, including an access token.
952
- *
953
- * @returns Request options that can be used to make a network request to
954
- * query the repository.
955
- */
956
959
  /**
957
960
  * Performs a network request using the configured `fetch` function. It
958
961
  * assumes all successful responses will have a JSON content type. It also
@@ -967,326 +970,241 @@ declare class Client {
967
970
  private fetch;
968
971
  }
969
972
 
970
- /**
971
- * The `at` predicate checks that the path matches the described value exactly.
972
- * It takes a single value for a field or an array (only for tags).
973
- *
974
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
975
- */
976
- declare const at: (path: string, value: string | number | (string | number)[]) => string;
977
- /**
978
- * The `not` predicate checks that the path doesn't match the provided value
979
- * exactly. It takes a single value as the argument.
980
- *
981
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
982
- */
983
- declare const not: (path: string, value: string | number | (string | number)[]) => string;
984
- /**
985
- * The `any` predicate takes an array of values. It works exactly the same way
986
- * as the `at` operator, but checks whether the fragment matches any of the
987
- * values in the array.
988
- *
989
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
990
- */
991
- declare const any: (path: string, value: string | number | (string | number)[]) => string;
992
- /**
993
- * The `in` predicate is used specifically to retrieve an array of documents by
994
- * their IDs or UIDs. This predicate is much more efficient at this than the any
995
- * predicate.
996
- *
997
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
998
- */
999
- declare const _in: (path: string, value: string | number | (string | number)[]) => string;
1000
-
1001
- /**
1002
- * The `fulltext` predicate provides two capabilities:
1003
- *
1004
- * 1. Checking if a certain string is anywhere inside a document (this is what you
1005
- * should use to make your project's search engine feature)
1006
- * 2. Checking if the string is contained inside a specific custom type’s Rich Text
1007
- * or Key Text fragment.
1008
- *
1009
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
1010
- */
1011
- declare const fulltext: (path: string, value: string | number | (string | number)[]) => string;
1012
- /**
1013
- * The `has` predicate checks whether a fragment has a value. It will return all
1014
- * the documents of the specified type that contain a value for the specified field.
1015
- *
1016
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}
1017
- */
1018
- declare const has: (path: string) => string;
1019
- /**
1020
- * The `missing` predicate checks if a fragment doesn't have a value. It will
1021
- * return all the documents of the specified type that do not contain a value
1022
- * for the specified field.
1023
- *
1024
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}
1025
- */
1026
- declare const missing: (path: string) => string;
1027
- /**
1028
- * The `similar` predicate takes the ID of a document, and returns a list of
1029
- * documents with similar content. This allows you to build an automated content
1030
- * discovery feature (for example, a "Related posts" section).
1031
- *
1032
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}
1033
- */
1034
- declare const similar: (id: string, value: number) => string;
1035
- /**
1036
- * The `geopoint.near` predicate checks that the value in the path is within the
1037
- * radius of the given coordinates.
1038
- *
1039
- * This predicate will only work for a GeoPoint field.
1040
- *
1041
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}
1042
- */
1043
- declare const geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1044
- /**
1045
- * The `number.lt` predicate checks that the value in the number field is less
1046
- * than the value passed into the predicate.
1047
- *
1048
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}
1049
- */
1050
- declare const numberLessThan: (path: string, value: number) => string;
1051
- /**
1052
- * The `number.gt` predicate checks that the value in the number field is
1053
- * greater than the value passed into the predicate.
1054
- *
1055
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}
1056
- */
1057
- declare const numberGreaterThan: (path: string, value: number) => string;
1058
- /**
1059
- * The `number.inRange` predicate checks that the value in the path is within
1060
- * the two values passed into the predicate.
1061
- *
1062
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}
1063
- */
1064
- declare const numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1065
- /**
1066
- * The `date.after` predicate checks that the value in the path is after the
1067
- * date value passed into the predicate.
1068
- *
1069
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}
1070
- */
1071
- declare const dateAfter: (path: string, date: string | number | Date) => string;
1072
- /**
1073
- * The `date.before` predicate checks that the value in the path is before the
1074
- * date value passed into the predicate.
1075
- *
1076
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}
1077
- */
1078
- declare const dateBefore: (path: string, date: string | number | Date) => string;
1079
- /**
1080
- * The `date.between` predicate checks that the value in the path is within the
1081
- * date values passed into the predicate.
1082
- *
1083
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}
1084
- */
1085
- declare const dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1086
- /**
1087
- * The `date.day-of-month` predicate checks that the value in the path is equal
1088
- * to the day of the month passed into the predicate.
1089
- *
1090
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}
1091
- */
1092
- declare const dateDayOfMonth: (path: string, day: number) => string;
1093
- /**
1094
- * The `date.day-of-month-after` predicate checks that the value in the path is
1095
- * after the day of the month passed into the predicate.
1096
- *
1097
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}
1098
- */
1099
- declare const dateDayOfMonthAfter: (path: string, day: number) => string;
1100
- /**
1101
- * The `date.day-of-month-before` predicate checks that the value in the path is
1102
- * before the day of the month passed into the predicate.
1103
- *
1104
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}
1105
- */
1106
- declare const dateDayOfMonthBefore: (path: string, day: number) => string;
1107
- /**
1108
- * The `date.day-of-week` predicate checks that the value in the path is equal
1109
- * to the day of the week passed into the predicate.
1110
- *
1111
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}
1112
- */
1113
- declare const dateDayOfWeek: (path: string, day: string | number) => string;
1114
- /**
1115
- * The `date.day-of-week-after` predicate checks that the value in the path is
1116
- * after the day of the week passed into the predicate.
1117
- *
1118
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}
1119
- */
1120
- declare const dateDayOfWeekAfter: (path: string, day: string | number) => string;
1121
- /**
1122
- * The date.day-of-week-before predicate checks that the value in the path is
1123
- * before the day of the week passed into the predicate.
1124
- *
1125
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}
1126
- */
1127
- declare const dateDayOfWeekBefore: (path: string, day: string | number) => string;
1128
- /**
1129
- * The `date.month` predicate checks that the value in the path occurs in the
1130
- * month value passed into the predicate.
1131
- *
1132
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}
1133
- */
1134
- declare const dateMonth: (path: string, month: string | number) => string;
1135
- /**
1136
- * The `date.month-after` predicate checks that the value in the path occurs in
1137
- * any month after the value passed into the predicate.
1138
- *
1139
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}
1140
- */
1141
- declare const dateMonthAfter: (path: string, month: string | number) => string;
1142
- /**
1143
- * The `date.month-before` predicate checks that the value in the path occurs in
1144
- * any month before the value passed into the predicate.
1145
- *
1146
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}
1147
- */
1148
- declare const dateMonthBefore: (path: string, month: string | number) => string;
1149
- /**
1150
- * The `date.year` predicate checks that the value in the path occurs in the
1151
- * year value passed into the predicate.
1152
- *
1153
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}
1154
- */
1155
- declare const dateYear: (path: string, year: number) => string;
1156
- /**
1157
- * The `date.hour` predicate checks that the value in the path occurs within the
1158
- * hour value passed into the predicate.
1159
- *
1160
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}
1161
- */
1162
- declare const dateHour: (path: string, hour: number) => string;
1163
- /**
1164
- * The `date.hour-after` predicate checks that the value in the path occurs
1165
- * after the hour value passed into the predicate.
1166
- *
1167
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}
1168
- */
1169
- declare const dateHourAfter: (path: string, hour: number) => string;
1170
- /**
1171
- * The `date.hour-before` predicate checks that the value in the path occurs
1172
- * before the hour value passed into the predicate.
1173
- *
1174
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}
1175
- */
1176
- declare const dateHourBefore: (path: string, hour: number) => string;
1177
-
1178
- declare const predicate_at: typeof at;
1179
- declare const predicate_not: typeof not;
1180
- declare const predicate_any: typeof any;
1181
- declare const predicate_fulltext: typeof fulltext;
1182
- declare const predicate_has: typeof has;
1183
- declare const predicate_missing: typeof missing;
1184
- declare const predicate_similar: typeof similar;
1185
- declare const predicate_geopointNear: typeof geopointNear;
1186
- declare const predicate_numberLessThan: typeof numberLessThan;
1187
- declare const predicate_numberGreaterThan: typeof numberGreaterThan;
1188
- declare const predicate_numberInRange: typeof numberInRange;
1189
- declare const predicate_dateAfter: typeof dateAfter;
1190
- declare const predicate_dateBefore: typeof dateBefore;
1191
- declare const predicate_dateBetween: typeof dateBetween;
1192
- declare const predicate_dateDayOfMonth: typeof dateDayOfMonth;
1193
- declare const predicate_dateDayOfMonthAfter: typeof dateDayOfMonthAfter;
1194
- declare const predicate_dateDayOfMonthBefore: typeof dateDayOfMonthBefore;
1195
- declare const predicate_dateDayOfWeek: typeof dateDayOfWeek;
1196
- declare const predicate_dateDayOfWeekAfter: typeof dateDayOfWeekAfter;
1197
- declare const predicate_dateDayOfWeekBefore: typeof dateDayOfWeekBefore;
1198
- declare const predicate_dateMonth: typeof dateMonth;
1199
- declare const predicate_dateMonthAfter: typeof dateMonthAfter;
1200
- declare const predicate_dateMonthBefore: typeof dateMonthBefore;
1201
- declare const predicate_dateYear: typeof dateYear;
1202
- declare const predicate_dateHour: typeof dateHour;
1203
- declare const predicate_dateHourAfter: typeof dateHourAfter;
1204
- declare const predicate_dateHourBefore: typeof dateHourBefore;
1205
- declare namespace predicate {
1206
- export {
1207
- _in as in,
1208
- predicate_at as at,
1209
- predicate_not as not,
1210
- predicate_any as any,
1211
- predicate_fulltext as fulltext,
1212
- predicate_has as has,
1213
- predicate_missing as missing,
1214
- predicate_similar as similar,
1215
- predicate_geopointNear as geopointNear,
1216
- predicate_numberLessThan as numberLessThan,
1217
- predicate_numberGreaterThan as numberGreaterThan,
1218
- predicate_numberInRange as numberInRange,
1219
- predicate_dateAfter as dateAfter,
1220
- predicate_dateBefore as dateBefore,
1221
- predicate_dateBetween as dateBetween,
1222
- predicate_dateDayOfMonth as dateDayOfMonth,
1223
- predicate_dateDayOfMonthAfter as dateDayOfMonthAfter,
1224
- predicate_dateDayOfMonthBefore as dateDayOfMonthBefore,
1225
- predicate_dateDayOfWeek as dateDayOfWeek,
1226
- predicate_dateDayOfWeekAfter as dateDayOfWeekAfter,
1227
- predicate_dateDayOfWeekBefore as dateDayOfWeekBefore,
1228
- predicate_dateMonth as dateMonth,
1229
- predicate_dateMonthAfter as dateMonthAfter,
1230
- predicate_dateMonthBefore as dateMonthBefore,
1231
- predicate_dateYear as dateYear,
1232
- predicate_dateHour as dateHour,
1233
- predicate_dateHourAfter as dateHourAfter,
1234
- predicate_dateHourBefore as dateHourBefore,
1235
- };
1236
- }
973
+ declare const predicate: {
974
+ /**
975
+ * The `at` predicate checks that the path matches the described value
976
+ * exactly. It takes a single value for a field or an array (only for tags).
977
+ *
978
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
979
+ */
980
+ at: (path: string, value: string | number | (string | number)[]) => string;
981
+ /**
982
+ * The `not` predicate checks that the path doesn't match the provided value
983
+ * exactly. It takes a single value as the argument.
984
+ *
985
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
986
+ */
987
+ not: (path: string, value: string | number | (string | number)[]) => string;
988
+ /**
989
+ * The `any` predicate takes an array of values. It works exactly the same way
990
+ * as the `at` operator, but checks whether the fragment matches any of the
991
+ * values in the array.
992
+ *
993
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
994
+ */
995
+ any: (path: string, value: string | number | (string | number)[]) => string;
996
+ /**
997
+ * The `in` predicate is used specifically to retrieve an array of documents
998
+ * by their IDs or UIDs. This predicate is much more efficient at this than
999
+ * the any predicate.
1000
+ *
1001
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
1002
+ */
1003
+ in: (path: string, value: string | number | (string | number)[]) => string;
1004
+ /**
1005
+ * The `fulltext` predicate provides two capabilities:
1006
+ *
1007
+ * 1. Checking if a certain string is anywhere inside a document (this is what
1008
+ * you should use to make your project's search engine feature)
1009
+ * 2. Checking if the string is contained inside a specific custom type’s Rich
1010
+ * Text or Key Text fragment.
1011
+ *
1012
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
1013
+ */
1014
+ fulltext: (path: string, value: string | number | (string | number)[]) => string;
1015
+ /**
1016
+ * The `has` predicate checks whether a fragment has a value. It will return
1017
+ * all the documents of the specified type that contain a value for the
1018
+ * specified field.
1019
+ *
1020
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}
1021
+ */
1022
+ has: (path: string) => string;
1023
+ /**
1024
+ * The `missing` predicate checks if a fragment doesn't have a value. It will
1025
+ * return all the documents of the specified type that do not contain a value
1026
+ * for the specified field.
1027
+ *
1028
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}
1029
+ */
1030
+ missing: (path: string) => string;
1031
+ /**
1032
+ * The `similar` predicate takes the ID of a document, and returns a list of
1033
+ * documents with similar content. This allows you to build an automated
1034
+ * content discovery feature (for example, a "Related posts" section).
1035
+ *
1036
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}
1037
+ */
1038
+ similar: (id: string, value: number) => string;
1039
+ /**
1040
+ * The `geopoint.near` predicate checks that the value in the path is within
1041
+ * the radius of the given coordinates.
1042
+ *
1043
+ * This predicate will only work for a GeoPoint field.
1044
+ *
1045
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}
1046
+ */
1047
+ geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1048
+ /**
1049
+ * The `number.lt` predicate checks that the value in the number field is less
1050
+ * than the value passed into the predicate.
1051
+ *
1052
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}
1053
+ */
1054
+ numberLessThan: (path: string, value: number) => string;
1055
+ /**
1056
+ * The `number.gt` predicate checks that the value in the number field is
1057
+ * greater than the value passed into the predicate.
1058
+ *
1059
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}
1060
+ */
1061
+ numberGreaterThan: (path: string, value: number) => string;
1062
+ /**
1063
+ * The `number.inRange` predicate checks that the value in the path is within
1064
+ * the two values passed into the predicate.
1065
+ *
1066
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}
1067
+ */
1068
+ numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1069
+ /**
1070
+ * The `date.after` predicate checks that the value in the path is after the
1071
+ * date value passed into the predicate.
1072
+ *
1073
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}
1074
+ */
1075
+ dateAfter: (path: string, date: string | number | Date) => string;
1076
+ /**
1077
+ * The `date.before` predicate checks that the value in the path is before the
1078
+ * date value passed into the predicate.
1079
+ *
1080
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}
1081
+ */
1082
+ dateBefore: (path: string, date: string | number | Date) => string;
1083
+ /**
1084
+ * The `date.between` predicate checks that the value in the path is within
1085
+ * the date values passed into the predicate.
1086
+ *
1087
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}
1088
+ */
1089
+ dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1090
+ /**
1091
+ * The `date.day-of-month` predicate checks that the value in the path is
1092
+ * equal to the day of the month passed into the predicate.
1093
+ *
1094
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}
1095
+ */
1096
+ dateDayOfMonth: (path: string, day: number) => string;
1097
+ /**
1098
+ * The `date.day-of-month-after` predicate checks that the value in the path
1099
+ * is after the day of the month passed into the predicate.
1100
+ *
1101
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}
1102
+ */
1103
+ dateDayOfMonthAfter: (path: string, day: number) => string;
1104
+ /**
1105
+ * The `date.day-of-month-before` predicate checks that the value in the path
1106
+ * is before the day of the month passed into the predicate.
1107
+ *
1108
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}
1109
+ */
1110
+ dateDayOfMonthBefore: (path: string, day: number) => string;
1111
+ /**
1112
+ * The `date.day-of-week` predicate checks that the value in the path is equal
1113
+ * to the day of the week passed into the predicate.
1114
+ *
1115
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}
1116
+ */
1117
+ dateDayOfWeek: (path: string, day: string | number) => string;
1118
+ /**
1119
+ * The `date.day-of-week-after` predicate checks that the value in the path is
1120
+ * after the day of the week passed into the predicate.
1121
+ *
1122
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}
1123
+ */
1124
+ dateDayOfWeekAfter: (path: string, day: string | number) => string;
1125
+ /**
1126
+ * The date.day-of-week-before predicate checks that the value in the path is
1127
+ * before the day of the week passed into the predicate.
1128
+ *
1129
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}
1130
+ */
1131
+ dateDayOfWeekBefore: (path: string, day: string | number) => string;
1132
+ /**
1133
+ * The `date.month` predicate checks that the value in the path occurs in the
1134
+ * month value passed into the predicate.
1135
+ *
1136
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}
1137
+ */
1138
+ dateMonth: (path: string, month: string | number) => string;
1139
+ /**
1140
+ * The `date.month-after` predicate checks that the value in the path occurs
1141
+ * in any month after the value passed into the predicate.
1142
+ *
1143
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}
1144
+ */
1145
+ dateMonthAfter: (path: string, month: string | number) => string;
1146
+ /**
1147
+ * The `date.month-before` predicate checks that the value in the path occurs
1148
+ * in any month before the value passed into the predicate.
1149
+ *
1150
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}
1151
+ */
1152
+ dateMonthBefore: (path: string, month: string | number) => string;
1153
+ /**
1154
+ * The `date.year` predicate checks that the value in the path occurs in the
1155
+ * year value passed into the predicate.
1156
+ *
1157
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}
1158
+ */
1159
+ dateYear: (path: string, year: number) => string;
1160
+ /**
1161
+ * The `date.hour` predicate checks that the value in the path occurs within
1162
+ * the hour value passed into the predicate.
1163
+ *
1164
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}
1165
+ */
1166
+ dateHour: (path: string, hour: number) => string;
1167
+ /**
1168
+ * The `date.hour-after` predicate checks that the value in the path occurs
1169
+ * after the hour value passed into the predicate.
1170
+ *
1171
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}
1172
+ */
1173
+ dateHourAfter: (path: string, hour: number) => string;
1174
+ /**
1175
+ * The `date.hour-before` predicate checks that the value in the path occurs
1176
+ * before the hour value passed into the predicate.
1177
+ *
1178
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}
1179
+ */
1180
+ dateHourBefore: (path: string, hour: number) => string;
1181
+ };
1237
1182
 
1238
- declare type PrismicErrorArgs = {
1239
- url: string;
1240
- response?: Record<string, unknown>;
1241
- };
1242
- declare class PrismicError extends Error {
1243
- url: string;
1244
- response?: Record<string, unknown>;
1245
- constructor(message: string | undefined, args: PrismicErrorArgs);
1183
+ declare class PrismicError<Response> extends Error {
1184
+ url?: string;
1185
+ response: Response;
1186
+ constructor(message: string | undefined, url: string | undefined, response: Response);
1246
1187
  }
1247
1188
 
1248
- interface ForbiddenErrorRepositoryAPIResponse {
1189
+ declare type ForbiddenErrorRepositoryAPIResponse = {
1249
1190
  type: string;
1250
1191
  message: string;
1251
- oauth_initiate: string;
1252
- oauth_token: string;
1253
- }
1254
- interface ForbiddenErrorQueryAPIResponse {
1192
+ };
1193
+ declare type ForbiddenErrorQueryAPIResponse = {
1255
1194
  error: string;
1256
- oauth_initiate: string;
1257
- oauth_token: string;
1258
- }
1259
- declare type ForbiddenErrorAPIResponse = ForbiddenErrorRepositoryAPIResponse | ForbiddenErrorQueryAPIResponse;
1260
- declare type ForbiddenErrorArgs = {
1261
- url: string;
1262
- response: ForbiddenErrorAPIResponse;
1263
1195
  };
1264
- declare class ForbiddenError extends Error {
1265
- url: string;
1266
- oauth_initiate: string;
1267
- oauth_token: string;
1268
- constructor(message: string, args: ForbiddenErrorArgs);
1196
+ declare class ForbiddenError extends PrismicError<ForbiddenErrorRepositoryAPIResponse | ForbiddenErrorQueryAPIResponse> {
1269
1197
  }
1270
1198
 
1271
- interface ParsingErrorAPIResponse {
1199
+ declare type ParsingErrorAPIResponse = {
1272
1200
  type: "parsing-error";
1273
1201
  message: string;
1274
1202
  line: number;
1275
1203
  column: number;
1276
1204
  id: number;
1277
1205
  location: string;
1278
- }
1279
- declare type ParsingErrorArgs = {
1280
- url: string;
1281
- response: ParsingErrorAPIResponse;
1282
1206
  };
1283
- declare class ParsingError extends Error {
1284
- url: string;
1285
- line: number;
1286
- column: number;
1287
- id: number;
1288
- location: string;
1289
- constructor(message: string, args: ParsingErrorArgs);
1207
+ declare class ParsingError extends PrismicError<ParsingErrorAPIResponse> {
1290
1208
  }
1291
1209
 
1292
1210
  /**
@@ -1301,4 +1219,71 @@ declare namespace cookie {
1301
1219
  };
1302
1220
  }
1303
1221
 
1304
- export { BuildQueryURLArgs, Client, ClientConfig, FetchLike, ForbiddenError, HttpRequestLike, Ordering, ParsingError, PrismicError, QueryParams, RequestInitLike, ResponseLike, Route, buildQueryURL, cookie, createClient, getEndpoint, predicate };
1222
+ /**
1223
+ * @deprecated Renamed to `predicate` (without an "s").
1224
+ */
1225
+ declare const predicates: {
1226
+ at: (path: string, value: string | number | (string | number)[]) => string;
1227
+ not: (path: string, value: string | number | (string | number)[]) => string;
1228
+ any: (path: string, value: string | number | (string | number)[]) => string;
1229
+ in: (path: string, value: string | number | (string | number)[]) => string;
1230
+ fulltext: (path: string, value: string | number | (string | number)[]) => string;
1231
+ has: (path: string) => string;
1232
+ missing: (path: string) => string;
1233
+ similar: (id: string, value: number) => string;
1234
+ geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1235
+ numberLessThan: (path: string, value: number) => string;
1236
+ numberGreaterThan: (path: string, value: number) => string;
1237
+ numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1238
+ dateAfter: (path: string, date: string | number | Date) => string;
1239
+ dateBefore: (path: string, date: string | number | Date) => string;
1240
+ dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1241
+ dateDayOfMonth: (path: string, day: number) => string;
1242
+ dateDayOfMonthAfter: (path: string, day: number) => string;
1243
+ dateDayOfMonthBefore: (path: string, day: number) => string;
1244
+ dateDayOfWeek: (path: string, day: string | number) => string;
1245
+ dateDayOfWeekAfter: (path: string, day: string | number) => string;
1246
+ dateDayOfWeekBefore: (path: string, day: string | number) => string;
1247
+ dateMonth: (path: string, month: string | number) => string;
1248
+ dateMonthAfter: (path: string, month: string | number) => string;
1249
+ dateMonthBefore: (path: string, month: string | number) => string;
1250
+ dateYear: (path: string, year: number) => string;
1251
+ dateHour: (path: string, hour: number) => string;
1252
+ dateHourAfter: (path: string, hour: number) => string;
1253
+ dateHourBefore: (path: string, hour: number) => string;
1254
+ };
1255
+ /**
1256
+ * @deprecated Renamed to `predicate` (lowercase and without an "s").
1257
+ */
1258
+ declare const Predicates: {
1259
+ at: (path: string, value: string | number | (string | number)[]) => string;
1260
+ not: (path: string, value: string | number | (string | number)[]) => string;
1261
+ any: (path: string, value: string | number | (string | number)[]) => string;
1262
+ in: (path: string, value: string | number | (string | number)[]) => string;
1263
+ fulltext: (path: string, value: string | number | (string | number)[]) => string;
1264
+ has: (path: string) => string;
1265
+ missing: (path: string) => string;
1266
+ similar: (id: string, value: number) => string;
1267
+ geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1268
+ numberLessThan: (path: string, value: number) => string;
1269
+ numberGreaterThan: (path: string, value: number) => string;
1270
+ numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1271
+ dateAfter: (path: string, date: string | number | Date) => string;
1272
+ dateBefore: (path: string, date: string | number | Date) => string;
1273
+ dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1274
+ dateDayOfMonth: (path: string, day: number) => string;
1275
+ dateDayOfMonthAfter: (path: string, day: number) => string;
1276
+ dateDayOfMonthBefore: (path: string, day: number) => string;
1277
+ dateDayOfWeek: (path: string, day: string | number) => string;
1278
+ dateDayOfWeekAfter: (path: string, day: string | number) => string;
1279
+ dateDayOfWeekBefore: (path: string, day: string | number) => string;
1280
+ dateMonth: (path: string, month: string | number) => string;
1281
+ dateMonthAfter: (path: string, month: string | number) => string;
1282
+ dateMonthBefore: (path: string, month: string | number) => string;
1283
+ dateYear: (path: string, year: number) => string;
1284
+ dateHour: (path: string, hour: number) => string;
1285
+ dateHourAfter: (path: string, hour: number) => string;
1286
+ dateHourBefore: (path: string, hour: number) => string;
1287
+ };
1288
+
1289
+ export { BuildQueryURLArgs, Client, ClientConfig, FetchLike, ForbiddenError, HttpRequestLike, Ordering, ParsingError, Predicates, PrismicError, QueryParams, RequestInitLike, ResponseLike, Route, buildQueryURL, cookie, createClient, getEndpoint, predicate, predicates };