@things-factory/notification 6.1.17 → 6.1.22
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/client/{bootstrap.js → bootstrap.ts} +13 -9
- package/client/pages/notification/notification-list-page.ts +267 -0
- package/client/pages/notification-rule/notification-rule-importer.ts +93 -0
- package/client/pages/notification-rule/notification-rule-list-page.ts +395 -0
- package/client/route.ts +10 -0
- package/client/tsconfig.json +13 -0
- package/client/viewparts/notification-badge.ts +58 -0
- package/client/viewparts/notification-item.ts +242 -0
- package/client/viewparts/notification-list.ts +171 -0
- package/client/viewparts/notification-sender.ts +126 -0
- package/client/viewparts/{notification-setting-let.js → notification-setting-let.ts} +48 -52
- package/dist-client/actions/notification-fcm.d.ts +7 -0
- package/dist-client/actions/notification-fcm.js +125 -0
- package/dist-client/actions/notification-fcm.js.map +1 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +112 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +5 -0
- package/dist-client/index.js +6 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/notification/notification-list-page.d.ts +49 -0
- package/dist-client/pages/notification/notification-list-page.js +262 -0
- package/dist-client/pages/notification/notification-list-page.js.map +1 -0
- package/dist-client/pages/notification-rule/notification-rule-importer.d.ts +22 -0
- package/dist-client/pages/notification-rule/notification-rule-importer.js +100 -0
- package/dist-client/pages/notification-rule/notification-rule-importer.js.map +1 -0
- package/dist-client/pages/notification-rule/notification-rule-list-page.d.ts +62 -0
- package/dist-client/pages/notification-rule/notification-rule-list-page.js +380 -0
- package/dist-client/pages/notification-rule/notification-rule-list-page.js.map +1 -0
- package/dist-client/reducers/notification.d.ts +8 -0
- package/dist-client/reducers/notification.js +22 -0
- package/dist-client/reducers/notification.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +11 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/viewparts/notification-badge.d.ts +15 -0
- package/dist-client/viewparts/notification-badge.js +61 -0
- package/dist-client/viewparts/notification-badge.js.map +1 -0
- package/dist-client/viewparts/notification-item.d.ts +16 -0
- package/dist-client/viewparts/notification-item.js +249 -0
- package/dist-client/viewparts/notification-item.js.map +1 -0
- package/dist-client/viewparts/notification-list.d.ts +20 -0
- package/dist-client/viewparts/notification-list.js +160 -0
- package/dist-client/viewparts/notification-list.js.map +1 -0
- package/dist-client/viewparts/notification-sender.d.ts +13 -0
- package/dist-client/viewparts/notification-sender.js +122 -0
- package/dist-client/viewparts/notification-sender.js.map +1 -0
- package/dist-client/viewparts/notification-setting-let.d.ts +20 -0
- package/dist-client/viewparts/notification-setting-let.js +193 -0
- package/dist-client/viewparts/notification-setting-let.js.map +1 -0
- package/dist-server/service/index.js +10 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/notification/index.js +6 -3
- package/dist-server/service/notification/index.js.map +1 -1
- package/dist-server/service/notification/notification-mutation.js +110 -0
- package/dist-server/service/notification/notification-mutation.js.map +1 -0
- package/dist-server/service/notification/notification-query.js +109 -0
- package/dist-server/service/notification/notification-query.js.map +1 -0
- package/dist-server/service/notification/notification-subscription.js +45 -0
- package/dist-server/service/notification/notification-subscription.js.map +1 -0
- package/dist-server/service/notification/notification-type.js +82 -0
- package/dist-server/service/notification/notification-type.js.map +1 -0
- package/dist-server/service/notification/notification.js +81 -8
- package/dist-server/service/notification/notification.js.map +1 -1
- package/dist-server/service/notification-rule/event-subscriber.js +21 -0
- package/dist-server/service/notification-rule/event-subscriber.js.map +1 -0
- package/dist-server/service/notification-rule/index.js +12 -0
- package/dist-server/service/notification-rule/index.js.map +1 -0
- package/dist-server/service/notification-rule/notification-rule-history.js +146 -0
- package/dist-server/service/notification-rule/notification-rule-history.js.map +1 -0
- package/dist-server/service/notification-rule/notification-rule-mutation.js +170 -0
- package/dist-server/service/notification-rule/notification-rule-mutation.js.map +1 -0
- package/dist-server/service/notification-rule/notification-rule-query.js +97 -0
- package/dist-server/service/notification-rule/notification-rule-query.js.map +1 -0
- package/dist-server/service/notification-rule/notification-rule-type.js +102 -0
- package/dist-server/service/notification-rule/notification-rule-type.js.map +1 -0
- package/dist-server/service/notification-rule/notification-rule.js +146 -0
- package/dist-server/service/notification-rule/notification-rule.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/notification/noti-box.md +160 -0
- package/helps/notification/noti-rule.md +160 -0
- package/helps/notification/notibox.md +160 -0
- package/package.json +15 -12
- package/server/service/index.ts +14 -0
- package/server/service/notification/index.ts +6 -3
- package/server/service/notification/notification-mutation.ts +119 -0
- package/server/service/notification/notification-query.ts +70 -0
- package/server/service/notification/{notification-resolver.ts → notification-subscription.ts} +4 -4
- package/server/service/notification/notification-type.ts +55 -0
- package/server/service/notification/notification.ts +87 -14
- package/server/service/notification-rule/event-subscriber.ts +20 -0
- package/server/service/notification-rule/index.ts +9 -0
- package/server/service/notification-rule/notification-rule-history.ts +130 -0
- package/server/service/notification-rule/notification-rule-mutation.ts +203 -0
- package/server/service/notification-rule/notification-rule-query.ts +62 -0
- package/server/service/notification-rule/notification-rule-type.ts +71 -0
- package/server/service/notification-rule/notification-rule.ts +125 -0
- package/server/tsconfig.json +9 -0
- package/things-factory.config.js +7 -1
- package/client/viewparts/notification-badge.js +0 -63
- package/client/viewparts/notification-item.js +0 -250
- package/client/viewparts/notification-list.js +0 -177
- package/client/viewparts/notification-sender.js +0 -128
- package/tsconfig.json +0 -9
- /package/client/actions/{notification-fcm.js → notification-fcm.ts} +0 -0
- /package/client/{index.js → index.ts} +0 -0
- /package/client/reducers/{notification.js → notification.ts} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationRuleHistory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const typeorm_history_1 = require("@operato/typeorm-history");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const env_1 = require("@things-factory/env");
|
|
10
|
+
const shell_1 = require("@things-factory/shell");
|
|
11
|
+
const notification_rule_1 = require("./notification-rule");
|
|
12
|
+
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
|
13
|
+
const DATABASE_TYPE = ORMCONFIG.type;
|
|
14
|
+
let NotificationRuleHistory = class NotificationRuleHistory {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.version = 1;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
tslib_1.__decorate([
|
|
20
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
21
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
22
|
+
tslib_1.__metadata("design:type", String)
|
|
23
|
+
], NotificationRuleHistory.prototype, "id", void 0);
|
|
24
|
+
tslib_1.__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ nullable: true, default: 1 }),
|
|
26
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
27
|
+
tslib_1.__metadata("design:type", Number)
|
|
28
|
+
], NotificationRuleHistory.prototype, "version", void 0);
|
|
29
|
+
tslib_1.__decorate([
|
|
30
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
33
|
+
], NotificationRuleHistory.prototype, "domain", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, typeorm_1.RelationId)((notificationRule) => notificationRule.domain),
|
|
36
|
+
tslib_1.__metadata("design:type", String)
|
|
37
|
+
], NotificationRuleHistory.prototype, "domainId", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, typeorm_1.Column)(),
|
|
40
|
+
(0, type_graphql_1.Field)(),
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
42
|
+
], NotificationRuleHistory.prototype, "name", void 0);
|
|
43
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
45
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
46
|
+
tslib_1.__metadata("design:type", String)
|
|
47
|
+
], NotificationRuleHistory.prototype, "description", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
50
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
52
|
+
], NotificationRuleHistory.prototype, "state", void 0);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
56
|
+
tslib_1.__metadata("design:type", String)
|
|
57
|
+
], NotificationRuleHistory.prototype, "title", void 0);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
60
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
61
|
+
tslib_1.__metadata("design:type", String)
|
|
62
|
+
], NotificationRuleHistory.prototype, "body", void 0);
|
|
63
|
+
tslib_1.__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
65
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
66
|
+
tslib_1.__metadata("design:type", String)
|
|
67
|
+
], NotificationRuleHistory.prototype, "url", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
70
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
71
|
+
tslib_1.__metadata("design:type", String)
|
|
72
|
+
], NotificationRuleHistory.prototype, "thumbnail", void 0);
|
|
73
|
+
tslib_1.__decorate([
|
|
74
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
75
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
76
|
+
tslib_1.__metadata("design:type", String)
|
|
77
|
+
], NotificationRuleHistory.prototype, "channels", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
80
|
+
(0, type_graphql_1.Field)(type => [notification_rule_1.RecipientItem], { nullable: true, description: 'notification recipients.' }),
|
|
81
|
+
tslib_1.__metadata("design:type", String)
|
|
82
|
+
], NotificationRuleHistory.prototype, "recipients", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
85
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
86
|
+
tslib_1.__metadata("design:type", Date)
|
|
87
|
+
], NotificationRuleHistory.prototype, "createdAt", void 0);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
90
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
91
|
+
tslib_1.__metadata("design:type", Date)
|
|
92
|
+
], NotificationRuleHistory.prototype, "updatedAt", void 0);
|
|
93
|
+
tslib_1.__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
95
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
96
|
+
tslib_1.__metadata("design:type", Date)
|
|
97
|
+
], NotificationRuleHistory.prototype, "deletedAt", void 0);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
100
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
101
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
102
|
+
], NotificationRuleHistory.prototype, "creator", void 0);
|
|
103
|
+
tslib_1.__decorate([
|
|
104
|
+
(0, typeorm_1.RelationId)((notificationRule) => notificationRule.creator),
|
|
105
|
+
tslib_1.__metadata("design:type", String)
|
|
106
|
+
], NotificationRuleHistory.prototype, "creatorId", void 0);
|
|
107
|
+
tslib_1.__decorate([
|
|
108
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
109
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
110
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
111
|
+
], NotificationRuleHistory.prototype, "updater", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, typeorm_1.RelationId)((notificationRule) => notificationRule.updater),
|
|
114
|
+
tslib_1.__metadata("design:type", String)
|
|
115
|
+
], NotificationRuleHistory.prototype, "updaterId", void 0);
|
|
116
|
+
tslib_1.__decorate([
|
|
117
|
+
(0, typeorm_history_1.HistoryOriginalIdColumn)(),
|
|
118
|
+
tslib_1.__metadata("design:type", String)
|
|
119
|
+
], NotificationRuleHistory.prototype, "originalId", void 0);
|
|
120
|
+
tslib_1.__decorate([
|
|
121
|
+
(0, typeorm_history_1.HistoryActionColumn)({
|
|
122
|
+
nullable: false,
|
|
123
|
+
type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
124
|
+
? 'enum'
|
|
125
|
+
: DATABASE_TYPE == 'oracle'
|
|
126
|
+
? 'varchar2'
|
|
127
|
+
: 'smallint',
|
|
128
|
+
enum: typeorm_history_1.HistoryActionType
|
|
129
|
+
}),
|
|
130
|
+
tslib_1.__metadata("design:type", String)
|
|
131
|
+
], NotificationRuleHistory.prototype, "action", void 0);
|
|
132
|
+
NotificationRuleHistory = tslib_1.__decorate([
|
|
133
|
+
(0, typeorm_1.Entity)(),
|
|
134
|
+
(0, typeorm_1.Index)('ix_notification-rule_history_0', (notificationRuleHistory) => [
|
|
135
|
+
notificationRuleHistory.originalId,
|
|
136
|
+
notificationRuleHistory.version
|
|
137
|
+
], { unique: true }),
|
|
138
|
+
(0, typeorm_1.Index)('ix_notification-rule_history_1', (notificationRuleHistory) => [
|
|
139
|
+
notificationRuleHistory.domain,
|
|
140
|
+
notificationRuleHistory.originalId,
|
|
141
|
+
notificationRuleHistory.version
|
|
142
|
+
], { unique: true }),
|
|
143
|
+
(0, type_graphql_1.ObjectType)({ description: 'History Entity of NotificationRule' })
|
|
144
|
+
], NotificationRuleHistory);
|
|
145
|
+
exports.NotificationRuleHistory = NotificationRuleHistory;
|
|
146
|
+
//# sourceMappingURL=notification-rule-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-rule-history.js","sourceRoot":"","sources":["../../../server/service/notification-rule/notification-rule-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAA8F;AAE9F,8DAKiC;AACjC,yDAAsD;AACtD,6CAA4C;AAC5C,iDAA8C;AAE9C,2DAA6F;AAE7F,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAqB7B,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAA7B;QAOL,YAAO,GAAY,CAAC,CAAA;IAqFtB,CAAC;CAAA,CAAA;AA3FC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;mDACC;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wDACN;AAEpB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,cAAM;uDAAA;AAEf;IAAC,IAAA,oBAAU,EAAC,CAAC,gBAAk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E,KAAK;QACf,IAAI,EACF,aAAa,IAAI,UAAU,IAAI,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,SAAS;YACnF,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,aAAa,IAAI,QAAQ;gBAC3B,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU;QAChB,IAAI,EAAE,mCAAiB;KACxB,CAAC;;uDAC+B;AA3FtB,uBAAuB;IAnBnC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,gCAAgC,EAChC,CAAC,uBAAgD,EAAE,EAAE,CAAC;QACpD,uBAAuB,CAAC,UAAU;QAClC,uBAAuB,CAAC,OAAO;KAChC,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,gCAAgC,EAChC,CAAC,uBAAgD,EAAE,EAAE,CAAC;QACpD,uBAAuB,CAAC,MAAM;QAC9B,uBAAuB,CAAC,UAAU;QAClC,uBAAuB,CAAC,OAAO;KAChC,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;GACrD,uBAAuB,CA4FnC;AA5FY,0DAAuB","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { Role, User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { NotificationRule, NotificationRuleStatus, RecipientItem } from './notification-rule'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_notification-rule_history_0',\n (notificationRuleHistory: NotificationRuleHistory) => [\n notificationRuleHistory.originalId,\n notificationRuleHistory.version\n ],\n { unique: true }\n)\n@Index(\n 'ix_notification-rule_history_1',\n (notificationRuleHistory: NotificationRuleHistory) => [\n notificationRuleHistory.domain,\n notificationRuleHistory.originalId,\n notificationRuleHistory.version\n ],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of NotificationRule' })\nexport class NotificationRuleHistory implements HistoryEntityInterface<NotificationRule> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((notificationRule: NotificationRule) => notificationRule.domain)\n domainId?: string\n\n @Column()\n @Field()\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n state?: NotificationRuleStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n title: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n body: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n url: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n thumbnail: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n channels: string\n\n @Column('simple-json', { nullable: true })\n @Field(type => [RecipientItem], { nullable: true, description: 'notification recipients.' })\n recipients: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((notificationRule: NotificationRule) => notificationRule.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((notificationRule: NotificationRule) => notificationRule.updater)\n updaterId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: HistoryActionType\n })\n public action!: HistoryActionType\n}\n"]}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationRuleMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
8
|
+
const notification_rule_1 = require("./notification-rule");
|
|
9
|
+
const notification_rule_type_1 = require("./notification-rule-type");
|
|
10
|
+
let NotificationRuleMutation = class NotificationRuleMutation {
|
|
11
|
+
async createNotificationRule(notificationRule, context) {
|
|
12
|
+
const { domain, user, tx } = context.state;
|
|
13
|
+
const result = await tx.getRepository(notification_rule_1.NotificationRule).save(Object.assign(Object.assign({}, notificationRule), { domain, creator: user, updater: user }));
|
|
14
|
+
if (notificationRule.thumbnail) {
|
|
15
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
16
|
+
attachment: {
|
|
17
|
+
file: notificationRule.thumbnail,
|
|
18
|
+
refType: notification_rule_1.NotificationRule.name,
|
|
19
|
+
refBy: result.id
|
|
20
|
+
}
|
|
21
|
+
}, context);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
async updateNotificationRule(id, patch, context) {
|
|
26
|
+
const { domain, user, tx } = context.state;
|
|
27
|
+
const repository = tx.getRepository(notification_rule_1.NotificationRule);
|
|
28
|
+
const notificationRule = await repository.findOne({
|
|
29
|
+
where: { domain: { id: domain.id }, id }
|
|
30
|
+
});
|
|
31
|
+
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, notificationRule), patch), { updater: user }));
|
|
32
|
+
if (patch.thumbnail) {
|
|
33
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
34
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
35
|
+
attachment: {
|
|
36
|
+
file: patch.thumbnail,
|
|
37
|
+
refType: notification_rule_1.NotificationRule.name,
|
|
38
|
+
refBy: result.id
|
|
39
|
+
}
|
|
40
|
+
}, context);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
async updateMultipleNotificationRule(patches, context) {
|
|
45
|
+
const { domain, user, tx } = context.state;
|
|
46
|
+
let results = [];
|
|
47
|
+
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
48
|
+
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
49
|
+
const notificationRuleRepo = tx.getRepository(notification_rule_1.NotificationRule);
|
|
50
|
+
if (_createRecords.length > 0) {
|
|
51
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
52
|
+
const newRecord = _createRecords[i];
|
|
53
|
+
const result = await notificationRuleRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
54
|
+
if (newRecord.thumbnail) {
|
|
55
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
56
|
+
attachment: {
|
|
57
|
+
file: newRecord.thumbnail,
|
|
58
|
+
refType: notification_rule_1.NotificationRule.name,
|
|
59
|
+
refBy: result.id
|
|
60
|
+
}
|
|
61
|
+
}, context);
|
|
62
|
+
}
|
|
63
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (_updateRecords.length > 0) {
|
|
67
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
68
|
+
const updateRecord = _updateRecords[i];
|
|
69
|
+
const notificationRule = await notificationRuleRepo.findOneBy({ id: updateRecord.id });
|
|
70
|
+
const result = await notificationRuleRepo.save(Object.assign(Object.assign(Object.assign({}, notificationRule), updateRecord), { updater: user }));
|
|
71
|
+
if (updateRecord.thumbnail) {
|
|
72
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
73
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
74
|
+
attachment: {
|
|
75
|
+
file: updateRecord.thumbnail,
|
|
76
|
+
refType: notification_rule_1.NotificationRule.name,
|
|
77
|
+
refBy: result.id
|
|
78
|
+
}
|
|
79
|
+
}, context);
|
|
80
|
+
}
|
|
81
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
async deleteNotificationRule(id, context) {
|
|
87
|
+
const { domain, tx } = context.state;
|
|
88
|
+
await tx.getRepository(notification_rule_1.NotificationRule).delete({ domain: { id: domain.id }, id });
|
|
89
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
async deleteNotificationRules(ids, context) {
|
|
93
|
+
const { domain, tx } = context.state;
|
|
94
|
+
await tx.getRepository(notification_rule_1.NotificationRule).delete({
|
|
95
|
+
domain: { id: domain.id },
|
|
96
|
+
id: (0, typeorm_1.In)(ids)
|
|
97
|
+
});
|
|
98
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
async importNotificationRules(notificationRules, context) {
|
|
102
|
+
const { domain, tx } = context.state;
|
|
103
|
+
await Promise.all(notificationRules.map(async (notificationRule) => {
|
|
104
|
+
const createdNotificationRule = await tx
|
|
105
|
+
.getRepository(notification_rule_1.NotificationRule)
|
|
106
|
+
.save(Object.assign({ domain }, notificationRule));
|
|
107
|
+
}));
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
tslib_1.__decorate([
|
|
112
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
113
|
+
(0, type_graphql_1.Mutation)(returns => notification_rule_1.NotificationRule, { description: 'To create new NotificationRule' }),
|
|
114
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('notificationRule')),
|
|
115
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
116
|
+
tslib_1.__metadata("design:type", Function),
|
|
117
|
+
tslib_1.__metadata("design:paramtypes", [notification_rule_type_1.NewNotificationRule, Object]),
|
|
118
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
119
|
+
], NotificationRuleMutation.prototype, "createNotificationRule", null);
|
|
120
|
+
tslib_1.__decorate([
|
|
121
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
122
|
+
(0, type_graphql_1.Mutation)(returns => notification_rule_1.NotificationRule, { description: 'To modify NotificationRule information' }),
|
|
123
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
124
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
125
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
126
|
+
tslib_1.__metadata("design:type", Function),
|
|
127
|
+
tslib_1.__metadata("design:paramtypes", [String, notification_rule_type_1.NotificationRulePatch, Object]),
|
|
128
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
129
|
+
], NotificationRuleMutation.prototype, "updateNotificationRule", null);
|
|
130
|
+
tslib_1.__decorate([
|
|
131
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
132
|
+
(0, type_graphql_1.Mutation)(returns => [notification_rule_1.NotificationRule], { description: "To modify multiple NotificationRules' information" }),
|
|
133
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [notification_rule_type_1.NotificationRulePatch])),
|
|
134
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
135
|
+
tslib_1.__metadata("design:type", Function),
|
|
136
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
137
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
138
|
+
], NotificationRuleMutation.prototype, "updateMultipleNotificationRule", null);
|
|
139
|
+
tslib_1.__decorate([
|
|
140
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
141
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete NotificationRule' }),
|
|
142
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
143
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
144
|
+
tslib_1.__metadata("design:type", Function),
|
|
145
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
146
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
147
|
+
], NotificationRuleMutation.prototype, "deleteNotificationRule", null);
|
|
148
|
+
tslib_1.__decorate([
|
|
149
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
150
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple NotificationRules' }),
|
|
151
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
152
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
153
|
+
tslib_1.__metadata("design:type", Function),
|
|
154
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
155
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
156
|
+
], NotificationRuleMutation.prototype, "deleteNotificationRules", null);
|
|
157
|
+
tslib_1.__decorate([
|
|
158
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
159
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple NotificationRules' }),
|
|
160
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('notificationRules', type => [notification_rule_type_1.NotificationRulePatch])),
|
|
161
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
162
|
+
tslib_1.__metadata("design:type", Function),
|
|
163
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
164
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
165
|
+
], NotificationRuleMutation.prototype, "importNotificationRules", null);
|
|
166
|
+
NotificationRuleMutation = tslib_1.__decorate([
|
|
167
|
+
(0, type_graphql_1.Resolver)(notification_rule_1.NotificationRule)
|
|
168
|
+
], NotificationRuleMutation);
|
|
169
|
+
exports.NotificationRuleMutation = NotificationRuleMutation;
|
|
170
|
+
//# sourceMappingURL=notification-rule-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-rule-mutation.js","sourceRoot":"","sources":["../../../server/service/notification-rule/notification-rule-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,2DAAsD;AACtD,qEAAqF;AAG9E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAG7B,AAAN,KAAK,CAAC,sBAAsB,CACD,gBAAqC,EACvD,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAC,IAAI,iCACvD,gBAAgB,KACnB,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,gBAAgB,CAAC,SAAS,EAAE;YAC9B,MAAM,IAAA,kCAAgB,EACpB,IAAI,EACJ;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB,CAAC,SAAS;oBAChC,OAAO,EAAE,oCAAgB,CAAC,IAAI;oBAC9B,KAAK,EAAE,MAAM,CAAC,EAAE;iBACjB;aACF,EACD,OAAO,CACR,CAAA;SACF;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,sBAAsB,CACf,EAAU,EACP,KAA4B,EACnC,OAAwB;QAE/B,MAA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Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { NotificationRule } from './notification-rule'\nimport { NewNotificationRule, NotificationRulePatch } from './notification-rule-type'\n\n@Resolver(NotificationRule)\nexport class NotificationRuleMutation {\n @Directive('@transaction')\n @Mutation(returns => NotificationRule, { description: 'To create new NotificationRule' })\n async createNotificationRule(\n @Arg('notificationRule') notificationRule: NewNotificationRule,\n @Ctx() context: ResolverContext\n ): Promise<NotificationRule> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(NotificationRule).save({\n ...notificationRule,\n domain,\n creator: user,\n updater: user\n })\n\n if (notificationRule.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: notificationRule.thumbnail,\n refType: NotificationRule.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => NotificationRule, { description: 'To modify NotificationRule information' })\n async updateNotificationRule(\n @Arg('id') id: string,\n @Arg('patch') patch: NotificationRulePatch,\n @Ctx() context: ResolverContext\n ): Promise<NotificationRule> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(NotificationRule)\n const notificationRule = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...notificationRule,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: NotificationRule.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [NotificationRule], { description: \"To modify multiple NotificationRules' information\" })\n async updateMultipleNotificationRule(\n @Arg('patches', type => [NotificationRulePatch]) patches: NotificationRulePatch[],\n @Ctx() context: ResolverContext\n ): Promise<NotificationRule[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const notificationRuleRepo = tx.getRepository(NotificationRule)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await notificationRuleRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: NotificationRule.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const notificationRule = await notificationRuleRepo.findOneBy({ id: updateRecord.id })\n\n const result = await notificationRuleRepo.save({\n ...notificationRule,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.thumbnail,\n refType: NotificationRule.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete NotificationRule' })\n async deleteNotificationRule(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(NotificationRule).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple NotificationRules' })\n async deleteNotificationRules(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(NotificationRule).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple NotificationRules' })\n async importNotificationRules(\n @Arg('notificationRules', type => [NotificationRulePatch]) notificationRules: NotificationRulePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n notificationRules.map(async (notificationRule: NotificationRulePatch) => {\n const createdNotificationRule: NotificationRule = await tx\n .getRepository(NotificationRule)\n .save({ domain, ...notificationRule })\n })\n )\n\n return true\n }\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationRuleQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const notification_rule_1 = require("./notification-rule");
|
|
10
|
+
const notification_rule_type_1 = require("./notification-rule-type");
|
|
11
|
+
let NotificationRuleQuery = class NotificationRuleQuery {
|
|
12
|
+
async notificationRule(id, context) {
|
|
13
|
+
const { domain } = context.state;
|
|
14
|
+
return await (0, shell_1.getRepository)(notification_rule_1.NotificationRule).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async notificationRules(params, context) {
|
|
19
|
+
const { domain } = context.state;
|
|
20
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
21
|
+
domain,
|
|
22
|
+
params,
|
|
23
|
+
repository: await (0, shell_1.getRepository)(notification_rule_1.NotificationRule),
|
|
24
|
+
searchables: ['name', 'description']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async thumbnail(notificationRule) {
|
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
31
|
+
where: {
|
|
32
|
+
domain: { id: notificationRule.domainId },
|
|
33
|
+
refType: notification_rule_1.NotificationRule.name,
|
|
34
|
+
refBy: notificationRule.id
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
|
38
|
+
}
|
|
39
|
+
async domain(notificationRule) {
|
|
40
|
+
return notificationRule.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: notificationRule.domainId }));
|
|
41
|
+
}
|
|
42
|
+
async updater(notificationRule) {
|
|
43
|
+
return notificationRule.updaterId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: notificationRule.updaterId }));
|
|
44
|
+
}
|
|
45
|
+
async creator(notificationRule) {
|
|
46
|
+
return notificationRule.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: notificationRule.creatorId }));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, type_graphql_1.Query)(returns => notification_rule_1.NotificationRule, { nullable: true, description: 'To fetch a NotificationRule' }),
|
|
51
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
52
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
|
+
tslib_1.__metadata("design:type", Function),
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
55
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
56
|
+
], NotificationRuleQuery.prototype, "notificationRule", null);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Query)(returns => notification_rule_type_1.NotificationRuleList, { description: 'To fetch multiple NotificationRules' }),
|
|
59
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
60
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
61
|
+
tslib_1.__metadata("design:type", Function),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
63
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
64
|
+
], NotificationRuleQuery.prototype, "notificationRules", null);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, type_graphql_1.FieldResolver)(type => String),
|
|
67
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
68
|
+
tslib_1.__metadata("design:type", Function),
|
|
69
|
+
tslib_1.__metadata("design:paramtypes", [notification_rule_1.NotificationRule]),
|
|
70
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
71
|
+
], NotificationRuleQuery.prototype, "thumbnail", null);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
74
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
75
|
+
tslib_1.__metadata("design:type", Function),
|
|
76
|
+
tslib_1.__metadata("design:paramtypes", [notification_rule_1.NotificationRule]),
|
|
77
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
+
], NotificationRuleQuery.prototype, "domain", null);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
81
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
82
|
+
tslib_1.__metadata("design:type", Function),
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [notification_rule_1.NotificationRule]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], NotificationRuleQuery.prototype, "updater", null);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
88
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
89
|
+
tslib_1.__metadata("design:type", Function),
|
|
90
|
+
tslib_1.__metadata("design:paramtypes", [notification_rule_1.NotificationRule]),
|
|
91
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
92
|
+
], NotificationRuleQuery.prototype, "creator", null);
|
|
93
|
+
NotificationRuleQuery = tslib_1.__decorate([
|
|
94
|
+
(0, type_graphql_1.Resolver)(notification_rule_1.NotificationRule)
|
|
95
|
+
], NotificationRuleQuery);
|
|
96
|
+
exports.NotificationRuleQuery = NotificationRuleQuery;
|
|
97
|
+
//# sourceMappingURL=notification-rule-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-rule-query.js","sourceRoot":"","sources":["../../../server/service/notification-rule/notification-rule-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,2DAAsD;AACtD,qEAA+D;AAGxD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAE1B,AAAN,KAAK,CAAC,gBAAgB,CAAY,EAAU,EAAS,OAAwB;QAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,oCAAgB,CAAC,CAAC,OAAO,CAAC;YACnD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,iBAAiB,CAAS,MAAiB,EAAS,OAAwB;QAChF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,oCAAgB,CAAC;YACjD,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;SACrC,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KA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AiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAC5E,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DAMnD;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,6CAAoB,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;IACtE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;8DAahD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAmB,oCAAgB;;sDAUzD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAmB,oCAAgB;;mDAEtD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAmB,oCAAgB;;oDAEvD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAmB,oCAAgB;;oDAEvD;AApDU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,oCAAgB,CAAC;GACd,qBAAqB,CAqDjC;AArDY,sDAAqB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { NotificationRule } from './notification-rule'\nimport { NotificationRuleList } from './notification-rule-type'\n\n@Resolver(NotificationRule)\nexport class NotificationRuleQuery {\n @Query(returns => NotificationRule!, { nullable: true, description: 'To fetch a NotificationRule' })\n async notificationRule(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<NotificationRule> {\n const { domain } = context.state\n\n return await getRepository(NotificationRule).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => NotificationRuleList, { description: 'To fetch multiple NotificationRules' })\n async notificationRules(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<NotificationRuleList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(NotificationRule),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() notificationRule: NotificationRule): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: notificationRule.domainId },\n refType: NotificationRule.name,\n refBy: notificationRule.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() notificationRule: NotificationRule): Promise<Domain> {\n return notificationRule.domainId && (await getRepository(Domain).findOneBy({ id: notificationRule.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() notificationRule: NotificationRule): Promise<User> {\n return notificationRule.updaterId && (await getRepository(User).findOneBy({ id: notificationRule.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() notificationRule: NotificationRule): Promise<User> {\n return notificationRule.creatorId && (await getRepository(User).findOneBy({ id: notificationRule.creatorId }))\n }\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationRuleList = exports.NotificationRulePatch = exports.NewNotificationRule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const notification_rule_1 = require("./notification-rule");
|
|
8
|
+
let NewNotificationRule = class NewNotificationRule {
|
|
9
|
+
};
|
|
10
|
+
tslib_1.__decorate([
|
|
11
|
+
(0, type_graphql_1.Field)(),
|
|
12
|
+
tslib_1.__metadata("design:type", String)
|
|
13
|
+
], NewNotificationRule.prototype, "name", void 0);
|
|
14
|
+
tslib_1.__decorate([
|
|
15
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
16
|
+
tslib_1.__metadata("design:type", String)
|
|
17
|
+
], NewNotificationRule.prototype, "description", void 0);
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, type_graphql_1.Field)(type => notification_rule_1.NotificationRuleStatus, { nullable: true }),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], NewNotificationRule.prototype, "state", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
24
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
25
|
+
], NewNotificationRule.prototype, "active", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], NewNotificationRule.prototype, "title", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], NewNotificationRule.prototype, "body", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
36
|
+
tslib_1.__metadata("design:type", String)
|
|
37
|
+
], NewNotificationRule.prototype, "url", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
40
|
+
tslib_1.__metadata("design:type", Object)
|
|
41
|
+
], NewNotificationRule.prototype, "thumbnail", void 0);
|
|
42
|
+
NewNotificationRule = tslib_1.__decorate([
|
|
43
|
+
(0, type_graphql_1.InputType)()
|
|
44
|
+
], NewNotificationRule);
|
|
45
|
+
exports.NewNotificationRule = NewNotificationRule;
|
|
46
|
+
let NotificationRulePatch = class NotificationRulePatch {
|
|
47
|
+
};
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], NotificationRulePatch.prototype, "id", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], NotificationRulePatch.prototype, "name", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
58
|
+
tslib_1.__metadata("design:type", String)
|
|
59
|
+
], NotificationRulePatch.prototype, "description", void 0);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.Field)(type => notification_rule_1.NotificationRuleStatus, { nullable: true }),
|
|
62
|
+
tslib_1.__metadata("design:type", String)
|
|
63
|
+
], NotificationRulePatch.prototype, "state", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
66
|
+
tslib_1.__metadata("design:type", String)
|
|
67
|
+
], NotificationRulePatch.prototype, "title", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
70
|
+
tslib_1.__metadata("design:type", String)
|
|
71
|
+
], NotificationRulePatch.prototype, "body", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
74
|
+
tslib_1.__metadata("design:type", String)
|
|
75
|
+
], NotificationRulePatch.prototype, "url", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
78
|
+
tslib_1.__metadata("design:type", Object)
|
|
79
|
+
], NotificationRulePatch.prototype, "thumbnail", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
82
|
+
tslib_1.__metadata("design:type", String)
|
|
83
|
+
], NotificationRulePatch.prototype, "cuFlag", void 0);
|
|
84
|
+
NotificationRulePatch = tslib_1.__decorate([
|
|
85
|
+
(0, type_graphql_1.InputType)()
|
|
86
|
+
], NotificationRulePatch);
|
|
87
|
+
exports.NotificationRulePatch = NotificationRulePatch;
|
|
88
|
+
let NotificationRuleList = class NotificationRuleList {
|
|
89
|
+
};
|
|
90
|
+
tslib_1.__decorate([
|
|
91
|
+
(0, type_graphql_1.Field)(type => [notification_rule_1.NotificationRule]),
|
|
92
|
+
tslib_1.__metadata("design:type", Array)
|
|
93
|
+
], NotificationRuleList.prototype, "items", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
96
|
+
tslib_1.__metadata("design:type", Number)
|
|
97
|
+
], NotificationRuleList.prototype, "total", void 0);
|
|
98
|
+
NotificationRuleList = tslib_1.__decorate([
|
|
99
|
+
(0, type_graphql_1.ObjectType)()
|
|
100
|
+
], NotificationRuleList);
|
|
101
|
+
exports.NotificationRuleList = NotificationRuleList;
|
|
102
|
+
//# sourceMappingURL=notification-rule-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-rule-type.js","sourceRoot":"","sources":["../../../server/service/notification-rule/notification-rule-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAoE;AAEpE,2DAA8E;AAGvE,IAAM,mBAAmB,GAAzB,MAAM,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AAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACb;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACd;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACf;AAEX;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wDAC3B;AAEtB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACX;AA1BJ,qBAAqB;IADjC,IAAA,wBAAS,GAAE;GACC,qBAAqB,CA2BjC;AA3BY,sDAAqB;AA8B3B,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAMhC,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,oCAAgB,CAAC,CAAC;;mDACT;AAEzB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;mDACN;AALF,oBAAoB;IADhC,IAAA,yBAAU,GAAE;GACA,oBAAoB,CAMhC;AANY,oDAAoB","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { ObjectType, Field, InputType, Int, ID } from 'type-graphql'\n\nimport { NotificationRule, NotificationRuleStatus } from './notification-rule'\n\n@InputType()\nexport class NewNotificationRule {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => NotificationRuleStatus, { nullable: true })\n state?: NotificationRuleStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n title: string\n\n @Field({ nullable: true })\n body: string\n\n @Field({ nullable: true })\n url: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n}\n\n@InputType()\nexport class NotificationRulePatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => NotificationRuleStatus, { nullable: true })\n state?: NotificationRuleStatus\n\n @Field({ nullable: true })\n title: string\n\n @Field({ nullable: true })\n body: string\n\n @Field({ nullable: true })\n url: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class NotificationRuleList {\n @Field(type => [NotificationRule])\n items: NotificationRule[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|