Browse Source

refactor: removes type definitions

e22m4u 4 days ago
parent
commit
50561bff46
100 changed files with 271 additions and 2956 deletions
  1. 2 3
      .mocharc.json
  2. 123 164
      README.md
  3. 8 114
      dist/cjs/index.cjs
  4. 29 58
      eslint.config.js
  5. 7 0
      jsconfig.json
  6. 10 18
      package.json
  7. 0 16
      src/adapter/adapter-loader.d.ts
  8. 3 4
      src/adapter/adapter-loader.js
  9. 0 14
      src/adapter/adapter-registry.d.ts
  10. 0 153
      src/adapter/adapter.d.ts
  11. 8 5
      src/adapter/adapter.js
  12. 10 9
      src/adapter/adapter.spec.js
  13. 0 148
      src/adapter/builtin/memory-adapter.d.ts
  14. 8 7
      src/adapter/builtin/memory-adapter.js
  15. 5 2
      src/adapter/builtin/memory-adapter.spec.js
  16. 0 14
      src/adapter/decorator/data-sanitizing-decorator.d.ts
  17. 0 14
      src/adapter/decorator/default-values-decorator.d.ts
  18. 1 2
      src/adapter/decorator/default-values-decorator.spec.js
  19. 0 14
      src/adapter/decorator/fields-filtering-decorator.d.ts
  20. 0 14
      src/adapter/decorator/inclusion-decorator.d.ts
  21. 0 5
      src/adapter/decorator/index.d.ts
  22. 0 14
      src/adapter/decorator/property-uniqueness-decorator.d.ts
  23. 0 3
      src/adapter/index.d.ts
  24. 0 37
      src/database-schema.d.ts
  25. 1 2
      src/database-schema.js
  26. 5 17
      src/database-schema.spec.js
  27. 0 14
      src/definition/datasource/datasource-definition-validator.d.ts
  28. 0 8
      src/definition/datasource/datasource-definition.d.ts
  29. 0 2
      src/definition/datasource/index.d.ts
  30. 0 50
      src/definition/definition-registry.d.ts
  31. 0 3
      src/definition/index.d.ts
  32. 0 6
      src/definition/model/index.d.ts
  33. 0 1
      src/definition/model/index.js
  34. 0 15
      src/definition/model/model-data-sanitizer.d.ts
  35. 0 180
      src/definition/model/model-definition-utils.d.ts
  36. 1 2
      src/definition/model/model-definition-utils.js
  37. 5 2
      src/definition/model/model-definition-utils.spec.js
  38. 0 14
      src/definition/model/model-definition-validator.d.ts
  39. 0 28
      src/definition/model/model-definition.d.ts
  40. 0 1
      src/definition/model/model-definition.js
  41. 0 16
      src/definition/model/properties/data-type.d.ts
  42. 0 6
      src/definition/model/properties/index.d.ts
  43. 0 1
      src/definition/model/properties/index.js
  44. 0 15
      src/definition/model/properties/primary-keys-definition-validator.d.ts
  45. 0 15
      src/definition/model/properties/properties-definition-validator.d.ts
  46. 0 23
      src/definition/model/properties/property-definition.d.ts
  47. 0 1
      src/definition/model/properties/property-definition.js
  48. 0 31
      src/definition/model/properties/property-uniqueness-validator.d.ts
  49. 0 14
      src/definition/model/properties/property-uniqueness.d.ts
  50. 0 3
      src/definition/model/relations/index.d.ts
  51. 0 1
      src/definition/model/relations/index.js
  52. 0 236
      src/definition/model/relations/relation-definition.d.ts
  53. 0 1
      src/definition/model/relations/relation-definition.js
  54. 0 14
      src/definition/model/relations/relation-type.d.ts
  55. 0 15
      src/definition/model/relations/relations-definition-validator.d.ts
  56. 4 5
      src/definition/model/relations/relations-definition-validator.js
  57. 0 3
      src/errors/index.d.ts
  58. 0 6
      src/errors/invalid-argument-error.d.ts
  59. 0 13
      src/errors/invalid-operator-value-error.d.ts
  60. 0 6
      src/errors/not-implemented-error.d.ts
  61. 0 38
      src/filter/fields-clause-tool.d.ts
  62. 0 348
      src/filter/filter-clause.d.ts
  63. 0 55
      src/filter/include-clause-tool.d.ts
  64. 8 6
      src/filter/include-clause-tool.js
  65. 0 7
      src/filter/index.d.ts
  66. 0 224
      src/filter/operator-clause-tool.d.ts
  67. 0 32
      src/filter/order-clause-tool.d.ts
  68. 0 30
      src/filter/slice-clause-tool.d.ts
  69. 0 23
      src/filter/where-clause-tool.d.ts
  70. 0 9
      src/index.d.ts
  71. 0 1
      src/index.js
  72. 0 46
      src/relations/belongs-to-resolver.d.ts
  73. 1 2
      src/relations/belongs-to-resolver.js
  74. 6 3
      src/relations/belongs-to-resolver.spec.js
  75. 0 67
      src/relations/has-many-resolver.d.ts
  76. 1 2
      src/relations/has-many-resolver.js
  77. 6 3
      src/relations/has-many-resolver.spec.js
  78. 0 67
      src/relations/has-one-resolver.d.ts
  79. 1 2
      src/relations/has-one-resolver.js
  80. 6 3
      src/relations/has-one-resolver.spec.js
  81. 0 4
      src/relations/index.d.ts
  82. 0 27
      src/relations/references-many-resolver.d.ts
  83. 1 2
      src/relations/references-many-resolver.js
  84. 6 3
      src/relations/references-many-resolver.spec.js
  85. 0 2
      src/repository/index.d.ts
  86. 0 29
      src/repository/repository-registry.d.ts
  87. 0 183
      src/repository/repository.d.ts
  88. 1 2
      src/repository/repository.js
  89. 0 43
      src/types.d.ts
  90. 0 1
      src/types.js
  91. 0 6
      src/utils/capitalize.d.ts
  92. 0 6
      src/utils/clone-deep.d.ts
  93. 0 10
      src/utils/exclude-object-keys.d.ts
  94. 0 12
      src/utils/get-value-by-path.d.ts
  95. 0 12
      src/utils/index.d.ts
  96. 0 10
      src/utils/is-deep-equal.d.ts
  97. 0 6
      src/utils/is-plain-object.d.ts
  98. 4 4
      src/utils/is-plain-object.js
  99. 0 10
      src/utils/is-promise.d.ts
  100. 0 14
      src/utils/like-to-regexp.d.ts

+ 2 - 3
.mocharc.json

@@ -1,5 +1,4 @@
 {
-  "extension": ["js", "ts"],
-  "spec": "src/**/*.spec.{js,ts}",
-  "require": ["ts-node/register"]
+  "extension": ["js"],
+  "spec": "src/**/*.spec.js"
 }

+ 123 - 164
README.md

@@ -40,7 +40,6 @@
   - [Has One (полиморфная)](#has-one-полиморфная-версия)
   - [Has Many (полиморфная)](#has-many-полиморфная-версия)
 - [Расширение](#расширение)
-- [TypeScript](#typescript)
 - [Тесты](#тесты)
 - [Лицензия](#лицензия)
 
@@ -82,10 +81,10 @@ const {DatabaseSchema} = require('@e22m4u/js-repository');
 Кроме того, *модель* может определять классические связи «один к одному»,
 «один ко многим» и другие типы отношений между моделями.
 
-Непосредственно чтение и запись данных производится с помощью *репозитория*,
+Непосредственно чтение и запись данных производятся с помощью *репозитория*,
 который есть у каждой модели с объявленным *источником данных*. Репозиторий
 может фильтровать запрашиваемые документы, выполнять валидацию свойств
-согласно определению модели, и встраивать связанные данные в результат
+согласно определению модели и встраивать связанные данные в результат
 выборки.
 
 - *Источник данных* - определяет способ подключения к базе
@@ -257,17 +256,36 @@ console.log(cityWithCountry);
 
 ## Схема
 
-Экземпляр класса `DatabaseSchema` хранит определения источников данных и моделей.
+Экземпляр класса `DatabaseSchema` хранит определения источников данных
+и моделей.
 
 **Методы**
 
-- `defineDatasource(datasourceDef: object): this` - добавить источник
-- `defineModel(modelDef: object): this` - добавить модель
-- `getRepository(modelName: string): Repository` - получить репозиторий
+Добавить источник
 
-**Примеры**
+- `defineDatasource(datasourceDef)`
+  - `datasourceDef: object`: определение источника;
+  - результат: `this`;
+
+Добавить модель:
+
+- `defineModel(modelDef)`
+  - `modelDef: object`: определение модели;
+  - результат: `this`;
+
+Получить репозиторий
+
+- `getRepository(modelName)`
+  - `modelName: string` имя модели;
+  - результат: `Repository`;
+
+**Пример**
 
-Импорт класса и создание экземпляра схемы.
+Ниже приводится пошаговый пример настройки модели `product` и получения
+экземпляра репозитория, с помощью которого можно управлять данными этой
+коллекции.
+
+1\. Импорт класса и создание экземпляра схемы.
 
 ```js
 import {DatabaseSchema} from '@e22m4u/js-repository';
@@ -275,7 +293,7 @@ import {DatabaseSchema} from '@e22m4u/js-repository';
 const dbs = new DatabaseSchema();
 ```
 
-Определение нового источника.
+2\. Определение нового источника.
 
 ```js
 dbs.defineDatasource({
@@ -284,7 +302,7 @@ dbs.defineDatasource({
 });
 ```
 
-Определение новой модели.
+3\. Определение новой модели.
 
 ```js
 dbs.defineModel({
@@ -297,7 +315,7 @@ dbs.defineModel({
 });
 ```
 
-Получение репозитория по названию модели.
+4\. Получение репозитория по названию модели.
 
 ```js
 const productRep = dbs.getRepository('product');
@@ -370,7 +388,7 @@ dbs.defineModel({
 ## Свойства
 
 Параметр `properties` находится в определении модели и принимает объект, ключи
-которого являются свойствами этой модели, а значением тип свойства или объект
+которого являются свойствами этой модели, а значениями тип свойства или объект
 с дополнительными параметрами.
 
 **Тип данных**
@@ -396,15 +414,16 @@ dbs.defineModel({
 
 **Параметр `unique`**
 
-Если значением параметра `unique` является `true` или `'strict'`, то выполняется
-строгая проверка на уникальность. В этом режиме [пустые значения](#Пустые-значения)
-так же подлежат проверке, где `null` и `undefined` также считаются значениями,
-которые должны быть уникальными.
+Если значением параметра `unique` является `true` или `'strict'`,
+то выполняется строгая проверка на уникальность. В этом режиме
+[пустые значения](#Пустые-значения) так же подлежат проверке,
+где `null` и `undefined` также считаются значениями, которые
+должны быть уникальными.
 
-Режим `'sparse'` проверяет только значения с полезной нагрузкой, исключая
-[пустые значения](#Пустые-значения), список которых отличается в зависимости
-от типа свойства. Например, для типа `string` пустым значением будет `undefined`,
-`null` и `''` (пустая строка).
+Режим `'sparse'` проверяет только значения с полезной нагрузкой,
+исключая [пустые значения](#Пустые-значения), список которых отличается
+в зависимости от типа свойства. Например, для типа `string` пустыми
+значениями будут `undefined`, `null` и `''` (пустая строка).
 
 - `unique: true | 'strict'` строгая проверка на уникальность
 - `unique: 'sparse'` исключить из проверки [пустые значения](#Пустые-значения)
@@ -503,26 +522,15 @@ dbs.defineModel({
 **EmptyValuesService**
 
 Для переопределения пустых значений необходимо получить экземпляр класса
-`EmptyValuesService` из контейнера схемы и вызвать метод, который принимает
-тип данных и массив новых значений.
-
-Интерфейс:
-
-```ts
-class EmptyValuesService {
-  /**
-   * Установить пустые значения
-   * для определенного типа данных.
-   * 
-   * @param dataType    Тип данных.
-   * @param emptyValues Массив новых пустых значений.
-   */
-  setEmptyValuesOf(
-    dataType: DataType,
-    emptyValues: unknown[],
-  ): this;
-}
-```
+`EmptyValuesService` из контейнера схемы и вызвать метод `setEmptyValuesOf`,
+который принимает тип данных и массив новых значений.
+
+Сигнатура:
+
+- `setEmptyValuesOf(dataType, emptyValues)`
+  - `dataType: DataType`: строковый литерал типа;
+  - `emptyValues: *[]`: массив новых значений;
+  - результат: `this`;
 
 **Пример**
 
@@ -555,24 +563,24 @@ emptyValuesService.setEmptyValuesOf(DataType.NUMBER, [undefined, null]);
 
 **Методы**
 
-- [`create(data, filter = undefined)`](#repositorycreate) создать новый документ;
-- [`replaceById(id, data, filter = undefined)`](#repositoryreplacebyid) заменить документ полностью;
-- [`replaceOrCreate(data, filter = undefined)`](#repositoryreplaceorcreate) заменить или создать новый;
-- [`patchById(id, data, filter = undefined)`](#repositorypatchbyid) обновить документ частично;
-- [`patch(data, where = undefined)`](#repositorypatch) обновить все документы или по условию;
-- [`find(filter = undefined)`](#repositoryfind) найти все документы или по условию;
-- [`findOne(filter = undefined)`](#repositoryfindone) найти первый документ или по условию;
-- [`findById(id, filter = undefined)`](#repositoryfindbyid) найти документ по идентификатору;
-- [`delete(where = undefined)`](#repositorydelete) удалить все документы или по условию;
+- [`create(data, [filter])`](#repositorycreate) создать новый документ;
+- [`replaceById(id, data, [filter])`](#repositoryreplacebyid) заменить документ полностью;
+- [`replaceOrCreate(data, [filter])`](#repositoryreplaceorcreate) заменить или создать новый;
+- [`patchById(id, data, [filter])`](#repositorypatchbyid) обновить документ частично;
+- [`patch(data, [where])`](#repositorypatch) обновить все документы или по условию;
+- [`find([filter])`](#repositoryfind) найти все документы или по условию;
+- [`findOne([filter])`](#repositoryfindone) найти первый документ или по условию;
+- [`findById(id, [filter])`](#repositoryfindbyid) найти документ по идентификатору;
+- [`delete([where])`](#repositorydelete) удалить все документы или по условию;
 - [`deleteById(id)`](#repositorydeletebyid) удалить документ по идентификатору;
 - [`exists(id)`](#repositoryexists) проверить существование по идентификатору;
-- [`count(where = undefined)`](#repositorycount) подсчет всех документов или по условию;
+- [`count([where])`](#repositorycount) подсчет всех документов или по условию;
 
 **Аргументы**
 
 - `id: number|string` идентификатор (первичный ключ)
 - `data: object` данные документа (используется при записи)
-- `where: object` условия фильтрации (см. [Фильтрация](#Фильтрация))
+- `where: object` условия выборки (см. [`where`](#where))
 - `filter: object` параметры выборки (см. [Фильтрация](#Фильтрация))
 
 **Получение репозитория**
@@ -612,12 +620,10 @@ const modelRep = dbs.getRepository('myModel');
 
 Сигнатура:
 
-```ts
-create(
-  data: WithOptionalId<FlatData, IdName>,
-  filter?: ItemFilterClause<FlatData>,
-): Promise<FlatData>;
-```
+- `create(data, [filter])`
+  - `data: object`: данные нового документа;
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object>`;
 
 **Примеры**
 
@@ -678,13 +684,11 @@ console.log(product);
 
 Сигнатура:
 
-```ts
-replaceById(
-  id: IdType,
-  data: WithoutId<FlatData, IdName>,
-  filter?: ItemFilterClause<FlatData>,
-): Promise<FlatData>;
-```
+- `replaceById(id, data, [filter])`
+  - `id: number|string`: идентификатор документа;
+  - `data: object`: новые данные;
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object>`;
 
 **Примеры**
 
@@ -720,12 +724,10 @@ console.log(updatedProduct);
 
 Сигнатура:
 
-```ts
-replaceOrCreate(
-  data: WithOptionalId<FlatData, IdName>,
-  filter?: ItemFilterClause<FlatData>,
-): Promise<FlatData>;
-```
+- `replaceOrCreate(data, [filter])`
+  - `data: object`: данные документа;
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object>`;
 
 **Примеры**
 
@@ -768,13 +770,11 @@ console.log(updatedProduct);
 
 Сигнатура:
 
-```ts
-patchById(
-  id: IdType,
-  data: PartialWithoutId<FlatData, IdName>,
-  filter?: ItemFilterClause<FlatData>,
-): Promise<FlatData>;
-```
+- `patchById(id, data, [filter])`
+  - `id: number|string`: идентификатор обновляемого документа;
+  - `data: object`: новые данные;
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object>`;
 
 **Примеры**
 
@@ -808,12 +808,10 @@ console.log(updatedProduct);
 
 Сигнатура:
 
-```ts
-patch(
-  data: PartialWithoutId<FlatData, IdName>,
-  where?: WhereClause<FlatData>,
-): Promise<number>;
-```
+- `patch(data, [where])`
+  - `data: object`: новые данные;
+  - `where?: object`: условия выборки (см. [`where`](#where));
+  - результат: `Promise<number>`;
 
 **Примеры**
 
@@ -843,9 +841,9 @@ const totalCount = await productRep.patch({
 
 Сигнатура:
 
-```ts
-find(filter?: FilterClause<FlatData>): Promise<FlatData[]>;
-```
+- `find([filter])`
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object[]>`;
 
 **Примеры**
 
@@ -879,11 +877,9 @@ const latestProducts = await productRep.find({
 
 Сигнатура:
 
-```ts
-findOne(
-  filter?: FilterClause<FlatData>,
-): Promise<FlatData | undefined>;
-```
+- `findOne([filter])`
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object|undefined>`;
 
 **Примеры**
 
@@ -914,12 +910,10 @@ if (!product) {
 
 Сигнатура:
 
-```ts
-findById(
-  id: IdType,
-  filter?: ItemFilterClause<FlatData>,
-): Promise<FlatData>;
-```
+- `findById(id, [filter])`
+  - `id: number|string`: идентификатор документа;
+  - `filter?: object`: настройки выборки (см. [Фильтрация](#фильтрация));
+  - результат: `Promise<object|undefined>`;
 
 **Примеры**
 
@@ -950,9 +944,9 @@ const product = await productRep.findById(1, {
 
 Сигнатура:
 
-```ts
-delete(where?: WhereClause<FlatData>): Promise<number>;
-```
+- `delete([where])`
+  - `where?: object`: условия выборки (см. [`where`](#where));
+  - результат: `Promise<number>`;
 
 **Примеры**
 
@@ -977,9 +971,15 @@ const totalCount = await productRep.delete();
 
 Сигнатура:
 
-```ts
-deleteById(id: IdType): Promise<boolean>;
-```
+- `deleteById(id)`
+  - `id: number|string`: идентификатор документа;
+  - результат: `Promise<boolean>`;
+
+Результат:
+
+- `Promise<boolean>`: логическое значение;
+  - `true`: документ был найден и удален;
+  - `false`: документ не найден;
 
 **Примеры**
 
@@ -1001,9 +1001,15 @@ if (wasDeleted) {
 
 Сигнатура:
 
-```ts
-exists(id: IdType): Promise<boolean>;
-```
+- `exists(id)`
+  - `id: number|string`: идентификатор документа;
+  - результат: `Promise<boolean>`;
+
+Результат:
+
+- `Promise<boolean>`: логическое значение;
+  - `true`: документ с таким идентификатором найден;
+  - `false`: идентификатор не найден;
 
 **Примеры**
 
@@ -1023,9 +1029,9 @@ if (productExists) {
 
 Сигнатура:
 
-```ts
-count(where?: WhereClause<FlatData>): Promise<number>;
-```
+- `count([where])`
+  - `where?: object`: условия выборки (см. [`where`](#where));
+  - результат: `Promise<number>`;
 
 **Примеры**
 
@@ -1045,10 +1051,10 @@ const totalCount = await productRep.count();
 
 ## Фильтрация
 
-Некоторые методы репозитория принимают объект настроек, влияющий
-на возвращаемый результат. Максимально широкий набор таких настроек
-имеет первый параметр метода `find`, где ожидается объект содержащий
-набор опций указанных ниже.
+Некоторые методы репозитория принимают объект настроек возвращаемого
+результата. Максимально широкий набор таких настроек имеет первый
+параметр метода `find`, где ожидается объект, содержащий набор
+опций указанных ниже.
 
 - `where: object` условия фильтрации по свойствам документа;
 - `order: string|string[]` сортировка по указанным свойствам;
@@ -1917,7 +1923,7 @@ dbs.defineModel({
 
 #### Has One (полиморфная версия)
 
-Обратная сторона полиморфная связи `belongsTo` по принципу *"один к одному"*.
+Обратная сторона полиморфной связи `belongsTo` по принципу *"один к одному"*.
 
 ```
     Текущая (company)  <───────┐      Целевая (license)
@@ -1984,7 +1990,7 @@ dbs.defineModel({
 
 #### Has Many (полиморфная версия)
 
-Обратная сторона полиморфная связи `belongsTo` по принципу *"один ко многим"*.
+Обратная сторона полиморфной связи `belongsTo` по принципу *"один ко многим"*.
 
 ```
     Текущая (letter)  <─────────┐      Целевая (file)
@@ -2097,56 +2103,9 @@ const rep = dbs.getRepository('model');
 console.log(rep instanceof MyRepository); // true
 ```
 
-*i. Так как экземпляры репозитория кэшируется, то замену конструктора
+*i. Так как экземпляры репозитория кэшируются, то замену конструктора
 следует выполнять до обращения к методу `getRepository`.*
 
-## TypeScript
-
-Получение типизированного репозитория с указанием интерфейса модели.
-
-```ts
-import {DataType} from '@e22m4u/js-repository';
-import {RelationType} from '@e22m4u/js-repository';
-import {DatabaseSchema} from '@e22m4u/js-repository';
-
-// const dbs = new DatabaseSchema();
-// dbs.defineDatasource ...
-
-// определение модели "city"
-dbs.defineModel({
-  name: 'city',
-  datasource: 'myDatasource',
-  properties: {
-    name: DataType.STRING,
-    timeZone: DataType.STRING,
-  },
-});
-
-// определение интерфейса "city"
-interface City {
-  id: number;
-  name?: string;
-  timeZone?: string;
-}
-
-// при получении репозитория нужной модели
-// можно указать тип документов
-const cityRep = dbs.getRepository<City>('city');
-
-// теперь, методы репозитория возвращают
-// тип City вместо Record<string, unknown>
-const city: City = await cityRep.create({
-  name: 'Moscow',
-  timeZone: 'Europe/Moscow',
-});
-```
-
-Для определения моделей с помощью TypeScript классов,
-рекомендуется использовать специальную версию данного модуля
-[@e22m4u/ts-repository](https://www.npmjs.com/package/@e22m4u/ts-repository),
-поставляемую с набором TypeScript декораторов и дополнительных
-инструментов для работы в TypeScript окружении.
-
 ## Тесты
 
 ```bash

+ 8 - 114
dist/cjs/index.cjs

@@ -1,4 +1,3 @@
-"use strict";
 var __create = Object.create;
 var __defProp = Object.defineProperty;
 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -46,7 +45,6 @@ function isPromise(value) {
 }
 var init_is_promise = __esm({
   "src/utils/is-promise.js"() {
-    "use strict";
     __name(isPromise, "isPromise");
   }
 });
@@ -58,7 +56,6 @@ function capitalize(string) {
 }
 var init_capitalize = __esm({
   "src/utils/capitalize.js"() {
-    "use strict";
     __name(capitalize, "capitalize");
   }
 });
@@ -102,7 +99,6 @@ function cloneDeep(value) {
 }
 var init_clone_deep = __esm({
   "src/utils/clone-deep.js"() {
-    "use strict";
     __name(cloneDeep, "cloneDeep");
   }
 });
@@ -126,7 +122,6 @@ function singularize(noun) {
 }
 var init_singularize = __esm({
   "src/utils/singularize.js"() {
-    "use strict";
     __name(singularize, "singularize");
   }
 });
@@ -175,7 +170,6 @@ function isDeepEqual(firstValue, secondValue) {
 }
 var init_is_deep_equal = __esm({
   "src/utils/is-deep-equal.js"() {
-    "use strict";
     __name(isDeepEqual, "isDeepEqual");
   }
 });
@@ -184,7 +178,6 @@ var init_is_deep_equal = __esm({
 var import_js_format, _NotImplementedError, NotImplementedError;
 var init_not_implemented_error = __esm({
   "src/errors/not-implemented-error.js"() {
-    "use strict";
     import_js_format = require("@e22m4u/js-format");
     _NotImplementedError = class _NotImplementedError extends import_js_format.Errorf {
     };
@@ -197,7 +190,6 @@ var init_not_implemented_error = __esm({
 var import_js_format2, _InvalidArgumentError, InvalidArgumentError;
 var init_invalid_argument_error = __esm({
   "src/errors/invalid-argument-error.js"() {
-    "use strict";
     import_js_format2 = require("@e22m4u/js-format");
     _InvalidArgumentError = class _InvalidArgumentError extends import_js_format2.Errorf {
     };
@@ -210,7 +202,6 @@ var init_invalid_argument_error = __esm({
 var import_js_format3, _InvalidOperatorValueError, InvalidOperatorValueError;
 var init_invalid_operator_value_error = __esm({
   "src/errors/invalid-operator-value-error.js"() {
-    "use strict";
     import_js_format3 = require("@e22m4u/js-format");
     _InvalidOperatorValueError = class _InvalidOperatorValueError extends Error {
       /**
@@ -239,7 +230,6 @@ var init_invalid_operator_value_error = __esm({
 // src/errors/index.js
 var init_errors = __esm({
   "src/errors/index.js"() {
-    "use strict";
     init_not_implemented_error();
     init_invalid_argument_error();
     init_invalid_operator_value_error();
@@ -281,7 +271,6 @@ function likeToRegexp(pattern, isCaseInsensitive = false) {
 }
 var init_like_to_regexp = __esm({
   "src/utils/like-to-regexp.js"() {
-    "use strict";
     init_errors();
     __name(likeToRegexp, "likeToRegexp");
   }
@@ -295,7 +284,6 @@ function isPlainObject(value) {
 }
 var init_is_plain_object = __esm({
   "src/utils/is-plain-object.js"() {
-    "use strict";
     __name(isPlainObject, "isPlainObject");
   }
 });
@@ -309,7 +297,6 @@ function stringToRegexp(pattern, flags = void 0) {
 }
 var init_string_to_regexp = __esm({
   "src/utils/string-to-regexp.js"() {
-    "use strict";
     __name(stringToRegexp, "stringToRegexp");
   }
 });
@@ -332,7 +319,6 @@ function getValueByPath(obj, path, orElse = void 0) {
 }
 var init_get_value_by_path = __esm({
   "src/utils/get-value-by-path.js"() {
-    "use strict";
     __name(getValueByPath, "getValueByPath");
   }
 });
@@ -365,7 +351,6 @@ function selectObjectKeys(obj, keys) {
 }
 var init_select_object_keys = __esm({
   "src/utils/select-object-keys.js"() {
-    "use strict";
     init_errors();
     __name(selectObjectKeys, "selectObjectKeys");
   }
@@ -385,7 +370,6 @@ function excludeObjectKeys(obj, keys) {
 }
 var init_exclude_object_keys = __esm({
   "src/utils/exclude-object-keys.js"() {
-    "use strict";
     init_errors();
     __name(excludeObjectKeys, "excludeObjectKeys");
   }
@@ -402,7 +386,6 @@ function modelNameToModelKey(modelName) {
 }
 var init_model_name_to_model_key = __esm({
   "src/utils/model-name-to-model-key.js"() {
-    "use strict";
     init_errors();
     __name(modelNameToModelKey, "modelNameToModelKey");
   }
@@ -411,7 +394,6 @@ var init_model_name_to_model_key = __esm({
 // src/utils/index.js
 var init_utils = __esm({
   "src/utils/index.js"() {
-    "use strict";
     init_is_promise();
     init_capitalize();
     init_clone_deep();
@@ -431,7 +413,6 @@ var init_utils = __esm({
 var import_js_service, _SliceClauseTool, SliceClauseTool;
 var init_slice_clause_tool = __esm({
   "src/filter/slice-clause-tool.js"() {
-    "use strict";
     import_js_service = require("@e22m4u/js-service");
     init_errors();
     _SliceClauseTool = class _SliceClauseTool extends import_js_service.Service {
@@ -514,7 +495,6 @@ function compareFn(a, b) {
 var import_js_service2, _OrderClauseTool, OrderClauseTool;
 var init_order_clause_tool = __esm({
   "src/filter/order-clause-tool.js"() {
-    "use strict";
     import_js_service2 = require("@e22m4u/js-service");
     init_utils();
     init_errors();
@@ -593,7 +573,6 @@ var init_order_clause_tool = __esm({
 var import_js_service3, _OperatorClauseTool, OperatorClauseTool;
 var init_operator_clause_tool = __esm({
   "src/filter/operator-clause-tool.js"() {
-    "use strict";
     import_js_service3 = require("@e22m4u/js-service");
     init_utils();
     init_errors();
@@ -1055,7 +1034,6 @@ var init_operator_clause_tool = __esm({
 var import_js_service4, _WhereClauseTool, WhereClauseTool;
 var init_where_clause_tool = __esm({
   "src/filter/where-clause-tool.js"() {
-    "use strict";
     import_js_service4 = require("@e22m4u/js-service");
     init_errors();
     init_operator_clause_tool();
@@ -1201,7 +1179,6 @@ var init_where_clause_tool = __esm({
 var RelationType;
 var init_relation_type = __esm({
   "src/definition/model/relations/relation-type.js"() {
-    "use strict";
     RelationType = {
       BELONGS_TO: "belongsTo",
       HAS_ONE: "hasOne",
@@ -1211,21 +1188,12 @@ var init_relation_type = __esm({
   }
 });
 
-// src/definition/model/relations/relation-definition.js
-var init_relation_definition = __esm({
-  "src/definition/model/relations/relation-definition.js"() {
-    "use strict";
-  }
-});
-
 // src/definition/model/relations/relations-definition-validator.js
 var import_js_service5, _RelationsDefinitionValidator, RelationsDefinitionValidator;
 var init_relations_definition_validator = __esm({
   "src/definition/model/relations/relations-definition-validator.js"() {
-    "use strict";
     import_js_service5 = require("@e22m4u/js-service");
     init_relation_type();
-    init_relation_type();
     init_errors();
     _RelationsDefinitionValidator = class _RelationsDefinitionValidator extends import_js_service5.Service {
       /**
@@ -1612,9 +1580,7 @@ var init_relations_definition_validator = __esm({
 // src/definition/model/relations/index.js
 var init_relations = __esm({
   "src/definition/model/relations/index.js"() {
-    "use strict";
     init_relation_type();
-    init_relation_definition();
     init_relations_definition_validator();
   }
 });
@@ -1623,7 +1589,6 @@ var init_relations = __esm({
 var DataType;
 var init_data_type = __esm({
   "src/definition/model/properties/data-type.js"() {
-    "use strict";
     DataType = {
       ANY: "any",
       STRING: "string",
@@ -1635,18 +1600,10 @@ var init_data_type = __esm({
   }
 });
 
-// src/definition/model/properties/property-definition.js
-var init_property_definition = __esm({
-  "src/definition/model/properties/property-definition.js"() {
-    "use strict";
-  }
-});
-
 // src/definition/model/properties/property-uniqueness.js
 var PropertyUniqueness;
 var init_property_uniqueness = __esm({
   "src/definition/model/properties/property-uniqueness.js"() {
-    "use strict";
     PropertyUniqueness = {
       STRICT: "strict",
       SPARSE: "sparse",
@@ -1659,7 +1616,6 @@ var init_property_uniqueness = __esm({
 var import_js_service6, _DefinitionRegistry, DefinitionRegistry;
 var init_definition_registry = __esm({
   "src/definition/definition-registry.js"() {
-    "use strict";
     import_js_service6 = require("@e22m4u/js-service");
     init_utils();
     init_errors();
@@ -1762,14 +1718,12 @@ var init_definition_registry = __esm({
 var import_js_service7, import_js_empty_values, DEFAULT_PRIMARY_KEY_PROPERTY_NAME, _ModelDefinitionUtils, ModelDefinitionUtils;
 var init_model_definition_utils = __esm({
   "src/definition/model/model-definition-utils.js"() {
-    "use strict";
     import_js_service7 = require("@e22m4u/js-service");
     init_properties();
-    init_utils();
-    init_utils();
     import_js_empty_values = require("@e22m4u/js-empty-values");
     init_errors();
     init_definition_registry();
+    init_utils();
     DEFAULT_PRIMARY_KEY_PROPERTY_NAME = "id";
     _ModelDefinitionUtils = class _ModelDefinitionUtils extends import_js_service7.Service {
       /**
@@ -2176,7 +2130,6 @@ var init_model_definition_utils = __esm({
 var import_js_service8, import_js_empty_values2, _PropertyUniquenessValidator, PropertyUniquenessValidator;
 var init_property_uniqueness_validator = __esm({
   "src/definition/model/properties/property-uniqueness-validator.js"() {
-    "use strict";
     init_data_type();
     import_js_service8 = require("@e22m4u/js-service");
     init_utils();
@@ -2296,7 +2249,6 @@ var init_property_uniqueness_validator = __esm({
 var import_js_service9, _PrimaryKeysDefinitionValidator, PrimaryKeysDefinitionValidator;
 var init_primary_keys_definition_validator = __esm({
   "src/definition/model/properties/primary-keys-definition-validator.js"() {
-    "use strict";
     import_js_service9 = require("@e22m4u/js-service");
     init_errors();
     init_model_definition_utils();
@@ -2348,7 +2300,6 @@ var init_primary_keys_definition_validator = __esm({
 var import_js_service10, _PropertiesDefinitionValidator, PropertiesDefinitionValidator;
 var init_properties_definition_validator = __esm({
   "src/definition/model/properties/properties-definition-validator.js"() {
-    "use strict";
     import_js_service10 = require("@e22m4u/js-service");
     init_data_type();
     init_utils();
@@ -2572,9 +2523,7 @@ var init_properties_definition_validator = __esm({
 // src/definition/model/properties/index.js
 var init_properties = __esm({
   "src/definition/model/properties/index.js"() {
-    "use strict";
     init_data_type();
-    init_property_definition();
     init_property_uniqueness();
     init_property_uniqueness_validator();
     init_properties_definition_validator();
@@ -2582,18 +2531,10 @@ var init_properties = __esm({
   }
 });
 
-// src/definition/model/model-definition.js
-var init_model_definition = __esm({
-  "src/definition/model/model-definition.js"() {
-    "use strict";
-  }
-});
-
 // src/definition/model/model-data-sanitizer.js
 var import_js_service11, _ModelDataSanitizer, ModelDataSanitizer;
 var init_model_data_sanitizer = __esm({
   "src/definition/model/model-data-sanitizer.js"() {
-    "use strict";
     import_js_service11 = require("@e22m4u/js-service");
     init_errors();
     init_model_definition_utils();
@@ -2630,7 +2571,6 @@ var init_model_data_sanitizer = __esm({
 var import_js_service12, _ModelDefinitionValidator, ModelDefinitionValidator;
 var init_model_definition_validator = __esm({
   "src/definition/model/model-definition-validator.js"() {
-    "use strict";
     import_js_service12 = require("@e22m4u/js-service");
     init_errors();
     init_relations();
@@ -2706,10 +2646,8 @@ var init_model_definition_validator = __esm({
 // src/definition/model/index.js
 var init_model = __esm({
   "src/definition/model/index.js"() {
-    "use strict";
     init_relations();
     init_properties();
-    init_model_definition();
     init_model_data_sanitizer();
     init_model_definition_utils();
     init_model_definition_validator();
@@ -2720,7 +2658,6 @@ var init_model = __esm({
 var import_js_service13, _DatasourceDefinitionValidator, DatasourceDefinitionValidator;
 var init_datasource_definition_validator = __esm({
   "src/definition/datasource/datasource-definition-validator.js"() {
-    "use strict";
     import_js_service13 = require("@e22m4u/js-service");
     init_errors();
     _DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends import_js_service13.Service {
@@ -2756,7 +2693,6 @@ var init_datasource_definition_validator = __esm({
 // src/definition/datasource/index.js
 var init_datasource = __esm({
   "src/definition/datasource/index.js"() {
-    "use strict";
     init_datasource_definition_validator();
   }
 });
@@ -2764,7 +2700,6 @@ var init_datasource = __esm({
 // src/definition/index.js
 var init_definition = __esm({
   "src/definition/index.js"() {
-    "use strict";
     init_model();
     init_datasource();
     init_definition_registry();
@@ -2775,7 +2710,6 @@ var init_definition = __esm({
 var import_js_service14, _FieldsClauseTool, FieldsClauseTool;
 var init_fields_clause_tool = __esm({
   "src/filter/fields-clause-tool.js"() {
-    "use strict";
     import_js_service14 = require("@e22m4u/js-service");
     init_utils();
     init_errors();
@@ -2867,7 +2801,6 @@ var init_fields_clause_tool = __esm({
 var import_js_service15, _InclusionDecorator, InclusionDecorator;
 var init_inclusion_decorator = __esm({
   "src/adapter/decorator/inclusion-decorator.js"() {
-    "use strict";
     init_adapter();
     import_js_service15 = require("@e22m4u/js-service");
     init_filter();
@@ -2956,7 +2889,6 @@ var init_inclusion_decorator = __esm({
 var import_js_service16, _DefaultValuesDecorator, DefaultValuesDecorator;
 var init_default_values_decorator = __esm({
   "src/adapter/decorator/default-values-decorator.js"() {
-    "use strict";
     init_adapter();
     import_js_service16 = require("@e22m4u/js-service");
     init_errors();
@@ -3021,7 +2953,6 @@ var init_default_values_decorator = __esm({
 var import_js_service17, _DataSanitizingDecorator, DataSanitizingDecorator;
 var init_data_sanitizing_decorator = __esm({
   "src/adapter/decorator/data-sanitizing-decorator.js"() {
-    "use strict";
     init_adapter();
     import_js_service17 = require("@e22m4u/js-service");
     init_errors();
@@ -3076,7 +3007,6 @@ var init_data_sanitizing_decorator = __esm({
 var import_js_service18, _FieldsFilteringDecorator, FieldsFilteringDecorator;
 var init_fields_filtering_decorator = __esm({
   "src/adapter/decorator/fields-filtering-decorator.js"() {
-    "use strict";
     init_adapter();
     import_js_service18 = require("@e22m4u/js-service");
     init_filter();
@@ -3159,7 +3089,6 @@ var init_fields_filtering_decorator = __esm({
 var import_js_service19, _PropertyUniquenessDecorator, PropertyUniquenessDecorator;
 var init_property_uniqueness_decorator = __esm({
   "src/adapter/decorator/property-uniqueness-decorator.js"() {
-    "use strict";
     init_adapter();
     import_js_service19 = require("@e22m4u/js-service");
     init_errors();
@@ -3234,7 +3163,6 @@ var init_property_uniqueness_decorator = __esm({
 // src/adapter/decorator/index.js
 var init_decorator = __esm({
   "src/adapter/decorator/index.js"() {
-    "use strict";
     init_inclusion_decorator();
     init_default_values_decorator();
     init_data_sanitizing_decorator();
@@ -3247,14 +3175,9 @@ var init_decorator = __esm({
 var import_js_service20, ADAPTER_CLASS_NAME, _Adapter, Adapter;
 var init_adapter = __esm({
   "src/adapter/adapter.js"() {
-    "use strict";
     import_js_service20 = require("@e22m4u/js-service");
     init_errors();
     init_decorator();
-    init_decorator();
-    init_decorator();
-    init_decorator();
-    init_decorator();
     ADAPTER_CLASS_NAME = "Adapter";
     _Adapter = class _Adapter extends import_js_service20.Service {
       /**
@@ -3459,16 +3382,11 @@ __export(memory_adapter_exports, {
 var _MemoryAdapter, MemoryAdapter;
 var init_memory_adapter = __esm({
   "src/adapter/builtin/memory-adapter.js"() {
-    "use strict";
     init_adapter();
     init_utils();
-    init_utils();
-    init_definition();
-    init_filter();
-    init_filter();
-    init_filter();
     init_errors();
     init_definition();
+    init_filter();
     _MemoryAdapter = class _MemoryAdapter extends Adapter {
       /**
        * Tables.
@@ -3879,11 +3797,9 @@ function findAdapterCtorInModule(module2) {
 var import_js_service21, _AdapterLoader, AdapterLoader;
 var init_adapter_loader = __esm({
   "src/adapter/adapter-loader.js"() {
-    "use strict";
-    init_adapter();
     import_js_service21 = require("@e22m4u/js-service");
-    init_adapter();
     init_errors();
+    init_adapter();
     init_();
     _AdapterLoader = class _AdapterLoader extends import_js_service21.Service {
       /**
@@ -3903,13 +3819,13 @@ var init_adapter_loader = __esm({
         try {
           const module2 = await globImport_builtin_adapter_js(`./builtin/${adapterName}-adapter.js`);
           adapterCtor = findAdapterCtorInModule(module2);
-        } catch (e) {
+        } catch {
         }
         if (!adapterCtor)
           try {
             const module2 = await Promise.resolve().then(() => __toESM(require(`@e22m4u/js-repository-${adapterName}-adapter`)));
             adapterCtor = findAdapterCtorInModule(module2);
-          } catch (e) {
+          } catch {
           }
         if (!adapterCtor)
           throw new InvalidArgumentError(
@@ -3929,7 +3845,6 @@ var init_adapter_loader = __esm({
 var import_js_service22, _AdapterRegistry, AdapterRegistry;
 var init_adapter_registry = __esm({
   "src/adapter/adapter-registry.js"() {
-    "use strict";
     init_adapter();
     import_js_service22 = require("@e22m4u/js-service");
     init_adapter_loader();
@@ -3968,7 +3883,6 @@ var init_adapter_registry = __esm({
 // src/adapter/index.js
 var init_adapter2 = __esm({
   "src/adapter/index.js"() {
-    "use strict";
     init_adapter();
     init_adapter_loader();
     init_adapter_registry();
@@ -3979,12 +3893,10 @@ var init_adapter2 = __esm({
 var import_js_service23, _Repository, Repository;
 var init_repository = __esm({
   "src/repository/repository.js"() {
-    "use strict";
     import_js_service23 = require("@e22m4u/js-service");
-    init_adapter2();
-    init_adapter2();
     init_errors();
     init_definition();
+    init_adapter2();
     _Repository = class _Repository extends import_js_service23.Service {
       /**
        * Model name.
@@ -4182,7 +4094,6 @@ var init_repository = __esm({
 var import_js_service24, _RepositoryRegistry, RepositoryRegistry;
 var init_repository_registry = __esm({
   "src/repository/repository-registry.js"() {
-    "use strict";
     import_js_service24 = require("@e22m4u/js-service");
     init_repository();
     init_utils();
@@ -4238,7 +4149,6 @@ var init_repository_registry = __esm({
 // src/repository/index.js
 var init_repository2 = __esm({
   "src/repository/index.js"() {
-    "use strict";
     init_repository();
     init_repository_registry();
   }
@@ -4248,10 +4158,8 @@ var init_repository2 = __esm({
 var import_js_service25, _HasOneResolver, HasOneResolver;
 var init_has_one_resolver = __esm({
   "src/relations/has-one-resolver.js"() {
-    "use strict";
     import_js_service25 = require("@e22m4u/js-service");
     init_utils();
-    init_definition();
     init_errors();
     init_repository2();
     init_definition();
@@ -4503,10 +4411,8 @@ var init_has_one_resolver = __esm({
 var import_js_service26, _HasManyResolver, HasManyResolver;
 var init_has_many_resolver = __esm({
   "src/relations/has-many-resolver.js"() {
-    "use strict";
     import_js_service26 = require("@e22m4u/js-service");
     init_utils();
-    init_definition();
     init_errors();
     init_repository2();
     init_definition();
@@ -4768,11 +4674,9 @@ var init_has_many_resolver = __esm({
 var import_js_service27, _BelongsToResolver, BelongsToResolver;
 var init_belongs_to_resolver = __esm({
   "src/relations/belongs-to-resolver.js"() {
-    "use strict";
     import_js_service27 = require("@e22m4u/js-service");
-    init_utils();
-    init_utils();
     init_errors();
+    init_utils();
     init_repository2();
     init_definition();
     _BelongsToResolver = class _BelongsToResolver extends import_js_service27.Service {
@@ -4976,11 +4880,9 @@ var init_belongs_to_resolver = __esm({
 var import_js_service28, _ReferencesManyResolver, ReferencesManyResolver;
 var init_references_many_resolver = __esm({
   "src/relations/references-many-resolver.js"() {
-    "use strict";
     import_js_service28 = require("@e22m4u/js-service");
-    init_utils();
-    init_utils();
     init_errors();
+    init_utils();
     init_repository2();
     init_definition();
     _ReferencesManyResolver = class _ReferencesManyResolver extends import_js_service28.Service {
@@ -5076,7 +4978,6 @@ var init_references_many_resolver = __esm({
 // src/relations/index.js
 var init_relations2 = __esm({
   "src/relations/index.js"() {
-    "use strict";
     init_has_one_resolver();
     init_has_many_resolver();
     init_belongs_to_resolver();
@@ -5088,16 +4989,11 @@ var init_relations2 = __esm({
 var import_js_service29, _IncludeClauseTool, IncludeClauseTool;
 var init_include_clause_tool = __esm({
   "src/filter/include-clause-tool.js"() {
-    "use strict";
     import_js_service29 = require("@e22m4u/js-service");
-    init_definition();
-    init_relations2();
-    init_relations2();
     init_where_clause_tool();
     init_order_clause_tool();
     init_slice_clause_tool();
     init_errors();
-    init_relations2();
     init_fields_clause_tool();
     init_definition();
     init_relations2();
@@ -5427,7 +5323,6 @@ var init_include_clause_tool = __esm({
 // src/filter/index.js
 var init_filter = __esm({
   "src/filter/index.js"() {
-    "use strict";
     init_slice_clause_tool();
     init_order_clause_tool();
     init_where_clause_tool();
@@ -5494,7 +5389,6 @@ init_adapter2();
 
 // src/database-schema.js
 var import_js_service30 = require("@e22m4u/js-service");
-init_repository2();
 init_definition();
 init_repository2();
 var _DatabaseSchema = class _DatabaseSchema extends import_js_service30.Service {

+ 29 - 58
eslint.config.js

@@ -1,68 +1,39 @@
 import globals from 'globals';
 import eslintJs from '@eslint/js';
-import eslintTypescript from 'typescript-eslint';
 import eslintJsdocPlugin from 'eslint-plugin-jsdoc';
 import eslintMochaPlugin from 'eslint-plugin-mocha';
+import eslintImportPlugin from 'eslint-plugin-import';
 import eslintPrettierConfig from 'eslint-config-prettier';
 import eslintChaiExpectPlugin from 'eslint-plugin-chai-expect';
 
-export default [
-  {
-    files: ['src/**/*.js'],
-    languageOptions: {
-      globals: {
-        ...globals.node,
-        ...globals.es2021,
-        ...globals.mocha,
-      },
-    },
-    plugins: {
-      'jsdoc': eslintJsdocPlugin,
-      'mocha': eslintMochaPlugin,
-      'chai-expect': eslintChaiExpectPlugin,
-    },
-    rules: {
-      ...eslintJs.configs.recommended.rules,
-      ...eslintPrettierConfig.rules,
-      ...eslintMochaPlugin.configs.recommended.rules,
-      ...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
-      ...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
-      'no-unused-vars': ['error', {'caughtErrors': 'none'}],
-      'jsdoc/reject-any-type': 0,
-      'jsdoc/reject-function-type': 0,
-      'jsdoc/require-param-description': 0,
-      'jsdoc/require-returns-description': 0,
-      'jsdoc/require-property-description': 0,
-      'jsdoc/tag-lines': ['error', 'any', {startLines: 1}],
+export default [{
+  languageOptions: {
+    globals: {
+      ...globals.node,
+      ...globals.es2021,
+      ...globals.mocha,
     },
   },
-  {
-    files: ['src/**/*.ts'],
-    ignores: ['src/**/*.d.ts'],
-    languageOptions: {
-      globals: {
-        ...globals.node,
-        ...globals.es2021,
-        ...globals.mocha,
-      },
-      parser: eslintTypescript.parser,
-      parserOptions: {
-        projectService: true,
-        tsconfigRootDir: import.meta.dirname,
-      },
-    },
-    plugins: {
-      '@typescript-eslint': eslintTypescript.plugin,
-      'mocha': eslintMochaPlugin,
-      'chai-expect': eslintChaiExpectPlugin,
-    },
-    rules: {
-      ...eslintJs.configs.recommended.rules,
-      ...eslintPrettierConfig.rules,
-      ...eslintTypescript.configs.recommended.rules,
-      '@typescript-eslint/no-namespace': 0,
-      '@typescript-eslint/no-var-requires': 0,
-      '@typescript-eslint/no-unnecessary-type-constraint': 0,
-    },
+  plugins: {
+    'jsdoc': eslintJsdocPlugin,
+    'mocha': eslintMochaPlugin,
+    'import': eslintImportPlugin,
+    'chai-expect': eslintChaiExpectPlugin,
+  },
+  rules: {
+    ...eslintJs.configs.recommended.rules,
+    ...eslintPrettierConfig.rules,
+    ...eslintImportPlugin.flatConfigs.recommended.rules,
+    ...eslintMochaPlugin.configs.recommended.rules,
+    ...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
+    ...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
+    'no-duplicate-imports': 'error',
+    'jsdoc/reject-any-type': 0,
+    'jsdoc/reject-function-type': 0,
+    'jsdoc/require-param-description': 0,
+    'jsdoc/require-returns-description': 0,
+    'jsdoc/require-property-description': 0,
+    'jsdoc/tag-lines': ['error', 'any', {startLines: 1}],
   },
-];
+  files: ['src/**/*.js'],
+}];

+ 7 - 0
jsconfig.json

@@ -0,0 +1,7 @@
+{
+  "compilerOptions": {
+    "target": "es2022",
+    "module": "NodeNext",
+    "moduleResolution": "NodeNext"
+  }
+}

+ 10 - 18
package.json

@@ -12,17 +12,15 @@
     "Datasource",
     "Relations"
   ],
-  "homepage": "https://github.com/e22m4u/js-repository",
+  "homepage": "https://gitrepos.ru/e22m4u/js-repository",
   "repository": {
     "type": "git",
-    "url": "git+https://github.com/e22m4u/js-repository.git"
+    "url": "git+https://gitrepos.ru/e22m4u/js-repository.git"
   },
   "type": "module",
-  "types": "./src/index.d.ts",
   "module": "./src/index.js",
   "main": "./dist/cjs/index.cjs",
   "exports": {
-    "types": "./src/index.d.ts",
     "import": "./src/index.js",
     "require": "./dist/cjs/index.cjs"
   },
@@ -30,26 +28,22 @@
     "node": ">=12"
   },
   "scripts": {
-    "lint": "tsc && eslint ./src",
-    "lint:fix": "tsc && eslint ./src --fix",
+    "lint": "eslint ./src",
+    "lint:fix": "eslint ./src --fix",
     "format": "prettier --write \"./src/**/*.js\"",
     "test": "npm run lint && c8 --reporter=text-summary mocha --bail",
     "test:coverage": "npm run lint && c8 --reporter=text mocha --bail",
-    "build:cjs": "rimraf ./dist/cjs && node --no-warnings=ExperimentalWarning build-cjs.js",
+    "build:cjs": "rimraf ./dist/cjs && node build-cjs.js",
     "prepare": "husky"
   },
   "dependencies": {
-    "@e22m4u/js-empty-values": "~0.1.3",
-    "@e22m4u/js-format": "~0.2.1",
+    "@e22m4u/js-empty-values": "~0.2.0",
+    "@e22m4u/js-format": "~0.3.0",
     "@e22m4u/js-service": "~0.4.6"
   },
   "devDependencies": {
     "@commitlint/cli": "~20.1.0",
     "@commitlint/config-conventional": "~20.0.0",
-    "@types/chai": "~5.2.3",
-    "@types/chai-as-promised": "~8.0.2",
-    "@types/chai-spies": "~1.0.6",
-    "@types/mocha": "~10.0.10",
     "c8": "~10.1.3",
     "chai": "~6.2.1",
     "chai-as-promised": "~8.0.2",
@@ -58,14 +52,12 @@
     "eslint": "~9.39.1",
     "eslint-config-prettier": "~10.1.8",
     "eslint-plugin-chai-expect": "~3.1.0",
+    "eslint-plugin-import": "~2.32.0",
     "eslint-plugin-jsdoc": "~61.4.1",
     "eslint-plugin-mocha": "~11.2.0",
     "husky": "~9.1.7",
     "mocha": "~11.7.5",
-    "prettier": "~3.6.2",
-    "rimraf": "~6.1.2",
-    "ts-node": "~10.9.2",
-    "typescript": "~5.9.3",
-    "typescript-eslint": "~8.48.0"
+    "prettier": "~3.7.3",
+    "rimraf": "~6.1.2"
   }
 }

+ 0 - 16
src/adapter/adapter-loader.d.ts

@@ -1,16 +0,0 @@
-import {Adapter} from './adapter.js';
-import {AnyObject} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Adapter loader.
- */
-export declare class AdapterLoader extends Service {
-  /**
-   * Load by name.
-   *
-   * @param adapterName
-   * @param settings
-   */
-  loadByName(adapterName: string, settings?: AnyObject): Promise<Adapter>;
-}

+ 3 - 4
src/adapter/adapter-loader.js

@@ -1,7 +1,6 @@
-import {Adapter} from './adapter.js';
 import {Service} from '@e22m4u/js-service';
-import {ADAPTER_CLASS_NAME} from './adapter.js';
 import {InvalidArgumentError} from '../errors/index.js';
+import {Adapter, ADAPTER_CLASS_NAME} from './adapter.js';
 
 /**
  * Adapter loader.
@@ -24,7 +23,7 @@ export class AdapterLoader extends Service {
     try {
       const module = await import(`./builtin/${adapterName}-adapter.js`);
       adapterCtor = findAdapterCtorInModule(module);
-    } catch (e) {
+    } catch {
       /**/
     }
     if (!adapterCtor)
@@ -33,7 +32,7 @@ export class AdapterLoader extends Service {
           `@e22m4u/js-repository-${adapterName}-adapter`
         );
         adapterCtor = findAdapterCtorInModule(module);
-      } catch (e) {
+      } catch {
         /**/
       }
     if (!adapterCtor)

+ 0 - 14
src/adapter/adapter-registry.d.ts

@@ -1,14 +0,0 @@
-import {Adapter} from './adapter.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Adapter registry.
- */
-export declare class AdapterRegistry extends Service {
-  /**
-   * Get adapter.
-   *
-   * @param datasourceName
-   */
-  getAdapter(datasourceName: string): Promise<Adapter>;
-}

+ 0 - 153
src/adapter/adapter.d.ts

@@ -1,153 +0,0 @@
-import {ModelId} from '../types.js';
-import {AnyObject} from '../types.js';
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {WhereClause} from '../filter/index.js';
-import {FilterClause} from '../filter/index.js';
-import {ItemFilterClause} from '../filter/index.js';
-import {ServiceContainer} from '@e22m4u/js-service';
-
-/**
- * Adapter.
- */
-export declare class Adapter extends Service {
-  /**
-   * Kinds.
-   */
-  static kinds: string[];
-
-  /**
-   * Settings.
-   */
-  get settings(): AnyObject | undefined;
-
-  /**
-   * Constructor.
-   *
-   * @param container
-   * @param settings
-   */
-  constructor(container?: ServiceContainer, settings?: AnyObject);
-
-  /**
-   * Create.
-   *
-   * @param modelName
-   * @param modelData
-   * @param filter
-   */
-  create(
-    modelName: string,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Replace by id.
-   *
-   * @param modelName
-   * @param id
-   * @param modelData
-   * @param filter
-   */
-  replaceById(
-    modelName: string,
-    id: ModelId,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Replace or create.
-   *
-   * @param modelName
-   * @param modelData
-   * @param filter
-   */
-  replaceOrCreate(
-    modelName: string,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Patch.
-   *
-   * @param modelName
-   * @param modelData
-   * @param where
-   */
-  patch(
-    modelName: string,
-    modelData: ModelData,
-    where?: WhereClause,
-  ): Promise<number>;
-
-  /**
-   * Patch by id.
-   *
-   * @param modelName
-   * @param id
-   * @param modelData
-   * @param filter
-   */
-  patchById(
-    modelName: string,
-    id: ModelId,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Find.
-   *
-   * @param modelName
-   * @param filter
-   */
-  find(modelName: string, filter?: FilterClause): Promise<ModelData[]>;
-
-  /**
-   * Find by id.
-   *
-   * @param modelName
-   * @param id
-   * @param filter
-   */
-  findById(
-    modelName: string,
-    id: ModelId,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Delete.
-   *
-   * @param modelName
-   * @param where
-   */
-  delete(modelName: string, where?: WhereClause): Promise<number>;
-
-  /**
-   * Delete by id.
-   *
-   * @param modelName
-   * @param id
-   */
-  deleteById(modelName: string, id: ModelId): Promise<boolean>;
-
-  /**
-   * Exists.
-   *
-   * @param modelName
-   * @param id
-   */
-  exists(modelName: string, id: ModelId): Promise<boolean>;
-
-  /**
-   * Count.
-   *
-   * @param modelName
-   * @param where
-   */
-  count(modelName: string, where?: WhereClause): Promise<number>;
-}

+ 8 - 5
src/adapter/adapter.js

@@ -2,11 +2,14 @@
 /* eslint jsdoc/require-returns-check: 0 */
 import {Service} from '@e22m4u/js-service';
 import {NotImplementedError} from '../errors/index.js';
-import {InclusionDecorator} from './decorator/index.js';
-import {DefaultValuesDecorator} from './decorator/index.js';
-import {DataSanitizingDecorator} from './decorator/index.js';
-import {FieldsFilteringDecorator} from './decorator/index.js';
-import {PropertyUniquenessDecorator} from './decorator/index.js';
+
+import {
+  InclusionDecorator,
+  DefaultValuesDecorator,
+  DataSanitizingDecorator,
+  FieldsFilteringDecorator,
+  PropertyUniquenessDecorator,
+} from './decorator/index.js';
 
 /**
  * Adapter class name.

+ 10 - 9
src/adapter/adapter.spec.js

@@ -1,15 +1,16 @@
 import {expect} from 'chai';
 import {chai} from '../chai.js';
-import {Adapter} from './adapter.js';
-import {Service} from '@e22m4u/js-service';
-import {ADAPTER_CLASS_NAME} from './adapter.js';
-import {ServiceContainer} from '@e22m4u/js-service';
 import {DatabaseSchema} from '../database-schema.js';
-import {InclusionDecorator} from './decorator/index.js';
-import {DefaultValuesDecorator} from './decorator/index.js';
-import {DataSanitizingDecorator} from './decorator/index.js';
-import {FieldsFilteringDecorator} from './decorator/index.js';
-import {PropertyUniquenessDecorator} from './decorator/index.js';
+import {Adapter, ADAPTER_CLASS_NAME} from './adapter.js';
+import {Service, ServiceContainer} from '@e22m4u/js-service';
+
+import {
+  InclusionDecorator,
+  DefaultValuesDecorator,
+  DataSanitizingDecorator,
+  FieldsFilteringDecorator,
+  PropertyUniquenessDecorator,
+} from './decorator/index.js';
 
 const sandbox = chai.spy.sandbox();
 

+ 0 - 148
src/adapter/builtin/memory-adapter.d.ts

@@ -1,148 +0,0 @@
-import {Adapter} from '../adapter.js';
-import {ModelId} from '../../types.js';
-import {AnyObject} from '../../types.js';
-import {ModelData} from '../../types.js';
-import {WhereClause} from '../../filter/index.js';
-import {FilterClause} from '../../filter/index.js';
-import {ServiceContainer} from '@e22m4u/js-service';
-import {ItemFilterClause} from '../../filter/index.js';
-
-/**
- * Memory adapter.
- */
-export declare class MemoryAdapter extends Adapter {
-  /**
-   * Settings.
-   */
-  get settings(): AnyObject | undefined;
-
-  /**
-   * Constructor.
-   *
-   * @param container
-   * @param settings
-   */
-  constructor(container?: ServiceContainer, settings?: AnyObject);
-
-  /**
-   * Create.
-   *
-   * @param modelName
-   * @param modelData
-   * @param filter
-   */
-  create(
-    modelName: string,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Replace by id.
-   *
-   * @param modelName
-   * @param id
-   * @param modelData
-   * @param filter
-   */
-  replaceById(
-    modelName: string,
-    id: ModelId,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Replace or create.
-   *
-   * @param modelName
-   * @param modelData
-   * @param filter
-   */
-  replaceOrCreate(
-    modelName: string,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Patch.
-   *
-   * @param modelName
-   * @param modelData
-   * @param where
-   */
-  patch(
-    modelName: string,
-    modelData: ModelData,
-    where?: WhereClause,
-  ): Promise<number>;
-
-  /**
-   * Patch by id.
-   *
-   * @param modelName
-   * @param id
-   * @param modelData
-   * @param filter
-   */
-  patchById(
-    modelName: string,
-    id: ModelId,
-    modelData: ModelData,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Find.
-   *
-   * @param modelName
-   * @param filter
-   */
-  find(modelName: string, filter?: FilterClause): Promise<ModelData[]>;
-
-  /**
-   * Find by id.
-   *
-   * @param modelName
-   * @param id
-   * @param filter
-   */
-  findById(
-    modelName: string,
-    id: ModelId,
-    filter?: ItemFilterClause,
-  ): Promise<ModelData>;
-
-  /**
-   * Delete.
-   *
-   * @param modelName
-   * @param where
-   */
-  delete(modelName: string, where?: WhereClause): Promise<number>;
-
-  /**
-   * Delete by id.
-   *
-   * @param modelName
-   * @param id
-   */
-  deleteById(modelName: string, id: ModelId): Promise<boolean>;
-
-  /**
-   * Exists.
-   *
-   * @param modelName
-   * @param id
-   */
-  exists(modelName: string, id: ModelId): Promise<boolean>;
-
-  /**
-   * Count.
-   *
-   * @param modelName
-   * @param where
-   */
-  count(modelName: string, where?: WhereClause): Promise<number>;
-}

+ 8 - 7
src/adapter/builtin/memory-adapter.js

@@ -1,12 +1,13 @@
 import {Adapter} from '../adapter.js';
-import {cloneDeep} from '../../utils/index.js';
-import {capitalize} from '../../utils/index.js';
-import {DataType} from '../../definition/index.js';
-import {SliceClauseTool} from '../../filter/index.js';
-import {WhereClauseTool} from '../../filter/index.js';
-import {OrderClauseTool} from '../../filter/index.js';
+import {cloneDeep, capitalize} from '../../utils/index.js';
 import {InvalidArgumentError} from '../../errors/index.js';
-import {ModelDefinitionUtils} from '../../definition/index.js';
+import {DataType, ModelDefinitionUtils} from '../../definition/index.js';
+
+import {
+  SliceClauseTool,
+  WhereClauseTool,
+  OrderClauseTool,
+} from '../../filter/index.js';
 
 /**
  * Memory adapter.

+ 5 - 2
src/adapter/builtin/memory-adapter.spec.js

@@ -1,9 +1,12 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/js-format';
 import {MemoryAdapter} from './memory-adapter.js';
-import {DataType} from '../../definition/index.js';
 import {DatabaseSchema} from '../../database-schema.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../../definition/index.js';
+
+import {
+  DataType,
+  DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
+} from '../../definition/index.js';
 
 describe('MemoryAdapter', function () {
   describe('_getTableOrCreate', function () {

+ 0 - 14
src/adapter/decorator/data-sanitizing-decorator.d.ts

@@ -1,14 +0,0 @@
-import {Adapter} from '../adapter.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Data sanitizing decorator.
- */
-export declare class DataSanitizingDecorator extends Service {
-  /**
-   * Decorate.
-   *
-   * @param adapter
-   */
-  decorate(adapter: Adapter): void;
-}

+ 0 - 14
src/adapter/decorator/default-values-decorator.d.ts

@@ -1,14 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {Adapter} from '../adapter.js';
-
-/**
- * Default values decorator.
- */
-export declare class DefaultValuesDecorator extends Service {
-  /**
-   * Decorate.
-   *
-   * @param adapter
-   */
-  decorate(adapter: Adapter): void;
-}

+ 1 - 2
src/adapter/decorator/default-values-decorator.spec.js

@@ -1,9 +1,8 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {DataType} from '../../definition/index.js';
 import {DatabaseSchema} from '../../database-schema.js';
-import {ModelDefinitionUtils} from '../../definition/index.js';
+import {DataType, ModelDefinitionUtils} from '../../definition/index.js';
 
 const dbs = new DatabaseSchema();
 dbs.defineModel({

+ 0 - 14
src/adapter/decorator/fields-filtering-decorator.d.ts

@@ -1,14 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {Adapter} from '../adapter.js';
-
-/**
- * Fields filtering decorator.
- */
-export declare class FieldsFilteringDecorator extends Service {
-  /**
-   * Decorate.
-   *
-   * @param adapter
-   */
-  decorate(adapter: Adapter): void;
-}

+ 0 - 14
src/adapter/decorator/inclusion-decorator.d.ts

@@ -1,14 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {Adapter} from '../adapter.js';
-
-/**
- * Inclusion decorator.
- */
-export declare class InclusionDecorator extends Service {
-  /**
-   * Decorate.
-   *
-   * @param adapter
-   */
-  decorate(adapter: Adapter): void;
-}

+ 0 - 5
src/adapter/decorator/index.d.ts

@@ -1,5 +0,0 @@
-export * from './inclusion-decorator.js';
-export * from './default-values-decorator.js';
-export * from './data-sanitizing-decorator.js';
-export * from './fields-filtering-decorator.js';
-export * from './property-uniqueness-decorator.js';

+ 0 - 14
src/adapter/decorator/property-uniqueness-decorator.d.ts

@@ -1,14 +0,0 @@
-import {Adapter} from '../adapter.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Property uniqueness decorator.
- */
-export declare class PropertyUniquenessDecorator extends Service {
-  /**
-   * Decorate.
-   *
-   * @param adapter
-   */
-  decorate(adapter: Adapter): void;
-}

+ 0 - 3
src/adapter/index.d.ts

@@ -1,3 +0,0 @@
-export * from './adapter.js';
-export * from './adapter-loader.js';
-export * from './adapter-registry.js';

+ 0 - 37
src/database-schema.d.ts

@@ -1,37 +0,0 @@
-import {ModelId} from './types.js';
-import {ModelData} from './types.js';
-import {Service} from '@e22m4u/js-service';
-import {Repository} from './repository/index.js';
-import {ModelDefinition} from './definition/index.js';
-import {DatasourceDefinition} from './definition/index.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME} from './definition/index.js';
-
-/**
- * Database schema.
- */
-export declare class DatabaseSchema extends Service {
-  /**
-   * Define datasource.
-   *
-   * @param datasourceDef
-   */
-  defineDatasource(datasourceDef: DatasourceDefinition): this;
-
-  /**
-   * Define model.
-   *
-   * @param modelDef
-   */
-  defineModel(modelDef: ModelDefinition): this;
-
-  /**
-   * Get repository.
-   *
-   * @param modelName
-   */
-  getRepository<
-    Data extends object = ModelData,
-    IdType extends ModelId = ModelId,
-    IdName extends string = typeof DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
-  >(modelName: string): Repository<Data, IdType, IdName>;
-}

+ 1 - 2
src/database-schema.js

@@ -1,7 +1,6 @@
 import {Service} from '@e22m4u/js-service';
-import {Repository} from './repository/index.js';
 import {DefinitionRegistry} from './definition/index.js';
-import {RepositoryRegistry} from './repository/index.js';
+import {Repository, RepositoryRegistry} from './repository/index.js';
 
 /**
  * Database schema.

+ 5 - 17
src/database-schema.spec.ts → src/database-schema.spec.js

@@ -17,16 +17,17 @@ describe('DatabaseSchema', function () {
     it('sets the datasource definition', function () {
       const dbs = new DatabaseSchema();
       dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
-      const res =
-        dbs.getService(DefinitionRegistry).getDatasource('datasource');
+      const res = dbs
+        .getService(DefinitionRegistry)
+        .getDatasource('datasource');
       expect(res).to.be.eql({name: 'datasource', adapter: 'memory'});
     });
 
     it('throws an error if the datasource name already defined', function () {
       const dbs = new DatabaseSchema();
       dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
-      const throwable =
-        () => dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
+      const throwable = () =>
+        dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
       expect(throwable).to.throw(
         'The datasource "datasource" is already defined.',
       );
@@ -69,18 +70,5 @@ describe('DatabaseSchema', function () {
       const throwable = () => dbs.getRepository('model');
       expect(throwable).to.throw('The model "model" is not defined.');
     });
-
-    it('uses generic types to define the repository type', function () {
-      const dbs = new DatabaseSchema();
-      dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
-      dbs.defineModel({name: 'model', datasource: 'datasource'});
-      interface MyModel {
-        myId: number;
-      }
-      const res1: Repository = dbs.getRepository('model');
-      const res2: Repository<MyModel, number, 'myId'> =
-        dbs.getRepository<MyModel, number, 'myId'>('model');
-      expect(res1).to.be.eq(res2);
-    });
   });
 });

+ 0 - 14
src/definition/datasource/datasource-definition-validator.d.ts

@@ -1,14 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {DatasourceDefinition} from './datasource-definition.js';
-
-/**
- * Datasource definition validator.
- */
-export declare class DatasourceDefinitionValidator extends Service {
-  /**
-   * Validate.
-   *
-   * @param datasourceDef
-   */
-  validate(datasourceDef: DatasourceDefinition): void;
-}

+ 0 - 8
src/definition/datasource/datasource-definition.d.ts

@@ -1,8 +0,0 @@
-/**
- * Datasource definition.
- */
-export declare type DatasourceDefinition = {
-  name: string;
-  adapter: string;
-  [option: string]: unknown;
-};

+ 0 - 2
src/definition/datasource/index.d.ts

@@ -1,2 +0,0 @@
-export * from './datasource-definition.js';
-export * from './datasource-definition-validator.js';

+ 0 - 50
src/definition/definition-registry.d.ts

@@ -1,50 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {ModelDefinition} from './model/index.js';
-import {DatasourceDefinition} from './datasource/index.js';
-
-/**
- * Definition registry.
- */
-export declare class DefinitionRegistry extends Service {
-  /**
-   * Add datasource.
-   *
-   * @param datasourceDef
-   */
-  addDatasource(datasourceDef: DatasourceDefinition): void;
-
-  /**
-   * Has datasource.
-   *
-   * @param name
-   */
-  hasDatasource(name: string): boolean;
-
-  /**
-   * Get datasource.
-   *
-   * @param name
-   */
-  getDatasource(name: string): DatasourceDefinition;
-
-  /**
-   * Add model.
-   *
-   * @param modelDef
-   */
-  addModel(modelDef: ModelDefinition): void;
-
-  /**
-   * Has model.
-   *
-   * @param name
-   */
-  hasModel(name: string): boolean;
-
-  /**
-   * Get model.
-   *
-   * @param name
-   */
-  getModel(name: string): ModelDefinition;
-}

+ 0 - 3
src/definition/index.d.ts

@@ -1,3 +0,0 @@
-export * from './model/index.js';
-export * from './datasource/index.js';
-export * from './definition-registry.js';

+ 0 - 6
src/definition/model/index.d.ts

@@ -1,6 +0,0 @@
-export * from './relations/index.js';
-export * from './properties/index.js';
-export * from './model-definition.js';
-export * from './model-data-sanitizer.js';
-export * from './model-definition-utils.js';
-export * from './model-definition-validator.js';

+ 0 - 1
src/definition/model/index.js

@@ -1,6 +1,5 @@
 export * from './relations/index.js';
 export * from './properties/index.js';
-export * from './model-definition.js';
 export * from './model-data-sanitizer.js';
 export * from './model-definition-utils.js';
 export * from './model-definition-validator.js';

+ 0 - 15
src/definition/model/model-data-sanitizer.d.ts

@@ -1,15 +0,0 @@
-import {ModelData} from '../../types.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Model data sanitizer.
- */
-export declare class ModelDataSanitizer extends Service {
-  /**
-   * Sanitize.
-   *
-   * @param modelName
-   * @param modelData
-   */
-  sanitize(modelName: string, modelData: ModelData): ModelData;
-}

+ 0 - 180
src/definition/model/model-definition-utils.d.ts

@@ -1,180 +0,0 @@
-import {ModelData} from '../../types.js';
-import {Service} from '@e22m4u/js-service';
-import {DataType} from './properties/index.js';
-import {RelationDefinition} from './relations/index.js';
-import {PropertyDefinition} from './properties/index.js';
-import {PropertyDefinitionMap} from './model-definition.js';
-import {RelationDefinitionMap} from './model-definition.js';
-
-/**
- * Default primary key property name.
- */
-export const DEFAULT_PRIMARY_KEY_PROPERTY_NAME: 'id';
-
-/**
- * Model definition utils.
- */
-export declare class ModelDefinitionUtils extends Service {
-  /**
-   * Get primary key as property name.
-   *
-   * @param modelName
-   */
-  getPrimaryKeyAsPropertyName(modelName: string): string;
-
-  /**
-   * Get primary key as column name.
-   *
-   * @param modelName
-   */
-  getPrimaryKeyAsColumnName(modelName: string): string;
-
-  /**
-   * Get table name by model name.
-   *
-   * @param modelName
-   */
-  getTableNameByModelName(modelName: string): string;
-
-  /**
-   * Get column name by property name.
-   *
-   * @param modelName
-   * @param propertyName
-   */
-  getColumnNameByPropertyName(modelName: string, propertyName: string): string;
-
-  /**
-   * Get default property value.
-   *
-   * @param modelName
-   * @param propertyName
-   */
-  getDefaultPropertyValue(modelName: string, propertyName: string): unknown;
-
-  /**
-   * Set default values to empty properties.
-   *
-   * @param modelName
-   * @param modelData
-   * @param onlyProvidedProperties
-   */
-  setDefaultValuesToEmptyProperties<T extends ModelData>(
-    modelName: string,
-    modelData: T,
-    onlyProvidedProperties?: boolean,
-  ): T;
-
-  /**
-   * Convert property names to column names.
-   *
-   * @param modelName
-   * @param modelData
-   */
-  convertPropertyNamesToColumnNames(
-    modelName: string,
-    modelData: ModelData,
-  ): ModelData;
-
-  /**
-   * Convert column names to property names.
-   *
-   * @param modelName
-   * @param tableData
-   */
-  convertColumnNamesToPropertyNames(
-    modelName: string,
-    tableData: ModelData,
-  ): ModelData;
-
-  /**
-   * Get data type by property name.
-   *
-   * @param modelName
-   * @param propertyName
-   */
-  getDataTypeByPropertyName(modelName: string, propertyName: string): DataType;
-
-  /**
-   * Get data type from property definition.
-   *
-   * @param propDef
-   */
-  getDataTypeFromPropertyDefinition(propDef: PropertyDefinition): DataType;
-
-  /**
-   * Get own properties definition of primary keys.
-   *
-   * @param modelName
-   */
-  getOwnPropertiesDefinitionOfPrimaryKeys(
-    modelName: string,
-  ): PropertyDefinitionMap;
-
-  /**
-   * Get own properties definition without primary keys.
-   *
-   * @param modelName
-   */
-  getOwnPropertiesDefinitionWithoutPrimaryKeys(
-    modelName: string,
-  ): PropertyDefinitionMap;
-
-  /**
-   * Get properties definition in base model hierarchy.
-   *
-   * @param modelName
-   */
-  getPropertiesDefinitionInBaseModelHierarchy(
-    modelName: string,
-  ): PropertyDefinitionMap;
-
-  /**
-   * Get own relations definition.
-   *
-   * @param modelName
-   */
-  getOwnRelationsDefinition(modelName: string): RelationDefinitionMap;
-
-  /**
-   * Get relations definition in base model hierarchy.
-   *
-   * @param modelName
-   */
-  getRelationsDefinitionInBaseModelHierarchy(
-    modelName: string,
-  ): RelationDefinitionMap;
-
-  /**
-   * Get relation definition by name.
-   *
-   * @param modelName
-   * @param relationName
-   */
-  getRelationDefinitionByName(
-    modelName: string,
-    relationName: string,
-  ): RelationDefinition;
-
-  /**
-   * Exclude object keys by relation names.
-   *
-   * @param modelName
-   * @param modelData
-   */
-  excludeObjectKeysByRelationNames<T extends ModelData>(
-    modelName: string,
-    modelData: T,
-  ): Partial<T>;
-
-  /**
-   * Get model name of property value if defined.
-   *
-   * @param modelName
-   * @param propertyName
-   */
-  getModelNameOfPropertyValueIfDefined(
-    modelName: string,
-    propertyName: string,
-  ): string | undefined;
-}

+ 1 - 2
src/definition/model/model-definition-utils.js

@@ -1,10 +1,9 @@
 import {Service} from '@e22m4u/js-service';
 import {DataType} from './properties/index.js';
-import {cloneDeep} from '../../utils/index.js';
-import {excludeObjectKeys} from '../../utils/index.js';
 import {EmptyValuesService} from '@e22m4u/js-empty-values';
 import {InvalidArgumentError} from '../../errors/index.js';
 import {DefinitionRegistry} from '../definition-registry.js';
+import {cloneDeep, excludeObjectKeys} from '../../utils/index.js';
 
 /**
  * Default primary key property name.

+ 5 - 2
src/definition/model/model-definition-utils.spec.js

@@ -6,8 +6,11 @@ import {RelationType} from './relations/index.js';
 import {DatabaseSchema} from '../../database-schema.js';
 import {EmptyValuesService} from '@e22m4u/js-empty-values';
 import {InvalidArgumentError} from '../../errors/index.js';
-import {ModelDefinitionUtils} from './model-definition-utils.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from './model-definition-utils.js';
+
+import {
+  ModelDefinitionUtils,
+  DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
+} from './model-definition-utils.js';
 
 const sandbox = chai.spy.sandbox();
 

+ 0 - 14
src/definition/model/model-definition-validator.d.ts

@@ -1,14 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {ModelDefinition} from './model-definition.js';
-
-/**
- * Model definition validator.
- */
-export declare class ModelDefinitionValidator extends Service {
-  /**
-   * Validate.
-   *
-   * @param modelDef
-   */
-  validate(modelDef: ModelDefinition): void;
-}

+ 0 - 28
src/definition/model/model-definition.d.ts

@@ -1,28 +0,0 @@
-import {RelationDefinition} from './relations/index.js';
-import {PropertyDefinition} from './properties/index.js';
-
-/**
- * Property definition map.
- */
-export declare type PropertyDefinitionMap = {
-  [name: string]: PropertyDefinition;
-};
-
-/**
- * Relation definition map.
- */
-export declare type RelationDefinitionMap = {
-  [name: string]: RelationDefinition;
-};
-
-/**
- * Model definition.
- */
-export declare type ModelDefinition = {
-  name: string;
-  datasource?: string;
-  base?: string;
-  tableName?: string;
-  properties?: PropertyDefinitionMap;
-  relations?: RelationDefinitionMap;
-};

+ 0 - 1
src/definition/model/model-definition.js

@@ -1 +0,0 @@
-export {};

+ 0 - 16
src/definition/model/properties/data-type.d.ts

@@ -1,16 +0,0 @@
-/**
- * Data type.
- */
-export declare const DataType: {
-  ANY: 'any';
-  STRING: 'string';
-  NUMBER: 'number';
-  BOOLEAN: 'boolean';
-  ARRAY: 'array';
-  OBJECT: 'object';
-};
-
-/**
- * Type of DataType.
- */
-export type DataType = (typeof DataType)[keyof typeof DataType];

+ 0 - 6
src/definition/model/properties/index.d.ts

@@ -1,6 +0,0 @@
-export * from './data-type.js';
-export * from './property-definition.js';
-export * from './property-uniqueness.js';
-export * from './property-uniqueness-validator.js';
-export * from './properties-definition-validator.js';
-export * from './primary-keys-definition-validator.js';

+ 0 - 1
src/definition/model/properties/index.js

@@ -1,5 +1,4 @@
 export * from './data-type.js';
-export * from './property-definition.js';
 export * from './property-uniqueness.js';
 export * from './property-uniqueness-validator.js';
 export * from './properties-definition-validator.js';

+ 0 - 15
src/definition/model/properties/primary-keys-definition-validator.d.ts

@@ -1,15 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {PropertyDefinitionMap} from '../model-definition.js';
-
-/**
- * Primary keys definition validator.
- */
-export declare class PrimaryKeysDefinitionValidator extends Service {
-  /**
-   * Validate.
-   *
-   * @param modelName
-   * @param propDefs
-   */
-  validate(modelName: string, propDefs: PropertyDefinitionMap): void;
-}

+ 0 - 15
src/definition/model/properties/properties-definition-validator.d.ts

@@ -1,15 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {PropertyDefinitionMap} from '../model-definition.js';
-
-/**
- * Properties definition validator.
- */
-export declare class PropertiesDefinitionValidator extends Service {
-  /**
-   * Validate.
-   *
-   * @param modelName
-   * @param propDefs
-   */
-  validate(modelName: string, propDefs: PropertyDefinitionMap): void;
-}

+ 0 - 23
src/definition/model/properties/property-definition.d.ts

@@ -1,23 +0,0 @@
-import {DataType} from './data-type.js';
-import {PropertyUniqueness} from './property-uniqueness.js';
-
-/**
- * Full property definition.
- */
-export declare type FullPropertyDefinition = {
-  type: DataType;
-  itemType?: DataType;
-  itemModel?: string;
-  model?: string;
-  primaryKey?: boolean;
-  columnName?: string;
-  columnType?: string;
-  required?: boolean;
-  default?: unknown;
-  unique?: boolean | PropertyUniqueness;
-};
-
-/**
- * Property definition.
- */
-export declare type PropertyDefinition = DataType | FullPropertyDefinition;

+ 0 - 1
src/definition/model/properties/property-definition.js

@@ -1 +0,0 @@
-export {};

+ 0 - 31
src/definition/model/properties/property-uniqueness-validator.d.ts

@@ -1,31 +0,0 @@
-import {ModelId} from '../../../types.js';
-import {Service} from '@e22m4u/js-service';
-import {ModelData} from '../../../types.js';
-import {WhereClause} from '../../../filter/index.js';
-
-/**
- * Count method.
- */
-type CountMethod = (where: WhereClause) => Promise<number>;
-
-/**
- * Property uniqueness validator.
- */
-export declare class PropertyUniquenessValidator extends Service {
-  /**
-   * Validate.
-   *
-   * @param countMethod
-   * @param methodName
-   * @param modelName
-   * @param modelData
-   * @param modelId
-   */
-  validate(
-    countMethod: CountMethod,
-    methodName: string,
-    modelName: string,
-    modelData: ModelData,
-    modelId?: ModelId,
-  ): Promise<void>;
-}

+ 0 - 14
src/definition/model/properties/property-uniqueness.d.ts

@@ -1,14 +0,0 @@
-/**
- * Property uniqueness.
- */
-export declare const PropertyUniqueness: {
-  STRICT: 'strict';
-  SPARSE: 'sparse';
-  NON_UNIQUE: 'nonUnique';
-};
-
-/**
- * Type of PropertyUniqueness.
- */
-export type PropertyUniqueness =
-  (typeof PropertyUniqueness)[keyof typeof PropertyUniqueness];

+ 0 - 3
src/definition/model/relations/index.d.ts

@@ -1,3 +0,0 @@
-export * from './relation-type.js';
-export * from './relation-definition.js';
-export * from './relations-definition-validator.js';

+ 0 - 1
src/definition/model/relations/index.js

@@ -1,3 +1,2 @@
 export * from './relation-type.js';
-export * from './relation-definition.js';
 export * from './relations-definition-validator.js';

+ 0 - 236
src/definition/model/relations/relation-definition.d.ts

@@ -1,236 +0,0 @@
-import {RelationType} from './relation-type.js';
-
-/**
- * Relation definition.
- *
- * @example Available options.
- * ```ts
- * {
- *   type: RelationType;
- *   model?: string;
- *   foreignKey?: string;
- *   polymorphic?: boolean | string;
- *   discriminator?: string;
- * }
- * ```
- */
-export declare type RelationDefinition =
-  // belongsTo
-  | BelongsToDefinition
-  | PolyBelongsToDefinition
-  // hasOne
-  | HasOneDefinition
-  | PolyHasOneDefinitionWithTargetRelationName
-  | PolyHasOneDefinitionWithTargetKeys
-  // hasMany
-  | HasManyDefinition
-  | PolyHasManyDefinitionWithTargetRelationName
-  | PolyHasManyDefinitionWithTargetKeys
-  // referencesMany
-  | ReferencesManyDefinition;
-
-/**
- * The regular "belongsTo" relation.
- *
- * @example Required options only.
- * ```
- * {
- *   type: 'belongsTo',
- *   model: 'model',
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- *   type: 'belongsTo',
- *   model: 'model',
- *   foreignKey: 'modelId',
- * }
- * ```
- */
-export declare type BelongsToDefinition = {
-  type: typeof RelationType.BELONGS_TO;
-  polymorphic?: false;
-  model: string;
-  foreignKey?: string;
-};
-
-/**
- * The polymorphic "belongsTo" relation.
- *
- * @example Required fields only.
- * ```
- * {
- *   type: 'belongsTo',
- *   polymorphic: true,
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- *   type: 'belongsTo',
- *   polymorphic: true,
- *   foreignKey: 'referenceId',
- *   discriminator: 'referenceType',
- * }
- * ```
- */
-export declare type PolyBelongsToDefinition = {
-  type: typeof RelationType.BELONGS_TO;
-  polymorphic: true;
-  foreignKey?: string;
-  discriminator?: string;
-};
-
-/**
- * The regular "hasOne" relation.
- *
- * @example
- * ```ts
- * {
- *   type: 'hasOne',
- *   model: 'model',
- *   foreignKey: 'modelId',
- * }
- * ```
- */
-export declare type HasOneDefinition = {
-  type: typeof RelationType.HAS_ONE;
-  model: string;
-  foreignKey: string;
-  polymorphic?: false;
-  discriminator?: undefined;
-};
-
-/**
- * The polymorphic "hasOne" relation with a target relation name.
- *
- * @example
- * ```ts
- * {
- *   type: 'hasOne',
- *   model: 'model',
- *   polymorphic: 'reference',
- * }
- * ```
- */
-export declare type PolyHasOneDefinitionWithTargetRelationName = {
-  type: typeof RelationType.HAS_ONE;
-  model: string;
-  polymorphic: string;
-  foreignKey?: undefined;
-  discriminator?: undefined;
-};
-
-/**
- * The polymorphic "hasOne" relation with target relation keys.
- *
- * @example
- * ```
- * {
- *   type: 'hasOne',
- *   model: 'model',
- *   polymorphic: true,
- *   foreignKey: 'referenceId',
- *   discriminator: 'referenceType',
- * }
- * ```
- */
-export declare type PolyHasOneDefinitionWithTargetKeys = {
-  type: typeof RelationType.HAS_ONE;
-  model: string;
-  polymorphic: true;
-  foreignKey: string;
-  discriminator: string;
-};
-
-/**
- * The regular "hasMany" relation.
- *
- * @example
- * ```ts
- * {
- *   type: 'hasMany',
- *   model: 'model',
- *   foreignKey: 'modelId',
- * }
- * ```
- */
-export declare type HasManyDefinition = {
-  type: typeof RelationType.HAS_MANY;
-  model: string;
-  foreignKey: string;
-  polymorphic?: false;
-  discriminator?: undefined;
-};
-
-/**
- * The polymorphic "hasMany" relation with a target relation name.
- *
- * @example
- * ```ts
- * {
- *   type: 'hasMany',
- *   model: 'model',
- *   polymorphic: 'reference',
- * }
- * ```
- */
-export declare type PolyHasManyDefinitionWithTargetRelationName = {
-  type: typeof RelationType.HAS_MANY;
-  model: string;
-  polymorphic: string;
-  foreignKey?: undefined;
-  discriminator?: undefined;
-};
-
-/**
- * The polymorphic "hasMany" relation with target relation keys.
- *
- * @example
- * ```
- * {
- *   type: 'hasMany',
- *   model: 'model',
- *   polymorphic: true,
- *   foreignKey: 'referenceId',
- *   discriminator: 'referenceType',
- * }
- * ```
- */
-export declare type PolyHasManyDefinitionWithTargetKeys = {
-  type: typeof RelationType.HAS_MANY;
-  model: string;
-  polymorphic: true;
-  foreignKey: string;
-  discriminator: string;
-};
-
-/**
- * The regular "referencesMany" relation.
- *
- * @example Required options only.
- * ```
- * {
- *   type: 'referencesMany',
- *   model: 'model',
- * }
- * ```
- *
- * @example Verbose definition.
- * ```
- * {
- *   type: 'referencesMany',
- *   model: 'model',
- *   foreignKey: 'modelIds',
- * }
- * ```
- */
-export declare type ReferencesManyDefinition = {
-  type: typeof RelationType.REFERENCES_MANY;
-  model: string;
-  foreignKey?: string;
-  discriminator?: undefined;
-};

+ 0 - 1
src/definition/model/relations/relation-definition.js

@@ -1 +0,0 @@
-export {};

+ 0 - 14
src/definition/model/relations/relation-type.d.ts

@@ -1,14 +0,0 @@
-/**
- * Relation type.
- */
-export declare const RelationType: {
-  BELONGS_TO: 'belongsTo';
-  HAS_ONE: 'hasOne';
-  HAS_MANY: 'hasMany';
-  REFERENCES_MANY: 'referencesMany';
-};
-
-/**
- * Type of RelationType.
- */
-export type RelationType = (typeof RelationType)[keyof typeof RelationType];

+ 0 - 15
src/definition/model/relations/relations-definition-validator.d.ts

@@ -1,15 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-import {RelationDefinitionMap} from '../model-definition.js';
-
-/**
- * Relations definition validator.
- */
-export declare class RelationsDefinitionValidator extends Service {
-  /**
-   * Validate.
-   *
-   * @param modelName
-   * @param relDefs
-   */
-  validate(modelName: string, relDefs: RelationDefinitionMap): void;
-}

+ 4 - 5
src/definition/model/relations/relations-definition-validator.js

@@ -1,6 +1,5 @@
 import {Service} from '@e22m4u/js-service';
 import {RelationType} from './relation-type.js';
-import {RelationType as Type} from './relation-type.js';
 import {InvalidArgumentError} from '../../../errors/index.js';
 
 /**
@@ -62,13 +61,13 @@ export class RelationsDefinitionValidator extends Service {
         modelName,
         relDef,
       );
-    if (!relDef.type || !Object.values(Type).includes(relDef.type))
+    if (!relDef.type || !Object.values(RelationType).includes(relDef.type))
       throw new InvalidArgumentError(
         'The relation %v of the model %v requires the option "type" ' +
           'to have one of relation types: %l, but %v was given.',
         relName,
         modelName,
-        Object.values(Type),
+        Object.values(RelationType),
         relDef.type,
       );
     this._validateBelongsTo(modelName, relName, relDef);
@@ -105,7 +104,7 @@ export class RelationsDefinitionValidator extends Service {
    * @private
    */
   _validateBelongsTo(modelName, relName, relDef) {
-    if (relDef.type !== Type.BELONGS_TO) return;
+    if (relDef.type !== RelationType.BELONGS_TO) return;
     if (relDef.polymorphic) {
       // A polymorphic "belongsTo" relation.
       if (typeof relDef.polymorphic !== 'boolean')
@@ -419,7 +418,7 @@ export class RelationsDefinitionValidator extends Service {
    * @private
    */
   _validateReferencesMany(modelName, relName, relDef) {
-    if (relDef.type !== Type.REFERENCES_MANY) return;
+    if (relDef.type !== RelationType.REFERENCES_MANY) return;
     if (!relDef.model || typeof relDef.model !== 'string')
       throw new InvalidArgumentError(
         'The relation %v of the model %v has the type "referencesMany", ' +

+ 0 - 3
src/errors/index.d.ts

@@ -1,3 +0,0 @@
-export * from './not-implemented-error.js';
-export * from './invalid-argument-error.js';
-export * from './invalid-operator-value-error.js';

+ 0 - 6
src/errors/invalid-argument-error.d.ts

@@ -1,6 +0,0 @@
-import {Errorf} from '@e22m4u/js-format';
-
-/**
- * Invalid argument error.
- */
-export declare class InvalidArgumentError extends Errorf {}

+ 0 - 13
src/errors/invalid-operator-value-error.d.ts

@@ -1,13 +0,0 @@
-/**
- * Invalid operator value error.
- */
-export declare class InvalidOperatorValueError extends Error {
-  /**
-   * Constructor.
-   *
-   * @param operator
-   * @param expects
-   * @param value
-   */
-  constructor(operator: string, expects: string, value: unknown);
-}

+ 0 - 6
src/errors/not-implemented-error.d.ts

@@ -1,6 +0,0 @@
-import {Errorf} from '@e22m4u/js-format';
-
-/**
- * Not implemented error.
- */
-export declare class NotImplementedError extends Errorf {}

+ 0 - 38
src/filter/fields-clause-tool.d.ts

@@ -1,38 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {FieldsClause} from './filter-clause.js';
-import {NormalizedFieldsClause} from './filter-clause.js';
-
-/**
- * Field clause tool.
- */
-export declare class FieldsClauseTool extends Service {
-  /**
-   * Filter.
-   *
-   * @param input
-   * @param modelName
-   * @param clause
-   */
-  filter<T extends ModelData | ModelData[]>(
-    input: T,
-    modelName: string,
-    clause: FieldsClause | undefined,
-  ): T;
-
-  /**
-   * Validate fields clause.
-   *
-   * @param clause
-   */
-  static validateFieldsClause(clause: FieldsClause | undefined): void;
-
-  /**
-   * Normalize fields clause.
-   *
-   * @param clause
-   */
-  static normalizeFieldsClause(
-    clause: FieldsClause | undefined,
-  ): NormalizedFieldsClause | undefined;
-}

+ 0 - 348
src/filter/filter-clause.d.ts

@@ -1,348 +0,0 @@
-import {ModelData} from '../types.js';
-
-/**
- * Filter clause.
- */
-export declare type FilterClause<M extends object = ModelData> = {
-  where?: WhereClause<M>;
-  order?: OrderClause<M>;
-  limit?: number;
-  skip?: number;
-  fields?: FieldsClause<M>;
-  include?: IncludeClause<M>;
-};
-
-/**
- * Item filter clause.
- */
-export declare type ItemFilterClause<M extends object = ModelData> = Pick<
-  FilterClause<M>,
-  'fields' | 'include'
->;
-
-/**
- * Where clause.
- *
- * @example
- * ```ts
- * value => value.featured === true
- * {foo: 'bar'}
- * {foo: {eq: 'bar'}}
- * {foo: {neq: 'bar'}}
- * {foo: {gt: 5}}
- * {foo: {lt: 10}}
- * {foo: {gte: 5}}
- * {foo: {lte: 10}}
- * {foo: {inq: ['bar', 'baz']}}
- * {foo: {nin: ['bar', 'baz']}}
- * {foo: {between: [5, 10]}}
- * {foo: {exists: true}}
- * {foo: {like: 'bar'}}
- * {foo: {ilike: 'BaR'}}
- * {foo: {nlike: 'bar'}}
- * {foo: {nilike: 'BaR'}}
- * {foo: {regexp: 'ba.+'}}
- * {foo: {regexp: 'ba.+', flags: 'i'}}
- * {and: [...]}
- * {or: [...]}
- * ```
- */
-export declare type WhereClause<M extends object = ModelData> =
-  Partial<AndClause<M>> |
-  Partial<OrClause<M>> |
-  PropertiesClause<M>;
-
-/**
- * Primitive values.
- */
-export declare type PrimitiveValue =
-  | string
-  | number
-  | boolean
-  | null
-  | undefined;
-
-/**
- * Properties clause.
- *
- * @example
- * ```ts
- * {
- *   name: {inq: ['John', 'Mary']},
- *   status: 'ACTIVE',
- *   age: {gte: 40}
- * }
- * ```
- */
-export declare type PropertiesClause<M extends object = ModelData> = {
-  [property in keyof M]?: OperatorClause | PrimitiveValue | RegExp;
-};
-
-/**
- * Operator clause.
- *
- * @example
- * ```ts
- * {eq: 'bar'}
- * {neq: 'bar'}
- * {gt: 5}
- * {lt: 10}
- * {gte: 5}
- * {lte: 10}
- * {inq: ['bar', 'baz']}
- * {nin: ['bar', 'baz']}
- * {between: [5, 10]}
- * {exists: true}
- * {like: 'bar'}
- * {ilike: 'BaR'}
- * {nlike: 'bar'}
- * {nilike: 'BaR'}
- * {regexp: 'ba.+'}
- * {regexp: 'ba.+', flags: 'i'}
- * ```
- */
-export declare type OperatorClause = {
-  eq?: PrimitiveValue;
-  neq?: PrimitiveValue;
-  gt?: string | number;
-  gte?: string | number;
-  lt?: string | number;
-  lte?: string | number;
-  inq?: PrimitiveValue[];
-  nin?: PrimitiveValue[];
-  between?: readonly [string | number, string | number];
-  exists?: boolean;
-  like?: string;
-  nlike?: string;
-  ilike?: string;
-  nilike?: string;
-  regexp?: string | RegExp;
-  flags?: string;
-};
-
-/**
- * And clause.
- *
- * @example
- * ```ts
- * {
- *   and: [...],
- * }
- * ```
- */
-export interface AndClause<M extends object = ModelData> {
-  and: WhereClause<M>[];
-}
-
-/**
- * Or clause.
- *
- * @example
- * ```ts
- * {
- *   or: [...],
- * }
- * ```
- */
-export interface OrClause<M extends object = ModelData> {
-  or: WhereClause<M>[];
-}
-
-/**
- * Order clause item.
- *
- * @example
- * ```ts
- * 'prop'
- * 'prop ASC'
- * 'prop DESC';
- * ```
- */
-export declare type OrderClauseItem<M extends object = ModelData> = {
-  [prop in keyof M]: prop | `${prop & string} ASC` | `${prop & string} DESC`;
-}[keyof M];
-
-/**
- * Order clause.
- *
- * @example
- * ```ts
- * 'prop'
- * 'prop ASC'
- * 'prop DESC';
- * ['prop1', 'prop2'];
- * ['prop1 ASC', 'prop2 DESC'];
- * ```
- */
-export declare type OrderClause<M extends object = ModelData> =
-  | OrderClauseItem<M>
-  | OrderClauseItem<M>[];
-
-/**
- * Fields.
- *
- * @example
- * ```ts
- * 'prop'
- * ['prop1', 'prop2']
- * ```
- */
-export declare type FieldsClause<M extends object = ModelData> =
-  | keyof M
-  | NormalizedFieldsClause<M>;
-
-/**
- * Normalized fields clause.
- *
- * @example
- * ```ts
- * [
- *   'prop1',
- *   'prop2',
- * ]
- * ```
- */
-export declare type NormalizedFieldsClause<M extends object = ModelData> =
-  (keyof M)[];
-
-/**
- * Include clause.
- *
- * @example
- * ```ts
- * 'customers'
- * ```
- *
- * @example
- * ```ts
- * [
- *   'customers',
- *   'orders',
- * ]
- * ```
- *
- * @example
- * ```ts
- * {
- *   customer: 'orders'
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   customer: {
- *     address: 'city',
- *   },
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   customer: [
- *     'orders',
- *     {address: 'city'},
- *   ],
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   relation: 'customer',
- *   scope: {
- *     where: {removed: false},
- *     order: 'createdAt DESC',
- *     skip: 0,
- *     limit: 16,
- *     fields: ['id', 'name', 'removed'],
- *     include: 'address',
- *   }
- * }
- * ```
- */
-export declare type IncludeClause<M extends object = ModelData> =
-  | keyof M
-  | (keyof M)[]
-  | NestedIncludeClause<M>
-  | NormalizedIncludeClause<M>
-  | IncludeClause[];
-
-/**
- * Nested include clause.
- *
- * @example
- * ```ts
- * {
- *   customer: 'orders'
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   customer: {
- *     address: 'city',
- *   },
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   customer: [
- *     'orders',
- *     {address: 'city'},
- *   ],
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   relation: 'customer',
- *   scope: {
- *     where: {removed: false},
- *     order: 'createdAt DESC',
- *     skip: 0,
- *     limit: 16,
- *     fields: ['id', 'name', 'removed'],
- *     include: 'address',
- *   }
- * }
- * ```
- */
-export declare type NestedIncludeClause<M extends object = ModelData> = {
-  [property in keyof M]?: IncludeClause;
-};
-
-/**
- * Inclusion.
- *
- * @example
- * ```ts
- * {
- *   relation: 'customer',
- * }
- * ```
- *
- * @example
- * ```ts
- * {
- *   relation: 'customer',
- *   scope: {
- *     where: {removed: false},
- *     order: 'createdAt DESC',
- *     skip: 0,
- *     limit: 16,
- *     fields: ['id', 'name', 'removed'],
- *     include: 'address',
- *   }
- * }
- * ```
- */
-export declare interface NormalizedIncludeClause<M extends object = ModelData> {
-  relation: keyof M;
-  scope?: FilterClause;
-}

+ 0 - 55
src/filter/include-clause-tool.d.ts

@@ -1,55 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {FilterClause} from './filter-clause.js';
-import {IncludeClause} from './filter-clause.js';
-import {NormalizedIncludeClause} from './filter-clause.js';
-
-/**
- * Include clause tool.
- */
-export declare class IncludeClauseTool extends Service {
-  /**
-   * Include to.
-   *
-   * @param entities
-   * @param modelName
-   * @param clause
-   */
-  includeTo(
-    entities: ModelData[],
-    modelName: string,
-    clause: IncludeClause | undefined,
-  ): Promise<void>;
-
-  /**
-   * Validate include clause.
-   *
-   * @param clause
-   */
-  static validateIncludeClause(clause: IncludeClause | undefined): void;
-
-  /**
-   * Validate scope clause.
-   *
-   * @param clause
-   */
-  static validateScopeClause(clause: FilterClause | undefined): void;
-
-  /**
-   * Normalize include clause.
-   *
-   * @param clause
-   */
-  static normalizeIncludeClause(
-    clause: IncludeClause | undefined,
-  ): NormalizedIncludeClause[];
-
-  /**
-   * Normalize scope clause.
-   *
-   * @param clause
-   */
-  static normalizeScopeClause(
-    clause: FilterClause | undefined,
-  ): FilterClause | undefined;
-}

+ 8 - 6
src/filter/include-clause-tool.js

@@ -1,15 +1,17 @@
 import {Service} from '@e22m4u/js-service';
-import {RelationType} from '../definition/index.js';
-import {HasOneResolver} from '../relations/index.js';
-import {HasManyResolver} from '../relations/index.js';
 import {WhereClauseTool} from './where-clause-tool.js';
 import {OrderClauseTool} from './order-clause-tool.js';
 import {SliceClauseTool} from './slice-clause-tool.js';
 import {InvalidArgumentError} from '../errors/index.js';
-import {BelongsToResolver} from '../relations/index.js';
 import {FieldsClauseTool} from './fields-clause-tool.js';
-import {ModelDefinitionUtils} from '../definition/index.js';
-import {ReferencesManyResolver} from '../relations/index.js';
+import {RelationType, ModelDefinitionUtils} from '../definition/index.js';
+
+import {
+  HasOneResolver,
+  HasManyResolver,
+  BelongsToResolver,
+  ReferencesManyResolver,
+} from '../relations/index.js';
 
 /**
  * Include clause tool.

+ 0 - 7
src/filter/index.d.ts

@@ -1,7 +0,0 @@
-export * from './filter-clause.js';
-export * from './slice-clause-tool.js';
-export * from './order-clause-tool.js';
-export * from './where-clause-tool.js';
-export * from './fields-clause-tool.js';
-export * from './include-clause-tool.js';
-export * from './operator-clause-tool.js';

+ 0 - 224
src/filter/operator-clause-tool.d.ts

@@ -1,224 +0,0 @@
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Operator clause tool.
- */
-export declare class OperatorClauseTool extends Service {
-  /**
-   * Compare.
-   *
-   * @param val1
-   * @param val2
-   * @param noTypeConversion
-   */
-  compare(val1: unknown, val2: unknown, noTypeConversion?: boolean): number;
-
-  /**
-   * Test all operators.
-   *
-   * @param clause
-   * @param value
-   */
-  testAll(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test eq/neq operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   eq: 'foo',
-   * }
-   * ```
-   *
-   * @example
-   * ```ts
-   * {
-   *   neq: 'foo',
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testEqNeq(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test lt/gt/lte/gte operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   lt: 10,
-   * }
-   * ```
-   *
-   * @example
-   * ```ts
-   * {
-   *   lte: 10,
-   * }
-   * ```
-   *
-   * @example
-   * ```ts
-   * {
-   *   gt: 10,
-   * }
-   * ```
-   *
-   * @example
-   * ```ts
-   * {
-   *   gte: 10,
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testGtLt(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test inc operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   inc: ['foo', 'bar'],
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testInq(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test nin operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   nin: ['foo', 'bar'],
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testNin(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test between operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   between: [10, 20],
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testBetween(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test exists operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   exists: true,
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testExists(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test like operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   like: 'foo',
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testLike(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test nlike operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   nlike: 'foo',
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testNlike(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test ilike operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   ilike: 'foo',
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testIlike(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test nilike operator.
-   *
-   * @example
-   * ```ts
-   * {
-   *   nilike: 'foo',
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testNilike(clause: object, value: unknown): boolean | undefined;
-
-  /**
-   * Test regexp.
-   *
-   * @example
-   * ```ts
-   * {
-   *   regexp: 'foo.*',
-   * }
-   * ```
-   *
-   * @example
-   * ```ts
-   * {
-   *   regexp: 'foo.*',
-   *   flags: 'i',
-   * }
-   * ```
-   *
-   * @param clause
-   * @param value
-   */
-  testRegexp(clause: object, value: unknown): boolean | undefined;
-}

+ 0 - 32
src/filter/order-clause-tool.d.ts

@@ -1,32 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {OrderClause} from './filter-clause.js';
-
-/**
- * Order clause tool.
- */
-export declare class OrderClauseTool extends Service {
-  /**
-   * Sort.
-   *
-   * @param entities
-   * @param clause
-   */
-  sort(entities: ModelData[], clause: OrderClause | undefined): void;
-
-  /**
-   * Validate order clause.
-   *
-   * @param clause
-   */
-  static validateOrderClause(clause: OrderClause | undefined): void;
-
-  /**
-   * Normalize order clause.
-   *
-   * @param clause
-   */
-  static normalizeOrderClause(
-    clause: OrderClause | undefined,
-  ): string[] | undefined;
-}

+ 0 - 30
src/filter/slice-clause-tool.d.ts

@@ -1,30 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Slice clause tool.
- */
-export declare class SliceClauseTool extends Service {
-  /**
-   * Slice.
-   *
-   * @param entities
-   * @param skip
-   * @param limit
-   */
-  slice(entities: ModelData[], skip?: number, limit?: number): ModelData[];
-
-  /**
-   * Validate skip clause.
-   *
-   * @param skip
-   */
-  static validateSkipClause(skip: number | undefined): void;
-
-  /**
-   * Validate limit clause.
-   *
-   * @param limit
-   */
-  static validateLimitClause(limit: number | undefined): void;
-}

+ 0 - 23
src/filter/where-clause-tool.d.ts

@@ -1,23 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {WhereClause} from './filter-clause.js';
-
-/**
- * Where clause tool.
- */
-export declare class WhereClauseTool extends Service {
-  /**
-   * Filter.
-   *
-   * @param entities
-   * @param where
-   */
-  filter(entities: ModelData[], where: WhereClause | undefined): ModelData[];
-
-  /**
-   * Validate where clause.
-   *
-   * @param clause
-   */
-  static validateWhereClause(clause: WhereClause | undefined): void;
-}

+ 0 - 9
src/index.d.ts

@@ -1,9 +0,0 @@
-export * from './types.js';
-export * from './utils/index.js';
-export * from './errors/index.js';
-export * from './filter/index.js';
-export * from './adapter/index.js';
-export * from './database-schema.js';
-export * from './relations/index.js';
-export * from './definition/index.js';
-export * from './repository/index.js';

+ 0 - 1
src/index.js

@@ -1,4 +1,3 @@
-export * from './types.js';
 export * from './utils/index.js';
 export * from './errors/index.js';
 export * from './filter/index.js';

+ 0 - 46
src/relations/belongs-to-resolver.d.ts

@@ -1,46 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {FilterClause} from '../filter/index.js';
-
-/**
- * Belongs to resolver.
- */
-export declare class BelongsToResolver extends Service {
-  /**
-   * Include to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param foreignKey
-   * @param scope
-   */
-  includeTo(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    foreignKey?: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-
-  /**
-   * Include polymorphic to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param relationName
-   * @param foreignKey
-   * @param discriminator
-   * @param scope
-   */
-  includePolymorphicTo(
-    entities: ModelData[],
-    sourceName: string,
-    relationName: string,
-    foreignKey?: string,
-    discriminator?: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-}

+ 1 - 2
src/relations/belongs-to-resolver.js

@@ -1,7 +1,6 @@
 import {Service} from '@e22m4u/js-service';
-import {cloneDeep} from '../utils/index.js';
-import {singularize} from '../utils/index.js';
 import {InvalidArgumentError} from '../errors/index.js';
+import {cloneDeep, singularize} from '../utils/index.js';
 import {RepositoryRegistry} from '../repository/index.js';
 import {ModelDefinitionUtils} from '../definition/index.js';
 

+ 6 - 3
src/relations/belongs-to-resolver.spec.js

@@ -1,10 +1,13 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/js-format';
-import {DataType} from '../definition/index.js';
-import {RelationType} from '../definition/index.js';
 import {DatabaseSchema} from '../database-schema.js';
 import {BelongsToResolver} from './belongs-to-resolver.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
+
+import {
+  DataType,
+  RelationType,
+  DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
+} from '../definition/index.js';
 
 describe('BelongsToResolver', function () {
   describe('includeTo', function () {

+ 0 - 67
src/relations/has-many-resolver.d.ts

@@ -1,67 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {FilterClause} from '../filter/index.js';
-
-/**
- * Has many resolver.
- */
-export declare class HasManyResolver extends Service {
-  /**
-   * Include to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param foreignKey
-   * @param scope
-   */
-  includeTo(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    foreignKey: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-
-  /**
-   * Include polymorphic to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param foreignKey
-   * @param discriminator
-   * @param scope
-   */
-  includePolymorphicTo(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    foreignKey: string,
-    discriminator: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-
-  /**
-   * Include polymorphic by relation name.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param targetRelationName
-   * @param scope
-   */
-  includePolymorphicByRelationName(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    targetRelationName: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-}

+ 1 - 2
src/relations/has-many-resolver.js

@@ -1,9 +1,8 @@
 import {Service} from '@e22m4u/js-service';
 import {cloneDeep} from '../utils/index.js';
-import {RelationType} from '../definition/index.js';
 import {InvalidArgumentError} from '../errors/index.js';
 import {RepositoryRegistry} from '../repository/index.js';
-import {ModelDefinitionUtils} from '../definition/index.js';
+import {RelationType, ModelDefinitionUtils} from '../definition/index.js';
 
 /**
  * Has many resolver.

+ 6 - 3
src/relations/has-many-resolver.spec.js

@@ -1,10 +1,13 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/js-format';
-import {DataType} from '../definition/index.js';
-import {RelationType} from '../definition/index.js';
 import {DatabaseSchema} from '../database-schema.js';
 import {HasManyResolver} from './has-many-resolver.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
+
+import {
+  DataType,
+  RelationType,
+  DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
+} from '../definition/index.js';
 
 describe('HasManyResolver', function () {
   describe('includeTo', function () {

+ 0 - 67
src/relations/has-one-resolver.d.ts

@@ -1,67 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {FilterClause} from '../filter/index.js';
-
-/**
- * Has one resolver.
- */
-export declare class HasOneResolver extends Service {
-  /**
-   * Include to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param foreignKey
-   * @param scope
-   */
-  includeTo(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    foreignKey: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-
-  /**
-   * Include polymorphic to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param foreignKey
-   * @param discriminator
-   * @param scope
-   */
-  includePolymorphicTo(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    foreignKey: string,
-    discriminator: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-
-  /**
-   * Include polymorphic by relation name.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param targetRelationName
-   * @param scope
-   */
-  includePolymorphicByRelationName(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    targetRelationName: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-}

+ 1 - 2
src/relations/has-one-resolver.js

@@ -1,9 +1,8 @@
 import {Service} from '@e22m4u/js-service';
 import {cloneDeep} from '../utils/index.js';
-import {RelationType} from '../definition/index.js';
 import {InvalidArgumentError} from '../errors/index.js';
 import {RepositoryRegistry} from '../repository/index.js';
-import {ModelDefinitionUtils} from '../definition/index.js';
+import {RelationType, ModelDefinitionUtils} from '../definition/index.js';
 
 /**
  * Has one resolver.

+ 6 - 3
src/relations/has-one-resolver.spec.js

@@ -1,10 +1,13 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/js-format';
-import {DataType} from '../definition/index.js';
-import {RelationType} from '../definition/index.js';
 import {HasOneResolver} from './has-one-resolver.js';
 import {DatabaseSchema} from '../database-schema.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
+
+import {
+  DataType,
+  RelationType,
+  DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
+} from '../definition/index.js';
 
 describe('HasOneResolver', function () {
   describe('includeTo', function () {

+ 0 - 4
src/relations/index.d.ts

@@ -1,4 +0,0 @@
-export * from './has-one-resolver.js';
-export * from './has-many-resolver.js';
-export * from './belongs-to-resolver.js';
-export * from './references-many-resolver.js';

+ 0 - 27
src/relations/references-many-resolver.d.ts

@@ -1,27 +0,0 @@
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {FilterClause} from '../filter/index.js';
-
-/**
- * References many resolver.
- */
-export declare class ReferencesManyResolver extends Service {
-  /**
-   * Include to.
-   *
-   * @param entities
-   * @param sourceName
-   * @param targetName
-   * @param relationName
-   * @param foreignKey
-   * @param scope
-   */
-  includeTo(
-    entities: ModelData[],
-    sourceName: string,
-    targetName: string,
-    relationName: string,
-    foreignKey?: string,
-    scope?: FilterClause,
-  ): Promise<void>;
-}

+ 1 - 2
src/relations/references-many-resolver.js

@@ -1,7 +1,6 @@
 import {Service} from '@e22m4u/js-service';
-import {cloneDeep} from '../utils/index.js';
-import {singularize} from '../utils/index.js';
 import {InvalidArgumentError} from '../errors/index.js';
+import {cloneDeep, singularize} from '../utils/index.js';
 import {RepositoryRegistry} from '../repository/index.js';
 import {ModelDefinitionUtils} from '../definition/index.js';
 

+ 6 - 3
src/relations/references-many-resolver.spec.js

@@ -1,10 +1,13 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/js-format';
-import {DataType} from '../definition/index.js';
-import {RelationType} from '../definition/index.js';
 import {DatabaseSchema} from '../database-schema.js';
 import {ReferencesManyResolver} from './references-many-resolver.js';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
+
+import {
+  DataType,
+  RelationType,
+  DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
+} from '../definition/index.js';
 
 describe('ReferencesManyResolver', function () {
   describe('includeTo', function () {

+ 0 - 2
src/repository/index.d.ts

@@ -1,2 +0,0 @@
-export * from './repository.js';
-export * from './repository-registry.js';

+ 0 - 29
src/repository/repository-registry.d.ts

@@ -1,29 +0,0 @@
-import {ModelId} from '../types.js';
-import {ModelData} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {Repository} from './repository.js';
-import {Constructor} from '@e22m4u/js-service';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME} from '../definition/index.js';
-
-/**
- * Repository registry.
- */
-export declare class RepositoryRegistry extends Service {
-  /**
-   * Set repository registry.
-   *
-   * @param ctor
-   */
-  setRepositoryCtor(ctor: Constructor<Repository<any, any, any>>): void;
-
-  /**
-   * Get repository.
-   *
-   * @param modelName
-   */
-  getRepository<
-    Data extends ModelData = ModelData,
-    IdType extends ModelId = ModelId,
-    IdName extends string = typeof DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
-  >(modelName: string): Repository<Data, IdType, IdName>;
-}

+ 0 - 183
src/repository/repository.d.ts

@@ -1,183 +0,0 @@
-import {ModelId} from '../types.js';
-import {Flatten} from '../types.js';
-import {ModelData} from '../types.js';
-import {PartialBy} from '../types.js';
-import {Service} from '@e22m4u/js-service';
-import {Adapter} from '../adapter/index.js';
-import {WhereClause} from '../filter/index.js';
-import {FilterClause} from '../filter/index.js';
-import {ItemFilterClause} from '../filter/index.js';
-import {ServiceContainer} from '@e22m4u/js-service';
-import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME} from '../definition/index.js';
-
-/**
- * Repository.
- */
-export declare class Repository<
-  Data extends object = ModelData,
-  IdType extends ModelId = ModelId,
-  IdName extends string = typeof DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
-  FlatData extends object = Flatten<Data>,
-> extends Service {
-  // it fixes unused generic bug
-  private _Data?: Data;
-  private _IdType?: IdType;
-  private _IdName?: IdName;
-  private _FlatData?: FlatData;
-
-  /**
-   * Model name.
-   */
-  get modelName(): string;
-
-  /**
-   * Datasource name.
-   */
-  get datasourceName(): string;
-
-  /**
-   * Constructor.
-   *
-   * @param container
-   * @param modelName
-   */
-  constructor(container: ServiceContainer, modelName: string);
-
-  /**
-   * Get adapter.
-   */
-  getAdapter(): Promise<Adapter>;
-
-  /**
-   * Create.
-   *
-   * @param data
-   * @param filter
-   */
-  create(
-    data: WithOptionalId<FlatData, IdName>,
-    filter?: ItemFilterClause<FlatData>,
-  ): Promise<FlatData>;
-
-  /**
-   * Replace by id.
-   *
-   * @param id
-   * @param data
-   * @param filter
-   */
-  replaceById(
-    id: IdType,
-    data: WithoutId<FlatData, IdName>,
-    filter?: ItemFilterClause<FlatData>,
-  ): Promise<FlatData>;
-
-  /**
-   * Replace or create.
-   *
-   * @param data
-   * @param filter
-   */
-  replaceOrCreate(
-    data: WithOptionalId<FlatData, IdName>,
-    filter?: ItemFilterClause<FlatData>,
-  ): Promise<FlatData>;
-
-  /**
-   * Patch.
-   *
-   * @param data
-   * @param where
-   */
-  patch(
-    data: PartialWithoutId<FlatData, IdName>,
-    where?: WhereClause<FlatData>,
-  ): Promise<number>;
-
-  /**
-   * Patch by id.
-   *
-   * @param id
-   * @param data
-   * @param filter
-   */
-  patchById(
-    id: IdType,
-    data: PartialWithoutId<FlatData, IdName>,
-    filter?: ItemFilterClause<FlatData>,
-  ): Promise<FlatData>;
-
-  /**
-   * Find.
-   *
-   * @param filter
-   */
-  find(filter?: FilterClause<FlatData>): Promise<FlatData[]>;
-
-  /**
-   * Find one.
-   *
-   * @param filter
-   */
-  findOne(filter?: FilterClause<FlatData>): Promise<FlatData | undefined>;
-
-  /**
-   * Find by id.
-   *
-   * @param id
-   * @param filter
-   */
-  findById(id: IdType, filter?: ItemFilterClause<FlatData>): Promise<FlatData>;
-
-  /**
-   * Delete.
-   *
-   * @param where
-   */
-  delete(where?: WhereClause<FlatData>): Promise<number>;
-
-  /**
-   * Delete by id.
-   *
-   * @param id
-   */
-  deleteById(id: IdType): Promise<boolean>;
-
-  /**
-   * Exists.
-   *
-   * @param id
-   */
-  exists(id: IdType): Promise<boolean>;
-
-  /**
-   * Count.
-   *
-   * @param where
-   */
-  count(where?: WhereClause<FlatData>): Promise<number>;
-}
-
-/**
- * Removes id field.
- */
-export declare type WithoutId<
-  Data extends object,
-  IdName extends string = 'id',
-> = Flatten<Omit<Data, IdName>>;
-
-/**
- * Makes fields as optional and remove id field.
- */
-export declare type PartialWithoutId<
-  Data extends object,
-  IdName extends string = 'id',
-> = Flatten<Partial<Omit<Data, IdName>>>;
-
-/**
- * Makes the required id field as optional.
- */
-export declare type WithOptionalId<
-  Data extends object,
-  IdName extends string = 'id',
-> = Flatten<Data extends {[K in IdName]: any} ? PartialBy<Data, IdName> : Data>;

+ 1 - 2
src/repository/repository.js

@@ -1,8 +1,7 @@
 import {Service} from '@e22m4u/js-service';
-import {Adapter} from '../adapter/index.js';
-import {AdapterRegistry} from '../adapter/index.js';
 import {InvalidArgumentError} from '../errors/index.js';
 import {DefinitionRegistry} from '../definition/index.js';
+import {Adapter, AdapterRegistry} from '../adapter/index.js';
 
 /**
  * Repository.

+ 0 - 43
src/types.d.ts

@@ -1,43 +0,0 @@
-/**
- * Free-form object with open properties.
- */
-export declare type AnyObject = {
-  [property: string]: unknown;
-};
-
-/**
- * Makes specific field as optional.
- */
-export declare type PartialBy<T, K extends keyof T> = Omit<T, K> &
-  Partial<Pick<T, K>>;
-
-/**
- * Model data.
- */
-export declare type ModelData = Record<string, unknown>;
-
-/**
- * Model id.
- */
-export declare type ModelId = unknown;
-
-/**
- * Flatten.
- */
-type Identity<T> = T;
-export declare type Flatten<T> = Identity<{[k in keyof T]: T[k]}>;
-
-/**
- * A callable type with the "new" operator
- * allows class and constructor.
- */
-export interface Constructor<T = unknown> {
-  new (...args: any[]): T;
-}
-
-/**
- * Representing a value or promise. This type is used
- * to represent results of synchronous/asynchronous
- * resolution of values.
- */
-export type ValueOrPromise<T> = T | PromiseLike<T>;

+ 0 - 1
src/types.js

@@ -1 +0,0 @@
-export {};

+ 0 - 6
src/utils/capitalize.d.ts

@@ -1,6 +0,0 @@
-/**
- * Capitalize.
- *
- * @param string
- */
-export declare function capitalize(string: string): string;

+ 0 - 6
src/utils/clone-deep.d.ts

@@ -1,6 +0,0 @@
-/**
- * Clone deep.
- *
- * @param value
- */
-export declare function cloneDeep<T>(value: T): T;

+ 0 - 10
src/utils/exclude-object-keys.d.ts

@@ -1,10 +0,0 @@
-/**
- * Exclude object keys.
- *
- * @param obj
- * @param keys
- */
-export declare function excludeObjectKeys<T extends object>(
-  obj: T,
-  keys: string | string[],
-): Partial<T>;

+ 0 - 12
src/utils/get-value-by-path.d.ts

@@ -1,12 +0,0 @@
-/**
- * Get value by path.
- *
- * @param obj
- * @param path
- * @param orElse
- */
-export declare function getValueByPath(
-  obj: object,
-  path: string,
-  orElse?: unknown,
-): unknown;

+ 0 - 12
src/utils/index.d.ts

@@ -1,12 +0,0 @@
-export * from './is-promise.js';
-export * from './capitalize.js';
-export * from './clone-deep.js';
-export * from './singularize.js';
-export * from './is-deep-equal.js';
-export * from './like-to-regexp.js';
-export * from './is-plain-object.js';
-export * from './string-to-regexp.js';
-export * from './get-value-by-path.js';
-export * from './select-object-keys.js';
-export * from './exclude-object-keys.js';
-export * from './model-name-to-model-key.js';

+ 0 - 10
src/utils/is-deep-equal.d.ts

@@ -1,10 +0,0 @@
-/**
- * Is deep equal.
- *
- * @param firstValue
- * @param secondValue
- */
-export declare function isDeepEqual(
-  firstValue: unknown,
-  secondValue: unknown,
-): boolean;

+ 0 - 6
src/utils/is-plain-object.d.ts

@@ -1,6 +0,0 @@
-/**
- * Is plain object.
- *
- * @param value
- */
-export declare function isPlainObject(value: unknown): boolean;

+ 4 - 4
src/utils/is-plain-object.js

@@ -7,9 +7,9 @@
 export function isPlainObject(value) {
   return Boolean(
     typeof value === 'object' &&
-      value &&
-      !Array.isArray(value) &&
-      (!value.constructor ||
-        (value.constructor && value.constructor.name === 'Object')),
+    value &&
+    !Array.isArray(value) &&
+    (!value.constructor ||
+      (value.constructor && value.constructor.name === 'Object')),
   );
 }

+ 0 - 10
src/utils/is-promise.d.ts

@@ -1,10 +0,0 @@
-/**
- * Check whether a value is a Promise-like
- * instance. Recognizes both native promises
- * and third-party promise libraries.
- *
- * @param value
- */
-export declare function isPromise<T>(
-  value: T | PromiseLike<T> | undefined
-): value is PromiseLike<T>;

+ 0 - 14
src/utils/like-to-regexp.d.ts

@@ -1,14 +0,0 @@
-/**
- * Преобразует SQL LIKE-шаблон в объект RegExp.
- *
- * Экранирует специальные символы регулярных выражений,
- * чтобы они обрабатывались как обычные символы, и преобразует
- * SQL wildcards (% и _) в их эквиваленты в регулярных выражениях.
- *
- * @param pattern
- * @param isCaseInsensitive
- */
-export function likeToRegexp(
-  pattern: string,
-  isCaseInsensitive?: boolean,
-): RegExp;

Some files were not shown because too many files changed in this diff