|
| 1 | +# @objectstack/plugin-setup |
| 2 | + |
| 3 | +Setup Plugin for ObjectStack — owns and composes the platform **Setup App** with area-based navigation. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Setup App is the central administration interface of the ObjectStack platform (equivalent to Salesforce Setup or ServiceNow System Administration). Rather than scattering setup definitions across `spec` and `objectql`, this plugin provides clear ownership: |
| 8 | + |
| 9 | +- **Spec** → protocol schemas only |
| 10 | +- **ObjectQL** → data engine only |
| 11 | +- **plugin-setup** → owns the Setup App identity, areas, and navigation composition |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Four Built-in Areas**: Administration, Platform, System, and AI — shipped as empty skeletons. |
| 16 | +- **Contribution Model**: Any plugin can contribute navigation items to Setup areas via the `setupNav` service. |
| 17 | +- **Area Filtering**: Empty areas are automatically filtered out at finalization. |
| 18 | +- **Custom Areas**: Plugins can contribute to custom area IDs beyond the four built-in ones. |
| 19 | +- **I18n Labels**: All labels use the `I18nLabel` union type for internationalization. |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +### Register the Plugin |
| 24 | + |
| 25 | +```typescript |
| 26 | +import { ObjectKernel } from '@objectstack/core'; |
| 27 | +import { SetupPlugin } from '@objectstack/plugin-setup'; |
| 28 | + |
| 29 | +const kernel = new ObjectKernel({ |
| 30 | + plugins: [ |
| 31 | + new SetupPlugin(), |
| 32 | + // ... other plugins |
| 33 | + ], |
| 34 | +}); |
| 35 | +``` |
| 36 | + |
| 37 | +### Contribute Navigation from Another Plugin |
| 38 | + |
| 39 | +```typescript |
| 40 | +import type { Plugin, PluginContext } from '@objectstack/core'; |
| 41 | +import type { SetupNavService } from '@objectstack/plugin-setup'; |
| 42 | +import { SETUP_AREA_IDS } from '@objectstack/plugin-setup'; |
| 43 | + |
| 44 | +export class MyPlugin implements Plugin { |
| 45 | + name = 'com.example.my-plugin'; |
| 46 | + |
| 47 | + async init(ctx: PluginContext) { |
| 48 | + const setupNav = ctx.getService<SetupNavService>('setupNav'); |
| 49 | + |
| 50 | + setupNav.contribute({ |
| 51 | + areaId: SETUP_AREA_IDS.administration, |
| 52 | + items: [ |
| 53 | + { id: 'nav_users', type: 'object', label: 'Users', objectName: 'sys_user' }, |
| 54 | + { id: 'nav_roles', type: 'object', label: 'Roles', objectName: 'sys_role' }, |
| 55 | + ], |
| 56 | + }); |
| 57 | + } |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +### Exported Components |
| 62 | + |
| 63 | +```typescript |
| 64 | +import { |
| 65 | + SetupPlugin, |
| 66 | + type SetupNavService, |
| 67 | + SETUP_APP_DEFAULTS, |
| 68 | + type SetupNavContribution, |
| 69 | + SETUP_AREAS, |
| 70 | + SETUP_AREA_IDS, |
| 71 | + type SetupAreaId, |
| 72 | +} from '@objectstack/plugin-setup'; |
| 73 | +``` |
| 74 | + |
| 75 | +## Built-in Setup Areas |
| 76 | + |
| 77 | +| Area | ID | Icon | Order | Description | |
| 78 | +|:-----|:---|:-----|:-----:|:------------| |
| 79 | +| Administration | `area_administration` | shield | 10 | Users, roles, permissions, security | |
| 80 | +| Platform | `area_platform` | layers | 20 | Objects, fields, layouts, automation | |
| 81 | +| System | `area_system` | settings | 30 | Datasources, integrations, jobs, logs | |
| 82 | +| AI | `area_ai` | brain | 40 | Agents, models, RAG pipelines | |
| 83 | + |
| 84 | +## Architecture |
| 85 | + |
| 86 | +``` |
| 87 | +┌──────────────────────────────────────────┐ |
| 88 | +│ SetupPlugin │ |
| 89 | +│ │ |
| 90 | +│ init(): │ |
| 91 | +│ → registers 'setupNav' service │ |
| 92 | +│ │ |
| 93 | +│ start(): │ |
| 94 | +│ → collects contributions │ |
| 95 | +│ → merges into area skeletons │ |
| 96 | +│ → filters empty areas │ |
| 97 | +│ → registers finalized Setup App │ |
| 98 | +│ │ |
| 99 | +└──────────────────────────────────────────┘ |
| 100 | + ▲ ▲ |
| 101 | + │ contribute() │ contribute() |
| 102 | + ┌────┴────┐ ┌────┴────┐ |
| 103 | + │ plugin │ │ plugin │ |
| 104 | + │ auth │ │security │ |
| 105 | + └─────────┘ └─────────┘ |
| 106 | +``` |
| 107 | + |
| 108 | +## License |
| 109 | + |
| 110 | +Apache-2.0 © ObjectStack |
0 commit comments