@mantajs/core 0.2.0-beta.1 → 0.2.0-beta.11
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/dist/adapters/file-memory.d.ts +2 -5
- package/dist/adapters/file-memory.d.ts.map +1 -1
- package/dist/adapters/file-memory.js +1 -1
- package/dist/adapters/file-memory.js.map +1 -1
- package/dist/config/types.d.ts +36 -16
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +4 -2
- package/dist/config/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ports/file.d.ts +9 -5
- package/dist/ports/file.d.ts.map +1 -1
- package/dist/ports/index.d.ts +1 -1
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/query/define-query.d.ts +17 -1
- package/dist/query/define-query.d.ts.map +1 -1
- package/dist/query/define-query.js.map +1 -1
- package/dist/query/index.d.ts.map +1 -1
- package/dist/query/index.js +7 -1
- package/dist/query/index.js.map +1 -1
- package/dist/service/define.d.ts +9 -1
- package/dist/service/define.d.ts.map +1 -1
- package/dist/service/define.js.map +1 -1
- package/dist/service/instantiate.d.ts +7 -1
- package/dist/service/instantiate.d.ts.map +1 -1
- package/dist/service/instantiate.js +9 -2
- package/dist/service/instantiate.js.map +1 -1
- package/dist/user/auto-routes.d.ts +6 -0
- package/dist/user/auto-routes.d.ts.map +1 -1
- package/dist/user/auto-routes.js +70 -8
- package/dist/user/auto-routes.js.map +1 -1
- package/docs/00-overview.md +9 -10
- package/docs/01-getting-started.md +26 -29
- package/docs/03-services.md +23 -5
- package/docs/04-users.md +47 -3
- package/docs/05-commands.md +1 -1
- package/docs/06-queries.md +54 -23
- package/docs/10-spa.md +63 -1
- package/docs/11-config.md +158 -39
- package/docs/14-adapters.md +52 -2
- package/docs/15-hosts.md +17 -2
- package/docs/16-reference.md +32 -3
- package/docs/17-dashboard.md +4 -2
- package/docs/AGENT.md +51 -4
- package/package.json +5 -3
- package/skills/mantajs/SKILL.md +67 -0
- package/skills/mantajs/agents/openai.yaml +3 -0
package/docs/16-reference.md
CHANGED
|
@@ -58,7 +58,7 @@ function defineLink(
|
|
|
58
58
|
): ResolvedLink
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
### defineContext(config)
|
|
61
|
+
### defineContext(config) — legacy
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
function defineContext(config: {
|
|
@@ -71,12 +71,32 @@ function defineContext(config: {
|
|
|
71
71
|
}): ContextDefinition
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
`defineContext()` is kept for legacy compatibility. New Manta apps should use filesystem contexts: `src/commands/{context}/` and `src/queries/{context}/` map to `/api/{context}/...`.
|
|
75
|
+
|
|
74
76
|
### defineConfig(config?)
|
|
75
77
|
|
|
76
78
|
```typescript
|
|
77
79
|
function defineConfig(config?: Partial<MantaConfig>): MantaConfig
|
|
78
80
|
```
|
|
79
81
|
|
|
82
|
+
Common SPA config shape:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
type SpaConfig = {
|
|
86
|
+
dashboard?: string | null // default: '@mantajs/dashboard'; null disables the shell
|
|
87
|
+
preset?: string | null // default: '@mantajs/ui'; null disables the preset
|
|
88
|
+
mountPath?: string | null // default: /{spaName}; use '/' for root-mounted SPA
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
export default defineConfig({
|
|
94
|
+
spa: {
|
|
95
|
+
admin: { mountPath: '/' },
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
80
100
|
## Helpers
|
|
81
101
|
|
|
82
102
|
### field property types
|
|
@@ -102,7 +122,7 @@ Modifiers: `.nullable()`, `.unique()`, `.indexed()`, `.searchable()`, `.default(
|
|
|
102
122
|
function many(entity: DmlEntity): Many<DmlEntity>
|
|
103
123
|
```
|
|
104
124
|
|
|
105
|
-
Cardinality modifier for `defineLink()`. See [Links](./
|
|
125
|
+
Cardinality modifier for `defineLink()`. See [Links](./08-links.md).
|
|
106
126
|
|
|
107
127
|
### Globals
|
|
108
128
|
|
|
@@ -111,7 +131,8 @@ All `define*` functions and helpers are globals — zero imports needed:
|
|
|
111
131
|
| Global | Purpose |
|
|
112
132
|
|--------|---------|
|
|
113
133
|
| `defineModel`, `defineService`, `defineLink`, `defineCommand` | Core primitives |
|
|
114
|
-
| `defineAgent`, `defineSubscriber`, `defineJob
|
|
134
|
+
| `defineAgent`, `defineSubscriber`, `defineJob` | Extended primitives |
|
|
135
|
+
| `defineContext` | Legacy context primitive; prefer filesystem contexts |
|
|
115
136
|
| `defineConfig` | Configuration |
|
|
116
137
|
| `field` | Property type factory |
|
|
117
138
|
| `many` | Cardinality modifier |
|
|
@@ -137,6 +158,14 @@ function makeIdempotent<T>(
|
|
|
137
158
|
): (event: Message<T>) => Promise<void>
|
|
138
159
|
```
|
|
139
160
|
|
|
161
|
+
### ICachePort production adapters
|
|
162
|
+
|
|
163
|
+
| Adapter | Package path | Notes |
|
|
164
|
+
| --- | --- | --- |
|
|
165
|
+
| Upstash Redis | `@mantajs/adapter-cache-upstash` | Default production cache for Vercel/Cloudflare presets |
|
|
166
|
+
| Postgres | `@mantajs/adapter-database-pg/cache` | Durable DB-backed fallback for auth revocation/session state |
|
|
167
|
+
| In-memory | `InMemoryCacheAdapter` | Dev/test only; not durable across instances |
|
|
168
|
+
|
|
140
169
|
## step API
|
|
141
170
|
|
|
142
171
|
Used inside `defineCommand({ workflow: (input, { step }) => {...} })`:
|
package/docs/17-dashboard.md
CHANGED
|
@@ -51,6 +51,8 @@ src/spa/admin/
|
|
|
51
51
|
|
|
52
52
|
**`.ts` not `.tsx`** — pages export `definePage()` or `defineForm()` specs (pure data), not JSX. Only files in `blocks/` and `components/` are `.tsx`.
|
|
53
53
|
|
|
54
|
+
**Mount path is project config, not page config.** A SPA named `admin` defaults to `/admin`. For a dedicated admin subdomain, set `spa.admin.mountPath = "/"` in `manta.config.ts`; page routes and navigation items remain SPA-local (`/products`, `/dashboard`, etc.).
|
|
55
|
+
|
|
54
56
|
---
|
|
55
57
|
|
|
56
58
|
## defineSpa()
|
|
@@ -141,7 +143,7 @@ export default definePage({
|
|
|
141
143
|
{ key: 'created_at', label: 'Created', format: 'date' },
|
|
142
144
|
],
|
|
143
145
|
searchable: ['title'],
|
|
144
|
-
navigateTo: '/
|
|
146
|
+
navigateTo: '/products/:id',
|
|
145
147
|
},
|
|
146
148
|
],
|
|
147
149
|
})
|
|
@@ -564,7 +566,7 @@ header: {
|
|
|
564
566
|
actions: [
|
|
565
567
|
'create',
|
|
566
568
|
{ label: 'Export', command: 'export-products' },
|
|
567
|
-
{ label: 'Import', to: '/
|
|
569
|
+
{ label: 'Import', to: '/products/import' },
|
|
568
570
|
],
|
|
569
571
|
}
|
|
570
572
|
```
|
package/docs/AGENT.md
CHANGED
|
@@ -350,7 +350,7 @@ Tables: `admin_user`, `admin_invite`
|
|
|
350
350
|
|
|
351
351
|
Auth routes (on `/api/admin/`):
|
|
352
352
|
- `POST /login` (public) — returns JWT with `{ id, type: 'admin' }`
|
|
353
|
-
- `DELETE /logout` (public) —
|
|
353
|
+
- `DELETE /logout` (public) — clears auth cookies and attempts server-side token revocation
|
|
354
354
|
- `POST /refresh` (public) — refresh token
|
|
355
355
|
- `POST /forgot-password` (public) — reset flow
|
|
356
356
|
- `POST /reset-password` (public) — confirm reset
|
|
@@ -362,7 +362,9 @@ Protected routes (JWT required, `type === 'admin'`):
|
|
|
362
362
|
- `POST /create-user`, `POST /update-user`, `POST /delete-user`
|
|
363
363
|
- `POST /create-invite`, `POST /refresh-invite`
|
|
364
364
|
|
|
365
|
-
Middleware: all `/api/admin/*` routes verify JWT
|
|
365
|
+
Middleware: all `/api/admin/*` routes verify JWT, reject cache-blacklisted identities when cache is reachable, then require `type === 'admin'`
|
|
366
|
+
|
|
367
|
+
Production auth requires a durable `ICachePort` for logout/reset/session revocation. Default production presets use `@mantajs/adapter-cache-upstash`; use `@mantajs/adapter-database-pg/cache` when Postgres should be the durable cache backend.
|
|
366
368
|
|
|
367
369
|
Override: create `src/commands/admin/login.ts` to replace auto-generated login.
|
|
368
370
|
Override: create `src/middleware/admin.ts` to replace auto-generated middleware.
|
|
@@ -396,7 +398,13 @@ src/spa/admin/
|
|
|
396
398
|
└── page.tsx # → /admin/products
|
|
397
399
|
```
|
|
398
400
|
|
|
399
|
-
Defaults: `@mantajs/dashboard` (shell) + `@mantajs/ui` (preset).
|
|
401
|
+
Defaults: `@mantajs/dashboard` (shell) + `@mantajs/ui` (preset). The generated Vite entry imports the dashboard CSS through the package export:
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
import '@mantajs/dashboard/index.css'
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Override in config:
|
|
400
408
|
|
|
401
409
|
```typescript
|
|
402
410
|
// manta.config.ts
|
|
@@ -408,6 +416,42 @@ export default defineConfig({
|
|
|
408
416
|
})
|
|
409
417
|
```
|
|
410
418
|
|
|
419
|
+
Mount paths:
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
export default defineConfig({
|
|
423
|
+
spa: {
|
|
424
|
+
admin: {}, // default: /admin
|
|
425
|
+
// admin: { mountPath: '/' } // root mount for admin.example.com
|
|
426
|
+
},
|
|
427
|
+
})
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
When `mountPath` is `/`, generated Vercel rewrites exclude `/api/*` so API routes remain server-side.
|
|
431
|
+
|
|
432
|
+
Dev Vite ports:
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
export default defineConfig({
|
|
436
|
+
spa: {
|
|
437
|
+
admin: {
|
|
438
|
+
vitePort: 5310, // default starts at 5200
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
})
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Temporary local overrides also work:
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
MANTA_VITE_PORT=5310 manta dev
|
|
448
|
+
MANTA_VITE_PORT_ADMIN=5311 manta dev
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
`manta build` writes a SPA fallback manifest. With the Node preset, `manta start` mirrors Vercel SPA fallback behavior locally: root/login auth shortcuts redirect under the single SPA mount path, SPA subroutes serve `index.html`, and `/api/*` remains server-side.
|
|
452
|
+
|
|
453
|
+
`manta build --preset vercel` preserves existing custom `vercel.json` project settings such as `buildCommand`, `installCommand`, `outputDirectory`, `functions`, `headers`, plus custom redirects/rewrites/crons that do not collide with framework-generated SPA or cron entries.
|
|
454
|
+
|
|
411
455
|
### SDK — Frontend hooks
|
|
412
456
|
|
|
413
457
|
```typescript
|
|
@@ -497,5 +541,8 @@ Complete framework documentation is in `node_modules/@mantajs/core/docs/`:
|
|
|
497
541
|
| [14-adapters](node_modules/@mantajs/core/docs/14-adapters.md) | Custom adapters |
|
|
498
542
|
| [15-hosts](node_modules/@mantajs/core/docs/15-hosts.md) | Custom hosts |
|
|
499
543
|
| [16-reference](node_modules/@mantajs/core/docs/16-reference.md) | API reference |
|
|
544
|
+
| [17-dashboard](node_modules/@mantajs/core/docs/17-dashboard.md) | Dashboard specs, pages, forms, blocks |
|
|
545
|
+
|
|
546
|
+
Projects generated by `manta init` include `.codex/skills/mantajs/SKILL.md` and `.claude/skills/mantajs/SKILL.md`. `manta dev` refreshes both from `@mantajs/core/skills/mantajs/SKILL.md` so Codex and Claude keep pointing at this same docs directory.
|
|
500
547
|
|
|
501
|
-
**Read the relevant doc BEFORE writing code.** When in doubt, check [
|
|
548
|
+
**Read the relevant doc BEFORE writing code.** When in doubt, check [05-commands.md](node_modules/@mantajs/core/docs/05-commands.md) for workflow patterns.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantajs/core",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"default": "./dist/testing/relational-query-suite.js"
|
|
37
37
|
},
|
|
38
38
|
"./package.json": "./package.json",
|
|
39
|
-
"./docs/*": "./docs/*"
|
|
39
|
+
"./docs/*": "./docs/*",
|
|
40
|
+
"./skills/*": "./skills/*"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"drizzle-orm": "^0.35.0",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
},
|
|
52
53
|
"files": [
|
|
53
54
|
"dist",
|
|
54
|
-
"docs"
|
|
55
|
+
"docs",
|
|
56
|
+
"skills"
|
|
55
57
|
]
|
|
56
58
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mantajs
|
|
3
|
+
description: Use when working inside a Manta/Mantajs project: creating models, services, commands, queries, workflows, dashboards/SPAs, adapters, plugins, hosts, tests, or deployment config. Loads the canonical framework documentation shipped by @mantajs/core.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Mantajs
|
|
7
|
+
|
|
8
|
+
Before changing Manta code in an application, read the project root `AGENT.md` if it exists. It contains project-specific conventions plus links to the framework docs.
|
|
9
|
+
|
|
10
|
+
The canonical framework documentation is shipped with `@mantajs/core`:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
node_modules/@mantajs/core/docs/
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If this skill was installed or refreshed by the Manta CLI, it should live at:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
.codex/skills/mantajs/SKILL.md
|
|
20
|
+
.claude/skills/mantajs/SKILL.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`manta init` writes the skill for new projects. `manta dev` refreshes it for existing projects so it stays aligned with the installed `@mantajs/core` docs.
|
|
24
|
+
|
|
25
|
+
## Workflow
|
|
26
|
+
|
|
27
|
+
1. Identify the primitive or area involved.
|
|
28
|
+
2. Read only the matching doc file from `node_modules/@mantajs/core/docs/`.
|
|
29
|
+
3. Follow the existing project structure and generated `AGENT.md`.
|
|
30
|
+
4. Prefer Manta primitives over hand-written routes or custom framework glue.
|
|
31
|
+
|
|
32
|
+
## Doc Map
|
|
33
|
+
|
|
34
|
+
| Need | Read |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| Mental model, project structure | `00-overview.md` |
|
|
37
|
+
| First project or scaffolded layout | `01-getting-started.md` |
|
|
38
|
+
| Entities and fields | `02-models.md` |
|
|
39
|
+
| Services and repositories | `03-services.md` |
|
|
40
|
+
| Users, auth, sessions | `04-users.md` |
|
|
41
|
+
| Commands, workflows, long-running runs | `05-commands.md` |
|
|
42
|
+
| Queries and external query graph | `06-queries.md` |
|
|
43
|
+
| Events, jobs, workflows | `07-events.md` |
|
|
44
|
+
| Links and relations | `08-links.md` |
|
|
45
|
+
| AI agents and typed LLM steps | `09-agents.md` |
|
|
46
|
+
| SPA generation, dashboard mount path, SDK | `10-spa.md` |
|
|
47
|
+
| `defineConfig`, CLI, presets, release config | `11-config.md` |
|
|
48
|
+
| Constraints and validation rules | `12-constraints.md` |
|
|
49
|
+
| Tests and conformance suites | `13-testing.md` |
|
|
50
|
+
| Adapter authoring | `14-adapters.md` |
|
|
51
|
+
| Host authoring and production bootstrap | `15-hosts.md` |
|
|
52
|
+
| API surface reference | `16-reference.md` |
|
|
53
|
+
| Dashboard specs, pages, forms, blocks | `17-dashboard.md` |
|
|
54
|
+
|
|
55
|
+
## Current SPA Rules
|
|
56
|
+
|
|
57
|
+
- Standalone/Nitro SPAs live in `src/spa/{name}/`.
|
|
58
|
+
- The default mount path is `/{name}`; set `spa.{name}.mountPath = "/"` in `manta.config.ts` for a root-mounted SPA on a dedicated subdomain.
|
|
59
|
+
- `@mantajs/dashboard/index.css` is the public dashboard stylesheet export.
|
|
60
|
+
- Root-mounted SPAs must not capture `/api/*`; keep API routes under `/api`.
|
|
61
|
+
|
|
62
|
+
## Hard Rules
|
|
63
|
+
|
|
64
|
+
- Do not create ad hoc API routes for business behavior; use `defineCommand()` or `defineQuery()`.
|
|
65
|
+
- Do not bypass generated services for simple entity writes.
|
|
66
|
+
- Keep module entities/services together under `src/modules/{module}/entities/{entity}/`.
|
|
67
|
+
- Read the relevant doc before inventing a new pattern.
|