diff --git a/es/aspects/token.js b/es/aspects/token.js index bac91bc75..88c199986 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -2027,6 +2027,7 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c expired: false, expiresAt: now + duration * 60 * 1000, type: captchaType, + applicationId: application?.id, }, }, { dontCollect: true, @@ -2158,6 +2159,7 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con // } code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join(''); const id = await generateNewIdAsync(); + const applicationId = context.getApplication()?.id; await context.operate('captcha', { id: await generateNewIdAsync(), action: 'create', @@ -2171,6 +2173,7 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con expired: false, expiresAt: now + duration * 60 * 1000, type: captchaType, + applicationId, }, }, { dontCollect: true, diff --git a/es/entities/Captcha.d.ts b/es/entities/Captcha.d.ts index 635a81045..8c916d010 100644 --- a/es/entities/Captcha.d.ts +++ b/es/entities/Captcha.d.ts @@ -2,6 +2,7 @@ import { EntityShape } from 'oak-domain/lib/types/Entity'; import { String, Text, Boolean, Datetime } from 'oak-domain/lib/types/DataType'; import { ActionDef } from 'oak-domain/lib/types'; import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; +import { Schema as Application } from './Application'; export interface Schema extends EntityShape { origin: 'mobile' | 'email'; content: String<32>; @@ -12,6 +13,7 @@ export interface Schema extends EntityShape { expired: Boolean; expiresAt: Datetime; type: 'login' | 'changePassword' | 'confirm'; + application?: Application; } export type IState = 'unsent' | 'sending' | 'sent' | 'failure'; export type IAction = 'send' | 'success' | 'fail'; diff --git a/es/entities/Captcha.js b/es/entities/Captcha.js index 51fa6c8bf..0807f0a93 100644 --- a/es/entities/Captcha.js +++ b/es/entities/Captcha.js @@ -22,6 +22,7 @@ export const entityDesc = { expiresAt: '过期时间', iState: '状态', type: '类型', + application: '应用', }, action: { send: '发送', diff --git a/es/oak-app-domain/Captcha/Storage.js b/es/oak-app-domain/Captcha/Storage.js index ae2b6c7b9..6fc92db73 100644 --- a/es/oak-app-domain/Captcha/Storage.js +++ b/es/oak-app-domain/Captcha/Storage.js @@ -44,6 +44,10 @@ export const desc = { type: "enum", enumeration: ["login", "changePassword", "confirm"] }, + applicationId: { + type: "ref", + ref: "application" + }, iState: { type: "enum", enumeration: ["unsent", "sending", "sent", "failure"] diff --git a/es/oak-app-domain/Captcha/_baseSchema.d.ts b/es/oak-app-domain/Captcha/_baseSchema.d.ts index e4f78d7ef..bfe2672b0 100644 --- a/es/oak-app-domain/Captcha/_baseSchema.d.ts +++ b/es/oak-app-domain/Captcha/_baseSchema.d.ts @@ -1,3 +1,4 @@ +import { ForeignKey } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { Action, ParticularAction, IState } from "./Action"; @@ -12,6 +13,7 @@ export type OpSchema = EntityShape & { expired: Boolean; expiresAt: Datetime; type: "login" | "changePassword" | "confirm"; + applicationId?: ForeignKey<"application"> | null; iState?: IState | null; } & { [A in ExpressionKey]?: any; @@ -31,6 +33,7 @@ export type OpFilter = { expired: Q_BooleanValue; expiresAt: Q_DateValue; type: Q_EnumValue<"login" | "changePassword" | "confirm">; + applicationId: Q_StringValue; iState: Q_EnumValue; } & ExprOp; export type OpProjection = { @@ -49,6 +52,7 @@ export type OpProjection = { expired?: number; expiresAt?: number; type?: number; + applicationId?: number; iState?: number; } & Partial>; export type OpSortAttr = Partial<{ @@ -64,6 +68,7 @@ export type OpSortAttr = Partial<{ expired: number; expiresAt: number; type: number; + applicationId: number; iState: number; [k: string]: any; } | ExprOp>; diff --git a/es/oak-app-domain/Captcha/locales/zh_CN.json b/es/oak-app-domain/Captcha/locales/zh_CN.json index d4f324794..9bf4f10cf 100644 --- a/es/oak-app-domain/Captcha/locales/zh_CN.json +++ b/es/oak-app-domain/Captcha/locales/zh_CN.json @@ -10,7 +10,8 @@ "expired": "是否过期", "expiresAt": "过期时间", "iState": "状态", - "type": "类型" + "type": "类型", + "application": "应用" }, "action": { "send": "发送", diff --git a/es/oak-app-domain/EntityDict.d.ts b/es/oak-app-domain/EntityDict.d.ts index 270eb74f3..332b7d0f8 100644 --- a/es/oak-app-domain/EntityDict.d.ts +++ b/es/oak-app-domain/EntityDict.d.ts @@ -1038,6 +1038,7 @@ export type Application = { system: System["Schema"]; domain?: Domain["Schema"]; applicationPassport$application?: Array>; + captcha$application?: Array>; extraFile$application?: Array>; notification$application?: Array>; sessionMessage$application?: Array>; @@ -1050,6 +1051,7 @@ export type Application = { wechatUser$application?: Array>; session$entity?: Array>; applicationPassport$application$$aggr?: AggregationResult>; + captcha$application$$aggr?: AggregationResult>; extraFile$application$$aggr?: AggregationResult>; notification$application$$aggr?: AggregationResult>; sessionMessage$application$$aggr?: AggregationResult>; @@ -1071,6 +1073,12 @@ export type Application = { applicationPassport$application$$aggr?: DeduceAggregation, Omit, ApplicationPassport["Sorter"]> & { $entity: "applicationPassport"; }; + captcha$application?: OakSelection<"select", Omit, Omit, Captcha["Sorter"]> & { + $entity: "captcha"; + }; + captcha$application$$aggr?: DeduceAggregation, Omit, Captcha["Sorter"]> & { + $entity: "captcha"; + }; extraFile$application?: OakSelection<"select", Omit, Omit, ExtraFile["Sorter"]> & { $entity: "extraFile"; }; @@ -1142,6 +1150,7 @@ export type Application = { system: MakeFilter; domain: MakeFilter; applicationPassport$application: MakeFilter> & SubQueryPredicateMetadata; + captcha$application: MakeFilter> & SubQueryPredicateMetadata; extraFile$application: MakeFilter> & SubQueryPredicateMetadata; notification$application: MakeFilter> & SubQueryPredicateMetadata; sessionMessage$application: MakeFilter> & SubQueryPredicateMetadata; @@ -1170,6 +1179,7 @@ export type Application = { system?: OakOperation<"create", System["CreateOperationData"]> | OakOperation; domain?: OakOperation<"create", Domain["CreateOperationData"]> | OakOperation; applicationPassport$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ApplicationPassport["Filter"]>)[]; + captcha$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Captcha["Filter"]>)[]; extraFile$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ExtraFile["Filter"]>)[]; notification$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Notification["Filter"]>)[]; sessionMessage$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, SessionMessage["Filter"]>)[]; @@ -1189,6 +1199,7 @@ export type Application = { system?: OakOperation<"create", System["CreateOperationData"]> | OakOperation | OakOperation<"remove", System["RemoveOperationData"], System["Filter"]>; domain?: OakOperation<"create", Domain["CreateOperationData"]> | OakOperation | OakOperation<"remove", Domain["RemoveOperationData"], Domain["Filter"]>; applicationPassport$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ApplicationPassport["Filter"]> | OakOperation<"remove", ApplicationPassport["RemoveOperationData"], ApplicationPassport["Filter"]>)[]; + captcha$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Captcha["Filter"]> | OakOperation<"remove", Captcha["RemoveOperationData"], Captcha["Filter"]>)[]; extraFile$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ExtraFile["Filter"]> | OakOperation<"remove", ExtraFile["RemoveOperationData"], ExtraFile["Filter"]>)[]; notification$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Notification["Filter"]> | OakOperation<"remove", Notification["RemoveOperationData"], Notification["Filter"]>)[]; sessionMessage$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, SessionMessage["Filter"]> | OakOperation<"remove", SessionMessage["RemoveOperationData"], SessionMessage["Filter"]>)[]; @@ -1447,11 +1458,19 @@ export type ArticleMenu = { export type Captcha = { OpSchema: BaseCaptcha.OpSchema; Action: BaseCaptcha.OpAction; - Schema: BaseCaptcha.OpSchema & {}; - Projection: BaseCaptcha.OpProjection & {}; - FilterUnit: BaseCaptcha.OpFilter & {}; + Schema: BaseCaptcha.OpSchema & { + application?: Application["Schema"]; + }; + Projection: BaseCaptcha.OpProjection & { + application?: Application["Projection"]; + }; + FilterUnit: BaseCaptcha.OpFilter & { + application: MakeFilter; + }; Filter: MakeFilter; - SortAttr: Partial; + SortAttr: Partial; SortNode: { $attr: Captcha["SortAttr"]; $direction?: "asc" | "desc"; @@ -1459,11 +1478,15 @@ export type Captcha = { Sorter: Captcha["SortNode"][]; Selection: OakSelection<"select", Captcha["Projection"], Captcha["Filter"], Captcha["Sorter"]>; Aggregation: DeduceAggregation; - CreateOperationData: FormCreateData; + CreateOperationData: FormCreateData | OakOperation; + }>; CreateSingle: OakOperation<"create", Captcha["CreateOperationData"]>; CreateMulti: OakOperation<"create", Array>; Create: Captcha["CreateSingle"] | Captcha["CreateMulti"]; - UpdateOperationData: FormUpdateData; + UpdateOperationData: FormUpdateData | OakOperation | OakOperation<"remove", Application["RemoveOperationData"], Application["Filter"]>; + }>; Update: OakOperation; RemoveOperationData: {}; Remove: OakOperation<"remove", Captcha["RemoveOperationData"], Captcha["Filter"], Captcha["Sorter"]>; diff --git a/lib/aspects/template.d.ts b/lib/aspects/template.d.ts index 3e1d30898..290b776b2 100644 --- a/lib/aspects/template.d.ts +++ b/lib/aspects/template.d.ts @@ -19,6 +19,6 @@ export declare function syncMessageTemplate(params: { example: string; keywordEnumValueList: { keywordCode: string; - enumValueList: string[]; + enumValueList: Array; }[]; }[]>; diff --git a/lib/aspects/token.js b/lib/aspects/token.js index ad8f93023..b8f7dbe51 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -2050,6 +2050,7 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context) expired: false, expiresAt: now + duration * 60 * 1000, type: captchaType, + applicationId: application?.id, }, }, { dontCollect: true, @@ -2181,6 +2182,7 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) { // } code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join(''); const id = await (0, uuid_1.generateNewIdAsync)(); + const applicationId = context.getApplication()?.id; await context.operate('captcha', { id: await (0, uuid_1.generateNewIdAsync)(), action: 'create', @@ -2194,6 +2196,7 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) { expired: false, expiresAt: now + duration * 60 * 1000, type: captchaType, + applicationId, }, }, { dontCollect: true, diff --git a/lib/entities/Captcha.d.ts b/lib/entities/Captcha.d.ts index 635a81045..8c916d010 100644 --- a/lib/entities/Captcha.d.ts +++ b/lib/entities/Captcha.d.ts @@ -2,6 +2,7 @@ import { EntityShape } from 'oak-domain/lib/types/Entity'; import { String, Text, Boolean, Datetime } from 'oak-domain/lib/types/DataType'; import { ActionDef } from 'oak-domain/lib/types'; import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; +import { Schema as Application } from './Application'; export interface Schema extends EntityShape { origin: 'mobile' | 'email'; content: String<32>; @@ -12,6 +13,7 @@ export interface Schema extends EntityShape { expired: Boolean; expiresAt: Datetime; type: 'login' | 'changePassword' | 'confirm'; + application?: Application; } export type IState = 'unsent' | 'sending' | 'sent' | 'failure'; export type IAction = 'send' | 'success' | 'fail'; diff --git a/lib/entities/Captcha.js b/lib/entities/Captcha.js index 170218e95..06a452a29 100644 --- a/lib/entities/Captcha.js +++ b/lib/entities/Captcha.js @@ -25,6 +25,7 @@ exports.entityDesc = { expiresAt: '过期时间', iState: '状态', type: '类型', + application: '应用', }, action: { send: '发送', diff --git a/lib/oak-app-domain/Captcha/Storage.js b/lib/oak-app-domain/Captcha/Storage.js index f22a5d168..dd78f80e5 100644 --- a/lib/oak-app-domain/Captcha/Storage.js +++ b/lib/oak-app-domain/Captcha/Storage.js @@ -47,6 +47,10 @@ exports.desc = { type: "enum", enumeration: ["login", "changePassword", "confirm"] }, + applicationId: { + type: "ref", + ref: "application" + }, iState: { type: "enum", enumeration: ["unsent", "sending", "sent", "failure"] diff --git a/lib/oak-app-domain/Captcha/_baseSchema.d.ts b/lib/oak-app-domain/Captcha/_baseSchema.d.ts index e4f78d7ef..bfe2672b0 100644 --- a/lib/oak-app-domain/Captcha/_baseSchema.d.ts +++ b/lib/oak-app-domain/Captcha/_baseSchema.d.ts @@ -1,3 +1,4 @@ +import { ForeignKey } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { Action, ParticularAction, IState } from "./Action"; @@ -12,6 +13,7 @@ export type OpSchema = EntityShape & { expired: Boolean; expiresAt: Datetime; type: "login" | "changePassword" | "confirm"; + applicationId?: ForeignKey<"application"> | null; iState?: IState | null; } & { [A in ExpressionKey]?: any; @@ -31,6 +33,7 @@ export type OpFilter = { expired: Q_BooleanValue; expiresAt: Q_DateValue; type: Q_EnumValue<"login" | "changePassword" | "confirm">; + applicationId: Q_StringValue; iState: Q_EnumValue; } & ExprOp; export type OpProjection = { @@ -49,6 +52,7 @@ export type OpProjection = { expired?: number; expiresAt?: number; type?: number; + applicationId?: number; iState?: number; } & Partial>; export type OpSortAttr = Partial<{ @@ -64,6 +68,7 @@ export type OpSortAttr = Partial<{ expired: number; expiresAt: number; type: number; + applicationId: number; iState: number; [k: string]: any; } | ExprOp>; diff --git a/lib/oak-app-domain/Captcha/locales/zh_CN.json b/lib/oak-app-domain/Captcha/locales/zh_CN.json index d4f324794..9bf4f10cf 100644 --- a/lib/oak-app-domain/Captcha/locales/zh_CN.json +++ b/lib/oak-app-domain/Captcha/locales/zh_CN.json @@ -10,7 +10,8 @@ "expired": "是否过期", "expiresAt": "过期时间", "iState": "状态", - "type": "类型" + "type": "类型", + "application": "应用" }, "action": { "send": "发送", diff --git a/lib/oak-app-domain/EntityDict.d.ts b/lib/oak-app-domain/EntityDict.d.ts index 270eb74f3..332b7d0f8 100644 --- a/lib/oak-app-domain/EntityDict.d.ts +++ b/lib/oak-app-domain/EntityDict.d.ts @@ -1038,6 +1038,7 @@ export type Application = { system: System["Schema"]; domain?: Domain["Schema"]; applicationPassport$application?: Array>; + captcha$application?: Array>; extraFile$application?: Array>; notification$application?: Array>; sessionMessage$application?: Array>; @@ -1050,6 +1051,7 @@ export type Application = { wechatUser$application?: Array>; session$entity?: Array>; applicationPassport$application$$aggr?: AggregationResult>; + captcha$application$$aggr?: AggregationResult>; extraFile$application$$aggr?: AggregationResult>; notification$application$$aggr?: AggregationResult>; sessionMessage$application$$aggr?: AggregationResult>; @@ -1071,6 +1073,12 @@ export type Application = { applicationPassport$application$$aggr?: DeduceAggregation, Omit, ApplicationPassport["Sorter"]> & { $entity: "applicationPassport"; }; + captcha$application?: OakSelection<"select", Omit, Omit, Captcha["Sorter"]> & { + $entity: "captcha"; + }; + captcha$application$$aggr?: DeduceAggregation, Omit, Captcha["Sorter"]> & { + $entity: "captcha"; + }; extraFile$application?: OakSelection<"select", Omit, Omit, ExtraFile["Sorter"]> & { $entity: "extraFile"; }; @@ -1142,6 +1150,7 @@ export type Application = { system: MakeFilter; domain: MakeFilter; applicationPassport$application: MakeFilter> & SubQueryPredicateMetadata; + captcha$application: MakeFilter> & SubQueryPredicateMetadata; extraFile$application: MakeFilter> & SubQueryPredicateMetadata; notification$application: MakeFilter> & SubQueryPredicateMetadata; sessionMessage$application: MakeFilter> & SubQueryPredicateMetadata; @@ -1170,6 +1179,7 @@ export type Application = { system?: OakOperation<"create", System["CreateOperationData"]> | OakOperation; domain?: OakOperation<"create", Domain["CreateOperationData"]> | OakOperation; applicationPassport$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ApplicationPassport["Filter"]>)[]; + captcha$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Captcha["Filter"]>)[]; extraFile$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ExtraFile["Filter"]>)[]; notification$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Notification["Filter"]>)[]; sessionMessage$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, SessionMessage["Filter"]>)[]; @@ -1189,6 +1199,7 @@ export type Application = { system?: OakOperation<"create", System["CreateOperationData"]> | OakOperation | OakOperation<"remove", System["RemoveOperationData"], System["Filter"]>; domain?: OakOperation<"create", Domain["CreateOperationData"]> | OakOperation | OakOperation<"remove", Domain["RemoveOperationData"], Domain["Filter"]>; applicationPassport$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ApplicationPassport["Filter"]> | OakOperation<"remove", ApplicationPassport["RemoveOperationData"], ApplicationPassport["Filter"]>)[]; + captcha$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Captcha["Filter"]> | OakOperation<"remove", Captcha["RemoveOperationData"], Captcha["Filter"]>)[]; extraFile$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, ExtraFile["Filter"]> | OakOperation<"remove", ExtraFile["RemoveOperationData"], ExtraFile["Filter"]>)[]; notification$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, Notification["Filter"]> | OakOperation<"remove", Notification["RemoveOperationData"], Notification["Filter"]>)[]; sessionMessage$application?: (OakOperation<"create", Omit | Omit[]> | OakOperation, SessionMessage["Filter"]> | OakOperation<"remove", SessionMessage["RemoveOperationData"], SessionMessage["Filter"]>)[]; @@ -1447,11 +1458,19 @@ export type ArticleMenu = { export type Captcha = { OpSchema: BaseCaptcha.OpSchema; Action: BaseCaptcha.OpAction; - Schema: BaseCaptcha.OpSchema & {}; - Projection: BaseCaptcha.OpProjection & {}; - FilterUnit: BaseCaptcha.OpFilter & {}; + Schema: BaseCaptcha.OpSchema & { + application?: Application["Schema"]; + }; + Projection: BaseCaptcha.OpProjection & { + application?: Application["Projection"]; + }; + FilterUnit: BaseCaptcha.OpFilter & { + application: MakeFilter; + }; Filter: MakeFilter; - SortAttr: Partial; + SortAttr: Partial; SortNode: { $attr: Captcha["SortAttr"]; $direction?: "asc" | "desc"; @@ -1459,11 +1478,15 @@ export type Captcha = { Sorter: Captcha["SortNode"][]; Selection: OakSelection<"select", Captcha["Projection"], Captcha["Filter"], Captcha["Sorter"]>; Aggregation: DeduceAggregation; - CreateOperationData: FormCreateData; + CreateOperationData: FormCreateData | OakOperation; + }>; CreateSingle: OakOperation<"create", Captcha["CreateOperationData"]>; CreateMulti: OakOperation<"create", Array>; Create: Captcha["CreateSingle"] | Captcha["CreateMulti"]; - UpdateOperationData: FormUpdateData; + UpdateOperationData: FormUpdateData | OakOperation | OakOperation<"remove", Application["RemoveOperationData"], Application["Filter"]>; + }>; Update: OakOperation; RemoveOperationData: {}; Remove: OakOperation<"remove", Captcha["RemoveOperationData"], Captcha["Filter"], Captcha["Sorter"]>; diff --git a/lib/triggers/index.d.ts b/lib/triggers/index.d.ts index 54d1ce8ac..acc432115 100644 --- a/lib/triggers/index.d.ts +++ b/lib/triggers/index.d.ts @@ -1,2 +1,2 @@ -declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[]; +declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[]; export default _default; diff --git a/lib/triggers/message.js b/lib/triggers/message.js index 647bc2625..0529c8bdb 100644 --- a/lib/triggers/message.js +++ b/lib/triggers/message.js @@ -1,6 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.tryMakeEmailNotification = exports.tryMakeSmsNotification = exports.registerMessageNotificationConverters = void 0; +exports.registerMessageNotificationConverters = registerMessageNotificationConverters; +exports.tryMakeSmsNotification = tryMakeSmsNotification; +exports.tryMakeEmailNotification = tryMakeEmailNotification; const uuid_1 = require("oak-domain/lib/utils/uuid"); const assert_1 = require("oak-domain/lib/utils/assert"); const lodash_1 = require("oak-domain/lib/utils/lodash"); @@ -11,7 +13,6 @@ function registerMessageNotificationConverters(converters) { ConverterDict[ele.type] = ele; }); } -exports.registerMessageNotificationConverters = registerMessageNotificationConverters; const InitialChannelByWeightMatrix = { high: ['wechatMp', 'wechatPublic', 'sms', 'email'], medium: ['wechatMp', 'wechatPublic', 'email'], @@ -46,7 +47,6 @@ async function tryMakeSmsNotification(message, context) { } } } -exports.tryMakeSmsNotification = tryMakeSmsNotification; async function tryMakeEmailNotification(message, context) { const { userId, type, entity, entityId, router } = message; const converter = ConverterDict[type] && ConverterDict[type].toEmail; @@ -61,7 +61,6 @@ async function tryMakeEmailNotification(message, context) { } } } -exports.tryMakeEmailNotification = tryMakeEmailNotification; async function createNotification(message, context) { const { restriction, userId, weight, type, entity, entityId, platformId, channels } = message; (0, assert_1.assert)(userId); diff --git a/lib/utils/email/index.d.ts b/lib/utils/email/index.d.ts index da272a8d0..6f2b842fa 100644 --- a/lib/utils/email/index.d.ts +++ b/lib/utils/email/index.d.ts @@ -10,7 +10,7 @@ export declare function getEmail(origin: string): Email(options: EmailOptions, context: BRC): Promise<{ success: boolean; - error?: string | undefined; + error?: string; } | { success: boolean; error: unknown; diff --git a/src/aspects/token.ts b/src/aspects/token.ts index 61fbc36c7..e1267e767 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -2718,6 +2718,7 @@ export async function sendCaptchaByMobile( expired: false, expiresAt: now + duration * 60 * 1000, type: captchaType, + applicationId: application?.id!, }, }, { @@ -2885,6 +2886,7 @@ export async function sendCaptchaByEmail( // } code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join(''); const id = await generateNewIdAsync(); + const applicationId = context.getApplication()?.id!; await context.operate( 'captcha', { @@ -2900,6 +2902,7 @@ export async function sendCaptchaByEmail( expired: false, expiresAt: now + duration * 60 * 1000, type: captchaType, + applicationId, }, }, { diff --git a/src/entities/Captcha.ts b/src/entities/Captcha.ts index 6b1d0580a..4f1f7293e 100644 --- a/src/entities/Captcha.ts +++ b/src/entities/Captcha.ts @@ -2,6 +2,7 @@ import { ActionType, EntityShape } from 'oak-domain/lib/types/Entity'; import { String, Text, Boolean, Datetime } from 'oak-domain/lib/types/DataType'; import { ActionDef, Index } from 'oak-domain/lib/types'; import { EntityDesc } from 'oak-domain/lib/types/EntityDesc'; +import { Schema as Application } from './Application'; export interface Schema extends EntityShape { origin: 'mobile' | 'email'; @@ -13,6 +14,7 @@ export interface Schema extends EntityShape { expired: Boolean; expiresAt: Datetime; type: 'login' | 'changePassword' | 'confirm'; + application?: Application; }; export type IState = 'unsent' | 'sending' | 'sent' | 'failure'; @@ -47,6 +49,7 @@ export const entityDesc: EntityDesc