@tstdl/base 0.82.0 → 0.82.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/api/utils.js +3 -1
- package/api/utils.js.map +1 -1
- package/authentication/authentication-credentials.service.d.ts +2 -2
- package/authentication/authentication-session.repository.d.ts +6 -0
- package/authentication/{authentication-session.service.js → authentication-session.repository.js} +7 -6
- package/authentication/authentication-session.repository.js.map +1 -0
- package/authentication/authentication.service.d.ts +3 -3
- package/authentication/authentication.service.js +7 -7
- package/authentication/authentication.service.js.map +1 -1
- package/authentication/models/authentication-credentials.model.d.ts +6 -1
- package/authentication/models/authentication-credentials.model.js +9 -2
- package/authentication/models/authentication-credentials.model.js.map +1 -1
- package/authentication/models/authentication-session.model.d.ts +6 -1
- package/authentication/models/authentication-session.model.js +9 -2
- package/authentication/models/authentication-session.model.js.map +1 -1
- package/container/container.js +3 -3
- package/container/container.js.map +1 -1
- package/container/decorators.js +0 -1
- package/container/decorators.js.map +1 -1
- package/container/resolve-chain.js +1 -1
- package/container/resolve-chain.js.map +1 -1
- package/mail/mail.service.d.ts +3 -1
- package/mail/mail.service.js +11 -6
- package/mail/mail.service.js.map +1 -1
- package/mail/models/mail-data.model.d.ts +1 -0
- package/mail/module.d.ts +3 -1
- package/mail/module.js +6 -2
- package/mail/module.js.map +1 -1
- package/mail/tokens.d.ts +1 -0
- package/mail/tokens.js +2 -1
- package/mail/tokens.js.map +1 -1
- package/notification/api.d.ts +2 -5
- package/notification/api.js +2 -5
- package/notification/api.js.map +1 -1
- package/notification/models/index.d.ts +2 -0
- package/notification/models/index.js +19 -0
- package/notification/models/index.js.map +1 -0
- package/notification/models/notification-channel-job.model.d.ts +3 -0
- package/notification/models/notification-channel-job.model.js +3 -0
- package/notification/models/notification-channel-job.model.js.map +1 -0
- package/notification/models/notification.model.d.ts +27 -0
- package/notification/{model.js → models/notification.model.js} +28 -16
- package/notification/models/notification.model.js.map +1 -0
- package/notification/notification-channel.service.d.ts +5 -0
- package/notification/notification-channel.service.js +7 -0
- package/notification/notification-channel.service.js.map +1 -0
- package/notification/notification.service.d.ts +8 -0
- package/notification/notification.service.js +40 -0
- package/notification/notification.service.js.map +1 -0
- package/orm/decorators.d.ts +26 -0
- package/orm/decorators.js +170 -0
- package/orm/decorators.js.map +1 -1
- package/orm/entity-definition.model.d.ts +51 -0
- package/orm/entity-definition.model.js +27 -0
- package/orm/entity-definition.model.js.map +1 -0
- package/orm/index.d.ts +1 -0
- package/orm/index.js +18 -0
- package/orm/index.js.map +1 -0
- package/orm/models/entity.d.ts +22 -0
- package/orm/models/entity.js +87 -0
- package/orm/models/entity.js.map +1 -0
- package/orm/models/index.d.ts +1 -0
- package/orm/models/index.js +18 -0
- package/orm/models/index.js.map +1 -0
- package/orm/repository/mongo/classes.d.ts +25 -0
- package/orm/repository/mongo/classes.js +33 -0
- package/orm/repository/mongo/classes.js.map +1 -0
- package/orm/repository/mongo/module.d.ts +8 -0
- package/orm/repository/mongo/module.js +88 -0
- package/orm/repository/mongo/module.js.map +1 -0
- package/orm/repository/mongo/mongo-repository.d.ts +11 -0
- package/orm/repository/mongo/mongo-repository.js +55 -0
- package/orm/repository/mongo/mongo-repository.js.map +1 -0
- package/orm/repository/mongo/mongo-transaction.d.ts +10 -0
- package/orm/repository/mongo/mongo-transaction.js +28 -0
- package/orm/repository/mongo/mongo-transaction.js.map +1 -0
- package/orm/repository/repository.d.ts +75 -0
- package/orm/repository/repository.js +182 -0
- package/orm/repository/repository.js.map +1 -0
- package/orm/repository/transaction.d.ts +26 -0
- package/orm/repository/transaction.js +65 -0
- package/orm/repository/transaction.js.map +1 -0
- package/orm/{types.d.ts → types/definition.d.ts} +1 -1
- package/orm/{types.js → types/definition.js} +8 -8
- package/orm/types/definition.js.map +1 -0
- package/orm/types/index.d.ts +3 -0
- package/orm/types/index.js +20 -0
- package/orm/types/index.js.map +1 -0
- package/orm/types/options.d.ts +36 -0
- package/orm/types/options.js +5 -0
- package/orm/types/options.js.map +1 -0
- package/orm/types/query.d.ts +110 -0
- package/orm/types/query.js +10 -0
- package/orm/types/query.js.map +1 -0
- package/package.json +3 -3
- package/reflection/decorator-data.js +2 -1
- package/reflection/decorator-data.js.map +1 -1
- package/reflection/registry.d.ts +9 -8
- package/reflection/registry.js +25 -10
- package/reflection/registry.js.map +1 -1
- package/reflection/types.d.ts +2 -2
- package/reflection/utils.d.ts +3 -3
- package/reflection/utils.js +6 -6
- package/reflection/utils.js.map +1 -1
- package/schema/array-constraints/maximum-length.d.ts +2 -2
- package/schema/array-constraints/maximum-length.js +2 -2
- package/schema/array-constraints/maximum-length.js.map +1 -1
- package/schema/array-constraints/minimum-length.d.ts +2 -2
- package/schema/array-constraints/minimum-length.js +2 -2
- package/schema/array-constraints/minimum-length.js.map +1 -1
- package/schema/constraints/enumeration.d.ts +4 -4
- package/schema/constraints/enumeration.js +5 -5
- package/schema/constraints/enumeration.js.map +1 -1
- package/schema/constraints/generic.d.ts +2 -2
- package/schema/constraints/generic.js +2 -2
- package/schema/constraints/generic.js.map +1 -1
- package/schema/constraints/integer.d.ts +2 -2
- package/schema/constraints/integer.js +3 -2
- package/schema/constraints/integer.js.map +1 -1
- package/schema/constraints/literal.d.ts +2 -2
- package/schema/constraints/literal.js +2 -2
- package/schema/constraints/literal.js.map +1 -1
- package/schema/constraints/maximum-date.d.ts +2 -2
- package/schema/constraints/maximum-date.js +3 -2
- package/schema/constraints/maximum-date.js.map +1 -1
- package/schema/constraints/maximum-length.d.ts +2 -2
- package/schema/constraints/maximum-length.js +2 -2
- package/schema/constraints/maximum-length.js.map +1 -1
- package/schema/constraints/maximum.d.ts +2 -2
- package/schema/constraints/maximum.js +3 -2
- package/schema/constraints/maximum.js.map +1 -1
- package/schema/constraints/minimum-date.d.ts +2 -2
- package/schema/constraints/minimum-date.js +3 -2
- package/schema/constraints/minimum-date.js.map +1 -1
- package/schema/constraints/minimum-length.d.ts +2 -2
- package/schema/constraints/minimum-length.js +2 -2
- package/schema/constraints/minimum-length.js.map +1 -1
- package/schema/constraints/minimum.d.ts +2 -2
- package/schema/constraints/minimum.js +3 -2
- package/schema/constraints/minimum.js.map +1 -1
- package/schema/constraints/pattern.d.ts +2 -2
- package/schema/constraints/pattern.js +3 -2
- package/schema/constraints/pattern.js.map +1 -1
- package/schema/decorators/utils.d.ts +4 -1
- package/schema/decorators/utils.js +1 -1
- package/schema/decorators/utils.js.map +1 -1
- package/schema/schemas/array.d.ts +1 -1
- package/schema/schemas/array.js +2 -2
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/date.d.ts +1 -1
- package/schema/schemas/date.js +2 -2
- package/schema/schemas/date.js.map +1 -1
- package/schema/schemas/enumeration.d.ts +1 -1
- package/schema/schemas/enumeration.js +2 -2
- package/schema/schemas/enumeration.js.map +1 -1
- package/schema/schemas/literal.d.ts +1 -1
- package/schema/schemas/literal.js +2 -2
- package/schema/schemas/literal.js.map +1 -1
- package/schema/schemas/number.d.ts +1 -1
- package/schema/schemas/number.js +2 -2
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/omit.d.ts +2 -2
- package/schema/schemas/omit.js.map +1 -1
- package/schema/schemas/string.d.ts +1 -1
- package/schema/schemas/string.js +3 -3
- package/schema/schemas/string.js.map +1 -1
- package/schema/schemas/uint8-array.d.ts +1 -1
- package/schema/schemas/uint8-array.js +3 -3
- package/schema/schemas/uint8-array.js.map +1 -1
- package/schema/types/index.d.ts +5 -0
- package/schema/types/index.js +22 -0
- package/schema/types/index.js.map +1 -0
- package/schema/types/schema-array-constraint.d.ts +5 -0
- package/schema/types/schema-array-constraint.js +7 -0
- package/schema/types/schema-array-constraint.js.map +1 -0
- package/schema/types/schema-value-coercer.d.ts +8 -0
- package/schema/types/schema-value-coercer.js +7 -0
- package/schema/types/schema-value-coercer.js.map +1 -0
- package/schema/types/schema-value-constraint.d.ts +8 -0
- package/schema/types/schema-value-constraint.js +7 -0
- package/schema/types/schema-value-constraint.js.map +1 -0
- package/schema/types/schema-value-transformer.d.ts +7 -0
- package/schema/types/schema-value-transformer.js +7 -0
- package/schema/types/schema-value-transformer.js.map +1 -0
- package/schema/{types.d.ts → types/types.d.ts} +16 -26
- package/schema/types/types.js +174 -0
- package/schema/types/types.js.map +1 -0
- package/schema/utils/schema.js +1 -1
- package/schema/utils/schema.js.map +1 -1
- package/schema/utils/value-type.d.ts +1 -1
- package/schema/utils/value-type.js +1 -1
- package/schema/utils/value-type.js.map +1 -1
- package/utils/array/array.d.ts +14 -1
- package/utils/array/array.js +16 -2
- package/utils/array/array.js.map +1 -1
- package/utils/object/object.js +1 -2
- package/utils/object/object.js.map +1 -1
- package/authentication/authentication-session.service.d.ts +0 -6
- package/authentication/authentication-session.service.js.map +0 -1
- package/notification/model.d.ts +0 -18
- package/notification/model.js.map +0 -1
- package/orm/mongo/mongo-repository.d.ts +0 -2
- package/orm/mongo/mongo-repository.js +0 -7
- package/orm/mongo/mongo-repository.js.map +0 -1
- package/orm/types.js.map +0 -1
- package/schema/types.js +0 -102
- package/schema/types.js.map +0 -1
package/notification/api.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { ApiServerResult } from "../api";
|
|
2
|
-
import { Notification } from './
|
|
2
|
+
import { Notification } from './models';
|
|
3
3
|
declare const notificationApiDefinition: {
|
|
4
4
|
readonly resource: string;
|
|
5
5
|
endpoints: {
|
|
6
6
|
get: {
|
|
7
|
-
|
|
8
|
-
for: string;
|
|
9
|
-
}>;
|
|
10
|
-
result: import("../schema").ValueSchema<Notification[]>;
|
|
7
|
+
result: import("../schema").ValueSchema<Notification<unknown>[]>;
|
|
11
8
|
};
|
|
12
9
|
};
|
|
13
10
|
};
|
package/notification/api.js
CHANGED
|
@@ -10,16 +10,13 @@ exports.NotificationApi = void 0;
|
|
|
10
10
|
const api_1 = require("../api");
|
|
11
11
|
const server_1 = require("../api/server");
|
|
12
12
|
const schema_1 = require("../schema");
|
|
13
|
-
const
|
|
13
|
+
const models_1 = require("./models");
|
|
14
14
|
const module_1 = require("./module");
|
|
15
15
|
const notificationApiDefinition = (0, api_1.defineApi)({
|
|
16
16
|
get resource() { return module_1.notificationModuleConfig.apiResource; },
|
|
17
17
|
endpoints: {
|
|
18
18
|
get: {
|
|
19
|
-
|
|
20
|
-
for: (0, schema_1.string)()
|
|
21
|
-
}),
|
|
22
|
-
result: (0, schema_1.array)(model_1.Notification)
|
|
19
|
+
result: (0, schema_1.array)(models_1.Notification)
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
});
|
package/notification/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../source/notification/api.ts"],"names":[],"mappings":";;;;;;;;;AACA,gCAAkC;AAClC,0CAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../source/notification/api.ts"],"names":[],"mappings":";;;;;;;;;AACA,gCAAkC;AAClC,0CAA6C;AAC7C,sCAAiC;AACjC,qCAAwC;AACxC,qCAAoD;AAEpD,MAAM,yBAAyB,GAAG,IAAA,eAAS,EAAC;IAC1C,IAAI,QAAQ,KAAK,OAAO,iCAAwB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/D,SAAS,EAAE;QACT,GAAG,EAAE;YACH,MAAM,EAAE,IAAA,cAAK,EAAC,qBAAY,CAAC;SAC5B;KACF;CACF,CAAC,CAAC;AAKI,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,KAAK,CAAC,GAAG;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;AAJY,eAAe;IAD3B,IAAA,sBAAa,EAAC,yBAAyB,CAAC;GAC5B,eAAe,CAI3B;AAJY,0CAAe"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./notification-channel-job.model"), exports);
|
|
18
|
+
__exportStar(require("./notification.model"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/notification/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-channel-job.model.js","sourceRoot":"","sources":["../../../source/notification/models/notification-channel-job.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Entity } from "../../orm/models";
|
|
2
|
+
export declare class Notification<T = unknown> extends Entity {
|
|
3
|
+
/**
|
|
4
|
+
* Receiver for the notification
|
|
5
|
+
*/
|
|
6
|
+
receiver: string;
|
|
7
|
+
/**
|
|
8
|
+
* Channels over which the notification is sent
|
|
9
|
+
*/
|
|
10
|
+
channels: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Timestamp at which the notification was created
|
|
13
|
+
*/
|
|
14
|
+
timestamp: number;
|
|
15
|
+
/**
|
|
16
|
+
* Timestamp at which the notification was marked as read
|
|
17
|
+
*/
|
|
18
|
+
readTimestamp: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Custom data
|
|
21
|
+
*/
|
|
22
|
+
data: T;
|
|
23
|
+
}
|
|
24
|
+
declare const NewNotification_base: import("../../types").Type<import("../../types").PartialProperty<Notification<any>, "id">, any>;
|
|
25
|
+
export declare class NewNotification extends NewNotification_base {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -9,30 +9,39 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Notification = void 0;
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
exports.NewNotification = exports.Notification = void 0;
|
|
13
|
+
const models_1 = require("../../orm/models");
|
|
14
|
+
const schema_1 = require("../../schema");
|
|
15
|
+
class Notification extends models_1.Entity {
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Receiver for the notification
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
receiver;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Channels over which the notification is sent
|
|
22
|
+
*/
|
|
23
|
+
channels;
|
|
24
|
+
/**
|
|
25
|
+
* Timestamp at which the notification was created
|
|
21
26
|
*/
|
|
22
27
|
timestamp;
|
|
23
28
|
/**
|
|
24
|
-
* Timestamp at which the notification was marked as read
|
|
29
|
+
* Timestamp at which the notification was marked as read
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
readTimestamp;
|
|
27
32
|
/**
|
|
28
|
-
* Custom data
|
|
33
|
+
* Custom data
|
|
29
34
|
*/
|
|
30
35
|
data;
|
|
31
|
-
}
|
|
36
|
+
}
|
|
32
37
|
__decorate([
|
|
33
38
|
(0, schema_1.Property)(),
|
|
34
39
|
__metadata("design:type", String)
|
|
35
|
-
], Notification.prototype, "
|
|
40
|
+
], Notification.prototype, "receiver", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, schema_1.Array)(String),
|
|
43
|
+
__metadata("design:type", Array)
|
|
44
|
+
], Notification.prototype, "channels", void 0);
|
|
36
45
|
__decorate([
|
|
37
46
|
(0, schema_1.Property)(),
|
|
38
47
|
__metadata("design:type", Number)
|
|
@@ -40,13 +49,16 @@ __decorate([
|
|
|
40
49
|
__decorate([
|
|
41
50
|
(0, schema_1.Property)(),
|
|
42
51
|
__metadata("design:type", Object)
|
|
43
|
-
], Notification.prototype, "
|
|
52
|
+
], Notification.prototype, "readTimestamp", void 0);
|
|
44
53
|
__decorate([
|
|
45
54
|
(0, schema_1.Any)(),
|
|
46
55
|
__metadata("design:type", Object)
|
|
47
56
|
], Notification.prototype, "data", void 0);
|
|
48
|
-
Notification = __decorate([
|
|
49
|
-
(0, schema_1.Class)()
|
|
50
|
-
], Notification);
|
|
51
57
|
exports.Notification = Notification;
|
|
52
|
-
|
|
58
|
+
let NewNotification = class NewNotification extends (0, models_1.newEntity)(Notification) {
|
|
59
|
+
};
|
|
60
|
+
NewNotification = __decorate([
|
|
61
|
+
(0, schema_1.Class)()
|
|
62
|
+
], NewNotification);
|
|
63
|
+
exports.NewNotification = NewNotification;
|
|
64
|
+
//# sourceMappingURL=notification.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.model.js","sourceRoot":"","sources":["../../../source/notification/models/notification.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAiD;AACjD,yCAAuD;AAEvD,MAAa,YAA0B,SAAQ,eAAM;IACnD;;OAEG;IAEH,QAAQ,CAAS;IAEjB;;OAEG;IAEH,QAAQ,CAAW;IAEnB;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,aAAa,CAAgB;IAE7B;;OAEG;IAEH,IAAI,CAAI;CACT;AA1BC;IAAC,IAAA,iBAAQ,GAAE;;8CACM;AAKjB;IAAC,IAAA,cAAK,EAAC,MAAM,CAAC;;8CACK;AAKnB;IAAC,IAAA,iBAAQ,GAAE;;+CACO;AAKlB;IAAC,IAAA,iBAAQ,GAAE;;mDACkB;AAK7B;IAAC,IAAA,YAAG,GAAE;;0CACE;AA7BV,oCA8BC;AAGM,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,IAAA,kBAAS,EAAC,YAAY,CAAC;CAAI,CAAA;AAAnD,eAAe;IAD3B,IAAA,cAAK,GAAE;GACK,eAAe,CAAoC;AAAnD,0CAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-channel.service.js","sourceRoot":"","sources":["../../source/notification/notification-channel.service.ts"],"names":[],"mappings":";;;AAEA,MAAsB,mBAAmB;CAIxC;AAJD,kDAIC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Repository } from "../orm/repository/repository";
|
|
2
|
+
import type { Notification } from './models';
|
|
3
|
+
export declare class NotificationService<T> {
|
|
4
|
+
private readonly notificationRepository;
|
|
5
|
+
constructor(notificationRepository: Repository<Notification<T>>);
|
|
6
|
+
send(receiver: string, channels: string[], data: T): Promise<Notification<T>>;
|
|
7
|
+
markAsRead(id: string): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NotificationService = void 0;
|
|
13
|
+
const container_1 = require("../container");
|
|
14
|
+
const repository_1 = require("../orm/repository/repository");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
let NotificationService = class NotificationService {
|
|
17
|
+
notificationRepository;
|
|
18
|
+
constructor(notificationRepository) {
|
|
19
|
+
this.notificationRepository = notificationRepository;
|
|
20
|
+
}
|
|
21
|
+
async send(receiver, channels, data) {
|
|
22
|
+
const newNotification = {
|
|
23
|
+
receiver,
|
|
24
|
+
channels,
|
|
25
|
+
timestamp: (0, utils_1.currentTimestamp)(),
|
|
26
|
+
readTimestamp: null,
|
|
27
|
+
data
|
|
28
|
+
};
|
|
29
|
+
return this.notificationRepository.saveAndLoad(newNotification);
|
|
30
|
+
}
|
|
31
|
+
async markAsRead(id) {
|
|
32
|
+
return this.notificationRepository.patch(id, { readTimestamp: (0, utils_1.currentTimestamp)() });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
NotificationService = __decorate([
|
|
36
|
+
(0, container_1.singleton)(),
|
|
37
|
+
__metadata("design:paramtypes", [repository_1.Repository])
|
|
38
|
+
], NotificationService);
|
|
39
|
+
exports.NotificationService = NotificationService;
|
|
40
|
+
//# sourceMappingURL=notification.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../source/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwC;AACxC,6DAAyD;AACzD,oCAA2C;AAIpC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACb,sBAAsB,CAA8B;IAErE,YAAY,sBAAmD;QAC7D,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAgB,EAAE,QAAkB,EAAE,IAAO;QACtD,MAAM,eAAe,GAAoB;YACvC,QAAQ;YACR,QAAQ;YACR,SAAS,EAAE,IAAA,wBAAgB,GAAE;YAC7B,aAAa,EAAE,IAAI;YACnB,IAAI;SACL,CAAC;QAEF,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,IAAA,wBAAgB,GAAE,EAAE,CAAC,CAAC;IACtF,CAAC;CACF,CAAA;AAtBY,mBAAmB;IAD/B,IAAA,qBAAS,GAAE;qCAI0B,uBAAU;GAHnC,mBAAmB,CAsB/B;AAtBY,kDAAmB"}
|
package/orm/decorators.d.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JsonPath } from "../json-path";
|
|
2
|
+
import type { ObjectSchema } from "../schema/types";
|
|
3
|
+
import type { AbstractConstructor, TypedOmit } from "../types";
|
|
4
|
+
import type { EntityDefinition, FieldDefinition, IndexOptions } from './entity-definition.model';
|
|
5
|
+
export type EntityOptions = Partial<Pick<EntityDefinition, 'name' | 'indexes'>>;
|
|
6
|
+
export type FieldOptions = Partial<FieldDefinition>;
|
|
7
|
+
export declare function createEntityDecorator(options: EntityOptions): ClassDecorator;
|
|
8
|
+
export declare function createFieldDecorator(options: FieldOptions): PropertyDecorator;
|
|
9
|
+
export declare function Entity(options?: EntityOptions): ClassDecorator;
|
|
10
|
+
export declare function Field(options?: FieldOptions): PropertyDecorator;
|
|
11
|
+
export declare function NullableField(options?: TypedOmit<FieldOptions, 'nullable'>): PropertyDecorator;
|
|
12
|
+
export declare function PrimaryField(options?: FieldOptions): PropertyDecorator;
|
|
13
|
+
export declare function PrimaryGeneratedField(options?: FieldOptions): PropertyDecorator;
|
|
14
|
+
export declare function CreatedField(options?: TypedOmit<FieldOptions, 'type'>): PropertyDecorator;
|
|
15
|
+
export declare function UpdatedField(options?: TypedOmit<FieldOptions, 'type'>): PropertyDecorator;
|
|
16
|
+
export declare function DeletedField(options?: TypedOmit<FieldOptions, 'type'>): PropertyDecorator;
|
|
17
|
+
export declare function RevisionField(options?: TypedOmit<FieldOptions, 'type'>): PropertyDecorator;
|
|
18
|
+
export declare function Index(fields: string[], options?: IndexOptions): ClassDecorator;
|
|
19
|
+
export declare function Index(options?: IndexOptions): PropertyDecorator;
|
|
20
|
+
type GetEntityDefinitionData = {
|
|
21
|
+
entityOptions?: EntityOptions;
|
|
22
|
+
objectSchema?: ObjectSchema;
|
|
23
|
+
};
|
|
24
|
+
export declare function getEntityDefinition(typeOrData: AbstractConstructor | GetEntityDefinitionData): EntityDefinition;
|
|
25
|
+
export declare function getEntityDefinition(typeOrData: AbstractConstructor | GetEntityDefinitionData, path: JsonPath): EntityDefinition;
|
|
26
|
+
export {};
|
package/orm/decorators.js
CHANGED
|
@@ -1,2 +1,172 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getEntityDefinition = exports.Index = exports.RevisionField = exports.DeletedField = exports.UpdatedField = exports.CreatedField = exports.PrimaryGeneratedField = exports.PrimaryField = exports.NullableField = exports.Field = exports.Entity = exports.createFieldDecorator = exports.createEntityDecorator = void 0;
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const json_path_1 = require("../json-path");
|
|
7
|
+
const reflection_1 = require("../reflection");
|
|
8
|
+
const enumeration_1 = require("../schema/constraints/enumeration");
|
|
9
|
+
const integer_1 = require("../schema/constraints/integer");
|
|
10
|
+
const types_1 = require("../schema/types");
|
|
11
|
+
const utils_1 = require("../schema/utils");
|
|
12
|
+
const array_1 = require("../utils/array/array");
|
|
13
|
+
const distinct_1 = require("../utils/iterable-helpers/distinct");
|
|
14
|
+
const map_1 = require("../utils/iterable-helpers/map");
|
|
15
|
+
const object_1 = require("../utils/object");
|
|
16
|
+
const type_guards_1 = require("../utils/type-guards");
|
|
17
|
+
function getEntityOptions(typeOrMetadata) {
|
|
18
|
+
const metadata = (0, type_guards_1.isFunction)(typeOrMetadata) ? reflection_1.reflectionRegistry.getMetadata(typeOrMetadata) : typeOrMetadata;
|
|
19
|
+
(0, type_guards_1.assert)(metadata?.metadataType == 'type', 'EntityOptions is only available for classes.');
|
|
20
|
+
return metadata.data.tryGet('orm') ?? {};
|
|
21
|
+
}
|
|
22
|
+
function getFieldOptions(typeOrMetadata, property) {
|
|
23
|
+
const metadata = (0, type_guards_1.isFunction)(typeOrMetadata) ? reflection_1.reflectionRegistry.getMetadata(typeOrMetadata)?.properties.get((0, type_guards_1.assertDefinedPass)(property, 'Missing property parameter.')) : typeOrMetadata;
|
|
24
|
+
(0, type_guards_1.assert)(metadata?.metadataType == 'property', 'FieldOptions is only available for properties.');
|
|
25
|
+
return metadata.data.tryGet('orm') ?? {};
|
|
26
|
+
}
|
|
27
|
+
function createEntityDecorator(options) {
|
|
28
|
+
return (0, reflection_1.createClassDecorator)({ data: { orm: options }, mergeData: true });
|
|
29
|
+
}
|
|
30
|
+
exports.createEntityDecorator = createEntityDecorator;
|
|
31
|
+
function createFieldDecorator(options) {
|
|
32
|
+
return (0, reflection_1.createPropertyDecorator)({ data: { orm: options }, mergeData: true });
|
|
33
|
+
}
|
|
34
|
+
exports.createFieldDecorator = createFieldDecorator;
|
|
35
|
+
function Entity(options = {}) {
|
|
36
|
+
return createEntityDecorator(options);
|
|
37
|
+
}
|
|
38
|
+
exports.Entity = Entity;
|
|
39
|
+
function Field(options = {}) {
|
|
40
|
+
return createFieldDecorator(options);
|
|
41
|
+
}
|
|
42
|
+
exports.Field = Field;
|
|
43
|
+
function NullableField(options = {}) {
|
|
44
|
+
return Field({ ...options, nullable: true });
|
|
45
|
+
}
|
|
46
|
+
exports.NullableField = NullableField;
|
|
47
|
+
function PrimaryField(options) {
|
|
48
|
+
return Field({ ...options, primary: true });
|
|
49
|
+
}
|
|
50
|
+
exports.PrimaryField = PrimaryField;
|
|
51
|
+
function PrimaryGeneratedField(options) {
|
|
52
|
+
return PrimaryField({ ...options, generated: true });
|
|
53
|
+
}
|
|
54
|
+
exports.PrimaryGeneratedField = PrimaryGeneratedField;
|
|
55
|
+
function CreatedField(options) {
|
|
56
|
+
return Field({ ...options, type: 'created' });
|
|
57
|
+
}
|
|
58
|
+
exports.CreatedField = CreatedField;
|
|
59
|
+
function UpdatedField(options) {
|
|
60
|
+
return Field({ ...options, type: 'updated', nullable: true });
|
|
61
|
+
}
|
|
62
|
+
exports.UpdatedField = UpdatedField;
|
|
63
|
+
function DeletedField(options) {
|
|
64
|
+
return Field({ ...options, type: 'deleted', nullable: true });
|
|
65
|
+
}
|
|
66
|
+
exports.DeletedField = DeletedField;
|
|
67
|
+
function RevisionField(options) {
|
|
68
|
+
return Field({ ...options, type: 'revision' });
|
|
69
|
+
}
|
|
70
|
+
exports.RevisionField = RevisionField;
|
|
71
|
+
function Index(fieldsOrOptions, optionsOrNothing) {
|
|
72
|
+
const fields = (0, type_guards_1.isArray)(fieldsOrOptions) ? fieldsOrOptions : undefined;
|
|
73
|
+
const options = ((0, type_guards_1.isArray)(fieldsOrOptions) ? optionsOrNothing : fieldsOrOptions) ?? {};
|
|
74
|
+
return (0, reflection_1.createDecorator)({ class: true, property: true }, (data, metadata) => {
|
|
75
|
+
switch (data.type) {
|
|
76
|
+
case 'class':
|
|
77
|
+
const entityOptions = getEntityOptions(metadata);
|
|
78
|
+
(0, type_guards_1.assertArray)(fields, 'Fields can only be specified on class index decorator.');
|
|
79
|
+
Entity({ indexes: [...(entityOptions.indexes ?? []), { fields, ...options }] })(data.constructor);
|
|
80
|
+
break;
|
|
81
|
+
case 'property':
|
|
82
|
+
const fieldOptions = getFieldOptions(metadata);
|
|
83
|
+
Field({ indexes: [...(fieldOptions.indexes ?? []), options] })(data.prototype, data.propertyKey);
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
throw new error_1.NotSupportedError('Only works for classes and properties.');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.Index = Index;
|
|
91
|
+
function getEntityDefinition(typeOrData, path = json_path_1.JsonPath.ROOT) {
|
|
92
|
+
const type = (0, type_guards_1.isFunction)(typeOrData) ? typeOrData : undefined;
|
|
93
|
+
const typeMetadata = (0, type_guards_1.isDefined)(type) ? reflection_1.reflectionRegistry.getMetadata(type) : undefined;
|
|
94
|
+
if ((0, type_guards_1.isUndefined)(typeMetadata)) {
|
|
95
|
+
throw new Error(`Type not found in reflection. Missing decorators? (${path.path})`);
|
|
96
|
+
}
|
|
97
|
+
const entityOptions = (0, type_guards_1.isDefined)(typeMetadata) ? getEntityOptions(typeMetadata) : typeOrData.entityOptions;
|
|
98
|
+
const objectSchema = (0, type_guards_1.isFunction)(typeOrData) ? (0, utils_1.tryGetObjectSchemaFromReflection)(typeOrData) : typeOrData.objectSchema;
|
|
99
|
+
const properties = [...(0, distinct_1.distinct)([...typeMetadata.properties.keys(), ...(0, object_1.objectKeys)(objectSchema?.properties ?? {})])];
|
|
100
|
+
const fieldEntries = (0, map_1.map)(properties, (property) => {
|
|
101
|
+
const propertyName = property.toString();
|
|
102
|
+
const propertyMetadata = typeMetadata.properties.get(propertyName);
|
|
103
|
+
const fieldOptions = (0, type_guards_1.isDefined)(propertyMetadata) ? getFieldOptions(propertyMetadata) : undefined;
|
|
104
|
+
const propertySchema = objectSchema?.properties[propertyName];
|
|
105
|
+
const fieldType = fieldOptions?.type
|
|
106
|
+
?? getFieldTypeFromSchema((0, type_guards_1.assertNotArrayPass)((0, type_guards_1.assertDefinedPass)(propertySchema, 'Could not get field type from schema.'), 'Only a single type is allowed as field type.'), path.add(propertyName));
|
|
107
|
+
return [propertyName, (0, object_1.filterObject)({
|
|
108
|
+
name: fieldOptions?.name,
|
|
109
|
+
type: fieldType,
|
|
110
|
+
primary: fieldOptions?.primary,
|
|
111
|
+
generated: fieldOptions?.generated,
|
|
112
|
+
nullable: fieldOptions?.nullable ?? ((0, types_1.isValueSchema)(propertySchema) ? (((propertySchema.nullable ?? false) || (propertySchema.optional ?? false)) ? true : undefined) : undefined),
|
|
113
|
+
indexes: fieldOptions?.indexes
|
|
114
|
+
}, type_guards_1.isDefined)];
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
name: (0, type_guards_1.assertDefinedPass)(entityOptions?.name ?? type?.name, 'Entity name not defined.'),
|
|
118
|
+
indexes: entityOptions?.indexes,
|
|
119
|
+
fields: Object.fromEntries(fieldEntries)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
exports.getEntityDefinition = getEntityDefinition;
|
|
123
|
+
function getFieldTypeFromSchema(schema, path) {
|
|
124
|
+
if ((0, types_1.isObjectSchema)(schema)) {
|
|
125
|
+
return { nested: getEntityDefinition({ objectSchema: schema }) };
|
|
126
|
+
}
|
|
127
|
+
if ((0, type_guards_1.isFunction)(schema)) {
|
|
128
|
+
return getFieldTypeFromType(schema, path);
|
|
129
|
+
}
|
|
130
|
+
if ((0, type_guards_1.isString)(schema)) {
|
|
131
|
+
throw new error_1.NotSupportedError(`Schema type "${schema}" is not supported as field type.`);
|
|
132
|
+
}
|
|
133
|
+
if ((0, types_1.isDeferredValueType)(schema)) {
|
|
134
|
+
return getFieldTypeFromSchema((0, types_1.resolveValueType)(schema), path);
|
|
135
|
+
}
|
|
136
|
+
if ((0, types_1.isTypeSchema)(schema)) {
|
|
137
|
+
return getFieldTypeFromSchema((0, types_1.resolveValueType)(schema.type), path);
|
|
138
|
+
}
|
|
139
|
+
return getFieldTypeFromValueSchema(schema, path);
|
|
140
|
+
}
|
|
141
|
+
function getFieldTypeFromValueSchema(schema, path) {
|
|
142
|
+
if ((0, type_guards_1.isDefined)(schema.valueConstraints)) {
|
|
143
|
+
const constraints = (0, array_1.toArray)(schema.valueConstraints ?? []);
|
|
144
|
+
const enumerationConstraint = constraints.find((constraint) => constraint instanceof enumeration_1.EnumerationConstraint);
|
|
145
|
+
const integerConstraint = constraints.find((constraint) => constraint instanceof integer_1.IntegerConstraint);
|
|
146
|
+
if ((0, type_guards_1.isDefined)(enumerationConstraint)) {
|
|
147
|
+
return { enumeration: enumerationConstraint.enumeration };
|
|
148
|
+
}
|
|
149
|
+
if ((0, type_guards_1.isDefined)(integerConstraint)) {
|
|
150
|
+
return 'integer';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const innerSchemas = (0, array_1.toArray)(schema.schema);
|
|
154
|
+
(0, type_guards_1.assert)(innerSchemas.length == 1, `Could not get field type from schema type as exactly 1 schema is required, but ${innerSchemas.length} were given.`);
|
|
155
|
+
const innerSchema = innerSchemas[0];
|
|
156
|
+
return getFieldTypeFromSchema(innerSchema, path);
|
|
157
|
+
}
|
|
158
|
+
function getFieldTypeFromType(type, path) {
|
|
159
|
+
switch (type) {
|
|
160
|
+
case String:
|
|
161
|
+
return 'string';
|
|
162
|
+
case Number:
|
|
163
|
+
return 'float';
|
|
164
|
+
case Boolean:
|
|
165
|
+
return 'boolean';
|
|
166
|
+
case Date:
|
|
167
|
+
return 'date-time';
|
|
168
|
+
default:
|
|
169
|
+
return { nested: getEntityDefinition(type, path) };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
2
172
|
//# sourceMappingURL=decorators.js.map
|
package/orm/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../source/orm/decorators.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../source/orm/decorators.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAEzD,oCAA4C;AAC5C,4CAAuC;AAEvC,8CAAkH;AAClH,mEAAyE;AACzE,2DAAiE;AAGjE,2CAAoH;AACpH,2CAAkE;AAElE,gDAA8C;AAC9C,iEAA6D;AAC7D,uDAAmD;AACnD,4CAA0D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AAiB,CAAC,EAAE;YAChC,OAAO,SAAS,CAAC;SAClB;KACF;IAED,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAA,oBAAM,EAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE,kFAAkF,YAAY,CAAC,MAAM,cAAc,CAAC,CAAC;IACtJ,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAE,CAAC;IAErC,OAAO,sBAAsB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAyB,EAAE,IAAc;IACrE,QAAQ,IAAI,EAAE;QACZ,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAElB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC;QAEjB,KAAK,OAAO;YACV,OAAO,SAAS,CAAC;QAEnB,KAAK,IAAI;YACP,OAAO,WAAW,CAAC;QAErB;YACE,OAAO,EAAE,MAAM,EAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;KACtD;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AbstractConstructor, Enumeration, Paths, Record } from "../types";
|
|
2
|
+
export type FieldType = SpecialFieldType | 'string' | 'integer' | 'float' | 'boolean' | 'date-time' | 'date' | 'time' | 'json' | {
|
|
3
|
+
nested: EntityDefinition;
|
|
4
|
+
} | {
|
|
5
|
+
enumeration: Enumeration;
|
|
6
|
+
};
|
|
7
|
+
export type SpecialFieldType = 'created' | 'updated' | 'deleted' | 'revision';
|
|
8
|
+
export type IndexOptions = {
|
|
9
|
+
unique?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type IndexDirection = 1 | -1 | 'asc' | 'desc';
|
|
12
|
+
export type EntityIndexDefinition<T = any> = IndexOptions & {
|
|
13
|
+
fields: (Paths<T> | [Paths<T>, IndexDirection])[] | {
|
|
14
|
+
[P in Paths<T>]?: IndexDirection;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type FieldIndexDefinition = IndexOptions;
|
|
18
|
+
export type FieldDefinition = {
|
|
19
|
+
/** type of field in database */
|
|
20
|
+
type: FieldType;
|
|
21
|
+
/** type of property in object (used for conversion) */
|
|
22
|
+
propertyType?: AbstractConstructor | 'numeric-date';
|
|
23
|
+
/** field name in database */
|
|
24
|
+
name?: string;
|
|
25
|
+
primary?: boolean;
|
|
26
|
+
generated?: boolean;
|
|
27
|
+
nullable?: boolean;
|
|
28
|
+
indexes?: FieldIndexDefinition[];
|
|
29
|
+
};
|
|
30
|
+
export type EntityDefinition = {
|
|
31
|
+
name: string;
|
|
32
|
+
fields: Record<string, FieldDefinition>;
|
|
33
|
+
indexes?: EntityIndexDefinition[];
|
|
34
|
+
};
|
|
35
|
+
export type NormalizedEntityDefinition = {
|
|
36
|
+
name: string;
|
|
37
|
+
fields: Record<string, NormalizedFieldDefinition>;
|
|
38
|
+
fieldsEntries: (readonly [string, NormalizedFieldDefinition])[];
|
|
39
|
+
indexes: EntityIndexDefinition[];
|
|
40
|
+
};
|
|
41
|
+
export type NormalizedFieldDefinition = {
|
|
42
|
+
type: FieldType;
|
|
43
|
+
propertyType?: AbstractConstructor | 'numeric-date' | 'numeric-time';
|
|
44
|
+
name: string;
|
|
45
|
+
primary: boolean;
|
|
46
|
+
generated: boolean;
|
|
47
|
+
nullable: boolean;
|
|
48
|
+
indexes: FieldIndexDefinition[];
|
|
49
|
+
};
|
|
50
|
+
export declare function normalizeEntityDefinition(definition: EntityDefinition): NormalizedEntityDefinition;
|
|
51
|
+
export declare function normalizeFieldDefinition(field: string, definition: FieldDefinition): NormalizedFieldDefinition;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeFieldDefinition = exports.normalizeEntityDefinition = void 0;
|
|
4
|
+
const object_1 = require("../utils/object");
|
|
5
|
+
function normalizeEntityDefinition(definition) {
|
|
6
|
+
const fieldsEntries = (0, object_1.objectEntries)(definition.fields).map(([field, fieldDefinition]) => [field, normalizeFieldDefinition(field, fieldDefinition)]);
|
|
7
|
+
return {
|
|
8
|
+
name: definition.name,
|
|
9
|
+
fields: Object.fromEntries(fieldsEntries),
|
|
10
|
+
fieldsEntries,
|
|
11
|
+
indexes: definition.indexes ?? []
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.normalizeEntityDefinition = normalizeEntityDefinition;
|
|
15
|
+
function normalizeFieldDefinition(field, definition) {
|
|
16
|
+
return {
|
|
17
|
+
type: definition.type,
|
|
18
|
+
propertyType: definition.propertyType,
|
|
19
|
+
name: definition.name ?? field,
|
|
20
|
+
primary: definition.primary ?? false,
|
|
21
|
+
generated: definition.generated ?? false,
|
|
22
|
+
nullable: definition.nullable ?? false,
|
|
23
|
+
indexes: definition.indexes ?? []
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.normalizeFieldDefinition = normalizeFieldDefinition;
|
|
27
|
+
//# sourceMappingURL=entity-definition.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-definition.model.js","sourceRoot":"","sources":["../../source/orm/entity-definition.model.ts"],"names":[],"mappings":";;;AACA,4CAA+C;AAyD/C,SAAgB,yBAAyB,CAAC,UAA4B;IACpE,MAAM,aAAa,GAAG,IAAA,sBAAa,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,wBAAwB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAU,CAAC,CAAC;IAE7J,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC;QACzC,aAAa;QACb,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;KAClC,CAAC;AACJ,CAAC;AATD,8DASC;AAED,SAAgB,wBAAwB,CAAC,KAAa,EAAE,UAA2B;IACjF,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK;QAC9B,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,KAAK;QACpC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,KAAK;QACxC,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,KAAK;QACtC,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;KAClC,CAAC;AACJ,CAAC;AAVD,4DAUC"}
|
package/orm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './models';
|
package/orm/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./models"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/orm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/orm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ObjectLiteral, PartialProperty, Type } from "../../types";
|
|
2
|
+
export type Id = string | number;
|
|
3
|
+
export declare abstract class EntityMetadata {
|
|
4
|
+
revision: number;
|
|
5
|
+
created: Date;
|
|
6
|
+
updated?: Date;
|
|
7
|
+
deleted?: Date;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class Entity {
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class EntityWithMetadata extends Entity {
|
|
13
|
+
metadata: EntityMetadata;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class NewEntityBase {
|
|
16
|
+
id?: string;
|
|
17
|
+
}
|
|
18
|
+
export type NewEntity<T> = T extends Entity ? PartialProperty<T, 'id'> : T;
|
|
19
|
+
export type MaybeNewEntity<T> = T | NewEntity<T>;
|
|
20
|
+
export declare function newEntity<T extends ObjectLiteral>(type: Type<T>): Type<NewEntity<T>>;
|
|
21
|
+
export declare function toEntity<T extends Entity>(entity: T | NewEntity<T>): T;
|
|
22
|
+
export declare function isId(value: any): value is Id;
|