@tscircuit/cli 0.0.132 → 0.0.134

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.
@@ -28,7 +28,7 @@ export default withWinterSpec({
28
28
  })
29
29
 
30
30
  const dev_package_example = await ctx.db.put("dev_package_example", {
31
- dev_package_example_id: existingDevPackageExample?.dev_package_example_id,
31
+ ...existingDevPackageExample,
32
32
  file_path: req.jsonBody.file_path,
33
33
  export_name: req.jsonBody.export_name,
34
34
  error: req.jsonBody.error,
@@ -37,7 +37,7 @@ export default withWinterSpec({
37
37
  )
38
38
 
39
39
  if (!dev_package_example) {
40
- throw new NotFoundError("Package not found")
40
+ return new Response("Package not found", { status: 404 })
41
41
  }
42
42
 
43
43
  return ctx.json({
@@ -23,7 +23,7 @@ export default withWinterSpec({
23
23
  )
24
24
 
25
25
  if (!dev_package_example) {
26
- throw new NotFoundError("Package not found")
26
+ return new Response("Package not found", { status: 404 })
27
27
  }
28
28
 
29
29
  const new_dev_package_example = {
@@ -25,7 +25,8 @@ export class ZodLevelDatabase {
25
25
  id: string | number
26
26
  ): Promise<DBSchemaType[K] | null> {
27
27
  const key = `${collection}:${id}`
28
- const data = await this.db.get(key)
28
+ const data = await this.db.get(key).catch((e) => null)
29
+ if (!data) return null
29
30
  return DBSchema.shape[collection].parse(JSON.parse(data)) as any
30
31
  }
31
32
 
@@ -0,0 +1,13 @@
1
+ import type { Middleware } from "winterspec"
2
+ import Debug from "debug"
3
+
4
+ const debug = Debug("tscircuit:cli:api")
5
+
6
+ export const withDebugRequestLogging: Middleware<{}, {}> = async (
7
+ req,
8
+ ctx,
9
+ next
10
+ ) => {
11
+ debug(`[REQ] ${req.method?.toUpperCase()} ${req.url}`)
12
+ return next(req, ctx)
13
+ }
@@ -1,8 +1,9 @@
1
1
  import { createWithWinterSpec } from "winterspec"
2
2
  import { withDb } from "./middlewares/with-db"
3
3
  import { withErrorResponse } from "./middlewares/with-error-response"
4
+ import { withDebugRequestLogging } from "./middlewares/with-debug-request-logging"
4
5
 
5
6
  export const withWinterSpec = createWithWinterSpec({
6
7
  authMiddleware: {},
7
- beforeAuthMiddleware: [withErrorResponse, withDb],
8
+ beforeAuthMiddleware: [withDebugRequestLogging, withErrorResponse, withDb],
8
9
  })
@@ -25,4 +25,14 @@ it("POST /api/dev_package_examples/update", async () => {
25
25
  expect(res.dev_package_example.edit_events_last_applied_at).toEqual(
26
26
  "2023-01-01T00:00:00.000Z"
27
27
  )
28
+
29
+ const getRes = await axios.post("/api/dev_package_examples/get", {
30
+ dev_package_example_id: 1,
31
+ })
32
+
33
+ expect(getRes.status).toBe(200)
34
+ expect(getRes.data.dev_package_example.completed_edit_events).toEqual([])
35
+ expect(getRes.data.dev_package_example.edit_events_last_applied_at).toEqual(
36
+ "2023-01-01T00:00:00.000Z"
37
+ )
28
38
  })
@@ -2673,9 +2673,9 @@
2673
2673
  }
2674
2674
  },
2675
2675
  "node_modules/@tscircuit/builder": {
2676
- "version": "1.5.142",
2677
- "resolved": "https://registry.npmjs.org/@tscircuit/builder/-/builder-1.5.142.tgz",
2678
- "integrity": "sha512-V/rUJmAWsHhBsIJi8umCfVbnE3FzGdIaqdsSGXBq8en8SdlkrWjJVHCgQAH/PPMCIwCxiHXfRF0U4CYptPGVOw==",
2676
+ "version": "1.5.143",
2677
+ "resolved": "https://registry.npmjs.org/@tscircuit/builder/-/builder-1.5.143.tgz",
2678
+ "integrity": "sha512-j3UkQ/TOUOH3TlUsM3SUTGA2LEoSEXMrVUGPMIwQNJgEsTaQOe+GWQcMdANfL8juUvYU2fCHrk2upuk8PNiQAg==",
2679
2679
  "license": "MIT",
2680
2680
  "dependencies": {
2681
2681
  "@lume/kiwi": "^0.1.0",