@things-factory/notification 10.1.248 → 10.1.254

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 (37) hide show
  1. package/dist-client/tsconfig.tsbuildinfo +1 -1
  2. package/dist-server/controllers/fcm.d.ts +6 -10
  3. package/dist-server/controllers/fcm.js +73 -122
  4. package/dist-server/controllers/fcm.js.map +1 -1
  5. package/dist-server/controllers/notice/deliver-notice.d.ts +2 -2
  6. package/dist-server/controllers/notice/deliver-notice.js +4 -4
  7. package/dist-server/controllers/notice/deliver-notice.js.map +1 -1
  8. package/dist-server/controllers/notice/index.d.ts +0 -2
  9. package/dist-server/controllers/notice/index.js +0 -2
  10. package/dist-server/controllers/notice/index.js.map +1 -1
  11. package/dist-server/controllers/notice/notice-channels.d.ts +2 -6
  12. package/dist-server/controllers/notice/notice-channels.js +2 -9
  13. package/dist-server/controllers/notice/notice-channels.js.map +1 -1
  14. package/dist-server/controllers/notice/send-notice.js +1 -2
  15. package/dist-server/controllers/notice/send-notice.js.map +1 -1
  16. package/dist-server/middlewares/notification-middleware.d.ts +1 -0
  17. package/dist-server/middlewares/notification-middleware.js +11 -1
  18. package/dist-server/middlewares/notification-middleware.js.map +1 -1
  19. package/dist-server/service/index.d.ts +2 -1
  20. package/dist-server/service/index.js +4 -1
  21. package/dist-server/service/index.js.map +1 -1
  22. package/dist-server/service/notification-token/index.d.ts +2 -0
  23. package/dist-server/service/notification-token/index.js +6 -0
  24. package/dist-server/service/notification-token/index.js.map +1 -0
  25. package/dist-server/service/notification-token/notification-token.d.ts +22 -0
  26. package/dist-server/service/notification-token/notification-token.js +64 -0
  27. package/dist-server/service/notification-token/notification-token.js.map +1 -0
  28. package/dist-server/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +8 -8
  30. package/tests/notice-delivery.test.ts +1 -116
  31. package/tests/push-tokens.test.ts +190 -0
  32. package/dist-server/controllers/notice/app-brand.d.ts +0 -17
  33. package/dist-server/controllers/notice/app-brand.js +0 -61
  34. package/dist-server/controllers/notice/app-brand.js.map +0 -1
  35. package/dist-server/controllers/notice/notice-email.d.ts +0 -32
  36. package/dist-server/controllers/notice/notice-email.js +0 -153
  37. package/dist-server/controllers/notice/notice-email.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"notification-middleware.js","sourceRoot":"","sources":["../../server/middlewares/notification-middleware.ts"],"names":[],"mappings":";;AAYA,gCAsDC;AAED,wDAOC;AA3ED,iDAA8C;AAC9C,6CAA4C;AAE5C,4CAA2C;AAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qDAAqD,CAAC,CAAA;AAErF;;;;GAIG;AACH,SAAgB,UAAU,CAAC,MAAM;IAC/B,OAAO,KAAK,WAAW,EACrB,SAAS,EACT,MAAM,EACN,KAAK,EACL,IAAI,EACJ,OAAO,GAAG,MAAM,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,OAAO,EACP,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EACtB,IAAI,GAAG,YAAY,EACpB;QACC,IAAI,CAAC;YACH,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1B,2CAA2C;gBAE3C,MAAM,IAAA,YAAM,EAAC;oBACX,SAAS;oBACT,MAAM;oBACN,KAAK;oBACL,KAAK;oBACL,IAAI;oBACJ,IAAI,EAAE;wBACJ,IAAI;wBACJ,GAAG;wBACH,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;qBAC7B;oBACD,KAAK;oBACL,OAAO;iBACR,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,0FAA0F;gBAC1F,2BAA2B;gBAC3B,MAAM,cAAM,CAAC,OAAO,CAAC,cAAc,EAAE;oBACnC,YAAY,EAAE;wBACZ,MAAM;wBACN,SAAS;wBACT,OAAO;wBACP,IAAI;wBACJ,KAAK;wBACL,IAAI;wBACJ,KAAK;wBACL,GAAG;wBACH,SAAS;qBACV;iBACF,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,OAAY,EAAE,IAAS;IAClE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,sGAAsG;QACtG,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;IAC7E,CAAC;IAED,MAAM,IAAI,EAAE,CAAA;AACd,CAAC","sourcesContent":["import { pubsub } from '@things-factory/shell'\nimport { logger } from '@things-factory/env'\n\nimport { notify } from '../controllers/fcm'\n\nconst debug = require('debug')('things-factory:notification:notification-middleware')\n\n/**\n * Tells the people of `domain` - by web push (`background`) or live to the screens they have open (`foreground`).\n * The middleware gives each request one as `context.state.notify`; work that runs with no request (a scheduled\n * announcement) takes one for its domain.\n */\nexport function notifierOf(domain) {\n return async function ({\n receivers,\n tokens,\n topic,\n type,\n subject = 'info',\n title,\n body,\n image,\n url,\n actions,\n timestamp = Date.now(),\n mode = 'background'\n }) {\n try {\n if (mode === 'background') {\n /* for send webpush notification message */\n\n await notify({\n receivers,\n tokens,\n topic,\n title,\n body,\n data: {\n type,\n url,\n timestamp: String(timestamp)\n },\n image,\n actions\n })\n } else {\n /* for send publish notification to clients - to the receivers only, when there are any */\n // TODO CONFIRM data format\n await pubsub.publish('notification', {\n notification: {\n domain,\n receivers,\n subject,\n type,\n title,\n body,\n image,\n url,\n timestamp\n }\n })\n }\n } catch (err) {\n logger.error(err)\n }\n }\n}\n\nexport async function notificationMiddleware(context: any, next: any) {\n if (!context.state.notify) {\n /* the domain as it stands when the notice is sent - a later middleware may be the one that sets it */\n context.state.notify = payload => notifierOf(context.state.domain)(payload)\n }\n\n await next()\n}\n"]}
1
+ {"version":3,"file":"notification-middleware.js","sourceRoot":"","sources":["../../server/middlewares/notification-middleware.ts"],"names":[],"mappings":";;AAaA,0CAEC;AAOD,gCAsDC;AAED,wDAOC;AArFD,iDAA8D;AAC9D,6CAA4C;AAE5C,4CAA2C;AAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qDAAqD,CAAC,CAAA;AAErF;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,MAAM,EAAE,GAAW;IACjD,OAAO,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAA,sBAAc,EAAC,MAAM,CAAC,GAAG,GAAG,EAAE,CAAA;AACzF,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,MAAM;IAC/B,OAAO,KAAK,WAAW,EACrB,SAAS,EACT,MAAM,EACN,KAAK,EACL,IAAI,EACJ,OAAO,GAAG,MAAM,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,OAAO,EACP,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EACtB,IAAI,GAAG,YAAY,EACpB;QACC,IAAI,CAAC;YACH,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1B,2CAA2C;gBAE3C,MAAM,IAAA,YAAM,EAAC;oBACX,SAAS;oBACT,MAAM;oBACN,KAAK;oBACL,KAAK;oBACL,IAAI;oBACJ,IAAI,EAAE;wBACJ,IAAI;wBACJ,GAAG,EAAE,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC;wBACxC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;qBAC7B;oBACD,KAAK;oBACL,OAAO;iBACR,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,0FAA0F;gBAC1F,2BAA2B;gBAC3B,MAAM,cAAM,CAAC,OAAO,CAAC,cAAc,EAAE;oBACnC,YAAY,EAAE;wBACZ,MAAM;wBACN,SAAS;wBACT,OAAO;wBACP,IAAI;wBACJ,KAAK;wBACL,IAAI;wBACJ,KAAK;wBACL,GAAG;wBACH,SAAS;qBACV;iBACF,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,OAAY,EAAE,IAAS;IAClE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,sGAAsG;QACtG,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;IAC7E,CAAC;IAED,MAAM,IAAI,EAAE,CAAA;AACd,CAAC","sourcesContent":["import { getContextPath, pubsub } from '@things-factory/shell'\nimport { logger } from '@things-factory/env'\n\nimport { notify } from '../controllers/fcm'\n\nconst debug = require('debug')('things-factory:notification:notification-middleware')\n\n/*\n * The page a web push opens. A notice names its page relative to the domain, as the open screen navigates; the service\n * worker that opens a web push knows no domain, so the page is handed to it from the origin - `/domain/<x>/<page>`,\n * which needs no host and so holds for a notice sent with no request. An address with a scheme or from the origin is\n * handed on as it is.\n */\nexport function workerAddressOf(domain, url: string): string {\n return /^([a-z][a-z0-9+.-]*:|\\/)/i.test(url) ? url : `/${getContextPath(domain)}${url}`\n}\n\n/**\n * Tells the people of `domain` - by web push (`background`) or live to the screens they have open (`foreground`).\n * The middleware gives each request one as `context.state.notify`; work that runs with no request (a scheduled\n * announcement) takes one for its domain.\n */\nexport function notifierOf(domain) {\n return async function ({\n receivers,\n tokens,\n topic,\n type,\n subject = 'info',\n title,\n body,\n image,\n url,\n actions,\n timestamp = Date.now(),\n mode = 'background'\n }) {\n try {\n if (mode === 'background') {\n /* for send webpush notification message */\n\n await notify({\n receivers,\n tokens,\n topic,\n title,\n body,\n data: {\n type,\n url: url && workerAddressOf(domain, url),\n timestamp: String(timestamp)\n },\n image,\n actions\n })\n } else {\n /* for send publish notification to clients - to the receivers only, when there are any */\n // TODO CONFIRM data format\n await pubsub.publish('notification', {\n notification: {\n domain,\n receivers,\n subject,\n type,\n title,\n body,\n image,\n url,\n timestamp\n }\n })\n }\n } catch (err) {\n logger.error(err)\n }\n }\n}\n\nexport async function notificationMiddleware(context: any, next: any) {\n if (!context.state.notify) {\n /* the domain as it stands when the notice is sent - a later middleware may be the one that sets it */\n context.state.notify = payload => notifierOf(context.state.domain)(payload)\n }\n\n await next()\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  export * from './notification-rule/notification-rule';
2
2
  export * from './notification/notification';
3
- export declare const entities: (typeof import("./notification-rule/notification-rule").NotificationRule | typeof import("./notification/notification").Notification)[];
3
+ export * from './notification-token/notification-token';
4
+ export declare const entities: (typeof import("./notification-rule/notification-rule").NotificationRule | typeof import("./notification/notification").Notification | typeof import("./notification-token/notification-token").NotificationToken)[];
4
5
  export declare const subscribers: typeof import("./notification-rule/event-subscriber").NotificationRuleHistoryEntitySubscriber[];
5
6
  export declare const schema: {
6
7
  typeDefs: {
@@ -5,14 +5,17 @@ const tslib_1 = require("tslib");
5
5
  /* EXPORT ENTITY TYPES */
6
6
  tslib_1.__exportStar(require("./notification-rule/notification-rule"), exports);
7
7
  tslib_1.__exportStar(require("./notification/notification"), exports);
8
+ tslib_1.__exportStar(require("./notification-token/notification-token"), exports);
8
9
  /* IMPORT ENTITIES AND RESOLVERS */
9
10
  const notification_rule_1 = require("./notification-rule");
10
11
  const notification_1 = require("./notification");
11
12
  const notice_channel_1 = require("./notice-channel");
13
+ const notification_token_1 = require("./notification-token");
12
14
  exports.entities = [
13
15
  /* ENTITIES */
14
16
  ...notification_rule_1.entities,
15
- ...notification_1.entities
17
+ ...notification_1.entities,
18
+ ...notification_token_1.entities
16
19
  ];
17
20
  exports.subscribers = [
18
21
  /* SUBSCRIBERS */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,gFAAqD;AACrD,sEAA2C;AAE3C,mCAAmC;AACnC,2DAI4B;AAC5B,iDAKuB;AACvB,qDAAsE;AAEzD,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,4BAAwB;IAC3B,GAAG,uBAAoB;CACxB,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,iBAAiB;IACjB,GAAG,+BAA2B;CAC/B,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,QAAQ,EAAE;QACR,GAAG,uBAAoB;KACxB;IACD,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,6BAAyB;QAC5B,GAAG,wBAAqB;QACxB,GAAG,wBAAqB;QACxB,GAAG,0BAAsB;KAC1B;IACD,UAAU,EAAE;QACV,GAAG,yBAAsB;KAC1B;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './notification-rule/notification-rule'\nexport * from './notification/notification'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport {\n entities as NotificationRuleEntities,\n resolvers as NotificationRuleResolvers,\n subscribers as NotificationRuleSubscribers\n} from './notification-rule'\nimport {\n entities as NotificationEntities,\n typeDefs as NotificationTypeDefs,\n resolvers as NotificationResolvers,\n directives as NotificationDirectives\n} from './notification'\nimport { resolvers as NoticeChannelResolvers } from './notice-channel'\n\nexport const entities = [\n /* ENTITIES */\n ...NotificationRuleEntities,\n ...NotificationEntities\n]\n\nexport const subscribers = [\n /* SUBSCRIBERS */\n ...NotificationRuleSubscribers\n]\n\nexport const schema = {\n typeDefs: {\n ...NotificationTypeDefs\n },\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...NotificationRuleResolvers,\n ...NotificationResolvers,\n ...NotificationResolvers,\n ...NoticeChannelResolvers\n ],\n directives: {\n ...NotificationDirectives\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,gFAAqD;AACrD,sEAA2C;AAC3C,kFAAuD;AAEvD,mCAAmC;AACnC,2DAI4B;AAC5B,iDAKuB;AACvB,qDAAsE;AACtE,6DAA4E;AAE/D,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,4BAAwB;IAC3B,GAAG,uBAAoB;IACvB,GAAG,6BAAyB;CAC7B,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,iBAAiB;IACjB,GAAG,+BAA2B;CAC/B,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,QAAQ,EAAE;QACR,GAAG,uBAAoB;KACxB;IACD,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,6BAAyB;QAC5B,GAAG,wBAAqB;QACxB,GAAG,wBAAqB;QACxB,GAAG,0BAAsB;KAC1B;IACD,UAAU,EAAE;QACV,GAAG,yBAAsB;KAC1B;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './notification-rule/notification-rule'\nexport * from './notification/notification'\nexport * from './notification-token/notification-token'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport {\n entities as NotificationRuleEntities,\n resolvers as NotificationRuleResolvers,\n subscribers as NotificationRuleSubscribers\n} from './notification-rule'\nimport {\n entities as NotificationEntities,\n typeDefs as NotificationTypeDefs,\n resolvers as NotificationResolvers,\n directives as NotificationDirectives\n} from './notification'\nimport { resolvers as NoticeChannelResolvers } from './notice-channel'\nimport { entities as NotificationTokenEntities } from './notification-token'\n\nexport const entities = [\n /* ENTITIES */\n ...NotificationRuleEntities,\n ...NotificationEntities,\n ...NotificationTokenEntities\n]\n\nexport const subscribers = [\n /* SUBSCRIBERS */\n ...NotificationRuleSubscribers\n]\n\nexport const schema = {\n typeDefs: {\n ...NotificationTypeDefs\n },\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...NotificationRuleResolvers,\n ...NotificationResolvers,\n ...NotificationResolvers,\n ...NoticeChannelResolvers\n ],\n directives: {\n ...NotificationDirectives\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { NotificationToken } from './notification-token';
2
+ export declare const entities: (typeof NotificationToken)[];
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.entities = void 0;
4
+ const notification_token_1 = require("./notification-token");
5
+ exports.entities = [notification_token_1.NotificationToken];
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/notification-token/index.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AAE3C,QAAA,QAAQ,GAAG,CAAC,sCAAiB,CAAC,CAAA","sourcesContent":["import { NotificationToken } from './notification-token'\n\nexport const entities = [NotificationToken]\n"]}
@@ -0,0 +1,22 @@
1
+ import { User } from '@things-factory/auth-base';
2
+ /**
3
+ * One browser or installed app of a person that web push reaches - the FCM registration token it was given.
4
+ *
5
+ * A token belongs to the person, not to a domain: the person's phone hears from every domain they belong to, and a
6
+ * notice carries its own full address. A token names one browser, so it is held by one person at a time - when
7
+ * someone else signs in on that browser and turns notices on, the token moves to them.
8
+ *
9
+ * It is a device handle, not a record: a token turned off or refused by FCM is deleted, not kept.
10
+ */
11
+ export declare class NotificationToken {
12
+ readonly id: string;
13
+ user?: User;
14
+ userId?: string;
15
+ token: string;
16
+ createdAt?: Date;
17
+ updatedAt?: Date;
18
+ creator?: User;
19
+ creatorId?: string;
20
+ updater?: User;
21
+ updaterId?: string;
22
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationToken = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const typeorm_1 = require("typeorm");
6
+ const auth_base_1 = require("@things-factory/auth-base");
7
+ /**
8
+ * One browser or installed app of a person that web push reaches - the FCM registration token it was given.
9
+ *
10
+ * A token belongs to the person, not to a domain: the person's phone hears from every domain they belong to, and a
11
+ * notice carries its own full address. A token names one browser, so it is held by one person at a time - when
12
+ * someone else signs in on that browser and turns notices on, the token moves to them.
13
+ *
14
+ * It is a device handle, not a record: a token turned off or refused by FCM is deleted, not kept.
15
+ */
16
+ let NotificationToken = class NotificationToken {
17
+ };
18
+ exports.NotificationToken = NotificationToken;
19
+ tslib_1.__decorate([
20
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], NotificationToken.prototype, "id", void 0);
23
+ tslib_1.__decorate([
24
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { onDelete: 'CASCADE' }),
25
+ tslib_1.__metadata("design:type", auth_base_1.User)
26
+ ], NotificationToken.prototype, "user", void 0);
27
+ tslib_1.__decorate([
28
+ (0, typeorm_1.RelationId)((notificationToken) => notificationToken.user),
29
+ tslib_1.__metadata("design:type", String)
30
+ ], NotificationToken.prototype, "userId", void 0);
31
+ tslib_1.__decorate([
32
+ (0, typeorm_1.Column)({ length: 512 }),
33
+ tslib_1.__metadata("design:type", String)
34
+ ], NotificationToken.prototype, "token", void 0);
35
+ tslib_1.__decorate([
36
+ (0, typeorm_1.CreateDateColumn)(),
37
+ tslib_1.__metadata("design:type", Date)
38
+ ], NotificationToken.prototype, "createdAt", void 0);
39
+ tslib_1.__decorate([
40
+ (0, typeorm_1.UpdateDateColumn)(),
41
+ tslib_1.__metadata("design:type", Date)
42
+ ], NotificationToken.prototype, "updatedAt", void 0);
43
+ tslib_1.__decorate([
44
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
45
+ tslib_1.__metadata("design:type", auth_base_1.User)
46
+ ], NotificationToken.prototype, "creator", void 0);
47
+ tslib_1.__decorate([
48
+ (0, typeorm_1.RelationId)((notificationToken) => notificationToken.creator),
49
+ tslib_1.__metadata("design:type", String)
50
+ ], NotificationToken.prototype, "creatorId", void 0);
51
+ tslib_1.__decorate([
52
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
53
+ tslib_1.__metadata("design:type", auth_base_1.User)
54
+ ], NotificationToken.prototype, "updater", void 0);
55
+ tslib_1.__decorate([
56
+ (0, typeorm_1.RelationId)((notificationToken) => notificationToken.updater),
57
+ tslib_1.__metadata("design:type", String)
58
+ ], NotificationToken.prototype, "updaterId", void 0);
59
+ exports.NotificationToken = NotificationToken = tslib_1.__decorate([
60
+ (0, typeorm_1.Entity)(),
61
+ (0, typeorm_1.Index)('ix_notification_token_0', (notificationToken) => [notificationToken.token], { unique: true }),
62
+ (0, typeorm_1.Index)('ix_notification_token_1', (notificationToken) => [notificationToken.user], { unique: false })
63
+ ], NotificationToken);
64
+ //# sourceMappingURL=notification-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-token.js","sourceRoot":"","sources":["../../../server/service/notification-token/notification-token.ts"],"names":[],"mappings":";;;;AAAA,qCAAkI;AAElI,yDAAgD;AAEhD;;;;;;;;GAQG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CA+B7B,CAAA;AA/BY,8CAAiB;AAEnB;IADR,IAAA,gCAAsB,EAAC,MAAM,CAAC;;6CACZ;AAGnB;IADC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;sCAC1C,gBAAI;+CAAA;AAGX;IADC,IAAA,oBAAU,EAAC,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;;iDAC9D;AAIf;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;gDACX;AAGb;IADC,IAAA,0BAAgB,GAAE;sCACP,IAAI;oDAAA;AAGhB;IADC,IAAA,0BAAgB,GAAE;sCACP,IAAI;oDAAA;AAGhB;IADC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAClC,gBAAI;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC;;oDAC9D;AAGlB;IADC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAClC,gBAAI;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC;;oDAC9D;4BA9BP,iBAAiB;IAH7B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,yBAAyB,EAAE,CAAC,iBAAoC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvH,IAAA,eAAK,EAAC,yBAAyB,EAAE,CAAC,iBAAoC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;GAC3G,iBAAiB,CA+B7B","sourcesContent":["import { CreateDateColumn, UpdateDateColumn, Entity, Index, Column, RelationId, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\n\n/**\n * One browser or installed app of a person that web push reaches - the FCM registration token it was given.\n *\n * A token belongs to the person, not to a domain: the person's phone hears from every domain they belong to, and a\n * notice carries its own full address. A token names one browser, so it is held by one person at a time - when\n * someone else signs in on that browser and turns notices on, the token moves to them.\n *\n * It is a device handle, not a record: a token turned off or refused by FCM is deleted, not kept.\n */\n@Entity()\n@Index('ix_notification_token_0', (notificationToken: NotificationToken) => [notificationToken.token], { unique: true })\n@Index('ix_notification_token_1', (notificationToken: NotificationToken) => [notificationToken.user], { unique: false })\nexport class NotificationToken {\n @PrimaryGeneratedColumn('uuid')\n readonly id: string\n\n @ManyToOne(type => User, { onDelete: 'CASCADE' })\n user?: User\n\n @RelationId((notificationToken: NotificationToken) => notificationToken.user)\n userId?: string\n\n /* FCM tokens run to about 160 characters today; the room is for what FCM may hand out later. */\n @Column({ length: 512 })\n token: string\n\n @CreateDateColumn()\n createdAt?: Date\n\n @UpdateDateColumn()\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n creator?: User\n\n @RelationId((notificationToken: NotificationToken) => notificationToken.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n updater?: User\n\n @RelationId((notificationToken: NotificationToken) => notificationToken.updater)\n updaterId?: string\n}\n"]}