@pylonts/dsl 1.1.21 → 1.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/action.d.ts +76 -33
- package/dist/action.js +19 -17
- package/dist/component.d.ts +3 -3
- package/dist/curd.d.ts +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/journey.d.ts +23 -0
- package/dist/journey.js +26 -0
- package/dist/navigation.d.ts +2 -2
- package/dist/page-action.d.ts +39 -0
- package/dist/page-action.js +17 -0
- package/dist/page-def.d.ts +9 -9
- package/dist/page-flow.d.ts +4 -4
- package/dist/popup.d.ts +3 -3
- package/dist/task.d.ts +20 -0
- package/dist/task.js +21 -0
- package/docs/aggregate-implementation.md +174 -174
- package/docs/aggregate.md +147 -147
- package/docs/concepts.md +109 -0
- package/docs/table.md +41 -41
- package/docs/task.md +81 -0
- package/package.json +1 -1
- package/src/action.ts +87 -52
- package/src/aggregate.ts +94 -94
- package/src/component.ts +3 -3
- package/src/curd.ts +2 -2
- package/src/index.ts +3 -0
- package/src/journey.ts +61 -0
- package/src/navigation.ts +2 -2
- package/src/page-action.ts +59 -0
- package/src/page-def.ts +9 -9
- package/src/page-flow.ts +4 -4
- package/src/popup.ts +3 -3
- package/src/repository.ts +35 -35
- package/src/task.ts +52 -0
package/README.md
CHANGED
|
@@ -7,21 +7,24 @@ Schema 定义与产物生成分离的 DSL 系统:先写 DSL 元数据(表 /
|
|
|
7
7
|
从概要设计到详细设计的自顶向下链路:
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
11
|
-
→
|
|
12
|
-
→
|
|
13
|
-
→
|
|
14
|
-
→
|
|
10
|
+
concepts(概念:名词 + 名词解释——先于一切存在的名字层)
|
|
11
|
+
→ project(地图:应用与 API 拓扑)
|
|
12
|
+
→ dictionary(词典:词根与字段命名标准,概念派生)
|
|
13
|
+
→ prototype(概要设计:页面与字段)
|
|
14
|
+
→ table / dto(详细设计)
|
|
15
|
+
→ driver 生成产物(SQL / 枚举 / TypeBox)
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
## 文档
|
|
18
19
|
|
|
20
|
+
- [concepts.md](./docs/concepts.md) — 概念层(名词 + 名词解释,蓝图的名字层;设计草案)
|
|
19
21
|
- [project.md](./docs/project.md) — 项目拓扑(地图)
|
|
20
22
|
- [dictionary.md](./docs/dictionary.md) — 短语词典(命名标准)
|
|
21
23
|
- [prototype.md](./docs/prototype.md) — 页面原型(概要设计)
|
|
22
24
|
- [table.md](./docs/table.md) — 定义表(详细设计)
|
|
23
25
|
- [dto.md](./docs/dto.md) — 定义 DTO
|
|
24
26
|
- [curd.md](./docs/curd.md) — 管理端 CRUD 页面标准(CurdSchema)
|
|
27
|
+
- [task.md](./docs/task.md) — 系统任务(TaskSchema:scheduled 定时 / async 异步,action 闭包成员)
|
|
25
28
|
- [utils.md](./docs/utils.md) — 工具模块与领域规则(UtilsSchema:防御 guard / 判断 / 计算)
|
|
26
29
|
- [aggregate.md](./docs/aggregate.md) — 聚合/仓储 DSL 扩展规划(声明层已落地:DomainAggregate/RepositorySchema + 存储校验,生成器待选型)
|
|
27
30
|
- [domain-event.md](./docs/domain-event.md) — 领域事件 DSL 扩展规划(声明层已落地:DomainEventSchema + event_schema 存储校验,发布/订阅待实现)
|
package/dist/action.d.ts
CHANGED
|
@@ -1,39 +1,82 @@
|
|
|
1
1
|
import { SchemaBase } from './dsl.js';
|
|
2
|
-
import type { DtoField, DtoMessage, DtoArrayField, DtoObjectField } from './dto.js';
|
|
3
|
-
import type { RefSchema } from './ref.js';
|
|
4
2
|
import type { ControllerMethodSchema } from './controller.js';
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type { ThirdServiceMethodSchema, ThirdCallbackSchema } from './third-service.js';
|
|
4
|
+
import type { TaskSchema } from './task.js';
|
|
5
|
+
import type { TableSchema } from './db.js';
|
|
6
|
+
import type { PageSchema } from './page.js';
|
|
7
|
+
/** A beat of a journey: type + properties + input data. */
|
|
7
8
|
export interface ActionSchema extends SchemaBase {
|
|
8
|
-
type:
|
|
9
|
+
type: 'page' | 'controller' | 'third' | 'db' | 'task';
|
|
10
|
+
/** Input data of this beat (blueprint: names first, refined to refs later). */
|
|
11
|
+
data?: Record<string, unknown>;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
/** Visit a page — `data` present means fill/submit a form, absent means pure view. */
|
|
14
|
+
export interface PageAction extends ActionSchema {
|
|
15
|
+
type: 'page';
|
|
16
|
+
/** Target page (PageFlow node). */
|
|
17
|
+
page: PageSchema;
|
|
18
|
+
/** Page url/path (e.g. '/bd/apply'). */
|
|
19
|
+
url: string;
|
|
20
|
+
}
|
|
21
|
+
/** Call a backend controller method. */
|
|
22
|
+
export interface ControllerAction extends ActionSchema {
|
|
23
|
+
type: 'controller';
|
|
24
|
+
/** The controller method invoked (shared instance). */
|
|
25
|
+
method: ControllerMethodSchema;
|
|
26
|
+
}
|
|
27
|
+
/** Invoke a third-party service method or receive its callback. */
|
|
28
|
+
export interface ThirdAction extends ActionSchema {
|
|
29
|
+
type: 'third';
|
|
30
|
+
/** The third-party method invoked (outbound). */
|
|
31
|
+
method?: ThirdServiceMethodSchema;
|
|
32
|
+
/** The third-party callback received (inbound) — mutually exclusive with method. */
|
|
33
|
+
callback?: ThirdCallbackSchema;
|
|
34
|
+
/** Wait for the async callback (inbound) before the journey continues. */
|
|
35
|
+
async?: boolean;
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
/** Write to a database table. */
|
|
38
|
+
export interface DbAction extends ActionSchema {
|
|
39
|
+
type: 'db';
|
|
40
|
+
/** The table written (shared instance). */
|
|
41
|
+
table: TableSchema;
|
|
42
|
+
/** Write operation: insert | update | delete. */
|
|
43
|
+
op: 'insert' | 'update' | 'delete';
|
|
38
44
|
}
|
|
39
|
-
|
|
45
|
+
/** Trigger a system task (scheduled or async). */
|
|
46
|
+
export interface TaskAction extends ActionSchema {
|
|
47
|
+
type: 'task';
|
|
48
|
+
/** The task triggered (shared instance). */
|
|
49
|
+
task: TaskSchema;
|
|
50
|
+
}
|
|
51
|
+
/** Builder for a journey action. */
|
|
52
|
+
export declare const action: {
|
|
53
|
+
page(options: {
|
|
54
|
+
page: PageSchema;
|
|
55
|
+
url: string;
|
|
56
|
+
data?: Record<string, unknown>;
|
|
57
|
+
description?: string;
|
|
58
|
+
}): PageAction;
|
|
59
|
+
controller(options: {
|
|
60
|
+
method: ControllerMethodSchema;
|
|
61
|
+
data?: Record<string, unknown>;
|
|
62
|
+
description?: string;
|
|
63
|
+
}): ControllerAction;
|
|
64
|
+
third(options: {
|
|
65
|
+
method?: ThirdServiceMethodSchema;
|
|
66
|
+
callback?: ThirdCallbackSchema;
|
|
67
|
+
data?: Record<string, unknown>;
|
|
68
|
+
async?: boolean;
|
|
69
|
+
description?: string;
|
|
70
|
+
}): ThirdAction;
|
|
71
|
+
db(options: {
|
|
72
|
+
table: TableSchema;
|
|
73
|
+
op: 'insert' | 'update' | 'delete';
|
|
74
|
+
data?: Record<string, unknown>;
|
|
75
|
+
description?: string;
|
|
76
|
+
}): DbAction;
|
|
77
|
+
task(options: {
|
|
78
|
+
task: TaskSchema;
|
|
79
|
+
data?: Record<string, unknown>;
|
|
80
|
+
description?: string;
|
|
81
|
+
}): TaskAction;
|
|
82
|
+
};
|
package/dist/action.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
/** Builder for a journey action. */
|
|
2
|
+
export const action = {
|
|
3
|
+
page(options) {
|
|
4
|
+
return { name: options.page.name, type: 'page', page: options.page, url: options.url, data: options.data, description: options.description };
|
|
5
|
+
},
|
|
6
|
+
controller(options) {
|
|
7
|
+
return { name: options.method.name, type: 'controller', method: options.method, data: options.data, description: options.description };
|
|
8
|
+
},
|
|
9
|
+
third(options) {
|
|
10
|
+
const name = options.method?.name ?? options.callback?.name ?? 'third';
|
|
11
|
+
return { name, type: 'third', method: options.method, callback: options.callback, data: options.data, async: options.async, description: options.description };
|
|
12
|
+
},
|
|
13
|
+
db(options) {
|
|
14
|
+
return { name: options.table.name, type: 'db', table: options.table, op: options.op, data: options.data, description: options.description };
|
|
15
|
+
},
|
|
16
|
+
task(options) {
|
|
17
|
+
return { name: options.task.name, type: 'task', task: options.task, data: options.data, description: options.description };
|
|
18
|
+
},
|
|
19
|
+
};
|
package/dist/component.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { SchemaBase } from './dsl.js';
|
|
2
2
|
import type { RefSchema } from './ref.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PageActionSchema } from './page-action.js';
|
|
4
4
|
import type { EventDataSchema } from './event.js';
|
|
5
5
|
/** A component event trigger declaration. */
|
|
6
6
|
export interface TriggerSchema extends SchemaBase {
|
|
7
7
|
/** Data the event carries (e.g. e.detail). */
|
|
8
8
|
eventData?: EventDataSchema;
|
|
9
|
-
/**
|
|
10
|
-
actions?:
|
|
9
|
+
/** Page actions that fire when the event occurs. */
|
|
10
|
+
actions?: PageActionSchema[];
|
|
11
11
|
}
|
|
12
12
|
/** A UI component declaration — a virtual schema that describes props and
|
|
13
13
|
* event triggers, not a real renderable component.
|
package/dist/curd.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemaBase, Field } from './dsl.js';
|
|
2
2
|
import { TableSchema } from './db.js';
|
|
3
3
|
import { FrontAppSchema } from './project.js';
|
|
4
|
-
import {
|
|
4
|
+
import { PageActionSchema } from './page-action.js';
|
|
5
5
|
import type { FilterSchema } from './filter.js';
|
|
6
6
|
/** Mode of an action page: modal dialog or standalone route. */
|
|
7
7
|
export type ActionPageMode = 'modal' | 'route';
|
|
@@ -43,7 +43,7 @@ export interface CurdSchema extends SchemaBase {
|
|
|
43
43
|
/** Sidebar menu section (group) this CRUD page belongs to. */
|
|
44
44
|
section: string;
|
|
45
45
|
/** Extra user actions on this page (beyond the standard CRUD). */
|
|
46
|
-
actions?:
|
|
46
|
+
actions?: PageActionSchema[];
|
|
47
47
|
/** Add/update/detail action pages. */
|
|
48
48
|
actionPages?: {
|
|
49
49
|
add?: ActionPage;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from './pattern.js';
|
|
|
16
16
|
export * from './patterns/retry.js';
|
|
17
17
|
export * from './flow.js';
|
|
18
18
|
export * from './action.js';
|
|
19
|
+
export * from './journey.js';
|
|
20
|
+
export * from './page-action.js';
|
|
19
21
|
export * from './event.js';
|
|
20
22
|
export * from './component.js';
|
|
21
23
|
export * from './convert.js';
|
|
@@ -31,6 +33,7 @@ export * from './aggregate.js';
|
|
|
31
33
|
export * from './repository.js';
|
|
32
34
|
export * from './domain-event.js';
|
|
33
35
|
export * from './third-service.js';
|
|
36
|
+
export * from './task.js';
|
|
34
37
|
export * from './token.js';
|
|
35
38
|
export * from './field-rule.js';
|
|
36
39
|
export * from './exception.js';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ export * from './pattern.js';
|
|
|
16
16
|
export * from './patterns/retry.js';
|
|
17
17
|
export * from './flow.js';
|
|
18
18
|
export * from './action.js';
|
|
19
|
+
export * from './journey.js';
|
|
20
|
+
export * from './page-action.js';
|
|
19
21
|
export * from './event.js';
|
|
20
22
|
export * from './component.js';
|
|
21
23
|
export * from './convert.js';
|
|
@@ -31,6 +33,7 @@ export * from './aggregate.js';
|
|
|
31
33
|
export * from './repository.js';
|
|
32
34
|
export * from './domain-event.js';
|
|
33
35
|
export * from './third-service.js';
|
|
36
|
+
export * from './task.js';
|
|
34
37
|
export * from './token.js';
|
|
35
38
|
export * from './field-rule.js';
|
|
36
39
|
export * from './exception.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SchemaBase } from './dsl.js';
|
|
2
|
+
import type { ActionSchema } from './action.js';
|
|
3
|
+
/** One business journey: a goal-directed line of actions. */
|
|
4
|
+
export interface JourneySchema extends SchemaBase {
|
|
5
|
+
/** Chinese title of the journey. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** The business goal the journey achieves (what it is for). */
|
|
8
|
+
goal: string;
|
|
9
|
+
/** The running list of actions, in business order. */
|
|
10
|
+
actions: ActionSchema[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Defines a business journey. `name` is kebab-case (e.g. 'merchant-onboarding');
|
|
14
|
+
* the export symbol is the kebab-camel of the name (merchantOnboarding).
|
|
15
|
+
* File name is the name plus '.journey.ts' (journey_schema/merchant-onboarding.journey.ts).
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineJourney(options: {
|
|
18
|
+
name: string;
|
|
19
|
+
title: string;
|
|
20
|
+
goal: string;
|
|
21
|
+
actions: ActionSchema[];
|
|
22
|
+
description?: string;
|
|
23
|
+
}): JourneySchema;
|
package/dist/journey.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a business journey. `name` is kebab-case (e.g. 'merchant-onboarding');
|
|
3
|
+
* the export symbol is the kebab-camel of the name (merchantOnboarding).
|
|
4
|
+
* File name is the name plus '.journey.ts' (journey_schema/merchant-onboarding.journey.ts).
|
|
5
|
+
*/
|
|
6
|
+
export function defineJourney(options) {
|
|
7
|
+
if (!/^[a-z][a-z0-9-]*$/.test(options.name)) {
|
|
8
|
+
throw new Error(`journey ${options.name}: name must be kebab-case (lowercase letters/digits/dashes)`);
|
|
9
|
+
}
|
|
10
|
+
if (!options.title) {
|
|
11
|
+
throw new Error(`journey ${options.name}: title is required`);
|
|
12
|
+
}
|
|
13
|
+
if (!options.goal) {
|
|
14
|
+
throw new Error(`journey ${options.name}: goal is required`);
|
|
15
|
+
}
|
|
16
|
+
if (!options.actions || options.actions.length === 0) {
|
|
17
|
+
throw new Error(`journey ${options.name}: actions must be non-empty (a journey is a line of actions)`);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
name: options.name,
|
|
21
|
+
title: options.title,
|
|
22
|
+
goal: options.goal,
|
|
23
|
+
description: options.description,
|
|
24
|
+
actions: options.actions,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/navigation.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RouteDataSchema } from './route.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageActionSchema } from './page-action.js';
|
|
3
3
|
import { PageSchema } from './page.js';
|
|
4
4
|
/** Navigation primitives: front-end routing actions that are not provider calls. */
|
|
5
|
-
export interface NavigationAction extends
|
|
5
|
+
export interface NavigationAction extends PageActionSchema {
|
|
6
6
|
type: 'navigation';
|
|
7
7
|
method: 'back' | 'push' | 'popup' | 'home';
|
|
8
8
|
/** Target page for push navigation. */
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SchemaBase } from './dsl.js';
|
|
2
|
+
import type { DtoField, DtoMessage, DtoArrayField, DtoObjectField } from './dto.js';
|
|
3
|
+
import type { RefSchema } from './ref.js';
|
|
4
|
+
import type { ControllerMethodSchema } from './controller.js';
|
|
5
|
+
/** An action a user can perform on a page (e.g. submit, approve, reject).
|
|
6
|
+
* Subclasses use `type` as the discriminator. */
|
|
7
|
+
export interface PageActionSchema extends SchemaBase {
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function definePageAction(name: string, description?: string): PageActionSchema;
|
|
11
|
+
/** Parameter data source for a call argument. */
|
|
12
|
+
export type DataRef = {
|
|
13
|
+
type: 'route';
|
|
14
|
+
key: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'data';
|
|
17
|
+
key: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'value';
|
|
20
|
+
value: unknown;
|
|
21
|
+
};
|
|
22
|
+
/** Create a route-parameter reference. */
|
|
23
|
+
export declare function route(key: string): DataRef;
|
|
24
|
+
/** Create a page-data reference. */
|
|
25
|
+
export declare function data(key: string): DataRef;
|
|
26
|
+
export interface CallAction extends PageActionSchema {
|
|
27
|
+
type: 'call';
|
|
28
|
+
func: ControllerMethodSchema;
|
|
29
|
+
args?: Record<string, DtoField | DtoMessage | DtoArrayField | DtoObjectField | RefSchema | string>;
|
|
30
|
+
}
|
|
31
|
+
export declare function call(func: ControllerMethodSchema, args?: Record<string, DtoField | DtoMessage | DtoArrayField | DtoObjectField | RefSchema | string>): CallAction;
|
|
32
|
+
/** Assign a call's result to a page data field.
|
|
33
|
+
* React: setState({ [field]: await ... }). Mini-program: this.setData({ [field]: ... }). */
|
|
34
|
+
export interface SetDataAction extends PageActionSchema {
|
|
35
|
+
type: 'setData';
|
|
36
|
+
call: CallAction;
|
|
37
|
+
field: DtoField;
|
|
38
|
+
}
|
|
39
|
+
export declare function setData(call: CallAction, field: DtoField): SetDataAction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function definePageAction(name, description) {
|
|
2
|
+
return { name, description, type: 'gesture' };
|
|
3
|
+
}
|
|
4
|
+
/** Create a route-parameter reference. */
|
|
5
|
+
export function route(key) {
|
|
6
|
+
return { type: 'route', key };
|
|
7
|
+
}
|
|
8
|
+
/** Create a page-data reference. */
|
|
9
|
+
export function data(key) {
|
|
10
|
+
return { type: 'data', key };
|
|
11
|
+
}
|
|
12
|
+
export function call(func, args) {
|
|
13
|
+
return { name: func.name, type: 'call', func, args };
|
|
14
|
+
}
|
|
15
|
+
export function setData(call, field) {
|
|
16
|
+
return { name: 'setData', type: 'setData', call, field };
|
|
17
|
+
}
|
package/dist/page-def.d.ts
CHANGED
|
@@ -2,21 +2,21 @@ import type { ImportableSchemaBase, CollectionSchemaBase, SchemaBase } from './d
|
|
|
2
2
|
import { DtoField } from './dto.js';
|
|
3
3
|
import type { DtoMessage, DtoArrayField, DtoObjectField } from './dto.js';
|
|
4
4
|
import type { ComponentSchema } from './component.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { PageActionSchema } from './page-action.js';
|
|
6
6
|
export type { RouteDataSchema } from './route.js';
|
|
7
7
|
export { defineRouteData } from './route.js';
|
|
8
8
|
/** Page lifecycle events that trigger data loading. */
|
|
9
9
|
export interface EventSchema extends SchemaBase {
|
|
10
10
|
type: 'onLoad' | 'onShow' | 'onHide' | 'onPullDownRefresh' | 'onReachBottom';
|
|
11
|
-
/**
|
|
12
|
-
actions?:
|
|
11
|
+
/** Page actions that fire when this event occurs. */
|
|
12
|
+
actions?: PageActionSchema[];
|
|
13
13
|
}
|
|
14
14
|
export declare const events: {
|
|
15
|
-
onLoad(actions?:
|
|
16
|
-
onShow(actions?:
|
|
17
|
-
onHide(actions?:
|
|
18
|
-
onPullDownRefresh(actions?:
|
|
19
|
-
onReachBottom(actions?:
|
|
15
|
+
onLoad(actions?: PageActionSchema[], description?: string): EventSchema;
|
|
16
|
+
onShow(actions?: PageActionSchema[], description?: string): EventSchema;
|
|
17
|
+
onHide(actions?: PageActionSchema[], description?: string): EventSchema;
|
|
18
|
+
onPullDownRefresh(actions?: PageActionSchema[], description?: string): EventSchema;
|
|
19
|
+
onReachBottom(actions?: PageActionSchema[], description?: string): EventSchema;
|
|
20
20
|
};
|
|
21
21
|
/** Page data: a named collection of fields that defines the page's data shape. */
|
|
22
22
|
export interface PageDataSchema extends CollectionSchemaBase {
|
|
@@ -30,7 +30,7 @@ export interface PageDef extends ImportableSchemaBase {
|
|
|
30
30
|
/** Lifecycle events that trigger data loading. */
|
|
31
31
|
events: EventSchema[];
|
|
32
32
|
/** Page actions (provider calls, navigation, etc.). */
|
|
33
|
-
actions:
|
|
33
|
+
actions: PageActionSchema[];
|
|
34
34
|
/** UI component declarations that make up the page skeleton. */
|
|
35
35
|
components: ComponentSchema[];
|
|
36
36
|
/** Whether the driver should generate page-level loading / error / empty state wrappers. */
|
package/dist/page-flow.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SchemaBase } from './dsl.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageActionSchema } from './page-action.js';
|
|
3
3
|
import { Page } from './page.js';
|
|
4
4
|
export interface PageEdge extends SchemaBase {
|
|
5
|
-
/** Trigger action; undefined = default path (success/normal). */
|
|
6
|
-
when?:
|
|
5
|
+
/** Trigger page action; undefined = default path (success/normal). */
|
|
6
|
+
when?: PageActionSchema;
|
|
7
7
|
start: Page;
|
|
8
8
|
end: Page;
|
|
9
9
|
}
|
|
@@ -14,7 +14,7 @@ export interface PageFlow extends SchemaBase {
|
|
|
14
14
|
pages: Page[];
|
|
15
15
|
edges: PageEdge[];
|
|
16
16
|
}
|
|
17
|
-
export declare function pageEdge(start: Page, end: Page, when?:
|
|
17
|
+
export declare function pageEdge(start: Page, end: Page, when?: PageActionSchema, description?: string): PageEdge;
|
|
18
18
|
export declare function definePageFlow(name: string, schema: {
|
|
19
19
|
start: Page;
|
|
20
20
|
pages: Page[];
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PageActionSchema } from './page-action.js';
|
|
2
2
|
import type { RefSchema } from './ref.js';
|
|
3
3
|
/** Display a toast notification. React: toast/message UI. Mini-program: wx.showToast. */
|
|
4
|
-
export interface ToastAction extends
|
|
4
|
+
export interface ToastAction extends PageActionSchema {
|
|
5
5
|
type: 'toast';
|
|
6
6
|
message: string | RefSchema;
|
|
7
7
|
icon?: 'success' | 'error' | 'loading' | 'none';
|
|
8
8
|
}
|
|
9
9
|
/** Display an alert dialog. React: modal. Mini-program: wx.showModal. */
|
|
10
|
-
export interface AlertAction extends
|
|
10
|
+
export interface AlertAction extends PageActionSchema {
|
|
11
11
|
type: 'alert';
|
|
12
12
|
title: string | RefSchema;
|
|
13
13
|
content: string | RefSchema;
|
package/dist/task.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CollectionSchemaBase } from './dsl.js';
|
|
2
|
+
export interface TaskSchema extends CollectionSchemaBase {
|
|
3
|
+
type: 'task';
|
|
4
|
+
/** Display label (Chinese) for the task. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Cron expression — the timer schedule. */
|
|
7
|
+
cron: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Defines a scheduled task. `name` must end with 'Task' (PascalCase,
|
|
11
|
+
* e.g. 'AutoRefundTask'); the export symbol equals the name. File name is the
|
|
12
|
+
* name minus the Task suffix, kebab-cased, plus '.task.ts'
|
|
13
|
+
* (AutoRefundTask → task_schema/auto-refund.task.ts).
|
|
14
|
+
*/
|
|
15
|
+
export declare function defineTask(options: {
|
|
16
|
+
name: string;
|
|
17
|
+
label: string;
|
|
18
|
+
cron: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}): TaskSchema;
|
package/dist/task.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a scheduled task. `name` must end with 'Task' (PascalCase,
|
|
3
|
+
* e.g. 'AutoRefundTask'); the export symbol equals the name. File name is the
|
|
4
|
+
* name minus the Task suffix, kebab-cased, plus '.task.ts'
|
|
5
|
+
* (AutoRefundTask → task_schema/auto-refund.task.ts).
|
|
6
|
+
*/
|
|
7
|
+
export function defineTask(options) {
|
|
8
|
+
if (!/(Task)$/.test(options.name)) {
|
|
9
|
+
throw new Error(`task ${options.name}: name must end with 'Task' (PascalCase, e.g. 'AutoRefundTask')`);
|
|
10
|
+
}
|
|
11
|
+
if (!options.cron || options.cron.trim() === '') {
|
|
12
|
+
throw new Error(`task ${options.name}: cron is required (a task is a timer)`);
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
type: 'task',
|
|
16
|
+
name: options.name,
|
|
17
|
+
label: options.label,
|
|
18
|
+
description: options.description,
|
|
19
|
+
cron: options.cron,
|
|
20
|
+
};
|
|
21
|
+
}
|