Skip to content

Create @singleton-sd/post-kit-types shared contracts package #17

Description

@patoperpetua

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

  • packages/post-kit-types builds cleanly (tsc --noEmit or equivalent).
  • All contracts listed above are exported from the package index.
  • At least compile-time assertions (or basic node --test tests) confirm the shape of each contract.
  • pnpm -r --if-present run test passes including this package.
  • Package is configured for public npm publication under @singleton-sd/post-kit-types.
  • README documents each exported contract and its intended consumers.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyMeets every criterion in docs/github-source-of-truth.md, section 4 — safe for an agent to claimenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions