@nest-omni/core 1.0.12 → 1.0.15
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/{common → dist/common}/abstract-client.service.d.ts +1 -1
- package/dist/common/boilerplate.polyfill.d.ts +39 -0
- package/dist/common/boilerplate.polyfill.js +77 -0
- package/{common → dist/common}/index.d.ts +3 -0
- package/{common → dist/common}/index.js +3 -0
- package/dist/common/snake-naming.strategy.d.ts +11 -0
- package/dist/common/snake-naming.strategy.js +37 -0
- package/dist/common/types.d.ts +9 -0
- package/{decorators → dist/decorators}/use-dto.decorator.d.ts +1 -1
- package/dist/index.d.ts +11 -0
- package/{index.js → dist/index.js} +0 -3
- package/dist/interfaces/response.js +2 -0
- package/{shared → dist/shared}/services/api-config.service.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +2 -17
- /package/{common → dist/common}/abstract-client.service.js +0 -0
- /package/{common → dist/common}/abstract.entity.d.ts +0 -0
- /package/{common → dist/common}/abstract.entity.js +0 -0
- /package/{common → dist/common}/dto/abstract.dto.d.ts +0 -0
- /package/{common → dist/common}/dto/abstract.dto.js +0 -0
- /package/{common → dist/common}/dto/bulk-id.dto.d.ts +0 -0
- /package/{common → dist/common}/dto/bulk-id.dto.js +0 -0
- /package/{common → dist/common}/dto/create-translation.dto.d.ts +0 -0
- /package/{common → dist/common}/dto/create-translation.dto.js +0 -0
- /package/{common → dist/common}/dto/index.d.ts +0 -0
- /package/{common → dist/common}/dto/index.js +0 -0
- /package/{common → dist/common}/dto/page-meta.dto.d.ts +0 -0
- /package/{common → dist/common}/dto/page-meta.dto.js +0 -0
- /package/{common → dist/common}/dto/page-options.dto.d.ts +0 -0
- /package/{common → dist/common}/dto/page-options.dto.js +0 -0
- /package/{common → dist/common}/dto/page.dto.d.ts +0 -0
- /package/{common → dist/common}/dto/page.dto.js +0 -0
- /package/{interfaces/IApiFile.js → dist/common/types.js} +0 -0
- /package/{common → dist/common}/utils.d.ts +0 -0
- /package/{common → dist/common}/utils.js +0 -0
- /package/{constants → dist/constants}/index.d.ts +0 -0
- /package/{constants → dist/constants}/index.js +0 -0
- /package/{constants → dist/constants}/language-code.d.ts +0 -0
- /package/{constants → dist/constants}/language-code.js +0 -0
- /package/{constants → dist/constants}/order.d.ts +0 -0
- /package/{constants → dist/constants}/order.js +0 -0
- /package/{decorators → dist/decorators}/api-page-ok-response.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/api-page-ok-response.decorator.js +0 -0
- /package/{decorators → dist/decorators}/auth-user.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/auth-user.decorator.js +0 -0
- /package/{decorators → dist/decorators}/controller.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/controller.decorator.js +0 -0
- /package/{decorators → dist/decorators}/field.decorators.d.ts +0 -0
- /package/{decorators → dist/decorators}/field.decorators.js +0 -0
- /package/{decorators → dist/decorators}/http.decorators.d.ts +0 -0
- /package/{decorators → dist/decorators}/http.decorators.js +0 -0
- /package/{decorators → dist/decorators}/index.d.ts +0 -0
- /package/{decorators → dist/decorators}/index.js +0 -0
- /package/{decorators → dist/decorators}/omni-auth.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/omni-auth.decorator.js +0 -0
- /package/{decorators → dist/decorators}/operation.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/operation.decorator.js +0 -0
- /package/{decorators → dist/decorators}/property.decorators.d.ts +0 -0
- /package/{decorators → dist/decorators}/property.decorators.js +0 -0
- /package/{decorators → dist/decorators}/public-route.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/public-route.decorator.js +0 -0
- /package/{decorators → dist/decorators}/swagger.schema.d.ts +0 -0
- /package/{decorators → dist/decorators}/swagger.schema.js +0 -0
- /package/{decorators → dist/decorators}/timestamp-column.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/timestamp-column.decorator.js +0 -0
- /package/{decorators → dist/decorators}/transform.decorators.d.ts +0 -0
- /package/{decorators → dist/decorators}/transform.decorators.js +0 -0
- /package/{decorators → dist/decorators}/translate.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/translate.decorator.js +0 -0
- /package/{decorators → dist/decorators}/use-dto.decorator.js +0 -0
- /package/{decorators → dist/decorators}/user-check.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/user-check.decorator.js +0 -0
- /package/{decorators → dist/decorators}/user.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/user.decorator.js +0 -0
- /package/{decorators → dist/decorators}/user_auth.decorator.d.ts +0 -0
- /package/{decorators → dist/decorators}/user_auth.decorator.js +0 -0
- /package/{decorators → dist/decorators}/validator.decorators.d.ts +0 -0
- /package/{decorators → dist/decorators}/validator.decorators.js +0 -0
- /package/{exceptions → dist/exceptions}/file-not-image.exception.d.ts +0 -0
- /package/{exceptions → dist/exceptions}/file-not-image.exception.js +0 -0
- /package/{exceptions → dist/exceptions}/index.d.ts +0 -0
- /package/{exceptions → dist/exceptions}/index.js +0 -0
- /package/{exceptions → dist/exceptions}/page-type.exception.d.ts +0 -0
- /package/{exceptions → dist/exceptions}/page-type.exception.js +0 -0
- /package/{exceptions → dist/exceptions}/user-not-found.exception.d.ts +0 -0
- /package/{exceptions → dist/exceptions}/user-not-found.exception.js +0 -0
- /package/{filters → dist/filters}/bad-request.filter.d.ts +0 -0
- /package/{filters → dist/filters}/bad-request.filter.js +0 -0
- /package/{filters → dist/filters}/constraint-errors.d.ts +0 -0
- /package/{filters → dist/filters}/constraint-errors.js +0 -0
- /package/{filters → dist/filters}/index.d.ts +0 -0
- /package/{filters → dist/filters}/index.js +0 -0
- /package/{filters → dist/filters}/query-failed.filter.d.ts +0 -0
- /package/{filters → dist/filters}/query-failed.filter.js +0 -0
- /package/{health-checker → dist/health-checker}/health-checker.controller.d.ts +0 -0
- /package/{health-checker → dist/health-checker}/health-checker.controller.js +0 -0
- /package/{health-checker → dist/health-checker}/health-checker.module.d.ts +0 -0
- /package/{health-checker → dist/health-checker}/health-checker.module.js +0 -0
- /package/{health-checker → dist/health-checker}/health-indicators/service.indicator.d.ts +0 -0
- /package/{health-checker → dist/health-checker}/health-indicators/service.indicator.js +0 -0
- /package/{helpers → dist/helpers}/common.helper.d.ts +0 -0
- /package/{helpers → dist/helpers}/common.helper.js +0 -0
- /package/{helpers → dist/helpers}/date.helper.d.ts +0 -0
- /package/{helpers → dist/helpers}/date.helper.js +0 -0
- /package/{helpers → dist/helpers}/index.d.ts +0 -0
- /package/{helpers → dist/helpers}/index.js +0 -0
- /package/{i18n → dist/i18n}/en_US/validation.json +0 -0
- /package/{i18n → dist/i18n}/zh_CN/validation.json +0 -0
- /package/{interceptors → dist/interceptors}/auth-user.interceptor.d.ts +0 -0
- /package/{interceptors → dist/interceptors}/auth-user.interceptor.js +0 -0
- /package/{interceptors → dist/interceptors}/index.d.ts +0 -0
- /package/{interceptors → dist/interceptors}/index.js +0 -0
- /package/{interceptors → dist/interceptors}/language-interceptor.service.d.ts +0 -0
- /package/{interceptors → dist/interceptors}/language-interceptor.service.js +0 -0
- /package/{interceptors → dist/interceptors}/translation-interceptor.service.d.ts +0 -0
- /package/{interceptors → dist/interceptors}/translation-interceptor.service.js +0 -0
- /package/{interfaces → dist/interfaces}/IApiFile.d.ts +0 -0
- /package/{interfaces/IFile.js → dist/interfaces/IApiFile.js} +0 -0
- /package/{interfaces → dist/interfaces}/IFile.d.ts +0 -0
- /package/{interfaces/ITranslationDecoratorInterface.js → dist/interfaces/IFile.js} +0 -0
- /package/{interfaces → dist/interfaces}/ITranslationDecoratorInterface.d.ts +0 -0
- /package/{interfaces/response.js → dist/interfaces/ITranslationDecoratorInterface.js} +0 -0
- /package/{interfaces → dist/interfaces}/index.d.ts +0 -0
- /package/{interfaces → dist/interfaces}/index.js +0 -0
- /package/{interfaces → dist/interfaces}/response.d.ts +0 -0
- /package/{middlewares → dist/middlewares}/index.d.ts +0 -0
- /package/{middlewares → dist/middlewares}/index.js +0 -0
- /package/{middlewares → dist/middlewares}/omni-auth.middleware.d.ts +0 -0
- /package/{middlewares → dist/middlewares}/omni-auth.middleware.js +0 -0
- /package/{middlewares → dist/middlewares}/powerby.middleware.d.ts +0 -0
- /package/{middlewares → dist/middlewares}/powerby.middleware.js +0 -0
- /package/{middlewares → dist/middlewares}/request-id.middleware.d.ts +0 -0
- /package/{middlewares → dist/middlewares}/request-id.middleware.js +0 -0
- /package/{providers → dist/providers}/context.provider.d.ts +0 -0
- /package/{providers → dist/providers}/context.provider.js +0 -0
- /package/{providers → dist/providers}/generator.provider.d.ts +0 -0
- /package/{providers → dist/providers}/generator.provider.js +0 -0
- /package/{providers → dist/providers}/index.d.ts +0 -0
- /package/{providers → dist/providers}/index.js +0 -0
- /package/{setup → dist/setup}/bootstrap.setup.d.ts +0 -0
- /package/{setup → dist/setup}/bootstrap.setup.js +0 -0
- /package/{setup → dist/setup}/index.d.ts +0 -0
- /package/{setup → dist/setup}/index.js +0 -0
- /package/{shared → dist/shared}/index.d.ts +0 -0
- /package/{shared → dist/shared}/index.js +0 -0
- /package/{shared → dist/shared}/serviceRegistryModule.d.ts +0 -0
- /package/{shared → dist/shared}/serviceRegistryModule.js +0 -0
- /package/{shared → dist/shared}/services/api-config.service.d.ts +0 -0
- /package/{shared → dist/shared}/services/aws-s3.service.d.ts +0 -0
- /package/{shared → dist/shared}/services/aws-s3.service.js +0 -0
- /package/{shared → dist/shared}/services/generator.service.d.ts +0 -0
- /package/{shared → dist/shared}/services/generator.service.js +0 -0
- /package/{shared → dist/shared}/services/index.d.ts +0 -0
- /package/{shared → dist/shared}/services/index.js +0 -0
- /package/{shared → dist/shared}/services/translation.service.d.ts +0 -0
- /package/{shared → dist/shared}/services/translation.service.js +0 -0
- /package/{shared → dist/shared}/services/validator.service.d.ts +0 -0
- /package/{shared → dist/shared}/services/validator.service.js +0 -0
- /package/{validator-json → dist/validator-json}/decorators.d.ts +0 -0
- /package/{validator-json → dist/validator-json}/decorators.js +0 -0
- /package/{validator-json → dist/validator-json}/default.d.ts +0 -0
- /package/{validator-json → dist/validator-json}/default.js +0 -0
- /package/{validator-json → dist/validator-json}/defaultConverters.d.ts +0 -0
- /package/{validator-json → dist/validator-json}/defaultConverters.js +0 -0
- /package/{validator-json → dist/validator-json}/index.d.ts +0 -0
- /package/{validator-json → dist/validator-json}/index.js +0 -0
- /package/{validator-json → dist/validator-json}/options.d.ts +0 -0
- /package/{validator-json → dist/validator-json}/options.js +0 -0
- /package/{validators → dist/validators}/file-mimetype.validator.d.ts +0 -0
- /package/{validators → dist/validators}/file-mimetype.validator.js +0 -0
- /package/{validators → dist/validators}/index.d.ts +0 -0
- /package/{validators → dist/validators}/index.js +0 -0
- /package/{validators → dist/validators}/is-exists.validator.d.ts +0 -0
- /package/{validators → dist/validators}/is-exists.validator.js +0 -0
- /package/{validators → dist/validators}/is-unique.validator.d.ts +0 -0
- /package/{validators → dist/validators}/is-unique.validator.js +0 -0
- /package/{validators → dist/validators}/phone-country-code.validator.d.ts +0 -0
- /package/{validators → dist/validators}/phone-country-code.validator.js +0 -0
- /package/{validators → dist/validators}/same-as.validator.d.ts +0 -0
- /package/{validators → dist/validators}/same-as.validator.js +0 -0
- /package/{validators → dist/validators}/skip-empty.validator.d.ts +0 -0
- /package/{validators → dist/validators}/skip-empty.validator.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClientProxy } from '@nestjs/microservices';
|
|
2
|
-
import type { Constructor } from '
|
|
2
|
+
import type { Constructor } from './types';
|
|
3
3
|
import type { PageDto } from './dto/page.dto';
|
|
4
4
|
export declare class AbstractClientService<ActionType> {
|
|
5
5
|
private client;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import 'source-map-support/register';
|
|
2
|
+
import type { ObjectLiteral } from 'typeorm';
|
|
3
|
+
import type { AbstractEntity } from './abstract.entity';
|
|
4
|
+
import type { AbstractDto } from './dto/abstract.dto';
|
|
5
|
+
import type { CreateTranslationDto } from './dto/create-translation.dto';
|
|
6
|
+
import { PageDto } from './dto/page.dto';
|
|
7
|
+
import { PageMetaDto } from './dto/page-meta.dto';
|
|
8
|
+
import type { PageOptionsDto } from './dto/page-options.dto';
|
|
9
|
+
import type { LanguageCode } from '../constants/language-code';
|
|
10
|
+
import type { KeyOfType } from './types';
|
|
11
|
+
declare global {
|
|
12
|
+
export type Uuid = string & {
|
|
13
|
+
_uuidBrand: undefined;
|
|
14
|
+
};
|
|
15
|
+
export type Todo = any & {
|
|
16
|
+
_todoBrand: undefined;
|
|
17
|
+
};
|
|
18
|
+
interface Array<T> {
|
|
19
|
+
toDtos<Dto extends AbstractDto>(this: T[], options?: unknown): Dto[];
|
|
20
|
+
getByLanguage(this: CreateTranslationDto[], languageCode: LanguageCode): string;
|
|
21
|
+
toPageDto<Dto extends AbstractDto>(this: T[], pageMetaDto: PageMetaDto, options?: unknown): PageDto<Dto>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
declare module 'typeorm' {
|
|
25
|
+
interface SelectQueryBuilder<Entity> {
|
|
26
|
+
searchByString(q: string, columnNames: string[], options?: {
|
|
27
|
+
formStart: boolean;
|
|
28
|
+
}): this;
|
|
29
|
+
withTenant(tenantId?: string | number, tenantFieldName?: string): this;
|
|
30
|
+
paginate(this: SelectQueryBuilder<Entity>, pageOptionsDto: PageOptionsDto, options?: Partial<{
|
|
31
|
+
takeAll: boolean;
|
|
32
|
+
skipCount: boolean;
|
|
33
|
+
}>): Promise<[Entity[], PageMetaDto]>;
|
|
34
|
+
leftJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(this: SelectQueryBuilder<Entity>, property: `${A}.${Exclude<KeyOfType<AliasEntity, AbstractEntity>, symbol>}`, alias: string, condition?: string, parameters?: ObjectLiteral): this;
|
|
35
|
+
leftJoin<AliasEntity extends AbstractEntity, A extends string>(this: SelectQueryBuilder<Entity>, property: `${A}.${Exclude<KeyOfType<AliasEntity, AbstractEntity>, symbol>}`, alias: string, condition?: string, parameters?: ObjectLiteral): this;
|
|
36
|
+
innerJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(this: SelectQueryBuilder<Entity>, property: `${A}.${Exclude<KeyOfType<AliasEntity, AbstractEntity>, symbol>}`, alias: string, condition?: string, parameters?: ObjectLiteral): this;
|
|
37
|
+
innerJoin<AliasEntity extends AbstractEntity, A extends string>(this: SelectQueryBuilder<Entity>, property: `${A}.${Exclude<KeyOfType<AliasEntity, AbstractEntity>, symbol>}`, alias: string, condition?: string, parameters?: ObjectLiteral): this;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
require("source-map-support/register");
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const page_dto_1 = require("./dto/page.dto");
|
|
16
|
+
const page_meta_dto_1 = require("./dto/page-meta.dto");
|
|
17
|
+
const providers_1 = require("../providers");
|
|
18
|
+
Array.prototype.toDtos = function (options) {
|
|
19
|
+
return (0, lodash_1.compact)((0, lodash_1.map)(this, (item) => item.toDto(options)));
|
|
20
|
+
};
|
|
21
|
+
Array.prototype.getByLanguage = function (languageCode) {
|
|
22
|
+
return this.find((translation) => languageCode === translation.languageCode)
|
|
23
|
+
.text;
|
|
24
|
+
};
|
|
25
|
+
Array.prototype.toPageDto = function (pageMetaDto, options) {
|
|
26
|
+
return new page_dto_1.PageDto(this.toDtos(options), pageMetaDto);
|
|
27
|
+
};
|
|
28
|
+
typeorm_1.SelectQueryBuilder.prototype.searchByString = function (q, columnNames, options) {
|
|
29
|
+
if (!q) {
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
this.andWhere(new typeorm_1.Brackets((qb) => {
|
|
33
|
+
for (const item of columnNames) {
|
|
34
|
+
qb.orWhere(`${item} ILIKE :q`);
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
if (options === null || options === void 0 ? void 0 : options.formStart) {
|
|
38
|
+
this.setParameter('q', `${q}%`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.setParameter('q', `%${q}%`);
|
|
42
|
+
}
|
|
43
|
+
return this;
|
|
44
|
+
};
|
|
45
|
+
typeorm_1.SelectQueryBuilder.prototype.paginate = function (pageOptionsDto, options) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!(options === null || options === void 0 ? void 0 : options.takeAll)) {
|
|
48
|
+
this.skip(pageOptionsDto.skip).take(pageOptionsDto.pageSize);
|
|
49
|
+
}
|
|
50
|
+
const entities = yield this.getMany();
|
|
51
|
+
let itemCount = -1;
|
|
52
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipCount)) {
|
|
53
|
+
itemCount = yield this.getCount();
|
|
54
|
+
}
|
|
55
|
+
const pageMetaDto = new page_meta_dto_1.PageMetaDto({
|
|
56
|
+
itemCount,
|
|
57
|
+
pageOptionsDto,
|
|
58
|
+
});
|
|
59
|
+
return [entities, pageMetaDto];
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
typeorm_1.SelectQueryBuilder.prototype.withTenant = function (tenantId, tenantFieldName = 'tenantId') {
|
|
63
|
+
var _a;
|
|
64
|
+
if (!tenantId) {
|
|
65
|
+
tenantId = providers_1.ContextProvider.getTenantId();
|
|
66
|
+
}
|
|
67
|
+
if (this.expressionMap.mainAlias.hasMetadata) {
|
|
68
|
+
const entityMetadata = this.expressionMap.mainAlias.metadata;
|
|
69
|
+
const columnName = (_a = entityMetadata.columns.find((column) => column.propertyName === tenantFieldName)) === null || _a === void 0 ? void 0 : _a.databaseName;
|
|
70
|
+
if (columnName) {
|
|
71
|
+
return this.andWhere(`${this.alias}.${columnName} = :tenantId`, {
|
|
72
|
+
tenantId,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return this;
|
|
77
|
+
};
|
|
@@ -18,3 +18,6 @@ __exportStar(require("./abstract.entity"), exports);
|
|
|
18
18
|
__exportStar(require("./abstract-client.service"), exports);
|
|
19
19
|
__exportStar(require("./utils"), exports);
|
|
20
20
|
__exportStar(require("./dto"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
__exportStar(require("./snake-naming.strategy"), exports);
|
|
23
|
+
__exportStar(require("./boilerplate.polyfill"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NamingStrategyInterface } from 'typeorm';
|
|
2
|
+
import { DefaultNamingStrategy } from 'typeorm';
|
|
3
|
+
export declare class SnakeNamingStrategy extends DefaultNamingStrategy implements NamingStrategyInterface {
|
|
4
|
+
tableName(className: string, customName: string | undefined): string;
|
|
5
|
+
columnName(propertyName: string, customName: string | undefined, embeddedPrefixes: string[]): string;
|
|
6
|
+
relationName(propertyName: string): string;
|
|
7
|
+
joinColumnName(relationName: string, referencedColumnName: string): string;
|
|
8
|
+
joinTableName(firstTableName: string, secondTableName: string, firstPropertyName: string, _secondPropertyName: string): string;
|
|
9
|
+
joinTableColumnName(tableName: string, propertyName: string, columnName?: string): string;
|
|
10
|
+
classTableInheritanceParentColumnName(parentTableName: string, parentTableIdPropertyName: string): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnakeNamingStrategy = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const StringUtils_1 = require("typeorm/util/StringUtils");
|
|
6
|
+
class SnakeNamingStrategy extends typeorm_1.DefaultNamingStrategy {
|
|
7
|
+
tableName(className, customName) {
|
|
8
|
+
if (className.includes('Entity')) {
|
|
9
|
+
className = className.replace('Entity', '');
|
|
10
|
+
}
|
|
11
|
+
return customName !== null && customName !== void 0 ? customName : (0, StringUtils_1.snakeCase)(className);
|
|
12
|
+
}
|
|
13
|
+
columnName(propertyName, customName, embeddedPrefixes) {
|
|
14
|
+
return ((0, StringUtils_1.snakeCase)(embeddedPrefixes.join('_')) +
|
|
15
|
+
(customName !== null && customName !== void 0 ? customName : (0, StringUtils_1.snakeCase)(propertyName)));
|
|
16
|
+
}
|
|
17
|
+
relationName(propertyName) {
|
|
18
|
+
return (0, StringUtils_1.snakeCase)(propertyName);
|
|
19
|
+
}
|
|
20
|
+
joinColumnName(relationName, referencedColumnName) {
|
|
21
|
+
return (0, StringUtils_1.snakeCase)(relationName + '_' + referencedColumnName);
|
|
22
|
+
}
|
|
23
|
+
joinTableName(firstTableName, secondTableName, firstPropertyName, _secondPropertyName) {
|
|
24
|
+
return (0, StringUtils_1.snakeCase)(firstTableName +
|
|
25
|
+
'_' +
|
|
26
|
+
firstPropertyName.replace(/\./gi, '_') +
|
|
27
|
+
'_' +
|
|
28
|
+
secondTableName);
|
|
29
|
+
}
|
|
30
|
+
joinTableColumnName(tableName, propertyName, columnName) {
|
|
31
|
+
return (0, StringUtils_1.snakeCase)(tableName + '_' + (columnName !== null && columnName !== void 0 ? columnName : propertyName));
|
|
32
|
+
}
|
|
33
|
+
classTableInheritanceParentColumnName(parentTableName, parentTableIdPropertyName) {
|
|
34
|
+
return (0, StringUtils_1.snakeCase)(`${parentTableName}_${parentTableIdPropertyName}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SnakeNamingStrategy = SnakeNamingStrategy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Constructor<T, Arguments extends unknown[] = undefined[]> = new (...arguments_: Arguments) => T;
|
|
2
|
+
export type Plain<T> = T;
|
|
3
|
+
export type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
|
|
4
|
+
export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
|
|
5
|
+
export type Path<T> = keyof T extends string ? PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T : never;
|
|
6
|
+
export type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
|
|
7
|
+
export type KeyOfType<Entity, U> = {
|
|
8
|
+
[P in keyof Required<Entity>]: Required<Entity>[P] extends U ? P : Required<Entity>[P] extends U[] ? P : never;
|
|
9
|
+
}[keyof Entity];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AbstractEntity } from '../common/abstract.entity';
|
|
2
2
|
import type { AbstractDto } from '../common/dto/abstract.dto';
|
|
3
|
-
import type { Constructor } from '../types';
|
|
3
|
+
import type { Constructor } from '../common/types';
|
|
4
4
|
export declare function UseDto(dtoClass: Constructor<AbstractDto, [AbstractEntity, unknown]>): ClassDecorator;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './decorators';
|
|
3
|
+
export * from './exceptions';
|
|
4
|
+
export * from './filters';
|
|
5
|
+
export * from './interfaces';
|
|
6
|
+
export * from './interceptors';
|
|
7
|
+
export * from './shared';
|
|
8
|
+
export * from './middlewares';
|
|
9
|
+
export * from './validators';
|
|
10
|
+
export * from './common';
|
|
11
|
+
export * from './validator-json';
|
|
@@ -21,9 +21,6 @@ __exportStar(require("./filters"), exports);
|
|
|
21
21
|
__exportStar(require("./interfaces"), exports);
|
|
22
22
|
__exportStar(require("./interceptors"), exports);
|
|
23
23
|
__exportStar(require("./shared"), exports);
|
|
24
|
-
__exportStar(require("./types"), exports);
|
|
25
|
-
__exportStar(require("./snake-naming.strategy"), exports);
|
|
26
|
-
__exportStar(require("./boilerplate.polyfill"), exports);
|
|
27
24
|
__exportStar(require("./middlewares"), exports);
|
|
28
25
|
__exportStar(require("./validators"), exports);
|
|
29
26
|
__exportStar(require("./common"), exports);
|
|
@@ -23,10 +23,10 @@ exports.ApiConfigService = void 0;
|
|
|
23
23
|
const common_1 = require("@nestjs/common");
|
|
24
24
|
const config_1 = require("@nestjs/config");
|
|
25
25
|
const lodash_1 = require("lodash");
|
|
26
|
-
const snake_naming_strategy_1 = require("../../snake-naming.strategy");
|
|
27
26
|
const cache_manager_ioredis_yet_1 = require("cache-manager-ioredis-yet");
|
|
28
27
|
const connect_redis_1 = require("connect-redis");
|
|
29
28
|
const ioredis_1 = require("ioredis");
|
|
29
|
+
const common_2 = require("../../common");
|
|
30
30
|
let ApiConfigService = ApiConfigService_1 = class ApiConfigService {
|
|
31
31
|
constructor(configService) {
|
|
32
32
|
this.configService = configService;
|
|
@@ -113,7 +113,7 @@ let ApiConfigService = ApiConfigService_1 = class ApiConfigService {
|
|
|
113
113
|
migrationsRun: true,
|
|
114
114
|
logging: this.getBoolean('DB_LOG_ENABLED'),
|
|
115
115
|
maxQueryExecutionTime: 3000,
|
|
116
|
-
namingStrategy: new
|
|
116
|
+
namingStrategy: new common_2.SnakeNamingStrategy(),
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
get awsS3Config() {
|