@tscircuit/fake-snippets 0.0.117 → 0.0.119
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/orgs/get_member.test.ts +110 -0
- package/bun-tests/fake-snippets-api/routes/orgs/list_members.test.ts +4 -3
- package/bun-tests/fake-snippets-api/routes/packages/get.test.ts +3 -0
- package/bun.lock +2 -2
- package/dist/bundle.js +482 -374
- package/dist/index.d.ts +30 -0
- package/dist/index.js +17 -6
- package/dist/schema.d.ts +60 -1
- package/dist/schema.js +16 -7
- package/fake-snippets-api/lib/db/db-client.ts +9 -0
- package/fake-snippets-api/lib/db/schema.ts +15 -6
- package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +6 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package.ts +9 -0
- package/fake-snippets-api/routes/api/orgs/get_member.ts +67 -0
- package/fake-snippets-api/routes/api/orgs/list_members.ts +40 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -538,6 +538,9 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
538
538
|
branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
539
539
|
commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
540
540
|
commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
541
|
+
pcb_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
542
|
+
sch_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
543
|
+
cad_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
541
544
|
}, "strip", z.ZodTypeAny, {
|
|
542
545
|
package_release_id: string;
|
|
543
546
|
created_at: string;
|
|
@@ -561,6 +564,9 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
561
564
|
image_generation_is_stale: boolean;
|
|
562
565
|
ai_review_requested: boolean;
|
|
563
566
|
is_pr_preview: boolean;
|
|
567
|
+
pcb_preview_image_url: string | null;
|
|
568
|
+
sch_preview_image_url: string | null;
|
|
569
|
+
cad_preview_image_url: string | null;
|
|
564
570
|
ai_review_text?: string | null | undefined;
|
|
565
571
|
commit_sha?: string | null | undefined;
|
|
566
572
|
license?: string | null | undefined;
|
|
@@ -634,6 +640,9 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
634
640
|
branch_name?: string | null | undefined;
|
|
635
641
|
commit_message?: string | null | undefined;
|
|
636
642
|
commit_author?: string | null | undefined;
|
|
643
|
+
pcb_preview_image_url?: string | null | undefined;
|
|
644
|
+
sch_preview_image_url?: string | null | undefined;
|
|
645
|
+
cad_preview_image_url?: string | null | undefined;
|
|
637
646
|
}>;
|
|
638
647
|
type PackageRelease = z.infer<typeof packageReleaseSchema>;
|
|
639
648
|
declare const packageFileSchema: z.ZodObject<{
|
|
@@ -698,6 +707,9 @@ declare const packageSchema: z.ZodObject<{
|
|
|
698
707
|
default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
|
|
699
708
|
allow_pr_previews: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
700
709
|
is_starred: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
710
|
+
latest_pcb_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
711
|
+
latest_sch_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
712
|
+
latest_cad_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
701
713
|
}, "strip", z.ZodTypeAny, {
|
|
702
714
|
name: string;
|
|
703
715
|
unscoped_name: string;
|
|
@@ -731,6 +743,9 @@ declare const packageSchema: z.ZodObject<{
|
|
|
731
743
|
latest_license?: string | null | undefined;
|
|
732
744
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
733
745
|
allow_pr_previews?: boolean | undefined;
|
|
746
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
747
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
748
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
734
749
|
}, {
|
|
735
750
|
name: string;
|
|
736
751
|
unscoped_name: string;
|
|
@@ -764,6 +779,9 @@ declare const packageSchema: z.ZodObject<{
|
|
|
764
779
|
latest_package_release_fs_sha?: string | null | undefined;
|
|
765
780
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
766
781
|
allow_pr_previews?: boolean | undefined;
|
|
782
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
783
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
784
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
767
785
|
}>;
|
|
768
786
|
type Package = z.infer<typeof packageSchema>;
|
|
769
787
|
declare const jlcpcbOrderStateSchema: z.ZodObject<{
|
|
@@ -1044,6 +1062,9 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1044
1062
|
image_generation_is_stale: boolean;
|
|
1045
1063
|
ai_review_requested: boolean;
|
|
1046
1064
|
is_pr_preview: boolean;
|
|
1065
|
+
pcb_preview_image_url: string | null;
|
|
1066
|
+
sch_preview_image_url: string | null;
|
|
1067
|
+
cad_preview_image_url: string | null;
|
|
1047
1068
|
ai_review_text?: string | null | undefined;
|
|
1048
1069
|
commit_sha?: string | null | undefined;
|
|
1049
1070
|
license?: string | null | undefined;
|
|
@@ -1145,6 +1166,9 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1145
1166
|
latest_license?: string | null | undefined;
|
|
1146
1167
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1147
1168
|
allow_pr_previews?: boolean | undefined;
|
|
1169
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
1170
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
1171
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
1148
1172
|
}[];
|
|
1149
1173
|
orders: {
|
|
1150
1174
|
error: z.objectOutputType<{
|
|
@@ -1558,6 +1582,9 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1558
1582
|
image_generation_is_stale: boolean;
|
|
1559
1583
|
ai_review_requested: boolean;
|
|
1560
1584
|
is_pr_preview: boolean;
|
|
1585
|
+
pcb_preview_image_url: string | null;
|
|
1586
|
+
sch_preview_image_url: string | null;
|
|
1587
|
+
cad_preview_image_url: string | null;
|
|
1561
1588
|
ai_review_text?: string | null | undefined;
|
|
1562
1589
|
commit_sha?: string | null | undefined;
|
|
1563
1590
|
license?: string | null | undefined;
|
|
@@ -1659,6 +1686,9 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1659
1686
|
latest_license?: string | null | undefined;
|
|
1660
1687
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1661
1688
|
allow_pr_previews?: boolean | undefined;
|
|
1689
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
1690
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
1691
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
1662
1692
|
}[];
|
|
1663
1693
|
orders: {
|
|
1664
1694
|
error: z.objectOutputType<{
|
package/dist/index.js
CHANGED
|
@@ -228,7 +228,11 @@ var packageReleaseSchema = z.object({
|
|
|
228
228
|
latest_package_build_id: z.string().nullable().optional(),
|
|
229
229
|
branch_name: z.string().nullable().optional(),
|
|
230
230
|
commit_message: z.string().nullable().optional(),
|
|
231
|
-
commit_author: z.string().nullable().optional()
|
|
231
|
+
commit_author: z.string().nullable().optional(),
|
|
232
|
+
// Preview images url
|
|
233
|
+
pcb_preview_image_url: z.string().nullable().default(null),
|
|
234
|
+
sch_preview_image_url: z.string().nullable().default(null),
|
|
235
|
+
cad_preview_image_url: z.string().nullable().default(null)
|
|
232
236
|
});
|
|
233
237
|
var packageFileSchema = z.object({
|
|
234
238
|
package_file_id: z.string(),
|
|
@@ -272,7 +276,10 @@ var packageSchema = z.object({
|
|
|
272
276
|
latest_package_release_fs_sha: z.string().nullable().default(null),
|
|
273
277
|
default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional(),
|
|
274
278
|
allow_pr_previews: z.boolean().default(false).optional(),
|
|
275
|
-
is_starred: z.boolean().default(false).optional()
|
|
279
|
+
is_starred: z.boolean().default(false).optional(),
|
|
280
|
+
latest_pcb_preview_image_url: z.string().nullable().optional(),
|
|
281
|
+
latest_sch_preview_image_url: z.string().nullable().optional(),
|
|
282
|
+
latest_cad_preview_image_url: z.string().nullable().optional()
|
|
276
283
|
});
|
|
277
284
|
var jlcpcbOrderStateSchema = z.object({
|
|
278
285
|
jlcpcb_order_state_id: z.string(),
|
|
@@ -351,6 +358,10 @@ var orgAccountSchema = z.object({
|
|
|
351
358
|
is_owner: z.boolean().default(false),
|
|
352
359
|
created_at: z.string().datetime()
|
|
353
360
|
});
|
|
361
|
+
var userPermissionsSchema = z.object({
|
|
362
|
+
can_manage_org: z.boolean().optional(),
|
|
363
|
+
can_manage_package: z.boolean().optional()
|
|
364
|
+
});
|
|
354
365
|
var publicOrgSchema = z.object({
|
|
355
366
|
org_id: z.string(),
|
|
356
367
|
//.uuid(),
|
|
@@ -363,10 +374,7 @@ var publicOrgSchema = z.object({
|
|
|
363
374
|
package_count: z.number(),
|
|
364
375
|
github_handle: z.string().optional(),
|
|
365
376
|
created_at: z.string(),
|
|
366
|
-
user_permissions:
|
|
367
|
-
can_manage_org: z.boolean().optional(),
|
|
368
|
-
can_manage_package: z.boolean().optional()
|
|
369
|
-
}).optional()
|
|
377
|
+
user_permissions: userPermissionsSchema.optional()
|
|
370
378
|
});
|
|
371
379
|
var databaseSchema = z.object({
|
|
372
380
|
idCounter: z.number().default(0),
|
|
@@ -3308,6 +3316,9 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3308
3316
|
const newPackage = {
|
|
3309
3317
|
package_id: `package_${timestamp}`,
|
|
3310
3318
|
github_repo_full_name: null,
|
|
3319
|
+
latest_pcb_preview_image_url: _package.latest_pcb_preview_image_url ?? `/api/packages/images/${_package.name}`,
|
|
3320
|
+
latest_cad_preview_image_url: _package.latest_cad_preview_image_url ?? `/api/packages/images/${_package.name}`,
|
|
3321
|
+
latest_sch_preview_image_url: _package.latest_sch_preview_image_url ?? `/api/packages/images/${_package.name}`,
|
|
3311
3322
|
..._package
|
|
3312
3323
|
};
|
|
3313
3324
|
set((state) => ({
|
package/dist/schema.d.ts
CHANGED
|
@@ -711,6 +711,9 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
711
711
|
branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
712
712
|
commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
713
713
|
commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
714
|
+
pcb_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
715
|
+
sch_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
716
|
+
cad_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
714
717
|
}, "strip", z.ZodTypeAny, {
|
|
715
718
|
package_release_id: string;
|
|
716
719
|
created_at: string;
|
|
@@ -734,6 +737,9 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
734
737
|
image_generation_is_stale: boolean;
|
|
735
738
|
ai_review_requested: boolean;
|
|
736
739
|
is_pr_preview: boolean;
|
|
740
|
+
pcb_preview_image_url: string | null;
|
|
741
|
+
sch_preview_image_url: string | null;
|
|
742
|
+
cad_preview_image_url: string | null;
|
|
737
743
|
ai_review_text?: string | null | undefined;
|
|
738
744
|
commit_sha?: string | null | undefined;
|
|
739
745
|
license?: string | null | undefined;
|
|
@@ -807,6 +813,9 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
807
813
|
branch_name?: string | null | undefined;
|
|
808
814
|
commit_message?: string | null | undefined;
|
|
809
815
|
commit_author?: string | null | undefined;
|
|
816
|
+
pcb_preview_image_url?: string | null | undefined;
|
|
817
|
+
sch_preview_image_url?: string | null | undefined;
|
|
818
|
+
cad_preview_image_url?: string | null | undefined;
|
|
810
819
|
}>;
|
|
811
820
|
type PackageRelease = z.infer<typeof packageReleaseSchema>;
|
|
812
821
|
declare const packageFileSchema: z.ZodObject<{
|
|
@@ -871,6 +880,9 @@ declare const packageSchema: z.ZodObject<{
|
|
|
871
880
|
default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
|
|
872
881
|
allow_pr_previews: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
873
882
|
is_starred: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
883
|
+
latest_pcb_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
884
|
+
latest_sch_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
885
|
+
latest_cad_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
874
886
|
}, "strip", z.ZodTypeAny, {
|
|
875
887
|
name: string;
|
|
876
888
|
unscoped_name: string;
|
|
@@ -904,6 +916,9 @@ declare const packageSchema: z.ZodObject<{
|
|
|
904
916
|
latest_license?: string | null | undefined;
|
|
905
917
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
906
918
|
allow_pr_previews?: boolean | undefined;
|
|
919
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
920
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
921
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
907
922
|
}, {
|
|
908
923
|
name: string;
|
|
909
924
|
unscoped_name: string;
|
|
@@ -937,6 +952,9 @@ declare const packageSchema: z.ZodObject<{
|
|
|
937
952
|
latest_package_release_fs_sha?: string | null | undefined;
|
|
938
953
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
939
954
|
allow_pr_previews?: boolean | undefined;
|
|
955
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
956
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
957
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
940
958
|
}>;
|
|
941
959
|
type Package = z.infer<typeof packageSchema>;
|
|
942
960
|
declare const jlcpcbOrderStateSchema: z.ZodObject<{
|
|
@@ -1165,6 +1183,17 @@ declare const orgAccountSchema: z.ZodObject<{
|
|
|
1165
1183
|
is_owner?: boolean | undefined;
|
|
1166
1184
|
}>;
|
|
1167
1185
|
type OrgAccount = z.infer<typeof orgAccountSchema>;
|
|
1186
|
+
declare const userPermissionsSchema: z.ZodObject<{
|
|
1187
|
+
can_manage_org: z.ZodOptional<z.ZodBoolean>;
|
|
1188
|
+
can_manage_package: z.ZodOptional<z.ZodBoolean>;
|
|
1189
|
+
}, "strip", z.ZodTypeAny, {
|
|
1190
|
+
can_manage_org?: boolean | undefined;
|
|
1191
|
+
can_manage_package?: boolean | undefined;
|
|
1192
|
+
}, {
|
|
1193
|
+
can_manage_org?: boolean | undefined;
|
|
1194
|
+
can_manage_package?: boolean | undefined;
|
|
1195
|
+
}>;
|
|
1196
|
+
type UserPermissions = z.infer<typeof userPermissionsSchema>;
|
|
1168
1197
|
declare const publicOrgSchema: z.ZodObject<{
|
|
1169
1198
|
org_id: z.ZodString;
|
|
1170
1199
|
owner_account_id: z.ZodString;
|
|
@@ -1335,6 +1364,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1335
1364
|
branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1336
1365
|
commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1337
1366
|
commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1367
|
+
pcb_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1368
|
+
sch_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1369
|
+
cad_preview_image_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1338
1370
|
}, "strip", z.ZodTypeAny, {
|
|
1339
1371
|
package_release_id: string;
|
|
1340
1372
|
created_at: string;
|
|
@@ -1358,6 +1390,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1358
1390
|
image_generation_is_stale: boolean;
|
|
1359
1391
|
ai_review_requested: boolean;
|
|
1360
1392
|
is_pr_preview: boolean;
|
|
1393
|
+
pcb_preview_image_url: string | null;
|
|
1394
|
+
sch_preview_image_url: string | null;
|
|
1395
|
+
cad_preview_image_url: string | null;
|
|
1361
1396
|
ai_review_text?: string | null | undefined;
|
|
1362
1397
|
commit_sha?: string | null | undefined;
|
|
1363
1398
|
license?: string | null | undefined;
|
|
@@ -1431,6 +1466,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1431
1466
|
branch_name?: string | null | undefined;
|
|
1432
1467
|
commit_message?: string | null | undefined;
|
|
1433
1468
|
commit_author?: string | null | undefined;
|
|
1469
|
+
pcb_preview_image_url?: string | null | undefined;
|
|
1470
|
+
sch_preview_image_url?: string | null | undefined;
|
|
1471
|
+
cad_preview_image_url?: string | null | undefined;
|
|
1434
1472
|
}>, "many">>;
|
|
1435
1473
|
packageFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1436
1474
|
package_file_id: z.ZodString;
|
|
@@ -1605,6 +1643,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1605
1643
|
default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
|
|
1606
1644
|
allow_pr_previews: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1607
1645
|
is_starred: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1646
|
+
latest_pcb_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1647
|
+
latest_sch_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1648
|
+
latest_cad_preview_image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1608
1649
|
}, "strip", z.ZodTypeAny, {
|
|
1609
1650
|
name: string;
|
|
1610
1651
|
unscoped_name: string;
|
|
@@ -1638,6 +1679,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1638
1679
|
latest_license?: string | null | undefined;
|
|
1639
1680
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1640
1681
|
allow_pr_previews?: boolean | undefined;
|
|
1682
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
1683
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
1684
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
1641
1685
|
}, {
|
|
1642
1686
|
name: string;
|
|
1643
1687
|
unscoped_name: string;
|
|
@@ -1671,6 +1715,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1671
1715
|
latest_package_release_fs_sha?: string | null | undefined;
|
|
1672
1716
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1673
1717
|
allow_pr_previews?: boolean | undefined;
|
|
1718
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
1719
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
1720
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
1674
1721
|
}>, "many">>;
|
|
1675
1722
|
orders: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1676
1723
|
order_id: z.ZodString;
|
|
@@ -2288,6 +2335,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2288
2335
|
image_generation_is_stale: boolean;
|
|
2289
2336
|
ai_review_requested: boolean;
|
|
2290
2337
|
is_pr_preview: boolean;
|
|
2338
|
+
pcb_preview_image_url: string | null;
|
|
2339
|
+
sch_preview_image_url: string | null;
|
|
2340
|
+
cad_preview_image_url: string | null;
|
|
2291
2341
|
ai_review_text?: string | null | undefined;
|
|
2292
2342
|
commit_sha?: string | null | undefined;
|
|
2293
2343
|
license?: string | null | undefined;
|
|
@@ -2389,6 +2439,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2389
2439
|
latest_license?: string | null | undefined;
|
|
2390
2440
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
2391
2441
|
allow_pr_previews?: boolean | undefined;
|
|
2442
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
2443
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
2444
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
2392
2445
|
}[];
|
|
2393
2446
|
orders: {
|
|
2394
2447
|
error: z.objectOutputType<{
|
|
@@ -2647,6 +2700,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2647
2700
|
branch_name?: string | null | undefined;
|
|
2648
2701
|
commit_message?: string | null | undefined;
|
|
2649
2702
|
commit_author?: string | null | undefined;
|
|
2703
|
+
pcb_preview_image_url?: string | null | undefined;
|
|
2704
|
+
sch_preview_image_url?: string | null | undefined;
|
|
2705
|
+
cad_preview_image_url?: string | null | undefined;
|
|
2650
2706
|
}[] | undefined;
|
|
2651
2707
|
packageFiles?: {
|
|
2652
2708
|
package_release_id: string;
|
|
@@ -2723,6 +2779,9 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2723
2779
|
latest_package_release_fs_sha?: string | null | undefined;
|
|
2724
2780
|
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
2725
2781
|
allow_pr_previews?: boolean | undefined;
|
|
2782
|
+
latest_pcb_preview_image_url?: string | null | undefined;
|
|
2783
|
+
latest_sch_preview_image_url?: string | null | undefined;
|
|
2784
|
+
latest_cad_preview_image_url?: string | null | undefined;
|
|
2726
2785
|
}[] | undefined;
|
|
2727
2786
|
orders?: {
|
|
2728
2787
|
error: z.objectInputType<{
|
|
@@ -2910,4 +2969,4 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2910
2969
|
}>;
|
|
2911
2970
|
type DatabaseSchema = z.infer<typeof databaseSchema>;
|
|
2912
2971
|
|
|
2913
|
-
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, 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 };
|
|
2972
|
+
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 };
|
package/dist/schema.js
CHANGED
|
@@ -223,7 +223,11 @@ var packageReleaseSchema = z.object({
|
|
|
223
223
|
latest_package_build_id: z.string().nullable().optional(),
|
|
224
224
|
branch_name: z.string().nullable().optional(),
|
|
225
225
|
commit_message: z.string().nullable().optional(),
|
|
226
|
-
commit_author: z.string().nullable().optional()
|
|
226
|
+
commit_author: z.string().nullable().optional(),
|
|
227
|
+
// Preview images url
|
|
228
|
+
pcb_preview_image_url: z.string().nullable().default(null),
|
|
229
|
+
sch_preview_image_url: z.string().nullable().default(null),
|
|
230
|
+
cad_preview_image_url: z.string().nullable().default(null)
|
|
227
231
|
});
|
|
228
232
|
var packageFileSchema = z.object({
|
|
229
233
|
package_file_id: z.string(),
|
|
@@ -267,7 +271,10 @@ var packageSchema = z.object({
|
|
|
267
271
|
latest_package_release_fs_sha: z.string().nullable().default(null),
|
|
268
272
|
default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional(),
|
|
269
273
|
allow_pr_previews: z.boolean().default(false).optional(),
|
|
270
|
-
is_starred: z.boolean().default(false).optional()
|
|
274
|
+
is_starred: z.boolean().default(false).optional(),
|
|
275
|
+
latest_pcb_preview_image_url: z.string().nullable().optional(),
|
|
276
|
+
latest_sch_preview_image_url: z.string().nullable().optional(),
|
|
277
|
+
latest_cad_preview_image_url: z.string().nullable().optional()
|
|
271
278
|
});
|
|
272
279
|
var jlcpcbOrderStateSchema = z.object({
|
|
273
280
|
jlcpcb_order_state_id: z.string(),
|
|
@@ -346,6 +353,10 @@ var orgAccountSchema = z.object({
|
|
|
346
353
|
is_owner: z.boolean().default(false),
|
|
347
354
|
created_at: z.string().datetime()
|
|
348
355
|
});
|
|
356
|
+
var userPermissionsSchema = z.object({
|
|
357
|
+
can_manage_org: z.boolean().optional(),
|
|
358
|
+
can_manage_package: z.boolean().optional()
|
|
359
|
+
});
|
|
349
360
|
var publicOrgSchema = z.object({
|
|
350
361
|
org_id: z.string(),
|
|
351
362
|
//.uuid(),
|
|
@@ -358,10 +369,7 @@ var publicOrgSchema = z.object({
|
|
|
358
369
|
package_count: z.number(),
|
|
359
370
|
github_handle: z.string().optional(),
|
|
360
371
|
created_at: z.string(),
|
|
361
|
-
user_permissions:
|
|
362
|
-
can_manage_org: z.boolean().optional(),
|
|
363
|
-
can_manage_package: z.boolean().optional()
|
|
364
|
-
}).optional()
|
|
372
|
+
user_permissions: userPermissionsSchema.optional()
|
|
365
373
|
});
|
|
366
374
|
var databaseSchema = z.object({
|
|
367
375
|
idCounter: z.number().default(0),
|
|
@@ -413,5 +421,6 @@ export {
|
|
|
413
421
|
quotedComponentSchema,
|
|
414
422
|
sessionSchema,
|
|
415
423
|
shippingInfoSchema,
|
|
416
|
-
snippetSchema
|
|
424
|
+
snippetSchema,
|
|
425
|
+
userPermissionsSchema
|
|
417
426
|
};
|
|
@@ -1253,6 +1253,15 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
1253
1253
|
const newPackage = {
|
|
1254
1254
|
package_id: `package_${timestamp}`,
|
|
1255
1255
|
github_repo_full_name: null,
|
|
1256
|
+
latest_pcb_preview_image_url:
|
|
1257
|
+
_package.latest_pcb_preview_image_url ??
|
|
1258
|
+
`/api/packages/images/${_package.name}`,
|
|
1259
|
+
latest_cad_preview_image_url:
|
|
1260
|
+
_package.latest_cad_preview_image_url ??
|
|
1261
|
+
`/api/packages/images/${_package.name}`,
|
|
1262
|
+
latest_sch_preview_image_url:
|
|
1263
|
+
_package.latest_sch_preview_image_url ??
|
|
1264
|
+
`/api/packages/images/${_package.name}`,
|
|
1256
1265
|
..._package,
|
|
1257
1266
|
}
|
|
1258
1267
|
set((state) => ({
|
|
@@ -278,6 +278,11 @@ export const packageReleaseSchema = z.object({
|
|
|
278
278
|
branch_name: z.string().nullable().optional(),
|
|
279
279
|
commit_message: z.string().nullable().optional(),
|
|
280
280
|
commit_author: z.string().nullable().optional(),
|
|
281
|
+
|
|
282
|
+
// Preview images url
|
|
283
|
+
pcb_preview_image_url: z.string().nullable().default(null),
|
|
284
|
+
sch_preview_image_url: z.string().nullable().default(null),
|
|
285
|
+
cad_preview_image_url: z.string().nullable().default(null),
|
|
281
286
|
})
|
|
282
287
|
export type PackageRelease = z.infer<typeof packageReleaseSchema>
|
|
283
288
|
|
|
@@ -329,6 +334,9 @@ export const packageSchema = z.object({
|
|
|
329
334
|
.optional(),
|
|
330
335
|
allow_pr_previews: z.boolean().default(false).optional(),
|
|
331
336
|
is_starred: z.boolean().default(false).optional(),
|
|
337
|
+
latest_pcb_preview_image_url: z.string().nullable().optional(),
|
|
338
|
+
latest_sch_preview_image_url: z.string().nullable().optional(),
|
|
339
|
+
latest_cad_preview_image_url: z.string().nullable().optional(),
|
|
332
340
|
})
|
|
333
341
|
export type Package = z.infer<typeof packageSchema>
|
|
334
342
|
|
|
@@ -419,6 +427,12 @@ export const orgAccountSchema = z.object({
|
|
|
419
427
|
})
|
|
420
428
|
export type OrgAccount = z.infer<typeof orgAccountSchema>
|
|
421
429
|
|
|
430
|
+
export const userPermissionsSchema = z.object({
|
|
431
|
+
can_manage_org: z.boolean().optional(),
|
|
432
|
+
can_manage_package: z.boolean().optional(),
|
|
433
|
+
})
|
|
434
|
+
export type UserPermissions = z.infer<typeof userPermissionsSchema>
|
|
435
|
+
|
|
422
436
|
export const publicOrgSchema = z.object({
|
|
423
437
|
org_id: z.string(), //.uuid(),
|
|
424
438
|
owner_account_id: z.string(), //.uuid(),
|
|
@@ -429,12 +443,7 @@ export const publicOrgSchema = z.object({
|
|
|
429
443
|
package_count: z.number(),
|
|
430
444
|
github_handle: z.string().optional(),
|
|
431
445
|
created_at: z.string(),
|
|
432
|
-
user_permissions:
|
|
433
|
-
.object({
|
|
434
|
-
can_manage_org: z.boolean().optional(),
|
|
435
|
-
can_manage_package: z.boolean().optional(),
|
|
436
|
-
})
|
|
437
|
-
.optional(),
|
|
446
|
+
user_permissions: userPermissionsSchema.optional(),
|
|
438
447
|
})
|
|
439
448
|
export type PublicOrgSchema = z.infer<typeof publicOrgSchema>
|
|
440
449
|
|
|
@@ -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) {
|
|
@@ -28,6 +28,9 @@ export const publicMapPackage = (internalPackage: {
|
|
|
28
28
|
latest_package_release_fs_sha: string | null
|
|
29
29
|
github_repo_full_name?: string | null
|
|
30
30
|
allow_pr_previews?: boolean
|
|
31
|
+
latest_pcb_preview_image_url?: string | null
|
|
32
|
+
latest_sch_preview_image_url?: string | null
|
|
33
|
+
latest_cad_preview_image_url?: string | null
|
|
31
34
|
}): zt.Package => {
|
|
32
35
|
return {
|
|
33
36
|
...internalPackage,
|
|
@@ -47,5 +50,11 @@ export const publicMapPackage = (internalPackage: {
|
|
|
47
50
|
? true
|
|
48
51
|
: (internalPackage.is_unlisted ?? false),
|
|
49
52
|
allow_pr_previews: Boolean(internalPackage.allow_pr_previews),
|
|
53
|
+
latest_pcb_preview_image_url:
|
|
54
|
+
internalPackage.latest_pcb_preview_image_url ?? null,
|
|
55
|
+
latest_sch_preview_image_url:
|
|
56
|
+
internalPackage.latest_sch_preview_image_url ?? null,
|
|
57
|
+
latest_cad_preview_image_url:
|
|
58
|
+
internalPackage.latest_cad_preview_image_url ?? null,
|
|
50
59
|
}
|
|
51
60
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
import {
|
|
4
|
+
orgAccountSchema,
|
|
5
|
+
userPermissionsSchema,
|
|
6
|
+
} from "fake-snippets-api/lib/db/schema"
|
|
7
|
+
|
|
8
|
+
export default withRouteSpec({
|
|
9
|
+
methods: ["GET"],
|
|
10
|
+
commonParams: z.object({
|
|
11
|
+
org_id: z.string().optional(),
|
|
12
|
+
org_name: z.string().optional(),
|
|
13
|
+
account_id: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
auth: "optional_session",
|
|
16
|
+
jsonResponse: z.object({
|
|
17
|
+
org_member: orgAccountSchema.merge(
|
|
18
|
+
z.object({ org_member_permissions: userPermissionsSchema.nullable() }),
|
|
19
|
+
),
|
|
20
|
+
}),
|
|
21
|
+
})(async (req, ctx) => {
|
|
22
|
+
const { org_id, org_name, account_id } = req.commonParams
|
|
23
|
+
|
|
24
|
+
const org = ctx.db.getOrg(
|
|
25
|
+
{
|
|
26
|
+
org_id,
|
|
27
|
+
org_name,
|
|
28
|
+
},
|
|
29
|
+
ctx.auth,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
if (!org) {
|
|
33
|
+
return ctx.error(404, {
|
|
34
|
+
error_code: "org_not_found",
|
|
35
|
+
message: "Organization not found",
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const memberOrgAccount = ctx.db.getOrganizationAccount({
|
|
40
|
+
org_id: org.org_id,
|
|
41
|
+
account_id: account_id,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const memberOrg = ctx.db.getOrg(
|
|
45
|
+
{
|
|
46
|
+
org_id,
|
|
47
|
+
org_name,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
account_id: account_id!,
|
|
51
|
+
},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if (!memberOrgAccount) {
|
|
55
|
+
return ctx.error(404, {
|
|
56
|
+
error_code: "member_not_found",
|
|
57
|
+
message: "Member not found in organization",
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return ctx.json({
|
|
62
|
+
org_member: {
|
|
63
|
+
...memberOrgAccount,
|
|
64
|
+
org_member_permissions: memberOrg,
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
2
2
|
import { z } from "zod"
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
accountSchema,
|
|
5
|
+
userPermissionsSchema,
|
|
6
|
+
} from "fake-snippets-api/lib/db/schema"
|
|
4
7
|
|
|
5
8
|
export default withRouteSpec({
|
|
6
9
|
methods: ["GET", "POST"],
|
|
@@ -15,7 +18,12 @@ export default withRouteSpec({
|
|
|
15
18
|
),
|
|
16
19
|
auth: "optional_session",
|
|
17
20
|
jsonResponse: z.object({
|
|
18
|
-
|
|
21
|
+
org_members: z.array(
|
|
22
|
+
accountSchema.omit({ shippingInfo: true }).extend({
|
|
23
|
+
joined_at: z.string(),
|
|
24
|
+
org_member_permissions: userPermissionsSchema,
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
19
27
|
}),
|
|
20
28
|
})(async (req, ctx) => {
|
|
21
29
|
const params = req.commonParams as { org_id?: string; name?: string }
|
|
@@ -40,8 +48,19 @@ export default withRouteSpec({
|
|
|
40
48
|
if (m.org_id !== org.org_id) return undefined
|
|
41
49
|
const account = ctx.db.getAccount(m.account_id)
|
|
42
50
|
if (!account) return undefined
|
|
51
|
+
const memberOrg = ctx.db.getOrg(
|
|
52
|
+
{
|
|
53
|
+
org_id: org.org_id,
|
|
54
|
+
org_name: org.org_name,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
account_id: account.account_id,
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
|
|
43
61
|
return {
|
|
44
62
|
...account,
|
|
63
|
+
user_permissions: memberOrg,
|
|
45
64
|
joined_at: m.created_at,
|
|
46
65
|
}
|
|
47
66
|
})
|
|
@@ -56,15 +75,32 @@ export default withRouteSpec({
|
|
|
56
75
|
(acc) => acc.account_id === org.owner_account_id,
|
|
57
76
|
)
|
|
58
77
|
if (owner) {
|
|
78
|
+
const memberOrg = ctx.db.getOrg(
|
|
79
|
+
{
|
|
80
|
+
org_id: org.org_id,
|
|
81
|
+
org_name: org.org_name,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
account_id: owner.account_id,
|
|
85
|
+
},
|
|
86
|
+
)
|
|
59
87
|
fullMembers = [
|
|
60
88
|
...members,
|
|
61
89
|
{
|
|
62
90
|
...owner,
|
|
91
|
+
user_permissions: memberOrg,
|
|
63
92
|
joined_at: org.created_at,
|
|
64
93
|
},
|
|
65
94
|
]
|
|
66
95
|
}
|
|
67
96
|
}
|
|
68
|
-
|
|
69
|
-
|
|
97
|
+
return ctx.json({
|
|
98
|
+
org_members: fullMembers.map((m) => ({
|
|
99
|
+
...m,
|
|
100
|
+
org_member_permissions: m.user_permissions ?? {
|
|
101
|
+
can_manage_org: false,
|
|
102
|
+
can_manage_package: false,
|
|
103
|
+
},
|
|
104
|
+
})),
|
|
105
|
+
})
|
|
70
106
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/fake-snippets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.119",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@tscircuit/3d-viewer": "^0.0.407",
|
|
82
82
|
"@tscircuit/assembly-viewer": "^0.0.5",
|
|
83
83
|
"@tscircuit/create-snippet-url": "^0.0.8",
|
|
84
|
-
"@tscircuit/eval": "^0.0.
|
|
84
|
+
"@tscircuit/eval": "^0.0.410",
|
|
85
85
|
"@tscircuit/layout": "^0.0.29",
|
|
86
86
|
"@tscircuit/mm": "^0.0.8",
|
|
87
87
|
"@tscircuit/pcb-viewer": "^1.11.218",
|