凌鲨微应用API大全

@linksaas-minapp/api

获取微应用信息

export interface MinAppInfo {
    userId: string; //用户ID(未登录为空字符串)
    userDisplayName: string;
    crossHttp: boolean;
    //打开redis代理时会设置
    redisProxyToken?: string;
    redisProxyAddr?: string;
    //打开mongo代理时会设置
    mongoProxyToken?: string;
    mongoProxyAddr?: string;
    //打开sql代理时会设置(目前支持mysql和postgres)
    sqlProxyToken?: string;
    sqlProxyAddr?: string;
    //打开ssh代理是会设置
    sshProxyToken?: string;
    sshProxyAddr?: string;
}

export function getMinAppInfo(): MinAppInfo | undefined {
    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
    return (window as any).minApp as MinAppInfo | undefined;
}

min_app_fs

获取本地文件操作的能力,需要用户授权。

使用

import min_app_fs from "@linksaas-minapp/api";

接口

export interface File {
    file_name: string;
    file_data: Uint8Array;
}

export interface Filter {
    name: string;
    extensions: string[];
}

//读取本地文件
export async function readFile(projectId: string, multi: boolean, filterName: string = "", extensions: string[] = []): Promise<File[]>;

//写本地文件
export async function writeFile(projectId: string, fileName: string, fileData: Uint8Array): Promise<void>;

//获取文件或目录
export async function openDialog(title: string, dir: boolean, saveName: string = "", filters: Filter[] = []): Promise<string>;

min_app_shell

打开浏览器访问指定url,需要用户授权。

使用

import min_app_shell from "@linksaas-minapp/api";

接口

export async function openBrowser(projectId: string, url: string): Promise<void> 

min_app_store

供微应用使用的kv数据库,每个微应用的数据是独立的。所有数据都是加密存储的。

使用

import min_app_store from "@linksaas-minapp/api";

接口

export interface KeyValue {
    key: Uint8Array,
    value: Uint8Array,
}

// 存储数据
export async function setData(key: Uint8Array, value: Uint8Array): Promise<void>;

// 根据key获取数据
export async function getData(key: Uint8Array): Promise<Uint8Array>;

// 根据key删除数据
export async function removeData(key: Uint8Array): Promise<void>;

// 列出所有数据
export async function listAll(): Promise<KeyValue[]>;

@linksaas-minapp/grpc-proxy-api

获取调用grpc接口的能力,需要用户授权。
api可以对proto文件进行编译,生成结果文件。通过结果文件可以获取接口信息,生成调用数据,进行远程调用。

使用

import * as grpc_proxy_api from "@linksaas-minapp/grpc-proxy-api";

接口

export interface InvokeError {
    error: string;
}

export interface MethodInfo {
    methodName: string;
    clientStream: boolean;
    serverStream: boolean;
}

export interface ServiceInfo {
    serviceName: string;
    methodList: MethodInfo[];
}

export interface MethodWithServiceInfo {
    serviceName: string;
    method: MethodInfo;
}

//获取解析结果文件
export async function getResultFile(grpcApiId: string): Promise<string>;

//生成解析结果文件
export async function genResultFile(grpcApiId: string, rootPath: string, importPathList: string[]): Promise<void>;

//读取协议描述信息
export async function readProtoDesc(grpcApiId: string): Promise<ServiceInfo[]>;

//生成请求数据
export async function genReqData(grpcApiId: string, serviceName: string, methodName: string): Promise<string>;

//请求grpc
export async function callMethod(grpcApiId: string, serviceName: string, methodName: string, remoteAddr: string, secure: boolean, reqData: string): Promise<string>;

@linksaas-minapp/mongo-proxy-api

获取访问mongo数据库的能力,需要用户授权。

接口是通过openapi tools自动生成的代码。

ConnectionApi

方法说明
connectionOpenPost连接数mongo据库
connectionClosePost关闭mongo数据库连接
connectionListPost列出所有数据库连接

DatabaseApi

方法说明
databaseListPost列出指定连接上所有数据库

CollectionApi

方法说明
collectionDeletePost删除记录
collectionFindPost查询记录
collectionInsertPost插入记录
collectionListPost列出数据表
collectionUpdatePost更新记录
viewListPost列出索引

@linksaas-minapp/redis-proxy-api

获取访问redis数据库的能力,需要用户授权。

接口是通过openapi tools自动生成的代码。

ConnectionApi

方法说明
openPost连接redis数据库
closePost关闭redis连接
listPost列出redis连接

CmdApi

方法说明
execPost执行redis指令

实现的命令

核心命令

async copy(srcKey: string, destKey: string): Promise<number>;
async del(...keyList: string[]): Promise<number>;
async dump(key: string): Promise<string>;
async exists(...keyList: string[]): Promise<number>;
async expire(key: string, seconds: number, option: "" | "NX" | "XX" | "GT" | "LT" = ""): Promise<number>;
async expireAt(key: string, unixTimeStamp: number, option: "" | "NX" | "XX" | "GT" | "LT" = ""): Promise<number>;
async expireTime(key: string): Promise<number> ;
async keys(pattern: string): Promise<string[]>;
async migrate(host: string, port: number, dbIndex: number, timeout: number, keyList: string[],
        username: string = "", password: string = "", copy: boolean = false, replace: boolean = false): Promise<string>;
async move(key: string, dbIndex: number): Promise<number>;
async objectEncoding(key: string): Promise<string | null>;
async objectFreq(key: string): Promise<number>;
async objectIdleTime(key: string): Promise<number>;
async objectRefCount(key: string): Promise<number>;
async persist(key: string): Promise<number>;
async pexpire(key: string, milliSeconds: number, option: "" | "NX" | "XX" | "GT" | "LT" = ""): Promise<number> ;
async pexpireAt(key: string, unixMilliSeconds: number, option: "" | "NX" | "XX" | "GT" | "LT" = ""): Promise<number>;
async pexpireTime(key: string): Promise<number>;
async pttl(key: string): Promise<number>;
async randomKey(): Promise<string | null>;
async rename(key: string, newKey: string): Promise<string>;
async renameNx(key: string, newKey: string): Promise<number>;
async restore(key: string, ttl: number, serValue: string, replace: boolean = false, absTtl: boolean = false, idelTime: number = 0, freq: number = 0): Promise<string>;
async scan(cursor: number, pattern: string = "", count: number = 0, scanType: "" | "string" | "list" | "set" | "zset" | "hash" = ""): Promise<unknown>;
async sort(key: string, by: string = "", offset: number = 0, limit: number = 0, getList: string[] = [], sort: "" | "ASC" | "DESC" = "", alpha: boolean = false, storeKey: string = ""): Promise<unknown>;
async sortRo(key: string, by: string = "", offset: number = 0, limit: number = 0, getList: string[] = [], sort: "" | "ASC" | "DESC" = "", alpha: boolean = false): Promise<unknown>;
async touch(keyList: string[]): Promise<number>;
async getType(key: string): Promise<null | string>;
async unlink(keyList:string[]):Promise<number>;

hash相关命令

async hdel(key: string, fieldList: string[]): Promise<number>;
async hexists(key: string, field: string): Promise<number>;
async hget(key: string, field: string): Promise<string | null>;
async hgetAll(key: string): Promise<string[]>;
async hincrBy(key: string, field: string, value: number): Promise<number>;
async hincrByFloat(key: string, field: string, value: number): Promise<string>;
async hkeys(key: string): Promise<string[]>;
async hlen(key: string): Promise<number>;
async hmget(key: string, filedList: string[]): Promise<string[]>;
async hrandField(key: string, count: number = 0, withValues: boolean = false): Promise<unknown>;
async hscan(key: string, cursor: number, pattern: string = "", count: number = 0): Promise<unknown>;
async hset(key: string, fieldValueList: FieldValue[]): Promise<number>;
async hsetnx(key: string, field: string, value: string): Promise<number>;
async hstrlen(key: string, field: string): Promise<number>;
async hvals(key: string): Promise<string[]>;

list相关命令

async blmove(srcKey: string, destKey: string, timeout: number, srcOpt: "LEFT" | "RIGHT", destOpt: "" | "LEFT" | "RIGHT"): Promise<string | null>;
async blmpop(timeout: number, numkeys: number, keyList: string[], opt: "LEFT" | "RIGHT", count: number = 0): Promise<unknown>;
async blpop(keyList: string[], timeout: number): Promise<unknown>;
async brpop(keyList: string[], timeout: number): Promise<unknown>;
async lindex(key: string, index: number): Promise<string | null>;
async linsert(key: string, opt: "BEFORE" | "AFTER", pivot: string, value: string): Promise<number>;
async llen(key: string): Promise<number>;
async lmove(srcKey: string, destKey: string, srcOpt: "LEFT" | "RIGHT", destOpt: "LEFT" | "RIGHT"): Promise<string | null> ;
async lmpop(numkeys: number, keyList: string[], opt: "LEFT" | "RIGHT", count: number = 0): Promise<unknown>;
async lpop(key: string, count: number = 0): Promise<unknown>;
async lpos(key: string, value: string, rank: number = 0, count: number = 0, maxlen: number = 0): Promise<unknown>;
async lpush(key: string, valueList: string[]): Promise<number>;
async lpushx(key: string, valueList: string[]): Promise<number>;
async lrange(key: string, start: number, stop: number): Promise<string[]>;
async lrem(key: string, count: number, value: string): Promise<number>;
async lset(key: string, index: number, value: string): Promise<string>;
async ltrim(key: string, start: number, stop: number): Promise<string>;
async rpop(key: string, count: number = 0): Promise<unknown>;
async rpush(key: string, valueList: string[]): Promise<number>;
async rpushx(key: string, valueList: string[]): Promise<number>;

set相关命令

async sadd(key: string, valueList: string[]): Promise<number>;
async scard(key: string): Promise<number>;
async sdiff(keyList: string[]): Promise<string[]>;
async sdiffStore(destkey: string, keyList: string[]): Promise<number>;
async sinter(keyList: string[]): Promise<string[]>;
async sinterCard(numkeys: number, keyList: string[], limit: number = 0): Promise<number>;
async sinterStore(destkey: string, keyList: string[]): Promise<number>;
async sismember(key: string, value: string): Promise<number>;
async smembers(key: string): Promise<string[]>;
async smismember(key: string, valueList: string[]): Promise<number[]>;
async smove(key: string, destKey: string, value: string): Promise<number>;
async spop(key: string, count: number = 0): Promise<unknown>;
async srandmember(key: string, count: number = 0): Promise<unknown>;
async srem(key: string, valueList: string[]): Promise<number>;
async sscan(key: string, cursor: number, pattern: string = "", count: number = 0): Promise<unknown>;
async sunion(keyList: string[]): Promise<string[]>;
async sunionStore(destKey: string, keyList: string[]): Promise<number>

sortset相关命令

async bzmpop(timeout: number, numkeys: number, keyList: string[], opt: "MIN" | "MAX", count: number = 0): Promise<unknown>;
async bzpopmax(keyList: string[], timeout: number): Promise<unknown>;
async bzpopmin(keyList: string[], timeout: number): Promise<unknown>;
async zadd(key: string, valueScoreList: ValueScore[], option: "" | "NX" | "XX" = "", cmp: "" | "GT" | "LT" = "", ch: boolean = false, incr: boolean = false): Promise<unknown>;
async zcard(key: string): Promise<number>;
async zcount(key: string, min: number, max: number): Promise<number>;
async zdiff(numkeys: number, keyList: string[], withScores: boolean = false): Promise<string[]>;
async zdiffStore(destKey: string, numkeys: number, keyList: string[]): Promise<number>;
async zincrBy(key: string, increment: number, value: string): Promise<string>;
async zinter(numkeys: number, keyList: string[], weightList: number[] = [], aggOpt: "" | "SUM" | "MIN" | "MAX" = "", withScores: boolean = false): Promise<string[]>;
async zinterCard(numkeys: number, keyList: string[], limit: number = 0): Promise<number>;
async zinterStore(destKey: string, numkeys: number, keyList: string[], weightList: number[] = [], aggOpt: "" | "SUM" | "MIN" | "MAX" = ""): Promise<number>;
async zlexCount(key: string, min: number, max: number): Promise<number>;
async zmpop(numkeys: number, keyList: string[], option: "MIN" | "MAX", count: number = 0): Promise<unknown>;
async zmscore(key: string, valueList: string[]): Promise<unknown>;
async zpopMax(key: string, count: number = 0): Promise<string[]>;
async zpopMin(key: string, count: number = 0): Promise<string[]>;
async zrandMember(key: string, count: number = 0, withScores: boolean = false): Promise<unknown>;
async zrange(key: string, start: number, stop: number, byOpt: "" | "BYSCORE" | "BYLEX" = "", rev: boolean = false, offset: number = 0, limit: number = 0, withScores: boolean = false): Promise<string[]>;
async zrangeStore(destKey: string, key: string, min: number, max: number, byOpt: "" | "BYSCORE" | "BYLEX" = "", rev: boolean = false, offset: number = 0, limit: number = 0): Promise<number>;
async zrank(key: string, value: string, withScores: boolean = false): Promise<unknown>;
async zrem(key: string, valueList: string[]): Promise<number>;
async zremRangeByLex(key: string, min: string, max: string): Promise<number>;
async zremRangeByRank(key: string, start: number, stop: number): Promise<number>;
async zremRangeByScore(key: string, min: number, max: number): Promise<number>;
async zrevRank(key: string, value: string, withScores: boolean = false): Promise<unknown>;
async zscan(key: string, cursor: number, pattern: string = "", count: number = 0): Promise<unknown>;
async zscore(key: string, value: string): Promise<string>;
async zunion(numkeys: number, keyList: string[], weightList: number[] = [], aggOpt: "" | "SUM" | "MIN" | "MAX" = "", withScores: boolean = false): Promise<string[]>;
async zunionStore(destKey: string, numkeys: number, keyList: string[], weightList: number[] = [], aggOpt: "" | "SUM" | "MIN" | "MAX" = ""): Promise<number>;

str项目命令

async append(key: string, value: string): Promise<number>;
async decr(key: string): Promise<number>;
async decrBy(key: string, value: number): Promise<number>;
async get(key: string): Promise<null | string>;
async getDel(key: string): Promise<null | string>;
async getEx(key: string, optType: "" | "EX" | "PX" | "EXAT" | "PXAT" | "PERSIST" = "", optValue: number = 0): Promise<null | string>;
async getRange(key: string, start: number, end: number): Promise<string>;
async incr(key: string): Promise<number>;
async incrBy(key: string, value: number): Promise<number>;
async incByFloat(key: string, value: number): Promise<string>;
async mget(keyList: string[]): Promise<unknown[]>;
async mset(keyValueList: KeyValue[]): Promise<string>;
async msetnx(keyValueList: KeyValue[]): Promise<number>;
sync set(key: string, value: string, setType: "" | "NX" | "XX" = "", doGet: boolean = false,
        optType: "" | "EX" | "PX" | "EXAT" | "PXAT" | "KEEPTTL" = "", optValue: number = 0): Promise<null | string>;
async setRange(key: string, offset: number, value: string): Promise<number>;
async strlen(key: string): Promise<number>;

@linksaas-minapp/sql-proxy-api

获取访问mysql或postgres数据库的能力,需要用户授权。

接口是通过openapi tools自动生成的代码。

ConnectionApi

方法说明
connectionOpenPost连接数据库
connectionClosePost关闭数据库连接
connectionListPost列出数据库连接

DatabaseApi

方法说明
databaseListPost列出数据库

TableApi

方法说明
tableListPost列出数据表
tableQueryPost查询数据表
tableRawQueryPost执行裸sql

@linksaas-minapp/ssh-proxy-api

获取访问ssh服务的能力,需要用户授权。

接口是通过openapi tools自动生成的代码。

ConnectionApi

方法说明
connectionOpenPost连接SSH服务
connectionClosePost关闭SSH连接
connectionListPost列出SSH连接

PortforwardApi

方法说明
portforwardOpenPost打开端口转发
portforwardClosePost关闭端口转发
portforwardListPost列出端口转发

SftpApi

方法说明
sftpDownloadPost下载文件
sftpListDirPost列出目录
sftpMkDirPost创建目录
sftpReadTextPost读取文本内容
sftpRemovePost删除目录或文件
sftpRenamePost文件目录重命名
sftpUploadPost上传文件
sftpWorkDirPost获取当前工作目录

@linksaas-minapp/netutil-api

获取访问网络诊断的能力,需要用户授权。

接口是通过openapi tools自动生成的代码。

DnsApi

方法说明
dnsQueryPost查询dns

IcmpApi

方法说明
icmpPingPost检查机器是否可达

ScanApi

方法说明
scanTcpportPost扫描TCP端口
  • 26
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凌鲨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值