@prismicio/client 6.0.0-alpha.7 → 6.0.0-beta.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/src/predicate.ts CHANGED
@@ -1,12 +1,18 @@
1
1
  /**
2
- * Formats the value of a predicate element to a stringified version accepted by the Prismic REST API.
2
+ * Formats the value of a predicate element to a stringified version accepted by
3
+ * the Prismic REST API.
3
4
  *
4
- * @params value Value to format.
5
+ * @param value - Value to format.
5
6
  *
6
7
  * @returns `value` formatted for the Prismic REST API.
7
8
  */
8
9
  const formatValue = (
9
- value: string | number | Date | unknown | (string | number | Date | unknown)[]
10
+ value:
11
+ | string
12
+ | number
13
+ | Date
14
+ | unknown
15
+ | (string | number | Date | unknown)[],
10
16
  ): string => {
11
17
  if (Array.isArray(value)) {
12
18
  return `[${value.map(formatValue).join(", ")}]`;
@@ -26,14 +32,14 @@ const formatValue = (
26
32
  /**
27
33
  * Creates a predicate builder function for predicates with a path and arguments.
28
34
  *
29
- * @typeParam Args Arguments for the predicate.
30
- * @params name Name of the predicate used in the resulting string.
35
+ * @typeParam Args - Arguments for the predicate.
36
+ * @param name - Name of the predicate used in the resulting string.
31
37
  *
32
38
  * @returns Predicate builder function for the given name.
33
39
  */
34
40
  const pathWithArgsPredicate = <Args extends unknown[]>(name: string) => {
35
41
  /**
36
- * @param path Path to the value to be compared.
42
+ * @param path - Path to the value to be compared.
37
43
  */
38
44
  const fn = (path: string, ...args: Args): string => {
39
45
  const formattedArgs = args.map(formatValue).join(", ");
@@ -48,7 +54,7 @@ const pathWithArgsPredicate = <Args extends unknown[]>(name: string) => {
48
54
  /**
49
55
  * Creates a predicate builder function for predicates with only a path.
50
56
  *
51
- * @params name Name of the predicate used in the resulting string.
57
+ * @param name - Name of the predicate used in the resulting string.
52
58
  *
53
59
  * @returns Predicate builder function for the given name.
54
60
  */
@@ -56,7 +62,7 @@ const pathPredicate = (name: string) => {
56
62
  const predicateFn = pathWithArgsPredicate(name);
57
63
 
58
64
  /**
59
- * @param path Path for the predicate.
65
+ * @param path - Path for the predicate.
60
66
  */
61
67
  const fn = (path: string): string => {
62
68
  return predicateFn(path);
@@ -68,7 +74,7 @@ const pathPredicate = (name: string) => {
68
74
  /**
69
75
  * Creates a predicate builder function for predicates with only arguments and no path.
70
76
  *
71
- * @params name Name of the predicate used in the resulting string.
77
+ * @param name - Name of the predicate used in the resulting string.
72
78
  *
73
79
  * @returns Predicate builder function for the given name.
74
80
  */
@@ -76,7 +82,7 @@ const argsPredicate = <Args extends unknown[]>(name: string) => {
76
82
  const predicateFn = pathWithArgsPredicate<Args>(name);
77
83
 
78
84
  /**
79
- * @param args Arguments for the predicate.
85
+ * @param args - Arguments for the predicate.
80
86
  */
81
87
  const fn = (...args: Args): string => {
82
88
  return predicateFn("", ...args);
@@ -90,234 +96,261 @@ const argsPredicate = <Args extends unknown[]>(name: string) => {
90
96
  */
91
97
  type DefaultPredicateArgs = [value: string | number | (string | number)[]];
92
98
 
93
- /**
94
- * The `at` predicate checks that the path matches the described value exactly. It takes a single value for a field or an array (only for tags).
95
- *
96
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
97
- */
98
- export const at = pathWithArgsPredicate<DefaultPredicateArgs>("at");
99
-
100
- /**
101
- * The `not` predicate checks that the path doesn't match the provided value exactly. It takes a single value as the argument.
102
- *
103
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
104
- */
105
- export const not = pathWithArgsPredicate<DefaultPredicateArgs>("not");
99
+ export const predicate = {
100
+ /**
101
+ * The `at` predicate checks that the path matches the described value
102
+ * exactly. It takes a single value for a field or an array (only for tags).
103
+ *
104
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
105
+ */
106
+ at: pathWithArgsPredicate<DefaultPredicateArgs>("at"),
106
107
 
107
- /**
108
- * The `any` predicate takes an array of values. It works exactly the same way as the `at` operator, but checks whether the fragment matches any of the values in the array.
109
- *
110
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
111
- */
112
- export const any = pathWithArgsPredicate<DefaultPredicateArgs>("any");
108
+ /**
109
+ * The `not` predicate checks that the path doesn't match the provided value
110
+ * exactly. It takes a single value as the argument.
111
+ *
112
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
113
+ */
114
+ not: pathWithArgsPredicate<DefaultPredicateArgs>("not"),
113
115
 
114
- /**
115
- * The `in` predicate is used specifically to retrieve an array of documents by their IDs or UIDs. This predicate is much more efficient at this than the any predicate.
116
- *
117
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
118
- */
119
- const _in = pathWithArgsPredicate<DefaultPredicateArgs>("in");
116
+ /**
117
+ * The `any` predicate takes an array of values. It works exactly the same way
118
+ * as the `at` operator, but checks whether the fragment matches any of the
119
+ * values in the array.
120
+ *
121
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
122
+ */
123
+ any: pathWithArgsPredicate<DefaultPredicateArgs>("any"),
120
124
 
121
- // Named `_in` since `in` is a keyword.
122
- export { _in as in };
125
+ /**
126
+ * The `in` predicate is used specifically to retrieve an array of documents
127
+ * by their IDs or UIDs. This predicate is much more efficient at this than
128
+ * the any predicate.
129
+ *
130
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
131
+ */
132
+ in: pathWithArgsPredicate<DefaultPredicateArgs>("in"),
123
133
 
124
- /**
125
- * The `fulltext` predicate provides two capabilities:
126
- *
127
- * 1. Checking if a certain string is anywhere inside a document (this is what you should use to make your project's search engine feature)
128
- * 2. Checking if the string is contained inside a specific custom type’s Rich Text or Key Text fragment.
129
- *
130
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
131
- */
132
- export const fulltext = pathWithArgsPredicate<DefaultPredicateArgs>("fulltext");
134
+ /**
135
+ * The `fulltext` predicate provides two capabilities:
136
+ *
137
+ * 1. Checking if a certain string is anywhere inside a document (this is what
138
+ * you should use to make your project's search engine feature)
139
+ * 2. Checking if the string is contained inside a specific custom type’s Rich
140
+ * Text or Key Text fragment.
141
+ *
142
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
143
+ */
144
+ fulltext: pathWithArgsPredicate<DefaultPredicateArgs>("fulltext"),
133
145
 
134
- /**
135
- * The `has` predicate checks whether a fragment has a value. It will return all the documents of the specified type that contain a value for the specified field.
136
- *
137
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}
138
- */
139
- export const has = pathPredicate("has");
146
+ /**
147
+ * The `has` predicate checks whether a fragment has a value. It will return
148
+ * all the documents of the specified type that contain a value for the
149
+ * specified field.
150
+ *
151
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}
152
+ */
153
+ has: pathPredicate("has"),
140
154
 
141
- /**
142
- * The `missing` predicate checks if a fragment doesn't have a value. It will return all the documents of the specified type that do not contain a value for the specified field.
143
- *
144
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}
145
- */
146
- export const missing = pathPredicate("missing");
155
+ /**
156
+ * The `missing` predicate checks if a fragment doesn't have a value. It will
157
+ * return all the documents of the specified type that do not contain a value
158
+ * for the specified field.
159
+ *
160
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}
161
+ */
162
+ missing: pathPredicate("missing"),
147
163
 
148
- /**
149
- * The `similar` predicate takes the ID of a document, and returns a list of documents with similar content. This allows you to build an automated content discovery feature (for example, a "Related posts" section).
150
- *
151
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}
152
- */
153
- export const similar = argsPredicate<[id: string, value: number]>("similar");
164
+ /**
165
+ * The `similar` predicate takes the ID of a document, and returns a list of
166
+ * documents with similar content. This allows you to build an automated
167
+ * content discovery feature (for example, a "Related posts" section).
168
+ *
169
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}
170
+ */
171
+ similar: argsPredicate<[id: string, value: number]>("similar"),
154
172
 
155
- /**
156
- * The `geopoint.near` predicate checks that the value in the path is within the radius of the given coordinates.
157
- *
158
- * This predicate will only work for a GeoPoint field.
159
- *
160
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}
161
- */
162
- export const geopointNear =
163
- pathWithArgsPredicate<[latitude: number, longitude: number, radius: number]>(
164
- "geopoint.near"
165
- );
173
+ /**
174
+ * The `geopoint.near` predicate checks that the value in the path is within
175
+ * the radius of the given coordinates.
176
+ *
177
+ * This predicate will only work for a GeoPoint field.
178
+ *
179
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}
180
+ */
181
+ geopointNear:
182
+ pathWithArgsPredicate<
183
+ [latitude: number, longitude: number, radius: number]
184
+ >("geopoint.near"),
166
185
 
167
- /**
168
- * The `number.lt` predicate checks that the value in the number field is less than the value passed into the predicate.
169
- *
170
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}
171
- */
172
- export const numberLessThan =
173
- pathWithArgsPredicate<[value: number]>("number.lt");
186
+ /**
187
+ * The `number.lt` predicate checks that the value in the number field is less
188
+ * than the value passed into the predicate.
189
+ *
190
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}
191
+ */
192
+ numberLessThan: pathWithArgsPredicate<[value: number]>("number.lt"),
174
193
 
175
- /**
176
- * The `number.gt` predicate checks that the value in the number field is greater than the value passed into the predicate.
177
- *
178
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}
179
- */
180
- export const numberGreaterThan =
181
- pathWithArgsPredicate<[value: number]>("number.gt");
194
+ /**
195
+ * The `number.gt` predicate checks that the value in the number field is
196
+ * greater than the value passed into the predicate.
197
+ *
198
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}
199
+ */
200
+ numberGreaterThan: pathWithArgsPredicate<[value: number]>("number.gt"),
182
201
 
183
- /**
184
- * The `number.inRange` predicate checks that the value in the path is within the two values passed into the predicate.
185
- *
186
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}
187
- */
188
- export const numberInRange =
189
- pathWithArgsPredicate<[lowerLimit: number, upperLimit: number]>(
190
- "number.inRange"
191
- );
202
+ /**
203
+ * The `number.inRange` predicate checks that the value in the path is within
204
+ * the two values passed into the predicate.
205
+ *
206
+ * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}
207
+ */
208
+ numberInRange:
209
+ pathWithArgsPredicate<[lowerLimit: number, upperLimit: number]>(
210
+ "number.inRange",
211
+ ),
192
212
 
193
- /**
194
- * The `date.after` predicate checks that the value in the path is after the date value passed into the predicate.
195
- *
196
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}
197
- */
198
- export const dateAfter =
199
- pathWithArgsPredicate<[date: string | number | Date]>("date.after");
213
+ /**
214
+ * The `date.after` predicate checks that the value in the path is after the
215
+ * date value passed into the predicate.
216
+ *
217
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}
218
+ */
219
+ dateAfter:
220
+ pathWithArgsPredicate<[date: string | number | Date]>("date.after"),
200
221
 
201
- /**
202
- * The `date.before` predicate checks that the value in the path is before the date value passed into the predicate.
203
- *
204
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}
205
- */
206
- export const dateBefore =
207
- pathWithArgsPredicate<[date: string | number | Date]>("date.before");
222
+ /**
223
+ * The `date.before` predicate checks that the value in the path is before the
224
+ * date value passed into the predicate.
225
+ *
226
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}
227
+ */
228
+ dateBefore:
229
+ pathWithArgsPredicate<[date: string | number | Date]>("date.before"),
208
230
 
209
- /**
210
- * The `date.between` predicate checks that the value in the path is within the date values passed into the predicate.
211
- *
212
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}
213
- */
214
- export const dateBetween =
215
- pathWithArgsPredicate<
216
- [startDate: string | number | Date, endDate: string | number | Date]
217
- >("date.between");
231
+ /**
232
+ * The `date.between` predicate checks that the value in the path is within
233
+ * the date values passed into the predicate.
234
+ *
235
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}
236
+ */
237
+ dateBetween:
238
+ pathWithArgsPredicate<
239
+ [startDate: string | number | Date, endDate: string | number | Date]
240
+ >("date.between"),
218
241
 
219
- /**
220
- * The `date.day-of-month` predicate checks that the value in the path is equal to the day of the month passed into the predicate.
221
- *
222
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}
223
- */
224
- export const dateDayOfMonth =
225
- pathWithArgsPredicate<[day: number]>("date.day-of-month");
242
+ /**
243
+ * The `date.day-of-month` predicate checks that the value in the path is
244
+ * equal to the day of the month passed into the predicate.
245
+ *
246
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}
247
+ */
248
+ dateDayOfMonth: pathWithArgsPredicate<[day: number]>("date.day-of-month"),
226
249
 
227
- /**
228
- * The `date.day-of-month-after` predicate checks that the value in the path is after the day of the month passed into the predicate.
229
- *
230
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}
231
- */
232
- export const dateDayOfMonthAfter = pathWithArgsPredicate<[day: number]>(
233
- "date.day-of-month-after"
234
- );
250
+ /**
251
+ * The `date.day-of-month-after` predicate checks that the value in the path
252
+ * is after the day of the month passed into the predicate.
253
+ *
254
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}
255
+ */
256
+ dateDayOfMonthAfter: pathWithArgsPredicate<[day: number]>(
257
+ "date.day-of-month-after",
258
+ ),
235
259
 
236
- /**
237
- * The `date.day-of-month-before` predicate checks that the value in the path is before the day of the month passed into the predicate.
238
- *
239
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}
240
- */
241
- export const dateDayOfMonthBefore = pathWithArgsPredicate<[day: number]>(
242
- "date.day-of-month-before"
243
- );
260
+ /**
261
+ * The `date.day-of-month-before` predicate checks that the value in the path
262
+ * is before the day of the month passed into the predicate.
263
+ *
264
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}
265
+ */
266
+ dateDayOfMonthBefore: pathWithArgsPredicate<[day: number]>(
267
+ "date.day-of-month-before",
268
+ ),
244
269
 
245
- /**
246
- * The `date.day-of-week` predicate checks that the value in the path is equal to the day of the week passed into the predicate.
247
- *
248
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}
249
- */
250
- export const dateDayOfWeek =
251
- pathWithArgsPredicate<[day: string | number]>("date.day-of-week");
270
+ /**
271
+ * The `date.day-of-week` predicate checks that the value in the path is equal
272
+ * to the day of the week passed into the predicate.
273
+ *
274
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}
275
+ */
276
+ dateDayOfWeek:
277
+ pathWithArgsPredicate<[day: string | number]>("date.day-of-week"),
252
278
 
253
- /**
254
- * The `date.day-of-week-after` predicate checks that the value in the path is after the day of the week passed into the predicate.
255
- *
256
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}
257
- */
258
- export const dateDayOfWeekAfter = pathWithArgsPredicate<[day: string | number]>(
259
- "date.day-of-week-after"
260
- );
279
+ /**
280
+ * The `date.day-of-week-after` predicate checks that the value in the path is
281
+ * after the day of the week passed into the predicate.
282
+ *
283
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}
284
+ */
285
+ dateDayOfWeekAfter: pathWithArgsPredicate<[day: string | number]>(
286
+ "date.day-of-week-after",
287
+ ),
261
288
 
262
- /**
263
- * The date.day-of-week-before predicate checks that the value in the path is before the day of the week passed into the predicate.
264
- *
265
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}
266
- */
267
- export const dateDayOfWeekBefore = pathWithArgsPredicate<
268
- [day: string | number]
269
- >("date.day-of-week-before");
289
+ /**
290
+ * The date.day-of-week-before predicate checks that the value in the path is
291
+ * before the day of the week passed into the predicate.
292
+ *
293
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}
294
+ */
295
+ dateDayOfWeekBefore: pathWithArgsPredicate<[day: string | number]>(
296
+ "date.day-of-week-before",
297
+ ),
270
298
 
271
- /**
272
- * The `date.month` predicate checks that the value in the path occurs in the month value passed into the predicate.
273
- *
274
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}
275
- */
276
- export const dateMonth =
277
- pathWithArgsPredicate<[month: string | number]>("date.month");
299
+ /**
300
+ * The `date.month` predicate checks that the value in the path occurs in the
301
+ * month value passed into the predicate.
302
+ *
303
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}
304
+ */
305
+ dateMonth: pathWithArgsPredicate<[month: string | number]>("date.month"),
278
306
 
279
- /**
280
- * The `date.month-after` predicate checks that the value in the path occurs in any month after the value passed into the predicate.
281
- *
282
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}
283
- */
284
- export const dateMonthAfter =
285
- pathWithArgsPredicate<[month: string | number]>("date.month-after");
307
+ /**
308
+ * The `date.month-after` predicate checks that the value in the path occurs
309
+ * in any month after the value passed into the predicate.
310
+ *
311
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}
312
+ */
313
+ dateMonthAfter:
314
+ pathWithArgsPredicate<[month: string | number]>("date.month-after"),
286
315
 
287
- /**
288
- * The `date.month-before` predicate checks that the value in the path occurs in any month before the value passed into the predicate.
289
- *
290
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}
291
- */
292
- export const dateMonthBefore =
293
- pathWithArgsPredicate<[month: string | number]>("date.month-before");
316
+ /**
317
+ * The `date.month-before` predicate checks that the value in the path occurs
318
+ * in any month before the value passed into the predicate.
319
+ *
320
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}
321
+ */
322
+ dateMonthBefore:
323
+ pathWithArgsPredicate<[month: string | number]>("date.month-before"),
294
324
 
295
- /**
296
- * The `date.year` predicate checks that the value in the path occurs in the year value passed into the predicate.
297
- *
298
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}
299
- */
300
- export const dateYear = pathWithArgsPredicate<[year: number]>("date.year");
325
+ /**
326
+ * The `date.year` predicate checks that the value in the path occurs in the
327
+ * year value passed into the predicate.
328
+ *
329
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}
330
+ */
331
+ dateYear: pathWithArgsPredicate<[year: number]>("date.year"),
301
332
 
302
- /**
303
- * The `date.hour` predicate checks that the value in the path occurs within the hour value passed into the predicate.
304
- *
305
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}
306
- */
307
- export const dateHour = pathWithArgsPredicate<[hour: number]>("date.hour");
333
+ /**
334
+ * The `date.hour` predicate checks that the value in the path occurs within
335
+ * the hour value passed into the predicate.
336
+ *
337
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}
338
+ */
339
+ dateHour: pathWithArgsPredicate<[hour: number]>("date.hour"),
308
340
 
309
- /**
310
- * The `date.hour-after` predicate checks that the value in the path occurs after the hour value passed into the predicate.
311
- *
312
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}
313
- */
314
- export const dateHourAfter =
315
- pathWithArgsPredicate<[hour: number]>("date.hour-after");
341
+ /**
342
+ * The `date.hour-after` predicate checks that the value in the path occurs
343
+ * after the hour value passed into the predicate.
344
+ *
345
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}
346
+ */
347
+ dateHourAfter: pathWithArgsPredicate<[hour: number]>("date.hour-after"),
316
348
 
317
- /**
318
- * The `date.hour-before` predicate checks that the value in the path occurs before the hour value passed into the predicate.
319
- *
320
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}
321
- */
322
- export const dateHourBefore =
323
- pathWithArgsPredicate<[hour: number]>("date.hour-before");
349
+ /**
350
+ * The `date.hour-before` predicate checks that the value in the path occurs
351
+ * before the hour value passed into the predicate.
352
+ *
353
+ * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}
354
+ */
355
+ dateHourBefore: pathWithArgsPredicate<[hour: number]>("date.hour-before"),
356
+ };
package/src/types.ts CHANGED
@@ -1,71 +1,9 @@
1
- import * as prismicT from "@prismicio/types";
2
-
3
- export interface Ref {
4
- ref: string;
5
- label: string;
6
- isMasterRef: boolean;
7
- scheduledAt?: string;
8
- id: string;
9
- }
10
-
11
- export type Release = Ref;
12
-
13
- export interface Language {
14
- id: string;
15
- name: string;
16
- }
17
-
18
- export interface Repository {
19
- refs: Ref[];
20
- bookmarks: Record<string, string>;
21
- languages: Language[];
22
- types: Record<string, string>;
23
- tags: string[];
24
- forms: Record<string, Form>;
25
- /**
26
- * @deprecated
27
- */
28
- experiments: unknown;
29
- oauth_initiate: string;
30
- oauth_token: string;
31
- version: string;
32
- license: string;
33
- }
34
-
35
- export interface Query<
36
- TDocument extends prismicT.PrismicDocument = prismicT.PrismicDocument
37
- > {
38
- page: number;
39
- results_per_page: number;
40
- results_size: number;
41
- total_results_size: number;
42
- total_pages: number;
43
- next_page: string | null;
44
- prev_page: string | null;
45
- results: TDocument[];
46
- }
47
-
48
- export interface Form {
49
- method: "GET";
50
- enctype: string;
51
- action: string;
52
- name?: string;
53
- rel?: string;
54
- fields: Record<string, FormField>;
55
- }
56
-
57
- export interface FormField {
58
- type: "String" | "Integer";
59
- multiple: boolean;
60
- default?: string;
61
- }
62
-
63
1
  /**
64
2
  * A universal API to make network requests. A subset of the `fetch()` API.
65
3
  */
66
4
  export type FetchLike = (
67
5
  input: string,
68
- init?: RequestInitLike
6
+ init?: RequestInitLike,
69
7
  ) => Promise<ResponseLike>;
70
8
 
71
9
  /**
@@ -85,7 +23,8 @@ export interface ResponseLike {
85
23
  }
86
24
 
87
25
  /**
88
- * The minimum required properties to treat as an HTTP Request for automatic Prismic preview support.
26
+ * The minimum required properties to treat as an HTTP Request for automatic
27
+ * Prismic preview support.
89
28
  */
90
29
  export interface HttpRequestLike {
91
30
  headers?: {
@@ -110,10 +49,16 @@ export interface Ordering {
110
49
  * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
111
50
  */
112
51
  export interface Route {
113
- /** The Custom Type of the document. */
52
+ /**
53
+ * The Custom Type of the document.
54
+ */
114
55
  type: string;
115
- /** The resolved path of the document with optional placeholders. */
56
+ /**
57
+ * The resolved path of the document with optional placeholders.
58
+ */
116
59
  path: string;
117
- /** An object that lists the API IDs of the Content Relationships in the route. */
118
- resolvers: Record<string, string>;
60
+ /**
61
+ * An object that lists the API IDs of the Content Relationships in the route.
62
+ */
63
+ resolvers?: Record<string, string>;
119
64
  }