diff --git a/client/packages/tailchat-client-sdk/.gitignore b/client/packages/tailchat-client-sdk/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/client/packages/tailchat-client-sdk/.gitignore @@ -0,0 +1 @@ +lib diff --git a/client/packages/tailchat-client-sdk/package.json b/client/packages/tailchat-client-sdk/package.json new file mode 100644 index 00000000..b3b6d8cc --- /dev/null +++ b/client/packages/tailchat-client-sdk/package.json @@ -0,0 +1,20 @@ +{ + "name": "tailchat-client-sdk", + "version": "1.0.0", + "description": "", + "main": "lib/index.js", + "scripts": { + "prepare": "tsc", + "release": "npm publish --registry https://registry.npmjs.com/", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "moonrailgun ", + "license": "MIT", + "devDependencies": { + "typescript": "^4.9.5" + }, + "dependencies": { + "axios": "^1.3.2" + } +} diff --git a/client/packages/tailchat-client-sdk/src/index.ts b/client/packages/tailchat-client-sdk/src/index.ts new file mode 100644 index 00000000..574c9869 --- /dev/null +++ b/client/packages/tailchat-client-sdk/src/index.ts @@ -0,0 +1 @@ +export * from './plugins/simplenotify'; diff --git a/client/packages/tailchat-client-sdk/src/plugins/simplenotify.ts b/client/packages/tailchat-client-sdk/src/plugins/simplenotify.ts new file mode 100644 index 00000000..3ea33df5 --- /dev/null +++ b/client/packages/tailchat-client-sdk/src/plugins/simplenotify.ts @@ -0,0 +1,24 @@ +import axios from 'axios'; + +/** + * 基于简易推送插件的消息通知服务 + * + * @param hostUrl 实例地址url + * @param subscribeId 订阅id + * @param text 发送的文本,默认支持bbcode + */ +export async function sendSimpleNotify( + hostUrl: string, + subscribeId: string, + text: string +) { + await axios({ + method: 'post', + baseURL: hostUrl, + url: '/api/plugin:com.msgbyte.simplenotify/webhook/callback', + data: { + subscribeId, + text, + }, + }); +} diff --git a/client/packages/tailchat-client-sdk/tsconfig.json b/client/packages/tailchat-client-sdk/tsconfig.json new file mode 100644 index 00000000..fcd70dbc --- /dev/null +++ b/client/packages/tailchat-client-sdk/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "esnext", + "lib": ["ESNext"], + "outDir": "lib", + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "isolatedModules": true, + "module": "CommonJS", + "moduleResolution": "node", + "strict": true, + "importsNotUsedAsValues": "error", + }, + "include": ["./src/*"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f6aca88c..a0422520 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -288,6 +288,15 @@ importers: '@types/node': 18.11.16 ts-node: 10.9.1_rmyookn2hbqnnqjamditnjqvjq + client/packages/tailchat-client-sdk: + specifiers: + axios: ^1.3.2 + typescript: ^4.9.5 + dependencies: + axios: 1.3.2 + devDependencies: + typescript: 4.9.5 + client/shared: specifiers: '@reduxjs/toolkit': ^1.7.1 @@ -15395,6 +15404,16 @@ packages: - debug dev: false + /axios/1.3.2: + resolution: {integrity: sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==} + dependencies: + follow-redirects: 1.15.2 + form-data: 4.0.0 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + dev: false + /b-tween/0.3.3: resolution: {integrity: sha512-oEHegcRpA7fAuc9KC4nktucuZn2aS8htymCPcP3qkEGPqiBH+GfqtqoG2l7LxHngg6O0HFM7hOeOYExl1Oz4ZA==} dev: false @@ -37616,6 +37635,12 @@ packages: engines: {node: '>=4.2.0'} hasBin: true + /typescript/4.9.5: + resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} + engines: {node: '>=4.2.0'} + hasBin: true + dev: true + /ua-parser-js/0.7.31: resolution: {integrity: sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ==} dev: false