@pylonts/dsl 1.1.1 → 1.1.2
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/dist/action.d.ts +7 -0
- package/dist/action.js +3 -0
- package/dist/asset.d.ts +2 -2
- package/dist/asset.js +2 -2
- package/dist/component.d.ts +20 -0
- package/dist/component.js +1 -0
- package/dist/convert.d.ts +9 -0
- package/dist/convert.js +3 -0
- package/dist/curd.d.ts +3 -1
- package/dist/db.d.ts +4 -0
- package/dist/db.js +9 -0
- package/dist/dsl.d.ts +5 -0
- package/dist/dto.d.ts +2 -2
- package/dist/dto.js +1 -1
- package/dist/event.d.ts +8 -0
- package/dist/event.js +3 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/mermaid-driver.js +2 -1
- package/dist/mock.d.ts +3 -21
- package/dist/mock.js +1 -18
- package/dist/mysql-driver.d.ts +4 -0
- package/dist/mysql-driver.js +8 -3
- package/dist/navigation.d.ts +22 -0
- package/dist/navigation.js +15 -0
- package/dist/page-def.d.ts +40 -0
- package/dist/page-def.js +38 -0
- package/dist/page-flow.d.ts +4 -2
- package/dist/page-flow.js +107 -12
- package/dist/page.d.ts +32 -10
- package/dist/page.js +20 -5
- package/dist/popup.d.ts +18 -0
- package/dist/popup.js +8 -0
- package/dist/project.d.ts +7 -0
- package/dist/provider.d.ts +54 -0
- package/dist/provider.js +18 -0
- package/dist/ref.d.ts +14 -0
- package/dist/ref.js +6 -0
- package/dist/route.d.ts +8 -0
- package/dist/route.js +3 -0
- package/docs/curd.md +110 -110
- package/docs/dto.md +66 -66
- package/docs/table.md +4 -2
- package/package.json +2 -2
- package/src/action.ts +11 -0
- package/src/asset.ts +63 -63
- package/src/bases.ts +29 -29
- package/src/component.ts +22 -0
- package/src/convert.ts +13 -0
- package/src/curd.ts +93 -91
- package/src/db.ts +11 -0
- package/src/dsl.ts +188 -182
- package/src/dto.ts +247 -247
- package/src/enum-driver.ts +42 -42
- package/src/event.ts +12 -0
- package/src/flow.ts +103 -103
- package/src/index.ts +31 -21
- package/src/mermaid-driver.ts +2 -1
- package/src/mock.ts +12 -45
- package/src/mysql-driver.ts +8 -2
- package/src/navigation.ts +29 -0
- package/src/page-def.ts +80 -0
- package/src/page-flow.ts +116 -14
- package/src/page.ts +51 -14
- package/src/patterns/retry.ts +54 -54
- package/src/popup.ts +25 -0
- package/src/project.ts +97 -90
- package/src/prototype.ts +29 -29
- package/src/provider.ts +73 -0
- package/src/ref.ts +19 -0
- package/src/route.ts +12 -0
- package/src/utils.ts +10 -10
package/src/dsl.ts
CHANGED
|
@@ -1,183 +1,189 @@
|
|
|
1
|
-
// DSL field type definitions.
|
|
2
|
-
// Shape: { type: <type name>, <extension fields> }
|
|
3
|
-
|
|
4
|
-
import type { DictionaryEntry } from './dictionary.js';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface
|
|
61
|
-
type: '
|
|
62
|
-
jsType: 'string';
|
|
63
|
-
precision
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
jsName: string
|
|
104
|
-
valueType: 'string' | 'integer'
|
|
105
|
-
values: EnumValue[]
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
1
|
+
// DSL field type definitions.
|
|
2
|
+
// Shape: { type: <type name>, <extension fields> }
|
|
3
|
+
|
|
4
|
+
import type { DictionaryEntry } from './dictionary.js';
|
|
5
|
+
import type { ImportBase } from './import-base.js';
|
|
6
|
+
import type { MockDescriptor } from './mock.js';
|
|
7
|
+
|
|
8
|
+
/** Field query comparison operators (search field semantics). */
|
|
9
|
+
export type Operator = 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ne';
|
|
10
|
+
|
|
11
|
+
export interface SchemaBase {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Schema base for cross-file entities. importRef locates the generating module; inline schemas omit it. */
|
|
17
|
+
export interface ImportableSchemaBase extends SchemaBase {
|
|
18
|
+
importRef?: ImportBase;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Field collection schemas (DB table vs DTO message); `type` is the discriminator */
|
|
22
|
+
export interface CollectionSchemaBase extends SchemaBase {
|
|
23
|
+
type: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface BaseField {
|
|
27
|
+
name: string;
|
|
28
|
+
/** 显示名称(中文标签) */
|
|
29
|
+
label?: string;
|
|
30
|
+
/** 字段描述 */
|
|
31
|
+
description?: string;
|
|
32
|
+
optional?: boolean;
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
default?: string;
|
|
35
|
+
/** 所属 schema(db 或 dto) */
|
|
36
|
+
schema?: CollectionSchemaBase;
|
|
37
|
+
/** Pure-data mock descriptor for test data generation */
|
|
38
|
+
mock?: MockDescriptor;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface StringField extends BaseField {
|
|
42
|
+
type: 'string';
|
|
43
|
+
jsType: 'string';
|
|
44
|
+
minLength?: number;
|
|
45
|
+
maxLength?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface TextField extends BaseField {
|
|
49
|
+
type: 'text';
|
|
50
|
+
jsType: 'string';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface IntField extends BaseField {
|
|
54
|
+
type: 'integer';
|
|
55
|
+
jsType: 'number';
|
|
56
|
+
min?: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface BigintField extends BaseField {
|
|
61
|
+
type: 'bigint';
|
|
62
|
+
jsType: 'string';
|
|
63
|
+
// Value is transported as string to keep precision beyond 2^53.
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface DecimalField extends BaseField {
|
|
67
|
+
type: 'decimal';
|
|
68
|
+
jsType: 'string';
|
|
69
|
+
precision: number;
|
|
70
|
+
scale: number;
|
|
71
|
+
// Value is transported as string to avoid binary float error.
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface BooleanField extends BaseField {
|
|
75
|
+
type: 'boolean';
|
|
76
|
+
jsType: 'boolean';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface DateField extends BaseField {
|
|
80
|
+
type: 'date';
|
|
81
|
+
jsType: 'Date';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface TimeField extends BaseField {
|
|
85
|
+
type: 'time';
|
|
86
|
+
jsType: 'string';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface DateTimeField extends BaseField {
|
|
90
|
+
type: 'datetime';
|
|
91
|
+
jsType: 'Date';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface EnumValue {
|
|
95
|
+
value: string | number;
|
|
96
|
+
symbol: string;
|
|
97
|
+
label: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Shared enum definition. Pure value object, safe to reference from multiple fields/tables. */
|
|
101
|
+
export interface EnumDef {
|
|
102
|
+
/** JS 定义名称,如 MerchantStatus */
|
|
103
|
+
jsName: string;
|
|
104
|
+
valueType: 'string' | 'integer';
|
|
105
|
+
values: EnumValue[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function defineEnum(
|
|
109
|
+
jsName: string,
|
|
110
|
+
valueType: 'string' | 'integer',
|
|
111
|
+
values: EnumValue[],
|
|
112
|
+
): EnumDef {
|
|
113
|
+
return { jsName, valueType, values };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface EnumField extends BaseField {
|
|
117
|
+
type: 'enum';
|
|
118
|
+
jsType: 'string' | 'number';
|
|
119
|
+
/** Reference to a shared enum definition (see defineEnum). */
|
|
120
|
+
enum: EnumDef;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface JsonField extends BaseField {
|
|
124
|
+
type: 'json';
|
|
125
|
+
jsType: 'object';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type Field =
|
|
129
|
+
| StringField
|
|
130
|
+
| TextField
|
|
131
|
+
| IntField
|
|
132
|
+
| BigintField
|
|
133
|
+
| DecimalField
|
|
134
|
+
| BooleanField
|
|
135
|
+
| DateField
|
|
136
|
+
| TimeField
|
|
137
|
+
| DateTimeField
|
|
138
|
+
| EnumField
|
|
139
|
+
| JsonField;
|
|
140
|
+
|
|
141
|
+
// Field builders: type and jsType are fixed, pass extra properties only.
|
|
142
|
+
// The field name is written back from the map key later (see defineTable).
|
|
143
|
+
|
|
144
|
+
type FieldExtras<T extends Field> = Omit<T, 'name' | 'type' | 'jsType'>;
|
|
145
|
+
|
|
146
|
+
export function stringField(extra: FieldExtras<StringField> = {}): StringField {
|
|
147
|
+
return { name: '', type: 'string', jsType: 'string', ...extra };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function textField(extra: FieldExtras<TextField> = {}): TextField {
|
|
151
|
+
return { name: '', type: 'text', jsType: 'string', ...extra };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function intField(extra: FieldExtras<IntField> = {}): IntField {
|
|
155
|
+
return { name: '', type: 'integer', jsType: 'number', ...extra };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function bigintField(extra: FieldExtras<BigintField> = {}): BigintField {
|
|
159
|
+
return { name: '', type: 'bigint', jsType: 'string', ...extra };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function decimalField(extra: FieldExtras<DecimalField>): DecimalField {
|
|
163
|
+
return { name: '', type: 'decimal', jsType: 'string', ...extra };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function booleanField(extra: FieldExtras<BooleanField> = {}): BooleanField {
|
|
167
|
+
return { name: '', type: 'boolean', jsType: 'boolean', ...extra };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function dateField(extra: FieldExtras<DateField> = {}): DateField {
|
|
171
|
+
return { name: '', type: 'date', jsType: 'Date', ...extra };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function timeField(extra: FieldExtras<TimeField> = {}): TimeField {
|
|
175
|
+
return { name: '', type: 'time', jsType: 'string', ...extra };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function datetimeField(extra: FieldExtras<DateTimeField> = {}): DateTimeField {
|
|
179
|
+
return { name: '', type: 'datetime', jsType: 'Date', ...extra };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function jsonField(extra: FieldExtras<JsonField> = {}): JsonField {
|
|
183
|
+
return { name: '', type: 'json', jsType: 'object', ...extra };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function enumField(extra: Omit<EnumField, 'name' | 'type' | 'jsType'>): EnumField {
|
|
187
|
+
const jsType = extra.enum.valueType === 'integer' ? 'number' : 'string';
|
|
188
|
+
return { name: '', type: 'enum', jsType, ...extra };
|
|
183
189
|
}
|