三面拆分⑥:触发器 upsert 路由 —— 定义面的 HTTP 口(启停仍走 toggle)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
@@ -1380,6 +1380,119 @@ export declare const toggleTriggerRoute: {
|
|||||||
ok: z.ZodBoolean;
|
ok: z.ZodBoolean;
|
||||||
}, z.core.$strip>;
|
}, z.core.$strip>;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 调起规则的**定义面**(设计中心):新建 / 改规则 / 改起单装配。
|
||||||
|
*
|
||||||
|
* 与 `toggleTriggerRoute` 分开是有意的:定义归设计,启停归运营 ——
|
||||||
|
* 同一个触发器,「它按什么规则调起」和「今天开不开」是两个人在两个台面上做的两件事。
|
||||||
|
* 触发器与流程包平级:改它**不动任何包版本**。
|
||||||
|
*/
|
||||||
|
export declare const upsertTriggerRoute: {
|
||||||
|
readonly method: "PUT";
|
||||||
|
readonly path: "/api/gov/triggers";
|
||||||
|
readonly body: z.ZodObject<{
|
||||||
|
trigger: z.ZodObject<{
|
||||||
|
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||||
|
name: z.ZodString;
|
||||||
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||||
|
processPackageId: z.core.$ZodBranded<z.ZodString, "ProcessPackageId", "out">;
|
||||||
|
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||||
|
target: z.ZodString;
|
||||||
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"output-port">;
|
||||||
|
port: z.ZodString;
|
||||||
|
path: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"workflow-var">;
|
||||||
|
name: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"initiation">;
|
||||||
|
path: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"constant">;
|
||||||
|
value: z.ZodUnknown;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"expression">;
|
||||||
|
sfeel: z.ZodString;
|
||||||
|
}, z.core.$strip>], "from">;
|
||||||
|
}, z.core.$strip>>>;
|
||||||
|
spec: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"periodic-calendar">;
|
||||||
|
calendar: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"periodic-data">;
|
||||||
|
domain: z.ZodString;
|
||||||
|
object: z.ZodString;
|
||||||
|
dateField: z.ZodString;
|
||||||
|
offset: z.ZodString;
|
||||||
|
filter: z.ZodOptional<z.ZodString>;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"event">;
|
||||||
|
rule: z.ZodString;
|
||||||
|
eventType: z.ZodDefault<z.ZodEnum<{
|
||||||
|
human: "human";
|
||||||
|
data: "data";
|
||||||
|
time: "time";
|
||||||
|
control: "control";
|
||||||
|
}>>;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"registration">;
|
||||||
|
formHint: z.ZodOptional<z.ZodString>;
|
||||||
|
}, z.core.$strip>], "kind">;
|
||||||
|
}, z.core.$strip>;
|
||||||
|
}, z.core.$strip>;
|
||||||
|
readonly output: z.ZodObject<{
|
||||||
|
trigger: z.ZodObject<{
|
||||||
|
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||||
|
name: z.ZodString;
|
||||||
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||||
|
processPackageId: z.core.$ZodBranded<z.ZodString, "ProcessPackageId", "out">;
|
||||||
|
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||||
|
target: z.ZodString;
|
||||||
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"output-port">;
|
||||||
|
port: z.ZodString;
|
||||||
|
path: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"workflow-var">;
|
||||||
|
name: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"initiation">;
|
||||||
|
path: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"constant">;
|
||||||
|
value: z.ZodUnknown;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
from: z.ZodLiteral<"expression">;
|
||||||
|
sfeel: z.ZodString;
|
||||||
|
}, z.core.$strip>], "from">;
|
||||||
|
}, z.core.$strip>>>;
|
||||||
|
spec: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"periodic-calendar">;
|
||||||
|
calendar: z.ZodString;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"periodic-data">;
|
||||||
|
domain: z.ZodString;
|
||||||
|
object: z.ZodString;
|
||||||
|
dateField: z.ZodString;
|
||||||
|
offset: z.ZodString;
|
||||||
|
filter: z.ZodOptional<z.ZodString>;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"event">;
|
||||||
|
rule: z.ZodString;
|
||||||
|
eventType: z.ZodDefault<z.ZodEnum<{
|
||||||
|
human: "human";
|
||||||
|
data: "data";
|
||||||
|
time: "time";
|
||||||
|
control: "control";
|
||||||
|
}>>;
|
||||||
|
}, z.core.$strip>, z.ZodObject<{
|
||||||
|
kind: z.ZodLiteral<"registration">;
|
||||||
|
formHint: z.ZodOptional<z.ZodString>;
|
||||||
|
}, z.core.$strip>], "kind">;
|
||||||
|
}, z.core.$strip>;
|
||||||
|
}, z.core.$strip>;
|
||||||
|
};
|
||||||
export declare const listActivitiesRoute: {
|
export declare const listActivitiesRoute: {
|
||||||
readonly method: "GET";
|
readonly method: "GET";
|
||||||
readonly path: "/api/gov/activities";
|
readonly path: "/api/gov/activities";
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
staffIdSchema,
|
staffIdSchema,
|
||||||
taskIdSchema,
|
taskIdSchema,
|
||||||
toggleTriggerRoute,
|
toggleTriggerRoute,
|
||||||
|
upsertTriggerRoute,
|
||||||
validateProcessRoute,
|
validateProcessRoute,
|
||||||
} from '@contracts';
|
} from '@contracts';
|
||||||
import { NotPublishableError } from '@modules/process';
|
import { NotPublishableError } from '@modules/process';
|
||||||
@@ -331,6 +332,21 @@ export function registerGovernanceOpsRoutes(app: Hono<AppEnv>, container: Contai
|
|||||||
return c.json({ ok: true });
|
return c.json({ ok: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调起规则的定义面(设计中心)—— 新建 / 改规则 / 改起单装配。
|
||||||
|
* 启停不走这里(那是运营的事,见 toggle);改定义同样不动任何流程包版本。
|
||||||
|
*/
|
||||||
|
app.put(upsertTriggerRoute.path, async (c) => {
|
||||||
|
const denied = await governTrigger(c.get('account'));
|
||||||
|
if (denied) return c.json(denied, denyStatus(denied));
|
||||||
|
const parsed = upsertTriggerRoute.body.safeParse(await c.req.json());
|
||||||
|
if (!parsed.success) {
|
||||||
|
const body: ApiError = { code: 'validation-failed', message: '触发器不合 schema', detail: parsed.error.issues };
|
||||||
|
return c.json(body, 400);
|
||||||
|
}
|
||||||
|
return c.json({ trigger: await container.trigger.upsert(parsed.data.trigger) });
|
||||||
|
});
|
||||||
|
|
||||||
/* ── 活动库管理:两维分类 × 两条版本序列 ─────────────────────────── */
|
/* ── 活动库管理:两维分类 × 两条版本序列 ─────────────────────────── */
|
||||||
|
|
||||||
app.get(listActivitiesRoute.path, async (c) => {
|
app.get(listActivitiesRoute.path, async (c) => {
|
||||||
|
|||||||
@@ -236,6 +236,20 @@ export const toggleTriggerRoute = {
|
|||||||
output: z.object({ ok: z.boolean() }),
|
output: z.object({ ok: z.boolean() }),
|
||||||
} as const satisfies RouteContract;
|
} as const satisfies RouteContract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调起规则的**定义面**(设计中心):新建 / 改规则 / 改起单装配。
|
||||||
|
*
|
||||||
|
* 与 `toggleTriggerRoute` 分开是有意的:定义归设计,启停归运营 ——
|
||||||
|
* 同一个触发器,「它按什么规则调起」和「今天开不开」是两个人在两个台面上做的两件事。
|
||||||
|
* 触发器与流程包平级:改它**不动任何包版本**。
|
||||||
|
*/
|
||||||
|
export const upsertTriggerRoute = {
|
||||||
|
method: 'PUT',
|
||||||
|
path: '/api/gov/triggers',
|
||||||
|
body: z.object({ trigger: triggerConfigSchema }),
|
||||||
|
output: z.object({ trigger: triggerConfigSchema }),
|
||||||
|
} as const satisfies RouteContract;
|
||||||
|
|
||||||
/* ── 活动库管理:两维分类 × 包版本 × 资产版本 ─────────────────────────── */
|
/* ── 活动库管理:两维分类 × 包版本 × 资产版本 ─────────────────────────── */
|
||||||
|
|
||||||
export const listActivitiesRoute = {
|
export const listActivitiesRoute = {
|
||||||
|
|||||||
Reference in New Issue
Block a user