@prismicio/vue 3.0.0-alpha.4 → 3.0.0-alpha.5

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.
@@ -54,25 +54,6 @@ export const useFirstPrismicDocument = <TDocument extends PrismicDocument>(
54
54
  ): ClientComposableReturnType<TDocument> =>
55
55
  useStatefulPrismicClientMethod("getFirst", args);
56
56
 
57
- /**
58
- * A composable that queries content from the Prismic repository and returns all
59
- * matching content. If no predicates are provided, all documents will be fetched.
60
- *
61
- * @remarks
62
- * An additional `@prismicio/client` instance can be provided at `params.client`.
63
- * @typeParam TDocument - Type of Prismic documents returned
64
- * @param params - Parameters to filter and sort results
65
- *
66
- * @returns The composable payload {@link ClientComposableReturnType}
67
- * @see Underlying `@prismicio/client` method {@link Client.getAll}
68
- */
69
- export const useAllPrismicDocuments = <TDocument extends PrismicDocument>(
70
- ...args: [
71
- params?: ClientMethodParameters<"getAll">[0] & ComposableOnlyParameters,
72
- ]
73
- ): ClientComposableReturnType<TDocument[]> =>
74
- useStatefulPrismicClientMethod("getAll", args);
75
-
76
57
  /**
77
58
  * A composable that queries a document from the Prismic repository with a specific ID.
78
59
  *
@@ -157,6 +138,51 @@ export const usePrismicDocumentByUID = <TDocument extends PrismicDocument>(
157
138
  ): ClientComposableReturnType<TDocument> =>
158
139
  useStatefulPrismicClientMethod("getByUID", args);
159
140
 
141
+ /**
142
+ * A composable that queries documents from the Prismic repository with specific UIDs.
143
+ *
144
+ * @remarks
145
+ * An additional `@prismicio/client` instance can be provided at `params.client`.
146
+ * @typeParam TDocument - Type of Prismic documents returned
147
+ * @param documentType - The API ID of the document's Custom Type
148
+ * @param uids - A list of document UIDs
149
+ * @param params - Parameters to filter, sort, and paginate results
150
+ *
151
+ * @returns The composable payload {@link ClientComposableReturnType}
152
+ * @see Underlying `@prismicio/client` method {@link Client.getByIDs}
153
+ */
154
+ export const usePrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
155
+ ...args: [
156
+ documentType: ClientMethodParameters<"getByUIDs">[0],
157
+ uids: ClientMethodParameters<"getByUIDs">[1],
158
+ params?: ClientMethodParameters<"getByUIDs">[2] & ComposableOnlyParameters,
159
+ ]
160
+ ): ClientComposableReturnType<Query<TDocument>> =>
161
+ useStatefulPrismicClientMethod("getByUIDs", args);
162
+
163
+ /**
164
+ * A composable that queries all documents from the Prismic repository with specific UIDs.
165
+ *
166
+ * @remarks
167
+ * An additional `@prismicio/client` instance can be provided at `params.client`.
168
+ * @typeParam TDocument - Type of Prismic documents returned
169
+ * @param documentType - The API ID of the document's Custom Type
170
+ * @param uids - A list of document UIDs
171
+ * @param params - Parameters to filter and sort results
172
+ *
173
+ * @returns The composable payload {@link ClientComposableReturnType}
174
+ * @see Underlying `@prismicio/client` method {@link Client.getAllByIDs}
175
+ */
176
+ export const useAllPrismicDocumentsByUIDs = <TDocument extends PrismicDocument>(
177
+ ...args: [
178
+ documentType: ClientMethodParameters<"getAllByUIDs">[0],
179
+ ids: ClientMethodParameters<"getAllByUIDs">[1],
180
+ params?: ClientMethodParameters<"getAllByUIDs">[2] &
181
+ ComposableOnlyParameters,
182
+ ]
183
+ ): ClientComposableReturnType<TDocument[]> =>
184
+ useStatefulPrismicClientMethod("getAllByUIDs", args);
185
+
160
186
  /**
161
187
  * A composable that queries a singleton document from the Prismic repository
162
188
  * for a specific Custom Type.
@@ -264,7 +290,56 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
264
290
  useStatefulPrismicClientMethod("getAllByTag", args);
265
291
 
266
292
  /**
267
- * A composable that queries documents from the Prismic repository with specific tags.
293
+ * A composable that queries documents from the Prismic repository with specific
294
+ * tags. A document must be tagged with all of the queried tags to be included.
295
+ *
296
+ * @remarks
297
+ * An additional `@prismicio/client` instance can be provided at `params.client`.
298
+ * @typeParam TDocument - Type of Prismic documents returned
299
+ * @param tags - A list of tags that must be included on a document
300
+ * @param params - Parameters to filter, sort, and paginate results
301
+ *
302
+ * @returns The composable payload {@link ClientComposableReturnType}
303
+ * @see Underlying `@prismicio/client` method {@link Client.getByTags}
304
+ */
305
+ export const usePrismicDocumentsByEveryTag = <
306
+ TDocument extends PrismicDocument,
307
+ >(
308
+ ...args: [
309
+ tags: ClientMethodParameters<"getByEveryTag">[0],
310
+ params?: ClientMethodParameters<"getByEveryTag">[1] &
311
+ ComposableOnlyParameters,
312
+ ]
313
+ ): ClientComposableReturnType<Query<TDocument>> =>
314
+ useStatefulPrismicClientMethod("getByEveryTag", args);
315
+
316
+ /**
317
+ * A composable that queries all documents from the Prismic repository with
318
+ * specific tags. A document must be tagged with all of the queried tags to be included.
319
+ *
320
+ * @remarks
321
+ * An additional `@prismicio/client` instance can be provided at `params.client`.
322
+ * @typeParam TDocument - Type of Prismic documents returned
323
+ * @param tags - A list of tags that must be included on a document
324
+ * @param params - Parameters to filter and sort results
325
+ *
326
+ * @returns The composable payload {@link ClientComposableReturnType}
327
+ * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
328
+ */
329
+ export const useAllPrismicDocumentsByEveryTag = <
330
+ TDocument extends PrismicDocument,
331
+ >(
332
+ ...args: [
333
+ tags: ClientMethodParameters<"getAllByEveryTag">[0],
334
+ params?: ClientMethodParameters<"getAllByEveryTag">[1] &
335
+ ComposableOnlyParameters,
336
+ ]
337
+ ): ClientComposableReturnType<TDocument[]> =>
338
+ useStatefulPrismicClientMethod("getAllByEveryTag", args);
339
+
340
+ /**
341
+ * A composable that queries documents from the Prismic repository with specific
342
+ * tags. A document must be tagged with at least one of the queried tags to be included.
268
343
  *
269
344
  * @remarks
270
345
  * An additional `@prismicio/client` instance can be provided at `params.client`.
@@ -275,16 +350,21 @@ export const useAllPrismicDocumentsByTag = <TDocument extends PrismicDocument>(
275
350
  * @returns The composable payload {@link ClientComposableReturnType}
276
351
  * @see Underlying `@prismicio/client` method {@link Client.getByTags}
277
352
  */
278
- export const usePrismicDocumentsByTags = <TDocument extends PrismicDocument>(
353
+ export const usePrismicDocumentsBySomeTags = <
354
+ TDocument extends PrismicDocument,
355
+ >(
279
356
  ...args: [
280
- tags: ClientMethodParameters<"getByTags">[0],
281
- params?: ClientMethodParameters<"getByTags">[1] & ComposableOnlyParameters,
357
+ tags: ClientMethodParameters<"getBySomeTags">[0],
358
+ params?: ClientMethodParameters<"getBySomeTags">[1] &
359
+ ComposableOnlyParameters,
282
360
  ]
283
361
  ): ClientComposableReturnType<Query<TDocument>> =>
284
- useStatefulPrismicClientMethod("getByTags", args);
362
+ useStatefulPrismicClientMethod("getBySomeTags", args);
285
363
 
286
364
  /**
287
- * A composable that queries all documents from the Prismic repository with specific tags.
365
+ * A composable that queries all documents from the Prismic repository with
366
+ * specific tags. A document must be tagged with at least one of the queried
367
+ * tags to be included.
288
368
  *
289
369
  * @remarks
290
370
  * An additional `@prismicio/client` instance can be provided at `params.client`.
@@ -295,11 +375,39 @@ export const usePrismicDocumentsByTags = <TDocument extends PrismicDocument>(
295
375
  * @returns The composable payload {@link ClientComposableReturnType}
296
376
  * @see Underlying `@prismicio/client` method {@link Client.getAllByTags}
297
377
  */
298
- export const useAllPrismicDocumentsByTags = <TDocument extends PrismicDocument>(
378
+ export const useAllPrismicDocumentsBySomeTags = <
379
+ TDocument extends PrismicDocument,
380
+ >(
381
+ ...args: [
382
+ tags: ClientMethodParameters<"getAllBySomeTags">[0],
383
+ params?: ClientMethodParameters<"getAllBySomeTags">[1] &
384
+ ComposableOnlyParameters,
385
+ ]
386
+ ): ClientComposableReturnType<TDocument[]> =>
387
+ useStatefulPrismicClientMethod("getAllBySomeTags", args);
388
+
389
+ /**
390
+ * **IMPORTANT**: Avoid using `dangerouslyUseAllPrismicDocuments` as it may be
391
+ * slower and require more resources than other composables. Prefer using other
392
+ * composables that filter by predicates such as `useAllPrismicDocumentsByType`.
393
+ *
394
+ * A composable that queries content from the Prismic repository and returns all
395
+ * matching content. If no predicates are provided, all documents will be fetched.
396
+ *
397
+ * @remarks
398
+ * An additional `@prismicio/client` instance can be provided at `params.client`.
399
+ * @typeParam TDocument - Type of Prismic documents returned
400
+ * @param params - Parameters to filter and sort results
401
+ *
402
+ * @returns The composable payload {@link ClientComposableReturnType}
403
+ * @see Underlying `@prismicio/client` method {@link Client.getAll}
404
+ */
405
+ export const dangerouslyUseAllPrismicDocuments = <
406
+ TDocument extends PrismicDocument,
407
+ >(
299
408
  ...args: [
300
- tags: ClientMethodParameters<"getAllByTags">[0],
301
- params?: ClientMethodParameters<"getAllByTags">[1] &
409
+ params?: ClientMethodParameters<"dangerouslyGetAll">[0] &
302
410
  ComposableOnlyParameters,
303
411
  ]
304
412
  ): ClientComposableReturnType<TDocument[]> =>
305
- useStatefulPrismicClientMethod("getAllByTags", args);
413
+ useStatefulPrismicClientMethod("dangerouslyGetAll", args);
package/src/index.ts CHANGED
@@ -41,20 +41,24 @@ export type {
41
41
  } from "./components";
42
42
 
43
43
  export {
44
- useAllPrismicDocuments,
45
44
  useAllPrismicDocumentsByIDs,
45
+ useAllPrismicDocumentsByUIDs,
46
46
  useAllPrismicDocumentsByTag,
47
- useAllPrismicDocumentsByTags,
47
+ useAllPrismicDocumentsByEveryTag,
48
+ useAllPrismicDocumentsBySomeTags,
48
49
  useAllPrismicDocumentsByType,
49
50
  useFirstPrismicDocument,
50
51
  usePrismicDocumentByID,
51
52
  usePrismicDocumentByUID,
52
53
  usePrismicDocuments,
53
54
  usePrismicDocumentsByIDs,
55
+ usePrismicDocumentsByUIDs,
54
56
  usePrismicDocumentsByTag,
55
- usePrismicDocumentsByTags,
57
+ usePrismicDocumentsByEveryTag,
58
+ usePrismicDocumentsBySomeTags,
56
59
  usePrismicDocumentsByType,
57
60
  useSinglePrismicDocument,
61
+ dangerouslyUseAllPrismicDocuments,
58
62
  } from "./composables";
59
63
 
60
64
  export type { ClientComposableReturnType } from "./useStatefulPrismicClientMethod";
@@ -15,7 +15,7 @@ type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  type ClientMethodLike = (...args: any[]) => Promise<any> | any;
17
17
  type ClientMethods = typeof Client.prototype;
18
- type ClientError = PrismicError | ParsingError | ForbiddenError;
18
+ type ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;
19
19
 
20
20
  // Interfaces
21
21