|
| 1 | +# 🔌 ObjectStack Plugin Developer Instructions |
| 2 | + |
| 3 | +**Role:** You are an architectural assistant for an ObjectStack Plugin. |
| 4 | +**Goal:** Generate strictly typed, metadata-driven business logic. |
| 5 | + |
| 6 | +## 1. File Suffix System (Mandatory) |
| 7 | + |
| 8 | +You must strictly adhere to the File Suffix Protocol. Every file type maps to a specific Zod Schema in `@objectstack/spec`. |
| 9 | + |
| 10 | +### A. Data Protocol (`@objectstack/spec/data`) |
| 11 | +| Suffix | Type Interpretation | Spec Schema | |
| 12 | +| :--- | :--- | :--- | |
| 13 | +| `*.object.ts` | **Object Entity** | `ObjectSchema` | |
| 14 | +| `*.field.ts` | **Reusable Field** | `FieldSchema` | |
| 15 | +| `*.dataset.ts` | **Static Dataset** | `DatasetSchema` | |
| 16 | +| `*.query.ts` | **Named Query** | `QuerySchema` | |
| 17 | +| `*.hook.ts` | **Data Hook / Trigger** | `HookSchema` | |
| 18 | +| `*.validation.ts`| **Validation Rule** | `ValidationSchema` | |
| 19 | +| `*.mapping.ts` | **Import/Integration Map**| `MappingSchema` | |
| 20 | + |
| 21 | +### B. UI Protocol (`@objectstack/spec/ui`) |
| 22 | +| Suffix | Type Interpretation | Spec Schema | |
| 23 | +| :--- | :--- | :--- | |
| 24 | +| `*.app.ts` | **Application** | `AppSchema` | |
| 25 | +| `*.view.ts` | **List/Details View** | `ViewSchema` | |
| 26 | +| `*.page.ts` | **Page Layout** | `PageSchema` | |
| 27 | +| `*.action.ts` | **Button / Action** | `ActionSchema` | |
| 28 | +| `*.dashboard.ts`| **BI Dashboard** | `DashboardSchema` | |
| 29 | +| `*.report.ts` | **Analytics Report** | `ReportSchema` | |
| 30 | +| `*.theme.ts` | **UI Theme** | `ThemeSchema` | |
| 31 | +| `*.block.ts` | **Component Props** | `BlockSchema` | |
| 32 | +| `*.nav.ts` | **Navigation Item** | `NavigationSchema` | |
| 33 | + |
| 34 | +### C. Automation Protocol (`@objectstack/spec/automation`) |
| 35 | +| Suffix | Type Interpretation | Spec Schema | |
| 36 | +| :--- | :--- | :--- | |
| 37 | +| `*.flow.ts` | **Visual Flow** | `FlowSchema` | |
| 38 | +| `*.workflow.ts` | **State Machine** | `WorkflowSchema` | |
| 39 | +| `*.webhook.ts` | **External Webhook** | `WebhookSchema` | |
| 40 | + |
| 41 | +### D. Permission & Security (`@objectstack/spec/permission`) |
| 42 | +| Suffix | Type Interpretation | Spec Schema | |
| 43 | +| :--- | :--- | :--- | |
| 44 | +| `*.permission.ts`| **Permission Set** | `PermissionSchema` | |
| 45 | +| `*.role.ts` | **User Role** | `RoleSchema` | |
| 46 | +| `*.sharing.ts` | **Sharing Rule** | `SharingRuleSchema` | |
| 47 | +| `*.territory.ts` | **Territory Model** | `TerritorySchema` | |
| 48 | + |
| 49 | +### E. AI Protocol (`@objectstack/spec/ai`) |
| 50 | +| Suffix | Type Interpretation | Spec Schema | |
| 51 | +| :--- | :--- | :--- | |
| 52 | +| `*.agent.ts` | **AI Agent** | `AgentSchema` | |
| 53 | +| `*.model.ts` | **LLM Model Config** | `ModelRegistrySchema` | |
| 54 | +| `*.rag.ts` | **RAG Pipeline** | `RagPipelineSchema` | |
| 55 | +| `*.prompt.ts` | **Prompt Template** | `PromptSchema` | |
| 56 | + |
| 57 | +### F. System Protocol (`@objectstack/spec/system`) |
| 58 | +| Suffix | Type Interpretation | Spec Schema | |
| 59 | +| :--- | :--- | :--- | |
| 60 | +| `*.manifest.ts` | **Package Config** | `ManifestSchema` | |
| 61 | +| `*.datasource.ts`| **Data Connection** | `DatasourceSchema` | |
| 62 | +| `*.api.ts` | **API Endpoint** | `ApiSchema` | |
| 63 | +| `*.job.ts` | **Scheduled Job** | `JobSchema` | |
| 64 | +| `*.i18n.ts` | **Translations** | `TranslationSchema` | |
| 65 | + |
| 66 | +## 2. Coding Standards |
| 67 | + |
| 68 | +### **A. No "Magic Strings"** |
| 69 | +* **Bad:** `type: 'text'` |
| 70 | +* **Good:** Use strict literal types defined by the schema. If you are unsure, ask to check `@objectstack/spec` definitions. |
| 71 | + |
| 72 | +### **B. Constant Exports** |
| 73 | +All metadata files must `export default` a strictly typed constant. |
| 74 | + |
| 75 | +```typescript |
| 76 | +// ✅ CORRECT |
| 77 | +import type { ObjectSchema } from '@objectstack/spec/data'; |
| 78 | + |
| 79 | +const Issue: ObjectSchema = { |
| 80 | + name: 'issue', |
| 81 | + // ... |
| 82 | +}; |
| 83 | +export default Issue; |
| 84 | +``` |
| 85 | + |
| 86 | +```typescript |
| 87 | +// ❌ WRONG |
| 88 | +export default { |
| 89 | + name: 'issue' |
| 90 | +} // Type is 'any', no validation! |
| 91 | +``` |
| 92 | + |
| 93 | +### **C. Naming Conventions** |
| 94 | +* **Filenames:** `snake_case` + `suffix.ts`. (e.g., `project_task.object.ts`) |
| 95 | +* **Metadata Keys:** `camelCase`. (e.g., `trackHistory`, `apiEnabled`) |
| 96 | +* **Machine Names:** `snake_case`. (e.g., `name: 'project_task'`) |
| 97 | + |
| 98 | +## 3. Workflow Priorities |
| 99 | + |
| 100 | +1. **Define Data First:** Always start by creating `.object.ts` files before Views or Actions. |
| 101 | +2. **Refer to Spec:** If the user asks for a feature, check if it exists in `@objectstack/spec` first. |
| 102 | +3. **Validation:** Ensure generated code satisfies the Zod Schema constraints (e.g., regex patterns for names). |
0 commit comments