create-restforge-skills 0.2.0 → 0.4.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.
- package/README.md +148 -150
- package/package.json +33 -30
- package/skills/restforge/SKILL.md +832 -559
- package/skills/restforge/references/auth.md +2 -2
- package/skills/restforge/references/config-schema.md +238 -173
- package/skills/restforge/references/dbschema-catalog.md +245 -238
- package/skills/restforge/references/design-to-sdf.md +621 -618
- package/skills/restforge/references/field-validation.md +247 -173
- package/skills/restforge/references/rdf-advanced.md +695 -488
- package/skills/restforge/references/udf-catalog.md +623 -496
|
@@ -1,173 +1,247 @@
|
|
|
1
|
-
# Reference: Field Validation Catalog
|
|
2
|
-
|
|
3
|
-
> **Offline mirror.** This file mirrors `codegen_get_field_validation_catalog`
|
|
4
|
-
> from the installed RESTForge platform. The live tool is authoritative — when
|
|
5
|
-
> this file and the tool disagree, trust the tool, then update this file. Always
|
|
6
|
-
> re-ground with the tool before defining content; do not rely on this mirror
|
|
7
|
-
> alone.
|
|
8
|
-
|
|
9
|
-
Source: `codegen_get_field_validation_catalog` — installed platform version.
|
|
10
|
-
Use as grounding before defining `fieldValidation` in a payload.
|
|
11
|
-
Schema version: 1.0.
|
|
12
|
-
|
|
13
|
-
Summary:
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
|
107
|
-
|
|
108
|
-
| `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
###
|
|
119
|
-
|
|
120
|
-
| Constraint | Value type | Example |
|
|
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
|
-
|
|
1
|
+
# Reference: Field Validation Catalog
|
|
2
|
+
|
|
3
|
+
> **Offline mirror.** This file mirrors `codegen_get_field_validation_catalog`
|
|
4
|
+
> from the installed RESTForge platform. The live tool is authoritative — when
|
|
5
|
+
> this file and the tool disagree, trust the tool, then update this file. Always
|
|
6
|
+
> re-ground with the tool before defining content; do not rely on this mirror
|
|
7
|
+
> alone.
|
|
8
|
+
|
|
9
|
+
Source: `codegen_get_field_validation_catalog` — installed platform version.
|
|
10
|
+
Use as grounding before defining `fieldValidation` in a payload.
|
|
11
|
+
Schema version: 1.0.
|
|
12
|
+
|
|
13
|
+
Summary: 13 types, 33 constraint entries (`format`, `min`, and `max` appear once
|
|
14
|
+
per scope), 4 string format presets.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Table of Contents
|
|
19
|
+
|
|
20
|
+
1. [Entry Shape](#entry-shape)
|
|
21
|
+
2. [Types and Applicable Constraints](#types-and-applicable-constraints)
|
|
22
|
+
3. [Constraints (full)](#constraints-full)
|
|
23
|
+
4. [Format Presets](#format-presets)
|
|
24
|
+
5. [Date and Time Configuration](#date-and-time-configuration)
|
|
25
|
+
6. [Audit Columns in Payload](#audit-columns-in-payload)
|
|
26
|
+
7. [Message Override Pattern](#message-override-pattern)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Entry Shape
|
|
31
|
+
|
|
32
|
+
`fieldValidation` is an array at the root of the RDF (and inside
|
|
33
|
+
`masterDetail.detailConfig` for detail columns). Each entry names one column:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
"fieldValidation": [
|
|
37
|
+
{
|
|
38
|
+
"name": "category_code",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"constraints": { "required": true, "maxLength": 20, "uppercase": true, "trim": true }
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Key | Required | Notes |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `name` | yes | Column name; must be listed in `fieldName` |
|
|
48
|
+
| `type` | yes | One of the types below |
|
|
49
|
+
| `constraints` | no | Object of constraint keys and their `*Message` overrides |
|
|
50
|
+
|
|
51
|
+
Rules apply to `/create` and `/update`. `codegen_generate_payload` writes these
|
|
52
|
+
entries from the database; edit them, do not write the array from scratch.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Types and Applicable Constraints
|
|
57
|
+
|
|
58
|
+
Use the `applicableConstraints` column to validate constraint scope per type.
|
|
59
|
+
Constraints not listed for a given type will be rejected.
|
|
60
|
+
|
|
61
|
+
| Type | Database Types | Applicable Constraints |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `string` | VARCHAR, TEXT, CHAR | required, unique, default, primaryKey, autoGenerate, nullable, minLength, maxLength, pattern, patternMessage, format, enum, trim, lowercase, uppercase |
|
|
64
|
+
| `integer` | INTEGER, INT, BIGINT | required, unique, default, primaryKey, nullable, min, max, precision, scale, positive, negative, integer, format |
|
|
65
|
+
| `decimal` | DECIMAL, NUMERIC | required, unique, default, primaryKey, nullable, min, max, precision, scale, positive, negative, integer, format |
|
|
66
|
+
| `number` | NUMERIC | required, unique, default, primaryKey, nullable, min, max, precision, scale, positive, negative, integer, format |
|
|
67
|
+
| `boolean` | BOOLEAN | required, unique, default, primaryKey, nullable, strict |
|
|
68
|
+
| `date` | DATE | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
|
|
69
|
+
| `datetime` | TIMESTAMP | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
|
|
70
|
+
| `timestamp` | TIMESTAMP | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
|
|
71
|
+
| `timestamptz` | TIMESTAMPTZ | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
|
|
72
|
+
| `time` | TIME | required, unique, default, primaryKey, nullable |
|
|
73
|
+
| `uuid` | UUID | required, unique, default, primaryKey, autoGenerate, nullable |
|
|
74
|
+
| `json` | JSON, JSONB | required, unique, default, primaryKey, nullable, schema |
|
|
75
|
+
| `array` | ARRAY | required, unique, default, primaryKey, nullable, minItems, maxItems, uniqueItems |
|
|
76
|
+
|
|
77
|
+
- `timestamp` is a date-time **without** time zone (wall-clock of `TIMEZONE`).
|
|
78
|
+
`timestamptz` is an absolute moment and exists on PostgreSQL only.
|
|
79
|
+
- `datetime` is a legacy alias of `timestamp`; the generator emits `timestamp`.
|
|
80
|
+
- `format` is listed for the date types, but `codegen_validate_payload` rejects
|
|
81
|
+
it there (see [Date and Time Configuration](#date-and-time-configuration)).
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Constraints (full)
|
|
86
|
+
|
|
87
|
+
### General (applies to all types)
|
|
88
|
+
|
|
89
|
+
| Constraint | Value type | Notes |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `required` | boolean | Field must be present and non-empty; override key `requiredMessage` |
|
|
92
|
+
| `unique` | boolean | Unique value across rows (enforced by DB, not app validation) |
|
|
93
|
+
| `default` | any | Default value when field is absent |
|
|
94
|
+
| `primaryKey` | boolean | Mark as primary key |
|
|
95
|
+
| `autoGenerate` | boolean | Auto-generate value at runtime (uuid, string, timestamp, timestamptz, datetime, date) |
|
|
96
|
+
| `nullable` | boolean | Allow null values |
|
|
97
|
+
|
|
98
|
+
### String scope
|
|
99
|
+
|
|
100
|
+
| Constraint | Value type | Message override key | Example |
|
|
101
|
+
|---|---|---|---|
|
|
102
|
+
| `minLength` | integer | `minLengthMessage` | `"minLength": 3` |
|
|
103
|
+
| `maxLength` | integer | `maxLengthMessage` | `"maxLength": 100` |
|
|
104
|
+
| `pattern` | string | `patternMessage` | `"pattern": "^[A-Z]{3}\\d{4}$"` |
|
|
105
|
+
| `patternMessage` | string | — | `"patternMessage": "Invalid format"` |
|
|
106
|
+
| `format` | string | `formatMessage` | `"format": "email"` (see format presets) |
|
|
107
|
+
| `enum` | array | `enumMessage` | `"enum": ["active", "inactive"]` |
|
|
108
|
+
| `trim` | boolean | — | `"trim": true` |
|
|
109
|
+
| `lowercase` | boolean | — | `"lowercase": true` |
|
|
110
|
+
| `uppercase` | boolean | — | `"uppercase": true` |
|
|
111
|
+
|
|
112
|
+
> `trim`, `lowercase`, and `uppercase` are **normalization transforms** applied to
|
|
113
|
+
> the stored value, not validators. `uppercase: true` forces the value to upper
|
|
114
|
+
> case; it does not reject non-uppercase input. To *reject* input that is not
|
|
115
|
+
> upper case, use `pattern` (e.g. `"^[A-Z ]+$"`). To enforce case at the database
|
|
116
|
+
> level, use an SDF check constraint, not `fieldValidation`.
|
|
117
|
+
|
|
118
|
+
### Number scope (integer, decimal, number)
|
|
119
|
+
|
|
120
|
+
| Constraint | Value type | Message override key | Example |
|
|
121
|
+
|---|---|---|---|
|
|
122
|
+
| `min` | number | `minMessage` | `"min": 0` |
|
|
123
|
+
| `max` | number | `maxMessage` | `"max": 9999999.99` |
|
|
124
|
+
| `precision` | integer | `precisionMessage` | `"precision": 10` |
|
|
125
|
+
| `scale` | integer | — | `"scale": 2` |
|
|
126
|
+
| `positive` | boolean | `positiveMessage` | `"positive": true` |
|
|
127
|
+
| `negative` | boolean | `negativeMessage` | `"negative": true` |
|
|
128
|
+
| `integer` | boolean | `integerMessage` | `"integer": true` |
|
|
129
|
+
| `format` | string | — | `"format": "currency"` (the only valid value) |
|
|
130
|
+
|
|
131
|
+
`format: "currency"` is a display hint, not a validator. `codegen_migrate_payload`
|
|
132
|
+
turns it into the UDF field attribute `format: "currency"`; every other numeric
|
|
133
|
+
field becomes `format: "number"`. `scale` becomes the UDF `decimalPlaces`.
|
|
134
|
+
|
|
135
|
+
### Date scope (date, datetime, timestamp, timestamptz)
|
|
136
|
+
|
|
137
|
+
| Constraint | Value type | Message override key | Example |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| `min` | string | `minMessage` | `"min": "01/01/2020"` |
|
|
140
|
+
| `max` | string | `maxMessage` | `"max": "31/12/2030"` |
|
|
141
|
+
| `before` | string (field name) | `beforeMessage` | `"before": "end_date"` |
|
|
142
|
+
| `after` | string (field name) | `afterMessage` | `"after": "start_date"` |
|
|
143
|
+
|
|
144
|
+
Do not set `format` on these types. The pattern always comes from `DATEFORMAT`
|
|
145
|
+
or `DATETIMEFORMAT`, and `codegen_validate_payload` fails with
|
|
146
|
+
`constraints.format ... is not supported for type '<type>'`.
|
|
147
|
+
|
|
148
|
+
### Boolean scope
|
|
149
|
+
|
|
150
|
+
| Constraint | Value type | Notes |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| `strict` | boolean | Reject coercion — only accept native boolean values, not the strings "true"/"false" |
|
|
153
|
+
|
|
154
|
+
### Array scope
|
|
155
|
+
|
|
156
|
+
| Constraint | Value type | Message override key | Example |
|
|
157
|
+
|---|---|---|---|
|
|
158
|
+
| `minItems` | integer | `minItemsMessage` | `"minItems": 1` |
|
|
159
|
+
| `maxItems` | integer | `maxItemsMessage` | `"maxItems": 100` |
|
|
160
|
+
| `uniqueItems` | boolean | `uniqueItemsMessage` | `"uniqueItems": true` |
|
|
161
|
+
|
|
162
|
+
### JSON scope
|
|
163
|
+
|
|
164
|
+
| Constraint | Value type | Example |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `schema` | object | `"schema": { "type": "object", "properties": { ... } }` |
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Format Presets
|
|
171
|
+
|
|
172
|
+
Applies to the `format` constraint on type `string`.
|
|
173
|
+
|
|
174
|
+
| Preset | Notes |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `email` | Validates email address format |
|
|
177
|
+
| `phone` | Validates phone number format |
|
|
178
|
+
| `url` | Validates URL format |
|
|
179
|
+
| `uuid` | Validates UUID format (v7 generated by app layer; v4 legacy remains valid) |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Date and Time Configuration
|
|
184
|
+
|
|
185
|
+
Three backend parameters in `config/db-connection.env` are the single
|
|
186
|
+
application-wide standard for every endpoint and dialect. Every API response
|
|
187
|
+
returns the active values in the `X-Timezone`, `X-Date-Format`, and
|
|
188
|
+
`X-DateTime-Format` headers.
|
|
189
|
+
|
|
190
|
+
| Parameter | Default | Applies to |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `TIMEZONE` | `UTC` | IANA zone (e.g. `Asia/Jakarta`) used to parse `timestamp`/`timestamptz` input without an offset and for audit column values. A local time inside a DST gap or overlap is rejected with 400 `INVALID_DATETIME`. Does not affect `date` |
|
|
193
|
+
| `DATEFORMAT` | `yyyy-MM-dd` | Input and output pattern of every `date` field. Input also accepts ISO `yyyy-MM-dd` |
|
|
194
|
+
| `DATETIMEFORMAT` | `yyyy-MM-dd HH:mm:ss.SSS` | Input and output pattern of every `timestamp` field, written `<date pattern> <time pattern>`. Input also accepts ISO 8601 with or without an offset |
|
|
195
|
+
|
|
196
|
+
Output per type:
|
|
197
|
+
|
|
198
|
+
| Type | Output |
|
|
199
|
+
|---|---|
|
|
200
|
+
| `timestamp` | Always `DATETIMEFORMAT`, fraction truncated to milliseconds |
|
|
201
|
+
| `timestamptz` | Always ISO 8601 UTC (e.g. `2025-01-16T08:30:45.123Z`), regardless of `TIMEZONE` and `DATETIMEFORMAT` |
|
|
202
|
+
| `date` | Always `DATEFORMAT`, never shifted by `TIMEZONE` |
|
|
203
|
+
| `time` | `HH:mm:ss`, or the per-field `format` declared in `dateTimeFields` |
|
|
204
|
+
|
|
205
|
+
Only `time` fields may declare a per-field `format`. The frontend
|
|
206
|
+
`appConfig.dateFormat` and `appConfig.dateTimeFormat` must equal `DATEFORMAT` and
|
|
207
|
+
`DATETIMEFORMAT`; `codegen_migrate_payload` copies them on every run.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Audit Columns in Payload
|
|
212
|
+
|
|
213
|
+
The `auditColumns` key in a payload controls which audit columns are managed by the runtime.
|
|
214
|
+
|
|
215
|
+
| Value | Behavior |
|
|
216
|
+
|---|---|
|
|
217
|
+
| absent (no key) | Use 4 default audit columns: created_at, created_by, updated_at, updated_by |
|
|
218
|
+
| `false` | Disable audit columns |
|
|
219
|
+
| `null` | Disable audit columns |
|
|
220
|
+
| object | Override column names; required keys: `createdAt`, `createdBy`, `updatedAt`, `updatedBy` |
|
|
221
|
+
|
|
222
|
+
Rejected values: `true`, string, array, number. Error message:
|
|
223
|
+
`"Invalid auditColumns value for <tableName>: must be false, null, or object"`.
|
|
224
|
+
|
|
225
|
+
Auto-update of `updated_at` is implemented entirely in the RDF runtime (BaseModel
|
|
226
|
+
auditColumns helper) based on naming convention — not by an SDF marker.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Message Override Pattern
|
|
231
|
+
|
|
232
|
+
Any constraint that has a `messageOverrideKey` can be overridden by adding a
|
|
233
|
+
sibling key named `{constraintName}Message` inside the same `constraints` object.
|
|
234
|
+
|
|
235
|
+
Example:
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"name": "supplier_code",
|
|
239
|
+
"type": "string",
|
|
240
|
+
"constraints": {
|
|
241
|
+
"required": true,
|
|
242
|
+
"requiredMessage": "Supplier code is required",
|
|
243
|
+
"minLength": 3,
|
|
244
|
+
"minLengthMessage": "Minimum 3 characters"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|