@tscircuit/fake-snippets 0.0.83 → 0.0.84

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/dist/index.d.ts CHANGED
@@ -384,6 +384,32 @@ declare const orderQuoteSchema: z.ZodObject<{
384
384
  total_cost_without_shipping?: number | undefined;
385
385
  }>;
386
386
  type OrderQuote = z.infer<typeof orderQuoteSchema>;
387
+ declare const aiReviewSchema: z.ZodObject<{
388
+ ai_review_id: z.ZodString;
389
+ ai_review_text: z.ZodNullable<z.ZodString>;
390
+ start_processing_at: z.ZodNullable<z.ZodString>;
391
+ finished_processing_at: z.ZodNullable<z.ZodString>;
392
+ processing_error: z.ZodNullable<z.ZodAny>;
393
+ created_at: z.ZodString;
394
+ display_status: z.ZodEnum<["pending", "completed", "failed"]>;
395
+ }, "strip", z.ZodTypeAny, {
396
+ created_at: string;
397
+ ai_review_id: string;
398
+ ai_review_text: string | null;
399
+ start_processing_at: string | null;
400
+ finished_processing_at: string | null;
401
+ display_status: "pending" | "completed" | "failed";
402
+ processing_error?: any;
403
+ }, {
404
+ created_at: string;
405
+ ai_review_id: string;
406
+ ai_review_text: string | null;
407
+ start_processing_at: string | null;
408
+ finished_processing_at: string | null;
409
+ display_status: "pending" | "completed" | "failed";
410
+ processing_error?: any;
411
+ }>;
412
+ type AiReview = z.infer<typeof aiReviewSchema>;
387
413
  declare const accountPackageSchema: z.ZodObject<{
388
414
  account_package_id: z.ZodString;
389
415
  account_id: z.ZodString;
@@ -445,11 +471,11 @@ declare const packageReleaseSchema: z.ZodObject<{
445
471
  package_release_id: string;
446
472
  created_at: string;
447
473
  version: string | null;
474
+ display_status: "error" | "pending" | "building" | "complete";
448
475
  package_id: string;
449
476
  is_locked: boolean;
450
477
  is_latest: boolean;
451
478
  has_transpiled: boolean;
452
- display_status: "error" | "pending" | "building" | "complete";
453
479
  transpilation_display_status: "error" | "pending" | "building" | "complete";
454
480
  transpilation_in_progress: boolean;
455
481
  transpilation_logs: any[];
@@ -459,6 +485,7 @@ declare const packageReleaseSchema: z.ZodObject<{
459
485
  circuit_json_build_logs: any[];
460
486
  circuit_json_build_is_stale: boolean;
461
487
  ai_review_requested: boolean;
488
+ ai_review_text?: string | null | undefined;
462
489
  commit_sha?: string | null | undefined;
463
490
  license?: string | null | undefined;
464
491
  circuit_json_build_error?: string | null | undefined;
@@ -470,7 +497,6 @@ declare const packageReleaseSchema: z.ZodObject<{
470
497
  transpilation_completed_at?: string | null | undefined;
471
498
  circuit_json_build_started_at?: string | null | undefined;
472
499
  circuit_json_build_completed_at?: string | null | undefined;
473
- ai_review_text?: string | null | undefined;
474
500
  ai_review_started_at?: string | null | undefined;
475
501
  ai_review_completed_at?: string | null | undefined;
476
502
  ai_review_error?: any;
@@ -482,6 +508,8 @@ declare const packageReleaseSchema: z.ZodObject<{
482
508
  package_id: string;
483
509
  is_locked: boolean;
484
510
  is_latest: boolean;
511
+ ai_review_text?: string | null | undefined;
512
+ display_status?: "error" | "pending" | "building" | "complete" | undefined;
485
513
  commit_sha?: string | null | undefined;
486
514
  license?: string | null | undefined;
487
515
  circuit_json_build_error?: string | null | undefined;
@@ -489,7 +517,6 @@ declare const packageReleaseSchema: z.ZodObject<{
489
517
  has_transpiled?: boolean | undefined;
490
518
  transpilation_error?: string | null | undefined;
491
519
  fs_sha?: string | null | undefined;
492
- display_status?: "error" | "pending" | "building" | "complete" | undefined;
493
520
  total_build_duration_ms?: number | null | undefined;
494
521
  transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
495
522
  transpilation_in_progress?: boolean | undefined;
@@ -503,7 +530,6 @@ declare const packageReleaseSchema: z.ZodObject<{
503
530
  circuit_json_build_completed_at?: string | null | undefined;
504
531
  circuit_json_build_logs?: any[] | undefined;
505
532
  circuit_json_build_is_stale?: boolean | undefined;
506
- ai_review_text?: string | null | undefined;
507
533
  ai_review_started_at?: string | null | undefined;
508
534
  ai_review_completed_at?: string | null | undefined;
509
535
  ai_review_error?: any;
@@ -765,11 +791,11 @@ declare const createDatabase: ({ seed }?: {
765
791
  package_release_id: string;
766
792
  created_at: string;
767
793
  version: string | null;
794
+ display_status: "error" | "pending" | "building" | "complete";
768
795
  package_id: string;
769
796
  is_locked: boolean;
770
797
  is_latest: boolean;
771
798
  has_transpiled: boolean;
772
- display_status: "error" | "pending" | "building" | "complete";
773
799
  transpilation_display_status: "error" | "pending" | "building" | "complete";
774
800
  transpilation_in_progress: boolean;
775
801
  transpilation_logs: any[];
@@ -779,6 +805,7 @@ declare const createDatabase: ({ seed }?: {
779
805
  circuit_json_build_logs: any[];
780
806
  circuit_json_build_is_stale: boolean;
781
807
  ai_review_requested: boolean;
808
+ ai_review_text?: string | null | undefined;
782
809
  commit_sha?: string | null | undefined;
783
810
  license?: string | null | undefined;
784
811
  circuit_json_build_error?: string | null | undefined;
@@ -790,7 +817,6 @@ declare const createDatabase: ({ seed }?: {
790
817
  transpilation_completed_at?: string | null | undefined;
791
818
  circuit_json_build_started_at?: string | null | undefined;
792
819
  circuit_json_build_completed_at?: string | null | undefined;
793
- ai_review_text?: string | null | undefined;
794
820
  ai_review_started_at?: string | null | undefined;
795
821
  ai_review_completed_at?: string | null | undefined;
796
822
  ai_review_error?: any;
@@ -973,7 +999,16 @@ declare const createDatabase: ({ seed }?: {
973
999
  }[];
974
1000
  total_cost_without_shipping: number;
975
1001
  }[];
976
- }, "addOrder" | "getOrderById" | "getOrderFilesByOrderId" | "addOrderQuote" | "getOrderQuoteById" | "getJlcpcbOrderStatesByOrderId" | "getJlcpcbOrderStepRunsByJlcpcbOrderStateId" | "updateOrder" | "addJlcpcbOrderState" | "updateJlcpcbOrderState" | "addOrderFile" | "getOrderFileById" | "addAccount" | "addAccountPackage" | "getAccountPackageById" | "updateAccountPackage" | "deleteAccountPackage" | "addSnippet" | "getLatestSnippets" | "getTrendingSnippets" | "getPackagesByAuthor" | "getSnippetByAuthorAndName" | "updateSnippet" | "getSnippetById" | "searchSnippets" | "searchPackages" | "deleteSnippet" | "addSession" | "getSessions" | "createLoginPage" | "getLoginPage" | "updateLoginPage" | "getAccount" | "updateAccount" | "createSession" | "addStar" | "removeStar" | "hasStarred" | "addPackage" | "updatePackage" | "getPackageById" | "getPackageReleaseById" | "addPackageRelease" | "updatePackageRelease" | "deletePackageFile" | "addPackageFile" | "updatePackageFile" | "getStarCount" | "getPackageFilesByReleaseId" | "updatePackageReleaseFsSha"> & {
1002
+ aiReviews: {
1003
+ created_at: string;
1004
+ ai_review_id: string;
1005
+ ai_review_text: string | null;
1006
+ start_processing_at: string | null;
1007
+ finished_processing_at: string | null;
1008
+ display_status: "pending" | "completed" | "failed";
1009
+ processing_error?: any;
1010
+ }[];
1011
+ }, "addOrder" | "getOrderById" | "getOrderFilesByOrderId" | "addOrderQuote" | "getOrderQuoteById" | "getJlcpcbOrderStatesByOrderId" | "getJlcpcbOrderStepRunsByJlcpcbOrderStateId" | "updateOrder" | "addJlcpcbOrderState" | "updateJlcpcbOrderState" | "addOrderFile" | "getOrderFileById" | "addAccount" | "addAccountPackage" | "getAccountPackageById" | "updateAccountPackage" | "deleteAccountPackage" | "addSnippet" | "getLatestSnippets" | "getTrendingSnippets" | "getPackagesByAuthor" | "getSnippetByAuthorAndName" | "updateSnippet" | "getSnippetById" | "searchSnippets" | "searchPackages" | "deleteSnippet" | "addSession" | "getSessions" | "createLoginPage" | "getLoginPage" | "updateLoginPage" | "getAccount" | "updateAccount" | "createSession" | "addStar" | "removeStar" | "hasStarred" | "addPackage" | "updatePackage" | "getPackageById" | "getPackageReleaseById" | "addPackageRelease" | "updatePackageRelease" | "deletePackageFile" | "addPackageFile" | "updatePackageFile" | "getStarCount" | "getPackageFilesByReleaseId" | "updatePackageReleaseFsSha" | "addAiReview" | "updateAiReview" | "getAiReviewById" | "listAiReviews"> & {
977
1012
  addOrder: (order: Omit<Order, "order_id">) => Order;
978
1013
  getOrderById: (orderId: string) => Order | undefined;
979
1014
  getOrderFilesByOrderId: (orderId: string) => OrderFile[];
@@ -1051,6 +1086,10 @@ declare const createDatabase: ({ seed }?: {
1051
1086
  * Update fs_sha for a package release based on its files
1052
1087
  */
1053
1088
  updatePackageReleaseFsSha: (packageReleaseId: string) => void;
1089
+ addAiReview: (review: Omit<AiReview, "ai_review_id">) => AiReview;
1090
+ updateAiReview: (aiReviewId: string, updates: Partial<AiReview>) => AiReview | undefined;
1091
+ getAiReviewById: (aiReviewId: string) => AiReview | undefined;
1092
+ listAiReviews: () => AiReview[];
1054
1093
  }> & Omit<{
1055
1094
  idCounter: number;
1056
1095
  snippets: {
@@ -1081,11 +1120,11 @@ declare const createDatabase: ({ seed }?: {
1081
1120
  package_release_id: string;
1082
1121
  created_at: string;
1083
1122
  version: string | null;
1123
+ display_status: "error" | "pending" | "building" | "complete";
1084
1124
  package_id: string;
1085
1125
  is_locked: boolean;
1086
1126
  is_latest: boolean;
1087
1127
  has_transpiled: boolean;
1088
- display_status: "error" | "pending" | "building" | "complete";
1089
1128
  transpilation_display_status: "error" | "pending" | "building" | "complete";
1090
1129
  transpilation_in_progress: boolean;
1091
1130
  transpilation_logs: any[];
@@ -1095,6 +1134,7 @@ declare const createDatabase: ({ seed }?: {
1095
1134
  circuit_json_build_logs: any[];
1096
1135
  circuit_json_build_is_stale: boolean;
1097
1136
  ai_review_requested: boolean;
1137
+ ai_review_text?: string | null | undefined;
1098
1138
  commit_sha?: string | null | undefined;
1099
1139
  license?: string | null | undefined;
1100
1140
  circuit_json_build_error?: string | null | undefined;
@@ -1106,7 +1146,6 @@ declare const createDatabase: ({ seed }?: {
1106
1146
  transpilation_completed_at?: string | null | undefined;
1107
1147
  circuit_json_build_started_at?: string | null | undefined;
1108
1148
  circuit_json_build_completed_at?: string | null | undefined;
1109
- ai_review_text?: string | null | undefined;
1110
1149
  ai_review_started_at?: string | null | undefined;
1111
1150
  ai_review_completed_at?: string | null | undefined;
1112
1151
  ai_review_error?: any;
@@ -1289,7 +1328,16 @@ declare const createDatabase: ({ seed }?: {
1289
1328
  }[];
1290
1329
  total_cost_without_shipping: number;
1291
1330
  }[];
1292
- }, "addOrder" | "getOrderById" | "getOrderFilesByOrderId" | "addOrderQuote" | "getOrderQuoteById" | "getJlcpcbOrderStatesByOrderId" | "getJlcpcbOrderStepRunsByJlcpcbOrderStateId" | "updateOrder" | "addJlcpcbOrderState" | "updateJlcpcbOrderState" | "addOrderFile" | "getOrderFileById" | "addAccount" | "addAccountPackage" | "getAccountPackageById" | "updateAccountPackage" | "deleteAccountPackage" | "addSnippet" | "getLatestSnippets" | "getTrendingSnippets" | "getPackagesByAuthor" | "getSnippetByAuthorAndName" | "updateSnippet" | "getSnippetById" | "searchSnippets" | "searchPackages" | "deleteSnippet" | "addSession" | "getSessions" | "createLoginPage" | "getLoginPage" | "updateLoginPage" | "getAccount" | "updateAccount" | "createSession" | "addStar" | "removeStar" | "hasStarred" | "addPackage" | "updatePackage" | "getPackageById" | "getPackageReleaseById" | "addPackageRelease" | "updatePackageRelease" | "deletePackageFile" | "addPackageFile" | "updatePackageFile" | "getStarCount" | "getPackageFilesByReleaseId" | "updatePackageReleaseFsSha"> & {
1331
+ aiReviews: {
1332
+ created_at: string;
1333
+ ai_review_id: string;
1334
+ ai_review_text: string | null;
1335
+ start_processing_at: string | null;
1336
+ finished_processing_at: string | null;
1337
+ display_status: "pending" | "completed" | "failed";
1338
+ processing_error?: any;
1339
+ }[];
1340
+ }, "addOrder" | "getOrderById" | "getOrderFilesByOrderId" | "addOrderQuote" | "getOrderQuoteById" | "getJlcpcbOrderStatesByOrderId" | "getJlcpcbOrderStepRunsByJlcpcbOrderStateId" | "updateOrder" | "addJlcpcbOrderState" | "updateJlcpcbOrderState" | "addOrderFile" | "getOrderFileById" | "addAccount" | "addAccountPackage" | "getAccountPackageById" | "updateAccountPackage" | "deleteAccountPackage" | "addSnippet" | "getLatestSnippets" | "getTrendingSnippets" | "getPackagesByAuthor" | "getSnippetByAuthorAndName" | "updateSnippet" | "getSnippetById" | "searchSnippets" | "searchPackages" | "deleteSnippet" | "addSession" | "getSessions" | "createLoginPage" | "getLoginPage" | "updateLoginPage" | "getAccount" | "updateAccount" | "createSession" | "addStar" | "removeStar" | "hasStarred" | "addPackage" | "updatePackage" | "getPackageById" | "getPackageReleaseById" | "addPackageRelease" | "updatePackageRelease" | "deletePackageFile" | "addPackageFile" | "updatePackageFile" | "getStarCount" | "getPackageFilesByReleaseId" | "updatePackageReleaseFsSha" | "addAiReview" | "updateAiReview" | "getAiReviewById" | "listAiReviews"> & {
1293
1341
  addOrder: (order: Omit<Order, "order_id">) => Order;
1294
1342
  getOrderById: (orderId: string) => Order | undefined;
1295
1343
  getOrderFilesByOrderId: (orderId: string) => OrderFile[];
@@ -1367,6 +1415,10 @@ declare const createDatabase: ({ seed }?: {
1367
1415
  * Update fs_sha for a package release based on its files
1368
1416
  */
1369
1417
  updatePackageReleaseFsSha: (packageReleaseId: string) => void;
1418
+ addAiReview: (review: Omit<AiReview, "ai_review_id">) => AiReview;
1419
+ updateAiReview: (aiReviewId: string, updates: Partial<AiReview>) => AiReview | undefined;
1420
+ getAiReviewById: (aiReviewId: string) => AiReview | undefined;
1421
+ listAiReviews: () => AiReview[];
1370
1422
  };
1371
1423
  type DbClient = ReturnType<typeof createDatabase>;
1372
1424
 
package/dist/index.js CHANGED
@@ -120,6 +120,15 @@ var orderQuoteSchema = z.object({
120
120
  shipping_options: z.array(shippingOptionSchema),
121
121
  total_cost_without_shipping: z.number().default(0)
122
122
  });
123
+ var aiReviewSchema = z.object({
124
+ ai_review_id: z.string().uuid(),
125
+ ai_review_text: z.string().nullable(),
126
+ start_processing_at: z.string().datetime().nullable(),
127
+ finished_processing_at: z.string().datetime().nullable(),
128
+ processing_error: z.any().nullable(),
129
+ created_at: z.string().datetime(),
130
+ display_status: z.enum(["pending", "completed", "failed"])
131
+ });
123
132
  var accountSnippetSchema = z.object({
124
133
  account_id: z.string(),
125
134
  snippet_id: z.string(),
@@ -264,7 +273,8 @@ var databaseSchema = z.object({
264
273
  accountPackages: z.array(accountPackageSchema).default([]),
265
274
  jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
266
275
  jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
267
- orderQuotes: z.array(orderQuoteSchema).default([])
276
+ orderQuotes: z.array(orderQuoteSchema).default([]),
277
+ aiReviews: z.array(aiReviewSchema).default([])
268
278
  });
269
279
 
270
280
  // fake-snippets-api/lib/db/autoload-dev-packages.ts
@@ -3049,6 +3059,40 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
3049
3059
  (pkg) => pkg.latest_package_release_id === packageReleaseId ? { ...pkg, latest_package_release_fs_sha: fsSha } : pkg
3050
3060
  )
3051
3061
  }));
3062
+ },
3063
+ addAiReview: (review) => {
3064
+ const base = aiReviewSchema.omit({ ai_review_id: true }).parse(review);
3065
+ const newReview = {
3066
+ ai_review_id: crypto.randomUUID(),
3067
+ ...base
3068
+ };
3069
+ set((state) => ({
3070
+ aiReviews: [...state.aiReviews, newReview],
3071
+ idCounter: state.idCounter + 1
3072
+ }));
3073
+ return newReview;
3074
+ },
3075
+ updateAiReview: (aiReviewId, updates) => {
3076
+ let updated;
3077
+ set((state) => {
3078
+ const index = state.aiReviews.findIndex(
3079
+ (ar) => ar.ai_review_id === aiReviewId
3080
+ );
3081
+ if (index === -1) return state;
3082
+ const aiReviews = [...state.aiReviews];
3083
+ aiReviews[index] = { ...aiReviews[index], ...updates };
3084
+ updated = aiReviews[index];
3085
+ return { ...state, aiReviews };
3086
+ });
3087
+ return updated;
3088
+ },
3089
+ getAiReviewById: (aiReviewId) => {
3090
+ const state = get();
3091
+ return state.aiReviews.find((ar) => ar.ai_review_id === aiReviewId);
3092
+ },
3093
+ listAiReviews: () => {
3094
+ const state = get();
3095
+ return state.aiReviews;
3052
3096
  }
3053
3097
  }));
3054
3098
 
package/dist/schema.d.ts CHANGED
@@ -489,6 +489,32 @@ declare const orderQuoteSchema: z.ZodObject<{
489
489
  total_cost_without_shipping?: number | undefined;
490
490
  }>;
491
491
  type OrderQuote = z.infer<typeof orderQuoteSchema>;
492
+ declare const aiReviewSchema: z.ZodObject<{
493
+ ai_review_id: z.ZodString;
494
+ ai_review_text: z.ZodNullable<z.ZodString>;
495
+ start_processing_at: z.ZodNullable<z.ZodString>;
496
+ finished_processing_at: z.ZodNullable<z.ZodString>;
497
+ processing_error: z.ZodNullable<z.ZodAny>;
498
+ created_at: z.ZodString;
499
+ display_status: z.ZodEnum<["pending", "completed", "failed"]>;
500
+ }, "strip", z.ZodTypeAny, {
501
+ created_at: string;
502
+ ai_review_id: string;
503
+ ai_review_text: string | null;
504
+ start_processing_at: string | null;
505
+ finished_processing_at: string | null;
506
+ display_status: "pending" | "completed" | "failed";
507
+ processing_error?: any;
508
+ }, {
509
+ created_at: string;
510
+ ai_review_id: string;
511
+ ai_review_text: string | null;
512
+ start_processing_at: string | null;
513
+ finished_processing_at: string | null;
514
+ display_status: "pending" | "completed" | "failed";
515
+ processing_error?: any;
516
+ }>;
517
+ type AiReview = z.infer<typeof aiReviewSchema>;
492
518
  declare const accountSnippetSchema: z.ZodObject<{
493
519
  account_id: z.ZodString;
494
520
  snippet_id: z.ZodString;
@@ -570,11 +596,11 @@ declare const packageReleaseSchema: z.ZodObject<{
570
596
  package_release_id: string;
571
597
  created_at: string;
572
598
  version: string | null;
599
+ display_status: "error" | "pending" | "building" | "complete";
573
600
  package_id: string;
574
601
  is_locked: boolean;
575
602
  is_latest: boolean;
576
603
  has_transpiled: boolean;
577
- display_status: "error" | "pending" | "building" | "complete";
578
604
  transpilation_display_status: "error" | "pending" | "building" | "complete";
579
605
  transpilation_in_progress: boolean;
580
606
  transpilation_logs: any[];
@@ -584,6 +610,7 @@ declare const packageReleaseSchema: z.ZodObject<{
584
610
  circuit_json_build_logs: any[];
585
611
  circuit_json_build_is_stale: boolean;
586
612
  ai_review_requested: boolean;
613
+ ai_review_text?: string | null | undefined;
587
614
  commit_sha?: string | null | undefined;
588
615
  license?: string | null | undefined;
589
616
  circuit_json_build_error?: string | null | undefined;
@@ -595,7 +622,6 @@ declare const packageReleaseSchema: z.ZodObject<{
595
622
  transpilation_completed_at?: string | null | undefined;
596
623
  circuit_json_build_started_at?: string | null | undefined;
597
624
  circuit_json_build_completed_at?: string | null | undefined;
598
- ai_review_text?: string | null | undefined;
599
625
  ai_review_started_at?: string | null | undefined;
600
626
  ai_review_completed_at?: string | null | undefined;
601
627
  ai_review_error?: any;
@@ -607,6 +633,8 @@ declare const packageReleaseSchema: z.ZodObject<{
607
633
  package_id: string;
608
634
  is_locked: boolean;
609
635
  is_latest: boolean;
636
+ ai_review_text?: string | null | undefined;
637
+ display_status?: "error" | "pending" | "building" | "complete" | undefined;
610
638
  commit_sha?: string | null | undefined;
611
639
  license?: string | null | undefined;
612
640
  circuit_json_build_error?: string | null | undefined;
@@ -614,7 +642,6 @@ declare const packageReleaseSchema: z.ZodObject<{
614
642
  has_transpiled?: boolean | undefined;
615
643
  transpilation_error?: string | null | undefined;
616
644
  fs_sha?: string | null | undefined;
617
- display_status?: "error" | "pending" | "building" | "complete" | undefined;
618
645
  total_build_duration_ms?: number | null | undefined;
619
646
  transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
620
647
  transpilation_in_progress?: boolean | undefined;
@@ -628,7 +655,6 @@ declare const packageReleaseSchema: z.ZodObject<{
628
655
  circuit_json_build_completed_at?: string | null | undefined;
629
656
  circuit_json_build_logs?: any[] | undefined;
630
657
  circuit_json_build_is_stale?: boolean | undefined;
631
- ai_review_text?: string | null | undefined;
632
658
  ai_review_started_at?: string | null | undefined;
633
659
  ai_review_completed_at?: string | null | undefined;
634
660
  ai_review_error?: any;
@@ -967,11 +993,11 @@ declare const databaseSchema: z.ZodObject<{
967
993
  package_release_id: string;
968
994
  created_at: string;
969
995
  version: string | null;
996
+ display_status: "error" | "pending" | "building" | "complete";
970
997
  package_id: string;
971
998
  is_locked: boolean;
972
999
  is_latest: boolean;
973
1000
  has_transpiled: boolean;
974
- display_status: "error" | "pending" | "building" | "complete";
975
1001
  transpilation_display_status: "error" | "pending" | "building" | "complete";
976
1002
  transpilation_in_progress: boolean;
977
1003
  transpilation_logs: any[];
@@ -981,6 +1007,7 @@ declare const databaseSchema: z.ZodObject<{
981
1007
  circuit_json_build_logs: any[];
982
1008
  circuit_json_build_is_stale: boolean;
983
1009
  ai_review_requested: boolean;
1010
+ ai_review_text?: string | null | undefined;
984
1011
  commit_sha?: string | null | undefined;
985
1012
  license?: string | null | undefined;
986
1013
  circuit_json_build_error?: string | null | undefined;
@@ -992,7 +1019,6 @@ declare const databaseSchema: z.ZodObject<{
992
1019
  transpilation_completed_at?: string | null | undefined;
993
1020
  circuit_json_build_started_at?: string | null | undefined;
994
1021
  circuit_json_build_completed_at?: string | null | undefined;
995
- ai_review_text?: string | null | undefined;
996
1022
  ai_review_started_at?: string | null | undefined;
997
1023
  ai_review_completed_at?: string | null | undefined;
998
1024
  ai_review_error?: any;
@@ -1004,6 +1030,8 @@ declare const databaseSchema: z.ZodObject<{
1004
1030
  package_id: string;
1005
1031
  is_locked: boolean;
1006
1032
  is_latest: boolean;
1033
+ ai_review_text?: string | null | undefined;
1034
+ display_status?: "error" | "pending" | "building" | "complete" | undefined;
1007
1035
  commit_sha?: string | null | undefined;
1008
1036
  license?: string | null | undefined;
1009
1037
  circuit_json_build_error?: string | null | undefined;
@@ -1011,7 +1039,6 @@ declare const databaseSchema: z.ZodObject<{
1011
1039
  has_transpiled?: boolean | undefined;
1012
1040
  transpilation_error?: string | null | undefined;
1013
1041
  fs_sha?: string | null | undefined;
1014
- display_status?: "error" | "pending" | "building" | "complete" | undefined;
1015
1042
  total_build_duration_ms?: number | null | undefined;
1016
1043
  transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
1017
1044
  transpilation_in_progress?: boolean | undefined;
@@ -1025,7 +1052,6 @@ declare const databaseSchema: z.ZodObject<{
1025
1052
  circuit_json_build_completed_at?: string | null | undefined;
1026
1053
  circuit_json_build_logs?: any[] | undefined;
1027
1054
  circuit_json_build_is_stale?: boolean | undefined;
1028
- ai_review_text?: string | null | undefined;
1029
1055
  ai_review_started_at?: string | null | undefined;
1030
1056
  ai_review_completed_at?: string | null | undefined;
1031
1057
  ai_review_error?: any;
@@ -1595,6 +1621,31 @@ declare const databaseSchema: z.ZodObject<{
1595
1621
  bare_pcb_cost?: number | undefined;
1596
1622
  total_cost_without_shipping?: number | undefined;
1597
1623
  }>, "many">>;
1624
+ aiReviews: z.ZodDefault<z.ZodArray<z.ZodObject<{
1625
+ ai_review_id: z.ZodString;
1626
+ ai_review_text: z.ZodNullable<z.ZodString>;
1627
+ start_processing_at: z.ZodNullable<z.ZodString>;
1628
+ finished_processing_at: z.ZodNullable<z.ZodString>;
1629
+ processing_error: z.ZodNullable<z.ZodAny>;
1630
+ created_at: z.ZodString;
1631
+ display_status: z.ZodEnum<["pending", "completed", "failed"]>;
1632
+ }, "strip", z.ZodTypeAny, {
1633
+ created_at: string;
1634
+ ai_review_id: string;
1635
+ ai_review_text: string | null;
1636
+ start_processing_at: string | null;
1637
+ finished_processing_at: string | null;
1638
+ display_status: "pending" | "completed" | "failed";
1639
+ processing_error?: any;
1640
+ }, {
1641
+ created_at: string;
1642
+ ai_review_id: string;
1643
+ ai_review_text: string | null;
1644
+ start_processing_at: string | null;
1645
+ finished_processing_at: string | null;
1646
+ display_status: "pending" | "completed" | "failed";
1647
+ processing_error?: any;
1648
+ }>, "many">>;
1598
1649
  }, "strip", z.ZodTypeAny, {
1599
1650
  idCounter: number;
1600
1651
  snippets: {
@@ -1625,11 +1676,11 @@ declare const databaseSchema: z.ZodObject<{
1625
1676
  package_release_id: string;
1626
1677
  created_at: string;
1627
1678
  version: string | null;
1679
+ display_status: "error" | "pending" | "building" | "complete";
1628
1680
  package_id: string;
1629
1681
  is_locked: boolean;
1630
1682
  is_latest: boolean;
1631
1683
  has_transpiled: boolean;
1632
- display_status: "error" | "pending" | "building" | "complete";
1633
1684
  transpilation_display_status: "error" | "pending" | "building" | "complete";
1634
1685
  transpilation_in_progress: boolean;
1635
1686
  transpilation_logs: any[];
@@ -1639,6 +1690,7 @@ declare const databaseSchema: z.ZodObject<{
1639
1690
  circuit_json_build_logs: any[];
1640
1691
  circuit_json_build_is_stale: boolean;
1641
1692
  ai_review_requested: boolean;
1693
+ ai_review_text?: string | null | undefined;
1642
1694
  commit_sha?: string | null | undefined;
1643
1695
  license?: string | null | undefined;
1644
1696
  circuit_json_build_error?: string | null | undefined;
@@ -1650,7 +1702,6 @@ declare const databaseSchema: z.ZodObject<{
1650
1702
  transpilation_completed_at?: string | null | undefined;
1651
1703
  circuit_json_build_started_at?: string | null | undefined;
1652
1704
  circuit_json_build_completed_at?: string | null | undefined;
1653
- ai_review_text?: string | null | undefined;
1654
1705
  ai_review_started_at?: string | null | undefined;
1655
1706
  ai_review_completed_at?: string | null | undefined;
1656
1707
  ai_review_error?: any;
@@ -1833,6 +1884,15 @@ declare const databaseSchema: z.ZodObject<{
1833
1884
  }[];
1834
1885
  total_cost_without_shipping: number;
1835
1886
  }[];
1887
+ aiReviews: {
1888
+ created_at: string;
1889
+ ai_review_id: string;
1890
+ ai_review_text: string | null;
1891
+ start_processing_at: string | null;
1892
+ finished_processing_at: string | null;
1893
+ display_status: "pending" | "completed" | "failed";
1894
+ processing_error?: any;
1895
+ }[];
1836
1896
  }, {
1837
1897
  idCounter?: number | undefined;
1838
1898
  snippets?: {
@@ -1866,6 +1926,8 @@ declare const databaseSchema: z.ZodObject<{
1866
1926
  package_id: string;
1867
1927
  is_locked: boolean;
1868
1928
  is_latest: boolean;
1929
+ ai_review_text?: string | null | undefined;
1930
+ display_status?: "error" | "pending" | "building" | "complete" | undefined;
1869
1931
  commit_sha?: string | null | undefined;
1870
1932
  license?: string | null | undefined;
1871
1933
  circuit_json_build_error?: string | null | undefined;
@@ -1873,7 +1935,6 @@ declare const databaseSchema: z.ZodObject<{
1873
1935
  has_transpiled?: boolean | undefined;
1874
1936
  transpilation_error?: string | null | undefined;
1875
1937
  fs_sha?: string | null | undefined;
1876
- display_status?: "error" | "pending" | "building" | "complete" | undefined;
1877
1938
  total_build_duration_ms?: number | null | undefined;
1878
1939
  transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
1879
1940
  transpilation_in_progress?: boolean | undefined;
@@ -1887,7 +1948,6 @@ declare const databaseSchema: z.ZodObject<{
1887
1948
  circuit_json_build_completed_at?: string | null | undefined;
1888
1949
  circuit_json_build_logs?: any[] | undefined;
1889
1950
  circuit_json_build_is_stale?: boolean | undefined;
1890
- ai_review_text?: string | null | undefined;
1891
1951
  ai_review_started_at?: string | null | undefined;
1892
1952
  ai_review_completed_at?: string | null | undefined;
1893
1953
  ai_review_error?: any;
@@ -2071,7 +2131,16 @@ declare const databaseSchema: z.ZodObject<{
2071
2131
  bare_pcb_cost?: number | undefined;
2072
2132
  total_cost_without_shipping?: number | undefined;
2073
2133
  }[] | undefined;
2134
+ aiReviews?: {
2135
+ created_at: string;
2136
+ ai_review_id: string;
2137
+ ai_review_text: string | null;
2138
+ start_processing_at: string | null;
2139
+ finished_processing_at: string | null;
2140
+ display_status: "pending" | "completed" | "failed";
2141
+ processing_error?: any;
2142
+ }[] | undefined;
2074
2143
  }>;
2075
2144
  type DatabaseSchema = z.infer<typeof databaseSchema>;
2076
2145
 
2077
- export { type Account, type AccountPackage, type AccountSnippet, type DatabaseSchema, type JlcpcbOrderState, type JlcpcbOrderStepRun, type LoginPage, type Order, type OrderFile, type OrderQuote, type Package, type PackageFile, type PackageRelease, type QuotedComponent, type Session, type ShippingOption, type Snippet, accountPackageSchema, accountSchema, accountSnippetSchema, databaseSchema, errorResponseSchema, errorSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, packageFileSchema, packageReleaseSchema, packageSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema };
2146
+ export { type Account, type AccountPackage, type AccountSnippet, type AiReview, type DatabaseSchema, type JlcpcbOrderState, type JlcpcbOrderStepRun, type LoginPage, type Order, type OrderFile, type OrderQuote, type Package, type PackageFile, type PackageRelease, type QuotedComponent, type Session, type ShippingOption, type Snippet, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, databaseSchema, errorResponseSchema, errorSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, packageFileSchema, packageReleaseSchema, packageSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema };
package/dist/schema.js CHANGED
@@ -115,6 +115,15 @@ var orderQuoteSchema = z.object({
115
115
  shipping_options: z.array(shippingOptionSchema),
116
116
  total_cost_without_shipping: z.number().default(0)
117
117
  });
118
+ var aiReviewSchema = z.object({
119
+ ai_review_id: z.string().uuid(),
120
+ ai_review_text: z.string().nullable(),
121
+ start_processing_at: z.string().datetime().nullable(),
122
+ finished_processing_at: z.string().datetime().nullable(),
123
+ processing_error: z.any().nullable(),
124
+ created_at: z.string().datetime(),
125
+ display_status: z.enum(["pending", "completed", "failed"])
126
+ });
118
127
  var accountSnippetSchema = z.object({
119
128
  account_id: z.string(),
120
129
  snippet_id: z.string(),
@@ -259,12 +268,14 @@ var databaseSchema = z.object({
259
268
  accountPackages: z.array(accountPackageSchema).default([]),
260
269
  jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
261
270
  jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
262
- orderQuotes: z.array(orderQuoteSchema).default([])
271
+ orderQuotes: z.array(orderQuoteSchema).default([]),
272
+ aiReviews: z.array(aiReviewSchema).default([])
263
273
  });
264
274
  export {
265
275
  accountPackageSchema,
266
276
  accountSchema,
267
277
  accountSnippetSchema,
278
+ aiReviewSchema,
268
279
  databaseSchema,
269
280
  errorResponseSchema,
270
281
  errorSchema,
@@ -16,6 +16,8 @@ import {
16
16
  type PackageFile,
17
17
  type PackageRelease,
18
18
  packageReleaseSchema,
19
+ type AiReview,
20
+ aiReviewSchema,
19
21
  type Session,
20
22
  type Snippet,
21
23
  databaseSchema,
@@ -1338,4 +1340,42 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
1338
1340
  ),
1339
1341
  }))
1340
1342
  },
1343
+
1344
+ addAiReview: (review: Omit<AiReview, "ai_review_id">): AiReview => {
1345
+ const base = aiReviewSchema.omit({ ai_review_id: true }).parse(review)
1346
+ const newReview = {
1347
+ ai_review_id: crypto.randomUUID(),
1348
+ ...base,
1349
+ }
1350
+ set((state) => ({
1351
+ aiReviews: [...state.aiReviews, newReview],
1352
+ idCounter: state.idCounter + 1,
1353
+ }))
1354
+ return newReview
1355
+ },
1356
+ updateAiReview: (
1357
+ aiReviewId: string,
1358
+ updates: Partial<AiReview>,
1359
+ ): AiReview | undefined => {
1360
+ let updated: AiReview | undefined
1361
+ set((state) => {
1362
+ const index = state.aiReviews.findIndex(
1363
+ (ar) => ar.ai_review_id === aiReviewId,
1364
+ )
1365
+ if (index === -1) return state
1366
+ const aiReviews = [...state.aiReviews]
1367
+ aiReviews[index] = { ...aiReviews[index], ...updates }
1368
+ updated = aiReviews[index]
1369
+ return { ...state, aiReviews }
1370
+ })
1371
+ return updated
1372
+ },
1373
+ getAiReviewById: (aiReviewId: string): AiReview | undefined => {
1374
+ const state = get()
1375
+ return state.aiReviews.find((ar) => ar.ai_review_id === aiReviewId)
1376
+ },
1377
+ listAiReviews: (): AiReview[] => {
1378
+ const state = get()
1379
+ return state.aiReviews
1380
+ },
1341
1381
  }))
@@ -138,6 +138,17 @@ export const orderQuoteSchema = z.object({
138
138
  })
139
139
  export type OrderQuote = z.infer<typeof orderQuoteSchema>
140
140
 
141
+ export const aiReviewSchema = z.object({
142
+ ai_review_id: z.string().uuid(),
143
+ ai_review_text: z.string().nullable(),
144
+ start_processing_at: z.string().datetime().nullable(),
145
+ finished_processing_at: z.string().datetime().nullable(),
146
+ processing_error: z.any().nullable(),
147
+ created_at: z.string().datetime(),
148
+ display_status: z.enum(["pending", "completed", "failed"]),
149
+ })
150
+ export type AiReview = z.infer<typeof aiReviewSchema>
151
+
141
152
  // TODO: Remove this schema after migration to accountPackages is complete
142
153
  export const accountSnippetSchema = z.object({
143
154
  account_id: z.string(),
@@ -314,5 +325,6 @@ export const databaseSchema = z.object({
314
325
  jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
315
326
  jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
316
327
  orderQuotes: z.array(orderQuoteSchema).default([]),
328
+ aiReviews: z.array(aiReviewSchema).default([]),
317
329
  })
318
330
  export type DatabaseSchema = z.infer<typeof databaseSchema>
@@ -0,0 +1,31 @@
1
+ import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
2
+ import { z } from "zod"
3
+ import { aiReviewSchema } from "fake-snippets-api/lib/db/schema"
4
+
5
+ export default withRouteSpec({
6
+ methods: ["POST"],
7
+ auth: "session",
8
+ jsonBody: z.object({
9
+ ai_review_id: z.string(),
10
+ }),
11
+ jsonResponse: z.object({
12
+ ai_review: aiReviewSchema,
13
+ }),
14
+ })(async (req, ctx) => {
15
+ const { ai_review_id } = req.jsonBody
16
+ const existing = ctx.db.getAiReviewById(ai_review_id)
17
+ if (!existing) {
18
+ return ctx.error(404, {
19
+ error_code: "ai_review_not_found",
20
+ message: "AI review not found",
21
+ })
22
+ }
23
+ const now = new Date().toISOString()
24
+ const updated = ctx.db.updateAiReview(ai_review_id, {
25
+ ai_review_text: "Placeholder AI Review",
26
+ start_processing_at: existing.start_processing_at ?? now,
27
+ finished_processing_at: now,
28
+ display_status: "completed",
29
+ })!
30
+ return ctx.json({ ai_review: updated })
31
+ })