New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@prismicio/client

Package Overview
Dependencies
Maintainers
19
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/client - npm Package Compare versions

Comparing version 6.0.0-beta.2 to 6.0.0-beta.3

15

dist/index.d.ts

@@ -432,2 +432,6 @@ import * as prismicT from '@prismicio/types';

/**
* **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
* require more resources than other methods. Prefer using other methods that
* filter by predicates such as `getAllByType`.
*
* Queries content from the Prismic repository and returns all matching

@@ -441,10 +445,11 @@ * content. If no predicates are provided, all documents will be fetched.

* ```ts
* const response = await client.getAll();
* const response = await client.dangerouslyGetAll();
* ```
*
* @typeParam TDocument - Type of Prismic documents returned. @param params -
* Parameters to filter, sort, and paginate results. @returns A list of
* documents matching the query.
* @typeParam TDocument - Type of Prismic documents returned.
* @param params - Parameters to filter, sort, and paginate results.
*
* @returns A list of documents matching the query.
*/
getAll<TDocument extends prismicT.PrismicDocument>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams): Promise<TDocument[]>;
dangerouslyGetAll<TDocument extends prismicT.PrismicDocument>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams): Promise<TDocument[]>;
/**

@@ -451,0 +456,0 @@ * Queries a document from the Prismic repository with a specific ID.

{
"name": "@prismicio/client",
"version": "6.0.0-beta.2",
"version": "6.0.0-beta.3",
"description": "The official JavaScript + TypeScript client library for Prismic",

@@ -5,0 +5,0 @@ "keywords": [

@@ -34,2 +34,11 @@ import * as prismicT from "@prismicio/types";

/**
* The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
* `getAllByType`, `getAllByTag`) will wait between individual page requests.
*
* This is done to ensure API performance is sustainable and reduces the chance
* of a failed API request due to overloading.
*/
export const GET_ALL_QUERY_DELAY = 500;
/**
* Modes for client ref management.

@@ -467,2 +476,6 @@ */

/**
* **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
* require more resources than other methods. Prefer using other methods that
* filter by predicates such as `getAllByType`.
*
* Queries content from the Prismic repository and returns all matching

@@ -476,10 +489,11 @@ * content. If no predicates are provided, all documents will be fetched.

* ```ts
* const response = await client.getAll();
* const response = await client.dangerouslyGetAll();
* ```
*
* @typeParam TDocument - Type of Prismic documents returned. @param params -
* Parameters to filter, sort, and paginate results. @returns A list of
* documents matching the query.
* @typeParam TDocument - Type of Prismic documents returned.
* @param params - Parameters to filter, sort, and paginate results.
*
* @returns A list of documents matching the query.
*/
async getAll<TDocument extends prismicT.PrismicDocument>(
async dangerouslyGetAll<TDocument extends prismicT.PrismicDocument>(
params: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams = {},

@@ -493,11 +507,17 @@ ): Promise<TDocument[]> {

const result = await this.get<TDocument>(resolvedParams);
const documents: TDocument[] = [];
let latestResult: prismicT.Query<TDocument> | undefined;
let page = result.page;
let documents = result.results;
while (
(!latestResult || latestResult.next_page) &&
documents.length < limit
) {
const page = latestResult ? latestResult.page + 1 : undefined;
while (page < result.total_pages && documents.length < limit) {
page += 1;
const result = await this.get<TDocument>({ ...resolvedParams, page });
documents = [...documents, ...result.results];
latestResult = await this.get<TDocument>({ ...resolvedParams, page });
documents.push(...latestResult.results);
if (latestResult.next_page) {
await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
}
}

@@ -597,3 +617,3 @@

): Promise<TDocument[]> {
return await this.getAll<TDocument>(
return await this.dangerouslyGetAll<TDocument>(
appendPredicates(params, predicate.in("document.id", ids)),

@@ -704,3 +724,3 @@ );

): Promise<TDocument[]> {
return await this.getAll<TDocument>(
return await this.dangerouslyGetAll<TDocument>(
appendPredicates(params, [

@@ -790,3 +810,3 @@ typePredicate(documentType),

): Promise<TDocument[]> {
return await this.getAll<TDocument>(
return await this.dangerouslyGetAll<TDocument>(
appendPredicates(params, typePredicate(documentType)),

@@ -843,3 +863,3 @@ );

): Promise<TDocument[]> {
return await this.getAll<TDocument>(
return await this.dangerouslyGetAll<TDocument>(
appendPredicates(params, everyTagPredicate(tag)),

@@ -896,3 +916,3 @@ );

): Promise<TDocument[]> {
return await this.getAll<TDocument>(
return await this.dangerouslyGetAll<TDocument>(
appendPredicates(params, everyTagPredicate(tags)),

@@ -949,3 +969,3 @@ );

): Promise<TDocument[]> {
return await this.getAll<TDocument>(
return await this.dangerouslyGetAll<TDocument>(
appendPredicates(params, someTagsPredicate(tags)),

@@ -952,0 +972,0 @@ );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc