742 lines
25 KiB
TypeScript
742 lines
25 KiB
TypeScript
import { NativeEnv, WebEnv, WechatMpEnv } from 'oak-domain/lib/types/Environment';
|
||
import { AppType } from '../oak-app-domain/Application/Schema';
|
||
import { EntityDict } from '../oak-app-domain';
|
||
import { Config } from '../types/Config';
|
||
import { Style } from '../types/Style';
|
||
import { MaterialType } from '../types/WeChat';
|
||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||
import { WechatPublicEventData, WechatMpEventData } from 'oak-external-sdk';
|
||
export type AspectDict<ED extends EntityDict> = {
|
||
/**
|
||
* 使用小程序 token 登录 Web 端
|
||
* @param mpToken 小程序的 token
|
||
* @param env Web 环境信息
|
||
* @returns 返回 Web 端的 token
|
||
*/
|
||
loginWebByMpToken: (params: {
|
||
mpToken: string;
|
||
env: WebEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 合并用户账号,将一个用户的数据迁移到另一个用户
|
||
* @param from 源用户 ID
|
||
* @param to 目标用户 ID
|
||
*/
|
||
mergeUser: (params: {
|
||
from: string;
|
||
to: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 刷新微信公众号用户信息(昵称、头像、性别等)
|
||
*/
|
||
refreshWechatPublicUserInfo: (params: {}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 获取微信小程序用户的手机号
|
||
* @param code 微信小程序获取手机号的 code
|
||
* @param env 小程序环境信息
|
||
* @returns 返回用户手机号
|
||
*/
|
||
getWechatMpUserPhoneNumber: (params: {
|
||
code: string;
|
||
env: WechatMpEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 通过手机号绑定当前登录用户
|
||
* @param mobile 手机号
|
||
* @param captcha 验证码
|
||
* @param env 环境信息
|
||
*/
|
||
bindByMobile: (params: {
|
||
mobile: string;
|
||
captcha: string;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 通过邮箱绑定当前登录用户
|
||
* @param email 邮箱地址
|
||
* @param captcha 验证码
|
||
* @param env 环境信息
|
||
*/
|
||
bindByEmail: (params: {
|
||
email: string;
|
||
captcha: string;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 通过手机号和验证码登录
|
||
* @param mobile 手机号
|
||
* @param captcha 验证码
|
||
* @param disableRegister 是否禁止自动注册,true 时账号不存在会报错
|
||
* @param env 环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginByMobile: (params: {
|
||
mobile: string;
|
||
captcha: string;
|
||
disableRegister?: boolean;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 验证用户密码是否正确
|
||
* @param password 密码(明文或 SHA1 密文,根据系统配置)
|
||
* @param env 环境信息
|
||
*/
|
||
verifyPassword: (params: {
|
||
password: string;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 通过账号(手机号/邮箱/登录名)和密码登录
|
||
* @param account 账号(可以是手机号、邮箱或登录名)
|
||
* @param password 密码(明文或 SHA1 密文,根据系统配置)
|
||
* @param env 环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginByAccount: (params: {
|
||
account: string;
|
||
password: string;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 通过邮箱和验证码登录
|
||
* @param email 邮箱地址
|
||
* @param captcha 验证码
|
||
* @param disableRegister 是否禁止自动注册,true 时账号不存在会报错
|
||
* @param env 环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginByEmail: (params: {
|
||
email: string;
|
||
captcha: string;
|
||
disableRegister?: boolean;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 微信公众号登录
|
||
* @param code 微信授权 code
|
||
* @param env Web 环境信息
|
||
* @param wechatLoginId 可选的微信登录 ID(用于扫码登录场景)
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginWechat: ({ code, env, wechatLoginId, }: {
|
||
code: string;
|
||
env: WebEnv;
|
||
wechatLoginId?: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 用户登出,使指定 token 失效
|
||
* @param tokenValue 要失效的 token
|
||
*/
|
||
logout: (params: {
|
||
tokenValue: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 微信小程序登录
|
||
* @param code 微信授权 code
|
||
* @param env 小程序环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginWechatMp: ({ code, env, }: {
|
||
code: string;
|
||
env: WechatMpEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 微信原生 APP 登录
|
||
* @param code 微信授权 code
|
||
* @param env 原生 APP 环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginWechatNative: ({ code, env, }: {
|
||
code: string;
|
||
env: NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 同步微信小程序用户信息(昵称、头像等)
|
||
* @param nickname 昵称
|
||
* @param avatarUrl 头像 URL
|
||
* @param encryptedData 加密数据
|
||
* @param iv 加密算法的初始向量
|
||
* @param signature 签名
|
||
*/
|
||
syncUserInfoWechatMp: ({ nickname, avatarUrl, encryptedData, iv, signature, }: {
|
||
nickname: string;
|
||
avatarUrl: string;
|
||
encryptedData: string;
|
||
iv: string;
|
||
signature: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 唤醒寄生用户(将 shadow 状态的用户激活)
|
||
* @param id 用户 ID
|
||
* @param env 环境信息
|
||
* @returns 返回 token
|
||
*/
|
||
wakeupParasite: (params: {
|
||
id: string;
|
||
env: WebEnv | WechatMpEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 刷新 token,延长有效期
|
||
* @param tokenValue 当前 token
|
||
* @param env 环境信息
|
||
* @param applicationId 应用 ID
|
||
* @returns 返回新的 token
|
||
*/
|
||
refreshToken: (params: {
|
||
tokenValue: string;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 通过手机号发送验证码
|
||
* @param mobile 手机号
|
||
* @param env 环境信息
|
||
* @param type 验证码类型:login-登录,changePassword-修改密码,confirm-确认操作
|
||
* @returns 返回验证码 ID
|
||
*/
|
||
sendCaptchaByMobile: (params: {
|
||
mobile: string;
|
||
env: WechatMpEnv | WebEnv;
|
||
type: 'login' | 'changePassword' | 'confirm';
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 通过邮箱发送验证码
|
||
* @param email 邮箱地址
|
||
* @param env 环境信息
|
||
* @param type 验证码类型:login-登录,changePassword-修改密码,confirm-确认操作
|
||
* @returns 返回验证码 ID
|
||
*/
|
||
sendCaptchaByEmail: (params: {
|
||
email: string;
|
||
env: WechatMpEnv | WebEnv;
|
||
type: 'login' | 'changePassword' | 'confirm';
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 根据域名和应用类型获取应用信息,并检查版本兼容性
|
||
* @param version 客户端版本号
|
||
* @param type 应用类型(web/wechatMp/wechatPublic/native)
|
||
* @param domain 域名
|
||
* @param data 需要返回的应用数据字段
|
||
* @param appId 可选的应用 ID
|
||
* @returns 返回应用 ID
|
||
*/
|
||
getApplication: (params: {
|
||
version: string;
|
||
type: AppType;
|
||
domain: string;
|
||
data: ED['application']['Projection'];
|
||
appId?: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 生成微信 JS-SDK 签名,用于调用微信 JS 接口
|
||
* @param url 当前页面 URL
|
||
* @param env Web 环境信息
|
||
* @returns 返回签名信息(signature、noncestr、timestamp、appId)
|
||
*/
|
||
signatureJsSDK: (params: {
|
||
url: string;
|
||
env: WebEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<{
|
||
signature: any;
|
||
noncestr: string;
|
||
timestamp: number;
|
||
appId: string;
|
||
}>;
|
||
/**
|
||
* 更新平台或系统的配置信息
|
||
* @param entity 实体类型(platform 或 system)
|
||
* @param entityId 实体 ID
|
||
* @param config 配置对象
|
||
*/
|
||
updateConfig: (params: {
|
||
entity: 'platform' | 'system';
|
||
entityId: string;
|
||
config: Config;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 更新平台、系统或应用的样式配置
|
||
* @param entity 实体类型(platform/system/application)
|
||
* @param entityId 实体 ID
|
||
* @param style 样式对象
|
||
*/
|
||
updateStyle: (params: {
|
||
entity: 'platform' | 'system' | 'application';
|
||
entityId: string;
|
||
style: Style;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 更新应用的配置信息
|
||
* @param entity 实体类型(application)
|
||
* @param entityId 应用 ID
|
||
* @param config 应用配置对象
|
||
*/
|
||
updateApplicationConfig: (params: {
|
||
entity: 'application';
|
||
entityId: string;
|
||
config: EntityDict['application']['Schema']['config'];
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 切换到指定用户(管理员扮演用户功能)
|
||
* @param userId 目标用户 ID
|
||
*/
|
||
switchTo: (params: {
|
||
userId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 获取小程序无限制二维码
|
||
* @param wechatQrCodeId 微信二维码 ID
|
||
* @returns 返回二维码图片数据(Base64 字符串)
|
||
*/
|
||
getMpUnlimitWxaCode: (wechatQrCodeId: string, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 创建微信登录会话(用于扫码登录场景)
|
||
* @param type 登录类型(login-登录,bind-绑定)
|
||
* @param interval 会话有效期(毫秒)
|
||
* @returns 返回登录会话 ID
|
||
*/
|
||
createWechatLogin: (params: {
|
||
type: EntityDict['wechatLogin']['Schema']['type'];
|
||
interval: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 解绑微信用户
|
||
* @param wechatUserId 微信用户 ID
|
||
* @param captcha 可选的验证码
|
||
* @param mobile 可选的手机号
|
||
*/
|
||
unbindingWechat: (params: {
|
||
wechatUserId: string;
|
||
captcha?: string;
|
||
mobile?: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 通过微信登录会话 ID 完成登录(Web 端扫码登录确认)
|
||
* @param wechatLoginId 微信登录会话 ID
|
||
* @param env Web 环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginByWechat: (params: {
|
||
wechatLoginId: string;
|
||
env: WebEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 从 URL 中提取网页信息(标题、发布时间、图片列表)
|
||
* @param url 网页 URL
|
||
* @returns 返回网页信息
|
||
*/
|
||
getInfoByUrl: (params: {
|
||
url: string;
|
||
}) => Promise<{
|
||
title: string;
|
||
publishDate: number | undefined;
|
||
imageList: string[];
|
||
}>;
|
||
/**
|
||
* 获取用户可用的修改密码方式
|
||
* @param userId 用户 ID
|
||
* @returns 返回可用的修改方式列表(mobile-手机号,password-原密码)
|
||
*/
|
||
getChangePasswordChannels: (params: {
|
||
userId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string[]>;
|
||
/**
|
||
* 修改用户密码
|
||
* @param userId 用户 ID
|
||
* @param prevPassword 原密码(使用原密码验证时提供)
|
||
* @param mobile 手机号(使用手机号验证时提供)
|
||
* @param captcha 验证码(使用手机号验证时提供)
|
||
* @param newPassword 新密码
|
||
* @returns 返回修改结果
|
||
*/
|
||
updateUserPassword: (params: {
|
||
userId: string;
|
||
prevPassword?: string;
|
||
mobile?: string;
|
||
captcha?: string;
|
||
newPassword: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<{
|
||
result: string;
|
||
times?: number;
|
||
}>;
|
||
/**
|
||
* 创建或获取会话(用于客服系统等场景)
|
||
* @param data 微信事件数据(可选)
|
||
* @param type 应用类型
|
||
* @param entity 关联实体类型(可选)
|
||
* @param entityId 关联实体 ID(可选)
|
||
* @returns 返回会话 ID
|
||
*/
|
||
createSession: (params: {
|
||
data?: WechatPublicEventData | WechatMpEventData;
|
||
type: AppType;
|
||
entity?: string;
|
||
entityId?: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 上传素材到微信服务器
|
||
* @param params 包含文件信息、应用 ID、素材类型等
|
||
* @returns 返回微信 mediaId
|
||
*/
|
||
uploadWechatMedia: (params: any, context: BackendRuntimeContext<ED>) => Promise<{
|
||
mediaId: string;
|
||
}>;
|
||
/**
|
||
* 获取微信公众号当前使用的自定义菜单配置
|
||
* @param applicationId 应用 ID
|
||
* @returns 返回当前菜单配置
|
||
*/
|
||
getCurrentMenu: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取微信公众号自定义菜单配置(包括默认和个性化菜单)
|
||
* @param applicationId 应用 ID
|
||
* @returns 返回菜单配置
|
||
*/
|
||
getMenu: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 创建微信公众号自定义菜单
|
||
* @param applicationId 应用 ID
|
||
* @param menuConfig 菜单配置
|
||
* @param id 菜单记录 ID
|
||
*/
|
||
createMenu: (params: {
|
||
applicationId: string;
|
||
menuConfig: any;
|
||
id: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 创建微信公众号个性化菜单(针对特定用户群体)
|
||
* @param applicationId 应用 ID
|
||
* @param menuConfig 菜单配置
|
||
* @param id 菜单记录 ID
|
||
*/
|
||
createConditionalMenu: (params: {
|
||
applicationId: string;
|
||
menuConfig: any;
|
||
id: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 删除微信公众号个性化菜单
|
||
* @param applicationId 应用 ID
|
||
* @param menuId 微信菜单 ID
|
||
*/
|
||
deleteConditionalMenu: (params: {
|
||
applicationId: string;
|
||
menuId: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 删除微信公众号自定义菜单
|
||
* @param applicationId 应用 ID
|
||
*/
|
||
deleteMenu: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 批量获取微信公众号图文消息素材
|
||
* @param applicationId 应用 ID
|
||
* @param offset 起始位置(可选)
|
||
* @param count 获取数量
|
||
* @param noContent 是否不返回内容(0-返回,1-不返回)
|
||
* @returns 返回图文消息列表
|
||
*/
|
||
batchGetArticle: (params: {
|
||
applicationId: string;
|
||
offset?: number;
|
||
count: number;
|
||
noContent?: 0 | 1;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取微信公众号单个图文消息素材
|
||
* @param applicationId 应用 ID
|
||
* @param articleId 图文消息 ID
|
||
* @returns 返回图文消息详情
|
||
*/
|
||
getArticle: (params: {
|
||
applicationId: string;
|
||
articleId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 批量获取微信素材列表
|
||
* @param applicationId 应用 ID
|
||
* @param type 素材类型(image-图片,voice-语音,video-视频,news-图文)
|
||
* @param offset 起始位置(可选)
|
||
* @param count 获取数量
|
||
* @returns 返回素材列表
|
||
*/
|
||
batchGetMaterialList: (params: {
|
||
applicationId: string;
|
||
type: MaterialType;
|
||
offset?: number;
|
||
count: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取微信素材
|
||
* @param applicationId 应用 ID
|
||
* @param mediaId 素材 ID
|
||
* @param isPermanent 是否为永久素材(默认获取临时素材)
|
||
* @returns 返回素材数据
|
||
*/
|
||
getMaterial: (params: {
|
||
applicationId: string;
|
||
mediaId: string;
|
||
isPermanent?: boolean;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 删除微信永久素材
|
||
* @param applicationId 应用 ID
|
||
* @param mediaId 素材 ID
|
||
*/
|
||
deleteMaterial: (params: {
|
||
applicationId: string;
|
||
mediaId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 创建微信公众号用户标签
|
||
* @param applicationId 应用 ID
|
||
* @param name 标签名称
|
||
* @returns 返回创建结果
|
||
*/
|
||
createTag: (params: {
|
||
applicationId: string;
|
||
name: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取微信公众号所有用户标签
|
||
* @param applicationId 应用 ID
|
||
* @returns 返回标签列表
|
||
*/
|
||
getTags: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 编辑微信公众号用户标签
|
||
* @param applicationId 应用 ID
|
||
* @param id 微信标签 ID
|
||
* @param name 新标签名称
|
||
*/
|
||
editTag: (params: {
|
||
applicationId: string;
|
||
id: number;
|
||
name: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 删除微信公众号用户标签
|
||
* @param applicationId 应用 ID
|
||
* @param id 本地标签 ID
|
||
* @param wechatId 微信标签 ID
|
||
*/
|
||
deleteTag: (params: {
|
||
applicationId: string;
|
||
id: string;
|
||
wechatId: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 同步微信公众号消息模板到本地
|
||
* @param applicationId 应用 ID
|
||
* @returns 返回同步结果
|
||
*/
|
||
syncWechatTemplate: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取已注册的消息类型列表
|
||
* @returns 返回消息类型数组
|
||
*/
|
||
getMessageType: (params: {}, content: BackendRuntimeContext<ED>) => Promise<string[]>;
|
||
/**
|
||
* 同步单个微信公众号用户标签到微信服务器
|
||
* @param applicationId 应用 ID
|
||
* @param id 本地标签 ID
|
||
*/
|
||
syncTag: (params: {
|
||
applicationId: string;
|
||
id: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 一键同步微信公众号用户标签(从微信服务器同步到本地)
|
||
* @param applicationId 应用 ID
|
||
*/
|
||
oneKeySync: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取指定标签下的微信用户列表
|
||
* @param applicationId 应用 ID
|
||
* @param tagId 微信标签 ID
|
||
* @returns 返回用户列表
|
||
*/
|
||
getTagUsers: (params: {
|
||
applicationId: string;
|
||
tagId: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 批量为用户打标签
|
||
* @param applicationId 应用 ID
|
||
* @param openIdList 微信用户 openId 列表
|
||
* @param tagId 微信标签 ID
|
||
*/
|
||
batchtagging: (params: {
|
||
applicationId: string;
|
||
openIdList: string[];
|
||
tagId: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 批量为用户取消标签
|
||
* @param applicationId 应用 ID
|
||
* @param openIdList 微信用户 openId 列表
|
||
* @param tagId 微信标签 ID
|
||
*/
|
||
batchuntagging: (params: {
|
||
applicationId: string;
|
||
openIdList: string[];
|
||
tagId: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取用户身上的标签列表
|
||
* @param applicationId 应用 ID
|
||
* @param openId 微信用户 openId
|
||
* @returns 返回用户的标签 ID 列表
|
||
*/
|
||
getUserTags: (params: {
|
||
applicationId: string;
|
||
openId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 获取微信公众号用户列表
|
||
* @param applicationId 应用 ID
|
||
* @param nextOpenId 下一个用户的 openId(用于分页)
|
||
* @returns 返回用户列表
|
||
*/
|
||
getUsers: (params: {
|
||
applicationId: string;
|
||
nextOpenId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 为单个用户设置标签列表
|
||
* @param applicationId 应用 ID
|
||
* @param openId 微信用户 openId
|
||
* @param tagIdList 标签 ID 列表
|
||
*/
|
||
tagging: (params: {
|
||
applicationId: string;
|
||
openId: string;
|
||
tagIdList: number[];
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 从微信服务器同步用户标签到本地
|
||
* @param applicationId 应用 ID
|
||
* @param openId 微信用户 openId
|
||
*/
|
||
syncToLocale: (params: {
|
||
applicationId: string;
|
||
openId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 将本地用户标签同步到微信服务器
|
||
* @param applicationId 应用 ID
|
||
* @param id 本地用户标签关联 ID
|
||
* @param openId 微信用户 openId
|
||
*/
|
||
syncToWechat: (params: {
|
||
applicationId: string;
|
||
id: string;
|
||
openId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<any>;
|
||
/**
|
||
* 同步短信模板(从服务商同步到本地)
|
||
* @param systemId 系统 ID
|
||
* @param origin 短信服务商(如阿里云、腾讯云等)
|
||
*/
|
||
syncSmsTemplate: (params: {
|
||
systemId: string;
|
||
origin: EntityDict['smsTemplate']['Schema']['origin'];
|
||
pageIndex?: number;
|
||
pageSize?: number;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 获取应用的登录方式配置列表
|
||
* @param applicationId 应用 ID
|
||
* @returns 返回登录方式配置列表
|
||
*/
|
||
getApplicationPassports: (params: {
|
||
applicationId: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<EntityDict['applicationPassport']['Schema'][]>;
|
||
/**
|
||
* 根据登录方式 ID 列表删除应用的登录方式配置
|
||
* @param passportIds 登录方式 ID 列表
|
||
*/
|
||
removeApplicationPassportsByPIds: (params: {
|
||
passportIds: string[];
|
||
}, content: BackendRuntimeContext<ED>) => Promise<void>;
|
||
/**
|
||
* 通过 OAuth 2.0 第三方登录
|
||
* @param code OAuth 授权码
|
||
* @param state 状态码(用于验证请求)
|
||
* @param env 环境信息
|
||
* @returns 返回登录 token
|
||
*/
|
||
loginByOauth: (params: {
|
||
code: string;
|
||
state: string;
|
||
env: WebEnv | WechatMpEnv | NativeEnv;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* 创建 OAuth 登录/绑定状态码
|
||
* @param providerId OAuth 提供商 ID
|
||
* @param userId 用户 ID(绑定时需要)
|
||
* @param type 操作类型(bind-绑定,login-登录)
|
||
* @returns 返回状态码
|
||
*/
|
||
createOAuthState: (params: {
|
||
providerId: string;
|
||
userId?: string;
|
||
type: "bind" | "login";
|
||
}, context: BackendRuntimeContext<ED>) => Promise<string>;
|
||
/**
|
||
* OAuth 2.0 授权确认(用户同意或拒绝授权)
|
||
* @param response_type 响应类型(固定为 "code")
|
||
* @param client_id 客户端应用 ID
|
||
* @param redirect_uri 回调地址
|
||
* @param scope 授权范围
|
||
* @param state 状态码
|
||
* @param action 用户操作(grant-同意,deny-拒绝)
|
||
* @returns 返回重定向 URL
|
||
*/
|
||
authorize: (params: {
|
||
response_type: string;
|
||
client_id: string;
|
||
redirect_uri: string;
|
||
scope: string;
|
||
state: string;
|
||
action: "grant" | "deny";
|
||
code_challenge?: string;
|
||
code_challenge_method?: 'plain' | 'S256';
|
||
}, context: BackendRuntimeContext<ED>) => Promise<{
|
||
redirectUri: string;
|
||
}>;
|
||
/**
|
||
* 获取 OAuth 客户端应用信息
|
||
* @param client_id 客户端应用 ID
|
||
* @returns 返回客户端应用信息,不存在则返回 null
|
||
*/
|
||
getOAuthClientInfo: (params: {
|
||
client_id: string;
|
||
currentUserId?: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<{
|
||
data: EntityDict['oauthApplication']['Schema'] | null;
|
||
alreadyAuth: boolean;
|
||
}>;
|
||
/**
|
||
* 更新用户头像为微信头像
|
||
* @param avatar 微信头像临时url
|
||
* @returns
|
||
*/
|
||
setUserAvatarFromWechat: (params: {
|
||
avatar: string;
|
||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||
};
|
||
export default AspectDict;
|