@or-sdk/notifications 1.1.0-beta.688.0

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.
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.Notifications = void 0;
55
+ var base_1 = require("@or-sdk/base");
56
+ var constants_1 = require("./constants");
57
+ var Notifications = (function (_super) {
58
+ __extends(Notifications, _super);
59
+ function Notifications(params) {
60
+ var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, notificationsUrl = params.notificationsUrl;
61
+ return _super.call(this, {
62
+ token: token,
63
+ discoveryUrl: discoveryUrl,
64
+ serviceKey: constants_1.SERVICE_KEY,
65
+ accountId: accountId,
66
+ serviceUrl: notificationsUrl,
67
+ }) || this;
68
+ }
69
+ Notifications.prototype.list = function (params) {
70
+ if (params === void 0) { params = {}; }
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ return __generator(this, function (_a) {
73
+ return [2, this.callApiV2({
74
+ route: '/user',
75
+ method: 'GET',
76
+ params: params,
77
+ })];
78
+ });
79
+ });
80
+ };
81
+ Notifications.prototype.markSeen = function () {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ return [2, this.callApiV2({
85
+ route: '/user',
86
+ method: 'POST',
87
+ })];
88
+ });
89
+ });
90
+ };
91
+ Notifications.prototype.createUserNotification = function (data) {
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ return __generator(this, function (_a) {
94
+ return [2, this.callApiV2({
95
+ route: '/user',
96
+ method: 'PUT',
97
+ data: data,
98
+ })];
99
+ });
100
+ });
101
+ };
102
+ Notifications.prototype.SACreateNotification = function (data) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ return [2, this.callApiV2({
106
+ route: '/service',
107
+ method: 'PUT',
108
+ data: data,
109
+ })];
110
+ });
111
+ });
112
+ };
113
+ Notifications.prototype.SAListNotifications = function (params) {
114
+ if (params === void 0) { params = {}; }
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ return __generator(this, function (_a) {
117
+ return [2, this.callApiV2({
118
+ route: '/service',
119
+ method: 'GET',
120
+ params: params,
121
+ })];
122
+ });
123
+ });
124
+ };
125
+ Notifications.prototype.SAUpdateNotification = function (id, data) {
126
+ return __awaiter(this, void 0, void 0, function () {
127
+ return __generator(this, function (_a) {
128
+ return [2, this.callApiV2({
129
+ route: "/service/".concat(id),
130
+ method: 'POST',
131
+ data: data,
132
+ })];
133
+ });
134
+ });
135
+ };
136
+ Notifications.prototype.SADeleteNotification = function (id) {
137
+ return __awaiter(this, void 0, void 0, function () {
138
+ return __generator(this, function (_a) {
139
+ return [2, this.callApiV2({
140
+ route: "/service/".concat(id),
141
+ method: 'DELETE',
142
+ })];
143
+ });
144
+ });
145
+ };
146
+ Notifications.prototype.createTrailEvent = function (data) {
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ return __generator(this, function (_a) {
149
+ return [2, this.callApiV2({
150
+ route: '/trail',
151
+ method: 'PUT',
152
+ data: data,
153
+ })];
154
+ });
155
+ });
156
+ };
157
+ Notifications.prototype.listTrailEvents = function (params) {
158
+ if (params === void 0) { params = {}; }
159
+ return __awaiter(this, void 0, void 0, function () {
160
+ return __generator(this, function (_a) {
161
+ return [2, this.callApiV2({
162
+ route: '/trail',
163
+ method: 'GET',
164
+ params: params,
165
+ })];
166
+ });
167
+ });
168
+ };
169
+ return Notifications;
170
+ }(base_1.Base));
171
+ exports.Notifications = Notifications;
172
+ //# sourceMappingURL=Notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notifications.js","sourceRoot":"","sources":["../../src/Notifications.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoC;AACpC,yCAA0C;AAU1C;IAAmC,iCAAI;IAOrC,uBAAY,MAA2B;QAC7B,IAAA,KAAK,GAAgD,MAAM,MAAtD,EAAE,YAAY,GAAkC,MAAM,aAAxC,EAAE,SAAS,GAAuB,MAAM,UAA7B,EAAE,gBAAgB,GAAK,MAAM,iBAAX,CAAY;eAEpE,kBAAM;YACJ,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,UAAU,EAAE,uBAAW;YACvB,SAAS,WAAA;YACT,UAAU,EAAE,gBAAgB;SAC7B,CAAC;IACJ,CAAC;IAQY,4BAAI,GAAjB,UAAkB,MAAsC;QAAtC,uBAAA,EAAA,SAAS,EAA6B;;;gBACtD,WAAO,IAAI,CAAC,SAAS,CAAC;wBACpB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,KAAK;wBACb,MAAM,QAAA;qBACP,CAAC,EAAC;;;KACJ;IAQY,gCAAQ,GAArB;;;gBACE,WAAO,IAAI,CAAC,SAAS,CAAC;wBACpB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,MAAM;qBACf,CAAC,EAAC;;;KACJ;IAQY,8CAAsB,GAAnC,UAAoC,IAAyB;;;gBAC3D,WAAO,IAAI,CAAC,SAAS,CAAC;wB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A/ID,CAAmC,WAAI,GA+ItC;AA/IY,sCAAa"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERVICE_KEY = void 0;
4
+ exports.SERVICE_KEY = 'notifications-api';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Notifications = void 0;
18
+ var Notifications_1 = require("./Notifications");
19
+ Object.defineProperty(exports, "Notifications", { enumerable: true, get: function () { return Notifications_1.Notifications; } });
20
+ __exportStar(require("./types"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,0CAAwB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,103 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Base } from '@or-sdk/base';
11
+ import { SERVICE_KEY } from './constants';
12
+ export class Notifications extends Base {
13
+ constructor(params) {
14
+ const { token, discoveryUrl, accountId, notificationsUrl } = params;
15
+ super({
16
+ token,
17
+ discoveryUrl,
18
+ serviceKey: SERVICE_KEY,
19
+ accountId,
20
+ serviceUrl: notificationsUrl,
21
+ });
22
+ }
23
+ list(params = {}) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this.callApiV2({
26
+ route: '/user',
27
+ method: 'GET',
28
+ params,
29
+ });
30
+ });
31
+ }
32
+ markSeen() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ return this.callApiV2({
35
+ route: '/user',
36
+ method: 'POST',
37
+ });
38
+ });
39
+ }
40
+ createUserNotification(data) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ return this.callApiV2({
43
+ route: '/user',
44
+ method: 'PUT',
45
+ data,
46
+ });
47
+ });
48
+ }
49
+ SACreateNotification(data) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ return this.callApiV2({
52
+ route: '/service',
53
+ method: 'PUT',
54
+ data,
55
+ });
56
+ });
57
+ }
58
+ SAListNotifications(params = {}) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ return this.callApiV2({
61
+ route: '/service',
62
+ method: 'GET',
63
+ params,
64
+ });
65
+ });
66
+ }
67
+ SAUpdateNotification(id, data) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return this.callApiV2({
70
+ route: `/service/${id}`,
71
+ method: 'POST',
72
+ data,
73
+ });
74
+ });
75
+ }
76
+ SADeleteNotification(id) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ return this.callApiV2({
79
+ route: `/service/${id}`,
80
+ method: 'DELETE',
81
+ });
82
+ });
83
+ }
84
+ createTrailEvent(data) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ return this.callApiV2({
87
+ route: '/trail',
88
+ method: 'PUT',
89
+ data,
90
+ });
91
+ });
92
+ }
93
+ listTrailEvents(params = {}) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ return this.callApiV2({
96
+ route: '/trail',
97
+ method: 'GET',
98
+ params,
99
+ });
100
+ });
101
+ }
102
+ }
103
+ //# sourceMappingURL=Notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notifications.js","sourceRoot":"","sources":["../../src/Notifications.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,MAAM,OAAO,aAAc,SAAQ,IAAI;IAOrC,YAAY,MAA2B;QACrC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC;QAEpE,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,UAAU,EAAE,WAAW;YACvB,SAAS;YACT,UAAU,EAAE,gBAAgB;SAC7B,CAAC,CAAC;IACL,CAAC;IAQY,IAAI,CAAC,SAAS,EAA6B;;YACtD,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,OAAO;gBACd,MAAM,EAAE,KAAK;gBACb,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;IA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,MAAM,EAAE,KAAK;gBACb,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
@@ -0,0 +1,2 @@
1
+ export const SERVICE_KEY = 'notifications-api';
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Notifications } from './Notifications';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { Base } from '@or-sdk/base';
2
+ import { NotificationsConfig, ListNotificationsParams, NotificationItem, NewUserNotification, SAListNotifications, FullNotificationItem, NewTrailEvent, ListTrailParams, TrailEvent } from './types';
3
+ export declare class Notifications extends Base {
4
+ constructor(params: NotificationsConfig);
5
+ list(params?: ListNotificationsParams): Promise<NotificationItem[]>;
6
+ markSeen(): Promise<null>;
7
+ createUserNotification(data: NewUserNotification): Promise<null>;
8
+ SACreateNotification(data: FullNotificationItem): Promise<null>;
9
+ SAListNotifications(params?: SAListNotifications): Promise<FullNotificationItem[]>;
10
+ SAUpdateNotification(id: string, data: FullNotificationItem): Promise<null>;
11
+ SADeleteNotification(id: string): Promise<null>;
12
+ createTrailEvent(data: NewTrailEvent): Promise<null>;
13
+ listTrailEvents(params?: ListTrailParams): Promise<TrailEvent[]>;
14
+ }
15
+ //# sourceMappingURL=Notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notifications.d.ts","sourceRoot":"","sources":["../../src/Notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AASrM,qBAAa,aAAc,SAAQ,IAAI;gBAOzB,MAAM,EAAE,mBAAmB;IAkB1B,IAAI,CAAC,MAAM,0BAAgC,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAczE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAazB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAchE,oBAAoB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAc/D,mBAAmB,CAAC,MAAM,sBAA4B,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAcxF,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3E,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/C,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAepD,eAAe,CAAC,MAAM,kBAAwB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAOpF"}
@@ -0,0 +1,2 @@
1
+ export declare const SERVICE_KEY = "notifications-api";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Notifications } from './Notifications';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { Token } from '@or-sdk/base';
2
+ export declare type NotificationsConfig = {
3
+ token: Token;
4
+ discoveryUrl?: string;
5
+ notificationsUrl?: string;
6
+ accountId?: string;
7
+ };
8
+ export declare type ListNotificationsParams = {
9
+ limit?: number;
10
+ offset?: number;
11
+ };
12
+ export declare type NotificationData = {
13
+ message: string;
14
+ img: string;
15
+ tags: string[];
16
+ };
17
+ export declare type NotificationItem = {
18
+ id: string;
19
+ data: NotificationData;
20
+ dateCreated: Date;
21
+ seen: boolean;
22
+ };
23
+ export declare type NewUserNotification = {
24
+ type: string;
25
+ data: NotificationData;
26
+ };
27
+ export declare type FullNotificationItem = NotificationItem & {
28
+ userId?: string;
29
+ accountId?: string;
30
+ parentId?: string;
31
+ type: string;
32
+ };
33
+ export declare type SAListNotifications = {
34
+ limit?: number;
35
+ offset: number;
36
+ userId?: string;
37
+ accountId?: string;
38
+ parentId?: string;
39
+ type?: string;
40
+ id?: string;
41
+ dateCreated?: Date;
42
+ seen?: boolean;
43
+ data?: {
44
+ message?: string;
45
+ img?: string;
46
+ tags?: string[];
47
+ };
48
+ };
49
+ export declare type NewTrailEvent = {
50
+ service: string;
51
+ data: {
52
+ message: string;
53
+ };
54
+ };
55
+ export declare type ListTrailParams = {
56
+ limit?: number;
57
+ offset?: number;
58
+ service?: string;
59
+ };
60
+ export declare type TrailEvent = {
61
+ id: string;
62
+ data: {
63
+ message: string;
64
+ };
65
+ dateCreated: Date;
66
+ };
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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ACZ,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,WAAW,EAAE,IAAI,CAAC;CACnB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "version": "1.1.0-beta.688.0",
3
+ "name": "@or-sdk/notifications",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
9
+ "build:cjs": "tsc --project tsconfig.json",
10
+ "build:esm": "tsc --project tsconfig.esm.json",
11
+ "build:types": "tsc --project tsconfig.types.json",
12
+ "build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
13
+ "build:watch:cjs": "tsc --project tsconfig.json -w",
14
+ "build:watch:esm": "tsc --project tsconfig.esm.json -w",
15
+ "build:watch:types": "tsc --project tsconfig.types.json -w",
16
+ "clean": "rm -rf ./dist",
17
+ "dev": "pnpm build:watch:esm"
18
+ },
19
+ "devDependencies": {
20
+ "concurrently": "^6.4.0",
21
+ "typescript": "^4.4.4"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "dependencies": {
27
+ "@or-sdk/base": "^0.26.7"
28
+ }
29
+ }
@@ -0,0 +1,157 @@
1
+ import { Base } from '@or-sdk/base';
2
+ import { SERVICE_KEY } from './constants';
3
+ import { NotificationsConfig, ListNotificationsParams, NotificationItem, NewUserNotification, SAListNotifications, FullNotificationItem, NewTrailEvent, ListTrailParams, TrailEvent } from './types';
4
+
5
+ /**
6
+ * OneReach Notifications service client
7
+ * ## Installation:
8
+ * ```
9
+ * $ npm i @or-sdk/notifications
10
+ * ```
11
+ */
12
+ export class Notifications extends Base {
13
+ /**
14
+ * ```typescript
15
+ * import { Notifications } from '@or-sdk/notifications'
16
+ * const notifications = new Notifications({token: () => token', notificationsUrl: 'https://example'});
17
+ * ```
18
+ */
19
+ constructor(params: NotificationsConfig) {
20
+ const { token, discoveryUrl, accountId, notificationsUrl } = params;
21
+
22
+ super({
23
+ token,
24
+ discoveryUrl,
25
+ serviceKey: SERVICE_KEY,
26
+ accountId,
27
+ serviceUrl: notificationsUrl,
28
+ });
29
+ }
30
+
31
+ /**
32
+ * List notifications
33
+ * ```typescript
34
+ * await notifications.list({limit, offset});
35
+ * ```
36
+ */
37
+ public async list(params = {} as ListNotificationsParams): Promise<NotificationItem[]> {
38
+ return this.callApiV2({
39
+ route: '/user',
40
+ method: 'GET',
41
+ params,
42
+ });
43
+ }
44
+
45
+ /**
46
+ * Mark all notifications seen
47
+ * ```typescript
48
+ * await notifications.markSeen();
49
+ * ```
50
+ */
51
+ public async markSeen(): Promise<null> {
52
+ return this.callApiV2({
53
+ route: '/user',
54
+ method: 'POST',
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Create user notification
60
+ * ```typescript
61
+ * await notifications.createUserNotification({type, data});
62
+ * ```
63
+ */
64
+ public async createUserNotification(data: NewUserNotification): Promise<null> {
65
+ return this.callApiV2({
66
+ route: '/user',
67
+ method: 'PUT',
68
+ data,
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Super admin create notification
74
+ * ```typescript
75
+ * await notifications.SACreateNotification({type, data, accountId, userId, dateCreated, parentId});
76
+ * ```
77
+ */
78
+ public async SACreateNotification(data: FullNotificationItem): Promise<null> {
79
+ return this.callApiV2({
80
+ route: '/service',
81
+ method: 'PUT',
82
+ data,
83
+ });
84
+ }
85
+
86
+ /**
87
+ * Super admin list notifications
88
+ * ```typescript
89
+ * await notifications.SAListNotifications({id, accountId,userId, dateCreated, type, seen, limit, offset, parentId});
90
+ * ```
91
+ */
92
+ public async SAListNotifications(params = {} as SAListNotifications): Promise<FullNotificationItem[]> {
93
+ return this.callApiV2({
94
+ route: '/service',
95
+ method: 'GET',
96
+ params,
97
+ });
98
+ }
99
+
100
+ /**
101
+ * Super admin create notification
102
+ * ```typescript
103
+ * await notifications.SAUpdateNotification(id, {type, data, accountId, userId, dateCreated, parentId});
104
+ * ```
105
+ */
106
+ public async SAUpdateNotification(id: string, data: FullNotificationItem): Promise<null> {
107
+ return this.callApiV2({
108
+ route: `/service/${id}`,
109
+ method: 'POST',
110
+ data,
111
+ });
112
+ }
113
+
114
+ /**
115
+ * Super admin delete notification
116
+ * ```typescript
117
+ * await notifications.SADeleteNotification(id);
118
+ * ```
119
+ */
120
+ public async SADeleteNotification(id: string): Promise<null> {
121
+ return this.callApiV2({
122
+ route: `/service/${id}`,
123
+ method: 'DELETE',
124
+ });
125
+ }
126
+
127
+ /**
128
+ * Create trail event
129
+ * ```typescript
130
+ * await notifications.createTrailEvent({service, data});
131
+ * ```
132
+ */
133
+ public async createTrailEvent(data: NewTrailEvent): Promise<null> {
134
+ return this.callApiV2({
135
+ route: '/trail',
136
+ method: 'PUT',
137
+ data,
138
+ });
139
+ }
140
+
141
+
142
+ /**
143
+ * List trail event
144
+ * ```typescript
145
+ * await notifications.listTrailEvents({limit, offset, service});
146
+ * ```
147
+ */
148
+ public async listTrailEvents(params = {} as ListTrailParams): Promise<TrailEvent[]> {
149
+ return this.callApiV2({
150
+ route: '/trail',
151
+ method: 'GET',
152
+ params,
153
+ });
154
+ }
155
+ }
156
+
157
+
@@ -0,0 +1 @@
1
+ export const SERVICE_KEY = 'notifications-api';
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Notifications } from './Notifications';
2
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,92 @@
1
+ import { Token } from '@or-sdk/base';
2
+
3
+ export type NotificationsConfig = {
4
+ /**
5
+ * token
6
+ */
7
+ token: Token;
8
+ /**
9
+ * service discrovery url
10
+ */
11
+ discoveryUrl?: string;
12
+
13
+ /**
14
+ * url of notifications service
15
+ */
16
+ notificationsUrl?: string;
17
+
18
+ /**
19
+ * Account id for cross account re
20
+ */
21
+ accountId?: string;
22
+ };
23
+
24
+
25
+ export type ListNotificationsParams = {
26
+ limit?: number;
27
+ offset?: number;
28
+ };
29
+
30
+ export type NotificationData = {
31
+ message: string;
32
+ img: string;
33
+ tags: string[];
34
+ };
35
+
36
+ export type NotificationItem = {
37
+ id: string;
38
+ data: NotificationData;
39
+ dateCreated: Date;
40
+ seen: boolean;
41
+ };
42
+
43
+ export type NewUserNotification = {
44
+ type: string;
45
+ data: NotificationData;
46
+ };
47
+
48
+ export type FullNotificationItem = NotificationItem & {
49
+ userId?: string;
50
+ accountId?: string;
51
+ parentId?: string;
52
+ type: string;
53
+ };
54
+
55
+
56
+ export type SAListNotifications = {
57
+ limit?: number;
58
+ offset: number;
59
+ userId?: string;
60
+ accountId?: string;
61
+ parentId?: string;
62
+ type?: string;
63
+ id?: string;
64
+ dateCreated?: Date;
65
+ seen?: boolean;
66
+ data?: {
67
+ message?: string;
68
+ img?: string;
69
+ tags?: string[];
70
+ };
71
+ };
72
+
73
+ export type NewTrailEvent = {
74
+ service: string;
75
+ data: {
76
+ message: string;
77
+ };
78
+ };
79
+
80
+ export type ListTrailParams = {
81
+ limit?: number;
82
+ offset?: number;
83
+ service?: string;
84
+ };
85
+
86
+ export type TrailEvent = {
87
+ id: string;
88
+ data: {
89
+ message: string;
90
+ };
91
+ dateCreated: Date;
92
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "./dist/types",
5
+ "rootDir": "./src",
6
+ "declaration": true
7
+ }
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/esm",
5
+ "declarationDir": "./dist/types",
6
+ "module": "ES6",
7
+ "target": "es6",
8
+ "rootDir": "./src",
9
+ "declaration": true,
10
+ "declarationMap": true
11
+ }
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/cjs/",
5
+ "rootDir": "./src"
6
+ }
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/types/",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "emitDeclarationOnly": true
9
+ }
10
+ }