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,238 +1,245 @@
|
|
|
1
|
-
# Reference: dbschema-kit Catalog
|
|
2
|
-
|
|
3
|
-
> **Offline mirror.** This file mirrors `codegen_get_dbschema_catalog` from the
|
|
4
|
-
> installed RESTForge platform. The live tool is authoritative — when this file
|
|
5
|
-
> and the tool disagree, trust the tool, then update this file. Always re-ground
|
|
6
|
-
> with the tool before defining SDF; do not rely on this mirror alone.
|
|
7
|
-
|
|
8
|
-
Source: `codegen_get_dbschema_catalog` — installed platform version.
|
|
9
|
-
Use as grounding before defining SDF.
|
|
10
|
-
Schema version: 1.1.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Table of Contents
|
|
15
|
-
|
|
16
|
-
1. [Field Types](#field-types)
|
|
17
|
-
2. [Shorthand Syntax](#shorthand-syntax)
|
|
18
|
-
3. [Constraints](#constraints)
|
|
19
|
-
4. [Relation Types](#relation-types)
|
|
20
|
-
5. [Referential Actions](#referential-actions)
|
|
21
|
-
6. [Check Operations](#check-operations)
|
|
22
|
-
7. [Audit Columns](#audit-columns)
|
|
23
|
-
8. [Soft-Delete Contract](#soft-delete-contract)
|
|
24
|
-
9. [Naming Rules](#naming-rules)
|
|
25
|
-
10. [Dialect Support](#dialect-support)
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Field Types
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| Type | Modifier | Shorthand example | Notes |
|
|
34
|
-
|---|---|---|---|
|
|
35
|
-
| `string` | required: `:<length>` | `string:255` | VARCHAR, explicit length required |
|
|
36
|
-
| `text` | none | `text` | TEXT/CLOB, no length limit |
|
|
37
|
-
| `integer` | none | `integer` | INT 32-bit |
|
|
38
|
-
| `bigint` | none | `bigint` | BIGINT 64-bit |
|
|
39
|
-
| `decimal` | required: `:<precision>,<scale>` | `decimal:15,2` | Fixed-point |
|
|
40
|
-
| `boolean` | none | `boolean` | Native BOOLEAN (PG), VARCHAR on others |
|
|
41
|
-
| `date` | none | `date` | Date only |
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
string:
|
|
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
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
-
|
|
202
|
-
|
|
203
|
-
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
###
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
1
|
+
# Reference: dbschema-kit Catalog
|
|
2
|
+
|
|
3
|
+
> **Offline mirror.** This file mirrors `codegen_get_dbschema_catalog` from the
|
|
4
|
+
> installed RESTForge platform. The live tool is authoritative — when this file
|
|
5
|
+
> and the tool disagree, trust the tool, then update this file. Always re-ground
|
|
6
|
+
> with the tool before defining SDF; do not rely on this mirror alone.
|
|
7
|
+
|
|
8
|
+
Source: `codegen_get_dbschema_catalog` — installed platform version.
|
|
9
|
+
Use as grounding before defining SDF.
|
|
10
|
+
Schema version: 1.1.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
1. [Field Types](#field-types)
|
|
17
|
+
2. [Shorthand Syntax](#shorthand-syntax)
|
|
18
|
+
3. [Constraints](#constraints)
|
|
19
|
+
4. [Relation Types](#relation-types)
|
|
20
|
+
5. [Referential Actions](#referential-actions)
|
|
21
|
+
6. [Check Operations](#check-operations)
|
|
22
|
+
7. [Audit Columns](#audit-columns)
|
|
23
|
+
8. [Soft-Delete Contract](#soft-delete-contract)
|
|
24
|
+
9. [Naming Rules](#naming-rules)
|
|
25
|
+
10. [Dialect Support](#dialect-support)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Field Types
|
|
30
|
+
|
|
31
|
+
12 types available. `string` and `decimal` require a modifier.
|
|
32
|
+
|
|
33
|
+
| Type | Modifier | Shorthand example | Notes |
|
|
34
|
+
|---|---|---|---|
|
|
35
|
+
| `string` | required: `:<length>` | `string:255` | VARCHAR, explicit length required |
|
|
36
|
+
| `text` | none | `text` | TEXT/CLOB, no length limit |
|
|
37
|
+
| `integer` | none | `integer` | INT 32-bit |
|
|
38
|
+
| `bigint` | none | `bigint` | BIGINT 64-bit |
|
|
39
|
+
| `decimal` | required: `:<precision>,<scale>` | `decimal:15,2` | Fixed-point |
|
|
40
|
+
| `boolean` | none | `boolean` | Native BOOLEAN (PG), VARCHAR on others |
|
|
41
|
+
| `date` | none | `date` | Date only |
|
|
42
|
+
| `time` | none | `time` | Time of day without date (TIME). Not affected by `TIMEZONE`/`DATEFORMAT`/`DATETIMEFORMAT`. **Rejected on Oracle** (no native TIME; use `timestamp`) |
|
|
43
|
+
| `timestamp` | none | `timestamp` | Date + time **without** time zone: wall-clock of `TIMEZONE`, millisecond precision. PG `TIMESTAMP`, MySQL `DATETIME(3)`, Oracle `TIMESTAMP`, SQLite text |
|
|
44
|
+
| `timestamptz` | none | `timestamptz` | Date + time **with** time zone, an absolute moment (stored as UTC, returned as ISO UTC). **PostgreSQL only**; rejected on MySQL, Oracle, SQLite with no silent fallback |
|
|
45
|
+
| `uuid` | none | `uuid` | Native UUID (PG), VARCHAR(36) on others |
|
|
46
|
+
| `json` | none | `json` | JSONB (PG), JSON (MySQL), CLOB (Oracle) |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Shorthand Syntax
|
|
51
|
+
|
|
52
|
+
Format: `<type>[:<modifier>] [<constraint>[:<value>]]...`
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
string:36 pk
|
|
56
|
+
string:255 notnull
|
|
57
|
+
decimal:15,2 notnull default:0
|
|
58
|
+
boolean default:true
|
|
59
|
+
string:100 default:'pending'
|
|
60
|
+
timestamp default:now()
|
|
61
|
+
string:36 fk:category.category_id
|
|
62
|
+
string:64 index
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Rules:
|
|
66
|
+
- Type must come first and must be from the field types list above.
|
|
67
|
+
- Modifier is required for `string` (length) and `decimal` (precision,scale).
|
|
68
|
+
- Standalone constraints have no value: `pk`, `notnull`, `unique`, `index`.
|
|
69
|
+
- Value constraints require `constraint:value` format: `default`, `fk`.
|
|
70
|
+
- String default: single-quoted `default:'value'`; numeric/boolean: raw `default:0`;
|
|
71
|
+
SQL constant: bare identifier `default:current_date`; native function: `default:now()`.
|
|
72
|
+
- FK uses dot notation: `fk:<table>.<column>`. `<column>` is the **actual
|
|
73
|
+
column name** of the referenced field in the target table — normally that
|
|
74
|
+
table's primary key column (e.g. `category.category_id`), NOT a literal `id`.
|
|
75
|
+
RESTForge does not auto-resolve `.id` to the primary key; a reference to a
|
|
76
|
+
column that does not exist is rejected. Bracket syntax is rejected by the parser.
|
|
77
|
+
- `autoUpdate` is deprecated — no functional effect, parsed for backward compat only.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Constraints
|
|
82
|
+
|
|
83
|
+
6 active constraints. The catalog counts 7 because it also lists the deprecated
|
|
84
|
+
`autoUpdate` (parsed for backward compatibility, no effect on DDL or runtime).
|
|
85
|
+
|
|
86
|
+
| Constraint | Kind | Example | Notes |
|
|
87
|
+
|---|---|---|---|
|
|
88
|
+
| `pk` | standalone | `string:36 pk` | Primary key |
|
|
89
|
+
| `notnull` | standalone | `string:255 notnull` | NOT NULL |
|
|
90
|
+
| `unique` | standalone | `string:32 unique` | Single-column UNIQUE |
|
|
91
|
+
| `index` | standalone | `string:64 index` | Single-column non-unique index |
|
|
92
|
+
| `default` | value | `boolean default:true` | Default value |
|
|
93
|
+
| `fk` | value | `string:36 fk:category.category_id` | FK + auto belongsTo relation; target is the actual PK column name |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Relation Types
|
|
98
|
+
|
|
99
|
+
3 relation types. All use `type`, `localKey`, `references` (required),
|
|
100
|
+
and `target`, `onDelete`, `onUpdate` (optional).
|
|
101
|
+
|
|
102
|
+
| Type | Direction | DDL |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `belongsTo` | Many-to-one, this table holds the FK | FK constraint generated |
|
|
105
|
+
| `hasOne` | One-to-one inverse of belongsTo | No additional DDL |
|
|
106
|
+
| `hasMany` | One-to-many inverse of belongsTo | No additional DDL |
|
|
107
|
+
|
|
108
|
+
Example:
|
|
109
|
+
```js
|
|
110
|
+
relations: {
|
|
111
|
+
category: {
|
|
112
|
+
type: "belongsTo",
|
|
113
|
+
localKey: "category_id",
|
|
114
|
+
references: "category_id",
|
|
115
|
+
onDelete: "restrict"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Referential Actions
|
|
123
|
+
|
|
124
|
+
4 actions for `onDelete` and `onUpdate`:
|
|
125
|
+
|
|
126
|
+
| Action | Behavior |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `cascade` | Delete/update child rows |
|
|
129
|
+
| `restrict` | Reject delete/update if child exists |
|
|
130
|
+
| `setNull` | Set child FK to NULL (field must be nullable) |
|
|
131
|
+
| `noAction` | Defer check (semantics similar to restrict in most dialects) |
|
|
132
|
+
|
|
133
|
+
Oracle writes `restrict` and `noAction` without an `ON DELETE` clause, which
|
|
134
|
+
Oracle enforces the same way. `codegen_dbschema_diff` treats `noAction` and
|
|
135
|
+
`restrict` as equal, so switching between them is not reported as drift.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Check Operations
|
|
140
|
+
|
|
141
|
+
7 operators for the `checks` array. Format: `{ name?, field, <operator>: <value> }`.
|
|
142
|
+
|
|
143
|
+
| Operator | Value type | Example |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| `in` | array | `{ field: "status", in: ["active", "inactive"] }` |
|
|
146
|
+
| `eq` | scalar | `{ field: "type", eq: "user" }` |
|
|
147
|
+
| `neq` | scalar | `{ field: "type", neq: "system" }` |
|
|
148
|
+
| `gt` | numeric | `{ field: "qty", gt: 0 }` |
|
|
149
|
+
| `gte` | numeric | `{ field: "qty", gte: 0 }` |
|
|
150
|
+
| `lt` | numeric | `{ field: "discount", lt: 100 }` |
|
|
151
|
+
| `lte` | numeric | `{ field: "discount", lte: 100 }` |
|
|
152
|
+
|
|
153
|
+
> Case enforcement at the DB level (e.g. require `customer_name` to be stored
|
|
154
|
+
> upper case) belongs here as a check, not in RDF `fieldValidation`. RDF
|
|
155
|
+
> `uppercase` only normalizes the value at the API layer.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Audit Columns
|
|
160
|
+
|
|
161
|
+
4 standard columns for tables managed by RESTForge. Emitted automatically by
|
|
162
|
+
`codegen_dbschema_init`. Lookup/system tables may remove them manually.
|
|
163
|
+
|
|
164
|
+
| Column | SDF shorthand | Notes |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `created_at` | `timestamp default:now()` | Set via DEFAULT now() on INSERT |
|
|
167
|
+
| `created_by` | `string:100` | Set by application layer on INSERT, nullable |
|
|
168
|
+
| `updated_at` | `timestamp` | Auto-updated via RDF runtime (not an SDF marker) |
|
|
169
|
+
| `updated_by` | `string:100` | Set by application layer on UPDATE, nullable |
|
|
170
|
+
|
|
171
|
+
All 4 columns are nullable. Drift between SDF (audit columns absent) and RDF
|
|
172
|
+
(assumes audit columns exist) causes runtime errors.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Soft-Delete Contract
|
|
177
|
+
|
|
178
|
+
Declare with `softDelete: { enabled: true }` in `defineModel`. The three
|
|
179
|
+
contract columns must be present in `fields` with the correct types.
|
|
180
|
+
|
|
181
|
+
| Column | Required shorthand | Nullable |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| `is_deleted` | `boolean notnull default:false` | no |
|
|
184
|
+
| `deleted_at` | `timestamp` | yes |
|
|
185
|
+
| `deleted_by` | `string:70` | yes |
|
|
186
|
+
|
|
187
|
+
### Biconditional rules
|
|
188
|
+
|
|
189
|
+
- `enabled: true` + all three columns present with correct types → valid.
|
|
190
|
+
- `enabled: true` + missing columns → ERROR (missing columns listed).
|
|
191
|
+
- Contract columns present but `enabled` not true → ERROR.
|
|
192
|
+
- Wrong column type → ERROR.
|
|
193
|
+
- `is_deleted`, `deleted_at`, `deleted_by` are reserved names — cannot be used
|
|
194
|
+
as regular columns in a RESTForge table.
|
|
195
|
+
|
|
196
|
+
### Reusable (UNIQUE column values freed after soft-delete)
|
|
197
|
+
|
|
198
|
+
Fields whose unique values should be freed after soft-delete must be declared
|
|
199
|
+
in `softDelete.reusable: [{ field, length }]`. Requirements:
|
|
200
|
+
- Field must exist in `fields`.
|
|
201
|
+
- Field type must be `string` or `text`.
|
|
202
|
+
- Field must have a single-column UNIQUE constraint.
|
|
203
|
+
- `length` = maximum input length. Physical length = `length + 38`
|
|
204
|
+
(38 = "##" + UUID v7).
|
|
205
|
+
|
|
206
|
+
### Generated DDL
|
|
207
|
+
|
|
208
|
+
- CHECK constraint: `chk_<table>_soft_delete_consistency` — enforces consistency
|
|
209
|
+
across the three contract columns.
|
|
210
|
+
- Non-unique indexes become PostgreSQL partial indexes:
|
|
211
|
+
`WHERE is_deleted = FALSE`.
|
|
212
|
+
- UNIQUE constraints are NOT made partial; column values are freed via
|
|
213
|
+
suffix mutation (not a partial unique index).
|
|
214
|
+
|
|
215
|
+
### Unique eligibility gate
|
|
216
|
+
|
|
217
|
+
When `enabled: true`, all UNIQUE constraints on the table are checked:
|
|
218
|
+
- Composite UNIQUE is rejected — suffix mutation cannot free composite columns.
|
|
219
|
+
- Single-column UNIQUE on a non-string type is rejected — suffix mutation only
|
|
220
|
+
works for `string`/`text`.
|
|
221
|
+
|
|
222
|
+
### Dialect support
|
|
223
|
+
|
|
224
|
+
Phase 1: PostgreSQL only. Other dialects produce an explicit error.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Naming Rules
|
|
229
|
+
|
|
230
|
+
- Table names: `snake_case`, lowercase, digits, underscores.
|
|
231
|
+
- Field/column names: `snake_case`.
|
|
232
|
+
- Constraint names: auto-generated with prefixes `pk_`, `fk_`, `idx_`, `uq_`,
|
|
233
|
+
`ck_`. When exceeding the dialect's maximum length, falls back to an 8-character
|
|
234
|
+
MD5 suffix.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Dialect Support
|
|
239
|
+
|
|
240
|
+
| Dialect | Driver | Boolean storage |
|
|
241
|
+
|---|---|---|
|
|
242
|
+
| `postgres` | pg | Native BOOLEAN |
|
|
243
|
+
| `mysql` | mysql2 | VARCHAR ("true"/"false") |
|
|
244
|
+
| `oracle` | oracledb | VARCHAR2 + CHECK constraint |
|
|
245
|
+
| `sqlite` | better-sqlite3 | TEXT |
|