create-restforge-skills 0.1.0 → 0.2.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 +14 -1
- package/package.json +1 -1
- package/skills/restforge/SKILL.md +163 -25
- package/skills/restforge/references/auth.md +145 -0
- package/skills/restforge/references/udf-catalog.md +10 -3
package/README.md
CHANGED
|
@@ -34,8 +34,10 @@ restforge-skills/
|
|
|
34
34
|
├── README.md ← this file
|
|
35
35
|
├── package.json ← npm package: create-restforge-skills
|
|
36
36
|
├── bump-and-publish.bat ← version bump + npm publish
|
|
37
|
+
├── sync-to-plugin.bat ← mirror the skill into the Claude Code plugin
|
|
37
38
|
├── cli/
|
|
38
|
-
│
|
|
39
|
+
│ ├── index.js ← installer that copies the skill into each client
|
|
40
|
+
│ └── mcp.js ← merges the MCP server into each client config
|
|
39
41
|
├── docs/ ← internal docs, NOT published (excluded from npm files)
|
|
40
42
|
└── skills/
|
|
41
43
|
└── restforge/
|
|
@@ -43,6 +45,17 @@ restforge-skills/
|
|
|
43
45
|
└── references/ ← progressive-disclosure reference material
|
|
44
46
|
```
|
|
45
47
|
|
|
48
|
+
## Single source of truth
|
|
49
|
+
|
|
50
|
+
`skills/restforge/` here is the **one** authoritative copy of the skill. Two
|
|
51
|
+
distribution channels consume it — do not edit the skill anywhere else:
|
|
52
|
+
|
|
53
|
+
- **This package** (`create-restforge-skills`) — published to npm; cross-client.
|
|
54
|
+
- **The Claude Code plugin** (`../packages/restforge-plugins`) — its
|
|
55
|
+
`skills/restforge-skills/` folder is a **generated mirror**. After editing the
|
|
56
|
+
canonical skill, run `sync-to-plugin.bat` to propagate, then commit the plugin
|
|
57
|
+
repo. Hand-edits to the plugin's skill copy are overwritten on the next sync.
|
|
58
|
+
|
|
46
59
|
## Install
|
|
47
60
|
|
|
48
61
|
One command. It detects your installed clients (Claude Code, Cursor), copies the
|
package/package.json
CHANGED
|
@@ -4,7 +4,8 @@ description: >
|
|
|
4
4
|
RESTForge end-to-end workflow — use for any task involving RESTForge: SDF
|
|
5
5
|
(Schema Definition File), RDF (Resource Definition File), UDF (UI Definition
|
|
6
6
|
File), dbschema, defineModel, codegen, payload, generate endpoint, generate
|
|
7
|
-
dashboard, generate frontend, migrate schema, setup project,
|
|
7
|
+
dashboard, generate frontend, migrate schema, setup project, add authentication
|
|
8
|
+
(project auth backend, embedded rfx_auth frontend auth), or design-to-SDF
|
|
8
9
|
(deriving a schema from an HTML mockup, screenshot, image, or UI design). Also
|
|
9
10
|
active for the codegen_*, designer_*, setup_*, runtime_* MCP tools and the
|
|
10
11
|
@restforgejs/platform / @restforgejs/mcp-server packages. Defines the canonical
|
|
@@ -28,7 +29,7 @@ RESTForge is a deterministic, definition-first generator with two output tracks:
|
|
|
28
29
|
endpoints. One SDF produces identical DDL; one RDF payload produces an
|
|
29
30
|
identical endpoint module on every execution.
|
|
30
31
|
- **Frontend track** — UDF defines the frontend application. One UDF payload
|
|
31
|
-
produces identical HTML/JS/CSS via `restforge-designer`, plugin-driven,
|
|
32
|
+
produces identical HTML/JS/CSS via `npx restforge-designer`, plugin-driven,
|
|
32
33
|
no build step required.
|
|
33
34
|
|
|
34
35
|
The agent interacts with the platform **exclusively through MCP tools**. The
|
|
@@ -51,6 +52,26 @@ The platform exposes its capabilities as MCP tools grouped by domain: `health_*`
|
|
|
51
52
|
|
|
52
53
|
---
|
|
53
54
|
|
|
55
|
+
## Preflight (run before any RESTForge task)
|
|
56
|
+
|
|
57
|
+
Verify readiness before planning or producing anything:
|
|
58
|
+
|
|
59
|
+
1. **Are the RESTForge MCP tools present?** If `codegen_*` / `designer_*` are not
|
|
60
|
+
in your available tools, the MCP server is **not active**. Stop and tell the
|
|
61
|
+
user to register the RESTForge MCP server and restart the client. Do **not**
|
|
62
|
+
finish the task by hand-reading the bundled `references/` — that bypasses the
|
|
63
|
+
generator and yields slower, non-deterministic output.
|
|
64
|
+
2. **Backend work** → confirm the project and config are ready with
|
|
65
|
+
`runtime_detect_project`, then the `setup_validate_config` gate.
|
|
66
|
+
3. **Frontend work** → the Designer tools pre-check that `npx restforge-designer`
|
|
67
|
+
can run (its binary is bundled in `@restforgejs/platform`, so it is available
|
|
68
|
+
once the project is created with `npx create-restforge-app` / the platform is
|
|
69
|
+
installed); if it cannot run, surface that before proceeding.
|
|
70
|
+
|
|
71
|
+
If a prerequisite is missing, report it as the next step — do not improvise around it.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
54
75
|
## Backend Pipeline (canonical)
|
|
55
76
|
|
|
56
77
|
This is the canonical (golden) path. For state-dependent choices see Decision
|
|
@@ -61,11 +82,18 @@ project, start from the step that matches the current state — do not re-run
|
|
|
61
82
|
earlier steps that already succeeded.
|
|
62
83
|
|
|
63
84
|
```
|
|
64
|
-
1.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
1. npx create-restforge-app <name> ── PRIMARY ── human-run scaffolder
|
|
86
|
+
One shot: creates the project folder, runs
|
|
87
|
+
npm install @restforgejs/platform (local), and bundles the designer
|
|
88
|
+
binary. This is the dominant way to start a new project.
|
|
89
|
+
Granular alternative (agent scaffolds step by step):
|
|
90
|
+
setup_create_folder → create the project folder.
|
|
91
|
+
|
|
92
|
+
2. setup_install_package (granular path only)
|
|
93
|
+
Install @restforgejs/platform into the folder. SKIP when the project
|
|
94
|
+
was created with create-restforge-app (already installed). Plain
|
|
95
|
+
'npm install @restforgejs/platform' stays valid but is not the
|
|
96
|
+
primary entry point.
|
|
69
97
|
|
|
70
98
|
3. setup_init_config
|
|
71
99
|
Write config/db-connection.env from the default template.
|
|
@@ -134,12 +162,9 @@ earlier steps that already succeeded.
|
|
|
134
162
|
Verify the server is running and endpoints are reachable.
|
|
135
163
|
```
|
|
136
164
|
|
|
137
|
-
Two hard checkpoints
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
`setup_validate_config` passes.
|
|
141
|
-
- **Step 17 is where the agent stops.** The agent never starts, stops, or
|
|
142
|
-
restarts the server itself; it only generates the launcher.
|
|
165
|
+
Two hard checkpoints (see Guardrails): **step 5** is a gate — no `codegen_*` call
|
|
166
|
+
before `setup_validate_config` passes; **step 17** is where the agent stops (it
|
|
167
|
+
generates the launcher, never runs the server).
|
|
143
168
|
|
|
144
169
|
---
|
|
145
170
|
|
|
@@ -191,12 +216,9 @@ designer_scaffold_plugin → [develop plugin templates]
|
|
|
191
216
|
→ designer_generate (test generation with the custom plugin)
|
|
192
217
|
```
|
|
193
218
|
|
|
194
|
-
Two checkpoints
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
payload — generation on an invalid payload produces incomplete or broken output.
|
|
198
|
-
- **Step 7 is where the agent stops.** The agent generates files; it does not
|
|
199
|
-
serve, open, or deploy the frontend.
|
|
219
|
+
Two checkpoints (see Guardrails): **step 5** is a gate — never `designer_generate`
|
|
220
|
+
an unvalidated payload; **step 7** is where the agent stops (generates files, does
|
|
221
|
+
not serve or deploy).
|
|
200
222
|
|
|
201
223
|
Licensing note: the Designer tools (`designer_preview_files`, `designer_generate`,
|
|
202
224
|
etc.) do **not** require a RESTForge license, unlike the `codegen_*`, `runtime_*`,
|
|
@@ -204,6 +226,57 @@ and `setup_validate_config` tools on the backend track.
|
|
|
204
226
|
|
|
205
227
|
---
|
|
206
228
|
|
|
229
|
+
## Auth Extension
|
|
230
|
+
|
|
231
|
+
RESTForge has **two different auth mechanisms — do not confuse them.** Pick the
|
|
232
|
+
right one; never describe one as the other, and never claim the extension does RBAC.
|
|
233
|
+
|
|
234
|
+
| Mechanism | RBAC? | How |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| **Plugin auth** — built into the frontend at generation time | **Yes (auth + RBAC)** | `vanilla-js-auth` or `vanilla-js-custom` plugin in `designer_init_project`; disable with `noAuth: true` (`--no-auth`) |
|
|
237
|
+
| **Auth extension** — bolt-on added to an existing project | **No RBAC** | backend `project_auth`; frontend `designer_auth_create` (embedded `rfx_auth`) |
|
|
238
|
+
|
|
239
|
+
Confirm which plugins provide auth with `designer_list_plugins` — do not hardcode
|
|
240
|
+
it. The rest of this section covers the **extension** (the no-RBAC bolt-on); for
|
|
241
|
+
plugin auth see Decision Points § Frontend plugin choice. Google Sign-In and
|
|
242
|
+
`@restforgejs/auth` are out of scope for the extension.
|
|
243
|
+
|
|
244
|
+
### Backend auth — `project_auth`
|
|
245
|
+
|
|
246
|
+
Adds the auth backend to an existing RESTForge project (run the standard backend
|
|
247
|
+
pipeline first; the project and its endpoint must already exist, and the DB must
|
|
248
|
+
be active).
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
project_auth (wraps: npx restforge project auth --create --project=<name>)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Installs auth SDF (`rfx`), DB tables, middleware, router, six processors
|
|
255
|
+
(register/login/refresh/logout/me/reset-password), a random `JWT_SECRET`, and
|
|
256
|
+
`bcrypt`+`jsonwebtoken`. Idempotent. → references/auth.md § Backend
|
|
257
|
+
|
|
258
|
+
### Frontend auth — `designer_auth_create` / `designer_auth_remove`
|
|
259
|
+
|
|
260
|
+
Adds (or removes) an **embedded** login / signup / forget-password overlay
|
|
261
|
+
(`rfx_auth`) on an existing frontend project, at route
|
|
262
|
+
`/api/<project>/rfx_auth`. This is independent of the `vanilla-js-auth` plugin.
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
designer_auth_create (wraps: npx restforge-designer auth --create --project=<name>)
|
|
266
|
+
designer_auth_remove (wraps: npx restforge-designer auth --remove --project=<name> --force)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`create` writes the auth pages + `js/rfx_auth.js` and injects a guard into existing
|
|
270
|
+
pages; `remove` deletes them. Idempotent. Runs via `npx restforge-designer`
|
|
271
|
+
(bundled in `@restforgejs/platform`; available once the project was created with
|
|
272
|
+
`npx create-restforge-app` / the platform is installed).
|
|
273
|
+
→ references/auth.md § Frontend
|
|
274
|
+
|
|
275
|
+
Do not combine the two mechanisms on one app: if an app already has plugin auth
|
|
276
|
+
(`vanilla-js-auth` / `vanilla-js-custom`), do not also add embedded `rfx_auth`.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
207
280
|
## Grounding-First Rules
|
|
208
281
|
|
|
209
282
|
Before reasoning about, proposing, or generating any **definition content** —
|
|
@@ -238,8 +311,10 @@ type, or wrong semantics. Two concrete failure modes this rule prevents:
|
|
|
238
311
|
constraint, not RDF `fieldValidation`. Grounding surfaces this distinction
|
|
239
312
|
before the agent commits to the wrong one.
|
|
240
313
|
|
|
241
|
-
The reference files
|
|
242
|
-
|
|
314
|
+
The reference files help you *understand* the catalog; they do **not** replace
|
|
315
|
+
the tool. Call the tool to ground, produce, and validate — do not hand-produce
|
|
316
|
+
output a tool would generate. The live tool is authoritative; when a reference and
|
|
317
|
+
the tool disagree, trust the tool.
|
|
243
318
|
|
|
244
319
|
---
|
|
245
320
|
|
|
@@ -300,6 +375,17 @@ branch still obeys the Grounding-First Rules above.
|
|
|
300
375
|
- **Master-detail (composite CRUD)** → add `details[]` to the RDF payload;
|
|
301
376
|
generates `/create-composite`, `/update-composite`, `/read-composite`.
|
|
302
377
|
→ references/rdf-advanced.md § Master-Detail
|
|
378
|
+
- **Excel export** → `/export` works by default (falls back to
|
|
379
|
+
`SELECT {fields} FROM tableName`); customise the columns/filter with
|
|
380
|
+
`exportQuery` in the RDF payload. Tune `EXPORT_FILE_EXPIRY` / `EXPORT_CHUNK_SIZE`
|
|
381
|
+
in config. Ground `exportQuery` via `codegen_get_query_declarative_catalog`.
|
|
382
|
+
→ references/rdf-advanced.md § Data Source Resolution
|
|
383
|
+
- **Excel import (.xlsx)** → add `importConfig` (sheet, startRow, strategy,
|
|
384
|
+
upsertKey, columns header→fieldName, optional lookup) to the RDF payload;
|
|
385
|
+
generates `/import-preview` (validates, returns a diff) and `/import-commit`
|
|
386
|
+
(applies). → references/rdf-advanced.md § Import Config
|
|
387
|
+
- Activate on an existing project: edit the payload to add `importConfig`
|
|
388
|
+
(and/or `exportQuery`) → `codegen_validate_payload` → `codegen_create_endpoint`.
|
|
303
389
|
|
|
304
390
|
### Soft-delete vs hard-delete
|
|
305
391
|
|
|
@@ -309,6 +395,31 @@ branch still obeys the Grounding-First Rules above.
|
|
|
309
395
|
- Soft-delete is supported on PostgreSQL only (Phase 1).
|
|
310
396
|
- Tables with composite UNIQUE constraints are incompatible with soft-delete.
|
|
311
397
|
|
|
398
|
+
### Data seeding / migration (rows, not schema)
|
|
399
|
+
|
|
400
|
+
Move table **rows** through SDF-driven envelope files. This is for data, never
|
|
401
|
+
for schema — use the dbschema tools for structure.
|
|
402
|
+
|
|
403
|
+
**Default output location:** `data-storage/<schema>/<table>.json`, relative to the
|
|
404
|
+
project cwd. The `data-storage` folder is the default of the `storagePath` param
|
|
405
|
+
(CLI `--storage-path <folder>`); override it to write elsewhere. The SDF read from
|
|
406
|
+
is `schemaPath` (CLI `--schema-path`, default `schema`).
|
|
407
|
+
|
|
408
|
+
- **Export / dump / snapshot / back up rows** → `data_pull`. Scope is exactly one
|
|
409
|
+
of `table`, `schema`, or `allSchemas`. Only tables registered in the SDF can be
|
|
410
|
+
pulled. `force: true` overwrites existing envelope files. Optional `limit`,
|
|
411
|
+
`batchSize`, `config` (falls back to the default set via `config set-default`,
|
|
412
|
+
i.e. `.restforge/defaults.json`), `schemaPath`, `storagePath`.
|
|
413
|
+
- **Import / load / seed / restore rows** → `data_push`. Same file names as
|
|
414
|
+
`data_pull`, so pulled files push back directly. Scope is exactly one of `table`,
|
|
415
|
+
`schema`, or `allSchemas`; for `schema`/`allSchemas` tables load in FK
|
|
416
|
+
parent→child order.
|
|
417
|
+
- **Move data between databases** → `data_pull` from the source, then `data_push`
|
|
418
|
+
into the target (`config` selects the env per side).
|
|
419
|
+
- ⚠ `data_push` is **APPEND-ONLY** (batch INSERT, no upsert/replace). Running it
|
|
420
|
+
twice inserts the rows twice. Confirm with the user before pushing into a
|
|
421
|
+
database that may already hold those rows.
|
|
422
|
+
|
|
312
423
|
### Frontend page type
|
|
313
424
|
|
|
314
425
|
- **Standard CRUD page** → `pageType: "crud"` (default) with `apiPath`,
|
|
@@ -321,12 +432,25 @@ branch still obeys the Grounding-First Rules above.
|
|
|
321
432
|
|
|
322
433
|
### Frontend plugin choice
|
|
323
434
|
|
|
324
|
-
- **No
|
|
325
|
-
- **
|
|
326
|
-
-
|
|
327
|
-
plugin
|
|
435
|
+
- **No auth** → `vanilla-js-basic`.
|
|
436
|
+
- **Auth WITH RBAC, built into the app** → `vanilla-js-auth` or
|
|
437
|
+
`vanilla-js-custom` at `designer_init_project`. Use `noAuth: true` (`--no-auth`)
|
|
438
|
+
to get the plugin's UI without its auth.
|
|
439
|
+
- **Custom branding / new plugin** → `designer_scaffold_plugin`.
|
|
440
|
+
- **Bolt-on auth WITHOUT RBAC** → not a plugin; see Authentication below.
|
|
328
441
|
→ references/udf-catalog.md § Plugins
|
|
329
442
|
|
|
443
|
+
### Authentication
|
|
444
|
+
|
|
445
|
+
- **Needs RBAC** → plugin auth (`vanilla-js-auth` / `vanilla-js-custom`) at
|
|
446
|
+
`designer_init_project`. The extension below does **not** do RBAC.
|
|
447
|
+
- **Backend auth on an existing project (no RBAC)** → `project_auth` (after the
|
|
448
|
+
project and its endpoint exist, with an active DB).
|
|
449
|
+
- **Frontend auth on an app built WITHOUT plugin auth (no RBAC)** →
|
|
450
|
+
`designer_auth_create` (embedded `rfx_auth`).
|
|
451
|
+
- **Remove embedded frontend auth** → `designer_auth_remove` — destructive,
|
|
452
|
+
confirm first (see Guardrails).
|
|
453
|
+
|
|
330
454
|
---
|
|
331
455
|
|
|
332
456
|
## Guardrails
|
|
@@ -376,6 +500,20 @@ widgets, or UDF content from memory. Call the matching catalog tool first (see
|
|
|
376
500
|
Grounding-First Rules). Inventing an option that "should" exist is the most
|
|
377
501
|
common way to produce confidently wrong output.
|
|
378
502
|
|
|
503
|
+
**7. Confirm before removing embedded auth.**
|
|
504
|
+
`designer_auth_remove` deletes the auth files (`login.html`, `signup.html`, the
|
|
505
|
+
forget-password overlay, `js/rfx_auth.js`) and strips the guard from existing
|
|
506
|
+
pages. Under MCP it runs with `--force` (no interactive prompt), so confirm the
|
|
507
|
+
project name and intent with the user **before** calling it.
|
|
508
|
+
|
|
509
|
+
**8. Execute through tools; never emulate them.** The bundled `references/` help
|
|
510
|
+
you *understand* options — they do not replace the tools. When a tool can produce
|
|
511
|
+
or validate an artifact (`codegen_dbschema_template`/`init`,
|
|
512
|
+
`codegen_generate_payload`, any `*_validate_*`), **call it**; do not hand-write its
|
|
513
|
+
output by reading a reference. Emulating the generator is slower, loses
|
|
514
|
+
determinism, and drifts from what the installed version emits. If the tool is not
|
|
515
|
+
available, stop (see Preflight) rather than improvising from the references.
|
|
516
|
+
|
|
379
517
|
---
|
|
380
518
|
|
|
381
519
|
## Prerequisites and Common Errors
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Reference: Auth Extension
|
|
2
|
+
|
|
3
|
+
> **Offline mirror.** This file mirrors the auth commands of the installed
|
|
4
|
+
> RESTForge platform and Designer (`restforge project auth`, `npx
|
|
5
|
+
> restforge-designer auth`). The live tools/CLI are authoritative — when this file and them disagree,
|
|
6
|
+
> trust the tools, then update this file.
|
|
7
|
+
|
|
8
|
+
**This file documents the auth EXTENSION — auth WITHOUT RBAC.** It is one of two
|
|
9
|
+
distinct auth mechanisms; do not confuse them:
|
|
10
|
+
|
|
11
|
+
| Mechanism | RBAC? | Where |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| **Plugin auth** — built into the frontend at generation | **Yes (auth + RBAC)** | `vanilla-js-auth` / `vanilla-js-custom` plugin, chosen at `designer_init_project`; toggle off with `noAuth: true` (`--no-auth`). See `udf-catalog.md § Plugins`. |
|
|
14
|
+
| **Auth extension** (this file) | **No RBAC** | `project_auth` (backend) + `designer_auth_create` (frontend `rfx_auth`) |
|
|
15
|
+
|
|
16
|
+
The extension is an optional add-on installed into a project that already exists.
|
|
17
|
+
Backend auth and frontend auth are **independent**: install either, both, or
|
|
18
|
+
neither. Both are JWT-based.
|
|
19
|
+
|
|
20
|
+
**Out of scope for the extension:** Google Sign-In, RBAC, and the
|
|
21
|
+
`@restforgejs/auth` package. The embedded frontend flow is independent of the
|
|
22
|
+
`vanilla-js-auth` plugin — if the user needs RBAC, use plugin auth, not this.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Backend
|
|
27
|
+
|
|
28
|
+
MCP tool: `project_auth` — wraps `npx restforge project auth --create`.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
npx restforge project auth --create --project=<name> [options]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Flag | Required | Default | Notes |
|
|
35
|
+
|---|---|---|---|
|
|
36
|
+
| `--create` | yes | `false` | Required trigger; must be present |
|
|
37
|
+
| `--project <name>` | yes* | — | Target project name |
|
|
38
|
+
| `--name <name>` | yes* | — | Alias of `--project` |
|
|
39
|
+
| `--schema-path <dir>` | no | `./schema` | Output folder for auth SDF files |
|
|
40
|
+
| `--config <file>` | no | `config/db-connection.env` | DB config for the migrate step |
|
|
41
|
+
| `--force` | no | `false` | Overwrite existing files (backup still made) |
|
|
42
|
+
|
|
43
|
+
\* one of `--project` / `--name` is required.
|
|
44
|
+
|
|
45
|
+
MCP params: `cwd` (project folder, must contain `node_modules/@restforgejs/platform`),
|
|
46
|
+
`project`, `schemaPath?`, `config?`, `force?`.
|
|
47
|
+
|
|
48
|
+
**What it does (in order):**
|
|
49
|
+
1. Generates auth SDF files (prefix `rfx`) to `--schema-path`.
|
|
50
|
+
2. Creates auth DB tables via dbschema-kit (idempotent, `IF NOT EXISTS`).
|
|
51
|
+
3. Writes auth middleware + router.
|
|
52
|
+
4. Writes six processors: `register`, `login`, `refresh`, `logout`, `me`,
|
|
53
|
+
`reset-password`.
|
|
54
|
+
5. Injects auth env vars (random `JWT_SECRET`) into the config file.
|
|
55
|
+
6. Records `bcrypt` + `jsonwebtoken` as runtime dependencies in the project's
|
|
56
|
+
`package.json`.
|
|
57
|
+
|
|
58
|
+
**Prerequisites:** the project already exists (run `endpoint create` /
|
|
59
|
+
the standard backend pipeline first), `@restforgejs/platform` is installed in the
|
|
60
|
+
project, and the DB is active and reachable with the config credentials.
|
|
61
|
+
|
|
62
|
+
Idempotent (re-runnable). Non-destructive aside from `--force` overwrites, which
|
|
63
|
+
still create a backup.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Frontend
|
|
68
|
+
|
|
69
|
+
Embedded login / signup / forget-password overlay (`rfx_auth`), mounted at route
|
|
70
|
+
`/api/<project>/rfx_auth`. Independent of the `vanilla-js-auth` plugin.
|
|
71
|
+
|
|
72
|
+
MCP tools: `designer_auth_create`, `designer_auth_remove` — wrap
|
|
73
|
+
`npx restforge-designer auth --create | --remove`.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
npx restforge-designer auth --create --project=<name> [options]
|
|
77
|
+
npx restforge-designer auth --remove --project=<name> [--frontend-path <path>] --force
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`--create` and `--remove` are mutually exclusive; exactly one is required.
|
|
81
|
+
|
|
82
|
+
| Flag | Applies to | Default | Notes |
|
|
83
|
+
|---|---|---|---|
|
|
84
|
+
| `--create` | create | — | Install the overlay |
|
|
85
|
+
| `--remove` | remove | — | Uninstall the overlay |
|
|
86
|
+
| `--project <name>` | both | — | App code, localStorage prefix, route `/api/<project>/rfx_auth` |
|
|
87
|
+
| `--frontend-path <path>` | both | `./frontend/apps` | Apps root; target app = `<frontend-path>/<project>` |
|
|
88
|
+
| `--api-base-url <url>` | create | from `app-config.json` | Override backend base URL |
|
|
89
|
+
| `--plugins-dir <dir>` | both | auto-detect | Plugins directory |
|
|
90
|
+
| `--overwrite` | create | `false` | Overwrite existing auth files (+ archive backup) |
|
|
91
|
+
| `--force` | remove | `false` | Skip the y/N removal prompt |
|
|
92
|
+
|
|
93
|
+
MCP params — `designer_auth_create`: `cwd`, `project`, `frontendPath?`,
|
|
94
|
+
`apiBaseUrl?`, `overwrite?`. `designer_auth_remove`: `cwd`, `project`,
|
|
95
|
+
`frontendPath?` (the MCP tool always passes `--force`).
|
|
96
|
+
|
|
97
|
+
**`--create` does (in order):**
|
|
98
|
+
1. Renders `login.html`, `signup.html`, the forget-password overlay, and
|
|
99
|
+
`js/rfx_auth.js` from embedded templates (no Google Sign-In).
|
|
100
|
+
2. Writes the artifacts to `<frontend-path>/<project>/`.
|
|
101
|
+
3. Injects an auth guard `<script src="js/rfx_auth.js">` into all existing
|
|
102
|
+
`*.html` pages in the target dir (except `login.html` / `signup.html`).
|
|
103
|
+
4. Writes the `embeddedAuth` marker to `payload/app-config.json` (non-destructive;
|
|
104
|
+
other keys untouched).
|
|
105
|
+
|
|
106
|
+
If no app pages exist yet, guard injection is skipped with a warning; the guard is
|
|
107
|
+
injected automatically when `designer_generate` creates pages later.
|
|
108
|
+
|
|
109
|
+
**`--remove` does (in order):**
|
|
110
|
+
1. Detects whether auth is installed (files + `embeddedAuth` marker).
|
|
111
|
+
2. Deletes `login.html`, `signup.html`, the forget-password overlay,
|
|
112
|
+
`js/rfx_auth.js`.
|
|
113
|
+
3. Strips the auth guard from all `*.html` pages (other content untouched).
|
|
114
|
+
4. Removes the `embeddedAuth` key from `payload/app-config.json` (other keys kept).
|
|
115
|
+
|
|
116
|
+
**Prerequisites:** the Designer is invoked via `npx restforge-designer` and is
|
|
117
|
+
bundled inside the `@restforgejs/platform` package; the prerequisite is that
|
|
118
|
+
`@restforgejs/platform` is installed in the project (e.g. a project created with
|
|
119
|
+
`npx create-restforge-app`), not a standalone binary on PATH.
|
|
120
|
+
|
|
121
|
+
Both are idempotent. **`--remove` is destructive** — confirm project name and
|
|
122
|
+
intent with the user before running (MCP always passes `--force`).
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Two frontend auth approaches — do not combine
|
|
127
|
+
|
|
128
|
+
| Approach | RBAC? | When | How |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| Plugin auth (`vanilla-js-auth`, `vanilla-js-custom`) | **Yes (auth + RBAC)** | A new app that needs auth/RBAC | Choose the plugin in `designer_init_project`; auth is built in at generation. Disable with `noAuth: true` (`--no-auth`) |
|
|
131
|
+
| Embedded `rfx_auth` | **No RBAC** | An existing app generated WITHOUT plugin auth | `designer_auth_create` bolts auth on |
|
|
132
|
+
|
|
133
|
+
Do not add `rfx_auth` to an app already built with plugin auth — they are two
|
|
134
|
+
separate mechanisms. If the user needs RBAC, only plugin auth provides it.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Common errors
|
|
139
|
+
|
|
140
|
+
| Symptom | Cause | Recovery |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| Backend: "package not installed" precondition | `@restforgejs/platform` missing in the project | Install the package, then re-run |
|
|
143
|
+
| Backend: project does not exist / DB not reachable | Auth runs against an existing project + live DB | Create the project + endpoints first; verify DB config |
|
|
144
|
+
| Frontend: Designer (`npx restforge-designer`) cannot run | `@restforgejs/platform` (which bundles the Designer) missing in the project | Install `@restforgejs/platform` in the project (e.g. via `npx create-restforge-app`), then re-run |
|
|
145
|
+
| Frontend: files already exist, not overwritten | Auth already installed | Use `--overwrite` (create) only if you intend to replace |
|
|
@@ -471,14 +471,21 @@ an event over the WebSocket channel.
|
|
|
471
471
|
|
|
472
472
|
## Plugins
|
|
473
473
|
|
|
474
|
-
|
|
474
|
+
Built-in plugins. Run `designer_list_plugins` to confirm what the installed
|
|
475
|
+
version provides — do not hardcode this list.
|
|
475
476
|
|
|
476
477
|
| Plugin | Auth | Notes |
|
|
477
478
|
|---|---|---|
|
|
478
479
|
| `vanilla-js-basic` | None | Standard CRUD app, no login flow |
|
|
479
|
-
| `vanilla-js-auth` |
|
|
480
|
+
| `vanilla-js-auth` | Auth + RBAC | Login page, token refresh, role-based access |
|
|
481
|
+
| `vanilla-js-custom` | Auth + RBAC | Customisable markup/CSS/JS; auth + RBAC capable (confirm via `designer_list_plugins`) |
|
|
480
482
|
|
|
481
|
-
|
|
483
|
+
Plugin auth is built into the app at generation time. Disable it with
|
|
484
|
+
`noAuth: true` (`--no-auth`) on `designer_init_project` to get the plugin's UI
|
|
485
|
+
without auth. **Plugin auth (with RBAC) is distinct from the embedded `rfx_auth`
|
|
486
|
+
extension** (`designer_auth_create`, no RBAC) — see references/auth.md.
|
|
487
|
+
|
|
488
|
+
`vanilla-js-auth` accepts additional `appConfig` / init properties:
|
|
482
489
|
- `authAppCode` — must match the backend auth module's app code
|
|
483
490
|
- `idleTimeout` — auto-logout after inactivity (seconds)
|
|
484
491
|
|