nicot 1.4.1 → 1.4.3
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 +4 -3
- package/README.md +5 -4
- package/dist/index.cjs +151 -68
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +102 -22
- package/dist/index.mjs.map +4 -4
- package/dist/src/decorators/property.d.ts +2 -0
- package/dist/src/decorators/query.d.ts +12 -7
- package/dist/src/restful.d.ts +3 -3
- package/dist/src/utility/base64-binary.d.ts +11 -5
- package/dist/src/utility/get-api-property.d.ts +3 -0
- package/dist/src/utility/patch-column-in-get.d.ts +1 -1
- package/dist/src/utility/swagger-decorators.d.ts +23 -0
- package/package.json +3 -2
|
@@ -7,6 +7,7 @@ import { SimpleColumnType, UnsignedColumnType, WithLengthColumnType, WithPrecisi
|
|
|
7
7
|
import { ColumnNumericOptions } from 'typeorm/decorator/options/ColumnNumericOptions';
|
|
8
8
|
import { ClassOrArray, ParseType } from 'nesties';
|
|
9
9
|
import { ColumnUnsignedOptions } from 'typeorm/decorator/options/ColumnUnsignedOptions';
|
|
10
|
+
import { Base64BinaryStorage } from '../utility/base64-binary';
|
|
10
11
|
export interface OpenAPIOptions<T> {
|
|
11
12
|
description?: string;
|
|
12
13
|
propertyExtras?: ApiPropertyOptions;
|
|
@@ -61,6 +62,7 @@ export declare const StringJsonColumn: <C extends ClassOrArray>(definition: C, o
|
|
|
61
62
|
export declare const IsBase64OrBinary: (validationOptions?: ValidationOptions) => PropertyDecorator;
|
|
62
63
|
export declare const Base64BinaryColumn: (options?: PropertyOptions<string> & {
|
|
63
64
|
columnType?: SimpleColumnType | WithLengthColumnType;
|
|
65
|
+
binaryStorage?: Base64BinaryStorage;
|
|
64
66
|
}) => PropertyDecorator;
|
|
65
67
|
export declare const NotColumn: (options?: OpenAPIOptions<any>, specials?: {
|
|
66
68
|
keepInCreate?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { QueryCond } from '../bases';
|
|
2
2
|
import { QueryFullTextColumnOptions } from '../utility/query-full-text-column-options.interface';
|
|
3
|
+
import { Base64BinaryStorage } from '../utility/base64-binary';
|
|
3
4
|
export declare const QueryCondition: (cond: QueryCond) => PropertyDecorator;
|
|
4
5
|
export declare const QueryManual: () => PropertyDecorator;
|
|
5
6
|
export declare class QueryWrapInfo<T = unknown> {
|
|
@@ -32,16 +33,20 @@ export declare const createQueryArrayify: (newWrapper: QueryWrapper, singleFallb
|
|
|
32
33
|
export declare const createQueryOperatorArrayify: (operator: string, singleFallback?: string | QueryWrapper) => (field?: string) => PropertyDecorator;
|
|
33
34
|
export declare const QueryIn: (field?: string) => PropertyDecorator;
|
|
34
35
|
export declare const QueryNotIn: (field?: string) => PropertyDecorator;
|
|
36
|
+
export interface QueryBase64Options {
|
|
37
|
+
field?: string;
|
|
38
|
+
binaryStorage?: Base64BinaryStorage;
|
|
39
|
+
}
|
|
35
40
|
/**
|
|
36
41
|
* Builds a query condition for a `Base64BinaryColumn`. The incoming base64
|
|
37
|
-
* string (the API-facing form) is decoded into a
|
|
38
|
-
*
|
|
39
|
-
* stored in the database. A value that is already binary
|
|
40
|
-
*
|
|
42
|
+
* string (the API-facing form) is decoded into a PostgreSQL-safe bytea hex
|
|
43
|
+
* parameter right before it is bound, so it can be compared against the raw
|
|
44
|
+
* binary stored in the database. A value that is already binary (Buffer /
|
|
45
|
+
* Uint8Array / ArrayBuffer) is used as that binary payload.
|
|
41
46
|
*/
|
|
42
|
-
export declare const createQueryBase64Operator: (operator: string) => (
|
|
43
|
-
export declare const QueryBase64Equal: (
|
|
44
|
-
export declare const QueryBase64NotEqual: (
|
|
47
|
+
export declare const createQueryBase64Operator: (operator: string) => (fieldOrOptions?: string | QueryBase64Options) => PropertyDecorator;
|
|
48
|
+
export declare const QueryBase64Equal: (fieldOrOptions?: string | QueryBase64Options) => PropertyDecorator;
|
|
49
|
+
export declare const QueryBase64NotEqual: (fieldOrOptions?: string | QueryBase64Options) => PropertyDecorator;
|
|
45
50
|
export declare const QueryFullText: (options?: QueryFullTextColumnOptions) => PropertyDecorator;
|
|
46
51
|
export declare const QueryAnd: (...decs: PropertyDecorator[]) => PropertyDecorator;
|
|
47
52
|
export declare const QueryOr: (...decs: PropertyDecorator[]) => PropertyDecorator;
|
package/dist/src/restful.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyClass, ClassType } from 'nesties';
|
|
2
|
-
import {
|
|
1
|
+
import type { AnyClass, ClassType } from 'nesties';
|
|
2
|
+
import { ApiOperationOptions } from '@nestjs/swagger';
|
|
3
3
|
import { CrudBase, CrudOptions } from './crud-base';
|
|
4
4
|
import { PageSettingsDto } from './bases';
|
|
5
5
|
import { CursorPaginationDto } from './dto';
|
|
@@ -21,7 +21,7 @@ export interface RestfulFactoryOptions<T, O extends keyof T = never, W extends k
|
|
|
21
21
|
skipNonQueryableFields?: boolean;
|
|
22
22
|
upsertIncludeRelations?: boolean;
|
|
23
23
|
}
|
|
24
|
-
export interface ResourceOptions extends
|
|
24
|
+
export interface ResourceOptions extends ApiOperationOptions {
|
|
25
25
|
prefix?: string;
|
|
26
26
|
}
|
|
27
27
|
export declare class RestfulFactory<T extends {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ValueTransformer } from 'typeorm';
|
|
2
2
|
export type BinaryLike = Buffer | Uint8Array | ArrayBuffer;
|
|
3
|
+
export type Base64BinaryStorage = 'postgres-bytea' | 'binary';
|
|
3
4
|
/**
|
|
4
5
|
* Whether the value is a raw binary payload (Buffer / Uint8Array / ArrayBuffer).
|
|
5
6
|
* Such values are considered "already the binary" and are accepted as-is even
|
|
@@ -7,17 +8,22 @@ export type BinaryLike = Buffer | Uint8Array | ArrayBuffer;
|
|
|
7
8
|
*/
|
|
8
9
|
export declare function isBinaryLike(value: unknown): value is BinaryLike;
|
|
9
10
|
export declare function binaryToBuffer(value: BinaryLike): Buffer;
|
|
11
|
+
export declare function binaryToPostgresByteaHex(value: BinaryLike): string;
|
|
12
|
+
export declare function base64OrBinaryToBuffer(value: string | BinaryLike): Buffer;
|
|
13
|
+
export declare function base64OrBinaryToDatabaseValue(value: string | BinaryLike, storage?: Base64BinaryStorage): Buffer | string;
|
|
10
14
|
/**
|
|
11
15
|
* Bridges a base64 `string` on the entity/API side with raw binary storage in
|
|
12
16
|
* the database.
|
|
13
17
|
*
|
|
14
|
-
* - `to` (entity -> DB): a base64 string is decoded into a
|
|
15
|
-
* incoming value is already binary (Buffer / Uint8Array /
|
|
16
|
-
* treated as the binary payload itself and stored directly.
|
|
18
|
+
* - `to` (entity -> DB): a base64 string is decoded into a database-safe bytea
|
|
19
|
+
* value. If the incoming value is already binary (Buffer / Uint8Array /
|
|
20
|
+
* ArrayBuffer) it is treated as the binary payload itself and stored directly.
|
|
17
21
|
* - `from` (DB -> entity): the stored binary is encoded back into a base64
|
|
18
22
|
* string.
|
|
19
23
|
*/
|
|
20
24
|
export declare class Base64BinaryTransformer implements ValueTransformer {
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
private readonly storage;
|
|
26
|
+
constructor(storage?: Base64BinaryStorage);
|
|
27
|
+
to(entValue: string | BinaryLike | null | undefined): Buffer | string | null | undefined;
|
|
28
|
+
from(dbValue: BinaryLike | string | null | undefined): string | null | undefined;
|
|
23
29
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AnyClass } from 'nesties';
|
|
1
|
+
import type { AnyClass } from 'nesties';
|
|
2
2
|
export declare const PatchColumnsInGet: <C extends AnyClass>(cl: C, originalCl?: AnyClass, fieldsToOmit?: string[]) => C;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SwaggerDecorators {
|
|
2
|
+
API_OPERATION: string;
|
|
3
|
+
API_RESPONSE: string;
|
|
4
|
+
API_PRODUCES: string;
|
|
5
|
+
API_CONSUMES: string;
|
|
6
|
+
API_TAGS: string;
|
|
7
|
+
API_WEBHOOK: string;
|
|
8
|
+
API_CALLBACKS: string;
|
|
9
|
+
API_PARAMETERS: string;
|
|
10
|
+
API_HEADERS: string;
|
|
11
|
+
API_MODEL_PROPERTIES: string;
|
|
12
|
+
API_MODEL_PROPERTIES_ARRAY: string;
|
|
13
|
+
API_SECURITY: string;
|
|
14
|
+
API_EXCLUDE_ENDPOINT: string;
|
|
15
|
+
API_INCLUDE_ENDPOINT: string;
|
|
16
|
+
API_EXCLUDE_CONTROLLER: string;
|
|
17
|
+
API_EXTRA_MODELS: string;
|
|
18
|
+
API_EXTENSION: string;
|
|
19
|
+
API_SCHEMA: string;
|
|
20
|
+
API_DEFAULT_GETTER: string;
|
|
21
|
+
API_LINK: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const DECORATORS: SwaggerDecorators;
|
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.
|
|
4
|
+
"version": "1.4.3",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nestjs/core": "^11.0.14",
|
|
70
70
|
"@nestjs/platform-express": "^11.0.14",
|
|
71
|
+
"@nestjs/swagger": "^11.4.4",
|
|
71
72
|
"@nestjs/testing": "^11.0.14",
|
|
72
73
|
"@nestjs/typeorm": "^11.0.1",
|
|
73
74
|
"@types/jest": "^29.5.14",
|
|
@@ -103,7 +104,7 @@
|
|
|
103
104
|
},
|
|
104
105
|
"dependencies": {
|
|
105
106
|
"lodash": "^4.17.21",
|
|
106
|
-
"nesties": "^1.1.
|
|
107
|
+
"nesties": "^1.1.34",
|
|
107
108
|
"nfkit": "^1.0.13",
|
|
108
109
|
"p-queue": "6.6.2",
|
|
109
110
|
"reflect-metadata": "^0.2.2",
|