@tscircuit/fake-snippets 0.0.1
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.
- package/.github/CODEOWNERS +1 -0
- package/.github/workflows/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-test.yml +28 -0
- package/.github/workflows/bun-typecheck.yml +26 -0
- package/.github/workflows/bundle-size-analysis.yml +79 -0
- package/.github/workflows/playwright-test.yml +37 -0
- package/.github/workflows/stale.yml +40 -0
- package/.github/workflows/update-snapshots.yml +49 -0
- package/CONTRIBUTING.md +59 -0
- package/LICENSE +21 -0
- package/README.md +113 -0
- package/biome.json +60 -0
- package/bun-tests/fake-snippets-api/fixtures/get-circuit-json.ts +148 -0
- package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +96 -0
- package/bun-tests/fake-snippets-api/fixtures/start-server.ts +44 -0
- package/bun-tests/fake-snippets-api/routes/accounts/get_account_balance.test.ts +18 -0
- package/bun-tests/fake-snippets-api/routes/health.test.ts +9 -0
- package/bun-tests/fake-snippets-api/routes/order_files/get.test.ts +48 -0
- package/bun-tests/fake-snippets-api/routes/order_files/upload.test.ts +77 -0
- package/bun-tests/fake-snippets-api/routes/orders/create.test.ts +19 -0
- package/bun-tests/fake-snippets-api/routes/orders/get.test.ts +38 -0
- package/bun-tests/fake-snippets-api/routes/orders/list.test.ts +30 -0
- package/bun-tests/fake-snippets-api/routes/orders/update.test.ts +46 -0
- package/bun-tests/fake-snippets-api/routes/snippets/add_star.test.ts +114 -0
- package/bun-tests/fake-snippets-api/routes/snippets/create.test.ts +28 -0
- package/bun-tests/fake-snippets-api/routes/snippets/delete.test.ts +106 -0
- package/bun-tests/fake-snippets-api/routes/snippets/download.test.ts +90 -0
- package/bun-tests/fake-snippets-api/routes/snippets/generate_from_jlcpcb.test.ts +25 -0
- package/bun-tests/fake-snippets-api/routes/snippets/get_image.test.ts +113 -0
- package/bun-tests/fake-snippets-api/routes/snippets/images.test.ts +112 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list.test.ts +62 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list_newest.test.ts +48 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list_trending.test.ts +69 -0
- package/bun-tests/fake-snippets-api/routes/snippets/remove_star.test.ts +110 -0
- package/bun-tests/fake-snippets-api/routes/snippets/search.test.ts +75 -0
- package/bun-tests/fake-snippets-api/routes/snippets/star-count.test.ts +44 -0
- package/bun-tests/fake-snippets-api/routes/snippets/update.test.ts +116 -0
- package/bun-tests/parts-engine.test.ts +18 -0
- package/bun.lockb +0 -0
- package/bunfig.toml +2 -0
- package/components.json +20 -0
- package/dist/assets/editor_example_1-1000w.webp +0 -0
- package/dist/assets/editor_example_1-1200w.webp +0 -0
- package/dist/assets/editor_example_1-1600w.webp +0 -0
- package/dist/assets/editor_example_1-2000w.webp +0 -0
- package/dist/assets/editor_example_1-400w.webp +0 -0
- package/dist/assets/editor_example_1-600w.webp +0 -0
- package/dist/assets/editor_example_1-800w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1200w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-2000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-400w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-800w.webp +0 -0
- package/dist/assets/editor_example_2-1000w.webp +0 -0
- package/dist/assets/editor_example_2-1200w.webp +0 -0
- package/dist/assets/editor_example_2-1600w.webp +0 -0
- package/dist/assets/editor_example_2-2000w.webp +0 -0
- package/dist/assets/editor_example_2-400w.webp +0 -0
- package/dist/assets/editor_example_2-600w.webp +0 -0
- package/dist/assets/editor_example_2-800w.webp +0 -0
- package/dist/assets/example_schematic-1000w.webp +0 -0
- package/dist/assets/example_schematic-1200w.webp +0 -0
- package/dist/assets/example_schematic-1600w.webp +0 -0
- package/dist/assets/example_schematic-2000w.webp +0 -0
- package/dist/assets/example_schematic-400w.webp +0 -0
- package/dist/assets/example_schematic-600w.webp +0 -0
- package/dist/assets/example_schematic-800w.webp +0 -0
- package/dist/bundle.js +3270 -0
- package/dist/robots.txt +9 -0
- package/dist/sitemap.xml +118 -0
- package/docs/CIRCUIT_JSON_SOURCE_COMPONENT_OVERVIEW.md +151 -0
- package/fake-snippets-api/README.md +6 -0
- package/fake-snippets-api/biome.json +47 -0
- package/fake-snippets-api/bun.lockb +0 -0
- package/fake-snippets-api/lib/db/autoload-dev-snippets.ts +84 -0
- package/fake-snippets-api/lib/db/autoload-snippets.json +24 -0
- package/fake-snippets-api/lib/db/db-client.ts +343 -0
- package/fake-snippets-api/lib/db/schema.ts +112 -0
- package/fake-snippets-api/lib/db/seed.ts +1608 -0
- package/fake-snippets-api/lib/middleware/with-ctx-error.ts +26 -0
- package/fake-snippets-api/lib/middleware/with-db.ts +15 -0
- package/fake-snippets-api/lib/middleware/with-error-handling.ts +24 -0
- package/fake-snippets-api/lib/middleware/with-optional-session-auth.ts +34 -0
- package/fake-snippets-api/lib/middleware/with-request-logging.ts +54 -0
- package/fake-snippets-api/lib/middleware/with-session-auth.ts +39 -0
- package/fake-snippets-api/lib/middleware/with-winter-spec.ts +24 -0
- package/fake-snippets-api/next-env.d.ts +5 -0
- package/fake-snippets-api/routes/api/accounts/get.ts +21 -0
- package/fake-snippets-api/routes/api/accounts/get_account_balance.ts +22 -0
- package/fake-snippets-api/routes/api/accounts/update.ts +32 -0
- package/fake-snippets-api/routes/api/ai/[...anyroute].ts +31 -0
- package/fake-snippets-api/routes/api/ai.ts +2 -0
- package/fake-snippets-api/routes/api/aistream/[...anyroute].ts +65 -0
- package/fake-snippets-api/routes/api/health.ts +9 -0
- package/fake-snippets-api/routes/api/internal/sessions/create_without_auth.ts +63 -0
- package/fake-snippets-api/routes/api/order_files/get.ts +28 -0
- package/fake-snippets-api/routes/api/order_files/upload.ts +43 -0
- package/fake-snippets-api/routes/api/orders/create.ts +41 -0
- package/fake-snippets-api/routes/api/orders/get.ts +28 -0
- package/fake-snippets-api/routes/api/orders/list.ts +15 -0
- package/fake-snippets-api/routes/api/orders/update.ts +50 -0
- package/fake-snippets-api/routes/api/snippets/add_star.ts +42 -0
- package/fake-snippets-api/routes/api/snippets/create.ts +55 -0
- package/fake-snippets-api/routes/api/snippets/delete.ts +41 -0
- package/fake-snippets-api/routes/api/snippets/download.ts +148 -0
- package/fake-snippets-api/routes/api/snippets/generate_from_jlcpcb.ts +55 -0
- package/fake-snippets-api/routes/api/snippets/get.ts +50 -0
- package/fake-snippets-api/routes/api/snippets/get_image.ts +65 -0
- package/fake-snippets-api/routes/api/snippets/images/[author]/[snippet_name]/[typeFormat].ts +74 -0
- package/fake-snippets-api/routes/api/snippets/list.ts +28 -0
- package/fake-snippets-api/routes/api/snippets/list_newest.ts +13 -0
- package/fake-snippets-api/routes/api/snippets/list_trending.ts +21 -0
- package/fake-snippets-api/routes/api/snippets/remove_star.ts +42 -0
- package/fake-snippets-api/routes/api/snippets/search.ts +18 -0
- package/fake-snippets-api/routes/api/snippets/update.ts +86 -0
- package/favicon.ico +0 -0
- package/index.html +23 -0
- package/landing.html +23 -0
- package/package.json +164 -0
- package/playwright-tests/ai-page.spec.ts +19 -0
- package/playwright-tests/cmd-click.spec.ts +43 -0
- package/playwright-tests/dashboard-page.spec.ts +10 -0
- package/playwright-tests/editor-page.spec.ts +15 -0
- package/playwright-tests/files-dialog.spec.ts +19 -0
- package/playwright-tests/footprint-dialog/footprint-dialog.spec.ts +27 -0
- package/playwright-tests/footprint-dialog/footprint-insertion.spec.ts +38 -0
- package/playwright-tests/footprint-dialog/footprint-preview.spec.ts +34 -0
- package/playwright-tests/footprint-dialog/footprint-selection.spec.ts +29 -0
- package/playwright-tests/handle-manual-edits.spec.ts +55 -0
- package/playwright-tests/home-page.spec.ts +10 -0
- package/playwright-tests/images.spec.ts +17 -0
- package/playwright-tests/manual-edits.spec.ts +89 -0
- package/playwright-tests/preview-page.spec.ts +14 -0
- package/playwright-tests/quickstart-page.spec.ts +10 -0
- package/playwright-tests/search-links.spec.ts +21 -0
- package/playwright-tests/search.spec.ts +27 -0
- package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-lg.png +0 -0
- package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-md.png +0 -0
- package/playwright-tests/snapshots/ai-page.spec.ts-AI-Page-xs.png +0 -0
- package/playwright-tests/snapshots/cmd-click.spec.ts-underlined-imports.png +0 -0
- package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-lg.png +0 -0
- package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-md.png +0 -0
- package/playwright-tests/snapshots/dashboard-page.spec.ts-Dashboard-page-xs.png +0 -0
- package/playwright-tests/snapshots/editor-page.spec.ts-editor-with-snippet.png +0 -0
- package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-lg.png +0 -0
- package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-md.png +0 -0
- package/playwright-tests/snapshots/error-fallback.spec.ts-error-fallback-xs.png +0 -0
- package/playwright-tests/snapshots/files-dialog.spec.ts-view-snippet-files.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-dialog.spec.ts-footprint-preview-xs.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-insertion.spec.ts-footprint-insertion-xs.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-preview.spec.ts-footprint-preview-xs.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-lg.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-md.png +0 -0
- package/playwright-tests/snapshots/footprint-dialog/footprint-selection.spec.ts-footprint-preview-xs.png +0 -0
- package/playwright-tests/snapshots/handle-manual-edits.spec.ts-handle-manual-edits.png +0 -0
- package/playwright-tests/snapshots/home-page.spec.ts-Home-page-lg.png +0 -0
- package/playwright-tests/snapshots/home-page.spec.ts-Home-page-md.png +0 -0
- package/playwright-tests/snapshots/home-page.spec.ts-Home-page-xs.png +0 -0
- package/playwright-tests/snapshots/images.spec.ts-pcb-image.png +0 -0
- package/playwright-tests/snapshots/images.spec.ts-schematic-image.png +0 -0
- package/playwright-tests/snapshots/manual-edits.spec.ts-editor-manual-edits.png +0 -0
- package/playwright-tests/snapshots/manual-edits.spec.ts-manual-edits-view.png +0 -0
- package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-pcb.png +0 -0
- package/playwright-tests/snapshots/preview-page.spec.ts-preview-snippet-schematic.png +0 -0
- package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagelg.png +0 -0
- package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagemd.png +0 -0
- package/playwright-tests/snapshots/quickstart-page.spec.ts-Quickstart-Pagexs.png +0 -0
- package/playwright-tests/snapshots/search-links.spec.ts-search-links.png +0 -0
- package/playwright-tests/snapshots/search.spec.ts-search-lg.png +0 -0
- package/playwright-tests/snapshots/search.spec.ts-search-md.png +0 -0
- package/playwright-tests/snapshots/search.spec.ts-search-xs.png +0 -0
- package/playwright-tests/snapshots/star.spec.ts-remove-star-button.png +0 -0
- package/playwright-tests/snapshots/star.spec.ts-star-button.png +0 -0
- package/playwright-tests/snapshots/update-description.spec.ts-update-description.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-lg.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-md.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-after-xs.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-lg.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-md.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-before-xs.png +0 -0
- package/playwright-tests/snapshots/view-snippet.spec.ts-view-snippet-files.png +0 -0
- package/playwright-tests/star.spec.ts +40 -0
- package/playwright-tests/update-description.spec.ts +18 -0
- package/playwright-tests/view-snippet.spec.ts +35 -0
- package/playwright-tests/viewports.ts +5 -0
- package/playwright.config.ts +27 -0
- package/postcss.config.js +6 -0
- package/public/robots.txt +9 -0
- package/renovate.json +24 -0
- package/scripts/generate-image-sizes.ts +58 -0
- package/scripts/generate-sitemap.ts +103 -0
- package/scripts/generate_bundle_stats.js +192 -0
- package/scripts/snapshot.ts +35 -0
- package/src/App.tsx +113 -0
- package/src/ContextProviders.tsx +9 -0
- package/src/assets/originals/editor_example_1.webp +0 -0
- package/src/assets/originals/editor_example_1_more_square.webp +0 -0
- package/src/assets/originals/editor_example_2.webp +0 -0
- package/src/assets/originals/example_schematic.webp +0 -0
- package/src/components/AiChatInterface.tsx +221 -0
- package/src/components/AiChatMessage.tsx +86 -0
- package/src/components/Analytics.tsx +30 -0
- package/src/components/BomTable.tsx +69 -0
- package/src/components/ChatInput.tsx +53 -0
- package/src/components/CircuitToSvgWithMouseControl.tsx +78 -0
- package/src/components/CmdKMenu.tsx +301 -0
- package/src/components/CodeAndPreview.tsx +258 -0
- package/src/components/CodeEditor.tsx +460 -0
- package/src/components/CodeEditorHeader.tsx +160 -0
- package/src/components/CreateNewSnippetWithAiHero.tsx +77 -0
- package/src/components/DownloadButtonAndMenu.tsx +212 -0
- package/src/components/EditorNav.tsx +428 -0
- package/src/components/ErrorFallback.tsx +25 -0
- package/src/components/ErrorTabContent.tsx +122 -0
- package/src/components/FAQ.tsx +113 -0
- package/src/components/Footer.tsx +134 -0
- package/src/components/Footer2.tsx +100 -0
- package/src/components/FootprintDialog.tsx +342 -0
- package/src/components/Header.tsx +187 -0
- package/src/components/Header2.tsx +135 -0
- package/src/components/HeaderDropdown.tsx +83 -0
- package/src/components/HeaderLogin.tsx +94 -0
- package/src/components/JLCPCBImportDialog.tsx +155 -0
- package/src/components/LandingHero.tsx +175 -0
- package/src/components/LatestSnippets.tsx +39 -0
- package/src/components/OptimizedImage.tsx +96 -0
- package/src/components/OrderPreviewContent.tsx +61 -0
- package/src/components/ParametersEditor.tsx +140 -0
- package/src/components/PcbViewerWithContainerHeight.tsx +47 -0
- package/src/components/PrefetchPageLink.tsx +45 -0
- package/src/components/PreviewContent.tsx +375 -0
- package/src/components/PreviewEmptyState.tsx +16 -0
- package/src/components/RunButton.tsx +27 -0
- package/src/components/SearchComponent.tsx +163 -0
- package/src/components/ShippingInformationForm.tsx +423 -0
- package/src/components/SnippetLink.tsx +37 -0
- package/src/components/StaticPreviewContent.tsx +89 -0
- package/src/components/StaticViewSnippetHeader.tsx +70 -0
- package/src/components/StaticViewSnippetSidebar.tsx +100 -0
- package/src/components/TableViewer/CircuitJsonTableViewer.tsx +316 -0
- package/src/components/TableViewer/ClickableText.tsx +21 -0
- package/src/components/TableViewer/HeaderCell.tsx +27 -0
- package/src/components/TableViewer/Modal.tsx +39 -0
- package/src/components/TrendingSnippetCarousel.tsx +77 -0
- package/src/components/TypeBadge.tsx +31 -0
- package/src/components/ViewSnippetHeader.tsx +144 -0
- package/src/components/ViewSnippetSidebar.tsx +162 -0
- package/src/components/dialogs/confirm-delete-snippet-dialog.tsx +80 -0
- package/src/components/dialogs/create-order-dialog.tsx +146 -0
- package/src/components/dialogs/create-use-dialog.tsx +34 -0
- package/src/components/dialogs/edit-description-dialog.tsx +96 -0
- package/src/components/dialogs/files-dialog.tsx +70 -0
- package/src/components/dialogs/import-snippet-dialog.tsx +84 -0
- package/src/components/dialogs/rename-snippet-dialog.tsx +81 -0
- package/src/components/dialogs/view-ts-files-dialog.tsx +89 -0
- package/src/components/ui/accordion.tsx +55 -0
- package/src/components/ui/alert-dialog.tsx +139 -0
- package/src/components/ui/alert.tsx +59 -0
- package/src/components/ui/aspect-ratio.tsx +5 -0
- package/src/components/ui/avatar.tsx +48 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/breadcrumb.tsx +118 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/calendar.tsx +73 -0
- package/src/components/ui/card.tsx +76 -0
- package/src/components/ui/carousel.tsx +260 -0
- package/src/components/ui/chart.tsx +363 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/collapsible.tsx +9 -0
- package/src/components/ui/combobox.tsx +178 -0
- package/src/components/ui/command.tsx +151 -0
- package/src/components/ui/context-menu.tsx +202 -0
- package/src/components/ui/dialog.tsx +120 -0
- package/src/components/ui/drawer.tsx +116 -0
- package/src/components/ui/dropdown-menu.tsx +203 -0
- package/src/components/ui/form.tsx +182 -0
- package/src/components/ui/hover-card.tsx +27 -0
- package/src/components/ui/input-otp.tsx +69 -0
- package/src/components/ui/input.tsx +25 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/menubar.tsx +238 -0
- package/src/components/ui/navigation-menu.tsx +129 -0
- package/src/components/ui/pagination.tsx +121 -0
- package/src/components/ui/popover.tsx +31 -0
- package/src/components/ui/progress.tsx +26 -0
- package/src/components/ui/radio-group.tsx +42 -0
- package/src/components/ui/resizable.tsx +43 -0
- package/src/components/ui/scroll-area.tsx +46 -0
- package/src/components/ui/searchable-select.tsx +94 -0
- package/src/components/ui/select.tsx +162 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/sheet.tsx +141 -0
- package/src/components/ui/skeleton.tsx +18 -0
- package/src/components/ui/slider.tsx +26 -0
- package/src/components/ui/sonner.tsx +30 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +120 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/textarea.tsx +24 -0
- package/src/components/ui/toast.tsx +128 -0
- package/src/components/ui/toaster.tsx +33 -0
- package/src/components/ui/toggle-group.tsx +59 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +28 -0
- package/src/entry-server.tsx +12 -0
- package/src/hooks/use-account-balance.ts +24 -0
- package/src/hooks/use-ai-api.ts +35 -0
- package/src/hooks/use-axios.ts +20 -0
- package/src/hooks/use-code-completion-ai-api.ts +11 -0
- package/src/hooks/use-compiled-tsx.ts +37 -0
- package/src/hooks/use-copy-to-clipboard.ts +26 -0
- package/src/hooks/use-create-snippet-mutation.ts +62 -0
- package/src/hooks/use-current-snippet-id.ts +75 -0
- package/src/hooks/use-current-snippet.ts +24 -0
- package/src/hooks/use-global-store.ts +33 -0
- package/src/hooks/use-is-using-fake-api.ts +3 -0
- package/src/hooks/use-run-tsx/construct-circuit.tsx +64 -0
- package/src/hooks/use-run-tsx/eval-compiled-js.ts +9 -0
- package/src/hooks/use-run-tsx/index.tsx +251 -0
- package/src/hooks/use-save-snippet.ts +66 -0
- package/src/hooks/use-sign-in.ts +22 -0
- package/src/hooks/use-snippet-by-name.ts +25 -0
- package/src/hooks/use-snippet.ts +23 -0
- package/src/hooks/use-snippets-base-api-url.ts +3 -0
- package/src/hooks/use-toast.tsx +208 -0
- package/src/hooks/use-typecheck.ts +54 -0
- package/src/hooks/use-url-params.ts +31 -0
- package/src/hooks/use-warn-user-on-page-change.ts +23 -0
- package/src/hooks/useForkSnippetMutation.ts +52 -0
- package/src/index.css +21 -0
- package/src/lib/__tests__/constants.test.ts +66 -0
- package/src/lib/base64ToBytes.ts +5 -0
- package/src/lib/bytesToBase64.ts +4 -0
- package/src/lib/codemirror/basic-setup.ts +51 -0
- package/src/lib/constants.ts +12 -0
- package/src/lib/decodeUrlHashToText.ts +15 -0
- package/src/lib/defaultCodeForBlankCode.tsx +7 -0
- package/src/lib/download-fns/createBlobURL.ts +4 -0
- package/src/lib/download-fns/download-assembly-svg.ts +12 -0
- package/src/lib/download-fns/download-circuit-json-fn.ts +12 -0
- package/src/lib/download-fns/download-dsn-file-fn.ts +12 -0
- package/src/lib/download-fns/download-fabrication-files.ts +233 -0
- package/src/lib/download-fns/download-gltf.ts +49 -0
- package/src/lib/download-fns/download-kicad-files.ts +27 -0
- package/src/lib/download-fns/download-readable-netlist.ts +12 -0
- package/src/lib/download-fns/download-schematic-svg.ts +12 -0
- package/src/lib/download-fns/download-simple-route-json.ts +17 -0
- package/src/lib/encodeTextToUrlHash.ts +17 -0
- package/src/lib/get-snippet-template.ts +26 -0
- package/src/lib/handleManualEditsImport.tsx +65 -0
- package/src/lib/jlc-parts-engine.ts +69 -0
- package/src/lib/templates/blank-3d-model-template.ts +12 -0
- package/src/lib/templates/blank-circuit-board-template.ts +24 -0
- package/src/lib/templates/blank-footprint-template.ts +29 -0
- package/src/lib/templates/blank-package-template.ts +22 -0
- package/src/lib/templates/blinking-led-board-template.ts +63 -0
- package/src/lib/templates/manual-edits-template.ts +5 -0
- package/src/lib/templates/usb-c-led-flashlight-template.ts +22 -0
- package/src/lib/utils/checkIfManualEditsImported.ts +6 -0
- package/src/lib/utils/getSyntaxError.ts +13 -0
- package/src/lib/utils/index.ts +6 -0
- package/src/lib/utils/load-prettier.ts +18 -0
- package/src/lib/utils/parseFootprintParams.ts +52 -0
- package/src/lib/utils/parseJsonOrNull.ts +8 -0
- package/src/lib/utils/pcbManualEditEventHandler.ts +156 -0
- package/src/main.tsx +10 -0
- package/src/pages/ai.tsx +92 -0
- package/src/pages/authorize.tsx +54 -0
- package/src/pages/dashboard.tsx +165 -0
- package/src/pages/dev-login.tsx +68 -0
- package/src/pages/editor.tsx +28 -0
- package/src/pages/landing.tsx +236 -0
- package/src/pages/my-orders.tsx +54 -0
- package/src/pages/newest.tsx +16 -0
- package/src/pages/preview.tsx +70 -0
- package/src/pages/quickstart.tsx +198 -0
- package/src/pages/search.tsx +26 -0
- package/src/pages/settings.tsx +25 -0
- package/src/pages/user-profile.tsx +97 -0
- package/src/pages/view-order.tsx +123 -0
- package/src/pages/view-snippet.tsx +149 -0
- package/src/prettier.ts +9 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +47 -0
- package/tsconfig.json +30 -0
- package/vercel.json +50 -0
- package/vite.config.ts +146 -0
- package/winterspec.config.ts +6 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { createStore, type StoreApi } from "zustand/vanilla"
|
|
2
|
+
import { immer } from "zustand/middleware/immer"
|
|
3
|
+
import { hoist, type HoistedStoreApi } from "zustand-hoist"
|
|
4
|
+
import { z } from "zod"
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
databaseSchema,
|
|
8
|
+
Snippet,
|
|
9
|
+
Session,
|
|
10
|
+
LoginPage,
|
|
11
|
+
Account,
|
|
12
|
+
type DatabaseSchema,
|
|
13
|
+
snippetSchema,
|
|
14
|
+
Order,
|
|
15
|
+
OrderFile,
|
|
16
|
+
AccountSnippet,
|
|
17
|
+
} from "./schema.ts"
|
|
18
|
+
import { combine } from "zustand/middleware"
|
|
19
|
+
import { seed as seedFn } from "./seed"
|
|
20
|
+
|
|
21
|
+
export const createDatabase = ({ seed }: { seed?: boolean } = {}) => {
|
|
22
|
+
const db = hoist(createStore(initializer))
|
|
23
|
+
if (seed) {
|
|
24
|
+
seedFn(db)
|
|
25
|
+
}
|
|
26
|
+
return db
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type DbClient = ReturnType<typeof createDatabase>
|
|
30
|
+
|
|
31
|
+
const initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
32
|
+
addOrder: (order: Omit<Order, "order_id">): Order => {
|
|
33
|
+
let newOrder = { order_id: `order_${get().idCounter + 1}`, ...order }
|
|
34
|
+
set((state) => {
|
|
35
|
+
return {
|
|
36
|
+
orders: [...state.orders, newOrder],
|
|
37
|
+
idCounter: state.idCounter + 1,
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
return newOrder
|
|
41
|
+
},
|
|
42
|
+
getOrderById: (orderId: string): Order | undefined => {
|
|
43
|
+
const state = get()
|
|
44
|
+
return state.orders.find((order) => order.order_id === orderId)
|
|
45
|
+
},
|
|
46
|
+
updateOrder: (orderId: string, updates: Partial<Order>) => {
|
|
47
|
+
set((state) => ({
|
|
48
|
+
orders: state.orders.map((order) =>
|
|
49
|
+
order.order_id === orderId ? { ...order, ...updates } : order,
|
|
50
|
+
),
|
|
51
|
+
}))
|
|
52
|
+
},
|
|
53
|
+
addOrderFile: (orderFile: Omit<OrderFile, "order_file_id">): OrderFile => {
|
|
54
|
+
const newOrderFile = {
|
|
55
|
+
order_file_id: `order_file_${get().idCounter + 1}`,
|
|
56
|
+
...orderFile,
|
|
57
|
+
}
|
|
58
|
+
set((state) => {
|
|
59
|
+
return {
|
|
60
|
+
orderFiles: [...state.orderFiles, newOrderFile],
|
|
61
|
+
idCounter: state.idCounter + 1,
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
return newOrderFile
|
|
65
|
+
},
|
|
66
|
+
getOrderFileById: (orderFileId: string): OrderFile | undefined => {
|
|
67
|
+
const state = get()
|
|
68
|
+
return state.orderFiles.find((file) => file.order_file_id === orderFileId)
|
|
69
|
+
},
|
|
70
|
+
addAccount: (
|
|
71
|
+
account: Omit<Account, "account_id"> & Partial<Pick<Account, "account_id">>,
|
|
72
|
+
) => {
|
|
73
|
+
const newAccount = {
|
|
74
|
+
account_id: account.account_id || `account_${get().idCounter + 1}`,
|
|
75
|
+
...account,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
set((state) => {
|
|
79
|
+
return {
|
|
80
|
+
accounts: [...state.accounts, newAccount],
|
|
81
|
+
idCounter: state.idCounter + 1,
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return newAccount
|
|
86
|
+
},
|
|
87
|
+
addSnippet: (
|
|
88
|
+
snippet: Omit<z.input<typeof snippetSchema>, "snippet_id">,
|
|
89
|
+
): Snippet => {
|
|
90
|
+
const newSnippetId = `snippet_${get().idCounter + 1}`
|
|
91
|
+
const newSnippet = snippetSchema.parse({
|
|
92
|
+
...snippet,
|
|
93
|
+
snippet_id: newSnippetId,
|
|
94
|
+
})
|
|
95
|
+
set((state) => {
|
|
96
|
+
return {
|
|
97
|
+
snippets: [...state.snippets, newSnippet],
|
|
98
|
+
idCounter: state.idCounter + 1,
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
return { ...newSnippet, snippet_id: newSnippetId }
|
|
102
|
+
},
|
|
103
|
+
getNewestSnippets: (limit: number): Snippet[] => {
|
|
104
|
+
const state = get()
|
|
105
|
+
return [...state.snippets]
|
|
106
|
+
.map((snippet) => ({
|
|
107
|
+
...snippet,
|
|
108
|
+
star_count: state.accountSnippets.filter(
|
|
109
|
+
(as) => as.snippet_id === snippet.snippet_id && as.has_starred,
|
|
110
|
+
).length,
|
|
111
|
+
}))
|
|
112
|
+
.sort(
|
|
113
|
+
(a, b) =>
|
|
114
|
+
new Date(b.created_at).getTime() - new Date(a.created_at).getTime(),
|
|
115
|
+
)
|
|
116
|
+
.slice(0, limit)
|
|
117
|
+
},
|
|
118
|
+
getTrendingSnippets: (limit: number, since: string): Snippet[] => {
|
|
119
|
+
const state = get()
|
|
120
|
+
const sinceDate = new Date(since).getTime()
|
|
121
|
+
|
|
122
|
+
// Get star counts within time period
|
|
123
|
+
const recentStars = new Map<string, number>()
|
|
124
|
+
state.accountSnippets.forEach((as) => {
|
|
125
|
+
if (as.has_starred && new Date(as.created_at).getTime() >= sinceDate) {
|
|
126
|
+
recentStars.set(
|
|
127
|
+
as.snippet_id,
|
|
128
|
+
(recentStars.get(as.snippet_id) || 0) + 1,
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return [...state.snippets]
|
|
134
|
+
.map((snippet) => ({
|
|
135
|
+
...snippet,
|
|
136
|
+
star_count: recentStars.get(snippet.snippet_id) || 0,
|
|
137
|
+
}))
|
|
138
|
+
.sort((a, b) => b.star_count - a.star_count)
|
|
139
|
+
.slice(0, limit)
|
|
140
|
+
},
|
|
141
|
+
getSnippetsByAuthor: (authorName?: string): Snippet[] => {
|
|
142
|
+
const state = get()
|
|
143
|
+
const snippets = authorName
|
|
144
|
+
? state.snippets.filter((snippet) => snippet.owner_name === authorName)
|
|
145
|
+
: state.snippets
|
|
146
|
+
return snippets.map((snippet) => ({
|
|
147
|
+
...snippet,
|
|
148
|
+
star_count: state.accountSnippets.filter(
|
|
149
|
+
(as) => as.snippet_id === snippet.snippet_id && as.has_starred,
|
|
150
|
+
).length,
|
|
151
|
+
}))
|
|
152
|
+
},
|
|
153
|
+
getSnippetByAuthorAndName: (
|
|
154
|
+
authorName: string,
|
|
155
|
+
snippetName: string,
|
|
156
|
+
): Snippet | undefined => {
|
|
157
|
+
const state = get()
|
|
158
|
+
return state.snippets.find(
|
|
159
|
+
(snippet) =>
|
|
160
|
+
snippet.owner_name === authorName && snippet.name === snippetName,
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
updateSnippet: (
|
|
164
|
+
snippet_id: string,
|
|
165
|
+
updates: Partial<Snippet>,
|
|
166
|
+
): Snippet | undefined => {
|
|
167
|
+
let updatedSnippet: Snippet | undefined
|
|
168
|
+
set((state) => {
|
|
169
|
+
const snippetIndex = state.snippets.findIndex(
|
|
170
|
+
(snippet) => snippet.snippet_id === snippet_id,
|
|
171
|
+
)
|
|
172
|
+
if (snippetIndex === -1) {
|
|
173
|
+
return state
|
|
174
|
+
}
|
|
175
|
+
const updatedSnippets = [...state.snippets]
|
|
176
|
+
updatedSnippet = {
|
|
177
|
+
...updatedSnippets[snippetIndex],
|
|
178
|
+
...updates,
|
|
179
|
+
updated_at: updates.updated_at || new Date().toISOString(),
|
|
180
|
+
}
|
|
181
|
+
updatedSnippets[snippetIndex] = updatedSnippet
|
|
182
|
+
return { ...state, snippets: updatedSnippets }
|
|
183
|
+
})
|
|
184
|
+
return updatedSnippet
|
|
185
|
+
},
|
|
186
|
+
getSnippetById: (snippet_id: string): Snippet | undefined => {
|
|
187
|
+
const state = get()
|
|
188
|
+
const snippet = state.snippets.find(
|
|
189
|
+
(snippet) => snippet.snippet_id === snippet_id,
|
|
190
|
+
)
|
|
191
|
+
if (!snippet) return undefined
|
|
192
|
+
return {
|
|
193
|
+
...snippet,
|
|
194
|
+
star_count: state.accountSnippets.filter(
|
|
195
|
+
(as) => as.snippet_id === snippet_id && as.has_starred,
|
|
196
|
+
).length,
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
searchSnippets: (query: string): Snippet[] => {
|
|
200
|
+
const state = get()
|
|
201
|
+
const lowercaseQuery = query.toLowerCase()
|
|
202
|
+
return state.snippets
|
|
203
|
+
.filter(
|
|
204
|
+
(snippet) =>
|
|
205
|
+
snippet.name.toLowerCase().includes(lowercaseQuery) ||
|
|
206
|
+
snippet.description?.toLowerCase().includes(lowercaseQuery) ||
|
|
207
|
+
snippet.code.toLowerCase().includes(lowercaseQuery),
|
|
208
|
+
)
|
|
209
|
+
.map((snippet) => ({
|
|
210
|
+
...snippet,
|
|
211
|
+
star_count: state.accountSnippets.filter(
|
|
212
|
+
(as) => as.snippet_id === snippet.snippet_id && as.has_starred,
|
|
213
|
+
).length,
|
|
214
|
+
}))
|
|
215
|
+
},
|
|
216
|
+
deleteSnippet: (snippet_id: string): boolean => {
|
|
217
|
+
let deleted = false
|
|
218
|
+
set((state) => {
|
|
219
|
+
const index = state.snippets.findIndex((s) => s.snippet_id === snippet_id)
|
|
220
|
+
if (index !== -1) {
|
|
221
|
+
state.snippets.splice(index, 1)
|
|
222
|
+
deleted = true
|
|
223
|
+
}
|
|
224
|
+
return state
|
|
225
|
+
})
|
|
226
|
+
return deleted
|
|
227
|
+
},
|
|
228
|
+
addSession: (session: Omit<Session, "session_id">): Session => {
|
|
229
|
+
const newSession = { session_id: `session_${Date.now()}`, ...session }
|
|
230
|
+
set((state) => ({
|
|
231
|
+
sessions: [...state.sessions, newSession],
|
|
232
|
+
}))
|
|
233
|
+
return newSession
|
|
234
|
+
},
|
|
235
|
+
getSessions: ({
|
|
236
|
+
account_id,
|
|
237
|
+
is_cli_session,
|
|
238
|
+
}: { account_id: string; is_cli_session?: boolean }): Session[] => {
|
|
239
|
+
const state = get()
|
|
240
|
+
return state.sessions.filter(
|
|
241
|
+
(session) =>
|
|
242
|
+
session.account_id === account_id &&
|
|
243
|
+
(is_cli_session === undefined ||
|
|
244
|
+
session.is_cli_session === is_cli_session),
|
|
245
|
+
)
|
|
246
|
+
},
|
|
247
|
+
createLoginPage: (): LoginPage => {
|
|
248
|
+
const newLoginPage: LoginPage = {
|
|
249
|
+
login_page_id: `login_page_${Date.now()}`,
|
|
250
|
+
login_page_auth_token: `token_${Date.now()}`,
|
|
251
|
+
was_login_successful: false,
|
|
252
|
+
has_been_used_to_create_session: false,
|
|
253
|
+
created_at: new Date().toISOString(),
|
|
254
|
+
expires_at: new Date(Date.now() + 30 * 60 * 1000).toISOString(), // 30 minutes expiration
|
|
255
|
+
}
|
|
256
|
+
set((state) => ({
|
|
257
|
+
loginPages: [...state.loginPages, newLoginPage],
|
|
258
|
+
}))
|
|
259
|
+
return newLoginPage
|
|
260
|
+
},
|
|
261
|
+
getLoginPage: (login_page_id: string): LoginPage | undefined => {
|
|
262
|
+
const state = get()
|
|
263
|
+
return state.loginPages.find((lp) => lp.login_page_id === login_page_id)
|
|
264
|
+
},
|
|
265
|
+
updateLoginPage: (
|
|
266
|
+
login_page_id: string,
|
|
267
|
+
updates: Partial<LoginPage>,
|
|
268
|
+
): void => {
|
|
269
|
+
set((state) => ({
|
|
270
|
+
loginPages: state.loginPages.map((lp) =>
|
|
271
|
+
lp.login_page_id === login_page_id ? { ...lp, ...updates } : lp,
|
|
272
|
+
),
|
|
273
|
+
}))
|
|
274
|
+
},
|
|
275
|
+
getAccount: (account_id: string): Account | undefined => {
|
|
276
|
+
const state = get()
|
|
277
|
+
return state.accounts.find((account) => account.account_id === account_id)
|
|
278
|
+
},
|
|
279
|
+
updateAccount: (
|
|
280
|
+
account_id: string,
|
|
281
|
+
updates: Partial<Account>,
|
|
282
|
+
): Account | undefined => {
|
|
283
|
+
let updatedAccount: Account | undefined
|
|
284
|
+
set((state) => {
|
|
285
|
+
const accountIndex = state.accounts.findIndex(
|
|
286
|
+
(account) => account.account_id === account_id,
|
|
287
|
+
)
|
|
288
|
+
if (accountIndex !== -1) {
|
|
289
|
+
updatedAccount = { ...state.accounts[accountIndex] }
|
|
290
|
+
if (updates.shippingInfo) {
|
|
291
|
+
updatedAccount.shippingInfo = {
|
|
292
|
+
...updatedAccount.shippingInfo,
|
|
293
|
+
...updates.shippingInfo,
|
|
294
|
+
}
|
|
295
|
+
delete updates.shippingInfo
|
|
296
|
+
}
|
|
297
|
+
updatedAccount = { ...updatedAccount, ...updates }
|
|
298
|
+
const updatedAccounts = [...state.accounts]
|
|
299
|
+
updatedAccounts[accountIndex] = updatedAccount
|
|
300
|
+
return { ...state, accounts: updatedAccounts }
|
|
301
|
+
}
|
|
302
|
+
return state
|
|
303
|
+
})
|
|
304
|
+
return updatedAccount
|
|
305
|
+
},
|
|
306
|
+
createSession: (session: Omit<Session, "session_id">): Session => {
|
|
307
|
+
const newSession = { session_id: `session_${Date.now()}`, ...session }
|
|
308
|
+
set((state) => ({
|
|
309
|
+
sessions: [...state.sessions, newSession],
|
|
310
|
+
}))
|
|
311
|
+
return newSession
|
|
312
|
+
},
|
|
313
|
+
addStar: (account_id: string, snippet_id: string): AccountSnippet => {
|
|
314
|
+
const now = new Date().toISOString()
|
|
315
|
+
const accountSnippet = {
|
|
316
|
+
account_id,
|
|
317
|
+
snippet_id,
|
|
318
|
+
has_starred: true,
|
|
319
|
+
created_at: now,
|
|
320
|
+
updated_at: now,
|
|
321
|
+
}
|
|
322
|
+
set((state) => ({
|
|
323
|
+
accountSnippets: [...state.accountSnippets, accountSnippet],
|
|
324
|
+
}))
|
|
325
|
+
return accountSnippet
|
|
326
|
+
},
|
|
327
|
+
removeStar: (account_id: string, snippet_id: string): void => {
|
|
328
|
+
set((state) => ({
|
|
329
|
+
accountSnippets: state.accountSnippets.filter(
|
|
330
|
+
(as) => !(as.account_id === account_id && as.snippet_id === snippet_id),
|
|
331
|
+
),
|
|
332
|
+
}))
|
|
333
|
+
},
|
|
334
|
+
hasStarred: (account_id: string, snippet_id: string): boolean => {
|
|
335
|
+
const state = get()
|
|
336
|
+
return state.accountSnippets.some(
|
|
337
|
+
(as) =>
|
|
338
|
+
as.account_id === account_id &&
|
|
339
|
+
as.snippet_id === snippet_id &&
|
|
340
|
+
as.has_starred,
|
|
341
|
+
)
|
|
342
|
+
},
|
|
343
|
+
}))
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
export const snippetSchema = z.object({
|
|
4
|
+
snippet_id: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
unscoped_name: z.string(),
|
|
7
|
+
owner_name: z.string(),
|
|
8
|
+
is_starred: z.boolean().default(false),
|
|
9
|
+
code: z.string(),
|
|
10
|
+
dts: z.string().optional(),
|
|
11
|
+
compiled_js: z.string().optional().nullable(),
|
|
12
|
+
circuit_json: z.array(z.record(z.any())).optional().nullable(),
|
|
13
|
+
manual_edits_json_content: z.string().optional().nullable(),
|
|
14
|
+
created_at: z.string(),
|
|
15
|
+
updated_at: z.string(),
|
|
16
|
+
snippet_type: z.enum(["board", "package", "model", "footprint"]),
|
|
17
|
+
description: z.string().optional(),
|
|
18
|
+
version: z.string().default("0.0.1"),
|
|
19
|
+
star_count: z.number().default(0),
|
|
20
|
+
})
|
|
21
|
+
export type Snippet = z.infer<typeof snippetSchema>
|
|
22
|
+
|
|
23
|
+
export const sessionSchema = z.object({
|
|
24
|
+
session_id: z.string(),
|
|
25
|
+
account_id: z.string(),
|
|
26
|
+
expires_at: z.string(),
|
|
27
|
+
is_cli_session: z.boolean(),
|
|
28
|
+
})
|
|
29
|
+
export type Session = z.infer<typeof sessionSchema>
|
|
30
|
+
|
|
31
|
+
export const loginPageSchema = z.object({
|
|
32
|
+
login_page_id: z.string(),
|
|
33
|
+
login_page_auth_token: z.string(),
|
|
34
|
+
was_login_successful: z.boolean(),
|
|
35
|
+
has_been_used_to_create_session: z.boolean(),
|
|
36
|
+
created_at: z.string(),
|
|
37
|
+
expires_at: z.string(),
|
|
38
|
+
})
|
|
39
|
+
export type LoginPage = z.infer<typeof loginPageSchema>
|
|
40
|
+
|
|
41
|
+
export const shippingInfoSchema = z.object({
|
|
42
|
+
firstName: z.string(),
|
|
43
|
+
lastName: z.string(),
|
|
44
|
+
companyName: z.string().optional(),
|
|
45
|
+
address: z.string(),
|
|
46
|
+
apartment: z.string().optional(),
|
|
47
|
+
city: z.string(),
|
|
48
|
+
state: z.string(),
|
|
49
|
+
zipCode: z.string(),
|
|
50
|
+
country: z.string(),
|
|
51
|
+
phone: z.string(),
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export const accountSchema = z.object({
|
|
55
|
+
account_id: z.string(),
|
|
56
|
+
github_username: z.string(),
|
|
57
|
+
shippingInfo: shippingInfoSchema.optional(),
|
|
58
|
+
})
|
|
59
|
+
export type Account = z.infer<typeof accountSchema>
|
|
60
|
+
|
|
61
|
+
export const orderSchema = z.object({
|
|
62
|
+
order_id: z.string(),
|
|
63
|
+
account_id: z.string(),
|
|
64
|
+
is_draft: z.boolean(),
|
|
65
|
+
is_pending_validation_by_fab: z.boolean(),
|
|
66
|
+
is_pending_review_by_fab: z.boolean(),
|
|
67
|
+
is_validated_by_fab: z.boolean(),
|
|
68
|
+
is_approved_by_fab_review: z.boolean(),
|
|
69
|
+
is_approved_by_orderer: z.boolean(),
|
|
70
|
+
is_in_production: z.boolean(),
|
|
71
|
+
is_shipped: z.boolean(),
|
|
72
|
+
is_cancelled: z.boolean(),
|
|
73
|
+
should_be_blank_pcb: z.boolean(),
|
|
74
|
+
should_include_stencil: z.boolean(),
|
|
75
|
+
jlcpcb_order_params: z.record(z.any()),
|
|
76
|
+
circuit_json: z.array(z.record(z.any())),
|
|
77
|
+
created_at: z.string(),
|
|
78
|
+
updated_at: z.string(),
|
|
79
|
+
})
|
|
80
|
+
export type Order = z.infer<typeof orderSchema>
|
|
81
|
+
|
|
82
|
+
export const orderFileSchema = z.object({
|
|
83
|
+
order_file_id: z.string(),
|
|
84
|
+
order_id: z.string(),
|
|
85
|
+
is_gerbers_zip: z.boolean(),
|
|
86
|
+
file_content: z.instanceof(Buffer),
|
|
87
|
+
content_type: z.string(),
|
|
88
|
+
for_provider: z.string().nullable(),
|
|
89
|
+
uploaded_at: z.string(),
|
|
90
|
+
})
|
|
91
|
+
export type OrderFile = z.infer<typeof orderFileSchema>
|
|
92
|
+
|
|
93
|
+
export const accountSnippetSchema = z.object({
|
|
94
|
+
account_id: z.string(),
|
|
95
|
+
snippet_id: z.string(),
|
|
96
|
+
has_starred: z.boolean(),
|
|
97
|
+
created_at: z.string(),
|
|
98
|
+
updated_at: z.string(),
|
|
99
|
+
})
|
|
100
|
+
export type AccountSnippet = z.infer<typeof accountSnippetSchema>
|
|
101
|
+
|
|
102
|
+
export const databaseSchema = z.object({
|
|
103
|
+
idCounter: z.number().default(0),
|
|
104
|
+
snippets: z.array(snippetSchema).default([]),
|
|
105
|
+
sessions: z.array(sessionSchema).default([]),
|
|
106
|
+
loginPages: z.array(loginPageSchema).default([]),
|
|
107
|
+
accounts: z.array(accountSchema).default([]),
|
|
108
|
+
orders: z.array(orderSchema).default([]),
|
|
109
|
+
orderFiles: z.array(orderFileSchema).default([]),
|
|
110
|
+
accountSnippets: z.array(accountSnippetSchema).default([]),
|
|
111
|
+
})
|
|
112
|
+
export type DatabaseSchema = z.infer<typeof databaseSchema>
|