@decaf-ts/for-nest 0.7.0 → 0.9.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/lib/cjs/index.cjs +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/types/controllers.d.cts +2 -2
- package/lib/types/controllers.d.mts +2 -2
- package/lib/types/core-module.d.cts +1 -1
- package/lib/types/core-module.d.mts +1 -1
- package/lib/types/decaf-model/DecafModelModule.d.cts +1 -1
- package/lib/types/decaf-model/DecafModelModule.d.mts +1 -1
- package/lib/types/decaf-model/FromModelController.d.cts +2 -2
- package/lib/types/decaf-model/FromModelController.d.mts +2 -2
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.cts +1 -1
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.mts +1 -1
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.cts +1 -1
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.mts +1 -1
- package/lib/types/decaf-model/decorators/DecafParams.d.cts +1 -1
- package/lib/types/decaf-model/decorators/DecafParams.d.mts +1 -1
- package/lib/types/decaf-model/decorators/index.d.cts +7 -7
- package/lib/types/decaf-model/decorators/index.d.mts +7 -7
- package/lib/types/decaf-model/decorators/utils.d.cts +1 -1
- package/lib/types/decaf-model/decorators/utils.d.mts +1 -1
- package/lib/types/decaf-model/index.d.cts +3 -3
- package/lib/types/decaf-model/index.d.mts +3 -3
- package/lib/types/decaf-model/types.d.cts +1 -1
- package/lib/types/decaf-model/types.d.mts +1 -1
- package/lib/types/decaf-model/utils.d.cts +3 -3
- package/lib/types/decaf-model/utils.d.mts +3 -3
- package/lib/types/events-module/EventsController.d.cts +3 -3
- package/lib/types/events-module/EventsController.d.mts +3 -3
- package/lib/types/events-module/index.d.cts +2 -2
- package/lib/types/events-module/index.d.mts +2 -2
- package/lib/types/factory/NestBootstraper.d.cts +2 -2
- package/lib/types/factory/NestBootstraper.d.mts +2 -2
- package/lib/types/factory/errors/index.d.cts +1 -1
- package/lib/types/factory/errors/index.d.mts +1 -1
- package/lib/types/factory/exceptions/index.d.cts +2 -2
- package/lib/types/factory/exceptions/index.d.mts +2 -2
- package/lib/types/factory/index.d.cts +4 -4
- package/lib/types/factory/index.d.mts +4 -4
- package/lib/types/factory/openapi/SwaggerBuilder.d.cts +1 -1
- package/lib/types/factory/openapi/SwaggerBuilder.d.mts +1 -1
- package/lib/types/factory/openapi/index.d.cts +2 -2
- package/lib/types/factory/openapi/index.d.mts +2 -2
- package/lib/types/index.d.cts +14 -14
- package/lib/types/index.d.mts +14 -14
- package/lib/types/interceptors/AuthInterceptor.d.cts +1 -1
- package/lib/types/interceptors/AuthInterceptor.d.mts +1 -1
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.cts +2 -2
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.mts +2 -2
- package/lib/types/interceptors/context.d.cts +1 -1
- package/lib/types/interceptors/context.d.mts +1 -1
- package/lib/types/interceptors/index.d.cts +3 -3
- package/lib/types/interceptors/index.d.mts +3 -3
- package/lib/types/module.d.cts +1 -1
- package/lib/types/module.d.mts +1 -1
- package/lib/types/overrides/Adapter.d.cts +1 -1
- package/lib/types/overrides/Adapter.d.mts +1 -1
- package/lib/types/overrides/index.d.cts +5 -5
- package/lib/types/overrides/index.d.mts +5 -5
- package/lib/types/ram/RamRequestTransformer.d.cts +1 -1
- package/lib/types/ram/RamRequestTransformer.d.mts +1 -1
- package/lib/types/ram/index.d.cts +1 -1
- package/lib/types/ram/index.d.mts +1 -1
- package/lib/types/request/DecafAuthHandler.d.cts +1 -1
- package/lib/types/request/DecafAuthHandler.d.mts +1 -1
- package/lib/types/request/DecafHandlerExecutor.d.cts +2 -2
- package/lib/types/request/DecafHandlerExecutor.d.mts +2 -2
- package/lib/types/request/DecafRequestContext.d.cts +1 -1
- package/lib/types/request/DecafRequestContext.d.mts +1 -1
- package/lib/types/request/DecafResponseInterceptor.d.cts +1 -1
- package/lib/types/request/DecafResponseInterceptor.d.mts +1 -1
- package/lib/types/request/index.d.cts +4 -4
- package/lib/types/request/index.d.mts +4 -4
- package/lib/types/types.d.cts +2 -2
- package/lib/types/types.d.mts +2 -2
- package/package.json +1 -1
- package/lib/types/bin/cli.d.ts +0 -1
- package/lib/types/cli-module.d.ts +0 -11
- package/lib/types/constants.d.ts +0 -15
- package/lib/types/controllers.d.ts +0 -22
- package/lib/types/core-module.d.ts +0 -17
- package/lib/types/decaf-model/DecafModelModule.d.ts +0 -9
- package/lib/types/decaf-model/FromModelController.d.ts +0 -61
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.ts +0 -30
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.ts +0 -13
- package/lib/types/decaf-model/decorators/DecafBody.d.ts +0 -5
- package/lib/types/decaf-model/decorators/DecafParams.d.ts +0 -9
- package/lib/types/decaf-model/decorators/decorators.d.ts +0 -29
- package/lib/types/decaf-model/decorators/index.d.ts +0 -7
- package/lib/types/decaf-model/decorators/types.d.ts +0 -23
- package/lib/types/decaf-model/decorators/utils.d.ts +0 -11
- package/lib/types/decaf-model/index.d.ts +0 -3
- package/lib/types/decaf-model/types.d.ts +0 -7
- package/lib/types/decaf-model/utils.d.ts +0 -10
- package/lib/types/decoration.d.ts +0 -1
- package/lib/types/events-module/DecafStreamModule.d.ts +0 -4
- package/lib/types/events-module/EventsController.d.ts +0 -11
- package/lib/types/events-module/constant.d.ts +0 -1
- package/lib/types/events-module/index.d.ts +0 -2
- package/lib/types/events-module/utils.d.ts +0 -1
- package/lib/types/factory/NestBootstraper.d.ts +0 -224
- package/lib/types/factory/errors/cors.d.ts +0 -4
- package/lib/types/factory/errors/index.d.ts +0 -1
- package/lib/types/factory/errors/throttling.d.ts +0 -4
- package/lib/types/factory/exceptions/DecafErrorFilter.d.ts +0 -4
- package/lib/types/factory/exceptions/decorators.d.ts +0 -2
- package/lib/types/factory/exceptions/index.d.ts +0 -2
- package/lib/types/factory/index.d.ts +0 -4
- package/lib/types/factory/openapi/DtoBuilder.d.ts +0 -25
- package/lib/types/factory/openapi/SwaggerBuilder.d.ts +0 -10
- package/lib/types/factory/openapi/SwaggerCustomUI.d.ts +0 -22
- package/lib/types/factory/openapi/constants.d.ts +0 -27
- package/lib/types/factory/openapi/index.d.ts +0 -2
- package/lib/types/index.d.ts +0 -43
- package/lib/types/interceptors/AuthInterceptor.d.ts +0 -10
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.ts +0 -57
- package/lib/types/interceptors/context.d.ts +0 -6
- package/lib/types/interceptors/index.d.ts +0 -3
- package/lib/types/module.d.ts +0 -8
- package/lib/types/overrides/Adapter.d.ts +0 -13
- package/lib/types/overrides/ModelBuilderExtensions.d.ts +0 -8
- package/lib/types/overrides/constants.d.ts +0 -21
- package/lib/types/overrides/decoration.d.ts +0 -30
- package/lib/types/overrides/helpers.d.ts +0 -11
- package/lib/types/overrides/index.d.ts +0 -6
- package/lib/types/overrides/overrides.d.ts +0 -1
- package/lib/types/ram/RamRequestTransformer.d.ts +0 -5
- package/lib/types/ram/index.d.ts +0 -1
- package/lib/types/request/DecafAuthHandler.d.ts +0 -10
- package/lib/types/request/DecafHandlerExecutor.d.ts +0 -52
- package/lib/types/request/DecafRequestContext.d.ts +0 -11
- package/lib/types/request/DecafResponseInterceptor.d.ts +0 -8
- package/lib/types/request/index.d.ts +0 -4
- package/lib/types/types.d.ts +0 -88
- package/lib/types/utils.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestToContextTransformer } from "../interceptors/context.
|
|
1
|
+
import { RequestToContextTransformer } from "../interceptors/context.d.cts";
|
|
2
2
|
export declare class RamTransformer implements RequestToContextTransformer<any> {
|
|
3
3
|
constructor();
|
|
4
4
|
from(req: any, ..._args: any[]): Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestToContextTransformer } from "../interceptors/context.
|
|
1
|
+
import { RequestToContextTransformer } from "../interceptors/context.d.mts";
|
|
2
2
|
export declare class RamTransformer implements RequestToContextTransformer<any> {
|
|
3
3
|
constructor();
|
|
4
4
|
from(req: any, ..._args: any[]): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./RamRequestTransformer.
|
|
1
|
+
export * from "./RamRequestTransformer.d.cts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./RamRequestTransformer.
|
|
1
|
+
export * from "./RamRequestTransformer.d.mts";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from "@nestjs/common";
|
|
2
|
-
import { AuthHandler } from "../types.
|
|
2
|
+
import { AuthHandler } from "../types.d.cts";
|
|
3
3
|
export declare class DecafAuthHandler implements AuthHandler {
|
|
4
4
|
protected parseRequest(req: any): string;
|
|
5
5
|
authorize(ctx: ExecutionContext, resource: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from "@nestjs/common";
|
|
2
|
-
import { AuthHandler } from "../types.
|
|
2
|
+
import { AuthHandler } from "../types.d.mts";
|
|
3
3
|
export declare class DecafAuthHandler implements AuthHandler {
|
|
4
4
|
protected parseRequest(req: any): string;
|
|
5
5
|
authorize(ctx: ExecutionContext, resource: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DecafRequestContext } from "./DecafRequestContext.
|
|
2
|
-
import { type DecafRequestHandler } from "../types.
|
|
1
|
+
import { DecafRequestContext } from "./DecafRequestContext.d.cts";
|
|
2
|
+
import { type DecafRequestHandler } from "../types.d.cts";
|
|
3
3
|
/**
|
|
4
4
|
* @description
|
|
5
5
|
* Executes all registered {@link DecafRequestHandler} instances for the current request,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DecafRequestContext } from "./DecafRequestContext.
|
|
2
|
-
import { type DecafRequestHandler } from "../types.
|
|
1
|
+
import { DecafRequestContext } from "./DecafRequestContext.d.mts";
|
|
2
|
+
import { type DecafRequestHandler } from "../types.d.mts";
|
|
3
3
|
/**
|
|
4
4
|
* @description
|
|
5
5
|
* Executes all registered {@link DecafRequestHandler} instances for the current request,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NestInterceptor, ExecutionContext, CallHandler } from "@nestjs/common";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
-
import { DecafRequestContext } from "./DecafRequestContext.
|
|
3
|
+
import { DecafRequestContext } from "./DecafRequestContext.d.cts";
|
|
4
4
|
export declare class DecafResponseInterceptor implements NestInterceptor {
|
|
5
5
|
protected ctx: DecafRequestContext;
|
|
6
6
|
constructor(ctx: DecafRequestContext);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NestInterceptor, ExecutionContext, CallHandler } from "@nestjs/common";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
-
import { DecafRequestContext } from "./DecafRequestContext.
|
|
3
|
+
import { DecafRequestContext } from "./DecafRequestContext.d.mts";
|
|
4
4
|
export declare class DecafResponseInterceptor implements NestInterceptor {
|
|
5
5
|
protected ctx: DecafRequestContext;
|
|
6
6
|
constructor(ctx: DecafRequestContext);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./DecafAuthHandler.
|
|
2
|
-
export * from "./DecafRequestContext.
|
|
3
|
-
export * from "./DecafHandlerExecutor.
|
|
4
|
-
export * from "./DecafResponseInterceptor.
|
|
1
|
+
export * from "./DecafAuthHandler.d.cts";
|
|
2
|
+
export * from "./DecafRequestContext.d.cts";
|
|
3
|
+
export * from "./DecafHandlerExecutor.d.cts";
|
|
4
|
+
export * from "./DecafResponseInterceptor.d.cts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./DecafAuthHandler.
|
|
2
|
-
export * from "./DecafRequestContext.
|
|
3
|
-
export * from "./DecafHandlerExecutor.
|
|
4
|
-
export * from "./DecafResponseInterceptor.
|
|
1
|
+
export * from "./DecafAuthHandler.d.mts";
|
|
2
|
+
export * from "./DecafRequestContext.d.mts";
|
|
3
|
+
export * from "./DecafHandlerExecutor.d.mts";
|
|
4
|
+
export * from "./DecafResponseInterceptor.d.mts";
|
package/lib/types/types.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Adapter, ConfigOf, ContextOf } from "@decaf-ts/core";
|
|
2
2
|
import { Constructor } from "@decaf-ts/decoration";
|
|
3
3
|
import { ExecutionContext, Type } from "@nestjs/common";
|
|
4
|
-
import { RequestToContextTransformer } from "./interceptors/context.
|
|
5
|
-
import { DecafRequestContext } from "./request/index.
|
|
4
|
+
import { RequestToContextTransformer } from "./interceptors/context.d.cts";
|
|
5
|
+
import { DecafRequestContext } from "./request/index.d.cts";
|
|
6
6
|
export interface DecafRequestHandler<C extends DecafRequestContext = DecafRequestContext> {
|
|
7
7
|
handle(context: C, req: Request, res: Response): Promise<void>;
|
|
8
8
|
}
|
package/lib/types/types.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Adapter, ConfigOf, ContextOf } from "@decaf-ts/core";
|
|
2
2
|
import { Constructor } from "@decaf-ts/decoration";
|
|
3
3
|
import { ExecutionContext, Type } from "@nestjs/common";
|
|
4
|
-
import { RequestToContextTransformer } from "./interceptors/context.
|
|
5
|
-
import { DecafRequestContext } from "./request/index.
|
|
4
|
+
import { RequestToContextTransformer } from "./interceptors/context.d.mts";
|
|
5
|
+
import { DecafRequestContext } from "./request/index.d.mts";
|
|
6
6
|
export interface DecafRequestHandler<C extends DecafRequestContext = DecafRequestContext> {
|
|
7
7
|
handle(context: C, req: Request, res: Response): Promise<void>;
|
|
8
8
|
}
|
package/package.json
CHANGED
package/lib/types/bin/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
export declare function resolveInputPath(input?: string, exists?: (candidate: string) => boolean, candidates?: string[]): string;
|
|
3
|
-
export declare function buildOutputFilePath(params: {
|
|
4
|
-
outputDir: string;
|
|
5
|
-
pkgName?: string;
|
|
6
|
-
name?: string;
|
|
7
|
-
fileName?: string;
|
|
8
|
-
appendVersion?: boolean;
|
|
9
|
-
version?: string;
|
|
10
|
-
}): string;
|
|
11
|
-
export default function nest(): Command;
|
package/lib/types/constants.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AdapterFlags, Context } from "@decaf-ts/core";
|
|
2
|
-
import { Logger } from "@decaf-ts/logging";
|
|
3
|
-
export declare const DECAF_MODULE_OPTIONS = "DecafModuleOptions";
|
|
4
|
-
export declare const DECAF_ADAPTER_ID = "DecafAdapter";
|
|
5
|
-
export declare const DECAF_ROUTE = "DecafRoute";
|
|
6
|
-
export declare const DECAF_HANDLERS: unique symbol;
|
|
7
|
-
export declare const DECAF_ADAPTER_OPTIONS: unique symbol;
|
|
8
|
-
export declare const AUTH_HANDLER: unique symbol;
|
|
9
|
-
export declare const AUTH_META_KEY = "auth:meta";
|
|
10
|
-
export declare const DECAF_CONTEXT_KEY: unique symbol;
|
|
11
|
-
export type DecafServerFlags<LOG extends Logger = Logger> = AdapterFlags<LOG> & {
|
|
12
|
-
headers: Record<string, any>;
|
|
13
|
-
overrides: Record<string, any>;
|
|
14
|
-
};
|
|
15
|
-
export type DecafServerCtx = Context<DecafServerFlags>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Context, ContextOf, ContextualizedArgs, FlagsOf, MaybeContextualArg, MethodOrOperation, ModelService, Repo, Service } from "@decaf-ts/core";
|
|
2
|
-
import { type Request } from "express";
|
|
3
|
-
import { DecafServerCtx } from "./constants";
|
|
4
|
-
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { DecafRequestContext } from "./request/DecafRequestContext";
|
|
6
|
-
export declare abstract class DecafController<CONTEXT extends DecafServerCtx> extends Service<CONTEXT> {
|
|
7
|
-
protected readonly clientContext: DecafRequestContext;
|
|
8
|
-
protected constructor(clientContext: DecafRequestContext, name: string);
|
|
9
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD): ContextualizedArgs<CONTEXT, ARGS, METHOD extends string ? true : false>;
|
|
10
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: false, overrides?: Partial<FlagsOf<CONTEXT>>): ContextualizedArgs<CONTEXT, ARGS, METHOD extends string ? true : false>;
|
|
11
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: true, overrides?: Partial<FlagsOf<CONTEXT>>): Promise<ContextualizedArgs<CONTEXT, ARGS, METHOD extends string ? true : false>>;
|
|
12
|
-
protected bindLoggerToRequest<RESULT extends ContextualizedArgs<any, any>>(value: RESULT | Promise<RESULT>, request?: Request): RESULT | Promise<RESULT>;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class DecafModelController<M extends Model<boolean>, C extends DecafServerCtx = DecafServerCtx> extends DecafController<C> {
|
|
15
|
-
private _persistence?;
|
|
16
|
-
abstract get class(): ModelConstructor<M>;
|
|
17
|
-
persistence(ctx?: Context<any>): Repo<M> | ModelService<M>;
|
|
18
|
-
protected constructor(clientContext: DecafRequestContext, name: string);
|
|
19
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<any, ARGS>, operation: METHOD): ContextualizedArgs<ContextOf<ReturnType<this["persistence"]>>, ARGS, METHOD extends string ? true : false>;
|
|
20
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<ReturnType<this["persistence"]>>, ARGS>, operation: METHOD, allowCreate: false, overrides?: Partial<FlagsOf<ContextOf<ReturnType<this["persistence"]>>>>): ContextualizedArgs<ContextOf<ReturnType<this["persistence"]>>, ARGS, METHOD extends string ? true : false>;
|
|
21
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<ReturnType<this["persistence"]>>, ARGS>, operation: METHOD, allowCreate: true, overrides?: Partial<FlagsOf<ContextOf<ReturnType<this["persistence"]>>>>): Promise<ContextualizedArgs<ContextOf<ReturnType<this["persistence"]>>, ARGS, METHOD extends string ? true : false>>;
|
|
22
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, OnApplicationShutdown } from "@nestjs/common";
|
|
2
|
-
import { ModuleRef } from "@nestjs/core";
|
|
3
|
-
import type { DecafModuleOptions } from "./types";
|
|
4
|
-
import { Adapter, PersistenceService } from "@decaf-ts/core";
|
|
5
|
-
import { Logger } from "@decaf-ts/logging";
|
|
6
|
-
export declare class DecafCoreModule<CONF, ADAPTER extends Adapter<CONF, any, any, any>> implements OnApplicationShutdown {
|
|
7
|
-
private readonly options;
|
|
8
|
-
private readonly moduleRef;
|
|
9
|
-
private static _logger;
|
|
10
|
-
private static _persistence?;
|
|
11
|
-
protected static get persistence(): PersistenceService<any>;
|
|
12
|
-
protected static get log(): Logger;
|
|
13
|
-
constructor(options: DecafModuleOptions<CONF, ADAPTER>, moduleRef: ModuleRef);
|
|
14
|
-
static forRoot(options: DecafModuleOptions): DynamicModule;
|
|
15
|
-
static bootPersistence(options: DecafModuleOptions): Promise<Adapter<any, any, any, any>[]>;
|
|
16
|
-
onApplicationShutdown(): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, Provider } from "@nestjs/common";
|
|
2
|
-
import { DecafModuleOptions } from "../types";
|
|
3
|
-
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
4
|
-
export declare function getModuleFor(flavour: string): {
|
|
5
|
-
new (): {};
|
|
6
|
-
readonly log: import("@decaf-ts/logging").Logger;
|
|
7
|
-
createModelServices<T extends Model<boolean>>(models: ModelConstructor<T>[]): Provider[];
|
|
8
|
-
forRoot(flavour: string, options?: Partial<DecafModuleOptions>): DynamicModule;
|
|
9
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ModelService, type Repo } from "@decaf-ts/core";
|
|
2
|
-
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { type DecafModelRoute } from "./decorators";
|
|
4
|
-
import { ControllerConstructor } from "./types";
|
|
5
|
-
import "../overrides";
|
|
6
|
-
/**
|
|
7
|
-
* @description
|
|
8
|
-
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
9
|
-
*
|
|
10
|
-
* @summary
|
|
11
|
-
* The `FromModelController` class provides the infrastructure necessary to automatically generate
|
|
12
|
-
* strongly-typed CRUD controllers based on a given {@link ModelConstructor}. It inspects metadata from
|
|
13
|
-
* the model, derives route paths, parameters, and generates a dynamic controller class at runtime with
|
|
14
|
-
* full support for querying, creation, update, and deletion of model entities through a {@link Repo}.
|
|
15
|
-
*
|
|
16
|
-
* @template T The {@link Model} type associated with the generated controller.
|
|
17
|
-
*
|
|
18
|
-
* @param ModelClazz The model class to generate the controller from.
|
|
19
|
-
*
|
|
20
|
-
* @class FromModelController
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* // Given a Decaf Model:
|
|
25
|
-
* class User extends Model<User> {
|
|
26
|
-
* id!: string;
|
|
27
|
-
* name!: string;
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* // Register controller:
|
|
31
|
-
* const UserController = FromModelController.create(User);
|
|
32
|
-
*
|
|
33
|
-
* // NestJS will expose:
|
|
34
|
-
* // POST /user
|
|
35
|
-
* // GET /user/:id
|
|
36
|
-
* // GET /user/query/:method
|
|
37
|
-
* // PUT /user/:id
|
|
38
|
-
* // DELETE /user/:id
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @mermaid
|
|
42
|
-
* sequenceDiagram
|
|
43
|
-
* participant Client
|
|
44
|
-
* participant Controller
|
|
45
|
-
* participant Repo
|
|
46
|
-
* participant DB
|
|
47
|
-
*
|
|
48
|
-
* Client->>Controller: HTTP Request
|
|
49
|
-
* Controller->>Repo: Resolve repository for Model
|
|
50
|
-
* Repo->>DB: Execute DB operation
|
|
51
|
-
* DB-->>Repo: DB Result
|
|
52
|
-
* Repo-->>Controller: Model Instance(s)
|
|
53
|
-
* Controller-->>Client: JSON Response
|
|
54
|
-
*/
|
|
55
|
-
export declare class FromModelController {
|
|
56
|
-
private static readonly log;
|
|
57
|
-
static getPersistence<T extends Model<boolean>>(ModelClazz: ModelConstructor<T>): Repo<T> | ModelService<T>;
|
|
58
|
-
static createQueryRoutesFromRepository<T extends Model<boolean>>(persistence: Repo<T> | ModelService<T>, prefix?: string): ControllerConstructor<T>;
|
|
59
|
-
static create<T extends Model<any>>(ModelConstr: ModelConstructor<T>): any;
|
|
60
|
-
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>): DecafModelRoute;
|
|
61
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { CrudOperations } from "@decaf-ts/db-decorators";
|
|
2
|
-
import { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { HttpVerbs } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* @description Determines if a given CRUD operation is blocked for a specific model constructor.
|
|
6
|
-
* @summary Retrieves the operation-blocking handler metadata stored on the provided model constructor (under `OperationKeys.REFLECT + OperationKeys.BLOCK`), executes it (if present) with its persisted arguments plus the requested operation, and returns whether the operation is blocked. If no handler exists, the operation is considered allowed (returns `false`).
|
|
7
|
-
* @param {ModelConstructor<any>} ModelConstructor - The target model constructor whose metadata may include a blocking handler.
|
|
8
|
-
* @param {CrudOperations} op - The CRUD operation to evaluate (e.g., `OperationKeys.CREATE`, `OperationKeys.READ`, `OperationKeys.UPDATE`, `OperationKeys.DELETE`).
|
|
9
|
-
* @return {boolean} `true` when the operation is explicitly blocked by the model's handler; otherwise `false`.
|
|
10
|
-
* @function isOperationBlocked
|
|
11
|
-
*/
|
|
12
|
-
export declare function isOperationBlocked(ModelConstructor: ModelConstructor<any>, op: CrudOperations): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* @description Conditionally applies an HTTP method decorator for a given model and verb, hiding the endpoint in Swagger (and not registering the route) when the model blocks that CRUD operation.
|
|
15
|
-
* @summary Maps an HTTP verb to its corresponding `CrudOperations` key and Nest HTTP decorator (`@Get`, `@Post`, etc.). It checks `isOperationBlocked(ModelConstructor, crudOp)` and, if blocked, applies only `@ApiExcludeEndpoint()` (Swagger-hidden, no Nest route). If permitted, it applies the appropriate HTTP decorator with the optional `path`.
|
|
16
|
-
* @param {ModelConstructor<any>} ModelConstructor - The model constructor used to resolve operation-blocking rules.
|
|
17
|
-
* @param {HttpVerbs} verb - The HTTP verb to map (e.g., `"GET" | "POST" | "PUT" | "PATCH" | "DELETE"`).
|
|
18
|
-
* @param {string} [path] - Optional route path passed through to the corresponding Nest HTTP method decorator.
|
|
19
|
-
* @return {MethodDecorator} A method decorator that either excludes the endpoint from Swagger (and route registration) or applies the correct HTTP decorator.
|
|
20
|
-
*/
|
|
21
|
-
export declare function ApiOperationFromModel(ModelConstructor: ModelConstructor<any>, verb: HttpVerbs, path?: string): MethodDecorator;
|
|
22
|
-
/**
|
|
23
|
-
* @description Conditionally applies an HTTP method decorator for a given model and verb, hiding the endpoint in Swagger (and not registering the route) when the model blocks that CRUD operation.
|
|
24
|
-
* @summary Maps an HTTP verb to its corresponding `CrudOperations` key and Nest HTTP decorator (`@Get`, `@Post`, etc.). It checks `isOperationBlocked(ModelConstructor, crudOp)` and, if blocked, applies only `@ApiExcludeEndpoint()` (Swagger-hidden, no Nest route). If permitted, it applies the appropriate HTTP decorator with the optional `path`.
|
|
25
|
-
* @param {ModelConstructor<any>} ModelConstructor - The model constructor used to resolve operation-blocking rules.
|
|
26
|
-
* @param {HttpVerbs} verb - The HTTP verb to map (e.g., `"GET" | "POST" | "PUT" | "PATCH" | "DELETE"`).
|
|
27
|
-
* @param {string} [path] - Optional route path passed through to the corresponding Nest HTTP method decorator.
|
|
28
|
-
* @return {MethodDecorator} A method decorator that either excludes the endpoint from Swagger (and route registration) or applies the correct HTTP decorator.
|
|
29
|
-
*/
|
|
30
|
-
export declare function BulkApiOperationFromModel(ModelConstructor: ModelConstructor<any>, verb: HttpVerbs, path?: string): MethodDecorator;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DecafApiProperty } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* @description Applies a set of Swagger `@ApiParam` decorators generated from a typed specification array.
|
|
4
|
-
* @summary Transforms each entry of the provided `ApiParam[]` into a corresponding `@ApiParam()` decorator (defaulting `description`, `required`, and `type` when omitted) and composes them into a single decorator via Nest's `applyDecorators`. Useful for synchronizing runtime route params with OpenAPI documentation in a concise, declarative way.
|
|
5
|
-
* @param {ApiParam[]} [props=[]] Array describing path parameters to be documented.
|
|
6
|
-
* @param {string} props[].name The parameter's name as it appears in the route template (e.g., `:id`).
|
|
7
|
-
* @param {string} [props[].description] Human-readable explanation of the parameter; defaults to `"Path parameter: <name>"`.
|
|
8
|
-
* @param {boolean} [props[].required=true] Whether the parameter is required; defaults to `true`.
|
|
9
|
-
* @param {Constructor<any>} [props[].type=String] Constructor/type used by Swagger to infer schema (e.g., `String`, `Number`, `UUID`, custom class).
|
|
10
|
-
* @return {any} A composed decorator applying all generated `@ApiParam` decorators to the target method or controller.
|
|
11
|
-
* @function ApiParamsFromModel
|
|
12
|
-
*/
|
|
13
|
-
export declare function ApiParamsFromModel(props?: DecafApiProperty[]): MethodDecorator & ClassDecorator;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Custom decorator that extracts the request body and instantiates it using the Model constructor
|
|
3
|
-
* found on the controller. Handles both single objects and arrays.
|
|
4
|
-
*/
|
|
5
|
-
export declare const DecafBody: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DecafApiProperty } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* @description A higher-level decorator factory that leverages `OrderedParams` to extract route parameters in a specific order derived from a list of `ApiParam` definitions.
|
|
4
|
-
* @summary `DecafParams` computes the order of route parameters based on the provided `ApiParam[]` specification (using each element’s `name`), then applies `OrderedParams(order)` as a parameter decorator. This enables parameter-level binding that remains consistent with the documented API parameter metadata.
|
|
5
|
-
* @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
|
|
6
|
-
* @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
|
|
7
|
-
*/
|
|
8
|
-
export declare function DecafParams(props?: DecafApiProperty[]): ParameterDecorator;
|
|
9
|
-
export declare const DecafQuery: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
-
/**
|
|
3
|
-
* A decorator function that applies authentication and authorization metadata to a NestJS controller or method.
|
|
4
|
-
*
|
|
5
|
-
* @param model - The model name or constructor function for the resource being accessed.
|
|
6
|
-
* If a string is provided, it is used as the resource name.
|
|
7
|
-
* If a constructor function is provided, its name is used as the resource name.
|
|
8
|
-
*
|
|
9
|
-
* @returns - A function that applies the authentication and authorization decorators to the target.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Controller('users')
|
|
14
|
-
* @Auth('User')
|
|
15
|
-
* export class UsersController {
|
|
16
|
-
* // ...
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* @Controller('users')
|
|
23
|
-
* @Auth(User)
|
|
24
|
-
* export class UsersController {
|
|
25
|
-
* // ...
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare function Auth(model?: string | Constructor): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type HttpVerbs = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
-
export type DecafApiProperty = {
|
|
3
|
-
name: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
required?: boolean;
|
|
6
|
-
type?: any;
|
|
7
|
-
};
|
|
8
|
-
export type DecafModelRoute = {
|
|
9
|
-
path: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
apiProperties: DecafApiProperty[];
|
|
12
|
-
getPK: (...args: Array<string | number>) => string;
|
|
13
|
-
};
|
|
14
|
-
export type DecafParamProps = {
|
|
15
|
-
raw: Record<string, string | number>;
|
|
16
|
-
keysInOrder: Array<string>;
|
|
17
|
-
valuesInOrder: Array<string | number>;
|
|
18
|
-
};
|
|
19
|
-
export interface DecafRouteDecOptions {
|
|
20
|
-
path: string;
|
|
21
|
-
httpMethod: HttpVerbs;
|
|
22
|
-
handler: PropertyDescriptor;
|
|
23
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HttpVerbs } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Maps an HTTP verb to its corresponding NestJS method decorator.
|
|
4
|
-
*
|
|
5
|
-
* @param verb - HTTP verb to be converted (e.g. GET, POST, PUT, PATCH, DELETE).
|
|
6
|
-
* @returns A NestJS method decorator matching the provided HTTP verb.
|
|
7
|
-
*
|
|
8
|
-
* @throws {Error} If the provided HTTP verb is not supported or not mapped
|
|
9
|
-
* to a NestJS decorator.
|
|
10
|
-
*/
|
|
11
|
-
export declare function HttpVerbToDecorator(verb: HttpVerbs): (path?: string) => MethodDecorator;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DecafModelController } from "../controllers";
|
|
2
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
-
export type ControllerConstructor<T extends Model<boolean>> = new (...args: any[]) => DecafModelController<T>;
|
|
4
|
-
export type DecoratorBundle = {
|
|
5
|
-
method: MethodDecorator[];
|
|
6
|
-
params?: ParameterDecorator[];
|
|
7
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type DecoratorBundle } from "./types";
|
|
2
|
-
import { type DecafParamProps, HttpVerbs } from "./decorators";
|
|
3
|
-
import { DirectionLimitOffset, ModelService, Repo } from "@decaf-ts/core";
|
|
4
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { DecafModelController } from "../controllers";
|
|
6
|
-
export declare function getApiDecorators(methodName: string, routePath: string, httpVerb: HttpVerbs, includeQueryParams?: boolean): DecoratorBundle;
|
|
7
|
-
export declare function applyApiDecorators(target: any, methodName: string, descriptor: PropertyDescriptor, decorators: DecoratorBundle): void;
|
|
8
|
-
export declare function resolvePersistenceMethod<T extends Model<boolean>>(persistence: Repo<T> | ModelService<T>, methodName: string, ...args: any[]): any;
|
|
9
|
-
export declare function createRouteHandler<T>(methodName: string): (this: DecafModelController<any>, pathParams: DecafParamProps, queryParams: DirectionLimitOffset) => Promise<T>;
|
|
10
|
-
export declare function defineRouteMethod(ControllerClass: new (...args: any[]) => any, methodName: string, handler: (...args: any[]) => any): PropertyDescriptor | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DecafController } from "../controllers";
|
|
2
|
-
import { DecafRequestContext } from "../request";
|
|
3
|
-
import { MessageEvent } from "@nestjs/common";
|
|
4
|
-
import { Observable } from "rxjs";
|
|
5
|
-
import { DecafServerCtx } from "../constants";
|
|
6
|
-
export declare class EventsController extends DecafController<DecafServerCtx> {
|
|
7
|
-
private readonly adapters;
|
|
8
|
-
constructor(clientContext: DecafRequestContext, flavours: string[]);
|
|
9
|
-
listen(): Observable<MessageEvent>;
|
|
10
|
-
listenForModel(model: string): Observable<MessageEvent>;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const LISTENING_ADAPTERS_FLAVOURS: unique symbol;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function normalizeEventResponse(args: any[]): unknown[];
|