@tscircuit/fake-snippets 0.0.118 → 0.0.120

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 (31) hide show
  1. package/bun-tests/fake-snippets-api/routes/bug_reports/create.test.ts +37 -0
  2. package/bun-tests/fake-snippets-api/routes/bug_reports/upload_file.test.ts +89 -0
  3. package/bun-tests/fake-snippets-api/routes/packages/get.test.ts +3 -0
  4. package/bun.lock +2 -2
  5. package/dist/bundle.js +778 -508
  6. package/dist/index.d.ts +161 -6
  7. package/dist/index.js +102 -3
  8. package/dist/schema.d.ts +225 -7
  9. package/dist/schema.js +38 -3
  10. package/fake-snippets-api/lib/db/db-client.ts +98 -0
  11. package/fake-snippets-api/lib/db/schema.ts +37 -0
  12. package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +6 -0
  13. package/fake-snippets-api/lib/public-mapping/public-map-package.ts +9 -0
  14. package/fake-snippets-api/routes/api/bug_reports/create.ts +43 -0
  15. package/fake-snippets-api/routes/api/bug_reports/upload_file.ts +113 -0
  16. package/package.json +2 -2
  17. package/src/components/Header.tsx +16 -0
  18. package/src/components/PackageCard.tsx +7 -4
  19. package/src/components/PackageSearchResults.tsx +1 -7
  20. package/src/components/SearchComponent.tsx +64 -53
  21. package/src/components/TrendingPackagesCarousel.tsx +16 -23
  22. package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +3 -2
  23. package/src/components/ViewPackagePage/components/preview-image-squares.tsx +6 -3
  24. package/src/hooks/use-preview-images.ts +22 -17
  25. package/src/hooks/useUpdatePackageFilesMutation.ts +8 -0
  26. package/src/lib/utils/getPackagePreviewImageUrl.ts +15 -0
  27. package/src/pages/dashboard.tsx +0 -1
  28. package/src/pages/editor.tsx +12 -9
  29. package/src/pages/organization-profile.tsx +0 -1
  30. package/src/pages/package-editor.tsx +13 -9
  31. package/src/pages/user-profile.tsx +0 -1
package/dist/schema.d.ts CHANGED
@@ -338,6 +338,85 @@ declare const orderFileSchema: z.ZodObject<{
338
338
  content_bytes: Uint8Array<ArrayBuffer> | null;
339
339
  }>;
340
340
  type OrderFile = z.infer<typeof orderFileSchema>;
341
+ declare const bugReportSchema: z.ZodObject<{
342
+ bug_report_id: z.ZodString;
343
+ reporter_account_id: z.ZodString;
344
+ text: z.ZodNullable<z.ZodString>;
345
+ is_auto_deleted: z.ZodDefault<z.ZodBoolean>;
346
+ delete_at: z.ZodNullable<z.ZodString>;
347
+ created_at: z.ZodString;
348
+ file_count: z.ZodNumber;
349
+ }, "strip", z.ZodTypeAny, {
350
+ created_at: string;
351
+ bug_report_id: string;
352
+ reporter_account_id: string;
353
+ text: string | null;
354
+ is_auto_deleted: boolean;
355
+ delete_at: string | null;
356
+ file_count: number;
357
+ }, {
358
+ created_at: string;
359
+ bug_report_id: string;
360
+ reporter_account_id: string;
361
+ text: string | null;
362
+ delete_at: string | null;
363
+ file_count: number;
364
+ is_auto_deleted?: boolean | undefined;
365
+ }>;
366
+ type BugReport = z.infer<typeof bugReportSchema>;
367
+ declare const bugReportFileSchema: z.ZodObject<{
368
+ bug_report_file_id: z.ZodString;
369
+ bug_report_id: z.ZodString;
370
+ file_path: z.ZodString;
371
+ content_mimetype: z.ZodString;
372
+ is_text: z.ZodBoolean;
373
+ created_at: z.ZodString;
374
+ content_text: z.ZodNullable<z.ZodString>;
375
+ content_bytes: z.ZodNullable<z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>>;
376
+ }, "strip", z.ZodTypeAny, {
377
+ created_at: string;
378
+ content_text: string | null;
379
+ content_bytes: Uint8Array<ArrayBuffer> | null;
380
+ bug_report_id: string;
381
+ bug_report_file_id: string;
382
+ file_path: string;
383
+ content_mimetype: string;
384
+ is_text: boolean;
385
+ }, {
386
+ created_at: string;
387
+ content_text: string | null;
388
+ content_bytes: Uint8Array<ArrayBuffer> | null;
389
+ bug_report_id: string;
390
+ bug_report_file_id: string;
391
+ file_path: string;
392
+ content_mimetype: string;
393
+ is_text: boolean;
394
+ }>;
395
+ declare const bugReportFileResponseSchema: z.ZodObject<Omit<{
396
+ bug_report_file_id: z.ZodString;
397
+ bug_report_id: z.ZodString;
398
+ file_path: z.ZodString;
399
+ content_mimetype: z.ZodString;
400
+ is_text: z.ZodBoolean;
401
+ created_at: z.ZodString;
402
+ content_text: z.ZodNullable<z.ZodString>;
403
+ content_bytes: z.ZodNullable<z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>>;
404
+ }, "content_text" | "content_bytes">, "strip", z.ZodTypeAny, {
405
+ created_at: string;
406
+ bug_report_id: string;
407
+ bug_report_file_id: string;
408
+ file_path: string;
409
+ content_mimetype: string;
410
+ is_text: boolean;
411
+ }, {
412
+ created_at: string;
413
+ bug_report_id: string;
414
+ bug_report_file_id: string;
415
+ file_path: string;
416
+ content_mimetype: string;
417
+ is_text: boolean;
418
+ }>;
419
+ type BugReportFile = z.infer<typeof bugReportFileSchema>;
341
420
  declare const shippingOptionSchema: z.ZodObject<{
342
421
  carrier: z.ZodString;
343
422
  service: z.ZodString;
@@ -711,6 +790,9 @@ declare const packageReleaseSchema: z.ZodObject<{
711
790
  branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
712
791
  commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
713
792
  commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
793
+ pcb_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
794
+ sch_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
795
+ cad_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
714
796
  }, "strip", z.ZodTypeAny, {
715
797
  package_release_id: string;
716
798
  created_at: string;
@@ -734,6 +816,9 @@ declare const packageReleaseSchema: z.ZodObject<{
734
816
  image_generation_is_stale: boolean;
735
817
  ai_review_requested: boolean;
736
818
  is_pr_preview: boolean;
819
+ pcb_preview_image_url: string | null;
820
+ sch_preview_image_url: string | null;
821
+ cad_preview_image_url: string | null;
737
822
  ai_review_text?: string | null | undefined;
738
823
  commit_sha?: string | null | undefined;
739
824
  license?: string | null | undefined;
@@ -807,6 +892,9 @@ declare const packageReleaseSchema: z.ZodObject<{
807
892
  branch_name?: string | null | undefined;
808
893
  commit_message?: string | null | undefined;
809
894
  commit_author?: string | null | undefined;
895
+ pcb_preview_image_url?: string | null | undefined;
896
+ sch_preview_image_url?: string | null | undefined;
897
+ cad_preview_image_url?: string | null | undefined;
810
898
  }>;
811
899
  type PackageRelease = z.infer<typeof packageReleaseSchema>;
812
900
  declare const packageFileSchema: z.ZodObject<{
@@ -821,8 +909,8 @@ declare const packageFileSchema: z.ZodObject<{
821
909
  }, "strip", z.ZodTypeAny, {
822
910
  package_release_id: string;
823
911
  created_at: string;
824
- package_file_id: string;
825
912
  file_path: string;
913
+ package_file_id: string;
826
914
  content_text?: string | null | undefined;
827
915
  content_mimetype?: string | null | undefined;
828
916
  is_release_tarball?: boolean | undefined;
@@ -830,8 +918,8 @@ declare const packageFileSchema: z.ZodObject<{
830
918
  }, {
831
919
  package_release_id: string;
832
920
  created_at: string;
833
- package_file_id: string;
834
921
  file_path: string;
922
+ package_file_id: string;
835
923
  content_text?: string | null | undefined;
836
924
  content_mimetype?: string | null | undefined;
837
925
  is_release_tarball?: boolean | undefined;
@@ -871,6 +959,9 @@ declare const packageSchema: z.ZodObject<{
871
959
  default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
872
960
  allow_pr_previews: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
873
961
  is_starred: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
962
+ latest_pcb_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
963
+ latest_sch_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
964
+ latest_cad_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
874
965
  }, "strip", z.ZodTypeAny, {
875
966
  name: string;
876
967
  unscoped_name: string;
@@ -904,6 +995,9 @@ declare const packageSchema: z.ZodObject<{
904
995
  latest_license?: string | null | undefined;
905
996
  default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
906
997
  allow_pr_previews?: boolean | undefined;
998
+ latest_pcb_preview_image_url?: string | null | undefined;
999
+ latest_sch_preview_image_url?: string | null | undefined;
1000
+ latest_cad_preview_image_url?: string | null | undefined;
907
1001
  }, {
908
1002
  name: string;
909
1003
  unscoped_name: string;
@@ -937,6 +1031,9 @@ declare const packageSchema: z.ZodObject<{
937
1031
  latest_package_release_fs_sha?: string | null | undefined;
938
1032
  default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
939
1033
  allow_pr_previews?: boolean | undefined;
1034
+ latest_pcb_preview_image_url?: string | null | undefined;
1035
+ latest_sch_preview_image_url?: string | null | undefined;
1036
+ latest_cad_preview_image_url?: string | null | undefined;
940
1037
  }>;
941
1038
  type Package = z.infer<typeof packageSchema>;
942
1039
  declare const jlcpcbOrderStateSchema: z.ZodObject<{
@@ -1346,6 +1443,9 @@ declare const databaseSchema: z.ZodObject<{
1346
1443
  branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1347
1444
  commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1348
1445
  commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1446
+ pcb_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1447
+ sch_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1448
+ cad_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1349
1449
  }, "strip", z.ZodTypeAny, {
1350
1450
  package_release_id: string;
1351
1451
  created_at: string;
@@ -1369,6 +1469,9 @@ declare const databaseSchema: z.ZodObject<{
1369
1469
  image_generation_is_stale: boolean;
1370
1470
  ai_review_requested: boolean;
1371
1471
  is_pr_preview: boolean;
1472
+ pcb_preview_image_url: string | null;
1473
+ sch_preview_image_url: string | null;
1474
+ cad_preview_image_url: string | null;
1372
1475
  ai_review_text?: string | null | undefined;
1373
1476
  commit_sha?: string | null | undefined;
1374
1477
  license?: string | null | undefined;
@@ -1442,6 +1545,9 @@ declare const databaseSchema: z.ZodObject<{
1442
1545
  branch_name?: string | null | undefined;
1443
1546
  commit_message?: string | null | undefined;
1444
1547
  commit_author?: string | null | undefined;
1548
+ pcb_preview_image_url?: string | null | undefined;
1549
+ sch_preview_image_url?: string | null | undefined;
1550
+ cad_preview_image_url?: string | null | undefined;
1445
1551
  }>, "many">>;
1446
1552
  packageFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
1447
1553
  package_file_id: z.ZodString;
@@ -1455,8 +1561,8 @@ declare const databaseSchema: z.ZodObject<{
1455
1561
  }, "strip", z.ZodTypeAny, {
1456
1562
  package_release_id: string;
1457
1563
  created_at: string;
1458
- package_file_id: string;
1459
1564
  file_path: string;
1565
+ package_file_id: string;
1460
1566
  content_text?: string | null | undefined;
1461
1567
  content_mimetype?: string | null | undefined;
1462
1568
  is_release_tarball?: boolean | undefined;
@@ -1464,8 +1570,8 @@ declare const databaseSchema: z.ZodObject<{
1464
1570
  }, {
1465
1571
  package_release_id: string;
1466
1572
  created_at: string;
1467
- package_file_id: string;
1468
1573
  file_path: string;
1574
+ package_file_id: string;
1469
1575
  content_text?: string | null | undefined;
1470
1576
  content_mimetype?: string | null | undefined;
1471
1577
  is_release_tarball?: boolean | undefined;
@@ -1616,6 +1722,9 @@ declare const databaseSchema: z.ZodObject<{
1616
1722
  default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
1617
1723
  allow_pr_previews: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
1618
1724
  is_starred: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
1725
+ latest_pcb_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1726
+ latest_sch_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1727
+ latest_cad_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1619
1728
  }, "strip", z.ZodTypeAny, {
1620
1729
  name: string;
1621
1730
  unscoped_name: string;
@@ -1649,6 +1758,9 @@ declare const databaseSchema: z.ZodObject<{
1649
1758
  latest_license?: string | null | undefined;
1650
1759
  default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
1651
1760
  allow_pr_previews?: boolean | undefined;
1761
+ latest_pcb_preview_image_url?: string | null | undefined;
1762
+ latest_sch_preview_image_url?: string | null | undefined;
1763
+ latest_cad_preview_image_url?: string | null | undefined;
1652
1764
  }, {
1653
1765
  name: string;
1654
1766
  unscoped_name: string;
@@ -1682,6 +1794,9 @@ declare const databaseSchema: z.ZodObject<{
1682
1794
  latest_package_release_fs_sha?: string | null | undefined;
1683
1795
  default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
1684
1796
  allow_pr_previews?: boolean | undefined;
1797
+ latest_pcb_preview_image_url?: string | null | undefined;
1798
+ latest_sch_preview_image_url?: string | null | undefined;
1799
+ latest_cad_preview_image_url?: string | null | undefined;
1685
1800
  }>, "many">>;
1686
1801
  orders: z.ZodDefault<z.ZodArray<z.ZodObject<{
1687
1802
  order_id: z.ZodString;
@@ -2250,6 +2365,59 @@ declare const databaseSchema: z.ZodObject<{
2250
2365
  preview_url?: string | null | undefined;
2251
2366
  build_logs?: string | null | undefined;
2252
2367
  }>, "many">>;
2368
+ bugReports: z.ZodDefault<z.ZodArray<z.ZodObject<{
2369
+ bug_report_id: z.ZodString;
2370
+ reporter_account_id: z.ZodString;
2371
+ text: z.ZodNullable<z.ZodString>;
2372
+ is_auto_deleted: z.ZodDefault<z.ZodBoolean>;
2373
+ delete_at: z.ZodNullable<z.ZodString>;
2374
+ created_at: z.ZodString;
2375
+ file_count: z.ZodNumber;
2376
+ }, "strip", z.ZodTypeAny, {
2377
+ created_at: string;
2378
+ bug_report_id: string;
2379
+ reporter_account_id: string;
2380
+ text: string | null;
2381
+ is_auto_deleted: boolean;
2382
+ delete_at: string | null;
2383
+ file_count: number;
2384
+ }, {
2385
+ created_at: string;
2386
+ bug_report_id: string;
2387
+ reporter_account_id: string;
2388
+ text: string | null;
2389
+ delete_at: string | null;
2390
+ file_count: number;
2391
+ is_auto_deleted?: boolean | undefined;
2392
+ }>, "many">>;
2393
+ bugReportFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
2394
+ bug_report_file_id: z.ZodString;
2395
+ bug_report_id: z.ZodString;
2396
+ file_path: z.ZodString;
2397
+ content_mimetype: z.ZodString;
2398
+ is_text: z.ZodBoolean;
2399
+ created_at: z.ZodString;
2400
+ content_text: z.ZodNullable<z.ZodString>;
2401
+ content_bytes: z.ZodNullable<z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>>;
2402
+ }, "strip", z.ZodTypeAny, {
2403
+ created_at: string;
2404
+ content_text: string | null;
2405
+ content_bytes: Uint8Array<ArrayBuffer> | null;
2406
+ bug_report_id: string;
2407
+ bug_report_file_id: string;
2408
+ file_path: string;
2409
+ content_mimetype: string;
2410
+ is_text: boolean;
2411
+ }, {
2412
+ created_at: string;
2413
+ content_text: string | null;
2414
+ content_bytes: Uint8Array<ArrayBuffer> | null;
2415
+ bug_report_id: string;
2416
+ bug_report_file_id: string;
2417
+ file_path: string;
2418
+ content_mimetype: string;
2419
+ is_text: boolean;
2420
+ }>, "many">>;
2253
2421
  }, "strip", z.ZodTypeAny, {
2254
2422
  idCounter: number;
2255
2423
  snippets: {
@@ -2299,6 +2467,9 @@ declare const databaseSchema: z.ZodObject<{
2299
2467
  image_generation_is_stale: boolean;
2300
2468
  ai_review_requested: boolean;
2301
2469
  is_pr_preview: boolean;
2470
+ pcb_preview_image_url: string | null;
2471
+ sch_preview_image_url: string | null;
2472
+ cad_preview_image_url: string | null;
2302
2473
  ai_review_text?: string | null | undefined;
2303
2474
  commit_sha?: string | null | undefined;
2304
2475
  license?: string | null | undefined;
@@ -2328,8 +2499,8 @@ declare const databaseSchema: z.ZodObject<{
2328
2499
  packageFiles: {
2329
2500
  package_release_id: string;
2330
2501
  created_at: string;
2331
- package_file_id: string;
2332
2502
  file_path: string;
2503
+ package_file_id: string;
2333
2504
  content_text?: string | null | undefined;
2334
2505
  content_mimetype?: string | null | undefined;
2335
2506
  is_release_tarball?: boolean | undefined;
@@ -2400,6 +2571,9 @@ declare const databaseSchema: z.ZodObject<{
2400
2571
  latest_license?: string | null | undefined;
2401
2572
  default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
2402
2573
  allow_pr_previews?: boolean | undefined;
2574
+ latest_pcb_preview_image_url?: string | null | undefined;
2575
+ latest_sch_preview_image_url?: string | null | undefined;
2576
+ latest_cad_preview_image_url?: string | null | undefined;
2403
2577
  }[];
2404
2578
  orders: {
2405
2579
  error: z.objectOutputType<{
@@ -2584,6 +2758,25 @@ declare const databaseSchema: z.ZodObject<{
2584
2758
  preview_url?: string | null | undefined;
2585
2759
  build_logs?: string | null | undefined;
2586
2760
  }[];
2761
+ bugReports: {
2762
+ created_at: string;
2763
+ bug_report_id: string;
2764
+ reporter_account_id: string;
2765
+ text: string | null;
2766
+ is_auto_deleted: boolean;
2767
+ delete_at: string | null;
2768
+ file_count: number;
2769
+ }[];
2770
+ bugReportFiles: {
2771
+ created_at: string;
2772
+ content_text: string | null;
2773
+ content_bytes: Uint8Array<ArrayBuffer> | null;
2774
+ bug_report_id: string;
2775
+ bug_report_file_id: string;
2776
+ file_path: string;
2777
+ content_mimetype: string;
2778
+ is_text: boolean;
2779
+ }[];
2587
2780
  }, {
2588
2781
  idCounter?: number | undefined;
2589
2782
  snippets?: {
@@ -2658,12 +2851,15 @@ declare const databaseSchema: z.ZodObject<{
2658
2851
  branch_name?: string | null | undefined;
2659
2852
  commit_message?: string | null | undefined;
2660
2853
  commit_author?: string | null | undefined;
2854
+ pcb_preview_image_url?: string | null | undefined;
2855
+ sch_preview_image_url?: string | null | undefined;
2856
+ cad_preview_image_url?: string | null | undefined;
2661
2857
  }[] | undefined;
2662
2858
  packageFiles?: {
2663
2859
  package_release_id: string;
2664
2860
  created_at: string;
2665
- package_file_id: string;
2666
2861
  file_path: string;
2862
+ package_file_id: string;
2667
2863
  content_text?: string | null | undefined;
2668
2864
  content_mimetype?: string | null | undefined;
2669
2865
  is_release_tarball?: boolean | undefined;
@@ -2734,6 +2930,9 @@ declare const databaseSchema: z.ZodObject<{
2734
2930
  latest_package_release_fs_sha?: string | null | undefined;
2735
2931
  default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
2736
2932
  allow_pr_previews?: boolean | undefined;
2933
+ latest_pcb_preview_image_url?: string | null | undefined;
2934
+ latest_sch_preview_image_url?: string | null | undefined;
2935
+ latest_cad_preview_image_url?: string | null | undefined;
2737
2936
  }[] | undefined;
2738
2937
  orders?: {
2739
2938
  error: z.objectInputType<{
@@ -2918,7 +3117,26 @@ declare const databaseSchema: z.ZodObject<{
2918
3117
  preview_url?: string | null | undefined;
2919
3118
  build_logs?: string | null | undefined;
2920
3119
  }[] | undefined;
3120
+ bugReports?: {
3121
+ created_at: string;
3122
+ bug_report_id: string;
3123
+ reporter_account_id: string;
3124
+ text: string | null;
3125
+ delete_at: string | null;
3126
+ file_count: number;
3127
+ is_auto_deleted?: boolean | undefined;
3128
+ }[] | undefined;
3129
+ bugReportFiles?: {
3130
+ created_at: string;
3131
+ content_text: string | null;
3132
+ content_bytes: Uint8Array<ArrayBuffer> | null;
3133
+ bug_report_id: string;
3134
+ bug_report_file_id: string;
3135
+ file_path: string;
3136
+ content_mimetype: string;
3137
+ is_text: boolean;
3138
+ }[] | undefined;
2921
3139
  }>;
2922
3140
  type DatabaseSchema = z.infer<typeof databaseSchema>;
2923
3141
 
2924
- export { type Account, type AccountPackage, type AccountSnippet, type AiReview, type DatabaseSchema, type Datasheet, type GithubInstallation, type JlcpcbOrderState, type JlcpcbOrderStepRun, type LoginPage, type Order, type OrderFile, type OrderQuote, type OrgAccount, type Organization, type Package, type PackageBuild, type PackageFile, type PackageRelease, type PublicOrgSchema, type QuotedComponent, type Session, type ShippingOption, type Snippet, type UserPermissions, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, databaseSchema, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, githubInstallationSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, orgAccountSchema, orgSchema, packageBuildSchema, packageFileSchema, packageReleaseSchema, packageSchema, publicOrgSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema, userPermissionsSchema };
3142
+ export { type Account, type AccountPackage, type AccountSnippet, type AiReview, type BugReport, type BugReportFile, type DatabaseSchema, type Datasheet, type GithubInstallation, type JlcpcbOrderState, type JlcpcbOrderStepRun, type LoginPage, type Order, type OrderFile, type OrderQuote, type OrgAccount, type Organization, type Package, type PackageBuild, type PackageFile, type PackageRelease, type PublicOrgSchema, type QuotedComponent, type Session, type ShippingOption, type Snippet, type UserPermissions, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, bugReportFileResponseSchema, bugReportFileSchema, bugReportSchema, databaseSchema, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, githubInstallationSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, orgAccountSchema, orgSchema, packageBuildSchema, packageFileSchema, packageReleaseSchema, packageSchema, publicOrgSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema, userPermissionsSchema };
package/dist/schema.js CHANGED
@@ -87,6 +87,29 @@ var orderFileSchema = z.object({
87
87
  content_text: z.string().nullable(),
88
88
  content_bytes: z.instanceof(Uint8Array).nullable()
89
89
  });
90
+ var bugReportSchema = z.object({
91
+ bug_report_id: z.string().uuid(),
92
+ reporter_account_id: z.string(),
93
+ text: z.string().nullable(),
94
+ is_auto_deleted: z.boolean().default(false),
95
+ delete_at: z.string().datetime().nullable(),
96
+ created_at: z.string().datetime(),
97
+ file_count: z.number().int()
98
+ });
99
+ var bugReportFileSchema = z.object({
100
+ bug_report_file_id: z.string().uuid(),
101
+ bug_report_id: z.string().uuid(),
102
+ file_path: z.string(),
103
+ content_mimetype: z.string(),
104
+ is_text: z.boolean(),
105
+ created_at: z.string().datetime(),
106
+ content_text: z.string().nullable(),
107
+ content_bytes: z.instanceof(Uint8Array).nullable()
108
+ });
109
+ var bugReportFileResponseSchema = bugReportFileSchema.omit({
110
+ content_text: true,
111
+ content_bytes: true
112
+ });
90
113
  var shippingOptionSchema = z.object({
91
114
  carrier: z.string(),
92
115
  service: z.string(),
@@ -223,7 +246,11 @@ var packageReleaseSchema = z.object({
223
246
  latest_package_build_id: z.string().nullable().optional(),
224
247
  branch_name: z.string().nullable().optional(),
225
248
  commit_message: z.string().nullable().optional(),
226
- commit_author: z.string().nullable().optional()
249
+ commit_author: z.string().nullable().optional(),
250
+ // Preview images url
251
+ pcb_preview_image_url: z.string().nullable().default(null),
252
+ sch_preview_image_url: z.string().nullable().default(null),
253
+ cad_preview_image_url: z.string().nullable().default(null)
227
254
  });
228
255
  var packageFileSchema = z.object({
229
256
  package_file_id: z.string(),
@@ -267,7 +294,10 @@ var packageSchema = z.object({
267
294
  latest_package_release_fs_sha: z.string().nullable().default(null),
268
295
  default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional(),
269
296
  allow_pr_previews: z.boolean().default(false).optional(),
270
- is_starred: z.boolean().default(false).optional()
297
+ is_starred: z.boolean().default(false).optional(),
298
+ latest_pcb_preview_image_url: z.string().nullable().optional(),
299
+ latest_sch_preview_image_url: z.string().nullable().optional(),
300
+ latest_cad_preview_image_url: z.string().nullable().optional()
271
301
  });
272
302
  var jlcpcbOrderStateSchema = z.object({
273
303
  jlcpcb_order_state_id: z.string(),
@@ -385,13 +415,18 @@ var databaseSchema = z.object({
385
415
  aiReviews: z.array(aiReviewSchema).default([]),
386
416
  datasheets: z.array(datasheetSchema).default([]),
387
417
  githubInstallations: z.array(githubInstallationSchema).default([]),
388
- packageBuilds: z.array(packageBuildSchema).default([])
418
+ packageBuilds: z.array(packageBuildSchema).default([]),
419
+ bugReports: z.array(bugReportSchema).default([]),
420
+ bugReportFiles: z.array(bugReportFileSchema).default([])
389
421
  });
390
422
  export {
391
423
  accountPackageSchema,
392
424
  accountSchema,
393
425
  accountSnippetSchema,
394
426
  aiReviewSchema,
427
+ bugReportFileResponseSchema,
428
+ bugReportFileSchema,
429
+ bugReportSchema,
395
430
  databaseSchema,
396
431
  datasheetPinInformationSchema,
397
432
  datasheetSchema,
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from "node:crypto"
1
2
  import type { z } from "zod"
2
3
  import { hoist } from "zustand-hoist"
3
4
  import { createStore } from "zustand/vanilla"
@@ -12,6 +13,10 @@ import {
12
13
  type Order,
13
14
  type OrderFile,
14
15
  OrderQuote,
16
+ type BugReport,
17
+ bugReportSchema,
18
+ type BugReportFile,
19
+ bugReportFileSchema,
15
20
  type Package,
16
21
  type PackageFile,
17
22
  type PackageRelease,
@@ -177,6 +182,90 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
177
182
  const state = get()
178
183
  return state.orderFiles.find((file) => file.order_file_id === orderFileId)
179
184
  },
185
+ addBugReport: ({
186
+ reporter_account_id,
187
+ text,
188
+ is_auto_deleted,
189
+ delete_at,
190
+ }: {
191
+ reporter_account_id: string
192
+ text?: string | null
193
+ is_auto_deleted?: boolean
194
+ delete_at?: string | null
195
+ }): BugReport => {
196
+ const normalizedIsAutoDeleted = Boolean(is_auto_deleted)
197
+ if (normalizedIsAutoDeleted && !delete_at) {
198
+ throw new Error("delete_at is required when is_auto_deleted is true")
199
+ }
200
+ const normalizedDeleteAt = normalizedIsAutoDeleted
201
+ ? (delete_at ?? null)
202
+ : null
203
+
204
+ const bugReport = bugReportSchema.parse({
205
+ bug_report_id: randomUUID(),
206
+ reporter_account_id,
207
+ text: text ?? null,
208
+ is_auto_deleted: normalizedIsAutoDeleted,
209
+ delete_at: normalizedDeleteAt,
210
+ created_at: new Date().toISOString(),
211
+ file_count: 0,
212
+ })
213
+
214
+ set((state) => ({
215
+ bugReports: [...state.bugReports, bugReport],
216
+ }))
217
+
218
+ return bugReport
219
+ },
220
+ getBugReportById: (bugReportId: string): BugReport | undefined => {
221
+ const state = get()
222
+ return state.bugReports.find(
223
+ (bugReport) => bugReport.bug_report_id === bugReportId,
224
+ )
225
+ },
226
+ addBugReportFile: ({
227
+ bug_report_id,
228
+ file_path,
229
+ content_mimetype,
230
+ is_text,
231
+ content_text,
232
+ content_bytes,
233
+ }: {
234
+ bug_report_id: string
235
+ file_path: string
236
+ content_mimetype: string
237
+ is_text: boolean
238
+ content_text: string | null
239
+ content_bytes: Uint8Array | null
240
+ }): BugReportFile => {
241
+ const bugReportFile = bugReportFileSchema.parse({
242
+ bug_report_file_id: randomUUID(),
243
+ bug_report_id,
244
+ file_path,
245
+ content_mimetype,
246
+ is_text,
247
+ created_at: new Date().toISOString(),
248
+ content_text,
249
+ content_bytes,
250
+ })
251
+
252
+ set((state) => ({
253
+ bugReportFiles: [...state.bugReportFiles, bugReportFile],
254
+ bugReports: state.bugReports.map((bugReport) =>
255
+ bugReport.bug_report_id === bug_report_id
256
+ ? { ...bugReport, file_count: bugReport.file_count + 1 }
257
+ : bugReport,
258
+ ),
259
+ }))
260
+
261
+ return bugReportFile
262
+ },
263
+ getBugReportFilesByBugReportId: (bugReportId: string): BugReportFile[] => {
264
+ const state = get()
265
+ return state.bugReportFiles.filter(
266
+ (file) => file.bug_report_id === bugReportId,
267
+ )
268
+ },
180
269
  addAccount: (
181
270
  account: Omit<Account, "account_id" | "is_tscircuit_staff"> &
182
271
  Partial<Pick<Account, "account_id" | "is_tscircuit_staff">>,
@@ -1253,6 +1342,15 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
1253
1342
  const newPackage = {
1254
1343
  package_id: `package_${timestamp}`,
1255
1344
  github_repo_full_name: null,
1345
+ latest_pcb_preview_image_url:
1346
+ _package.latest_pcb_preview_image_url ??
1347
+ `/api/packages/images/${_package.name}`,
1348
+ latest_cad_preview_image_url:
1349
+ _package.latest_cad_preview_image_url ??
1350
+ `/api/packages/images/${_package.name}`,
1351
+ latest_sch_preview_image_url:
1352
+ _package.latest_sch_preview_image_url ??
1353
+ `/api/packages/images/${_package.name}`,
1256
1354
  ..._package,
1257
1355
  }
1258
1356
  set((state) => ({
@@ -103,6 +103,33 @@ export const orderFileSchema = z.object({
103
103
  })
104
104
  export type OrderFile = z.infer<typeof orderFileSchema>
105
105
 
106
+ export const bugReportSchema = z.object({
107
+ bug_report_id: z.string().uuid(),
108
+ reporter_account_id: z.string(),
109
+ text: z.string().nullable(),
110
+ is_auto_deleted: z.boolean().default(false),
111
+ delete_at: z.string().datetime().nullable(),
112
+ created_at: z.string().datetime(),
113
+ file_count: z.number().int(),
114
+ })
115
+ export type BugReport = z.infer<typeof bugReportSchema>
116
+
117
+ export const bugReportFileSchema = z.object({
118
+ bug_report_file_id: z.string().uuid(),
119
+ bug_report_id: z.string().uuid(),
120
+ file_path: z.string(),
121
+ content_mimetype: z.string(),
122
+ is_text: z.boolean(),
123
+ created_at: z.string().datetime(),
124
+ content_text: z.string().nullable(),
125
+ content_bytes: z.instanceof(Uint8Array).nullable(),
126
+ })
127
+ export const bugReportFileResponseSchema = bugReportFileSchema.omit({
128
+ content_text: true,
129
+ content_bytes: true,
130
+ })
131
+ export type BugReportFile = z.infer<typeof bugReportFileSchema>
132
+
106
133
  const shippingOptionSchema = z.object({
107
134
  carrier: z.string(),
108
135
  service: z.string(),
@@ -278,6 +305,11 @@ export const packageReleaseSchema = z.object({
278
305
  branch_name: z.string().nullable().optional(),
279
306
  commit_message: z.string().nullable().optional(),
280
307
  commit_author: z.string().nullable().optional(),
308
+
309
+ // Preview images url
310
+ pcb_preview_image_url: z.string().nullable().default(null),
311
+ sch_preview_image_url: z.string().nullable().default(null),
312
+ cad_preview_image_url: z.string().nullable().default(null),
281
313
  })
282
314
  export type PackageRelease = z.infer<typeof packageReleaseSchema>
283
315
 
@@ -329,6 +361,9 @@ export const packageSchema = z.object({
329
361
  .optional(),
330
362
  allow_pr_previews: z.boolean().default(false).optional(),
331
363
  is_starred: z.boolean().default(false).optional(),
364
+ latest_pcb_preview_image_url: z.string().nullable().optional(),
365
+ latest_sch_preview_image_url: z.string().nullable().optional(),
366
+ latest_cad_preview_image_url: z.string().nullable().optional(),
332
367
  })
333
368
  export type Package = z.infer<typeof packageSchema>
334
369
 
@@ -461,5 +496,7 @@ export const databaseSchema = z.object({
461
496
  datasheets: z.array(datasheetSchema).default([]),
462
497
  githubInstallations: z.array(githubInstallationSchema).default([]),
463
498
  packageBuilds: z.array(packageBuildSchema).default([]),
499
+ bugReports: z.array(bugReportSchema).default([]),
500
+ bugReportFiles: z.array(bugReportFileSchema).default([]),
464
501
  })
465
502
  export type DatabaseSchema = z.infer<typeof databaseSchema>
@@ -46,6 +46,12 @@ export const publicMapPackageRelease = (
46
46
  branch_name: internal_package_release.branch_name,
47
47
  commit_message: internal_package_release.commit_message ?? null,
48
48
  commit_author: internal_package_release.commit_author ?? null,
49
+ pcb_preview_image_url:
50
+ internal_package_release.pcb_preview_image_url ?? null,
51
+ sch_preview_image_url:
52
+ internal_package_release.sch_preview_image_url ?? null,
53
+ cad_preview_image_url:
54
+ internal_package_release.cad_preview_image_url ?? null,
49
55
  }
50
56
 
51
57
  if (options.include_ai_review && options.db) {