@notifkit/provider-console 0.1.0 → 0.1.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/dist/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export declare class ConsoleTransport implements Transport {
17
17
  constructor({ channel, logger, limits }?: ConsoleTransportOptions);
18
18
  send(task: NotificationDispatchedPayload): Promise<DeliveryResult>;
19
19
  }
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,6BAA6B,EAC7B,cAAc,EACd,mBAAmB,EACnB,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAED,qBAAa,gBAAiB,YAAW,SAAS;IAChD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;gBAErB,EAAE,OAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAE,uBAA4B;IAMxE,IAAI,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,cAAc,CAAC;CA6BzE"}
package/dist/index.js CHANGED
@@ -29,3 +29,4 @@ export class ConsoleTransport {
29
29
  return { success: true, providerMessageId };
30
30
  }
31
31
  }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,gBAAgB;IAClB,OAAO,CAAsB;IAC7B,MAAM,CAA4C;IAC1C,MAAM,CAAU;IAEjC,YAAY,EAAE,OAAO,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,KAA8B,EAAE;QAC5E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAmC;QAC5C,MAAM,iBAAiB,GAAG,WAAW,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAElD,OAAO,CAAC,GAAG,CACT;YACE,EAAE;YACF,8DAA8D;YAC9D,gBAAgB,IAAI,CAAC,WAAW,EAAE;YAClC,gBAAgB,IAAI,CAAC,WAAW,EAAE;YAClC,gBAAgB,IAAI,CAAC,QAAQ,EAAE;YAC/B,gBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE;YAC9D,gBAAgB,IAAI,CAAC,MAAM,EAAE;YAC7B,8DAA8D;YAC9D,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,IAAI,CACf;YACE,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,iBAAiB;SAClB,EACD,oCAAoC,CACrC,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC9C,CAAC;CACF","sourcesContent":["import type {\n Transport,\n NotificationDispatchedPayload,\n DeliveryResult,\n NotificationChannel,\n Logger,\n} from \"notifkit\";\n\nexport interface ConsoleTransportOptions {\n channel?: NotificationChannel;\n logger?: Logger;\n limits?: { limit: number; windowSeconds: number };\n}\n\nexport class ConsoleTransport implements Transport {\n readonly channel: NotificationChannel;\n readonly limits?: { limit: number; windowSeconds: number };\n private readonly logger?: Logger;\n\n constructor({ channel = \"push\", logger, limits }: ConsoleTransportOptions = {}) {\n this.channel = channel;\n this.logger = logger;\n this.limits = limits;\n }\n\n async send(task: NotificationDispatchedPayload): Promise<DeliveryResult> {\n const providerMessageId = `console-${Date.now()}`;\n\n console.log(\n [\n \"\",\n \"┌───────────────── 📲 PUSH NOTIFICATION ─────────────────\",\n `│ to token : ${task.destination}`,\n `│ recipient: ${task.recipientId}`,\n `│ priority : ${task.priority}`,\n `│ content : ${JSON.stringify(task.renderedContent.content)}`,\n `│ taskId : ${task.taskId}`,\n \"└───────────────────────────────────────────────────────────\",\n \"\",\n ].join(\"\\n\"),\n );\n\n this.logger?.info(\n {\n taskId: task.taskId,\n channel: this.channel,\n destination: task.destination,\n providerMessageId,\n },\n \"push delivered (console transport)\",\n );\n\n return { success: true, providerMessageId };\n }\n}\n"]}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@notifkit/provider-console",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
+ "src",
9
10
  "README.md",
10
11
  "LICENSE"
11
12
  ],
package/src/index.ts ADDED
@@ -0,0 +1,55 @@
1
+ import type {
2
+ Transport,
3
+ NotificationDispatchedPayload,
4
+ DeliveryResult,
5
+ NotificationChannel,
6
+ Logger,
7
+ } from "notifkit";
8
+
9
+ export interface ConsoleTransportOptions {
10
+ channel?: NotificationChannel;
11
+ logger?: Logger;
12
+ limits?: { limit: number; windowSeconds: number };
13
+ }
14
+
15
+ export class ConsoleTransport implements Transport {
16
+ readonly channel: NotificationChannel;
17
+ readonly limits?: { limit: number; windowSeconds: number };
18
+ private readonly logger?: Logger;
19
+
20
+ constructor({ channel = "push", logger, limits }: ConsoleTransportOptions = {}) {
21
+ this.channel = channel;
22
+ this.logger = logger;
23
+ this.limits = limits;
24
+ }
25
+
26
+ async send(task: NotificationDispatchedPayload): Promise<DeliveryResult> {
27
+ const providerMessageId = `console-${Date.now()}`;
28
+
29
+ console.log(
30
+ [
31
+ "",
32
+ "┌───────────────── 📲 PUSH NOTIFICATION ─────────────────",
33
+ `│ to token : ${task.destination}`,
34
+ `│ recipient: ${task.recipientId}`,
35
+ `│ priority : ${task.priority}`,
36
+ `│ content : ${JSON.stringify(task.renderedContent.content)}`,
37
+ `│ taskId : ${task.taskId}`,
38
+ "└───────────────────────────────────────────────────────────",
39
+ "",
40
+ ].join("\n"),
41
+ );
42
+
43
+ this.logger?.info(
44
+ {
45
+ taskId: task.taskId,
46
+ channel: this.channel,
47
+ destination: task.destination,
48
+ providerMessageId,
49
+ },
50
+ "push delivered (console transport)",
51
+ );
52
+
53
+ return { success: true, providerMessageId };
54
+ }
55
+ }