Browse Source

chore: renames Schema class to RepositoriesSchema

e22m4u 2 years ago
parent
commit
191d940456

+ 7 - 7
README.md

@@ -21,12 +21,12 @@ npm install @e22m4u/repository-mongodb-adapter
 
 ## Пример
 
-Создаем экземпляр класса `Schema`
+Создаем экземпляр класса `RepositoriesSchema`
 
 ```js
-import {Schema} from '@e22m4u/repository';
+import {RepositoriesSchema} from '@e22m4u/repository';
 
-const schema = new Schema();
+const schema = new RepositoriesSchema();
 ```
 
 Создаем источник данных `myMemory`
@@ -116,9 +116,9 @@ await userRep.deleteById(fedor.id); // true
 Получение репозитория модели:
 
 ```js
-import {Schema} from '@e22m4u/repository';
+import {RepositoriesSchema} from '@e22m4u/repository';
 
-const schema = new Schema();
+const schema = new RepositoriesSchema();
 // создаем источник
 schema.defineDatasource({name: 'myDatasource', adapter: 'memory'});
 // создаем модель
@@ -130,15 +130,15 @@ const repositorty = schema.getRepository('myModel');
 Переопределение конструктора:
 
 ```js
-import {Schema} from '@e22m4u/repository';
 import {Repository} from '@e22m4u/repository';
+import {RepositoriesSchema} from '@e22m4u/repository';
 import {RepositoryRegistry} from '@e22m4u/repository';
 
 class MyRepository extends Repository {
   /*...*/
 }
 
-const schema = new Schema();
+const schema = new RepositoriesSchema();
 schema.get(RepositoryRegistry).setRepositoryCtor(MyRepository);
 // теперь schema.getRepository(modelName) будет возвращать
 // экземпляр класса MyRepository

+ 3 - 3
src/adapter/adapter-registry.spec.js

@@ -1,12 +1,12 @@
 import {expect} from 'chai';
 import {AdapterRegistry} from './adapter-registry.js';
 import {MemoryAdapter} from './builtin/memory-adapter.js';
-import {Schema} from '../schema.js';
+import {RepositoriesSchema} from '../repository/index.js';
 
 describe('AdapterRegistry', function () {
   describe('getAdapter', function () {
     it('instantiates a new or returns an existing adapter by a given datasource name', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       const R = S.getService(AdapterRegistry);
       const adapter = await R.getAdapter('datasource');
@@ -24,7 +24,7 @@ describe('AdapterRegistry', function () {
     });
 
     it('throws an error if an adapter is not exists', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'unknown'});
       const R = S.getService(AdapterRegistry);
       const promise = R.getAdapter('datasource');

+ 3 - 3
src/adapter/adapter.spec.js

@@ -1,14 +1,14 @@
 import chai from 'chai';
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {Adapter} from './adapter.js';
 import {Service} from '@e22m4u/service';
+import {ServiceContainer} from '@e22m4u/service';
 import {InclusionDecorator} from './decorator/index.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {DefaultValuesDecorator} from './decorator/index.js';
 import {DataValidationDecorator} from './decorator/index.js';
 import {DataSanitizingDecorator} from './decorator/index.js';
 import {FieldsFilteringDecorator} from './decorator/index.js';
-import {ServiceContainer} from '@e22m4u/service';
 
 const sandbox = chai.spy.sandbox();
 
@@ -32,7 +32,7 @@ describe('Adapter', function () {
     });
 
     it('decorates only extended adapter', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       const dec1 = schema.getService(DataValidationDecorator);
       const dec2 = schema.getService(DataSanitizingDecorator);
       const dec3 = schema.getService(DefaultValuesDecorator);

+ 96 - 96
src/adapter/builtin/memory-adapter.spec.js

@@ -1,14 +1,14 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/format';
-import {Schema} from '../../schema.js';
 import {MemoryAdapter} from './memory-adapter.js';
 import {DataType} from '../../definition/index.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../../definition/index.js';
 
 describe('MemoryAdapter', function () {
   describe('_getTableOrCreate', function () {
     it('returns an existing table or creates a new', function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'model'});
       const A = S.getService(MemoryAdapter);
       const table = A._getTableOrCreate('model');
@@ -18,7 +18,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a model name to find a table, even a table name is specified', function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({
         name: 'myModel',
         tableName: 'myTable',
@@ -31,7 +31,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('stores a table by specified table name', function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({
         name: 'myModel',
         tableName: 'myTable',
@@ -46,7 +46,7 @@ describe('MemoryAdapter', function () {
 
   describe('_genNextIdValue', function () {
     it('returns an unique number identifier', function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'model'});
       const A = S.getService(MemoryAdapter);
       const id1 = A._genNextIdValue('model', DEF_PK);
@@ -60,7 +60,7 @@ describe('MemoryAdapter', function () {
 
   describe('create', function () {
     it('skips existing values when generating a new identifier for a default primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -81,7 +81,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('skips existing values when generating a new identifier for a specified primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -108,7 +108,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('generates a new identifier when a value of a primary key has not provided', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -132,7 +132,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('generates a new identifier when a value of a primary key is undefined', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -160,7 +160,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('generates a new identifier when a value of a primary key is null', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -188,7 +188,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('generates a new identifier for a primary key of a "number" type', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -213,7 +213,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('generates a new identifier for a primary key of an "any" type', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -238,7 +238,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error when generating a new value for a primary key of a "string" type', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -265,7 +265,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error when generating a new value for a primary key of a "boolean" type', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -292,7 +292,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error when generating a new value for a primary key of an "array" type', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -320,7 +320,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error when generating a new value for a primary key of an "object" type', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -347,7 +347,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify an identifier value for a new item', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -374,7 +374,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error if a given identifier value already exists', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -398,7 +398,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets default values if they are not provided for a new item', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -428,7 +428,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets default values for properties provided with an undefined value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -458,7 +458,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets default values for properties provided with a null value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -488,7 +488,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -513,7 +513,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -538,7 +538,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property with a default value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -564,7 +564,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a short form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -585,7 +585,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a full form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -611,7 +611,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a fields clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -648,7 +648,7 @@ describe('MemoryAdapter', function () {
 
   describe('replaceById', function () {
     it('removes properties when replacing an item by a given identifier', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -674,7 +674,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('ignores identifier value in a given data in case of a default primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -698,7 +698,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('ignores identifier value in a given data in case of a specified primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -728,7 +728,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets a default values for removed properties when replacing an item', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -769,7 +769,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets a default values for replaced properties with an undefined value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -803,7 +803,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets a default values for replaced properties with a null value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -837,7 +837,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error if a given identifier does not exist', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -861,7 +861,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -910,7 +910,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -953,7 +953,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property with a default value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1005,7 +1005,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a short form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1038,7 +1038,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a full form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1076,7 +1076,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a fields clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1135,7 +1135,7 @@ describe('MemoryAdapter', function () {
 
   describe('patchById', function () {
     it('updates only provided properties by a given identifier', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1172,7 +1172,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('does not throw an error if a partial data does not have required property', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1212,7 +1212,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('ignores identifier value in a given data in case of a default primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1239,7 +1239,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('ignores identifier value in a given data in case of a specified primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1270,7 +1270,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets a default values for patched properties with an undefined value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1306,7 +1306,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('sets a default values for patched properties with a null value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1342,7 +1342,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('throws an error if a given identifier does not exist', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1366,7 +1366,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1411,7 +1411,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1459,7 +1459,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property with a default value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1511,7 +1511,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a short form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1547,7 +1547,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a full form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1585,7 +1585,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a fields clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1644,7 +1644,7 @@ describe('MemoryAdapter', function () {
 
   describe('find', function () {
     it('returns an empty array if a table does not have an items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1660,7 +1660,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('returns an array of table items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1682,7 +1682,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses default values for non-existent properties', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1716,7 +1716,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses default values for properties of an undefined', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1750,7 +1750,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses default values for properties of a null', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1784,7 +1784,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a short form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1817,7 +1817,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a full form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1863,7 +1863,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a fields clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1919,7 +1919,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a short form of an order clause to sort a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1953,7 +1953,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a full form of an order clause to sort a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -1997,7 +1997,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('an order clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2051,7 +2051,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a where clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2088,7 +2088,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a where clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2145,7 +2145,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a where clause uses a persisted data instead of default values', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2178,7 +2178,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a limit clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2209,7 +2209,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a skip clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2242,7 +2242,7 @@ describe('MemoryAdapter', function () {
 
   describe('findById', function () {
     it('throws an error if a given identifier does not exist', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2262,7 +2262,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses default values for non-existent properties', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2288,7 +2288,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses default values for properties of an undefined', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2315,7 +2315,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses default values for properties of a null', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2342,7 +2342,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2370,7 +2370,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2400,7 +2400,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a regular property with a default value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2430,7 +2430,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a short form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2453,7 +2453,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('allows to specify a full form of a fields clause to filter a return value', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2482,7 +2482,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a fields clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2525,7 +2525,7 @@ describe('MemoryAdapter', function () {
 
   describe('delete', function () {
     it('removes all table items and returns their number', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2546,7 +2546,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('returns zero if nothing to remove', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2561,7 +2561,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a given where clause to remove specific items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2586,7 +2586,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a where clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2613,7 +2613,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a where clause uses a persisted data instead of default values', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2657,7 +2657,7 @@ describe('MemoryAdapter', function () {
 
   describe('deleteById', function () {
     it('returns false if a given identifier is not exist', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2672,7 +2672,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('returns true if an item has removed by a given identifier', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2689,7 +2689,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2719,7 +2719,7 @@ describe('MemoryAdapter', function () {
 
   describe('exists', function () {
     it('returns false if a given identifier is not exist', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2734,7 +2734,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('returns true if a given identifier is exist', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2750,7 +2750,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a specified column name for a primary key', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2777,7 +2777,7 @@ describe('MemoryAdapter', function () {
 
   describe('count', function () {
     it('returns zero if nothing to count', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2792,7 +2792,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('returns zero if a given where clause does not met', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2819,7 +2819,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('returns a number of table items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2837,7 +2837,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('uses a given where clause to count specific items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2864,7 +2864,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a where clause uses property names instead of column names', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',
@@ -2894,7 +2894,7 @@ describe('MemoryAdapter', function () {
     });
 
     it('a where clause uses a persisted data instead of default values', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({
         name: 'memory',
         adapter: 'memory',

+ 2 - 2
src/adapter/decorator/data-sanitizing-decorator.spec.js

@@ -1,10 +1,10 @@
 import chai from 'chai';
 import {expect} from 'chai';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 import {ModelDataSanitizer} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new RepositoriesSchema();
 S.defineModel({name: 'model'});
 
 class TestAdapter extends Adapter {

+ 2 - 2
src/adapter/decorator/data-validation-decorator.spec.js

@@ -1,10 +1,10 @@
 import chai from 'chai';
 import {expect} from 'chai';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 import {ModelDataValidator} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new RepositoriesSchema();
 S.defineModel({name: 'model'});
 
 class TestAdapter extends Adapter {

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

@@ -1,11 +1,11 @@
 import chai from 'chai';
 import {expect} from 'chai';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
 import {DataType} from '../../definition/index.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 import {ModelDefinitionUtils} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new RepositoriesSchema();
 S.defineModel({
   name: 'model',
   properties: {

+ 2 - 2
src/adapter/decorator/fields-filtering-decorator.spec.js

@@ -1,10 +1,10 @@
 import chai from 'chai';
 import {expect} from 'chai';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
 import {FieldsClauseTool} from '../../filter/index.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 
-const S = new Schema();
+const S = new RepositoriesSchema();
 const MODEL_NAME = 'model';
 S.defineModel({name: MODEL_NAME});
 

+ 2 - 2
src/adapter/decorator/inclusion-decorator.spec.js

@@ -1,10 +1,10 @@
 import chai from 'chai';
 import {expect} from 'chai';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
 import {IncludeClauseTool} from '../../filter/index.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 
-const S = new Schema();
+const S = new RepositoriesSchema();
 S.defineModel({name: 'model'});
 const FILTER = {include: 'parent'};
 

+ 106 - 106
src/definition/model/model-data-validator.spec.js

@@ -1,20 +1,20 @@
 import {expect} from 'chai';
 import {format} from '@e22m4u/format';
-import {Schema} from '../../schema.js';
 import {DataType} from './properties/index.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 import {ModelDataValidator} from './model-data-validator.js';
 
 describe('ModelDataValidator', function () {
   describe('validate', function () {
     it('does not throw an error if a model does not have a property of a given data', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({name: 'model'});
       schema.getService(ModelDataValidator).validate('model', {foo: 'bar'});
     });
 
     it('throws an error if a given data is not a pure object', function () {
       const throwable = modelData => {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           datasource: 'datasource',
@@ -37,7 +37,7 @@ describe('ModelDataValidator', function () {
     });
 
     it('uses a base model hierarchy to validate a given data', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -57,7 +57,7 @@ describe('ModelDataValidator', function () {
     });
 
     it('throws an error if a given data does not have a required property', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -76,7 +76,7 @@ describe('ModelDataValidator', function () {
     });
 
     it('throws an error if a required property is undefined', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -96,7 +96,7 @@ describe('ModelDataValidator', function () {
     });
 
     it('throws an error if a required property is null', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -115,7 +115,7 @@ describe('ModelDataValidator', function () {
 
     describe('an option "isPartial" is true', function () {
       it('does not throw an error if a given data does not have a required property', function () {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -129,7 +129,7 @@ describe('ModelDataValidator', function () {
       });
 
       it('throws an error if a required property is undefined', function () {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -150,7 +150,7 @@ describe('ModelDataValidator', function () {
       });
 
       it('throws an error if a required property is null', function () {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -173,7 +173,7 @@ describe('ModelDataValidator', function () {
     describe('DataType.ANY', function () {
       describe('ShortPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -187,7 +187,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -201,7 +201,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -215,7 +215,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -229,7 +229,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -243,7 +243,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -257,7 +257,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -271,7 +271,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -287,7 +287,7 @@ describe('ModelDataValidator', function () {
 
       describe('FullPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -303,7 +303,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -319,7 +319,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -335,7 +335,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -351,7 +351,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -367,7 +367,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -383,7 +383,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -399,7 +399,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -419,7 +419,7 @@ describe('ModelDataValidator', function () {
     describe('DataType.STRING', function () {
       describe('ShortPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -433,7 +433,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -447,7 +447,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -461,7 +461,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -480,7 +480,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -499,7 +499,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -518,7 +518,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -537,7 +537,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -558,7 +558,7 @@ describe('ModelDataValidator', function () {
 
       describe('FullPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -574,7 +574,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -590,7 +590,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -606,7 +606,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -627,7 +627,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -648,7 +648,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -669,7 +669,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -690,7 +690,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -715,7 +715,7 @@ describe('ModelDataValidator', function () {
     describe('DataType.NUMBER', function () {
       describe('ShortPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -729,7 +729,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -743,7 +743,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -762,7 +762,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -776,7 +776,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -795,7 +795,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -814,7 +814,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -833,7 +833,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -854,7 +854,7 @@ describe('ModelDataValidator', function () {
 
       describe('FullPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -870,7 +870,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -886,7 +886,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -907,7 +907,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -923,7 +923,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -944,7 +944,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -965,7 +965,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -986,7 +986,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1011,7 +1011,7 @@ describe('ModelDataValidator', function () {
     describe('DataType.BOOLEAN', function () {
       describe('ShortPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1025,7 +1025,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1039,7 +1039,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1058,7 +1058,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1077,7 +1077,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1091,7 +1091,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1105,7 +1105,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1124,7 +1124,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1145,7 +1145,7 @@ describe('ModelDataValidator', function () {
 
       describe('FullPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1161,7 +1161,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1177,7 +1177,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1198,7 +1198,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1219,7 +1219,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1235,7 +1235,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1251,7 +1251,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1272,7 +1272,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1297,7 +1297,7 @@ describe('ModelDataValidator', function () {
     describe('DataType.ARRAY', function () {
       describe('ShortPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1311,7 +1311,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1325,7 +1325,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1344,7 +1344,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1363,7 +1363,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1382,7 +1382,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1401,7 +1401,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1415,7 +1415,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1436,7 +1436,7 @@ describe('ModelDataValidator', function () {
 
       describe('FullPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1452,7 +1452,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1468,7 +1468,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1489,7 +1489,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1510,7 +1510,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1531,7 +1531,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1552,7 +1552,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1568,7 +1568,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1593,7 +1593,7 @@ describe('ModelDataValidator', function () {
     describe('DataType.OBJECT', function () {
       describe('ShortPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1607,7 +1607,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1621,7 +1621,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1640,7 +1640,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1659,7 +1659,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1678,7 +1678,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1697,7 +1697,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1716,7 +1716,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1732,7 +1732,7 @@ describe('ModelDataValidator', function () {
 
       describe('FullPropertyDefinition', function () {
         it('does not throw an error if an undefined given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1748,7 +1748,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if a null given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1764,7 +1764,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a string given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1785,7 +1785,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if a number given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1806,7 +1806,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if true given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1827,7 +1827,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if false given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1848,7 +1848,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('throws an error if an array given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',
@@ -1869,7 +1869,7 @@ describe('ModelDataValidator', function () {
         });
 
         it('does not throw an error if an object given', function () {
-          const S = new Schema();
+          const S = new RepositoriesSchema();
           S.defineModel({
             name: 'model',
             datasource: 'datasource',

+ 74 - 74
src/definition/model/model-definition-utils.spec.js

@@ -1,12 +1,12 @@
 import chai from 'chai';
 import {expect} from 'chai';
 import {format} from '@e22m4u/format';
-import {Schema} from '../../schema.js';
 import {DataType} from './properties/index.js';
+import {RelationType} from './relations/index.js';
 import {InvalidArgumentError} from '../../errors/index.js';
+import {RepositoriesSchema} from '../../repository/index.js';
 import {ModelDefinitionUtils} from './model-definition-utils.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from './model-definition-utils.js';
-import {RelationType} from './relations/index.js';
 
 const sandbox = chai.spy.sandbox();
 
@@ -17,7 +17,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getPrimaryKeyAsPropertyName', function () {
     it('returns a default property name if no primary key defined', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -28,7 +28,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a property name of a default primary key already in use as a regular property', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       const S = schema.getService(ModelDefinitionUtils);
       sandbox.on(
         S,
@@ -50,7 +50,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property name if a primary key has a custom name and a default primary key is used as a regular property', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -68,7 +68,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property name of a primary key', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -88,7 +88,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a property name of a primary key', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -111,7 +111,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getPrimaryKeyAsColumnName', function () {
     it('returns a property name of a primary key if a column name is not specified', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -131,7 +131,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a column name of a primary key if specified', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -152,7 +152,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a default property name if a primary key is not defined', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -163,7 +163,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a property name of a default primary key already in use as a regular property', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       const S = schema.getService(ModelDefinitionUtils);
       sandbox.on(
         S,
@@ -185,7 +185,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property name of a custom primary key when a default primary key is used as a regular property', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -203,7 +203,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a column name of a primary key', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -226,7 +226,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getTableNameByModelName', function () {
     it('returns a model name if no table name specified', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -237,7 +237,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a table name from a model definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         tableName: 'table',
@@ -251,7 +251,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getColumnNameByPropertyName', function () {
     it('returns a property name if a column name is not defined', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -265,7 +265,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a specified column name', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -282,7 +282,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a given property name does not exist', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -294,7 +294,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a specified column name', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -317,7 +317,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getDefaultPropertyValue', function () {
     it('returns undefined if no default value specified', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -331,7 +331,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a default value from a property definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -348,7 +348,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a value from a factory function', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -365,7 +365,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a given property name does not exist', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -377,7 +377,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a specified default value', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -400,7 +400,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('setDefaultValuesToEmptyProperties', function () {
     it('does nothing if no property definitions', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -411,7 +411,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('does nothing if no "default" option in property definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -426,7 +426,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property does not exist', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -443,7 +443,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property is undefined', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -460,7 +460,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property is null', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -477,7 +477,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a value from a factory function', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -511,7 +511,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to set a default values', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -545,7 +545,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('an option "onlyProvidedProperties" is true', function () {
       it('does not set a default value if a property does not exist', function () {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -562,7 +562,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('sets a default value if a property is undefined', function () {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -579,7 +579,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('sets a default value if a property is null', function () {
-        const schema = new Schema();
+        const schema = new RepositoriesSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -599,7 +599,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('convertPropertyNamesToColumnNames', function () {
     it('does nothing if no property definitions', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -610,7 +610,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('does nothing if no column name specified', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -625,7 +625,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('replaces property names by column names', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -646,7 +646,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to replace property names by column names', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -673,7 +673,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('convertColumnNamesToPropertyNames', function () {
     it('does nothing if no property definitions', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -684,7 +684,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('does nothing if no column name specified', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -699,7 +699,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('replaces column names by property names', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -720,7 +720,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to replace column names by property names', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -747,7 +747,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getDataTypeByPropertyName', function () {
     it('returns a property type of a short property definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -761,7 +761,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property type of a full property definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -777,7 +777,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a property name does not exist', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -789,7 +789,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a type from a short property definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -807,7 +807,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a type from a full property definition', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -829,7 +829,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getOwnPropertiesDefinitionWithoutPrimaryKeys', function () {
     it('returns an empty object if a model does not have properties', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -840,7 +840,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition without primary keys', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -862,7 +862,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns its own properties definition even it has a base model properties', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -896,7 +896,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getOwnPropertiesDefinitionOfPrimaryKeys', function () {
     it('returns an empty object if a model does not have properties', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -907,7 +907,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition of primary keys', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -931,7 +931,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns its own properties definition even it has a base model properties', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -968,7 +968,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getPropertiesDefinitionInBaseModelHierarchy', function () {
     it('returns an empty object if a model does not have properties', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -979,7 +979,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition of a model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -1005,7 +1005,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition of an extended model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1029,7 +1029,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses child properties in priority over a base model properties', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1066,7 +1066,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses primary keys from a model closest to child model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1102,7 +1102,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error for a circular reference', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         base: 'model',
@@ -1119,7 +1119,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getOwnRelationsDefinition', function () {
     it('returns an empty object if a model does not have relations', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1130,7 +1130,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relations definition by a given model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1152,7 +1152,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns its own relations definition even it has a base model relations', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1186,7 +1186,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getRelationsDefinitionInBaseModelHierarchy', function () {
     it('returns an empty object if a model does not have relations', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1197,7 +1197,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relations definition of a model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1227,7 +1227,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relations definition of an extended model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1263,7 +1263,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses child relations in priority over a base model relations', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1303,7 +1303,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error for a circular reference', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         base: 'model',
@@ -1320,7 +1320,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getRelationDefinitionByName', function () {
     it('throws an error if a given model is not found', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       const throwable = () =>
         schema
           .getService(ModelDefinitionUtils)
@@ -1329,7 +1329,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a given relation is not found', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1343,7 +1343,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relation definition by a given name', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1363,7 +1363,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a child relations in priority over a base model relations', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1393,7 +1393,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a base model relation if a given relation name is not found in a child model', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1419,7 +1419,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('excludeObjectKeysByRelationNames', function () {
     it('excludes object keys by relation names', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1447,7 +1447,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('requires a given object as an object', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineModel({name: 'model'});
       const throwable = v => () =>
         schema

+ 2 - 2
src/filter/fields-clause-tool.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/format';
 import {FieldsClauseTool} from './fields-clause-tool.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
-const S = new Schema();
+const S = new RepositoriesSchema();
 const MODEL_NAME = 'model';
 S.defineModel({name: MODEL_NAME});
 const T = S.getService(FieldsClauseTool);

+ 0 - 1
src/index.js

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

+ 37 - 37
src/relations/belongs-to-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {BelongsToResolver} from './belongs-to-resolver.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('BelongsToResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -30,7 +30,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -51,7 +51,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -71,7 +71,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -91,7 +91,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -111,7 +111,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "foreignKey" to be a string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -128,7 +128,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -152,7 +152,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(BelongsToResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -162,7 +162,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'target'});
       const R = S.getService(BelongsToResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -172,7 +172,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -187,7 +187,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if a primary key is not defined in the target model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -210,7 +210,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -242,7 +242,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -274,7 +274,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the property "foreignKey" is specified', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -297,7 +297,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -338,7 +338,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -375,7 +375,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -475,7 +475,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -523,7 +523,7 @@ describe('BelongsToResolver', function () {
 
   describe('includePolymorphicTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -544,7 +544,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -565,7 +565,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -586,7 +586,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -606,7 +606,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "foreignKey" to be a string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -623,7 +623,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "discriminator" to be a string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -640,7 +640,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -664,7 +664,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if a target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(BelongsToResolver);
       const entity = {[DEF_PK]: 1, parentId: 1, parentType: 'target'};
@@ -673,7 +673,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throws an error if a target model does not have datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(BelongsToResolver);
@@ -683,7 +683,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -702,7 +702,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if no discriminator value', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(BelongsToResolver);
       const entity = {[DEF_PK]: 1, parentId: 1};
@@ -711,7 +711,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if a primary key is not defined in the target model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -739,7 +739,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -776,7 +776,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the property "foreignKey" is specified', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -804,7 +804,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the property "discriminator" is specified', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -838,7 +838,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -893,7 +893,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -938,7 +938,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',

+ 60 - 60
src/relations/has-many-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
 import {HasManyResolver} from './has-many-resolver.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('HasManyResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -36,7 +36,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const error = v =>
@@ -58,7 +58,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -79,7 +79,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -100,7 +100,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -121,7 +121,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -142,7 +142,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -166,7 +166,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if a target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const promise = R.includeTo(
@@ -182,7 +182,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if a target model does not have datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasManyResolver);
@@ -199,7 +199,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not exist', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -214,7 +214,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -255,7 +255,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -305,7 +305,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -355,7 +355,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -425,7 +425,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -488,7 +488,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -646,7 +646,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -721,7 +721,7 @@ describe('HasManyResolver', function () {
 
   describe('includePolymorphicTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -749,7 +749,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const error = v =>
@@ -778,7 +778,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -806,7 +806,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -834,7 +834,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -862,7 +862,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -890,7 +890,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "discriminator" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -918,7 +918,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -943,7 +943,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const entity = {[DEF_PK]: 1};
@@ -961,7 +961,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasManyResolver);
@@ -980,7 +980,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1005,7 +1005,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1040,7 +1040,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1102,7 +1102,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -1173,7 +1173,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1244,7 +1244,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1335,7 +1335,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1410,7 +1410,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -1584,7 +1584,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1680,7 +1680,7 @@ describe('HasManyResolver', function () {
 
   describe('includePolymorphicByRelationName', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1707,7 +1707,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1744,7 +1744,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1771,7 +1771,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1798,7 +1798,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1825,7 +1825,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetRelationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1852,7 +1852,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1876,7 +1876,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const entity = {[DEF_PK]: 1};
@@ -1893,7 +1893,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have the given relation name', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasManyResolver);
@@ -1911,7 +1911,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the target relation is not "belongsTo"', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1939,7 +1939,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the target relation is not polymorphic', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1967,7 +1967,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1993,7 +1993,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2026,7 +2026,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2069,7 +2069,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2139,7 +2139,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -2218,7 +2218,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2294,7 +2294,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom "foreignKey"', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2371,7 +2371,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom "discriminator"', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2448,7 +2448,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2546,7 +2546,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2629,7 +2629,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -2808,7 +2808,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({

+ 60 - 60
src/relations/has-one-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
 import {HasOneResolver} from './has-one-resolver.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('HasOneResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -36,7 +36,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const error = v =>
@@ -58,7 +58,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -79,7 +79,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -100,7 +100,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -121,7 +121,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -142,7 +142,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -166,7 +166,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if a target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const promise = R.includeTo(
@@ -182,7 +182,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if a target model does not have datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasOneResolver);
@@ -199,7 +199,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not throw an error if a relation target is not exist', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -213,7 +213,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -238,7 +238,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -272,7 +272,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -306,7 +306,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -358,7 +358,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -393,7 +393,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -495,7 +495,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -552,7 +552,7 @@ describe('HasOneResolver', function () {
 
   describe('includePolymorphicTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -580,7 +580,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const error = v =>
@@ -609,7 +609,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -637,7 +637,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -665,7 +665,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -693,7 +693,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -721,7 +721,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "discriminator" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -749,7 +749,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -774,7 +774,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const entity = {[DEF_PK]: 1};
@@ -792,7 +792,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasOneResolver);
@@ -811,7 +811,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -835,7 +835,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -869,7 +869,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -906,7 +906,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -952,7 +952,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -998,7 +998,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1068,7 +1068,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1111,7 +1111,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -1227,7 +1227,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1302,7 +1302,7 @@ describe('HasOneResolver', function () {
 
   describe('includePolymorphicByRelationName', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1329,7 +1329,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1366,7 +1366,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1393,7 +1393,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1420,7 +1420,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1447,7 +1447,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetRelationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1474,7 +1474,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1498,7 +1498,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const entity = {[DEF_PK]: 1};
@@ -1515,7 +1515,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model does not have the given relation name', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasOneResolver);
@@ -1533,7 +1533,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the target relation is not "belongsTo"', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1561,7 +1561,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the target relation is not polymorphic', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1589,7 +1589,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1615,7 +1615,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1647,7 +1647,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1689,7 +1689,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1734,7 +1734,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -1788,7 +1788,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1839,7 +1839,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom "foreignKey"', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1891,7 +1891,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom "discriminator"', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1943,7 +1943,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2020,7 +2020,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2071,7 +2071,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -2192,7 +2192,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({

+ 20 - 20
src/relations/references-many-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {ReferencesManyResolver} from './references-many-resolver.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('ReferencesManyResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -30,7 +30,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -51,7 +51,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -71,7 +71,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -91,7 +91,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -111,7 +111,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the provided parameter "foreignKey" to be a string', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -128,7 +128,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -152,7 +152,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(ReferencesManyResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -162,7 +162,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineModel({name: 'target'});
       const R = S.getService(ReferencesManyResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -172,7 +172,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -188,7 +188,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the target model', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -217,7 +217,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -255,7 +255,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -293,7 +293,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if the property "foreignKey" is specified', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -322,7 +322,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -362,7 +362,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses a slice clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -406,7 +406,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -467,7 +467,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -589,7 +589,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new RepositoriesSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});

+ 1 - 0
src/repository/index.js

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

+ 4 - 4
src/schema.js → src/repository/repositories-schema.js

@@ -1,11 +1,11 @@
 import {Service} from '@e22m4u/service';
-import {DefinitionRegistry} from './definition/index.js';
-import {RepositoryRegistry} from './repository/index.js';
+import {DefinitionRegistry} from '../definition/index.js';
+import {RepositoryRegistry} from './repository-registry.js';
 
 /**
- * Schema.
+ * Repositories schema.
  */
-export class Schema extends Service {
+export class RepositoriesSchema extends Service {
   /**
    * Define datasource.
    *

+ 3 - 3
src/repository/repository-registry.spec.js

@@ -1,13 +1,13 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {Repository} from './repository.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {RepositoryRegistry} from './repository-registry.js';
 
 describe('RepositoryRegistry', function () {
   describe('setRepositoryCtor', function () {
     it('sets a given class as the repository constructor', function () {
       class MyRepository extends Repository {}
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const registry = schema.getService(RepositoryRegistry);
@@ -20,7 +20,7 @@ describe('RepositoryRegistry', function () {
 
   describe('getRepository', function () {
     it('uses a given model name to return an existing repository or create the new', function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'modelA', datasource: 'datasource'});
       schema.defineModel({name: 'modelB', datasource: 'datasource'});

+ 17 - 17
src/repository/repository.spec.js

@@ -1,11 +1,11 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
+import {RepositoriesSchema} from '../repository/index.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('Repository', function () {
   describe('create', function () {
     it('creates a new item from the given data', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const data = {foo: 'bar'};
@@ -17,7 +17,7 @@ describe('Repository', function () {
 
   describe('replaceById', function () {
     it('replaces an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -29,7 +29,7 @@ describe('Repository', function () {
 
   describe('replaceOrCreate', function () {
     it('creates a new item from the given data', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const data = {foo: 'bar'};
@@ -39,7 +39,7 @@ describe('Repository', function () {
     });
 
     it('replaces an existing item', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -52,7 +52,7 @@ describe('Repository', function () {
 
   describe('patchById', function () {
     it('patches an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -68,7 +68,7 @@ describe('Repository', function () {
 
   describe('find', function () {
     it('returns all items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -79,7 +79,7 @@ describe('Repository', function () {
     });
 
     it('returns found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -92,7 +92,7 @@ describe('Repository', function () {
 
   describe('findOne', function () {
     it('returns a first item', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -103,7 +103,7 @@ describe('Repository', function () {
     });
 
     it('returns a found item by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -116,7 +116,7 @@ describe('Repository', function () {
 
   describe('findById', function () {
     it('returns an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -128,7 +128,7 @@ describe('Repository', function () {
 
   describe('delete', function () {
     it('removes all items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -139,7 +139,7 @@ describe('Repository', function () {
     });
 
     it('removes found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -153,7 +153,7 @@ describe('Repository', function () {
 
   describe('deleteById', function () {
     it('removes an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -165,7 +165,7 @@ describe('Repository', function () {
 
   describe('exists', function () {
     it('returns true if the given id exists', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -177,7 +177,7 @@ describe('Repository', function () {
 
   describe('count', function () {
     it('counts all items', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -188,7 +188,7 @@ describe('Repository', function () {
     });
 
     it('counts found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new RepositoriesSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');