From a505458b67f4916017012eb28b0bf47e3ef82a71 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 25 Nov 2025 20:05:56 +0530 Subject: [PATCH 1/2] Fixed the JSDoc Strings --- src/lib/asset-query.ts | 10 +- src/lib/asset.ts | 10 +- src/lib/base-query.ts | 9 +- src/lib/cache.ts | 10 ++ src/lib/content-type.ts | 9 +- src/lib/contentstack.ts | 2 +- src/lib/contenttype-query.ts | 4 +- src/lib/entries.ts | 35 +++-- src/lib/entry.ts | 18 +-- src/lib/global-field-query.ts | 6 +- src/lib/global-field.ts | 14 +- src/lib/image-transform.ts | 82 ++++++----- src/lib/pagination.ts | 4 +- src/lib/query.ts | 131 +++++++++++------- src/lib/stack.ts | 76 ++++++---- src/lib/utils.ts | 9 ++ .../config/persistance-storage-config.ts | 23 ++- src/persistance/persistance-store.ts | 30 ++++ src/persistance/storages/local-storage.ts | 29 ++++ src/persistance/storages/memory-storage.ts | 24 ++++ 20 files changed, 370 insertions(+), 165 deletions(-) diff --git a/src/lib/asset-query.ts b/src/lib/asset-query.ts index 0f66d63a..6bec3194 100644 --- a/src/lib/asset-query.ts +++ b/src/lib/asset-query.ts @@ -61,14 +61,14 @@ export class AssetQuery extends BaseQuery { /** * @method includeMetadata - * @memberof Entries - * @description Include the metadata for getting metadata content for the entry. - * @returns {Entries} + * @memberof AssetQuery + * @description Include the metadata for getting metadata content for the asset. + * @returns {AssetQuery} * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.asset().includeMetadata().fetch(); + * const result = await stack.asset().includeMetadata().find(); */ includeMetadata(): AssetQuery { this._queryParams.include_metadata = 'true'; @@ -128,7 +128,7 @@ export class AssetQuery extends BaseQuery { } /** * @method query - * @memberof Query + * @memberof AssetQuery * @description Fetches the asset data on the basis of the query * @returns {Query} * @example diff --git a/src/lib/asset.ts b/src/lib/asset.ts index 4d635e19..b5c7c235 100644 --- a/src/lib/asset.ts +++ b/src/lib/asset.ts @@ -29,9 +29,9 @@ export class Asset { /** * @method includeMetadata - * @memberof Entries - * @description Include the metadata for getting metadata content for the entry. - * @returns {Entries} + * @memberof Asset + * @description Include the metadata for getting metadata content for the asset. + * @returns {Asset} * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -115,7 +115,7 @@ export class Asset { /** * @method locale * @memberof Asset - * @description The assets published in the locale will be fetched + * @description The asset published in the locale will be fetched * @returns {Asset} * @example * import contentstack from '@contentstack/delivery-sdk' @@ -133,7 +133,7 @@ export class Asset { * @method fetch * @memberof Asset * @description Fetches the asset data on the basis of the asset uid - * @returns {Asset} + * @returns {Promise} Promise that resolves to the asset data * @example * import contentstack from '@contentstack/delivery-sdk' * diff --git a/src/lib/base-query.ts b/src/lib/base-query.ts index a1347ed9..dc9fe794 100644 --- a/src/lib/base-query.ts +++ b/src/lib/base-query.ts @@ -191,9 +191,10 @@ export class BaseQuery extends Pagination { /** * @method find - * @memberof AssetQuery - * @description The assets of the stack will be fetched - * @returns {Collection} + * @memberof BaseQuery + * @description Fetches the data based on the query parameters + * @param {boolean} encode - Whether to encode query parameters + * @returns {Promise>} Promise that resolves to the find response * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -208,7 +209,7 @@ export class BaseQuery extends Pagination { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.asset(asset_uid).fetch(); + * const result = await stack.contentType("contentTypeUid").entry().query().find(); */ async find(encode: boolean = false): Promise> { diff --git a/src/lib/cache.ts b/src/lib/cache.ts index 0d28f7bf..83743cd9 100644 --- a/src/lib/cache.ts +++ b/src/lib/cache.ts @@ -39,6 +39,16 @@ function generateEnhancedCacheKey(originalKey: string, contentTypeUid?: string, return cacheKey; } +/** + * Handles cache requests based on the cache policy + * @param {CacheOptions} cacheOptions - Cache configuration options + * @param {string} apiKey - API key for cache key generation + * @param {Function} defaultAdapter - Default axios adapter function + * @param {Function} resolve - Promise resolve function + * @param {Function} reject - Promise reject function + * @param {object} config - Request configuration object + * @returns {Promise} Resolves or rejects based on cache policy and API response + */ export async function handleRequest( cacheOptions: CacheOptions, apiKey: string, diff --git a/src/lib/content-type.ts b/src/lib/content-type.ts index af75fc0d..d62842a3 100644 --- a/src/lib/content-type.ts +++ b/src/lib/content-type.ts @@ -21,13 +21,16 @@ export class ContentType { /** * @method entry * @memberof ContentType - * @description Creates entry object of the passed entry uid. - * @returns {Entry} + * @description Creates entry object of the passed entry uid, or entries query object if no uid is provided. + * @param {string} [uid] - Optional entry UID. If provided, returns a single Entry instance. If omitted, returns Entries query object. + * @returns {Entry | Entries} Entry instance if uid is provided, otherwise Entries query object * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const entry = stack.contentType("contentTypeUid").entry("entryUid"); + * // OR + * const entries = stack.contentType("contentTypeUid").entry(); */ entry(uid: string): Entry; entry(): Entries; @@ -41,7 +44,7 @@ export class ContentType { * @method fetch * @memberof ContentType * @description Fetches the contentType data on the basis of the contentType uid - * @returns {ContentType} + * @returns {Promise} Promise that resolves to the content type data * @example * import contentstack from '@contentstack/delivery-sdk' * diff --git a/src/lib/contentstack.ts b/src/lib/contentstack.ts index 837b99df..9fae49a4 100644 --- a/src/lib/contentstack.ts +++ b/src/lib/contentstack.ts @@ -14,7 +14,7 @@ let version = '{{VERSION}}'; * @memberof Contentstack * @description Creates a stack instance * @param {StackConfig} config - config object for stack with apiKey, deliveryToken and environment as required fields - * + * @returns {StackClass} Stack instance * @example * import contentstack from '@contentstack/delivery-sdk' * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); diff --git a/src/lib/contenttype-query.ts b/src/lib/contenttype-query.ts index 50702f8d..aceec4ce 100644 --- a/src/lib/contenttype-query.ts +++ b/src/lib/contenttype-query.ts @@ -13,7 +13,7 @@ export class ContentTypeQuery { /** * @method includeGlobalFieldSchema * @memberof ContentTypeQuery - * @description The assets published in the locale will be fetched + * @description Includes the global field schema in the content type response * @returns {ContentTypeQuery} * @example * import contentstack from '@contentstack/delivery-sdk' @@ -31,7 +31,7 @@ export class ContentTypeQuery { * @method find * @memberof ContentTypeQuery * @description Fetches all contentTypes of the stack - * @returns {ContentTypeQuery} + * @returns {Promise>} Promise that resolves to the find response containing content types * @example * import contentstack from '@contentstack/delivery-sdk' * diff --git a/src/lib/entries.ts b/src/lib/entries.ts index c7727d39..685268fd 100644 --- a/src/lib/entries.ts +++ b/src/lib/entries.ts @@ -62,13 +62,13 @@ export class Entries extends BaseQuery { /** * @method includeContentType * @memberof Entries - * @description IInclude the details of the content type along with the entries details + * @description Include the details of the content type along with the entries details * @returns {Entries} * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.contentType(contentType_uid).entry().includeContentType().fetch(); + * const result = await stack.contentType(contentType_uid).entry().includeContentType().find(); */ includeContentType(): Entries { this._queryParams.include_content_type = 'true'; @@ -85,7 +85,7 @@ export class Entries extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.contentType(contentType_uid).entry().includeEmbeddedItems().fetch(); + * const result = await stack.contentType(contentType_uid).entry().includeEmbeddedItems().find(); */ includeEmbeddedItems(): Entries { this._queryParams['include_embedded_items[]'] = 'BASE'; @@ -134,7 +134,9 @@ export class Entries extends BaseQuery { * you need to use the include[] parameter and specify the UID of the reference field as value. * This function sets the include parameter to a reference field UID in the API request. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().includeReference("brand") * const res = await query.find() * @@ -160,7 +162,9 @@ export class Entries extends BaseQuery { * @memberof Entries * @description This method also includes the content type UIDs of the referenced entries returned in the response. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().includeReferenceContentTypeUID() * const res = await query.find() * @@ -175,9 +179,11 @@ export class Entries extends BaseQuery { /** * @method includeSchema * @memberof Entries - * @description This method also includes the content type UIDs of the referenced entries returned in the response. + * @description Includes the schema of the content type along with the entries details. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().includeSchema() * const res = await query.find() * @@ -191,9 +197,9 @@ export class Entries extends BaseQuery { /** * @method locale - * @memberof Entry - * @description The assets published in the locale will be fetched - * @returns {Entry} + * @memberof Entries + * @description The entries published in the locale will be fetched + * @returns {Entries} * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -235,8 +241,9 @@ export class Entries extends BaseQuery { /** * @method query * @memberof Entries - * @description Fetches the Entry data on the basis of the asset uid - * @returns {Collection} + * @description Creates a query object for filtering entries + * @param {object} queryObj - Optional query object to initialize the query + * @returns {Query} Query instance for chaining query methods * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -251,9 +258,9 @@ export class Entries extends BaseQuery { /** * @method variants - * @memberof Entry + * @memberof Entries * @description The variant header will be added to axios client - * @returns {Entry} + * @returns {Entries} * @example * import contentstack from '@contentstack/delivery-sdk' * diff --git a/src/lib/entry.ts b/src/lib/entry.ts index 077c8cdb..d74fd798 100644 --- a/src/lib/entry.ts +++ b/src/lib/entry.ts @@ -97,7 +97,9 @@ export class Entry { * you need to use the include[] parameter and specify the UID of the reference field as value. * This function sets the include parameter to a reference field UID in the API request. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry(entry_uid).includeReference("brand").fetch() * * @param {string} referenceFieldUid - UID of the reference field to include. @@ -120,7 +122,7 @@ export class Entry { /** * @method includeContentType * @memberof Entry - * @description IInclude the details of the content type along with the entries details + * @description Include the details of the content type along with the entries details * @returns {Entry} * @example * import contentstack from '@contentstack/delivery-sdk' @@ -154,13 +156,13 @@ export class Entry { /** * @method locale * @memberof Entry - * @description The assets published in the locale will be fetched + * @description The entry published in the locale will be fetched * @returns {Entry} * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.assetQuery().locale('en-us').fetch(); + * const result = await stack.contentType('contentTypeUid').entry('entryUid').locale('en-us').fetch(); */ locale(locale: string): this { this._queryParams.locale = locale; @@ -172,7 +174,7 @@ export class Entry { * @method fetch * @memberof Entry * @description Fetches the entry data on the basis of the entry uid - * @returns {Collection} + * @returns {Promise} Promise that resolves to the entry data * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -208,7 +210,7 @@ export class Entry { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = stack.contentType("contentTypeUid").entry().addParams({"key": "value"}).fetch() + * const result = await stack.contentType("contentTypeUid").entry("entryUid").addParams({"key": "value"}).fetch() * * @returns {Entry} */ @@ -226,7 +228,7 @@ export class Entry { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.contentType("contentTypeUid").entry().except("fieldUID").find() + * const result = await stack.contentType("contentTypeUid").entry("entryUid").except("fieldUID").fetch() * * @param {string} fieldUid - field uid to exclude * @returns {Entry} - returns Entry object for chaining method calls @@ -253,7 +255,7 @@ export class Entry { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.contentType("contentTypeUid").entry().only("fieldUID").find() + * const result = await stack.contentType("contentTypeUid").entry("entryUid").only("fieldUID").fetch() * * @param {string} fieldUid - field uid to select * @returns {Entry} - returns Entry object for chaining method calls diff --git a/src/lib/global-field-query.ts b/src/lib/global-field-query.ts index 3cfc49da..f29328ef 100644 --- a/src/lib/global-field-query.ts +++ b/src/lib/global-field-query.ts @@ -14,9 +14,11 @@ export class GlobalFieldQuery extends BaseQuery { * @description Includes the _branch top-level key in the response * @returns {GlobalFieldQuery} * @example - * const stack = contentstack.stack('apiKey','deliveryToken','environment'); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const globalFields = stack.globalField(); - * const result = globalFields.includeBranch().find(); + * const result = await globalFields.includeBranch().find(); */ includeBranch(): GlobalFieldQuery { this._queryParams.include_branch = 'true'; diff --git a/src/lib/global-field.ts b/src/lib/global-field.ts index 9b459bc2..dd69ad68 100644 --- a/src/lib/global-field.ts +++ b/src/lib/global-field.ts @@ -15,9 +15,11 @@ export class GlobalField { * @description Includes the _branch top-level key in the response * @returns {GlobalField} * @example - * const stack = contentstack.stack('apiKey','deliveryToken','environment'); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const globalField = stack.globalField('global_field_uid'); - * const result = globalField.includeBranch().fetch(); + * const result = await globalField.includeBranch().fetch(); */ includeBranch(): GlobalField { this._queryParams.include_branch = 'true'; @@ -25,14 +27,16 @@ export class GlobalField { return this; } /** - * @method find + * @method fetch * @memberof GlobalField * @description Fetches comprehensive details of a specific global field - * @returns {GlobalField} + * @returns {Promise} Promise that resolves to the global field data * @example + * import contentstack from '@contentstack/delivery-sdk' + * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const globalField = stack.globalField('global_field_uid'); - * const result = globalField.fetch(); + * const result = await globalField.fetch(); */ async fetch(): Promise { const response = await getData(this._client, this._urlPath, { params: this._queryParams }); diff --git a/src/lib/image-transform.ts b/src/lib/image-transform.ts index 64bfc800..6b9db557 100644 --- a/src/lib/image-transform.ts +++ b/src/lib/image-transform.ts @@ -53,7 +53,7 @@ export class ImageTransform { /** * @method format * @memberof ImageTransform - * @description The format parameter lets you converts a given image from one format to another. + * @description The format parameter lets you convert a given image from one format to another. * @param {Format} format - Specifies the format to change to. * @returns {ImageTransform} * @example @@ -72,11 +72,12 @@ export class ImageTransform { * @method resize * @memberof ImageTransform * @description The resize parameter lets you resize the image in terms of width, height, upscaling the image. - * @param {string | number} width - Specifies the width to resize the image to. + * @param {object} options - Resize options object + * @param {string | number} [options.width] - Specifies the width to resize the image to. * The value can be in pixels (for example, 400) or in percentage (for example, 0.60 OR '60p') - * @param {string | number} height - Specifies the height to resize the image to. + * @param {string | number} [options.height] - Specifies the height to resize the image to. * The value can be in pixels (for example, 400) or in percentage (for example, 0.60 OR '60p') - * @param {string} disable - The disable parameter disables the functionality that is enabled by default. + * @param {string} [options.disable] - The disable parameter disables the functionality that is enabled by default. * As of now, there is only one value, i.e., upscale, that you can use with the disable parameter. * @returns {ImageTransform} * @example @@ -108,20 +109,21 @@ export class ImageTransform { * the height and width in pixels or percentage value, or defining height and width in aspect ratio. * You can also define a sub region (i.e., define the starting point for crop) before cropping the image, * or you can offset the image on its X and Y axis (i.e., define the centre point of the crop) before cropping the image. - * @returns {ImageTransform} - * @param {string | number} width - Specifies the width to resize the image to. + * @param {object} options - Crop options object + * @param {string | number} options.width - Specifies the width to resize the image to. * The value can be in pixels (for example, 400) or in percentage (for example, 0.60 OR '60p') - * @param {string | number} height - Specifies the height to resize the image to. + * @param {string | number} options.height - Specifies the height to resize the image to. * The value can be in pixels (for example, 400) or in percentage (for example, 0.60 OR '60p') - * @param {string | number} xval - (Optional) For CropBy Region, xval defines the X-axis position + * @param {string | number} [options.xval] - (Optional) For CropBy Region, xval defines the X-axis position * of the top left corner of the crop. For CropBy Offset, xval defines the horizontal offset of the crop region. - * @param {string | number} yval - (Optional) For CropBy Region, yval defines the Y-axis position + * @param {string | number} [options.yval] - (Optional) For CropBy Region, yval defines the Y-axis position * of the top left corner of the crop. For CropBy Offset, yval defines the vertical offset of the crop region. - * @param {CropBy} cropBy - (Optional) Specifies the CropBy type. Values are DEFAULT, ASPECTRATIO, REGION, OFFSET. - * @param {boolean} safe - (Optional) Ensures that the output image never returns an error due to the specified crop area being + * @param {CropBy} [options.cropBy] - (Optional) Specifies the CropBy type. Values are DEFAULT, ASPECTRATIO, REGION, OFFSET. + * @param {boolean} [options.safe] - (Optional) Ensures that the output image never returns an error due to the specified crop area being * out of bounds. The output image is returned as an intersection of the source image and the defined crop area. - * @param {boolean} smart - (Optional) Ensures crop is done using content-aware algorithms. Content-aware image cropping returns a + * @param {boolean} [options.smart] - (Optional) Ensures crop is done using content-aware algorithms. Content-aware image cropping returns a * cropped image that automatically fits the defined dimensions while intelligently including the most important components of the image. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().crop({ width: 100, height: 200 }) @@ -177,8 +179,11 @@ export class ImageTransform { this.obj.crop = [width.toString(), height.toString(), `offset-x${xval}`, `offset-y${yval}`]; } } - if (safe) this.obj.crop = [...this.obj.crop, 'safe']; - if (smart) this.obj.crop = [...this.obj.crop, 'smart']; + // Only add safe/smart when crop is an array (not for ASPECTRATIO which is a string) + if (Array.isArray(this.obj.crop)) { + if (safe) this.obj.crop = [...this.obj.crop, 'safe']; + if (smart) this.obj.crop = [...this.obj.crop, 'smart']; + } return this; } @@ -187,8 +192,8 @@ export class ImageTransform { * @method fit * @memberof ImageTransform * @description The fit parameter enables you to fit the given image properly within the specified height and width. - * @returns {ImageTransform} * @param {FitBy} type - Specifies fit type (BOUNDS or CROP). + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().resize({ width: 200, height: 200 }).fit(FitBy.BOUNDS); @@ -204,9 +209,9 @@ export class ImageTransform { /** * @method trim * @memberof ImageTransform - * @description The trim parameterlets you trim an image from the edges. This is especially useful for removing border or white spaces. - * @returns {ImageTransform} + * @description The trim parameter lets you trim an image from the edges. This is especially useful for removing border or white spaces. * @param {number | number[]} trimValues - specifies values for top, right, bottom, and left edges of an image. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().trim([25, 50, 75, 90]); @@ -234,9 +239,9 @@ export class ImageTransform { * @memberof ImageTransform * @description The orient parameter lets you control the cardinal orientation of the given image. Using this parameter, * you can orient the image right or left, flip horizontally or vertically or both - * @returns {ImageTransform} * @param {Orientation} orientType - Type of Orientation. Values are DEFAULT, FLIP_HORIZONTAL, FLIP_HORIZONTAL_VERTICAL, * FLIP_VERTICAL, FLIP_HORIZONTAL_LEFT, RIGHT, FLIP_HORIZONTAL_RIGHT, LEFT. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().orient(Orientation.FLIP_HORIZONTAL); @@ -254,18 +259,19 @@ export class ImageTransform { * @memberof ImageTransform * @description The overlay parameter allows you to put one image on top of another. * You need to specify the relative URL of the image as value for this parameter. - * @returns {ImageTransform} - * @param {string} relativeURL - URL of the image to overlay on base image - * @param {OverlayAlign | OverlayAlign[]} align - lets you define the position of the overlay image. + * @param {object} options - Overlay options object + * @param {string} options.relativeURL - URL of the image to overlay on base image + * @param {OverlayAlign | OverlayAlign[]} [options.align] - lets you define the position of the overlay image. * Accepted values are TOP, BOTTOM, LEFT, RIGHT, MIDDLE, CENTER. - * @param {OverlayRepeat} repeat - lets you define how the overlay image will be repeated on the given image. + * @param {OverlayRepeat} [options.repeat] - lets you define how the overlay image will be repeated on the given image. * Accepted values are X, Y, BOTH. - * @param {string | number} width - lets you define the width of the overlay image. + * @param {string | number} [options.width] - lets you define the width of the overlay image. * For pixels, use any whole number between 1 and 8192. For percentages, use any decimal number between 0.0 and 0.99. - * @param {string | number} height - lets you define the height of the overlay image. + * @param {string | number} [options.height] - lets you define the height of the overlay image. * For pixels, use any whole number between 1 and 8192. For percentages, use any decimal number between 0.0 and 0.99 - * @param {number | number[]} pad - lets you add extra pixels to the edges of an image. + * @param {number | number[]} [options.pad] - lets you add extra pixels to the edges of an image. * This is useful if you want to add whitespace or border to an image. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().overlay({ relativeURL: overlayImgURL }); @@ -315,8 +321,8 @@ export class ImageTransform { * @memberof ImageTransform * @description The padding parameter lets you add extra pixels to the edges of an image. * This is useful if you want to add whitespace or border to an image. - * @returns {ImageTransform} * @param {number | number[]} padding - padding value in pixels or percentages + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().padding([25, 50, 75, 90]); @@ -337,9 +343,9 @@ export class ImageTransform { /** * @method bgColor * @memberof ImageTransform - * @description The bgColor parameter lets you set a backgroud color for the given image. - * @returns {ImageTransform} + * @description The bgColor parameter lets you set a background color for the given image. * @param {string | number[]} color - color of the background + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().bgColor('cccccc'); @@ -361,8 +367,8 @@ export class ImageTransform { * @method dpr * @memberof ImageTransform * @description The dpr parameter lets you deliver images with appropriate size to devices that come with a defined device pixel ratio. - * @returns {ImageTransform} * @param {number} dprValue - value of device pixel ratio 1-10000 or 0.0 to 9999.999 + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().resize({ width: 300, height: 500 }).dpr(10); @@ -379,8 +385,8 @@ export class ImageTransform { * @method blur * @memberof ImageTransform * @description The blur parameter allows you to decrease the focus and clarity of a given image. - * @returns {ImageTransform} * @param {number} blurValue - to set the blur intensity between 1-1000. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().blur(10); @@ -415,10 +421,10 @@ export class ImageTransform { * @method sharpen * @memberof ImageTransform * @description The sharpen parameter allows you to increase the definition of the edges of objects in an image. - * @returns {ImageTransform} * @param {number} amount - [0-10] specifies the amount of contrast to be set for the image edges * @param {number} radius - [1-1000] specifies the radius of the image edges * @param {number} threshold - [0-255] specifies the range of image edges that need to be ignored while sharpening + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().sharpen(5, 1000, 2); @@ -435,8 +441,8 @@ export class ImageTransform { * @method saturation * @memberof ImageTransform * @description The saturation parameter allows you to increase or decrease the intensity of the colors in a given image. - * @returns {ImageTransform} * @param {number} saturationValue - to set the saturation of image between -100 to 100 + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().saturation(-80.99); @@ -452,9 +458,9 @@ export class ImageTransform { /** * @method contrast * @memberof ImageTransform - * @description The contrast parameter lets you enable the functionality that automates certain image optimization features. - * @returns {ImageTransform} + * @description The contrast parameter lets you adjust the contrast level of the image. * @param {number} contrastValue - to set the contrast of image between -100 to 100 + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().contrast(-80.99); @@ -470,9 +476,9 @@ export class ImageTransform { /** * @method brightness * @memberof ImageTransform - * @description The brightness parameter lets you enable the functionality that automates certain image optimization features. + * @description The brightness parameter lets you adjust the brightness level of the image. + * @param {number} brightnessValue - to set the brightness of image between -100 to 100 * @returns {ImageTransform} - * @param {number} contrastValue - to set the brightness of image between -100 to 100 * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().brightness(80.50); @@ -490,9 +496,9 @@ export class ImageTransform { * @memberof ImageTransform * @description The resizeFilter parameter allows you to use the resizing filter to increase or * decrease the number of pixels in a given image. - * @returns {ImageTransform} * @param {ResizeFilter} type - type of Filter to apply * Values are NEAREST, BILINEAR, BICUBIC, LANCZOS2, LANCZOS3. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().resize({ width: 500, height: 550 }).resizeFilter(ResizeFilter.NEAREST); @@ -511,12 +517,12 @@ export class ImageTransform { * @description The canvas parameter allows you to increase the size of the canvas that surrounds an image. * You can specify the height and width of the canvas area in pixels or percentage or define the height and width * of the aspect ratio of the canvas. You can also define the starting point for the canvas area or offset the canvas on its X and Y axis. - * @returns {ImageTransform} * @param {string | number} width - sets width of the canvas * @param {string | number} height - sets height of the canvas * @param {string | number} xval - defines the X-axis position of the top left corner or horizontal offset * @param {string | number} yval - defines the Y-axis position of the top left corner or vertical offset * @param {CanvasBy} canvasBy - Specifies the canvasBy type. Accepted values are DEFAULT, ASPECTRATIO, REGION, OFFSET. + * @returns {ImageTransform} * @example * const url = 'www.example.com'; * const transformObj = new ImageTransform().canvas({ width: 100, height: 200 }); diff --git a/src/lib/pagination.ts b/src/lib/pagination.ts index 0a4748aa..6005f088 100644 --- a/src/lib/pagination.ts +++ b/src/lib/pagination.ts @@ -6,8 +6,8 @@ export class Pagination { * @method constructor * @memberof Pagination * @description Create a pagination class object to paginate through the query response - * @param {baseQuery} object of class BaseQUery - * @param {paginationObj} object to send skip and limit values + * @param {BaseQuery} object of class BaseQuery + * @param {PaginationObj} object to send skip and limit values * @example * import contentstack from '@contentstack/delivery-sdk' * diff --git a/src/lib/query.ts b/src/lib/query.ts index 96ecc1dc..e731ffd1 100644 --- a/src/lib/query.ts +++ b/src/lib/query.ts @@ -97,7 +97,7 @@ export class Query extends BaseQuery { * const query = stack.contentType("contentTypeUid").entry().query(); * const result = await query.regex('title','^Demo').find() * // OR - * const result = await query..regex('title','^Demo', 'i').find() // regex with options + * const result = await query.regex('title','^Demo', 'i').find() // regex with options * @returns {Query} */ regex(fieldUid: string, regexPattern: string, options?: string): Query { @@ -122,9 +122,12 @@ export class Query extends BaseQuery { * The query retrieves all entries that satisfy the query conditions made on referenced fields * This method sets the '$in_query' parameter to a reference field UID and a query instance in the API request. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().query(); - * query.whereIn("brand") + * const subQuery = stack.contentType("referencedContentTypeUid").entry().query().where("title", QueryOperation.EQUALS, "value"); + * query.whereIn("brand", subQuery) * const res = await query.find() * * @param {string} referenceUid - UID of the reference field to query. @@ -147,9 +150,12 @@ export class Query extends BaseQuery { * This query works the opposite of $in_query and retrieves all entries that does not satisfy query conditions made on referenced fields. * This method sets the '$nin_query' parameter to a reference field UID and a query instance in the API request. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().query(); - * query.whereNotIn("brand") + * const subQuery = stack.contentType("referencedContentTypeUid").entry().query().where("title", QueryOperation.EQUALS, "value"); + * query.whereNotIn("brand", subQuery) * const res = await query.find() * * @param {string} referenceUid - UID of the reference field to query. @@ -171,10 +177,12 @@ export class Query extends BaseQuery { * @description In case of '$and' get entries that satisfy all the conditions provided in the '$and' query and * in case of '$or' query get all entries that satisfy at least one of the given conditions provided in the '$or' query. * @example - * const stack = contentstack.stack("apiKey", "deliveryKey", "environment"); + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentType1Uid").entry().query(); - * const subQuery1 = stack.contentType("contentType2Uid").query().where("price", QueryOperation.IS_LESS_THAN, fields=90); - * const subQuery2 = stack.contentType("contentType3Uid").query().where("discount", QueryOperation.INCLUDES, fields=[20, 45]); + * const subQuery1 = stack.contentType("contentType2Uid").entry().query().where("price", QueryOperation.IS_LESS_THAN, 90); + * const subQuery2 = stack.contentType("contentType3Uid").entry().query().where("discount", QueryOperation.INCLUDES, [20, 45]); * query.queryOperator(QueryOperator.AND, subQuery1, subQuery2) * const res = await query.find() * @@ -201,9 +209,10 @@ export class Query extends BaseQuery { * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().query(); - * const result = await query.query({'brand': {'$nin_query': {'title': 'Apple Inc.'}}}).getQuery() + * const result = query.getQuery() * // OR - * const asset = await stack.asset().query({'brand': {'$nin_query': {'title': 'Apple Inc.'}}}).getQuery() + * const assetQuery = stack.asset().query(); + * const assetResult = assetQuery.getQuery() * * @returns {Query} */ @@ -214,7 +223,9 @@ export class Query extends BaseQuery { /** * @method containedIn * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value is contained in the provided array of values + * @param {string} key - The field UID to filter on + * @param {(string | number | boolean)[]} value - Array of values to match against * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -238,9 +249,11 @@ export class Query extends BaseQuery { } /** - * @method NoContainedIn + * @method notContainedIn * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value is not contained in the provided array of values + * @param {string} key - The field UID to filter on + * @param {(string | number | boolean)[]} value - Array of values to exclude * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -266,7 +279,8 @@ export class Query extends BaseQuery { /** * @method exists * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the specified field exists + * @param {string} key - The field UID to check for existence * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -288,7 +302,8 @@ export class Query extends BaseQuery { /** * @method notExists * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the specified field does not exist + * @param {string} key - The field UID to check for non-existence * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -310,7 +325,8 @@ export class Query extends BaseQuery { /** * @method or * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Combines multiple queries with OR logic - returns entries that match at least one of the provided queries + * @param {...Query} queries - Query instances to combine with OR logic * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -333,14 +349,15 @@ export class Query extends BaseQuery { /** * @method and * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Combines multiple queries with AND logic - returns entries that match all of the provided queries + * @param {...Query} queries - Query instances to combine with AND logic * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query1 = stack.contentType('contenttype_uid').Entry().query().containedIn('fieldUID', ['value']); - * const query2 = stack.contentType('contenttype_uid').Entry().query().where('fieldUID', QueryOperation.EQUALS, 'value2'); - * const query = await stack.contentType('contenttype_uid').Entry().query().and(query1, query2).find(); + * const query1 = stack.contentType('contenttype_uid').entry().query().containedIn('fieldUID', ['value']); + * const query2 = stack.contentType('contenttype_uid').entry().query().where('fieldUID', QueryOperation.EQUALS, 'value2'); + * const query = await stack.contentType('contenttype_uid').entry().query().and(query1, query2).find(); * * @returns {Query} */ @@ -356,12 +373,14 @@ export class Query extends BaseQuery { /** * @method equalTo * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value equals the specified value + * @param {string} key - The field UID to filter on + * @param {string | number | boolean} value - The value to match * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = await stack.contentType('contenttype_uid').Entry().query().equalTo('fieldUid', 'value').find(); + * const query = await stack.contentType('contenttype_uid').entry().query().equalTo('fieldUid', 'value').find(); * * @returns {Query} */ @@ -381,12 +400,14 @@ export class Query extends BaseQuery { /** * @method notEqualTo * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value does not equal the specified value + * @param {string} key - The field UID to filter on + * @param {string | number | boolean} value - The value to exclude * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = await stack.contentType('contenttype_uid').Entry().query().notEqualTo('fieldUid', 'value').find(); + * const query = await stack.contentType('contenttype_uid').entry().query().notEqualTo('fieldUid', 'value').find(); * * @returns {Query} */ @@ -406,13 +427,15 @@ export class Query extends BaseQuery { /** * @method referenceIn * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the reference field matches entries from the provided query + * @param {string} key - The reference field UID to filter on + * @param {Query} query - Query instance to match referenced entries against * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().referenceIn('reference_uid', query).find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().referenceIn('reference_uid', query).find(); * * @returns {Query} */ @@ -428,13 +451,15 @@ export class Query extends BaseQuery { /** * @method referenceNotIn * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the reference field does not match entries from the provided query + * @param {string} key - The reference field UID to filter on + * @param {Query} query - Query instance to exclude referenced entries against * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().referenceNotIn('reference_uid', query).find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().referenceNotIn('reference_uid', query).find(); * * @returns {Query} */ @@ -450,13 +475,14 @@ export class Query extends BaseQuery { /** * @method tags * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries that have any of the specified tags + * @param {(string | number | boolean)[]} values - Array of tag values to filter by * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().tags(['tag1']).find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().tags(['tag1']).find(); * * @returns {Query} */ @@ -472,13 +498,14 @@ export class Query extends BaseQuery { /** * @method search * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Enables typeahead search functionality for the query + * @param {string} key - The search term to use for typeahead search * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().search('key').find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().search('key').find(); * * @returns {Query} */ @@ -494,13 +521,15 @@ export class Query extends BaseQuery { /** * @method lessThan * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value is less than the specified value + * @param {string} key - The field UID to filter on + * @param {string | number} value - The value to compare against * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().lessThan('fieldUid', 'value').find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().lessThan('fieldUid', 'value').find(); * * @returns {Query} */ @@ -521,13 +550,15 @@ export class Query extends BaseQuery { /** * @method lessThanOrEqualTo * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value is less than or equal to the specified value + * @param {string} key - The field UID to filter on + * @param {string | number} value - The value to compare against * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().lessThanOrEqualTo('fieldUid', 'value').find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().lessThanOrEqualTo('fieldUid', 'value').find(); * * @returns {Query} */ @@ -547,13 +578,15 @@ export class Query extends BaseQuery { /** * @method greaterThan * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value is greater than the specified value + * @param {string} key - The field UID to filter on + * @param {string | number} value - The value to compare against * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().greaterThan('fieldUid', 'value').find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().greaterThan('fieldUid', 'value').find(); * * @returns {Query} */ @@ -573,13 +606,15 @@ export class Query extends BaseQuery { /** * @method greaterThanOrEqualTo * @memberof Query - * @description Returns the raw (JSON) query based on the filters applied on Query object. + * @description Filters entries where the field value is greater than or equal to the specified value + * @param {string} key - The field UID to filter on + * @param {string | number} value - The value to compare against * @example * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').query().greaterThanOrEqualTo('fieldUid', 'value').find(); + * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const entryQuery = await stack.contentType('contenttype_uid').entry().query().greaterThanOrEqualTo('fieldUid', 'value').find(); * * @returns {Query} */ diff --git a/src/lib/stack.ts b/src/lib/stack.ts index b4fe63cd..f36046ff 100644 --- a/src/lib/stack.ts +++ b/src/lib/stack.ts @@ -21,7 +21,7 @@ export class Stack { /** * @method asset - * @memberOf Stack + * @memberof Stack * @param {String} uid - uid of the asset * @description Creates an object for all assets of a stack by default. To retrieve a single asset, specify its UID. * @@ -45,9 +45,9 @@ export class Stack { /** * @method contentType - * @memberOf Stack - * @param {String} uid - uid of the asset - * @description Retrieves all contentTypes of a stack by default. To retrieve a single asset, specify its UID. + * @memberof Stack + * @param {String} uid - uid of the contentType + * @description Retrieves all contentTypes of a stack by default. To retrieve a single contentType, specify its UID. * * @returns {ContentType} * @example @@ -68,11 +68,12 @@ export class Stack { /** * @method Taxonomy - * @memberOf Stack + * @memberof Stack * @description Sets the url to /taxonomies/entries. Pass a query to fetch entries with taxonomies * - * @returns {TaxonomyQuery} * @example - * import contentstack from '@contentstack/typescript' + * @returns {TaxonomyQuery} + * @example + * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); @@ -84,14 +85,18 @@ export class Stack { /** * @method GlobalField - * @memberOf Stack - * @param {String} uid - uid of the asset - * @description Retrieves all contentTypes of a stack by default. To retrieve a single asset, specify its UID. + * @memberof Stack + * @param {String} uid - uid of the globalField + * @description Retrieves all globalFields of a stack by default. To retrieve a single globalField, specify its UID. * - * @returns {ContentType} - * const contentType = stack.contentType() // For collection of contentType + * @returns {GlobalField} + * @example + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * const globalField = stack.globalField() // For collection of globalField * // OR - * const contentType = stack.contentType('contentTypeUid') // For a single contentType with uid 'contentTypeUid' + * const globalField = stack.globalField('globalFieldUid') // For a single globalField with uid 'globalFieldUid' */ globalField(): GlobalFieldQuery; globalField(uid: string): GlobalField; @@ -103,7 +108,7 @@ export class Stack { /** * @method setLocale - * @memberOf Stack + * @memberof Stack * @description Sets the locale of the API server * @param {String} locale - valid locale e.g. fr-fr * @return {Stack} @@ -120,25 +125,46 @@ export class Stack { /** * @method sync - * @memberOf Stack + * @memberof Stack * @description Syncs your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates - * @param {object} params - params is an object that supports ‘locale’, ‘start_date’, ‘content_type_uid’, and ‘type’ queries. + * @param {object} params - params is an object that supports 'locale', 'start_date', 'content_type_uid', and 'type' queries. * @example - * Stack.sync() // For initializing sync + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync() // For initializing sync * @example - * Stack.sync({ 'locale': 'en-us'}) //For initializing sync with entries of a specific locale + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync({ 'locale': 'en-us'}) //For initializing sync with entries of a specific locale * @example - * Stack.sync({ 'start_date': '2018-10-22'}) //For initializing sync with entries published after a specific date + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync({ 'start_date': '2018-10-22'}) //For initializing sync with entries published after a specific date * @example - * Stack.sync({ 'content_type_uid': 'session'}) //For initializing sync with entries of a specific content type + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync({ 'content_type_uid': 'session'}) //For initializing sync with entries of a specific content type * @example - * Stack.sync({ 'type': 'entry_published'}) + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync({ 'type': 'entry_published'}) * //Use the type parameter to get a specific type of content. Supports'asset_published', * // 'entry_published', 'asset_unpublished', 'entry_unpublished', 'asset_deleted', 'entry_deleted', 'content_type_deleted'. * @example - * Stack.sync({'pagination_token': ''}) // For fetching the next batch of entries using pagination token + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync({'pagination_token': ''}) // For fetching the next batch of entries using pagination token * @example - * Stack.sync({'sync_token': ''}) // For performing subsequent sync after initial sync + * import contentstack from '@contentstack/delivery-sdk' + * + * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); + * await stack.sync({'sync_token': ''}) // For performing subsequent sync after initial sync * @instance */ async sync(params: SyncType | SyncStack = {}, recursive = false) { @@ -205,7 +231,7 @@ export class Stack { /** * @method setPort - * @memberOf Stack + * @memberof Stack * @description Sets the port of the host * @param {Number} port - Port Number * @return {Stack} @@ -218,7 +244,7 @@ export class Stack { /** * @method setDebug - * @memberOf Stack + * @memberof Stack * @description Sets the debug option * @param {Number} debug - Debug value * @return {Stack} diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 341e1de4..c23ef6b7 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -7,10 +7,19 @@ export function getHostforRegion(region: string = "aws_na", host?: string): stri return getContentstackEndpoint(region, 'contentDelivery', true) as string; } +/** + * Checks if the code is running in a browser environment + * @returns {boolean} True if running in browser, false otherwise + */ export function isBrowser() { return (typeof window !== "undefined"); } +/** + * Encodes query parameters recursively, handling nested objects + * @param {params} params - Query parameters object to encode + * @returns {params} Encoded query parameters object + */ export function encodeQueryParams(params: params): params { const encodedParams: params = {}; diff --git a/src/persistance/config/persistance-storage-config.ts b/src/persistance/config/persistance-storage-config.ts index 39029fe6..cc223d77 100644 --- a/src/persistance/config/persistance-storage-config.ts +++ b/src/persistance/config/persistance-storage-config.ts @@ -1,15 +1,32 @@ import { Storage } from '../types/storage'; import { StorageType } from '../types/storage-type'; +/** + * Configuration type for persistence store + * Can be either a custom storage with Store interface or standard storage with PersistanceStoreOptions + */ export type PersistanceStoreConfig = | (Store & PersistanceStoreOptions) | ({ storeType?: StorageType } & PersistanceStoreOptions); + +/** + * Interface for custom storage configuration + */ export interface Store { + /** Custom storage implementation */ storage: Storage; + /** Storage type identifier */ storeType: 'customStorage'; } + +/** + * Options for persistence store configuration + */ export interface PersistanceStoreOptions { - maxAge?: number; // default 24 hrs - serializer?: (content: any) => string; // default JSON.stringify - deserializer?: (cacheString: string) => any; // default JSON.parse + /** Maximum age for cached items in milliseconds (default: 24 hours) */ + maxAge?: number; + /** Serializer function for storing data (default: JSON.stringify) */ + serializer?: (content: any) => string; + /** Deserializer function for retrieving data (default: JSON.parse) */ + deserializer?: (cacheString: string) => any; } diff --git a/src/persistance/persistance-store.ts b/src/persistance/persistance-store.ts index 008e5690..be6e4a7d 100644 --- a/src/persistance/persistance-store.ts +++ b/src/persistance/persistance-store.ts @@ -4,11 +4,19 @@ import { memoryStorage } from './storages/memory-storage'; import { Storage } from './types/storage'; import { StorageType } from './types/storage-type'; +/** + * Persistence store for caching data with expiration support + * Supports localStorage, memoryStorage, and custom storage implementations + */ export class PersistanceStore { protected store: Storage = localStorage; readonly config: PersistanceStoreConfig; protected name: string; + /** + * Creates a new PersistanceStore instance + * @param {PersistanceStoreConfig} [config] - Configuration options for the store + */ constructor(config?: PersistanceStoreConfig) { let defaultConfig: PersistanceStoreConfig = { storeType: 'localStorage', @@ -40,6 +48,13 @@ export class PersistanceStore { break; } } + /** + * Sets an item in the store with optional expiration + * @param {string} key - The key to store the value under + * @param {any} value - The value to store + * @param {string} [contentTypeUid] - Optional content type UID for key scoping + * @param {number} [maxAge] - Optional maximum age in milliseconds (overrides config maxAge) + */ setItem(key: string, value: any, contentTypeUid?: string, maxAge?: number) { if (!key) { return; @@ -59,6 +74,12 @@ export class PersistanceStore { this.store.setItem(generatedKey, content); } + /** + * Gets an item from the store if it exists and hasn't expired + * @param {string} key - The key to retrieve + * @param {string} [contentTypeUid] - Optional content type UID for key scoping + * @returns {any} The stored value if found and not expired, undefined otherwise + */ getItem(key: string, contentTypeUid?: string): any { const generatedKey = this.generateCSKey(key, contentTypeUid); const content = this.store.getItem(generatedKey); @@ -75,11 +96,20 @@ export class PersistanceStore { } } + /** + * Removes an item from the store + * @param {string} key - The key to remove + * @param {string} [contentTypeUid] - Optional content type UID for key scoping + */ removeItem(key: string, contentTypeUid?: string) { const generatedKey = this.generateCSKey(key, contentTypeUid); this.store.removeItem(generatedKey); } + /** + * Clears all items from the store, or items matching a specific content type UID + * @param {string} [contentTypeUid] - Optional content type UID to clear only matching items + */ clear(contentTypeUid?: string) { if (!contentTypeUid) { this.store.clear(); diff --git a/src/persistance/storages/local-storage.ts b/src/persistance/storages/local-storage.ts index 5152820b..9ee4479b 100644 --- a/src/persistance/storages/local-storage.ts +++ b/src/persistance/storages/local-storage.ts @@ -11,13 +11,26 @@ export const localStorage: Storage = { setItem: setItem, }; +/** + * Gets the localStorage instance from the global object + * @returns {Storage} The localStorage instance + * @private + */ function _localStorage() { return iGlobal.localStorage; } +/** + * Clears all items from localStorage + */ function clear() { _localStorage().clear(); } + +/** + * Iterates over all items in localStorage and calls the callback for each + * @param {Callback} callback - Function to call for each item with (value, key) parameters + */ function each(callback: Callback) { for (let i = _localStorage().length - 1; i >= 0; i--) { const key = _localStorage().key(i); @@ -27,15 +40,31 @@ function each(callback: Callback) { } } } +/** + * Sets an item in localStorage + * @param {string} key - The key to store under + * @param {string} value - The value to store + */ function setItem(key: string, value: string) { if (!key) { return; } _localStorage().setItem(key, value); } + +/** + * Gets an item from localStorage + * @param {string} key - The key to retrieve + * @returns {string | null} The stored value or null if not found + */ function getItem(key: string): string | null { return _localStorage().getItem(key); } + +/** + * Removes an item from localStorage + * @param {string} key - The key to remove + */ function removeItem(key: string) { _localStorage().removeItem(key); } diff --git a/src/persistance/storages/memory-storage.ts b/src/persistance/storages/memory-storage.ts index bf1020b0..2596c309 100644 --- a/src/persistance/storages/memory-storage.ts +++ b/src/persistance/storages/memory-storage.ts @@ -12,24 +12,48 @@ export const memoryStorage: Storage = { let memory: { [key: string]: string | null } = {}; +/** + * Clears all items from memory storage + */ function clear() { memory = {}; } + +/** + * Iterates over all items in memory storage and calls the callback for each + * @param {Callback} callback - Function to call for each item with (value, key) parameters + */ function each(callback: Callback) { for (const key in memory) { const value = getItem(key); callback(value, key); } } +/** + * Sets an item in memory storage + * @param {string} key - The key to store under + * @param {string} value - The value to store + */ function setItem(key: string, value: string) { if (!key) { return; } memory[key] = value; } + +/** + * Gets an item from memory storage + * @param {string} key - The key to retrieve + * @returns {string | null} The stored value or null if not found + */ function getItem(key: string): string | null { return memory[key]; } + +/** + * Removes an item from memory storage + * @param {string} key - The key to remove + */ function removeItem(key: string) { delete memory[key]; } From a81d173c3230d7e17fd6e37dbeb1d7fba772ea92 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 25 Nov 2025 21:19:33 +0530 Subject: [PATCH 2/2] Fixed Doc string --- src/lib/asset-query.ts | 2 +- src/lib/base-query.ts | 8 ++++---- src/lib/contentstack.ts | 2 +- src/lib/entries.ts | 14 ++++++------- src/lib/entry.ts | 2 +- src/lib/query.ts | 44 ++++++++++++++++++----------------------- src/lib/stack.ts | 4 ++-- 7 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/lib/asset-query.ts b/src/lib/asset-query.ts index 6bec3194..0c1b906b 100644 --- a/src/lib/asset-query.ts +++ b/src/lib/asset-query.ts @@ -135,7 +135,7 @@ export class AssetQuery extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.asset().query().where('fieldUid', queryOperators, 'value').find(); + * const result = await stack.asset().query().where('fieldUid', QueryOperation.EQUALS, 'value').find(); */ query() { return new Query(this._client, this._parameters, this._queryParams); diff --git a/src/lib/base-query.ts b/src/lib/base-query.ts index dc9fe794..5e885fe9 100644 --- a/src/lib/base-query.ts +++ b/src/lib/base-query.ts @@ -51,7 +51,7 @@ export class BaseQuery extends Pagination { * const query = stack.contentType("contentTypeUid").entry().query(); * const result = await query.orderByAscending("field_uid").find() * // OR - * const asset = await stack.asset().orderByAscending().find() + * const asset = await stack.asset().orderByAscending("field_uid").find() * * @returns {Query} */ @@ -72,7 +72,7 @@ export class BaseQuery extends Pagination { * const query = stack.contentType("contentTypeUid").entry().query(); * const result = await query.orderByDescending("field_uid").find() * // OR - * const asset = await stack.asset().orderByDescending().find() + * const asset = await stack.asset().orderByDescending("field_uid").find() * * @returns {Query} */ @@ -91,7 +91,7 @@ export class BaseQuery extends Pagination { * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().query(); - * const result = await query.limit("limit_value").find() + * const result = await query.limit(10).find() * // OR * const asset = await stack.asset().limit(5).find() * @@ -112,7 +112,7 @@ export class BaseQuery extends Pagination { * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query = stack.contentType("contentTypeUid").entry().query(); - * const result = await query.skip("skip_value").find() + * const result = await query.skip(10).find() * // OR * const asset = await stack.asset().skip(5).find() * diff --git a/src/lib/contentstack.ts b/src/lib/contentstack.ts index 9fae49a4..c95ac487 100644 --- a/src/lib/contentstack.ts +++ b/src/lib/contentstack.ts @@ -30,7 +30,7 @@ let version = '{{VERSION}}'; * policy: Policy.CACHE_THEN_NETWORK, * storeType: 'localStorage' * } - * } + * }); */ // eslint-disable-next-line @typescript-eslint/naming-convention export function stack(config: StackConfig): StackClass { diff --git a/src/lib/entries.ts b/src/lib/entries.ts index 685268fd..30f2c24e 100644 --- a/src/lib/entries.ts +++ b/src/lib/entries.ts @@ -137,8 +137,8 @@ export class Entries extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType("contentTypeUid").entry().includeReference("brand") - * const res = await query.find() + * const entries = stack.contentType("contentTypeUid").entry().includeReference("brand") + * const result = await entries.find() * * @param {string} referenceFieldUid - UID of the reference field to include. * @returns {Entries} - Returns the Entries instance for chaining. @@ -165,8 +165,8 @@ export class Entries extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType("contentTypeUid").entry().includeReferenceContentTypeUID() - * const res = await query.find() + * const entries = stack.contentType("contentTypeUid").entry().includeReferenceContentTypeUID() + * const result = await entries.find() * * @returns {Entries} - Returns the Entries instance for chaining. */ @@ -184,8 +184,8 @@ export class Entries extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType("contentTypeUid").entry().includeSchema() - * const res = await query.find() + * const entries = stack.contentType("contentTypeUid").entry().includeSchema() + * const result = await entries.find() * * @returns {Entries} - Returns the Entries instance for chaining. */ @@ -248,7 +248,7 @@ export class Entries extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const result = await stack.contentType("contentTypeUid").entry().query(); + * const query = stack.contentType("contentTypeUid").entry().query(); */ query(queryObj?: { [key: string]: any }) { if (queryObj) return new Query(this._client, this._parameters, this._queryParams, this._variants, this._contentTypeUid, queryObj); diff --git a/src/lib/entry.ts b/src/lib/entry.ts index d74fd798..c41435df 100644 --- a/src/lib/entry.ts +++ b/src/lib/entry.ts @@ -100,7 +100,7 @@ export class Entry { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType("contentTypeUid").entry(entry_uid).includeReference("brand").fetch() + * const result = await stack.contentType("contentTypeUid").entry(entry_uid).includeReference("brand").fetch() * * @param {string} referenceFieldUid - UID of the reference field to include. * @returns {Entry} - Returns the Entry instance for chaining. diff --git a/src/lib/query.ts b/src/lib/query.ts index e731ffd1..eff5a1c4 100644 --- a/src/lib/query.ts +++ b/src/lib/query.ts @@ -57,7 +57,7 @@ export class Query extends BaseQuery { * const query = stack.contentType("contentTypeUid").entry().query(); * const result = await query.where("field_UID", QueryOperation.IS_LESS_THAN, ["field1", "field2"]).find() * // OR - * const asset = await stack.asset().where("field_UID", QueryOperation.IS_LESS_THAN, ["field1", "field2"]).find() + * const asset = await stack.asset().query().where("field_UID", QueryOperation.IS_LESS_THAN, ["field1", "field2"]).find() * @example * import contentstack from '@contentstack/delivery-sdk' * @@ -128,7 +128,7 @@ export class Query extends BaseQuery { * const query = stack.contentType("contentTypeUid").entry().query(); * const subQuery = stack.contentType("referencedContentTypeUid").entry().query().where("title", QueryOperation.EQUALS, "value"); * query.whereIn("brand", subQuery) - * const res = await query.find() + * const result = await query.find() * * @param {string} referenceUid - UID of the reference field to query. * @param {Query} queryInstance - The Query instance to include in the where clause. @@ -156,7 +156,7 @@ export class Query extends BaseQuery { * const query = stack.contentType("contentTypeUid").entry().query(); * const subQuery = stack.contentType("referencedContentTypeUid").entry().query().where("title", QueryOperation.EQUALS, "value"); * query.whereNotIn("brand", subQuery) - * const res = await query.find() + * const result = await query.find() * * @param {string} referenceUid - UID of the reference field to query. * @param {Query} queryInstance - The Query instance to include in the where clause. @@ -184,7 +184,7 @@ export class Query extends BaseQuery { * const subQuery1 = stack.contentType("contentType2Uid").entry().query().where("price", QueryOperation.IS_LESS_THAN, 90); * const subQuery2 = stack.contentType("contentType3Uid").entry().query().where("discount", QueryOperation.INCLUDES, [20, 45]); * query.queryOperator(QueryOperator.AND, subQuery1, subQuery2) - * const res = await query.find() + * const result = await query.find() * * @param {QueryOperator} queryType - The type of query operator to apply. * @param {...Query[]} queryObjects - The Query instances to apply the query to. @@ -214,7 +214,7 @@ export class Query extends BaseQuery { * const assetQuery = stack.asset().query(); * const assetResult = assetQuery.getQuery() * - * @returns {Query} + * @returns {{ [key: string]: any }} The raw query object */ getQuery(): { [key: string]: any } { return this._parameters; @@ -333,7 +333,7 @@ export class Query extends BaseQuery { * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query1 = stack.contentType('contenttype_uid').entry().query().containedIn('fieldUID', ['value']); * const query2 = stack.contentType('contenttype_uid').entry().query().where('fieldUID', QueryOperation.EQUALS, 'value2'); - * const query = await stack.contentType('contenttype_uid').entry().query().or(query1, query2).find(); + * const result = await stack.contentType('contenttype_uid').entry().query().or(query1, query2).find(); * * @returns {Query} */ @@ -357,7 +357,7 @@ export class Query extends BaseQuery { * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); * const query1 = stack.contentType('contenttype_uid').entry().query().containedIn('fieldUID', ['value']); * const query2 = stack.contentType('contenttype_uid').entry().query().where('fieldUID', QueryOperation.EQUALS, 'value2'); - * const query = await stack.contentType('contenttype_uid').entry().query().and(query1, query2).find(); + * const result = await stack.contentType('contenttype_uid').entry().query().and(query1, query2).find(); * * @returns {Query} */ @@ -380,7 +380,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = await stack.contentType('contenttype_uid').entry().query().equalTo('fieldUid', 'value').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().equalTo('fieldUid', 'value').find(); * * @returns {Query} */ @@ -407,7 +407,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = await stack.contentType('contenttype_uid').entry().query().notEqualTo('fieldUid', 'value').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().notEqualTo('fieldUid', 'value').find(); * * @returns {Query} */ @@ -434,8 +434,8 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().referenceIn('reference_uid', query).find(); + * const subQuery = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const result = await stack.contentType('contenttype_uid').entry().query().referenceIn('reference_uid', subQuery).find(); * * @returns {Query} */ @@ -458,8 +458,8 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().referenceNotIn('reference_uid', query).find(); + * const subQuery = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); + * const result = await stack.contentType('contenttype_uid').entry().query().referenceNotIn('reference_uid', subQuery).find(); * * @returns {Query} */ @@ -481,8 +481,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().tags(['tag1']).find(); + * const result = await stack.contentType('contenttype_uid').entry().query().tags(['tag1']).find(); * * @returns {Query} */ @@ -504,8 +503,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().search('key').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().search('key').find(); * * @returns {Query} */ @@ -528,8 +526,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().lessThan('fieldUid', 'value').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().lessThan('fieldUid', 100).find(); * * @returns {Query} */ @@ -557,8 +554,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().lessThanOrEqualTo('fieldUid', 'value').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().lessThanOrEqualTo('fieldUid', 100).find(); * * @returns {Query} */ @@ -585,8 +581,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().greaterThan('fieldUid', 'value').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().greaterThan('fieldUid', 100).find(); * * @returns {Query} */ @@ -613,8 +608,7 @@ export class Query extends BaseQuery { * import contentstack from '@contentstack/delivery-sdk' * * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" }); - * const query = stack.contentType('contenttype_uid').entry().query().where('title', QueryOperation.EQUALS, 'value'); - * const entryQuery = await stack.contentType('contenttype_uid').entry().query().greaterThanOrEqualTo('fieldUid', 'value').find(); + * const result = await stack.contentType('contenttype_uid').entry().query().greaterThanOrEqualTo('fieldUid', 100).find(); * * @returns {Query} */ diff --git a/src/lib/stack.ts b/src/lib/stack.ts index f36046ff..781f40de 100644 --- a/src/lib/stack.ts +++ b/src/lib/stack.ts @@ -246,7 +246,7 @@ export class Stack { * @method setDebug * @memberof Stack * @description Sets the debug option - * @param {Number} debug - Debug value + * @param {boolean} debug - Debug value * @return {Stack} * @instance * */ @@ -257,7 +257,7 @@ export class Stack { /** * @method setHost - * @memberOf Stack + * @memberof Stack * @description Sets the host based on cloud region * @param {String} cloudRegion - Cloud region (e.g., 'aws_na', 'aws_eu') * @param {String} host - Optional custom host