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.
@@ -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: 12 types, 32 constraints, 4 format presets.
14
-
15
- ---
16
-
17
- ## Table of Contents
18
-
19
- 1. [Types and Applicable Constraints](#types-and-applicable-constraints)
20
- 2. [Constraints (full)](#constraints-full)
21
- 3. [Format Presets](#format-presets)
22
- 4. [Audit Columns in Payload](#audit-columns-in-payload)
23
- 5. [Message Override Pattern](#message-override-pattern)
24
-
25
- ---
26
-
27
- ## Types and Applicable Constraints
28
-
29
- Use the `applicableConstraints` column to validate constraint scope per type.
30
- Constraints not listed for a given type will be rejected.
31
-
32
- | Type | Database Types | Applicable Constraints |
33
- |---|---|---|
34
- | `string` | VARCHAR, TEXT, CHAR | required, unique, default, primaryKey, autoGenerate, nullable, minLength, maxLength, pattern, patternMessage, format, enum, trim, lowercase, uppercase |
35
- | `integer` | INTEGER, INT, BIGINT | required, unique, default, primaryKey, nullable, min, max, precision, scale, positive, negative, integer |
36
- | `decimal` | DECIMAL, NUMERIC | required, unique, default, primaryKey, nullable, min, max, precision, scale, positive, negative, integer |
37
- | `number` | NUMERIC | required, unique, default, primaryKey, nullable, min, max, precision, scale, positive, negative, integer |
38
- | `boolean` | BOOLEAN | required, unique, default, primaryKey, nullable, strict |
39
- | `date` | DATE | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
40
- | `datetime` | TIMESTAMP | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
41
- | `timestamp` | TIMESTAMPTZ | required, unique, default, primaryKey, autoGenerate, nullable, format, min, max, before, after |
42
- | `time` | TIME | required, unique, default, primaryKey, nullable |
43
- | `uuid` | UUID | required, unique, default, primaryKey, autoGenerate, nullable |
44
- | `json` | JSON, JSONB | required, unique, default, primaryKey, nullable, schema |
45
- | `array` | ARRAY | required, unique, default, primaryKey, nullable, minItems, maxItems, uniqueItems |
46
-
47
- ---
48
-
49
- ## Constraints (full)
50
-
51
- ### General (applies to all types)
52
-
53
- | Constraint | Value type | Notes |
54
- |---|---|---|
55
- | `required` | boolean | Field must be present and non-empty |
56
- | `unique` | boolean | Unique value across rows (enforced by DB, not app validation) |
57
- | `default` | any | Default value when field is absent |
58
- | `primaryKey` | boolean | Mark as primary key |
59
- | `autoGenerate` | boolean | Auto-generate value at runtime (uuid, string, timestamp, datetime, date) |
60
- | `nullable` | boolean | Allow null values |
61
-
62
- ### String scope
63
-
64
- | Constraint | Value type | Message override key | Example |
65
- |---|---|---|---|
66
- | `minLength` | integer | `minLengthMessage` | `"minLength": 3` |
67
- | `maxLength` | integer | `maxLengthMessage` | `"maxLength": 100` |
68
- | `pattern` | string | `patternMessage` | `"pattern": "^[A-Z]{3}\\d{4}$"` |
69
- | `patternMessage` | string | — | `"patternMessage": "Invalid format"` |
70
- | `format` | string | `formatMessage` | `"format": "email"` (see format presets) |
71
- | `enum` | array | `enumMessage` | `"enum": ["active", "inactive"]` |
72
- | `trim` | boolean | — | `"trim": true` |
73
- | `lowercase` | boolean | — | `"lowercase": true` |
74
- | `uppercase` | boolean | — | `"uppercase": true` |
75
-
76
- > `trim`, `lowercase`, and `uppercase` are **normalization transforms** applied to
77
- > the stored value, not validators. `uppercase: true` forces the value to upper
78
- > case; it does not reject non-uppercase input. To *reject* input that is not
79
- > upper case, use `pattern` (e.g. `"^[A-Z ]+$"`). To enforce case at the database
80
- > level, use an SDF check constraint, not `fieldValidation`.
81
-
82
- ### Number scope (integer, decimal, number)
83
-
84
- | Constraint | Value type | Message override key | Example |
85
- |---|---|---|---|
86
- | `min` | number | `minMessage` | `"min": 0` |
87
- | `max` | number | `maxMessage` | `"max": 9999999.99` |
88
- | `precision` | integer | `precisionMessage` | `"precision": 10` |
89
- | `scale` | integer | — | `"scale": 2` |
90
- | `positive` | boolean | `positiveMessage` | `"positive": true` |
91
- | `negative` | boolean | `negativeMessage` | `"negative": true` |
92
- | `integer` | boolean | `integerMessage` | `"integer": true` |
93
-
94
- ### Date scope (date, datetime, timestamp)
95
-
96
- | Constraint | Value type | Message override key | Example |
97
- |---|---|---|---|
98
- | `format` | string | — | `"format": "DD/MM/YYYY"` |
99
- | `min` | string | `minMessage` | `"min": "01/01/2020"` |
100
- | `max` | string | `maxMessage` | `"max": "31/12/2030"` |
101
- | `before` | string (field name) | `beforeMessage` | `"before": "end_date"` |
102
- | `after` | string (field name) | `afterMessage` | `"after": "start_date"` |
103
-
104
- ### Boolean scope
105
-
106
- | Constraint | Value type | Notes |
107
- |---|---|---|
108
- | `strict` | boolean | Reject coercion — only accept native boolean values, not the strings "true"/"false" |
109
-
110
- ### Array scope
111
-
112
- | Constraint | Value type | Message override key | Example |
113
- |---|---|---|---|
114
- | `minItems` | integer | `minItemsMessage` | `"minItems": 1` |
115
- | `maxItems` | integer | `maxItemsMessage` | `"maxItems": 100` |
116
- | `uniqueItems` | boolean | `uniqueItemsMessage` | `"uniqueItems": true` |
117
-
118
- ### JSON scope
119
-
120
- | Constraint | Value type | Example |
121
- |---|---|---|
122
- | `schema` | object | `"schema": { "type": "object", "properties": { ... } }` |
123
-
124
- ---
125
-
126
- ## Format Presets
127
-
128
- Applies to the `format` constraint on type `string`.
129
-
130
- | Preset | Notes |
131
- |---|---|
132
- | `email` | Validates email address format |
133
- | `phone` | Validates phone number format |
134
- | `url` | Validates URL format |
135
- | `uuid` | Validates UUID format (v7 generated by app layer; v4 legacy remains valid) |
136
-
137
- ---
138
-
139
- ## Audit Columns in Payload
140
-
141
- The `auditColumns` key in a payload controls which audit columns are managed by the runtime.
142
-
143
- | Value | Behavior |
144
- |---|---|
145
- | absent (no key) | Use 4 default audit columns: created_at, created_by, updated_at, updated_by |
146
- | `false` | Disable audit columns |
147
- | `null` | Disable audit columns |
148
- | object | Override column names; required keys: `createdAt`, `createdBy`, `updatedAt`, `updatedBy` |
149
-
150
- Rejected values: `true`, string, array, number. Error message:
151
- `"Invalid auditColumns value for <tableName>: must be false, null, or object"`.
152
-
153
- Auto-update of `updated_at` is implemented entirely in the RDF runtime (BaseModel
154
- auditColumns helper) based on naming convention — not by an SDF marker.
155
-
156
- ---
157
-
158
- ## Message Override Pattern
159
-
160
- Any constraint that has a `messageOverrideKey` can be overridden by adding a
161
- sibling key named `{constraintName}Message`.
162
-
163
- Example:
164
- ```json
165
- {
166
- "fieldName": "supplier_code",
167
- "type": "string",
168
- "fieldValidation": [
169
- { "required": true, "requiredMessage": "Supplier code is required" },
170
- { "minLength": 3, "minLengthMessage": "Minimum 3 characters" }
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
+ ```