|
| 1 | +--- |
| 2 | +'@objectstack/spec': minor |
| 3 | +'@objectstack/objectql': patch |
| 4 | +'@objectstack/metadata': patch |
| 5 | +'@objectstack/runtime': patch |
| 6 | +'@objectstack/example-crm': patch |
| 7 | +--- |
| 8 | + |
| 9 | +Promote `email_template` to a first-class metadata type using the canonical |
| 10 | +`EmailTemplateDefinitionSchema`. |
| 11 | + |
| 12 | +Previously `email_template` had two competing Zod schemas (Prime Directive |
| 13 | +#8 violation): the legacy `EmailTemplateSchema` (a sub-shape of |
| 14 | +`Notification`) and the richer `EmailTemplateDefinitionSchema`. The runtime |
| 15 | +metadata protocol (`packages/objectql/src/protocol.ts`) and Studio's |
| 16 | +property panel registered the legacy one, which is why all the new fields |
| 17 | +(`name`, `label`, `category`, `locale`, `bodyHtml`, `bodyText`, …) were |
| 18 | +reported as “declared in form layout but missing from schema”. |
| 19 | + |
| 20 | +This change: |
| 21 | + |
| 22 | +- Repoints the `email_template` entry in `TYPE_TO_SCHEMA` |
| 23 | + (`packages/objectql/src/protocol.ts`) and in |
| 24 | + `BUILTIN_METADATA_TYPE_SCHEMAS` |
| 25 | + (`packages/spec/src/kernel/metadata-type-schemas.ts`) to |
| 26 | + `EmailTemplateDefinitionSchema`. The legacy `EmailTemplateSchema` is |
| 27 | + kept only as an inline sub-shape inside `Notification`. |
| 28 | +- Adds an `emailTemplates` collection to `defineStack()` input |
| 29 | + (`packages/spec/src/stack.zod.ts`), registers it in |
| 30 | + `MAP_SUPPORTED_FIELDS`/`PLURAL_TO_SINGULAR` |
| 31 | + (`packages/spec/src/shared/metadata-collection.zod.ts`), wires it into |
| 32 | + `ARTIFACT_FIELD_TO_TYPE` (`packages/metadata/src/plugin.ts`) and |
| 33 | + `APP_CATEGORY_KEYS` (`packages/runtime/src/app-plugin.ts`). |
| 34 | +- Rewrites `packages/spec/src/system/email-template.form.ts` for the new |
| 35 | + schema with sections for Identity, Subject, HTML body, Plain-text body, |
| 36 | + Variables, Delivery overrides, Status. |
| 37 | +- Ships three reference templates in `examples/app-crm/src/emails/`: |
| 38 | + `crm.deal_won` (rewritten to canonical shape), `crm.welcome` (new), |
| 39 | + `crm.lead_followup` (new), and wires them into the CRM stack via |
| 40 | + `emailTemplates: Object.values(emails)`. |
| 41 | + |
| 42 | +End-to-end verified in Studio: list view at |
| 43 | +`/_console/apps/studio/metadata/email_template` shows all three entries; |
| 44 | +the detail view renders the EmailTemplatePreview iframe and the property |
| 45 | +panel cleanly renders every canonical field (no missing-schema warnings). |
| 46 | +`GET /api/v1/meta` now returns the new `properties` set |
| 47 | +(`name, label, category, locale, subject, bodyHtml, bodyText, variables, |
| 48 | +fromOverride, replyTo, active, isSystem, description`). |
0 commit comments