handoff-app 1.2.2-6 → 2.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/Changelog.md +37 -15
  2. package/README.md +372 -118
  3. package/dist/app-builder/build.d.ts +41 -2
  4. package/dist/app-builder/build.js +455 -18
  5. package/dist/app-builder/client-config.d.ts +15 -2
  6. package/dist/app-builder/client-config.js +43 -4
  7. package/dist/app-builder/config-diff/snapshot.d.ts +1 -6
  8. package/dist/app-builder/config-diff/snapshot.js +2 -9
  9. package/dist/app-builder/index.d.ts +1 -1
  10. package/dist/app-builder/index.js +3 -1
  11. package/dist/app-builder/nav-shell.d.ts +23 -0
  12. package/dist/app-builder/nav-shell.js +80 -0
  13. package/dist/app-builder/static-export.d.ts +17 -0
  14. package/dist/app-builder/static-export.js +181 -0
  15. package/dist/app-builder/vercel-output.d.ts +39 -0
  16. package/dist/app-builder/vercel-output.js +259 -0
  17. package/dist/app-builder/watchers/utils.d.ts +2 -0
  18. package/dist/app-builder/watchers.d.ts +14 -4
  19. package/dist/app-builder/watchers.js +123 -28
  20. package/dist/app-builder/websocket.js +1 -1
  21. package/dist/artifacts/index.d.ts +2 -0
  22. package/dist/artifacts/index.js +13 -0
  23. package/dist/artifacts/types.d.ts +136 -0
  24. package/dist/artifacts/types.js +24 -0
  25. package/dist/artifacts/url.d.ts +49 -0
  26. package/dist/artifacts/url.js +86 -0
  27. package/dist/cache/build-cache.js +48 -4
  28. package/dist/commands/build/app.js +1 -2
  29. package/dist/commands/build/index.d.ts +17 -0
  30. package/dist/commands/build/index.js +66 -0
  31. package/dist/commands/checkout/index.d.ts +24 -0
  32. package/dist/commands/checkout/index.js +71 -0
  33. package/dist/commands/db/migrate.d.ts +11 -0
  34. package/dist/commands/db/migrate.js +33 -0
  35. package/dist/commands/index.js +8 -0
  36. package/dist/commands/publish/index.d.ts +21 -0
  37. package/dist/commands/publish/index.js +68 -0
  38. package/dist/config/defaults.js +15 -1
  39. package/dist/config/loader.js +6 -1
  40. package/dist/config/normalizers/declaration.js +4 -1
  41. package/dist/config/normalizers/page.d.ts +18 -0
  42. package/dist/config/normalizers/page.js +34 -0
  43. package/dist/config/normalizers/pattern.js +7 -1
  44. package/dist/config/runtime.d.ts +4 -0
  45. package/dist/config/runtime.js +53 -5
  46. package/dist/index.d.ts +65 -1
  47. package/dist/index.js +123 -3
  48. package/dist/nav/index.d.ts +83 -0
  49. package/dist/nav/index.js +9 -0
  50. package/dist/nav/registry.d.ts +15 -0
  51. package/dist/nav/registry.js +42 -0
  52. package/dist/nav/resolver.d.ts +8 -0
  53. package/dist/nav/resolver.js +192 -0
  54. package/dist/nav/workspace.d.ts +18 -0
  55. package/dist/nav/workspace.js +103 -0
  56. package/dist/pipeline/styles.js +7 -35
  57. package/dist/pipeline/token-transformers.d.ts +45 -0
  58. package/dist/pipeline/token-transformers.js +71 -0
  59. package/dist/registry/asset-storage/adapters/vercel-blob.d.ts +17 -0
  60. package/dist/registry/asset-storage/adapters/vercel-blob.js +87 -0
  61. package/dist/registry/asset-storage/define.d.ts +10 -0
  62. package/dist/registry/asset-storage/define.js +13 -0
  63. package/dist/registry/asset-storage/resolve.d.ts +45 -0
  64. package/dist/registry/asset-storage/resolve.js +36 -0
  65. package/dist/registry/asset-storage/types.d.ts +51 -0
  66. package/dist/registry/asset-storage/types.js +9 -0
  67. package/dist/registry/assets/layout.d.ts +22 -0
  68. package/dist/registry/assets/layout.js +30 -0
  69. package/dist/registry/assets/sets.d.ts +18 -0
  70. package/dist/registry/assets/sets.js +44 -0
  71. package/dist/registry/assets/transfer.d.ts +45 -0
  72. package/dist/registry/assets/transfer.js +11 -0
  73. package/dist/registry/checkout/assets.d.ts +16 -0
  74. package/dist/registry/checkout/assets.js +150 -0
  75. package/dist/registry/checkout/index.d.ts +33 -0
  76. package/dist/registry/checkout/index.js +610 -0
  77. package/dist/registry/checkout/tokens.d.ts +15 -0
  78. package/dist/registry/checkout/tokens.js +171 -0
  79. package/dist/registry/client.d.ts +61 -0
  80. package/dist/registry/client.js +211 -0
  81. package/dist/registry/connection.d.ts +30 -0
  82. package/dist/registry/connection.js +36 -0
  83. package/dist/registry/db/adapter.d.ts +43 -0
  84. package/dist/registry/db/adapter.js +59 -0
  85. package/dist/registry/db/client.d.ts +35 -0
  86. package/dist/registry/db/client.js +94 -0
  87. package/dist/registry/db/index.d.ts +5 -0
  88. package/dist/registry/db/index.js +24 -0
  89. package/dist/registry/db/migrate.d.ts +23 -0
  90. package/dist/registry/db/migrate.js +64 -0
  91. package/dist/registry/db/schema.d.ts +4869 -0
  92. package/dist/registry/db/schema.js +347 -0
  93. package/dist/registry/path.d.ts +4 -0
  94. package/dist/registry/path.js +31 -0
  95. package/dist/registry/publish/artifacts.d.ts +16 -0
  96. package/dist/registry/publish/artifacts.js +132 -0
  97. package/dist/registry/publish/assets.d.ts +16 -0
  98. package/dist/registry/publish/assets.js +129 -0
  99. package/dist/registry/publish/errors.d.ts +5 -0
  100. package/dist/registry/publish/errors.js +26 -0
  101. package/dist/registry/publish/index.d.ts +27 -0
  102. package/dist/registry/publish/index.js +126 -0
  103. package/dist/registry/publish/package.d.ts +27 -0
  104. package/dist/registry/publish/package.js +257 -0
  105. package/dist/registry/publish/publish-build.d.ts +12 -0
  106. package/dist/registry/publish/publish-build.js +43 -0
  107. package/dist/registry/publish/tokens.d.ts +18 -0
  108. package/dist/registry/publish/tokens.js +112 -0
  109. package/dist/registry/tokens/sets.d.ts +59 -0
  110. package/dist/registry/tokens/sets.js +109 -0
  111. package/dist/registry/tokens/transfer.d.ts +48 -0
  112. package/dist/registry/tokens/transfer.js +10 -0
  113. package/dist/registry/transfer.d.ts +75 -0
  114. package/dist/registry/transfer.js +11 -0
  115. package/dist/store/filesystem-assets.d.ts +17 -0
  116. package/dist/store/filesystem-assets.js +147 -0
  117. package/dist/store/filesystem.d.ts +76 -0
  118. package/dist/store/filesystem.js +208 -0
  119. package/dist/store/index.d.ts +20 -0
  120. package/dist/store/index.js +38 -0
  121. package/dist/store/registry.d.ts +77 -0
  122. package/dist/store/registry.js +350 -0
  123. package/dist/store/source-files.d.ts +24 -0
  124. package/dist/store/source-files.js +147 -0
  125. package/dist/store/types.d.ts +185 -0
  126. package/dist/store/types.js +12 -0
  127. package/dist/transformers/plugins/csf-render.js +17 -8
  128. package/dist/transformers/plugins/handlebars-previews.js +10 -3
  129. package/dist/transformers/plugins/ssr-render.js +116 -49
  130. package/dist/transformers/preview/component/api.js +3 -1
  131. package/dist/transformers/preview/component/artifacts.js +8 -1
  132. package/dist/transformers/preview/component/builder.js +13 -5
  133. package/dist/transformers/preview/component/css.js +9 -1
  134. package/dist/transformers/preview/component/javascript.d.ts +9 -3
  135. package/dist/transformers/preview/component/javascript.js +45 -17
  136. package/dist/transformers/preview/component/shared-artifacts.d.ts +83 -0
  137. package/dist/transformers/preview/component/shared-artifacts.js +92 -0
  138. package/dist/transformers/preview/component.js +5 -2
  139. package/dist/transformers/preview/pattern/builder.js +28 -9
  140. package/dist/transformers/preview/pattern/html.d.ts +13 -10
  141. package/dist/transformers/preview/pattern/html.js +62 -27
  142. package/dist/transformers/preview/types.d.ts +38 -0
  143. package/dist/transformers/utils/handlebars.d.ts +3 -0
  144. package/dist/transformers/utils/handlebars.js +19 -5
  145. package/dist/types/config.d.ts +118 -25
  146. package/dist/utils/menu-shell.d.ts +60 -0
  147. package/dist/utils/menu-shell.js +221 -0
  148. package/dist/utils/stable-stringify.d.ts +2 -0
  149. package/dist/utils/stable-stringify.js +8 -0
  150. package/docs/cli.md +4 -2
  151. package/drizzle/0000_init_registry_storage.sql +95 -0
  152. package/drizzle/0001_add_review_metadata.sql +2 -0
  153. package/drizzle/0002_add_pages.sql +28 -0
  154. package/drizzle/0003_add_tokens.sql +29 -0
  155. package/drizzle/0004_add_assets.sql +37 -0
  156. package/drizzle/meta/0000_snapshot.json +642 -0
  157. package/drizzle/meta/0001_snapshot.json +654 -0
  158. package/drizzle/meta/0002_snapshot.json +835 -0
  159. package/drizzle/meta/0003_snapshot.json +1023 -0
  160. package/drizzle/meta/0004_snapshot.json +1252 -0
  161. package/drizzle/meta/_journal.json +41 -0
  162. package/drizzle.config.ts +16 -0
  163. package/package.json +10 -1
  164. package/src/app/components/Component/ComponentLists.tsx +102 -102
  165. package/src/app/components/Component/Preview.tsx +3 -2
  166. package/src/app/components/Component/RegistryActions.tsx +150 -0
  167. package/src/app/components/Foundations/DisplayLogo.tsx +5 -3
  168. package/src/app/components/Layout/Header.tsx +21 -3
  169. package/src/app/components/Layout/Main.tsx +11 -3
  170. package/src/app/components/Navigation/MainNav.tsx +4 -2
  171. package/src/app/components/Navigation/MobileNav.tsx +4 -2
  172. package/src/app/components/Navigation/SideNav.tsx +46 -11
  173. package/src/app/components/NotFound.tsx +24 -0
  174. package/src/app/components/context/NavProvider.tsx +71 -0
  175. package/src/app/components/old/Header.tsx +3 -3
  176. package/src/app/components/util/index.ts +203 -380
  177. package/src/app/components/util/useCollectionAssets.ts +125 -0
  178. package/src/app/components/util/useFoundationTokens.ts +67 -0
  179. package/src/app/generated/default-pages.json +1 -0
  180. package/src/app/generated/nav-shell.json +1 -0
  181. package/src/app/lib/api/query.ts +6 -0
  182. package/src/app/lib/api/redact.ts +46 -0
  183. package/src/app/lib/asset-storage.ts +81 -0
  184. package/src/app/lib/docs-api/artifacts.ts +116 -0
  185. package/src/app/lib/docs-api/backend.ts +151 -0
  186. package/src/app/lib/docs-api/errors.ts +52 -0
  187. package/src/app/lib/docs-api/handler.ts +34 -0
  188. package/src/app/lib/docs-api/index.ts +7 -0
  189. package/src/app/lib/docs-api/records.ts +189 -0
  190. package/src/app/lib/docs-api/registry.ts +130 -0
  191. package/src/app/lib/docs-api/runtime-config.ts +173 -0
  192. package/src/app/lib/docs-api/serve.ts +37 -0
  193. package/src/app/lib/docs-api/token-detail.ts +19 -0
  194. package/src/app/lib/registry-api/allowlist.ts +163 -0
  195. package/src/app/lib/registry-api/asset-transfer.ts +363 -0
  196. package/src/app/lib/registry-api/auth.ts +68 -0
  197. package/src/app/lib/registry-api/entity-routes.ts +197 -0
  198. package/src/app/lib/registry-api/errors.ts +51 -0
  199. package/src/app/lib/registry-api/files.ts +135 -0
  200. package/src/app/lib/registry-api/handler.ts +96 -0
  201. package/src/app/lib/registry-api/index.ts +4 -0
  202. package/src/app/lib/registry-api/meta.ts +87 -0
  203. package/src/app/lib/registry-api/revalidate.ts +36 -0
  204. package/src/app/lib/registry-api/store.ts +348 -0
  205. package/src/app/lib/registry-api/token-transfer.ts +231 -0
  206. package/src/app/lib/registry-api/transfer.ts +513 -0
  207. package/src/app/lib/registry-api/validation.ts +74 -0
  208. package/src/app/lib/registry-connection.ts +58 -0
  209. package/src/app/lib/utils.ts +14 -0
  210. package/src/app/next.config.mjs +72 -13
  211. package/src/app/pages/[...slug]/index.tsx +74 -20
  212. package/src/app/pages/_app.tsx +5 -2
  213. package/src/app/pages/api/docs/artifacts/[...artifactPath].ts +16 -0
  214. package/src/app/pages/api/docs/assets/[collection]/[...path].ts +50 -0
  215. package/src/app/pages/api/docs/assets/[collection]/index.ts +22 -0
  216. package/src/app/pages/api/docs/components/[id]/assets/[asset].ts +33 -0
  217. package/src/app/pages/api/docs/components/[id]/inspect/[previewId].ts +20 -0
  218. package/src/app/pages/api/docs/components/[id]/previews/[previewId].ts +21 -0
  219. package/src/app/pages/api/docs/components/[id].ts +24 -0
  220. package/src/app/pages/api/docs/components.json.ts +12 -0
  221. package/src/app/pages/api/docs/nav.json.ts +48 -0
  222. package/src/app/pages/api/docs/patterns/[id]/preview.ts +19 -0
  223. package/src/app/pages/api/docs/patterns/[id].ts +24 -0
  224. package/src/app/pages/api/docs/patterns.json.ts +12 -0
  225. package/src/app/pages/api/docs/tokens/components/[id].ts +30 -0
  226. package/src/app/pages/api/docs/tokens/foundations/[type].ts +32 -0
  227. package/src/app/pages/api/registry/components/[id]/files/[...filePath].ts +19 -0
  228. package/src/app/pages/api/registry/components/[id]/files/index.ts +19 -0
  229. package/src/app/pages/api/registry/components/[id].ts +20 -0
  230. package/src/app/pages/api/registry/components/index.ts +19 -0
  231. package/src/app/pages/api/registry/health.ts +20 -0
  232. package/src/app/pages/api/registry/patterns/[id]/files/[...filePath].ts +19 -0
  233. package/src/app/pages/api/registry/patterns/[id]/files/index.ts +19 -0
  234. package/src/app/pages/api/registry/patterns/[id].ts +20 -0
  235. package/src/app/pages/api/registry/patterns/index.ts +19 -0
  236. package/src/app/pages/api/registry/transfer/[kind]/[id].ts +39 -0
  237. package/src/app/pages/api/registry/transfer/assets/[collection].ts +24 -0
  238. package/src/app/pages/api/registry/transfer/assets/blobs/[hash].ts +23 -0
  239. package/src/app/pages/api/registry/transfer/assets/blobs/have.ts +11 -0
  240. package/src/app/pages/api/registry/transfer/assets/index.ts +10 -0
  241. package/src/app/pages/api/registry/transfer/tokens/[...setId].ts +26 -0
  242. package/src/app/pages/api/registry/transfer/tokens/index.ts +11 -0
  243. package/src/app/pages/assets/fonts.tsx +41 -17
  244. package/src/app/pages/assets/index.tsx +2 -2
  245. package/src/app/pages/assets/logos.tsx +2 -2
  246. package/src/app/pages/foundations/colors.tsx +18 -8
  247. package/src/app/pages/foundations/effects.tsx +18 -8
  248. package/src/app/pages/foundations/icons/[name]/index.tsx +26 -14
  249. package/src/app/pages/foundations/icons/index.tsx +13 -9
  250. package/src/app/pages/foundations/index.tsx +1 -1
  251. package/src/app/pages/foundations/logo.tsx +7 -4
  252. package/src/app/pages/foundations/typography.tsx +19 -9
  253. package/src/app/pages/index.tsx +1 -1
  254. package/src/app/pages/system/component/[component]/index.tsx +87 -17
  255. package/src/app/pages/system/index.tsx +13 -4
  256. package/src/app/pages/system/pattern/[pattern]/index.tsx +70 -14
  257. package/src/app/pages/system/tokens/components/[component]/index.tsx +42 -14
  258. package/src/app/pages/system/tokens/foundations/colors.tsx +7 -5
  259. package/src/app/pages/system/tokens/foundations/effects.tsx +7 -5
  260. package/src/app/pages/system/tokens/foundations/typography.tsx +8 -4
  261. package/src/app/tsconfig.json +2 -3
  262. package/src/app-builder/build.ts +555 -11
  263. package/src/app-builder/client-config.ts +61 -4
  264. package/src/app-builder/config-diff/snapshot.ts +1 -11
  265. package/src/app-builder/index.ts +1 -1
  266. package/src/app-builder/nav-shell.ts +74 -0
  267. package/src/app-builder/static-export.ts +215 -0
  268. package/src/app-builder/vercel-output.ts +297 -0
  269. package/src/app-builder/watchers/utils.ts +2 -0
  270. package/src/app-builder/watchers.ts +149 -25
  271. package/src/app-builder/websocket.ts +2 -2
  272. package/src/artifacts/README.md +14 -0
  273. package/src/artifacts/index.ts +17 -0
  274. package/src/artifacts/types.ts +146 -0
  275. package/src/artifacts/url.ts +90 -0
  276. package/src/cache/build-cache.ts +47 -2
  277. package/src/commands/build/app.ts +1 -2
  278. package/src/commands/build/index.ts +61 -0
  279. package/src/commands/checkout/index.ts +66 -0
  280. package/src/commands/db/migrate.ts +25 -0
  281. package/src/commands/index.ts +8 -0
  282. package/src/commands/publish/index.ts +63 -0
  283. package/src/config/defaults.ts +15 -0
  284. package/src/config/loader.ts +10 -1
  285. package/src/config/normalizers/declaration.ts +3 -0
  286. package/src/config/normalizers/page.ts +45 -0
  287. package/src/config/normalizers/pattern.ts +4 -1
  288. package/src/config/runtime.ts +48 -2
  289. package/src/index.ts +126 -3
  290. package/src/nav/index.ts +94 -0
  291. package/src/nav/registry.ts +54 -0
  292. package/src/nav/resolver.ts +217 -0
  293. package/src/nav/workspace.ts +87 -0
  294. package/src/pipeline/styles.ts +4 -35
  295. package/src/pipeline/token-transformers.ts +97 -0
  296. package/src/registry/asset-storage/adapters/vercel-blob.ts +51 -0
  297. package/src/registry/asset-storage/define.ts +15 -0
  298. package/src/registry/asset-storage/resolve.ts +72 -0
  299. package/src/registry/asset-storage/types.ts +46 -0
  300. package/src/registry/assets/layout.ts +38 -0
  301. package/src/registry/assets/sets.ts +48 -0
  302. package/src/registry/assets/transfer.ts +50 -0
  303. package/src/registry/checkout/assets.ts +126 -0
  304. package/src/registry/checkout/index.ts +596 -0
  305. package/src/registry/checkout/tokens.ts +152 -0
  306. package/src/registry/client.ts +234 -0
  307. package/src/registry/connection.ts +50 -0
  308. package/src/registry/db/adapter.ts +74 -0
  309. package/src/registry/db/client.ts +88 -0
  310. package/src/registry/db/index.ts +35 -0
  311. package/src/registry/db/migrate.ts +56 -0
  312. package/src/registry/db/schema.ts +444 -0
  313. package/src/registry/path.ts +26 -0
  314. package/src/registry/publish/artifacts.ts +147 -0
  315. package/src/registry/publish/assets.ts +129 -0
  316. package/src/registry/publish/errors.ts +34 -0
  317. package/src/registry/publish/index.ts +128 -0
  318. package/src/registry/publish/package.ts +272 -0
  319. package/src/registry/publish/publish-build.ts +51 -0
  320. package/src/registry/publish/tokens.ts +119 -0
  321. package/src/registry/tokens/sets.ts +132 -0
  322. package/src/registry/tokens/transfer.ts +53 -0
  323. package/src/registry/transfer.ts +82 -0
  324. package/src/store/filesystem-assets.ts +152 -0
  325. package/src/store/filesystem.ts +237 -0
  326. package/src/store/index.ts +62 -0
  327. package/src/store/registry.ts +334 -0
  328. package/src/store/source-files.ts +155 -0
  329. package/src/store/types.ts +210 -0
  330. package/src/transformers/plugins/csf-render.ts +31 -7
  331. package/src/transformers/plugins/handlebars-previews.ts +22 -3
  332. package/src/transformers/plugins/ssr-render.ts +145 -57
  333. package/src/transformers/preview/component/api.ts +2 -1
  334. package/src/transformers/preview/component/artifacts.ts +10 -1
  335. package/src/transformers/preview/component/builder.ts +9 -2
  336. package/src/transformers/preview/component/css.ts +10 -1
  337. package/src/transformers/preview/component/javascript.ts +55 -20
  338. package/src/transformers/preview/component/shared-artifacts.ts +146 -0
  339. package/src/transformers/preview/component.ts +5 -2
  340. package/src/transformers/preview/pattern/builder.ts +33 -7
  341. package/src/transformers/preview/pattern/html.ts +71 -27
  342. package/src/transformers/preview/types.ts +42 -0
  343. package/src/transformers/utils/handlebars.ts +31 -5
  344. package/src/types/config.ts +123 -25
  345. package/src/utils/menu-shell.ts +241 -0
  346. package/src/utils/stable-stringify.ts +7 -0
  347. package/templates/default/package.json.tpl +1 -1
  348. package/handoff.config.js +0 -90
  349. package/src/app/components/ComponentSearch.tsx +0 -93
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Structured artifact and build-metadata model for handoff-app v2.
3
+ *
4
+ * These types are the contract the rest of v2 reads from instead of parsing generated HTML.
5
+ * The workspace (filesystem) and registry (database) tracks both produce and consume this
6
+ * shape, so dependency validation, serving, publish, ingestion, and pattern composition all
7
+ * rely on structured data rather than HTML inspection.
8
+ *
9
+ * This module is a pure prefactor: types and constants only. No artifact is read or written
10
+ * here — consumers (the store, docs read API, build, publish/ingest) come in later issues.
11
+ */
12
+ /**
13
+ * Logical artifact kind. Mirrors the docs read-model artifact record's `artifactKind` — the
14
+ * broad class an artifact belongs to, independent of how it is stored or served.
15
+ */
16
+ export type ArtifactKind = 'json' | 'html' | 'css' | 'javascript' | 'other';
17
+ /**
18
+ * What an artifact (or reference) logically belongs to. Shared/global artifacts are owned by
19
+ * `asset` with a `null` owner id; entity-owned artifacts name their component or pattern.
20
+ */
21
+ export type ArtifactOwnerKind = 'component' | 'pattern' | 'asset';
22
+ /**
23
+ * Kind of a structured artifact reference carried by an HTML artifact. Drives load order,
24
+ * validation, and pattern dedup without ever parsing the HTML.
25
+ */
26
+ export type ArtifactReferenceKind = 'client' | 'style' | 'script' | 'shared' | 'other';
27
+ /**
28
+ * Build status for an artifact/entity. A successful publish sets `current` with `builtAt`,
29
+ * `builderVersion`, and `artifactHash` all present; metadata-only records report `missing`.
30
+ */
31
+ export type ArtifactBuildStatus = 'current' | 'stale' | 'missing' | 'error';
32
+ /**
33
+ * A structured reference from one artifact (typically preview/inspect HTML) to another
34
+ * artifact it depends on. References are the single source of truth for dependency
35
+ * resolution — HTML is never parsed for dependencies.
36
+ */
37
+ export interface ArtifactReference {
38
+ /** Logical path of the referenced artifact (e.g. `component/main.css`). */
39
+ path: string;
40
+ /** Reference kind, used for load ordering and dedup. */
41
+ kind: ArtifactReferenceKind;
42
+ /** Whether the referencing artifact cannot render correctly without this reference. */
43
+ required: boolean;
44
+ /** What the referenced artifact belongs to, when known. */
45
+ ownerKind?: ArtifactOwnerKind;
46
+ /** Owner entity id; `null` for shared/global artifacts. */
47
+ ownerId?: string | null;
48
+ /** Optional content type of the referenced artifact. */
49
+ contentType?: string;
50
+ /** Optional format/version tag of the referenced artifact. */
51
+ formatVersion?: string;
52
+ /** Optional build identity the reference was resolved against. */
53
+ buildId?: string;
54
+ /** Optional content hash of the referenced artifact. */
55
+ hash?: string;
56
+ /** Optional byte size of the referenced artifact. */
57
+ size?: number;
58
+ }
59
+ /**
60
+ * Build metadata for an artifact or entity. Captures enough to validate, serve, and debug docs
61
+ * output.
62
+ */
63
+ export interface ArtifactBuildMetadata {
64
+ /** Current build state for the artifact/entity. */
65
+ status: ArtifactBuildStatus;
66
+ /** ISO timestamp of the build that produced the current artifact, when built. */
67
+ builtAt?: string;
68
+ /** Version of the builder that produced the artifact. */
69
+ builderVersion?: string;
70
+ /** Content hash of the produced artifact. */
71
+ artifactHash?: string;
72
+ /** Optional hash of the source that produced the artifact, for staleness detection. */
73
+ sourceHash?: string;
74
+ /** Optional non-fatal build warnings. */
75
+ warnings?: string[];
76
+ /** Optional fatal build error message. */
77
+ error?: string;
78
+ }
79
+ /**
80
+ * Size diagnostics for an artifact, used for publish/build reporting.
81
+ */
82
+ export interface ArtifactSizeDiagnostics {
83
+ /** Raw byte size of the artifact content. */
84
+ bytes: number;
85
+ /** Optional gzipped byte size, when measured. */
86
+ gzipBytes?: number;
87
+ }
88
+ /**
89
+ * Structured description of a single docs read-model artifact. This is the shape the docs read
90
+ * API serves, the static build materializes, and registry publish/ingest moves over the wire —
91
+ * carrying enough to validate, serve, and debug an artifact.
92
+ *
93
+ * `content` and `storageRef` are intentionally both optional so the model leaves room for
94
+ * future object storage of large/binary assets rather than assuming inline content for every
95
+ * kind.
96
+ */
97
+ export interface ArtifactDescriptor {
98
+ /** Logical artifact path (e.g. `component/badge-primary.html`). Stable key for serving. */
99
+ path: string;
100
+ /** Broad artifact kind. */
101
+ artifactKind: ArtifactKind;
102
+ /** Content type to serve the artifact with (e.g. `text/html; charset=utf-8`). */
103
+ contentType: string;
104
+ /** Inline artifact content, when stored inline. */
105
+ content?: string;
106
+ /** Reference to externally stored content (future object storage), when not inline. */
107
+ storageRef?: string;
108
+ /** What the artifact belongs to. */
109
+ ownerKind: ArtifactOwnerKind;
110
+ /** Owner entity id; `null` for shared/global artifacts. */
111
+ ownerId: string | null;
112
+ /** Structured references this artifact depends on (required and optional). */
113
+ references: ArtifactReference[];
114
+ /** Optional format/version tag (e.g. preview/inspect HTML format version). */
115
+ formatVersion?: string;
116
+ /** Build identity that produced this artifact. */
117
+ buildId?: string;
118
+ /** Content hash of the artifact. */
119
+ hash?: string;
120
+ /** Byte size of the artifact. */
121
+ size?: number;
122
+ /** Build metadata for the artifact. */
123
+ build?: ArtifactBuildMetadata;
124
+ /** Optional size diagnostics. */
125
+ diagnostics?: ArtifactSizeDiagnostics;
126
+ }
127
+ /** Logical path of the shared global stylesheet artifact. */
128
+ export declare const SHARED_MAIN_CSS_ARTIFACT_PATH = "component/main.css";
129
+ /** Logical path of the shared global script artifact. */
130
+ export declare const SHARED_MAIN_JS_ARTIFACT_PATH = "component/main.js";
131
+ /** Logical path of the shared component styles artifact. */
132
+ export declare const SHARED_STYLES_CSS_ARTIFACT_PATH = "component/shared.css";
133
+ /** Logical path of the per-build artifact metadata manifest. */
134
+ export declare const ARTIFACT_METADATA_PATH = "artifact-metadata.json";
135
+ /** Format version tag carried by generated React preview/inspect HTML. */
136
+ export declare const REACT_PREVIEW_FORMAT_VERSION = "handoff-react-preview-v1";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * Structured artifact and build-metadata model for handoff-app v2.
4
+ *
5
+ * These types are the contract the rest of v2 reads from instead of parsing generated HTML.
6
+ * The workspace (filesystem) and registry (database) tracks both produce and consume this
7
+ * shape, so dependency validation, serving, publish, ingestion, and pattern composition all
8
+ * rely on structured data rather than HTML inspection.
9
+ *
10
+ * This module is a pure prefactor: types and constants only. No artifact is read or written
11
+ * here — consumers (the store, docs read API, build, publish/ingest) come in later issues.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.REACT_PREVIEW_FORMAT_VERSION = exports.ARTIFACT_METADATA_PATH = exports.SHARED_STYLES_CSS_ARTIFACT_PATH = exports.SHARED_MAIN_JS_ARTIFACT_PATH = exports.SHARED_MAIN_CSS_ARTIFACT_PATH = void 0;
15
+ /** Logical path of the shared global stylesheet artifact. */
16
+ exports.SHARED_MAIN_CSS_ARTIFACT_PATH = 'component/main.css';
17
+ /** Logical path of the shared global script artifact. */
18
+ exports.SHARED_MAIN_JS_ARTIFACT_PATH = 'component/main.js';
19
+ /** Logical path of the shared component styles artifact. */
20
+ exports.SHARED_STYLES_CSS_ARTIFACT_PATH = 'component/shared.css';
21
+ /** Logical path of the per-build artifact metadata manifest. */
22
+ exports.ARTIFACT_METADATA_PATH = 'artifact-metadata.json';
23
+ /** Format version tag carried by generated React preview/inspect HTML. */
24
+ exports.REACT_PREVIEW_FORMAT_VERSION = 'handoff-react-preview-v1';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Centralized, basePath-aware canonical artifact URL builder.
3
+ *
4
+ * Every artifact reference emitted in generated HTML and docs read data flows through this one
5
+ * builder. URLs are always of the canonical form:
6
+ *
7
+ * {basePath}/api/docs/artifacts/{artifactPath}
8
+ *
9
+ * intended for use directly in native `href`/`src` attributes. By contract these URLs never carry
10
+ * a query string and never depend on artifact-specific data attributes — artifact references come
11
+ * from structured metadata, not the URL or the HTML.
12
+ *
13
+ * This module is pure and runtime-agnostic (no Node or browser globals) so the build and the
14
+ * Next app can both import it.
15
+ */
16
+ /** Canonical route prefix all artifact URLs are served under. */
17
+ export declare const ARTIFACTS_ROUTE_SEGMENT = "api/docs/artifacts";
18
+ /** Route prefix for docs read API metadata (`.json`) reads. */
19
+ export declare const DOCS_ROUTE_SEGMENT = "api/docs";
20
+ /**
21
+ * Normalize a configured basePath to either an empty string or a single-leading-slash,
22
+ * no-trailing-slash form. Mirrors the Next app's `resolveBasePath` so builder output composes
23
+ * correctly with the configured Next `basePath`.
24
+ */
25
+ export declare const normalizeBasePath: (basePath?: string | null) => string;
26
+ /**
27
+ * Build a canonical artifact URL for a logical artifact path.
28
+ *
29
+ * Each path segment is individually `encodeURIComponent`-encoded (so a slash separating logical
30
+ * segments is preserved while reserved characters within a segment are escaped), and the
31
+ * configured `basePath` is preserved ahead of the canonical route.
32
+ *
33
+ * @param artifactPath Logical artifact path, e.g. `component/badge-primary.html`.
34
+ * @param basePath Optional configured base path; normalized like the Next app's basePath.
35
+ * @returns A canonical `{basePath}/api/docs/artifacts/{encodedPath}` URL.
36
+ * @throws If `artifactPath` has no usable segments, or contains a `.`/`..` traversal segment.
37
+ */
38
+ export declare const buildArtifactUrl: (artifactPath: string, basePath?: string | null) => string;
39
+ /**
40
+ * Build the canonical docs read API URL for a component's detail metadata
41
+ * (`{basePath}/api/docs/components/{id}.json`). The id is URL-encoded; `basePath` is preserved.
42
+ * This is the single source of the metadata-read URL that the build records as an entity's `path`.
43
+ */
44
+ export declare const buildComponentDetailUrl: (id: string, basePath?: string | null) => string;
45
+ /**
46
+ * Build the canonical docs read API URL for a pattern's detail metadata
47
+ * (`{basePath}/api/docs/patterns/{id}.json`). The id is URL-encoded; `basePath` is preserved.
48
+ */
49
+ export declare const buildPatternDetailUrl: (id: string, basePath?: string | null) => string;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Centralized, basePath-aware canonical artifact URL builder.
4
+ *
5
+ * Every artifact reference emitted in generated HTML and docs read data flows through this one
6
+ * builder. URLs are always of the canonical form:
7
+ *
8
+ * {basePath}/api/docs/artifacts/{artifactPath}
9
+ *
10
+ * intended for use directly in native `href`/`src` attributes. By contract these URLs never carry
11
+ * a query string and never depend on artifact-specific data attributes — artifact references come
12
+ * from structured metadata, not the URL or the HTML.
13
+ *
14
+ * This module is pure and runtime-agnostic (no Node or browser globals) so the build and the
15
+ * Next app can both import it.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.buildPatternDetailUrl = exports.buildComponentDetailUrl = exports.buildArtifactUrl = exports.normalizeBasePath = exports.DOCS_ROUTE_SEGMENT = exports.ARTIFACTS_ROUTE_SEGMENT = void 0;
19
+ /** Canonical route prefix all artifact URLs are served under. */
20
+ exports.ARTIFACTS_ROUTE_SEGMENT = 'api/docs/artifacts';
21
+ /** Route prefix for docs read API metadata (`.json`) reads. */
22
+ exports.DOCS_ROUTE_SEGMENT = 'api/docs';
23
+ /**
24
+ * Normalize a configured basePath to either an empty string or a single-leading-slash,
25
+ * no-trailing-slash form. Mirrors the Next app's `resolveBasePath` so builder output composes
26
+ * correctly with the configured Next `basePath`.
27
+ */
28
+ const normalizeBasePath = (basePath) => {
29
+ if (!basePath) {
30
+ return '';
31
+ }
32
+ const trimmed = basePath.replace(/^\/+|\/+$/g, '');
33
+ return trimmed ? `/${trimmed}` : '';
34
+ };
35
+ exports.normalizeBasePath = normalizeBasePath;
36
+ /**
37
+ * Split a logical artifact path into its non-empty segments. Leading/trailing/duplicate slashes
38
+ * are ignored; backslashes are treated as separators so Windows-style inputs normalize too.
39
+ */
40
+ const toArtifactSegments = (artifactPath) => artifactPath
41
+ .split(/[\\/]+/)
42
+ .filter((segment) => segment.length > 0);
43
+ /**
44
+ * Whether a logical path segment is a relative-traversal marker (`.` or `..`). These survive
45
+ * `encodeURIComponent` (dots are unreserved) and so must be rejected explicitly to keep emitted
46
+ * URLs canonical and contained — mirrors the server resolver's segment validation as defense in
47
+ * depth.
48
+ */
49
+ const isTraversalSegment = (segment) => segment === '.' || segment === '..';
50
+ /**
51
+ * Build a canonical artifact URL for a logical artifact path.
52
+ *
53
+ * Each path segment is individually `encodeURIComponent`-encoded (so a slash separating logical
54
+ * segments is preserved while reserved characters within a segment are escaped), and the
55
+ * configured `basePath` is preserved ahead of the canonical route.
56
+ *
57
+ * @param artifactPath Logical artifact path, e.g. `component/badge-primary.html`.
58
+ * @param basePath Optional configured base path; normalized like the Next app's basePath.
59
+ * @returns A canonical `{basePath}/api/docs/artifacts/{encodedPath}` URL.
60
+ * @throws If `artifactPath` has no usable segments, or contains a `.`/`..` traversal segment.
61
+ */
62
+ const buildArtifactUrl = (artifactPath, basePath) => {
63
+ const segments = toArtifactSegments(artifactPath);
64
+ if (segments.length === 0) {
65
+ throw new Error(`Cannot build artifact URL: empty artifact path "${artifactPath}".`);
66
+ }
67
+ if (segments.some(isTraversalSegment)) {
68
+ throw new Error(`Cannot build artifact URL: path traversal is not allowed in "${artifactPath}".`);
69
+ }
70
+ const encoded = segments.map((segment) => encodeURIComponent(segment)).join('/');
71
+ return `${(0, exports.normalizeBasePath)(basePath)}/${exports.ARTIFACTS_ROUTE_SEGMENT}/${encoded}`;
72
+ };
73
+ exports.buildArtifactUrl = buildArtifactUrl;
74
+ /**
75
+ * Build the canonical docs read API URL for a component's detail metadata
76
+ * (`{basePath}/api/docs/components/{id}.json`). The id is URL-encoded; `basePath` is preserved.
77
+ * This is the single source of the metadata-read URL that the build records as an entity's `path`.
78
+ */
79
+ const buildComponentDetailUrl = (id, basePath) => `${(0, exports.normalizeBasePath)(basePath)}/${exports.DOCS_ROUTE_SEGMENT}/components/${encodeURIComponent(id)}.json`;
80
+ exports.buildComponentDetailUrl = buildComponentDetailUrl;
81
+ /**
82
+ * Build the canonical docs read API URL for a pattern's detail metadata
83
+ * (`{basePath}/api/docs/patterns/{id}.json`). The id is URL-encoded; `basePath` is preserved.
84
+ */
85
+ const buildPatternDetailUrl = (id, basePath) => `${(0, exports.normalizeBasePath)(basePath)}/${exports.DOCS_ROUTE_SEGMENT}/patterns/${encodeURIComponent(id)}.json`;
86
+ exports.buildPatternDetailUrl = buildPatternDetailUrl;
@@ -136,7 +136,7 @@ function haveGlobalDepsChanged(cached, current) {
136
136
  * Gets all file paths that should be tracked for a component
137
137
  */
138
138
  function getComponentFilePaths(handoff, componentId) {
139
- var _a, _b, _c;
139
+ var _a, _b, _c, _d, _e, _f, _g;
140
140
  const runtimeComponent = (_c = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c[componentId];
141
141
  if (!runtimeComponent) {
142
142
  return { files: [] };
@@ -169,7 +169,7 @@ function getComponentFilePaths(handoff, componentId) {
169
169
  componentDirs.add((0, path_2.normalizePathForCompare)(path_1.default.dirname(templatePath)));
170
170
  }
171
171
  }
172
- catch (_d) {
172
+ catch (_h) {
173
173
  // File doesn't exist, still add to track
174
174
  files.push(templatePath);
175
175
  componentDirs.add((0, path_2.normalizePathForCompare)(path_1.default.dirname(templatePath)));
@@ -202,6 +202,24 @@ function getComponentFilePaths(handoff, componentId) {
202
202
  if (matchingConfigPath) {
203
203
  files.push(matchingConfigPath);
204
204
  }
205
+ // Include every pattern config file whose declaration references this component.
206
+ // When a pattern is added or modified, injectPatternPreviews injects new
207
+ // __pattern_* synthetic preview keys onto the referenced component, changing
208
+ // what processComponents must render. Without tracking these files here, the
209
+ // cache would incorrectly consider the component unchanged and skip the preview
210
+ // rebuild, leaving buildPatterns unable to find the required HTML fragments.
211
+ const runtimePatterns = (_f = (_e = (_d = handoff.runtimeConfig) === null || _d === void 0 ? void 0 : _d.entries) === null || _e === void 0 ? void 0 : _e.patterns) !== null && _f !== void 0 ? _f : {};
212
+ for (const configPath of configPaths) {
213
+ const entry = handoff.getConfigFileEntry(configPath);
214
+ if ((entry === null || entry === void 0 ? void 0 : entry.kind) !== 'pattern')
215
+ continue;
216
+ const pattern = runtimePatterns[entry.entityId];
217
+ if (!pattern)
218
+ continue;
219
+ if ((_g = pattern.components) === null || _g === void 0 ? void 0 : _g.some((ref) => ref.id === componentId)) {
220
+ files.push(configPath);
221
+ }
222
+ }
205
223
  return { files, templateDir };
206
224
  }
207
225
  /**
@@ -262,8 +280,34 @@ function hasComponentChanged(cached, current) {
262
280
  */
263
281
  function checkOutputExists(handoff, componentId) {
264
282
  return __awaiter(this, void 0, void 0, function* () {
265
- const outputPath = path_1.default.resolve(handoff.workingPath, 'public/api/component', `${componentId}.json`);
266
- return fs_extra_1.default.pathExists(outputPath);
283
+ var _a, _b, _c, _d, _e, _f;
284
+ const outputDirectory = path_1.default.resolve(handoff.workingPath, 'public/api/component');
285
+ const componentPath = path_1.default.resolve(outputDirectory, `${componentId}.json`);
286
+ if (!(yield fs_extra_1.default.pathExists(componentPath))) {
287
+ return false;
288
+ }
289
+ const runtimeComponent = (_c = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c[componentId];
290
+ const previewIds = new Set([
291
+ ...Object.keys((_d = runtimeComponent === null || runtimeComponent === void 0 ? void 0 : runtimeComponent.previews) !== null && _d !== void 0 ? _d : {}),
292
+ ...Object.keys((_e = runtimeComponent === null || runtimeComponent === void 0 ? void 0 : runtimeComponent.internalPatternPreviews) !== null && _e !== void 0 ? _e : {}),
293
+ ]);
294
+ try {
295
+ const component = yield fs_extra_1.default.readJson(componentPath);
296
+ for (const previewId of Object.keys((_f = component === null || component === void 0 ? void 0 : component.previews) !== null && _f !== void 0 ? _f : {})) {
297
+ previewIds.add(previewId);
298
+ }
299
+ }
300
+ catch (_g) {
301
+ return false;
302
+ }
303
+ for (const previewId of previewIds) {
304
+ const previewPath = path_1.default.resolve(outputDirectory, `${componentId}-${previewId}.html`);
305
+ const inspectPath = path_1.default.resolve(outputDirectory, `${componentId}-${previewId}-inspect.html`);
306
+ if (!(yield fs_extra_1.default.pathExists(previewPath)) || !(yield fs_extra_1.default.pathExists(inspectPath))) {
307
+ return false;
308
+ }
309
+ }
310
+ return true;
267
311
  });
268
312
  }
269
313
  /**
@@ -23,12 +23,11 @@ const command = {
23
23
  type: 'boolean',
24
24
  default: false,
25
25
  });
26
- return (0, utils_1.getSharedOptions)(yargs);
27
26
  },
28
27
  handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
29
28
  var _a;
30
29
  const handoff = new __1.default(args.debug, args.force);
31
- yield handoff.build((_a = args.skipComponents) !== null && _a !== void 0 ? _a : false);
30
+ yield handoff.build('static', (_a = args.skipComponents) !== null && _a !== void 0 ? _a : false);
32
31
  }),
33
32
  };
34
33
  exports.default = command;
@@ -0,0 +1,17 @@
1
+ import { CommandModule } from 'yargs';
2
+ import { type BuildPackage, type BuildTarget } from '../../app-builder';
3
+ import { SharedArgs } from '../types';
4
+ export interface BuildArgs extends SharedArgs {
5
+ target?: BuildTarget;
6
+ package?: BuildPackage;
7
+ skipComponents?: boolean;
8
+ }
9
+ /**
10
+ * `handoff-app build [--target static|registry] [--package standalone|vercel]` — builds the
11
+ * documentation site for the resolved target and packages it for the resolved deliverable.
12
+ * `--target` selects *what* is built; the optional, additive `--package` selects *how* it is
13
+ * packaged. Bare `build` resolves to the static target with the `out/<projectId>` export;
14
+ * `--package` never implies a `--target`.
15
+ */
16
+ declare const command: CommandModule<{}, BuildArgs>;
17
+ export default command;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const __1 = __importDefault(require("../../"));
16
+ const app_builder_1 = require("../../app-builder");
17
+ const logger_1 = require("../../utils/logger");
18
+ const utils_1 = require("../utils");
19
+ const BUILD_TARGETS = ['static', 'registry'];
20
+ const BUILD_PACKAGES = ['standalone', 'vercel'];
21
+ /**
22
+ * `handoff-app build [--target static|registry] [--package standalone|vercel]` — builds the
23
+ * documentation site for the resolved target and packages it for the resolved deliverable.
24
+ * `--target` selects *what* is built; the optional, additive `--package` selects *how* it is
25
+ * packaged. Bare `build` resolves to the static target with the `out/<projectId>` export;
26
+ * `--package` never implies a `--target`.
27
+ */
28
+ const command = {
29
+ command: 'build',
30
+ describe: 'Build the design system for the given target (default: static export)',
31
+ builder: (yargs) => {
32
+ return (0, utils_1.getSharedOptions)(yargs)
33
+ .option('target', {
34
+ describe: 'Build target (what is built)',
35
+ choices: BUILD_TARGETS,
36
+ default: app_builder_1.DEFAULT_BUILD_TARGET,
37
+ })
38
+ .option('package', {
39
+ describe: 'Packaging format (how it is delivered). Omit for the default per-target deliverable.',
40
+ choices: BUILD_PACKAGES,
41
+ })
42
+ .option('skip-components', {
43
+ describe: 'Skip building components before building the app',
44
+ type: 'boolean',
45
+ default: false,
46
+ });
47
+ },
48
+ handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
49
+ var _a, _b;
50
+ const handoff = new __1.default(args.debug, args.force);
51
+ try {
52
+ yield handoff.build((_a = args.target) !== null && _a !== void 0 ? _a : app_builder_1.DEFAULT_BUILD_TARGET, (_b = args.skipComponents) !== null && _b !== void 0 ? _b : false, args.package);
53
+ }
54
+ catch (error) {
55
+ // Expected business/flow failures (invalid combinations, unsupported runtime modes) print as a
56
+ // single actionable line; unexpected errors re-throw so their stack trace is preserved.
57
+ if (error instanceof app_builder_1.HandoffBuildError) {
58
+ logger_1.Logger.error(error.message);
59
+ process.exitCode = 1;
60
+ return;
61
+ }
62
+ throw error;
63
+ }
64
+ }),
65
+ };
66
+ exports.default = command;
@@ -0,0 +1,24 @@
1
+ import { CommandModule } from 'yargs';
2
+ import { SharedArgs } from '../types';
3
+ /** Entity kinds checkout-able from a connected workspace. */
4
+ declare const ENTITY_KINDS: readonly ["component", "pattern", "page", "tokens", "assets"];
5
+ export interface CheckoutArgs extends SharedArgs {
6
+ type: (typeof ENTITY_KINDS)[number];
7
+ id?: string;
8
+ }
9
+ /**
10
+ * `handoff-app checkout <component|pattern|page> <id>` — pull an entity from the connected registry
11
+ * into this workspace: writes its source files in standard authoring form and synthesizes a local
12
+ * declaration.
13
+ *
14
+ * `handoff-app checkout tokens [setId]` — pull every published token set (or only the named set) into
15
+ * this workspace: reconstruct `tokens.json` and restore the generated token files.
16
+ *
17
+ * `handoff-app checkout assets [collection]` pulls every published asset collection (or only the
18
+ * named one) into this workspace, recreating the standard asset files, sprite/manifest, and archives.
19
+ * Available only from a connected workspace (`runtime.mode: workspace` + a configured
20
+ * `registryConnection`). Overwriting existing local files requires `--force` or an interactive
21
+ * confirmation.
22
+ */
23
+ declare const command: CommandModule<{}, CheckoutArgs>;
24
+ export default command;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const __1 = __importDefault(require("../../"));
16
+ const logger_1 = require("../../utils/logger");
17
+ const utils_1 = require("../utils");
18
+ /** Entity kinds checkout-able from a connected workspace. */
19
+ const ENTITY_KINDS = ['component', 'pattern', 'page', 'tokens', 'assets'];
20
+ /**
21
+ * `handoff-app checkout <component|pattern|page> <id>` — pull an entity from the connected registry
22
+ * into this workspace: writes its source files in standard authoring form and synthesizes a local
23
+ * declaration.
24
+ *
25
+ * `handoff-app checkout tokens [setId]` — pull every published token set (or only the named set) into
26
+ * this workspace: reconstruct `tokens.json` and restore the generated token files.
27
+ *
28
+ * `handoff-app checkout assets [collection]` pulls every published asset collection (or only the
29
+ * named one) into this workspace, recreating the standard asset files, sprite/manifest, and archives.
30
+ * Available only from a connected workspace (`runtime.mode: workspace` + a configured
31
+ * `registryConnection`). Overwriting existing local files requires `--force` or an interactive
32
+ * confirmation.
33
+ */
34
+ const command = {
35
+ command: 'checkout <type> [id]',
36
+ describe: 'Pull a component, pattern, page, design tokens, or assets from the connected registry into this workspace',
37
+ builder: (yargs) => {
38
+ return (0, utils_1.getSharedOptions)(yargs)
39
+ .positional('type', {
40
+ describe: 'The kind of entity to checkout',
41
+ choices: ENTITY_KINDS,
42
+ type: 'string',
43
+ })
44
+ .positional('id', {
45
+ describe: 'The stable id of the entity (component/pattern/page id, token set id, or asset collection); optional for tokens/assets',
46
+ type: 'string',
47
+ });
48
+ },
49
+ handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
50
+ const handoff = new __1.default(args.debug, args.force);
51
+ try {
52
+ if (args.type === 'tokens') {
53
+ yield handoff.checkoutTokens(args.id);
54
+ return;
55
+ }
56
+ if (args.type === 'assets') {
57
+ yield handoff.checkoutAssets(args.id);
58
+ return;
59
+ }
60
+ if (!args.id) {
61
+ throw new Error(`An id is required to checkout a ${args.type} (e.g. "handoff-app checkout ${args.type} <id>").`);
62
+ }
63
+ yield handoff.checkout(args.type, args.id);
64
+ }
65
+ catch (error) {
66
+ logger_1.Logger.error(error instanceof Error ? error.message : String(error));
67
+ process.exitCode = 1;
68
+ }
69
+ }),
70
+ };
71
+ exports.default = command;
@@ -0,0 +1,11 @@
1
+ import { CommandModule } from 'yargs';
2
+ import { SharedArgs } from '../types';
3
+ export interface DbMigrateArgs extends SharedArgs {
4
+ }
5
+ /**
6
+ * `handoff-app db:migrate` — runs the package-owned registry database migrations against the
7
+ * configured PostgreSQL/Neon database. Reads the consuming project's config + DB env vars and runs
8
+ * independently of `build`.
9
+ */
10
+ declare const command: CommandModule<{}, DbMigrateArgs>;
11
+ export default command;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const __1 = __importDefault(require("../../"));
16
+ const utils_1 = require("../utils");
17
+ /**
18
+ * `handoff-app db:migrate` — runs the package-owned registry database migrations against the
19
+ * configured PostgreSQL/Neon database. Reads the consuming project's config + DB env vars and runs
20
+ * independently of `build`.
21
+ */
22
+ const command = {
23
+ command: 'db:migrate',
24
+ describe: 'Run registry database migrations (Drizzle / PostgreSQL)',
25
+ builder: (yargs) => {
26
+ return (0, utils_1.getSharedOptions)(yargs);
27
+ },
28
+ handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
29
+ const handoff = new __1.default(args.debug, args.force);
30
+ yield handoff.dbMigrate();
31
+ }),
32
+ };
33
+ exports.default = command;
@@ -4,8 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.commands = void 0;
7
+ const build_1 = __importDefault(require("./build"));
7
8
  const app_1 = __importDefault(require("./build/app"));
8
9
  const components_1 = __importDefault(require("./build/components"));
10
+ const checkout_1 = __importDefault(require("./checkout"));
11
+ const migrate_1 = __importDefault(require("./db/migrate"));
9
12
  const dev_1 = __importDefault(require("./dev"));
10
13
  const config_1 = __importDefault(require("./eject/config"));
11
14
  const pages_1 = __importDefault(require("./eject/pages"));
@@ -15,12 +18,16 @@ const init_1 = __importDefault(require("./init"));
15
18
  const component_1 = __importDefault(require("./make/component"));
16
19
  const page_1 = __importDefault(require("./make/page"));
17
20
  const template_1 = __importDefault(require("./make/template"));
21
+ const publish_1 = __importDefault(require("./publish"));
18
22
  const scaffold_1 = __importDefault(require("./scaffold"));
19
23
  const start_1 = __importDefault(require("./start"));
20
24
  const components_2 = __importDefault(require("./validate/components"));
21
25
  exports.commands = [
26
+ build_1.default,
22
27
  app_1.default,
23
28
  components_1.default,
29
+ checkout_1.default,
30
+ migrate_1.default,
24
31
  dev_1.default,
25
32
  config_1.default,
26
33
  pages_1.default,
@@ -30,6 +37,7 @@ exports.commands = [
30
37
  page_1.default,
31
38
  component_1.default,
32
39
  template_1.default,
40
+ publish_1.default,
33
41
  scaffold_1.default,
34
42
  start_1.default,
35
43
  components_2.default,