Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for pagination, GCP support and package bump #113

Merged
merged 9 commits into from
Jan 18, 2024
1,357 changes: 374 additions & 983 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"build:types": "node tools/cleanup types && tsc -p config/tsconfig.types.json"
},
"dependencies": {
"@contentstack/core": "file:contentstack-core-0.0.1.tgz",
"@contentstack/utils": "^1.1.3",
"@types/humps": "^2.0.2",
"@contentstack/core": "^1.0.0",
"@contentstack/utils": "^1.3.1",
"@types/humps": "^2.0.6",
"dotenv": "^16.3.1",
"humps": "^2.0.1"
},
Expand All @@ -31,16 +31,16 @@
"README.md"
],
"devDependencies": {
"@nrwl/jest": "^16.8.1",
"@types/jest": "^29.5.5",
"axios-mock-adapter": "^1.21.2",
"@nrwl/jest": "^17.2.8",
"@types/jest": "^29.5.11",
"axios-mock-adapter": "^1.22.0",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-html-reporters": "^3.1.4",
"jest-html-reporters": "^3.1.7",
"jest-junit": "^16.0.0",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.4",
"ts-node": "10.9.1"
"ts-loader": "^9.5.1",
"ts-node": "10.9.2"
}
}
14 changes: 7 additions & 7 deletions src/lib/asset-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class AssetQuery extends BaseQuery {
* @description Retrieve a specific version of an asset in result
* @returns {AssetQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().version(1).find();
Expand All @@ -30,7 +30,7 @@ export class AssetQuery extends BaseQuery {
* @description Includes the dimensions (height and width) of the image in result
* @returns {AssetQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().includeDimension().find();
Expand All @@ -47,7 +47,7 @@ export class AssetQuery extends BaseQuery {
* @description Includes the branch in result
* @returns {AssetQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().includeBranch().find();
Expand All @@ -64,7 +64,7 @@ export class AssetQuery extends BaseQuery {
* @description Include the metadata for getting metadata content for the entry.
* @returns {Entries}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().includeMetadata().fetch();
Expand All @@ -81,7 +81,7 @@ export class AssetQuery extends BaseQuery {
* @description Includes the relative URLs of the assets in result
* @returns {AssetQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().relativeUrls().find();
Expand All @@ -98,7 +98,7 @@ export class AssetQuery extends BaseQuery {
* @description When an entry is not published in a specific language, content can be fetched from its fallback language
* @returns {AssetQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().includeFallback().find();
Expand All @@ -115,7 +115,7 @@ export class AssetQuery extends BaseQuery {
* @description The assets published in the locale will be fetched
* @returns {AssetQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().locale('en-us').find();
Expand Down
16 changes: 8 additions & 8 deletions src/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Asset {
* @description When an entry is not published in a specific language, content can be fetched from its fallback language
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').includeFallback().fetch();
Expand All @@ -36,7 +36,7 @@ export class Asset {
* @description Include the metadata for getting metadata content for the entry.
* @returns {Entries}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').includeMetadata().fetch();
Expand All @@ -53,7 +53,7 @@ export class Asset {
* @description Includes the dimensions (height and width) of the image in result
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').includeDimension().fetch();
Expand All @@ -70,7 +70,7 @@ export class Asset {
* @description Includes the branch in result
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').includeBranch().fetch();
Expand All @@ -87,7 +87,7 @@ export class Asset {
* @description Includes the relative URLs of the asset in result
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').relativeUrls().fetch();
Expand All @@ -104,7 +104,7 @@ export class Asset {
* @description Retrieve a specific version of an asset in result
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').version(1).fetch();
Expand All @@ -121,7 +121,7 @@ export class Asset {
* @description The assets published in the locale will be fetched
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').locale('en-us').fetch();
Expand All @@ -138,7 +138,7 @@ export class Asset {
* @description Fetches the asset data on the basis of the asset uid
* @returns {Asset}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset('asset_uid').fetch();
Expand Down
62 changes: 53 additions & 9 deletions src/lib/base-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class BaseQuery extends Pagination {
* @memberof BaseQuery
* @description Retrieve count and data of objects in result
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
Expand All @@ -32,7 +32,7 @@ export class BaseQuery extends Pagination {
* @memberof BaseQuery
* @description Sorts the results in ascending order based on the specified field UID.
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
Expand All @@ -53,7 +53,7 @@ export class BaseQuery extends Pagination {
* @memberof BaseQuery
* @description Sorts the results in descending order based on the specified key.
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
Expand All @@ -69,12 +69,56 @@ export class BaseQuery extends Pagination {
return this;
}

/**
* @method limit
* @memberof BaseQuery
* @description Returns a specific number of entries based on the set limit
* @example
* import contentstack from '@contentstack/delivery'
*
* 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()
* // OR
* const asset = await stack.asset().limit(5).find()
*
* @returns {BaseQuery}
*/
limit(key: number): BaseQuery {
this._queryParams.limit = key;

return this;
}

/**
* @method skip
* @memberof BaseQuery
* @description Skips at specific number of entries.
* @example
* import contentstack from '@contentstack/delivery'
*
* 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()
* // OR
* const asset = await stack.asset().skip(5).find()
*
* @returns {BaseQuery}
*/
skip(key: number): BaseQuery {
this._queryParams.skip = key;

return this;
}



/**
* @method param
* @memberof BaseQuery
* @description Adds query parameters to the URL.
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
Expand All @@ -95,7 +139,7 @@ export class BaseQuery extends Pagination {
* @memberof BaseQuery
* @description Adds a query parameter to the query.
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
Expand All @@ -116,7 +160,7 @@ export class BaseQuery extends Pagination {
* @memberof BaseQuery
* @description Removes a query parameter from the query.
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
Expand All @@ -138,17 +182,17 @@ export class BaseQuery extends Pagination {
* @description The assets of the stack will be fetched
* @returns {Collection}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset().find();
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.contentType("contentType1Uid").entry().query().find();
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.asset(asset_uid).fetch();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/content-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ContentType {
* @description Creates entry object of the passed entry uid.
* @returns {Entry}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const entry = stack.contentType("contentTypeUid").entry("entryUid");
Expand All @@ -43,7 +43,7 @@ export class ContentType {
* @description Fetches the contentType data on the basis of the contentType uid
* @returns {ContentType}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.contentType(asset_uid).fetch();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/contentstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export * as Utils from '@contentstack/utils';
* @param {StackConfig} config - config object for stack with apiKey, deliveryToken and environment as required fields
*
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
* const stack = contentstack.Stack({
* apiKey: "apiKey",
* deliveryToken: "deliveryToken",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/contenttype-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ContentTypeQuery {
* @description The assets published in the locale will be fetched
* @returns {ContentTypeQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const contentTypeQuery = stack.contentType();
Expand All @@ -32,7 +32,7 @@ export class ContentTypeQuery {
* @description Fetches all contentTypes of the stack
* @returns {ContentTypeQuery}
* @example
* import contentstack from '@contentstack/typescript'
* import contentstack from '@contentstack/delivery'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const contentTypeQuery = stack.contentType();
Expand Down
Loading
Loading