nicot 1.3.8 → 1.4.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/README-CN.md +40 -0
- package/README.md +41 -0
- package/dist/index.cjs +100 -12
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +96 -13
- package/dist/index.mjs.map +4 -4
- package/dist/src/decorators/property.d.ts +10 -0
- package/dist/src/decorators/query.d.ts +10 -0
- package/dist/src/utility/base64-binary.d.ts +23 -0
- package/dist/src/utility/index.d.ts +1 -0
- package/package.json +6 -4
|
@@ -2,6 +2,7 @@ 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 { ValidationOptions } from 'class-validator';
|
|
5
6
|
import { SimpleColumnType, UnsignedColumnType, WithLengthColumnType, WithPrecisionColumnType } from 'typeorm/driver/types/ColumnTypes';
|
|
6
7
|
import { ColumnNumericOptions } from 'typeorm/decorator/options/ColumnNumericOptions';
|
|
7
8
|
import { ClassOrArray, ParseType } from 'nesties';
|
|
@@ -52,6 +53,15 @@ export declare const SimpleJsonColumn: <C extends ClassOrArray>(definition: C, o
|
|
|
52
53
|
export declare const StringJsonColumn: <C extends ClassOrArray>(definition: C, options?: PropertyOptions<ParseType<C>> & {
|
|
53
54
|
columnType?: SimpleColumnType;
|
|
54
55
|
}) => PropertyDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* Accepts either a valid base64 `string` or a raw binary payload
|
|
58
|
+
* (`Buffer` / `Uint8Array` / `ArrayBuffer`). The binary case represents the
|
|
59
|
+
* actual binary data being assigned directly instead of its base64 form.
|
|
60
|
+
*/
|
|
61
|
+
export declare const IsBase64OrBinary: (validationOptions?: ValidationOptions) => PropertyDecorator;
|
|
62
|
+
export declare const Base64BinaryColumn: (options?: PropertyOptions<string> & {
|
|
63
|
+
columnType?: SimpleColumnType | WithLengthColumnType;
|
|
64
|
+
}) => PropertyDecorator;
|
|
55
65
|
export declare const NotColumn: (options?: OpenAPIOptions<any>, specials?: {
|
|
56
66
|
keepInCreate?: boolean;
|
|
57
67
|
hideInUpsert?: boolean;
|
|
@@ -32,6 +32,16 @@ export declare const createQueryArrayify: (newWrapper: QueryWrapper, singleFallb
|
|
|
32
32
|
export declare const createQueryOperatorArrayify: (operator: string, singleFallback?: string | QueryWrapper) => (field?: string) => PropertyDecorator;
|
|
33
33
|
export declare const QueryIn: (field?: string) => PropertyDecorator;
|
|
34
34
|
export declare const QueryNotIn: (field?: string) => PropertyDecorator;
|
|
35
|
+
/**
|
|
36
|
+
* Builds a query condition for a `Base64BinaryColumn`. The incoming base64
|
|
37
|
+
* string (the API-facing form) is decoded into a `Buffer` right before it is
|
|
38
|
+
* bound as a query parameter, so it can be compared against the raw binary
|
|
39
|
+
* stored in the database. A value that is already binary
|
|
40
|
+
* (Buffer / Uint8Array / ArrayBuffer) is used as-is.
|
|
41
|
+
*/
|
|
42
|
+
export declare const createQueryBase64Operator: (operator: string) => (field?: string) => PropertyDecorator;
|
|
43
|
+
export declare const QueryBase64Equal: (field?: string) => PropertyDecorator;
|
|
44
|
+
export declare const QueryBase64NotEqual: (field?: string) => PropertyDecorator;
|
|
35
45
|
export declare const QueryFullText: (options?: QueryFullTextColumnOptions) => PropertyDecorator;
|
|
36
46
|
export declare const QueryAnd: (...decs: PropertyDecorator[]) => PropertyDecorator;
|
|
37
47
|
export declare const QueryOr: (...decs: PropertyDecorator[]) => PropertyDecorator;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ValueTransformer } from 'typeorm';
|
|
2
|
+
export type BinaryLike = Buffer | Uint8Array | ArrayBuffer;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the value is a raw binary payload (Buffer / Uint8Array / ArrayBuffer).
|
|
5
|
+
* Such values are considered "already the binary" and are accepted as-is even
|
|
6
|
+
* though the TS-level type of a base64 binary column is a base64 `string`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isBinaryLike(value: unknown): value is BinaryLike;
|
|
9
|
+
export declare function binaryToBuffer(value: BinaryLike): Buffer;
|
|
10
|
+
/**
|
|
11
|
+
* Bridges a base64 `string` on the entity/API side with raw binary storage in
|
|
12
|
+
* the database.
|
|
13
|
+
*
|
|
14
|
+
* - `to` (entity -> DB): a base64 string is decoded into a `Buffer`. If the
|
|
15
|
+
* incoming value is already binary (Buffer / Uint8Array / ArrayBuffer) it is
|
|
16
|
+
* treated as the binary payload itself and stored directly.
|
|
17
|
+
* - `from` (DB -> entity): the stored binary is encoded back into a base64
|
|
18
|
+
* string.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Base64BinaryTransformer implements ValueTransformer {
|
|
21
|
+
to(entValue: string | BinaryLike | null | undefined): Buffer | null | undefined;
|
|
22
|
+
from(dbValue: BinaryLike | null | undefined): string | null | undefined;
|
|
23
|
+
}
|
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.4.1",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -69,13 +69,14 @@
|
|
|
69
69
|
"@nestjs/core": "^11.0.14",
|
|
70
70
|
"@nestjs/platform-express": "^11.0.14",
|
|
71
71
|
"@nestjs/testing": "^11.0.14",
|
|
72
|
-
"@nestjs/typeorm": "^11.0.
|
|
72
|
+
"@nestjs/typeorm": "^11.0.1",
|
|
73
73
|
"@types/jest": "^29.5.14",
|
|
74
74
|
"@types/lodash": "^4.17.20",
|
|
75
75
|
"@types/node": "^22.15.2",
|
|
76
76
|
"@types/supertest": "^2.0.12",
|
|
77
77
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
78
78
|
"@typescript-eslint/parser": "^4.33.0",
|
|
79
|
+
"class-validator": "^0.15.1",
|
|
79
80
|
"esbuild": "^0.25.12",
|
|
80
81
|
"esbuild-register": "^3.6.0",
|
|
81
82
|
"eslint": "^7.32.0",
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
"rxjs": "^7.8.2",
|
|
88
89
|
"supertest": "^6.2.4",
|
|
89
90
|
"ts-jest": "^29.3.2",
|
|
91
|
+
"typeorm": "^1.0.0",
|
|
90
92
|
"typescript": "^5.8.3"
|
|
91
93
|
},
|
|
92
94
|
"peerDependencies": {
|
|
@@ -95,9 +97,9 @@
|
|
|
95
97
|
"@nestjs/core": "^11.0.0 || ^9.4.0 || ^10.0.0",
|
|
96
98
|
"@nestjs/swagger": "^11.0.0 || ^7.1.8 || ^6.3.0",
|
|
97
99
|
"class-transformer": "^0.5.1",
|
|
98
|
-
"class-validator": "^0.14.0",
|
|
100
|
+
"class-validator": "^0.14.0 || ^0.15.0",
|
|
99
101
|
"rxjs": ">=7.0.0",
|
|
100
|
-
"typeorm": "^0.3.27"
|
|
102
|
+
"typeorm": "^0.3.27 || ^1.0.0"
|
|
101
103
|
},
|
|
102
104
|
"dependencies": {
|
|
103
105
|
"lodash": "^4.17.21",
|