@tscircuit/cli 0.0.61 → 0.0.62
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/dev-server-api/routes/api/export_requests/create.ts +15 -41
- package/dev-server-api/src/db/create-schema.ts +1 -1
- package/dev-server-api/src/db/get-db.ts +4 -3
- package/dev-server-api/src/lib/public-mapping/public-map-export-request.ts +19 -0
- package/dev-server-api/src/lib/zod/export_request.ts +13 -0
- package/dist/cli.js +43 -29
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { withEdgeSpec } from "src/with-edge-spec"
|
|
2
2
|
import { NotFoundError } from "edgespec/middleware"
|
|
3
3
|
import { z } from "zod"
|
|
4
|
+
import { export_request } from "src/lib/zod/export_request"
|
|
5
|
+
import { publicMapExportRequest } from "src/lib/public-mapping/public-map-export-request"
|
|
4
6
|
|
|
5
7
|
export default withEdgeSpec({
|
|
6
8
|
methods: ["POST"],
|
|
@@ -17,51 +19,23 @@ export default withEdgeSpec({
|
|
|
17
19
|
}),
|
|
18
20
|
}),
|
|
19
21
|
jsonResponse: z.object({
|
|
20
|
-
export_request
|
|
21
|
-
export_request_id: z.coerce.number(),
|
|
22
|
-
created_at: z.string(),
|
|
23
|
-
file_summary: z.array(
|
|
24
|
-
z.object({
|
|
25
|
-
file_name: z.string(),
|
|
26
|
-
is_complete: z.boolean(),
|
|
27
|
-
})
|
|
28
|
-
),
|
|
29
|
-
}),
|
|
22
|
+
export_request,
|
|
30
23
|
}),
|
|
31
24
|
auth: "none",
|
|
32
25
|
})(async (req, ctx) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// last_updated_at: new Date().toISOString(),
|
|
45
|
-
// })
|
|
46
|
-
// .onConflict((oc) =>
|
|
47
|
-
// oc.columns(["file_path"]).doUpdateSet({
|
|
48
|
-
// export_name: req.jsonBody.export_name,
|
|
49
|
-
// error: req.jsonBody.error,
|
|
50
|
-
// tscircuit_soup,
|
|
51
|
-
// is_loading: req.jsonBody.is_loading ? 1 : 0,
|
|
52
|
-
// last_updated_at: new Date().toISOString(),
|
|
53
|
-
// })
|
|
54
|
-
// )
|
|
55
|
-
// .returningAll()
|
|
56
|
-
// .executeTakeFirstOrThrow()
|
|
57
|
-
|
|
58
|
-
const export_request = {
|
|
59
|
-
export_request_id: 1,
|
|
60
|
-
created_at: new Date().toISOString(),
|
|
61
|
-
file_summary: [],
|
|
62
|
-
}
|
|
26
|
+
const db_export_request = await ctx.db
|
|
27
|
+
.insertInto("export_request")
|
|
28
|
+
.values({
|
|
29
|
+
example_file_path: req.jsonBody.example_file_path,
|
|
30
|
+
export_parameters: JSON.stringify(req.jsonBody.export_parameters),
|
|
31
|
+
export_name: req.jsonBody.export_name ?? "default",
|
|
32
|
+
is_complete: 0,
|
|
33
|
+
created_at: new Date().toISOString(),
|
|
34
|
+
})
|
|
35
|
+
.returningAll()
|
|
36
|
+
.executeTakeFirstOrThrow()
|
|
63
37
|
|
|
64
38
|
return ctx.json({
|
|
65
|
-
export_request,
|
|
39
|
+
export_request: publicMapExportRequest(db_export_request),
|
|
66
40
|
})
|
|
67
41
|
})
|
|
@@ -20,7 +20,7 @@ export const createSchema = async (db: DbClient) => {
|
|
|
20
20
|
col.primaryKey().autoIncrement()
|
|
21
21
|
)
|
|
22
22
|
.addColumn("example_file_path", "text")
|
|
23
|
-
.addColumn("export_parameters", "
|
|
23
|
+
.addColumn("export_parameters", "json")
|
|
24
24
|
.addColumn("export_name", "text")
|
|
25
25
|
.addColumn("is_complete", "boolean", (col) => col.defaultTo(0).notNull())
|
|
26
26
|
.addColumn("created_at", "text")
|
|
@@ -3,7 +3,7 @@ import { createSchema } from "./create-schema"
|
|
|
3
3
|
import { mkdirSync } from "fs"
|
|
4
4
|
import * as Path from "path"
|
|
5
5
|
|
|
6
|
-
interface DevPackageExample {
|
|
6
|
+
export interface DevPackageExample {
|
|
7
7
|
dev_package_example_id: Generated<number>
|
|
8
8
|
tscircuit_soup: any
|
|
9
9
|
file_path: string
|
|
@@ -13,15 +13,16 @@ interface DevPackageExample {
|
|
|
13
13
|
last_updated_at: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
interface ExportRequest {
|
|
16
|
+
export interface ExportRequest {
|
|
17
17
|
export_request_id: Generated<number>
|
|
18
18
|
example_file_path: string
|
|
19
|
+
export_parameters: string
|
|
19
20
|
export_name: string
|
|
20
21
|
is_complete: 1 | 0
|
|
21
22
|
created_at: string
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
interface ExportFile {
|
|
25
|
+
export interface ExportFile {
|
|
25
26
|
export_file_id: Generated<number>
|
|
26
27
|
file_name: string
|
|
27
28
|
file_content: Buffer
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ExportRequest } from "src/db/get-db"
|
|
2
|
+
import { export_request } from "src/lib/zod/export_request"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
export const publicMapExportRequest = (db_export_request: {
|
|
6
|
+
export_request_id: number
|
|
7
|
+
example_file_path: string
|
|
8
|
+
export_parameters: string
|
|
9
|
+
export_name: string
|
|
10
|
+
is_complete: 1 | 0
|
|
11
|
+
created_at: string
|
|
12
|
+
}): z.infer<typeof export_request> => {
|
|
13
|
+
return {
|
|
14
|
+
export_request_id: db_export_request.export_request_id as any,
|
|
15
|
+
is_completed: db_export_request.is_complete === 1,
|
|
16
|
+
created_at: db_export_request.created_at,
|
|
17
|
+
file_summary: [],
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
export const export_request = z.object({
|
|
4
|
+
export_request_id: z.coerce.number(),
|
|
5
|
+
is_completed: z.boolean(),
|
|
6
|
+
created_at: z.string(),
|
|
7
|
+
file_summary: z.array(
|
|
8
|
+
z.object({
|
|
9
|
+
file_name: z.string(),
|
|
10
|
+
is_complete: z.boolean(),
|
|
11
|
+
})
|
|
12
|
+
),
|
|
13
|
+
})
|