Parent: #2, #3, #4, #6
Blocks: #14, #15, #17, #19, #20
Goal
Create packages/post-kit-types — a new workspace package exporting all shared TypeScript contracts used across apps/api, post-kit-compiler, post-kit-publisher, post-kit-client, and post-kit-editor. Centralising contracts here prevents duplication and gives every downstream package a stable, versioned API surface.
Scope
Package setup
- Path:
packages/post-kit-types
- npm name:
@singleton-sd/post-kit-types
- TypeScript ESM, tests via
node --test, src/**/*.spec.ts convention
- Configured for public npm publication under the Singleton SD scope
- Mirror the structure, tsconfig, and package.json conventions of
packages/post-kit-email
Contracts to export
Template source
TemplateSourceMetadata // key, name, subject, description, variables[], schemaVersion
TemplatePreviewData // Record<string, string> — sample variable values
Compiled artifact
TemplateManifest // key, schemaVersion, compiledAt, sourceCommit, variables[], contentHash
CompiledTemplate // templateHtml, metadata: TemplateSourceMetadata, manifest: TemplateManifest
API send
SendRequest // template (key string), to (string), variables (Record<string, string>)
SendResponse // id (string), status ('sent')
PostKitErrorCode // string enum: UNAUTHENTICATED | UNAUTHORIZED | TEMPLATE_NOT_FOUND |
// INVALID_TEMPLATE | MISSING_VARIABLES | INVALID_RECIPIENT |
// PROVIDER_FAILURE | STORAGE_FAILURE
PostKitErrorResponse // error (string), code (PostKitErrorCode), correlationId (string)
Tenant
TenantEnvironment // 'development' | 'staging' | 'production'
TenantContext // tenantId (string), environment (TenantEnvironment)
TenantBranding // companyName?, logoUrl?, websiteUrl?, supportEmail? — all string | undefined
Variable rendering
TemplateVariables // Record<string, string>
Runtime validation
If Zod is already a monorepo dependency (check packages/post-kit-email/package.json and apps/api/package.json), export Zod schemas alongside types using the z.infer pattern. If not present, use plain TypeScript interfaces and do not add Zod as a new dependency without a clear need.
Constraints
- No runtime dependencies beyond Zod if already present — this must remain a thin types layer.
- Do not import from
apps/api or any other workspace package — contracts flow outward from here.
- All exported names are a public API surface; treat them as stable from day one.
- Do not reach into app internals (AGENTS.md).
Acceptance criteria
Agent implementation notes
Read packages/post-kit-email/package.json and its tsconfig.json before scaffolding — match those conventions exactly. Check for Zod in the monorepo before adding it. Branch: feat/13-post-kit-types.
Parent: #2, #3, #4, #6
Blocks: #14, #15, #17, #19, #20
Goal
Create
packages/post-kit-types— a new workspace package exporting all shared TypeScript contracts used acrossapps/api,post-kit-compiler,post-kit-publisher,post-kit-client, andpost-kit-editor. Centralising contracts here prevents duplication and gives every downstream package a stable, versioned API surface.Scope
Package setup
packages/post-kit-types@singleton-sd/post-kit-typesnode --test,src/**/*.spec.tsconventionpackages/post-kit-emailContracts to export
Template source
Compiled artifact
API send
Tenant
Variable rendering
Runtime validation
If Zod is already a monorepo dependency (check
packages/post-kit-email/package.jsonandapps/api/package.json), export Zod schemas alongside types using thez.inferpattern. If not present, use plain TypeScript interfaces and do not add Zod as a new dependency without a clear need.Constraints
apps/apior any other workspace package — contracts flow outward from here.Acceptance criteria
packages/post-kit-typesbuilds cleanly (tsc --noEmitor equivalent).node --testtests) confirm the shape of each contract.pnpm -r --if-present run testpasses including this package.@singleton-sd/post-kit-types.Agent implementation notes
Read
packages/post-kit-email/package.jsonand itstsconfig.jsonbefore scaffolding — match those conventions exactly. Check for Zod in the monorepo before adding it. Branch:feat/13-post-kit-types.