@tscircuit/fake-snippets 0.0.84 → 0.0.86
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/bun-tests/fake-snippets-api/routes/ai_reviews/create.test.ts +11 -2
- package/bun-tests/fake-snippets-api/routes/datasheets/create.test.ts +15 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/get.test.ts +17 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/process_all_datasheets.test.ts +21 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/run_async_tasks.test.ts +18 -0
- package/bun-tests/fake-snippets-api/routes/package_releases/get.test.ts +25 -0
- package/dist/bundle.js +602 -427
- package/dist/index.d.ts +86 -2
- package/dist/index.js +47 -1
- package/dist/schema.d.ts +138 -1
- package/dist/schema.js +18 -1
- package/fake-snippets-api/lib/db/db-client.ts +36 -0
- package/fake-snippets-api/lib/db/schema.ts +18 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +23 -0
- package/fake-snippets-api/routes/api/_fake/datasheets/process_all_datasheets.ts +37 -0
- package/fake-snippets-api/routes/api/_fake/run_async_tasks.ts +12 -0
- package/fake-snippets-api/routes/api/ai_reviews/create.ts +20 -0
- package/fake-snippets-api/routes/api/datasheets/create.ts +18 -0
- package/fake-snippets-api/routes/api/datasheets/get.ts +25 -0
- package/fake-snippets-api/routes/api/package_releases/create.ts +1 -1
- package/fake-snippets-api/routes/api/package_releases/get.ts +4 -0
- package/fake-snippets-api/routes/api/package_releases/list.ts +1 -0
- package/package.json +1 -1
- package/src/components/SearchComponent.tsx +47 -2
- package/src/hooks/use-request-ai-review-mutation.ts +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -386,6 +386,7 @@ declare const orderQuoteSchema: z.ZodObject<{
|
|
|
386
386
|
type OrderQuote = z.infer<typeof orderQuoteSchema>;
|
|
387
387
|
declare const aiReviewSchema: z.ZodObject<{
|
|
388
388
|
ai_review_id: z.ZodString;
|
|
389
|
+
package_release_id: z.ZodOptional<z.ZodString>;
|
|
389
390
|
ai_review_text: z.ZodNullable<z.ZodString>;
|
|
390
391
|
start_processing_at: z.ZodNullable<z.ZodString>;
|
|
391
392
|
finished_processing_at: z.ZodNullable<z.ZodString>;
|
|
@@ -399,6 +400,7 @@ declare const aiReviewSchema: z.ZodObject<{
|
|
|
399
400
|
start_processing_at: string | null;
|
|
400
401
|
finished_processing_at: string | null;
|
|
401
402
|
display_status: "pending" | "completed" | "failed";
|
|
403
|
+
package_release_id?: string | undefined;
|
|
402
404
|
processing_error?: any;
|
|
403
405
|
}, {
|
|
404
406
|
created_at: string;
|
|
@@ -407,9 +409,55 @@ declare const aiReviewSchema: z.ZodObject<{
|
|
|
407
409
|
start_processing_at: string | null;
|
|
408
410
|
finished_processing_at: string | null;
|
|
409
411
|
display_status: "pending" | "completed" | "failed";
|
|
412
|
+
package_release_id?: string | undefined;
|
|
410
413
|
processing_error?: any;
|
|
411
414
|
}>;
|
|
412
415
|
type AiReview = z.infer<typeof aiReviewSchema>;
|
|
416
|
+
declare const datasheetSchema: z.ZodObject<{
|
|
417
|
+
datasheet_id: z.ZodString;
|
|
418
|
+
chip_name: z.ZodString;
|
|
419
|
+
created_at: z.ZodString;
|
|
420
|
+
pin_information: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
421
|
+
pin_number: z.ZodString;
|
|
422
|
+
name: z.ZodString;
|
|
423
|
+
description: z.ZodString;
|
|
424
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
425
|
+
}, "strip", z.ZodTypeAny, {
|
|
426
|
+
name: string;
|
|
427
|
+
description: string;
|
|
428
|
+
pin_number: string;
|
|
429
|
+
capabilities: string[];
|
|
430
|
+
}, {
|
|
431
|
+
name: string;
|
|
432
|
+
description: string;
|
|
433
|
+
pin_number: string;
|
|
434
|
+
capabilities: string[];
|
|
435
|
+
}>, "many">>;
|
|
436
|
+
datasheet_pdf_urls: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
437
|
+
}, "strip", z.ZodTypeAny, {
|
|
438
|
+
created_at: string;
|
|
439
|
+
datasheet_id: string;
|
|
440
|
+
chip_name: string;
|
|
441
|
+
pin_information: {
|
|
442
|
+
name: string;
|
|
443
|
+
description: string;
|
|
444
|
+
pin_number: string;
|
|
445
|
+
capabilities: string[];
|
|
446
|
+
}[] | null;
|
|
447
|
+
datasheet_pdf_urls: string[] | null;
|
|
448
|
+
}, {
|
|
449
|
+
created_at: string;
|
|
450
|
+
datasheet_id: string;
|
|
451
|
+
chip_name: string;
|
|
452
|
+
pin_information: {
|
|
453
|
+
name: string;
|
|
454
|
+
description: string;
|
|
455
|
+
pin_number: string;
|
|
456
|
+
capabilities: string[];
|
|
457
|
+
}[] | null;
|
|
458
|
+
datasheet_pdf_urls: string[] | null;
|
|
459
|
+
}>;
|
|
460
|
+
type Datasheet = z.infer<typeof datasheetSchema>;
|
|
413
461
|
declare const accountPackageSchema: z.ZodObject<{
|
|
414
462
|
account_package_id: z.ZodString;
|
|
415
463
|
account_id: z.ZodString;
|
|
@@ -1006,9 +1054,22 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1006
1054
|
start_processing_at: string | null;
|
|
1007
1055
|
finished_processing_at: string | null;
|
|
1008
1056
|
display_status: "pending" | "completed" | "failed";
|
|
1057
|
+
package_release_id?: string | undefined;
|
|
1009
1058
|
processing_error?: any;
|
|
1010
1059
|
}[];
|
|
1011
|
-
|
|
1060
|
+
datasheets: {
|
|
1061
|
+
created_at: string;
|
|
1062
|
+
datasheet_id: string;
|
|
1063
|
+
chip_name: string;
|
|
1064
|
+
pin_information: {
|
|
1065
|
+
name: string;
|
|
1066
|
+
description: string;
|
|
1067
|
+
pin_number: string;
|
|
1068
|
+
capabilities: string[];
|
|
1069
|
+
}[] | null;
|
|
1070
|
+
datasheet_pdf_urls: string[] | null;
|
|
1071
|
+
}[];
|
|
1072
|
+
}, "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" | "addDatasheet" | "getDatasheetById" | "updateDatasheet"> & {
|
|
1012
1073
|
addOrder: (order: Omit<Order, "order_id">) => Order;
|
|
1013
1074
|
getOrderById: (orderId: string) => Order | undefined;
|
|
1014
1075
|
getOrderFilesByOrderId: (orderId: string) => OrderFile[];
|
|
@@ -1090,6 +1151,11 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1090
1151
|
updateAiReview: (aiReviewId: string, updates: Partial<AiReview>) => AiReview | undefined;
|
|
1091
1152
|
getAiReviewById: (aiReviewId: string) => AiReview | undefined;
|
|
1092
1153
|
listAiReviews: () => AiReview[];
|
|
1154
|
+
addDatasheet: ({ chip_name }: {
|
|
1155
|
+
chip_name: string;
|
|
1156
|
+
}) => Datasheet;
|
|
1157
|
+
getDatasheetById: (datasheetId: string) => Datasheet | undefined;
|
|
1158
|
+
updateDatasheet: (datasheetId: string, updates: Partial<Datasheet>) => Datasheet | undefined;
|
|
1093
1159
|
}> & Omit<{
|
|
1094
1160
|
idCounter: number;
|
|
1095
1161
|
snippets: {
|
|
@@ -1335,9 +1401,22 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1335
1401
|
start_processing_at: string | null;
|
|
1336
1402
|
finished_processing_at: string | null;
|
|
1337
1403
|
display_status: "pending" | "completed" | "failed";
|
|
1404
|
+
package_release_id?: string | undefined;
|
|
1338
1405
|
processing_error?: any;
|
|
1339
1406
|
}[];
|
|
1340
|
-
|
|
1407
|
+
datasheets: {
|
|
1408
|
+
created_at: string;
|
|
1409
|
+
datasheet_id: string;
|
|
1410
|
+
chip_name: string;
|
|
1411
|
+
pin_information: {
|
|
1412
|
+
name: string;
|
|
1413
|
+
description: string;
|
|
1414
|
+
pin_number: string;
|
|
1415
|
+
capabilities: string[];
|
|
1416
|
+
}[] | null;
|
|
1417
|
+
datasheet_pdf_urls: string[] | null;
|
|
1418
|
+
}[];
|
|
1419
|
+
}, "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" | "addDatasheet" | "getDatasheetById" | "updateDatasheet"> & {
|
|
1341
1420
|
addOrder: (order: Omit<Order, "order_id">) => Order;
|
|
1342
1421
|
getOrderById: (orderId: string) => Order | undefined;
|
|
1343
1422
|
getOrderFilesByOrderId: (orderId: string) => OrderFile[];
|
|
@@ -1419,6 +1498,11 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1419
1498
|
updateAiReview: (aiReviewId: string, updates: Partial<AiReview>) => AiReview | undefined;
|
|
1420
1499
|
getAiReviewById: (aiReviewId: string) => AiReview | undefined;
|
|
1421
1500
|
listAiReviews: () => AiReview[];
|
|
1501
|
+
addDatasheet: ({ chip_name }: {
|
|
1502
|
+
chip_name: string;
|
|
1503
|
+
}) => Datasheet;
|
|
1504
|
+
getDatasheetById: (datasheetId: string) => Datasheet | undefined;
|
|
1505
|
+
updateDatasheet: (datasheetId: string, updates: Partial<Datasheet>) => Datasheet | undefined;
|
|
1422
1506
|
};
|
|
1423
1507
|
type DbClient = ReturnType<typeof createDatabase>;
|
|
1424
1508
|
|
package/dist/index.js
CHANGED
|
@@ -122,6 +122,7 @@ var orderQuoteSchema = z.object({
|
|
|
122
122
|
});
|
|
123
123
|
var aiReviewSchema = z.object({
|
|
124
124
|
ai_review_id: z.string().uuid(),
|
|
125
|
+
package_release_id: z.string().optional(),
|
|
125
126
|
ai_review_text: z.string().nullable(),
|
|
126
127
|
start_processing_at: z.string().datetime().nullable(),
|
|
127
128
|
finished_processing_at: z.string().datetime().nullable(),
|
|
@@ -129,6 +130,19 @@ var aiReviewSchema = z.object({
|
|
|
129
130
|
created_at: z.string().datetime(),
|
|
130
131
|
display_status: z.enum(["pending", "completed", "failed"])
|
|
131
132
|
});
|
|
133
|
+
var datasheetPinInformationSchema = z.object({
|
|
134
|
+
pin_number: z.string(),
|
|
135
|
+
name: z.string(),
|
|
136
|
+
description: z.string(),
|
|
137
|
+
capabilities: z.array(z.string())
|
|
138
|
+
});
|
|
139
|
+
var datasheetSchema = z.object({
|
|
140
|
+
datasheet_id: z.string(),
|
|
141
|
+
chip_name: z.string(),
|
|
142
|
+
created_at: z.string(),
|
|
143
|
+
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
144
|
+
datasheet_pdf_urls: z.array(z.string()).nullable()
|
|
145
|
+
});
|
|
132
146
|
var accountSnippetSchema = z.object({
|
|
133
147
|
account_id: z.string(),
|
|
134
148
|
snippet_id: z.string(),
|
|
@@ -274,7 +288,8 @@ var databaseSchema = z.object({
|
|
|
274
288
|
jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
|
|
275
289
|
jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
|
|
276
290
|
orderQuotes: z.array(orderQuoteSchema).default([]),
|
|
277
|
-
aiReviews: z.array(aiReviewSchema).default([])
|
|
291
|
+
aiReviews: z.array(aiReviewSchema).default([]),
|
|
292
|
+
datasheets: z.array(datasheetSchema).default([])
|
|
278
293
|
});
|
|
279
294
|
|
|
280
295
|
// fake-snippets-api/lib/db/autoload-dev-packages.ts
|
|
@@ -3093,6 +3108,37 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3093
3108
|
listAiReviews: () => {
|
|
3094
3109
|
const state = get();
|
|
3095
3110
|
return state.aiReviews;
|
|
3111
|
+
},
|
|
3112
|
+
addDatasheet: ({ chip_name }) => {
|
|
3113
|
+
const newDatasheet = datasheetSchema.parse({
|
|
3114
|
+
datasheet_id: `datasheet_${Date.now()}`,
|
|
3115
|
+
chip_name,
|
|
3116
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3117
|
+
pin_information: null,
|
|
3118
|
+
datasheet_pdf_urls: null
|
|
3119
|
+
});
|
|
3120
|
+
set((state) => ({
|
|
3121
|
+
datasheets: [...state.datasheets, newDatasheet]
|
|
3122
|
+
}));
|
|
3123
|
+
return newDatasheet;
|
|
3124
|
+
},
|
|
3125
|
+
getDatasheetById: (datasheetId) => {
|
|
3126
|
+
const state = get();
|
|
3127
|
+
return state.datasheets.find((d) => d.datasheet_id === datasheetId);
|
|
3128
|
+
},
|
|
3129
|
+
updateDatasheet: (datasheetId, updates) => {
|
|
3130
|
+
let updated;
|
|
3131
|
+
set((state) => {
|
|
3132
|
+
const index = state.datasheets.findIndex(
|
|
3133
|
+
(d) => d.datasheet_id === datasheetId
|
|
3134
|
+
);
|
|
3135
|
+
if (index === -1) return state;
|
|
3136
|
+
const datasheets = [...state.datasheets];
|
|
3137
|
+
datasheets[index] = { ...datasheets[index], ...updates };
|
|
3138
|
+
updated = datasheets[index];
|
|
3139
|
+
return { ...state, datasheets };
|
|
3140
|
+
});
|
|
3141
|
+
return updated;
|
|
3096
3142
|
}
|
|
3097
3143
|
}));
|
|
3098
3144
|
|
package/dist/schema.d.ts
CHANGED
|
@@ -491,6 +491,7 @@ declare const orderQuoteSchema: z.ZodObject<{
|
|
|
491
491
|
type OrderQuote = z.infer<typeof orderQuoteSchema>;
|
|
492
492
|
declare const aiReviewSchema: z.ZodObject<{
|
|
493
493
|
ai_review_id: z.ZodString;
|
|
494
|
+
package_release_id: z.ZodOptional<z.ZodString>;
|
|
494
495
|
ai_review_text: z.ZodNullable<z.ZodString>;
|
|
495
496
|
start_processing_at: z.ZodNullable<z.ZodString>;
|
|
496
497
|
finished_processing_at: z.ZodNullable<z.ZodString>;
|
|
@@ -504,6 +505,7 @@ declare const aiReviewSchema: z.ZodObject<{
|
|
|
504
505
|
start_processing_at: string | null;
|
|
505
506
|
finished_processing_at: string | null;
|
|
506
507
|
display_status: "pending" | "completed" | "failed";
|
|
508
|
+
package_release_id?: string | undefined;
|
|
507
509
|
processing_error?: any;
|
|
508
510
|
}, {
|
|
509
511
|
created_at: string;
|
|
@@ -512,9 +514,71 @@ declare const aiReviewSchema: z.ZodObject<{
|
|
|
512
514
|
start_processing_at: string | null;
|
|
513
515
|
finished_processing_at: string | null;
|
|
514
516
|
display_status: "pending" | "completed" | "failed";
|
|
517
|
+
package_release_id?: string | undefined;
|
|
515
518
|
processing_error?: any;
|
|
516
519
|
}>;
|
|
517
520
|
type AiReview = z.infer<typeof aiReviewSchema>;
|
|
521
|
+
declare const datasheetPinInformationSchema: z.ZodObject<{
|
|
522
|
+
pin_number: z.ZodString;
|
|
523
|
+
name: z.ZodString;
|
|
524
|
+
description: z.ZodString;
|
|
525
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
526
|
+
}, "strip", z.ZodTypeAny, {
|
|
527
|
+
name: string;
|
|
528
|
+
description: string;
|
|
529
|
+
pin_number: string;
|
|
530
|
+
capabilities: string[];
|
|
531
|
+
}, {
|
|
532
|
+
name: string;
|
|
533
|
+
description: string;
|
|
534
|
+
pin_number: string;
|
|
535
|
+
capabilities: string[];
|
|
536
|
+
}>;
|
|
537
|
+
declare const datasheetSchema: z.ZodObject<{
|
|
538
|
+
datasheet_id: z.ZodString;
|
|
539
|
+
chip_name: z.ZodString;
|
|
540
|
+
created_at: z.ZodString;
|
|
541
|
+
pin_information: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
542
|
+
pin_number: z.ZodString;
|
|
543
|
+
name: z.ZodString;
|
|
544
|
+
description: z.ZodString;
|
|
545
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
546
|
+
}, "strip", z.ZodTypeAny, {
|
|
547
|
+
name: string;
|
|
548
|
+
description: string;
|
|
549
|
+
pin_number: string;
|
|
550
|
+
capabilities: string[];
|
|
551
|
+
}, {
|
|
552
|
+
name: string;
|
|
553
|
+
description: string;
|
|
554
|
+
pin_number: string;
|
|
555
|
+
capabilities: string[];
|
|
556
|
+
}>, "many">>;
|
|
557
|
+
datasheet_pdf_urls: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
558
|
+
}, "strip", z.ZodTypeAny, {
|
|
559
|
+
created_at: string;
|
|
560
|
+
datasheet_id: string;
|
|
561
|
+
chip_name: string;
|
|
562
|
+
pin_information: {
|
|
563
|
+
name: string;
|
|
564
|
+
description: string;
|
|
565
|
+
pin_number: string;
|
|
566
|
+
capabilities: string[];
|
|
567
|
+
}[] | null;
|
|
568
|
+
datasheet_pdf_urls: string[] | null;
|
|
569
|
+
}, {
|
|
570
|
+
created_at: string;
|
|
571
|
+
datasheet_id: string;
|
|
572
|
+
chip_name: string;
|
|
573
|
+
pin_information: {
|
|
574
|
+
name: string;
|
|
575
|
+
description: string;
|
|
576
|
+
pin_number: string;
|
|
577
|
+
capabilities: string[];
|
|
578
|
+
}[] | null;
|
|
579
|
+
datasheet_pdf_urls: string[] | null;
|
|
580
|
+
}>;
|
|
581
|
+
type Datasheet = z.infer<typeof datasheetSchema>;
|
|
518
582
|
declare const accountSnippetSchema: z.ZodObject<{
|
|
519
583
|
account_id: z.ZodString;
|
|
520
584
|
snippet_id: z.ZodString;
|
|
@@ -1623,6 +1687,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1623
1687
|
}>, "many">>;
|
|
1624
1688
|
aiReviews: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1625
1689
|
ai_review_id: z.ZodString;
|
|
1690
|
+
package_release_id: z.ZodOptional<z.ZodString>;
|
|
1626
1691
|
ai_review_text: z.ZodNullable<z.ZodString>;
|
|
1627
1692
|
start_processing_at: z.ZodNullable<z.ZodString>;
|
|
1628
1693
|
finished_processing_at: z.ZodNullable<z.ZodString>;
|
|
@@ -1636,6 +1701,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1636
1701
|
start_processing_at: string | null;
|
|
1637
1702
|
finished_processing_at: string | null;
|
|
1638
1703
|
display_status: "pending" | "completed" | "failed";
|
|
1704
|
+
package_release_id?: string | undefined;
|
|
1639
1705
|
processing_error?: any;
|
|
1640
1706
|
}, {
|
|
1641
1707
|
created_at: string;
|
|
@@ -1644,8 +1710,53 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1644
1710
|
start_processing_at: string | null;
|
|
1645
1711
|
finished_processing_at: string | null;
|
|
1646
1712
|
display_status: "pending" | "completed" | "failed";
|
|
1713
|
+
package_release_id?: string | undefined;
|
|
1647
1714
|
processing_error?: any;
|
|
1648
1715
|
}>, "many">>;
|
|
1716
|
+
datasheets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1717
|
+
datasheet_id: z.ZodString;
|
|
1718
|
+
chip_name: z.ZodString;
|
|
1719
|
+
created_at: z.ZodString;
|
|
1720
|
+
pin_information: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1721
|
+
pin_number: z.ZodString;
|
|
1722
|
+
name: z.ZodString;
|
|
1723
|
+
description: z.ZodString;
|
|
1724
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
1725
|
+
}, "strip", z.ZodTypeAny, {
|
|
1726
|
+
name: string;
|
|
1727
|
+
description: string;
|
|
1728
|
+
pin_number: string;
|
|
1729
|
+
capabilities: string[];
|
|
1730
|
+
}, {
|
|
1731
|
+
name: string;
|
|
1732
|
+
description: string;
|
|
1733
|
+
pin_number: string;
|
|
1734
|
+
capabilities: string[];
|
|
1735
|
+
}>, "many">>;
|
|
1736
|
+
datasheet_pdf_urls: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
1737
|
+
}, "strip", z.ZodTypeAny, {
|
|
1738
|
+
created_at: string;
|
|
1739
|
+
datasheet_id: string;
|
|
1740
|
+
chip_name: string;
|
|
1741
|
+
pin_information: {
|
|
1742
|
+
name: string;
|
|
1743
|
+
description: string;
|
|
1744
|
+
pin_number: string;
|
|
1745
|
+
capabilities: string[];
|
|
1746
|
+
}[] | null;
|
|
1747
|
+
datasheet_pdf_urls: string[] | null;
|
|
1748
|
+
}, {
|
|
1749
|
+
created_at: string;
|
|
1750
|
+
datasheet_id: string;
|
|
1751
|
+
chip_name: string;
|
|
1752
|
+
pin_information: {
|
|
1753
|
+
name: string;
|
|
1754
|
+
description: string;
|
|
1755
|
+
pin_number: string;
|
|
1756
|
+
capabilities: string[];
|
|
1757
|
+
}[] | null;
|
|
1758
|
+
datasheet_pdf_urls: string[] | null;
|
|
1759
|
+
}>, "many">>;
|
|
1649
1760
|
}, "strip", z.ZodTypeAny, {
|
|
1650
1761
|
idCounter: number;
|
|
1651
1762
|
snippets: {
|
|
@@ -1891,8 +2002,21 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1891
2002
|
start_processing_at: string | null;
|
|
1892
2003
|
finished_processing_at: string | null;
|
|
1893
2004
|
display_status: "pending" | "completed" | "failed";
|
|
2005
|
+
package_release_id?: string | undefined;
|
|
1894
2006
|
processing_error?: any;
|
|
1895
2007
|
}[];
|
|
2008
|
+
datasheets: {
|
|
2009
|
+
created_at: string;
|
|
2010
|
+
datasheet_id: string;
|
|
2011
|
+
chip_name: string;
|
|
2012
|
+
pin_information: {
|
|
2013
|
+
name: string;
|
|
2014
|
+
description: string;
|
|
2015
|
+
pin_number: string;
|
|
2016
|
+
capabilities: string[];
|
|
2017
|
+
}[] | null;
|
|
2018
|
+
datasheet_pdf_urls: string[] | null;
|
|
2019
|
+
}[];
|
|
1896
2020
|
}, {
|
|
1897
2021
|
idCounter?: number | undefined;
|
|
1898
2022
|
snippets?: {
|
|
@@ -2138,9 +2262,22 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2138
2262
|
start_processing_at: string | null;
|
|
2139
2263
|
finished_processing_at: string | null;
|
|
2140
2264
|
display_status: "pending" | "completed" | "failed";
|
|
2265
|
+
package_release_id?: string | undefined;
|
|
2141
2266
|
processing_error?: any;
|
|
2142
2267
|
}[] | undefined;
|
|
2268
|
+
datasheets?: {
|
|
2269
|
+
created_at: string;
|
|
2270
|
+
datasheet_id: string;
|
|
2271
|
+
chip_name: string;
|
|
2272
|
+
pin_information: {
|
|
2273
|
+
name: string;
|
|
2274
|
+
description: string;
|
|
2275
|
+
pin_number: string;
|
|
2276
|
+
capabilities: string[];
|
|
2277
|
+
}[] | null;
|
|
2278
|
+
datasheet_pdf_urls: string[] | null;
|
|
2279
|
+
}[] | undefined;
|
|
2143
2280
|
}>;
|
|
2144
2281
|
type DatabaseSchema = z.infer<typeof databaseSchema>;
|
|
2145
2282
|
|
|
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 };
|
|
2283
|
+
export { type Account, type AccountPackage, type AccountSnippet, type AiReview, type DatabaseSchema, type Datasheet, 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, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, packageFileSchema, packageReleaseSchema, packageSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema };
|
package/dist/schema.js
CHANGED
|
@@ -117,6 +117,7 @@ var orderQuoteSchema = z.object({
|
|
|
117
117
|
});
|
|
118
118
|
var aiReviewSchema = z.object({
|
|
119
119
|
ai_review_id: z.string().uuid(),
|
|
120
|
+
package_release_id: z.string().optional(),
|
|
120
121
|
ai_review_text: z.string().nullable(),
|
|
121
122
|
start_processing_at: z.string().datetime().nullable(),
|
|
122
123
|
finished_processing_at: z.string().datetime().nullable(),
|
|
@@ -124,6 +125,19 @@ var aiReviewSchema = z.object({
|
|
|
124
125
|
created_at: z.string().datetime(),
|
|
125
126
|
display_status: z.enum(["pending", "completed", "failed"])
|
|
126
127
|
});
|
|
128
|
+
var datasheetPinInformationSchema = z.object({
|
|
129
|
+
pin_number: z.string(),
|
|
130
|
+
name: z.string(),
|
|
131
|
+
description: z.string(),
|
|
132
|
+
capabilities: z.array(z.string())
|
|
133
|
+
});
|
|
134
|
+
var datasheetSchema = z.object({
|
|
135
|
+
datasheet_id: z.string(),
|
|
136
|
+
chip_name: z.string(),
|
|
137
|
+
created_at: z.string(),
|
|
138
|
+
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
139
|
+
datasheet_pdf_urls: z.array(z.string()).nullable()
|
|
140
|
+
});
|
|
127
141
|
var accountSnippetSchema = z.object({
|
|
128
142
|
account_id: z.string(),
|
|
129
143
|
snippet_id: z.string(),
|
|
@@ -269,7 +283,8 @@ var databaseSchema = z.object({
|
|
|
269
283
|
jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
|
|
270
284
|
jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
|
|
271
285
|
orderQuotes: z.array(orderQuoteSchema).default([]),
|
|
272
|
-
aiReviews: z.array(aiReviewSchema).default([])
|
|
286
|
+
aiReviews: z.array(aiReviewSchema).default([]),
|
|
287
|
+
datasheets: z.array(datasheetSchema).default([])
|
|
273
288
|
});
|
|
274
289
|
export {
|
|
275
290
|
accountPackageSchema,
|
|
@@ -277,6 +292,8 @@ export {
|
|
|
277
292
|
accountSnippetSchema,
|
|
278
293
|
aiReviewSchema,
|
|
279
294
|
databaseSchema,
|
|
295
|
+
datasheetPinInformationSchema,
|
|
296
|
+
datasheetSchema,
|
|
280
297
|
errorResponseSchema,
|
|
281
298
|
errorSchema,
|
|
282
299
|
jlcpcbOrderStateSchema,
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
packageReleaseSchema,
|
|
19
19
|
type AiReview,
|
|
20
20
|
aiReviewSchema,
|
|
21
|
+
type Datasheet,
|
|
22
|
+
datasheetSchema,
|
|
21
23
|
type Session,
|
|
22
24
|
type Snippet,
|
|
23
25
|
databaseSchema,
|
|
@@ -1378,4 +1380,38 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
1378
1380
|
const state = get()
|
|
1379
1381
|
return state.aiReviews
|
|
1380
1382
|
},
|
|
1383
|
+
addDatasheet: ({ chip_name }: { chip_name: string }): Datasheet => {
|
|
1384
|
+
const newDatasheet = datasheetSchema.parse({
|
|
1385
|
+
datasheet_id: `datasheet_${Date.now()}`,
|
|
1386
|
+
chip_name,
|
|
1387
|
+
created_at: new Date().toISOString(),
|
|
1388
|
+
pin_information: null,
|
|
1389
|
+
datasheet_pdf_urls: null,
|
|
1390
|
+
})
|
|
1391
|
+
set((state) => ({
|
|
1392
|
+
datasheets: [...state.datasheets, newDatasheet],
|
|
1393
|
+
}))
|
|
1394
|
+
return newDatasheet
|
|
1395
|
+
},
|
|
1396
|
+
getDatasheetById: (datasheetId: string): Datasheet | undefined => {
|
|
1397
|
+
const state = get()
|
|
1398
|
+
return state.datasheets.find((d) => d.datasheet_id === datasheetId)
|
|
1399
|
+
},
|
|
1400
|
+
updateDatasheet: (
|
|
1401
|
+
datasheetId: string,
|
|
1402
|
+
updates: Partial<Datasheet>,
|
|
1403
|
+
): Datasheet | undefined => {
|
|
1404
|
+
let updated: Datasheet | undefined
|
|
1405
|
+
set((state) => {
|
|
1406
|
+
const index = state.datasheets.findIndex(
|
|
1407
|
+
(d) => d.datasheet_id === datasheetId,
|
|
1408
|
+
)
|
|
1409
|
+
if (index === -1) return state
|
|
1410
|
+
const datasheets = [...state.datasheets]
|
|
1411
|
+
datasheets[index] = { ...datasheets[index], ...updates }
|
|
1412
|
+
updated = datasheets[index]
|
|
1413
|
+
return { ...state, datasheets }
|
|
1414
|
+
})
|
|
1415
|
+
return updated
|
|
1416
|
+
},
|
|
1381
1417
|
}))
|
|
@@ -140,6 +140,7 @@ export type OrderQuote = z.infer<typeof orderQuoteSchema>
|
|
|
140
140
|
|
|
141
141
|
export const aiReviewSchema = z.object({
|
|
142
142
|
ai_review_id: z.string().uuid(),
|
|
143
|
+
package_release_id: z.string().optional(),
|
|
143
144
|
ai_review_text: z.string().nullable(),
|
|
144
145
|
start_processing_at: z.string().datetime().nullable(),
|
|
145
146
|
finished_processing_at: z.string().datetime().nullable(),
|
|
@@ -149,6 +150,22 @@ export const aiReviewSchema = z.object({
|
|
|
149
150
|
})
|
|
150
151
|
export type AiReview = z.infer<typeof aiReviewSchema>
|
|
151
152
|
|
|
153
|
+
export const datasheetPinInformationSchema = z.object({
|
|
154
|
+
pin_number: z.string(),
|
|
155
|
+
name: z.string(),
|
|
156
|
+
description: z.string(),
|
|
157
|
+
capabilities: z.array(z.string()),
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
export const datasheetSchema = z.object({
|
|
161
|
+
datasheet_id: z.string(),
|
|
162
|
+
chip_name: z.string(),
|
|
163
|
+
created_at: z.string(),
|
|
164
|
+
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
165
|
+
datasheet_pdf_urls: z.array(z.string()).nullable(),
|
|
166
|
+
})
|
|
167
|
+
export type Datasheet = z.infer<typeof datasheetSchema>
|
|
168
|
+
|
|
152
169
|
// TODO: Remove this schema after migration to accountPackages is complete
|
|
153
170
|
export const accountSnippetSchema = z.object({
|
|
154
171
|
account_id: z.string(),
|
|
@@ -326,5 +343,6 @@ export const databaseSchema = z.object({
|
|
|
326
343
|
jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
|
|
327
344
|
orderQuotes: z.array(orderQuoteSchema).default([]),
|
|
328
345
|
aiReviews: z.array(aiReviewSchema).default([]),
|
|
346
|
+
datasheets: z.array(datasheetSchema).default([]),
|
|
329
347
|
})
|
|
330
348
|
export type DatabaseSchema = z.infer<typeof databaseSchema>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as ZT from "fake-snippets-api/lib/db/schema"
|
|
2
|
+
import type { DbClient } from "fake-snippets-api/lib/db/db-client"
|
|
2
3
|
|
|
3
4
|
export const publicMapPackageRelease = (
|
|
4
5
|
internal_package_release: ZT.PackageRelease,
|
|
5
6
|
options: {
|
|
6
7
|
include_logs?: boolean
|
|
7
8
|
include_ai_review?: boolean
|
|
9
|
+
db?: DbClient
|
|
8
10
|
} = {
|
|
9
11
|
include_logs: false,
|
|
10
12
|
include_ai_review: false,
|
|
@@ -24,6 +26,27 @@ export const publicMapPackageRelease = (
|
|
|
24
26
|
: [],
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
if (options.include_ai_review && options.db) {
|
|
30
|
+
const reviews = options.db
|
|
31
|
+
.listAiReviews()
|
|
32
|
+
.filter(
|
|
33
|
+
(r) =>
|
|
34
|
+
r.package_release_id === internal_package_release.package_release_id,
|
|
35
|
+
)
|
|
36
|
+
.sort(
|
|
37
|
+
(a, b) =>
|
|
38
|
+
new Date(b.created_at).getTime() - new Date(a.created_at).getTime(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
if (reviews.length > 0) {
|
|
42
|
+
const latest = reviews[0]
|
|
43
|
+
result.ai_review_text = latest.ai_review_text ?? null
|
|
44
|
+
result.ai_review_started_at = latest.start_processing_at ?? null
|
|
45
|
+
result.ai_review_completed_at = latest.finished_processing_at ?? null
|
|
46
|
+
result.ai_review_error = latest.processing_error ?? null
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
27
50
|
// Only include AI review fields when include_ai_review is true
|
|
28
51
|
if (!options.include_ai_review) {
|
|
29
52
|
delete result.ai_review_text
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { datasheetSchema } from "fake-snippets-api/lib/db/schema"
|
|
2
|
+
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
export const processAllDatasheets = (ctx: any) => {
|
|
6
|
+
const processed = [] as z.infer<typeof datasheetSchema>[]
|
|
7
|
+
ctx.db.datasheets.forEach((ds: any) => {
|
|
8
|
+
if (!ds.pin_information || !ds.datasheet_pdf_urls) {
|
|
9
|
+
const updated = ctx.db.updateDatasheet(ds.datasheet_id, {
|
|
10
|
+
pin_information: [
|
|
11
|
+
{
|
|
12
|
+
pin_number: "1",
|
|
13
|
+
name: "PIN1",
|
|
14
|
+
description: "Placeholder pin",
|
|
15
|
+
capabilities: ["digital"],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
datasheet_pdf_urls: ["https://example.com/datasheet.pdf"],
|
|
19
|
+
})
|
|
20
|
+
processed.push(updated!)
|
|
21
|
+
} else {
|
|
22
|
+
processed.push(ds)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
return processed
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default withRouteSpec({
|
|
29
|
+
methods: ["POST"],
|
|
30
|
+
auth: "none",
|
|
31
|
+
jsonResponse: z.object({
|
|
32
|
+
datasheets: datasheetSchema.array(),
|
|
33
|
+
}),
|
|
34
|
+
})(async (req, ctx) => {
|
|
35
|
+
const datasheets = processAllDatasheets(ctx)
|
|
36
|
+
return ctx.json({ datasheets })
|
|
37
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
import { processAllDatasheets } from "./datasheets/process_all_datasheets"
|
|
4
|
+
|
|
5
|
+
export default withRouteSpec({
|
|
6
|
+
methods: ["GET"],
|
|
7
|
+
auth: "none",
|
|
8
|
+
jsonResponse: z.object({ ok: z.boolean() }),
|
|
9
|
+
})(async (req, ctx) => {
|
|
10
|
+
processAllDatasheets(ctx)
|
|
11
|
+
return ctx.json({ ok: true })
|
|
12
|
+
})
|
|
@@ -5,11 +5,31 @@ import { aiReviewSchema } from "fake-snippets-api/lib/db/schema"
|
|
|
5
5
|
export default withRouteSpec({
|
|
6
6
|
methods: ["POST"],
|
|
7
7
|
auth: "session",
|
|
8
|
+
queryParams: z.object({
|
|
9
|
+
package_release_id: z.string().optional(),
|
|
10
|
+
}),
|
|
8
11
|
jsonResponse: z.object({
|
|
9
12
|
ai_review: aiReviewSchema,
|
|
10
13
|
}),
|
|
11
14
|
})(async (req, ctx) => {
|
|
15
|
+
const { package_release_id } = req.query
|
|
16
|
+
|
|
17
|
+
if (package_release_id) {
|
|
18
|
+
const release = ctx.db.getPackageReleaseById(package_release_id)
|
|
19
|
+
if (!release) {
|
|
20
|
+
return ctx.error(404, {
|
|
21
|
+
error_code: "package_release_not_found",
|
|
22
|
+
message: "Package release not found",
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
ctx.db.updatePackageRelease({
|
|
26
|
+
...release,
|
|
27
|
+
ai_review_requested: true,
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
12
31
|
const ai_review = ctx.db.addAiReview({
|
|
32
|
+
package_release_id: package_release_id,
|
|
13
33
|
ai_review_text: null,
|
|
14
34
|
start_processing_at: null,
|
|
15
35
|
finished_processing_at: null,
|