@companix/xeo-server 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +54 -0
- package/dist/common/decorators.d.ts +3 -0
- package/dist/common/decorators.js +14 -0
- package/dist/common/decorators.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.js +20 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/tokens.d.ts +3 -0
- package/dist/common/tokens.js +14 -0
- package/dist/common/tokens.js.map +1 -0
- package/dist/common/utils.d.ts +2 -0
- package/dist/common/utils.js +19 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/driver.module.d.ts +7 -0
- package/dist/driver.module.js +41 -0
- package/dist/driver.module.js.map +1 -0
- package/dist/drivers/collection.driver.d.ts +21 -0
- package/dist/drivers/collection.driver.js +101 -0
- package/dist/drivers/collection.driver.js.map +1 -0
- package/dist/drivers/table.driver.d.ts +13 -0
- package/dist/drivers/table.driver.js +79 -0
- package/dist/drivers/table.driver.js.map +1 -0
- package/dist/factories/definitions.factory.d.ts +11 -0
- package/dist/factories/definitions.factory.js +116 -0
- package/dist/factories/definitions.factory.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/mongoose-options.interface.d.ts +12 -0
- package/dist/mongoose-options.interface.js +3 -0
- package/dist/mongoose-options.interface.js.map +1 -0
- package/dist/mongoose.module.d.ts +11 -0
- package/dist/mongoose.module.js +108 -0
- package/dist/mongoose.module.js.map +1 -0
- package/dist/storages/data-source.d.ts +10 -0
- package/dist/storages/data-source.js +34 -0
- package/dist/storages/data-source.js.map +1 -0
- package/jest.cases.config.cjs +14 -0
- package/lib/common/decorators.ts +17 -0
- package/lib/common/index.ts +3 -0
- package/lib/common/tokens.ts +17 -0
- package/lib/common/utils.ts +29 -0
- package/lib/constants.ts +4 -0
- package/lib/driver.module.ts +37 -0
- package/lib/drivers/collection.driver.ts +157 -0
- package/lib/drivers/table.driver.ts +109 -0
- package/lib/factories/definitions.factory.ts +129 -0
- package/lib/index.ts +3 -0
- package/lib/mongoose-options.interface.ts +19 -0
- package/lib/mongoose.module.ts +95 -0
- package/lib/storages/data-source.ts +37 -0
- package/package.json +42 -0
- package/tests/app/bootstrap.ts +16 -0
- package/tests/app/db.ts +22 -0
- package/tests/app/filters.ts +25 -0
- package/tests/app/helpers/is-one-of.ts +58 -0
- package/tests/app/main.ts +3 -0
- package/tests/app/module/app.controller.ts +67 -0
- package/tests/app/module/app.dto.ts +394 -0
- package/tests/app/module/app.module.ts +12 -0
- package/tests/app/module/app.service.ts +76 -0
- package/tests/app/root.module.ts +12 -0
- package/tests/globals.d.ts +6 -0
- package/tests/integrations/cases.test.ts +154 -0
- package/tests/integrations/custom.test.ts +69 -0
- package/tests/unit/definitions.test.ts +31 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +17 -0
- package/tsconfig.test-app.json +10 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CoreError, DataSource } from '@companix/xeo-scheme'
|
|
2
|
+
import { getDataSourceToken } from '../../lib'
|
|
3
|
+
|
|
4
|
+
import { bootstrap } from '../app/bootstrap'
|
|
5
|
+
import { MongoCollectionDriver } from '../../lib/drivers/collection.driver'
|
|
6
|
+
import { AppScheme, createMockKit, dataScheme } from '@companix/xeo-devkit'
|
|
7
|
+
|
|
8
|
+
const runScenario = async (dataSource: DataSource<AppScheme, MongoCollectionDriver<AppScheme>>) => {
|
|
9
|
+
// version: 11
|
|
10
|
+
// const kit = await createMockKit(dataSource)
|
|
11
|
+
// await kit.addDictionary({ dictionary: 'regions' })
|
|
12
|
+
// await kit.addOption({
|
|
13
|
+
// value: 'option-1',
|
|
14
|
+
// dictionary: 'regions' // BelongsTo
|
|
15
|
+
// })
|
|
16
|
+
// await kit.addRevisorWorker({ workerId: 2 })
|
|
17
|
+
// await dataSource.collections.worker.update(2, (w) => {
|
|
18
|
+
// if (w.type === 'revisor') {
|
|
19
|
+
// w.about.height = 10
|
|
20
|
+
// w.password = 'password'
|
|
21
|
+
// // w.job_type = 'self_employed'
|
|
22
|
+
// }
|
|
23
|
+
// })
|
|
24
|
+
// await kit.addDictionary({
|
|
25
|
+
// dictionary: 'value_type',
|
|
26
|
+
// name: 'ТМЦ'
|
|
27
|
+
// })
|
|
28
|
+
// await kit.addOption({
|
|
29
|
+
// dictionary: 'regions',
|
|
30
|
+
// value: 'moscow',
|
|
31
|
+
// title: 'Москва'
|
|
32
|
+
// })
|
|
33
|
+
// await kit.addOption({
|
|
34
|
+
// dictionary: 'regions',
|
|
35
|
+
// value: 'shanghai',
|
|
36
|
+
// title: 'Шанхай'
|
|
37
|
+
// })
|
|
38
|
+
// await dataSource.collections.options.remove('moscow')
|
|
39
|
+
// await kit.addRole({
|
|
40
|
+
// value: 'director',
|
|
41
|
+
// title: 'Директор'
|
|
42
|
+
// })
|
|
43
|
+
// await kit.addRevisorWorker({
|
|
44
|
+
// workerId: 3
|
|
45
|
+
// })
|
|
46
|
+
// await dataSource.collections.worker.remove(1)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function bootstrapTest() {
|
|
50
|
+
const app = await bootstrap()
|
|
51
|
+
const dataSource = app.get<DataSource<AppScheme, MongoCollectionDriver<AppScheme>>>(
|
|
52
|
+
getDataSourceToken(dataScheme)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
console.log('Run Scenario')
|
|
57
|
+
await runScenario(dataSource)
|
|
58
|
+
console.log('Scenario Done!')
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof CoreError) {
|
|
61
|
+
console.error('CoreError:', error)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
throw error
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
bootstrapTest()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { dataScheme } from '@companix/xeo-devkit'
|
|
2
|
+
import { DefinitionsFactory } from '../../lib/factories/definitions.factory'
|
|
3
|
+
|
|
4
|
+
const factory = new DefinitionsFactory(dataScheme)
|
|
5
|
+
|
|
6
|
+
const schemas = {
|
|
7
|
+
worker: factory.createForCollection('worker'),
|
|
8
|
+
bankCard: factory.createForCollection('bankCard'),
|
|
9
|
+
bankDetail: factory.createForCollection('bankDetail'),
|
|
10
|
+
scan: factory.createForCollection('scan'),
|
|
11
|
+
dictionaries: factory.createForCollection('dictionaries'),
|
|
12
|
+
options: factory.createForCollection('options')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const workerScheme = dataScheme.models[dataScheme.collections.worker.name].scheme
|
|
16
|
+
|
|
17
|
+
console.dir(schemas.worker, {
|
|
18
|
+
depth: null,
|
|
19
|
+
colors: true
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
if (workerScheme.type === 'discriminated') {
|
|
23
|
+
console.log('\ndiscriminated:\n')
|
|
24
|
+
|
|
25
|
+
for (const i of workerScheme.discriminators) {
|
|
26
|
+
console.dir(factory.createDefinitionScheme(i), {
|
|
27
|
+
depth: null,
|
|
28
|
+
colors: true
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"noImplicitAny": false,
|
|
6
|
+
"removeComments": true,
|
|
7
|
+
"noLib": false,
|
|
8
|
+
"emitDecoratorMetadata": true,
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"target": "ES2021",
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"strictPropertyInitialization": false
|
|
16
|
+
}
|
|
17
|
+
}
|