@prismicio/client 6.6.0 → 6.6.2
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.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +19 -14
- package/src/types.ts +0 -4
package/src/client.ts
CHANGED
|
@@ -392,7 +392,7 @@ export class Client<
|
|
|
392
392
|
if (typeof options.fetch === "function") {
|
|
393
393
|
this.fetchFn = options.fetch;
|
|
394
394
|
} else if (typeof globalThis.fetch === "function") {
|
|
395
|
-
this.fetchFn = globalThis.fetch;
|
|
395
|
+
this.fetchFn = globalThis.fetch as FetchLike;
|
|
396
396
|
} else {
|
|
397
397
|
throw new PrismicError(
|
|
398
398
|
"A valid fetch implementation was not provided. In environments where fetch is not available (including Node.js), a fetch implementation must be provided via a polyfill or the `fetch` option.",
|
|
@@ -531,7 +531,12 @@ export class Client<
|
|
|
531
531
|
async getFirst<TDocument extends TDocuments>(
|
|
532
532
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
533
533
|
): Promise<TDocument> {
|
|
534
|
-
const url = await this.buildQueryURL(
|
|
534
|
+
const url = await this.buildQueryURL({
|
|
535
|
+
pageSize:
|
|
536
|
+
this.defaultParams?.pageSize ||
|
|
537
|
+
(params && "page" in params ? undefined : 1),
|
|
538
|
+
...params,
|
|
539
|
+
});
|
|
535
540
|
const result = await this.fetch<prismicT.Query<TDocument>>(url, params);
|
|
536
541
|
|
|
537
542
|
const firstResult = result.results[0];
|
|
@@ -720,8 +725,8 @@ export class Client<
|
|
|
720
725
|
documentType: TDocumentType,
|
|
721
726
|
uid: string,
|
|
722
727
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
723
|
-
): Promise<ExtractDocumentType<
|
|
724
|
-
return await this.getFirst<ExtractDocumentType<
|
|
728
|
+
): Promise<ExtractDocumentType<TDocument, TDocumentType>> {
|
|
729
|
+
return await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(
|
|
725
730
|
appendPredicates(params, [
|
|
726
731
|
typePredicate(documentType),
|
|
727
732
|
predicate.at(`my.${documentType}.uid`, uid),
|
|
@@ -760,8 +765,8 @@ export class Client<
|
|
|
760
765
|
documentType: TDocumentType,
|
|
761
766
|
uids: string[],
|
|
762
767
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
763
|
-
): Promise<prismicT.Query<ExtractDocumentType<
|
|
764
|
-
return await this.get<ExtractDocumentType<
|
|
768
|
+
): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>> {
|
|
769
|
+
return await this.get<ExtractDocumentType<TDocument, TDocumentType>>(
|
|
765
770
|
appendPredicates(params, [
|
|
766
771
|
typePredicate(documentType),
|
|
767
772
|
predicate.in(`my.${documentType}.uid`, uids),
|
|
@@ -801,9 +806,9 @@ export class Client<
|
|
|
801
806
|
documentType: TDocumentType,
|
|
802
807
|
uids: string[],
|
|
803
808
|
params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams,
|
|
804
|
-
): Promise<ExtractDocumentType<
|
|
809
|
+
): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {
|
|
805
810
|
return await this.dangerouslyGetAll<
|
|
806
|
-
ExtractDocumentType<
|
|
811
|
+
ExtractDocumentType<TDocument, TDocumentType>
|
|
807
812
|
>(
|
|
808
813
|
appendPredicates(params, [
|
|
809
814
|
typePredicate(documentType),
|
|
@@ -838,8 +843,8 @@ export class Client<
|
|
|
838
843
|
>(
|
|
839
844
|
documentType: TDocumentType,
|
|
840
845
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
841
|
-
): Promise<ExtractDocumentType<
|
|
842
|
-
return await this.getFirst<ExtractDocumentType<
|
|
846
|
+
): Promise<ExtractDocumentType<TDocument, TDocumentType>> {
|
|
847
|
+
return await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(
|
|
843
848
|
appendPredicates(params, typePredicate(documentType)),
|
|
844
849
|
);
|
|
845
850
|
}
|
|
@@ -868,8 +873,8 @@ export class Client<
|
|
|
868
873
|
>(
|
|
869
874
|
documentType: TDocumentType,
|
|
870
875
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
871
|
-
): Promise<prismicT.Query<ExtractDocumentType<
|
|
872
|
-
return await this.get<ExtractDocumentType<
|
|
876
|
+
): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>> {
|
|
877
|
+
return await this.get<ExtractDocumentType<TDocument, TDocumentType>>(
|
|
873
878
|
appendPredicates(params, typePredicate(documentType)),
|
|
874
879
|
);
|
|
875
880
|
}
|
|
@@ -899,9 +904,9 @@ export class Client<
|
|
|
899
904
|
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
900
905
|
GetAllParams &
|
|
901
906
|
FetchParams,
|
|
902
|
-
): Promise<ExtractDocumentType<
|
|
907
|
+
): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {
|
|
903
908
|
return await this.dangerouslyGetAll<
|
|
904
|
-
ExtractDocumentType<
|
|
909
|
+
ExtractDocumentType<TDocument, TDocumentType>
|
|
905
910
|
>(appendPredicates(params, typePredicate(documentType)));
|
|
906
911
|
}
|
|
907
912
|
|
package/src/types.ts
CHANGED
|
@@ -79,10 +79,6 @@ export type AbortSignalLike = {
|
|
|
79
79
|
dispatchEvent: any;
|
|
80
80
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
81
|
onabort: any;
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
-
reason: any;
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
-
throwIfAborted: any;
|
|
86
82
|
};
|
|
87
83
|
|
|
88
84
|
/**
|