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

V4 beta/next #163

Merged
merged 19 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7e3205f
feat: referenceNotIn operator implementation
harshithad0703 Mar 14, 2024
81b37ef
feat: tags query operator implementation
harshithad0703 Mar 14, 2024
4e5b9bb
test: unit and api tests for tags and referenceNot In operators
harshithad0703 Mar 15, 2024
2d4d577
Merge pull request #159 referenceNotIn and tags query operator
harshithad0703 Mar 15, 2024
0259d2f
feat: search query operator implementation
harshithad0703 Mar 18, 2024
20e53f8
test: api and unit test cases for search operator
harshithad0703 Mar 18, 2024
3e6fa5d
chore: :package: upgraded contentstack utils package
harshithad0703 Mar 18, 2024
b879c3c
Merge pull request #161 from contentstack/feat/cs-43921-search-query-…
harshithad0703 Mar 18, 2024
27ef180
feat: exist query operator implementation
harshithad0703 Mar 19, 2024
17b4e2e
test: unit and api test cases
harshithad0703 Mar 19, 2024
74f92bd
Merge pull request #162 from contentstack/feat/cs-43902-exist-query
harshithad0703 Mar 19, 2024
cbd85a4
chore: version bump and changeLog update
harshithad0703 Mar 21, 2024
d9c3e62
Merge pull request #164 from contentstack/fix/cs-43904-version-bump
abhinav-from-contentstack Mar 21, 2024
a46561b
feat: compare query operators implementation
harshithad0703 Mar 22, 2024
d26614d
test: unit and api test cases for compare query operators
harshithad0703 Mar 22, 2024
2783ab7
Merge pull request #165 from contentstack/feat/cs-43905-less-than
harshithad0703 Mar 26, 2024
51df88e
chore: :package: axios package update to pass all checks
harshithad0703 Mar 26, 2024
6bdc743
Merge pull request #166 from contentstack/fix/package-version-snyk-ch…
harshithad0703 Mar 26, 2024
233f750
Merge branch 'release/v4-beta' into v4-beta/next
abhinav-from-contentstack Mar 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Change log

### Version: 4.0.0-beta.5
#### Date: March-26-2024
##### New Features:
- Query operators implementation-2

### Version: 4.0.0-beta.4
#### Date: March-14-2024
##### New Features:
Expand Down
47 changes: 24 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/delivery-sdk",
"version": "4.0.0-beta.4",
"version": "4.0.0-beta.5",
"type": "commonjs",
"main": "./dist/cjs/src/index.js",
"types": "./dist/types/src/index.d.ts",
Expand All @@ -24,8 +24,9 @@
},
"dependencies": {
"@contentstack/core": "^1.0.1",
"@contentstack/utils": "^1.3.1",
"@contentstack/utils": "^1.3.3",
"@types/humps": "^2.0.6",
"axios": "^1.6.8",
"dotenv": "^16.3.1",
"humps": "^2.0.1"
},
Expand Down
150 changes: 147 additions & 3 deletions src/lib/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ export class Query extends BaseQuery {
return this;
}

/**
* @method exists
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @example
* import contentstack from '@contentstack/delivery-sdk'
*
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const query = stack.contentType("contentTypeUid").entry().query();
* const result = await query.exists('fieldUid').find()
*
* @returns {Query}
*/
exists(key: string): Query {
this._parameters[key] = { '$exists': true };
return this;
}

/**
* @method notExists
* @memberof Query
Expand Down Expand Up @@ -291,12 +309,138 @@ export class Query extends BaseQuery {
*
* 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<TEntry>();
* const entryQuery = await stack.contentType('contenttype_uid').query().referenceIn('reference_uid', query).find();
*
* @returns {Query}
*/
referenceIn(key: string, query: Query) {
referenceIn(key: string, query: Query): Query {
this._parameters[key] = { '$in_query': query._parameters }
return this;
}
}

/**
* @method referenceNotIn
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
referenceNotIn(key: string, query: Query): Query {
this._parameters[key] = { '$nin_query': query._parameters }
return this;
}

/**
* @method tags
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
tags(values: (string | number | boolean)[]): Query {
this._parameters['tags'] = values;
return this;
}

/**
* @method search
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
search(key: string): Query {
this._queryParams['typeahead'] = key
return this
}

/**
* @method lessThan
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
lessThan(key: string, value: (string | number)): Query {
this._parameters[key] = { '$lt': value };
return this;
}

/**
* @method lessThanOrEqualTo
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
lessThanOrEqualTo(key: string, value: (string | number)): Query {
this._parameters[key] = { '$lte': value };
return this;
}

/**
* @method greaterThan
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
greaterThan(key: string, value: (string | number)): Query {
this._parameters[key] = { '$gt': value };
return this;
}

/**
* @method greaterThanOrEqualTo
* @memberof Query
* @description Returns the raw (JSON) query based on the filters applied on Query object.
* @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();
*
* @returns {Query}
*/
greaterThanOrEqualTo(key: string, value: (string | number)): Query {
this._parameters[key] = { '$gte': value };
return this;
}
}
Loading