@decaf-ts/core 0.7.6 → 0.7.8
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.md +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/interfaces/Paginatable.d.ts +1 -1
- package/lib/esm/overrides/injectables.d.ts +1 -1
- package/lib/esm/persistence/constants.d.ts +3 -1
- package/lib/esm/persistence/constants.js +2 -0
- package/lib/esm/persistence/constants.js.map +1 -1
- package/lib/esm/query/decorators.d.ts +2 -1
- package/lib/esm/query/decorators.js +70 -38
- package/lib/esm/query/decorators.js.map +1 -1
- package/lib/esm/repository/Repository.d.ts +11 -4
- package/lib/esm/repository/Repository.js +65 -0
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/utils/Services.d.ts +8 -2
- package/lib/esm/utils/Services.js +118 -0
- package/lib/esm/utils/Services.js.map +1 -1
- package/lib/esm/utils/decorators.d.ts +5 -1
- package/lib/esm/utils/decorators.js +20 -0
- package/lib/esm/utils/decorators.js.map +1 -1
- package/lib/esm/utils/utils.d.ts +3 -0
- package/lib/esm/utils/utils.js +7 -0
- package/lib/esm/utils/utils.js.map +1 -0
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/Paginatable.d.ts +1 -1
- package/lib/overrides/injectables.d.ts +1 -1
- package/lib/persistence/constants.cjs +2 -0
- package/lib/persistence/constants.d.ts +3 -1
- package/lib/persistence/constants.js.map +1 -1
- package/lib/query/decorators.cjs +71 -38
- package/lib/query/decorators.d.ts +2 -1
- package/lib/query/decorators.js.map +1 -1
- package/lib/repository/Repository.cjs +65 -0
- package/lib/repository/Repository.d.ts +11 -4
- package/lib/repository/Repository.js.map +1 -1
- package/lib/utils/Services.cjs +118 -0
- package/lib/utils/Services.d.ts +8 -2
- package/lib/utils/Services.js.map +1 -1
- package/lib/utils/decorators.cjs +25 -0
- package/lib/utils/decorators.d.ts +5 -1
- package/lib/utils/decorators.js.map +1 -1
- package/lib/utils/utils.cjs +10 -0
- package/lib/utils/utils.d.ts +3 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +1 -1
package/lib/utils/decorators.cjs
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.del = exports.update = exports.read = exports.create = void 0;
|
|
3
4
|
exports.service = service;
|
|
4
5
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
5
6
|
const injectable_decorators_1 = require("@decaf-ts/injectable-decorators");
|
|
6
7
|
const index_1 = require("./../persistence/index.cjs");
|
|
8
|
+
const utils_1 = require("./utils.cjs");
|
|
9
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
10
|
+
function OperationGuard(op) {
|
|
11
|
+
return function (target, _propertyKey, descriptor) {
|
|
12
|
+
const original = descriptor.value;
|
|
13
|
+
descriptor.value = function (...args) {
|
|
14
|
+
const ModelConstr = this.class;
|
|
15
|
+
if (ModelConstr && (0, utils_1.isOperationBlocked)(ModelConstr, op)) {
|
|
16
|
+
const name = ModelConstr?.name ?? "Model";
|
|
17
|
+
throw new Error(`Operation "${op}" is blocked by @BlockOperations for ${name}.`);
|
|
18
|
+
}
|
|
19
|
+
return original.apply(this, args);
|
|
20
|
+
};
|
|
21
|
+
return descriptor;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const create = () => OperationGuard(db_decorators_1.OperationKeys.CREATE);
|
|
25
|
+
exports.create = create;
|
|
26
|
+
const read = () => OperationGuard(db_decorators_1.OperationKeys.READ);
|
|
27
|
+
exports.read = read;
|
|
28
|
+
const update = () => OperationGuard(db_decorators_1.OperationKeys.UPDATE);
|
|
29
|
+
exports.update = update;
|
|
30
|
+
const del = () => OperationGuard(db_decorators_1.OperationKeys.DELETE);
|
|
31
|
+
exports.del = del;
|
|
7
32
|
function service(key) {
|
|
8
33
|
key =
|
|
9
34
|
typeof key === "string"
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
1
|
+
import type { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
|
+
export declare const create: () => (target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
3
|
+
export declare const read: () => (target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
4
|
+
export declare const update: () => (target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
5
|
+
export declare const del: () => (target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
2
6
|
export declare function service(key: string | ModelConstructor<any>): (target: any, prop?: any, descriptor?: any) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/utils/decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/utils/decorators.ts"],"names":[],"mappings":";;;AAmCA,0BA6BC;AAhED,qDAAiE;AACjE,2EAAqE;AACrE,sDAAuD;AAGvD,uCAA6C;AAC7C,2DAAwD;AAGxD,SAAS,cAAc,CAAC,EAAkB;IACxC,OAAO,UACL,MAAW,EACX,YAA6B,EAC7B,UAA8B;QAE9B,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC;QAClC,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;YACzC,MAAM,WAAW,GAAI,IAA+B,CAAC,KAAK,CAAC;YAC3D,IAAI,WAAW,IAAI,IAAA,0BAAkB,EAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC;gBACvD,MAAM,IAAI,GAAG,WAAW,EAAE,IAAI,IAAI,OAAO,CAAC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CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CACP,IAAA,kCAAU,EAAC,GAAG,EAAE;gBACd,QAAQ,EAAE,CAAC,IAAS,EAAE,EAAE,CACtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE;oBAClC,UAAU,EAAE,IAAI;oBAChB,YAAY,EAAE,KAAK;oBACnB,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,GAAG;iBACX,CAAC;aACL,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,IAAI,CAAC,UAAU,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,IAAA,8BAAM,EAAC,GAAG,CAAC,CAAC,CAAC;QACzB,CAAC;;YAAM,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAExE,IAAI,CAAC,IAAI,CAAC,IAAA,qBAAQ,EAAC,uBAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAClD,OAAO,IAAA,kBAAK,EAAC,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOperationBlocked = isOperationBlocked;
|
|
4
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
5
|
+
const decoration_1 = require("@decaf-ts/decoration");
|
|
6
|
+
function isOperationBlocked(ModelConstructor, op) {
|
|
7
|
+
const { handler, args } = (decoration_1.Metadata.get(ModelConstructor, db_decorators_1.OperationKeys.REFLECT + db_decorators_1.OperationKeys.BLOCK) || {});
|
|
8
|
+
return !handler ? false : (handler(...args, op) ?? false);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;AAKA,gDAiBC;AArBD,2DAAwD;AAExD,qDAAgD;AAEhD,SAAgB,kBAAkB,CAChC,gBAAuC,EACvC,EAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GACrB,CAAC,qBAAQ,CAAC,GAAG,CACX,gBAAuB,EACvB,6BAAa,CAAC,OAAO,GAAG,6BAAa,CAAC,KAAK,CAC5C,IAAI,EAAE,CAMN,CAAC;IAEJ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC;AAC5D,CAAC"}
|