@travetto/model-query 4.1.4 → 5.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 ArcSine Technologies
3
+ Copyright (c) 2023 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-query",
3
- "version": "4.1.4",
3
+ "version": "5.0.0-rc.0",
4
4
  "description": "Datastore abstraction for advanced query support.",
5
5
  "keywords": [
6
6
  "datastore",
@@ -27,12 +27,12 @@
27
27
  "directory": "module/model-query"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/di": "^4.1.1",
31
- "@travetto/model": "^4.1.3",
32
- "@travetto/schema": "^4.1.1"
30
+ "@travetto/di": "^5.0.0-rc.0",
31
+ "@travetto/model": "^5.0.0-rc.0",
32
+ "@travetto/schema": "^5.0.0-rc.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@travetto/test": "^4.1.1"
35
+ "@travetto/test": "^5.0.0-rc.0"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@travetto/test": {
@@ -1,5 +1,5 @@
1
- import { SchemaRegistry, ValidationResultError, ValidationError } from '@travetto/schema';
2
- import { Class, ObjectUtil } from '@travetto/base';
1
+ import { DataUtil, SchemaRegistry, ValidationResultError, ValidationError } from '@travetto/schema';
2
+ import { Class } from '@travetto/base';
3
3
 
4
4
  import { ModelQuery, Query, PageableModelQuery } from '../../model/query';
5
5
 
@@ -120,7 +120,7 @@ export class QueryVerifier {
120
120
  }
121
121
  }
122
122
 
123
- if (!ObjectUtil.isPlainObject(value)) {
123
+ if (!DataUtil.isPlainObject(value)) {
124
124
  // Handle literal
125
125
  const actualType = TypeUtil.getActualType(value);
126
126
  if (!this.typesMatch(declaredType, actualType)) {
@@ -196,7 +196,7 @@ export class QueryVerifier {
196
196
  return true;
197
197
  }
198
198
  } else if (firstKey === '$not') {
199
- if (ObjectUtil.isPlainObject(sub)) {
199
+ if (DataUtil.isPlainObject(sub)) {
200
200
  this.processWhereClause(state, cls, sub);
201
201
  return true;
202
202
  } else {
@@ -19,9 +19,8 @@ export class ModelQueryUtil {
19
19
  * @returns
20
20
  */
21
21
  static resolveComparator(val: unknown): unknown {
22
- if (typeof val === 'string') {
23
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
24
- return TimeUtil.timeFromNow(val as '1m');
22
+ if (typeof val === 'string' && TimeUtil.isTimeSpan(val)) {
23
+ return TimeUtil.fromNow(val);
25
24
  } else {
26
25
  return val;
27
26
  }
@@ -1,4 +1,5 @@
1
- import { TimeSpan, Primitive } from '@travetto/base';
1
+ import { TimeSpan } from '@travetto/base';
2
+ import { Primitive } from '@travetto/schema';
2
3
 
3
4
  /**
4
5
  * Point as [number,number] with validation and binding support
@@ -254,7 +254,7 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
254
254
  async verifyDateRange() {
255
255
  const service = await this.service;
256
256
  await this.saveAll(Aged, (['-5d', '-4d', '-3d', '-2d', '-1d', '0d', '1d', '2d', '3d', '4d', '5d'] as const).map(delta =>
257
- Aged.from({ createdAt: TimeUtil.timeFromNow(delta) })
257
+ Aged.from({ createdAt: TimeUtil.fromNow(delta) })
258
258
  ));
259
259
 
260
260
  const simple = await service.queryCount(Aged, {
@@ -280,18 +280,18 @@ export abstract class ModelQuerySuite extends BaseModelSuite<ModelQuerySupport &
280
280
  const simple3 = await service.queryCount(Aged, {
281
281
  where: {
282
282
  createdAt: {
283
- $gt: '-1d',
284
- $lt: '3d'
283
+ $gt: '-.9d',
284
+ $lt: '2.9d'
285
285
  }
286
286
  }
287
287
  });
288
- assert(simple3 === 4);
288
+ assert(simple3 === 3);
289
289
 
290
290
  const simple4 = await service.queryCount(Aged, {
291
291
  where: {
292
292
  createdAt: {
293
- $gt: new Date(),
294
- $lt: TimeUtil.timeFromNow('3d')
293
+ $gt: TimeUtil.fromNow('-0.1d'),
294
+ $lt: TimeUtil.fromNow('2.9d')
295
295
  }
296
296
  }
297
297
  });