|
| 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 |
0 commit comments