Skip to content

Commit

Permalink
add support for string values
Browse files Browse the repository at this point in the history
  • Loading branch information
cfaur09 committed Feb 5, 2024
1 parent 0136aca commit 82ae52a
Show file tree
Hide file tree
Showing 15 changed files with 424 additions and 450 deletions.
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "3.1.4",
"version": "3.1.5",
"packages": [
"packages/*"
],
"npmClient": "npm"
}
}
801 changes: 375 additions & 426 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-auth",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs auth package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -46,4 +46,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-cache",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs cache package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -49,4 +49,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-common",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs common package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -49,4 +49,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/elastic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-elastic",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs elastic package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -37,4 +37,4 @@
"publishConfig": {
"access": "public"
}
}
}
10 changes: 9 additions & 1 deletion packages/elastic/src/entities/elastic.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { RangeGreaterThanOrEqual } from "./range.greater.than.or.equal";
import { RangeLowerThanOrEqual } from "./range.lower.than.or.equal";
import { RangeQuery } from "./range.query";
import { TermsQuery } from "./terms.query";
import { RangeDataType } from "./range.data.type.enum";

function buildElasticIndexerSort(sorts: ElasticSortProperty[]): any[] {
if (!sorts) {
Expand Down Expand Up @@ -148,7 +149,14 @@ export class ElasticQuery {
return this;
}

return this.withFilter(QueryType.Range(key, new RangeGreaterThanOrEqual(after ?? 0), new RangeLowerThanOrEqual(before ?? Date.now())));
const afterValue = after !== null && after !== void 0 ? after.toString() : '0';
const beforeValue = before !== null && before !== void 0 ? before.toString() : Math.floor(Date.now() / 1000).toString();

return this.withFilter(QueryType.Range(
key,
new RangeGreaterThanOrEqual(afterValue, RangeDataType.string),
new RangeLowerThanOrEqual(beforeValue, RangeDataType.string)
));
}

withFilter(filter: RangeQuery): ElasticQuery {
Expand Down
5 changes: 4 additions & 1 deletion packages/elastic/src/entities/query.range.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { RangeDataType } from "./range.data.type.enum";

export abstract class QueryRange {
constructor(
readonly key: string,
readonly value: number
readonly value: number,
readonly type: RangeDataType = RangeDataType.number
) { }
}
4 changes: 4 additions & 0 deletions packages/elastic/src/entities/range.data.type.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum RangeDataType {
string = 'string',
number = 'number'
}
9 changes: 7 additions & 2 deletions packages/elastic/src/entities/range.greater.than.or.equal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { QueryRange } from "./query.range";
import { RangeDataType } from "./range.data.type.enum";

export class RangeGreaterThanOrEqual extends QueryRange {
constructor(value: number) {
super('gte', value);
constructor(value: string | number, withType: RangeDataType = RangeDataType.number) {
if (withType === RangeDataType.string) {
value = value.toString();
}
const numericValue = typeof value === 'string' ? parseFloat(value) : value;
super('gte', numericValue, withType);
}
}
9 changes: 7 additions & 2 deletions packages/elastic/src/entities/range.lower.than.or.equal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { QueryRange } from "./query.range";
import { RangeDataType } from "./range.data.type.enum";

export class RangeLowerThanOrEqual extends QueryRange {
constructor(value: number) {
super('lte', value);
constructor(value: string | number, withType: RangeDataType = RangeDataType.number) {
if (withType === RangeDataType.string) {
value = value.toString();
}
const numericValue = typeof value === 'string' ? parseFloat(value) : value;
super('lte', numericValue, withType);
}
}
4 changes: 2 additions & 2 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-http",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs http package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -46,4 +46,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/monitoring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-monitoring",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs monitoring package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -41,4 +41,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/rabbitmq/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-rabbitmq",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs rabbitmq client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -43,4 +43,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/redis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-redis",
"version": "3.1.4",
"version": "3.1.5",
"description": "Multiversx SDK Nestjs redis client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -40,4 +40,4 @@
"publishConfig": {
"access": "public"
}
}
}

0 comments on commit 82ae52a

Please sign in to comment.