Files
2026-05-27 23:29:53 +01:00

4.7 KiB

Tasks — add-payment-provider-square

Every checkbox MUST reflect work actually done in this change. No retroactive ticking.

1. Spec authoring

  • 1.1 Read ../suaveplan/enterprise/payment-providers.md end-to-end
  • 1.2 Read upstream src/square.ts, src/square.md, src/square.test.ts
  • 1.3 Read openspec/AGENTS.md Sections 13 and 14
  • 1.4 Read slim archive openspec/archive/2026-05-17-slim-payment-providers/
  • 1.5 Draft proposal.md from openspec/templates/proposal.md
  • 1.6 Fill in ## Source mapping table — every requirement cites a line range or appears in the "no source line" table with justification
  • 1.7 Draft specs/payment-provider-square/spec.md from openspec/templates/spec-delta.md
  • 1.8 Every requirement carries a **Verified by:** line naming concrete it(...) titles

2. Implementation

  • 2.1 Create packages/universal/payment-provider-square/ with package.json (0.1.0, deps: @suaveplan/payment-providers, @suaveplan/payment, tslib), tsconfig.json, tsconfig.lib.json, vite.config.ts, vitest.config.ts, tests/setup/polyfills.ts
  • 2.2 src/types/config.ts — SquareConfig extends ApiKeyConfig with locationId, sandbox?, randomId?, apiVersion?; export constants SQUARE_DEFAULT_BASE_URL, SQUARE_SANDBOX_BASE_URL, SQUARE_DEFAULT_API_VERSION
  • 2.3 src/mapping/payment.ts — mapPaymentStatus, mapPayment, SquarePaymentDto type
  • 2.4 src/mapping/refund.ts — mapRefundStatus, mapRefund, SquareRefundDto type
  • 2.5 src/square/square.ts — SquareProvider implements PaymentProvider class
  • 2.6 src/index.ts — explicit named re-exports (§6a)

3. Tests

  • 3.1 src/square/square.test.ts — full lifecycle, deterministic randomId, real FetchLike recorder, sandbox URL flip, header pinning, idempotency-key forwarding
  • 3.2 src/mapping/payment.test.ts — every status branch, missing-card-details, approved-money branch
  • 3.3 src/mapping/refund.test.ts — every refund-status branch, reason fallback
  • 3.4 src/types/config.test.ts — type-level assertions (expectTypeOf) on SquareConfig extends ApiKeyConfig and locationId required-ness
  • 3.5 tests/dep-graph.test.ts — universal-tier purity gate (no node: / bun: / fs / path / crypto imports)
  • 3.6 Every it(...) carries { timeout: 5000 }

4. Documentation

  • 4.1 src/square/square.md — sibling doc (≥200 words, basic + advanced examples, full API reference)
  • 4.2 src/types/config.md — sibling doc
  • 4.3 src/mapping/payment.md — sibling doc
  • 4.4 src/mapping/refund.md — sibling doc
  • 4.5 README.md linking every co-located .md under ## Modules

5. Pre-archive verification (the 5-gate triple)

  • 5.1 bun run check — Biome 0/0/0 across the touched files (run inside the package)
  • 5.2 bunx turbo lint typecheck test --filter=@suaveplan/payment-provider-square — green
  • 5.3 bunx turbo test:coverage --filter=@suaveplan/payment-provider-square — 100/100/100/100
  • 5.4 Manual spec-completeness audit (§12a) — every requirement implemented, every Verified by test exists with verbatim title
  • 5.5 bunx turbo build --filter=@suaveplan/payment-provider-square — green

6. Pre-archive 8-row checklist (skill Step 7)

  • 6.1 Generics threaded; expectTypeOf on literal-type claims (name: "square", SquareConfig extends ApiKeyConfig)
  • 6.2 No Zod boundaries claimed by spec — config is a TS interface, no runtime parse boundary in this package
  • 6.3 No error codes added — the package reuses PAYMENT_PROVIDER_CODES from the foundation and raises only PaymentProviderError via the foundation's httpRequest
  • 6.4 No strict-mode toggles claimed
  • 6.5 No OTel instruments declared by this package (foundation owns metrics)
  • 6.6 Idempotency-key generation tested with a deterministic injected randomId
  • 6.7 No retroactive tick — every box reflects work done in this change
  • 6.8 No export * in any feature-module barrel — every <feature>/index.ts uses named re-exports
  • 6.9 No direct vitest / bun:test imports — every test imports from @suaveplan/testing/runner

7. Archive

  • 7.1 Fold spec delta into openspec/specs/payment-provider-square/spec.md
  • 7.2 Move openspec/changes/add-payment-provider-square/ → openspec/archive/2026-05-17-add-payment-provider-square/
  • 7.3 Refresh STATUS.md (Pending → Completed row added)
  • 7.4 Refresh SUMMARY.md (per-package paragraph added)
  • 7.5 Refresh MANIFEST.md via bun scripts/folder-reorg/generate-manifest.ts (run after package lands)
  • 7.6 Add package row to CLAUDE.md listing