@things-factory/notification 6.2.86 → 7.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/notification",
3
- "version": "6.2.86",
3
+ "version": "7.0.0-alpha.1",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -30,17 +30,17 @@
30
30
  "@material/mwc-button": "^0.27.0",
31
31
  "@material/mwc-formfield": "^0.27.0",
32
32
  "@material/mwc-switch": "^0.27.0",
33
- "@operato/layout": "^1.0.1",
34
- "@things-factory/auth-base": "^6.2.84",
35
- "@things-factory/codelingua": "^6.2.86",
36
- "@things-factory/i18n-base": "^6.2.84",
37
- "@things-factory/organization": "^6.2.84",
38
- "@things-factory/setting-base": "^6.2.84",
39
- "@things-factory/shell": "^6.2.84",
33
+ "@operato/layout": "^2.0.0-alpha.0",
34
+ "@things-factory/auth-base": "^7.0.0-alpha.1",
35
+ "@things-factory/codelingua": "^7.0.0-alpha.1",
36
+ "@things-factory/i18n-base": "^7.0.0-alpha.1",
37
+ "@things-factory/organization": "^7.0.0-alpha.1",
38
+ "@things-factory/setting-base": "^7.0.0-alpha.1",
39
+ "@things-factory/shell": "^7.0.0-alpha.1",
40
40
  "clipboard": "^2.0.6",
41
41
  "firebase": "^9.14.0",
42
42
  "firebase-admin": "^11.3.0",
43
43
  "google": "^2.1.0"
44
44
  },
45
- "gitHead": "f90a5c1ff2a93331bb6e375944972dc68dde8a1f"
45
+ "gitHead": "778315d165d7f15e147583a45d5079c3d7cbce38"
46
46
  }
@@ -1,4 +1,4 @@
1
- import { withFilter } from 'graphql-subscriptions'
1
+ import { filter, pipe } from 'graphql-yoga'
2
2
  import { Arg, Resolver, FieldResolver, Root, Subscription } from 'type-graphql'
3
3
 
4
4
  import { pubsub, ScalarDate } from '@things-factory/shell'
@@ -8,37 +8,37 @@ import { Notification } from './notification'
8
8
  @Resolver(Notification)
9
9
  export class NotificationSubscription {
10
10
  @Subscription({
11
- subscribe: withFilter(
12
- () => pubsub.asyncIterator('notification'),
13
- (payload, variables, context, info) => {
14
- /* normally, subscription context doesn't have domain */
15
- const { domain, user } = context.state
16
-
17
- const { subjects = [] } = variables
18
- const {
19
- notification: { subject, domain: pdomain }
20
- } = payload
21
-
22
- const subdomain = pdomain?.subdomain
23
-
24
- if (subdomain) {
25
- if (domain?.subdomain) {
26
- if (subdomain !== domain.subdomain) {
11
+ subscribe: ({ args, context, info }) => {
12
+ const { subjects = [] } = args
13
+
14
+ return pipe(
15
+ pubsub.subscribe('notification'),
16
+ filter(async (payload: { notification: Notification }) => {
17
+ /* normally, subscription context doesn't have domain */
18
+ const { domain, user } = context.state
19
+
20
+ const {
21
+ notification: { subject, domain: pdomain }
22
+ } = payload
23
+
24
+ const subdomain = pdomain?.subdomain
25
+
26
+ if (subdomain) {
27
+ if (domain?.subdomain) {
28
+ if (subdomain !== domain.subdomain) {
29
+ return false
30
+ }
31
+ } else if (!user.domains.find(d => d.subdomain === subdomain)) {
27
32
  return false
28
33
  }
29
- } else if (!user.domains.find(d => d.subdomain === subdomain)) {
30
- return false
31
34
  }
32
- }
33
35
 
34
- return !subject || subjects.indexOf(subject) !== -1
35
- }
36
- )
36
+ return !subject || subjects.indexOf(subject) !== -1
37
+ })
38
+ )
39
+ }
37
40
  })
38
- notification(
39
- @Root() payload: { notification: Notification },
40
- @Arg('subjects', type => [String], { nullable: true }) subjects: string[]
41
- ): Notification {
41
+ notification(@Root() payload: { notification: Notification }, @Arg('subjects', type => [String], { nullable: true }) subjects: string[]): Notification {
42
42
  return payload.notification
43
43
  }
44
44
  }