Skip to content

Commit a505458

Browse files
committed
Fixed the JSDoc Strings
1 parent 7d8dce1 commit a505458

20 files changed

+370
-165
lines changed

src/lib/asset-query.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ export class AssetQuery extends BaseQuery {
6161

6262
/**
6363
* @method includeMetadata
64-
* @memberof Entries
65-
* @description Include the metadata for getting metadata content for the entry.
66-
* @returns {Entries}
64+
* @memberof AssetQuery
65+
* @description Include the metadata for getting metadata content for the asset.
66+
* @returns {AssetQuery}
6767
* @example
6868
* import contentstack from '@contentstack/delivery-sdk'
6969
*
7070
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
71-
* const result = await stack.asset().includeMetadata().fetch();
71+
* const result = await stack.asset().includeMetadata().find();
7272
*/
7373
includeMetadata(): AssetQuery {
7474
this._queryParams.include_metadata = 'true';
@@ -128,7 +128,7 @@ export class AssetQuery extends BaseQuery {
128128
}
129129
/**
130130
* @method query
131-
* @memberof Query
131+
* @memberof AssetQuery
132132
* @description Fetches the asset data on the basis of the query
133133
* @returns {Query}
134134
* @example

src/lib/asset.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export class Asset {
2929

3030
/**
3131
* @method includeMetadata
32-
* @memberof Entries
33-
* @description Include the metadata for getting metadata content for the entry.
34-
* @returns {Entries}
32+
* @memberof Asset
33+
* @description Include the metadata for getting metadata content for the asset.
34+
* @returns {Asset}
3535
* @example
3636
* import contentstack from '@contentstack/delivery-sdk'
3737
*
@@ -115,7 +115,7 @@ export class Asset {
115115
/**
116116
* @method locale
117117
* @memberof Asset
118-
* @description The assets published in the locale will be fetched
118+
* @description The asset published in the locale will be fetched
119119
* @returns {Asset}
120120
* @example
121121
* import contentstack from '@contentstack/delivery-sdk'
@@ -133,7 +133,7 @@ export class Asset {
133133
* @method fetch
134134
* @memberof Asset
135135
* @description Fetches the asset data on the basis of the asset uid
136-
* @returns {Asset}
136+
* @returns {Promise<T>} Promise that resolves to the asset data
137137
* @example
138138
* import contentstack from '@contentstack/delivery-sdk'
139139
*

src/lib/base-query.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ export class BaseQuery extends Pagination {
191191

192192
/**
193193
* @method find
194-
* @memberof AssetQuery
195-
* @description The assets of the stack will be fetched
196-
* @returns {Collection}
194+
* @memberof BaseQuery
195+
* @description Fetches the data based on the query parameters
196+
* @param {boolean} encode - Whether to encode query parameters
197+
* @returns {Promise<FindResponse<T>>} Promise that resolves to the find response
197198
* @example
198199
* import contentstack from '@contentstack/delivery-sdk'
199200
*
@@ -208,7 +209,7 @@ export class BaseQuery extends Pagination {
208209
* import contentstack from '@contentstack/delivery-sdk'
209210
*
210211
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
211-
* const result = await stack.asset(asset_uid).fetch();
212+
* const result = await stack.contentType("contentTypeUid").entry().query().find();
212213
*/
213214

214215
async find<T>(encode: boolean = false): Promise<FindResponse<T>> {

src/lib/cache.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ function generateEnhancedCacheKey(originalKey: string, contentTypeUid?: string,
3939
return cacheKey;
4040
}
4141

42+
/**
43+
* Handles cache requests based on the cache policy
44+
* @param {CacheOptions} cacheOptions - Cache configuration options
45+
* @param {string} apiKey - API key for cache key generation
46+
* @param {Function} defaultAdapter - Default axios adapter function
47+
* @param {Function} resolve - Promise resolve function
48+
* @param {Function} reject - Promise reject function
49+
* @param {object} config - Request configuration object
50+
* @returns {Promise} Resolves or rejects based on cache policy and API response
51+
*/
4252
export async function handleRequest(
4353
cacheOptions: CacheOptions,
4454
apiKey: string,

src/lib/content-type.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ export class ContentType {
2121
/**
2222
* @method entry
2323
* @memberof ContentType
24-
* @description Creates entry object of the passed entry uid.
25-
* @returns {Entry}
24+
* @description Creates entry object of the passed entry uid, or entries query object if no uid is provided.
25+
* @param {string} [uid] - Optional entry UID. If provided, returns a single Entry instance. If omitted, returns Entries query object.
26+
* @returns {Entry | Entries} Entry instance if uid is provided, otherwise Entries query object
2627
* @example
2728
* import contentstack from '@contentstack/delivery-sdk'
2829
*
2930
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
3031
* const entry = stack.contentType("contentTypeUid").entry("entryUid");
32+
* // OR
33+
* const entries = stack.contentType("contentTypeUid").entry();
3134
*/
3235
entry(uid: string): Entry;
3336
entry(): Entries;
@@ -41,7 +44,7 @@ export class ContentType {
4144
* @method fetch
4245
* @memberof ContentType
4346
* @description Fetches the contentType data on the basis of the contentType uid
44-
* @returns {ContentType}
47+
* @returns {Promise<T>} Promise that resolves to the content type data
4548
* @example
4649
* import contentstack from '@contentstack/delivery-sdk'
4750
*

src/lib/contentstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let version = '{{VERSION}}';
1414
* @memberof Contentstack
1515
* @description Creates a stack instance
1616
* @param {StackConfig} config - config object for stack with apiKey, deliveryToken and environment as required fields
17-
*
17+
* @returns {StackClass} Stack instance
1818
* @example
1919
* import contentstack from '@contentstack/delivery-sdk'
2020
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });

src/lib/contenttype-query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ContentTypeQuery {
1313
/**
1414
* @method includeGlobalFieldSchema
1515
* @memberof ContentTypeQuery
16-
* @description The assets published in the locale will be fetched
16+
* @description Includes the global field schema in the content type response
1717
* @returns {ContentTypeQuery}
1818
* @example
1919
* import contentstack from '@contentstack/delivery-sdk'
@@ -31,7 +31,7 @@ export class ContentTypeQuery {
3131
* @method find
3232
* @memberof ContentTypeQuery
3333
* @description Fetches all contentTypes of the stack
34-
* @returns {ContentTypeQuery}
34+
* @returns {Promise<FindResponse<T>>} Promise that resolves to the find response containing content types
3535
* @example
3636
* import contentstack from '@contentstack/delivery-sdk'
3737
*

src/lib/entries.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ export class Entries extends BaseQuery {
6262
/**
6363
* @method includeContentType
6464
* @memberof Entries
65-
* @description IInclude the details of the content type along with the entries details
65+
* @description Include the details of the content type along with the entries details
6666
* @returns {Entries}
6767
* @example
6868
* import contentstack from '@contentstack/delivery-sdk'
6969
*
7070
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
71-
* const result = await stack.contentType(contentType_uid).entry().includeContentType().fetch();
71+
* const result = await stack.contentType(contentType_uid).entry().includeContentType().find();
7272
*/
7373
includeContentType(): Entries {
7474
this._queryParams.include_content_type = 'true';
@@ -85,7 +85,7 @@ export class Entries extends BaseQuery {
8585
* import contentstack from '@contentstack/delivery-sdk'
8686
*
8787
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
88-
* const result = await stack.contentType(contentType_uid).entry().includeEmbeddedItems().fetch();
88+
* const result = await stack.contentType(contentType_uid).entry().includeEmbeddedItems().find();
8989
*/
9090
includeEmbeddedItems(): Entries {
9191
this._queryParams['include_embedded_items[]'] = 'BASE';
@@ -134,7 +134,9 @@ export class Entries extends BaseQuery {
134134
* you need to use the include[] parameter and specify the UID of the reference field as value.
135135
* This function sets the include parameter to a reference field UID in the API request.
136136
* @example
137-
* const stack = contentstack.stack("apiKey", "deliveryKey", "environment");
137+
* import contentstack from '@contentstack/delivery-sdk'
138+
*
139+
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
138140
* const query = stack.contentType("contentTypeUid").entry().includeReference("brand")
139141
* const res = await query.find()
140142
*
@@ -160,7 +162,9 @@ export class Entries extends BaseQuery {
160162
* @memberof Entries
161163
* @description This method also includes the content type UIDs of the referenced entries returned in the response.
162164
* @example
163-
* const stack = contentstack.stack("apiKey", "deliveryKey", "environment");
165+
* import contentstack from '@contentstack/delivery-sdk'
166+
*
167+
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
164168
* const query = stack.contentType("contentTypeUid").entry().includeReferenceContentTypeUID()
165169
* const res = await query.find()
166170
*
@@ -175,9 +179,11 @@ export class Entries extends BaseQuery {
175179
/**
176180
* @method includeSchema
177181
* @memberof Entries
178-
* @description This method also includes the content type UIDs of the referenced entries returned in the response.
182+
* @description Includes the schema of the content type along with the entries details.
179183
* @example
180-
* const stack = contentstack.stack("apiKey", "deliveryKey", "environment");
184+
* import contentstack from '@contentstack/delivery-sdk'
185+
*
186+
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
181187
* const query = stack.contentType("contentTypeUid").entry().includeSchema()
182188
* const res = await query.find()
183189
*
@@ -191,9 +197,9 @@ export class Entries extends BaseQuery {
191197

192198
/**
193199
* @method locale
194-
* @memberof Entry
195-
* @description The assets published in the locale will be fetched
196-
* @returns {Entry}
200+
* @memberof Entries
201+
* @description The entries published in the locale will be fetched
202+
* @returns {Entries}
197203
* @example
198204
* import contentstack from '@contentstack/delivery-sdk'
199205
*
@@ -235,8 +241,9 @@ export class Entries extends BaseQuery {
235241
/**
236242
* @method query
237243
* @memberof Entries
238-
* @description Fetches the Entry data on the basis of the asset uid
239-
* @returns {Collection}
244+
* @description Creates a query object for filtering entries
245+
* @param {object} queryObj - Optional query object to initialize the query
246+
* @returns {Query} Query instance for chaining query methods
240247
* @example
241248
* import contentstack from '@contentstack/delivery-sdk'
242249
*
@@ -251,9 +258,9 @@ export class Entries extends BaseQuery {
251258

252259
/**
253260
* @method variants
254-
* @memberof Entry
261+
* @memberof Entries
255262
* @description The variant header will be added to axios client
256-
* @returns {Entry}
263+
* @returns {Entries}
257264
* @example
258265
* import contentstack from '@contentstack/delivery-sdk'
259266
*

src/lib/entry.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ export class Entry {
9797
* you need to use the include[] parameter and specify the UID of the reference field as value.
9898
* This function sets the include parameter to a reference field UID in the API request.
9999
* @example
100-
* const stack = contentstack.stack("apiKey", "deliveryKey", "environment");
100+
* import contentstack from '@contentstack/delivery-sdk'
101+
*
102+
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
101103
* const query = stack.contentType("contentTypeUid").entry(entry_uid).includeReference("brand").fetch()
102104
*
103105
* @param {string} referenceFieldUid - UID of the reference field to include.
@@ -120,7 +122,7 @@ export class Entry {
120122
/**
121123
* @method includeContentType
122124
* @memberof Entry
123-
* @description IInclude the details of the content type along with the entries details
125+
* @description Include the details of the content type along with the entries details
124126
* @returns {Entry}
125127
* @example
126128
* import contentstack from '@contentstack/delivery-sdk'
@@ -154,13 +156,13 @@ export class Entry {
154156
/**
155157
* @method locale
156158
* @memberof Entry
157-
* @description The assets published in the locale will be fetched
159+
* @description The entry published in the locale will be fetched
158160
* @returns {Entry}
159161
* @example
160162
* import contentstack from '@contentstack/delivery-sdk'
161163
*
162164
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
163-
* const result = await stack.assetQuery().locale('en-us').fetch();
165+
* const result = await stack.contentType('contentTypeUid').entry('entryUid').locale('en-us').fetch();
164166
*/
165167
locale(locale: string): this {
166168
this._queryParams.locale = locale;
@@ -172,7 +174,7 @@ export class Entry {
172174
* @method fetch
173175
* @memberof Entry
174176
* @description Fetches the entry data on the basis of the entry uid
175-
* @returns {Collection}
177+
* @returns {Promise<T>} Promise that resolves to the entry data
176178
* @example
177179
* import contentstack from '@contentstack/delivery-sdk'
178180
*
@@ -208,7 +210,7 @@ export class Entry {
208210
* import contentstack from '@contentstack/delivery-sdk'
209211
*
210212
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
211-
* const result = stack.contentType("contentTypeUid").entry().addParams({"key": "value"}).fetch()
213+
* const result = await stack.contentType("contentTypeUid").entry("entryUid").addParams({"key": "value"}).fetch()
212214
*
213215
* @returns {Entry}
214216
*/
@@ -226,7 +228,7 @@ export class Entry {
226228
* import contentstack from '@contentstack/delivery-sdk'
227229
*
228230
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
229-
* const result = await stack.contentType("contentTypeUid").entry().except("fieldUID").find()
231+
* const result = await stack.contentType("contentTypeUid").entry("entryUid").except("fieldUID").fetch()
230232
*
231233
* @param {string} fieldUid - field uid to exclude
232234
* @returns {Entry} - returns Entry object for chaining method calls
@@ -253,7 +255,7 @@ export class Entry {
253255
* import contentstack from '@contentstack/delivery-sdk'
254256
*
255257
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
256-
* const result = await stack.contentType("contentTypeUid").entry().only("fieldUID").find()
258+
* const result = await stack.contentType("contentTypeUid").entry("entryUid").only("fieldUID").fetch()
257259
*
258260
* @param {string} fieldUid - field uid to select
259261
* @returns {Entry} - returns Entry object for chaining method calls

src/lib/global-field-query.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ export class GlobalFieldQuery extends BaseQuery {
1414
* @description Includes the _branch top-level key in the response
1515
* @returns {GlobalFieldQuery}
1616
* @example
17-
* const stack = contentstack.stack('apiKey','deliveryToken','environment');
17+
* import contentstack from '@contentstack/delivery-sdk'
18+
*
19+
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
1820
* const globalFields = stack.globalField();
19-
* const result = globalFields.includeBranch().find();
21+
* const result = await globalFields.includeBranch().find();
2022
*/
2123
includeBranch(): GlobalFieldQuery {
2224
this._queryParams.include_branch = 'true';

0 commit comments

Comments
 (0)