@nest-omni/core 2.0.1-0 → 2.0.1-1
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/package.json +1 -1
- package/.history/src/common/boilerplate.polyfill_20250521135408.ts +0 -202
- package/.history/src/common/boilerplate.polyfill_20250712165919.ts +0 -254
- package/.history/src/common/boilerplate.polyfill_20250712165924.ts +0 -254
- package/.history/src/common/boilerplate.polyfill_20250712165927.ts +0 -254
- package/.history/src/common/boilerplate.polyfill_20250712170044.ts +0 -265
- package/.history/src/common/boilerplate.polyfill_20250712170049.ts +0 -265
- package/.history/src/common/boilerplate.polyfill_20250712170053.ts +0 -265
- package/.history/src/common/boilerplate.polyfill_20250712170610.ts +0 -280
- package/.history/src/common/boilerplate.polyfill_20250712170614.ts +0 -280
- package/.history/src/common/boilerplate.polyfill_20250712170739.ts +0 -265
- package/.history/src/common/boilerplate.polyfill_20250712170801.ts +0 -291
- package/.history/src/common/boilerplate.polyfill_20250712170809.ts +0 -317
- package/.history/src/common/boilerplate.polyfill_20250712170816.ts +0 -319
- package/.history/src/common/boilerplate.polyfill_20250712170820.ts +0 -318
- package/.history/src/common/boilerplate.polyfill_20250712170824.ts +0 -318
- package/.history/src/common/boilerplate.polyfill_20250712171040.ts +0 -289
- package/README.md +0 -16
- package/build.sh +0 -45
- package/dist/package.json +0 -71
- package/dist/yarn.lock +0 -644
- package/src/.hygen.js +0 -116
- package/src/common/abstract-client.service.ts +0 -56
- package/src/common/abstract.entity.ts +0 -82
- package/src/common/boilerplate.polyfill.ts +0 -202
- package/src/common/dto/abstract.dto.ts +0 -61
- package/src/common/dto/bulk-id.dto.ts +0 -13
- package/src/common/dto/create-translation.dto.ts +0 -10
- package/src/common/dto/index.ts +0 -6
- package/src/common/dto/page-meta.dto.ts +0 -37
- package/src/common/dto/page-options.dto.ts +0 -35
- package/src/common/dto/page.dto.ts +0 -36
- package/src/common/index.ts +0 -7
- package/src/common/snake-naming.strategy.ts +0 -64
- package/src/common/types.ts +0 -44
- package/src/common/utils.ts +0 -45
- package/src/constants/index.ts +0 -2
- package/src/constants/language-code.ts +0 -7
- package/src/constants/order.ts +0 -4
- package/src/decorators/api-page-ok-response.decorator.ts +0 -32
- package/src/decorators/auth-user.decorator.ts +0 -16
- package/src/decorators/controller.decorator.ts +0 -8
- package/src/decorators/field.decorators.ts +0 -856
- package/src/decorators/http.decorators.ts +0 -10
- package/src/decorators/index.ts +0 -12
- package/src/decorators/operation.decorator.ts +0 -4
- package/src/decorators/property.decorators.ts +0 -62
- package/src/decorators/public-route.decorator.ts +0 -8
- package/src/decorators/swagger.schema.ts +0 -117
- package/src/decorators/timestamp-column.decorator.ts +0 -29
- package/src/decorators/transform.decorators.ts +0 -159
- package/src/decorators/translate.decorator.ts +0 -19
- package/src/decorators/use-dto.decorator.ts +0 -11
- package/src/decorators/user-check.decorator.ts +0 -30
- package/src/decorators/user.decorator.ts +0 -59
- package/src/decorators/user_auth.decorator.ts +0 -15
- package/src/decorators/validator.decorators.ts +0 -98
- package/src/exceptions/file-not-image.exception.ts +0 -7
- package/src/exceptions/index.ts +0 -2
- package/src/exceptions/page-type.exception.ts +0 -7
- package/src/exceptions/user-not-found.exception.ts +0 -7
- package/src/filters/bad-request.filter.ts +0 -77
- package/src/filters/constraint-errors.ts +0 -5
- package/src/filters/index.ts +0 -3
- package/src/filters/query-failed.filter.ts +0 -32
- package/src/health-checker/health-checker.controller.ts +0 -51
- package/src/health-checker/health-checker.module.ts +0 -13
- package/src/health-checker/health-indicators/service.indicator.ts +0 -44
- package/src/helpers/common.helper.ts +0 -49
- package/src/helpers/date.helper.ts +0 -64
- package/src/helpers/index.ts +0 -2
- package/src/i18n/en_US/validation.json +0 -41
- package/src/i18n/zh_CN/validation.json +0 -41
- package/src/index.ts +0 -11
- package/src/interceptors/index.ts +0 -2
- package/src/interceptors/language-interceptor.service.ts +0 -28
- package/src/interceptors/translation-interceptor.service.ts +0 -43
- package/src/interfaces/IApiFile.ts +0 -4
- package/src/interfaces/IFile.ts +0 -8
- package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
- package/src/interfaces/index.ts +0 -3
- package/src/interfaces/response.ts +0 -37
- package/src/middlewares/index.ts +0 -4
- package/src/middlewares/omni-auth.middleware.ts +0 -10
- package/src/middlewares/powerby.middleware.ts +0 -6
- package/src/middlewares/request-id.middleware.ts +0 -28
- package/src/middlewares/xml.middleware.ts +0 -14
- package/src/providers/context.provider.ts +0 -109
- package/src/providers/generator.provider.ts +0 -66
- package/src/providers/index.ts +0 -2
- package/src/setup/bootstrap.setup.ts +0 -254
- package/src/setup/index.ts +0 -1
- package/src/shared/index.ts +0 -2
- package/src/shared/serviceRegistryModule.ts +0 -135
- package/src/shared/services/api-config.service.ts +0 -336
- package/src/shared/services/generator.service.ts +0 -13
- package/src/shared/services/index.ts +0 -4
- package/src/shared/services/translation.service.ts +0 -59
- package/src/shared/services/validator.service.ts +0 -10
- package/src/validator-json/decorators.ts +0 -63
- package/src/validator-json/default.ts +0 -257
- package/src/validator-json/defaultConverters.ts +0 -402
- package/src/validator-json/index.ts +0 -4
- package/src/validator-json/options.ts +0 -50
- package/src/validators/file-mimetype.validator.ts +0 -34
- package/src/validators/index.ts +0 -6
- package/src/validators/is-exists.validator.ts +0 -60
- package/src/validators/is-unique.validator.ts +0 -93
- package/src/validators/phone-country-code.validator.ts +0 -36
- package/src/validators/same-as.validator.ts +0 -27
- package/src/validators/skip-empty.validator.ts +0 -25
- package/tsconfig.json +0 -31
- package/tsconfig.lib.json +0 -16
- /package/{dist/.hygen → .hygen}/new/crud/controller.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/create.dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/entity.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/get.dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/index-dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/index-response.dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/module.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/prompt.js +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/service.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/crud/update.dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/controller.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/create-command.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/create.dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/entity.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/get-query.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/module.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/not-found.exception.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/page-options.dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/prompt.js +0 -0
- /package/{dist/.hygen → .hygen}/new/module/repository.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/service.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/translation-dto.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/translation-entity.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/translation-repository.ejs.t +0 -0
- /package/{dist/.hygen → .hygen}/new/module/update.dto.ejs.t +0 -0
- /package/{dist/.hygen.js → .hygen.js} +0 -0
- /package/{dist/common → common}/abstract-client.service.d.ts +0 -0
- /package/{dist/common → common}/abstract-client.service.js +0 -0
- /package/{dist/common → common}/abstract.entity.d.ts +0 -0
- /package/{dist/common → common}/abstract.entity.js +0 -0
- /package/{dist/common → common}/boilerplate.polyfill.d.ts +0 -0
- /package/{dist/common → common}/boilerplate.polyfill.js +0 -0
- /package/{dist/common → common}/dto/abstract.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/abstract.dto.js +0 -0
- /package/{dist/common → common}/dto/bulk-id.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/bulk-id.dto.js +0 -0
- /package/{dist/common → common}/dto/create-translation.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/create-translation.dto.js +0 -0
- /package/{dist/common → common}/dto/index.d.ts +0 -0
- /package/{dist/common → common}/dto/index.js +0 -0
- /package/{dist/common → common}/dto/page-meta.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/page-meta.dto.js +0 -0
- /package/{dist/common → common}/dto/page-options.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/page-options.dto.js +0 -0
- /package/{dist/common → common}/dto/page.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/page.dto.js +0 -0
- /package/{dist/common → common}/index.d.ts +0 -0
- /package/{dist/common → common}/index.js +0 -0
- /package/{dist/common → common}/snake-naming.strategy.d.ts +0 -0
- /package/{dist/common → common}/snake-naming.strategy.js +0 -0
- /package/{dist/common → common}/types.d.ts +0 -0
- /package/{dist/common → common}/types.js +0 -0
- /package/{dist/common → common}/utils.d.ts +0 -0
- /package/{dist/common → common}/utils.js +0 -0
- /package/{dist/constants → constants}/index.d.ts +0 -0
- /package/{dist/constants → constants}/index.js +0 -0
- /package/{dist/constants → constants}/language-code.d.ts +0 -0
- /package/{dist/constants → constants}/language-code.js +0 -0
- /package/{dist/constants → constants}/order.d.ts +0 -0
- /package/{dist/constants → constants}/order.js +0 -0
- /package/{dist/decorators → decorators}/api-page-ok-response.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/api-page-ok-response.decorator.js +0 -0
- /package/{dist/decorators → decorators}/auth-user.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/auth-user.decorator.js +0 -0
- /package/{dist/decorators → decorators}/controller.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/controller.decorator.js +0 -0
- /package/{dist/decorators → decorators}/field.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/field.decorators.js +0 -0
- /package/{dist/decorators → decorators}/http.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/http.decorators.js +0 -0
- /package/{dist/decorators → decorators}/index.d.ts +0 -0
- /package/{dist/decorators → decorators}/index.js +0 -0
- /package/{dist/decorators → decorators}/operation.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/operation.decorator.js +0 -0
- /package/{dist/decorators → decorators}/property.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/property.decorators.js +0 -0
- /package/{dist/decorators → decorators}/public-route.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/public-route.decorator.js +0 -0
- /package/{dist/decorators → decorators}/swagger.schema.d.ts +0 -0
- /package/{dist/decorators → decorators}/swagger.schema.js +0 -0
- /package/{dist/decorators → decorators}/timestamp-column.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/timestamp-column.decorator.js +0 -0
- /package/{dist/decorators → decorators}/transform.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/transform.decorators.js +0 -0
- /package/{dist/decorators → decorators}/translate.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/translate.decorator.js +0 -0
- /package/{dist/decorators → decorators}/use-dto.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/use-dto.decorator.js +0 -0
- /package/{dist/decorators → decorators}/user-check.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/user-check.decorator.js +0 -0
- /package/{dist/decorators → decorators}/user.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/user.decorator.js +0 -0
- /package/{dist/decorators → decorators}/user_auth.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/user_auth.decorator.js +0 -0
- /package/{dist/decorators → decorators}/validator.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/validator.decorators.js +0 -0
- /package/{dist/exceptions → exceptions}/file-not-image.exception.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/file-not-image.exception.js +0 -0
- /package/{dist/exceptions → exceptions}/index.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/index.js +0 -0
- /package/{dist/exceptions → exceptions}/page-type.exception.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/page-type.exception.js +0 -0
- /package/{dist/exceptions → exceptions}/user-not-found.exception.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/user-not-found.exception.js +0 -0
- /package/{dist/filters → filters}/bad-request.filter.d.ts +0 -0
- /package/{dist/filters → filters}/bad-request.filter.js +0 -0
- /package/{dist/filters → filters}/constraint-errors.d.ts +0 -0
- /package/{dist/filters → filters}/constraint-errors.js +0 -0
- /package/{dist/filters → filters}/index.d.ts +0 -0
- /package/{dist/filters → filters}/index.js +0 -0
- /package/{dist/filters → filters}/query-failed.filter.d.ts +0 -0
- /package/{dist/filters → filters}/query-failed.filter.js +0 -0
- /package/{dist/health-checker → health-checker}/health-checker.controller.d.ts +0 -0
- /package/{dist/health-checker → health-checker}/health-checker.controller.js +0 -0
- /package/{dist/health-checker → health-checker}/health-checker.module.d.ts +0 -0
- /package/{dist/health-checker → health-checker}/health-checker.module.js +0 -0
- /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.d.ts +0 -0
- /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.js +0 -0
- /package/{dist/helpers → helpers}/common.helper.d.ts +0 -0
- /package/{dist/helpers → helpers}/common.helper.js +0 -0
- /package/{dist/helpers → helpers}/date.helper.d.ts +0 -0
- /package/{dist/helpers → helpers}/date.helper.js +0 -0
- /package/{dist/helpers → helpers}/index.d.ts +0 -0
- /package/{dist/helpers → helpers}/index.js +0 -0
- /package/{dist/i18n → i18n}/en_US/validation.json +0 -0
- /package/{dist/i18n → i18n}/zh_CN/validation.json +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/interceptors → interceptors}/index.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/index.js +0 -0
- /package/{dist/interceptors → interceptors}/language-interceptor.service.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/language-interceptor.service.js +0 -0
- /package/{dist/interceptors → interceptors}/translation-interceptor.service.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/translation-interceptor.service.js +0 -0
- /package/{dist/interfaces → interfaces}/IApiFile.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/IApiFile.js +0 -0
- /package/{dist/interfaces → interfaces}/IFile.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/IFile.js +0 -0
- /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.js +0 -0
- /package/{dist/interfaces → interfaces}/index.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/index.js +0 -0
- /package/{dist/interfaces → interfaces}/response.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/response.js +0 -0
- /package/{dist/middlewares → middlewares}/index.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/index.js +0 -0
- /package/{dist/middlewares → middlewares}/omni-auth.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/omni-auth.middleware.js +0 -0
- /package/{dist/middlewares → middlewares}/powerby.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/powerby.middleware.js +0 -0
- /package/{dist/middlewares → middlewares}/request-id.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/request-id.middleware.js +0 -0
- /package/{dist/middlewares → middlewares}/xml.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/xml.middleware.js +0 -0
- /package/{dist/providers → providers}/context.provider.d.ts +0 -0
- /package/{dist/providers → providers}/context.provider.js +0 -0
- /package/{dist/providers → providers}/generator.provider.d.ts +0 -0
- /package/{dist/providers → providers}/generator.provider.js +0 -0
- /package/{dist/providers → providers}/index.d.ts +0 -0
- /package/{dist/providers → providers}/index.js +0 -0
- /package/{dist/setup → setup}/bootstrap.setup.d.ts +0 -0
- /package/{dist/setup → setup}/bootstrap.setup.js +0 -0
- /package/{dist/setup → setup}/index.d.ts +0 -0
- /package/{dist/setup → setup}/index.js +0 -0
- /package/{dist/shared → shared}/index.d.ts +0 -0
- /package/{dist/shared → shared}/index.js +0 -0
- /package/{dist/shared → shared}/serviceRegistryModule.d.ts +0 -0
- /package/{dist/shared → shared}/serviceRegistryModule.js +0 -0
- /package/{dist/shared → shared}/services/api-config.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/api-config.service.js +0 -0
- /package/{dist/shared → shared}/services/generator.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/generator.service.js +0 -0
- /package/{dist/shared → shared}/services/index.d.ts +0 -0
- /package/{dist/shared → shared}/services/index.js +0 -0
- /package/{dist/shared → shared}/services/translation.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/translation.service.js +0 -0
- /package/{dist/shared → shared}/services/validator.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/validator.service.js +0 -0
- /package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +0 -0
- /package/{dist/validator-json → validator-json}/decorators.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/decorators.js +0 -0
- /package/{dist/validator-json → validator-json}/default.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/default.js +0 -0
- /package/{dist/validator-json → validator-json}/defaultConverters.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/defaultConverters.js +0 -0
- /package/{dist/validator-json → validator-json}/index.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/index.js +0 -0
- /package/{dist/validator-json → validator-json}/options.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/options.js +0 -0
- /package/{dist/validators → validators}/file-mimetype.validator.d.ts +0 -0
- /package/{dist/validators → validators}/file-mimetype.validator.js +0 -0
- /package/{dist/validators → validators}/index.d.ts +0 -0
- /package/{dist/validators → validators}/index.js +0 -0
- /package/{dist/validators → validators}/is-exists.validator.d.ts +0 -0
- /package/{dist/validators → validators}/is-exists.validator.js +0 -0
- /package/{dist/validators → validators}/is-unique.validator.d.ts +0 -0
- /package/{dist/validators → validators}/is-unique.validator.js +0 -0
- /package/{dist/validators → validators}/phone-country-code.validator.d.ts +0 -0
- /package/{dist/validators → validators}/phone-country-code.validator.js +0 -0
- /package/{dist/validators → validators}/same-as.validator.d.ts +0 -0
- /package/{dist/validators → validators}/same-as.validator.js +0 -0
- /package/{dist/validators → validators}/skip-empty.validator.d.ts +0 -0
- /package/{dist/validators → validators}/skip-empty.validator.js +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { NamingStrategyInterface } from 'typeorm';
|
|
2
|
-
import { DefaultNamingStrategy } from 'typeorm';
|
|
3
|
-
import { snakeCase } from 'typeorm/util/StringUtils';
|
|
4
|
-
|
|
5
|
-
export class SnakeNamingStrategy
|
|
6
|
-
extends DefaultNamingStrategy
|
|
7
|
-
implements NamingStrategyInterface
|
|
8
|
-
{
|
|
9
|
-
tableName(className: string, customName: string | undefined): string {
|
|
10
|
-
if (className.includes('Entity')) {
|
|
11
|
-
className = className.replace('Entity', '');
|
|
12
|
-
}
|
|
13
|
-
return customName ?? snakeCase(className);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
columnName(
|
|
17
|
-
propertyName: string,
|
|
18
|
-
customName: string | undefined,
|
|
19
|
-
embeddedPrefixes: string[],
|
|
20
|
-
): string {
|
|
21
|
-
return (
|
|
22
|
-
snakeCase(embeddedPrefixes.join('_')) +
|
|
23
|
-
(customName ?? snakeCase(propertyName))
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
relationName(propertyName: string): string {
|
|
28
|
-
return snakeCase(propertyName);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
joinColumnName(relationName: string, referencedColumnName: string): string {
|
|
32
|
-
return snakeCase(relationName + '_' + referencedColumnName);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
joinTableName(
|
|
36
|
-
firstTableName: string,
|
|
37
|
-
secondTableName: string,
|
|
38
|
-
firstPropertyName: string,
|
|
39
|
-
_secondPropertyName: string,
|
|
40
|
-
): string {
|
|
41
|
-
return snakeCase(
|
|
42
|
-
firstTableName +
|
|
43
|
-
'_' +
|
|
44
|
-
firstPropertyName.replace(/\./gi, '_') +
|
|
45
|
-
'_' +
|
|
46
|
-
secondTableName,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
joinTableColumnName(
|
|
51
|
-
tableName: string,
|
|
52
|
-
propertyName: string,
|
|
53
|
-
columnName?: string,
|
|
54
|
-
): string {
|
|
55
|
-
return snakeCase(tableName + '_' + (columnName ?? propertyName));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
classTableInheritanceParentColumnName(
|
|
59
|
-
parentTableName: string,
|
|
60
|
-
parentTableIdPropertyName: string,
|
|
61
|
-
): string {
|
|
62
|
-
return snakeCase(`${parentTableName}_${parentTableIdPropertyName}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/common/types.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
export type Constructor<T, Arguments extends unknown[] = undefined[]> = new (
|
|
3
|
-
...arguments_: Arguments
|
|
4
|
-
) => T;
|
|
5
|
-
|
|
6
|
-
export type Plain<T> = T;
|
|
7
|
-
|
|
8
|
-
export type PathImpl<T, Key extends keyof T> = Key extends string
|
|
9
|
-
? T[Key] extends Record<string, any>
|
|
10
|
-
?
|
|
11
|
-
| `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> &
|
|
12
|
-
string}`
|
|
13
|
-
| `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}`
|
|
14
|
-
: never
|
|
15
|
-
: never;
|
|
16
|
-
|
|
17
|
-
export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
|
|
18
|
-
|
|
19
|
-
export type Path<T> = keyof T extends string
|
|
20
|
-
? PathImpl2<T> extends string | keyof T
|
|
21
|
-
? PathImpl2<T>
|
|
22
|
-
: keyof T
|
|
23
|
-
: never;
|
|
24
|
-
|
|
25
|
-
export type PathValue<
|
|
26
|
-
T,
|
|
27
|
-
P extends Path<T>,
|
|
28
|
-
> = P extends `${infer Key}.${infer Rest}`
|
|
29
|
-
? Key extends keyof T
|
|
30
|
-
? Rest extends Path<T[Key]>
|
|
31
|
-
? PathValue<T[Key], Rest>
|
|
32
|
-
: never
|
|
33
|
-
: never
|
|
34
|
-
: P extends keyof T
|
|
35
|
-
? T[P]
|
|
36
|
-
: never;
|
|
37
|
-
|
|
38
|
-
export type KeyOfType<Entity, U> = {
|
|
39
|
-
[P in keyof Required<Entity>]: Required<Entity>[P] extends U
|
|
40
|
-
? P
|
|
41
|
-
: Required<Entity>[P] extends U[]
|
|
42
|
-
? P
|
|
43
|
-
: never;
|
|
44
|
-
}[keyof Entity];
|
package/src/common/utils.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import bcrypt from 'bcrypt';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* generate hash from password or string
|
|
5
|
-
* @param {string} password
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
|
-
export function generateHash(password: string): string {
|
|
9
|
-
return bcrypt.hashSync(password, 10);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* validate text with hash
|
|
14
|
-
* @param {string} password
|
|
15
|
-
* @param {string} hash
|
|
16
|
-
* @returns {Promise<boolean>}
|
|
17
|
-
*/
|
|
18
|
-
export function validateHash(
|
|
19
|
-
password: string | undefined,
|
|
20
|
-
hash: string | undefined,
|
|
21
|
-
): Promise<boolean> {
|
|
22
|
-
if (!password || !hash) {
|
|
23
|
-
return Promise.resolve(false);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return bcrypt.compare(password, hash);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function getVariableName<TResult>(getVar: () => TResult): string {
|
|
30
|
-
const m = /\(\)=>(.*)/.exec(
|
|
31
|
-
getVar.toString().replace(/(\r\n|\n|\r|\s)/gm, ''),
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
if (!m) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
"The function does not contain a statement matching 'return variableName;'",
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const fullMemberName = m[1];
|
|
41
|
-
|
|
42
|
-
const memberParts = fullMemberName.split('.');
|
|
43
|
-
|
|
44
|
-
return memberParts[memberParts.length - 1];
|
|
45
|
-
}
|
package/src/constants/index.ts
DELETED
package/src/constants/order.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Type } from '@nestjs/common';
|
|
2
|
-
import { applyDecorators } from '@nestjs/common';
|
|
3
|
-
import type { ApiResponseOptions } from '@nestjs/swagger';
|
|
4
|
-
import { ApiExtraModels, ApiOkResponse, getSchemaPath } from '@nestjs/swagger';
|
|
5
|
-
|
|
6
|
-
import { PageDto } from '../common/dto/page.dto';
|
|
7
|
-
|
|
8
|
-
export function ApiPageResponse<T extends Type>(options: {
|
|
9
|
-
type: T;
|
|
10
|
-
description?: string;
|
|
11
|
-
}): MethodDecorator {
|
|
12
|
-
return applyDecorators(
|
|
13
|
-
ApiExtraModels(PageDto),
|
|
14
|
-
ApiExtraModels(options.type),
|
|
15
|
-
ApiOkResponse({
|
|
16
|
-
description: options.description,
|
|
17
|
-
schema: {
|
|
18
|
-
allOf: [
|
|
19
|
-
{ $ref: getSchemaPath(PageDto) },
|
|
20
|
-
{
|
|
21
|
-
properties: {
|
|
22
|
-
results: {
|
|
23
|
-
type: 'array',
|
|
24
|
-
items: { $ref: getSchemaPath(options.type) },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
} as ApiResponseOptions | undefined),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { createParamDecorator } from '@nestjs/common';
|
|
3
|
-
|
|
4
|
-
export function AuthUser() {
|
|
5
|
-
return createParamDecorator((_data: unknown, context: ExecutionContext) => {
|
|
6
|
-
const request = context.switchToHttp().getRequest();
|
|
7
|
-
|
|
8
|
-
const user = request.user;
|
|
9
|
-
|
|
10
|
-
if (user?.[Symbol.for('isPublic')]) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return user;
|
|
15
|
-
})();
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { applyDecorators, Controller as NestController } from '@nestjs/common';
|
|
2
|
-
import { Feature } from '@dataui/crud';
|
|
3
|
-
import * as _ from 'lodash';
|
|
4
|
-
|
|
5
|
-
export function Controller(field: string) {
|
|
6
|
-
const featureName = _.upperFirst(field);
|
|
7
|
-
return applyDecorators(NestController(field), Feature(featureName));
|
|
8
|
-
}
|