scaffold-engine 0.1.0

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.
Files changed (52) hide show
  1. package/README.md +117 -0
  2. package/engine.project.example.json +23 -0
  3. package/package.json +49 -0
  4. package/scripts/postinstall.cjs +42 -0
  5. package/specs/catalogs/action-templates.yaml +189 -0
  6. package/specs/catalogs/child-templates.yaml +54 -0
  7. package/specs/catalogs/field-fragments.yaml +203 -0
  8. package/specs/catalogs/object-catalog.yaml +35 -0
  9. package/specs/catalogs/object-name-suggestions.yaml +30 -0
  10. package/specs/catalogs/object-templates.yaml +45 -0
  11. package/specs/catalogs/pattern-catalog.yaml +48 -0
  12. package/specs/catalogs/status-templates.yaml +16 -0
  13. package/specs/projects/crm-pilot/customer.yaml +122 -0
  14. package/specs/projects/crm-pilot/lead.from-nl.yaml +76 -0
  15. package/specs/projects/crm-pilot/lead.yaml +82 -0
  16. package/specs/projects/generated-from-nl/crm-customer.yaml +158 -0
  17. package/specs/projects/generated-from-nl/crm-lead.yaml +76 -0
  18. package/specs/projects/generated-from-nl/crm-opportunity.yaml +78 -0
  19. package/specs/projects/generated-from-nl/crm-quote.yaml +78 -0
  20. package/specs/projects/generated-from-nl/custom-documentLines.yaml +125 -0
  21. package/specs/projects/generated-from-nl/custom-treeEntity.yaml +78 -0
  22. package/specs/projects/generated-from-nl/erp-material-pattern-test.yaml +79 -0
  23. package/specs/projects/generated-from-nl/erp-material.yaml +78 -0
  24. package/specs/projects/generated-from-nl/hr-orgUnit.yaml +100 -0
  25. package/specs/projects/pattern-examples/document-lines-demo.yaml +125 -0
  26. package/specs/projects/pattern-examples/tree-entity-demo.yaml +79 -0
  27. package/specs/rules/business-model.schema.json +262 -0
  28. package/specs/rules/extension-boundaries.json +26 -0
  29. package/specs/rules/requirement-draft.schema.json +75 -0
  30. package/specs/rules/spec-governance.json +29 -0
  31. package/specs/templates/crm/customer.template.yaml +121 -0
  32. package/specs/templates/crm/lead.template.yaml +82 -0
  33. package/tools/analyze-requirement.cjs +950 -0
  34. package/tools/cli.cjs +59 -0
  35. package/tools/create-draft.cjs +18 -0
  36. package/tools/engine.cjs +47 -0
  37. package/tools/generate-draft.cjs +33 -0
  38. package/tools/generate-module.cjs +1218 -0
  39. package/tools/init-project.cjs +194 -0
  40. package/tools/lib/draft-toolkit.cjs +357 -0
  41. package/tools/lib/model-toolkit.cjs +482 -0
  42. package/tools/lib/pattern-renderers.cjs +166 -0
  43. package/tools/lib/renderers/detail-page-renderer.cjs +327 -0
  44. package/tools/lib/renderers/form-page-renderer.cjs +553 -0
  45. package/tools/lib/renderers/list-page-renderer.cjs +371 -0
  46. package/tools/lib/runtime-config.cjs +154 -0
  47. package/tools/patch-draft.cjs +57 -0
  48. package/tools/prompts/business-model-prompt.md +58 -0
  49. package/tools/run-requirement.cjs +672 -0
  50. package/tools/validate-draft.cjs +32 -0
  51. package/tools/validate-model.cjs +140 -0
  52. package/tools/verify-patterns.cjs +67 -0
@@ -0,0 +1,125 @@
1
+ meta:
2
+ domain: demo
3
+ object: requestOrder
4
+ label: 申请单
5
+ pattern: documentLines
6
+ version: 0.1.0
7
+ description: 用于验证 documentLines 模式生成效果的最小示例。
8
+
9
+ data:
10
+ table: demo_request_order
11
+ fields:
12
+ - name: documentNo
13
+ label: 单据编号
14
+ type: string
15
+ required: true
16
+ unique: true
17
+ - name: documentTitle
18
+ label: 单据标题
19
+ type: string
20
+ required: true
21
+ - name: bizDate
22
+ label: 业务日期
23
+ type: date
24
+ required: true
25
+ - name: status
26
+ label: 状态
27
+ type: enum
28
+ options: [draft, active, closed]
29
+ default: draft
30
+ children:
31
+ - name: lines
32
+ label: 明细行
33
+ table: demo_request_order_line
34
+ foreignKey: documentId
35
+ fields:
36
+ - name: lineNo
37
+ label: 行号
38
+ type: string
39
+ required: true
40
+ - name: itemCode
41
+ label: 项目编码
42
+ type: string
43
+ required: true
44
+ - name: itemName
45
+ label: 项目名称
46
+ type: string
47
+ required: true
48
+ - name: quantity
49
+ label: 数量
50
+ type: number
51
+ required: true
52
+ - name: unitPrice
53
+ label: 单价
54
+ type: number
55
+ - name: amount
56
+ label: 金额
57
+ type: number
58
+
59
+ app:
60
+ actions: [create, update, list, detail, submit, approve, reject]
61
+ defaultStatus: draft
62
+ responseContract:
63
+ envelope: standard
64
+ listSchema: pagedList
65
+ detailSchema: object
66
+ mutationSchema: object
67
+ permissionProfile:
68
+ mode: inherit
69
+ resourceScope: document
70
+ actionPolicies:
71
+ - action: create
72
+ permission: create
73
+ - action: update
74
+ permission: update
75
+ - action: list
76
+ permission: list
77
+ - action: detail
78
+ permission: detail
79
+ - action: submit
80
+ permission: submit
81
+ - action: approve
82
+ permission: approve
83
+ - action: reject
84
+ permission: reject
85
+ statusFlow:
86
+ enabled: true
87
+ states: [draft, submitted, approved, rejected]
88
+ transitions:
89
+ - action: submit
90
+ from: [draft, rejected]
91
+ to: submitted
92
+ - action: approve
93
+ from: [submitted]
94
+ to: approved
95
+ - action: reject
96
+ from: [submitted]
97
+ to: rejected
98
+ validationRules:
99
+ - name: statusTransition
100
+ scope: workflow
101
+ rule: statusTransition
102
+ fields: [status]
103
+ message: 状态流转必须符合既定规则
104
+ errorCodes:
105
+ - code: VALIDATION_FAILED
106
+ message: 输入校验失败
107
+ - code: RECORD_NOT_FOUND
108
+ message: 单据不存在
109
+ - code: DUPLICATE_KEY
110
+ message: 单据编号已存在
111
+ - code: INVALID_STATUS_TRANSITION
112
+ message: 当前状态不允许执行该动作
113
+
114
+ ui:
115
+ list:
116
+ columns: [documentNo, documentTitle, bizDate, status, createdAt]
117
+ filters: [documentNo, documentTitle, status]
118
+ form:
119
+ groups:
120
+ - title: 基本信息
121
+ fields: [documentNo, documentTitle, bizDate, status]
122
+ - title: 明细行
123
+ childTable: lines
124
+ detail:
125
+ sections: [basicInfo, lines]
@@ -0,0 +1,79 @@
1
+ meta:
2
+ domain: demo
3
+ object: categoryNode
4
+ label: 分类节点
5
+ pattern: treeEntity
6
+ version: 0.1.0
7
+ description: 用于验证 treeEntity 模式生成效果的最小示例。
8
+
9
+ data:
10
+ table: demo_category_node
11
+ fields:
12
+ - name: categoryCode
13
+ label: 节点编码
14
+ type: string
15
+ required: true
16
+ unique: true
17
+ - name: categoryName
18
+ label: 节点名称
19
+ type: string
20
+ required: true
21
+ - name: parentId
22
+ label: 父节点ID
23
+ type: integer
24
+ - name: parentName
25
+ label: 父节点名称
26
+ type: string
27
+ - name: sortOrder
28
+ label: 排序号
29
+ type: integer
30
+ - name: status
31
+ label: 状态
32
+ type: enum
33
+ options: [active, inactive]
34
+ default: active
35
+
36
+ app:
37
+ actions: [create, update, list, detail]
38
+ defaultStatus: active
39
+ responseContract:
40
+ envelope: standard
41
+ listSchema: pagedList
42
+ detailSchema: object
43
+ mutationSchema: object
44
+ permissionProfile:
45
+ mode: inherit
46
+ resourceScope: object
47
+ actionPolicies:
48
+ - action: create
49
+ permission: create
50
+ - action: update
51
+ permission: update
52
+ - action: list
53
+ permission: list
54
+ - action: detail
55
+ permission: detail
56
+ validationRules:
57
+ - name: uniqueCategoryCode
58
+ scope: service
59
+ rule: unique
60
+ fields: [categoryCode]
61
+ message: 节点编码必须唯一
62
+ errorCodes:
63
+ - code: VALIDATION_FAILED
64
+ message: 输入校验失败
65
+ - code: RECORD_NOT_FOUND
66
+ message: 节点不存在
67
+ - code: DUPLICATE_KEY
68
+ message: 节点编码已存在
69
+
70
+ ui:
71
+ list:
72
+ columns: [categoryCode, categoryName, parentName, sortOrder, status, createdAt]
73
+ filters: [categoryCode, categoryName, parentName, status]
74
+ form:
75
+ groups:
76
+ - title: 基本信息
77
+ fields: [categoryCode, categoryName, parentId, parentName, sortOrder, status]
78
+ detail:
79
+ sections: [basicInfo]
@@ -0,0 +1,262 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://aiko-boot.local/scaffold/business-model.schema.json",
4
+ "title": "BusinessModelSpec",
5
+ "type": "object",
6
+ "required": ["meta", "data", "app", "ui"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "meta": {
10
+ "type": "object",
11
+ "required": ["domain", "object", "label", "version"],
12
+ "additionalProperties": false,
13
+ "properties": {
14
+ "domain": { "type": "string", "minLength": 1 },
15
+ "object": { "type": "string", "minLength": 1 },
16
+ "label": { "type": "string", "minLength": 1 },
17
+ "pattern": { "type": "string", "minLength": 1 },
18
+ "version": { "type": "string", "minLength": 1 },
19
+ "description": { "type": "string" }
20
+ }
21
+ },
22
+ "data": {
23
+ "type": "object",
24
+ "required": ["table", "fields"],
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "table": { "type": "string", "minLength": 1 },
28
+ "fields": {
29
+ "type": "array",
30
+ "minItems": 1,
31
+ "items": { "$ref": "#/$defs/field" }
32
+ },
33
+ "children": {
34
+ "type": "array",
35
+ "items": { "$ref": "#/$defs/childTable" }
36
+ }
37
+ }
38
+ },
39
+ "app": {
40
+ "type": "object",
41
+ "required": ["actions"],
42
+ "additionalProperties": false,
43
+ "properties": {
44
+ "actions": {
45
+ "type": "array",
46
+ "minItems": 1,
47
+ "items": {
48
+ "type": "string",
49
+ "enum": ["create", "update", "detail", "list", "activate", "deactivate", "submit", "approve", "reject", "close", "archive", "convert"]
50
+ }
51
+ },
52
+ "defaultStatus": { "type": "string" },
53
+ "statusFlow": { "$ref": "#/$defs/statusFlow" },
54
+ "responseContract": { "$ref": "#/$defs/responseContract" },
55
+ "permissionProfile": { "$ref": "#/$defs/permissionProfile" },
56
+ "validationRules": {
57
+ "type": "array",
58
+ "items": { "$ref": "#/$defs/validationRule" }
59
+ },
60
+ "errorCodes": {
61
+ "type": "array",
62
+ "items": { "$ref": "#/$defs/errorCode" }
63
+ }
64
+ }
65
+ },
66
+ "ui": {
67
+ "type": "object",
68
+ "required": ["list", "form", "detail"],
69
+ "additionalProperties": false,
70
+ "properties": {
71
+ "list": {
72
+ "type": "object",
73
+ "required": ["columns", "filters"],
74
+ "additionalProperties": false,
75
+ "properties": {
76
+ "columns": {
77
+ "type": "array",
78
+ "items": { "type": "string", "minLength": 1 }
79
+ },
80
+ "filters": {
81
+ "type": "array",
82
+ "items": { "type": "string", "minLength": 1 }
83
+ }
84
+ }
85
+ },
86
+ "form": {
87
+ "type": "object",
88
+ "required": ["groups"],
89
+ "additionalProperties": false,
90
+ "properties": {
91
+ "groups": {
92
+ "type": "array",
93
+ "minItems": 1,
94
+ "items": {
95
+ "type": "object",
96
+ "required": ["title"],
97
+ "additionalProperties": false,
98
+ "properties": {
99
+ "title": { "type": "string", "minLength": 1 },
100
+ "fields": {
101
+ "type": "array",
102
+ "items": { "type": "string", "minLength": 1 }
103
+ },
104
+ "childTable": { "type": "string", "minLength": 1 }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ },
110
+ "detail": {
111
+ "type": "object",
112
+ "required": ["sections"],
113
+ "additionalProperties": false,
114
+ "properties": {
115
+ "sections": {
116
+ "type": "array",
117
+ "minItems": 1,
118
+ "items": { "type": "string", "minLength": 1 }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ },
125
+ "$defs": {
126
+ "field": {
127
+ "type": "object",
128
+ "required": ["name", "type"],
129
+ "additionalProperties": false,
130
+ "properties": {
131
+ "name": { "type": "string", "minLength": 1 },
132
+ "type": {
133
+ "type": "string",
134
+ "enum": ["string", "text", "enum", "boolean", "integer", "number", "decimal", "date", "datetime"]
135
+ },
136
+ "label": { "type": "string" },
137
+ "required": { "type": "boolean" },
138
+ "unique": { "type": "boolean" },
139
+ "default": {
140
+ "oneOf": [
141
+ { "type": "string" },
142
+ { "type": "number" },
143
+ { "type": "boolean" }
144
+ ]
145
+ },
146
+ "options": {
147
+ "type": "array",
148
+ "items": {
149
+ "oneOf": [
150
+ { "type": "string" },
151
+ { "type": "number" }
152
+ ]
153
+ }
154
+ },
155
+ "column": { "type": "string" }
156
+ }
157
+ },
158
+ "childTable": {
159
+ "type": "object",
160
+ "required": ["name", "table", "foreignKey", "fields"],
161
+ "additionalProperties": false,
162
+ "properties": {
163
+ "name": { "type": "string", "minLength": 1 },
164
+ "table": { "type": "string", "minLength": 1 },
165
+ "foreignKey": { "type": "string", "minLength": 1 },
166
+ "label": { "type": "string" },
167
+ "fields": {
168
+ "type": "array",
169
+ "minItems": 1,
170
+ "items": { "$ref": "#/$defs/field" }
171
+ }
172
+ }
173
+ },
174
+ "statusFlow": {
175
+ "type": "object",
176
+ "required": ["enabled", "states", "transitions"],
177
+ "additionalProperties": false,
178
+ "properties": {
179
+ "enabled": { "type": "boolean" },
180
+ "states": {
181
+ "type": "array",
182
+ "minItems": 1,
183
+ "items": { "type": "string", "minLength": 1 }
184
+ },
185
+ "transitions": {
186
+ "type": "array",
187
+ "items": {
188
+ "type": "object",
189
+ "required": ["action", "from", "to"],
190
+ "additionalProperties": false,
191
+ "properties": {
192
+ "action": { "type": "string", "minLength": 1 },
193
+ "from": {
194
+ "type": "array",
195
+ "minItems": 1,
196
+ "items": { "type": "string", "minLength": 1 }
197
+ },
198
+ "to": { "type": "string", "minLength": 1 }
199
+ }
200
+ }
201
+ }
202
+ }
203
+ },
204
+ "errorCode": {
205
+ "type": "object",
206
+ "required": ["code", "message"],
207
+ "additionalProperties": false,
208
+ "properties": {
209
+ "code": { "type": "string", "minLength": 1 },
210
+ "message": { "type": "string", "minLength": 1 }
211
+ }
212
+ },
213
+ "responseContract": {
214
+ "type": "object",
215
+ "required": ["envelope", "listSchema", "detailSchema", "mutationSchema"],
216
+ "additionalProperties": false,
217
+ "properties": {
218
+ "envelope": { "type": "string", "enum": ["standard", "raw"] },
219
+ "listSchema": { "type": "string", "enum": ["pagedList", "list"] },
220
+ "detailSchema": { "type": "string", "enum": ["object", "detail"] },
221
+ "mutationSchema": { "type": "string", "enum": ["object", "mutationResult", "void"] }
222
+ }
223
+ },
224
+ "permissionProfile": {
225
+ "type": "object",
226
+ "required": ["mode", "resourceScope", "actionPolicies"],
227
+ "additionalProperties": false,
228
+ "properties": {
229
+ "mode": { "type": "string", "enum": ["inherit", "custom"] },
230
+ "resourceScope": { "type": "string", "minLength": 1 },
231
+ "actionPolicies": {
232
+ "type": "array",
233
+ "items": {
234
+ "type": "object",
235
+ "required": ["action", "permission"],
236
+ "additionalProperties": false,
237
+ "properties": {
238
+ "action": { "type": "string", "minLength": 1 },
239
+ "permission": { "type": "string", "minLength": 1 },
240
+ "condition": { "type": "string" }
241
+ }
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "validationRule": {
247
+ "type": "object",
248
+ "required": ["name", "scope", "rule", "message"],
249
+ "additionalProperties": false,
250
+ "properties": {
251
+ "name": { "type": "string", "minLength": 1 },
252
+ "scope": { "type": "string", "enum": ["form", "service", "workflow"] },
253
+ "rule": { "type": "string", "minLength": 1 },
254
+ "fields": {
255
+ "type": "array",
256
+ "items": { "type": "string", "minLength": 1 }
257
+ },
258
+ "message": { "type": "string", "minLength": 1 }
259
+ }
260
+ }
261
+ }
262
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "reservedTables": [
3
+ "sys_user",
4
+ "sys_role",
5
+ "sys_menu",
6
+ "sys_user_role",
7
+ "sys_role_menu"
8
+ ],
9
+ "reservedTablePrefixes": [
10
+ "sys_"
11
+ ],
12
+ "protectedDomains": [
13
+ "system",
14
+ "auth"
15
+ ],
16
+ "protectedMetaObjects": [
17
+ "user",
18
+ "role",
19
+ "menu"
20
+ ],
21
+ "systemFields": [
22
+ "id",
23
+ "createdAt",
24
+ "updatedAt"
25
+ ]
26
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://aiko-boot.local/scaffold/requirement-draft.schema.json",
4
+ "title": "RequirementDraft",
5
+ "type": "object",
6
+ "required": ["contractVersion", "kind", "id", "status", "rawRequirement", "analysis", "draftModel", "history"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "contractVersion": { "type": "string", "minLength": 1 },
10
+ "kind": { "type": "string", "const": "requirementDraft" },
11
+ "id": { "type": "string", "minLength": 1 },
12
+ "status": {
13
+ "type": "string",
14
+ "enum": ["analyzed", "clarifying", "validated", "generated", "failed"]
15
+ },
16
+ "rawRequirement": { "type": "string", "minLength": 1 },
17
+ "analysis": {
18
+ "type": "object",
19
+ "required": ["decision", "nextAction", "status"],
20
+ "additionalProperties": true,
21
+ "properties": {
22
+ "decision": { "type": "string", "minLength": 1 },
23
+ "nextAction": { "type": "string", "minLength": 1 },
24
+ "status": { "type": "string", "minLength": 1 }
25
+ }
26
+ },
27
+ "draftModel": {
28
+ "oneOf": [
29
+ { "type": "object" },
30
+ { "type": "null" }
31
+ ]
32
+ },
33
+ "validation": {
34
+ "oneOf": [
35
+ { "type": "object" },
36
+ { "type": "null" }
37
+ ]
38
+ },
39
+ "generation": {
40
+ "oneOf": [
41
+ { "type": "object" },
42
+ { "type": "null" }
43
+ ]
44
+ },
45
+ "storage": {
46
+ "oneOf": [
47
+ {
48
+ "type": "object",
49
+ "required": ["draftRoot", "fileName", "absolutePath", "savedAt"],
50
+ "additionalProperties": false,
51
+ "properties": {
52
+ "draftRoot": { "type": "string", "minLength": 1 },
53
+ "fileName": { "type": "string", "minLength": 1 },
54
+ "absolutePath": { "type": "string", "minLength": 1 },
55
+ "savedAt": { "type": "string", "minLength": 1 }
56
+ }
57
+ },
58
+ { "type": "null" }
59
+ ]
60
+ },
61
+ "history": {
62
+ "type": "array",
63
+ "items": {
64
+ "type": "object",
65
+ "required": ["event", "timestamp"],
66
+ "additionalProperties": false,
67
+ "properties": {
68
+ "event": { "type": "string", "minLength": 1 },
69
+ "timestamp": { "type": "string", "minLength": 1 },
70
+ "summary": { "type": "string" }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "scopes": {
3
+ "template": {
4
+ "roots": ["specs/templates/"],
5
+ "allowCustomDomain": false,
6
+ "requireDescription": true,
7
+ "forbidSampleObjectSuffix": true
8
+ },
9
+ "project": {
10
+ "roots": ["specs/projects/"],
11
+ "allowCustomDomain": true,
12
+ "requireDescription": false,
13
+ "forbidSampleObjectSuffix": false
14
+ },
15
+ "generatedProject": {
16
+ "roots": ["specs/projects/generated-from-nl/"],
17
+ "allowCustomDomain": true,
18
+ "requireDescription": false,
19
+ "forbidSampleObjectSuffix": false
20
+ },
21
+ "patternExample": {
22
+ "roots": ["specs/projects/pattern-examples/"],
23
+ "allowCustomDomain": true,
24
+ "requireDescription": true,
25
+ "forbidSampleObjectSuffix": false,
26
+ "requirePattern": true
27
+ }
28
+ }
29
+ }