midway-fatcms 0.0.5 โ†’ 0.0.6

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 (126) hide show
  1. package/README.md +377 -134
  2. package/dist/controller/manage/CrudStandardDesignApi.d.ts +0 -2
  3. package/dist/controller/manage/CrudStandardDesignApi.js +11 -85
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.js +2 -0
  6. package/dist/libs/crud-pro/CrudPro.d.ts +9 -1
  7. package/dist/libs/crud-pro/CrudPro.js +15 -0
  8. package/dist/libs/crud-pro/README.md +809 -0
  9. package/dist/libs/crud-pro/README_FUNC.md +193 -0
  10. package/dist/libs/crud-pro/exceptions.d.ts +2 -0
  11. package/dist/libs/crud-pro/exceptions.js +2 -0
  12. package/dist/libs/crud-pro/interfaces.d.ts +34 -1
  13. package/dist/libs/crud-pro/models/ExecuteContext.d.ts +3 -3
  14. package/dist/libs/crud-pro/models/ExecuteContext.js +2 -0
  15. package/dist/libs/crud-pro/models/RequestModel.d.ts +41 -1
  16. package/dist/libs/crud-pro/models/RequestModel.js +103 -39
  17. package/dist/libs/crud-pro/models/ResModel.d.ts +6 -4
  18. package/dist/libs/crud-pro/models/ServiceHub.d.ts +1 -0
  19. package/dist/libs/crud-pro/models/keys.d.ts +6 -1
  20. package/dist/libs/crud-pro/models/keys.js +5 -0
  21. package/dist/libs/crud-pro/services/CrudProDataTypeConvertService.d.ts +52 -0
  22. package/dist/libs/crud-pro/services/CrudProDataTypeConvertService.js +158 -0
  23. package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +20 -1
  24. package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +7 -0
  25. package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +32 -0
  26. package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +13 -0
  27. package/dist/libs/crud-pro/services/CrudProGenSqlService.js +44 -7
  28. package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +43 -0
  29. package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +132 -1
  30. package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +15 -1
  31. package/dist/libs/crud-pro/services/CrudProTableMetaService.js +107 -0
  32. package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +5 -1
  33. package/dist/libs/crud-pro/services/CurdProServiceHub.js +11 -0
  34. package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +1 -0
  35. package/dist/libs/crud-pro/utils/DateTimeUtils.js +3 -0
  36. package/dist/libs/crud-pro/utils/MixinUtils.d.ts +32 -0
  37. package/dist/libs/crud-pro/utils/MixinUtils.js +85 -1
  38. package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
  39. package/dist/libs/crud-sharding/ROUTING_LOGIC.md +944 -0
  40. package/dist/libs/crud-sharding/ShardingConfig.d.ts +218 -0
  41. package/dist/libs/crud-sharding/ShardingConfig.js +32 -0
  42. package/dist/libs/crud-sharding/ShardingCountCache.d.ts +69 -0
  43. package/dist/libs/crud-sharding/ShardingCountCache.js +160 -0
  44. package/dist/libs/crud-sharding/ShardingCrudPro.d.ts +363 -0
  45. package/dist/libs/crud-sharding/ShardingCrudPro.js +699 -0
  46. package/dist/libs/crud-sharding/ShardingMerger.d.ts +130 -0
  47. package/dist/libs/crud-sharding/ShardingMerger.js +280 -0
  48. package/dist/libs/crud-sharding/ShardingRouter.d.ts +69 -0
  49. package/dist/libs/crud-sharding/ShardingRouter.js +377 -0
  50. package/dist/libs/crud-sharding/ShardingTableCreator.d.ts +146 -0
  51. package/dist/libs/crud-sharding/ShardingTableCreator.js +805 -0
  52. package/dist/libs/crud-sharding/ShardingUtils.d.ts +38 -0
  53. package/dist/libs/crud-sharding/ShardingUtils.js +77 -0
  54. package/dist/libs/crud-sharding/index.d.ts +45 -0
  55. package/dist/libs/crud-sharding/index.js +55 -0
  56. package/dist/models/StandardColumns.d.ts +71 -0
  57. package/dist/models/StandardColumns.js +28 -0
  58. package/dist/service/SysAppService.js +2 -2
  59. package/dist/service/SysConfigService.js +1 -1
  60. package/dist/service/SysDictDataService.js +2 -2
  61. package/dist/service/SysMenuService.js +1 -1
  62. package/dist/service/UserAccountService.d.ts +1 -1
  63. package/dist/service/crudstd/CrudStdService.d.ts +0 -1
  64. package/dist/service/crudstd/CrudStdService.js +0 -27
  65. package/dist/service/curd/CrudProQuick.d.ts +134 -4
  66. package/dist/service/curd/CrudProQuick.js +155 -3
  67. package/dist/service/curd/CurdMixService.d.ts +2 -1
  68. package/dist/service/curd/CurdMixService.js +5 -1
  69. package/dist/service/curd/CurdProService.d.ts +44 -2
  70. package/dist/service/curd/CurdProService.js +53 -1
  71. package/dist/service/curd/README.md +1001 -0
  72. package/dist/service/curd/fixSoftDelete.d.ts +14 -0
  73. package/dist/service/curd/fixSoftDelete.js +29 -11
  74. package/dist/service/flow/FlowConfigService.js +1 -1
  75. package/dist/service/flow/FlowInstanceCrudService.js +1 -1
  76. package/package.json +3 -1
  77. package/src/controller/gateway/AsyncTaskController.ts +1 -1
  78. package/src/controller/manage/CrudStandardDesignApi.ts +16 -100
  79. package/src/index.ts +3 -0
  80. package/src/libs/crud-pro/CrudPro.ts +19 -1
  81. package/src/libs/crud-pro/README.md +809 -0
  82. package/src/libs/crud-pro/README_FUNC.md +193 -0
  83. package/src/libs/crud-pro/exceptions.ts +2 -0
  84. package/src/libs/crud-pro/interfaces.ts +38 -1
  85. package/src/libs/crud-pro/models/ExecuteContext.ts +6 -3
  86. package/src/libs/crud-pro/models/RequestModel.ts +108 -44
  87. package/src/libs/crud-pro/models/ResModel.ts +10 -4
  88. package/src/libs/crud-pro/models/ServiceHub.ts +2 -0
  89. package/src/libs/crud-pro/models/keys.ts +5 -0
  90. package/src/libs/crud-pro/services/CrudProDataTypeConvertService.ts +171 -0
  91. package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +24 -1
  92. package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +53 -1
  93. package/src/libs/crud-pro/services/CrudProGenSqlService.ts +51 -7
  94. package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +159 -2
  95. package/src/libs/crud-pro/services/CrudProTableMetaService.ts +139 -1
  96. package/src/libs/crud-pro/services/CurdProServiceHub.ts +16 -1
  97. package/src/libs/crud-pro/utils/DateTimeUtils.ts +3 -0
  98. package/src/libs/crud-pro/utils/MixinUtils.ts +97 -1
  99. package/src/libs/crud-pro/utils/ValidateUtils.ts +1 -1
  100. package/src/libs/crud-sharding/ROUTING_LOGIC.md +944 -0
  101. package/src/libs/crud-sharding/ShardingConfig.ts +240 -0
  102. package/src/libs/crud-sharding/ShardingCountCache.ts +200 -0
  103. package/src/libs/crud-sharding/ShardingCrudPro.ts +856 -0
  104. package/src/libs/crud-sharding/ShardingMerger.ts +382 -0
  105. package/src/libs/crud-sharding/ShardingRouter.ts +512 -0
  106. package/src/libs/crud-sharding/ShardingTableCreator.ts +1007 -0
  107. package/src/libs/crud-sharding/ShardingUtils.ts +84 -0
  108. package/src/libs/crud-sharding/index.ts +64 -0
  109. package/src/models/StandardColumns.ts +76 -0
  110. package/src/service/FileCenterService.ts +1 -1
  111. package/src/service/SysAppService.ts +2 -2
  112. package/src/service/SysConfigService.ts +1 -1
  113. package/src/service/SysDictDataService.ts +2 -2
  114. package/src/service/SysMenuService.ts +2 -2
  115. package/src/service/WorkbenchService.ts +1 -1
  116. package/src/service/anyapi/AnyApiService.ts +1 -1
  117. package/src/service/asyncTask/AsyncTaskRunnerService.ts +1 -1
  118. package/src/service/crudstd/CrudStdService.ts +0 -32
  119. package/src/service/curd/CrudProQuick.ts +164 -5
  120. package/src/service/curd/CurdMixService.ts +7 -2
  121. package/src/service/curd/CurdProService.ts +62 -3
  122. package/src/service/curd/README.md +1001 -0
  123. package/src/service/curd/fixCfgModel.ts +1 -2
  124. package/src/service/curd/fixSoftDelete.ts +38 -16
  125. package/src/service/flow/FlowConfigService.ts +1 -1
  126. package/src/service/flow/FlowInstanceCrudService.ts +1 -1
package/README.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # Midway FatCMS
2
2
 
3
3
  <p align="center">
4
- <strong>๐Ÿš€ Enterprise-Grade Low-Code / Zero-Code Development Platform</strong>
4
+ <strong>Enterprise-Grade Low-Code / Zero-Code Development Platform</strong>
5
5
  </p>
6
6
 
7
7
  <p align="center">
8
8
  Build production-ready enterprise applications in minutes, not months.
9
9
  </p>
10
10
 
11
+ <p align="center">
12
+ <a href="#-quick-start">Quick Start</a> ยท <a href="#-core-engines">Core Engines</a> ยท <a href="#-architecture">Architecture</a> ยท <a href="#-api-reference">API Reference</a>
13
+ </p>
14
+
11
15
  ---
12
16
 
13
- ## โœจ Why Midway FatCMS?
17
+ ## Why Midway FatCMS?
14
18
 
15
19
  Stop writing repetitive CRUD boilerplate. Stop struggling with API versioning. Stop worrying about multi-tenant data isolation.
16
20
 
@@ -23,35 +27,139 @@ Stop writing repetitive CRUD boilerplate. Stop struggling with API versioning. S
23
27
  | 2 weeks to build a CRUD module | 15 minutes of configuration |
24
28
  | Manual API documentation | Auto-generated, always in sync |
25
29
  | Complex multi-tenant logic | Built-in tenant isolation |
30
+ | Hand-coded sharding & pagination | Cross-shard queries out of the box |
26
31
  | Reinventing the wheel | Production-ready building blocks |
27
32
 
28
33
  ---
29
34
 
30
- ## ๐ŸŽฏ What You Get
35
+ ## Core Engines
31
36
 
32
- ### ๐Ÿ—๏ธ CRUD-Pro Engine โ€” Zero-Code Data Operations
37
+ ### CRUD-Pro Engine โ€” Zero-Code Data Operations
33
38
 
34
- Transform database tables into fully functional REST APIs with zero code.
39
+ Transform database tables into fully functional REST APIs with zero code. CRUD-Pro is the heart of Midway FatCMS, providing configuration-driven SQL execution with built-in validation, security, and multi-database support.
35
40
 
36
41
  **Features:**
37
- - โšก **Instant CRUD** โ€” Auto-generated Create, Read, Update, Delete endpoints
38
- - ๐Ÿ” **Advanced Querying** โ€” Pagination, sorting, filtering, and joins out of the box
39
- - ๐Ÿ” **Field-Level Security** โ€” Granular control over visibility, read-only, and mandatory fields
40
- - โœ… **Built-in Validation** โ€” 20+ validators (email, phone, date, regex, etc.)
41
- - ๐Ÿ”— **Smart Relations** โ€” Automatic handling of one-to-one, one-to-many, many-to-many
42
- - ๐Ÿ—‘๏ธ **Soft Delete** โ€” Logical deletion with recovery support
43
- - ๐Ÿ“Š **Audit Trail** โ€” Automatic tracking of creators, modifiers, and timestamps
44
- - ๐ŸŒ **Multi-Database** โ€” MySQL, PostgreSQL, SQL Server support
45
-
46
- **Perfect for:**
47
- - Admin dashboards and back-office systems
48
- - Data management platforms
49
- - Reporting and analytics systems
50
- - Business configuration centers
42
+
43
+ - **Instant CRUD** โ€” Auto-generated Create, Read, Update, Delete endpoints via `sqlSimpleName`
44
+ - **Advanced Querying** โ€” Pagination, sorting, filtering, joins, and MongoDB-style query operators
45
+ - **Field-Level Security** โ€” Granular control over visibility (`allowCfg`), read-only, and rejected fields (`rejectCfg`)
46
+ - **Built-in Validation** โ€” 20+ validators (email, phone, date, regex, length, range, enum, etc.)
47
+ - **Smart Relations** โ€” Automatic data enrichment via `columnsRelation` (dict, sysConfig, account, workbench, custom)
48
+ - **Soft Delete** โ€” Logical deletion with recovery support (`enableSoftDelete`)
49
+ - **Audit Trail** โ€” Automatic tracking of creators, modifiers, and timestamps (`enableStandardUpdateCfg`)
50
+ - **Data Type Conversion** โ€” Auto-convert JS arrays to PostgreSQL array literals, JSON strings parsed automatically
51
+ - **Multi-Database** โ€” MySQL, PostgreSQL, SQL Server support with dialect-aware SQL generation
52
+ - **Custom SQL** โ€” Template-based SQL with `@@placeholder` syntax for complex queries
53
+ - **Transaction Support** โ€” Built-in transaction management with configurable isolation levels
54
+ - **Configuration Cache** โ€” Database-stored configurations with TTL-based caching
55
+
56
+ **10-Step Execution Pipeline:**
57
+
58
+ ```
59
+ 1. Receive Request (RequestModel)
60
+ โ†“
61
+ 2. Load Configuration (RequestCfgModel)
62
+ โ†“
63
+ 3. Field Filtering (filterDataByTableMeta) โ€” Remove non-existent columns based on table schema
64
+ โ†“
65
+ 4. Data Type Conversion (convertDataTypeByTableMeta) โ€” Auto-convert based on column types (e.g. PG ARRAY)
66
+ โ†“
67
+ 5. Data Validation (validateByAllow/rejectCfg/validateCfg)
68
+ โ†“
69
+ 6. Permission Check (validateByAuthCfg)
70
+ โ†“
71
+ 7. Default Value Setting (updateByCfg)
72
+ โ†“
73
+ 8. Generate SQL (generateSQLList)
74
+ โ†“
75
+ 9. Execute SQL (executeSQLList)
76
+ โ†“
77
+ 10. Return Result (ExecuteContext)
78
+ ```
79
+
80
+ **Quick Example:**
81
+
82
+ ```typescript
83
+ const cfgJson: IRequestCfgModel = {
84
+ method: 'article.list',
85
+ sqlTable: 'article',
86
+ sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_PAGE,
87
+ };
88
+
89
+ const reqJson: IRequestModel = {
90
+ columns: 'id,title,content,author_id,created_at',
91
+ condition: {
92
+ status: 1,
93
+ category_id: { $in: [1, 2, 3] },
94
+ created_at: { $gte: '2024-01-01' },
95
+ },
96
+ pageNo: 1,
97
+ pageSize: 20,
98
+ orderBy: 'created_at-',
99
+ };
100
+
101
+ const ctx = await crudPro.executeCrudByCfg(reqJson, cfgJson);
102
+ const { rows, total_count } = ctx.getResModelForQueryPage();
103
+ ```
104
+
105
+ > Full CRUD-Pro documentation: [src/libs/crud-pro/README.md](src/libs/crud-pro/README.md) ยท Built-in Functions: [src/libs/crud-pro/README_FUNC.md](src/libs/crud-pro/README_FUNC.md)
106
+
107
+ ---
108
+
109
+ ### Sharding Engine โ€” Scalable Table Partitioning
110
+
111
+ Built on top of CRUD-Pro, the Sharding Engine provides transparent table partitioning with automatic routing, cross-shard pagination, and smart result merging โ€” zero code changes required.
112
+
113
+ **Sharding Strategies:**
114
+
115
+ | Strategy | Enum | Suffix Example | Best For |
116
+ |----------|------|----------------|----------|
117
+ | By Year | `ShardingType.YEAR` | `_2024`, `_2025` | Annual reports, yearly archives |
118
+ | By Month | `ShardingType.MONTH` | `_202401`, `_202402` | Order systems, log tables |
119
+ | By Day | `ShardingType.DAY` | `_20240101` | High-volume daily logs |
120
+ | By Range | `ShardingType.RANGE` | `_0` ~ `_99` | Numeric ID-based partitioning |
121
+ | By Hash | `ShardingType.HASH` | `_01` ~ `_16` | Even distribution, user-based |
122
+ | Custom | `ShardingType.CUSTOM` | User-defined | Tenant-based, business-specific |
123
+
124
+ **Key Features:**
125
+
126
+ - **Automatic Routing** โ€” Insert/update/delete routed to the correct shard based on data fields
127
+ - **Cross-Shard Pagination** โ€” Transparent `queryPage()` across multiple shards with direct-offset optimization
128
+ - **Smart Batch Insert** โ€” `batchInsert()` auto-groups data by shard, parallel writes across tables
129
+ - **COUNT Query Cache** โ€” LRU + TTL cache for historical shard COUNT queries, real-time for current period
130
+ - **Table Existence Filtering** โ€” Non-existent shards silently skipped in queries, error on insert
131
+ - **Multi-Sort Support** โ€” Primary time-based sort + secondary field sorts within each shard
132
+
133
+ **Quick Example:**
134
+
135
+ ```typescript
136
+ const sharding = curdProService.getShardingCrud('mydb', SqlDbType.mysql, {
137
+ type: ShardingType.MONTH,
138
+ baseTable: 't_order',
139
+ timeColumn: 'created_at',
140
+ autoCreateTable: true,
141
+ countCache: { ttlSeconds: 300, maxSize: 1000 },
142
+ });
143
+
144
+ // Insert โ€” auto-routes to t_order_202403
145
+ await sharding.insert({
146
+ data: { order_id: '001', amount: 100, created_at: '2024-03-15' }
147
+ });
148
+
149
+ // Cross-shard pagination โ€” automatic merging
150
+ const page = await sharding.queryPage({
151
+ condition: { status: 'paid' },
152
+ pageNo: 1,
153
+ pageSize: 10,
154
+ orderBy: 'created_at DESC',
155
+ });
156
+ ```
157
+
158
+ > Full Sharding documentation: [src/libs/crud-sharding/ROUTING_LOGIC.md](src/libs/crud-sharding/ROUTING_LOGIC.md)
51
159
 
52
160
  ---
53
161
 
54
- ### ๐ŸŒŸ Any API โ€” Three Ways to Build APIs
162
+ ### Any API โ€” Three Ways to Build APIs
55
163
 
56
164
  Whether you need a simple query or complex business logic, we've got you covered.
57
165
 
@@ -79,15 +187,9 @@ Full control when you need it.
79
187
  - Circuit breaker & timeout protection
80
188
  - IP whitelist/blacklist
81
189
 
82
- **Perfect for:**
83
- - Rapid API prototyping
84
- - Data aggregation services
85
- - Third-party integrations
86
- - Microservice orchestration
87
-
88
190
  ---
89
191
 
90
- ### ๐Ÿšช API Gateway & Proxy โ€” Enterprise-Grade Traffic Management
192
+ ### API Gateway & Proxy โ€” Enterprise-Grade Traffic Management
91
193
 
92
194
  A full-featured API gateway that handles the complexity so you don't have to.
93
195
 
@@ -111,15 +213,9 @@ A full-featured API gateway that handles the complexity so you don't have to.
111
213
  - Customizable headers (Host, Origin)
112
214
  - Request/response header manipulation
113
215
 
114
- **Perfect for:**
115
- - Microservices gateway
116
- - Canary deployments
117
- - A/B testing
118
- - Traffic splitting & aggregation
119
-
120
216
  ---
121
217
 
122
- ### ๐Ÿข Multi-Tenant Architecture โ€” True SaaS-Ready
218
+ ### Multi-Tenant Architecture โ€” True SaaS-Ready
123
219
 
124
220
  Deploy once, serve unlimited customers. Complete tenant isolation without the complexity.
125
221
 
@@ -135,15 +231,9 @@ Deploy once, serve unlimited customers. Complete tenant isolation without the co
135
231
  - Tenant templates for rapid onboarding
136
232
  - Customizable tenant branding
137
233
 
138
- **Perfect for:**
139
- - SaaS platforms
140
- - Multi-brand operations
141
- - Enterprise groups
142
- - White-label products
143
-
144
234
  ---
145
235
 
146
- ### ๐Ÿ”„ Workflow Engine โ€” Automate Business Processes
236
+ ### Workflow Engine โ€” Automate Business Processes
147
237
 
148
238
  Streamline approvals and business flows with a flexible workflow engine.
149
239
 
@@ -153,14 +243,9 @@ Streamline approvals and business flows with a flexible workflow engine.
153
243
  - Real-time status monitoring
154
244
  - Historical flow records
155
245
 
156
- **Perfect for:**
157
- - Approval workflows (expenses, leaves, purchases)
158
- - Business process automation
159
- - State machine management
160
-
161
246
  ---
162
247
 
163
- ### ๐Ÿ“š Document Management System โ€” Enterprise Knowledge Base
248
+ ### Document Management System โ€” Enterprise Knowledge Base
164
249
 
165
250
  A complete document management solution with version control and analytics.
166
251
 
@@ -170,15 +255,9 @@ A complete document management solution with version control and analytics.
170
255
  - **Analytics** โ€” PV/UV tracking with IP deduplication
171
256
  - **Access Control** โ€” Document-level permissions
172
257
 
173
- **Perfect for:**
174
- - API documentation
175
- - Product documentation
176
- - Internal knowledge bases
177
- - Help centers
178
-
179
258
  ---
180
259
 
181
- ### ๐Ÿ“ File Service โ€” Complete File Management
260
+ ### File Service โ€” Complete File Management
182
261
 
183
262
  Enterprise file handling with cloud storage integration.
184
263
 
@@ -190,7 +269,7 @@ Enterprise file handling with cloud storage integration.
190
269
 
191
270
  ---
192
271
 
193
- ### โš™๏ธ System Management โ€” Everything You Need
272
+ ### System Management โ€” Everything You Need
194
273
 
195
274
  **User & Permissions:**
196
275
  - User account management
@@ -218,7 +297,7 @@ Enterprise file handling with cloud storage integration.
218
297
 
219
298
  ---
220
299
 
221
- ## ๐Ÿ›ก๏ธ Security First
300
+ ## Security First
222
301
 
223
302
  We take security seriously. Built-in protection at every layer:
224
303
 
@@ -226,10 +305,10 @@ We take security seriously. Built-in protection at every layer:
226
305
  - JWT Token authentication
227
306
  - Session management with Redis
228
307
  - Super admin mechanism
229
- - Granular permission control
308
+ - Granular permission control (`authType: free | login | byRoleCode | byFuncCode`)
230
309
 
231
310
  ### Attack Prevention
232
- - SQL injection protection
311
+ - SQL injection protection (parameterized queries)
233
312
  - XSS protection
234
313
  - CSRF token validation
235
314
  - Path traversal prevention
@@ -244,7 +323,224 @@ We take security seriously. Built-in protection at every layer:
244
323
 
245
324
  ---
246
325
 
247
- ## ๐Ÿš€ Quick Start
326
+ ## Architecture
327
+
328
+ ### Technology Stack
329
+
330
+ | Layer | Technology |
331
+ |-------|-----------|
332
+ | **Framework** | Midway.js 3.x (Enterprise Node.js) |
333
+ | **Web Server** | Koa |
334
+ | **Language** | TypeScript |
335
+ | **Database** | MySQL / PostgreSQL / SQL Server |
336
+ | **Cache** | Redis |
337
+ | **File Storage** | Alibaba Cloud OSS / S3-compatible |
338
+
339
+ ### Core Middleware
340
+
341
+ **Global Middleware:**
342
+ - User session management
343
+ - Multi-tenant isolation
344
+ - Transaction management
345
+ - Request-level logging
346
+ - Unified response formatting
347
+ - Real IP extraction
348
+
349
+ **Security Middleware:**
350
+ - Login verification (`checkLogin`)
351
+ - Role verification (`checkRole`)
352
+ - Permission verification (`checkPermission`)
353
+ - Path blacklist (`Forbidden`)
354
+ - Distributed locking (`RedisLock`)
355
+ - Response caching (`RedisCache`)
356
+
357
+ ### Project Structure
358
+
359
+ ```
360
+ midway-fatcms/
361
+ โ”œโ”€โ”€ src/
362
+ โ”‚ โ”œโ”€โ”€ config/ # Configuration files
363
+ โ”‚ โ”œโ”€โ”€ controller/ # Controllers
364
+ โ”‚ โ”‚ โ”œโ”€โ”€ base/ # Base controllers
365
+ โ”‚ โ”‚ โ”œโ”€โ”€ gateway/ # Gateway APIs (CRUD, AnyAPI, Proxy, etc.)
366
+ โ”‚ โ”‚ โ”œโ”€โ”€ manage/ # Management APIs
367
+ โ”‚ โ”‚ โ”œโ”€โ”€ myinfo/ # Personal info & Auth APIs
368
+ โ”‚ โ”‚ โ””โ”€โ”€ render/ # Rendering APIs
369
+ โ”‚ โ”œโ”€โ”€ filter/ # Exception filters
370
+ โ”‚ โ”œโ”€โ”€ libs/ # Core libraries
371
+ โ”‚ โ”‚ โ”œโ”€โ”€ crud-pro/ # CRUD-Pro engine (SQL generation, validation, execution)
372
+ โ”‚ โ”‚ โ”œโ”€โ”€ crud-sharding/ # Sharding engine (routing, merging, caching)
373
+ โ”‚ โ”‚ โ”œโ”€โ”€ global-config/ # Global configuration
374
+ โ”‚ โ”‚ โ””โ”€โ”€ utils/ # Shared utilities
375
+ โ”‚ โ”œโ”€โ”€ middleware/ # Middleware (auth, permission, tx, cache, lock)
376
+ โ”‚ โ”œโ”€โ”€ models/ # Data models & type definitions
377
+ โ”‚ โ”œโ”€โ”€ schedule/ # Scheduled tasks
378
+ โ”‚ โ”œโ”€โ”€ service/ # Business services
379
+ โ”‚ โ”‚ โ”œโ”€โ”€ anyapi/ # Dynamic API (SQL, Sandbox, Custom Code)
380
+ โ”‚ โ”‚ โ”œโ”€โ”€ asyncTask/ # Async task runner
381
+ โ”‚ โ”‚ โ”œโ”€โ”€ base/ # Base services (cache, rate limiter)
382
+ โ”‚ โ”‚ โ”œโ”€โ”€ crudstd/ # Standard CRUD (gateway-level)
383
+ โ”‚ โ”‚ โ”œโ”€โ”€ curd/ # CRUD service layer (context injection, soft delete, relations)
384
+ โ”‚ โ”‚ โ”œโ”€โ”€ flow/ # Workflow engine
385
+ โ”‚ โ”‚ โ””โ”€โ”€ proxyapi/ # Proxy API gateway
386
+ โ”‚ โ””โ”€โ”€ views/ # View templates
387
+ โ”œโ”€โ”€ ddl/ # Database initialization scripts
388
+ โ”œโ”€โ”€ scripts/ # Utility scripts
389
+ โ””โ”€โ”€ package.json # Project configuration
390
+ ```
391
+
392
+ ### Service Layer Architecture
393
+
394
+ ```
395
+ Business Code
396
+ โ”‚
397
+ โ”œโ”€โ”€ CurdMixService (orchestrator: CRUD + relation enrichment)
398
+ โ”‚ โ”œโ”€โ”€ CurdMixByDictService โ†’ relatedType: 'dict'
399
+ โ”‚ โ”œโ”€โ”€ CurdMixBySysConfigService โ†’ relatedType: 'sysCfgEnum'
400
+ โ”‚ โ”œโ”€โ”€ CurdMixByAccountService โ†’ relatedType: 'accountBasic'
401
+ โ”‚ โ”œโ”€โ”€ CurdMixByWorkbenchService โ†’ relatedType: 'workbenchBasic'
402
+ โ”‚ โ””โ”€โ”€ CurdMixByLinkToCustomService โ†’ relatedType: 'linkToCustom'
403
+ โ”‚
404
+ โ””โ”€โ”€ CurdProService (core service layer)
405
+ โ”œโ”€โ”€ CrudProQuick โ†’ Quick CRUD (fluent API)
406
+ โ”œโ”€โ”€ ShardingCrudPro โ†’ Sharded CRUD
407
+ โ”œโ”€โ”€ fixCfgModel() โ†’ Standard field auto-fill
408
+ โ””โ”€โ”€ fixSoftDelete() โ†’ Soft delete handling
409
+ ```
410
+
411
+ > Full service layer documentation: [src/service/curd/README.md](src/service/curd/README.md)
412
+
413
+ ---
414
+
415
+ ## API Reference
416
+
417
+ ### CrudProQuick โ€” Fluent CRUD API
418
+
419
+ The quickest way to perform database operations. All methods automatically inherit context (visitor, transaction, soft delete, standard fields).
420
+
421
+ ```typescript
422
+ const quick = curdProService.getQuickCrud('mydb', SqlDbType.mysql, 't_user');
423
+
424
+ // Query methods
425
+ const users = await quick.getList({ condition: { status: 'active' } });
426
+ const page = await quick.getListPage({ condition: { status: 'active' }, pageNo: 1, pageSize: 20 });
427
+ const user = await quick.getUniqueOne({ condition: { email: 'user@example.com' } });
428
+ const exists = await quick.isExist({ condition: { phone: '13800138000' } });
429
+ const count = await quick.getTotalCount({ condition: { status: 'active' } });
430
+
431
+ // Write methods
432
+ const result = await quick.insertObject({ data: { name: 'Alice', email: 'a@b.com' } });
433
+ const batch = await quick.batchInsert({ data: [{ name: 'A' }, { name: 'B' }] });
434
+ const updated = await quick.updateObject({ condition: { id: 1 }, data: { name: 'Bob' } });
435
+ const deleted = await quick.deleteObject({ condition: { id: 1 } });
436
+ const upserted = await quick.insertOnDuplicate({ data: { id: 1, name: 'A' } }, ['id']);
437
+
438
+ // Raw SQL
439
+ const rows = await quick.executeSQL('SELECT * FROM t_user WHERE status = ?', ['active']);
440
+ ```
441
+
442
+ ### Query Condition Operators
443
+
444
+ MongoDB-style operators for powerful queries:
445
+
446
+ ```typescript
447
+ const condition = {
448
+ status: 1, // Equal
449
+ age: { $gt: 18, $lt: 60 }, // Greater than / Less than
450
+ id: { $in: [1, 2, 3] }, // IN
451
+ code: { $nin: ['a', 'b'] }, // NOT IN
452
+ amount: { $between: [100, 500] }, // BETWEEN
453
+ name: { $like: 'ๅผ ' }, // Prefix match
454
+ title: { $likeInclude: 'ๆ–‡็ซ ' }, // Contains match
455
+ deleted_at: { $isNull: true }, // IS NULL
456
+ updated_at: { $isNotNull: true }, // IS NOT NULL
457
+ $or: [{ name: { $like: 'ๅผ ' } }, { name: { $like: 'ๆŽ' } }], // OR
458
+ };
459
+ ```
460
+
461
+ ### Sorting Syntax
462
+
463
+ ```typescript
464
+ // Standard SQL format
465
+ orderBy: 'created_at DESC, amount ASC'
466
+
467
+ // Shorthand format (+ ascending, - descending)
468
+ orderBy: 'created_at-, amount+'
469
+
470
+ // Array format (mixed strings & objects)
471
+ orderBy: ['order_id', { fieldName: 'created_at', orderType: 'desc' }, 'amount+']
472
+ ```
473
+
474
+ ### ShardingCrudPro API
475
+
476
+ | Method | Returns | Description |
477
+ |--------|---------|-------------|
478
+ | `insert(reqJson)` | `ExecuteContext` | Insert single record (auto-route) |
479
+ | `batchInsert(reqJson)` | `IShardingSmartBatchInsertResult` | Batch insert (cross-shard, parallel) |
480
+ | `update(reqJson)` | `ExecuteContext` | Update data |
481
+ | `delete(reqJson)` | `ExecuteContext` | Delete data |
482
+ | `insertOrUpdate(reqJson)` | `ExecuteContext` | Insert or update |
483
+ | `insertOnDuplicateUpdate(reqJson)` | `ExecuteContext` | Native upsert |
484
+ | `queryOne(reqJson)` | `any \| null` | Query single record |
485
+ | `query(reqJson)` | `any[]` | List query (auto-merge shards) |
486
+ | `queryPage(reqJson)` | `IShardingPageQueryResult` | Cross-shard pagination |
487
+ | `queryCount(reqJson)` | `number` | Count across shards |
488
+ | `isExist(reqJson)` | `boolean` | Existence check across shards |
489
+
490
+ ### Built-in Functions
491
+
492
+ CrudPro provides 30+ built-in functions for `updateCfg`, `validateCfg`, `executeWhen`, and `validate`:
493
+
494
+ **DateTime:** `getCurrentTimeStampMs`, `getCurrentTimeStampSecond`, `getCurrentTimeString`, `getCurrentDateFormat`, `getYesterdayDateFormat`
495
+
496
+ **Compare:** `eq`, `ne`, `gt`, `gte`, `lt`, `lte`
497
+
498
+ **Utility:** `isNil`, `isNotNil`, `isEmpty`, `isNotEmpty`, `equals`, `equalsIgnoreCase`, `startsWith`, `isValidFieldName`, `selectNotEmpty`, `hasAny`, `parseValueByType`, `sleepMs`, `uuid`, `generateSnowflakeId`
499
+
500
+ **Type Check:** `isBasicType`, `isBoolean`, `isString`, `isInteger`, `isNumber`, `isNumeric`, `isValidName`, `isChinesePhone`, `isEmailStrValid`, `pickNumber`
501
+
502
+ > Full function reference: [src/libs/crud-pro/README_FUNC.md](src/libs/crud-pro/README_FUNC.md)
503
+
504
+ ### Soft Delete
505
+
506
+ When `enableSoftDelete: true`, operations are automatically rewritten:
507
+
508
+ | Operation | Original | With Soft Delete |
509
+ |-----------|----------|-----------------|
510
+ | INSERT | Normal insert | Auto-set `data.deleted_at = 0` |
511
+ | DELETE | Physical DELETE | UPDATE: `deleted_at = timestamp`, `deleted_by = userId` |
512
+ | QUERY | Normal query | Auto-append `condition.deleted_at = 0` |
513
+
514
+ ### Standard Field Auto-Fill
515
+
516
+ When `enableStandardUpdateCfg: true`, standard fields are automatically populated:
517
+
518
+ | Operation | Auto-Filled Fields |
519
+ |-----------|--------------------|
520
+ | INSERT | `created_by`, `created_avatar`, `created_nickname`, `created_account_type` |
521
+ | UPDATE | `modified_by`, `modified_avatar`, `modified_nickname`, `modified_account_type` |
522
+ | DELETE | โ€” (condition auto-includes `created_by` for ownership check) |
523
+
524
+ ### Data Type Auto-Conversion
525
+
526
+ CrudPro automatically converts data types based on table schema before INSERT/UPDATE:
527
+
528
+ **PostgreSQL ARRAY** โ€” JS arrays are automatically converted to PG array literal format:
529
+
530
+ | Input | Converted | Description |
531
+ |-------|-----------|-------------|
532
+ | `["a","b","c"]` | `{"a","b","c"}` | String arrays: double-quoted |
533
+ | `[1,2,3]` | `{1,2,3}` | Number arrays: no quotes |
534
+ | `[true,false]` | `{t,f}` | Boolean arrays: t/f notation |
535
+ | `[1,null,3]` | `{1,NULL,3}` | Null handling |
536
+ | `[]` | `{}` | Empty arrays |
537
+ | `['he"llo']` | `{"he\"llo"}` | Special character escaping |
538
+
539
+ > Only applies to PostgreSQL; MySQL and SQL Server drivers handle type conversion natively.
540
+
541
+ ---
542
+
543
+ ## Quick Start
248
544
 
249
545
  ### Prerequisites
250
546
 
@@ -312,76 +608,7 @@ npm run cov
312
608
 
313
609
  ---
314
610
 
315
- ## ๐Ÿ›๏ธ Architecture
316
-
317
- ### Technology Stack
318
-
319
- | Layer | Technology |
320
- |-------|-----------|
321
- | **Framework** | Midway.js 3.x (Enterprise Node.js) |
322
- | **Web Server** | Koa |
323
- | **Language** | TypeScript |
324
- | **Database** | MySQL / PostgreSQL / SQL Server |
325
- | **Cache** | Redis |
326
- | **File Storage** | Alibaba Cloud OSS / S3-compatible |
327
-
328
- ### Core Middleware
329
-
330
- **Global Middleware:**
331
- - User session management
332
- - Multi-tenant isolation
333
- - Transaction management
334
- - Request-level logging
335
- - Unified response formatting
336
- - Real IP extraction
337
-
338
- **Security Middleware:**
339
- - Login verification (`checkLogin`)
340
- - Role verification (`checkRole`)
341
- - Permission verification (`checkPermission`)
342
- - Path blacklist (`Forbidden`)
343
- - Distributed locking (`RedisLock`)
344
- - Response caching (`RedisCache`)
345
-
346
- ---
347
-
348
- ## ๐Ÿ“ Project Structure
349
-
350
- ```
351
- midway-fatcms/
352
- โ”œโ”€โ”€ src/
353
- โ”‚ โ”œโ”€โ”€ config/ # Configuration files
354
- โ”‚ โ”œโ”€โ”€ controller/ # Controllers
355
- โ”‚ โ”‚ โ”œโ”€โ”€ base/ # Base controllers
356
- โ”‚ โ”‚ โ”œโ”€โ”€ gateway/ # Gateway APIs
357
- โ”‚ โ”‚ โ”œโ”€โ”€ manage/ # Management APIs
358
- โ”‚ โ”‚ โ”œโ”€โ”€ myinfo/ # Personal info APIs
359
- โ”‚ โ”‚ โ””โ”€โ”€ render/ # Rendering APIs
360
- โ”‚ โ”œโ”€โ”€ filter/ # Exception filters
361
- โ”‚ โ”œโ”€โ”€ libs/ # Core libraries
362
- โ”‚ โ”‚ โ”œโ”€โ”€ crud-pro/ # CRUD-Pro engine
363
- โ”‚ โ”‚ โ”œโ”€โ”€ global-config/ # Global configuration
364
- โ”‚ โ”‚ โ””โ”€โ”€ utils/ # Utilities
365
- โ”‚ โ”œโ”€โ”€ middleware/ # Middleware
366
- โ”‚ โ”œโ”€โ”€ models/ # Data models
367
- โ”‚ โ”œโ”€โ”€ schedule/ # Scheduled tasks
368
- โ”‚ โ”œโ”€โ”€ service/ # Business services
369
- โ”‚ โ”‚ โ”œโ”€โ”€ anyapi/ # Dynamic API
370
- โ”‚ โ”‚ โ”œโ”€โ”€ asyncTask/ # Async tasks
371
- โ”‚ โ”‚ โ”œโ”€โ”€ base/ # Base services
372
- โ”‚ โ”‚ โ”œโ”€โ”€ crudstd/ # Standard CRUD
373
- โ”‚ โ”‚ โ”œโ”€โ”€ curd/ # CRUD services
374
- โ”‚ โ”‚ โ”œโ”€โ”€ flow/ # Workflow
375
- โ”‚ โ”‚ โ””โ”€โ”€ proxyapi/ # Proxy API
376
- โ”‚ โ””โ”€โ”€ views/ # View templates
377
- โ”œโ”€โ”€ ddl/ # Database scripts
378
- โ”œโ”€โ”€ scripts/ # Utility scripts
379
- โ””โ”€โ”€ package.json # Project configuration
380
- ```
381
-
382
- ---
383
-
384
- ## ๐ŸŽฏ Use Cases
611
+ ## Use Cases
385
612
 
386
613
  ### Enterprise Back-Office Systems
387
614
  - Rapid admin dashboard creation
@@ -398,6 +625,11 @@ midway-fatcms/
398
625
  - Data open platforms
399
626
  - Microservice aggregation
400
627
 
628
+ ### High-Volume Data Systems
629
+ - Sharded order management (millions of records per month)
630
+ - Time-series log storage with auto-routing
631
+ - Real-time analytics across partitioned tables
632
+
401
633
  ### Low-Code Development
402
634
  - Rapid business system development
403
635
  - Form-driven applications
@@ -410,7 +642,7 @@ midway-fatcms/
410
642
 
411
643
  ---
412
644
 
413
- ## ๐Ÿ› ๏ธ Utility Endpoints
645
+ ## Utility Endpoints
414
646
 
415
647
  ### Encryption Helper
416
648
 
@@ -420,26 +652,37 @@ http://127.0.0.1:7002/ns/api/helpers/cryptoAes128CBC?input=123
420
652
 
421
653
  ---
422
654
 
423
- ## ๐Ÿ“Œ Version
655
+ ## Documentation Index
656
+
657
+ | Document | Description |
658
+ |----------|-------------|
659
+ | [CRUD-Pro Guide](src/libs/crud-pro/README.md) | Configuration-driven CRUD operations, validation, permissions |
660
+ | [Built-in Functions](src/libs/crud-pro/README_FUNC.md) | 30+ functions: date, compare, utility, type check |
661
+ | [Service Layer Guide](src/service/curd/README.md) | Context injection, soft delete, quick CRUD, sharding, relations |
662
+ | [Sharding Routing Logic](src/libs/crud-sharding/ROUTING_LOGIC.md) | Shard strategies, cross-shard pagination, COUNT cache |
663
+
664
+ ---
665
+
666
+ ## Version
424
667
 
425
668
  Current Version: `0.0.1-beta.82`
426
669
 
427
670
  ---
428
671
 
429
- ## ๐Ÿ“„ License
672
+ ## License
430
673
 
431
674
  MIT License โ€” Use it freely, contribute often.
432
675
 
433
676
  ---
434
677
 
435
- ## ๐Ÿ‘ฅ Contributing
678
+ ## Contributing
436
679
 
437
680
  We welcome contributions! Whether it's bug reports, feature requests, or pull requests, your input helps make Midway FatCMS better for everyone.
438
681
 
439
682
  ---
440
683
 
441
684
  <p align="center">
442
- <strong>Built with โค๏ธ by the Enterprise Low-Code Development Team</strong>
685
+ <strong>Built with care by the Enterprise Low-Code Development Team</strong>
443
686
  </p>
444
687
 
445
688
  <p align="center">
@@ -31,8 +31,6 @@ export declare class CrudStandardDesignApi extends BaseApiController {
31
31
  * ่Žทๅ–ๅŠŸ่ƒฝ็‚นๅˆ—่กจ
32
32
  */
33
33
  getFuncOptionsList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
34
- private getTableListOfSqlserver;
35
- private getTableListOfPostgreSQL;
36
34
  private getTableFieldsOfSqlServer;
37
35
  private getTableFieldsOfPostgreSQL;
38
36
  /**