@tscircuit/fake-snippets 0.0.105 → 0.0.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CLAUDE.md +92 -0
  2. package/api/generated-index.js +3 -4
  3. package/bun-tests/fake-snippets-api/routes/package_builds/get.test.ts +294 -0
  4. package/bun-tests/fake-snippets-api/routes/package_builds/list.test.ts +304 -0
  5. package/dist/bundle.js +698 -335
  6. package/dist/index.d.ts +147 -4
  7. package/dist/index.js +195 -7
  8. package/dist/schema.d.ts +206 -1
  9. package/dist/schema.js +31 -2
  10. package/fake-snippets-api/lib/db/db-client.ts +60 -3
  11. package/fake-snippets-api/lib/db/schema.ts +31 -0
  12. package/fake-snippets-api/lib/db/seed.ts +139 -2
  13. package/fake-snippets-api/lib/public-mapping/public-map-package-build.ts +41 -0
  14. package/fake-snippets-api/routes/api/package_builds/get.ts +70 -0
  15. package/fake-snippets-api/routes/api/package_builds/list.ts +97 -0
  16. package/package.json +3 -2
  17. package/src/App.tsx +21 -5
  18. package/src/components/PackageBreadcrumb.tsx +111 -0
  19. package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +22 -11
  20. package/src/components/preview/BuildsList.tsx +196 -211
  21. package/src/components/preview/ConnectedPackagesList.tsx +54 -25
  22. package/src/components/preview/ConnectedRepoOverview.tsx +63 -35
  23. package/src/components/preview/{ConnectedRepoDashboard.tsx → PackageReleasesDashboard.tsx} +33 -71
  24. package/src/components/preview/index.tsx +20 -77
  25. package/src/hooks/use-package-builds.ts +87 -0
  26. package/src/hooks/use-package-release-by-id-or-version.ts +36 -0
  27. package/src/hooks/use-package-release.ts +32 -0
  28. package/src/lib/utils/isUuid.ts +5 -0
  29. package/src/pages/preview-build.tsx +3 -3
  30. package/src/pages/release-builds.tsx +107 -0
  31. package/src/pages/release-detail.tsx +118 -0
  32. package/src/pages/releases.tsx +51 -0
  33. package/src/pages/view-connected-repo.tsx +0 -18
package/dist/schema.d.ts CHANGED
@@ -693,6 +693,7 @@ declare const packageReleaseSchema: z.ZodObject<{
693
693
  ai_review_requested: z.ZodDefault<z.ZodBoolean>;
694
694
  is_pr_preview: z.ZodDefault<z.ZodBoolean>;
695
695
  github_pr_number: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
696
+ latest_package_build_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
696
697
  }, "strip", z.ZodTypeAny, {
697
698
  package_release_id: string;
698
699
  created_at: string;
@@ -729,6 +730,7 @@ declare const packageReleaseSchema: z.ZodObject<{
729
730
  ai_review_error?: any;
730
731
  ai_review_logs?: any[] | null | undefined;
731
732
  github_pr_number?: number | null | undefined;
733
+ latest_package_build_id?: string | null | undefined;
732
734
  }, {
733
735
  package_release_id: string;
734
736
  created_at: string;
@@ -765,6 +767,7 @@ declare const packageReleaseSchema: z.ZodObject<{
765
767
  ai_review_requested?: boolean | undefined;
766
768
  is_pr_preview?: boolean | undefined;
767
769
  github_pr_number?: number | null | undefined;
770
+ latest_package_build_id?: string | null | undefined;
768
771
  }>;
769
772
  type PackageRelease = z.infer<typeof packageReleaseSchema>;
770
773
  declare const packageFileSchema: z.ZodObject<{
@@ -994,6 +997,80 @@ declare const jlcpcbOrderStepRunSchema: z.ZodObject<{
994
997
  error_message?: string | null | undefined;
995
998
  }>;
996
999
  type JlcpcbOrderStepRun = z.infer<typeof jlcpcbOrderStepRunSchema>;
1000
+ declare const packageBuildSchema: z.ZodObject<{
1001
+ package_build_id: z.ZodString;
1002
+ package_release_id: z.ZodString;
1003
+ created_at: z.ZodString;
1004
+ transpilation_in_progress: z.ZodDefault<z.ZodBoolean>;
1005
+ transpilation_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1006
+ transpilation_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1007
+ transpilation_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
1008
+ transpilation_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1009
+ circuit_json_build_in_progress: z.ZodDefault<z.ZodBoolean>;
1010
+ circuit_json_build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1011
+ circuit_json_build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1012
+ circuit_json_build_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
1013
+ circuit_json_build_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1014
+ build_in_progress: z.ZodDefault<z.ZodBoolean>;
1015
+ build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1016
+ build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1017
+ build_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1018
+ build_error_last_updated_at: z.ZodString;
1019
+ preview_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1020
+ build_logs: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1021
+ branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1022
+ commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1023
+ commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1024
+ }, "strip", z.ZodTypeAny, {
1025
+ package_release_id: string;
1026
+ created_at: string;
1027
+ transpilation_in_progress: boolean;
1028
+ transpilation_logs: any[];
1029
+ circuit_json_build_in_progress: boolean;
1030
+ circuit_json_build_logs: any[];
1031
+ package_build_id: string;
1032
+ build_in_progress: boolean;
1033
+ build_error_last_updated_at: string;
1034
+ circuit_json_build_error?: string | null | undefined;
1035
+ transpilation_error?: string | null | undefined;
1036
+ transpilation_started_at?: string | null | undefined;
1037
+ transpilation_completed_at?: string | null | undefined;
1038
+ circuit_json_build_started_at?: string | null | undefined;
1039
+ circuit_json_build_completed_at?: string | null | undefined;
1040
+ build_started_at?: string | null | undefined;
1041
+ build_completed_at?: string | null | undefined;
1042
+ build_error?: string | null | undefined;
1043
+ preview_url?: string | null | undefined;
1044
+ build_logs?: string | null | undefined;
1045
+ branch_name?: string | null | undefined;
1046
+ commit_message?: string | null | undefined;
1047
+ commit_author?: string | null | undefined;
1048
+ }, {
1049
+ package_release_id: string;
1050
+ created_at: string;
1051
+ package_build_id: string;
1052
+ build_error_last_updated_at: string;
1053
+ circuit_json_build_error?: string | null | undefined;
1054
+ transpilation_error?: string | null | undefined;
1055
+ transpilation_in_progress?: boolean | undefined;
1056
+ transpilation_started_at?: string | null | undefined;
1057
+ transpilation_completed_at?: string | null | undefined;
1058
+ transpilation_logs?: any[] | undefined;
1059
+ circuit_json_build_in_progress?: boolean | undefined;
1060
+ circuit_json_build_started_at?: string | null | undefined;
1061
+ circuit_json_build_completed_at?: string | null | undefined;
1062
+ circuit_json_build_logs?: any[] | undefined;
1063
+ build_in_progress?: boolean | undefined;
1064
+ build_started_at?: string | null | undefined;
1065
+ build_completed_at?: string | null | undefined;
1066
+ build_error?: string | null | undefined;
1067
+ preview_url?: string | null | undefined;
1068
+ build_logs?: string | null | undefined;
1069
+ branch_name?: string | null | undefined;
1070
+ commit_message?: string | null | undefined;
1071
+ commit_author?: string | null | undefined;
1072
+ }>;
1073
+ type PackageBuild = z.infer<typeof packageBuildSchema>;
997
1074
  declare const databaseSchema: z.ZodObject<{
998
1075
  idCounter: z.ZodDefault<z.ZodNumber>;
999
1076
  snippets: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -1102,6 +1179,7 @@ declare const databaseSchema: z.ZodObject<{
1102
1179
  ai_review_requested: z.ZodDefault<z.ZodBoolean>;
1103
1180
  is_pr_preview: z.ZodDefault<z.ZodBoolean>;
1104
1181
  github_pr_number: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1182
+ latest_package_build_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1105
1183
  }, "strip", z.ZodTypeAny, {
1106
1184
  package_release_id: string;
1107
1185
  created_at: string;
@@ -1138,6 +1216,7 @@ declare const databaseSchema: z.ZodObject<{
1138
1216
  ai_review_error?: any;
1139
1217
  ai_review_logs?: any[] | null | undefined;
1140
1218
  github_pr_number?: number | null | undefined;
1219
+ latest_package_build_id?: string | null | undefined;
1141
1220
  }, {
1142
1221
  package_release_id: string;
1143
1222
  created_at: string;
@@ -1174,6 +1253,7 @@ declare const databaseSchema: z.ZodObject<{
1174
1253
  ai_review_requested?: boolean | undefined;
1175
1254
  is_pr_preview?: boolean | undefined;
1176
1255
  github_pr_number?: number | null | undefined;
1256
+ latest_package_build_id?: string | null | undefined;
1177
1257
  }>, "many">>;
1178
1258
  packageFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
1179
1259
  package_file_id: z.ZodString;
@@ -1850,6 +1930,79 @@ declare const databaseSchema: z.ZodObject<{
1850
1930
  access_token?: string | null | undefined;
1851
1931
  access_token_expires_at?: string | null | undefined;
1852
1932
  }>, "many">>;
1933
+ packageBuilds: z.ZodDefault<z.ZodArray<z.ZodObject<{
1934
+ package_build_id: z.ZodString;
1935
+ package_release_id: z.ZodString;
1936
+ created_at: z.ZodString;
1937
+ transpilation_in_progress: z.ZodDefault<z.ZodBoolean>;
1938
+ transpilation_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1939
+ transpilation_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1940
+ transpilation_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
1941
+ transpilation_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1942
+ circuit_json_build_in_progress: z.ZodDefault<z.ZodBoolean>;
1943
+ circuit_json_build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1944
+ circuit_json_build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1945
+ circuit_json_build_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
1946
+ circuit_json_build_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1947
+ build_in_progress: z.ZodDefault<z.ZodBoolean>;
1948
+ build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1949
+ build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1950
+ build_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1951
+ build_error_last_updated_at: z.ZodString;
1952
+ preview_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1953
+ build_logs: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1954
+ branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1955
+ commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1956
+ commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1957
+ }, "strip", z.ZodTypeAny, {
1958
+ package_release_id: string;
1959
+ created_at: string;
1960
+ transpilation_in_progress: boolean;
1961
+ transpilation_logs: any[];
1962
+ circuit_json_build_in_progress: boolean;
1963
+ circuit_json_build_logs: any[];
1964
+ package_build_id: string;
1965
+ build_in_progress: boolean;
1966
+ build_error_last_updated_at: string;
1967
+ circuit_json_build_error?: string | null | undefined;
1968
+ transpilation_error?: string | null | undefined;
1969
+ transpilation_started_at?: string | null | undefined;
1970
+ transpilation_completed_at?: string | null | undefined;
1971
+ circuit_json_build_started_at?: string | null | undefined;
1972
+ circuit_json_build_completed_at?: string | null | undefined;
1973
+ build_started_at?: string | null | undefined;
1974
+ build_completed_at?: string | null | undefined;
1975
+ build_error?: string | null | undefined;
1976
+ preview_url?: string | null | undefined;
1977
+ build_logs?: string | null | undefined;
1978
+ branch_name?: string | null | undefined;
1979
+ commit_message?: string | null | undefined;
1980
+ commit_author?: string | null | undefined;
1981
+ }, {
1982
+ package_release_id: string;
1983
+ created_at: string;
1984
+ package_build_id: string;
1985
+ build_error_last_updated_at: string;
1986
+ circuit_json_build_error?: string | null | undefined;
1987
+ transpilation_error?: string | null | undefined;
1988
+ transpilation_in_progress?: boolean | undefined;
1989
+ transpilation_started_at?: string | null | undefined;
1990
+ transpilation_completed_at?: string | null | undefined;
1991
+ transpilation_logs?: any[] | undefined;
1992
+ circuit_json_build_in_progress?: boolean | undefined;
1993
+ circuit_json_build_started_at?: string | null | undefined;
1994
+ circuit_json_build_completed_at?: string | null | undefined;
1995
+ circuit_json_build_logs?: any[] | undefined;
1996
+ build_in_progress?: boolean | undefined;
1997
+ build_started_at?: string | null | undefined;
1998
+ build_completed_at?: string | null | undefined;
1999
+ build_error?: string | null | undefined;
2000
+ preview_url?: string | null | undefined;
2001
+ build_logs?: string | null | undefined;
2002
+ branch_name?: string | null | undefined;
2003
+ commit_message?: string | null | undefined;
2004
+ commit_author?: string | null | undefined;
2005
+ }>, "many">>;
1853
2006
  }, "strip", z.ZodTypeAny, {
1854
2007
  idCounter: number;
1855
2008
  snippets: {
@@ -1912,6 +2065,7 @@ declare const databaseSchema: z.ZodObject<{
1912
2065
  ai_review_error?: any;
1913
2066
  ai_review_logs?: any[] | null | undefined;
1914
2067
  github_pr_number?: number | null | undefined;
2068
+ latest_package_build_id?: string | null | undefined;
1915
2069
  }[];
1916
2070
  packageFiles: {
1917
2071
  package_release_id: string;
@@ -2126,6 +2280,31 @@ declare const databaseSchema: z.ZodObject<{
2126
2280
  access_token?: string | null | undefined;
2127
2281
  access_token_expires_at?: string | null | undefined;
2128
2282
  }[];
2283
+ packageBuilds: {
2284
+ package_release_id: string;
2285
+ created_at: string;
2286
+ transpilation_in_progress: boolean;
2287
+ transpilation_logs: any[];
2288
+ circuit_json_build_in_progress: boolean;
2289
+ circuit_json_build_logs: any[];
2290
+ package_build_id: string;
2291
+ build_in_progress: boolean;
2292
+ build_error_last_updated_at: string;
2293
+ circuit_json_build_error?: string | null | undefined;
2294
+ transpilation_error?: string | null | undefined;
2295
+ transpilation_started_at?: string | null | undefined;
2296
+ transpilation_completed_at?: string | null | undefined;
2297
+ circuit_json_build_started_at?: string | null | undefined;
2298
+ circuit_json_build_completed_at?: string | null | undefined;
2299
+ build_started_at?: string | null | undefined;
2300
+ build_completed_at?: string | null | undefined;
2301
+ build_error?: string | null | undefined;
2302
+ preview_url?: string | null | undefined;
2303
+ build_logs?: string | null | undefined;
2304
+ branch_name?: string | null | undefined;
2305
+ commit_message?: string | null | undefined;
2306
+ commit_author?: string | null | undefined;
2307
+ }[];
2129
2308
  }, {
2130
2309
  idCounter?: number | undefined;
2131
2310
  snippets?: {
@@ -2188,6 +2367,7 @@ declare const databaseSchema: z.ZodObject<{
2188
2367
  ai_review_requested?: boolean | undefined;
2189
2368
  is_pr_preview?: boolean | undefined;
2190
2369
  github_pr_number?: number | null | undefined;
2370
+ latest_package_build_id?: string | null | undefined;
2191
2371
  }[] | undefined;
2192
2372
  packageFiles?: {
2193
2373
  package_release_id: string;
@@ -2402,7 +2582,32 @@ declare const databaseSchema: z.ZodObject<{
2402
2582
  access_token?: string | null | undefined;
2403
2583
  access_token_expires_at?: string | null | undefined;
2404
2584
  }[] | undefined;
2585
+ packageBuilds?: {
2586
+ package_release_id: string;
2587
+ created_at: string;
2588
+ package_build_id: string;
2589
+ build_error_last_updated_at: string;
2590
+ circuit_json_build_error?: string | null | undefined;
2591
+ transpilation_error?: string | null | undefined;
2592
+ transpilation_in_progress?: boolean | undefined;
2593
+ transpilation_started_at?: string | null | undefined;
2594
+ transpilation_completed_at?: string | null | undefined;
2595
+ transpilation_logs?: any[] | undefined;
2596
+ circuit_json_build_in_progress?: boolean | undefined;
2597
+ circuit_json_build_started_at?: string | null | undefined;
2598
+ circuit_json_build_completed_at?: string | null | undefined;
2599
+ circuit_json_build_logs?: any[] | undefined;
2600
+ build_in_progress?: boolean | undefined;
2601
+ build_started_at?: string | null | undefined;
2602
+ build_completed_at?: string | null | undefined;
2603
+ build_error?: string | null | undefined;
2604
+ preview_url?: string | null | undefined;
2605
+ build_logs?: string | null | undefined;
2606
+ branch_name?: string | null | undefined;
2607
+ commit_message?: string | null | undefined;
2608
+ commit_author?: string | null | undefined;
2609
+ }[] | undefined;
2405
2610
  }>;
2406
2611
  type DatabaseSchema = z.infer<typeof databaseSchema>;
2407
2612
 
2408
- 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 Package, type PackageFile, type PackageRelease, type QuotedComponent, type Session, type ShippingOption, type Snippet, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, databaseSchema, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, githubInstallationSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, packageFileSchema, packageReleaseSchema, packageSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema };
2613
+ 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 Package, type PackageBuild, type PackageFile, type PackageRelease, type QuotedComponent, type Session, type ShippingOption, type Snippet, accountPackageSchema, accountSchema, accountSnippetSchema, aiReviewSchema, databaseSchema, datasheetPinInformationSchema, datasheetSchema, errorResponseSchema, errorSchema, githubInstallationSchema, jlcpcbOrderStateSchema, jlcpcbOrderStepRunSchema, loginPageSchema, orderFileSchema, orderQuoteSchema, orderSchema, packageBuildSchema, packageFileSchema, packageReleaseSchema, packageSchema, quotedComponentSchema, sessionSchema, shippingInfoSchema, snippetSchema };
package/dist/schema.js CHANGED
@@ -207,7 +207,9 @@ var packageReleaseSchema = z.object({
207
207
  ai_review_requested: z.boolean().default(false),
208
208
  // Preview
209
209
  is_pr_preview: z.boolean().default(false),
210
- github_pr_number: z.number().nullable().optional()
210
+ github_pr_number: z.number().nullable().optional(),
211
+ // Latest Build Reference
212
+ latest_package_build_id: z.string().nullable().optional()
211
213
  });
212
214
  var packageFileSchema = z.object({
213
215
  package_file_id: z.string(),
@@ -286,6 +288,31 @@ var jlcpcbOrderStepRunSchema = z.object({
286
288
  error_message: z.string().nullable().default(null),
287
289
  created_at: z.string()
288
290
  });
291
+ var packageBuildSchema = z.object({
292
+ package_build_id: z.string().uuid(),
293
+ package_release_id: z.string(),
294
+ created_at: z.string().datetime(),
295
+ transpilation_in_progress: z.boolean().default(false),
296
+ transpilation_started_at: z.string().datetime().nullable().optional(),
297
+ transpilation_completed_at: z.string().datetime().nullable().optional(),
298
+ transpilation_logs: z.array(z.any()).default([]),
299
+ transpilation_error: z.string().nullable().optional(),
300
+ circuit_json_build_in_progress: z.boolean().default(false),
301
+ circuit_json_build_started_at: z.string().datetime().nullable().optional(),
302
+ circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
303
+ circuit_json_build_logs: z.array(z.any()).default([]),
304
+ circuit_json_build_error: z.string().nullable().optional(),
305
+ build_in_progress: z.boolean().default(false),
306
+ build_started_at: z.string().datetime().nullable().optional(),
307
+ build_completed_at: z.string().datetime().nullable().optional(),
308
+ build_error: z.string().nullable().optional(),
309
+ build_error_last_updated_at: z.string().datetime(),
310
+ preview_url: z.string().nullable().optional(),
311
+ build_logs: z.string().nullable().optional(),
312
+ branch_name: z.string().nullable().optional(),
313
+ commit_message: z.string().nullable().optional(),
314
+ commit_author: z.string().nullable().optional()
315
+ });
289
316
  var databaseSchema = z.object({
290
317
  idCounter: z.number().default(0),
291
318
  snippets: z.array(snippetSchema).default([]),
@@ -304,7 +331,8 @@ var databaseSchema = z.object({
304
331
  orderQuotes: z.array(orderQuoteSchema).default([]),
305
332
  aiReviews: z.array(aiReviewSchema).default([]),
306
333
  datasheets: z.array(datasheetSchema).default([]),
307
- githubInstallations: z.array(githubInstallationSchema).default([])
334
+ githubInstallations: z.array(githubInstallationSchema).default([]),
335
+ packageBuilds: z.array(packageBuildSchema).default([])
308
336
  });
309
337
  export {
310
338
  accountPackageSchema,
@@ -323,6 +351,7 @@ export {
323
351
  orderFileSchema,
324
352
  orderQuoteSchema,
325
353
  orderSchema,
354
+ packageBuildSchema,
326
355
  packageFileSchema,
327
356
  packageReleaseSchema,
328
357
  packageSchema,
@@ -16,6 +16,7 @@ import {
16
16
  type PackageFile,
17
17
  type PackageRelease,
18
18
  packageReleaseSchema,
19
+ type PackageBuild,
19
20
  type AiReview,
20
21
  aiReviewSchema,
21
22
  type Datasheet,
@@ -241,7 +242,7 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
241
242
  snippet: Omit<
242
243
  z.input<typeof snippetSchema>,
243
244
  "snippet_id" | "package_release_id"
244
- >,
245
+ > & { creator_account_id?: string; github_repo_full_name?: string },
245
246
  ): Snippet => {
246
247
  const timestamp = Date.now()
247
248
  const currentTime = new Date(timestamp).toISOString()
@@ -252,7 +253,7 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
252
253
  // Create the package that will serve as our snippet
253
254
  const newPackage = {
254
255
  package_id: `pkg_${nextId}`,
255
- creator_account_id: snippet.owner_name, // Using owner_name as account_id since we don't have context
256
+ creator_account_id: snippet.creator_account_id ?? snippet.owner_name, // Using owner_name as account_id since we don't have context
256
257
  owner_org_id: "", // Empty string instead of null to match type
257
258
  owner_github_username: snippet.owner_name,
258
259
  is_source_from_github: false,
@@ -265,7 +266,7 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
265
266
  star_count: 0,
266
267
  created_at: currentTime,
267
268
  updated_at: currentTime,
268
- github_repo_full_name: null,
269
+ github_repo_full_name: snippet.github_repo_full_name || null,
269
270
  ai_description: "placeholder ai description",
270
271
  ai_usage_instructions: "placeholder ai usage instructions",
271
272
  is_snippet: true,
@@ -292,6 +293,9 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
292
293
  updated_at: currentTime,
293
294
  has_transpiled: true,
294
295
  transpilation_error: null,
296
+ ...(snippet.name == "testuser/my-test-board"
297
+ ? { is_pr_preview: true, github_pr_number: 69 }
298
+ : {}),
295
299
  })
296
300
 
297
301
  // Add all the files
@@ -1475,4 +1479,57 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
1475
1479
  })
1476
1480
  return updated
1477
1481
  },
1482
+ addPackageBuild: (
1483
+ packageBuild: Omit<PackageBuild, "package_build_id">,
1484
+ ): PackageBuild => {
1485
+ const newPackageBuild = {
1486
+ package_build_id: crypto.randomUUID(),
1487
+ ...packageBuild,
1488
+ }
1489
+ set((state) => ({
1490
+ packageBuilds: [...state.packageBuilds, newPackageBuild],
1491
+ // Automatically update the package release to reference this as the latest build
1492
+ packageReleases: state.packageReleases.map((release) =>
1493
+ release.package_release_id === packageBuild.package_release_id
1494
+ ? {
1495
+ ...release,
1496
+ latest_package_build_id: newPackageBuild.package_build_id,
1497
+ }
1498
+ : release,
1499
+ ),
1500
+ }))
1501
+ return newPackageBuild
1502
+ },
1503
+ getPackageBuildById: (packageBuildId: string): PackageBuild | undefined => {
1504
+ const state = get()
1505
+ return state.packageBuilds.find(
1506
+ (pb) => pb.package_build_id === packageBuildId,
1507
+ )
1508
+ },
1509
+ getPackageBuildsByReleaseId: (packageReleaseId: string): PackageBuild[] => {
1510
+ const state = get()
1511
+ return state.packageBuilds
1512
+ .filter((pb) => pb.package_release_id === packageReleaseId)
1513
+ .sort(
1514
+ (a, b) =>
1515
+ new Date(b.created_at).getTime() - new Date(a.created_at).getTime(),
1516
+ )
1517
+ },
1518
+ updatePackageBuild: (
1519
+ packageBuildId: string,
1520
+ updates: Partial<PackageBuild>,
1521
+ ): PackageBuild | undefined => {
1522
+ let updated: PackageBuild | undefined
1523
+ set((state) => {
1524
+ const index = state.packageBuilds.findIndex(
1525
+ (pb) => pb.package_build_id === packageBuildId,
1526
+ )
1527
+ if (index === -1) return state
1528
+ const packageBuilds = [...state.packageBuilds]
1529
+ packageBuilds[index] = { ...packageBuilds[index], ...updates }
1530
+ updated = packageBuilds[index]
1531
+ return { ...state, packageBuilds }
1532
+ })
1533
+ return updated
1534
+ },
1478
1535
  }))
@@ -255,6 +255,9 @@ export const packageReleaseSchema = z.object({
255
255
  // Preview
256
256
  is_pr_preview: z.boolean().default(false),
257
257
  github_pr_number: z.number().nullable().optional(),
258
+
259
+ // Latest Build Reference
260
+ latest_package_build_id: z.string().nullable().optional(),
258
261
  })
259
262
  export type PackageRelease = z.infer<typeof packageReleaseSchema>
260
263
 
@@ -346,6 +349,33 @@ export const jlcpcbOrderStepRunSchema = z.object({
346
349
  })
347
350
  export type JlcpcbOrderStepRun = z.infer<typeof jlcpcbOrderStepRunSchema>
348
351
 
352
+ export const packageBuildSchema = z.object({
353
+ package_build_id: z.string().uuid(),
354
+ package_release_id: z.string(),
355
+ created_at: z.string().datetime(),
356
+ transpilation_in_progress: z.boolean().default(false),
357
+ transpilation_started_at: z.string().datetime().nullable().optional(),
358
+ transpilation_completed_at: z.string().datetime().nullable().optional(),
359
+ transpilation_logs: z.array(z.any()).default([]),
360
+ transpilation_error: z.string().nullable().optional(),
361
+ circuit_json_build_in_progress: z.boolean().default(false),
362
+ circuit_json_build_started_at: z.string().datetime().nullable().optional(),
363
+ circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
364
+ circuit_json_build_logs: z.array(z.any()).default([]),
365
+ circuit_json_build_error: z.string().nullable().optional(),
366
+ build_in_progress: z.boolean().default(false),
367
+ build_started_at: z.string().datetime().nullable().optional(),
368
+ build_completed_at: z.string().datetime().nullable().optional(),
369
+ build_error: z.string().nullable().optional(),
370
+ build_error_last_updated_at: z.string().datetime(),
371
+ preview_url: z.string().nullable().optional(),
372
+ build_logs: z.string().nullable().optional(),
373
+ branch_name: z.string().nullable().optional(),
374
+ commit_message: z.string().nullable().optional(),
375
+ commit_author: z.string().nullable().optional(),
376
+ })
377
+ export type PackageBuild = z.infer<typeof packageBuildSchema>
378
+
349
379
  export const databaseSchema = z.object({
350
380
  idCounter: z.number().default(0),
351
381
  snippets: z.array(snippetSchema).default([]),
@@ -365,5 +395,6 @@ export const databaseSchema = z.object({
365
395
  aiReviews: z.array(aiReviewSchema).default([]),
366
396
  datasheets: z.array(datasheetSchema).default([]),
367
397
  githubInstallations: z.array(githubInstallationSchema).default([]),
398
+ packageBuilds: z.array(packageBuildSchema).default([]),
368
399
  })
369
400
  export type DatabaseSchema = z.infer<typeof databaseSchema>
@@ -26,10 +26,12 @@ export const seed = (db: DbClient) => {
26
26
  loadAutoloadPackages(db)
27
27
  }
28
28
 
29
- db.addSnippet({
29
+ const { package_release_id: packageReleaseId1 } = db.addSnippet({
30
30
  name: "testuser/my-test-board",
31
31
  unscoped_name: "my-test-board",
32
+ github_repo_full_name: "testuser/my-test-board",
32
33
  owner_name: "testuser",
34
+ creator_account_id: account_id,
33
35
  code: `
34
36
  import { A555Timer } from "@tsci/seveibar.a555timer"
35
37
 
@@ -536,6 +538,49 @@ export default () => (
536
538
  ],
537
539
  })
538
540
 
541
+ const firstBuild = db.addPackageBuild({
542
+ package_release_id: packageReleaseId1,
543
+ created_at: new Date(Date.now() - 15000).toISOString(), // 15 seconds ago
544
+ transpilation_in_progress: false,
545
+ transpilation_started_at: new Date(Date.now() - 15000).toISOString(),
546
+ transpilation_completed_at: new Date(Date.now() - 14000).toISOString(),
547
+ transpilation_logs: [
548
+ "[INFO] Starting transpilation...",
549
+ "[INFO] Parsing package code",
550
+ "[ERROR] Failed to parse TypeScript definitions",
551
+ "[ERROR] Invalid syntax in component declaration",
552
+ ],
553
+ transpilation_error:
554
+ "TypeScript compilation failed: Syntax error in component declaration",
555
+ circuit_json_build_in_progress: false,
556
+ circuit_json_build_started_at: null,
557
+ circuit_json_build_completed_at: null,
558
+ circuit_json_build_logs: [],
559
+ circuit_json_build_error: "Build cancelled due to transpilation failure",
560
+ build_in_progress: false,
561
+ build_started_at: new Date(Date.now() - 15000).toISOString(),
562
+ build_completed_at: new Date(Date.now() - 14000).toISOString(),
563
+ build_error: "Build failed: Unable to complete transpilation step",
564
+ build_error_last_updated_at: new Date(Date.now() - 14000).toISOString(),
565
+ preview_url: null,
566
+ build_logs:
567
+ "Build process:\n" +
568
+ "1. Environment setup - OK\n" +
569
+ "2. Dependency resolution - OK\n" +
570
+ "3. Code compilation - FAILED\n" +
571
+ "Error: Invalid syntax in component declaration\n" +
572
+ "Build terminated with errors",
573
+ branch_name: "main",
574
+ commit_message: "Attempted build of a555timer-square-wave package",
575
+ commit_author: "testuser",
576
+ })
577
+
578
+ // Update the package release with the latest build ID
579
+ const release1 = db.getPackageReleaseById(packageReleaseId1)!
580
+ db.updatePackageRelease({
581
+ ...release1,
582
+ latest_package_build_id: firstBuild.package_build_id,
583
+ })
539
584
  // Define the @tsci/seveibar.a555timer package
540
585
  db.addSnippet({
541
586
  name: "seveibar/a555timer",
@@ -1067,10 +1112,11 @@ exports.A555Timer = A555Timer;
1067
1112
 
1068
1113
  // Add a snippet that outputs a square waveform using the a555timer
1069
1114
 
1070
- db.addSnippet({
1115
+ const { package_release_id: packageReleaseId2 } = db.addSnippet({
1071
1116
  name: "testuser/a555timer-square-wave",
1072
1117
  unscoped_name: "a555timer-square-wave",
1073
1118
  owner_name: "testuser",
1119
+ creator_account_id: account_id,
1074
1120
  code: `
1075
1121
  import { A555Timer } from "@tsci/seveibar.a555timer"
1076
1122
 
@@ -1084,6 +1130,7 @@ export const SquareWaveModule = () => (
1084
1130
  created_at: new Date().toISOString(),
1085
1131
  updated_at: new Date().toISOString(),
1086
1132
  snippet_type: "package",
1133
+ github_repo_full_name: "testuser/test",
1087
1134
  description:
1088
1135
  "A simple package that outputs a square waveform using the a555timer",
1089
1136
  circuit_json: [
@@ -1579,6 +1626,96 @@ export const SquareWaveModule = () => (
1579
1626
  ],
1580
1627
  })
1581
1628
 
1629
+ // Add failed build first
1630
+ const failedBuild = db.addPackageBuild({
1631
+ package_release_id: packageReleaseId2,
1632
+ created_at: new Date(Date.now() - 15000).toISOString(), // 15 seconds ago
1633
+ transpilation_in_progress: false,
1634
+ transpilation_started_at: new Date(Date.now() - 15000).toISOString(),
1635
+ transpilation_completed_at: new Date(Date.now() - 14000).toISOString(),
1636
+ transpilation_logs: [
1637
+ "[INFO] Starting transpilation...",
1638
+ "[INFO] Parsing package code",
1639
+ "[ERROR] Failed to parse TypeScript definitions",
1640
+ "[ERROR] Invalid syntax in component declaration",
1641
+ ],
1642
+ transpilation_error:
1643
+ "TypeScript compilation failed: Syntax error in component declaration",
1644
+ circuit_json_build_in_progress: false,
1645
+ circuit_json_build_started_at: null,
1646
+ circuit_json_build_completed_at: null,
1647
+ circuit_json_build_logs: [],
1648
+ circuit_json_build_error: "Build cancelled due to transpilation failure",
1649
+ build_in_progress: false,
1650
+ build_started_at: new Date(Date.now() - 15000).toISOString(),
1651
+ build_completed_at: new Date(Date.now() - 14000).toISOString(),
1652
+ build_error: "Build failed: Unable to complete transpilation step",
1653
+ build_error_last_updated_at: new Date(Date.now() - 14000).toISOString(),
1654
+ preview_url: null,
1655
+ build_logs:
1656
+ "Build process:\n" +
1657
+ "1. Environment setup - OK\n" +
1658
+ "2. Dependency resolution - OK\n" +
1659
+ "3. Code compilation - FAILED\n" +
1660
+ "Error: Invalid syntax in component declaration\n" +
1661
+ "Build terminated with errors",
1662
+ branch_name: "main",
1663
+ commit_message: "Attempted build of a555timer-square-wave package",
1664
+ commit_author: "testuser",
1665
+ })
1666
+
1667
+ // Add successful build
1668
+ const successfulBuild = db.addPackageBuild({
1669
+ package_release_id: packageReleaseId2,
1670
+ created_at: new Date().toISOString(),
1671
+ transpilation_in_progress: false,
1672
+ transpilation_started_at: new Date(Date.now() - 5000).toISOString(), // Started 5 seconds ago
1673
+ transpilation_completed_at: new Date(Date.now() - 3000).toISOString(), // Completed 3 seconds ago
1674
+ transpilation_logs: [
1675
+ "[INFO] Starting transpilation...",
1676
+ "[INFO] Parsing package code",
1677
+ "[INFO] Generating TypeScript definitions",
1678
+ "[INFO] Compiling to JavaScript",
1679
+ "[SUCCESS] Transpilation completed successfully",
1680
+ ],
1681
+ transpilation_error: null,
1682
+ circuit_json_build_in_progress: false,
1683
+ circuit_json_build_started_at: new Date(Date.now() - 3000).toISOString(), // Started after transpilation
1684
+ circuit_json_build_completed_at: new Date(Date.now() - 1000).toISOString(), // Completed 1 second ago
1685
+ circuit_json_build_logs: [
1686
+ "[INFO] Starting circuit JSON build...",
1687
+ "[INFO] Analyzing component structure",
1688
+ "[INFO] Generating port configurations",
1689
+ "[INFO] Validating circuit connections",
1690
+ "[SUCCESS] Circuit JSON build completed",
1691
+ ],
1692
+ circuit_json_build_error: null,
1693
+ build_in_progress: false,
1694
+ build_started_at: new Date(Date.now() - 10000).toISOString(), // Started 10 seconds ago
1695
+ build_completed_at: new Date().toISOString(), // Just completed
1696
+ build_error: null,
1697
+ build_error_last_updated_at: new Date().toISOString(),
1698
+ preview_url: "http://localhost:3000/preview/package_build_1",
1699
+ build_logs:
1700
+ "Build process:\n" +
1701
+ "1. Environment setup - OK\n" +
1702
+ "2. Dependency resolution - OK\n" +
1703
+ "3. Code compilation - OK\n" +
1704
+ "4. Circuit validation - OK\n" +
1705
+ "5. Package assembly - OK\n" +
1706
+ "Build completed successfully",
1707
+ branch_name: "main",
1708
+ commit_message: "Initial build of a555timer-square-wave package",
1709
+ commit_author: "testuser",
1710
+ })
1711
+
1712
+ // Update the package release with the latest (successful) build ID
1713
+ const release2 = db.getPackageReleaseById(packageReleaseId2)!
1714
+ db.updatePackageRelease({
1715
+ ...release2,
1716
+ latest_package_build_id: successfulBuild.package_build_id,
1717
+ })
1718
+
1582
1719
  db.addOrder({
1583
1720
  account_id,
1584
1721
  is_running: false,