@prismicio/client 6.4.1-alpha.1 → 6.4.3

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/client.ts CHANGED
@@ -218,7 +218,7 @@ const typePredicate = (documentType: string): string =>
218
218
  * Creates a predicate to filter content by document tags. All tags are required
219
219
  * on the document.
220
220
  *
221
- * @param documentType - Document tags to filter queried content.
221
+ * @param tags - Document tags to filter queried content.
222
222
  *
223
223
  * @returns A predicate that can be used in a Prismic REST API V2 request.
224
224
  */
@@ -229,7 +229,7 @@ const everyTagPredicate = (tags: string | string[]): string =>
229
229
  * Creates a predicate to filter content by document tags. At least one matching
230
230
  * tag is required on the document.
231
231
  *
232
- * @param documentType - Document tags to filter queried content.
232
+ * @param tags - Document tags to filter queried content.
233
233
  *
234
234
  * @returns A predicate that can be used in a Prismic REST API V2 request.
235
235
  */
@@ -547,8 +547,10 @@ export class Client {
547
547
  const { limit = Infinity, ...actualParams } = params;
548
548
  const resolvedParams = {
549
549
  ...actualParams,
550
- pageSize:
550
+ pageSize: Math.min(
551
+ limit,
551
552
  actualParams.pageSize || this.defaultParams?.pageSize || MAX_PAGE_SIZE,
553
+ ),
552
554
  };
553
555
 
554
556
  const documents: TDocument[] = [];
@@ -658,7 +660,7 @@ export class Client {
658
660
  */
659
661
  async getAllByIDs<TDocument extends prismicT.PrismicDocument>(
660
662
  ids: string[],
661
- params?: Partial<BuildQueryURLArgs> & FetchParams,
663
+ params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams,
662
664
  ): Promise<TDocument[]> {
663
665
  return await this.dangerouslyGetAll<TDocument>(
664
666
  appendPredicates(params, predicate.in("document.id", ids)),
@@ -764,7 +766,7 @@ export class Client {
764
766
  async getAllByUIDs<TDocument extends prismicT.PrismicDocument>(
765
767
  documentType: string,
766
768
  uids: string[],
767
- params?: Partial<BuildQueryURLArgs> & FetchParams,
769
+ params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams,
768
770
  ): Promise<TDocument[]> {
769
771
  return await this.dangerouslyGetAll<TDocument>(
770
772
  appendPredicates(params, [
@@ -849,7 +851,9 @@ export class Client {
849
851
  */
850
852
  async getAllByType<TDocument extends prismicT.PrismicDocument>(
851
853
  documentType: string,
852
- params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams,
854
+ params?: Partial<Omit<BuildQueryURLArgs, "page">> &
855
+ GetAllParams &
856
+ FetchParams,
853
857
  ): Promise<TDocument[]> {
854
858
  return await this.dangerouslyGetAll<TDocument>(
855
859
  appendPredicates(params, typePredicate(documentType)),
@@ -901,7 +905,9 @@ export class Client {
901
905
  */
902
906
  async getAllByTag<TDocument extends prismicT.PrismicDocument>(
903
907
  tag: string,
904
- params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams,
908
+ params?: Partial<Omit<BuildQueryURLArgs, "page">> &
909
+ GetAllParams &
910
+ FetchParams,
905
911
  ): Promise<TDocument[]> {
906
912
  return await this.dangerouslyGetAll<TDocument>(
907
913
  appendPredicates(params, someTagsPredicate(tag)),
@@ -953,7 +959,9 @@ export class Client {
953
959
  */
954
960
  async getAllByEveryTag<TDocument extends prismicT.PrismicDocument>(
955
961
  tags: string[],
956
- params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams,
962
+ params?: Partial<Omit<BuildQueryURLArgs, "page">> &
963
+ GetAllParams &
964
+ FetchParams,
957
965
  ): Promise<TDocument[]> {
958
966
  return await this.dangerouslyGetAll<TDocument>(
959
967
  appendPredicates(params, everyTagPredicate(tags)),
@@ -1005,7 +1013,9 @@ export class Client {
1005
1013
  */
1006
1014
  async getAllBySomeTags<TDocument extends prismicT.PrismicDocument>(
1007
1015
  tags: string[],
1008
- params?: Partial<Omit<BuildQueryURLArgs, "page">> & FetchParams,
1016
+ params?: Partial<Omit<BuildQueryURLArgs, "page">> &
1017
+ GetAllParams &
1018
+ FetchParams,
1009
1019
  ): Promise<TDocument[]> {
1010
1020
  return await this.dangerouslyGetAll<TDocument>(
1011
1021
  appendPredicates(params, someTagsPredicate(tags)),
@@ -1258,7 +1268,7 @@ export class Client {
1258
1268
  * const document = await client.getByID("WW4bKScAAMAqmluX");
1259
1269
  * ```
1260
1270
  *
1261
- * @param id - The ID of the Release.
1271
+ * @param releaseID - The ID of the Release.
1262
1272
  */
1263
1273
  queryContentFromReleaseByID(releaseID: string): void {
1264
1274
  this.refState = {
@@ -1281,7 +1291,7 @@ export class Client {
1281
1291
  * const document = await client.getByID("WW4bKScAAMAqmluX");
1282
1292
  * ```
1283
1293
  *
1284
- * @param label - The label of the Release.
1294
+ * @param releaseLabel - The label of the Release.
1285
1295
  */
1286
1296
  queryContentFromReleaseByLabel(releaseLabel: string): void {
1287
1297
  this.refState = {
package/src/predicate.ts CHANGED
@@ -91,11 +91,6 @@ const argsPredicate = <Args extends unknown[]>(name: string) => {
91
91
  return fn;
92
92
  };
93
93
 
94
- /**
95
- * The default arguments allowed by predicates.
96
- */
97
- type DefaultPredicateArgs = [value: string | number | (string | number)[]];
98
-
99
94
  export const predicate = {
100
95
  /**
101
96
  * The `at` predicate checks that the path matches the described value
@@ -103,7 +98,9 @@ export const predicate = {
103
98
  *
104
99
  * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
105
100
  */
106
- at: pathWithArgsPredicate<DefaultPredicateArgs>("at"),
101
+ at: pathWithArgsPredicate<
102
+ [value: string | number | boolean | Date | string[]]
103
+ >("at"),
107
104
 
108
105
  /**
109
106
  * The `not` predicate checks that the path doesn't match the provided value
@@ -111,7 +108,7 @@ export const predicate = {
111
108
  *
112
109
  * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
113
110
  */
114
- not: pathWithArgsPredicate<DefaultPredicateArgs>("not"),
111
+ not: pathWithArgsPredicate<[value: string | number | boolean | Date]>("not"),
115
112
 
116
113
  /**
117
114
  * The `any` predicate takes an array of values. It works exactly the same way
@@ -120,7 +117,9 @@ export const predicate = {
120
117
  *
121
118
  * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
122
119
  */
123
- any: pathWithArgsPredicate<DefaultPredicateArgs>("any"),
120
+ any: pathWithArgsPredicate<[values: (string | number | boolean | Date)[]]>(
121
+ "any",
122
+ ),
124
123
 
125
124
  /**
126
125
  * The `in` predicate is used specifically to retrieve an array of documents
@@ -129,7 +128,7 @@ export const predicate = {
129
128
  *
130
129
  * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
131
130
  */
132
- in: pathWithArgsPredicate<DefaultPredicateArgs>("in"),
131
+ in: pathWithArgsPredicate<[values: string[]]>("in"),
133
132
 
134
133
  /**
135
134
  * The `fulltext` predicate provides two capabilities:
@@ -141,7 +140,7 @@ export const predicate = {
141
140
  *
142
141
  * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
143
142
  */
144
- fulltext: pathWithArgsPredicate<DefaultPredicateArgs>("fulltext"),
143
+ fulltext: pathWithArgsPredicate<[searchTerms: string]>("fulltext"),
145
144
 
146
145
  /**
147
146
  * The `has` predicate checks whether a fragment has a value. It will return