@stacksjs/notifications 0.62.0 → 0.63.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.js +3 -52
- package/dist/index.js.map +14 -0
- package/package.json +1 -11
package/dist/index.js
CHANGED
|
@@ -1,54 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import process from "process";
|
|
4
|
-
import {log} from "@stacksjs/cli";
|
|
5
|
-
import {notification as config2} from "@stacksjs/config";
|
|
6
|
-
import {err} from "@stacksjs/error-handling";
|
|
7
|
-
import {ExitCode} from "@stacksjs/types";
|
|
2
|
+
import m from"process";import{log as s}from"@stacksjs/cli";import{notification as r}from"@stacksjs/config";import{err as p}from"@stacksjs/error-handling";import{ExitCode as u}from"@stacksjs/types";import*as i from"@stacksjs/chat";import*as a from"@stacksjs/email";import*as k from"@stacksjs/push";import*as f from"@stacksjs/sms";function c(t="slack"){return i[t]}function l(t="mailtrap"){return a[t]}function x(t="twilio"){return f[t]}function d(t="email",n="mailtrap"){if(!r.default)return s.error("No default notification type set in config/notification.ts"),m.exit(u.InvalidArgument);const e=t||r.default,o=n||r.default;switch(e){case"email":return l(o);case"chat":return c(o);case"sms":return x(o);default:return p(`Type ${e} not supported`)}}function j(){return d()}export{x as useSMS,d as useNotification,l as useEmail,c as useChat,j as notification};
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// src/drivers/email.ts
|
|
12
|
-
import * as email from "@stacksjs/email";
|
|
13
|
-
// src/drivers/push.ts
|
|
14
|
-
import * as push from "@stacksjs/push";
|
|
15
|
-
// src/drivers/sms.ts
|
|
16
|
-
import * as sms from "@stacksjs/sms";
|
|
17
|
-
// src/index.ts
|
|
18
|
-
var useChat = function(driver = "slack") {
|
|
19
|
-
return chat[driver];
|
|
20
|
-
};
|
|
21
|
-
var useEmail = function(driver = "mailtrap") {
|
|
22
|
-
return email[driver];
|
|
23
|
-
};
|
|
24
|
-
var useSMS = function(driver = "twilio") {
|
|
25
|
-
return sms[driver];
|
|
26
|
-
};
|
|
27
|
-
var useNotification = function(typeParam = "email", driverParam = "mailtrap") {
|
|
28
|
-
if (!config2.default) {
|
|
29
|
-
log.error("No default notification type set in config/notification.ts");
|
|
30
|
-
return process.exit(ExitCode.InvalidArgument);
|
|
31
|
-
}
|
|
32
|
-
const type = typeParam || config2.default;
|
|
33
|
-
const driver = driverParam || config2.default;
|
|
34
|
-
switch (type) {
|
|
35
|
-
case "email":
|
|
36
|
-
return useEmail(driver);
|
|
37
|
-
case "chat":
|
|
38
|
-
return useChat(driver);
|
|
39
|
-
case "sms":
|
|
40
|
-
return useSMS(driver);
|
|
41
|
-
default:
|
|
42
|
-
return err(`Type ${type} not supported`);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var notification = function() {
|
|
46
|
-
return useNotification();
|
|
47
|
-
};
|
|
48
|
-
export {
|
|
49
|
-
useSMS,
|
|
50
|
-
useNotification,
|
|
51
|
-
useEmail,
|
|
52
|
-
useChat,
|
|
53
|
-
notification
|
|
54
|
-
};
|
|
4
|
+
//# debugId=D49DFD7988CA032764756E2164756E21
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/drivers/chat.ts", "../src/drivers/email.ts", "../src/drivers/push.ts", "../src/drivers/sms.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import process from 'node:process'\nimport { log } from '@stacksjs/cli'\nimport { notification as config } from '@stacksjs/config'\nimport { err } from '@stacksjs/error-handling'\nimport { ExitCode } from '@stacksjs/types'\nimport { chat, email, sms } from './drivers'\n\nfunction useChat(driver = 'slack') {\n return chat[driver as keyof typeof chat]\n}\n\nfunction useEmail(driver = 'mailtrap') {\n return email[driver as keyof typeof email]\n}\n\nfunction useSMS(driver = 'twilio') {\n return sms[driver as keyof typeof sms]\n}\n\nfunction useNotification(typeParam = 'email', driverParam = 'mailtrap') {\n if (!config.default) {\n log.error('No default notification type set in config/notification.ts')\n return process.exit(ExitCode.InvalidArgument)\n }\n\n const type = typeParam || config.default\n const driver = driverParam || config.default\n\n switch (type) {\n case 'email':\n return useEmail(driver)\n case 'chat':\n return useChat(driver)\n case 'sms':\n return useSMS(driver)\n default:\n return err(`Type ${type} not supported`)\n }\n}\n\nfunction notification() {\n return useNotification()\n}\n\nexport { useEmail, useChat, useSMS, useNotification, notification }\n",
|
|
6
|
+
"export * as chat from '@stacksjs/chat'\n",
|
|
7
|
+
"export * as email from '@stacksjs/email'\n",
|
|
8
|
+
"export * as push from '@stacksjs/push'\n",
|
|
9
|
+
"export * as sms from '@stacksjs/sms'\n"
|
|
10
|
+
],
|
|
11
|
+
"mappings": ";AAAA,uBACA,cAAS,sBACT,uBAAS,yBACT,cAAS,iCACT,mBAAS,wBCJT,iCCAA,kCCAA,iCCAA,gCJOA,SAAS,CAAO,CAAC,EAAS,QAAS,CACjC,OAAO,EAAK,GAGd,SAAS,CAAQ,CAAC,EAAS,WAAY,CACrC,OAAO,EAAM,GAGf,SAAS,CAAM,CAAC,EAAS,SAAU,CACjC,OAAO,EAAI,GAGb,SAAS,CAAe,CAAC,EAAY,QAAS,EAAc,WAAY,CACtE,IAAK,EAAO,QAEV,OADA,EAAI,MAAM,4DAA4D,EAC/D,EAAQ,KAAK,EAAS,eAAe,EAG9C,MAAM,EAAO,GAAa,EAAO,QAC3B,EAAS,GAAe,EAAO,QAErC,OAAQ,OACD,QACH,OAAO,EAAS,CAAM,MACnB,OACH,OAAO,EAAQ,CAAM,MAClB,MACH,OAAO,EAAO,CAAM,UAEpB,OAAO,EAAI,QAAQ,iBAAoB,GAI7C,SAAS,CAAY,EAAG,CACtB,OAAO,EAAgB",
|
|
12
|
+
"debugId": "D49DFD7988CA032764756E2164756E21",
|
|
13
|
+
"names": []
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/notifications",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.63.1",
|
|
5
5
|
"description": "The Stacks notifications integration.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -53,16 +53,6 @@
|
|
|
53
53
|
"typecheck": "bun --bun tsc --noEmit",
|
|
54
54
|
"prepublishOnly": "bun run build"
|
|
55
55
|
},
|
|
56
|
-
"peerDependencies": {
|
|
57
|
-
"@stacksjs/chat": "latest",
|
|
58
|
-
"@stacksjs/cli": "latest",
|
|
59
|
-
"@stacksjs/config": "latest",
|
|
60
|
-
"@stacksjs/email": "latest",
|
|
61
|
-
"@stacksjs/error-handling": "latest",
|
|
62
|
-
"@stacksjs/push": "latest",
|
|
63
|
-
"@stacksjs/sms": "latest",
|
|
64
|
-
"@stacksjs/types": "latest"
|
|
65
|
-
},
|
|
66
56
|
"dependencies": {
|
|
67
57
|
"@stacksjs/chat": "latest",
|
|
68
58
|
"@stacksjs/cli": "latest",
|