@things-factory/notification 8.0.0 → 9.0.0-beta.3

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.
Files changed (56) hide show
  1. package/dist-client/tsconfig.tsbuildinfo +1 -1
  2. package/dist-server/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +9 -9
  4. package/client/actions/notification-fcm.ts +0 -148
  5. package/client/bootstrap.ts +0 -135
  6. package/client/index.ts +0 -6
  7. package/client/pages/notification/notification-list-page.ts +0 -258
  8. package/client/pages/notification-rule/notification-rule-importer.ts +0 -87
  9. package/client/pages/notification-rule/notification-rule-list-page.ts +0 -386
  10. package/client/reducers/notification.ts +0 -27
  11. package/client/route.ts +0 -10
  12. package/client/tsconfig.json +0 -13
  13. package/client/viewparts/notification-badge.ts +0 -54
  14. package/client/viewparts/notification-item.ts +0 -246
  15. package/client/viewparts/notification-list.ts +0 -160
  16. package/client/viewparts/notification-sender.ts +0 -142
  17. package/client/viewparts/notification-setting-let.ts +0 -222
  18. package/docs/images/config-app-1.png +0 -0
  19. package/docs/images/config-app-2.png +0 -0
  20. package/docs/images/config-server-key.png +0 -0
  21. package/docs/images/config-service-account.png +0 -0
  22. package/docs/images/config-vapidkey-1.png +0 -0
  23. package/docs/images/config-vapidkey-2-get-public-key.png +0 -0
  24. package/docs/images/config-vapidkey-3-get-private-key.png +0 -0
  25. package/docs/images/element-notification-badge.png +0 -0
  26. package/docs/images/element-notification-list.png +0 -0
  27. package/docs/images/element-notification-setting-let.png +0 -0
  28. package/docs/images/push-test-on-chrome-1.png +0 -0
  29. package/docs/images/push-test-on-chrome-2.png +0 -0
  30. package/docs/images/push-test-on-firebase-1.png +0 -0
  31. package/docs/images/push-test-on-firebase-2.png +0 -0
  32. package/docs/images/push-test-on-firebase-3.png +0 -0
  33. package/docs/images/push-test-on-firebase-4.png +0 -0
  34. package/server/controllers/fcm.ts +0 -214
  35. package/server/controllers/index.ts +0 -1
  36. package/server/index.ts +0 -5
  37. package/server/middlewares/index.ts +0 -5
  38. package/server/middlewares/notification-middleware.ts +0 -73
  39. package/server/routers/notification-router.ts +0 -67
  40. package/server/routes.ts +0 -11
  41. package/server/service/index.ts +0 -42
  42. package/server/service/notification/directive-notification.ts +0 -71
  43. package/server/service/notification/index.ts +0 -14
  44. package/server/service/notification/notification-mutation.ts +0 -119
  45. package/server/service/notification/notification-query.ts +0 -76
  46. package/server/service/notification/notification-subscription.ts +0 -44
  47. package/server/service/notification/notification-type.ts +0 -55
  48. package/server/service/notification/notification.ts +0 -105
  49. package/server/service/notification-rule/event-subscriber.ts +0 -20
  50. package/server/service/notification-rule/index.ts +0 -9
  51. package/server/service/notification-rule/notification-rule-history.ts +0 -136
  52. package/server/service/notification-rule/notification-rule-mutation.ts +0 -203
  53. package/server/service/notification-rule/notification-rule-query.ts +0 -65
  54. package/server/service/notification-rule/notification-rule-type.ts +0 -71
  55. package/server/service/notification-rule/notification-rule.ts +0 -125
  56. package/server/tsconfig.json +0 -9
@@ -1,203 +0,0 @@
1
- import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
- import { In } from 'typeorm'
3
-
4
- import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
5
-
6
- import { NotificationRule } from './notification-rule'
7
- import { NewNotificationRule, NotificationRulePatch } from './notification-rule-type'
8
-
9
- @Resolver(NotificationRule)
10
- export class NotificationRuleMutation {
11
- @Directive('@transaction')
12
- @Mutation(returns => NotificationRule, { description: 'To create new NotificationRule' })
13
- async createNotificationRule(
14
- @Arg('notificationRule') notificationRule: NewNotificationRule,
15
- @Ctx() context: ResolverContext
16
- ): Promise<NotificationRule> {
17
- const { domain, user, tx } = context.state
18
-
19
- const result = await tx.getRepository(NotificationRule).save({
20
- ...notificationRule,
21
- domain,
22
- creator: user,
23
- updater: user
24
- })
25
-
26
- if (notificationRule.thumbnail) {
27
- await createAttachment(
28
- null,
29
- {
30
- attachment: {
31
- file: notificationRule.thumbnail,
32
- refType: NotificationRule.name,
33
- refBy: result.id
34
- }
35
- },
36
- context
37
- )
38
- }
39
-
40
- return result
41
- }
42
-
43
- @Directive('@transaction')
44
- @Mutation(returns => NotificationRule, { description: 'To modify NotificationRule information' })
45
- async updateNotificationRule(
46
- @Arg('id') id: string,
47
- @Arg('patch') patch: NotificationRulePatch,
48
- @Ctx() context: ResolverContext
49
- ): Promise<NotificationRule> {
50
- const { domain, user, tx } = context.state
51
-
52
- const repository = tx.getRepository(NotificationRule)
53
- const notificationRule = await repository.findOne({
54
- where: { domain: { id: domain.id }, id }
55
- })
56
-
57
- const result = await repository.save({
58
- ...notificationRule,
59
- ...patch,
60
- updater: user
61
- })
62
-
63
- if (patch.thumbnail) {
64
- await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
65
- await createAttachment(
66
- null,
67
- {
68
- attachment: {
69
- file: patch.thumbnail,
70
- refType: NotificationRule.name,
71
- refBy: result.id
72
- }
73
- },
74
- context
75
- )
76
- }
77
-
78
- return result
79
- }
80
-
81
- @Directive('@transaction')
82
- @Mutation(returns => [NotificationRule], { description: "To modify multiple NotificationRules' information" })
83
- async updateMultipleNotificationRule(
84
- @Arg('patches', type => [NotificationRulePatch]) patches: NotificationRulePatch[],
85
- @Ctx() context: ResolverContext
86
- ): Promise<NotificationRule[]> {
87
- const { domain, user, tx } = context.state
88
-
89
- let results = []
90
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
91
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
92
- const notificationRuleRepo = tx.getRepository(NotificationRule)
93
-
94
- if (_createRecords.length > 0) {
95
- for (let i = 0; i < _createRecords.length; i++) {
96
- const newRecord = _createRecords[i]
97
-
98
- const result = await notificationRuleRepo.save({
99
- ...newRecord,
100
- domain,
101
- creator: user,
102
- updater: user
103
- })
104
-
105
- if (newRecord.thumbnail) {
106
- await createAttachment(
107
- null,
108
- {
109
- attachment: {
110
- file: newRecord.thumbnail,
111
- refType: NotificationRule.name,
112
- refBy: result.id
113
- }
114
- },
115
- context
116
- )
117
- }
118
-
119
- results.push({ ...result, cuFlag: '+' })
120
- }
121
- }
122
-
123
- if (_updateRecords.length > 0) {
124
- for (let i = 0; i < _updateRecords.length; i++) {
125
- const updateRecord = _updateRecords[i]
126
- const notificationRule = await notificationRuleRepo.findOneBy({ id: updateRecord.id })
127
-
128
- const result = await notificationRuleRepo.save({
129
- ...notificationRule,
130
- ...updateRecord,
131
- updater: user
132
- })
133
-
134
- if (updateRecord.thumbnail) {
135
- await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
136
- await createAttachment(
137
- null,
138
- {
139
- attachment: {
140
- file: updateRecord.thumbnail,
141
- refType: NotificationRule.name,
142
- refBy: result.id
143
- }
144
- },
145
- context
146
- )
147
- }
148
-
149
- results.push({ ...result, cuFlag: 'M' })
150
- }
151
- }
152
-
153
- return results
154
- }
155
-
156
- @Directive('@transaction')
157
- @Mutation(returns => Boolean, { description: 'To delete NotificationRule' })
158
- async deleteNotificationRule(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
159
- const { domain, tx } = context.state
160
-
161
- await tx.getRepository(NotificationRule).delete({ domain: { id: domain.id }, id })
162
- await deleteAttachmentsByRef(null, { refBys: [id] }, context)
163
-
164
- return true
165
- }
166
-
167
- @Directive('@transaction')
168
- @Mutation(returns => Boolean, { description: 'To delete multiple NotificationRules' })
169
- async deleteNotificationRules(
170
- @Arg('ids', type => [String]) ids: string[],
171
- @Ctx() context: ResolverContext
172
- ): Promise<boolean> {
173
- const { domain, tx } = context.state
174
-
175
- await tx.getRepository(NotificationRule).delete({
176
- domain: { id: domain.id },
177
- id: In(ids)
178
- })
179
-
180
- await deleteAttachmentsByRef(null, { refBys: ids }, context)
181
-
182
- return true
183
- }
184
-
185
- @Directive('@transaction')
186
- @Mutation(returns => Boolean, { description: 'To import multiple NotificationRules' })
187
- async importNotificationRules(
188
- @Arg('notificationRules', type => [NotificationRulePatch]) notificationRules: NotificationRulePatch[],
189
- @Ctx() context: ResolverContext
190
- ): Promise<boolean> {
191
- const { domain, tx } = context.state
192
-
193
- await Promise.all(
194
- notificationRules.map(async (notificationRule: NotificationRulePatch) => {
195
- const createdNotificationRule: NotificationRule = await tx
196
- .getRepository(NotificationRule)
197
- .save({ domain, ...notificationRule })
198
- })
199
- )
200
-
201
- return true
202
- }
203
- }
@@ -1,65 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
2
- import { Attachment } from '@things-factory/attachment-base'
3
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
- import { User } from '@things-factory/auth-base'
5
- import { NotificationRule } from './notification-rule'
6
- import { NotificationRuleList } from './notification-rule-type'
7
-
8
- @Resolver(NotificationRule)
9
- export class NotificationRuleQuery {
10
- @Query(returns => NotificationRule!, { nullable: true, description: 'To fetch a NotificationRule' })
11
- async notificationRule(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<NotificationRule> {
12
- const { domain } = context.state
13
-
14
- return await getRepository(NotificationRule).findOne({
15
- where: { domain: { id: domain.id }, id }
16
- })
17
- }
18
-
19
- @Query(returns => NotificationRuleList, { description: 'To fetch multiple NotificationRules' })
20
- async notificationRules(
21
- @Args(type => ListParam) params: ListParam,
22
- @Ctx() context: ResolverContext
23
- ): Promise<NotificationRuleList> {
24
- const { domain } = context.state
25
-
26
- const queryBuilder = getQueryBuilderFromListParams({
27
- domain,
28
- params,
29
- repository: await getRepository(NotificationRule),
30
- searchables: ['name', 'description']
31
- })
32
-
33
- const [items, total] = await queryBuilder.getManyAndCount()
34
-
35
- return { items, total }
36
- }
37
-
38
- @FieldResolver(type => String)
39
- async thumbnail(@Root() notificationRule: NotificationRule): Promise<string | undefined> {
40
- const attachment: Attachment = await getRepository(Attachment).findOne({
41
- where: {
42
- domain: { id: notificationRule.domainId },
43
- refType: NotificationRule.name,
44
- refBy: notificationRule.id
45
- }
46
- })
47
-
48
- return attachment?.fullpath
49
- }
50
-
51
- @FieldResolver(type => Domain)
52
- async domain(@Root() notificationRule: NotificationRule): Promise<Domain> {
53
- return notificationRule.domainId && (await getRepository(Domain).findOneBy({ id: notificationRule.domainId }))
54
- }
55
-
56
- @FieldResolver(type => User)
57
- async updater(@Root() notificationRule: NotificationRule): Promise<User> {
58
- return notificationRule.updaterId && (await getRepository(User).findOneBy({ id: notificationRule.updaterId }))
59
- }
60
-
61
- @FieldResolver(type => User)
62
- async creator(@Root() notificationRule: NotificationRule): Promise<User> {
63
- return notificationRule.creatorId && (await getRepository(User).findOneBy({ id: notificationRule.creatorId }))
64
- }
65
- }
@@ -1,71 +0,0 @@
1
- import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
2
- import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
3
- import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
4
-
5
- import { NotificationRule, NotificationRuleStatus } from './notification-rule'
6
-
7
- @InputType()
8
- export class NewNotificationRule {
9
- @Field()
10
- name: string
11
-
12
- @Field({ nullable: true })
13
- description?: string
14
-
15
- @Field(type => NotificationRuleStatus, { nullable: true })
16
- state?: NotificationRuleStatus
17
-
18
- @Field({ nullable: true })
19
- active?: boolean
20
-
21
- @Field({ nullable: true })
22
- title: string
23
-
24
- @Field({ nullable: true })
25
- body: string
26
-
27
- @Field({ nullable: true })
28
- url: string
29
-
30
- @Field(type => GraphQLUpload, { nullable: true })
31
- thumbnail?: FileUpload
32
- }
33
-
34
- @InputType()
35
- export class NotificationRulePatch {
36
- @Field(type => ID, { nullable: true })
37
- id?: string
38
-
39
- @Field({ nullable: true })
40
- name?: string
41
-
42
- @Field({ nullable: true })
43
- description?: string
44
-
45
- @Field(type => NotificationRuleStatus, { nullable: true })
46
- state?: NotificationRuleStatus
47
-
48
- @Field({ nullable: true })
49
- title: string
50
-
51
- @Field({ nullable: true })
52
- body: string
53
-
54
- @Field({ nullable: true })
55
- url: string
56
-
57
- @Field(type => GraphQLUpload, { nullable: true })
58
- thumbnail?: FileUpload
59
-
60
- @Field({ nullable: true })
61
- cuFlag?: string
62
- }
63
-
64
- @ObjectType()
65
- export class NotificationRuleList {
66
- @Field(type => [NotificationRule])
67
- items: NotificationRule[]
68
-
69
- @Field(type => Int)
70
- total: number
71
- }
@@ -1,125 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- DeleteDateColumn,
5
- Entity,
6
- Index,
7
- Column,
8
- RelationId,
9
- ManyToOne,
10
- PrimaryGeneratedColumn,
11
- VersionColumn
12
- } from 'typeorm'
13
- import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
14
-
15
- import { Domain } from '@things-factory/shell'
16
- import { User } from '@things-factory/auth-base'
17
- import { OrgMemberTargetType, OrgMemberTarget } from '@things-factory/organization'
18
-
19
- export enum NotificationRuleStatus {
20
- DRAFT = 'DRAFT',
21
- RELEASED = 'RELEASED'
22
- }
23
-
24
- registerEnumType(NotificationRuleStatus, {
25
- name: 'NotificationRuleStatus',
26
- description: 'state enumeration of a notificationRule'
27
- })
28
-
29
- @ObjectType()
30
- export class RecipientItem {
31
- @Field(type => OrgMemberTargetType, { nullable: true })
32
- type?: OrgMemberTargetType
33
-
34
- @Field({ nullable: true })
35
- value?: string
36
-
37
- @Field(type => OrgMemberTarget, { nullable: true })
38
- recipient?: OrgMemberTarget
39
- }
40
-
41
- @Entity()
42
- @Index(
43
- 'ix_notification_rule_0',
44
- (notificationRule: NotificationRule) => [notificationRule.domain, notificationRule.name, notificationRule.deletedAt],
45
- { unique: true }
46
- )
47
- @ObjectType({ description: 'Entity for NotificationRule' })
48
- export class NotificationRule {
49
- @PrimaryGeneratedColumn('uuid')
50
- @Field(type => ID)
51
- readonly id: string
52
-
53
- @VersionColumn()
54
- @Field({ nullable: true })
55
- version?: number = 1
56
-
57
- @ManyToOne(type => Domain)
58
- @Field(type => Domain)
59
- domain?: Domain
60
-
61
- @RelationId((notificationRule: NotificationRule) => notificationRule.domain)
62
- domainId?: string
63
-
64
- @Column()
65
- @Field({ nullable: true })
66
- name?: string
67
-
68
- @Column({ nullable: true })
69
- @Field({ nullable: true })
70
- description?: string
71
-
72
- @Column({ nullable: true })
73
- @Field({ nullable: true })
74
- state?: NotificationRuleStatus
75
-
76
- @Column({ nullable: true })
77
- @Field({ nullable: true })
78
- title: string
79
-
80
- @Column({ nullable: true })
81
- @Field({ nullable: true })
82
- body: string
83
-
84
- @Column({ nullable: true })
85
- @Field({ nullable: true })
86
- url: string
87
-
88
- @Column({ nullable: true })
89
- @Field({ nullable: true })
90
- thumbnail: string
91
-
92
- @Column({ nullable: true })
93
- @Field({ nullable: true })
94
- channels: string
95
-
96
- @Column('simple-json', { nullable: true })
97
- @Field(type => [RecipientItem], { nullable: true, description: 'notification recipients.' })
98
- recipients: string
99
-
100
- @CreateDateColumn()
101
- @Field({ nullable: true })
102
- createdAt?: Date
103
-
104
- @UpdateDateColumn()
105
- @Field({ nullable: true })
106
- updatedAt?: Date
107
-
108
- @DeleteDateColumn()
109
- @Field({ nullable: true })
110
- deletedAt?: Date
111
-
112
- @ManyToOne(type => User, { nullable: true })
113
- @Field(type => User, { nullable: true })
114
- creator?: User
115
-
116
- @RelationId((notificationRule: NotificationRule) => notificationRule.creator)
117
- creatorId?: string
118
-
119
- @ManyToOne(type => User, { nullable: true })
120
- @Field(type => User, { nullable: true })
121
- updater?: User
122
-
123
- @RelationId((notificationRule: NotificationRule) => notificationRule.updater)
124
- updaterId?: string
125
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "outDir": "../dist-server",
5
- "baseUrl": "./"
6
- },
7
- "include": ["./**/*"],
8
- "exclude": ["**/*.spec.ts"]
9
- }