@tscircuit/cli 0.0.394 → 0.1.1
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/.github/workflows/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-pver-release.yml +25 -0
- package/.github/workflows/{typecheck.yml → bun-typecheck.yml} +0 -3
- package/LICENSE +21 -0
- package/README.md +30 -36
- package/biome.json +9 -9
- package/bun.lockb +0 -0
- package/cli/CliContext.ts +8 -0
- package/cli/auth/login/register.ts +73 -0
- package/cli/auth/logout/register.ts +11 -0
- package/cli/auth/register.ts +5 -0
- package/cli/config/print/register.ts +12 -0
- package/cli/config/register.ts +5 -0
- package/cli/dev/register.ts +111 -0
- package/cli/main.ts +31 -0
- package/dist/main.js +473 -0
- package/docs/file-server-api-usage.md +57 -0
- package/docs/run-frame-usage.md +14 -0
- package/example-dir/manual-edits.json +1 -0
- package/example-dir/snippet.d.ts +13 -0
- package/example-dir/snippet.tsx +20 -0
- package/example-dir/types.d.ts +11 -0
- package/lib/cli-config/TypedConfigStore.ts +50 -0
- package/lib/cli-config/index.ts +16 -0
- package/lib/dependency-analysis/DependencyAnalyzer.ts +129 -0
- package/lib/dependency-analysis/getLocalFileDependencies.ts +101 -0
- package/lib/dependency-analysis/installNodeModuleTypes.ts +74 -0
- package/lib/index.ts +2 -0
- package/lib/project-config/index.ts +5 -0
- package/lib/registry-api/endpoint-types.ts +20 -0
- package/lib/registry-api/get-ky.ts +30 -0
- package/lib/server/EventsWatcher.ts +75 -0
- package/lib/server/createServer.ts +62 -0
- package/lib/site/getIndex.ts +18 -0
- package/package.json +27 -144
- package/tsconfig.json +25 -22
- package/.github/workflows/formatbot.yml +0 -63
- package/.github/workflows/release.yml +0 -40
- package/.github/workflows/test.yml +0 -32
- package/.github/workflows/windows-tests.yml +0 -32
- package/.prettierrc +0 -1
- package/DEVELOPMENT.md +0 -7
- package/api/README.md +0 -3
- package/api/db/generic-json-level.ts +0 -123
- package/api/db/get-db.ts +0 -26
- package/api/db/schema.ts +0 -65
- package/api/db/zod-level-db.ts +0 -148
- package/api/index.ts +0 -4
- package/api/lib/middlewares/with-db.ts +0 -18
- package/api/lib/middlewares/with-debug-request-logging.ts +0 -13
- package/api/lib/middlewares/with-error-response.ts +0 -37
- package/api/lib/with-winter-spec.ts +0 -9
- package/api/lib/zod/export_parameters.ts +0 -25
- package/api/routes/api/db/download.ts +0 -25
- package/api/routes/api/dev_package_examples/create.ts +0 -43
- package/api/routes/api/dev_package_examples/get.ts +0 -46
- package/api/routes/api/dev_package_examples/list.ts +0 -36
- package/api/routes/api/dev_package_examples/update.ts +0 -59
- package/api/routes/api/dev_server/reset.ts +0 -13
- package/api/routes/api/export_files/create.ts +0 -27
- package/api/routes/api/export_files/download.ts +0 -25
- package/api/routes/api/export_requests/create.ts +0 -30
- package/api/routes/api/export_requests/get.ts +0 -43
- package/api/routes/api/export_requests/list.ts +0 -26
- package/api/routes/api/export_requests/update.ts +0 -34
- package/api/routes/api/health.ts +0 -11
- package/api/routes/api/package_info/create.ts +0 -26
- package/api/routes/api/package_info/get.ts +0 -16
- package/api/routes/health.ts +0 -11
- package/api/routes/index.ts +0 -16
- package/api/server.ts +0 -20
- package/api/static-routes.ts +0 -24
- package/api/tests/fixtures/get-test-server.ts +0 -31
- package/api/tests/fixtures/start-server.ts +0 -41
- package/api/tests/routes/dev_package_examples/create.test.ts +0 -19
- package/api/tests/routes/dev_package_examples/get.test.ts +0 -25
- package/api/tests/routes/dev_package_examples/list.test.ts +0 -32
- package/api/tests/routes/dev_package_examples/update.test.ts +0 -38
- package/api/tests/routes/export_files/create.test.ts +0 -18
- package/api/tests/routes/export_files/download.test.ts +0 -29
- package/api/tests/routes/export_requests/create.test.ts +0 -24
- package/api/tests/routes/export_requests/get.test.ts +0 -41
- package/api/tests/routes/export_requests/list.test.ts +0 -35
- package/api/tests/routes/export_requests/update.test.ts +0 -50
- package/api/tests/routes/health.test.ts +0 -10
- package/bunfig.toml +0 -2
- package/cli/cli.ts +0 -13
- package/cli/lib/cmd-fns/add.ts +0 -34
- package/cli/lib/cmd-fns/auth-login.ts +0 -59
- package/cli/lib/cmd-fns/auth-logout.ts +0 -7
- package/cli/lib/cmd-fns/auth-sessions-create.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-get.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-list.ts +0 -5
- package/cli/lib/cmd-fns/config-clear.ts +0 -5
- package/cli/lib/cmd-fns/config-print-config.ts +0 -6
- package/cli/lib/cmd-fns/config-reveal-location.ts +0 -5
- package/cli/lib/cmd-fns/config-set-log-requests.ts +0 -7
- package/cli/lib/cmd-fns/config-set-registry.ts +0 -9
- package/cli/lib/cmd-fns/config-set-runtime.ts +0 -7
- package/cli/lib/cmd-fns/config-set-session.ts +0 -7
- package/cli/lib/cmd-fns/dev/check-if-initialized.ts +0 -22
- package/cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -23
- package/cli/lib/cmd-fns/dev/dev-server-request-handler.ts +0 -61
- package/cli/lib/cmd-fns/dev/find-available-port.ts +0 -32
- package/cli/lib/cmd-fns/dev/fulfill-export-requests.ts +0 -162
- package/cli/lib/cmd-fns/dev/get-dev-server-axios.ts +0 -29
- package/cli/lib/cmd-fns/dev/index.ts +0 -168
- package/cli/lib/cmd-fns/dev/infer-export-name-from-source.ts +0 -17
- package/cli/lib/cmd-fns/dev/mark-all-examples-loading.ts +0 -18
- package/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +0 -62
- package/cli/lib/cmd-fns/dev/start-dev-server.ts +0 -34
- package/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +0 -347
- package/cli/lib/cmd-fns/dev/start-export-request-watcher.ts +0 -33
- package/cli/lib/cmd-fns/dev/start-fs-watcher.ts +0 -54
- package/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +0 -42
- package/cli/lib/cmd-fns/dev-server-fulfill-export-requests.ts +0 -43
- package/cli/lib/cmd-fns/dev-server-upload.ts +0 -56
- package/cli/lib/cmd-fns/export-gerbers.ts +0 -28
- package/cli/lib/cmd-fns/export-kicad-pcb.ts +0 -36
- package/cli/lib/cmd-fns/export-pnp-csv.ts +0 -32
- package/cli/lib/cmd-fns/gen-jlcpcb-component.ts +0 -64
- package/cli/lib/cmd-fns/go.ts +0 -14
- package/cli/lib/cmd-fns/index.ts +0 -46
- package/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +0 -21
- package/cli/lib/cmd-fns/init/get-generated-npmrc.ts +0 -8
- package/cli/lib/cmd-fns/init/get-generated-readme.ts +0 -41
- package/cli/lib/cmd-fns/init/get-generated-tsconfig.ts +0 -34
- package/cli/lib/cmd-fns/init/index.ts +0 -193
- package/cli/lib/cmd-fns/install.ts +0 -34
- package/cli/lib/cmd-fns/lint.ts +0 -43
- package/cli/lib/cmd-fns/open.ts +0 -19
- package/cli/lib/cmd-fns/package-examples-create.ts +0 -36
- package/cli/lib/cmd-fns/package-examples-get.ts +0 -20
- package/cli/lib/cmd-fns/package-examples-list.ts +0 -18
- package/cli/lib/cmd-fns/package-files-create.ts +0 -31
- package/cli/lib/cmd-fns/package-files-download.ts +0 -29
- package/cli/lib/cmd-fns/package-files-get.ts +0 -3
- package/cli/lib/cmd-fns/package-files-list.ts +0 -28
- package/cli/lib/cmd-fns/package-files-upload-directory.ts +0 -6
- package/cli/lib/cmd-fns/package-releases-create.ts +0 -35
- package/cli/lib/cmd-fns/package-releases-get.ts +0 -3
- package/cli/lib/cmd-fns/package-releases-list.ts +0 -32
- package/cli/lib/cmd-fns/package-releases-update.ts +0 -45
- package/cli/lib/cmd-fns/packages-create.ts +0 -16
- package/cli/lib/cmd-fns/packages-get.ts +0 -16
- package/cli/lib/cmd-fns/packages-list.ts +0 -16
- package/cli/lib/cmd-fns/publish/index.ts +0 -336
- package/cli/lib/cmd-fns/remove.ts +0 -31
- package/cli/lib/cmd-fns/render.ts +0 -45
- package/cli/lib/cmd-fns/soupify.ts +0 -31
- package/cli/lib/cmd-fns/uninstall.ts +0 -31
- package/cli/lib/cmd-fns/version.ts +0 -38
- package/cli/lib/create-config-manager.ts +0 -97
- package/cli/lib/export-fns/export-bom-csv.ts +0 -32
- package/cli/lib/export-fns/export-gerbers.ts +0 -108
- package/cli/lib/export-fns/export-kicad-pcb.ts +0 -32
- package/cli/lib/export-fns/export-pnp-csv.ts +0 -31
- package/cli/lib/get-program.ts +0 -387
- package/cli/lib/param-handlers/index.ts +0 -21
- package/cli/lib/param-handlers/interact-for-local-directory.ts +0 -58
- package/cli/lib/param-handlers/interact-for-local-file.ts +0 -59
- package/cli/lib/param-handlers/interact-for-package-example-id.ts +0 -25
- package/cli/lib/param-handlers/interact-for-package-name-with-version.ts +0 -63
- package/cli/lib/param-handlers/interact-for-package-name.ts +0 -45
- package/cli/lib/param-handlers/interact-for-package-release-id.ts +0 -15
- package/cli/lib/param-handlers/interact-for-registry-url.ts +0 -27
- package/cli/lib/param-handlers/interact-for-runtime.ts +0 -33
- package/cli/lib/param-handlers/param-handler-type.ts +0 -7
- package/cli/lib/posthog.ts +0 -23
- package/cli/lib/soupify/get-export-name-from-file.ts +0 -29
- package/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +0 -15
- package/cli/lib/soupify/index.ts +0 -1
- package/cli/lib/soupify/run-entrypoint-file.ts +0 -59
- package/cli/lib/soupify/soupify-with-core.ts +0 -74
- package/cli/lib/soupify/soupify.ts +0 -6
- package/cli/lib/util/app-context.ts +0 -17
- package/cli/lib/util/create-context-and-run-program.ts +0 -168
- package/cli/lib/util/get-all-package-files.ts +0 -66
- package/cli/lib/util/lint-project.ts +0 -137
- package/cli/tests/export-gerber-keyboard.test.ts +0 -16
- package/cli/tests/export-gerber.test.ts +0 -49
- package/cli/tests/export-kicad-pcb.test.ts +0 -23
- package/cli/tests/export-pnp-csv.test.ts +0 -24
- package/cli/tests/fixtures/preload.ts +0 -54
- package/cli/tests/init.test.ts +0 -9
- package/cli/tests/open.test.ts +0 -9
- package/cli/tests/soupify-builder.test.ts +0 -9
- package/cli/tests/soupify-core.test.ts +0 -9
- package/dist/cli.js +0 -3676
- package/docs/EDIT_EVENT_PIPELINE.md +0 -34
- package/example-project/README.md +0 -18
- package/example-project/examples/basic-capacitor.tsx +0 -5
- package/example-project/examples/basic-chip.tsx +0 -26
- package/example-project/examples/basic-resistor.tsx +0 -3
- package/example-project/examples/macrokeypad.tsx +0 -59
- package/example-project/index.ts +0 -1
- package/example-project/package.json +0 -5
- package/example-project/src/ArduinoProMicroBreakout.tsx +0 -37
- package/example-project/src/Key.tsx +0 -46
- package/example-project/src/Keyswitch.tsx +0 -26
- package/example-project/src/KeyswitchSocket.tsx +0 -56
- package/example-project/src/MyCircuit.tsx +0 -38
- package/example-project/src/manual-edits.ts +0 -93
- package/frontend/README.md +0 -3
- package/frontend/bun.lockb +0 -0
- package/frontend/components/command-k.tsx +0 -86
- package/frontend/components/dialogs/generic-export-dialog.tsx +0 -189
- package/frontend/components/dialogs/gerber-export-dialog.tsx +0 -168
- package/frontend/components/global-context-providers.tsx +0 -11
- package/frontend/components/select-example-search.tsx +0 -118
- package/frontend/components/ui/alert-dialog.tsx +0 -139
- package/frontend/components/ui/alert.tsx +0 -59
- package/frontend/components/ui/breadcrumb.tsx +0 -115
- package/frontend/components/ui/button.tsx +0 -57
- package/frontend/components/ui/card.tsx +0 -76
- package/frontend/components/ui/command.tsx +0 -153
- package/frontend/components/ui/context-menu.tsx +0 -202
- package/frontend/components/ui/dialog.tsx +0 -120
- package/frontend/components/ui/menubar.tsx +0 -238
- package/frontend/components/ui/navigation-menu.tsx +0 -128
- package/frontend/components/ui/popover.tsx +0 -31
- package/frontend/components/ui/select.tsx +0 -162
- package/frontend/components/ui/tabs.tsx +0 -53
- package/frontend/components/ui/toggle-group.tsx +0 -59
- package/frontend/components/ui/toggle.tsx +0 -43
- package/frontend/components/ui/tooltip.tsx +0 -28
- package/frontend/components.json +0 -17
- package/frontend/hooks/toast-if-api-not-connected.ts +0 -23
- package/frontend/hooks/use-active-dev-package-example-lite.ts +0 -39
- package/frontend/hooks/use-dev-package-examples.tsx +0 -18
- package/frontend/hooks/use-global-store.ts +0 -42
- package/frontend/index.css +0 -76
- package/frontend/index.html +0 -13
- package/frontend/lib/utils.ts +0 -6
- package/frontend/main.tsx +0 -13
- package/frontend/tailwind.config.js +0 -74
- package/frontend/views/App.tsx +0 -22
- package/frontend/views/Header.tsx +0 -55
- package/frontend/views/HeaderMenu.tsx +0 -326
- package/frontend/views/MainContentView.tsx +0 -172
- package/frontend/vite-env.d.ts +0 -1
- package/frontend/vite.config.ts +0 -50
- package/renovate.json +0 -16
- package/scripts/build-cli.ts +0 -12
- package/tsup.config.ts +0 -7
package/api/db/zod-level-db.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// import { Level } from "level"
|
|
2
|
-
// import { GenericJsonLevel } from "./generic-json-level"
|
|
3
|
-
import { MemoryLevel } from "memory-level"
|
|
4
|
-
import { z } from "zod"
|
|
5
|
-
import { DBSchema, type DBSchemaType, type DBInputSchemaType } from "./schema"
|
|
6
|
-
|
|
7
|
-
// Create a wrapper class for Level with Zod validation
|
|
8
|
-
export class ZodLevelDatabase {
|
|
9
|
-
private db: MemoryLevel<string, any>
|
|
10
|
-
|
|
11
|
-
constructor(location: string) {
|
|
12
|
-
this.db = new MemoryLevel() // new GenericJsonLevel(location)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async open() {
|
|
16
|
-
return this.db.open()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async close() {
|
|
20
|
-
return this.db.close()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async get<K extends keyof DBSchemaType>(
|
|
24
|
-
collection: K,
|
|
25
|
-
id: string | number,
|
|
26
|
-
): Promise<DBSchemaType[K] | null> {
|
|
27
|
-
const key = `${collection}:${id}`
|
|
28
|
-
const data = await this.db.get(key).catch((e) => null)
|
|
29
|
-
if (!data) return null
|
|
30
|
-
return DBSchema.shape[collection].parse(JSON.parse(data)) as any
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async put<K extends keyof DBSchemaType>(
|
|
34
|
-
collection: K,
|
|
35
|
-
value: DBInputSchemaType[K],
|
|
36
|
-
): Promise<DBSchemaType[K]> {
|
|
37
|
-
const idkey = `${collection}_id`
|
|
38
|
-
const valueLoose: any = value
|
|
39
|
-
if (!valueLoose[idkey]) {
|
|
40
|
-
// generate an id using the "count" key
|
|
41
|
-
let count = await this.db.get(`${collection}.count`).catch(() => 1)
|
|
42
|
-
if (typeof count === "string") count = parseInt(count)
|
|
43
|
-
;(value as any)[idkey] = count
|
|
44
|
-
await this.db.put(`${collection}.count`, (count + 1).toString())
|
|
45
|
-
}
|
|
46
|
-
const key = `${collection}:${valueLoose[idkey]}`
|
|
47
|
-
const validatedData = DBSchema.shape[collection].parse(value)
|
|
48
|
-
await this.db.put(key, JSON.stringify(validatedData))
|
|
49
|
-
return validatedData as DBSchemaType[K]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async del<K extends keyof DBSchemaType>(
|
|
53
|
-
collection: K,
|
|
54
|
-
id: string,
|
|
55
|
-
): Promise<void> {
|
|
56
|
-
const key = `${collection}:${id}`
|
|
57
|
-
await this.db.del(key)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async find<K extends keyof DBSchemaType>(
|
|
61
|
-
collection: K,
|
|
62
|
-
partialObject: Partial<DBSchemaType[K]>,
|
|
63
|
-
): Promise<DBSchemaType[K] | null> {
|
|
64
|
-
const schema = DBSchema.shape[collection]
|
|
65
|
-
|
|
66
|
-
for await (const [key, value] of this.db.iterator({
|
|
67
|
-
gte: `${collection}:`,
|
|
68
|
-
lte: `${collection}:\uffff`,
|
|
69
|
-
})) {
|
|
70
|
-
try {
|
|
71
|
-
const parsedValue = schema.parse(JSON.parse(value))
|
|
72
|
-
if (this.matchesPartialObject(parsedValue, partialObject)) {
|
|
73
|
-
return parsedValue as any
|
|
74
|
-
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error(`Error parsing value for key ${key}:`, error)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return null
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async findOrThrow<K extends keyof DBSchemaType>(
|
|
84
|
-
collection: K,
|
|
85
|
-
partialObject: Partial<DBSchemaType[K]>,
|
|
86
|
-
): Promise<DBSchemaType[K]> {
|
|
87
|
-
const result = await this.find(collection, partialObject)
|
|
88
|
-
if (!result) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`No record in "${collection}" matches query ${JSON.stringify(
|
|
91
|
-
partialObject,
|
|
92
|
-
)}`,
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
return result
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private matchesPartialObject<T>(
|
|
99
|
-
fullObject: T,
|
|
100
|
-
partialObject: Partial<T>,
|
|
101
|
-
): boolean {
|
|
102
|
-
for (const [key, value] of Object.entries(partialObject)) {
|
|
103
|
-
if (fullObject[key as keyof T] !== value) {
|
|
104
|
-
return false
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return true
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async dump(): Promise<DBSchemaType> {
|
|
111
|
-
// Serialize all data in the database
|
|
112
|
-
const dump: any = {}
|
|
113
|
-
for await (const [key, value] of this.db.iterator({})) {
|
|
114
|
-
const [collection, id] = key.split(":")
|
|
115
|
-
if (!dump[collection]) {
|
|
116
|
-
dump[collection] = {}
|
|
117
|
-
}
|
|
118
|
-
dump[collection][id] = JSON.parse(value)
|
|
119
|
-
}
|
|
120
|
-
return dump
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async list<K extends keyof DBSchemaType>(
|
|
124
|
-
collection: K,
|
|
125
|
-
): Promise<DBSchemaType[K][]> {
|
|
126
|
-
const schema = DBSchema.shape[collection]
|
|
127
|
-
const results: DBSchemaType[K][] = []
|
|
128
|
-
|
|
129
|
-
for await (const [key, value] of this.db.iterator({
|
|
130
|
-
gte: `${collection}:`,
|
|
131
|
-
lte: `${collection}:\uffff`,
|
|
132
|
-
})) {
|
|
133
|
-
if (key.endsWith(".count")) continue
|
|
134
|
-
try {
|
|
135
|
-
const parsedValue = schema.parse(JSON.parse(value))
|
|
136
|
-
results.push(parsedValue as DBSchemaType[K])
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.error(`Error parsing value for key ${key}:`, error)
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return results
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async clear() {
|
|
146
|
-
return this.db.clear()
|
|
147
|
-
}
|
|
148
|
-
}
|
package/api/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Middleware } from "winterspec"
|
|
2
|
-
import { getDb } from "api/db/get-db"
|
|
3
|
-
import type { ZodLevelDatabase } from "api/db/zod-level-db"
|
|
4
|
-
|
|
5
|
-
export const withDb: Middleware<
|
|
6
|
-
{},
|
|
7
|
-
{
|
|
8
|
-
db: ZodLevelDatabase
|
|
9
|
-
}
|
|
10
|
-
> = async (req, ctx, next) => {
|
|
11
|
-
if (!ctx.db) {
|
|
12
|
-
ctx.db = await getDb()
|
|
13
|
-
}
|
|
14
|
-
// await ctx.db.open()
|
|
15
|
-
const res = await next(req, ctx)
|
|
16
|
-
// await ctx.db.close()
|
|
17
|
-
return res
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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,37 +0,0 @@
|
|
|
1
|
-
import { NotFoundError, type Middleware } from "winterspec/middleware"
|
|
2
|
-
import kleur from "kleur"
|
|
3
|
-
|
|
4
|
-
export const withErrorResponse: Middleware<{}, {}> = async (req, ctx, next) => {
|
|
5
|
-
try {
|
|
6
|
-
return await next(req, ctx)
|
|
7
|
-
} catch (error: any) {
|
|
8
|
-
// If error is a Response, return it
|
|
9
|
-
if (error instanceof Response) {
|
|
10
|
-
return error
|
|
11
|
-
}
|
|
12
|
-
if (error instanceof NotFoundError) {
|
|
13
|
-
return (ctx as any).json(
|
|
14
|
-
{
|
|
15
|
-
ok: false,
|
|
16
|
-
error: {
|
|
17
|
-
message: error?.message,
|
|
18
|
-
error_code: "not_found",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
{ status: error?.status || 404 },
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.error(kleur.red("Intercepted unhandled error:"), error)
|
|
26
|
-
return (ctx as any).json(
|
|
27
|
-
{
|
|
28
|
-
ok: false,
|
|
29
|
-
error: {
|
|
30
|
-
message: error?.message,
|
|
31
|
-
error_code: error?.error_code ?? "internal_server_error",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{ status: error?.status || 500 },
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createWithWinterSpec } from "winterspec"
|
|
2
|
-
import { withDb } from "./middlewares/with-db"
|
|
3
|
-
import { withErrorResponse } from "./middlewares/with-error-response"
|
|
4
|
-
import { withDebugRequestLogging } from "./middlewares/with-debug-request-logging"
|
|
5
|
-
|
|
6
|
-
export const withWinterSpec = createWithWinterSpec({
|
|
7
|
-
authMiddleware: {},
|
|
8
|
-
beforeAuthMiddleware: [withDebugRequestLogging, withErrorResponse, withDb],
|
|
9
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from "zod"
|
|
2
|
-
|
|
3
|
-
export const export_parameters = z.object({
|
|
4
|
-
should_export_gerber_zip: z.boolean().default(false),
|
|
5
|
-
should_export_pnp_csv: z.boolean().default(false),
|
|
6
|
-
should_export_bom_csv: z.boolean().default(false),
|
|
7
|
-
should_export_soup_json: z.boolean().default(false),
|
|
8
|
-
should_export_kicad_pcb: z.boolean().default(false),
|
|
9
|
-
gerbers_zip_file_name: z
|
|
10
|
-
.string()
|
|
11
|
-
.nullable()
|
|
12
|
-
.optional()
|
|
13
|
-
.default("gerbers.zip"),
|
|
14
|
-
pnp_csv_file_name: z.string().nullable().optional().default("pnp.csv"),
|
|
15
|
-
bom_csv_file_name: z.string().nullable().optional().default("bom.csv"),
|
|
16
|
-
soup_json_file_name: z.string().nullable().optional().default("soup.json"),
|
|
17
|
-
kicad_pcb_file_name: z
|
|
18
|
-
.string()
|
|
19
|
-
.nullable()
|
|
20
|
-
.optional()
|
|
21
|
-
.default("output.kicad_pcb"),
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
export type ExportParametersInput = z.input<typeof export_parameters>
|
|
25
|
-
export type ExportParameters = z.infer<typeof export_parameters>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
|
|
4
|
-
export default withWinterSpec({
|
|
5
|
-
methods: ["GET"],
|
|
6
|
-
jsonResponse: z.object({
|
|
7
|
-
dev_server_database_dump: z.any(),
|
|
8
|
-
}),
|
|
9
|
-
auth: "none",
|
|
10
|
-
})(async (req, ctx) => {
|
|
11
|
-
return new Response(
|
|
12
|
-
JSON.stringify(
|
|
13
|
-
{
|
|
14
|
-
dev_server_database_dump: await ctx.db.dump(),
|
|
15
|
-
},
|
|
16
|
-
null,
|
|
17
|
-
" ",
|
|
18
|
-
),
|
|
19
|
-
{
|
|
20
|
-
headers: {
|
|
21
|
-
"content-type": "application/json",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
)
|
|
25
|
-
})
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
|
|
4
|
-
export default withWinterSpec({
|
|
5
|
-
methods: ["POST"],
|
|
6
|
-
jsonBody: z.object({
|
|
7
|
-
file_path: z.string(),
|
|
8
|
-
export_name: z.string().default("default"),
|
|
9
|
-
tscircuit_soup: z.any(),
|
|
10
|
-
error: z.string().nullable().optional().default(null),
|
|
11
|
-
is_loading: z.boolean().optional(),
|
|
12
|
-
}),
|
|
13
|
-
jsonResponse: z.object({
|
|
14
|
-
dev_package_example: z.object({
|
|
15
|
-
dev_package_example_id: z.coerce.number(),
|
|
16
|
-
file_path: z.string(),
|
|
17
|
-
tscircuit_soup: z.any(),
|
|
18
|
-
error: z.string().nullable().optional(),
|
|
19
|
-
last_updated_at: z.string().datetime().nullable(), // TODO remove nullable
|
|
20
|
-
}),
|
|
21
|
-
}),
|
|
22
|
-
auth: "none",
|
|
23
|
-
})(async (req, ctx) => {
|
|
24
|
-
const tscircuit_soup = req.jsonBody.tscircuit_soup
|
|
25
|
-
|
|
26
|
-
const existingDevPackageExample = await ctx.db.find("dev_package_example", {
|
|
27
|
-
file_path: req.jsonBody.file_path,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const dev_package_example = await ctx.db.put("dev_package_example", {
|
|
31
|
-
...existingDevPackageExample,
|
|
32
|
-
file_path: req.jsonBody.file_path,
|
|
33
|
-
export_name: req.jsonBody.export_name,
|
|
34
|
-
error: req.jsonBody.error,
|
|
35
|
-
tscircuit_soup,
|
|
36
|
-
is_loading: Boolean(req.jsonBody.is_loading),
|
|
37
|
-
last_updated_at: new Date().toISOString(),
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
return ctx.json({
|
|
41
|
-
dev_package_example,
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { NotFoundError } from "winterspec/middleware"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
|
|
5
|
-
export default withWinterSpec({
|
|
6
|
-
methods: ["GET", "POST"],
|
|
7
|
-
commonParams: z.object({
|
|
8
|
-
dev_package_example_id: z.coerce.number(),
|
|
9
|
-
}),
|
|
10
|
-
jsonResponse: z.object({
|
|
11
|
-
dev_package_example: z.object({
|
|
12
|
-
dev_package_example_id: z.coerce.number(),
|
|
13
|
-
file_path: z.string(),
|
|
14
|
-
tscircuit_soup: z.any(),
|
|
15
|
-
completed_edit_events: z.array(z.any()).default([]),
|
|
16
|
-
is_loading: z.boolean(),
|
|
17
|
-
error: z.string().nullable().optional().default(null),
|
|
18
|
-
soup_last_updated_at: z.string().datetime().nullable().default(null),
|
|
19
|
-
edit_events_last_updated_at: z
|
|
20
|
-
.string()
|
|
21
|
-
.datetime()
|
|
22
|
-
.nullable()
|
|
23
|
-
.default(null),
|
|
24
|
-
edit_events_last_applied_at: z
|
|
25
|
-
.string()
|
|
26
|
-
.datetime()
|
|
27
|
-
.nullable()
|
|
28
|
-
.default(null),
|
|
29
|
-
last_updated_at: z.string().datetime().nullable(),
|
|
30
|
-
}),
|
|
31
|
-
}),
|
|
32
|
-
auth: "none",
|
|
33
|
-
})(async (req, ctx) => {
|
|
34
|
-
const dev_package_example = await ctx.db.get(
|
|
35
|
-
"dev_package_example",
|
|
36
|
-
req.commonParams.dev_package_example_id,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
if (!dev_package_example) {
|
|
40
|
-
return new Response("Package not found", { status: 404 })
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return ctx.json({
|
|
44
|
-
dev_package_example,
|
|
45
|
-
})
|
|
46
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
|
|
4
|
-
export default withWinterSpec({
|
|
5
|
-
methods: ["GET", "POST"],
|
|
6
|
-
jsonResponse: z.object({
|
|
7
|
-
dev_package_examples: z.array(
|
|
8
|
-
z.object({
|
|
9
|
-
dev_package_example_id: z.coerce.number(),
|
|
10
|
-
file_path: z.string(),
|
|
11
|
-
export_name: z.string().nullable(),
|
|
12
|
-
is_loading: z.boolean(),
|
|
13
|
-
edit_events_last_updated_at: z.string().datetime().nullable(),
|
|
14
|
-
soup_last_updated_at: z.string().datetime().nullable(),
|
|
15
|
-
last_updated_at: z.string().datetime().nullable(),
|
|
16
|
-
}),
|
|
17
|
-
),
|
|
18
|
-
}),
|
|
19
|
-
auth: "none",
|
|
20
|
-
})(async (req, ctx) => {
|
|
21
|
-
const dev_package_examples = (await ctx.db.list("dev_package_example")).map(
|
|
22
|
-
(dpe) => ({
|
|
23
|
-
dev_package_example_id: dpe.dev_package_example_id,
|
|
24
|
-
file_path: dpe.file_path,
|
|
25
|
-
export_name: dpe.export_name,
|
|
26
|
-
is_loading: dpe.is_loading,
|
|
27
|
-
edit_events_last_updated_at: dpe.edit_events_last_updated_at,
|
|
28
|
-
soup_last_updated_at: dpe.soup_last_updated_at,
|
|
29
|
-
last_updated_at: dpe.last_updated_at,
|
|
30
|
-
}),
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
return ctx.json({
|
|
34
|
-
dev_package_examples,
|
|
35
|
-
})
|
|
36
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { NotFoundError } from "winterspec/middleware"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
import { DevPackageExampleSchema } from "api/db/schema"
|
|
5
|
-
|
|
6
|
-
export default withWinterSpec({
|
|
7
|
-
methods: ["POST"],
|
|
8
|
-
jsonBody: z.object({
|
|
9
|
-
dev_package_example_id: z.coerce.number(),
|
|
10
|
-
tscircuit_soup: z.any().optional(),
|
|
11
|
-
completed_edit_events: z.array(z.any()).optional(),
|
|
12
|
-
edit_events_last_applied_at: z.string().datetime().optional(),
|
|
13
|
-
error: z.string().nullable().optional().default(null),
|
|
14
|
-
}),
|
|
15
|
-
jsonResponse: z.object({
|
|
16
|
-
dev_package_example: DevPackageExampleSchema,
|
|
17
|
-
}),
|
|
18
|
-
auth: "none",
|
|
19
|
-
})(async (req, ctx) => {
|
|
20
|
-
const dev_package_example = await ctx.db.get(
|
|
21
|
-
"dev_package_example",
|
|
22
|
-
req.jsonBody.dev_package_example_id,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
if (!dev_package_example) {
|
|
26
|
-
return new Response("Package not found", { status: 404 })
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const new_dev_package_example = {
|
|
30
|
-
...dev_package_example,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (req.jsonBody.completed_edit_events !== undefined) {
|
|
34
|
-
new_dev_package_example.completed_edit_events =
|
|
35
|
-
req.jsonBody.completed_edit_events
|
|
36
|
-
new_dev_package_example.edit_events_last_updated_at =
|
|
37
|
-
new Date().toISOString()
|
|
38
|
-
}
|
|
39
|
-
if (req.jsonBody.edit_events_last_applied_at !== undefined) {
|
|
40
|
-
new_dev_package_example.edit_events_last_applied_at =
|
|
41
|
-
req.jsonBody.edit_events_last_applied_at
|
|
42
|
-
}
|
|
43
|
-
if (req.jsonBody.tscircuit_soup !== undefined) {
|
|
44
|
-
new_dev_package_example.tscircuit_soup = req.jsonBody.tscircuit_soup
|
|
45
|
-
new_dev_package_example.error = null
|
|
46
|
-
new_dev_package_example.soup_last_updated_at = new Date().toISOString()
|
|
47
|
-
}
|
|
48
|
-
if (req.jsonBody.error !== undefined) {
|
|
49
|
-
new_dev_package_example.error = req.jsonBody.error
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
new_dev_package_example.last_updated_at = new Date().toISOString()
|
|
53
|
-
|
|
54
|
-
await ctx.db.put("dev_package_example", new_dev_package_example)
|
|
55
|
-
|
|
56
|
-
return ctx.json({
|
|
57
|
-
dev_package_example: new_dev_package_example,
|
|
58
|
-
})
|
|
59
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
|
|
3
|
-
export default withWinterSpec({
|
|
4
|
-
methods: ["GET", "POST"],
|
|
5
|
-
auth: "none",
|
|
6
|
-
})(async (req, ctx) => {
|
|
7
|
-
await ctx.db.clear()
|
|
8
|
-
return new Response(JSON.stringify({}), {
|
|
9
|
-
headers: {
|
|
10
|
-
"content-type": "application/json",
|
|
11
|
-
},
|
|
12
|
-
})
|
|
13
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ExportFileSchema } from "api/db/schema"
|
|
2
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
|
|
5
|
-
export default withWinterSpec({
|
|
6
|
-
methods: ["POST"],
|
|
7
|
-
jsonBody: z.object({
|
|
8
|
-
export_request_id: z.number().int(),
|
|
9
|
-
file_name: z.string(),
|
|
10
|
-
file_content_base64: z.string(),
|
|
11
|
-
}),
|
|
12
|
-
jsonResponse: z.object({
|
|
13
|
-
export_file: ExportFileSchema.omit({ file_content_base64: true }),
|
|
14
|
-
}),
|
|
15
|
-
auth: "none",
|
|
16
|
-
})(async (req, ctx) => {
|
|
17
|
-
const export_file = await ctx.db.put("export_file", {
|
|
18
|
-
export_request_id: req.jsonBody.export_request_id,
|
|
19
|
-
file_name: req.jsonBody.file_name,
|
|
20
|
-
file_content_base64: req.jsonBody.file_content_base64,
|
|
21
|
-
created_at: new Date().toISOString(),
|
|
22
|
-
})
|
|
23
|
-
console.log("done putting file")
|
|
24
|
-
return ctx.json({
|
|
25
|
-
export_file,
|
|
26
|
-
})
|
|
27
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { NotFoundError } from "winterspec/middleware"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
|
|
5
|
-
export default withWinterSpec({
|
|
6
|
-
methods: ["GET"],
|
|
7
|
-
queryParams: z.object({
|
|
8
|
-
export_file_id: z.coerce.number().int(),
|
|
9
|
-
}),
|
|
10
|
-
auth: "none",
|
|
11
|
-
})(async (req, ctx) => {
|
|
12
|
-
const export_file = await ctx.db.get("export_file", req.query.export_file_id)
|
|
13
|
-
|
|
14
|
-
if (!export_file) {
|
|
15
|
-
throw new NotFoundError("Export file not found")
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const file_content = Buffer.from(export_file.file_content_base64!, "base64")
|
|
19
|
-
|
|
20
|
-
return new Response(file_content, {
|
|
21
|
-
headers: {
|
|
22
|
-
"Content-Disposition": `attachment; filename="${export_file.file_name}"`,
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { export_parameters } from "api/lib/zod/export_parameters"
|
|
4
|
-
import { ExportRequestSchema } from "api/db/schema"
|
|
5
|
-
|
|
6
|
-
export default withWinterSpec({
|
|
7
|
-
methods: ["POST"],
|
|
8
|
-
jsonBody: z.object({
|
|
9
|
-
example_file_path: z.string(),
|
|
10
|
-
export_name: z.string().nullable().optional(),
|
|
11
|
-
export_parameters: export_parameters,
|
|
12
|
-
}),
|
|
13
|
-
jsonResponse: z.object({
|
|
14
|
-
export_request: ExportRequestSchema,
|
|
15
|
-
}),
|
|
16
|
-
auth: "none",
|
|
17
|
-
})(async (req, ctx) => {
|
|
18
|
-
const export_request = await ctx.db.put("export_request", {
|
|
19
|
-
example_file_path: req.jsonBody.example_file_path,
|
|
20
|
-
export_parameters: req.jsonBody.export_parameters,
|
|
21
|
-
export_name: req.jsonBody.export_name ?? "default",
|
|
22
|
-
is_complete: false,
|
|
23
|
-
has_error: false,
|
|
24
|
-
created_at: new Date().toISOString(),
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return ctx.json({
|
|
28
|
-
export_request,
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { NotFoundError } from "winterspec/middleware"
|
|
4
|
-
import { ExportRequestSchema } from "api/db/schema"
|
|
5
|
-
|
|
6
|
-
export default withWinterSpec({
|
|
7
|
-
methods: ["GET", "POST"],
|
|
8
|
-
commonParams: z.object({
|
|
9
|
-
export_request_id: z.coerce.number(),
|
|
10
|
-
}),
|
|
11
|
-
jsonResponse: z.object({
|
|
12
|
-
export_request: ExportRequestSchema.extend({
|
|
13
|
-
file_summary: z.array(
|
|
14
|
-
z.object({ file_name: z.string(), export_file_id: z.coerce.number() }),
|
|
15
|
-
),
|
|
16
|
-
}),
|
|
17
|
-
}),
|
|
18
|
-
auth: "none",
|
|
19
|
-
})(async (req, ctx) => {
|
|
20
|
-
const { export_request_id } = req.commonParams
|
|
21
|
-
const export_request = await ctx.db.get("export_request", export_request_id)
|
|
22
|
-
|
|
23
|
-
if (!export_request) {
|
|
24
|
-
throw new NotFoundError("Export request not found")
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const ext_export_request: Parameters<typeof ctx.json>[0]["export_request"] = {
|
|
28
|
-
...export_request,
|
|
29
|
-
file_summary: undefined as any,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const export_files = (await ctx.db.list("export_file")).filter(
|
|
33
|
-
(ef) => ef.export_request_id === export_request_id,
|
|
34
|
-
)
|
|
35
|
-
ext_export_request.file_summary = export_files.map((ef) => ({
|
|
36
|
-
file_name: ef.file_name!,
|
|
37
|
-
export_file_id: ef.export_file_id,
|
|
38
|
-
}))
|
|
39
|
-
|
|
40
|
-
return ctx.json({
|
|
41
|
-
export_request: ext_export_request,
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { ExportRequestSchema } from "api/db/schema"
|
|
4
|
-
|
|
5
|
-
export default withWinterSpec({
|
|
6
|
-
methods: ["GET", "POST"],
|
|
7
|
-
commonParams: z.object({
|
|
8
|
-
is_complete: z.boolean().nullable().default(null),
|
|
9
|
-
}),
|
|
10
|
-
jsonResponse: z.object({
|
|
11
|
-
export_requests: z.array(ExportRequestSchema),
|
|
12
|
-
}),
|
|
13
|
-
auth: "none",
|
|
14
|
-
})(async (req, ctx) => {
|
|
15
|
-
const { is_complete } = req.commonParams
|
|
16
|
-
const db_export_requests = await ctx.db.list("export_request")
|
|
17
|
-
|
|
18
|
-
const filtered_requests =
|
|
19
|
-
is_complete === null
|
|
20
|
-
? db_export_requests
|
|
21
|
-
: db_export_requests.filter((er) => er.is_complete === is_complete)
|
|
22
|
-
|
|
23
|
-
return ctx.json({
|
|
24
|
-
export_requests: filtered_requests,
|
|
25
|
-
})
|
|
26
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { withWinterSpec } from "api/lib/with-winter-spec"
|
|
2
|
-
import { NotFoundError } from "winterspec/middleware"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
import { ExportRequestSchema } from "api/db/schema"
|
|
5
|
-
|
|
6
|
-
export default withWinterSpec({
|
|
7
|
-
methods: ["POST"],
|
|
8
|
-
jsonBody: z.object({
|
|
9
|
-
export_request_id: z.coerce.number(),
|
|
10
|
-
is_complete: z.boolean().optional(),
|
|
11
|
-
has_error: z.boolean().optional(),
|
|
12
|
-
error: z.string().optional(),
|
|
13
|
-
}),
|
|
14
|
-
jsonResponse: z.object({
|
|
15
|
-
export_request: ExportRequestSchema,
|
|
16
|
-
}),
|
|
17
|
-
auth: "none",
|
|
18
|
-
})(async (req, ctx) => {
|
|
19
|
-
const { export_request_id, ...updateData } = req.jsonBody
|
|
20
|
-
const existingRequest = await ctx.db.get("export_request", export_request_id)
|
|
21
|
-
|
|
22
|
-
if (!existingRequest) {
|
|
23
|
-
throw new NotFoundError("Export request not found")
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const updatedRequest = await ctx.db.put("export_request", {
|
|
27
|
-
...existingRequest,
|
|
28
|
-
...updateData,
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return ctx.json({
|
|
32
|
-
export_request: updatedRequest,
|
|
33
|
-
})
|
|
34
|
-
})
|