@e22m4u/js-repository 0.6.4 → 0.6.5

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.
@@ -205,19 +205,6 @@ var init_get_ctor_name = __esm({
205
205
  }
206
206
  });
207
207
 
208
- // src/utils/is-pure-object.js
209
- function isPureObject(value) {
210
- return Boolean(
211
- typeof value === "object" && value && !Array.isArray(value) && (!value.constructor || value.constructor && value.constructor.name === "Object")
212
- );
213
- }
214
- var init_is_pure_object = __esm({
215
- "src/utils/is-pure-object.js"() {
216
- "use strict";
217
- __name(isPureObject, "isPureObject");
218
- }
219
- });
220
-
221
208
  // src/errors/not-implemented-error.js
222
209
  var import_js_format, _NotImplementedError, NotImplementedError;
223
210
  var init_not_implemented_error = __esm({
@@ -325,6 +312,19 @@ var init_like_to_regexp = __esm({
325
312
  }
326
313
  });
327
314
 
315
+ // src/utils/is-plain-object.js
316
+ function isPlainObject(value) {
317
+ return Boolean(
318
+ typeof value === "object" && value && !Array.isArray(value) && (!value.constructor || value.constructor && value.constructor.name === "Object")
319
+ );
320
+ }
321
+ var init_is_plain_object = __esm({
322
+ "src/utils/is-plain-object.js"() {
323
+ "use strict";
324
+ __name(isPlainObject, "isPlainObject");
325
+ }
326
+ });
327
+
328
328
  // src/utils/string-to-regexp.js
329
329
  function stringToRegexp(pattern, flags = void 0) {
330
330
  if (pattern instanceof RegExp) {
@@ -497,8 +497,8 @@ var init_utils = __esm({
497
497
  init_singularize();
498
498
  init_is_deep_equal();
499
499
  init_get_ctor_name();
500
- init_is_pure_object();
501
500
  init_like_to_regexp();
501
+ init_is_plain_object();
502
502
  init_string_to_regexp();
503
503
  init_get_value_by_path();
504
504
  init_transform_promise();
@@ -1242,7 +1242,7 @@ var init_where_clause_tool = __esm({
1242
1242
  }
1243
1243
  return false;
1244
1244
  }
1245
- if (isPureObject(example)) {
1245
+ if (isPlainObject(example)) {
1246
1246
  const operatorsTest = this.getService(OperatorClauseTool).testAll(
1247
1247
  example,
1248
1248
  value
@@ -2633,7 +2633,7 @@ var init_property_uniqueness_validator = __esm({
2633
2633
  'The parameter "modelName" of the PropertyUniquenessValidator must be a non-empty String, but %v was given.',
2634
2634
  modelName
2635
2635
  );
2636
- if (!isPureObject(modelData))
2636
+ if (!isPlainObject(modelData))
2637
2637
  throw new InvalidArgumentError(
2638
2638
  "The data of the model %v should be an Object, but %v was given.",
2639
2639
  modelName,
@@ -3130,7 +3130,7 @@ var init_model_data_validator = __esm({
3130
3130
  * @returns {undefined}
3131
3131
  */
3132
3132
  validate(modelName, modelData, isPartial = false) {
3133
- if (!isPureObject(modelData))
3133
+ if (!isPlainObject(modelData))
3134
3134
  throw new InvalidArgumentError(
3135
3135
  "The data of the model %v should be an Object, but %v was given.",
3136
3136
  modelName,
@@ -3248,7 +3248,7 @@ var init_model_data_validator = __esm({
3248
3248
  break;
3249
3249
  // OBJECT
3250
3250
  case DataType.OBJECT: {
3251
- if (!isPureObject(propValue)) throw createError("an Object");
3251
+ if (!isPlainObject(propValue)) throw createError("an Object");
3252
3252
  if (typeof propDef === "object") {
3253
3253
  const modelOptionField = isArrayValue ? "itemModel" : "model";
3254
3254
  const modelOptionValue = propDef[modelOptionField];
@@ -3420,7 +3420,7 @@ var init_model_data_transformer = __esm({
3420
3420
  * @returns {object|Promise<object>}
3421
3421
  */
3422
3422
  transform(modelName, modelData, isPartial = false) {
3423
- if (!isPureObject(modelData))
3423
+ if (!isPlainObject(modelData))
3424
3424
  throw new InvalidArgumentError(
3425
3425
  "The data of the model %v should be an Object, but %v was given.",
3426
3426
  modelName,
@@ -6483,8 +6483,8 @@ __export(index_exports, {
6483
6483
  getValueByPath: () => getValueByPath,
6484
6484
  isCtor: () => isCtor,
6485
6485
  isDeepEqual: () => isDeepEqual,
6486
+ isPlainObject: () => isPlainObject,
6486
6487
  isPromise: () => isPromise,
6487
- isPureObject: () => isPureObject,
6488
6488
  likeToRegexp: () => likeToRegexp,
6489
6489
  modelNameToModelKey: () => modelNameToModelKey,
6490
6490
  selectObjectKeys: () => selectObjectKeys,
@@ -6589,8 +6589,8 @@ init_repository2();
6589
6589
  getValueByPath,
6590
6590
  isCtor,
6591
6591
  isDeepEqual,
6592
+ isPlainObject,
6592
6593
  isPromise,
6593
- isPureObject,
6594
6594
  likeToRegexp,
6595
6595
  modelNameToModelKey,
6596
6596
  selectObjectKeys,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/js-repository",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Реализация репозитория для работы с базами данных",
5
5
  "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@e22m4u/js-empty-values": "~0.1.3",
43
43
  "@e22m4u/js-format": "~0.2.1",
44
- "@e22m4u/js-service": "~0.4.5"
44
+ "@e22m4u/js-service": "~0.4.6"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@commitlint/cli": "~20.1.0",
@@ -51,14 +51,14 @@
51
51
  "@types/chai-spies": "~1.0.6",
52
52
  "@types/mocha": "~10.0.10",
53
53
  "c8": "~10.1.3",
54
- "chai": "~6.2.0",
54
+ "chai": "~6.2.1",
55
55
  "chai-as-promised": "~8.0.2",
56
56
  "chai-spies": "~1.1.0",
57
- "esbuild": "~0.25.12",
57
+ "esbuild": "~0.27.0",
58
58
  "eslint": "~9.39.1",
59
59
  "eslint-config-prettier": "~10.1.8",
60
60
  "eslint-plugin-chai-expect": "~3.1.0",
61
- "eslint-plugin-jsdoc": "~61.1.12",
61
+ "eslint-plugin-jsdoc": "~61.2.1",
62
62
  "eslint-plugin-mocha": "~11.2.0",
63
63
  "husky": "~9.1.7",
64
64
  "mocha": "~11.7.5",
@@ -66,6 +66,6 @@
66
66
  "rimraf": "~6.1.0",
67
67
  "ts-node": "~10.9.2",
68
68
  "typescript": "~5.9.3",
69
- "typescript-eslint": "~8.46.3"
69
+ "typescript-eslint": "~8.46.4"
70
70
  }
71
71
  }
@@ -1,6 +1,6 @@
1
1
  import {Service} from '@e22m4u/js-service';
2
2
  import {cloneDeep} from '../../utils/index.js';
3
- import {isPureObject} from '../../utils/index.js';
3
+ import {isPlainObject} from '../../utils/index.js';
4
4
  import {transformPromise} from '../../utils/index.js';
5
5
  import {EmptyValuesService} from '@e22m4u/js-empty-values';
6
6
  import {InvalidArgumentError} from '../../errors/index.js';
@@ -20,7 +20,7 @@ export class ModelDataTransformer extends Service {
20
20
  * @returns {object|Promise<object>}
21
21
  */
22
22
  transform(modelName, modelData, isPartial = false) {
23
- if (!isPureObject(modelData))
23
+ if (!isPlainObject(modelData))
24
24
  throw new InvalidArgumentError(
25
25
  'The data of the model %v should be an Object, but %v was given.',
26
26
  modelName,
@@ -1,7 +1,7 @@
1
1
  import {Service} from '@e22m4u/js-service';
2
2
  import {DataType} from './properties/index.js';
3
3
  import {getCtorName} from '../../utils/index.js';
4
- import {isPureObject} from '../../utils/index.js';
4
+ import {isPlainObject} from '../../utils/index.js';
5
5
  import {EmptyValuesService} from '@e22m4u/js-empty-values';
6
6
  import {InvalidArgumentError} from '../../errors/index.js';
7
7
  import {PropertyValidatorRegistry} from './properties/index.js';
@@ -20,7 +20,7 @@ export class ModelDataValidator extends Service {
20
20
  * @returns {undefined}
21
21
  */
22
22
  validate(modelName, modelData, isPartial = false) {
23
- if (!isPureObject(modelData))
23
+ if (!isPlainObject(modelData))
24
24
  throw new InvalidArgumentError(
25
25
  'The data of the model %v should be an Object, but %v was given.',
26
26
  modelName,
@@ -157,7 +157,7 @@ export class ModelDataValidator extends Service {
157
157
  break;
158
158
  // OBJECT
159
159
  case DataType.OBJECT: {
160
- if (!isPureObject(propValue)) throw createError('an Object');
160
+ if (!isPlainObject(propValue)) throw createError('an Object');
161
161
  if (typeof propDef === 'object') {
162
162
  const modelOptionField = isArrayValue ? 'itemModel' : 'model';
163
163
  const modelOptionValue = propDef[modelOptionField];
@@ -1,6 +1,6 @@
1
1
  import {DataType} from './data-type.js';
2
2
  import {Service} from '@e22m4u/js-service';
3
- import {isPureObject} from '../../../utils/index.js';
3
+ import {isPlainObject} from '../../../utils/index.js';
4
4
  import {EmptyValuesService} from '@e22m4u/js-empty-values';
5
5
  import {PropertyUniqueness} from './property-uniqueness.js';
6
6
  import {InvalidArgumentError} from '../../../errors/index.js';
@@ -45,7 +45,7 @@ export class PropertyUniquenessValidator extends Service {
45
45
  'must be a non-empty String, but %v was given.',
46
46
  modelName,
47
47
  );
48
- if (!isPureObject(modelData))
48
+ if (!isPlainObject(modelData))
49
49
  throw new InvalidArgumentError(
50
50
  'The data of the model %v should be an Object, but %v was given.',
51
51
  modelName,
@@ -47,10 +47,9 @@ export declare type ItemFilterClause<M extends object = ModelData> = Pick<
47
47
  * {or: [...]}
48
48
  * ```
49
49
  */
50
- export declare type WhereClause<M extends object = ModelData> = Partial<
51
- AndClause<M>
52
- > &
53
- Partial<OrClause<M>> &
50
+ export declare type WhereClause<M extends object = ModelData> =
51
+ Partial<AndClause<M>> |
52
+ Partial<OrClause<M>> |
54
53
  PropertiesClause<M>;
55
54
 
56
55
  /**
@@ -1,7 +1,7 @@
1
1
  import {Service} from '@e22m4u/js-service';
2
2
  import {InvalidArgumentError} from '../errors/index.js';
3
3
  import {OperatorClauseTool} from './operator-clause-tool.js';
4
- import {getValueByPath, isDeepEqual, isPureObject} from '../utils/index.js';
4
+ import {getValueByPath, isDeepEqual, isPlainObject} from '../utils/index.js';
5
5
 
6
6
  /**
7
7
  * Where clause tool.
@@ -124,7 +124,7 @@ export class WhereClauseTool extends Service {
124
124
  return false;
125
125
  }
126
126
  // условием является простой объект
127
- if (isPureObject(example)) {
127
+ if (isPlainObject(example)) {
128
128
  const operatorsTest = this.getService(OperatorClauseTool).testAll(
129
129
  example,
130
130
  value,
@@ -5,8 +5,8 @@ export * from './clone-deep.js';
5
5
  export * from './singularize.js';
6
6
  export * from './is-deep-equal.js';
7
7
  export * from './get-ctor-name.js';
8
- export * from './is-pure-object.js';
9
8
  export * from './like-to-regexp.js';
9
+ export * from './is-plain-object.js';
10
10
  export * from './string-to-regexp.js';
11
11
  export * from './get-value-by-path.js';
12
12
  export * from './transform-promise.js';
@@ -5,8 +5,8 @@ export * from './clone-deep.js';
5
5
  export * from './singularize.js';
6
6
  export * from './is-deep-equal.js';
7
7
  export * from './get-ctor-name.js';
8
- export * from './is-pure-object.js';
9
8
  export * from './like-to-regexp.js';
9
+ export * from './is-plain-object.js';
10
10
  export * from './string-to-regexp.js';
11
11
  export * from './get-value-by-path.js';
12
12
  export * from './transform-promise.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Is plain object.
3
+ *
4
+ * @param value
5
+ */
6
+ export declare function isPlainObject(value: unknown): boolean;
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Is pure object.
2
+ * Is plain object.
3
3
  *
4
4
  * @param {*} value
5
5
  * @returns {boolean}
6
6
  */
7
- export function isPureObject(value) {
7
+ export function isPlainObject(value) {
8
8
  return Boolean(
9
9
  typeof value === 'object' &&
10
10
  value &&
@@ -0,0 +1,25 @@
1
+ import {expect} from 'chai';
2
+ import {isPlainObject} from './is-plain-object.js';
3
+
4
+ describe('isPlainObject', function () {
5
+ it('returns true if a pure object given', function () {
6
+ expect(isPlainObject({})).to.be.true;
7
+ expect(isPlainObject({key: 'val'})).to.be.true;
8
+ expect(isPlainObject(Object.create(null))).to.be.true;
9
+ });
10
+
11
+ it('returns false if a non-pure object given', function () {
12
+ expect(isPlainObject(new Date())).to.be.false;
13
+ expect(isPlainObject([])).to.be.false;
14
+ expect(isPlainObject(() => undefined)).to.be.false;
15
+ });
16
+
17
+ it('returns false if a non-object given', function () {
18
+ expect(isPlainObject('string')).to.be.false;
19
+ expect(isPlainObject(10)).to.be.false;
20
+ expect(isPlainObject(true)).to.be.false;
21
+ expect(isPlainObject(false)).to.be.false;
22
+ expect(isPlainObject(null)).to.be.false;
23
+ expect(isPlainObject(undefined)).to.be.false;
24
+ });
25
+ });
@@ -1,6 +0,0 @@
1
- /**
2
- * Is pure object.
3
- *
4
- * @param value
5
- */
6
- export declare function isPureObject(value: unknown): boolean;
@@ -1,25 +0,0 @@
1
- import {expect} from 'chai';
2
- import {isPureObject} from './is-pure-object.js';
3
-
4
- describe('isPureObject', function () {
5
- it('returns ture if a pure object given', function () {
6
- expect(isPureObject({})).to.be.true;
7
- expect(isPureObject({key: 'val'})).to.be.true;
8
- expect(isPureObject(Object.create(null))).to.be.true;
9
- });
10
-
11
- it('returns false if a non-pure object given', function () {
12
- expect(isPureObject(new Date())).to.be.false;
13
- expect(isPureObject([])).to.be.false;
14
- expect(isPureObject(() => undefined)).to.be.false;
15
- });
16
-
17
- it('returns false if a non-object given', function () {
18
- expect(isPureObject('string')).to.be.false;
19
- expect(isPureObject(10)).to.be.false;
20
- expect(isPureObject(true)).to.be.false;
21
- expect(isPureObject(false)).to.be.false;
22
- expect(isPureObject(null)).to.be.false;
23
- expect(isPureObject(undefined)).to.be.false;
24
- });
25
- });