获取微应用信息
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;
}
获取本地文件操作的能力,需要用户授权。
使用
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>;
打开浏览器访问指定url,需要用户授权。
使用
import min_app_shell from "@linksaas-minapp/api";
接口
export async function openBrowser(projectId: string, url: string): Promise<void>
供微应用使用的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[]>;
获取调用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>;
获取访问mongo数据库的能力,需要用户授权。
接口是通过openapi tools自动生成的代码。
方法 | 说明 |
---|---|
connectionOpenPost | 连接数mongo据库 |
connectionClosePost | 关闭mongo数据库连接 |
connectionListPost | 列出所有数据库连接 |
方法 | 说明 |
---|---|
databaseListPost | 列出指定连接上所有数据库 |
方法 | 说明 |
---|---|
collectionDeletePost | 删除记录 |
collectionFindPost | 查询记录 |
collectionInsertPost | 插入记录 |
collectionListPost | 列出数据表 |
collectionUpdatePost | 更新记录 |
viewListPost | 列出索引 |
获取访问redis数据库的能力,需要用户授权。
接口是通过openapi tools自动生成的代码。
方法 | 说明 |
---|---|
openPost | 连接redis数据库 |
closePost | 关闭redis连接 |
listPost | 列出redis连接 |
方法 | 说明 |
---|---|
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>;
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[]>;
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>;
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>
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>;
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>;
获取访问mysql或postgres数据库的能力,需要用户授权。
接口是通过openapi tools自动生成的代码。
方法 | 说明 |
---|---|
connectionOpenPost | 连接数据库 |
connectionClosePost | 关闭数据库连接 |
connectionListPost | 列出数据库连接 |
方法 | 说明 |
---|---|
databaseListPost | 列出数据库 |
方法 | 说明 |
---|---|
tableListPost | 列出数据表 |
tableQueryPost | 查询数据表 |
tableRawQueryPost | 执行裸sql |
获取访问ssh服务的能力,需要用户授权。
接口是通过openapi tools自动生成的代码。
方法 | 说明 |
---|---|
connectionOpenPost | 连接SSH服务 |
connectionClosePost | 关闭SSH连接 |
connectionListPost | 列出SSH连接 |
方法 | 说明 |
---|---|
portforwardOpenPost | 打开端口转发 |
portforwardClosePost | 关闭端口转发 |
portforwardListPost | 列出端口转发 |
方法 | 说明 |
---|---|
sftpDownloadPost | 下载文件 |
sftpListDirPost | 列出目录 |
sftpMkDirPost | 创建目录 |
sftpReadTextPost | 读取文本内容 |
sftpRemovePost | 删除目录或文件 |
sftpRenamePost | 文件目录重命名 |
sftpUploadPost | 上传文件 |
sftpWorkDirPost | 获取当前工作目录 |
获取访问网络诊断的能力,需要用户授权。
接口是通过openapi tools自动生成的代码。
方法 | 说明 |
---|---|
dnsQueryPost | 查询dns |
方法 | 说明 |
---|---|
icmpPingPost | 检查机器是否可达 |
方法 | 说明 |
---|---|
scanTcpportPost | 扫描TCP端口 |