nicot 1.1.37 → 1.2.0
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/README.md +58 -20
- package/dist/index.cjs +651 -271
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +580 -221
- package/dist/index.mjs.map +4 -4
- package/dist/src/bases/base-restful-controller.d.ts +1 -1
- package/dist/src/crud-base.d.ts +1 -0
- package/dist/src/decorators/access.d.ts +1 -0
- package/dist/src/decorators/get-mutator.d.ts +17 -0
- package/dist/src/decorators/index.d.ts +1 -0
- package/dist/src/decorators/pipes.d.ts +6 -4
- package/dist/src/decorators/property.d.ts +3 -3
- package/dist/src/decorators/query.d.ts +26 -6
- package/dist/src/restful.d.ts +26 -20
- package/dist/src/utility/memorize.d.ts +1 -0
- package/dist/src/utility/metadata.d.ts +7 -5
- package/dist/src/utility/mutate-pipe.d.ts +8 -0
- package/dist/src/utility/omit-type-exclude.d.ts +1 -0
- package/dist/src/utility/parse-bool.d.ts +0 -7
- package/package.json +3 -3
|
@@ -13,7 +13,7 @@ export declare class BaseRestfulController<T extends {
|
|
|
13
13
|
relations: (string | RelationDef)[];
|
|
14
14
|
entityClass: ClassType<T>;
|
|
15
15
|
}>;
|
|
16
|
-
|
|
16
|
+
_service: CrudBase<T>;
|
|
17
17
|
constructor(serviceOrRepo: CrudBase<T> | Repository<T>, _options?: Partial<{
|
|
18
18
|
paginateType: RestfulPaginateType;
|
|
19
19
|
relations: (string | RelationDef)[];
|
package/dist/src/crud-base.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface CrudOptions<T extends ValidCrudEntity<T>> {
|
|
|
18
18
|
hardDelete?: boolean;
|
|
19
19
|
createOrUpdate?: boolean;
|
|
20
20
|
keepEntityVersioningDates?: boolean;
|
|
21
|
+
outputFieldsToOmit?: (keyof T)[];
|
|
21
22
|
}
|
|
22
23
|
export declare class CrudBase<T extends ValidCrudEntity<T>> {
|
|
23
24
|
entityClass: ClassType<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const NotWritable: () => PropertyDecorator;
|
|
2
|
+
export declare const NotCreatable: () => PropertyDecorator;
|
|
2
3
|
export declare const NotChangeable: () => PropertyDecorator;
|
|
3
4
|
export declare const NotQueryable: () => import("typed-reflector").AllDecorators;
|
|
4
5
|
export declare const NotInResult: (options?: {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
+
export interface GetMutatorOptions {
|
|
3
|
+
mutator: (s: string) => any;
|
|
4
|
+
enum?: string[];
|
|
5
|
+
example?: string;
|
|
6
|
+
apiPropertyExtras?: ApiPropertyOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare const RequireGetMutator: () => import("typed-reflector").AllDecorators;
|
|
9
|
+
export declare const GetMutator: (mutator: (s: string) => any, options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
10
|
+
export declare const createGetMutator: (mutator: (s: string) => any, defaultOptions?: Omit<GetMutatorOptions, "mutator">) => (options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
11
|
+
export declare const GetMutatorBool: (options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
12
|
+
export declare const GetMutatorInt: (options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
13
|
+
export declare const GetMutatorFloat: (options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
14
|
+
export declare const GetMutatorStringSeparated: (separator?: string, options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
15
|
+
export declare const GetMutatorIntSeparated: (separator?: string, options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
16
|
+
export declare const GetMutatorFloatSeparated: (separator?: string, options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
17
|
+
export declare const GetMutatorJson: (options?: Omit<GetMutatorOptions, "mutator">) => import("typed-reflector").AllDecorators;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ValidationPipe } from '@nestjs/common';
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
1
|
+
import { PipeTransform, ValidationPipe } from '@nestjs/common';
|
|
2
|
+
export declare const OptionalDataPipe: () => ValidationPipe;
|
|
3
|
+
type FieldKey = string | number | symbol;
|
|
4
|
+
export declare const PickPipe: (fields: FieldKey[]) => PipeTransform;
|
|
5
|
+
export declare const OmitPipe: (fields: FieldKey[]) => PipeTransform;
|
|
6
|
+
export {};
|
|
@@ -2,10 +2,10 @@ import { ColumnCommonOptions } from 'typeorm/decorator/options/ColumnCommonOptio
|
|
|
2
2
|
import { ApiPropertyOptions } from '@nestjs/swagger';
|
|
3
3
|
import { ColumnWithLengthOptions } from 'typeorm/decorator/options/ColumnWithLengthOptions';
|
|
4
4
|
import { AnyClass } from 'nesties';
|
|
5
|
-
import { SimpleColumnType, WithLengthColumnType, WithPrecisionColumnType
|
|
6
|
-
import { ColumnWithWidthOptions } from 'typeorm/decorator/options/ColumnWithWidthOptions';
|
|
5
|
+
import { SimpleColumnType, UnsignedColumnType, WithLengthColumnType, WithPrecisionColumnType } from 'typeorm/driver/types/ColumnTypes';
|
|
7
6
|
import { ColumnNumericOptions } from 'typeorm/decorator/options/ColumnNumericOptions';
|
|
8
7
|
import { ClassOrArray, ParseType } from 'nesties';
|
|
8
|
+
import { ColumnUnsignedOptions } from 'typeorm/decorator/options/ColumnUnsignedOptions';
|
|
9
9
|
export interface OpenAPIOptions<T> {
|
|
10
10
|
description?: string;
|
|
11
11
|
propertyExtras?: ApiPropertyOptions;
|
|
@@ -24,7 +24,7 @@ export declare const TextColumn: (options?: PropertyOptions<string> & {
|
|
|
24
24
|
export declare const UuidColumn: (options?: PropertyOptions<string> & {
|
|
25
25
|
generated?: boolean;
|
|
26
26
|
}) => PropertyDecorator;
|
|
27
|
-
export declare const IntColumn: (type:
|
|
27
|
+
export declare const IntColumn: (type: UnsignedColumnType, options?: PropertyOptions<number, ColumnUnsignedOptions> & {
|
|
28
28
|
unsigned?: boolean;
|
|
29
29
|
range?: {
|
|
30
30
|
min?: number;
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import { QueryCond } from '../bases';
|
|
2
2
|
import { QueryFullTextColumnOptions } from '../utility/query-full-text-column-options.interface';
|
|
3
3
|
export declare const QueryCondition: (cond: QueryCond) => PropertyDecorator;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export declare const QueryManual: () => PropertyDecorator;
|
|
5
|
+
export declare class QueryWrapInfo<T = unknown> {
|
|
6
|
+
readonly obj: any;
|
|
7
|
+
readonly key: string;
|
|
8
|
+
readonly field: string;
|
|
9
|
+
private _value;
|
|
10
|
+
constructor(obj: any, key: string, field: string);
|
|
11
|
+
get value(): T;
|
|
12
|
+
mutateValue(next: T): void;
|
|
13
|
+
}
|
|
14
|
+
export type QueryWrapper = (entityExpr: string, varExpr: string, info: QueryWrapInfo<any>) => string | undefined;
|
|
15
|
+
export declare const QueryWrap: (wrapper: QueryWrapper, field?: string) => PropertyDecorator;
|
|
16
|
+
export declare const createQueryWrap: (wrapper: QueryWrapper) => (field?: string) => PropertyDecorator;
|
|
17
|
+
export declare const QueryLike: (field?: string) => PropertyDecorator;
|
|
18
|
+
export declare const QuerySearch: (field?: string) => PropertyDecorator;
|
|
19
|
+
export declare const QueryEqualZeroNullable: (field?: string) => PropertyDecorator;
|
|
20
|
+
export declare const QueryMatchBoolean: (field?: string) => PropertyDecorator;
|
|
21
|
+
export declare const QueryMatchBooleanMySQL: (field?: string) => PropertyDecorator;
|
|
10
22
|
export declare const QueryOperator: (operator: string, field?: string) => PropertyDecorator;
|
|
11
23
|
export declare const createQueryOperator: (operator: string) => (field?: string) => PropertyDecorator;
|
|
24
|
+
export declare const QueryEqual: (field?: string) => PropertyDecorator;
|
|
12
25
|
export declare const QueryGreater: (field?: string) => PropertyDecorator;
|
|
13
26
|
export declare const QueryGreaterEqual: (field?: string) => PropertyDecorator;
|
|
14
27
|
export declare const QueryLess: (field?: string) => PropertyDecorator;
|
|
15
28
|
export declare const QueryLessEqual: (field?: string) => PropertyDecorator;
|
|
16
29
|
export declare const QueryNotEqual: (field?: string) => PropertyDecorator;
|
|
30
|
+
export declare const QueryJsonbHas: (field?: string) => PropertyDecorator;
|
|
31
|
+
export declare const createQueryArrayify: (newWrapper: QueryWrapper, singleFallbackWrapper?: QueryWrapper) => (field?: string) => PropertyDecorator;
|
|
32
|
+
export declare const createQueryOperatorArrayify: (operator: string, singleFallback?: string | QueryWrapper) => (field?: string) => PropertyDecorator;
|
|
33
|
+
export declare const QueryIn: (field?: string) => PropertyDecorator;
|
|
34
|
+
export declare const QueryNotIn: (field?: string) => PropertyDecorator;
|
|
17
35
|
export declare const QueryFullText: (options?: QueryFullTextColumnOptions) => PropertyDecorator;
|
|
36
|
+
export declare const QueryAnd: (...decs: PropertyDecorator[]) => PropertyDecorator;
|
|
37
|
+
export declare const QueryOr: (...decs: PropertyDecorator[]) => PropertyDecorator;
|
package/dist/src/restful.d.ts
CHANGED
|
@@ -8,11 +8,16 @@ import { Repository } from 'typeorm';
|
|
|
8
8
|
import { RelationDef } from './utility/relation-def';
|
|
9
9
|
export interface RestfulFactoryOptions<T> {
|
|
10
10
|
fieldsToOmit?: (keyof T)[];
|
|
11
|
+
writeFieldsToOmit?: (keyof T)[];
|
|
12
|
+
createFieldsToOmit?: (keyof T)[];
|
|
13
|
+
updateFieldsToOmit?: (keyof T)[];
|
|
14
|
+
findAllFieldsToOmit?: (keyof T)[];
|
|
15
|
+
outputFieldsToOmit?: (keyof T)[];
|
|
11
16
|
prefix?: string;
|
|
12
17
|
keepEntityVersioningDates?: boolean;
|
|
13
|
-
outputFieldsToOmit?: (keyof T)[];
|
|
14
18
|
entityClassName?: string;
|
|
15
19
|
relations?: (string | RelationDef)[];
|
|
20
|
+
skipNonQueryableFields?: boolean;
|
|
16
21
|
}
|
|
17
22
|
export declare class RestfulFactory<T extends {
|
|
18
23
|
id: any;
|
|
@@ -21,31 +26,32 @@ export declare class RestfulFactory<T extends {
|
|
|
21
26
|
private options;
|
|
22
27
|
private __resolveVisited;
|
|
23
28
|
private getEntityClassName;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
get fieldsToOmit(): (keyof T)[];
|
|
30
|
+
get fieldsInCreateToOmit(): (keyof T)[];
|
|
31
|
+
get createDto(): ClassType<T>;
|
|
32
|
+
get fieldsInUpdateToOmit(): (keyof T)[];
|
|
33
|
+
get updateDto(): ClassType<T>;
|
|
34
|
+
get importDto(): new () => {
|
|
28
35
|
data: T[];
|
|
29
36
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly importReturnMessageDto: new (statusCode: number, message: string, data: {
|
|
37
|
+
get fieldsInGetToOmit(): (keyof T)[];
|
|
38
|
+
get queryableFields(): (keyof T)[];
|
|
39
|
+
get findAllDto(): ClassType<T>;
|
|
40
|
+
get findAllCursorPaginatedDto(): ClassType<T>;
|
|
41
|
+
get entityResultDto(): ClassType<T>;
|
|
42
|
+
get entityCreateResultDto(): import("@nestjs/common").Type<Omit<T, keyof T>>;
|
|
43
|
+
get entityReturnMessageDto(): new (statusCode: number, message: string, data: T) => import("nesties").GenericReturnMessageDto<T>;
|
|
44
|
+
get entityCreateReturnMessageDto(): new (statusCode: number, message: string, data: Omit<T, keyof T>) => import("nesties").GenericReturnMessageDto<Omit<T, keyof T>>;
|
|
45
|
+
get entityArrayReturnMessageDto(): new (statusCode: number, message: string, data: T[], total: number, pageSettings: import("nesties").PageSettingsWise) => import("nesties").GenericPaginatedReturnMessageDto<T>;
|
|
46
|
+
get entityCursorPaginationReturnMessageDto(): new (statusCode: number, message: string, data: T[], cursorResponse: import("./dto").CursorPaginationResponseWise) => import("./dto").GenericCursorPaginationReturnMessageDto<T>;
|
|
47
|
+
get importReturnMessageDto(): new (statusCode: number, message: string, data: {
|
|
42
48
|
result: string;
|
|
43
49
|
entry: Omit<T, keyof T>;
|
|
44
50
|
}[]) => import("nesties").GenericReturnMessageDto<{
|
|
45
51
|
result: string;
|
|
46
52
|
entry: Omit<T, keyof T>;
|
|
47
53
|
}[]>;
|
|
48
|
-
|
|
54
|
+
get idType(): StringConstructor | NumberConstructor;
|
|
49
55
|
constructor(entityClass: ClassType<T>, options?: RestfulFactoryOptions<T>, __resolveVisited?: Map<AnyClass, [AnyClass]>);
|
|
50
56
|
private usePrefix;
|
|
51
57
|
create(extras?: Partial<OperationObject>): MethodDecorator;
|
|
@@ -54,7 +60,7 @@ export declare class RestfulFactory<T extends {
|
|
|
54
60
|
idParam(): ParameterDecorator;
|
|
55
61
|
findAll(extras?: Partial<OperationObject>): MethodDecorator;
|
|
56
62
|
findAllCursorPaginated(extras?: Partial<OperationObject>): MethodDecorator;
|
|
57
|
-
private
|
|
63
|
+
private getMutatorColumns;
|
|
58
64
|
findAllParam(): ParameterDecorator;
|
|
59
65
|
update(extras?: Partial<OperationObject>): MethodDecorator;
|
|
60
66
|
updateParam(): ParameterDecorator;
|
|
@@ -74,7 +80,7 @@ export declare class RestfulFactory<T extends {
|
|
|
74
80
|
} ? M_1 : never; }[keyof NonNullable<Options["routes"]>] & ("update" | "create" | "delete" | "findOne" | "findAll" | "import")> : Pick<BaseRestfulController<T>, { [M in keyof NonNullable<Options["routes"]>]: NonNullable<Options["routes"]>[M] extends {
|
|
75
81
|
enabled: true;
|
|
76
82
|
} ? M : never; }[keyof NonNullable<Options["routes"]>] & ("update" | "create" | "delete" | "findOne" | "findAll" | "import")>) & {
|
|
77
|
-
|
|
83
|
+
_service: CrudBase<T>;
|
|
78
84
|
};
|
|
79
85
|
crudService(options?: CrudOptions<T>): {
|
|
80
86
|
new (repo: Repository<T>): {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Memorize: () => (_target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -2,11 +2,13 @@ import { MetadataSetter, Reflector } from 'typed-reflector';
|
|
|
2
2
|
import { QueryCond } from '../bases';
|
|
3
3
|
import { AnyClass } from 'nesties';
|
|
4
4
|
import { QueryFullTextColumnOptions } from './query-full-text-column-options.interface';
|
|
5
|
+
import { GetMutatorOptions } from '../decorators/get-mutator';
|
|
5
6
|
interface SpecificFields {
|
|
6
7
|
notColumn: {
|
|
7
8
|
keepInCreate?: boolean;
|
|
8
9
|
};
|
|
9
10
|
notWritable: boolean;
|
|
11
|
+
notCreatable: boolean;
|
|
10
12
|
notChangeable: boolean;
|
|
11
13
|
notQueryable: boolean;
|
|
12
14
|
notInResult: {
|
|
@@ -17,17 +19,17 @@ interface SpecificFields {
|
|
|
17
19
|
isArray: boolean;
|
|
18
20
|
};
|
|
19
21
|
queryFullTextColumn: QueryFullTextColumnOptions;
|
|
20
|
-
boolColumn: boolean;
|
|
21
22
|
notRequiredButHasDefault: boolean;
|
|
22
|
-
}
|
|
23
|
-
interface MetadataMap extends SpecificFields {
|
|
24
23
|
queryCondition: QueryCond;
|
|
24
|
+
requireGetMutator: boolean;
|
|
25
|
+
getMutator: GetMutatorOptions;
|
|
25
26
|
}
|
|
27
|
+
type MetadataMap = SpecificFields;
|
|
26
28
|
type FieldsMap = {
|
|
27
29
|
[K in keyof MetadataMap as `${K}Fields`]: string;
|
|
28
30
|
};
|
|
29
|
-
export declare const Metadata: MetadataSetter<
|
|
30
|
-
export declare const reflector: Reflector<
|
|
31
|
+
export declare const Metadata: MetadataSetter<SpecificFields, FieldsMap>;
|
|
32
|
+
export declare const reflector: Reflector<SpecificFields, FieldsMap>;
|
|
31
33
|
export declare function getSpecificFields<K extends keyof SpecificFields>(obj: any, type: K, filter?: (meta: SpecificFields[K], obj: any) => boolean): FieldsMap[`${K}Fields`][];
|
|
32
34
|
export declare function getNotInResultFields(obj: any, keepEntityVersioningDates?: boolean): string[];
|
|
33
35
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PipeTransform } from '@nestjs/common';
|
|
2
|
+
import { AnyClass } from 'nesties';
|
|
3
|
+
export declare class MutatorPipe implements PipeTransform {
|
|
4
|
+
private readonly entityClass;
|
|
5
|
+
constructor(entityClass: AnyClass);
|
|
6
|
+
private mutatorFields;
|
|
7
|
+
transform<T>(obj: T): T;
|
|
8
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ClassType } from 'nesties';
|
|
2
2
|
export declare const OmitTypeExclude: <T, K extends keyof T>(cl: ClassType<T>, keys: readonly K[]) => import("@nestjs/common").Type<Omit<T, K>>;
|
|
3
|
+
export declare const PickTypeExpose: <T, K extends keyof T>(cl: ClassType<T>, keys: readonly K[]) => import("@nestjs/common").Type<Omit<T, K>>;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import { PipeTransform } from '@nestjs/common';
|
|
2
1
|
export declare const parseBool: (value: any) => boolean;
|
|
3
|
-
export declare const parseBoolObject: <T>(obj: T, boolFields: (keyof T)[]) => T;
|
|
4
|
-
export declare class ParseBoolObjectPipe<T> implements PipeTransform {
|
|
5
|
-
private readonly boolFields;
|
|
6
|
-
constructor(boolFields: string[]);
|
|
7
|
-
transform(obj: T): T;
|
|
8
|
-
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nicot",
|
|
3
3
|
"description": "Nest.js interacting with class-validator + OpenAPI + TypeORM for Nest.js Restful API development.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
"@nestjs/swagger": "^11.0.0 || ^7.1.8 || ^6.3.0",
|
|
92
92
|
"class-transformer": "^0.5.1",
|
|
93
93
|
"class-validator": "^0.14.0",
|
|
94
|
-
"typeorm": "^0.3.
|
|
94
|
+
"typeorm": "^0.3.27"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"lodash": "^4.17.21",
|
|
98
98
|
"nesties": "^1.1.15",
|
|
99
99
|
"p-queue": "6.6.2",
|
|
100
100
|
"superjson": "1.13.3",
|
|
101
|
-
"typed-reflector": "^1.0.
|
|
101
|
+
"typed-reflector": "^1.0.14"
|
|
102
102
|
}
|
|
103
103
|
}
|