@tscircuit/fake-snippets 0.0.121 → 0.0.123

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 (737) hide show
  1. package/dist/bundle.js +9422 -0
  2. package/dist/index.d.ts +2190 -0
  3. package/dist/index.js +3961 -0
  4. package/dist/schema.d.ts +3142 -0
  5. package/{fake-snippets-api/lib/db/schema.ts → dist/schema.js} +147 -195
  6. package/package.json +5 -2
  7. package/.github/CODEOWNERS +0 -1
  8. package/.github/workflows/bun-formatcheck.yml +0 -26
  9. package/.github/workflows/bun-pver-release.yml +0 -53
  10. package/.github/workflows/bun-test.yml +0 -28
  11. package/.github/workflows/bun-typecheck.yml +0 -26
  12. package/.github/workflows/bundle-size-analysis.yml +0 -79
  13. package/.github/workflows/stale.yml +0 -40
  14. package/.github/workflows/update-package.yml +0 -58
  15. package/.github/workflows/update-snapshots.yml +0 -49
  16. package/CLAUDE.md +0 -92
  17. package/CONTRIBUTING.md +0 -59
  18. package/api/generated-index.js +0 -456
  19. package/biome.json +0 -67
  20. package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +0 -141
  21. package/bun-tests/fake-snippets-api/fixtures/preload.ts +0 -18
  22. package/bun-tests/fake-snippets-api/fixtures/start-server.ts +0 -48
  23. package/bun-tests/fake-snippets-api/routes/accounts/get.test.ts +0 -64
  24. package/bun-tests/fake-snippets-api/routes/accounts/get_account_balance.test.ts +0 -14
  25. package/bun-tests/fake-snippets-api/routes/ai_reviews/create.test.ts +0 -21
  26. package/bun-tests/fake-snippets-api/routes/ai_reviews/get.test.ts +0 -16
  27. package/bun-tests/fake-snippets-api/routes/ai_reviews/list.test.ts +0 -14
  28. package/bun-tests/fake-snippets-api/routes/ai_reviews/process_review.test.ts +0 -16
  29. package/bun-tests/fake-snippets-api/routes/bug_reports/create.test.ts +0 -37
  30. package/bun-tests/fake-snippets-api/routes/bug_reports/upload_file.test.ts +0 -89
  31. package/bun-tests/fake-snippets-api/routes/datasheets/create.test.ts +0 -16
  32. package/bun-tests/fake-snippets-api/routes/datasheets/get.test.ts +0 -54
  33. package/bun-tests/fake-snippets-api/routes/datasheets/list.test.ts +0 -49
  34. package/bun-tests/fake-snippets-api/routes/datasheets/process_all_datasheets.test.ts +0 -22
  35. package/bun-tests/fake-snippets-api/routes/datasheets/run_async_tasks.test.ts +0 -19
  36. package/bun-tests/fake-snippets-api/routes/health.test.ts +0 -9
  37. package/bun-tests/fake-snippets-api/routes/order_files/get.test.ts +0 -48
  38. package/bun-tests/fake-snippets-api/routes/order_files/upload.test.ts +0 -77
  39. package/bun-tests/fake-snippets-api/routes/order_quotes/create.test.ts +0 -33
  40. package/bun-tests/fake-snippets-api/routes/orders/create.test.ts +0 -17
  41. package/bun-tests/fake-snippets-api/routes/orders/get.test.ts +0 -199
  42. package/bun-tests/fake-snippets-api/routes/orders/list.test.ts +0 -30
  43. package/bun-tests/fake-snippets-api/routes/orgs/add_member.test.ts +0 -26
  44. package/bun-tests/fake-snippets-api/routes/orgs/create.test.ts +0 -37
  45. package/bun-tests/fake-snippets-api/routes/orgs/get.test.ts +0 -53
  46. package/bun-tests/fake-snippets-api/routes/orgs/get_member.test.ts +0 -110
  47. package/bun-tests/fake-snippets-api/routes/orgs/list.test.ts +0 -17
  48. package/bun-tests/fake-snippets-api/routes/orgs/list_members.test.ts +0 -24
  49. package/bun-tests/fake-snippets-api/routes/orgs/remove_member.test.ts +0 -81
  50. package/bun-tests/fake-snippets-api/routes/orgs/update.test.ts +0 -151
  51. package/bun-tests/fake-snippets-api/routes/package_builds/get.test.ts +0 -279
  52. package/bun-tests/fake-snippets-api/routes/package_builds/list.test.ts +0 -292
  53. package/bun-tests/fake-snippets-api/routes/package_files/create.test.ts +0 -320
  54. package/bun-tests/fake-snippets-api/routes/package_files/create_or_update.test.ts +0 -603
  55. package/bun-tests/fake-snippets-api/routes/package_files/delete.test.ts +0 -233
  56. package/bun-tests/fake-snippets-api/routes/package_files/download.test.ts +0 -248
  57. package/bun-tests/fake-snippets-api/routes/package_files/get.test.ts +0 -230
  58. package/bun-tests/fake-snippets-api/routes/package_files/list.test.ts +0 -212
  59. package/bun-tests/fake-snippets-api/routes/package_releases/create.test.ts +0 -171
  60. package/bun-tests/fake-snippets-api/routes/package_releases/get.test.ts +0 -181
  61. package/bun-tests/fake-snippets-api/routes/package_releases/get_image_generation_fields.test.ts +0 -38
  62. package/bun-tests/fake-snippets-api/routes/package_releases/list.test.ts +0 -149
  63. package/bun-tests/fake-snippets-api/routes/package_releases/update.test.ts +0 -160
  64. package/bun-tests/fake-snippets-api/routes/packages/add_star.test.ts +0 -129
  65. package/bun-tests/fake-snippets-api/routes/packages/create.test.ts +0 -67
  66. package/bun-tests/fake-snippets-api/routes/packages/delete.test.ts +0 -74
  67. package/bun-tests/fake-snippets-api/routes/packages/fork.test.ts +0 -132
  68. package/bun-tests/fake-snippets-api/routes/packages/get.test.ts +0 -112
  69. package/bun-tests/fake-snippets-api/routes/packages/images.test.ts +0 -72
  70. package/bun-tests/fake-snippets-api/routes/packages/list-1.test.ts +0 -145
  71. package/bun-tests/fake-snippets-api/routes/packages/list-2.test.ts +0 -48
  72. package/bun-tests/fake-snippets-api/routes/packages/list_latest.test.ts +0 -110
  73. package/bun-tests/fake-snippets-api/routes/packages/list_trending.test.ts +0 -103
  74. package/bun-tests/fake-snippets-api/routes/packages/remove_star.test.ts +0 -131
  75. package/bun-tests/fake-snippets-api/routes/packages/update.test.ts +0 -217
  76. package/bun-tests/fake-snippets-api/routes/proxy.test.ts +0 -42
  77. package/bun.lock +0 -2724
  78. package/bunfig.toml +0 -3
  79. package/components.json +0 -20
  80. package/dist/assets/404-CnNkOMw-.js +0 -1
  81. package/dist/assets/Analytics-DIw7l2gi.js +0 -84
  82. package/dist/assets/BuildsList-CeqVVhbz.js +0 -1
  83. package/dist/assets/CodeAndPreview-Dycd0s15.js +0 -722
  84. package/dist/assets/DownloadButtonAndMenu-OIUhbKkj.js +0 -194
  85. package/dist/assets/FileSaver.min-BDsOlqKl.js +0 -1
  86. package/dist/assets/Footer-DU-HdqGk.js +0 -1
  87. package/dist/assets/GithubAvatarWithFallback-CQhrBiKP.js +0 -6
  88. package/dist/assets/Header-CI4GZVOv.js +0 -1
  89. package/dist/assets/Header2-CrMDmo3P.js +0 -5
  90. package/dist/assets/NotFound-DaXtEPsC.js +0 -1
  91. package/dist/assets/OrganizationCard-Bs2dw-AL.js +0 -1
  92. package/dist/assets/PackageBreadcrumb-DpOpPbGc.js +0 -6
  93. package/dist/assets/PackageCard-ejE2dLlA.js +0 -16
  94. package/dist/assets/PackageSearchResults-BI3Rtmr2.js +0 -1
  95. package/dist/assets/ProfileRouter-4xNgtXr5.js +0 -6
  96. package/dist/assets/alert-dialog-DrOB4Tui.js +0 -1
  97. package/dist/assets/authorize-D-5R3QHA.js +0 -16
  98. package/dist/assets/badge-Bk-k6kyg.js +0 -1
  99. package/dist/assets/card-CzXDit7x.js +0 -1
  100. package/dist/assets/circle-alert-Du9-4of0.js +0 -6
  101. package/dist/assets/circle-check-big-KaRyRsht.js +0 -6
  102. package/dist/assets/cpu-BnvjzmIA.js +0 -6
  103. package/dist/assets/create-organization-BHNFvE7B.js +0 -1
  104. package/dist/assets/dashboard-DDH4V91X.js +0 -11
  105. package/dist/assets/datasheet-DqKtWt-O.js +0 -1
  106. package/dist/assets/datasheets-4W6pEMf3.js +0 -1
  107. package/dist/assets/dev-login-CbHdDthp.js +0 -1
  108. package/dist/assets/editor-bqg9Yv91.js +0 -1
  109. package/dist/assets/editor_example_1-1000w.webp +0 -0
  110. package/dist/assets/editor_example_1-1200w.webp +0 -0
  111. package/dist/assets/editor_example_1-1600w.webp +0 -0
  112. package/dist/assets/editor_example_1-2000w.webp +0 -0
  113. package/dist/assets/editor_example_1-400w.webp +0 -0
  114. package/dist/assets/editor_example_1-600w.webp +0 -0
  115. package/dist/assets/editor_example_1-800w.webp +0 -0
  116. package/dist/assets/editor_example_1_more_square-1000w.webp +0 -0
  117. package/dist/assets/editor_example_1_more_square-1200w.webp +0 -0
  118. package/dist/assets/editor_example_1_more_square-1600w.webp +0 -0
  119. package/dist/assets/editor_example_1_more_square-2000w.webp +0 -0
  120. package/dist/assets/editor_example_1_more_square-400w.webp +0 -0
  121. package/dist/assets/editor_example_1_more_square-600w.webp +0 -0
  122. package/dist/assets/editor_example_1_more_square-800w.webp +0 -0
  123. package/dist/assets/editor_example_2-1000w.webp +0 -0
  124. package/dist/assets/editor_example_2-1200w.webp +0 -0
  125. package/dist/assets/editor_example_2-1600w.webp +0 -0
  126. package/dist/assets/editor_example_2-2000w.webp +0 -0
  127. package/dist/assets/editor_example_2-400w.webp +0 -0
  128. package/dist/assets/editor_example_2-600w.webp +0 -0
  129. package/dist/assets/editor_example_2-800w.webp +0 -0
  130. package/dist/assets/example_schematic-1000w.webp +0 -0
  131. package/dist/assets/example_schematic-1200w.webp +0 -0
  132. package/dist/assets/example_schematic-1600w.webp +0 -0
  133. package/dist/assets/example_schematic-2000w.webp +0 -0
  134. package/dist/assets/example_schematic-400w.webp +0 -0
  135. package/dist/assets/example_schematic-600w.webp +0 -0
  136. package/dist/assets/example_schematic-800w.webp +0 -0
  137. package/dist/assets/eye-B_NMTTT7.js +0 -6
  138. package/dist/assets/fallback-image.svg +0 -1
  139. package/dist/assets/favicon-BwEjZKGP.ico +0 -0
  140. package/dist/assets/formatTimeAgo-CawXna5h.js +0 -6
  141. package/dist/assets/github-DjKGjbX1.js +0 -6
  142. package/dist/assets/github-dark-DHJKELXO.js +0 -1
  143. package/dist/assets/github-light-DAi9KRSo.js +0 -1
  144. package/dist/assets/hash-DfKYpqTm.js +0 -6
  145. package/dist/assets/index-B17tE1vy.js +0 -1
  146. package/dist/assets/index-BQPj88OW.js +0 -6051
  147. package/dist/assets/index-DvNLZBaq.js +0 -6
  148. package/dist/assets/keyboard-4b_qLHIF.js +0 -11
  149. package/dist/assets/label-CTudXc4q.js +0 -1
  150. package/dist/assets/landing-Cjvvx-9q.js +0 -11
  151. package/dist/assets/latest-DMk4BmXW.js +0 -1
  152. package/dist/assets/layers-BJ1iwaVM.js +0 -6
  153. package/dist/assets/load-prettier-DgbV1Jgu.js +0 -1
  154. package/dist/assets/lock-BOZRJdUv.js +0 -6
  155. package/dist/assets/main-DPEM9abA.js +0 -26
  156. package/dist/assets/main-MTKdI4FA.css +0 -1
  157. package/dist/assets/my-orders-B7lEyNR9.js +0 -1
  158. package/dist/assets/organization-settings-rNvhYFgZ.js +0 -6
  159. package/dist/assets/package-editor-T4WIRP49.js +0 -1
  160. package/dist/assets/pen-D54fxNRf.js +0 -6
  161. package/dist/assets/plus-KkE_6Dq2.js +0 -6
  162. package/dist/assets/preview-release-DWhKHFWp.js +0 -1
  163. package/dist/assets/quickstart-WF3HR9Dc.js +0 -1
  164. package/dist/assets/refresh-cw-aWASTRku.js +0 -6
  165. package/dist/assets/release-builds-COa5ndHa.js +0 -1
  166. package/dist/assets/release-detail-iclJPUO-.js +0 -6
  167. package/dist/assets/releases-Clsyp-7n.js +0 -1
  168. package/dist/assets/role-badge-BGF_IMlO.js +0 -16
  169. package/dist/assets/search-CwH23pAU.js +0 -1
  170. package/dist/assets/select-BN8AF1J7.js +0 -1
  171. package/dist/assets/settings-B2bMEtS4.js +0 -6
  172. package/dist/assets/skeleton-DLAS40-y.js +0 -1
  173. package/dist/assets/svg-to-png-BX4YEHCP-JcDm8Hc5.js +0 -1
  174. package/dist/assets/svg-to-png-BX4YEHCP-pNo9Afg8.js +0 -1
  175. package/dist/assets/tabs-Ce0NFuwd.js +0 -1
  176. package/dist/assets/timeAgo-VY0F2EV9.js +0 -10
  177. package/dist/assets/tooltip-C1pwvC0K.js +0 -11
  178. package/dist/assets/trash-2-BW3eClHz.js +0 -6
  179. package/dist/assets/trending-C8246HGf.js +0 -1
  180. package/dist/assets/triangle-alert-BMIBEO1D.js +0 -6
  181. package/dist/assets/tsx-COt5Ahok.js +0 -1
  182. package/dist/assets/use-create-datasheet-B7TDsTUt.js +0 -1
  183. package/dist/assets/use-delete-package-DLKtoTOj.js +0 -1
  184. package/dist/assets/use-download-zip-CAOKjGXW.js +0 -1
  185. package/dist/assets/use-list-user-orgs-CgJIT7N4.js +0 -1
  186. package/dist/assets/use-organization-XwYYTFck.js +0 -1
  187. package/dist/assets/use-package-builds-Bx8rfxi1.js +0 -1
  188. package/dist/assets/use-package-by-package-name-1s1Pcarw.js +0 -1
  189. package/dist/assets/use-package-files-CmmWVuGn.js +0 -1
  190. package/dist/assets/use-package-release-by-id-or-version-BuuXcSZq.js +0 -1
  191. package/dist/assets/use-package-release-images-BMaZtvmk.js +0 -1
  192. package/dist/assets/use-packages-base-api-url-DA1hucM7.js +0 -1
  193. package/dist/assets/useQueries-BJ7Ue7HV.js +0 -1
  194. package/dist/assets/user-settings-BqO5FkMf.js +0 -1
  195. package/dist/assets/view-package-C-OvJr_Q.js +0 -165
  196. package/dist/assets/vitesse-light-CVO1_9PV.js +0 -1
  197. package/dist/assets/wasm-CG6Dc4jp.js +0 -1
  198. package/dist/index.html +0 -127
  199. package/dist/landing.html +0 -34
  200. package/dist/robots.txt +0 -9
  201. package/dist/sitemap.xml +0 -118
  202. package/dist/stats.html +0 -4949
  203. package/docs/CIRCUIT_JSON_SOURCE_COMPONENT_OVERVIEW.md +0 -151
  204. package/fake-snippets-api/README.md +0 -6
  205. package/fake-snippets-api/biome.json +0 -47
  206. package/fake-snippets-api/lib/db/autoload-dev-packages.ts +0 -222
  207. package/fake-snippets-api/lib/db/autoload-packages.json +0 -8
  208. package/fake-snippets-api/lib/db/db-client.ts +0 -1857
  209. package/fake-snippets-api/lib/db/seed.ts +0 -1843
  210. package/fake-snippets-api/lib/index.ts +0 -3
  211. package/fake-snippets-api/lib/middleware/with-ctx-error.ts +0 -26
  212. package/fake-snippets-api/lib/middleware/with-db.ts +0 -15
  213. package/fake-snippets-api/lib/middleware/with-error-handling.ts +0 -24
  214. package/fake-snippets-api/lib/middleware/with-optional-session-auth.ts +0 -53
  215. package/fake-snippets-api/lib/middleware/with-request-logging.ts +0 -54
  216. package/fake-snippets-api/lib/middleware/with-session-auth.ts +0 -102
  217. package/fake-snippets-api/lib/middleware/with-winter-spec.ts +0 -24
  218. package/fake-snippets-api/lib/package_file/generate-fs-sha.ts +0 -20
  219. package/fake-snippets-api/lib/package_file/get-package-file-id-from-file-descriptor.ts +0 -173
  220. package/fake-snippets-api/lib/package_release/find-package-release-id.ts +0 -120
  221. package/fake-snippets-api/lib/public-mapping/public-map-org.ts +0 -34
  222. package/fake-snippets-api/lib/public-mapping/public-map-package-build.ts +0 -48
  223. package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +0 -88
  224. package/fake-snippets-api/lib/public-mapping/public-map-package.ts +0 -60
  225. package/fake-snippets-api/lib/with-winter-spec.ts +0 -1
  226. package/fake-snippets-api/next-env.d.ts +0 -5
  227. package/fake-snippets-api/routes/api/_fake/ai_reviews/process_review.ts +0 -31
  228. package/fake-snippets-api/routes/api/_fake/datasheets/process_all_datasheets.ts +0 -38
  229. package/fake-snippets-api/routes/api/_fake/db.ts +0 -11
  230. package/fake-snippets-api/routes/api/_fake/move_orders_forward.ts +0 -65
  231. package/fake-snippets-api/routes/api/_fake/received_quotes.ts +0 -112
  232. package/fake-snippets-api/routes/api/_fake/run_async_tasks.ts +0 -12
  233. package/fake-snippets-api/routes/api/_fake/seed.ts +0 -13
  234. package/fake-snippets-api/routes/api/accounts/get.ts +0 -35
  235. package/fake-snippets-api/routes/api/accounts/get_account_balance.ts +0 -22
  236. package/fake-snippets-api/routes/api/accounts/search.ts +0 -20
  237. package/fake-snippets-api/routes/api/accounts/update.ts +0 -32
  238. package/fake-snippets-api/routes/api/ai/[...anyroute].ts +0 -31
  239. package/fake-snippets-api/routes/api/ai.ts +0 -2
  240. package/fake-snippets-api/routes/api/ai_reviews/create.ts +0 -44
  241. package/fake-snippets-api/routes/api/ai_reviews/get.ts +0 -24
  242. package/fake-snippets-api/routes/api/ai_reviews/list.ts +0 -14
  243. package/fake-snippets-api/routes/api/aistream/[...anyroute].ts +0 -65
  244. package/fake-snippets-api/routes/api/autocomplete/create_autocomplete.ts +0 -16
  245. package/fake-snippets-api/routes/api/bug_reports/create.ts +0 -43
  246. package/fake-snippets-api/routes/api/bug_reports/upload_file.ts +0 -113
  247. package/fake-snippets-api/routes/api/datasheets/create.ts +0 -18
  248. package/fake-snippets-api/routes/api/datasheets/get.ts +0 -35
  249. package/fake-snippets-api/routes/api/datasheets/list.ts +0 -29
  250. package/fake-snippets-api/routes/api/github/installations/create_new_installation_redirect.ts +0 -75
  251. package/fake-snippets-api/routes/api/github/repos/list_available.ts +0 -91
  252. package/fake-snippets-api/routes/api/github/repos/refresh.ts +0 -44
  253. package/fake-snippets-api/routes/api/health.ts +0 -9
  254. package/fake-snippets-api/routes/api/internal/sessions/create_without_auth.ts +0 -63
  255. package/fake-snippets-api/routes/api/order_files/get.ts +0 -28
  256. package/fake-snippets-api/routes/api/order_files/upload.ts +0 -46
  257. package/fake-snippets-api/routes/api/order_quotes/create.ts +0 -60
  258. package/fake-snippets-api/routes/api/order_quotes/create_all_vendor_quotes.ts +0 -30
  259. package/fake-snippets-api/routes/api/order_quotes/get.ts +0 -29
  260. package/fake-snippets-api/routes/api/orders/create.ts +0 -70
  261. package/fake-snippets-api/routes/api/orders/get.ts +0 -168
  262. package/fake-snippets-api/routes/api/orders/list.ts +0 -15
  263. package/fake-snippets-api/routes/api/orgs/add_member.ts +0 -52
  264. package/fake-snippets-api/routes/api/orgs/create.ts +0 -48
  265. package/fake-snippets-api/routes/api/orgs/get.ts +0 -39
  266. package/fake-snippets-api/routes/api/orgs/get_member.ts +0 -67
  267. package/fake-snippets-api/routes/api/orgs/list.ts +0 -31
  268. package/fake-snippets-api/routes/api/orgs/list_members.ts +0 -106
  269. package/fake-snippets-api/routes/api/orgs/remove_member.ts +0 -46
  270. package/fake-snippets-api/routes/api/orgs/update.ts +0 -118
  271. package/fake-snippets-api/routes/api/package_builds/get.ts +0 -70
  272. package/fake-snippets-api/routes/api/package_builds/list.ts +0 -97
  273. package/fake-snippets-api/routes/api/package_files/create.ts +0 -135
  274. package/fake-snippets-api/routes/api/package_files/create_or_update.ts +0 -194
  275. package/fake-snippets-api/routes/api/package_files/delete.ts +0 -109
  276. package/fake-snippets-api/routes/api/package_files/download.ts +0 -87
  277. package/fake-snippets-api/routes/api/package_files/get.ts +0 -68
  278. package/fake-snippets-api/routes/api/package_files/list.ts +0 -54
  279. package/fake-snippets-api/routes/api/package_releases/create.ts +0 -109
  280. package/fake-snippets-api/routes/api/package_releases/get.ts +0 -137
  281. package/fake-snippets-api/routes/api/package_releases/list.ts +0 -85
  282. package/fake-snippets-api/routes/api/package_releases/rebuild.ts +0 -66
  283. package/fake-snippets-api/routes/api/package_releases/update.ts +0 -122
  284. package/fake-snippets-api/routes/api/packages/add_star.ts +0 -84
  285. package/fake-snippets-api/routes/api/packages/create.ts +0 -136
  286. package/fake-snippets-api/routes/api/packages/delete.ts +0 -41
  287. package/fake-snippets-api/routes/api/packages/fork.ts +0 -165
  288. package/fake-snippets-api/routes/api/packages/generate_from_jlcpcb.ts +0 -111
  289. package/fake-snippets-api/routes/api/packages/get.ts +0 -81
  290. package/fake-snippets-api/routes/api/packages/images/[owner_github_username]/[unscoped_name]/[view_format].ts +0 -119
  291. package/fake-snippets-api/routes/api/packages/list.ts +0 -105
  292. package/fake-snippets-api/routes/api/packages/list_latest.ts +0 -29
  293. package/fake-snippets-api/routes/api/packages/list_trending.ts +0 -43
  294. package/fake-snippets-api/routes/api/packages/remove_star.ts +0 -70
  295. package/fake-snippets-api/routes/api/packages/search.ts +0 -19
  296. package/fake-snippets-api/routes/api/packages/update.ts +0 -112
  297. package/fake-snippets-api/routes/api/packages/update_ai_description.ts +0 -37
  298. package/fake-snippets-api/routes/api/proxy.ts +0 -128
  299. package/fake-snippets-api/routes/api/snippets/add_star.ts +0 -62
  300. package/fake-snippets-api/routes/api/snippets/create.ts +0 -184
  301. package/fake-snippets-api/routes/api/snippets/delete.ts +0 -41
  302. package/fake-snippets-api/routes/api/snippets/download.ts +0 -162
  303. package/fake-snippets-api/routes/api/snippets/generate_from_jlcpcb.ts +0 -48
  304. package/fake-snippets-api/routes/api/snippets/get.ts +0 -83
  305. package/fake-snippets-api/routes/api/snippets/get_image.ts +0 -65
  306. package/fake-snippets-api/routes/api/snippets/images/[author]/[snippet_name]/[typeFormat].ts +0 -80
  307. package/fake-snippets-api/routes/api/snippets/list.ts +0 -151
  308. package/fake-snippets-api/routes/api/snippets/list_latest.ts +0 -13
  309. package/fake-snippets-api/routes/api/snippets/list_trending.ts +0 -38
  310. package/fake-snippets-api/routes/api/snippets/remove_star.ts +0 -42
  311. package/fake-snippets-api/routes/api/snippets/search.ts +0 -18
  312. package/fake-snippets-api/routes/api/snippets/update.ts +0 -114
  313. package/fake-snippets-api/utils/normalizeProjectFilePath.ts +0 -60
  314. package/fake-snippets-api/utils/order-steps.ts +0 -20
  315. package/favicon.ico +0 -0
  316. package/index.html +0 -125
  317. package/landing.html +0 -23
  318. package/playwright-tests/ai-page.spec.ts +0 -19
  319. package/playwright-tests/circuit-json-import.spec.ts +0 -133
  320. package/playwright-tests/cmd-click.spec.ts +0 -43
  321. package/playwright-tests/dashboard-page.spec.ts +0 -10
  322. package/playwright-tests/editor-page.spec.ts +0 -15
  323. package/playwright-tests/exampleCircuitJson.ts +0 -498
  324. package/playwright-tests/files-dialog.spec.ts +0 -19
  325. package/playwright-tests/footprint-dialog/footprint-dialog.spec.ts +0 -27
  326. package/playwright-tests/footprint-dialog/footprint-insertion.spec.ts +0 -38
  327. package/playwright-tests/footprint-dialog/footprint-preview.spec.ts +0 -34
  328. package/playwright-tests/footprint-dialog/footprint-selection.spec.ts +0 -29
  329. package/playwright-tests/handle-manual-edits.spec.ts +0 -55
  330. package/playwright-tests/home-page.spec.ts +0 -10
  331. package/playwright-tests/images.spec.ts +0 -17
  332. package/playwright-tests/manual-edits.spec.ts +0 -89
  333. package/playwright-tests/preview-page.spec.ts +0 -7
  334. package/playwright-tests/profile-page.spec.ts +0 -108
  335. package/playwright-tests/quickstart-page.spec.ts +0 -10
  336. package/playwright-tests/search-links.spec.ts +0 -21
  337. package/playwright-tests/search.spec.ts +0 -27
  338. package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-lg.png +0 -0
  339. package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-md.png +0 -0
  340. package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-xs.png +0 -0
  341. package/playwright-tests/snapshots/cmd-click.spec.ts-underlined-imports.png +0 -0
  342. package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-lg.png +0 -0
  343. package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-md.png +0 -0
  344. package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-xs.png +0 -0
  345. package/playwright-tests/snapshots/editor-page.spec.ts-editor-with-snippet.png +0 -0
  346. package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-lg.png +0 -0
  347. package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-md.png +0 -0
  348. package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-xs.png +0 -0
  349. package/playwright-tests/snapshots/files-dialog.spec.ts-view-snippet-files.png +0 -0
  350. package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-lg.png +0 -0
  351. package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-md.png +0 -0
  352. package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-xs.png +0 -0
  353. package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-lg.png +0 -0
  354. package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-md.png +0 -0
  355. package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-xs.png +0 -0
  356. package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-lg.png +0 -0
  357. package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-md.png +0 -0
  358. package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-xs.png +0 -0
  359. package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-lg.png +0 -0
  360. package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-md.png +0 -0
  361. package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-xs.png +0 -0
  362. package/playwright-tests/snapshots/handle-manual-edits.spec.ts-handle-manual-edits.png +0 -0
  363. package/playwright-tests/snapshots/home-page.spec.ts-Home-page-lg.png +0 -0
  364. package/playwright-tests/snapshots/home-page.spec.ts-Home-page-md.png +0 -0
  365. package/playwright-tests/snapshots/home-page.spec.ts-Home-page-xs.png +0 -0
  366. package/playwright-tests/snapshots/images.spec.ts-pcb-image.png +0 -0
  367. package/playwright-tests/snapshots/images.spec.ts-schematic-image.png +0 -0
  368. package/playwright-tests/snapshots/manual-edits.spec.ts-editor-manual-edits.png +0 -0
  369. package/playwright-tests/snapshots/manual-edits.spec.ts-manual-edits-view.png +0 -0
  370. package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png +0 -0
  371. package/playwright-tests/snapshots/profile-page.spec.ts-profile-page-before-delete.png +0 -0
  372. package/playwright-tests/snapshots/profile-page.spec.ts-profile-page-delete-dialog.png +0 -0
  373. package/playwright-tests/snapshots/profile-page.spec.ts-profile-page-dropdown-open.png +0 -0
  374. package/playwright-tests/snapshots/profile-page.spec.ts-profile-page-snippets-tab.png +0 -0
  375. package/playwright-tests/snapshots/profile-page.spec.ts-profile-page-starred-tab.png +0 -0
  376. package/playwright-tests/snapshots/profile-page.spec.ts-snippet-page-open-after-star-click.png +0 -0
  377. package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagelg.png +0 -0
  378. package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagemd.png +0 -0
  379. package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagexs.png +0 -0
  380. package/playwright-tests/snapshots/search-links.spec.ts-search-links.png +0 -0
  381. package/playwright-tests/snapshots/search.spec.ts-search-lg.png +0 -0
  382. package/playwright-tests/snapshots/search.spec.ts-search-md.png +0 -0
  383. package/playwright-tests/snapshots/search.spec.ts-search-xs.png +0 -0
  384. package/playwright-tests/snapshots/star.spec.ts-remove-star-button.png +0 -0
  385. package/playwright-tests/snapshots/star.spec.ts-star-button.png +0 -0
  386. package/playwright-tests/snapshots/update-description.spec.ts-update-description.png +0 -0
  387. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-lg.png +0 -0
  388. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-md.png +0 -0
  389. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-xs.png +0 -0
  390. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-lg.png +0 -0
  391. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-md.png +0 -0
  392. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-xs.png +0 -0
  393. package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-files.png +0 -0
  394. package/playwright-tests/star.spec.ts +0 -40
  395. package/playwright-tests/update-description.spec.ts +0 -18
  396. package/playwright-tests/view-snippet.spec.ts +0 -35
  397. package/playwright-tests/viewports.ts +0 -5
  398. package/playwright.config.ts +0 -27
  399. package/postcss.config.js +0 -6
  400. package/public/robots.txt +0 -9
  401. package/renovate.json +0 -25
  402. package/scripts/generate-image-sizes.ts +0 -57
  403. package/scripts/generate-sitemap.ts +0 -103
  404. package/scripts/generate_bundle_stats.js +0 -208
  405. package/scripts/snapshot.ts +0 -35
  406. package/src/App.tsx +0 -314
  407. package/src/ContextProviders.tsx +0 -94
  408. package/src/assets/originals/editor_example_1.webp +0 -0
  409. package/src/assets/originals/editor_example_1_more_square.webp +0 -0
  410. package/src/assets/originals/editor_example_2.webp +0 -0
  411. package/src/assets/originals/example_schematic.webp +0 -0
  412. package/src/components/AiChatMessage.tsx +0 -86
  413. package/src/components/Analytics.tsx +0 -23
  414. package/src/components/BomTable.tsx +0 -69
  415. package/src/components/ChatInput.tsx +0 -53
  416. package/src/components/CircuitJsonImportDialog.tsx +0 -269
  417. package/src/components/CircuitToSvgWithMouseControl.tsx +0 -78
  418. package/src/components/CmdKMenu.tsx +0 -809
  419. package/src/components/CreateNewSnippetWithAiHero.tsx +0 -81
  420. package/src/components/CreateReleaseDialog.tsx +0 -124
  421. package/src/components/DownloadButtonAndMenu.tsx +0 -443
  422. package/src/components/ErrorFallback.tsx +0 -25
  423. package/src/components/ErrorOutline.tsx +0 -35
  424. package/src/components/ErrorTabContent.tsx +0 -122
  425. package/src/components/ExpandableText.tsx +0 -29
  426. package/src/components/FAQ.tsx +0 -189
  427. package/src/components/FileSidebar.tsx +0 -271
  428. package/src/components/Footer.tsx +0 -144
  429. package/src/components/GithubAvatarWithFallback.tsx +0 -35
  430. package/src/components/Header.tsx +0 -202
  431. package/src/components/Header2.tsx +0 -202
  432. package/src/components/HeaderDropdown.tsx +0 -88
  433. package/src/components/HeaderLogin.tsx +0 -105
  434. package/src/components/HiddenFilesDropdown.tsx +0 -42
  435. package/src/components/ImageWithFallback.tsx +0 -37
  436. package/src/components/LatestSnippets.tsx +0 -39
  437. package/src/components/NotFound.tsx +0 -37
  438. package/src/components/OptimizedImage.tsx +0 -100
  439. package/src/components/PackageBreadcrumb.tsx +0 -105
  440. package/src/components/PackageBuildsPage/ErrorObject.ts +0 -12
  441. package/src/components/PackageBuildsPage/capitalCase.ts +0 -4
  442. package/src/components/PackageBuildsPage/getColorForDisplayStatus.ts +0 -17
  443. package/src/components/PackageCard.tsx +0 -191
  444. package/src/components/PackageCardSkeleton.tsx +0 -17
  445. package/src/components/PackageLink.tsx +0 -29
  446. package/src/components/PackageSearchResults.tsx +0 -81
  447. package/src/components/PackagesList.tsx +0 -71
  448. package/src/components/PcbViewerWithContainerHeight.tsx +0 -47
  449. package/src/components/PrefetchPageLink.tsx +0 -114
  450. package/src/components/PreviewEmptyState.tsx +0 -16
  451. package/src/components/ProfileRouter.tsx +0 -30
  452. package/src/components/RunButton.tsx +0 -27
  453. package/src/components/SearchComponent.tsx +0 -282
  454. package/src/components/SentryNotFoundReporter.tsx +0 -44
  455. package/src/components/SnippetTypeIcon.tsx +0 -60
  456. package/src/components/StaticPreviewContent.tsx +0 -89
  457. package/src/components/StaticViewSnippetSidebar.tsx +0 -100
  458. package/src/components/SuspenseRunFrame.tsx +0 -28
  459. package/src/components/TableViewer/CircuitJsonTableViewer.tsx +0 -316
  460. package/src/components/TableViewer/ClickableText.tsx +0 -21
  461. package/src/components/TableViewer/HeaderCell.tsx +0 -27
  462. package/src/components/TableViewer/Modal.tsx +0 -39
  463. package/src/components/TrendingPackagesCarousel.tsx +0 -79
  464. package/src/components/TypeBadge.tsx +0 -31
  465. package/src/components/UserCard.tsx +0 -80
  466. package/src/components/ViewPackagePage/components/ShikiCodeViewer.tsx +0 -49
  467. package/src/components/ViewPackagePage/components/build-status.tsx +0 -38
  468. package/src/components/ViewPackagePage/components/important-files-view.tsx +0 -611
  469. package/src/components/ViewPackagePage/components/main-content-header.tsx +0 -181
  470. package/src/components/ViewPackagePage/components/main-content-view-selector.tsx +0 -167
  471. package/src/components/ViewPackagePage/components/markdown-viewer.tsx +0 -88
  472. package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +0 -301
  473. package/src/components/ViewPackagePage/components/package-header.tsx +0 -264
  474. package/src/components/ViewPackagePage/components/preview-image-squares.tsx +0 -47
  475. package/src/components/ViewPackagePage/components/repo-page-content.tsx +0 -266
  476. package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +0 -223
  477. package/src/components/ViewPackagePage/components/sidebar-packages-section.tsx +0 -16
  478. package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +0 -126
  479. package/src/components/ViewPackagePage/components/sidebar.tsx +0 -29
  480. package/src/components/ViewPackagePage/components/tab-views/3d-view.tsx +0 -43
  481. package/src/components/ViewPackagePage/components/tab-views/bom-view.tsx +0 -30
  482. package/src/components/ViewPackagePage/components/tab-views/files-view.tsx +0 -295
  483. package/src/components/ViewPackagePage/components/tab-views/pcb-view.tsx +0 -35
  484. package/src/components/ViewPackagePage/components/tab-views/schematic-view.tsx +0 -38
  485. package/src/components/ViewPackagePage/components/theme-toggle.tsx +0 -40
  486. package/src/components/ViewPackagePage/hooks/use-current-package-circuit-json.ts +0 -46
  487. package/src/components/ViewPackagePage/hooks/use-mobile.tsx +0 -19
  488. package/src/components/ViewPackagePage/hooks/use-toast.tsx +0 -69
  489. package/src/components/ViewPackagePage/utils/fuzz-search.ts +0 -121
  490. package/src/components/ViewPackagePage/utils/get-license-content.ts +0 -119
  491. package/src/components/ViewPackagePage/utils/is-hidden-file.ts +0 -55
  492. package/src/components/ViewPackagePage/utils/is-package-file-important.ts +0 -35
  493. package/src/components/ViewPackagePage/utils/is-within-directory.ts +0 -32
  494. package/src/components/dialogs/GitHubRepositorySelector.tsx +0 -300
  495. package/src/components/dialogs/confirm-delete-package-dialog.tsx +0 -74
  496. package/src/components/dialogs/confirm-discard-changes-dialog.tsx +0 -73
  497. package/src/components/dialogs/create-use-dialog.tsx +0 -40
  498. package/src/components/dialogs/edit-description-dialog.tsx +0 -96
  499. package/src/components/dialogs/edit-package-details-dialog.tsx +0 -474
  500. package/src/components/dialogs/files-dialog.tsx +0 -70
  501. package/src/components/dialogs/import-component-dialog.tsx +0 -32
  502. package/src/components/dialogs/import-package-dialog.tsx +0 -90
  503. package/src/components/dialogs/new-package-save-prompt-dialog.tsx +0 -199
  504. package/src/components/dialogs/package-visibility-settings-dialog.tsx +0 -93
  505. package/src/components/dialogs/pcb-download-dialog.tsx +0 -113
  506. package/src/components/dialogs/rename-package-dialog.tsx +0 -86
  507. package/src/components/dialogs/rename-snippet-dialog.tsx +0 -81
  508. package/src/components/dialogs/update-package-description-dialog.tsx +0 -96
  509. package/src/components/dialogs/view-ts-files-dialog.tsx +0 -664
  510. package/src/components/organization/OrganizationCard.tsx +0 -202
  511. package/src/components/organization/OrganizationCardSkeleton.tsx +0 -55
  512. package/src/components/organization/OrganizationHeader.tsx +0 -140
  513. package/src/components/organization/OrganizationMembers.tsx +0 -117
  514. package/src/components/package-port/CodeAndPreview.tsx +0 -253
  515. package/src/components/package-port/CodeEditor.tsx +0 -866
  516. package/src/components/package-port/CodeEditorHeader.tsx +0 -427
  517. package/src/components/package-port/EditorNav.tsx +0 -606
  518. package/src/components/package-port/GlobalFindReplace.tsx +0 -681
  519. package/src/components/package-port/QuickOpen.tsx +0 -241
  520. package/src/components/preview/BuildsList.tsx +0 -237
  521. package/src/components/preview/ConnectedPackagesList.tsx +0 -229
  522. package/src/components/preview/ConnectedRepoOverview.tsx +0 -588
  523. package/src/components/preview/PackageReleasesDashboard.tsx +0 -228
  524. package/src/components/preview/index.tsx +0 -54
  525. package/src/components/ui/accordion.tsx +0 -55
  526. package/src/components/ui/alert-dialog.tsx +0 -139
  527. package/src/components/ui/alert.tsx +0 -59
  528. package/src/components/ui/aspect-ratio.tsx +0 -5
  529. package/src/components/ui/avatar.tsx +0 -48
  530. package/src/components/ui/badge.tsx +0 -36
  531. package/src/components/ui/breadcrumb.tsx +0 -118
  532. package/src/components/ui/button.tsx +0 -58
  533. package/src/components/ui/calendar.tsx +0 -73
  534. package/src/components/ui/card.tsx +0 -76
  535. package/src/components/ui/carousel.tsx +0 -260
  536. package/src/components/ui/chart.tsx +0 -363
  537. package/src/components/ui/checkbox.tsx +0 -28
  538. package/src/components/ui/collapsible.tsx +0 -9
  539. package/src/components/ui/combobox.tsx +0 -178
  540. package/src/components/ui/command.tsx +0 -151
  541. package/src/components/ui/context-menu.tsx +0 -202
  542. package/src/components/ui/dialog.tsx +0 -120
  543. package/src/components/ui/drawer.tsx +0 -116
  544. package/src/components/ui/dropdown-menu.tsx +0 -203
  545. package/src/components/ui/form.tsx +0 -182
  546. package/src/components/ui/hover-card.tsx +0 -27
  547. package/src/components/ui/input.tsx +0 -25
  548. package/src/components/ui/label.tsx +0 -24
  549. package/src/components/ui/menubar.tsx +0 -238
  550. package/src/components/ui/navigation-menu.tsx +0 -129
  551. package/src/components/ui/pagination.tsx +0 -121
  552. package/src/components/ui/popover.tsx +0 -31
  553. package/src/components/ui/progress.tsx +0 -26
  554. package/src/components/ui/radio-group.tsx +0 -42
  555. package/src/components/ui/resizable.tsx +0 -43
  556. package/src/components/ui/role-badge.tsx +0 -27
  557. package/src/components/ui/scroll-area.tsx +0 -46
  558. package/src/components/ui/searchable-select.tsx +0 -94
  559. package/src/components/ui/select.tsx +0 -162
  560. package/src/components/ui/separator.tsx +0 -29
  561. package/src/components/ui/sheet.tsx +0 -141
  562. package/src/components/ui/skeleton.tsx +0 -18
  563. package/src/components/ui/slider.tsx +0 -26
  564. package/src/components/ui/sonner.tsx +0 -30
  565. package/src/components/ui/switch.tsx +0 -27
  566. package/src/components/ui/table.tsx +0 -120
  567. package/src/components/ui/tabs.tsx +0 -53
  568. package/src/components/ui/textarea.tsx +0 -24
  569. package/src/components/ui/toast.tsx +0 -128
  570. package/src/components/ui/toaster.tsx +0 -1
  571. package/src/components/ui/toggle-group.tsx +0 -59
  572. package/src/components/ui/toggle.tsx +0 -43
  573. package/src/components/ui/tooltip.tsx +0 -28
  574. package/src/components/ui/tree-view.tsx +0 -563
  575. package/src/entry-server.tsx +0 -12
  576. package/src/hooks/use-account-balance.ts +0 -25
  577. package/src/hooks/use-add-org-member-mutation.ts +0 -51
  578. package/src/hooks/use-ai-api.ts +0 -35
  579. package/src/hooks/use-ai-review.ts +0 -31
  580. package/src/hooks/use-axios.ts +0 -20
  581. package/src/hooks/use-code-completion-ai-api.ts +0 -11
  582. package/src/hooks/use-copy-to-clipboard.ts +0 -26
  583. package/src/hooks/use-create-datasheet.ts +0 -30
  584. package/src/hooks/use-create-org-mutation.ts +0 -38
  585. package/src/hooks/use-create-package-files-mutation.ts +0 -76
  586. package/src/hooks/use-create-package-mutation.ts +0 -54
  587. package/src/hooks/use-create-package-release-mutation.ts +0 -107
  588. package/src/hooks/use-create-release-dialog.ts +0 -160
  589. package/src/hooks/use-create-snippet-mutation.ts +0 -65
  590. package/src/hooks/use-current-package-id.ts +0 -16
  591. package/src/hooks/use-current-package-info.ts +0 -32
  592. package/src/hooks/use-current-package-release.ts +0 -48
  593. package/src/hooks/use-current-snippet-id.ts +0 -78
  594. package/src/hooks/use-current-snippet.ts +0 -24
  595. package/src/hooks/use-datasheet.ts +0 -18
  596. package/src/hooks/use-debounce.ts +0 -17
  597. package/src/hooks/use-delete-package.ts +0 -45
  598. package/src/hooks/use-download-zip.ts +0 -50
  599. package/src/hooks/use-fork-package-mutation.ts +0 -61
  600. package/src/hooks/use-global-store.ts +0 -36
  601. package/src/hooks/use-hotkey.ts +0 -116
  602. package/src/hooks/use-hydration.ts +0 -30
  603. package/src/hooks/use-is-using-fake-api.ts +0 -3
  604. package/src/hooks/use-jlcpcb-component-import.tsx +0 -164
  605. package/src/hooks/use-list-org-members.ts +0 -32
  606. package/src/hooks/use-list-user-orgs.ts +0 -25
  607. package/src/hooks/use-now.ts +0 -12
  608. package/src/hooks/use-org-by-github-handle.ts +0 -24
  609. package/src/hooks/use-org.ts +0 -24
  610. package/src/hooks/use-organization.ts +0 -42
  611. package/src/hooks/use-package-as-snippet.ts +0 -81
  612. package/src/hooks/use-package-builds.ts +0 -91
  613. package/src/hooks/use-package-by-package-id.ts +0 -24
  614. package/src/hooks/use-package-by-package-name.ts +0 -29
  615. package/src/hooks/use-package-details-form.ts +0 -146
  616. package/src/hooks/use-package-files.ts +0 -122
  617. package/src/hooks/use-package-release-by-id-or-version.ts +0 -45
  618. package/src/hooks/use-package-release-images.ts +0 -105
  619. package/src/hooks/use-package-release.ts +0 -124
  620. package/src/hooks/use-package-stars.ts +0 -163
  621. package/src/hooks/use-package.ts +0 -24
  622. package/src/hooks/use-packages-base-api-url.ts +0 -3
  623. package/src/hooks/use-preview-images.ts +0 -78
  624. package/src/hooks/use-rebuild-package-release-mutation.ts +0 -41
  625. package/src/hooks/use-remove-org-member-mutation.ts +0 -32
  626. package/src/hooks/use-request-ai-review-mutation.ts +0 -54
  627. package/src/hooks/use-run-tsx/eval-compiled-js.ts +0 -9
  628. package/src/hooks/use-shiki-highlighter.ts +0 -33
  629. package/src/hooks/use-sign-in.ts +0 -24
  630. package/src/hooks/use-snippet-by-name.ts +0 -25
  631. package/src/hooks/use-snippet.ts +0 -24
  632. package/src/hooks/use-toast.tsx +0 -90
  633. package/src/hooks/use-update-ai-description-mutation.ts +0 -42
  634. package/src/hooks/use-update-org-mutation.ts +0 -41
  635. package/src/hooks/use-url-params.ts +0 -31
  636. package/src/hooks/use-warn-user-on-page-change.ts +0 -90
  637. package/src/hooks/useFileManagement.ts +0 -602
  638. package/src/hooks/useForkPackageMutation.ts +0 -50
  639. package/src/hooks/useForkSnippetMutation.ts +0 -53
  640. package/src/hooks/useOptimizedPackageFilesLoader.ts +0 -136
  641. package/src/hooks/usePackageFilesLoader.ts +0 -58
  642. package/src/hooks/useUpdatePackageFilesMutation.ts +0 -131
  643. package/src/hooks/useUpdatePackageMutation.ts +0 -63
  644. package/src/index.css +0 -108
  645. package/src/lib/__tests__/constants.test.ts +0 -66
  646. package/src/lib/base64ToBytes.ts +0 -5
  647. package/src/lib/bytesToBase64.ts +0 -4
  648. package/src/lib/codemirror/basic-setup.ts +0 -67
  649. package/src/lib/constants.ts +0 -23
  650. package/src/lib/decodeUrlHashToFsMap.ts +0 -17
  651. package/src/lib/decodeUrlHashToText.ts +0 -15
  652. package/src/lib/defaultCodeForBlankCode.tsx +0 -7
  653. package/src/lib/download-fns/createBlobURL.ts +0 -4
  654. package/src/lib/download-fns/download-assembly-svg.ts +0 -12
  655. package/src/lib/download-fns/download-circuit-json-fn.ts +0 -12
  656. package/src/lib/download-fns/download-circuit-png.ts +0 -96
  657. package/src/lib/download-fns/download-dsn-file-fn.ts +0 -12
  658. package/src/lib/download-fns/download-fabrication-files.ts +0 -233
  659. package/src/lib/download-fns/download-gltf-from-circuit-json.ts +0 -44
  660. package/src/lib/download-fns/download-gltf.ts +0 -43
  661. package/src/lib/download-fns/download-kicad-files.ts +0 -38
  662. package/src/lib/download-fns/download-pcb-svg.ts +0 -35
  663. package/src/lib/download-fns/download-png-utils.ts +0 -31
  664. package/src/lib/download-fns/download-readable-netlist.ts +0 -12
  665. package/src/lib/download-fns/download-schematic-svg.ts +0 -12
  666. package/src/lib/download-fns/download-simple-route-json.ts +0 -17
  667. package/src/lib/download-fns/download-spice-file.ts +0 -13
  668. package/src/lib/download-fns/download-step.ts +0 -12
  669. package/src/lib/encodeFsMapToUrlHash.ts +0 -13
  670. package/src/lib/encodeTextToUrlHash.ts +0 -17
  671. package/src/lib/get-snippet-template.ts +0 -26
  672. package/src/lib/getLicenseFromLicenseContent.ts +0 -67
  673. package/src/lib/handleManualEditsImport.tsx +0 -65
  674. package/src/lib/handleManualEditsImportWithSupportForMultipleFiles.ts +0 -67
  675. package/src/lib/normalize-svg-for-tile.ts +0 -50
  676. package/src/lib/populate-query-cache-with-ssr-data.ts +0 -53
  677. package/src/lib/posthog.ts +0 -17
  678. package/src/lib/react-query-api-failure-tracking.ts +0 -148
  679. package/src/lib/sentry.ts +0 -14
  680. package/src/lib/templates/blank-3d-model-template.ts +0 -12
  681. package/src/lib/templates/blank-circuit-board-template.ts +0 -20
  682. package/src/lib/templates/blank-footprint-template.ts +0 -29
  683. package/src/lib/templates/blank-package-template.ts +0 -21
  684. package/src/lib/templates/blinking-led-board-template.ts +0 -64
  685. package/src/lib/templates/usb-c-led-flashlight-template.ts +0 -22
  686. package/src/lib/ts-lib-cache.ts +0 -162
  687. package/src/lib/types.ts +0 -31
  688. package/src/lib/utils/checkIfManualEditsImported.ts +0 -20
  689. package/src/lib/utils/findTargetFile.ts +0 -97
  690. package/src/lib/utils/formatTimeAgo.ts +0 -10
  691. package/src/lib/utils/getPackagePreviewImageUrl.ts +0 -15
  692. package/src/lib/utils/index.ts +0 -6
  693. package/src/lib/utils/isComponentExported.ts +0 -10
  694. package/src/lib/utils/isUuid.ts +0 -5
  695. package/src/lib/utils/isValidFileName.ts +0 -17
  696. package/src/lib/utils/load-prettier.ts +0 -23
  697. package/src/lib/utils/member-role.tsx +0 -61
  698. package/src/lib/utils/package-utils.ts +0 -7
  699. package/src/lib/utils/parseJsonOrNull.ts +0 -8
  700. package/src/lib/utils/pcbManualEditEventHandler.ts +0 -156
  701. package/src/lib/utils/resolveRelativePath.ts +0 -40
  702. package/src/lib/utils/timeAgo.ts +0 -20
  703. package/src/lib/utils/toastManualEditConflicts.tsx +0 -39
  704. package/src/lib/utils/transformFilesToTreeData.tsx +0 -195
  705. package/src/main.tsx +0 -15
  706. package/src/pages/404.tsx +0 -23
  707. package/src/pages/authorize.tsx +0 -208
  708. package/src/pages/create-organization.tsx +0 -169
  709. package/src/pages/dashboard.tsx +0 -254
  710. package/src/pages/datasheet.tsx +0 -198
  711. package/src/pages/datasheets.tsx +0 -148
  712. package/src/pages/dev-login.tsx +0 -68
  713. package/src/pages/editor.tsx +0 -54
  714. package/src/pages/landing.tsx +0 -237
  715. package/src/pages/latest.tsx +0 -145
  716. package/src/pages/my-orders.tsx +0 -54
  717. package/src/pages/organization-profile.tsx +0 -197
  718. package/src/pages/organization-settings.tsx +0 -571
  719. package/src/pages/package-editor.tsx +0 -60
  720. package/src/pages/preview-release.tsx +0 -209
  721. package/src/pages/quickstart.tsx +0 -258
  722. package/src/pages/release-builds.tsx +0 -99
  723. package/src/pages/release-detail.tsx +0 -211
  724. package/src/pages/releases.tsx +0 -55
  725. package/src/pages/search.tsx +0 -288
  726. package/src/pages/settings-redirect.tsx +0 -44
  727. package/src/pages/trending.tsx +0 -201
  728. package/src/pages/user-profile.tsx +0 -330
  729. package/src/pages/user-settings.tsx +0 -161
  730. package/src/pages/view-package.tsx +0 -90
  731. package/src/types/package.ts +0 -4
  732. package/src/vite-env.d.ts +0 -1
  733. package/tailwind.config.js +0 -47
  734. package/tsconfig.json +0 -30
  735. package/vercel.json +0 -50
  736. package/vite.config.ts +0 -236
  737. package/winterspec.config.ts +0 -6
package/dist/index.js ADDED
@@ -0,0 +1,3961 @@
1
+ // fake-snippets-api/lib/db/db-client.ts
2
+ import { randomUUID } from "crypto";
3
+ import { hoist } from "zustand-hoist";
4
+ import { createStore } from "zustand/vanilla";
5
+ import { combine } from "zustand/middleware";
6
+
7
+ // fake-snippets-api/lib/db/schema.ts
8
+ import { z } from "zod";
9
+ var errorSchema = z.object({
10
+ error_code: z.string(),
11
+ message: z.string()
12
+ }).passthrough();
13
+ var errorResponseSchema = z.object({
14
+ error: errorSchema
15
+ });
16
+ var snippetSchema = z.object({
17
+ snippet_id: z.string(),
18
+ package_release_id: z.string(),
19
+ name: z.string(),
20
+ unscoped_name: z.string(),
21
+ owner_name: z.string(),
22
+ is_starred: z.boolean().default(false),
23
+ code: z.string(),
24
+ dts: z.string().optional(),
25
+ compiled_js: z.string().optional().nullable(),
26
+ circuit_json: z.array(z.record(z.any())).optional().nullable(),
27
+ manual_edits_json_content: z.string().optional().nullable(),
28
+ created_at: z.string(),
29
+ updated_at: z.string(),
30
+ starred_at: z.string().optional(),
31
+ snippet_type: z.enum(["board", "package", "model", "footprint"]),
32
+ description: z.string().optional(),
33
+ version: z.string().default("0.0.1"),
34
+ star_count: z.number().default(0),
35
+ is_private: z.boolean().default(false),
36
+ is_public: z.boolean().default(true),
37
+ is_unlisted: z.boolean().default(false),
38
+ tags: z.array(z.string()).optional()
39
+ });
40
+ var sessionSchema = z.object({
41
+ session_id: z.string(),
42
+ account_id: z.string(),
43
+ expires_at: z.string(),
44
+ is_cli_session: z.boolean()
45
+ });
46
+ var loginPageSchema = z.object({
47
+ login_page_id: z.string(),
48
+ login_page_auth_token: z.string(),
49
+ was_login_successful: z.boolean(),
50
+ has_been_used_to_create_session: z.boolean(),
51
+ created_at: z.string(),
52
+ expires_at: z.string()
53
+ });
54
+ var shippingInfoSchema = z.object({
55
+ firstName: z.string(),
56
+ lastName: z.string(),
57
+ companyName: z.string().optional(),
58
+ address: z.string(),
59
+ apartment: z.string().optional(),
60
+ city: z.string(),
61
+ state: z.string(),
62
+ zipCode: z.string(),
63
+ country: z.string(),
64
+ phone: z.string()
65
+ });
66
+ var accountSchema = z.object({
67
+ account_id: z.string(),
68
+ github_username: z.string(),
69
+ shippingInfo: shippingInfoSchema.optional(),
70
+ personal_org_id: z.string().optional(),
71
+ is_tscircuit_staff: z.boolean().default(false)
72
+ });
73
+ var orderSchema = z.object({
74
+ order_id: z.string(),
75
+ account_id: z.string().nullable(),
76
+ is_running: z.boolean(),
77
+ is_started: z.boolean(),
78
+ is_finished: z.boolean(),
79
+ error: errorSchema.nullable(),
80
+ has_error: z.boolean(),
81
+ created_at: z.string(),
82
+ started_at: z.string().nullable(),
83
+ completed_at: z.string().nullable(),
84
+ circuit_json: z.any()
85
+ });
86
+ var orderFileSchema = z.object({
87
+ order_file_id: z.string(),
88
+ order_id: z.string(),
89
+ is_gerbers_zip: z.boolean(),
90
+ content_type: z.string(),
91
+ for_provider: z.string().nullable(),
92
+ uploaded_at: z.string(),
93
+ content_text: z.string().nullable(),
94
+ content_bytes: z.instanceof(Uint8Array).nullable()
95
+ });
96
+ var bugReportSchema = z.object({
97
+ bug_report_id: z.string().uuid(),
98
+ reporter_account_id: z.string(),
99
+ text: z.string().nullable(),
100
+ is_auto_deleted: z.boolean().default(false),
101
+ delete_at: z.string().datetime().nullable(),
102
+ created_at: z.string().datetime(),
103
+ file_count: z.number().int()
104
+ });
105
+ var bugReportFileSchema = z.object({
106
+ bug_report_file_id: z.string().uuid(),
107
+ bug_report_id: z.string().uuid(),
108
+ file_path: z.string(),
109
+ content_mimetype: z.string(),
110
+ is_text: z.boolean(),
111
+ created_at: z.string().datetime(),
112
+ content_text: z.string().nullable(),
113
+ content_bytes: z.instanceof(Uint8Array).nullable()
114
+ });
115
+ var bugReportFileResponseSchema = bugReportFileSchema.omit({
116
+ content_text: true,
117
+ content_bytes: true
118
+ });
119
+ var shippingOptionSchema = z.object({
120
+ carrier: z.string(),
121
+ service: z.string(),
122
+ cost: z.number()
123
+ });
124
+ var quotedComponentSchema = z.object({
125
+ manufacturer_part_number: z.string().nullable(),
126
+ supplier_part_number: z.string().nullable(),
127
+ quantity: z.number().default(0),
128
+ unit_price: z.number().default(0),
129
+ total_price: z.number().default(0),
130
+ available: z.boolean().default(true)
131
+ });
132
+ var orderQuoteSchema = z.object({
133
+ order_quote_id: z.string(),
134
+ account_id: z.string().nullable(),
135
+ package_release_id: z.string().nullable(),
136
+ is_completed: z.boolean().default(false),
137
+ is_processing: z.boolean().default(true),
138
+ vendor_name: z.string(),
139
+ error: errorSchema.nullable(),
140
+ has_error: z.boolean().default(false),
141
+ created_at: z.string(),
142
+ updated_at: z.string(),
143
+ completed_at: z.string().nullable(),
144
+ quoted_components: z.array(quotedComponentSchema).nullable(),
145
+ bare_pcb_cost: z.number().default(0),
146
+ shipping_options: z.array(shippingOptionSchema),
147
+ total_cost_without_shipping: z.number().default(0)
148
+ });
149
+ var aiReviewSchema = z.object({
150
+ ai_review_id: z.string().uuid(),
151
+ package_release_id: z.string().optional(),
152
+ ai_review_text: z.string().nullable(),
153
+ start_processing_at: z.string().datetime().nullable(),
154
+ finished_processing_at: z.string().datetime().nullable(),
155
+ processing_error: z.any().nullable(),
156
+ created_at: z.string().datetime(),
157
+ display_status: z.enum(["pending", "completed", "failed"])
158
+ });
159
+ var datasheetPinInformationSchema = z.object({
160
+ pin_number: z.string(),
161
+ name: z.string(),
162
+ description: z.string(),
163
+ capabilities: z.array(z.string())
164
+ });
165
+ var datasheetSchema = z.object({
166
+ datasheet_id: z.string(),
167
+ chip_name: z.string(),
168
+ created_at: z.string(),
169
+ pin_information: datasheetPinInformationSchema.array().nullable(),
170
+ datasheet_pdf_urls: z.array(z.string()).nullable(),
171
+ ai_description: z.string().nullable()
172
+ });
173
+ var githubInstallationSchema = z.object({
174
+ github_installation_id: z.string(),
175
+ account_id: z.string(),
176
+ installation_id: z.string(),
177
+ // GitHub App installation ID
178
+ github_username: z.string(),
179
+ created_at: z.string().datetime(),
180
+ updated_at: z.string().datetime(),
181
+ is_active: z.boolean().default(true),
182
+ access_token: z.string().nullable().optional(),
183
+ // For storing GitHub access token
184
+ access_token_expires_at: z.string().datetime().nullable().optional()
185
+ });
186
+ var accountSnippetSchema = z.object({
187
+ account_id: z.string(),
188
+ snippet_id: z.string(),
189
+ has_starred: z.boolean(),
190
+ created_at: z.string(),
191
+ updated_at: z.string()
192
+ });
193
+ var accountPackageSchema = z.object({
194
+ account_package_id: z.string(),
195
+ account_id: z.string(),
196
+ package_id: z.string(),
197
+ is_starred: z.boolean(),
198
+ created_at: z.string(),
199
+ updated_at: z.string()
200
+ });
201
+ var packageReleaseSchema = z.object({
202
+ package_release_id: z.string(),
203
+ package_id: z.string(),
204
+ version: z.string().nullable(),
205
+ is_locked: z.boolean(),
206
+ is_latest: z.boolean(),
207
+ created_at: z.string().datetime(),
208
+ commit_sha: z.string().nullable().optional(),
209
+ license: z.string().nullable().optional(),
210
+ circuit_json_build_error: z.string().nullable().optional(),
211
+ circuit_json_build_error_last_updated_at: z.string().datetime().nullable().optional(),
212
+ has_transpiled: z.boolean().default(false),
213
+ transpilation_error: z.string().nullable().optional(),
214
+ fs_sha: z.string().nullable().optional(),
215
+ // Build Status and Display
216
+ display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
217
+ total_build_duration_ms: z.number().nullable().optional(),
218
+ // Transpilation Process
219
+ transpilation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
220
+ transpilation_in_progress: z.boolean().default(false),
221
+ transpilation_started_at: z.string().datetime().nullable().optional(),
222
+ transpilation_completed_at: z.string().datetime().nullable().optional(),
223
+ transpilation_logs: z.array(z.any()).default([]),
224
+ transpilation_is_stale: z.boolean().default(false),
225
+ // Circuit JSON Build Process
226
+ circuit_json_build_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
227
+ circuit_json_build_in_progress: z.boolean().default(false),
228
+ circuit_json_build_started_at: z.string().datetime().nullable().optional(),
229
+ circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
230
+ circuit_json_build_logs: z.array(z.any()).default([]),
231
+ circuit_json_build_is_stale: z.boolean().default(false),
232
+ // Image Generation Process
233
+ image_generation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
234
+ image_generation_in_progress: z.boolean().default(false),
235
+ image_generation_started_at: z.string().datetime().nullable().optional(),
236
+ image_generation_completed_at: z.string().datetime().nullable().optional(),
237
+ image_generation_logs: z.array(z.any()).nullable().default(null),
238
+ image_generation_is_stale: z.boolean().default(false),
239
+ image_generation_error: z.string().nullable().optional(),
240
+ image_generation_error_last_updated_at: z.string().datetime().nullable().optional(),
241
+ // AI Review
242
+ ai_review_text: z.string().nullable().default(null).optional(),
243
+ ai_review_started_at: z.string().datetime().nullable().optional(),
244
+ ai_review_completed_at: z.string().datetime().nullable().optional(),
245
+ ai_review_error: z.any().optional().nullable(),
246
+ ai_review_logs: z.array(z.any()).optional().nullable(),
247
+ ai_review_requested: z.boolean().default(false),
248
+ // Preview
249
+ is_pr_preview: z.boolean().default(false),
250
+ github_pr_number: z.number().nullable().optional(),
251
+ // Latest Build Reference
252
+ latest_package_build_id: z.string().nullable().optional(),
253
+ branch_name: z.string().nullable().optional(),
254
+ commit_message: z.string().nullable().optional(),
255
+ commit_author: z.string().nullable().optional(),
256
+ // Preview images url
257
+ pcb_preview_image_url: z.string().nullable().default(null),
258
+ sch_preview_image_url: z.string().nullable().default(null),
259
+ cad_preview_image_url: z.string().nullable().default(null)
260
+ });
261
+ var packageFileSchema = z.object({
262
+ package_file_id: z.string(),
263
+ package_release_id: z.string(),
264
+ file_path: z.string(),
265
+ content_text: z.string().nullable().optional(),
266
+ created_at: z.string().datetime(),
267
+ content_mimetype: z.string().nullable().optional(),
268
+ is_release_tarball: z.boolean().optional(),
269
+ npm_pack_output: z.any().nullable().optional()
270
+ });
271
+ var packageSchema = z.object({
272
+ package_id: z.string(),
273
+ creator_account_id: z.string(),
274
+ owner_org_id: z.string(),
275
+ owner_github_username: z.string().nullable(),
276
+ github_repo_full_name: z.string().nullable(),
277
+ name: z.string(),
278
+ unscoped_name: z.string(),
279
+ description: z.string().nullable(),
280
+ created_at: z.string().datetime(),
281
+ updated_at: z.string().datetime(),
282
+ is_snippet: z.boolean().default(false),
283
+ is_board: z.boolean().default(false),
284
+ is_package: z.boolean().default(false),
285
+ is_model: z.boolean().default(false),
286
+ is_footprint: z.boolean().default(false),
287
+ is_private: z.boolean().nullable().default(false),
288
+ is_public: z.boolean().nullable().default(true),
289
+ is_unlisted: z.boolean().nullable().default(false),
290
+ is_source_from_github: z.boolean().default(false),
291
+ snippet_type: z.enum(["board", "package", "model", "footprint"]).optional(),
292
+ latest_package_release_id: z.string().nullable(),
293
+ latest_version: z.string().nullable(),
294
+ license: z.string().nullable(),
295
+ website: z.string().nullable().default(null),
296
+ star_count: z.number().default(0),
297
+ ai_description: z.string().nullable(),
298
+ latest_license: z.string().nullable().optional(),
299
+ ai_usage_instructions: z.string().nullable(),
300
+ latest_package_release_fs_sha: z.string().nullable().default(null),
301
+ default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional(),
302
+ allow_pr_previews: z.boolean().default(false).optional(),
303
+ is_starred: z.boolean().default(false).optional(),
304
+ latest_pcb_preview_image_url: z.string().nullable().optional(),
305
+ latest_sch_preview_image_url: z.string().nullable().optional(),
306
+ latest_cad_preview_image_url: z.string().nullable().optional()
307
+ });
308
+ var jlcpcbOrderStateSchema = z.object({
309
+ jlcpcb_order_state_id: z.string(),
310
+ order_id: z.string(),
311
+ are_gerbers_uploaded: z.boolean().default(false),
312
+ is_gerber_analyzed: z.boolean().default(false),
313
+ are_initial_costs_calculated: z.boolean().default(false),
314
+ is_pcb_added_to_cart: z.boolean().default(false),
315
+ is_bom_uploaded: z.boolean().default(false),
316
+ is_pnp_uploaded: z.boolean().default(false),
317
+ is_bom_pnp_analyzed: z.boolean().default(false),
318
+ is_bom_parsing_complete: z.boolean().default(false),
319
+ are_components_available: z.boolean().default(false),
320
+ is_patch_map_generated: z.boolean().default(false),
321
+ is_json_merge_file_created: z.boolean().default(false),
322
+ is_dfm_result_generated: z.boolean().default(false),
323
+ are_files_downloaded: z.boolean().default(false),
324
+ are_product_categories_fetched: z.boolean().default(false),
325
+ are_final_costs_calculated: z.boolean().default(false),
326
+ is_json_merge_file_updated: z.boolean().default(false),
327
+ is_added_to_cart: z.boolean().default(false),
328
+ uploaded_gerber_metadata: z.any().nullable().default(null),
329
+ gerber_analysis: z.any().nullable().default(null),
330
+ created_at: z.string(),
331
+ are_gerbers_generated: z.boolean().default(false),
332
+ current_step: z.string().nullable().default(null)
333
+ });
334
+ var jlcpcbOrderStepRunSchema = z.object({
335
+ jlcpcb_order_step_run_id: z.string(),
336
+ is_running: z.boolean().nullable().default(null),
337
+ step_function_name: z.string().nullable().default(null),
338
+ jlcpcb_order_state_id: z.string().nullable().default(null),
339
+ error_message: z.string().nullable().default(null),
340
+ created_at: z.string()
341
+ });
342
+ var packageBuildSchema = z.object({
343
+ package_build_id: z.string().uuid(),
344
+ package_release_id: z.string(),
345
+ created_at: z.string().datetime(),
346
+ transpilation_in_progress: z.boolean().default(false),
347
+ transpilation_started_at: z.string().datetime().nullable().optional(),
348
+ transpilation_completed_at: z.string().datetime().nullable().optional(),
349
+ transpilation_logs: z.array(z.any()).default([]),
350
+ transpilation_error: z.string().nullable().optional(),
351
+ circuit_json_build_in_progress: z.boolean().default(false),
352
+ circuit_json_build_started_at: z.string().datetime().nullable().optional(),
353
+ circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
354
+ circuit_json_build_logs: z.array(z.any()).default([]),
355
+ circuit_json_build_error: z.string().nullable().optional(),
356
+ image_generation_in_progress: z.boolean().default(false),
357
+ image_generation_started_at: z.string().datetime().nullable().optional(),
358
+ image_generation_completed_at: z.string().datetime().nullable().optional(),
359
+ image_generation_logs: z.array(z.any()).default([]),
360
+ image_generation_error: z.string().nullable().optional(),
361
+ build_in_progress: z.boolean().default(false),
362
+ build_started_at: z.string().datetime().nullable().optional(),
363
+ build_completed_at: z.string().datetime().nullable().optional(),
364
+ build_error: z.string().nullable().optional(),
365
+ build_error_last_updated_at: z.string().datetime(),
366
+ preview_url: z.string().nullable().optional(),
367
+ build_logs: z.string().nullable().optional()
368
+ });
369
+ var orgSchema = z.object({
370
+ org_id: z.string(),
371
+ github_handle: z.string().optional(),
372
+ owner_account_id: z.string(),
373
+ is_personal_org: z.boolean().default(false),
374
+ created_at: z.string().datetime(),
375
+ org_display_name: z.string().optional(),
376
+ org_name: z.string()
377
+ });
378
+ var orgAccountSchema = z.object({
379
+ org_account_id: z.string(),
380
+ org_id: z.string(),
381
+ account_id: z.string(),
382
+ is_owner: z.boolean().default(false),
383
+ created_at: z.string().datetime()
384
+ });
385
+ var userPermissionsSchema = z.object({
386
+ can_manage_org: z.boolean().optional(),
387
+ can_manage_package: z.boolean().optional()
388
+ });
389
+ var publicOrgSchema = z.object({
390
+ org_id: z.string(),
391
+ //.uuid(),
392
+ owner_account_id: z.string(),
393
+ //.uuid(),
394
+ name: z.string().nullable(),
395
+ member_count: z.number(),
396
+ is_personal_org: z.boolean(),
397
+ display_name: z.string().optional(),
398
+ package_count: z.number(),
399
+ github_handle: z.string().optional(),
400
+ created_at: z.string(),
401
+ user_permissions: userPermissionsSchema.optional()
402
+ });
403
+ var databaseSchema = z.object({
404
+ idCounter: z.number().default(0),
405
+ snippets: z.array(snippetSchema).default([]),
406
+ packageReleases: z.array(packageReleaseSchema).default([]),
407
+ packageFiles: z.array(packageFileSchema).default([]),
408
+ sessions: z.array(sessionSchema).default([]),
409
+ loginPages: z.array(loginPageSchema).default([]),
410
+ accounts: z.array(accountSchema).default([]),
411
+ packages: z.array(packageSchema).default([]),
412
+ orders: z.array(orderSchema).default([]),
413
+ organizations: z.array(orgSchema).default([]),
414
+ orgAccounts: z.array(orgAccountSchema).default([]),
415
+ orderFiles: z.array(orderFileSchema).default([]),
416
+ accountSnippets: z.array(accountSnippetSchema).default([]),
417
+ accountPackages: z.array(accountPackageSchema).default([]),
418
+ jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
419
+ jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
420
+ orderQuotes: z.array(orderQuoteSchema).default([]),
421
+ aiReviews: z.array(aiReviewSchema).default([]),
422
+ datasheets: z.array(datasheetSchema).default([]),
423
+ githubInstallations: z.array(githubInstallationSchema).default([]),
424
+ packageBuilds: z.array(packageBuildSchema).default([]),
425
+ bugReports: z.array(bugReportSchema).default([]),
426
+ bugReportFiles: z.array(bugReportFileSchema).default([])
427
+ });
428
+
429
+ // fake-snippets-api/lib/db/autoload-dev-packages.ts
430
+ import fs from "fs";
431
+ import path from "path";
432
+ import axios from "redaxios";
433
+ var extractTsciDependencies = (code) => {
434
+ const regex = /@tsci\/([^.]+)\.([^"'\s]+)/g;
435
+ const matches = Array.from(code.matchAll(regex));
436
+ return matches.map((match) => ({
437
+ owner: match[1],
438
+ name: match[2]
439
+ }));
440
+ };
441
+ var registryApi = axios.create({
442
+ baseURL: "https://api.tscircuit.com",
443
+ headers: {
444
+ Accept: "application/json",
445
+ "Content-Type": "application/json"
446
+ }
447
+ });
448
+ var fetchPackageFromRegistry = async (owner, name) => {
449
+ const fullName = `${owner}/${name}`;
450
+ console.log(`[autoload-dev-pkgs] \u{1F4E6} Fetching package ${fullName}...`);
451
+ let packageData;
452
+ try {
453
+ const response = await registryApi.post("/packages/get", {
454
+ name: fullName
455
+ });
456
+ packageData = response.data;
457
+ } catch (e) {
458
+ console.error(`Failed to fetch package data for ${fullName}:`, e);
459
+ throw e;
460
+ }
461
+ let releaseData;
462
+ try {
463
+ const response = await registryApi.post("/package_releases/get", {
464
+ package_id: packageData.package.package_id,
465
+ is_latest: true
466
+ });
467
+ releaseData = response.data;
468
+ } catch (e) {
469
+ console.error(
470
+ `[autoload-dev-pkgs] \u274C Failed to fetch release data for ${fullName}:`,
471
+ e
472
+ );
473
+ throw e;
474
+ }
475
+ let filesData;
476
+ try {
477
+ const response = await registryApi.post(
478
+ `package_files/list?package_release_id=${releaseData.package_release.package_release_id}`,
479
+ {}
480
+ );
481
+ filesData = response.data;
482
+ for (const file of filesData.package_files) {
483
+ try {
484
+ const fileResponse = await registryApi.post(
485
+ `/package_files/get?package_file_id=${file.package_file_id}`,
486
+ {}
487
+ );
488
+ file.content_text = fileResponse.data.package_file.content_text;
489
+ } catch (e) {
490
+ console.error(
491
+ `[autoload-dev-pkgs] \u274C Failed to fetch content for file ${file.file_path} in package ${fullName}:`,
492
+ e
493
+ );
494
+ throw e;
495
+ }
496
+ }
497
+ } catch (e) {
498
+ console.error(
499
+ `[autoload-dev-pkgs] \u274C Failed to fetch files data for ${fullName}:`,
500
+ e
501
+ );
502
+ throw e;
503
+ }
504
+ return {
505
+ package: packageData.package,
506
+ release: releaseData.package_release,
507
+ files: filesData.package_files
508
+ };
509
+ };
510
+ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @__PURE__ */ new Set()) => {
511
+ const packageKey = `${owner}/${name}`;
512
+ if (loadedPackages.has(packageKey)) {
513
+ return true;
514
+ }
515
+ let result;
516
+ try {
517
+ result = await fetchPackageFromRegistry(owner, name);
518
+ } catch (e) {
519
+ console.error(`[autoload-dev-pkgs] \u274C Failed to load ${packageKey}`);
520
+ return false;
521
+ }
522
+ const { package: pkg, release, files } = result;
523
+ if (db.getPackageById(pkg.package_id)) {
524
+ console.log(`[autoload-dev-pkgs] \u26A1 Package ${packageKey} already exists`);
525
+ return true;
526
+ }
527
+ db.addPackage({
528
+ ...pkg,
529
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
530
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
531
+ latest_package_release_id: release.package_release_id,
532
+ star_count: Math.floor(Math.random() * 11)
533
+ });
534
+ db.addPackageRelease({
535
+ ...release,
536
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
537
+ transpilation_logs: Array.isArray(release.transpilation_logs) ? release.transpilation_logs : [],
538
+ circuit_json_build_logs: Array.isArray(release.circuit_json_build_logs) ? release.circuit_json_build_logs : [],
539
+ transpilation_display_status: release.transpilation_display_status ?? "pending"
540
+ });
541
+ for (const file of files) {
542
+ db.addPackageFile({
543
+ ...file,
544
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
545
+ });
546
+ }
547
+ loadedPackages.add(packageKey);
548
+ console.log(`[autoload-dev-pkgs] \u{1F4E6} Loaded ${packageKey}`);
549
+ const mainFile = files.find(
550
+ (f) => f.file_path === "index.tsx" || f.file_path === "index.ts"
551
+ );
552
+ if (!mainFile?.content_text) {
553
+ return true;
554
+ }
555
+ const dependencies = extractTsciDependencies(mainFile.content_text);
556
+ let allDepsLoaded = true;
557
+ for (const dep of dependencies) {
558
+ const depLoaded = await loadPackageWithDependencies(
559
+ db,
560
+ dep.owner,
561
+ dep.name,
562
+ loadedPackages
563
+ );
564
+ if (!depLoaded) {
565
+ allDepsLoaded = false;
566
+ console.warn(
567
+ `[autoload-dev-pkgs] \u26A0\uFE0F Failed to load dependency ${dep.owner}/${dep.name} for ${packageKey}`
568
+ );
569
+ }
570
+ }
571
+ return allDepsLoaded;
572
+ };
573
+ var loadAutoloadPackages = async (db) => {
574
+ const autoloadPath = path.join(
575
+ path.dirname(__dirname),
576
+ "db",
577
+ "autoload-packages.json"
578
+ );
579
+ if (!fs.existsSync(autoloadPath)) {
580
+ console.error("[autoload-dev-pkgs] \u274C No autoload-packages.json found");
581
+ return;
582
+ }
583
+ const autoloadContent = JSON.parse(fs.readFileSync(autoloadPath, "utf8"));
584
+ const loadedPackages = /* @__PURE__ */ new Set();
585
+ let successCount = 0;
586
+ let failureCount = 0;
587
+ for (const packageRef of autoloadContent.packages) {
588
+ const success = await loadPackageWithDependencies(
589
+ db,
590
+ packageRef.owner,
591
+ packageRef.name,
592
+ loadedPackages
593
+ );
594
+ if (success) {
595
+ successCount++;
596
+ } else {
597
+ failureCount++;
598
+ }
599
+ }
600
+ console.log(`
601
+ [autoload-dev-pkgs] \u{1F4CB} Package loading complete:`);
602
+ console.log(
603
+ `[autoload-dev-pkgs] \u2705 Successfully loaded: ${successCount} packages`
604
+ );
605
+ if (failureCount > 0) {
606
+ console.log(
607
+ `[autoload-dev-pkgs] \u274C Failed to load: ${failureCount} packages`
608
+ );
609
+ }
610
+ };
611
+
612
+ // fake-snippets-api/lib/db/seed.ts
613
+ var seed = (db) => {
614
+ const { account_id } = db.addAccount({
615
+ account_id: "account-1234",
616
+ personal_org_id: "org-1234",
617
+ github_username: "testuser",
618
+ shippingInfo: {
619
+ firstName: "Test",
620
+ lastName: "User",
621
+ companyName: "Test Company",
622
+ address: "123 Test St",
623
+ apartment: "Apt 4B",
624
+ city: "Testville",
625
+ state: "NY",
626
+ zipCode: "10001",
627
+ country: "United States of America",
628
+ phone: "555-123-4567"
629
+ }
630
+ });
631
+ const seveibarAcc = db.addAccount({
632
+ github_username: "seveibar"
633
+ });
634
+ if (process.env.AUTOLOAD_PACKAGES === "true") {
635
+ loadAutoloadPackages(db);
636
+ }
637
+ const { package_release_id: packageReleaseId1 } = db.addSnippet({
638
+ name: "testuser/my-test-board",
639
+ unscoped_name: "my-test-board",
640
+ github_repo_full_name: "testuser/my-test-board",
641
+ owner_name: "testuser",
642
+ branch_name: "main",
643
+ commit_message: "Attempted build of a555timer-square-wave package",
644
+ commit_author: "testuser",
645
+ creator_account_id: account_id,
646
+ code: `
647
+ import { A555Timer } from "@tsci/seveibar.a555timer"
648
+
649
+ export default () => (
650
+ <board width="10mm" height="10mm">
651
+ <A555Timer name="U1" />
652
+ </board>
653
+ )`.trim(),
654
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
655
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
656
+ snippet_type: "board",
657
+ description: "A simple board with an A555 Timer component",
658
+ circuit_json: [
659
+ {
660
+ type: "source_port",
661
+ source_port_id: "source_port_0",
662
+ name: "pin1",
663
+ pin_number: 1,
664
+ port_hints: ["pin1", "1"],
665
+ source_component_id: "source_component_0"
666
+ },
667
+ {
668
+ type: "source_port",
669
+ source_port_id: "source_port_1",
670
+ name: "pin2",
671
+ pin_number: 2,
672
+ port_hints: ["pin2", "2"],
673
+ source_component_id: "source_component_0"
674
+ },
675
+ {
676
+ type: "source_port",
677
+ source_port_id: "source_port_2",
678
+ name: "pin3",
679
+ pin_number: 3,
680
+ port_hints: ["pin3", "3"],
681
+ source_component_id: "source_component_0"
682
+ },
683
+ {
684
+ type: "source_port",
685
+ source_port_id: "source_port_3",
686
+ name: "pin4",
687
+ pin_number: 4,
688
+ port_hints: ["pin4", "4"],
689
+ source_component_id: "source_component_0"
690
+ },
691
+ {
692
+ type: "source_port",
693
+ source_port_id: "source_port_4",
694
+ name: "pin5",
695
+ pin_number: 5,
696
+ port_hints: ["pin5", "5"],
697
+ source_component_id: "source_component_0"
698
+ },
699
+ {
700
+ type: "source_port",
701
+ source_port_id: "source_port_5",
702
+ name: "pin6",
703
+ pin_number: 6,
704
+ port_hints: ["pin6", "6"],
705
+ source_component_id: "source_component_0"
706
+ },
707
+ {
708
+ type: "source_port",
709
+ source_port_id: "source_port_6",
710
+ name: "pin7",
711
+ pin_number: 7,
712
+ port_hints: ["pin7", "7"],
713
+ source_component_id: "source_component_0"
714
+ },
715
+ {
716
+ type: "source_port",
717
+ source_port_id: "source_port_7",
718
+ name: "pin8",
719
+ pin_number: 8,
720
+ port_hints: ["pin8", "8"],
721
+ source_component_id: "source_component_0"
722
+ },
723
+ {
724
+ type: "source_component",
725
+ source_component_id: "source_component_0",
726
+ ftype: "simple_chip",
727
+ name: "U1",
728
+ supplier_part_numbers: {}
729
+ },
730
+ {
731
+ type: "schematic_component",
732
+ schematic_component_id: "schematic_component_0",
733
+ center: {
734
+ x: 0,
735
+ y: 0
736
+ },
737
+ rotation: 0,
738
+ size: {
739
+ width: 1.1,
740
+ height: 1
741
+ },
742
+ pin_spacing: 0.2,
743
+ port_labels: {},
744
+ source_component_id: "source_component_0"
745
+ },
746
+ {
747
+ type: "schematic_port",
748
+ schematic_port_id: "schematic_port_0",
749
+ schematic_component_id: "schematic_component_0",
750
+ center: {
751
+ x: -0.9500000000000001,
752
+ y: 0.30000000000000004
753
+ },
754
+ source_port_id: "source_port_0",
755
+ facing_direction: "left",
756
+ distance_from_component_edge: 0.4,
757
+ side_of_component: "left",
758
+ pin_number: 1,
759
+ true_ccw_index: 0
760
+ },
761
+ {
762
+ type: "schematic_port",
763
+ schematic_port_id: "schematic_port_1",
764
+ schematic_component_id: "schematic_component_0",
765
+ center: {
766
+ x: -0.9500000000000001,
767
+ y: 0.10000000000000003
768
+ },
769
+ source_port_id: "source_port_1",
770
+ facing_direction: "left",
771
+ distance_from_component_edge: 0.4,
772
+ side_of_component: "left",
773
+ pin_number: 2,
774
+ true_ccw_index: 1
775
+ },
776
+ {
777
+ type: "schematic_port",
778
+ schematic_port_id: "schematic_port_2",
779
+ schematic_component_id: "schematic_component_0",
780
+ center: {
781
+ x: -0.9500000000000001,
782
+ y: -0.09999999999999998
783
+ },
784
+ source_port_id: "source_port_2",
785
+ facing_direction: "left",
786
+ distance_from_component_edge: 0.4,
787
+ side_of_component: "left",
788
+ pin_number: 3,
789
+ true_ccw_index: 2
790
+ },
791
+ {
792
+ type: "schematic_port",
793
+ schematic_port_id: "schematic_port_3",
794
+ schematic_component_id: "schematic_component_0",
795
+ center: {
796
+ x: -0.9500000000000001,
797
+ y: -0.30000000000000004
798
+ },
799
+ source_port_id: "source_port_3",
800
+ facing_direction: "left",
801
+ distance_from_component_edge: 0.4,
802
+ side_of_component: "left",
803
+ pin_number: 4,
804
+ true_ccw_index: 3
805
+ },
806
+ {
807
+ type: "schematic_port",
808
+ schematic_port_id: "schematic_port_4",
809
+ schematic_component_id: "schematic_component_0",
810
+ center: {
811
+ x: 0.9500000000000001,
812
+ y: -0.30000000000000004
813
+ },
814
+ source_port_id: "source_port_4",
815
+ facing_direction: "right",
816
+ distance_from_component_edge: 0.4,
817
+ side_of_component: "right",
818
+ pin_number: 5,
819
+ true_ccw_index: 4
820
+ },
821
+ {
822
+ type: "schematic_port",
823
+ schematic_port_id: "schematic_port_5",
824
+ schematic_component_id: "schematic_component_0",
825
+ center: {
826
+ x: 0.9500000000000001,
827
+ y: -0.10000000000000003
828
+ },
829
+ source_port_id: "source_port_5",
830
+ facing_direction: "right",
831
+ distance_from_component_edge: 0.4,
832
+ side_of_component: "right",
833
+ pin_number: 6,
834
+ true_ccw_index: 5
835
+ },
836
+ {
837
+ type: "schematic_port",
838
+ schematic_port_id: "schematic_port_6",
839
+ schematic_component_id: "schematic_component_0",
840
+ center: {
841
+ x: 0.9500000000000001,
842
+ y: 0.09999999999999998
843
+ },
844
+ source_port_id: "source_port_6",
845
+ facing_direction: "right",
846
+ distance_from_component_edge: 0.4,
847
+ side_of_component: "right",
848
+ pin_number: 7,
849
+ true_ccw_index: 6
850
+ },
851
+ {
852
+ type: "schematic_port",
853
+ schematic_port_id: "schematic_port_7",
854
+ schematic_component_id: "schematic_component_0",
855
+ center: {
856
+ x: 0.9500000000000001,
857
+ y: 0.30000000000000004
858
+ },
859
+ source_port_id: "source_port_7",
860
+ facing_direction: "right",
861
+ distance_from_component_edge: 0.4,
862
+ side_of_component: "right",
863
+ pin_number: 8,
864
+ true_ccw_index: 7
865
+ },
866
+ {
867
+ type: "pcb_component",
868
+ pcb_component_id: "pcb_component_0",
869
+ center: {
870
+ x: 0,
871
+ y: 0
872
+ },
873
+ width: 8.82,
874
+ height: 8.82,
875
+ layer: "top",
876
+ rotation: 0,
877
+ source_component_id: "source_component_0"
878
+ },
879
+ {
880
+ type: "pcb_board",
881
+ pcb_board_id: "pcb_board_0",
882
+ center: {
883
+ x: 0,
884
+ y: 0
885
+ },
886
+ thickness: 1.4,
887
+ num_layers: 4,
888
+ width: 10,
889
+ height: 10
890
+ },
891
+ {
892
+ type: "pcb_plated_hole",
893
+ pcb_plated_hole_id: "pcb_plated_hole_0",
894
+ pcb_component_id: "pcb_component_0",
895
+ pcb_port_id: "pcb_port_0",
896
+ outer_diameter: 1.2,
897
+ hole_diameter: 1,
898
+ shape: "circle",
899
+ port_hints: ["1"],
900
+ x: -3.81,
901
+ y: 3.81,
902
+ layers: ["top", "bottom"]
903
+ },
904
+ {
905
+ type: "pcb_plated_hole",
906
+ pcb_plated_hole_id: "pcb_plated_hole_1",
907
+ pcb_component_id: "pcb_component_0",
908
+ pcb_port_id: "pcb_port_1",
909
+ outer_diameter: 1.2,
910
+ hole_diameter: 1,
911
+ shape: "circle",
912
+ port_hints: ["2"],
913
+ x: -3.81,
914
+ y: 1.27,
915
+ layers: ["top", "bottom"]
916
+ },
917
+ {
918
+ type: "pcb_plated_hole",
919
+ pcb_plated_hole_id: "pcb_plated_hole_2",
920
+ pcb_component_id: "pcb_component_0",
921
+ pcb_port_id: "pcb_port_2",
922
+ outer_diameter: 1.2,
923
+ hole_diameter: 1,
924
+ shape: "circle",
925
+ port_hints: ["3"],
926
+ x: -3.81,
927
+ y: -1.27,
928
+ layers: ["top", "bottom"]
929
+ },
930
+ {
931
+ type: "pcb_plated_hole",
932
+ pcb_plated_hole_id: "pcb_plated_hole_3",
933
+ pcb_component_id: "pcb_component_0",
934
+ pcb_port_id: "pcb_port_3",
935
+ outer_diameter: 1.2,
936
+ hole_diameter: 1,
937
+ shape: "circle",
938
+ port_hints: ["4"],
939
+ x: -3.81,
940
+ y: -3.81,
941
+ layers: ["top", "bottom"]
942
+ },
943
+ {
944
+ type: "pcb_plated_hole",
945
+ pcb_plated_hole_id: "pcb_plated_hole_4",
946
+ pcb_component_id: "pcb_component_0",
947
+ pcb_port_id: "pcb_port_4",
948
+ outer_diameter: 1.2,
949
+ hole_diameter: 1,
950
+ shape: "circle",
951
+ port_hints: ["5"],
952
+ x: 3.81,
953
+ y: -3.81,
954
+ layers: ["top", "bottom"]
955
+ },
956
+ {
957
+ type: "pcb_plated_hole",
958
+ pcb_plated_hole_id: "pcb_plated_hole_5",
959
+ pcb_component_id: "pcb_component_0",
960
+ pcb_port_id: "pcb_port_5",
961
+ outer_diameter: 1.2,
962
+ hole_diameter: 1,
963
+ shape: "circle",
964
+ port_hints: ["6"],
965
+ x: 3.81,
966
+ y: -1.27,
967
+ layers: ["top", "bottom"]
968
+ },
969
+ {
970
+ type: "pcb_plated_hole",
971
+ pcb_plated_hole_id: "pcb_plated_hole_6",
972
+ pcb_component_id: "pcb_component_0",
973
+ pcb_port_id: "pcb_port_6",
974
+ outer_diameter: 1.2,
975
+ hole_diameter: 1,
976
+ shape: "circle",
977
+ port_hints: ["7"],
978
+ x: 3.81,
979
+ y: 1.27,
980
+ layers: ["top", "bottom"]
981
+ },
982
+ {
983
+ type: "pcb_plated_hole",
984
+ pcb_plated_hole_id: "pcb_plated_hole_7",
985
+ pcb_component_id: "pcb_component_0",
986
+ pcb_port_id: "pcb_port_7",
987
+ outer_diameter: 1.2,
988
+ hole_diameter: 1,
989
+ shape: "circle",
990
+ port_hints: ["8"],
991
+ x: 3.81,
992
+ y: 3.81,
993
+ layers: ["top", "bottom"]
994
+ },
995
+ {
996
+ type: "pcb_silkscreen_path",
997
+ pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
998
+ pcb_component_id: "pcb_component_0",
999
+ layer: "top",
1000
+ route: [
1001
+ {
1002
+ x: -3.01,
1003
+ y: -4.61
1004
+ },
1005
+ {
1006
+ x: -3.01,
1007
+ y: 4.61
1008
+ },
1009
+ {
1010
+ x: -1.0033333333333332,
1011
+ y: 4.61
1012
+ },
1013
+ {
1014
+ x: -0.9269591309529909,
1015
+ y: 4.226040956193693
1016
+ },
1017
+ {
1018
+ x: -0.7094638037905026,
1019
+ y: 3.9005361962094978
1020
+ },
1021
+ {
1022
+ x: -0.3839590438063067,
1023
+ y: 3.6830408690470096
1024
+ },
1025
+ {
1026
+ x: 6143644775722556e-32,
1027
+ y: 3.6066666666666674
1028
+ },
1029
+ {
1030
+ x: 0.38395904380630674,
1031
+ y: 3.6830408690470096
1032
+ },
1033
+ {
1034
+ x: 0.7094638037905027,
1035
+ y: 3.9005361962094978
1036
+ },
1037
+ {
1038
+ x: 0.9269591309529909,
1039
+ y: 4.226040956193693
1040
+ },
1041
+ {
1042
+ x: 1.0033333333333332,
1043
+ y: 4.61
1044
+ },
1045
+ {
1046
+ x: 3.01,
1047
+ y: 4.61
1048
+ },
1049
+ {
1050
+ x: 3.01,
1051
+ y: -4.61
1052
+ },
1053
+ {
1054
+ x: -3.01,
1055
+ y: -4.61
1056
+ }
1057
+ ],
1058
+ stroke_width: 0.1
1059
+ },
1060
+ {
1061
+ type: "pcb_port",
1062
+ pcb_port_id: "pcb_port_0",
1063
+ pcb_component_id: "pcb_component_0",
1064
+ layers: ["top", "inner1", "inner2", "bottom"],
1065
+ x: -3.81,
1066
+ y: 3.81,
1067
+ source_port_id: "source_port_0"
1068
+ },
1069
+ {
1070
+ type: "pcb_port",
1071
+ pcb_port_id: "pcb_port_1",
1072
+ pcb_component_id: "pcb_component_0",
1073
+ layers: ["top", "inner1", "inner2", "bottom"],
1074
+ x: -3.81,
1075
+ y: 1.27,
1076
+ source_port_id: "source_port_1"
1077
+ },
1078
+ {
1079
+ type: "pcb_port",
1080
+ pcb_port_id: "pcb_port_2",
1081
+ pcb_component_id: "pcb_component_0",
1082
+ layers: ["top", "inner1", "inner2", "bottom"],
1083
+ x: -3.81,
1084
+ y: -1.27,
1085
+ source_port_id: "source_port_2"
1086
+ },
1087
+ {
1088
+ type: "pcb_port",
1089
+ pcb_port_id: "pcb_port_3",
1090
+ pcb_component_id: "pcb_component_0",
1091
+ layers: ["top", "inner1", "inner2", "bottom"],
1092
+ x: -3.81,
1093
+ y: -3.81,
1094
+ source_port_id: "source_port_3"
1095
+ },
1096
+ {
1097
+ type: "pcb_port",
1098
+ pcb_port_id: "pcb_port_4",
1099
+ pcb_component_id: "pcb_component_0",
1100
+ layers: ["top", "inner1", "inner2", "bottom"],
1101
+ x: 3.81,
1102
+ y: -3.81,
1103
+ source_port_id: "source_port_4"
1104
+ },
1105
+ {
1106
+ type: "pcb_port",
1107
+ pcb_port_id: "pcb_port_5",
1108
+ pcb_component_id: "pcb_component_0",
1109
+ layers: ["top", "inner1", "inner2", "bottom"],
1110
+ x: 3.81,
1111
+ y: -1.27,
1112
+ source_port_id: "source_port_5"
1113
+ },
1114
+ {
1115
+ type: "pcb_port",
1116
+ pcb_port_id: "pcb_port_6",
1117
+ pcb_component_id: "pcb_component_0",
1118
+ layers: ["top", "inner1", "inner2", "bottom"],
1119
+ x: 3.81,
1120
+ y: 1.27,
1121
+ source_port_id: "source_port_6"
1122
+ },
1123
+ {
1124
+ type: "pcb_port",
1125
+ pcb_port_id: "pcb_port_7",
1126
+ pcb_component_id: "pcb_component_0",
1127
+ layers: ["top", "inner1", "inner2", "bottom"],
1128
+ x: 3.81,
1129
+ y: 3.81,
1130
+ source_port_id: "source_port_7"
1131
+ },
1132
+ {
1133
+ type: "cad_component",
1134
+ cad_component_id: "cad_component_0",
1135
+ position: {
1136
+ x: 0,
1137
+ y: 0,
1138
+ z: 0.7
1139
+ },
1140
+ rotation: {
1141
+ x: 0,
1142
+ y: 0,
1143
+ z: 0
1144
+ },
1145
+ pcb_component_id: "pcb_component_0",
1146
+ source_component_id: "source_component_0",
1147
+ footprinter_string: "dip8"
1148
+ }
1149
+ ]
1150
+ });
1151
+ const firstBuild = db.addPackageBuild({
1152
+ package_release_id: packageReleaseId1,
1153
+ created_at: new Date(Date.now() - 15e3).toISOString(),
1154
+ // 15 seconds ago
1155
+ transpilation_in_progress: false,
1156
+ transpilation_started_at: new Date(Date.now() - 15e3).toISOString(),
1157
+ transpilation_completed_at: new Date(Date.now() - 14e3).toISOString(),
1158
+ transpilation_logs: [
1159
+ "[INFO] Starting transpilation...",
1160
+ "[INFO] Parsing package code",
1161
+ "[ERROR] Failed to parse TypeScript definitions",
1162
+ "[ERROR] Invalid syntax in component declaration"
1163
+ ],
1164
+ transpilation_error: "TypeScript compilation failed: Syntax error in component declaration",
1165
+ circuit_json_build_in_progress: false,
1166
+ circuit_json_build_started_at: null,
1167
+ circuit_json_build_completed_at: null,
1168
+ circuit_json_build_logs: [],
1169
+ circuit_json_build_error: "Build cancelled due to transpilation failure",
1170
+ build_in_progress: false,
1171
+ build_started_at: new Date(Date.now() - 15e3).toISOString(),
1172
+ build_completed_at: new Date(Date.now() - 14e3).toISOString(),
1173
+ build_error: "Build failed: Unable to complete transpilation step",
1174
+ build_error_last_updated_at: new Date(Date.now() - 14e3).toISOString(),
1175
+ preview_url: null,
1176
+ build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - FAILED\nError: Invalid syntax in component declaration\nBuild terminated with errors"
1177
+ });
1178
+ const release1 = db.getPackageReleaseById(packageReleaseId1);
1179
+ db.updatePackageRelease({
1180
+ ...release1,
1181
+ latest_package_build_id: firstBuild.package_build_id
1182
+ });
1183
+ const test2Package = db.addPackage({
1184
+ name: "testuser/test2-package",
1185
+ unscoped_name: "test2-package",
1186
+ creator_account_id: account_id,
1187
+ owner_org_id: "org-1234",
1188
+ owner_github_username: "testuser",
1189
+ description: "A test package for development",
1190
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1191
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1192
+ is_source_from_github: false,
1193
+ snippet_type: "package",
1194
+ latest_package_release_id: null,
1195
+ latest_version: "0.0.1",
1196
+ license: "MIT",
1197
+ website: "https://tscircuit.com",
1198
+ star_count: 10,
1199
+ ai_description: "A comprehensive test package designed for development and testing purposes. This package includes various components and utilities commonly used in circuit design and simulation workflows.",
1200
+ ai_usage_instructions: "Import the package using `import { TestComponent } from '@tsci/testuser.test2-package'`. Use the TestComponent in your circuit designs by providing the required props. Example: `<TestComponent name='my-test' value={42} />`",
1201
+ default_view: "files",
1202
+ latest_pcb_preview_image_url: `/api/packages/images/testuser/test2-package/pcb.png`,
1203
+ latest_cad_preview_image_url: `/api/packages/images/testuser/test2-package/3d.png`,
1204
+ latest_sch_preview_image_url: `/api/packages/images/testuser/test2-package/schematic.png`
1205
+ });
1206
+ const { package_release_id: test2PackageReleaseId } = db.addPackageRelease({
1207
+ package_id: test2Package.package_id,
1208
+ version: "0.0.1",
1209
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1210
+ is_latest: true,
1211
+ is_locked: false,
1212
+ has_transpiled: true,
1213
+ transpilation_error: null
1214
+ });
1215
+ db.addPackageFile({
1216
+ package_release_id: test2PackageReleaseId,
1217
+ file_path: "index.tsx",
1218
+ content_text: `
1219
+ export const TestComponent = ({ name }: { name: string }) => (
1220
+ <resistor name={name} resistance="10k" />
1221
+ )
1222
+ `.trim(),
1223
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
1224
+ });
1225
+ db.addPackageFile({
1226
+ package_release_id: test2PackageReleaseId,
1227
+ file_path: "/dist/circuit.json",
1228
+ content_text: `[
1229
+ {
1230
+ "type": "source_project_metadata",
1231
+ "source_project_metadata_id": "source_project_metadata_0",
1232
+ "software_used_string": "@tscircuit/core@0.0.813"
1233
+ },
1234
+ {
1235
+ "type": "source_group",
1236
+ "source_group_id": "source_group_0",
1237
+ "is_subcircuit": true,
1238
+ "was_automatically_named": true,
1239
+ "subcircuit_id": "subcircuit_source_group_0"
1240
+ },
1241
+ {
1242
+ "type": "source_board",
1243
+ "source_board_id": "source_board_0",
1244
+ "source_group_id": "source_group_0"
1245
+ },
1246
+ {
1247
+ "type": "schematic_group",
1248
+ "schematic_group_id": "schematic_group_0",
1249
+ "is_subcircuit": true,
1250
+ "subcircuit_id": "subcircuit_source_group_0",
1251
+ "name": "unnamed_board1",
1252
+ "center": {
1253
+ "x": 0,
1254
+ "y": 0
1255
+ },
1256
+ "width": 0,
1257
+ "height": 0,
1258
+ "schematic_component_ids": [],
1259
+ "source_group_id": "source_group_0"
1260
+ },
1261
+ {
1262
+ "type": "pcb_board",
1263
+ "pcb_board_id": "pcb_board_0",
1264
+ "center": {
1265
+ "x": 0,
1266
+ "y": 0
1267
+ },
1268
+ "thickness": 1.4,
1269
+ "num_layers": 2,
1270
+ "width": 10,
1271
+ "height": 10,
1272
+ "material": "fr4"
1273
+ }
1274
+ ]`.trim(),
1275
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
1276
+ });
1277
+ db.addPackageBuild({
1278
+ package_release_id: test2PackageReleaseId,
1279
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1280
+ transpilation_in_progress: false,
1281
+ transpilation_started_at: new Date(Date.now() - 5e3).toISOString(),
1282
+ // Started 5 seconds ago
1283
+ transpilation_completed_at: new Date(Date.now() - 3e3).toISOString(),
1284
+ // Completed 3 seconds ago
1285
+ transpilation_logs: [
1286
+ "[INFO] Starting transpilation...",
1287
+ "[INFO] Parsing package code",
1288
+ "[INFO] Generating TypeScript definitions",
1289
+ "[INFO] Compiling to JavaScript",
1290
+ "[SUCCESS] Transpilation completed successfully"
1291
+ ],
1292
+ transpilation_error: null,
1293
+ circuit_json_build_in_progress: false,
1294
+ circuit_json_build_started_at: new Date(Date.now() - 3e3).toISOString(),
1295
+ // Started after transpilation
1296
+ circuit_json_build_completed_at: new Date(Date.now() - 1e3).toISOString(),
1297
+ // Completed 1 second ago
1298
+ circuit_json_build_logs: [
1299
+ "[INFO] Starting circuit JSON build...",
1300
+ "[INFO] Analyzing component structure",
1301
+ "[INFO] Generating port configurations",
1302
+ "[INFO] Validating circuit connections",
1303
+ "[SUCCESS] Circuit JSON build completed"
1304
+ ],
1305
+ circuit_json_build_error: null,
1306
+ build_in_progress: false,
1307
+ build_started_at: new Date(Date.now() - 1e4).toISOString(),
1308
+ // Started 10 seconds ago
1309
+ build_completed_at: (/* @__PURE__ */ new Date()).toISOString(),
1310
+ // Just completed
1311
+ build_error: null,
1312
+ build_error_last_updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1313
+ build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - OK\n4. Circuit validation - OK\n5. Package assembly - OK\nBuild completed successfully"
1314
+ });
1315
+ db.addSnippet({
1316
+ name: "seveibar/a555timer",
1317
+ unscoped_name: "a555timer",
1318
+ owner_name: "seveibar",
1319
+ code: `
1320
+ export const A555Timer = ({ name }: { name: string }) => (
1321
+ <chip name={name} footprint="dip8" />
1322
+ )
1323
+ `.trim(),
1324
+ dts: `
1325
+ declare module "@tsci/seveibar.a555timer" {
1326
+ export const A555Timer: ({ name }: {
1327
+ name: string;
1328
+ }) => any;
1329
+ }
1330
+ `.trim(),
1331
+ compiled_js: `
1332
+ "use strict";
1333
+
1334
+ Object.defineProperty(exports, "__esModule", {
1335
+ value: true
1336
+ });
1337
+ exports.A555Timer = void 0;
1338
+ const A555Timer = ({
1339
+ name
1340
+ }) => /*#__PURE__*/React.createElement("chip", {
1341
+ name: name,
1342
+ footprint: "dip8"
1343
+ });
1344
+ exports.A555Timer = A555Timer;
1345
+ `.trim(),
1346
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1347
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1348
+ snippet_type: "package",
1349
+ description: "A simple package with an A555 Timer component",
1350
+ circuit_json: [
1351
+ {
1352
+ type: "source_port",
1353
+ source_port_id: "source_port_0",
1354
+ name: "pin1",
1355
+ pin_number: 1,
1356
+ port_hints: ["pin1", "1"],
1357
+ source_component_id: "source_component_0"
1358
+ },
1359
+ {
1360
+ type: "source_port",
1361
+ source_port_id: "source_port_1",
1362
+ name: "pin2",
1363
+ pin_number: 2,
1364
+ port_hints: ["pin2", "2"],
1365
+ source_component_id: "source_component_0"
1366
+ },
1367
+ {
1368
+ type: "source_port",
1369
+ source_port_id: "source_port_2",
1370
+ name: "pin3",
1371
+ pin_number: 3,
1372
+ port_hints: ["pin3", "3"],
1373
+ source_component_id: "source_component_0"
1374
+ },
1375
+ {
1376
+ type: "source_port",
1377
+ source_port_id: "source_port_3",
1378
+ name: "pin4",
1379
+ pin_number: 4,
1380
+ port_hints: ["pin4", "4"],
1381
+ source_component_id: "source_component_0"
1382
+ },
1383
+ {
1384
+ type: "source_port",
1385
+ source_port_id: "source_port_4",
1386
+ name: "pin5",
1387
+ pin_number: 5,
1388
+ port_hints: ["pin5", "5"],
1389
+ source_component_id: "source_component_0"
1390
+ },
1391
+ {
1392
+ type: "source_port",
1393
+ source_port_id: "source_port_5",
1394
+ name: "pin6",
1395
+ pin_number: 6,
1396
+ port_hints: ["pin6", "6"],
1397
+ source_component_id: "source_component_0"
1398
+ },
1399
+ {
1400
+ type: "source_port",
1401
+ source_port_id: "source_port_6",
1402
+ name: "pin7",
1403
+ pin_number: 7,
1404
+ port_hints: ["pin7", "7"],
1405
+ source_component_id: "source_component_0"
1406
+ },
1407
+ {
1408
+ type: "source_port",
1409
+ source_port_id: "source_port_7",
1410
+ name: "pin8",
1411
+ pin_number: 8,
1412
+ port_hints: ["pin8", "8"],
1413
+ source_component_id: "source_component_0"
1414
+ },
1415
+ {
1416
+ type: "source_component",
1417
+ source_component_id: "source_component_0",
1418
+ ftype: "simple_chip",
1419
+ name: "U1"
1420
+ },
1421
+ {
1422
+ type: "schematic_component",
1423
+ schematic_component_id: "schematic_component_0",
1424
+ center: {
1425
+ x: 0,
1426
+ y: 0
1427
+ },
1428
+ rotation: 0,
1429
+ size: {
1430
+ width: 1.1,
1431
+ height: 1
1432
+ },
1433
+ pin_spacing: 0.2,
1434
+ port_labels: {},
1435
+ source_component_id: "source_component_0"
1436
+ },
1437
+ {
1438
+ type: "schematic_port",
1439
+ schematic_port_id: "schematic_port_0",
1440
+ schematic_component_id: "schematic_component_0",
1441
+ center: {
1442
+ x: -0.9500000000000001,
1443
+ y: 0.30000000000000004
1444
+ },
1445
+ source_port_id: "source_port_0",
1446
+ facing_direction: "left",
1447
+ distance_from_component_edge: 0.4,
1448
+ side_of_component: "left",
1449
+ pin_number: 1,
1450
+ true_ccw_index: 0
1451
+ },
1452
+ {
1453
+ type: "schematic_port",
1454
+ schematic_port_id: "schematic_port_1",
1455
+ schematic_component_id: "schematic_component_0",
1456
+ center: {
1457
+ x: -0.9500000000000001,
1458
+ y: 0.10000000000000003
1459
+ },
1460
+ source_port_id: "source_port_1",
1461
+ facing_direction: "left",
1462
+ distance_from_component_edge: 0.4,
1463
+ side_of_component: "left",
1464
+ pin_number: 2,
1465
+ true_ccw_index: 1
1466
+ },
1467
+ {
1468
+ type: "schematic_port",
1469
+ schematic_port_id: "schematic_port_2",
1470
+ schematic_component_id: "schematic_component_0",
1471
+ center: {
1472
+ x: -0.9500000000000001,
1473
+ y: -0.09999999999999998
1474
+ },
1475
+ source_port_id: "source_port_2",
1476
+ facing_direction: "left",
1477
+ distance_from_component_edge: 0.4,
1478
+ side_of_component: "left",
1479
+ pin_number: 3,
1480
+ true_ccw_index: 2
1481
+ },
1482
+ {
1483
+ type: "schematic_port",
1484
+ schematic_port_id: "schematic_port_3",
1485
+ schematic_component_id: "schematic_component_0",
1486
+ center: {
1487
+ x: -0.9500000000000001,
1488
+ y: -0.30000000000000004
1489
+ },
1490
+ source_port_id: "source_port_3",
1491
+ facing_direction: "left",
1492
+ distance_from_component_edge: 0.4,
1493
+ side_of_component: "left",
1494
+ pin_number: 4,
1495
+ true_ccw_index: 3
1496
+ },
1497
+ {
1498
+ type: "schematic_port",
1499
+ schematic_port_id: "schematic_port_4",
1500
+ schematic_component_id: "schematic_component_0",
1501
+ center: {
1502
+ x: 0.9500000000000001,
1503
+ y: -0.30000000000000004
1504
+ },
1505
+ source_port_id: "source_port_4",
1506
+ facing_direction: "right",
1507
+ distance_from_component_edge: 0.4,
1508
+ side_of_component: "right",
1509
+ pin_number: 5,
1510
+ true_ccw_index: 4
1511
+ },
1512
+ {
1513
+ type: "schematic_port",
1514
+ schematic_port_id: "schematic_port_5",
1515
+ schematic_component_id: "schematic_component_0",
1516
+ center: {
1517
+ x: 0.9500000000000001,
1518
+ y: -0.10000000000000003
1519
+ },
1520
+ source_port_id: "source_port_5",
1521
+ facing_direction: "right",
1522
+ distance_from_component_edge: 0.4,
1523
+ side_of_component: "right",
1524
+ pin_number: 6,
1525
+ true_ccw_index: 5
1526
+ },
1527
+ {
1528
+ type: "schematic_port",
1529
+ schematic_port_id: "schematic_port_6",
1530
+ schematic_component_id: "schematic_component_0",
1531
+ center: {
1532
+ x: 0.9500000000000001,
1533
+ y: 0.09999999999999998
1534
+ },
1535
+ source_port_id: "source_port_6",
1536
+ facing_direction: "right",
1537
+ distance_from_component_edge: 0.4,
1538
+ side_of_component: "right",
1539
+ pin_number: 7,
1540
+ true_ccw_index: 6
1541
+ },
1542
+ {
1543
+ type: "schematic_port",
1544
+ schematic_port_id: "schematic_port_7",
1545
+ schematic_component_id: "schematic_component_0",
1546
+ center: {
1547
+ x: 0.9500000000000001,
1548
+ y: 0.30000000000000004
1549
+ },
1550
+ source_port_id: "source_port_7",
1551
+ facing_direction: "right",
1552
+ distance_from_component_edge: 0.4,
1553
+ side_of_component: "right",
1554
+ pin_number: 8,
1555
+ true_ccw_index: 7
1556
+ },
1557
+ {
1558
+ type: "pcb_component",
1559
+ pcb_component_id: "pcb_component_0",
1560
+ center: {
1561
+ x: 0,
1562
+ y: 0
1563
+ },
1564
+ width: 8.82,
1565
+ height: 8.82,
1566
+ layer: "top",
1567
+ rotation: 0,
1568
+ source_component_id: "source_component_0"
1569
+ },
1570
+ {
1571
+ type: "pcb_board",
1572
+ pcb_board_id: "pcb_board_0",
1573
+ center: {
1574
+ x: 0,
1575
+ y: 0
1576
+ },
1577
+ thickness: 1.4,
1578
+ num_layers: 4,
1579
+ width: 50,
1580
+ height: 50
1581
+ },
1582
+ {
1583
+ type: "pcb_plated_hole",
1584
+ pcb_plated_hole_id: "pcb_plated_hole_0",
1585
+ pcb_component_id: "pcb_component_0",
1586
+ pcb_port_id: "pcb_port_0",
1587
+ outer_diameter: 1.2,
1588
+ hole_diameter: 1,
1589
+ shape: "circle",
1590
+ port_hints: ["1"],
1591
+ x: -3.81,
1592
+ y: 3.81,
1593
+ layers: ["top", "bottom"]
1594
+ },
1595
+ {
1596
+ type: "pcb_plated_hole",
1597
+ pcb_plated_hole_id: "pcb_plated_hole_1",
1598
+ pcb_component_id: "pcb_component_0",
1599
+ pcb_port_id: "pcb_port_1",
1600
+ outer_diameter: 1.2,
1601
+ hole_diameter: 1,
1602
+ shape: "circle",
1603
+ port_hints: ["2"],
1604
+ x: -3.81,
1605
+ y: 1.27,
1606
+ layers: ["top", "bottom"]
1607
+ },
1608
+ {
1609
+ type: "pcb_plated_hole",
1610
+ pcb_plated_hole_id: "pcb_plated_hole_2",
1611
+ pcb_component_id: "pcb_component_0",
1612
+ pcb_port_id: "pcb_port_2",
1613
+ outer_diameter: 1.2,
1614
+ hole_diameter: 1,
1615
+ shape: "circle",
1616
+ port_hints: ["3"],
1617
+ x: -3.81,
1618
+ y: -1.27,
1619
+ layers: ["top", "bottom"]
1620
+ },
1621
+ {
1622
+ type: "pcb_plated_hole",
1623
+ pcb_plated_hole_id: "pcb_plated_hole_3",
1624
+ pcb_component_id: "pcb_component_0",
1625
+ pcb_port_id: "pcb_port_3",
1626
+ outer_diameter: 1.2,
1627
+ hole_diameter: 1,
1628
+ shape: "circle",
1629
+ port_hints: ["4"],
1630
+ x: -3.81,
1631
+ y: -3.81,
1632
+ layers: ["top", "bottom"]
1633
+ },
1634
+ {
1635
+ type: "pcb_plated_hole",
1636
+ pcb_plated_hole_id: "pcb_plated_hole_4",
1637
+ pcb_component_id: "pcb_component_0",
1638
+ pcb_port_id: "pcb_port_4",
1639
+ outer_diameter: 1.2,
1640
+ hole_diameter: 1,
1641
+ shape: "circle",
1642
+ port_hints: ["5"],
1643
+ x: 3.81,
1644
+ y: -3.81,
1645
+ layers: ["top", "bottom"]
1646
+ },
1647
+ {
1648
+ type: "pcb_plated_hole",
1649
+ pcb_plated_hole_id: "pcb_plated_hole_5",
1650
+ pcb_component_id: "pcb_component_0",
1651
+ pcb_port_id: "pcb_port_5",
1652
+ outer_diameter: 1.2,
1653
+ hole_diameter: 1,
1654
+ shape: "circle",
1655
+ port_hints: ["6"],
1656
+ x: 3.81,
1657
+ y: -1.27,
1658
+ layers: ["top", "bottom"]
1659
+ },
1660
+ {
1661
+ type: "pcb_plated_hole",
1662
+ pcb_plated_hole_id: "pcb_plated_hole_6",
1663
+ pcb_component_id: "pcb_component_0",
1664
+ pcb_port_id: "pcb_port_6",
1665
+ outer_diameter: 1.2,
1666
+ hole_diameter: 1,
1667
+ shape: "circle",
1668
+ port_hints: ["7"],
1669
+ x: 3.81,
1670
+ y: 1.27,
1671
+ layers: ["top", "bottom"]
1672
+ },
1673
+ {
1674
+ type: "pcb_plated_hole",
1675
+ pcb_plated_hole_id: "pcb_plated_hole_7",
1676
+ pcb_component_id: "pcb_component_0",
1677
+ pcb_port_id: "pcb_port_7",
1678
+ outer_diameter: 1.2,
1679
+ hole_diameter: 1,
1680
+ shape: "circle",
1681
+ port_hints: ["8"],
1682
+ x: 3.81,
1683
+ y: 3.81,
1684
+ layers: ["top", "bottom"]
1685
+ },
1686
+ {
1687
+ type: "pcb_silkscreen_path",
1688
+ pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
1689
+ pcb_component_id: "pcb_component_0",
1690
+ layer: "top",
1691
+ route: [
1692
+ {
1693
+ x: -3.01,
1694
+ y: -4.61
1695
+ },
1696
+ {
1697
+ x: -3.01,
1698
+ y: 4.61
1699
+ },
1700
+ {
1701
+ x: -1.0033333333333332,
1702
+ y: 4.61
1703
+ },
1704
+ {
1705
+ x: -0.9269591309529909,
1706
+ y: 4.226040956193693
1707
+ },
1708
+ {
1709
+ x: -0.7094638037905026,
1710
+ y: 3.9005361962094978
1711
+ },
1712
+ {
1713
+ x: -0.3839590438063067,
1714
+ y: 3.6830408690470096
1715
+ },
1716
+ {
1717
+ x: 6143644775722556e-32,
1718
+ y: 3.6066666666666674
1719
+ },
1720
+ {
1721
+ x: 0.38395904380630674,
1722
+ y: 3.6830408690470096
1723
+ },
1724
+ {
1725
+ x: 0.7094638037905027,
1726
+ y: 3.9005361962094978
1727
+ },
1728
+ {
1729
+ x: 0.9269591309529909,
1730
+ y: 4.226040956193693
1731
+ },
1732
+ {
1733
+ x: 1.0033333333333332,
1734
+ y: 4.61
1735
+ },
1736
+ {
1737
+ x: 3.01,
1738
+ y: 4.61
1739
+ },
1740
+ {
1741
+ x: 3.01,
1742
+ y: -4.61
1743
+ },
1744
+ {
1745
+ x: -3.01,
1746
+ y: -4.61
1747
+ }
1748
+ ],
1749
+ stroke_width: 0.1
1750
+ },
1751
+ {
1752
+ type: "pcb_port",
1753
+ pcb_port_id: "pcb_port_0",
1754
+ pcb_component_id: "pcb_component_0",
1755
+ layers: ["top", "inner1", "inner2", "bottom"],
1756
+ x: -3.81,
1757
+ y: 3.81,
1758
+ source_port_id: "source_port_0"
1759
+ },
1760
+ {
1761
+ type: "pcb_port",
1762
+ pcb_port_id: "pcb_port_1",
1763
+ pcb_component_id: "pcb_component_0",
1764
+ layers: ["top", "inner1", "inner2", "bottom"],
1765
+ x: -3.81,
1766
+ y: 1.27,
1767
+ source_port_id: "source_port_1"
1768
+ },
1769
+ {
1770
+ type: "pcb_port",
1771
+ pcb_port_id: "pcb_port_2",
1772
+ pcb_component_id: "pcb_component_0",
1773
+ layers: ["top", "inner1", "inner2", "bottom"],
1774
+ x: -3.81,
1775
+ y: -1.27,
1776
+ source_port_id: "source_port_2"
1777
+ },
1778
+ {
1779
+ type: "pcb_port",
1780
+ pcb_port_id: "pcb_port_3",
1781
+ pcb_component_id: "pcb_component_0",
1782
+ layers: ["top", "inner1", "inner2", "bottom"],
1783
+ x: -3.81,
1784
+ y: -3.81,
1785
+ source_port_id: "source_port_3"
1786
+ },
1787
+ {
1788
+ type: "pcb_port",
1789
+ pcb_port_id: "pcb_port_4",
1790
+ pcb_component_id: "pcb_component_0",
1791
+ layers: ["top", "inner1", "inner2", "bottom"],
1792
+ x: 3.81,
1793
+ y: -3.81,
1794
+ source_port_id: "source_port_4"
1795
+ },
1796
+ {
1797
+ type: "pcb_port",
1798
+ pcb_port_id: "pcb_port_5",
1799
+ pcb_component_id: "pcb_component_0",
1800
+ layers: ["top", "inner1", "inner2", "bottom"],
1801
+ x: 3.81,
1802
+ y: -1.27,
1803
+ source_port_id: "source_port_5"
1804
+ },
1805
+ {
1806
+ type: "pcb_port",
1807
+ pcb_port_id: "pcb_port_6",
1808
+ pcb_component_id: "pcb_component_0",
1809
+ layers: ["top", "inner1", "inner2", "bottom"],
1810
+ x: 3.81,
1811
+ y: 1.27,
1812
+ source_port_id: "source_port_6"
1813
+ },
1814
+ {
1815
+ type: "pcb_port",
1816
+ pcb_port_id: "pcb_port_7",
1817
+ pcb_component_id: "pcb_component_0",
1818
+ layers: ["top", "inner1", "inner2", "bottom"],
1819
+ x: 3.81,
1820
+ y: 3.81,
1821
+ source_port_id: "source_port_7"
1822
+ },
1823
+ {
1824
+ type: "cad_component",
1825
+ cad_component_id: "cad_component_0",
1826
+ position: {
1827
+ x: 0,
1828
+ y: 0,
1829
+ z: 0.7
1830
+ },
1831
+ rotation: {
1832
+ x: 0,
1833
+ y: 0,
1834
+ z: 0
1835
+ },
1836
+ pcb_component_id: "pcb_component_0",
1837
+ source_component_id: "source_component_0",
1838
+ footprinter_string: "dip8"
1839
+ }
1840
+ ]
1841
+ });
1842
+ const { package_release_id: packageReleaseId2 } = db.addSnippet({
1843
+ name: "testuser/a555timer-square-wave",
1844
+ unscoped_name: "a555timer-square-wave",
1845
+ owner_name: "testuser",
1846
+ branch_name: "main",
1847
+ commit_message: "Attempted build of a555timer-square-wave package",
1848
+ commit_author: "testuser",
1849
+ creator_account_id: account_id,
1850
+ code: `
1851
+ import { A555Timer } from "@tsci/seveibar.a555timer"
1852
+
1853
+ export const SquareWaveModule = () => (
1854
+ <A555Timer name="U1" />
1855
+ )
1856
+ `.trim(),
1857
+ dts: 'export declare const SquareWaveModule: () => import("react/jsx-runtime").JSX.Element;\n',
1858
+ compiled_js: '"use strict";\n\nObject.defineProperty(exports, "__esModule", {\n value: true\n});\nexports.SquareWaveModule = void 0;\nvar _seveibar = require("@tsci/seveibar.a555timer");\nconst SquareWaveModule = () => /*#__PURE__*/React.createElement(_seveibar.A555Timer, {\n name: "U1"\n});\nexports.SquareWaveModule = SquareWaveModule;',
1859
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1860
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1861
+ snippet_type: "package",
1862
+ github_repo_full_name: "testuser/test",
1863
+ description: "A simple package that outputs a square waveform using the a555timer",
1864
+ circuit_json: [
1865
+ {
1866
+ type: "source_port",
1867
+ source_port_id: "source_port_0",
1868
+ name: "pin1",
1869
+ pin_number: 1,
1870
+ port_hints: ["pin1", "1"],
1871
+ source_component_id: "source_component_0"
1872
+ },
1873
+ {
1874
+ type: "source_port",
1875
+ source_port_id: "source_port_1",
1876
+ name: "pin2",
1877
+ pin_number: 2,
1878
+ port_hints: ["pin2", "2"],
1879
+ source_component_id: "source_component_0"
1880
+ },
1881
+ {
1882
+ type: "source_port",
1883
+ source_port_id: "source_port_2",
1884
+ name: "pin3",
1885
+ pin_number: 3,
1886
+ port_hints: ["pin3", "3"],
1887
+ source_component_id: "source_component_0"
1888
+ },
1889
+ {
1890
+ type: "source_port",
1891
+ source_port_id: "source_port_3",
1892
+ name: "pin4",
1893
+ pin_number: 4,
1894
+ port_hints: ["pin4", "4"],
1895
+ source_component_id: "source_component_0"
1896
+ },
1897
+ {
1898
+ type: "source_port",
1899
+ source_port_id: "source_port_4",
1900
+ name: "pin5",
1901
+ pin_number: 5,
1902
+ port_hints: ["pin5", "5"],
1903
+ source_component_id: "source_component_0"
1904
+ },
1905
+ {
1906
+ type: "source_port",
1907
+ source_port_id: "source_port_5",
1908
+ name: "pin6",
1909
+ pin_number: 6,
1910
+ port_hints: ["pin6", "6"],
1911
+ source_component_id: "source_component_0"
1912
+ },
1913
+ {
1914
+ type: "source_port",
1915
+ source_port_id: "source_port_6",
1916
+ name: "pin7",
1917
+ pin_number: 7,
1918
+ port_hints: ["pin7", "7"],
1919
+ source_component_id: "source_component_0"
1920
+ },
1921
+ {
1922
+ type: "source_port",
1923
+ source_port_id: "source_port_7",
1924
+ name: "pin8",
1925
+ pin_number: 8,
1926
+ port_hints: ["pin8", "8"],
1927
+ source_component_id: "source_component_0"
1928
+ },
1929
+ {
1930
+ type: "source_component",
1931
+ source_component_id: "source_component_0",
1932
+ ftype: "simple_chip",
1933
+ name: "U1"
1934
+ },
1935
+ {
1936
+ type: "schematic_component",
1937
+ schematic_component_id: "schematic_component_0",
1938
+ center: {
1939
+ x: 0,
1940
+ y: 0
1941
+ },
1942
+ rotation: 0,
1943
+ size: {
1944
+ width: 1.1,
1945
+ height: 1
1946
+ },
1947
+ pin_spacing: 0.2,
1948
+ port_labels: {},
1949
+ source_component_id: "source_component_0"
1950
+ },
1951
+ {
1952
+ type: "schematic_port",
1953
+ schematic_port_id: "schematic_port_0",
1954
+ schematic_component_id: "schematic_component_0",
1955
+ center: {
1956
+ x: -0.9500000000000001,
1957
+ y: 0.30000000000000004
1958
+ },
1959
+ source_port_id: "source_port_0",
1960
+ facing_direction: "left",
1961
+ distance_from_component_edge: 0.4,
1962
+ side_of_component: "left",
1963
+ pin_number: 1,
1964
+ true_ccw_index: 0
1965
+ },
1966
+ {
1967
+ type: "schematic_port",
1968
+ schematic_port_id: "schematic_port_1",
1969
+ schematic_component_id: "schematic_component_0",
1970
+ center: {
1971
+ x: -0.9500000000000001,
1972
+ y: 0.10000000000000003
1973
+ },
1974
+ source_port_id: "source_port_1",
1975
+ facing_direction: "left",
1976
+ distance_from_component_edge: 0.4,
1977
+ side_of_component: "left",
1978
+ pin_number: 2,
1979
+ true_ccw_index: 1
1980
+ },
1981
+ {
1982
+ type: "schematic_port",
1983
+ schematic_port_id: "schematic_port_2",
1984
+ schematic_component_id: "schematic_component_0",
1985
+ center: {
1986
+ x: -0.9500000000000001,
1987
+ y: -0.09999999999999998
1988
+ },
1989
+ source_port_id: "source_port_2",
1990
+ facing_direction: "left",
1991
+ distance_from_component_edge: 0.4,
1992
+ side_of_component: "left",
1993
+ pin_number: 3,
1994
+ true_ccw_index: 2
1995
+ },
1996
+ {
1997
+ type: "schematic_port",
1998
+ schematic_port_id: "schematic_port_3",
1999
+ schematic_component_id: "schematic_component_0",
2000
+ center: {
2001
+ x: -0.9500000000000001,
2002
+ y: -0.30000000000000004
2003
+ },
2004
+ source_port_id: "source_port_3",
2005
+ facing_direction: "left",
2006
+ distance_from_component_edge: 0.4,
2007
+ side_of_component: "left",
2008
+ pin_number: 4,
2009
+ true_ccw_index: 3
2010
+ },
2011
+ {
2012
+ type: "schematic_port",
2013
+ schematic_port_id: "schematic_port_4",
2014
+ schematic_component_id: "schematic_component_0",
2015
+ center: {
2016
+ x: 0.9500000000000001,
2017
+ y: -0.30000000000000004
2018
+ },
2019
+ source_port_id: "source_port_4",
2020
+ facing_direction: "right",
2021
+ distance_from_component_edge: 0.4,
2022
+ side_of_component: "right",
2023
+ pin_number: 5,
2024
+ true_ccw_index: 4
2025
+ },
2026
+ {
2027
+ type: "schematic_port",
2028
+ schematic_port_id: "schematic_port_5",
2029
+ schematic_component_id: "schematic_component_0",
2030
+ center: {
2031
+ x: 0.9500000000000001,
2032
+ y: -0.10000000000000003
2033
+ },
2034
+ source_port_id: "source_port_5",
2035
+ facing_direction: "right",
2036
+ distance_from_component_edge: 0.4,
2037
+ side_of_component: "right",
2038
+ pin_number: 6,
2039
+ true_ccw_index: 5
2040
+ },
2041
+ {
2042
+ type: "schematic_port",
2043
+ schematic_port_id: "schematic_port_6",
2044
+ schematic_component_id: "schematic_component_0",
2045
+ center: {
2046
+ x: 0.9500000000000001,
2047
+ y: 0.09999999999999998
2048
+ },
2049
+ source_port_id: "source_port_6",
2050
+ facing_direction: "right",
2051
+ distance_from_component_edge: 0.4,
2052
+ side_of_component: "right",
2053
+ pin_number: 7,
2054
+ true_ccw_index: 6
2055
+ },
2056
+ {
2057
+ type: "schematic_port",
2058
+ schematic_port_id: "schematic_port_7",
2059
+ schematic_component_id: "schematic_component_0",
2060
+ center: {
2061
+ x: 0.9500000000000001,
2062
+ y: 0.30000000000000004
2063
+ },
2064
+ source_port_id: "source_port_7",
2065
+ facing_direction: "right",
2066
+ distance_from_component_edge: 0.4,
2067
+ side_of_component: "right",
2068
+ pin_number: 8,
2069
+ true_ccw_index: 7
2070
+ },
2071
+ {
2072
+ type: "pcb_component",
2073
+ pcb_component_id: "pcb_component_0",
2074
+ center: {
2075
+ x: 0,
2076
+ y: 0
2077
+ },
2078
+ width: 8.82,
2079
+ height: 8.82,
2080
+ layer: "top",
2081
+ rotation: 0,
2082
+ source_component_id: "source_component_0"
2083
+ },
2084
+ {
2085
+ type: "pcb_board",
2086
+ pcb_board_id: "pcb_board_0",
2087
+ center: {
2088
+ x: 0,
2089
+ y: 0
2090
+ },
2091
+ thickness: 1.4,
2092
+ num_layers: 4,
2093
+ width: 50,
2094
+ height: 50
2095
+ },
2096
+ {
2097
+ type: "pcb_plated_hole",
2098
+ pcb_plated_hole_id: "pcb_plated_hole_0",
2099
+ pcb_component_id: "pcb_component_0",
2100
+ pcb_port_id: "pcb_port_0",
2101
+ outer_diameter: 1.2,
2102
+ hole_diameter: 1,
2103
+ shape: "circle",
2104
+ port_hints: ["1"],
2105
+ x: -3.81,
2106
+ y: 3.81,
2107
+ layers: ["top", "bottom"]
2108
+ },
2109
+ {
2110
+ type: "pcb_plated_hole",
2111
+ pcb_plated_hole_id: "pcb_plated_hole_1",
2112
+ pcb_component_id: "pcb_component_0",
2113
+ pcb_port_id: "pcb_port_1",
2114
+ outer_diameter: 1.2,
2115
+ hole_diameter: 1,
2116
+ shape: "circle",
2117
+ port_hints: ["2"],
2118
+ x: -3.81,
2119
+ y: 1.27,
2120
+ layers: ["top", "bottom"]
2121
+ },
2122
+ {
2123
+ type: "pcb_plated_hole",
2124
+ pcb_plated_hole_id: "pcb_plated_hole_2",
2125
+ pcb_component_id: "pcb_component_0",
2126
+ pcb_port_id: "pcb_port_2",
2127
+ outer_diameter: 1.2,
2128
+ hole_diameter: 1,
2129
+ shape: "circle",
2130
+ port_hints: ["3"],
2131
+ x: -3.81,
2132
+ y: -1.27,
2133
+ layers: ["top", "bottom"]
2134
+ },
2135
+ {
2136
+ type: "pcb_plated_hole",
2137
+ pcb_plated_hole_id: "pcb_plated_hole_3",
2138
+ pcb_component_id: "pcb_component_0",
2139
+ pcb_port_id: "pcb_port_3",
2140
+ outer_diameter: 1.2,
2141
+ hole_diameter: 1,
2142
+ shape: "circle",
2143
+ port_hints: ["4"],
2144
+ x: -3.81,
2145
+ y: -3.81,
2146
+ layers: ["top", "bottom"]
2147
+ },
2148
+ {
2149
+ type: "pcb_plated_hole",
2150
+ pcb_plated_hole_id: "pcb_plated_hole_4",
2151
+ pcb_component_id: "pcb_component_0",
2152
+ pcb_port_id: "pcb_port_4",
2153
+ outer_diameter: 1.2,
2154
+ hole_diameter: 1,
2155
+ shape: "circle",
2156
+ port_hints: ["5"],
2157
+ x: 3.81,
2158
+ y: -3.81,
2159
+ layers: ["top", "bottom"]
2160
+ },
2161
+ {
2162
+ type: "pcb_plated_hole",
2163
+ pcb_plated_hole_id: "pcb_plated_hole_5",
2164
+ pcb_component_id: "pcb_component_0",
2165
+ pcb_port_id: "pcb_port_5",
2166
+ outer_diameter: 1.2,
2167
+ hole_diameter: 1,
2168
+ shape: "circle",
2169
+ port_hints: ["6"],
2170
+ x: 3.81,
2171
+ y: -1.27,
2172
+ layers: ["top", "bottom"]
2173
+ },
2174
+ {
2175
+ type: "pcb_plated_hole",
2176
+ pcb_plated_hole_id: "pcb_plated_hole_6",
2177
+ pcb_component_id: "pcb_component_0",
2178
+ pcb_port_id: "pcb_port_6",
2179
+ outer_diameter: 1.2,
2180
+ hole_diameter: 1,
2181
+ shape: "circle",
2182
+ port_hints: ["7"],
2183
+ x: 3.81,
2184
+ y: 1.27,
2185
+ layers: ["top", "bottom"]
2186
+ },
2187
+ {
2188
+ type: "pcb_plated_hole",
2189
+ pcb_plated_hole_id: "pcb_plated_hole_7",
2190
+ pcb_component_id: "pcb_component_0",
2191
+ pcb_port_id: "pcb_port_7",
2192
+ outer_diameter: 1.2,
2193
+ hole_diameter: 1,
2194
+ shape: "circle",
2195
+ port_hints: ["8"],
2196
+ x: 3.81,
2197
+ y: 3.81,
2198
+ layers: ["top", "bottom"]
2199
+ },
2200
+ {
2201
+ type: "pcb_silkscreen_path",
2202
+ pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
2203
+ pcb_component_id: "pcb_component_0",
2204
+ layer: "top",
2205
+ route: [
2206
+ {
2207
+ x: -3.01,
2208
+ y: -4.61
2209
+ },
2210
+ {
2211
+ x: -3.01,
2212
+ y: 4.61
2213
+ },
2214
+ {
2215
+ x: -1.0033333333333332,
2216
+ y: 4.61
2217
+ },
2218
+ {
2219
+ x: -0.9269591309529909,
2220
+ y: 4.226040956193693
2221
+ },
2222
+ {
2223
+ x: -0.7094638037905026,
2224
+ y: 3.9005361962094978
2225
+ },
2226
+ {
2227
+ x: -0.3839590438063067,
2228
+ y: 3.6830408690470096
2229
+ },
2230
+ {
2231
+ x: 6143644775722556e-32,
2232
+ y: 3.6066666666666674
2233
+ },
2234
+ {
2235
+ x: 0.38395904380630674,
2236
+ y: 3.6830408690470096
2237
+ },
2238
+ {
2239
+ x: 0.7094638037905027,
2240
+ y: 3.9005361962094978
2241
+ },
2242
+ {
2243
+ x: 0.9269591309529909,
2244
+ y: 4.226040956193693
2245
+ },
2246
+ {
2247
+ x: 1.0033333333333332,
2248
+ y: 4.61
2249
+ },
2250
+ {
2251
+ x: 3.01,
2252
+ y: 4.61
2253
+ },
2254
+ {
2255
+ x: 3.01,
2256
+ y: -4.61
2257
+ },
2258
+ {
2259
+ x: -3.01,
2260
+ y: -4.61
2261
+ }
2262
+ ],
2263
+ stroke_width: 0.1
2264
+ },
2265
+ {
2266
+ type: "pcb_port",
2267
+ pcb_port_id: "pcb_port_0",
2268
+ pcb_component_id: "pcb_component_0",
2269
+ layers: ["top", "inner1", "inner2", "bottom"],
2270
+ x: -3.81,
2271
+ y: 3.81,
2272
+ source_port_id: "source_port_0"
2273
+ },
2274
+ {
2275
+ type: "pcb_port",
2276
+ pcb_port_id: "pcb_port_1",
2277
+ pcb_component_id: "pcb_component_0",
2278
+ layers: ["top", "inner1", "inner2", "bottom"],
2279
+ x: -3.81,
2280
+ y: 1.27,
2281
+ source_port_id: "source_port_1"
2282
+ },
2283
+ {
2284
+ type: "pcb_port",
2285
+ pcb_port_id: "pcb_port_2",
2286
+ pcb_component_id: "pcb_component_0",
2287
+ layers: ["top", "inner1", "inner2", "bottom"],
2288
+ x: -3.81,
2289
+ y: -1.27,
2290
+ source_port_id: "source_port_2"
2291
+ },
2292
+ {
2293
+ type: "pcb_port",
2294
+ pcb_port_id: "pcb_port_3",
2295
+ pcb_component_id: "pcb_component_0",
2296
+ layers: ["top", "inner1", "inner2", "bottom"],
2297
+ x: -3.81,
2298
+ y: -3.81,
2299
+ source_port_id: "source_port_3"
2300
+ },
2301
+ {
2302
+ type: "pcb_port",
2303
+ pcb_port_id: "pcb_port_4",
2304
+ pcb_component_id: "pcb_component_0",
2305
+ layers: ["top", "inner1", "inner2", "bottom"],
2306
+ x: 3.81,
2307
+ y: -3.81,
2308
+ source_port_id: "source_port_4"
2309
+ },
2310
+ {
2311
+ type: "pcb_port",
2312
+ pcb_port_id: "pcb_port_5",
2313
+ pcb_component_id: "pcb_component_0",
2314
+ layers: ["top", "inner1", "inner2", "bottom"],
2315
+ x: 3.81,
2316
+ y: -1.27,
2317
+ source_port_id: "source_port_5"
2318
+ },
2319
+ {
2320
+ type: "pcb_port",
2321
+ pcb_port_id: "pcb_port_6",
2322
+ pcb_component_id: "pcb_component_0",
2323
+ layers: ["top", "inner1", "inner2", "bottom"],
2324
+ x: 3.81,
2325
+ y: 1.27,
2326
+ source_port_id: "source_port_6"
2327
+ },
2328
+ {
2329
+ type: "pcb_port",
2330
+ pcb_port_id: "pcb_port_7",
2331
+ pcb_component_id: "pcb_component_0",
2332
+ layers: ["top", "inner1", "inner2", "bottom"],
2333
+ x: 3.81,
2334
+ y: 3.81,
2335
+ source_port_id: "source_port_7"
2336
+ },
2337
+ {
2338
+ type: "cad_component",
2339
+ cad_component_id: "cad_component_0",
2340
+ position: {
2341
+ x: 0,
2342
+ y: 0,
2343
+ z: 0.7
2344
+ },
2345
+ rotation: {
2346
+ x: 0,
2347
+ y: 0,
2348
+ z: 0
2349
+ },
2350
+ pcb_component_id: "pcb_component_0",
2351
+ source_component_id: "source_component_0",
2352
+ footprinter_string: "dip8"
2353
+ }
2354
+ ]
2355
+ });
2356
+ const failedBuild = db.addPackageBuild({
2357
+ package_release_id: packageReleaseId2,
2358
+ created_at: new Date(Date.now() - 15e3).toISOString(),
2359
+ // 15 seconds ago
2360
+ transpilation_in_progress: false,
2361
+ transpilation_started_at: new Date(Date.now() - 15e3).toISOString(),
2362
+ transpilation_completed_at: new Date(Date.now() - 14e3).toISOString(),
2363
+ transpilation_logs: [
2364
+ "[INFO] Starting transpilation...",
2365
+ "[INFO] Parsing package code",
2366
+ "[ERROR] Failed to parse TypeScript definitions",
2367
+ "[ERROR] Invalid syntax in component declaration"
2368
+ ],
2369
+ transpilation_error: "TypeScript compilation failed: Syntax error in component declaration",
2370
+ circuit_json_build_in_progress: false,
2371
+ circuit_json_build_started_at: null,
2372
+ circuit_json_build_completed_at: null,
2373
+ circuit_json_build_logs: [],
2374
+ circuit_json_build_error: "Build cancelled due to transpilation failure",
2375
+ build_in_progress: false,
2376
+ build_started_at: new Date(Date.now() - 15e3).toISOString(),
2377
+ build_completed_at: new Date(Date.now() - 14e3).toISOString(),
2378
+ build_error: "Build failed: Unable to complete transpilation step",
2379
+ build_error_last_updated_at: new Date(Date.now() - 14e3).toISOString(),
2380
+ preview_url: null,
2381
+ build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - FAILED\nError: Invalid syntax in component declaration\nBuild terminated with errors"
2382
+ });
2383
+ const successfulBuild = db.addPackageBuild({
2384
+ package_release_id: packageReleaseId2,
2385
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2386
+ transpilation_in_progress: false,
2387
+ transpilation_started_at: new Date(Date.now() - 5e3).toISOString(),
2388
+ // Started 5 seconds ago
2389
+ transpilation_completed_at: new Date(Date.now() - 3e3).toISOString(),
2390
+ // Completed 3 seconds ago
2391
+ transpilation_logs: [
2392
+ "[INFO] Starting transpilation...",
2393
+ "[INFO] Parsing package code",
2394
+ "[INFO] Generating TypeScript definitions",
2395
+ "[INFO] Compiling to JavaScript",
2396
+ "[SUCCESS] Transpilation completed successfully"
2397
+ ],
2398
+ transpilation_error: null,
2399
+ circuit_json_build_in_progress: false,
2400
+ circuit_json_build_started_at: new Date(Date.now() - 3e3).toISOString(),
2401
+ // Started after transpilation
2402
+ circuit_json_build_completed_at: new Date(Date.now() - 1e3).toISOString(),
2403
+ // Completed 1 second ago
2404
+ circuit_json_build_logs: [
2405
+ "[INFO] Starting circuit JSON build...",
2406
+ "[INFO] Analyzing component structure",
2407
+ "[INFO] Generating port configurations",
2408
+ "[INFO] Validating circuit connections",
2409
+ "[SUCCESS] Circuit JSON build completed"
2410
+ ],
2411
+ circuit_json_build_error: null,
2412
+ build_in_progress: false,
2413
+ build_started_at: new Date(Date.now() - 1e4).toISOString(),
2414
+ // Started 10 seconds ago
2415
+ build_completed_at: (/* @__PURE__ */ new Date()).toISOString(),
2416
+ // Just completed
2417
+ build_error: null,
2418
+ build_error_last_updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2419
+ preview_url: "http://localhost:3000/preview/package_build_1",
2420
+ build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - OK\n4. Circuit validation - OK\n5. Package assembly - OK\nBuild completed successfully"
2421
+ });
2422
+ const release2 = db.getPackageReleaseById(packageReleaseId2);
2423
+ db.updatePackageRelease({
2424
+ ...release2,
2425
+ latest_package_build_id: successfulBuild.package_build_id
2426
+ });
2427
+ db.addOrder({
2428
+ account_id,
2429
+ is_running: false,
2430
+ is_started: false,
2431
+ is_finished: false,
2432
+ error: null,
2433
+ has_error: false,
2434
+ circuit_json: [
2435
+ {
2436
+ type: "source_component",
2437
+ ftype: "simple_resistor",
2438
+ source_component_id: "source_component_1",
2439
+ name: "R1",
2440
+ resistane: "1k"
2441
+ }
2442
+ ],
2443
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2444
+ started_at: null,
2445
+ completed_at: null
2446
+ });
2447
+ const testOrg = db.addOrganization({
2448
+ name: "test-organization",
2449
+ github_handle: "tscircuit",
2450
+ owner_account_id: account_id
2451
+ });
2452
+ db.addOrganizationAccount({
2453
+ org_id: testOrg.org_id,
2454
+ account_id,
2455
+ is_owner: true
2456
+ });
2457
+ const { package_release_id: orgPackageReleaseId } = db.addSnippet({
2458
+ name: "test-organization/test-package",
2459
+ unscoped_name: "test-package",
2460
+ owner_name: "test-organization",
2461
+ code: `
2462
+ export const TestComponent = ({ name }: { name: string }) => (
2463
+ <resistor name={name} resistance="10k" />
2464
+ )
2465
+ `.trim(),
2466
+ dts: `
2467
+ declare module "@tsci/test-organization.test-package" {
2468
+ export const TestComponent: ({ name }: {
2469
+ name: string;
2470
+ }) => any;
2471
+ }
2472
+ `.trim(),
2473
+ compiled_js: `
2474
+ "use strict";
2475
+
2476
+ Object.defineProperty(exports, "__esModule", {
2477
+ value: true
2478
+ });
2479
+ exports.TestComponent = void 0;
2480
+ const TestComponent = ({
2481
+ name
2482
+ }) => /*#__PURE__*/React.createElement("resistor", {
2483
+ name: name,
2484
+ resistance: "10k"
2485
+ });
2486
+ exports.TestComponent = TestComponent;
2487
+ `.trim(),
2488
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2489
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2490
+ snippet_type: "package",
2491
+ description: "Test package for organization",
2492
+ circuit_json: [
2493
+ {
2494
+ type: "source_component",
2495
+ source_component_id: "source_component_0",
2496
+ ftype: "simple_resistor",
2497
+ name: "R1",
2498
+ resistance: "10k"
2499
+ }
2500
+ ]
2501
+ });
2502
+ const orgPackageBuild = db.addPackageBuild({
2503
+ package_release_id: orgPackageReleaseId,
2504
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2505
+ transpilation_in_progress: false,
2506
+ transpilation_started_at: new Date(Date.now() - 5e3).toISOString(),
2507
+ transpilation_completed_at: new Date(Date.now() - 3e3).toISOString(),
2508
+ transpilation_logs: [
2509
+ "[INFO] Starting transpilation...",
2510
+ "[SUCCESS] Transpilation completed successfully"
2511
+ ],
2512
+ transpilation_error: null,
2513
+ circuit_json_build_in_progress: false,
2514
+ circuit_json_build_started_at: new Date(Date.now() - 3e3).toISOString(),
2515
+ circuit_json_build_completed_at: new Date(Date.now() - 1e3).toISOString(),
2516
+ circuit_json_build_logs: [
2517
+ "[INFO] Starting circuit JSON build...",
2518
+ "[SUCCESS] Circuit JSON build completed"
2519
+ ],
2520
+ circuit_json_build_error: null,
2521
+ build_in_progress: false,
2522
+ build_started_at: new Date(Date.now() - 1e4).toISOString(),
2523
+ build_completed_at: (/* @__PURE__ */ new Date()).toISOString(),
2524
+ build_error: null,
2525
+ build_error_last_updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2526
+ preview_url: "http://localhost:3000/preview/org_package_build",
2527
+ build_logs: "Build completed successfully"
2528
+ });
2529
+ const orgRelease = db.getPackageReleaseById(orgPackageReleaseId);
2530
+ db.updatePackageRelease({
2531
+ ...orgRelease,
2532
+ latest_package_build_id: orgPackageBuild.package_build_id
2533
+ });
2534
+ db.addOrganization({
2535
+ name: "testuser",
2536
+ owner_account_id: account_id,
2537
+ github_handle: "tscircuit",
2538
+ is_personal_org: true,
2539
+ org_id: "org-1234"
2540
+ });
2541
+ db.addOrganizationAccount({
2542
+ org_id: testOrg.org_id,
2543
+ account_id: seveibarAcc.account_id
2544
+ });
2545
+ };
2546
+
2547
+ // fake-snippets-api/lib/package_file/generate-fs-sha.ts
2548
+ import md5 from "md5";
2549
+ function generateFsSha(packageFiles) {
2550
+ const fsMap = {};
2551
+ packageFiles.filter((file) => file.content_text).forEach((file) => {
2552
+ fsMap[file.file_path] = file.content_text || "";
2553
+ });
2554
+ const hash = md5(JSON.stringify(fsMap));
2555
+ return `md5-${hash}`;
2556
+ }
2557
+
2558
+ // fake-snippets-api/lib/db/db-client.ts
2559
+ var createDatabase = ({ seed: seed2 } = {}) => {
2560
+ const db = hoist(createStore(initializer));
2561
+ if (seed2) {
2562
+ seed(db);
2563
+ }
2564
+ return db;
2565
+ };
2566
+ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
2567
+ addOrder: (order) => {
2568
+ const newOrder = { order_id: `order_${get().idCounter + 1}`, ...order };
2569
+ set((state) => {
2570
+ return {
2571
+ orders: [...state.orders, newOrder],
2572
+ idCounter: state.idCounter + 1
2573
+ };
2574
+ });
2575
+ return newOrder;
2576
+ },
2577
+ getOrderById: (orderId) => {
2578
+ const state = get();
2579
+ return state.orders.find((order) => order.order_id === orderId);
2580
+ },
2581
+ getOrderFilesByOrderId: (orderId) => {
2582
+ const state = get();
2583
+ return state.orderFiles.filter((file) => file.order_id === orderId);
2584
+ },
2585
+ addOrderQuote: ({
2586
+ account_id,
2587
+ package_release_id,
2588
+ vendor_name
2589
+ }) => {
2590
+ const newOrderQuote = {
2591
+ order_quote_id: `order_quote_${get().idCounter + 1}`,
2592
+ account_id,
2593
+ package_release_id: package_release_id ?? null,
2594
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2595
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2596
+ completed_at: null,
2597
+ error: null,
2598
+ has_error: false,
2599
+ is_completed: false,
2600
+ is_processing: true,
2601
+ vendor_name,
2602
+ quoted_components: [],
2603
+ bare_pcb_cost: 0,
2604
+ shipping_options: [],
2605
+ total_cost_without_shipping: 0
2606
+ };
2607
+ set((state) => {
2608
+ return {
2609
+ orderQuotes: [...state.orderQuotes, newOrderQuote],
2610
+ idCounter: state.idCounter + 1
2611
+ };
2612
+ });
2613
+ return newOrderQuote.order_quote_id;
2614
+ },
2615
+ getOrderQuoteById: (orderQuoteId) => {
2616
+ const state = get();
2617
+ return state.orderQuotes.find(
2618
+ (quote) => quote.order_quote_id === orderQuoteId
2619
+ );
2620
+ },
2621
+ getJlcpcbOrderStatesByOrderId: (orderId) => {
2622
+ const state = get();
2623
+ return state.jlcpcbOrderState.find((state2) => state2.order_id === orderId);
2624
+ },
2625
+ getJlcpcbOrderStepRunsByJlcpcbOrderStateId: (jlcpcbOrderStateId) => {
2626
+ const state = get();
2627
+ return state.jlcpcbOrderStepRuns.filter((stepRun) => {
2628
+ const orderState = state.jlcpcbOrderState.find(
2629
+ (state2) => state2.jlcpcb_order_state_id === stepRun.jlcpcb_order_state_id
2630
+ );
2631
+ return orderState?.order_id === jlcpcbOrderStateId;
2632
+ }).sort(
2633
+ (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
2634
+ );
2635
+ },
2636
+ updateOrder: (orderId, updates) => {
2637
+ set((state) => ({
2638
+ orders: state.orders.map(
2639
+ (order) => order.order_id === orderId ? { ...order, ...updates } : order
2640
+ )
2641
+ }));
2642
+ },
2643
+ addJlcpcbOrderState: (orderState) => {
2644
+ const newOrderState = {
2645
+ jlcpcb_order_state_id: `order_state_${get().idCounter + 1}`,
2646
+ ...orderState
2647
+ };
2648
+ set((state) => {
2649
+ return {
2650
+ jlcpcbOrderState: [...state.jlcpcbOrderState, newOrderState],
2651
+ idCounter: state.idCounter + 1
2652
+ };
2653
+ });
2654
+ return newOrderState;
2655
+ },
2656
+ updateJlcpcbOrderState: (orderId, updates) => {
2657
+ set((state) => ({
2658
+ jlcpcbOrderState: state.jlcpcbOrderState.map(
2659
+ (orderState) => orderState.order_id === orderId ? { ...orderState, ...updates } : orderState
2660
+ )
2661
+ }));
2662
+ },
2663
+ addOrderFile: (orderFile) => {
2664
+ const newOrderFile = {
2665
+ order_file_id: `order_file_${get().idCounter + 1}`,
2666
+ ...orderFile
2667
+ };
2668
+ set((state) => {
2669
+ return {
2670
+ orderFiles: [...state.orderFiles, newOrderFile],
2671
+ idCounter: state.idCounter + 1
2672
+ };
2673
+ });
2674
+ return newOrderFile;
2675
+ },
2676
+ getOrderFileById: (orderFileId) => {
2677
+ const state = get();
2678
+ return state.orderFiles.find((file) => file.order_file_id === orderFileId);
2679
+ },
2680
+ addBugReport: ({
2681
+ reporter_account_id,
2682
+ text,
2683
+ is_auto_deleted,
2684
+ delete_at
2685
+ }) => {
2686
+ const normalizedIsAutoDeleted = Boolean(is_auto_deleted);
2687
+ if (normalizedIsAutoDeleted && !delete_at) {
2688
+ throw new Error("delete_at is required when is_auto_deleted is true");
2689
+ }
2690
+ const normalizedDeleteAt = normalizedIsAutoDeleted ? delete_at ?? null : null;
2691
+ const bugReport = bugReportSchema.parse({
2692
+ bug_report_id: randomUUID(),
2693
+ reporter_account_id,
2694
+ text: text ?? null,
2695
+ is_auto_deleted: normalizedIsAutoDeleted,
2696
+ delete_at: normalizedDeleteAt,
2697
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2698
+ file_count: 0
2699
+ });
2700
+ set((state) => ({
2701
+ bugReports: [...state.bugReports, bugReport]
2702
+ }));
2703
+ return bugReport;
2704
+ },
2705
+ getBugReportById: (bugReportId) => {
2706
+ const state = get();
2707
+ return state.bugReports.find(
2708
+ (bugReport) => bugReport.bug_report_id === bugReportId
2709
+ );
2710
+ },
2711
+ addBugReportFile: ({
2712
+ bug_report_id,
2713
+ file_path,
2714
+ content_mimetype,
2715
+ is_text,
2716
+ content_text,
2717
+ content_bytes
2718
+ }) => {
2719
+ const bugReportFile = bugReportFileSchema.parse({
2720
+ bug_report_file_id: randomUUID(),
2721
+ bug_report_id,
2722
+ file_path,
2723
+ content_mimetype,
2724
+ is_text,
2725
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
2726
+ content_text,
2727
+ content_bytes
2728
+ });
2729
+ set((state) => ({
2730
+ bugReportFiles: [...state.bugReportFiles, bugReportFile],
2731
+ bugReports: state.bugReports.map(
2732
+ (bugReport) => bugReport.bug_report_id === bug_report_id ? { ...bugReport, file_count: bugReport.file_count + 1 } : bugReport
2733
+ )
2734
+ }));
2735
+ return bugReportFile;
2736
+ },
2737
+ getBugReportFilesByBugReportId: (bugReportId) => {
2738
+ const state = get();
2739
+ return state.bugReportFiles.filter(
2740
+ (file) => file.bug_report_id === bugReportId
2741
+ );
2742
+ },
2743
+ addAccount: (account) => {
2744
+ const newAccount = {
2745
+ account_id: account.account_id || `account_${get().idCounter + 1}`,
2746
+ ...account,
2747
+ is_tscircuit_staff: Boolean(account.is_tscircuit_staff)
2748
+ };
2749
+ set((state) => {
2750
+ return {
2751
+ accounts: [...state.accounts, newAccount],
2752
+ idCounter: state.idCounter + 1
2753
+ };
2754
+ });
2755
+ return newAccount;
2756
+ },
2757
+ addAccountPackage: (accountPackage) => {
2758
+ const newAccountPackage = {
2759
+ account_package_id: `ap_${get().idCounter + 1}`,
2760
+ ...accountPackage
2761
+ };
2762
+ set((state) => {
2763
+ return {
2764
+ accountPackages: [...state.accountPackages, newAccountPackage],
2765
+ idCounter: state.idCounter + 1
2766
+ };
2767
+ });
2768
+ return newAccountPackage;
2769
+ },
2770
+ getAccountPackageById: (accountPackageId) => {
2771
+ const state = get();
2772
+ return state.accountPackages.find(
2773
+ (ap) => ap.account_package_id === accountPackageId
2774
+ );
2775
+ },
2776
+ updateAccountPackage: (accountPackageId, updates) => {
2777
+ set((state) => ({
2778
+ accountPackages: state.accountPackages.map(
2779
+ (ap) => ap.account_package_id === accountPackageId ? { ...ap, ...updates } : ap
2780
+ )
2781
+ }));
2782
+ },
2783
+ deleteAccountPackage: (accountPackageId) => {
2784
+ let deleted = false;
2785
+ set((state) => {
2786
+ const index = state.accountPackages.findIndex(
2787
+ (ap) => ap.account_package_id === accountPackageId
2788
+ );
2789
+ if (index !== -1) {
2790
+ state.accountPackages.splice(index, 1);
2791
+ deleted = true;
2792
+ }
2793
+ return state;
2794
+ });
2795
+ return deleted;
2796
+ },
2797
+ addSnippet: (snippet) => {
2798
+ const timestamp = Date.now();
2799
+ const currentTime = new Date(timestamp).toISOString();
2800
+ const newState = get();
2801
+ const nextId = newState.idCounter + 1;
2802
+ const newPackage = {
2803
+ package_id: `pkg_${nextId}`,
2804
+ creator_account_id: snippet.creator_account_id ?? snippet.owner_name,
2805
+ // Using owner_name as account_id since we don't have context
2806
+ owner_org_id: "",
2807
+ // Empty string instead of null to match type
2808
+ owner_github_username: snippet.owner_name,
2809
+ is_source_from_github: false,
2810
+ description: snippet.description || "",
2811
+ name: `${snippet.owner_name}/${snippet.unscoped_name}`,
2812
+ unscoped_name: snippet.unscoped_name,
2813
+ latest_version: "0.0.1",
2814
+ license: null,
2815
+ website: null,
2816
+ star_count: 0,
2817
+ created_at: currentTime,
2818
+ updated_at: currentTime,
2819
+ github_repo_full_name: snippet.github_repo_full_name || null,
2820
+ ai_description: "placeholder ai description",
2821
+ ai_usage_instructions: "placeholder ai usage instructions",
2822
+ is_snippet: true,
2823
+ is_board: snippet.snippet_type === "board",
2824
+ is_package: snippet.snippet_type === "package",
2825
+ is_model: snippet.snippet_type === "model",
2826
+ is_footprint: snippet.snippet_type === "footprint",
2827
+ snippet_type: snippet.snippet_type,
2828
+ is_private: false,
2829
+ is_public: true,
2830
+ is_unlisted: false,
2831
+ latest_package_release_id: `package_release_${nextId}`,
2832
+ latest_package_release_fs_sha: null
2833
+ };
2834
+ const newPackageRelease = packageReleaseSchema.parse({
2835
+ package_release_id: `package_release_${nextId}`,
2836
+ package_id: newPackage.package_id,
2837
+ version: "0.0.1",
2838
+ is_latest: true,
2839
+ is_locked: false,
2840
+ created_at: currentTime,
2841
+ updated_at: currentTime,
2842
+ branch_name: snippet.branch_name,
2843
+ commit_message: snippet.commit_message,
2844
+ commit_author: snippet.commit_author,
2845
+ has_transpiled: true,
2846
+ transpilation_error: null,
2847
+ ...snippet.name == "testuser/my-test-board" ? { is_pr_preview: true, github_pr_number: 69 } : {}
2848
+ });
2849
+ const packageFiles = [];
2850
+ let fileIdCounter = nextId;
2851
+ packageFiles.push({
2852
+ package_file_id: `package_file_${fileIdCounter++}`,
2853
+ package_release_id: newPackageRelease.package_release_id,
2854
+ file_path: "index.tsx",
2855
+ content_text: snippet.code || "",
2856
+ created_at: currentTime
2857
+ });
2858
+ if (snippet.dts) {
2859
+ packageFiles.push({
2860
+ package_file_id: `package_file_${fileIdCounter++}`,
2861
+ package_release_id: newPackageRelease.package_release_id,
2862
+ file_path: "/dist/index.d.ts",
2863
+ content_text: snippet.dts,
2864
+ created_at: currentTime
2865
+ });
2866
+ }
2867
+ if (snippet.compiled_js) {
2868
+ packageFiles.push({
2869
+ package_file_id: `package_file_${fileIdCounter++}`,
2870
+ package_release_id: newPackageRelease.package_release_id,
2871
+ file_path: "/dist/index.js",
2872
+ content_text: snippet.compiled_js,
2873
+ created_at: currentTime
2874
+ });
2875
+ }
2876
+ if (snippet.circuit_json && snippet.circuit_json.length > 0) {
2877
+ packageFiles.push({
2878
+ package_file_id: `package_file_${fileIdCounter++}`,
2879
+ package_release_id: newPackageRelease.package_release_id,
2880
+ file_path: "/dist/circuit.json",
2881
+ content_text: JSON.stringify(snippet.circuit_json),
2882
+ created_at: currentTime
2883
+ });
2884
+ }
2885
+ set((state) => ({
2886
+ ...state,
2887
+ packages: [...state.packages, newPackage],
2888
+ packageReleases: [...state.packageReleases, newPackageRelease],
2889
+ packageFiles: [...state.packageFiles, ...packageFiles],
2890
+ idCounter: fileIdCounter
2891
+ }));
2892
+ const dbState = get();
2893
+ const releaseFiles = dbState.packageFiles.filter(
2894
+ (pf) => pf.package_release_id === newPackageRelease.package_release_id
2895
+ );
2896
+ const fsSha = generateFsSha(releaseFiles);
2897
+ set((state) => ({
2898
+ ...state,
2899
+ packageReleases: state.packageReleases.map(
2900
+ (pr) => pr.package_release_id === newPackageRelease.package_release_id ? { ...pr, fs_sha: fsSha } : pr
2901
+ ),
2902
+ packages: state.packages.map(
2903
+ (pkg) => pkg.latest_package_release_id === newPackageRelease.package_release_id ? { ...pkg, latest_package_release_fs_sha: fsSha } : pkg
2904
+ )
2905
+ }));
2906
+ return {
2907
+ snippet_id: newPackage.package_id,
2908
+ package_release_id: newPackageRelease.package_release_id,
2909
+ name: newPackage.name,
2910
+ unscoped_name: newPackage.unscoped_name,
2911
+ owner_name: snippet.owner_name,
2912
+ code: snippet.code || "",
2913
+ dts: snippet.dts,
2914
+ compiled_js: snippet.compiled_js,
2915
+ star_count: 0,
2916
+ created_at: currentTime,
2917
+ updated_at: currentTime,
2918
+ snippet_type: snippet.snippet_type,
2919
+ circuit_json: snippet.circuit_json || [],
2920
+ description: snippet.description || "",
2921
+ is_starred: false,
2922
+ version: "0.0.1",
2923
+ is_private: false,
2924
+ is_public: true,
2925
+ is_unlisted: false
2926
+ };
2927
+ },
2928
+ getLatestSnippets: (limit) => {
2929
+ const state = get();
2930
+ const snippetPackages = state.packages.filter((pkg) => pkg.is_snippet === true).map((pkg) => {
2931
+ const packageRelease = state.packageReleases.find(
2932
+ (pr) => pr.package_release_id === pkg.latest_package_release_id && pr.is_latest === true
2933
+ );
2934
+ if (!packageRelease) return null;
2935
+ const packageFiles = state.packageFiles.filter(
2936
+ (file) => file.package_release_id === packageRelease.package_release_id
2937
+ );
2938
+ const codeFile = packageFiles.find(
2939
+ (file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
2940
+ );
2941
+ const isStarred = state.accountPackages.some(
2942
+ (ap) => ap.package_id === pkg.package_id && ap.is_starred
2943
+ );
2944
+ return {
2945
+ snippet_id: pkg.package_id,
2946
+ package_release_id: pkg.latest_package_release_id || "",
2947
+ unscoped_name: pkg.unscoped_name,
2948
+ name: pkg.name,
2949
+ owner_name: pkg.owner_github_username || "",
2950
+ description: pkg.description || "",
2951
+ snippet_type: pkg.snippet_type || "board",
2952
+ code: codeFile?.content_text || "",
2953
+ dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
2954
+ compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
2955
+ created_at: pkg.created_at,
2956
+ updated_at: pkg.updated_at,
2957
+ star_count: pkg.star_count || 0,
2958
+ is_starred: isStarred,
2959
+ version: pkg.latest_version || "0.0.1",
2960
+ circuit_json: packageFiles.filter((file) => file.file_path === "/dist/circuit.json").flatMap((file) => JSON.parse(file.content_text || "[]")) || [],
2961
+ is_private: pkg.is_private || false,
2962
+ is_public: pkg.is_public || true,
2963
+ is_unlisted: pkg.is_unlisted || false
2964
+ };
2965
+ }).filter(
2966
+ (snippet) => snippet !== null
2967
+ ).map((snippet) => ({
2968
+ ...snippet,
2969
+ description: snippet.description || ""
2970
+ })).sort(
2971
+ (a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
2972
+ ).slice(0, limit);
2973
+ return snippetPackages;
2974
+ },
2975
+ getTrendingSnippets: (limit, since) => {
2976
+ const state = get();
2977
+ const sinceDate = new Date(since).getTime();
2978
+ const recentStars = /* @__PURE__ */ new Map();
2979
+ state.accountPackages.forEach((ap) => {
2980
+ if (ap.is_starred && new Date(ap.created_at).getTime() >= sinceDate) {
2981
+ recentStars.set(
2982
+ ap.package_id,
2983
+ (recentStars.get(ap.package_id) || 0) + 1
2984
+ );
2985
+ }
2986
+ });
2987
+ const packagesWithStarCount = [...state.packages].map((pkg) => ({
2988
+ ...pkg,
2989
+ star_count: recentStars.get(pkg.package_id) || 0
2990
+ })).sort((a, b) => b.star_count - a.star_count).slice(0, limit);
2991
+ const trendingSnippets = packagesWithStarCount.map((pkg) => {
2992
+ const packageRelease = state.packageReleases.find(
2993
+ (pr) => pr.package_release_id === pkg.latest_package_release_id && pr.is_latest === true
2994
+ );
2995
+ if (!packageRelease) return null;
2996
+ const packageFiles = state.packageFiles.filter(
2997
+ (file) => file.package_release_id === packageRelease.package_release_id
2998
+ );
2999
+ const codeFile = packageFiles.find(
3000
+ (file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
3001
+ );
3002
+ return {
3003
+ snippet_id: pkg.package_id,
3004
+ package_release_id: pkg.latest_package_release_id || "",
3005
+ unscoped_name: pkg.unscoped_name,
3006
+ name: pkg.name,
3007
+ owner_name: pkg.owner_github_username || "",
3008
+ code: codeFile ? codeFile.content_text || "" : "",
3009
+ created_at: pkg.created_at,
3010
+ updated_at: pkg.updated_at,
3011
+ snippet_type: pkg.is_snippet ? "board" : "package",
3012
+ star_count: pkg.star_count
3013
+ };
3014
+ }).filter((snippet) => snippet !== null);
3015
+ return trendingSnippets;
3016
+ },
3017
+ getPackagesByAuthor: (authorName) => {
3018
+ const state = get();
3019
+ const packages = authorName ? state.packages.filter((pkg) => pkg.owner_github_username === authorName) : state.packages;
3020
+ return packages.map((pkg) => ({
3021
+ ...pkg,
3022
+ star_count: state.accountPackages.filter(
3023
+ (ap) => ap.package_id === pkg.package_id && ap.is_starred
3024
+ ).length
3025
+ }));
3026
+ },
3027
+ getSnippetByAuthorAndName: (authorName, snippetName) => {
3028
+ const state = get();
3029
+ const _package = state.packages.find(
3030
+ (pkg) => pkg.owner_github_username?.toLowerCase() === authorName.toLowerCase() && pkg.name.toLowerCase() === snippetName.toLowerCase() && pkg.is_snippet === true
3031
+ );
3032
+ if (!_package) return void 0;
3033
+ const packageRelease = state.packageReleases.find(
3034
+ (pr) => pr.package_release_id === _package.latest_package_release_id && pr.is_latest === true
3035
+ );
3036
+ if (!packageRelease) return void 0;
3037
+ const packageFiles = state.packageFiles.filter(
3038
+ (file) => file.package_release_id === packageRelease.package_release_id
3039
+ );
3040
+ const codeFile = packageFiles.find(
3041
+ (file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
3042
+ );
3043
+ return {
3044
+ snippet_id: _package.package_id,
3045
+ package_release_id: _package.latest_package_release_id || "",
3046
+ unscoped_name: _package.unscoped_name,
3047
+ name: _package.name,
3048
+ owner_name: _package.owner_github_username || "",
3049
+ description: _package.description || "",
3050
+ snippet_type: _package.snippet_type || "board",
3051
+ code: codeFile?.content_text || "",
3052
+ dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
3053
+ compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
3054
+ created_at: _package.created_at,
3055
+ updated_at: _package.updated_at,
3056
+ star_count: _package.star_count || 0,
3057
+ is_starred: false,
3058
+ version: _package.latest_version || "0.0.1",
3059
+ circuit_json: packageFiles.find(
3060
+ (file) => file.file_path === "/dist/circuit.json"
3061
+ )?.content_text ? JSON.parse(
3062
+ packageFiles.find((file) => file.file_path === "/dist/circuit.json")?.content_text || "[]"
3063
+ ) : [],
3064
+ is_private: _package.is_private || false,
3065
+ is_public: _package.is_public || true,
3066
+ is_unlisted: _package.is_unlisted || false
3067
+ };
3068
+ },
3069
+ updateSnippet: (snippetId, updates) => {
3070
+ set((state) => {
3071
+ const packageIndex = state.packages.findIndex(
3072
+ (pkg) => pkg.package_id === snippetId && pkg.is_snippet === true
3073
+ );
3074
+ if (packageIndex === -1) {
3075
+ return state;
3076
+ }
3077
+ const timestamp = Date.now();
3078
+ const currentTime = new Date(timestamp).toISOString();
3079
+ const updatedPackages = [...state.packages];
3080
+ const currentPackage = updatedPackages[packageIndex];
3081
+ updatedPackages[packageIndex] = {
3082
+ ...currentPackage,
3083
+ description: updates.description ?? currentPackage.description,
3084
+ is_private: updates.is_private ?? currentPackage.is_private,
3085
+ is_public: updates.is_private !== void 0 ? !updates.is_private : currentPackage.is_public,
3086
+ is_unlisted: updates.is_private ? true : updates.is_unlisted ?? currentPackage.is_unlisted,
3087
+ updated_at: currentTime
3088
+ };
3089
+ const packageRelease2 = state.packageReleases.find(
3090
+ (pr) => pr.package_release_id === currentPackage.latest_package_release_id
3091
+ );
3092
+ if (!packageRelease2) return state;
3093
+ const updatedFiles = [...state.packageFiles];
3094
+ const packageFiles2 = updatedFiles.filter(
3095
+ (file) => file.package_release_id === packageRelease2.package_release_id
3096
+ );
3097
+ if (updates.code !== void 0) {
3098
+ const codeFileIndex = packageFiles2.findIndex(
3099
+ (file) => file.file_path === "index.tsx" || file.file_path === "index.ts"
3100
+ );
3101
+ if (codeFileIndex >= 0) {
3102
+ updatedFiles[codeFileIndex] = {
3103
+ ...packageFiles2[codeFileIndex],
3104
+ content_text: updates.code,
3105
+ created_at: currentTime
3106
+ };
3107
+ } else {
3108
+ updatedFiles.push({
3109
+ package_file_id: `package_file_${timestamp}`,
3110
+ package_release_id: packageRelease2.package_release_id,
3111
+ file_path: "index.tsx",
3112
+ content_text: updates.code,
3113
+ created_at: currentTime
3114
+ });
3115
+ }
3116
+ }
3117
+ if (updates.dts !== void 0) {
3118
+ const dtsFileIndex = packageFiles2.findIndex(
3119
+ (file) => file.file_path === "/dist/index.d.ts"
3120
+ );
3121
+ if (dtsFileIndex >= 0) {
3122
+ updatedFiles[dtsFileIndex] = {
3123
+ ...packageFiles2[dtsFileIndex],
3124
+ content_text: updates.dts,
3125
+ created_at: currentTime
3126
+ };
3127
+ } else {
3128
+ updatedFiles.push({
3129
+ package_file_id: `package_file_${timestamp}`,
3130
+ package_release_id: packageRelease2.package_release_id,
3131
+ file_path: "/dist/index.d.ts",
3132
+ content_text: updates.dts,
3133
+ created_at: currentTime
3134
+ });
3135
+ }
3136
+ }
3137
+ if (updates.compiled_js !== void 0) {
3138
+ const jsFileIndex = packageFiles2.findIndex(
3139
+ (file) => file.file_path === "/dist/index.js"
3140
+ );
3141
+ if (jsFileIndex >= 0) {
3142
+ updatedFiles[jsFileIndex] = {
3143
+ ...packageFiles2[jsFileIndex],
3144
+ content_text: updates.compiled_js,
3145
+ created_at: currentTime
3146
+ };
3147
+ } else {
3148
+ updatedFiles.push({
3149
+ package_file_id: `package_file_${timestamp}`,
3150
+ package_release_id: packageRelease2.package_release_id,
3151
+ file_path: "/dist/index.js",
3152
+ content_text: updates.compiled_js,
3153
+ created_at: currentTime
3154
+ });
3155
+ }
3156
+ }
3157
+ if (updates.circuit_json !== void 0) {
3158
+ const circuitFileIndex = packageFiles2.findIndex(
3159
+ (file) => file.file_path === "/dist/circuit.json"
3160
+ );
3161
+ if (circuitFileIndex >= 0) {
3162
+ updatedFiles[circuitFileIndex] = {
3163
+ ...packageFiles2[circuitFileIndex],
3164
+ content_text: JSON.stringify(updates.circuit_json),
3165
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
3166
+ };
3167
+ }
3168
+ }
3169
+ return {
3170
+ ...state,
3171
+ packages: updatedPackages,
3172
+ packageFiles: updatedFiles
3173
+ };
3174
+ });
3175
+ const updatedPackage = get().packages.find(
3176
+ (pkg) => pkg.package_id === snippetId
3177
+ );
3178
+ if (!updatedPackage) return void 0;
3179
+ const packageRelease = get().packageReleases.find(
3180
+ (pr) => pr.package_release_id === updatedPackage.latest_package_release_id
3181
+ );
3182
+ if (!packageRelease) return void 0;
3183
+ const packageFiles = get().packageFiles.filter(
3184
+ (file) => file.package_release_id === packageRelease.package_release_id
3185
+ );
3186
+ const codeFile = packageFiles.find(
3187
+ (file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
3188
+ );
3189
+ const dtsFile = packageFiles.find(
3190
+ (file) => file.file_path === "/dist/index.d.ts"
3191
+ );
3192
+ const jsFile = packageFiles.find(
3193
+ (file) => file.file_path === "/dist/index.js"
3194
+ );
3195
+ const circuitFile = packageFiles.find(
3196
+ (file) => file.file_path === "/dist/circuit.json"
3197
+ );
3198
+ return {
3199
+ snippet_id: updatedPackage.package_id,
3200
+ package_release_id: updatedPackage.latest_package_release_id || "",
3201
+ unscoped_name: updatedPackage.unscoped_name,
3202
+ name: updatedPackage.name,
3203
+ owner_name: updatedPackage.owner_github_username || "",
3204
+ description: updatedPackage.description || "",
3205
+ snippet_type: updatedPackage.snippet_type || "board",
3206
+ code: codeFile?.content_text || "",
3207
+ dts: dtsFile?.content_text || "",
3208
+ compiled_js: jsFile?.content_text || "",
3209
+ created_at: updatedPackage.created_at,
3210
+ updated_at: updatedPackage.updated_at,
3211
+ star_count: updatedPackage.star_count || 0,
3212
+ is_starred: false,
3213
+ version: updatedPackage.latest_version || "0.0.1",
3214
+ circuit_json: circuitFile ? JSON.parse(circuitFile.content_text || "[]") : [],
3215
+ is_private: updatedPackage.is_private ?? false,
3216
+ is_public: updatedPackage.is_public ?? true,
3217
+ is_unlisted: updatedPackage.is_unlisted ?? false
3218
+ };
3219
+ },
3220
+ getSnippetById: (snippetId, auth) => {
3221
+ const state = get();
3222
+ const _package = state.packages.find(
3223
+ (pkg) => pkg.package_id === snippetId && pkg.is_snippet === true
3224
+ );
3225
+ if (!_package) return void 0;
3226
+ if (!auth) {
3227
+ if (!_package.is_public || _package.is_unlisted) {
3228
+ return void 0;
3229
+ }
3230
+ } else {
3231
+ const isOwnPackage = _package.owner_github_username === auth?.github_username;
3232
+ const isPublicAndNotUnlisted = _package.is_public && !_package.is_unlisted;
3233
+ const isOwnUnlisted = _package.is_unlisted && isOwnPackage;
3234
+ const isOwnPrivate = _package.is_private && isOwnPackage;
3235
+ if (!isPublicAndNotUnlisted && !isOwnUnlisted && !isOwnPrivate) {
3236
+ return void 0;
3237
+ }
3238
+ }
3239
+ const packageRelease = state.packageReleases.find(
3240
+ (pr) => pr.package_release_id === _package.latest_package_release_id && pr.is_latest === true
3241
+ );
3242
+ if (!packageRelease) return void 0;
3243
+ const packageFiles = state.packageFiles.filter(
3244
+ (file) => file.package_release_id === packageRelease.package_release_id
3245
+ );
3246
+ const codeFile = packageFiles.find(
3247
+ (file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
3248
+ );
3249
+ const isStarred = state.accountPackages.some(
3250
+ (ap) => ap.package_id === snippetId && ap.is_starred
3251
+ );
3252
+ return {
3253
+ snippet_id: _package.package_id,
3254
+ package_release_id: _package.latest_package_release_id || "",
3255
+ unscoped_name: _package.unscoped_name,
3256
+ name: _package.name,
3257
+ owner_name: _package.owner_github_username || "",
3258
+ description: _package.description || "",
3259
+ snippet_type: _package.snippet_type || "board",
3260
+ code: codeFile?.content_text || "",
3261
+ dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
3262
+ compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
3263
+ created_at: _package.created_at,
3264
+ updated_at: _package.updated_at,
3265
+ star_count: _package.star_count || 0,
3266
+ is_starred: isStarred,
3267
+ version: _package.latest_version || "0.0.1",
3268
+ circuit_json: packageFiles.find(
3269
+ (file) => file.file_path === "/dist/circuit.json"
3270
+ )?.content_text ? JSON.parse(
3271
+ packageFiles.find((file) => file.file_path === "/dist/circuit.json")?.content_text || "[]"
3272
+ ) : [],
3273
+ is_private: _package.is_private || false,
3274
+ is_public: _package.is_public || true,
3275
+ is_unlisted: _package.is_unlisted || false
3276
+ };
3277
+ },
3278
+ searchSnippets: (query) => {
3279
+ const state = get();
3280
+ const lowercaseQuery = query.toLowerCase();
3281
+ const packages = state.packages.filter((pkg) => pkg.is_snippet === true);
3282
+ const matchingPackagesByMetadata = packages.filter(
3283
+ (pkg) => pkg.name.toLowerCase().includes(lowercaseQuery) || pkg.description?.toLowerCase().includes(lowercaseQuery)
3284
+ );
3285
+ const matchingFilesByContent = state.packageFiles.filter(
3286
+ (file) => file.content_text?.toLowerCase().includes(lowercaseQuery) ?? false
3287
+ );
3288
+ const matchingPackagesByContent = matchingFilesByContent.map((file) => {
3289
+ const packageRelease = state.packageReleases.find(
3290
+ (pr) => pr.package_release_id === file.package_release_id
3291
+ );
3292
+ if (!packageRelease) return null;
3293
+ return packages.find(
3294
+ (pkg) => pkg.latest_package_release_id === packageRelease.package_release_id
3295
+ );
3296
+ }).filter((pkg) => pkg !== null);
3297
+ const matchingPackages = [
3298
+ .../* @__PURE__ */ new Set([...matchingPackagesByMetadata, ...matchingPackagesByContent])
3299
+ ];
3300
+ return matchingPackages.map((pkg) => {
3301
+ const packageRelease = state.packageReleases.find(
3302
+ (pr) => pr.package_release_id === pkg.latest_package_release_id && pr.is_latest === true
3303
+ );
3304
+ if (!packageRelease) return null;
3305
+ const packageFiles = state.packageFiles.filter(
3306
+ (file) => file.package_release_id === packageRelease.package_release_id
3307
+ );
3308
+ const codeFile = packageFiles.find(
3309
+ (file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
3310
+ );
3311
+ const isStarred = state.accountPackages.some(
3312
+ (ap) => ap.package_id === pkg.package_id && ap.is_starred
3313
+ );
3314
+ return {
3315
+ snippet_id: pkg.package_id,
3316
+ package_release_id: pkg.latest_package_release_id || "",
3317
+ unscoped_name: pkg.unscoped_name,
3318
+ name: pkg.name,
3319
+ owner_name: pkg.owner_github_username || "",
3320
+ description: pkg.description || "",
3321
+ snippet_type: pkg.snippet_type || "board",
3322
+ code: codeFile?.content_text || "",
3323
+ dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
3324
+ compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
3325
+ created_at: pkg.created_at,
3326
+ updated_at: pkg.updated_at,
3327
+ star_count: pkg.star_count || 0,
3328
+ is_starred: isStarred,
3329
+ version: pkg.latest_version || "0.0.1",
3330
+ circuit_json: packageFiles.filter((file) => file.file_path === "/dist/circuit.json").flatMap((file) => JSON.parse(file.content_text || "[]")) || []
3331
+ };
3332
+ }).filter((snippet) => snippet !== null);
3333
+ },
3334
+ searchPackages: (query) => {
3335
+ const state = get();
3336
+ const lowercaseQuery = query.toLowerCase();
3337
+ const packages = state.packages.filter((pkg) => pkg.is_public === true);
3338
+ const matchingPackagesByMetadata = packages.filter(
3339
+ (pkg) => pkg.name.toLowerCase().includes(lowercaseQuery) || pkg.description?.toLowerCase().includes(lowercaseQuery)
3340
+ );
3341
+ const matchingFilesByContent = state.packageFiles.filter(
3342
+ (file) => file.content_text?.toLowerCase().includes(lowercaseQuery) ?? false
3343
+ );
3344
+ const matchingPackagesByContent = matchingFilesByContent.map((file) => {
3345
+ const packageRelease = state.packageReleases.find(
3346
+ (pr) => pr.package_release_id === file.package_release_id
3347
+ );
3348
+ if (!packageRelease) return null;
3349
+ return packages.find(
3350
+ (pkg) => pkg.latest_package_release_id === packageRelease.package_release_id
3351
+ );
3352
+ }).filter((pkg) => pkg !== null);
3353
+ const matchingPackages = [
3354
+ .../* @__PURE__ */ new Set([...matchingPackagesByMetadata, ...matchingPackagesByContent])
3355
+ ];
3356
+ return matchingPackages;
3357
+ },
3358
+ searchAccounts: (query, limit) => {
3359
+ const state = get();
3360
+ const lowercaseQuery = query.toLowerCase();
3361
+ const accountsWithPublicPackages = /* @__PURE__ */ new Set();
3362
+ state.packages.filter((pkg) => pkg.is_public === true).forEach((pkg) => {
3363
+ if (pkg.creator_account_id) {
3364
+ accountsWithPublicPackages.add(pkg.creator_account_id);
3365
+ }
3366
+ if (pkg.owner_github_username) {
3367
+ const account = state.accounts.find(
3368
+ (acc) => acc.github_username === pkg.owner_github_username
3369
+ );
3370
+ if (account) {
3371
+ accountsWithPublicPackages.add(account.account_id);
3372
+ }
3373
+ }
3374
+ });
3375
+ const matchingAccounts = state.accounts.filter((account) => {
3376
+ if (!accountsWithPublicPackages.has(account.account_id)) {
3377
+ return false;
3378
+ }
3379
+ return account.github_username.toLowerCase().includes(lowercaseQuery);
3380
+ }).slice(0, limit || 50);
3381
+ return matchingAccounts;
3382
+ },
3383
+ deleteSnippet: (snippetId) => {
3384
+ let deleted = false;
3385
+ set((state) => {
3386
+ const index = state.snippets.findIndex((s) => s.snippet_id === snippetId);
3387
+ if (index !== -1) {
3388
+ state.snippets.splice(index, 1);
3389
+ deleted = true;
3390
+ }
3391
+ return state;
3392
+ });
3393
+ return deleted;
3394
+ },
3395
+ addSession: (session) => {
3396
+ const newSession = { session_id: `session_${Date.now()}`, ...session };
3397
+ set((state) => ({
3398
+ sessions: [...state.sessions, newSession]
3399
+ }));
3400
+ return newSession;
3401
+ },
3402
+ getSessions: ({
3403
+ account_id,
3404
+ is_cli_session
3405
+ }) => {
3406
+ const state = get();
3407
+ return state.sessions.filter(
3408
+ (session) => session.account_id === account_id && (is_cli_session === void 0 || session.is_cli_session === is_cli_session)
3409
+ );
3410
+ },
3411
+ createLoginPage: () => {
3412
+ const newLoginPage = {
3413
+ login_page_id: `login_page_${Date.now()}`,
3414
+ login_page_auth_token: `token_${Date.now()}`,
3415
+ was_login_successful: false,
3416
+ has_been_used_to_create_session: false,
3417
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
3418
+ expires_at: new Date(Date.now() + 30 * 60 * 1e3).toISOString()
3419
+ // 30 minutes expiration
3420
+ };
3421
+ set((state) => ({
3422
+ loginPages: [...state.loginPages, newLoginPage]
3423
+ }));
3424
+ return newLoginPage;
3425
+ },
3426
+ getLoginPage: (loginPageId) => {
3427
+ const state = get();
3428
+ return state.loginPages.find((lp) => lp.login_page_id === loginPageId);
3429
+ },
3430
+ updateLoginPage: (loginPageId, updates) => {
3431
+ set((state) => ({
3432
+ loginPages: state.loginPages.map(
3433
+ (lp) => lp.login_page_id === loginPageId ? { ...lp, ...updates } : lp
3434
+ )
3435
+ }));
3436
+ },
3437
+ getAccount: (accountId) => {
3438
+ const state = get();
3439
+ return state.accounts.find((account) => account.account_id === accountId);
3440
+ },
3441
+ updateAccount: (accountId, updates) => {
3442
+ let updatedAccount;
3443
+ set((state) => {
3444
+ const accountIndex = state.accounts.findIndex(
3445
+ (account) => account.account_id === accountId
3446
+ );
3447
+ if (accountIndex !== -1) {
3448
+ updatedAccount = { ...state.accounts[accountIndex] };
3449
+ if (updates.shippingInfo) {
3450
+ updatedAccount.shippingInfo = {
3451
+ ...updatedAccount.shippingInfo,
3452
+ ...updates.shippingInfo
3453
+ };
3454
+ delete updates.shippingInfo;
3455
+ }
3456
+ updatedAccount = { ...updatedAccount, ...updates };
3457
+ const updatedAccounts = [...state.accounts];
3458
+ updatedAccounts[accountIndex] = updatedAccount;
3459
+ return { ...state, accounts: updatedAccounts };
3460
+ }
3461
+ return state;
3462
+ });
3463
+ return updatedAccount;
3464
+ },
3465
+ createSession: (session) => {
3466
+ const newSession = { session_id: `session_${Date.now()}`, ...session };
3467
+ set((state) => ({
3468
+ sessions: [...state.sessions, newSession]
3469
+ }));
3470
+ return newSession;
3471
+ },
3472
+ addStar: (accountId, packageId) => {
3473
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3474
+ const accountPackage = {
3475
+ account_package_id: `ap_${Date.now()}`,
3476
+ account_id: accountId,
3477
+ package_id: packageId,
3478
+ is_starred: true,
3479
+ created_at: now,
3480
+ updated_at: now
3481
+ };
3482
+ set((state) => {
3483
+ const packageIndex = state.packages.findIndex(
3484
+ (pkg) => pkg.package_id === packageId
3485
+ );
3486
+ if (packageIndex >= 0) {
3487
+ const updatedPackages = [...state.packages];
3488
+ updatedPackages[packageIndex] = {
3489
+ ...updatedPackages[packageIndex],
3490
+ star_count: (updatedPackages[packageIndex].star_count || 0) + 1
3491
+ };
3492
+ return {
3493
+ packages: updatedPackages,
3494
+ accountPackages: [...state.accountPackages, accountPackage]
3495
+ };
3496
+ }
3497
+ return {
3498
+ accountPackages: [...state.accountPackages, accountPackage]
3499
+ };
3500
+ });
3501
+ return accountPackage;
3502
+ },
3503
+ removeStar: (accountId, packageId) => {
3504
+ set((state) => {
3505
+ const packageIndex = state.packages.findIndex(
3506
+ (pkg) => pkg.package_id === packageId
3507
+ );
3508
+ if (packageIndex >= 0) {
3509
+ const updatedPackages = [...state.packages];
3510
+ updatedPackages[packageIndex] = {
3511
+ ...updatedPackages[packageIndex],
3512
+ star_count: Math.max(
3513
+ 0,
3514
+ (updatedPackages[packageIndex].star_count || 0) - 1
3515
+ )
3516
+ };
3517
+ return {
3518
+ packages: updatedPackages,
3519
+ accountPackages: state.accountPackages.filter(
3520
+ (ap) => !(ap.account_id === accountId && ap.package_id === packageId)
3521
+ )
3522
+ };
3523
+ }
3524
+ return {
3525
+ accountPackages: state.accountPackages.filter(
3526
+ (ap) => !(ap.account_id === accountId && ap.package_id === packageId)
3527
+ )
3528
+ };
3529
+ });
3530
+ },
3531
+ hasStarred: (accountId, packageId) => {
3532
+ const state = get();
3533
+ return state.accountPackages.some(
3534
+ (ap) => ap.account_id === accountId && ap.package_id === packageId && ap.is_starred
3535
+ );
3536
+ },
3537
+ addPackage: (_package) => {
3538
+ const timestamp = Date.now();
3539
+ const newPackage = {
3540
+ package_id: `package_${timestamp}`,
3541
+ github_repo_full_name: null,
3542
+ latest_pcb_preview_image_url: _package.latest_pcb_preview_image_url ?? `/api/packages/images/${_package.name}`,
3543
+ latest_cad_preview_image_url: _package.latest_cad_preview_image_url ?? `/api/packages/images/${_package.name}`,
3544
+ latest_sch_preview_image_url: _package.latest_sch_preview_image_url ?? `/api/packages/images/${_package.name}`,
3545
+ ..._package
3546
+ };
3547
+ set((state) => ({
3548
+ packages: [...state.packages, newPackage]
3549
+ }));
3550
+ return newPackage;
3551
+ },
3552
+ updatePackage: (packageId, updates) => {
3553
+ let updatedPackage;
3554
+ set((state) => {
3555
+ const packageIndex = state.packages.findIndex(
3556
+ (pkg) => pkg.package_id === packageId
3557
+ );
3558
+ if (packageIndex === -1) return state;
3559
+ const updatedPackages = [...state.packages];
3560
+ updatedPackages[packageIndex] = {
3561
+ ...updatedPackages[packageIndex],
3562
+ ...updates
3563
+ };
3564
+ updatedPackage = updatedPackages[packageIndex];
3565
+ return { ...state, packages: updatedPackages };
3566
+ });
3567
+ return updatedPackage;
3568
+ },
3569
+ getPackageById: (packageId) => {
3570
+ const state = get();
3571
+ const pkg = state.packages.find((pkg2) => pkg2.package_id === packageId);
3572
+ if (!pkg) return void 0;
3573
+ return {
3574
+ ...pkg
3575
+ };
3576
+ },
3577
+ getPackageReleaseById: (packageReleaseId) => {
3578
+ const state = get();
3579
+ return state.packageReleases.find(
3580
+ (pr) => pr.package_release_id === packageReleaseId
3581
+ );
3582
+ },
3583
+ addPackageRelease: (packageRelease) => {
3584
+ const parsed = packageReleaseSchema.parse({
3585
+ package_release_id: `package_release_${Date.now()}`,
3586
+ ...packageRelease
3587
+ });
3588
+ set((state) => ({
3589
+ packageReleases: [...state.packageReleases, parsed]
3590
+ }));
3591
+ return parsed;
3592
+ },
3593
+ updatePackageRelease: (packageRelease) => {
3594
+ set((state) => ({
3595
+ packageReleases: state.packageReleases.map(
3596
+ (pr) => pr.package_release_id === packageRelease.package_release_id ? packageRelease : pr
3597
+ )
3598
+ }));
3599
+ },
3600
+ deletePackageFile: (packageFileId) => {
3601
+ let deleted = false;
3602
+ set((state) => {
3603
+ const index = state.packageFiles.findIndex(
3604
+ (file) => file.package_file_id === packageFileId
3605
+ );
3606
+ if (index !== -1) {
3607
+ state.packageFiles.splice(index, 1);
3608
+ deleted = true;
3609
+ }
3610
+ return state;
3611
+ });
3612
+ return deleted;
3613
+ },
3614
+ addPackageFile: (packageFile) => {
3615
+ const newPackageFile = {
3616
+ package_file_id: `package_file_${get().idCounter + 1}`,
3617
+ ...packageFile
3618
+ };
3619
+ set((state) => ({
3620
+ idCounter: state.idCounter + 1,
3621
+ packageFiles: [...state.packageFiles, newPackageFile]
3622
+ }));
3623
+ return newPackageFile;
3624
+ },
3625
+ updatePackageFile: (packageFileId, updates) => {
3626
+ set((state2) => ({
3627
+ packageFiles: state2.packageFiles.map(
3628
+ (file) => file.package_file_id === packageFileId ? { ...file, ...updates } : file
3629
+ )
3630
+ }));
3631
+ const state = get();
3632
+ return state.packageFiles.find(
3633
+ (file) => file.package_file_id === packageFileId
3634
+ );
3635
+ },
3636
+ getStarCount: (packageId) => {
3637
+ const state = get();
3638
+ return state.accountPackages.filter(
3639
+ (ap) => ap.package_id === packageId && ap.is_starred
3640
+ ).length;
3641
+ },
3642
+ getPackageFilesByReleaseId: (packageReleaseId) => {
3643
+ const state = get();
3644
+ return state.packageFiles.filter(
3645
+ (pf) => pf.package_release_id === packageReleaseId
3646
+ );
3647
+ },
3648
+ /**
3649
+ * Update fs_sha for a package release based on its files
3650
+ */
3651
+ updatePackageReleaseFsSha: (packageReleaseId) => {
3652
+ const state = get();
3653
+ const packageFiles = state.packageFiles.filter(
3654
+ (pf) => pf.package_release_id === packageReleaseId
3655
+ );
3656
+ const fsSha = generateFsSha(packageFiles);
3657
+ set((currentState) => ({
3658
+ ...currentState,
3659
+ packageReleases: currentState.packageReleases.map(
3660
+ (pr) => pr.package_release_id === packageReleaseId ? { ...pr, fs_sha: fsSha } : pr
3661
+ ),
3662
+ packages: currentState.packages.map(
3663
+ (pkg) => pkg.latest_package_release_id === packageReleaseId ? { ...pkg, latest_package_release_fs_sha: fsSha } : pkg
3664
+ )
3665
+ }));
3666
+ },
3667
+ addAiReview: (review) => {
3668
+ const base = aiReviewSchema.omit({ ai_review_id: true }).parse(review);
3669
+ const newReview = {
3670
+ ai_review_id: crypto.randomUUID(),
3671
+ ...base
3672
+ };
3673
+ set((state) => ({
3674
+ aiReviews: [...state.aiReviews, newReview],
3675
+ idCounter: state.idCounter + 1
3676
+ }));
3677
+ return newReview;
3678
+ },
3679
+ updateAiReview: (aiReviewId, updates) => {
3680
+ let updated;
3681
+ set((state) => {
3682
+ const index = state.aiReviews.findIndex(
3683
+ (ar) => ar.ai_review_id === aiReviewId
3684
+ );
3685
+ if (index === -1) return state;
3686
+ const aiReviews = [...state.aiReviews];
3687
+ aiReviews[index] = { ...aiReviews[index], ...updates };
3688
+ updated = aiReviews[index];
3689
+ return { ...state, aiReviews };
3690
+ });
3691
+ return updated;
3692
+ },
3693
+ getAiReviewById: (aiReviewId) => {
3694
+ const state = get();
3695
+ return state.aiReviews.find((ar) => ar.ai_review_id === aiReviewId);
3696
+ },
3697
+ listAiReviews: () => {
3698
+ const state = get();
3699
+ return state.aiReviews;
3700
+ },
3701
+ addDatasheet: ({ chip_name }) => {
3702
+ const newDatasheet = datasheetSchema.parse({
3703
+ datasheet_id: crypto.randomUUID(),
3704
+ chip_name,
3705
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
3706
+ pin_information: null,
3707
+ datasheet_pdf_urls: null,
3708
+ ai_description: null
3709
+ });
3710
+ set((state) => ({
3711
+ datasheets: [...state.datasheets, newDatasheet]
3712
+ }));
3713
+ return newDatasheet;
3714
+ },
3715
+ getDatasheetById: (datasheetId) => {
3716
+ const state = get();
3717
+ return state.datasheets.find((d) => d.datasheet_id === datasheetId);
3718
+ },
3719
+ getDatasheetByChipName: (chipName) => {
3720
+ const state = get();
3721
+ return state.datasheets.find(
3722
+ (d) => d.chip_name.toLowerCase() === chipName.toLowerCase()
3723
+ );
3724
+ },
3725
+ listDatasheets: ({
3726
+ chip_name,
3727
+ is_popular
3728
+ } = {}) => {
3729
+ const state = get();
3730
+ if (is_popular) {
3731
+ return state.datasheets;
3732
+ }
3733
+ if (chip_name) {
3734
+ return state.datasheets.filter(
3735
+ (d) => d.chip_name.toLowerCase() === chip_name.toLowerCase()
3736
+ );
3737
+ }
3738
+ return state.datasheets;
3739
+ },
3740
+ updateDatasheet: (datasheetId, updates) => {
3741
+ let updated;
3742
+ set((state) => {
3743
+ const index = state.datasheets.findIndex(
3744
+ (d) => d.datasheet_id === datasheetId
3745
+ );
3746
+ if (index === -1) return state;
3747
+ const datasheets = [...state.datasheets];
3748
+ datasheets[index] = { ...datasheets[index], ...updates };
3749
+ updated = datasheets[index];
3750
+ return { ...state, datasheets };
3751
+ });
3752
+ return updated;
3753
+ },
3754
+ addPackageBuild: (packageBuild) => {
3755
+ const newPackageBuild = packageBuildSchema.parse({
3756
+ package_build_id: crypto.randomUUID(),
3757
+ ...packageBuild
3758
+ });
3759
+ set((state) => ({
3760
+ packageBuilds: [...state.packageBuilds, newPackageBuild],
3761
+ // Automatically update the package release to reference this as the latest build
3762
+ packageReleases: state.packageReleases.map(
3763
+ (release) => release.package_release_id === packageBuild.package_release_id ? {
3764
+ ...release,
3765
+ latest_package_build_id: newPackageBuild.package_build_id
3766
+ } : release
3767
+ )
3768
+ }));
3769
+ return newPackageBuild;
3770
+ },
3771
+ getPackageBuildById: (packageBuildId) => {
3772
+ const state = get();
3773
+ return state.packageBuilds.find(
3774
+ (pb) => pb.package_build_id === packageBuildId
3775
+ );
3776
+ },
3777
+ getPackageBuildsByReleaseId: (packageReleaseId) => {
3778
+ const state = get();
3779
+ return state.packageBuilds.filter((pb) => pb.package_release_id === packageReleaseId).sort(
3780
+ (a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
3781
+ );
3782
+ },
3783
+ updatePackageBuild: (packageBuildId, updates) => {
3784
+ let updated;
3785
+ set((state) => {
3786
+ const index = state.packageBuilds.findIndex(
3787
+ (pb) => pb.package_build_id === packageBuildId
3788
+ );
3789
+ if (index === -1) return state;
3790
+ const packageBuilds = [...state.packageBuilds];
3791
+ packageBuilds[index] = { ...packageBuilds[index], ...updates };
3792
+ updated = packageBuilds[index];
3793
+ return { ...state, packageBuilds };
3794
+ });
3795
+ return updated;
3796
+ },
3797
+ addOrganization: (organization) => {
3798
+ const newOrganization = {
3799
+ org_name: organization.name,
3800
+ org_id: organization.org_id || `org_${get().idCounter + 1}`,
3801
+ github_handle: organization.github_handle,
3802
+ is_personal_org: organization.is_personal_org || false,
3803
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
3804
+ ...organization
3805
+ };
3806
+ set((state) => ({
3807
+ idCounter: state.idCounter + 1,
3808
+ organizations: [...state.organizations, newOrganization],
3809
+ // Add the creator as a member of the new org by setting their personal_org_id
3810
+ accounts: state.accounts.map(
3811
+ (account) => account.account_id === organization.owner_account_id ? { ...account, personal_org_id: newOrganization.org_id } : account
3812
+ )
3813
+ }));
3814
+ return newOrganization;
3815
+ },
3816
+ getOrgs: (filters, auth) => {
3817
+ let orgs = get().organizations;
3818
+ if (filters?.owner_account_id) {
3819
+ orgs = orgs.filter(
3820
+ (org) => org.owner_account_id === filters.owner_account_id
3821
+ );
3822
+ }
3823
+ if (filters?.github_handle) {
3824
+ orgs = orgs.filter((org) => {
3825
+ const account = get().accounts.find(
3826
+ (account2) => account2.account_id === org.owner_account_id
3827
+ );
3828
+ return account?.github_username === filters.github_handle;
3829
+ });
3830
+ }
3831
+ if (filters?.name) {
3832
+ orgs = orgs.filter((org) => org.github_handle === filters.name);
3833
+ }
3834
+ return orgs.map((org) => {
3835
+ const member_count = get().accounts.filter(
3836
+ (account) => account.personal_org_id === org.org_id
3837
+ ).length;
3838
+ const package_count = get().packages.filter(
3839
+ (pkg) => pkg.owner_org_id === org.org_id
3840
+ ).length;
3841
+ const can_manage_org = auth ? org.owner_account_id === auth.account_id : false;
3842
+ return {
3843
+ ...org,
3844
+ member_count,
3845
+ package_count,
3846
+ can_manage_org
3847
+ };
3848
+ });
3849
+ },
3850
+ getOrg: (filters, auth) => {
3851
+ let orgs = get().organizations;
3852
+ if (filters?.org_id) {
3853
+ orgs = orgs.filter((org2) => org2.org_id === filters.org_id);
3854
+ }
3855
+ if (filters?.org_name) {
3856
+ orgs = orgs.filter((org2) => org2.org_name === filters.org_name);
3857
+ }
3858
+ if (filters?.github_handle) {
3859
+ orgs = orgs.filter((org2) => org2.github_handle === filters.github_handle);
3860
+ }
3861
+ if (orgs.length === 0) {
3862
+ return null;
3863
+ }
3864
+ const org = orgs[0];
3865
+ const member_count = get().accounts.filter(
3866
+ (account) => account.personal_org_id === org.org_id
3867
+ ).length;
3868
+ const package_count = get().packages.filter(
3869
+ (pkg) => pkg.owner_org_id === org.org_id
3870
+ ).length;
3871
+ const can_manage_org = auth ? org.owner_account_id === auth.account_id : false;
3872
+ return {
3873
+ ...org,
3874
+ member_count,
3875
+ package_count,
3876
+ can_manage_org
3877
+ };
3878
+ },
3879
+ addOrganizationAccount: (organizationAccount) => {
3880
+ const newOrgAccount = {
3881
+ org_account_id: `org_account_${get().idCounter + 1}`,
3882
+ org_id: organizationAccount.org_id,
3883
+ account_id: organizationAccount.account_id,
3884
+ is_owner: organizationAccount.is_owner || false,
3885
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
3886
+ };
3887
+ set((state) => ({
3888
+ orgAccounts: [...state.orgAccounts, newOrgAccount],
3889
+ idCounter: state.idCounter + 1
3890
+ }));
3891
+ return newOrgAccount;
3892
+ },
3893
+ getOrganizationAccount: (filters) => {
3894
+ const state = get();
3895
+ return state.orgAccounts.find((orgAccount) => {
3896
+ if (filters.org_id && orgAccount.org_id !== filters.org_id) {
3897
+ return false;
3898
+ }
3899
+ if (filters.account_id && orgAccount.account_id !== filters.account_id) {
3900
+ return false;
3901
+ }
3902
+ return true;
3903
+ });
3904
+ },
3905
+ getOrganizationAccounts: (filters) => {
3906
+ const state = get();
3907
+ return state.orgAccounts.filter((orgAccount) => {
3908
+ if (filters?.org_id && orgAccount.org_id !== filters.org_id) {
3909
+ return false;
3910
+ }
3911
+ if (filters?.account_id && orgAccount.account_id !== filters.account_id) {
3912
+ return false;
3913
+ }
3914
+ return true;
3915
+ });
3916
+ },
3917
+ removeOrganizationAccount: (filters) => {
3918
+ let removed = false;
3919
+ set((state) => {
3920
+ const index = state.orgAccounts.findIndex(
3921
+ (orgAccount) => orgAccount.org_id === filters.org_id && orgAccount.account_id === filters.account_id
3922
+ );
3923
+ if (index !== -1) {
3924
+ state.orgAccounts.splice(index, 1);
3925
+ removed = true;
3926
+ }
3927
+ return state;
3928
+ });
3929
+ return removed;
3930
+ },
3931
+ updateOrganization: (orgId, updates) => {
3932
+ let updatedOrg;
3933
+ set((state) => {
3934
+ const orgIndex = state.organizations.findIndex(
3935
+ (org) => org.org_id === orgId
3936
+ );
3937
+ if (orgIndex === -1) return state;
3938
+ const updatedOrganizations = [...state.organizations];
3939
+ updatedOrganizations[orgIndex] = {
3940
+ ...updatedOrganizations[orgIndex],
3941
+ ...updates
3942
+ };
3943
+ updatedOrg = updatedOrganizations[orgIndex];
3944
+ return { ...state, organizations: updatedOrganizations };
3945
+ });
3946
+ return updatedOrg;
3947
+ }
3948
+ }));
3949
+
3950
+ // fake-snippets-api/lib/middleware/with-db.ts
3951
+ var withDb = async (req, ctx, next) => {
3952
+ if (!ctx.db) {
3953
+ ctx.db = createDatabase();
3954
+ }
3955
+ return next(req, ctx);
3956
+ };
3957
+ export {
3958
+ createDatabase,
3959
+ seed,
3960
+ withDb
3961
+ };