Skip to content

Commit c9a1ac9

Browse files
authored
Merge pull request #610 from objectstack-ai/copilot/add-development-mode-plugin
2 parents 9010d99 + 09dcbce commit c9a1ac9

11 files changed

Lines changed: 1788 additions & 0 deletions

File tree

.changeset/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@objectstack/plugin-auth",
2020
"@objectstack/plugin-hono-server",
2121
"@objectstack/plugin-msw",
22+
"@objectstack/plugin-dev",
2223
"@objectstack/plugin-security",
2324
"@objectstack/hono",
2425
"@objectstack/nestjs",
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# @objectstack/plugin-dev
2+
3+
> Development Mode Plugin for ObjectStack — auto-enables **all 17+ kernel services** for a full-featured API development environment.
4+
5+
## Overview
6+
7+
Instead of manually wiring up ObjectQL, drivers, auth, HTTP server, REST endpoints, dispatcher, security, and metadata for local development, use `DevPlugin` to get a fully functional stack in one line.
8+
9+
The dev environment simulates **all kernel services** so you can:
10+
- CRUD business objects via REST API
11+
- Read, modify, and save views/apps/dashboards via metadata API (`PUT /api/v1/meta/:type/:name`)
12+
- Use GraphQL, analytics, storage, and automation endpoints
13+
- Authenticate with dev credentials (no real auth provider needed)
14+
- Test UI permissions, workflows, and notifications with dev stubs
15+
16+
## Usage
17+
18+
### Zero-config
19+
20+
```typescript
21+
import { defineStack } from '@objectstack/spec';
22+
import { DevPlugin } from '@objectstack/plugin-dev';
23+
24+
export default defineStack({
25+
manifest: {
26+
id: 'com.example.myapp',
27+
name: 'My App',
28+
version: '0.1.0',
29+
type: 'app',
30+
},
31+
plugins: [new DevPlugin()],
32+
});
33+
```
34+
35+
### Full-stack dev with project metadata
36+
37+
```typescript
38+
import config from './objectstack.config';
39+
import { DevPlugin } from '@objectstack/plugin-dev';
40+
41+
// Load all project metadata (objects, views, etc.) into the dev server
42+
export default defineStack({
43+
...config,
44+
plugins: [new DevPlugin({ stack: config })],
45+
});
46+
```
47+
48+
### With options
49+
50+
```typescript
51+
plugins: [
52+
new DevPlugin({
53+
port: 4000,
54+
seedAdminUser: true,
55+
services: {
56+
auth: false, // Skip auth for quick prototyping
57+
dispatcher: false, // Skip extended API routes
58+
},
59+
}),
60+
]
61+
```
62+
63+
## What it auto-configures
64+
65+
### Real plugin implementations
66+
67+
| Service | Package | Description |
68+
|---------|---------|-------------|
69+
| ObjectQL | `@objectstack/objectql` | Data engine (query, CRUD, hooks, metadata) |
70+
| InMemoryDriver | `@objectstack/driver-memory` | In-memory database (no DB install) |
71+
| App/Metadata | `@objectstack/runtime` | Project metadata (objects, views, apps, dashboards) |
72+
| Auth | `@objectstack/plugin-auth` | Authentication with dev credentials |
73+
| Security | `@objectstack/plugin-security` | RBAC, RLS, field-level masking |
74+
| Hono Server | `@objectstack/plugin-hono-server` | HTTP server on configured port |
75+
| REST API | `@objectstack/rest` | Auto-generated CRUD + metadata endpoints |
76+
| Dispatcher | `@objectstack/runtime` | Auth routes, GraphQL, analytics, packages, storage |
77+
78+
### Dev stubs (in-memory / no-op)
79+
80+
Any core kernel service not provided by a real plugin is automatically registered as a dev stub. This ensures the **full kernel service map** is populated and features like UI permissions, automation, etc. don't crash:
81+
82+
`cache`, `queue`, `job`, `file-storage`, `search`, `automation`, `graphql`, `analytics`, `realtime`, `notification`, `ai`, `i18n`, `ui`, `workflow`, `security.permissions`, `security.rls`, `security.fieldMasker`
83+
84+
All services are **optional** — if a peer package isn't installed, it is silently skipped and a stub takes its place.
85+
86+
## API Endpoints (when all services enabled)
87+
88+
| Endpoint | Description |
89+
|----------|-------------|
90+
| `GET /api/v1/data/:object` | List records |
91+
| `POST /api/v1/data/:object` | Create record |
92+
| `GET /api/v1/data/:object/:id` | Get record |
93+
| `PUT /api/v1/data/:object/:id` | Update record |
94+
| `DELETE /api/v1/data/:object/:id` | Delete record |
95+
| `GET /api/v1/meta` | List metadata types |
96+
| `GET /api/v1/meta/:type` | List metadata of type |
97+
| `GET /api/v1/meta/:type/:name` | Get metadata item |
98+
| `PUT /api/v1/meta/:type/:name` | Save metadata item |
99+
| `POST /api/v1/graphql` | GraphQL endpoint |
100+
| `GET /.well-known/objectstack` | Service discovery |
101+
102+
## Options
103+
104+
| Option | Type | Default | Description |
105+
|--------|------|---------|-------------|
106+
| `port` | `number` | `3000` | HTTP server port |
107+
| `seedAdminUser` | `boolean` | `true` | Create `admin@dev.local` on startup |
108+
| `authSecret` | `string` | dev default | JWT secret for auth sessions |
109+
| `authBaseUrl` | `string` | `http://localhost:{port}` | Auth callback URL |
110+
| `verbose` | `boolean` | `true` | Enable verbose logging |
111+
| `services` | `Record<string, boolean>` | all `true` | Enable/disable individual services |
112+
| `extraPlugins` | `Plugin[]` | `[]` | Additional plugins to load |
113+
| `stack` | `object` || Stack definition to load as project metadata |
114+
115+
## License
116+
117+
Apache-2.0
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "@objectstack/plugin-dev",
3+
"version": "2.0.6",
4+
"license": "Apache-2.0",
5+
"description": "Development Mode Plugin for ObjectStack — auto-enables all services with in-memory implementations",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.mjs",
12+
"require": "./dist/index.js"
13+
}
14+
},
15+
"scripts": {
16+
"build": "tsup --config ../../../tsup.config.ts",
17+
"test": "vitest run"
18+
},
19+
"dependencies": {
20+
"@objectstack/core": "workspace:*",
21+
"@objectstack/spec": "workspace:*"
22+
},
23+
"peerDependencies": {
24+
"@objectstack/driver-memory": "workspace:*",
25+
"@objectstack/objectql": "workspace:*",
26+
"@objectstack/runtime": "workspace:*",
27+
"@objectstack/plugin-auth": "workspace:*",
28+
"@objectstack/plugin-hono-server": "workspace:*",
29+
"@objectstack/plugin-security": "workspace:*",
30+
"@objectstack/rest": "workspace:*"
31+
},
32+
"peerDependenciesMeta": {
33+
"@objectstack/driver-memory": { "optional": true },
34+
"@objectstack/objectql": { "optional": true },
35+
"@objectstack/runtime": { "optional": true },
36+
"@objectstack/plugin-auth": { "optional": true },
37+
"@objectstack/plugin-hono-server": { "optional": true },
38+
"@objectstack/plugin-security": { "optional": true },
39+
"@objectstack/rest": { "optional": true }
40+
},
41+
"devDependencies": {
42+
"@objectstack/driver-memory": "workspace:*",
43+
"@objectstack/objectql": "workspace:*",
44+
"@objectstack/runtime": "workspace:*",
45+
"@objectstack/plugin-auth": "workspace:*",
46+
"@objectstack/plugin-hono-server": "workspace:*",
47+
"@objectstack/plugin-security": "workspace:*",
48+
"@objectstack/rest": "workspace:*",
49+
"@types/node": "^25.2.2",
50+
"typescript": "^5.0.0",
51+
"vitest": "^4.0.18"
52+
}
53+
}

0 commit comments

Comments
 (0)