Socket
Socket
Sign inDemoInstall

@alipay/faas-server-sdk

Package Overview
Dependencies
Maintainers
3
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/faas-server-sdk - npm Package Compare versions

Comparing version 1.1.21-alpha.3 to 1.1.21-alpha.4

20

lib/Websocket.d.ts

@@ -16,2 +16,16 @@ import { CloudConfig } from '@alipay/faas-server-utils';

}
export interface IsAliveManyResponse {
aliveCount: number;
allCount: number;
aliveConnIds: string[];
deadConnIds: string[];
requestID: string;
}
export interface IsAliveOneResponse {
isAlive: boolean;
requestID: string;
}
export interface WebSocketCloseOptions {
status?: 'NORMAL' | 'GOING_AWAY' | 'PROTOCOL_ERROR' | 'BAD_DATA' | 'TOO_BIG_TO_PROCESS' | 'SERVER_ERROR' | 'SERVICE_RESTARTED' | 'SERVICE_OVERLOAD' | 'USER_STATUS_1' | 'USER_STATUS_2' | 'USER_STATUS_3' | string;
}
export declare class WebsocketSDK {

@@ -22,4 +36,6 @@ #private;

send(connectionId: string, data: any): Promise<ToOneResponse>;
close(connectionId: string[]): Promise<ToManyResponse>;
close(connectionId: string): Promise<ToOneResponse>;
close(connectionId: string[], opts?: WebSocketCloseOptions): Promise<ToManyResponse>;
close(connectionId: string, opts?: WebSocketCloseOptions): Promise<ToOneResponse>;
isAlive(connectionId: string[]): Promise<IsAliveManyResponse>;
isAlive(connectionId: string): Promise<IsAliveOneResponse>;
}

2

lib/Websocket.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WebsocketSDK=void 0;const errors_1=require("./errors"),requester_1=require("./requester");class WebsocketSDK{#t;constructor(e){this.#t=requester_1.Httpclient.createWebsocketHttpclient(e)}async send(e,t){let s="TEXT",r;typeof t=="string"?r=t:Buffer.isBuffer(t)?(r=t.toString("base64"),s="BINARY"):r=JSON.stringify(t);const a=Array.isArray(e)?e:[e];return a.length===1?await this.#a(a[0],{type:s,payload:r}):await this.#n(a,{type:s,payload:r})}async close(e){const t=Array.isArray(e)?e:[e];return t.length===1?await this.#o(t[0]):await this.#c(t)}async#a(e,t){const s=await this.#t.request({method:"POST",path:`/connection/send/${e}`,data:t});return this.#s(s)}async#n(e,t){const s=await this.#t.request({method:"POST",path:"/connection/batch/send",data:{connIds:e,message:t}});return this.#r(s)}async#o(e){const t=await this.#t.request({method:"POST",path:`/connection/close/${e}`});return this.#s(t)}async#c(e){const t=await this.#t.request({method:"POST",path:"/connection/batch/close",data:{connIds:e}});return this.#r(t)}#e(e){if(e.status!==200){const{errorCode:t,resultMsg:s,detailMsg:r,traceId:a,requestId:n}=e.data||{},o=s??"\u7F51\u7EDC\u5F02\u5E38";throw errors_1.errors.WEBSOCKET_ERR(o,t?`${t}(${e.status})`:`${e.status}`,r,a||n)}if(!e.data.success){const{errorCode:t,resultMsg:s,detailMsg:r,traceId:a,requestId:n}=e.data;throw errors_1.errors.WEBSOCKET_ERR(s,t,r,a||n)}return e.data}#s(e){const t=this.#e(e);return{success:t.data,requestID:t.requestId||t.traceId}}#r(e){const t=this.#e(e);return{requestID:t.requestId||t.traceId,...t.data}}}exports.WebsocketSDK=WebsocketSDK;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WebsocketSDK=void 0;const errors_1=require("./errors"),requester_1=require("./requester");class WebsocketSDK{#t;constructor(t){this.#t=requester_1.Httpclient.createWebsocketHttpclient(t)}async send(t,e){let s="TEXT",r;typeof e=="string"?r=e:Buffer.isBuffer(e)?(r=e.toString("base64"),s="BINARY"):r=JSON.stringify(e);const a=Array.isArray(t)?t:[t];return a.length===1?await this.#a(a[0],{type:s,payload:r}):await this.#i(a,{type:s,payload:r})}async close(t,e){const s=Array.isArray(t)?t:[t];return s.length===1?await this.#n(s[0],e):await this.#c(s,e)}async isAlive(t){const e=Array.isArray(t)?t:[t];return e.length===1?await this.#o(e[0]):await this.#u(e)}async#a(t,e){const s=await this.#t.request({method:"POST",path:`/connection/send/${t}`,data:e});return this.#r(s)}async#i(t,e){const s=await this.#t.request({method:"POST",path:"/connection/batch/send",data:{connIds:t,message:e}});return this.#s(s)}async#n(t,e){const s=await this.#t.request({method:"POST",path:e?.status?`/connection/close/${e.status}/${t}`:`/connection/close/${t}`});return this.#r(s)}async#c(t,e){const s=await this.#t.request({method:"POST",path:"/connection/batch/close",data:{connIds:t,status:e?.status}});return this.#s(s)}async#o(t){const e=await this.#t.request({method:"POST",path:`/connection/isAlive/${t}`}),s=this.#e(e);return{isAlive:s.data,requestID:s.requestId||s.traceId}}async#u(t){const e=await this.#t.request({method:"POST",path:"/connection/batch/isAlive",data:{connIds:t}});return this.#s(e)}#e(t){if(t.status!==200){const{errorCode:e,resultMsg:s,detailMsg:r,traceId:a,requestId:i}=t.data||{},n=s??"\u7F51\u7EDC\u5F02\u5E38";throw errors_1.errors.WEBSOCKET_ERR(n,e?`${e}(${t.status})`:`${t.status}`,r,a||i)}if(!t.data.success){const{errorCode:e,resultMsg:s,detailMsg:r,traceId:a,requestId:i}=t.data;throw errors_1.errors.WEBSOCKET_ERR(s,e,r,a||i)}return t.data}#r(t){const e=this.#e(t);return{success:e.data,requestID:e.requestId||e.traceId}}#s(t){const e=this.#e(t);return{requestID:e.requestId||e.traceId,...e.data}}}exports.WebsocketSDK=WebsocketSDK;
{
"name": "@alipay/faas-server-sdk",
"version": "1.1.21-alpha.3",
"version": "1.1.21-alpha.4",
"description": "云函数服务 SDK",

@@ -37,5 +37,5 @@ "main": "lib/index.js",

"dependencies": {
"@alipay/faas-common-sdk": "^1.1.21-alpha.3",
"@alipay/faas-db-builder": "^1.1.21-alpha.3",
"@alipay/faas-server-utils": "^1.1.21-alpha.3",
"@alipay/faas-common-sdk": "^1.1.21-alpha.4",
"@alipay/faas-db-builder": "^1.1.21-alpha.4",
"@alipay/faas-server-utils": "^1.1.21-alpha.4",
"ali-rds": "^6.2.0",

@@ -42,0 +42,0 @@ "bson": "^4.7.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc