@schorts/shared-kernel 1.1.5 → 1.2.1
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/CHANGELOG +13 -0
- package/README.md +5 -0
- package/dist/cjs/auth/exceptions/index.js +3 -1
- package/dist/cjs/auth/exceptions/index.js.map +1 -1
- package/dist/cjs/auth/exceptions/not-authenticated.js +6 -0
- package/dist/cjs/auth/exceptions/not-authenticated.js.map +1 -1
- package/dist/cjs/auth/exceptions/require-auth-not-implemented-correctly.js +13 -0
- package/dist/cjs/auth/exceptions/require-auth-not-implemented-correctly.js.map +1 -0
- package/dist/cjs/auth/index.js +16 -3
- package/dist/cjs/auth/index.js.map +1 -1
- package/dist/cjs/auth/require-auth.decorator.js +2 -2
- package/dist/cjs/auth/require-auth.decorator.js.map +1 -1
- package/dist/cjs/criteria/criteria.js +2 -2
- package/dist/cjs/criteria/criteria.js.map +1 -1
- package/dist/cjs/criteria/exceptions/limit-not-valid.js +6 -0
- package/dist/cjs/criteria/exceptions/limit-not-valid.js.map +1 -1
- package/dist/cjs/criteria/exceptions/offset-not-valid.js +6 -0
- package/dist/cjs/criteria/exceptions/offset-not-valid.js.map +1 -1
- package/dist/cjs/criteria/index.js +16 -4
- package/dist/cjs/criteria/index.js.map +1 -1
- package/dist/cjs/entities/entity-registry.js +7 -7
- package/dist/cjs/entities/entity-registry.js.map +1 -1
- package/dist/cjs/entities/exceptions/entity-not-registered.js +6 -0
- package/dist/cjs/entities/exceptions/entity-not-registered.js.map +1 -1
- package/dist/cjs/entities/index.js +16 -3
- package/dist/cjs/entities/index.js.map +1 -1
- package/dist/cjs/i18n/index.js +6 -0
- package/dist/cjs/i18n/index.js.map +1 -0
- package/dist/cjs/i18n/shared-kernel-translation-keys.js +23 -0
- package/dist/cjs/i18n/shared-kernel-translation-keys.js.map +1 -0
- package/dist/cjs/i18n/translation-resolver.js +3 -0
- package/dist/cjs/i18n/translation-resolver.js.map +1 -0
- package/dist/esm/auth/exceptions/index.js +3 -1
- package/dist/esm/auth/exceptions/index.js.map +1 -1
- package/dist/esm/auth/exceptions/not-authenticated.js +6 -0
- package/dist/esm/auth/exceptions/not-authenticated.js.map +1 -1
- package/dist/esm/auth/exceptions/require-auth-not-implemented-correctly.js +13 -0
- package/dist/esm/auth/exceptions/require-auth-not-implemented-correctly.js.map +1 -0
- package/dist/esm/auth/index.js +16 -3
- package/dist/esm/auth/index.js.map +1 -1
- package/dist/esm/auth/require-auth.decorator.js +2 -2
- package/dist/esm/auth/require-auth.decorator.js.map +1 -1
- package/dist/esm/criteria/criteria.js +2 -2
- package/dist/esm/criteria/criteria.js.map +1 -1
- package/dist/esm/criteria/exceptions/limit-not-valid.js +6 -0
- package/dist/esm/criteria/exceptions/limit-not-valid.js.map +1 -1
- package/dist/esm/criteria/exceptions/offset-not-valid.js +6 -0
- package/dist/esm/criteria/exceptions/offset-not-valid.js.map +1 -1
- package/dist/esm/criteria/index.js +16 -4
- package/dist/esm/criteria/index.js.map +1 -1
- package/dist/esm/entities/entity-registry.js +7 -7
- package/dist/esm/entities/entity-registry.js.map +1 -1
- package/dist/esm/entities/exceptions/entity-not-registered.js +6 -0
- package/dist/esm/entities/exceptions/entity-not-registered.js.map +1 -1
- package/dist/esm/entities/index.js +16 -3
- package/dist/esm/entities/index.js.map +1 -1
- package/dist/esm/i18n/index.js +6 -0
- package/dist/esm/i18n/index.js.map +1 -0
- package/dist/esm/i18n/shared-kernel-translation-keys.js +23 -0
- package/dist/esm/i18n/shared-kernel-translation-keys.js.map +1 -0
- package/dist/esm/i18n/translation-resolver.js +3 -0
- package/dist/esm/i18n/translation-resolver.js.map +1 -0
- package/dist/types/auth/exceptions/index.d.ts +1 -0
- package/dist/types/auth/exceptions/index.d.ts.map +1 -1
- package/dist/types/auth/exceptions/not-authenticated.d.ts +2 -0
- package/dist/types/auth/exceptions/not-authenticated.d.ts.map +1 -1
- package/dist/types/auth/exceptions/require-auth-not-implemented-correctly.d.ts +5 -0
- package/dist/types/auth/exceptions/require-auth-not-implemented-correctly.d.ts.map +1 -0
- package/dist/types/auth/index.d.ts +1 -1
- package/dist/types/auth/index.d.ts.map +1 -1
- package/dist/types/auth/require-auth.decorator.d.ts +2 -0
- package/dist/types/auth/require-auth.decorator.d.ts.map +1 -1
- package/dist/types/criteria/exceptions/limit-not-valid.d.ts +2 -0
- package/dist/types/criteria/exceptions/limit-not-valid.d.ts.map +1 -1
- package/dist/types/criteria/exceptions/offset-not-valid.d.ts +2 -0
- package/dist/types/criteria/exceptions/offset-not-valid.d.ts.map +1 -1
- package/dist/types/criteria/index.d.ts +1 -1
- package/dist/types/criteria/index.d.ts.map +1 -1
- package/dist/types/entities/entity-registry.d.ts +3 -3
- package/dist/types/entities/entity-registry.d.ts.map +1 -1
- package/dist/types/entities/exceptions/entity-not-registered.d.ts +2 -0
- package/dist/types/entities/exceptions/entity-not-registered.d.ts.map +1 -1
- package/dist/types/entities/index.d.ts +1 -1
- package/dist/types/entities/index.d.ts.map +1 -1
- package/dist/types/i18n/index.d.ts +3 -0
- package/dist/types/i18n/index.d.ts.map +1 -0
- package/dist/types/i18n/shared-kernel-translation-keys.d.ts +20 -0
- package/dist/types/i18n/shared-kernel-translation-keys.d.ts.map +1 -0
- package/dist/types/i18n/translation-resolver.d.ts +4 -0
- package/dist/types/i18n/translation-resolver.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/auth/exceptions/index.ts +1 -0
- package/src/auth/exceptions/not-authenticated.ts +11 -1
- package/src/auth/exceptions/require-auth-not-implemented-correctly.ts +11 -0
- package/src/auth/index.ts +1 -1
- package/src/auth/require-auth.decorator.ts +5 -4
- package/src/criteria/criteria.ts +2 -2
- package/src/criteria/exceptions/limit-not-valid.ts +11 -1
- package/src/criteria/exceptions/offset-not-valid.ts +11 -1
- package/src/criteria/index.ts +1 -2
- package/src/entities/entity-registry.ts +7 -7
- package/src/entities/exceptions/entity-not-registered.ts +11 -1
- package/src/entities/index.ts +1 -1
- package/src/http/fetch-http-provider.ts +6 -1
- package/src/i18n/index.ts +2 -0
- package/src/i18n/shared-kernel-translation-keys.ts +19 -0
- package/src/i18n/translation-resolver.ts +3 -0
|
@@ -4,16 +4,16 @@ exports.EntityRegistry = void 0;
|
|
|
4
4
|
const exceptions_1 = require("./exceptions");
|
|
5
5
|
class EntityRegistry {
|
|
6
6
|
static registry = new Map();
|
|
7
|
-
static register(
|
|
8
|
-
this.registry.set(
|
|
7
|
+
static register(tableOrCollectionName, entity) {
|
|
8
|
+
this.registry.set(tableOrCollectionName, entity);
|
|
9
9
|
}
|
|
10
|
-
static resolve(
|
|
11
|
-
return (this.registry.get(
|
|
10
|
+
static resolve(tableOrCollectionName) {
|
|
11
|
+
return (this.registry.get(tableOrCollectionName) || null);
|
|
12
12
|
}
|
|
13
|
-
static create(
|
|
14
|
-
const entity = this.resolve(
|
|
13
|
+
static create(tableOrCollectionName, model) {
|
|
14
|
+
const entity = this.resolve(tableOrCollectionName);
|
|
15
15
|
if (!entity) {
|
|
16
|
-
throw new exceptions_1.EntityNotRegistered(
|
|
16
|
+
throw new exceptions_1.EntityNotRegistered(tableOrCollectionName);
|
|
17
17
|
}
|
|
18
18
|
return entity.fromPrimitives(model);
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-registry.js","sourceRoot":"","sources":["../../../src/entities/entity-registry.ts"],"names":[],"mappings":";;;AAEA,6CAAmD;AAOnD,MAAa,cAAc;IACjB,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;IAE/D,MAAM,CAAC,QAAQ,CAA0B,
|
|
1
|
+
{"version":3,"file":"entity-registry.js","sourceRoot":"","sources":["../../../src/entities/entity-registry.ts"],"names":[],"mappings":";;;AAEA,6CAAmD;AAOnD,MAAa,cAAc;IACjB,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;IAE/D,MAAM,CAAC,QAAQ,CAA0B,qBAA6B,EAAE,MAAgC;QACtG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,OAAO,CAA0B,qBAA6B;QACnE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,IAAI,CAAoC,CAAC;IAC/F,CAAC;IAED,MAAM,CAAC,MAAM,CAA0B,qBAA6B,EAAE,KAAY;QAChF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAQ,qBAAqB,CAAC,CAAC;QAE1D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,gCAAmB,CAAC,qBAAqB,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;;AAnBH,wCAoBC"}
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntityNotRegistered = void 0;
|
|
4
4
|
class EntityNotRegistered extends Error {
|
|
5
|
+
constructor(tableOrCollectionName, translationResolver) {
|
|
6
|
+
const message = translationResolver
|
|
7
|
+
? translationResolver.resolve("entities.errors.entity_not_registered")
|
|
8
|
+
: `Entity Not Registered: ${tableOrCollectionName}`;
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
5
11
|
}
|
|
6
12
|
exports.EntityNotRegistered = EntityNotRegistered;
|
|
7
13
|
//# sourceMappingURL=entity-not-registered.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-not-registered.js","sourceRoot":"","sources":["../../../../src/entities/exceptions/entity-not-registered.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"entity-not-registered.js","sourceRoot":"","sources":["../../../../src/entities/exceptions/entity-not-registered.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,qBAA6B,EAAE,mBAAyC;QAClF,MAAM,OAAO,GAAG,mBAAmB;YACjC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,uCAAuC,CAAC;YACtE,CAAC,CAAC,0BAA0B,qBAAqB,EAAE,CAAC;QAEtD,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AARD,kDAQC"}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegisterEntity = exports.
|
|
17
|
+
exports.RegisterEntity = exports.EntityRegistry = exports.Entity = void 0;
|
|
4
18
|
var entity_1 = require("./entity");
|
|
5
19
|
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return entity_1.Entity; } });
|
|
6
20
|
var entity_registry_1 = require("./entity-registry");
|
|
7
21
|
Object.defineProperty(exports, "EntityRegistry", { enumerable: true, get: function () { return entity_registry_1.EntityRegistry; } });
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "EntityNotRegistered", { enumerable: true, get: function () { return exceptions_1.EntityNotRegistered; } });
|
|
22
|
+
__exportStar(require("./exceptions"), exports);
|
|
10
23
|
var register_entity_decorator_1 = require("./register-entity.decorator");
|
|
11
24
|
Object.defineProperty(exports, "RegisterEntity", { enumerable: true, get: function () { return register_entity_decorator_1.RegisterEntity; } });
|
|
12
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,+CAA6B;AAC7B,yEAA6D;AAApD,2HAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedKernelTranslationKeys = void 0;
|
|
4
|
+
var shared_kernel_translation_keys_1 = require("./shared-kernel-translation-keys");
|
|
5
|
+
Object.defineProperty(exports, "SharedKernelTranslationKeys", { enumerable: true, get: function () { return shared_kernel_translation_keys_1.SharedKernelTranslationKeys; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":";;;AACA,mFAA+E;AAAtE,6IAAA,2BAA2B,OAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedKernelTranslationKeys = void 0;
|
|
4
|
+
exports.SharedKernelTranslationKeys = {
|
|
5
|
+
auth: {
|
|
6
|
+
errors: {
|
|
7
|
+
NotAuthenticated: "auth.errors.not_authenticated",
|
|
8
|
+
RequireAuthNotImplementedCorrectly: "auth.errors.require_auth_not_implemented_correctly",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
criteria: {
|
|
12
|
+
errors: {
|
|
13
|
+
LimitNotValid: "criteria.errors.limit_not_valid",
|
|
14
|
+
OffsetNotValid: "criteria.errors.offset_not_valid",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
entities: {
|
|
18
|
+
errors: {
|
|
19
|
+
EntityNotRegistered: "entities.errors.entity_not_registered",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=shared-kernel-translation-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-kernel-translation-keys.js","sourceRoot":"","sources":["../../../src/i18n/shared-kernel-translation-keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG;IACzC,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,gBAAgB,EAAE,+BAA+B;YACjD,kCAAkC,EAAE,oDAAoD;SACzF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,aAAa,EAAE,iCAAiC;YAChD,cAAc,EAAE,kCAAkC;SACnD;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,mBAAmB,EAAE,uCAAuC;SAC7D;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-resolver.js","sourceRoot":"","sources":["../../../src/i18n/translation-resolver.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,kCAAkC,EAAE,MAAM,0CAA0C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-authenticated.d.ts","sourceRoot":"","sources":["../../../../src/auth/exceptions/not-authenticated.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"not-authenticated.d.ts","sourceRoot":"","sources":["../../../../src/auth/exceptions/not-authenticated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,mBAAmB,CAAC,EAAE,mBAAmB;CAOtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-auth-not-implemented-correctly.d.ts","sourceRoot":"","sources":["../../../../src/auth/exceptions/require-auth-not-implemented-correctly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,mBAAmB,CAAC,EAAE,mBAAmB;CAOtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,cAAc,cAAc,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AuthProvider } from "./auth-provider";
|
|
2
|
+
import { TranslationResolver } from "../i18n";
|
|
2
3
|
export declare function RequireAuth(onFail?: () => any): (...args: any[]) => PropertyDescriptor | ((this: {
|
|
3
4
|
authProvider?: AuthProvider<any>;
|
|
5
|
+
translationResolver?: TranslationResolver;
|
|
4
6
|
}, ...args: any[]) => Promise<unknown>);
|
|
5
7
|
//# sourceMappingURL=require-auth.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-auth.decorator.d.ts","sourceRoot":"","sources":["../../../src/auth/require-auth.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"require-auth.decorator.d.ts","sourceRoot":"","sources":["../../../src/auth/require-auth.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAuB3B,GAAG,MAAM,GAAG,EAAE;mBAtBa,YAAY,CAAC,GAAG,CAAC;0BAAwB,mBAAmB;wCAoCzG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limit-not-valid.d.ts","sourceRoot":"","sources":["../../../../src/criteria/exceptions/limit-not-valid.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"limit-not-valid.d.ts","sourceRoot":"","sources":["../../../../src/criteria/exceptions/limit-not-valid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,KAAK,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,mBAAmB;CAOrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offset-not-valid.d.ts","sourceRoot":"","sources":["../../../../src/criteria/exceptions/offset-not-valid.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"offset-not-valid.d.ts","sourceRoot":"","sources":["../../../../src/criteria/exceptions/offset-not-valid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,MAAM,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,mBAAmB;CAOtE"}
|
|
@@ -3,5 +3,5 @@ export type { Order } from "./order";
|
|
|
3
3
|
export type { FilterCriterion } from "./filter-criterion";
|
|
4
4
|
export type { Direction } from "./direction";
|
|
5
5
|
export { Criteria } from "./criteria";
|
|
6
|
-
export
|
|
6
|
+
export * from "./exceptions";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/criteria/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/criteria/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,cAAc,CAAC"}
|
|
@@ -6,9 +6,9 @@ type EntityConstructor<Model extends BaseModel = BaseModel> = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare class EntityRegistry {
|
|
8
8
|
private static registry;
|
|
9
|
-
static register<Model extends BaseModel>(
|
|
10
|
-
static resolve<Model extends BaseModel>(
|
|
11
|
-
static create<Model extends BaseModel>(
|
|
9
|
+
static register<Model extends BaseModel>(tableOrCollectionName: string, entity: EntityConstructor<Model>): void;
|
|
10
|
+
static resolve<Model extends BaseModel>(tableOrCollectionName: string): EntityConstructor<Model> | null;
|
|
11
|
+
static create<Model extends BaseModel>(tableOrCollectionName: string, model: Model): Entity<ValueObject, Model>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=entity-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-registry.d.ts","sourceRoot":"","sources":["../../../src/entities/entity-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,iBAAiB,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,IAAI;IAC5D,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CAC1D,CAAC;AAEF,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAwC;IAE/D,MAAM,CAAC,QAAQ,CAAC,KAAK,SAAS,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"entity-registry.d.ts","sourceRoot":"","sources":["../../../src/entities/entity-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,iBAAiB,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,IAAI;IAC5D,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CAC1D,CAAC;AAEF,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAwC;IAE/D,MAAM,CAAC,QAAQ,CAAC,KAAK,SAAS,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI;IAI/G,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,SAAS,EAAE,qBAAqB,EAAE,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI;IAIvG,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC;CAShH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-not-registered.d.ts","sourceRoot":"","sources":["../../../../src/entities/exceptions/entity-not-registered.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAoB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"entity-not-registered.d.ts","sourceRoot":"","sources":["../../../../src/entities/exceptions/entity-not-registered.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,mBAAmB;CAOrF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Entity } from "./entity";
|
|
2
2
|
export { EntityRegistry } from "./entity-registry";
|
|
3
|
-
export
|
|
3
|
+
export * from "./exceptions";
|
|
4
4
|
export { RegisterEntity } from "./register-entity.decorator";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SharedKernelTranslationKeys: {
|
|
2
|
+
auth: {
|
|
3
|
+
errors: {
|
|
4
|
+
NotAuthenticated: string;
|
|
5
|
+
RequireAuthNotImplementedCorrectly: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
criteria: {
|
|
9
|
+
errors: {
|
|
10
|
+
LimitNotValid: string;
|
|
11
|
+
OffsetNotValid: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
entities: {
|
|
15
|
+
errors: {
|
|
16
|
+
EntityNotRegistered: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=shared-kernel-translation-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-kernel-translation-keys.d.ts","sourceRoot":"","sources":["../../../src/i18n/shared-kernel-translation-keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;CAkBvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-resolver.d.ts","sourceRoot":"","sources":["../../../src/i18n/translation-resolver.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;CAC5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schorts/shared-kernel",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A modular, type-safe foundation for building expressive, maintainable applications. This package provides core abstractions for domain modeling, HTTP integration, authentication, state management, and more — designed to be framework-agnostic and highly extensible.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { TranslationResolver } from "../../i18n";
|
|
2
|
+
|
|
3
|
+
export class NotAuthenticated extends Error {
|
|
4
|
+
constructor(translationResolver?: TranslationResolver) {
|
|
5
|
+
const message = translationResolver
|
|
6
|
+
? translationResolver.resolve("auth.errors.not_authenticated")
|
|
7
|
+
: "Not Authenticated";
|
|
8
|
+
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TranslationResolver } from "../../i18n";
|
|
2
|
+
|
|
3
|
+
export class RequireAuthNotImplementedCorrectly extends Error {
|
|
4
|
+
constructor(translationResolver?: TranslationResolver) {
|
|
5
|
+
const message = translationResolver
|
|
6
|
+
? translationResolver.resolve("auth.errors.require_auth_not_implemented_correctly")
|
|
7
|
+
: "RequireAuth decorator not implemented correctly";
|
|
8
|
+
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/auth/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AuthProvider } from "./auth-provider";
|
|
2
|
-
import { NotAuthenticated } from './exceptions';
|
|
2
|
+
import { NotAuthenticated, RequireAuthNotImplementedCorrectly } from './exceptions';
|
|
3
|
+
import { TranslationResolver } from "../i18n";
|
|
3
4
|
|
|
4
5
|
export function RequireAuth(onFail?: () => any) {
|
|
5
|
-
function wrapper<T extends { authProvider?: AuthProvider<any
|
|
6
|
+
function wrapper<T extends { authProvider?: AuthProvider<any>, translationResolver?: TranslationResolver }, A extends any[], R>(
|
|
6
7
|
originalMethod: (this: T, ...args: A) => Promise<R>
|
|
7
8
|
): (this: T, ...args: A) => Promise<R> {
|
|
8
9
|
return async function (this: T, ...args: A): Promise<R> {
|
|
@@ -16,7 +17,7 @@ export function RequireAuth(onFail?: () => any) {
|
|
|
16
17
|
if (onFail) {
|
|
17
18
|
return onFail();
|
|
18
19
|
} else {
|
|
19
|
-
throw new NotAuthenticated();
|
|
20
|
+
throw new NotAuthenticated(this.translationResolver);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -36,6 +37,6 @@ export function RequireAuth(onFail?: () => any) {
|
|
|
36
37
|
return wrapper(originalMethod);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
throw new
|
|
40
|
+
throw new RequireAuthNotImplementedCorrectly();
|
|
40
41
|
};
|
|
41
42
|
}
|
package/src/criteria/criteria.ts
CHANGED
|
@@ -31,7 +31,7 @@ export class Criteria {
|
|
|
31
31
|
|
|
32
32
|
limitResults(limit: number): Criteria {
|
|
33
33
|
if (limit < 1) {
|
|
34
|
-
throw new LimitNotValid();
|
|
34
|
+
throw new LimitNotValid(limit);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
this.limit = limit;
|
|
@@ -41,7 +41,7 @@ export class Criteria {
|
|
|
41
41
|
|
|
42
42
|
offsetResults(offset: number): Criteria {
|
|
43
43
|
if (offset < 1) {
|
|
44
|
-
throw new OffsetNotValid();
|
|
44
|
+
throw new OffsetNotValid(offset);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
this.offset = offset;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { TranslationResolver } from "../../i18n";
|
|
2
|
+
|
|
3
|
+
export class LimitNotValid extends Error {
|
|
4
|
+
constructor(limit: number, translationResolver?: TranslationResolver) {
|
|
5
|
+
const message = translationResolver
|
|
6
|
+
? translationResolver.resolve("criteria.errors.limit_not_valid", { limit })
|
|
7
|
+
: `Limit Not Valid: ${limit}`;
|
|
8
|
+
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { TranslationResolver } from "../../i18n";
|
|
2
|
+
|
|
3
|
+
export class OffsetNotValid extends Error {
|
|
4
|
+
constructor(offset: number, translationResolver?: TranslationResolver) {
|
|
5
|
+
const message = translationResolver
|
|
6
|
+
? translationResolver.resolve("criteria.errors.offset_not_valid", { offset })
|
|
7
|
+
: `Offset Not Valid: ${offset}`;
|
|
8
|
+
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/criteria/index.ts
CHANGED
|
@@ -2,6 +2,5 @@ export type { Operator } from "./operator";
|
|
|
2
2
|
export type { Order } from "./order";
|
|
3
3
|
export type { FilterCriterion } from "./filter-criterion";
|
|
4
4
|
export type { Direction } from "./direction";
|
|
5
|
-
|
|
6
5
|
export { Criteria } from "./criteria";
|
|
7
|
-
export
|
|
6
|
+
export * from "./exceptions";
|
|
@@ -10,19 +10,19 @@ type EntityConstructor<Model extends BaseModel = BaseModel> = {
|
|
|
10
10
|
export class EntityRegistry {
|
|
11
11
|
private static registry = new Map<string, EntityConstructor>();
|
|
12
12
|
|
|
13
|
-
static register<Model extends BaseModel>(
|
|
14
|
-
this.registry.set(
|
|
13
|
+
static register<Model extends BaseModel>(tableOrCollectionName: string, entity: EntityConstructor<Model>): void {
|
|
14
|
+
this.registry.set(tableOrCollectionName, entity);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
static resolve<Model extends BaseModel>(
|
|
18
|
-
return (this.registry.get(
|
|
17
|
+
static resolve<Model extends BaseModel>(tableOrCollectionName: string): EntityConstructor<Model> | null {
|
|
18
|
+
return (this.registry.get(tableOrCollectionName) || null) as EntityConstructor<Model> | null;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static create<Model extends BaseModel>(
|
|
22
|
-
const entity = this.resolve<Model>(
|
|
21
|
+
static create<Model extends BaseModel>(tableOrCollectionName: string, model: Model): Entity<ValueObject, Model> {
|
|
22
|
+
const entity = this.resolve<Model>(tableOrCollectionName);
|
|
23
23
|
|
|
24
24
|
if (!entity) {
|
|
25
|
-
throw new EntityNotRegistered(
|
|
25
|
+
throw new EntityNotRegistered(tableOrCollectionName);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return entity.fromPrimitives(model);
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { TranslationResolver } from "../../i18n";
|
|
2
|
+
|
|
3
|
+
export class EntityNotRegistered extends Error {
|
|
4
|
+
constructor(tableOrCollectionName: string, translationResolver?: TranslationResolver) {
|
|
5
|
+
const message = translationResolver
|
|
6
|
+
? translationResolver.resolve("entities.errors.entity_not_registered")
|
|
7
|
+
: `Entity Not Registered: ${tableOrCollectionName}`;
|
|
8
|
+
|
|
9
|
+
super(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/entities/index.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { HTTPException } from "./exceptions";
|
|
|
3
3
|
|
|
4
4
|
export class FetchHTTPProvider implements HTTPProvider {
|
|
5
5
|
private ongoingRequests = new Map<string, Promise<any>>();
|
|
6
|
+
private readonly init: Pick<RequestInit, "credentials">;
|
|
7
|
+
|
|
8
|
+
constructor(init: Pick<RequestInit, "credentials">) {
|
|
9
|
+
this.init = init;
|
|
10
|
+
}
|
|
6
11
|
|
|
7
12
|
get<ResponseType>(url: URL): Promise<ResponseType> {
|
|
8
13
|
return this.request("GET", url);
|
|
@@ -54,7 +59,7 @@ export class FetchHTTPProvider implements HTTPProvider {
|
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
const request = (async () => {
|
|
57
|
-
const response = await fetch(url.href, init);
|
|
62
|
+
const response = await fetch(url.href, { ...init, ...this.init });
|
|
58
63
|
|
|
59
64
|
if (!response) {
|
|
60
65
|
throw new HTTPException("Fetch returned undefined", 0);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const SharedKernelTranslationKeys = {
|
|
2
|
+
auth: {
|
|
3
|
+
errors: {
|
|
4
|
+
NotAuthenticated: "auth.errors.not_authenticated",
|
|
5
|
+
RequireAuthNotImplementedCorrectly: "auth.errors.require_auth_not_implemented_correctly",
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
criteria: {
|
|
9
|
+
errors: {
|
|
10
|
+
LimitNotValid: "criteria.errors.limit_not_valid",
|
|
11
|
+
OffsetNotValid: "criteria.errors.offset_not_valid",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
entities: {
|
|
15
|
+
errors: {
|
|
16
|
+
EntityNotRegistered: "entities.errors.entity_not_registered",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|