@tscircuit/fake-snippets 0.0.94 → 0.0.96
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/api/generated-index.js +32 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/create.test.ts +1 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/get.test.ts +12 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/process_all_datasheets.test.ts +1 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/run_async_tasks.test.ts +1 -0
- package/dist/bundle.js +11 -6
- package/dist/index.d.ts +9 -4
- package/dist/index.js +7 -3
- package/dist/schema.d.ts +14 -6
- package/dist/schema.js +2 -1
- package/fake-snippets-api/lib/db/db-client.ts +4 -1
- package/fake-snippets-api/lib/db/schema.ts +1 -0
- package/fake-snippets-api/routes/api/_fake/datasheets/process_all_datasheets.ts +2 -1
- package/package.json +1 -1
- package/src/App.tsx +2 -0
- package/src/components/DownloadButtonAndMenu.tsx +3 -3
- package/src/components/ExpandableText.tsx +29 -0
- package/src/components/Header.tsx +11 -0
- package/src/components/Header2.tsx +6 -0
- package/src/components/PackageCard.tsx +11 -2
- package/src/components/PrefetchPageLink.tsx +11 -2
- package/src/components/ViewPackagePage/components/main-content-header.tsx +1 -1
- package/src/hooks/use-account-balance.ts +2 -1
- package/src/pages/datasheet.tsx +36 -15
- package/src/pages/datasheets.tsx +130 -0
package/api/generated-index.js
CHANGED
|
@@ -153,12 +153,34 @@ export async function handleUserProfile(req, res) {
|
|
|
153
153
|
res.status(200).send(html)
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
async function handleDatasheetPage(req, res) {
|
|
157
|
+
const parts = req.url.split("?")[0].split("/")
|
|
158
|
+
if (parts[1] !== "datasheets" || !parts[2]) {
|
|
159
|
+
throw new Error("Not a datasheet page")
|
|
160
|
+
}
|
|
161
|
+
const chipName = parts[2]
|
|
162
|
+
|
|
163
|
+
const html = getHtmlWithModifiedSeoTags({
|
|
164
|
+
title: `${chipName} Datasheet - tscircuit`,
|
|
165
|
+
description: `View the ${chipName} datasheet on tscircuit.`,
|
|
166
|
+
canonicalUrl: `${BASE_URL}/datasheets/${he.encode(chipName)}`,
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8")
|
|
170
|
+
res.setHeader("Cache-Control", cacheControlHeader)
|
|
171
|
+
res.setHeader("Vary", "Accept-Encoding")
|
|
172
|
+
res.status(200).send(html)
|
|
173
|
+
}
|
|
174
|
+
|
|
156
175
|
async function handleCustomPackageHtml(req, res) {
|
|
157
176
|
// Get the author and package name
|
|
158
177
|
const [_, author, unscopedPackageName] = req.url.split("?")[0].split("/")
|
|
159
178
|
if (!author || !unscopedPackageName) {
|
|
160
179
|
throw new Error("Invalid author/package URL")
|
|
161
180
|
}
|
|
181
|
+
if (author === "datasheets") {
|
|
182
|
+
throw new Error("Datasheet route")
|
|
183
|
+
}
|
|
162
184
|
|
|
163
185
|
const packageNotFoundHtml = getHtmlWithModifiedSeoTags({
|
|
164
186
|
title: "Package Not Found - tscircuit",
|
|
@@ -279,6 +301,16 @@ export default async function handler(req, res) {
|
|
|
279
301
|
console.warn(e)
|
|
280
302
|
}
|
|
281
303
|
|
|
304
|
+
const pathParts = req.url.split("?")[0].split("/")
|
|
305
|
+
if (pathParts[1] === "datasheets" && pathParts[2]) {
|
|
306
|
+
try {
|
|
307
|
+
await handleDatasheetPage(req, res)
|
|
308
|
+
return
|
|
309
|
+
} catch (e) {
|
|
310
|
+
console.warn(e)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
282
314
|
try {
|
|
283
315
|
await handleCustomPage(req, res)
|
|
284
316
|
return
|
|
@@ -12,4 +12,5 @@ test("create datasheet", async () => {
|
|
|
12
12
|
expect(res.data.datasheet.chip_name).toBe("TestChip")
|
|
13
13
|
expect(res.data.datasheet.pin_information).toBeNull()
|
|
14
14
|
expect(res.data.datasheet.datasheet_pdf_urls).toBeNull()
|
|
15
|
+
expect(res.data.datasheet.ai_description).toBeNull()
|
|
15
16
|
})
|
|
@@ -40,3 +40,15 @@ test("get datasheet by chip name 404", async () => {
|
|
|
40
40
|
})
|
|
41
41
|
expect(res.status).toBe(404)
|
|
42
42
|
})
|
|
43
|
+
|
|
44
|
+
test("get datasheet by chip name case insensitive", async () => {
|
|
45
|
+
const { axios } = await getTestServer()
|
|
46
|
+
await axios.post("/api/datasheets/create", { chip_name: "ChipCase" })
|
|
47
|
+
|
|
48
|
+
const res = await axios.get("/api/datasheets/get", {
|
|
49
|
+
params: { chip_name: "chipcase" },
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
expect(res.status).toBe(200)
|
|
53
|
+
expect(res.data.datasheet.chip_name).toBe("ChipCase")
|
|
54
|
+
})
|