nicot 1.4.0 → 1.4.2

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.
@@ -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;
@@ -1,5 +1,5 @@
1
- import { AnyClass, ClassType } from 'nesties';
2
- import { OperationObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
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 Partial<OperationObject> {
24
+ export interface ResourceOptions extends ApiOperationOptions {
25
25
  prefix?: string;
26
26
  }
27
27
  export declare class RestfulFactory<T extends {
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ import type { ApiPropertyOptions } from '@nestjs/swagger';
2
+ import type { AnyClass } from 'nesties';
3
+ export declare const getApiProperty: (cls: AnyClass, key: string) => ApiPropertyOptions;
@@ -1 +1,2 @@
1
1
  export * from './query';
2
+ export * from './base64-binary';
@@ -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.0",
4
+ "version": "1.4.2",
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.33",
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",