@nx-ddd/common 4.0.1 → 4.2.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/domain/models.d.ts +17 -0
- package/domain/models.js +17 -0
- package/domain/models.js.map +1 -0
- package/domain/repository.d.ts +14 -0
- package/domain/repository.js +31 -0
- package/domain/repository.js.map +1 -0
- package/infrastructure/converter.d.ts +4 -0
- package/infrastructure/converter.js +7 -0
- package/infrastructure/converter.js.map +1 -0
- package/infrastructure/index.d.ts +1 -0
- package/infrastructure/index.js +5 -0
- package/infrastructure/index.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
export declare type DomainLangMap<Entity> = Partial<{
|
|
3
|
+
[K in keyof Entity]: string;
|
|
4
|
+
}>;
|
|
5
|
+
export interface Entity<Id = string> {
|
|
6
|
+
id: Id | null;
|
|
7
|
+
createdAt: Dayjs | null;
|
|
8
|
+
updatedAt: Dayjs | null;
|
|
9
|
+
}
|
|
10
|
+
export declare type OmitGetter<T> = {
|
|
11
|
+
[P in keyof T as string extends P ? never : number extends P ? never : P]: T[P];
|
|
12
|
+
};
|
|
13
|
+
export declare class Entity {
|
|
14
|
+
static from<E extends Entity = any>(obj: Partial<OmitGetter<E>>): E;
|
|
15
|
+
static fromObj<T extends Entity = Entity>(obj: object): T;
|
|
16
|
+
static toObj(entity: Entity): Entity;
|
|
17
|
+
}
|
package/domain/models.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Entity = void 0;
|
|
4
|
+
const utilities_1 = require("@nx-ddd/common/utilities");
|
|
5
|
+
class Entity {
|
|
6
|
+
static from(obj) {
|
|
7
|
+
return Object.assign(new this(), obj);
|
|
8
|
+
}
|
|
9
|
+
static fromObj(obj) {
|
|
10
|
+
return Object.assign(new this(), Object.assign({ id: null, createdAt: null, updatedAt: null }, obj));
|
|
11
|
+
}
|
|
12
|
+
static toObj(entity) {
|
|
13
|
+
return (0, utilities_1.toObject)(entity);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Entity = Entity;
|
|
17
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../libs/common/src/domain/models.ts"],"names":[],"mappings":";;;AAAA,wDAAoD;AAepD,MAAa,MAAM;IACjB,MAAM,CAAC,IAAI,CAAyB,GAA2B;QAC7D,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,GAAG,CAAM,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,OAAO,CAA4B,GAAW;QACnD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,kBAC7B,EAAE,EAAE,IAAI,EACR,SAAS,EAAE,IAAI,EACf,SAAS,EAAE,IAAI,IACZ,GAAG,EACQ,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,OAAO,IAAA,oBAAQ,EAAC,MAAM,CAAW,CAAC;IACpC,CAAC;CASF;AAzBD,wBAyBC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type PartialWithId<T> = {
|
|
2
|
+
[P in keyof T]?: T[P];
|
|
3
|
+
} & {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export declare abstract class Repository<E extends {
|
|
7
|
+
id: string;
|
|
8
|
+
}> {
|
|
9
|
+
list(): Promise<E[]>;
|
|
10
|
+
get(entity: PartialWithId<E>): Promise<E>;
|
|
11
|
+
create(entity: Partial<E>): Promise<E>;
|
|
12
|
+
update(entity: PartialWithId<E>): Promise<void>;
|
|
13
|
+
delete(entity: PartialWithId<E>): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Repository = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@nx-ddd/core");
|
|
6
|
+
let Repository = class Repository {
|
|
7
|
+
list() {
|
|
8
|
+
throw new Error('is not implemented!');
|
|
9
|
+
}
|
|
10
|
+
;
|
|
11
|
+
get(entity) {
|
|
12
|
+
throw new Error('is not implemented!');
|
|
13
|
+
}
|
|
14
|
+
;
|
|
15
|
+
create(entity) {
|
|
16
|
+
throw new Error('is not implemented!');
|
|
17
|
+
}
|
|
18
|
+
;
|
|
19
|
+
update(entity) {
|
|
20
|
+
throw new Error('is not implemented!');
|
|
21
|
+
}
|
|
22
|
+
delete(entity) {
|
|
23
|
+
throw new Error('is not implemented!');
|
|
24
|
+
}
|
|
25
|
+
;
|
|
26
|
+
};
|
|
27
|
+
Repository = tslib_1.__decorate([
|
|
28
|
+
(0, core_1.Injectable)()
|
|
29
|
+
], Repository);
|
|
30
|
+
exports.Repository = Repository;
|
|
31
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../../libs/common/src/domain/repository.ts"],"names":[],"mappings":";;;;AAAA,uCAA0C;AAKnC,IAAe,UAAU,GAAzB,MAAe,UAAU;IAC9B,IAAI;QACF,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAAA,CAAC;IACF,GAAG,CAAC,MAAwB;QAC1B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAAA,CAAC;IACF,MAAM,CAAC,MAAkB;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAAA,CAAC;IACF,MAAM,CAAC,MAAwB;QAC7B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,CAAC,MAAwB;QAC7B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAAA,CAAC;CACH,CAAA;AAhBqB,UAAU;IAD/B,IAAA,iBAAU,GAAE;GACS,UAAU,CAgB/B;AAhBqB,gCAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../../libs/common/src/infrastructure/converter.ts"],"names":[],"mappings":";;;AAAA,MAAsB,SAAS;CAG9B;AAHD,8BAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './converter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/common/src/infrastructure/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx-ddd/common",
|
|
3
|
-
"version": "4.0
|
|
4
|
-
"main": "./
|
|
5
|
-
"types": "./
|
|
3
|
+
"version": "4.2.0",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
+
"@nx-ddd/core": "4.2.0",
|
|
9
|
+
"injection-js": "^2.4.0",
|
|
10
|
+
"reflect-metadata": "^0.1.13",
|
|
8
11
|
"tslib": "^2.0.0"
|
|
9
12
|
}
|
|
10
13
|
}
|