Skip to content

Scope widget SDK to widgetContract; drop unused schema from bundle (~36 KB)#203

Merged
yasithdev merged 3 commits into
devfrom
contract-subcontracts-split
Jun 2, 2026
Merged

Scope widget SDK to widgetContract; drop unused schema from bundle (~36 KB)#203
yasithdev merged 3 commits into
devfrom
contract-subcontracts-split

Conversation

@yasithdev
Copy link
Copy Markdown
Member

@yasithdev yasithdev commented Jun 2, 2026

Closes #204

Summary

Repoints widget/src/sdk to its scoped audience contract (widgetContract, the 8 procedures the widget calls) from the restructured api (Marketrix-ai/api#598). Internal-only — no wire/API-surface change.

  • SDK mirror is now the closure copy contract.ts + contracts/* (generated by api's sync-consumers.mjs), replacing the routes.ts/schema.ts monolith; client typed ContractRouterClient<typeof widgetContract>.
  • Named runtime re-exports for the 2 schema values the widget uses at runtime; everything else type-only. sideEffects:false added.
  • Bundle: 561 KB → 525 KB (~36 KB off)schema.ts no longer shipped; tree-shaking now reaches the contract closure.
  • contract-drift.yml CI gate reworked to sync-consumers widget --check.

Deploy ordering

Independent of api/app (no wire change). Published @marketrix.ai/widget API surface unchanged — republish optional.

Test Plan

  • npm run type-check, npm run test:run (225), npm run build; needs_healing no longer leaking app/QA schema
  • Dev smoke: widget loads, chat Q&A + show/tell/do, session recording

🤖 Generated with Claude Code

yasithdev and others added 2 commits June 2, 2026 03:21
…used schema from bundle

- Replace src/sdk/routes.ts + schema.ts monolith mirrors with sync-generated
  contract.ts + contracts/* scoped to widgetContract (8 procedures)
- Repoint index.ts to widgetContract; add named re-exports for all widget-consumed
  types and runtime schemas (WidgetEventSchema, WidgetSettingsDataSchema)
- Add sideEffects:false to package.json to unlock tree-shaking
- Fix all intra-package imports from sdk/schema → sdk barrel
- sdk/* attributed bytes: 7531 (entities 5906, common 1232, index 393)
  vs old schema.ts ~37-41 KB; schema.ts row is GONE from bundle

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the old structural-diff gate (check-contract-drift.mjs comparing
routes.ts + schema.ts) with the generator in --check mode. The gate now
sparse-checkouts contracts/, sdk/, and scripts/sync-consumers.mjs from
Marketrix-ai/api@dev and runs: node .api-src/scripts/sync-consumers.mjs
widget --check --dest src/sdk. Trigger path updated to src/sdk/**.
Delete scripts/check-contract-drift.mjs (superseded).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yasithdev yasithdev merged commit 41e3971 into dev Jun 2, 2026
3 of 5 checks passed
@yasithdev yasithdev deleted the contract-subcontracts-split branch June 2, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scope widget SDK to widgetContract; drop unused schema from bundle (~36 KB)

1 participant