@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/README.md +38 -34
- package/dist/index.cjs +219 -280
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +663 -566
- package/dist/index.mjs +480 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -37
- package/src/ForbiddenError.ts +9 -31
- package/src/ParsingError.ts +4 -34
- package/src/PrismicError.ts +11 -12
- package/src/buildQueryURL.ts +29 -16
- package/src/client.ts +687 -543
- package/src/getEndpoint.ts +3 -3
- package/src/index.ts +2 -8
- package/src/lib/appendPredicates.ts +19 -16
- package/src/lib/castArray.ts +5 -3
- package/src/lib/castThunk.ts +11 -0
- package/src/lib/findMasterRef.ts +15 -0
- package/src/lib/findRef.ts +27 -0
- package/src/lib/findRefByID.ts +16 -0
- package/src/lib/findRefByLabel.ts +19 -0
- package/src/lib/getCookie.ts +20 -7
- package/src/lib/orElseThrow.ts +4 -5
- package/src/predicate.ts +247 -214
- package/src/types.ts +13 -68
- package/dist/index.es.js +0 -539
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
|
|
2
|
+
* Formats the value of a predicate element to a stringified version accepted by
|
|
3
|
+
* the Prismic REST API.
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
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:
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
[day: string | number]
|
|
269
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
|
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
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* The Custom Type of the document.
|
|
54
|
+
*/
|
|
114
55
|
type: string;
|
|
115
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The resolved path of the document with optional placeholders.
|
|
58
|
+
*/
|
|
116
59
|
path: string;
|
|
117
|
-
/**
|
|
118
|
-
|
|
60
|
+
/**
|
|
61
|
+
* An object that lists the API IDs of the Content Relationships in the route.
|
|
62
|
+
*/
|
|
63
|
+
resolvers?: Record<string, string>;
|
|
119
64
|
}
|