Skip to content

Commit 6f2664c

Browse files
committed
feat: 增加时间触发器定义和生命周期操作权限,优化工作流和权限模型
1 parent 38eede2 commit 6f2664c

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

packages/spec/src/data/flow.zod.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const FlowEdgeSchema = z.object({
5858
/** Condition for this path (only for decision/branch nodes) */
5959
condition: z.string().optional().describe('Expression returning boolean used for branching'),
6060

61+
type: z.enum(['default', 'fault']).default('default').describe('Connection type: Standard (Success) or Fault (Error) path'),
6162
label: z.string().optional().describe('Label on the connector'),
6263
});
6364

@@ -71,6 +72,11 @@ export const FlowSchema = z.object({
7172
label: z.string().describe('Flow label'),
7273
description: z.string().optional(),
7374

75+
/** Metadata & Versioning */
76+
version: z.number().int().default(1).describe('Version number'),
77+
status: z.enum(['draft', 'active', 'obsolete', 'invalid']).default('draft').describe('Deployment status'),
78+
template: z.boolean().default(false).describe('Is logic template (Subflow)'),
79+
7480
/** Trigger Type */
7581
type: z.enum(['autolaunched', 'record_change', 'schedule', 'screen', 'api']).describe('Flow type'),
7682

@@ -82,7 +88,7 @@ export const FlowSchema = z.object({
8288
edges: z.array(FlowEdgeSchema).describe('Flow connections'),
8389

8490
/** Execution Config */
85-
active: z.boolean().default(false).describe('Is active'),
91+
active: z.boolean().default(false).describe('Is active (Deprecated: use status)'),
8692
runAs: z.enum(['system', 'user']).default('user').describe('Execution context'),
8793
});
8894

packages/spec/src/data/permission.zod.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { z } from 'zod';
22

33
/**
44
* Entity (Object) Level Permissions
5-
* Defines CRUD + VAMA (View All / Modify All) access.
5+
* Defines CRUD + VAMA (View All / Modify All) + Lifecycle access.
6+
*
7+
* Refined with enterprise data lifecycle controls:
8+
* - Transfer (Ownership change)
9+
* - Restore (Soft delete recovery)
10+
* - Purge (Hard delete / Compliance)
611
*/
712
export const ObjectPermissionSchema = z.object({
813
/** C: Create */
@@ -14,6 +19,11 @@ export const ObjectPermissionSchema = z.object({
1419
/** D: Delete (Owned records or Shared records) */
1520
allowDelete: z.boolean().default(false).describe('Delete permission'),
1621

22+
/** Lifecycle Operations */
23+
allowTransfer: z.boolean().default(false).describe('Change record ownership'),
24+
allowRestore: z.boolean().default(false).describe('Restore from trash (Undelete)'),
25+
allowPurge: z.boolean().default(false).describe('Permanently delete (Hard Delete/GDPR)'),
26+
1727
/**
1828
* View All Records: Super-user read access.
1929
* Bypasses Sharing Rules and Ownership checks.

packages/spec/src/data/workflow.zod.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,26 @@ export const WorkflowActionSchema = z.discriminatedUnion('type', [
160160
CustomScriptActionSchema,
161161
]);
162162

163+
/**
164+
* Time Trigger Definition
165+
* Schedules actions to run relative to a specific time or date field.
166+
*/
167+
export const TimeTriggerSchema = z.object({
168+
id: z.string().optional().describe('Unique identifier'),
169+
170+
/** Timing Logic */
171+
timeLength: z.number().int().describe('Duration amount (e.g. 1, 30)'),
172+
timeUnit: z.enum(['minutes', 'hours', 'days']).describe('Unit of time'),
173+
174+
/** Reference Point */
175+
offsetDirection: z.enum(['before', 'after']).describe('Before or After the reference date'),
176+
offsetFrom: z.enum(['trigger_date', 'date_field']).describe('Basis for calculation'),
177+
dateField: z.string().optional().describe('Date field to calculate from (required if offsetFrom is date_field)'),
178+
179+
/** Actions */
180+
actions: z.array(WorkflowActionSchema).describe('Actions to execute at the scheduled time'),
181+
});
182+
163183
/**
164184
* Schema for Workflow Rules (Automation)
165185
*/
@@ -182,8 +202,18 @@ export const WorkflowRuleSchema = z.object({
182202
/** Actions to execute immediately */
183203
actions: z.array(WorkflowActionSchema).optional().describe('Immediate actions'),
184204

205+
/**
206+
* Time-Dependent Actions
207+
* Actions scheduled to run in the future.
208+
*/
209+
timeTriggers: z.array(TimeTriggerSchema).optional().describe('Scheduled actions relative to trigger or date field'),
210+
185211
/** Active status */
186212
active: z.boolean().default(true).describe('Whether this workflow is active'),
213+
214+
/** Recursion Control */
215+
reevaluateOnChange: z.boolean().default(false).describe('Re-evaluate rule if field updates change the record validity'),
187216
});
188217

189218
export type WorkflowRule = z.infer<typeof WorkflowRuleSchema>;
219+
export type TimeTrigger = z.infer<typeof TimeTriggerSchema>;

0 commit comments

Comments
 (0)