@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
@@ -7,7 +7,7 @@ import { TreeView, TreeDataItem } from "@/components/ui/tree-view"
7
7
  import { cn } from "@/lib/utils"
8
8
  import { PrefetchPageLink } from "@/components/PrefetchPageLink"
9
9
  import NotFoundPage from "./404"
10
- import { getBuildStatus, MOCK_DEPLOYMENTS } from "@/components/preview"
10
+ import { getBuildStatus, MOCK_PACKAGE_BUILDS } from "@/components/preview"
11
11
 
12
12
  const MOCK_DEPLOYMENT_FILES: Record<
13
13
  string,
@@ -189,8 +189,8 @@ export default function PreviewBuildPage() {
189
189
  const buildFsMap = getBuildFsMap(buildId)
190
190
 
191
191
  const build = buildId
192
- ? MOCK_DEPLOYMENTS.find((d) => d.package_build_id === buildId)
193
- : MOCK_DEPLOYMENTS[0]
192
+ ? MOCK_PACKAGE_BUILDS.find((d) => d.package_build_id === buildId)
193
+ : MOCK_PACKAGE_BUILDS[0]
194
194
 
195
195
  if (!build) {
196
196
  return <NotFoundPage heading="Build Not Found" />
@@ -0,0 +1,107 @@
1
+ import { useParams } from "wouter"
2
+ import NotFoundPage from "./404"
3
+ import { usePackageByName } from "@/hooks/use-package-by-package-name"
4
+ import { usePackageReleaseByIdOrVersion } from "@/hooks/use-package-release-by-id-or-version"
5
+ import { usePackageBuildsByReleaseId } from "@/hooks/use-package-builds"
6
+ import { BuildsList } from "@/components/preview/BuildsList"
7
+ import Header from "@/components/Header"
8
+ import { useLocation } from "wouter"
9
+ import { PackageBreadcrumb } from "@/components/PackageBreadcrumb"
10
+ import { PackageBuild } from "fake-snippets-api/lib/db/schema"
11
+
12
+ export default function ReleaseBuildsPage() {
13
+ const params = useParams<{
14
+ author: string
15
+ packageName: string
16
+ releaseId: string
17
+ }>()
18
+
19
+ const packageName =
20
+ params?.author && params?.packageName
21
+ ? `${params.author}/${params.packageName}`
22
+ : null
23
+
24
+ const [, setLocation] = useLocation()
25
+
26
+ const {
27
+ data: pkg,
28
+ isLoading: isLoadingPackage,
29
+ error: packageError,
30
+ } = usePackageByName(packageName)
31
+
32
+ const {
33
+ data: packageRelease,
34
+ isLoading: isLoadingRelease,
35
+ error: releaseError,
36
+ } = usePackageReleaseByIdOrVersion(params?.releaseId ?? null, packageName)
37
+
38
+ const {
39
+ data: builds,
40
+ isLoading: isLoadingBuilds,
41
+ error: buildsError,
42
+ } = usePackageBuildsByReleaseId(params?.releaseId ?? null)
43
+
44
+ const handleSelectBuild = (build: PackageBuild) => {
45
+ setLocation(`/build/${build.package_build_id}`)
46
+ }
47
+
48
+ if (isLoadingPackage || isLoadingRelease || isLoadingBuilds) {
49
+ return null
50
+ }
51
+
52
+ if (packageError?.status === 404 || !pkg) {
53
+ return <NotFoundPage heading="Package Not Found" />
54
+ }
55
+
56
+ if (releaseError?.status === 404 || !packageRelease) {
57
+ return <NotFoundPage heading="Release Not Found" />
58
+ }
59
+
60
+ if (buildsError?.status === 404 || !builds?.length) {
61
+ return <NotFoundPage heading="No Builds Found for Release" />
62
+ }
63
+
64
+ return (
65
+ <>
66
+ <Header />
67
+ <div className="min-h-screen bg-white">
68
+ <div className="bg-gray-50 border-b py-10">
69
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
70
+ <PackageBreadcrumb
71
+ author={params?.author || ""}
72
+ packageName={packageName || ""}
73
+ unscopedName={pkg.unscoped_name}
74
+ currentPage="builds"
75
+ releaseVersion={
76
+ packageRelease.version ||
77
+ `v${packageRelease.package_release_id.slice(-6)}`
78
+ }
79
+ />
80
+ <div className="flex items-center gap-4">
81
+ <div>
82
+ <h1 className="text-3xl font-bold text-gray-900">
83
+ {pkg.name} - Release Builds
84
+ </h1>
85
+ <p className="text-gray-600 mt-2">
86
+ All builds for release {packageRelease.package_release_id}
87
+ </p>
88
+ </div>
89
+ </div>
90
+ </div>
91
+ </div>
92
+
93
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
94
+ <div className="space-y-6">
95
+ <div className="flex items-center justify-between">
96
+ <h2 className="text-2xl font-bold text-gray-900">All Builds</h2>
97
+ <p className="text-sm text-gray-600">
98
+ {builds?.length} build{builds?.length !== 1 ? "s" : ""} found
99
+ </p>
100
+ </div>
101
+ {pkg && <BuildsList pkg={pkg} />}
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </>
106
+ )
107
+ }
@@ -0,0 +1,118 @@
1
+ import { useParams } from "wouter"
2
+ import NotFoundPage from "./404"
3
+ import { usePackageByName } from "@/hooks/use-package-by-package-name"
4
+ import { usePackageReleaseByIdOrVersion } from "@/hooks/use-package-release-by-id-or-version"
5
+ import { usePackageBuild } from "@/hooks/use-package-builds"
6
+ import { ConnectedRepoOverview } from "@/components/preview/ConnectedRepoOverview"
7
+ import Header from "@/components/Header"
8
+ import { Badge } from "@/components/ui/badge"
9
+ import { Button } from "@/components/ui/button"
10
+ import { Calendar, GitBranch, Hash, Copy, Check } from "lucide-react"
11
+ import { useState } from "react"
12
+ import { formatTimeAgo } from "@/lib/utils/formatTimeAgo"
13
+ import { PackageBreadcrumb } from "@/components/PackageBreadcrumb"
14
+
15
+ export default function ReleaseDetailPage() {
16
+ const params = useParams<{
17
+ author: string
18
+ packageName: string
19
+ releaseId?: string
20
+ packageReleaseId?: string
21
+ }>()
22
+
23
+ const packageName =
24
+ params?.author && params?.packageName
25
+ ? `${params.author}/${params.packageName}`
26
+ : null
27
+
28
+ const [copied, setCopied] = useState(false)
29
+
30
+ const {
31
+ data: pkg,
32
+ isLoading: isLoadingPackage,
33
+ error: packageError,
34
+ } = usePackageByName(packageName)
35
+
36
+ const releaseIdOrVersion =
37
+ params?.releaseId ?? params?.packageReleaseId ?? null
38
+
39
+ const {
40
+ data: packageRelease,
41
+ isLoading: isLoadingRelease,
42
+ error: releaseError,
43
+ } = usePackageReleaseByIdOrVersion(releaseIdOrVersion, packageName)
44
+
45
+ const {
46
+ data: latestBuild,
47
+ isLoading: isLoadingBuild,
48
+ error: buildError,
49
+ } = usePackageBuild(packageRelease?.latest_package_build_id ?? null)
50
+
51
+ if (isLoadingPackage || isLoadingRelease || isLoadingBuild) {
52
+ return null
53
+ }
54
+
55
+ if (packageError?.status === 404 || !pkg) {
56
+ return <NotFoundPage heading="Package Not Found" />
57
+ }
58
+
59
+ if (releaseError?.status === 404 || !packageRelease) {
60
+ return <NotFoundPage heading="Release Not Found" />
61
+ }
62
+
63
+ if (buildError?.status === 404 || !latestBuild) {
64
+ return <NotFoundPage heading="No Builds Found for Release" />
65
+ }
66
+
67
+ return (
68
+ <>
69
+ <Header />
70
+ <div className="min-h-screen bg-white">
71
+ {/* Page Header */}
72
+ <div className="bg-gray-50 border-b py-6">
73
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
74
+ {/* Breadcrumb */}
75
+ <PackageBreadcrumb
76
+ author={pkg.owner_github_username || ""}
77
+ packageName={pkg.name}
78
+ unscopedName={pkg.unscoped_name}
79
+ releaseVersion={
80
+ packageRelease.version ||
81
+ `v${packageRelease.package_release_id.slice(-6)}`
82
+ }
83
+ />
84
+
85
+ {/* Header Content */}
86
+ <div className="flex flex-col lg:flex-row lg:items-start lg:justify-between gap-2">
87
+ <div className="flex-1">
88
+ <div className="flex items-center gap-4 text-sm text-gray-600">
89
+ {packageRelease.is_pr_preview && (
90
+ <div className="flex items-center gap-1">
91
+ <GitBranch className="w-4 h-4" />
92
+ <Badge variant="outline" className="text-xs">
93
+ PR #{packageRelease.github_pr_number}
94
+ </Badge>
95
+ </div>
96
+ )}
97
+ <div className="flex items-center gap-1">
98
+ <Calendar className="w-4 h-4" />
99
+ <span>
100
+ Created {formatTimeAgo(packageRelease.created_at)}
101
+ </span>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ </div>
107
+ </div>
108
+
109
+ {/* Main Content */}
110
+ <ConnectedRepoOverview
111
+ build={latestBuild}
112
+ pkg={pkg}
113
+ packageRelease={packageRelease}
114
+ />
115
+ </div>
116
+ </>
117
+ )
118
+ }
@@ -0,0 +1,51 @@
1
+ import { useParams } from "wouter"
2
+ import NotFoundPage from "./404"
3
+ import { useLatestPackageRelease } from "@/hooks/use-package-release"
4
+ import { usePackageBuild } from "@/hooks/use-package-builds"
5
+ import { usePackageByName } from "@/hooks/use-package-by-package-name"
6
+ import { PackageReleasesDashboard } from "@/components/preview/PackageReleasesDashboard"
7
+
8
+ export default function ReleasesPage() {
9
+ const params = useParams<{ author: string; packageName: string }>()
10
+ const packageName =
11
+ params?.author && params?.packageName
12
+ ? `${params.author}/${params.packageName}`
13
+ : null
14
+
15
+ const {
16
+ data: pkg,
17
+ isLoading: isLoadingPackage,
18
+ error: packageError,
19
+ } = usePackageByName(packageName)
20
+
21
+ const {
22
+ data: latestRelease,
23
+ isLoading: isLoadingRelease,
24
+ error: releaseError,
25
+ } = useLatestPackageRelease(pkg?.package_id ?? null)
26
+
27
+ // Get the latest build for the latest release to show status and metadata
28
+ const {
29
+ data: latestBuild,
30
+ isLoading: isLoadingBuild,
31
+ error: buildError,
32
+ } = usePackageBuild(latestRelease?.latest_package_build_id ?? null)
33
+
34
+ if (isLoadingPackage || isLoadingRelease || isLoadingBuild) {
35
+ return null
36
+ }
37
+
38
+ if (packageError?.status === 404 || !pkg) {
39
+ return <NotFoundPage heading="Package Not Found" />
40
+ }
41
+
42
+ if (releaseError?.status === 404 || !latestRelease) {
43
+ return <NotFoundPage heading="No Releases Found" />
44
+ }
45
+
46
+ // If there's no build, we still want to show the releases page
47
+ // The PackageReleasesDashboard will handle the case where latestBuild is null
48
+ return (
49
+ <PackageReleasesDashboard latestBuild={latestBuild ?? null} pkg={pkg} />
50
+ )
51
+ }
@@ -1,18 +0,0 @@
1
- import { useParams } from "wouter"
2
- import NotFoundPage from "./404"
3
- import { ConnectedRepoDashboard, MOCK_DEPLOYMENTS } from "@/components/preview"
4
-
5
- export default function ViewConnectedRepoOverview() {
6
- const params = useParams<{ buildId: string }>()
7
- const buildId = params?.buildId || null
8
-
9
- const selectedBuild = buildId
10
- ? MOCK_DEPLOYMENTS.find((d) => d.package_build_id === buildId)
11
- : MOCK_DEPLOYMENTS[0]
12
-
13
- if (!selectedBuild) {
14
- return <NotFoundPage heading="Build Not Found" />
15
- }
16
-
17
- return <ConnectedRepoDashboard latestBuild={selectedBuild} />
18
- }