@mee4dy/crud-nestjs 1.0.12 → 1.0.13
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/dist/decorators/crud-ctx.decorator.d.ts +1 -0
- package/dist/decorators/crud-ctx.decorator.js +11 -0
- package/dist/decorators/crud-ctx.decorator.js.map +1 -0
- package/dist/decorators/crud-params.decorator.js +3 -1
- package/dist/decorators/crud-params.decorator.js.map +1 -1
- package/dist/decorators/use-crud-ctx.decorator.d.ts +1 -0
- package/dist/decorators/use-crud-ctx.decorator.js +20 -0
- package/dist/decorators/use-crud-ctx.decorator.js.map +1 -0
- package/dist/decorators/use-crud-scope.decorator.d.ts +1 -0
- package/dist/decorators/use-crud-scope.decorator.js +20 -0
- package/dist/decorators/use-crud-scope.decorator.js.map +1 -0
- package/dist/decorators/use-middleware.decorator.d.ts +1 -0
- package/dist/decorators/use-middleware.decorator.js +23 -0
- package/dist/decorators/use-middleware.decorator.js.map +1 -0
- package/dist/interfaces/crud-ctx.interface.d.ts +3 -0
- package/dist/interfaces/crud-ctx.interface.js +3 -0
- package/dist/interfaces/crud-ctx.interface.js.map +1 -0
- package/dist/interfaces/find-params.interface.d.ts +13 -0
- package/dist/interfaces/find-params.interface.js +3 -0
- package/dist/interfaces/find-params.interface.js.map +1 -0
- package/dist/pipes/query.parse.pipe.d.ts +4 -0
- package/dist/pipes/query.parse.pipe.js +27 -0
- package/dist/pipes/query.parse.pipe.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CrudCtx: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudCtx = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.CrudCtx = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const request = ctx.switchToHttp().getRequest();
|
|
7
|
+
return Object.assign({
|
|
8
|
+
params: {},
|
|
9
|
+
}, request.crudCtx);
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=crud-ctx.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud-ctx.decorator.js","sourceRoot":"","sources":["../../src/decorators/crud-ctx.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAG3D,QAAA,OAAO,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAa,EAAE,GAAqB,EAAe,EAAE;IAChG,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAEhD,OAAO,MAAM,CAAC,MAAM,CAClB;QACE,MAAM,EAAE,EAAE;KACX,EACD,OAAO,CAAC,OAAO,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -28,7 +28,9 @@ exports.CrudParamsDecorator = (0, common_1.createParamDecorator)((data, ctx) =>
|
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
const query = qs_1.default.parse(request.query
|
|
31
|
+
const query = qs_1.default.parse(request.query, {
|
|
32
|
+
arrayFormat: 'indices',
|
|
33
|
+
});
|
|
32
34
|
const queryAllowedParams = ((_c = config === null || config === void 0 ? void 0 : config.query) === null || _c === void 0 ? void 0 : _c.allowedParams) || {};
|
|
33
35
|
const extractor = new query_params_extractor_service_1.QueryParamsExtractorService((0, replace_pk_util_1.replacePkRecursive)(query, pk), (0, replace_pk_util_1.replacePkRecursive)(queryAllowedParams, pk));
|
|
34
36
|
const queryParams = extractor.extract();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud-params.decorator.js","sourceRoot":"","sources":["../../src/decorators/crud-params.decorator.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAwE;AAExE,+FAAyF;AACzF,oDAA4C;AAC5C,4CAAoB;AACpB,4BAA0B;AAC1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AC;QAClB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACtC,YAAY,GAAG,IAAA,kBAAK,EAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,IAAI,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACtC,YAAY,GAAG,IAAA,kBAAK,EAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,IAAA,kBAAK,EACV;QACE,GAAG,IAAA,oCAAkB,EAAC,aAAa,EAAE,EAAE,CAAC;QACxC,GAAG,IAAA,kBAAK,EAAC,IAAA,oCAAkB,EAAC,MAAM,EAAE,EAAE,CAAC,EAAE,IAAA,oCAAkB,EAAC,YAAY,EAAE,EAAE,CAAC,CAAC;KAC/E,EACD,IAAA,oCAAkB,EAAC,WAAW,EAAE,EAAE,CAAC,CACpC,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UseCrudCtx: (callback: any) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseCrudCtx = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const use_middleware_decorator_1 = require("./use-middleware.decorator");
|
|
6
|
+
const UseCrudCtx = (callback) => {
|
|
7
|
+
const middlewareDecorator = (0, use_middleware_decorator_1.UseMiddleware)((req) => {
|
|
8
|
+
const crudCtx = callback(req);
|
|
9
|
+
if (!req.crudCtx) {
|
|
10
|
+
req.crudCtx = {};
|
|
11
|
+
}
|
|
12
|
+
req.crudCtx = {
|
|
13
|
+
...req.crudCtx,
|
|
14
|
+
...crudCtx,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return (0, common_1.applyDecorators)(middlewareDecorator);
|
|
18
|
+
};
|
|
19
|
+
exports.UseCrudCtx = UseCrudCtx;
|
|
20
|
+
//# sourceMappingURL=use-crud-ctx.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crud-ctx.decorator.js","sourceRoot":"","sources":["../../src/decorators/use-crud-ctx.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,yEAA2D;AAEpD,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,EAAE;IACrC,MAAM,mBAAmB,GAAG,IAAA,wCAAa,EAAC,CAAC,GAAG,EAAE,EAAE;QAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE9B,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjB,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,GAAG,CAAC,OAAO,GAAG;YACZ,GAAG,GAAG,CAAC,OAAO;YACd,GAAG,OAAO;SACX,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,wBAAe,EAAC,mBAAmB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAfW,QAAA,UAAU,cAerB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UseCrudScope: (callback: any) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseCrudScope = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const use_middleware_decorator_1 = require("./use-middleware.decorator");
|
|
6
|
+
const UseCrudScope = (callback) => {
|
|
7
|
+
const middlewareDecorator = (0, use_middleware_decorator_1.UseMiddleware)((req) => {
|
|
8
|
+
const crudScope = callback(req);
|
|
9
|
+
if (!req.crudCtx) {
|
|
10
|
+
req.crudCtx = {};
|
|
11
|
+
}
|
|
12
|
+
req.crudCtx.params = {
|
|
13
|
+
...req.crudCtx.params,
|
|
14
|
+
...crudScope,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return (0, common_1.applyDecorators)(middlewareDecorator);
|
|
18
|
+
};
|
|
19
|
+
exports.UseCrudScope = UseCrudScope;
|
|
20
|
+
//# sourceMappingURL=use-crud-scope.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crud-scope.decorator.js","sourceRoot":"","sources":["../../src/decorators/use-crud-scope.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,yEAA2D;AAEpD,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,EAAE;IACvC,MAAM,mBAAmB,GAAG,IAAA,wCAAa,EAAC,CAAC,GAAG,EAAE,EAAE;QAChD,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEhC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjB,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG;YACnB,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM;YACrB,GAAG,SAAS;SACb,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,wBAAe,EAAC,mBAAmB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UseMiddleware: (middleware: any) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseMiddleware = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class CrudInterceptor {
|
|
6
|
+
constructor(middleware) {
|
|
7
|
+
this.middleware = middleware;
|
|
8
|
+
}
|
|
9
|
+
intercept(context, next) {
|
|
10
|
+
const req = context.switchToHttp().getRequest();
|
|
11
|
+
if (this.middleware) {
|
|
12
|
+
this.middleware(req);
|
|
13
|
+
}
|
|
14
|
+
return next.handle();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const UseMiddleware = (middleware) => {
|
|
18
|
+
const crudInterceptor = new CrudInterceptor(middleware);
|
|
19
|
+
const interceptorDecorator = (0, common_1.UseInterceptors)(crudInterceptor);
|
|
20
|
+
return (0, common_1.applyDecorators)(interceptorDecorator);
|
|
21
|
+
};
|
|
22
|
+
exports.UseMiddleware = UseMiddleware;
|
|
23
|
+
//# sourceMappingURL=use-middleware.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-middleware.decorator.js","sourceRoot":"","sources":["../../src/decorators/use-middleware.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAkH;AAGlH,MAAM,eAAe;IACnB,YAAY,UAAU;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAID,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAEhD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF;AAEM,MAAM,aAAa,GAAG,CAAC,UAAe,EAAE,EAAE;IAC/C,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,oBAAoB,GAAG,IAAA,wBAAe,EAAC,eAAe,CAAC,CAAC;IAE9D,OAAO,IAAA,wBAAe,EAAC,oBAAoB,CAAC,CAAC;AAC/C,CAAC,CAAC;AALW,QAAA,aAAa,iBAKxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud-ctx.interface.js","sourceRoot":"","sources":["../../src/interfaces/crud-ctx.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-params.interface.js","sourceRoot":"","sources":["../../src/interfaces/find-params.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.QueryParsePipe = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const qs_1 = __importDefault(require("qs"));
|
|
15
|
+
let QueryParsePipe = class QueryParsePipe {
|
|
16
|
+
transform(value, metadata) {
|
|
17
|
+
if (metadata.type === 'query') {
|
|
18
|
+
return qs_1.default.parse(value);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.QueryParsePipe = QueryParsePipe;
|
|
24
|
+
exports.QueryParsePipe = QueryParsePipe = __decorate([
|
|
25
|
+
(0, common_1.Injectable)()
|
|
26
|
+
], QueryParsePipe);
|
|
27
|
+
//# sourceMappingURL=query.parse.pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.parse.pipe.js","sourceRoot":"","sources":["../../src/pipes/query.parse.pipe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2D;AAC3D,4CAAoB;AAGb,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,SAAS,CAAC,KAAU,EAAE,QAAQ;QAC5B,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC9B,OAAO,YAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AARY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAQ1B"}
|