@tscircuit/fake-snippets 0.0.119 → 0.0.121
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-pver-release.yml +29 -4
- package/bun-tests/fake-snippets-api/routes/bug_reports/create.test.ts +37 -0
- package/bun-tests/fake-snippets-api/routes/bug_reports/upload_file.test.ts +89 -0
- package/bun.lock +2 -2
- package/dist/assets/404-CnNkOMw-.js +1 -0
- package/dist/assets/Analytics-DIw7l2gi.js +84 -0
- package/dist/assets/BuildsList-CeqVVhbz.js +1 -0
- package/dist/assets/CodeAndPreview-Dycd0s15.js +722 -0
- package/dist/assets/DownloadButtonAndMenu-OIUhbKkj.js +194 -0
- package/dist/assets/FileSaver.min-BDsOlqKl.js +1 -0
- package/dist/assets/Footer-DU-HdqGk.js +1 -0
- package/dist/assets/GithubAvatarWithFallback-CQhrBiKP.js +6 -0
- package/dist/assets/Header-CI4GZVOv.js +1 -0
- package/dist/assets/Header2-CrMDmo3P.js +5 -0
- package/dist/assets/NotFound-DaXtEPsC.js +1 -0
- package/dist/assets/OrganizationCard-Bs2dw-AL.js +1 -0
- package/dist/assets/PackageBreadcrumb-DpOpPbGc.js +6 -0
- package/dist/assets/PackageCard-ejE2dLlA.js +16 -0
- package/dist/assets/PackageSearchResults-BI3Rtmr2.js +1 -0
- package/dist/assets/ProfileRouter-4xNgtXr5.js +6 -0
- package/dist/assets/alert-dialog-DrOB4Tui.js +1 -0
- package/dist/assets/authorize-D-5R3QHA.js +16 -0
- package/dist/assets/badge-Bk-k6kyg.js +1 -0
- package/dist/assets/card-CzXDit7x.js +1 -0
- package/dist/assets/circle-alert-Du9-4of0.js +6 -0
- package/dist/assets/circle-check-big-KaRyRsht.js +6 -0
- package/dist/assets/cpu-BnvjzmIA.js +6 -0
- package/dist/assets/create-organization-BHNFvE7B.js +1 -0
- package/dist/assets/dashboard-DDH4V91X.js +11 -0
- package/dist/assets/datasheet-DqKtWt-O.js +1 -0
- package/dist/assets/datasheets-4W6pEMf3.js +1 -0
- package/dist/assets/dev-login-CbHdDthp.js +1 -0
- package/dist/assets/editor-bqg9Yv91.js +1 -0
- package/dist/assets/editor_example_1-1000w.webp +0 -0
- package/dist/assets/editor_example_1-1200w.webp +0 -0
- package/dist/assets/editor_example_1-1600w.webp +0 -0
- package/dist/assets/editor_example_1-2000w.webp +0 -0
- package/dist/assets/editor_example_1-400w.webp +0 -0
- package/dist/assets/editor_example_1-600w.webp +0 -0
- package/dist/assets/editor_example_1-800w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1200w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-1600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-2000w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-400w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-600w.webp +0 -0
- package/dist/assets/editor_example_1_more_square-800w.webp +0 -0
- package/dist/assets/editor_example_2-1000w.webp +0 -0
- package/dist/assets/editor_example_2-1200w.webp +0 -0
- package/dist/assets/editor_example_2-1600w.webp +0 -0
- package/dist/assets/editor_example_2-2000w.webp +0 -0
- package/dist/assets/editor_example_2-400w.webp +0 -0
- package/dist/assets/editor_example_2-600w.webp +0 -0
- package/dist/assets/editor_example_2-800w.webp +0 -0
- package/dist/assets/example_schematic-1000w.webp +0 -0
- package/dist/assets/example_schematic-1200w.webp +0 -0
- package/dist/assets/example_schematic-1600w.webp +0 -0
- package/dist/assets/example_schematic-2000w.webp +0 -0
- package/dist/assets/example_schematic-400w.webp +0 -0
- package/dist/assets/example_schematic-600w.webp +0 -0
- package/dist/assets/example_schematic-800w.webp +0 -0
- package/dist/assets/eye-B_NMTTT7.js +6 -0
- package/dist/assets/fallback-image.svg +1 -0
- package/dist/assets/favicon-BwEjZKGP.ico +0 -0
- package/dist/assets/formatTimeAgo-CawXna5h.js +6 -0
- package/dist/assets/github-DjKGjbX1.js +6 -0
- package/dist/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/assets/hash-DfKYpqTm.js +6 -0
- package/dist/assets/index-B17tE1vy.js +1 -0
- package/dist/assets/index-BQPj88OW.js +6051 -0
- package/dist/assets/index-DvNLZBaq.js +6 -0
- package/dist/assets/keyboard-4b_qLHIF.js +11 -0
- package/dist/assets/label-CTudXc4q.js +1 -0
- package/dist/assets/landing-Cjvvx-9q.js +11 -0
- package/dist/assets/latest-DMk4BmXW.js +1 -0
- package/dist/assets/layers-BJ1iwaVM.js +6 -0
- package/dist/assets/load-prettier-DgbV1Jgu.js +1 -0
- package/dist/assets/lock-BOZRJdUv.js +6 -0
- package/dist/assets/main-DPEM9abA.js +26 -0
- package/dist/assets/main-MTKdI4FA.css +1 -0
- package/dist/assets/my-orders-B7lEyNR9.js +1 -0
- package/dist/assets/organization-settings-rNvhYFgZ.js +6 -0
- package/dist/assets/package-editor-T4WIRP49.js +1 -0
- package/dist/assets/pen-D54fxNRf.js +6 -0
- package/dist/assets/plus-KkE_6Dq2.js +6 -0
- package/dist/assets/preview-release-DWhKHFWp.js +1 -0
- package/dist/assets/quickstart-WF3HR9Dc.js +1 -0
- package/dist/assets/refresh-cw-aWASTRku.js +6 -0
- package/dist/assets/release-builds-COa5ndHa.js +1 -0
- package/dist/assets/release-detail-iclJPUO-.js +6 -0
- package/dist/assets/releases-Clsyp-7n.js +1 -0
- package/dist/assets/role-badge-BGF_IMlO.js +16 -0
- package/dist/assets/search-CwH23pAU.js +1 -0
- package/dist/assets/select-BN8AF1J7.js +1 -0
- package/dist/assets/settings-B2bMEtS4.js +6 -0
- package/dist/assets/skeleton-DLAS40-y.js +1 -0
- package/dist/assets/svg-to-png-BX4YEHCP-JcDm8Hc5.js +1 -0
- package/dist/assets/svg-to-png-BX4YEHCP-pNo9Afg8.js +1 -0
- package/dist/assets/tabs-Ce0NFuwd.js +1 -0
- package/dist/assets/timeAgo-VY0F2EV9.js +10 -0
- package/dist/assets/tooltip-C1pwvC0K.js +11 -0
- package/dist/assets/trash-2-BW3eClHz.js +6 -0
- package/dist/assets/trending-C8246HGf.js +1 -0
- package/dist/assets/triangle-alert-BMIBEO1D.js +6 -0
- package/dist/assets/tsx-COt5Ahok.js +1 -0
- package/dist/assets/use-create-datasheet-B7TDsTUt.js +1 -0
- package/dist/assets/use-delete-package-DLKtoTOj.js +1 -0
- package/dist/assets/use-download-zip-CAOKjGXW.js +1 -0
- package/dist/assets/use-list-user-orgs-CgJIT7N4.js +1 -0
- package/dist/assets/use-organization-XwYYTFck.js +1 -0
- package/dist/assets/use-package-builds-Bx8rfxi1.js +1 -0
- package/dist/assets/use-package-by-package-name-1s1Pcarw.js +1 -0
- package/dist/assets/use-package-files-CmmWVuGn.js +1 -0
- package/dist/assets/use-package-release-by-id-or-version-BuuXcSZq.js +1 -0
- package/dist/assets/use-package-release-images-BMaZtvmk.js +1 -0
- package/dist/assets/use-packages-base-api-url-DA1hucM7.js +1 -0
- package/dist/assets/useQueries-BJ7Ue7HV.js +1 -0
- package/dist/assets/user-settings-BqO5FkMf.js +1 -0
- package/dist/assets/view-package-C-OvJr_Q.js +165 -0
- package/dist/assets/vitesse-light-CVO1_9PV.js +1 -0
- package/dist/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/index.html +127 -0
- package/dist/landing.html +34 -0
- package/dist/robots.txt +9 -0
- package/dist/sitemap.xml +118 -0
- package/dist/stats.html +4949 -0
- package/fake-snippets-api/lib/db/db-client.ts +89 -0
- package/fake-snippets-api/lib/db/schema.ts +29 -0
- package/fake-snippets-api/routes/api/bug_reports/create.ts +43 -0
- package/fake-snippets-api/routes/api/bug_reports/upload_file.ts +113 -0
- package/package.json +2 -2
- package/src/components/Header.tsx +16 -0
- package/src/components/PackageCard.tsx +7 -4
- package/src/components/PackageSearchResults.tsx +1 -7
- package/src/components/SearchComponent.tsx +64 -53
- package/src/components/TrendingPackagesCarousel.tsx +16 -23
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +3 -2
- package/src/components/ViewPackagePage/components/preview-image-squares.tsx +6 -3
- package/src/hooks/use-preview-images.ts +22 -17
- package/src/hooks/useUpdatePackageFilesMutation.ts +8 -0
- package/src/lib/utils/getPackagePreviewImageUrl.ts +15 -0
- package/src/pages/dashboard.tsx +0 -1
- package/src/pages/editor.tsx +12 -9
- package/src/pages/organization-profile.tsx +0 -1
- package/src/pages/package-editor.tsx +13 -9
- package/src/pages/user-profile.tsx +0 -1
- package/dist/bundle.js +0 -9034
- package/dist/index.d.ts +0 -2065
- package/dist/index.js +0 -3737
- package/dist/schema.d.ts +0 -2972
- package/dist/schema.js +0 -426
- package/fake-snippets-api/bun.lockb +0 -0
package/dist/index.js
DELETED
|
@@ -1,3737 +0,0 @@
|
|
|
1
|
-
// fake-snippets-api/lib/db/db-client.ts
|
|
2
|
-
import { hoist } from "zustand-hoist";
|
|
3
|
-
import { createStore } from "zustand/vanilla";
|
|
4
|
-
import { combine } from "zustand/middleware";
|
|
5
|
-
|
|
6
|
-
// fake-snippets-api/lib/db/schema.ts
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
var errorSchema = z.object({
|
|
9
|
-
error_code: z.string(),
|
|
10
|
-
message: z.string()
|
|
11
|
-
}).passthrough();
|
|
12
|
-
var errorResponseSchema = z.object({
|
|
13
|
-
error: errorSchema
|
|
14
|
-
});
|
|
15
|
-
var snippetSchema = z.object({
|
|
16
|
-
snippet_id: z.string(),
|
|
17
|
-
package_release_id: z.string(),
|
|
18
|
-
name: z.string(),
|
|
19
|
-
unscoped_name: z.string(),
|
|
20
|
-
owner_name: z.string(),
|
|
21
|
-
is_starred: z.boolean().default(false),
|
|
22
|
-
code: z.string(),
|
|
23
|
-
dts: z.string().optional(),
|
|
24
|
-
compiled_js: z.string().optional().nullable(),
|
|
25
|
-
circuit_json: z.array(z.record(z.any())).optional().nullable(),
|
|
26
|
-
manual_edits_json_content: z.string().optional().nullable(),
|
|
27
|
-
created_at: z.string(),
|
|
28
|
-
updated_at: z.string(),
|
|
29
|
-
starred_at: z.string().optional(),
|
|
30
|
-
snippet_type: z.enum(["board", "package", "model", "footprint"]),
|
|
31
|
-
description: z.string().optional(),
|
|
32
|
-
version: z.string().default("0.0.1"),
|
|
33
|
-
star_count: z.number().default(0),
|
|
34
|
-
is_private: z.boolean().default(false),
|
|
35
|
-
is_public: z.boolean().default(true),
|
|
36
|
-
is_unlisted: z.boolean().default(false),
|
|
37
|
-
tags: z.array(z.string()).optional()
|
|
38
|
-
});
|
|
39
|
-
var sessionSchema = z.object({
|
|
40
|
-
session_id: z.string(),
|
|
41
|
-
account_id: z.string(),
|
|
42
|
-
expires_at: z.string(),
|
|
43
|
-
is_cli_session: z.boolean()
|
|
44
|
-
});
|
|
45
|
-
var loginPageSchema = z.object({
|
|
46
|
-
login_page_id: z.string(),
|
|
47
|
-
login_page_auth_token: z.string(),
|
|
48
|
-
was_login_successful: z.boolean(),
|
|
49
|
-
has_been_used_to_create_session: z.boolean(),
|
|
50
|
-
created_at: z.string(),
|
|
51
|
-
expires_at: z.string()
|
|
52
|
-
});
|
|
53
|
-
var shippingInfoSchema = z.object({
|
|
54
|
-
firstName: z.string(),
|
|
55
|
-
lastName: z.string(),
|
|
56
|
-
companyName: z.string().optional(),
|
|
57
|
-
address: z.string(),
|
|
58
|
-
apartment: z.string().optional(),
|
|
59
|
-
city: z.string(),
|
|
60
|
-
state: z.string(),
|
|
61
|
-
zipCode: z.string(),
|
|
62
|
-
country: z.string(),
|
|
63
|
-
phone: z.string()
|
|
64
|
-
});
|
|
65
|
-
var accountSchema = z.object({
|
|
66
|
-
account_id: z.string(),
|
|
67
|
-
github_username: z.string(),
|
|
68
|
-
shippingInfo: shippingInfoSchema.optional(),
|
|
69
|
-
personal_org_id: z.string().optional(),
|
|
70
|
-
is_tscircuit_staff: z.boolean().default(false)
|
|
71
|
-
});
|
|
72
|
-
var orderSchema = z.object({
|
|
73
|
-
order_id: z.string(),
|
|
74
|
-
account_id: z.string().nullable(),
|
|
75
|
-
is_running: z.boolean(),
|
|
76
|
-
is_started: z.boolean(),
|
|
77
|
-
is_finished: z.boolean(),
|
|
78
|
-
error: errorSchema.nullable(),
|
|
79
|
-
has_error: z.boolean(),
|
|
80
|
-
created_at: z.string(),
|
|
81
|
-
started_at: z.string().nullable(),
|
|
82
|
-
completed_at: z.string().nullable(),
|
|
83
|
-
circuit_json: z.any()
|
|
84
|
-
});
|
|
85
|
-
var orderFileSchema = z.object({
|
|
86
|
-
order_file_id: z.string(),
|
|
87
|
-
order_id: z.string(),
|
|
88
|
-
is_gerbers_zip: z.boolean(),
|
|
89
|
-
content_type: z.string(),
|
|
90
|
-
for_provider: z.string().nullable(),
|
|
91
|
-
uploaded_at: z.string(),
|
|
92
|
-
content_text: z.string().nullable(),
|
|
93
|
-
content_bytes: z.instanceof(Uint8Array).nullable()
|
|
94
|
-
});
|
|
95
|
-
var shippingOptionSchema = z.object({
|
|
96
|
-
carrier: z.string(),
|
|
97
|
-
service: z.string(),
|
|
98
|
-
cost: z.number()
|
|
99
|
-
});
|
|
100
|
-
var quotedComponentSchema = z.object({
|
|
101
|
-
manufacturer_part_number: z.string().nullable(),
|
|
102
|
-
supplier_part_number: z.string().nullable(),
|
|
103
|
-
quantity: z.number().default(0),
|
|
104
|
-
unit_price: z.number().default(0),
|
|
105
|
-
total_price: z.number().default(0),
|
|
106
|
-
available: z.boolean().default(true)
|
|
107
|
-
});
|
|
108
|
-
var orderQuoteSchema = z.object({
|
|
109
|
-
order_quote_id: z.string(),
|
|
110
|
-
account_id: z.string().nullable(),
|
|
111
|
-
package_release_id: z.string().nullable(),
|
|
112
|
-
is_completed: z.boolean().default(false),
|
|
113
|
-
is_processing: z.boolean().default(true),
|
|
114
|
-
vendor_name: z.string(),
|
|
115
|
-
error: errorSchema.nullable(),
|
|
116
|
-
has_error: z.boolean().default(false),
|
|
117
|
-
created_at: z.string(),
|
|
118
|
-
updated_at: z.string(),
|
|
119
|
-
completed_at: z.string().nullable(),
|
|
120
|
-
quoted_components: z.array(quotedComponentSchema).nullable(),
|
|
121
|
-
bare_pcb_cost: z.number().default(0),
|
|
122
|
-
shipping_options: z.array(shippingOptionSchema),
|
|
123
|
-
total_cost_without_shipping: z.number().default(0)
|
|
124
|
-
});
|
|
125
|
-
var aiReviewSchema = z.object({
|
|
126
|
-
ai_review_id: z.string().uuid(),
|
|
127
|
-
package_release_id: z.string().optional(),
|
|
128
|
-
ai_review_text: z.string().nullable(),
|
|
129
|
-
start_processing_at: z.string().datetime().nullable(),
|
|
130
|
-
finished_processing_at: z.string().datetime().nullable(),
|
|
131
|
-
processing_error: z.any().nullable(),
|
|
132
|
-
created_at: z.string().datetime(),
|
|
133
|
-
display_status: z.enum(["pending", "completed", "failed"])
|
|
134
|
-
});
|
|
135
|
-
var datasheetPinInformationSchema = z.object({
|
|
136
|
-
pin_number: z.string(),
|
|
137
|
-
name: z.string(),
|
|
138
|
-
description: z.string(),
|
|
139
|
-
capabilities: z.array(z.string())
|
|
140
|
-
});
|
|
141
|
-
var datasheetSchema = z.object({
|
|
142
|
-
datasheet_id: z.string(),
|
|
143
|
-
chip_name: z.string(),
|
|
144
|
-
created_at: z.string(),
|
|
145
|
-
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
146
|
-
datasheet_pdf_urls: z.array(z.string()).nullable(),
|
|
147
|
-
ai_description: z.string().nullable()
|
|
148
|
-
});
|
|
149
|
-
var githubInstallationSchema = z.object({
|
|
150
|
-
github_installation_id: z.string(),
|
|
151
|
-
account_id: z.string(),
|
|
152
|
-
installation_id: z.string(),
|
|
153
|
-
// GitHub App installation ID
|
|
154
|
-
github_username: z.string(),
|
|
155
|
-
created_at: z.string().datetime(),
|
|
156
|
-
updated_at: z.string().datetime(),
|
|
157
|
-
is_active: z.boolean().default(true),
|
|
158
|
-
access_token: z.string().nullable().optional(),
|
|
159
|
-
// For storing GitHub access token
|
|
160
|
-
access_token_expires_at: z.string().datetime().nullable().optional()
|
|
161
|
-
});
|
|
162
|
-
var accountSnippetSchema = z.object({
|
|
163
|
-
account_id: z.string(),
|
|
164
|
-
snippet_id: z.string(),
|
|
165
|
-
has_starred: z.boolean(),
|
|
166
|
-
created_at: z.string(),
|
|
167
|
-
updated_at: z.string()
|
|
168
|
-
});
|
|
169
|
-
var accountPackageSchema = z.object({
|
|
170
|
-
account_package_id: z.string(),
|
|
171
|
-
account_id: z.string(),
|
|
172
|
-
package_id: z.string(),
|
|
173
|
-
is_starred: z.boolean(),
|
|
174
|
-
created_at: z.string(),
|
|
175
|
-
updated_at: z.string()
|
|
176
|
-
});
|
|
177
|
-
var packageReleaseSchema = z.object({
|
|
178
|
-
package_release_id: z.string(),
|
|
179
|
-
package_id: z.string(),
|
|
180
|
-
version: z.string().nullable(),
|
|
181
|
-
is_locked: z.boolean(),
|
|
182
|
-
is_latest: z.boolean(),
|
|
183
|
-
created_at: z.string().datetime(),
|
|
184
|
-
commit_sha: z.string().nullable().optional(),
|
|
185
|
-
license: z.string().nullable().optional(),
|
|
186
|
-
circuit_json_build_error: z.string().nullable().optional(),
|
|
187
|
-
circuit_json_build_error_last_updated_at: z.string().datetime().nullable().optional(),
|
|
188
|
-
has_transpiled: z.boolean().default(false),
|
|
189
|
-
transpilation_error: z.string().nullable().optional(),
|
|
190
|
-
fs_sha: z.string().nullable().optional(),
|
|
191
|
-
// Build Status and Display
|
|
192
|
-
display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
193
|
-
total_build_duration_ms: z.number().nullable().optional(),
|
|
194
|
-
// Transpilation Process
|
|
195
|
-
transpilation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
196
|
-
transpilation_in_progress: z.boolean().default(false),
|
|
197
|
-
transpilation_started_at: z.string().datetime().nullable().optional(),
|
|
198
|
-
transpilation_completed_at: z.string().datetime().nullable().optional(),
|
|
199
|
-
transpilation_logs: z.array(z.any()).default([]),
|
|
200
|
-
transpilation_is_stale: z.boolean().default(false),
|
|
201
|
-
// Circuit JSON Build Process
|
|
202
|
-
circuit_json_build_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
203
|
-
circuit_json_build_in_progress: z.boolean().default(false),
|
|
204
|
-
circuit_json_build_started_at: z.string().datetime().nullable().optional(),
|
|
205
|
-
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
206
|
-
circuit_json_build_logs: z.array(z.any()).default([]),
|
|
207
|
-
circuit_json_build_is_stale: z.boolean().default(false),
|
|
208
|
-
// Image Generation Process
|
|
209
|
-
image_generation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
210
|
-
image_generation_in_progress: z.boolean().default(false),
|
|
211
|
-
image_generation_started_at: z.string().datetime().nullable().optional(),
|
|
212
|
-
image_generation_completed_at: z.string().datetime().nullable().optional(),
|
|
213
|
-
image_generation_logs: z.array(z.any()).nullable().default(null),
|
|
214
|
-
image_generation_is_stale: z.boolean().default(false),
|
|
215
|
-
image_generation_error: z.string().nullable().optional(),
|
|
216
|
-
image_generation_error_last_updated_at: z.string().datetime().nullable().optional(),
|
|
217
|
-
// AI Review
|
|
218
|
-
ai_review_text: z.string().nullable().default(null).optional(),
|
|
219
|
-
ai_review_started_at: z.string().datetime().nullable().optional(),
|
|
220
|
-
ai_review_completed_at: z.string().datetime().nullable().optional(),
|
|
221
|
-
ai_review_error: z.any().optional().nullable(),
|
|
222
|
-
ai_review_logs: z.array(z.any()).optional().nullable(),
|
|
223
|
-
ai_review_requested: z.boolean().default(false),
|
|
224
|
-
// Preview
|
|
225
|
-
is_pr_preview: z.boolean().default(false),
|
|
226
|
-
github_pr_number: z.number().nullable().optional(),
|
|
227
|
-
// Latest Build Reference
|
|
228
|
-
latest_package_build_id: z.string().nullable().optional(),
|
|
229
|
-
branch_name: z.string().nullable().optional(),
|
|
230
|
-
commit_message: z.string().nullable().optional(),
|
|
231
|
-
commit_author: z.string().nullable().optional(),
|
|
232
|
-
// Preview images url
|
|
233
|
-
pcb_preview_image_url: z.string().nullable().default(null),
|
|
234
|
-
sch_preview_image_url: z.string().nullable().default(null),
|
|
235
|
-
cad_preview_image_url: z.string().nullable().default(null)
|
|
236
|
-
});
|
|
237
|
-
var packageFileSchema = z.object({
|
|
238
|
-
package_file_id: z.string(),
|
|
239
|
-
package_release_id: z.string(),
|
|
240
|
-
file_path: z.string(),
|
|
241
|
-
content_text: z.string().nullable().optional(),
|
|
242
|
-
created_at: z.string().datetime(),
|
|
243
|
-
content_mimetype: z.string().nullable().optional(),
|
|
244
|
-
is_release_tarball: z.boolean().optional(),
|
|
245
|
-
npm_pack_output: z.any().nullable().optional()
|
|
246
|
-
});
|
|
247
|
-
var packageSchema = z.object({
|
|
248
|
-
package_id: z.string(),
|
|
249
|
-
creator_account_id: z.string(),
|
|
250
|
-
owner_org_id: z.string(),
|
|
251
|
-
owner_github_username: z.string().nullable(),
|
|
252
|
-
github_repo_full_name: z.string().nullable(),
|
|
253
|
-
name: z.string(),
|
|
254
|
-
unscoped_name: z.string(),
|
|
255
|
-
description: z.string().nullable(),
|
|
256
|
-
created_at: z.string().datetime(),
|
|
257
|
-
updated_at: z.string().datetime(),
|
|
258
|
-
is_snippet: z.boolean().default(false),
|
|
259
|
-
is_board: z.boolean().default(false),
|
|
260
|
-
is_package: z.boolean().default(false),
|
|
261
|
-
is_model: z.boolean().default(false),
|
|
262
|
-
is_footprint: z.boolean().default(false),
|
|
263
|
-
is_private: z.boolean().nullable().default(false),
|
|
264
|
-
is_public: z.boolean().nullable().default(true),
|
|
265
|
-
is_unlisted: z.boolean().nullable().default(false),
|
|
266
|
-
is_source_from_github: z.boolean().default(false),
|
|
267
|
-
snippet_type: z.enum(["board", "package", "model", "footprint"]).optional(),
|
|
268
|
-
latest_package_release_id: z.string().nullable(),
|
|
269
|
-
latest_version: z.string().nullable(),
|
|
270
|
-
license: z.string().nullable(),
|
|
271
|
-
website: z.string().nullable().default(null),
|
|
272
|
-
star_count: z.number().default(0),
|
|
273
|
-
ai_description: z.string().nullable(),
|
|
274
|
-
latest_license: z.string().nullable().optional(),
|
|
275
|
-
ai_usage_instructions: z.string().nullable(),
|
|
276
|
-
latest_package_release_fs_sha: z.string().nullable().default(null),
|
|
277
|
-
default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional(),
|
|
278
|
-
allow_pr_previews: z.boolean().default(false).optional(),
|
|
279
|
-
is_starred: z.boolean().default(false).optional(),
|
|
280
|
-
latest_pcb_preview_image_url: z.string().nullable().optional(),
|
|
281
|
-
latest_sch_preview_image_url: z.string().nullable().optional(),
|
|
282
|
-
latest_cad_preview_image_url: z.string().nullable().optional()
|
|
283
|
-
});
|
|
284
|
-
var jlcpcbOrderStateSchema = z.object({
|
|
285
|
-
jlcpcb_order_state_id: z.string(),
|
|
286
|
-
order_id: z.string(),
|
|
287
|
-
are_gerbers_uploaded: z.boolean().default(false),
|
|
288
|
-
is_gerber_analyzed: z.boolean().default(false),
|
|
289
|
-
are_initial_costs_calculated: z.boolean().default(false),
|
|
290
|
-
is_pcb_added_to_cart: z.boolean().default(false),
|
|
291
|
-
is_bom_uploaded: z.boolean().default(false),
|
|
292
|
-
is_pnp_uploaded: z.boolean().default(false),
|
|
293
|
-
is_bom_pnp_analyzed: z.boolean().default(false),
|
|
294
|
-
is_bom_parsing_complete: z.boolean().default(false),
|
|
295
|
-
are_components_available: z.boolean().default(false),
|
|
296
|
-
is_patch_map_generated: z.boolean().default(false),
|
|
297
|
-
is_json_merge_file_created: z.boolean().default(false),
|
|
298
|
-
is_dfm_result_generated: z.boolean().default(false),
|
|
299
|
-
are_files_downloaded: z.boolean().default(false),
|
|
300
|
-
are_product_categories_fetched: z.boolean().default(false),
|
|
301
|
-
are_final_costs_calculated: z.boolean().default(false),
|
|
302
|
-
is_json_merge_file_updated: z.boolean().default(false),
|
|
303
|
-
is_added_to_cart: z.boolean().default(false),
|
|
304
|
-
uploaded_gerber_metadata: z.any().nullable().default(null),
|
|
305
|
-
gerber_analysis: z.any().nullable().default(null),
|
|
306
|
-
created_at: z.string(),
|
|
307
|
-
are_gerbers_generated: z.boolean().default(false),
|
|
308
|
-
current_step: z.string().nullable().default(null)
|
|
309
|
-
});
|
|
310
|
-
var jlcpcbOrderStepRunSchema = z.object({
|
|
311
|
-
jlcpcb_order_step_run_id: z.string(),
|
|
312
|
-
is_running: z.boolean().nullable().default(null),
|
|
313
|
-
step_function_name: z.string().nullable().default(null),
|
|
314
|
-
jlcpcb_order_state_id: z.string().nullable().default(null),
|
|
315
|
-
error_message: z.string().nullable().default(null),
|
|
316
|
-
created_at: z.string()
|
|
317
|
-
});
|
|
318
|
-
var packageBuildSchema = z.object({
|
|
319
|
-
package_build_id: z.string().uuid(),
|
|
320
|
-
package_release_id: z.string(),
|
|
321
|
-
created_at: z.string().datetime(),
|
|
322
|
-
transpilation_in_progress: z.boolean().default(false),
|
|
323
|
-
transpilation_started_at: z.string().datetime().nullable().optional(),
|
|
324
|
-
transpilation_completed_at: z.string().datetime().nullable().optional(),
|
|
325
|
-
transpilation_logs: z.array(z.any()).default([]),
|
|
326
|
-
transpilation_error: z.string().nullable().optional(),
|
|
327
|
-
circuit_json_build_in_progress: z.boolean().default(false),
|
|
328
|
-
circuit_json_build_started_at: z.string().datetime().nullable().optional(),
|
|
329
|
-
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
330
|
-
circuit_json_build_logs: z.array(z.any()).default([]),
|
|
331
|
-
circuit_json_build_error: z.string().nullable().optional(),
|
|
332
|
-
image_generation_in_progress: z.boolean().default(false),
|
|
333
|
-
image_generation_started_at: z.string().datetime().nullable().optional(),
|
|
334
|
-
image_generation_completed_at: z.string().datetime().nullable().optional(),
|
|
335
|
-
image_generation_logs: z.array(z.any()).default([]),
|
|
336
|
-
image_generation_error: z.string().nullable().optional(),
|
|
337
|
-
build_in_progress: z.boolean().default(false),
|
|
338
|
-
build_started_at: z.string().datetime().nullable().optional(),
|
|
339
|
-
build_completed_at: z.string().datetime().nullable().optional(),
|
|
340
|
-
build_error: z.string().nullable().optional(),
|
|
341
|
-
build_error_last_updated_at: z.string().datetime(),
|
|
342
|
-
preview_url: z.string().nullable().optional(),
|
|
343
|
-
build_logs: z.string().nullable().optional()
|
|
344
|
-
});
|
|
345
|
-
var orgSchema = z.object({
|
|
346
|
-
org_id: z.string(),
|
|
347
|
-
github_handle: z.string().optional(),
|
|
348
|
-
owner_account_id: z.string(),
|
|
349
|
-
is_personal_org: z.boolean().default(false),
|
|
350
|
-
created_at: z.string().datetime(),
|
|
351
|
-
org_display_name: z.string().optional(),
|
|
352
|
-
org_name: z.string()
|
|
353
|
-
});
|
|
354
|
-
var orgAccountSchema = z.object({
|
|
355
|
-
org_account_id: z.string(),
|
|
356
|
-
org_id: z.string(),
|
|
357
|
-
account_id: z.string(),
|
|
358
|
-
is_owner: z.boolean().default(false),
|
|
359
|
-
created_at: z.string().datetime()
|
|
360
|
-
});
|
|
361
|
-
var userPermissionsSchema = z.object({
|
|
362
|
-
can_manage_org: z.boolean().optional(),
|
|
363
|
-
can_manage_package: z.boolean().optional()
|
|
364
|
-
});
|
|
365
|
-
var publicOrgSchema = z.object({
|
|
366
|
-
org_id: z.string(),
|
|
367
|
-
//.uuid(),
|
|
368
|
-
owner_account_id: z.string(),
|
|
369
|
-
//.uuid(),
|
|
370
|
-
name: z.string().nullable(),
|
|
371
|
-
member_count: z.number(),
|
|
372
|
-
is_personal_org: z.boolean(),
|
|
373
|
-
display_name: z.string().optional(),
|
|
374
|
-
package_count: z.number(),
|
|
375
|
-
github_handle: z.string().optional(),
|
|
376
|
-
created_at: z.string(),
|
|
377
|
-
user_permissions: userPermissionsSchema.optional()
|
|
378
|
-
});
|
|
379
|
-
var databaseSchema = z.object({
|
|
380
|
-
idCounter: z.number().default(0),
|
|
381
|
-
snippets: z.array(snippetSchema).default([]),
|
|
382
|
-
packageReleases: z.array(packageReleaseSchema).default([]),
|
|
383
|
-
packageFiles: z.array(packageFileSchema).default([]),
|
|
384
|
-
sessions: z.array(sessionSchema).default([]),
|
|
385
|
-
loginPages: z.array(loginPageSchema).default([]),
|
|
386
|
-
accounts: z.array(accountSchema).default([]),
|
|
387
|
-
packages: z.array(packageSchema).default([]),
|
|
388
|
-
orders: z.array(orderSchema).default([]),
|
|
389
|
-
organizations: z.array(orgSchema).default([]),
|
|
390
|
-
orgAccounts: z.array(orgAccountSchema).default([]),
|
|
391
|
-
orderFiles: z.array(orderFileSchema).default([]),
|
|
392
|
-
accountSnippets: z.array(accountSnippetSchema).default([]),
|
|
393
|
-
accountPackages: z.array(accountPackageSchema).default([]),
|
|
394
|
-
jlcpcbOrderState: z.array(jlcpcbOrderStateSchema).default([]),
|
|
395
|
-
jlcpcbOrderStepRuns: z.array(jlcpcbOrderStepRunSchema).default([]),
|
|
396
|
-
orderQuotes: z.array(orderQuoteSchema).default([]),
|
|
397
|
-
aiReviews: z.array(aiReviewSchema).default([]),
|
|
398
|
-
datasheets: z.array(datasheetSchema).default([]),
|
|
399
|
-
githubInstallations: z.array(githubInstallationSchema).default([]),
|
|
400
|
-
packageBuilds: z.array(packageBuildSchema).default([])
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
// fake-snippets-api/lib/db/autoload-dev-packages.ts
|
|
404
|
-
import fs from "fs";
|
|
405
|
-
import path from "path";
|
|
406
|
-
import axios from "redaxios";
|
|
407
|
-
var extractTsciDependencies = (code) => {
|
|
408
|
-
const regex = /@tsci\/([^.]+)\.([^"'\s]+)/g;
|
|
409
|
-
const matches = Array.from(code.matchAll(regex));
|
|
410
|
-
return matches.map((match) => ({
|
|
411
|
-
owner: match[1],
|
|
412
|
-
name: match[2]
|
|
413
|
-
}));
|
|
414
|
-
};
|
|
415
|
-
var registryApi = axios.create({
|
|
416
|
-
baseURL: "https://api.tscircuit.com",
|
|
417
|
-
headers: {
|
|
418
|
-
Accept: "application/json",
|
|
419
|
-
"Content-Type": "application/json"
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
var fetchPackageFromRegistry = async (owner, name) => {
|
|
423
|
-
const fullName = `${owner}/${name}`;
|
|
424
|
-
console.log(`[autoload-dev-pkgs] \u{1F4E6} Fetching package ${fullName}...`);
|
|
425
|
-
let packageData;
|
|
426
|
-
try {
|
|
427
|
-
const response = await registryApi.post("/packages/get", {
|
|
428
|
-
name: fullName
|
|
429
|
-
});
|
|
430
|
-
packageData = response.data;
|
|
431
|
-
} catch (e) {
|
|
432
|
-
console.error(`Failed to fetch package data for ${fullName}:`, e);
|
|
433
|
-
throw e;
|
|
434
|
-
}
|
|
435
|
-
let releaseData;
|
|
436
|
-
try {
|
|
437
|
-
const response = await registryApi.post("/package_releases/get", {
|
|
438
|
-
package_id: packageData.package.package_id,
|
|
439
|
-
is_latest: true
|
|
440
|
-
});
|
|
441
|
-
releaseData = response.data;
|
|
442
|
-
} catch (e) {
|
|
443
|
-
console.error(
|
|
444
|
-
`[autoload-dev-pkgs] \u274C Failed to fetch release data for ${fullName}:`,
|
|
445
|
-
e
|
|
446
|
-
);
|
|
447
|
-
throw e;
|
|
448
|
-
}
|
|
449
|
-
let filesData;
|
|
450
|
-
try {
|
|
451
|
-
const response = await registryApi.post(
|
|
452
|
-
`package_files/list?package_release_id=${releaseData.package_release.package_release_id}`,
|
|
453
|
-
{}
|
|
454
|
-
);
|
|
455
|
-
filesData = response.data;
|
|
456
|
-
for (const file of filesData.package_files) {
|
|
457
|
-
try {
|
|
458
|
-
const fileResponse = await registryApi.post(
|
|
459
|
-
`/package_files/get?package_file_id=${file.package_file_id}`,
|
|
460
|
-
{}
|
|
461
|
-
);
|
|
462
|
-
file.content_text = fileResponse.data.package_file.content_text;
|
|
463
|
-
} catch (e) {
|
|
464
|
-
console.error(
|
|
465
|
-
`[autoload-dev-pkgs] \u274C Failed to fetch content for file ${file.file_path} in package ${fullName}:`,
|
|
466
|
-
e
|
|
467
|
-
);
|
|
468
|
-
throw e;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
} catch (e) {
|
|
472
|
-
console.error(
|
|
473
|
-
`[autoload-dev-pkgs] \u274C Failed to fetch files data for ${fullName}:`,
|
|
474
|
-
e
|
|
475
|
-
);
|
|
476
|
-
throw e;
|
|
477
|
-
}
|
|
478
|
-
return {
|
|
479
|
-
package: packageData.package,
|
|
480
|
-
release: releaseData.package_release,
|
|
481
|
-
files: filesData.package_files
|
|
482
|
-
};
|
|
483
|
-
};
|
|
484
|
-
var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @__PURE__ */ new Set()) => {
|
|
485
|
-
const packageKey = `${owner}/${name}`;
|
|
486
|
-
if (loadedPackages.has(packageKey)) {
|
|
487
|
-
return true;
|
|
488
|
-
}
|
|
489
|
-
let result;
|
|
490
|
-
try {
|
|
491
|
-
result = await fetchPackageFromRegistry(owner, name);
|
|
492
|
-
} catch (e) {
|
|
493
|
-
console.error(`[autoload-dev-pkgs] \u274C Failed to load ${packageKey}`);
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
const { package: pkg, release, files } = result;
|
|
497
|
-
if (db.getPackageById(pkg.package_id)) {
|
|
498
|
-
console.log(`[autoload-dev-pkgs] \u26A1 Package ${packageKey} already exists`);
|
|
499
|
-
return true;
|
|
500
|
-
}
|
|
501
|
-
db.addPackage({
|
|
502
|
-
...pkg,
|
|
503
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
504
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
505
|
-
latest_package_release_id: release.package_release_id,
|
|
506
|
-
star_count: Math.floor(Math.random() * 11)
|
|
507
|
-
});
|
|
508
|
-
db.addPackageRelease({
|
|
509
|
-
...release,
|
|
510
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
511
|
-
transpilation_logs: Array.isArray(release.transpilation_logs) ? release.transpilation_logs : [],
|
|
512
|
-
circuit_json_build_logs: Array.isArray(release.circuit_json_build_logs) ? release.circuit_json_build_logs : [],
|
|
513
|
-
transpilation_display_status: release.transpilation_display_status ?? "pending"
|
|
514
|
-
});
|
|
515
|
-
for (const file of files) {
|
|
516
|
-
db.addPackageFile({
|
|
517
|
-
...file,
|
|
518
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
loadedPackages.add(packageKey);
|
|
522
|
-
console.log(`[autoload-dev-pkgs] \u{1F4E6} Loaded ${packageKey}`);
|
|
523
|
-
const mainFile = files.find(
|
|
524
|
-
(f) => f.file_path === "index.tsx" || f.file_path === "index.ts"
|
|
525
|
-
);
|
|
526
|
-
if (!mainFile?.content_text) {
|
|
527
|
-
return true;
|
|
528
|
-
}
|
|
529
|
-
const dependencies = extractTsciDependencies(mainFile.content_text);
|
|
530
|
-
let allDepsLoaded = true;
|
|
531
|
-
for (const dep of dependencies) {
|
|
532
|
-
const depLoaded = await loadPackageWithDependencies(
|
|
533
|
-
db,
|
|
534
|
-
dep.owner,
|
|
535
|
-
dep.name,
|
|
536
|
-
loadedPackages
|
|
537
|
-
);
|
|
538
|
-
if (!depLoaded) {
|
|
539
|
-
allDepsLoaded = false;
|
|
540
|
-
console.warn(
|
|
541
|
-
`[autoload-dev-pkgs] \u26A0\uFE0F Failed to load dependency ${dep.owner}/${dep.name} for ${packageKey}`
|
|
542
|
-
);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
return allDepsLoaded;
|
|
546
|
-
};
|
|
547
|
-
var loadAutoloadPackages = async (db) => {
|
|
548
|
-
const autoloadPath = path.join(
|
|
549
|
-
path.dirname(__dirname),
|
|
550
|
-
"db",
|
|
551
|
-
"autoload-packages.json"
|
|
552
|
-
);
|
|
553
|
-
if (!fs.existsSync(autoloadPath)) {
|
|
554
|
-
console.error("[autoload-dev-pkgs] \u274C No autoload-packages.json found");
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
const autoloadContent = JSON.parse(fs.readFileSync(autoloadPath, "utf8"));
|
|
558
|
-
const loadedPackages = /* @__PURE__ */ new Set();
|
|
559
|
-
let successCount = 0;
|
|
560
|
-
let failureCount = 0;
|
|
561
|
-
for (const packageRef of autoloadContent.packages) {
|
|
562
|
-
const success = await loadPackageWithDependencies(
|
|
563
|
-
db,
|
|
564
|
-
packageRef.owner,
|
|
565
|
-
packageRef.name,
|
|
566
|
-
loadedPackages
|
|
567
|
-
);
|
|
568
|
-
if (success) {
|
|
569
|
-
successCount++;
|
|
570
|
-
} else {
|
|
571
|
-
failureCount++;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
console.log(`
|
|
575
|
-
[autoload-dev-pkgs] \u{1F4CB} Package loading complete:`);
|
|
576
|
-
console.log(
|
|
577
|
-
`[autoload-dev-pkgs] \u2705 Successfully loaded: ${successCount} packages`
|
|
578
|
-
);
|
|
579
|
-
if (failureCount > 0) {
|
|
580
|
-
console.log(
|
|
581
|
-
`[autoload-dev-pkgs] \u274C Failed to load: ${failureCount} packages`
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
// fake-snippets-api/lib/db/seed.ts
|
|
587
|
-
var seed = (db) => {
|
|
588
|
-
const { account_id } = db.addAccount({
|
|
589
|
-
account_id: "account-1234",
|
|
590
|
-
github_username: "testuser",
|
|
591
|
-
shippingInfo: {
|
|
592
|
-
firstName: "Test",
|
|
593
|
-
lastName: "User",
|
|
594
|
-
companyName: "Test Company",
|
|
595
|
-
address: "123 Test St",
|
|
596
|
-
apartment: "Apt 4B",
|
|
597
|
-
city: "Testville",
|
|
598
|
-
state: "NY",
|
|
599
|
-
zipCode: "10001",
|
|
600
|
-
country: "United States of America",
|
|
601
|
-
phone: "555-123-4567"
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
const seveibarAcc = db.addAccount({
|
|
605
|
-
github_username: "seveibar"
|
|
606
|
-
});
|
|
607
|
-
if (process.env.AUTOLOAD_PACKAGES === "true") {
|
|
608
|
-
loadAutoloadPackages(db);
|
|
609
|
-
}
|
|
610
|
-
const { package_release_id: packageReleaseId1 } = db.addSnippet({
|
|
611
|
-
name: "testuser/my-test-board",
|
|
612
|
-
unscoped_name: "my-test-board",
|
|
613
|
-
github_repo_full_name: "testuser/my-test-board",
|
|
614
|
-
owner_name: "testuser",
|
|
615
|
-
branch_name: "main",
|
|
616
|
-
commit_message: "Attempted build of a555timer-square-wave package",
|
|
617
|
-
commit_author: "testuser",
|
|
618
|
-
creator_account_id: account_id,
|
|
619
|
-
code: `
|
|
620
|
-
import { A555Timer } from "@tsci/seveibar.a555timer"
|
|
621
|
-
|
|
622
|
-
export default () => (
|
|
623
|
-
<board width="10mm" height="10mm">
|
|
624
|
-
<A555Timer name="U1" />
|
|
625
|
-
</board>
|
|
626
|
-
)`.trim(),
|
|
627
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
628
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
629
|
-
snippet_type: "board",
|
|
630
|
-
description: "A simple board with an A555 Timer component",
|
|
631
|
-
circuit_json: [
|
|
632
|
-
{
|
|
633
|
-
type: "source_port",
|
|
634
|
-
source_port_id: "source_port_0",
|
|
635
|
-
name: "pin1",
|
|
636
|
-
pin_number: 1,
|
|
637
|
-
port_hints: ["pin1", "1"],
|
|
638
|
-
source_component_id: "source_component_0"
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
type: "source_port",
|
|
642
|
-
source_port_id: "source_port_1",
|
|
643
|
-
name: "pin2",
|
|
644
|
-
pin_number: 2,
|
|
645
|
-
port_hints: ["pin2", "2"],
|
|
646
|
-
source_component_id: "source_component_0"
|
|
647
|
-
},
|
|
648
|
-
{
|
|
649
|
-
type: "source_port",
|
|
650
|
-
source_port_id: "source_port_2",
|
|
651
|
-
name: "pin3",
|
|
652
|
-
pin_number: 3,
|
|
653
|
-
port_hints: ["pin3", "3"],
|
|
654
|
-
source_component_id: "source_component_0"
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
type: "source_port",
|
|
658
|
-
source_port_id: "source_port_3",
|
|
659
|
-
name: "pin4",
|
|
660
|
-
pin_number: 4,
|
|
661
|
-
port_hints: ["pin4", "4"],
|
|
662
|
-
source_component_id: "source_component_0"
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
type: "source_port",
|
|
666
|
-
source_port_id: "source_port_4",
|
|
667
|
-
name: "pin5",
|
|
668
|
-
pin_number: 5,
|
|
669
|
-
port_hints: ["pin5", "5"],
|
|
670
|
-
source_component_id: "source_component_0"
|
|
671
|
-
},
|
|
672
|
-
{
|
|
673
|
-
type: "source_port",
|
|
674
|
-
source_port_id: "source_port_5",
|
|
675
|
-
name: "pin6",
|
|
676
|
-
pin_number: 6,
|
|
677
|
-
port_hints: ["pin6", "6"],
|
|
678
|
-
source_component_id: "source_component_0"
|
|
679
|
-
},
|
|
680
|
-
{
|
|
681
|
-
type: "source_port",
|
|
682
|
-
source_port_id: "source_port_6",
|
|
683
|
-
name: "pin7",
|
|
684
|
-
pin_number: 7,
|
|
685
|
-
port_hints: ["pin7", "7"],
|
|
686
|
-
source_component_id: "source_component_0"
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
type: "source_port",
|
|
690
|
-
source_port_id: "source_port_7",
|
|
691
|
-
name: "pin8",
|
|
692
|
-
pin_number: 8,
|
|
693
|
-
port_hints: ["pin8", "8"],
|
|
694
|
-
source_component_id: "source_component_0"
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
type: "source_component",
|
|
698
|
-
source_component_id: "source_component_0",
|
|
699
|
-
ftype: "simple_chip",
|
|
700
|
-
name: "U1",
|
|
701
|
-
supplier_part_numbers: {}
|
|
702
|
-
},
|
|
703
|
-
{
|
|
704
|
-
type: "schematic_component",
|
|
705
|
-
schematic_component_id: "schematic_component_0",
|
|
706
|
-
center: {
|
|
707
|
-
x: 0,
|
|
708
|
-
y: 0
|
|
709
|
-
},
|
|
710
|
-
rotation: 0,
|
|
711
|
-
size: {
|
|
712
|
-
width: 1.1,
|
|
713
|
-
height: 1
|
|
714
|
-
},
|
|
715
|
-
pin_spacing: 0.2,
|
|
716
|
-
port_labels: {},
|
|
717
|
-
source_component_id: "source_component_0"
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
type: "schematic_port",
|
|
721
|
-
schematic_port_id: "schematic_port_0",
|
|
722
|
-
schematic_component_id: "schematic_component_0",
|
|
723
|
-
center: {
|
|
724
|
-
x: -0.9500000000000001,
|
|
725
|
-
y: 0.30000000000000004
|
|
726
|
-
},
|
|
727
|
-
source_port_id: "source_port_0",
|
|
728
|
-
facing_direction: "left",
|
|
729
|
-
distance_from_component_edge: 0.4,
|
|
730
|
-
side_of_component: "left",
|
|
731
|
-
pin_number: 1,
|
|
732
|
-
true_ccw_index: 0
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
type: "schematic_port",
|
|
736
|
-
schematic_port_id: "schematic_port_1",
|
|
737
|
-
schematic_component_id: "schematic_component_0",
|
|
738
|
-
center: {
|
|
739
|
-
x: -0.9500000000000001,
|
|
740
|
-
y: 0.10000000000000003
|
|
741
|
-
},
|
|
742
|
-
source_port_id: "source_port_1",
|
|
743
|
-
facing_direction: "left",
|
|
744
|
-
distance_from_component_edge: 0.4,
|
|
745
|
-
side_of_component: "left",
|
|
746
|
-
pin_number: 2,
|
|
747
|
-
true_ccw_index: 1
|
|
748
|
-
},
|
|
749
|
-
{
|
|
750
|
-
type: "schematic_port",
|
|
751
|
-
schematic_port_id: "schematic_port_2",
|
|
752
|
-
schematic_component_id: "schematic_component_0",
|
|
753
|
-
center: {
|
|
754
|
-
x: -0.9500000000000001,
|
|
755
|
-
y: -0.09999999999999998
|
|
756
|
-
},
|
|
757
|
-
source_port_id: "source_port_2",
|
|
758
|
-
facing_direction: "left",
|
|
759
|
-
distance_from_component_edge: 0.4,
|
|
760
|
-
side_of_component: "left",
|
|
761
|
-
pin_number: 3,
|
|
762
|
-
true_ccw_index: 2
|
|
763
|
-
},
|
|
764
|
-
{
|
|
765
|
-
type: "schematic_port",
|
|
766
|
-
schematic_port_id: "schematic_port_3",
|
|
767
|
-
schematic_component_id: "schematic_component_0",
|
|
768
|
-
center: {
|
|
769
|
-
x: -0.9500000000000001,
|
|
770
|
-
y: -0.30000000000000004
|
|
771
|
-
},
|
|
772
|
-
source_port_id: "source_port_3",
|
|
773
|
-
facing_direction: "left",
|
|
774
|
-
distance_from_component_edge: 0.4,
|
|
775
|
-
side_of_component: "left",
|
|
776
|
-
pin_number: 4,
|
|
777
|
-
true_ccw_index: 3
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
type: "schematic_port",
|
|
781
|
-
schematic_port_id: "schematic_port_4",
|
|
782
|
-
schematic_component_id: "schematic_component_0",
|
|
783
|
-
center: {
|
|
784
|
-
x: 0.9500000000000001,
|
|
785
|
-
y: -0.30000000000000004
|
|
786
|
-
},
|
|
787
|
-
source_port_id: "source_port_4",
|
|
788
|
-
facing_direction: "right",
|
|
789
|
-
distance_from_component_edge: 0.4,
|
|
790
|
-
side_of_component: "right",
|
|
791
|
-
pin_number: 5,
|
|
792
|
-
true_ccw_index: 4
|
|
793
|
-
},
|
|
794
|
-
{
|
|
795
|
-
type: "schematic_port",
|
|
796
|
-
schematic_port_id: "schematic_port_5",
|
|
797
|
-
schematic_component_id: "schematic_component_0",
|
|
798
|
-
center: {
|
|
799
|
-
x: 0.9500000000000001,
|
|
800
|
-
y: -0.10000000000000003
|
|
801
|
-
},
|
|
802
|
-
source_port_id: "source_port_5",
|
|
803
|
-
facing_direction: "right",
|
|
804
|
-
distance_from_component_edge: 0.4,
|
|
805
|
-
side_of_component: "right",
|
|
806
|
-
pin_number: 6,
|
|
807
|
-
true_ccw_index: 5
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
type: "schematic_port",
|
|
811
|
-
schematic_port_id: "schematic_port_6",
|
|
812
|
-
schematic_component_id: "schematic_component_0",
|
|
813
|
-
center: {
|
|
814
|
-
x: 0.9500000000000001,
|
|
815
|
-
y: 0.09999999999999998
|
|
816
|
-
},
|
|
817
|
-
source_port_id: "source_port_6",
|
|
818
|
-
facing_direction: "right",
|
|
819
|
-
distance_from_component_edge: 0.4,
|
|
820
|
-
side_of_component: "right",
|
|
821
|
-
pin_number: 7,
|
|
822
|
-
true_ccw_index: 6
|
|
823
|
-
},
|
|
824
|
-
{
|
|
825
|
-
type: "schematic_port",
|
|
826
|
-
schematic_port_id: "schematic_port_7",
|
|
827
|
-
schematic_component_id: "schematic_component_0",
|
|
828
|
-
center: {
|
|
829
|
-
x: 0.9500000000000001,
|
|
830
|
-
y: 0.30000000000000004
|
|
831
|
-
},
|
|
832
|
-
source_port_id: "source_port_7",
|
|
833
|
-
facing_direction: "right",
|
|
834
|
-
distance_from_component_edge: 0.4,
|
|
835
|
-
side_of_component: "right",
|
|
836
|
-
pin_number: 8,
|
|
837
|
-
true_ccw_index: 7
|
|
838
|
-
},
|
|
839
|
-
{
|
|
840
|
-
type: "pcb_component",
|
|
841
|
-
pcb_component_id: "pcb_component_0",
|
|
842
|
-
center: {
|
|
843
|
-
x: 0,
|
|
844
|
-
y: 0
|
|
845
|
-
},
|
|
846
|
-
width: 8.82,
|
|
847
|
-
height: 8.82,
|
|
848
|
-
layer: "top",
|
|
849
|
-
rotation: 0,
|
|
850
|
-
source_component_id: "source_component_0"
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
type: "pcb_board",
|
|
854
|
-
pcb_board_id: "pcb_board_0",
|
|
855
|
-
center: {
|
|
856
|
-
x: 0,
|
|
857
|
-
y: 0
|
|
858
|
-
},
|
|
859
|
-
thickness: 1.4,
|
|
860
|
-
num_layers: 4,
|
|
861
|
-
width: 10,
|
|
862
|
-
height: 10
|
|
863
|
-
},
|
|
864
|
-
{
|
|
865
|
-
type: "pcb_plated_hole",
|
|
866
|
-
pcb_plated_hole_id: "pcb_plated_hole_0",
|
|
867
|
-
pcb_component_id: "pcb_component_0",
|
|
868
|
-
pcb_port_id: "pcb_port_0",
|
|
869
|
-
outer_diameter: 1.2,
|
|
870
|
-
hole_diameter: 1,
|
|
871
|
-
shape: "circle",
|
|
872
|
-
port_hints: ["1"],
|
|
873
|
-
x: -3.81,
|
|
874
|
-
y: 3.81,
|
|
875
|
-
layers: ["top", "bottom"]
|
|
876
|
-
},
|
|
877
|
-
{
|
|
878
|
-
type: "pcb_plated_hole",
|
|
879
|
-
pcb_plated_hole_id: "pcb_plated_hole_1",
|
|
880
|
-
pcb_component_id: "pcb_component_0",
|
|
881
|
-
pcb_port_id: "pcb_port_1",
|
|
882
|
-
outer_diameter: 1.2,
|
|
883
|
-
hole_diameter: 1,
|
|
884
|
-
shape: "circle",
|
|
885
|
-
port_hints: ["2"],
|
|
886
|
-
x: -3.81,
|
|
887
|
-
y: 1.27,
|
|
888
|
-
layers: ["top", "bottom"]
|
|
889
|
-
},
|
|
890
|
-
{
|
|
891
|
-
type: "pcb_plated_hole",
|
|
892
|
-
pcb_plated_hole_id: "pcb_plated_hole_2",
|
|
893
|
-
pcb_component_id: "pcb_component_0",
|
|
894
|
-
pcb_port_id: "pcb_port_2",
|
|
895
|
-
outer_diameter: 1.2,
|
|
896
|
-
hole_diameter: 1,
|
|
897
|
-
shape: "circle",
|
|
898
|
-
port_hints: ["3"],
|
|
899
|
-
x: -3.81,
|
|
900
|
-
y: -1.27,
|
|
901
|
-
layers: ["top", "bottom"]
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
type: "pcb_plated_hole",
|
|
905
|
-
pcb_plated_hole_id: "pcb_plated_hole_3",
|
|
906
|
-
pcb_component_id: "pcb_component_0",
|
|
907
|
-
pcb_port_id: "pcb_port_3",
|
|
908
|
-
outer_diameter: 1.2,
|
|
909
|
-
hole_diameter: 1,
|
|
910
|
-
shape: "circle",
|
|
911
|
-
port_hints: ["4"],
|
|
912
|
-
x: -3.81,
|
|
913
|
-
y: -3.81,
|
|
914
|
-
layers: ["top", "bottom"]
|
|
915
|
-
},
|
|
916
|
-
{
|
|
917
|
-
type: "pcb_plated_hole",
|
|
918
|
-
pcb_plated_hole_id: "pcb_plated_hole_4",
|
|
919
|
-
pcb_component_id: "pcb_component_0",
|
|
920
|
-
pcb_port_id: "pcb_port_4",
|
|
921
|
-
outer_diameter: 1.2,
|
|
922
|
-
hole_diameter: 1,
|
|
923
|
-
shape: "circle",
|
|
924
|
-
port_hints: ["5"],
|
|
925
|
-
x: 3.81,
|
|
926
|
-
y: -3.81,
|
|
927
|
-
layers: ["top", "bottom"]
|
|
928
|
-
},
|
|
929
|
-
{
|
|
930
|
-
type: "pcb_plated_hole",
|
|
931
|
-
pcb_plated_hole_id: "pcb_plated_hole_5",
|
|
932
|
-
pcb_component_id: "pcb_component_0",
|
|
933
|
-
pcb_port_id: "pcb_port_5",
|
|
934
|
-
outer_diameter: 1.2,
|
|
935
|
-
hole_diameter: 1,
|
|
936
|
-
shape: "circle",
|
|
937
|
-
port_hints: ["6"],
|
|
938
|
-
x: 3.81,
|
|
939
|
-
y: -1.27,
|
|
940
|
-
layers: ["top", "bottom"]
|
|
941
|
-
},
|
|
942
|
-
{
|
|
943
|
-
type: "pcb_plated_hole",
|
|
944
|
-
pcb_plated_hole_id: "pcb_plated_hole_6",
|
|
945
|
-
pcb_component_id: "pcb_component_0",
|
|
946
|
-
pcb_port_id: "pcb_port_6",
|
|
947
|
-
outer_diameter: 1.2,
|
|
948
|
-
hole_diameter: 1,
|
|
949
|
-
shape: "circle",
|
|
950
|
-
port_hints: ["7"],
|
|
951
|
-
x: 3.81,
|
|
952
|
-
y: 1.27,
|
|
953
|
-
layers: ["top", "bottom"]
|
|
954
|
-
},
|
|
955
|
-
{
|
|
956
|
-
type: "pcb_plated_hole",
|
|
957
|
-
pcb_plated_hole_id: "pcb_plated_hole_7",
|
|
958
|
-
pcb_component_id: "pcb_component_0",
|
|
959
|
-
pcb_port_id: "pcb_port_7",
|
|
960
|
-
outer_diameter: 1.2,
|
|
961
|
-
hole_diameter: 1,
|
|
962
|
-
shape: "circle",
|
|
963
|
-
port_hints: ["8"],
|
|
964
|
-
x: 3.81,
|
|
965
|
-
y: 3.81,
|
|
966
|
-
layers: ["top", "bottom"]
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
type: "pcb_silkscreen_path",
|
|
970
|
-
pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
|
|
971
|
-
pcb_component_id: "pcb_component_0",
|
|
972
|
-
layer: "top",
|
|
973
|
-
route: [
|
|
974
|
-
{
|
|
975
|
-
x: -3.01,
|
|
976
|
-
y: -4.61
|
|
977
|
-
},
|
|
978
|
-
{
|
|
979
|
-
x: -3.01,
|
|
980
|
-
y: 4.61
|
|
981
|
-
},
|
|
982
|
-
{
|
|
983
|
-
x: -1.0033333333333332,
|
|
984
|
-
y: 4.61
|
|
985
|
-
},
|
|
986
|
-
{
|
|
987
|
-
x: -0.9269591309529909,
|
|
988
|
-
y: 4.226040956193693
|
|
989
|
-
},
|
|
990
|
-
{
|
|
991
|
-
x: -0.7094638037905026,
|
|
992
|
-
y: 3.9005361962094978
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
x: -0.3839590438063067,
|
|
996
|
-
y: 3.6830408690470096
|
|
997
|
-
},
|
|
998
|
-
{
|
|
999
|
-
x: 6143644775722556e-32,
|
|
1000
|
-
y: 3.6066666666666674
|
|
1001
|
-
},
|
|
1002
|
-
{
|
|
1003
|
-
x: 0.38395904380630674,
|
|
1004
|
-
y: 3.6830408690470096
|
|
1005
|
-
},
|
|
1006
|
-
{
|
|
1007
|
-
x: 0.7094638037905027,
|
|
1008
|
-
y: 3.9005361962094978
|
|
1009
|
-
},
|
|
1010
|
-
{
|
|
1011
|
-
x: 0.9269591309529909,
|
|
1012
|
-
y: 4.226040956193693
|
|
1013
|
-
},
|
|
1014
|
-
{
|
|
1015
|
-
x: 1.0033333333333332,
|
|
1016
|
-
y: 4.61
|
|
1017
|
-
},
|
|
1018
|
-
{
|
|
1019
|
-
x: 3.01,
|
|
1020
|
-
y: 4.61
|
|
1021
|
-
},
|
|
1022
|
-
{
|
|
1023
|
-
x: 3.01,
|
|
1024
|
-
y: -4.61
|
|
1025
|
-
},
|
|
1026
|
-
{
|
|
1027
|
-
x: -3.01,
|
|
1028
|
-
y: -4.61
|
|
1029
|
-
}
|
|
1030
|
-
],
|
|
1031
|
-
stroke_width: 0.1
|
|
1032
|
-
},
|
|
1033
|
-
{
|
|
1034
|
-
type: "pcb_port",
|
|
1035
|
-
pcb_port_id: "pcb_port_0",
|
|
1036
|
-
pcb_component_id: "pcb_component_0",
|
|
1037
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1038
|
-
x: -3.81,
|
|
1039
|
-
y: 3.81,
|
|
1040
|
-
source_port_id: "source_port_0"
|
|
1041
|
-
},
|
|
1042
|
-
{
|
|
1043
|
-
type: "pcb_port",
|
|
1044
|
-
pcb_port_id: "pcb_port_1",
|
|
1045
|
-
pcb_component_id: "pcb_component_0",
|
|
1046
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1047
|
-
x: -3.81,
|
|
1048
|
-
y: 1.27,
|
|
1049
|
-
source_port_id: "source_port_1"
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
type: "pcb_port",
|
|
1053
|
-
pcb_port_id: "pcb_port_2",
|
|
1054
|
-
pcb_component_id: "pcb_component_0",
|
|
1055
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1056
|
-
x: -3.81,
|
|
1057
|
-
y: -1.27,
|
|
1058
|
-
source_port_id: "source_port_2"
|
|
1059
|
-
},
|
|
1060
|
-
{
|
|
1061
|
-
type: "pcb_port",
|
|
1062
|
-
pcb_port_id: "pcb_port_3",
|
|
1063
|
-
pcb_component_id: "pcb_component_0",
|
|
1064
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1065
|
-
x: -3.81,
|
|
1066
|
-
y: -3.81,
|
|
1067
|
-
source_port_id: "source_port_3"
|
|
1068
|
-
},
|
|
1069
|
-
{
|
|
1070
|
-
type: "pcb_port",
|
|
1071
|
-
pcb_port_id: "pcb_port_4",
|
|
1072
|
-
pcb_component_id: "pcb_component_0",
|
|
1073
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1074
|
-
x: 3.81,
|
|
1075
|
-
y: -3.81,
|
|
1076
|
-
source_port_id: "source_port_4"
|
|
1077
|
-
},
|
|
1078
|
-
{
|
|
1079
|
-
type: "pcb_port",
|
|
1080
|
-
pcb_port_id: "pcb_port_5",
|
|
1081
|
-
pcb_component_id: "pcb_component_0",
|
|
1082
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1083
|
-
x: 3.81,
|
|
1084
|
-
y: -1.27,
|
|
1085
|
-
source_port_id: "source_port_5"
|
|
1086
|
-
},
|
|
1087
|
-
{
|
|
1088
|
-
type: "pcb_port",
|
|
1089
|
-
pcb_port_id: "pcb_port_6",
|
|
1090
|
-
pcb_component_id: "pcb_component_0",
|
|
1091
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1092
|
-
x: 3.81,
|
|
1093
|
-
y: 1.27,
|
|
1094
|
-
source_port_id: "source_port_6"
|
|
1095
|
-
},
|
|
1096
|
-
{
|
|
1097
|
-
type: "pcb_port",
|
|
1098
|
-
pcb_port_id: "pcb_port_7",
|
|
1099
|
-
pcb_component_id: "pcb_component_0",
|
|
1100
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1101
|
-
x: 3.81,
|
|
1102
|
-
y: 3.81,
|
|
1103
|
-
source_port_id: "source_port_7"
|
|
1104
|
-
},
|
|
1105
|
-
{
|
|
1106
|
-
type: "cad_component",
|
|
1107
|
-
cad_component_id: "cad_component_0",
|
|
1108
|
-
position: {
|
|
1109
|
-
x: 0,
|
|
1110
|
-
y: 0,
|
|
1111
|
-
z: 0.7
|
|
1112
|
-
},
|
|
1113
|
-
rotation: {
|
|
1114
|
-
x: 0,
|
|
1115
|
-
y: 0,
|
|
1116
|
-
z: 0
|
|
1117
|
-
},
|
|
1118
|
-
pcb_component_id: "pcb_component_0",
|
|
1119
|
-
source_component_id: "source_component_0",
|
|
1120
|
-
footprinter_string: "dip8"
|
|
1121
|
-
}
|
|
1122
|
-
]
|
|
1123
|
-
});
|
|
1124
|
-
const firstBuild = db.addPackageBuild({
|
|
1125
|
-
package_release_id: packageReleaseId1,
|
|
1126
|
-
created_at: new Date(Date.now() - 15e3).toISOString(),
|
|
1127
|
-
// 15 seconds ago
|
|
1128
|
-
transpilation_in_progress: false,
|
|
1129
|
-
transpilation_started_at: new Date(Date.now() - 15e3).toISOString(),
|
|
1130
|
-
transpilation_completed_at: new Date(Date.now() - 14e3).toISOString(),
|
|
1131
|
-
transpilation_logs: [
|
|
1132
|
-
"[INFO] Starting transpilation...",
|
|
1133
|
-
"[INFO] Parsing package code",
|
|
1134
|
-
"[ERROR] Failed to parse TypeScript definitions",
|
|
1135
|
-
"[ERROR] Invalid syntax in component declaration"
|
|
1136
|
-
],
|
|
1137
|
-
transpilation_error: "TypeScript compilation failed: Syntax error in component declaration",
|
|
1138
|
-
circuit_json_build_in_progress: false,
|
|
1139
|
-
circuit_json_build_started_at: null,
|
|
1140
|
-
circuit_json_build_completed_at: null,
|
|
1141
|
-
circuit_json_build_logs: [],
|
|
1142
|
-
circuit_json_build_error: "Build cancelled due to transpilation failure",
|
|
1143
|
-
build_in_progress: false,
|
|
1144
|
-
build_started_at: new Date(Date.now() - 15e3).toISOString(),
|
|
1145
|
-
build_completed_at: new Date(Date.now() - 14e3).toISOString(),
|
|
1146
|
-
build_error: "Build failed: Unable to complete transpilation step",
|
|
1147
|
-
build_error_last_updated_at: new Date(Date.now() - 14e3).toISOString(),
|
|
1148
|
-
preview_url: null,
|
|
1149
|
-
build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - FAILED\nError: Invalid syntax in component declaration\nBuild terminated with errors"
|
|
1150
|
-
});
|
|
1151
|
-
const release1 = db.getPackageReleaseById(packageReleaseId1);
|
|
1152
|
-
db.updatePackageRelease({
|
|
1153
|
-
...release1,
|
|
1154
|
-
latest_package_build_id: firstBuild.package_build_id
|
|
1155
|
-
});
|
|
1156
|
-
db.addSnippet({
|
|
1157
|
-
name: "seveibar/a555timer",
|
|
1158
|
-
unscoped_name: "a555timer",
|
|
1159
|
-
owner_name: "seveibar",
|
|
1160
|
-
code: `
|
|
1161
|
-
export const A555Timer = ({ name }: { name: string }) => (
|
|
1162
|
-
<chip name={name} footprint="dip8" />
|
|
1163
|
-
)
|
|
1164
|
-
`.trim(),
|
|
1165
|
-
dts: `
|
|
1166
|
-
declare module "@tsci/seveibar.a555timer" {
|
|
1167
|
-
export const A555Timer: ({ name }: {
|
|
1168
|
-
name: string;
|
|
1169
|
-
}) => any;
|
|
1170
|
-
}
|
|
1171
|
-
`.trim(),
|
|
1172
|
-
compiled_js: `
|
|
1173
|
-
"use strict";
|
|
1174
|
-
|
|
1175
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1176
|
-
value: true
|
|
1177
|
-
});
|
|
1178
|
-
exports.A555Timer = void 0;
|
|
1179
|
-
const A555Timer = ({
|
|
1180
|
-
name
|
|
1181
|
-
}) => /*#__PURE__*/React.createElement("chip", {
|
|
1182
|
-
name: name,
|
|
1183
|
-
footprint: "dip8"
|
|
1184
|
-
});
|
|
1185
|
-
exports.A555Timer = A555Timer;
|
|
1186
|
-
`.trim(),
|
|
1187
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1188
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1189
|
-
snippet_type: "package",
|
|
1190
|
-
description: "A simple package with an A555 Timer component",
|
|
1191
|
-
circuit_json: [
|
|
1192
|
-
{
|
|
1193
|
-
type: "source_port",
|
|
1194
|
-
source_port_id: "source_port_0",
|
|
1195
|
-
name: "pin1",
|
|
1196
|
-
pin_number: 1,
|
|
1197
|
-
port_hints: ["pin1", "1"],
|
|
1198
|
-
source_component_id: "source_component_0"
|
|
1199
|
-
},
|
|
1200
|
-
{
|
|
1201
|
-
type: "source_port",
|
|
1202
|
-
source_port_id: "source_port_1",
|
|
1203
|
-
name: "pin2",
|
|
1204
|
-
pin_number: 2,
|
|
1205
|
-
port_hints: ["pin2", "2"],
|
|
1206
|
-
source_component_id: "source_component_0"
|
|
1207
|
-
},
|
|
1208
|
-
{
|
|
1209
|
-
type: "source_port",
|
|
1210
|
-
source_port_id: "source_port_2",
|
|
1211
|
-
name: "pin3",
|
|
1212
|
-
pin_number: 3,
|
|
1213
|
-
port_hints: ["pin3", "3"],
|
|
1214
|
-
source_component_id: "source_component_0"
|
|
1215
|
-
},
|
|
1216
|
-
{
|
|
1217
|
-
type: "source_port",
|
|
1218
|
-
source_port_id: "source_port_3",
|
|
1219
|
-
name: "pin4",
|
|
1220
|
-
pin_number: 4,
|
|
1221
|
-
port_hints: ["pin4", "4"],
|
|
1222
|
-
source_component_id: "source_component_0"
|
|
1223
|
-
},
|
|
1224
|
-
{
|
|
1225
|
-
type: "source_port",
|
|
1226
|
-
source_port_id: "source_port_4",
|
|
1227
|
-
name: "pin5",
|
|
1228
|
-
pin_number: 5,
|
|
1229
|
-
port_hints: ["pin5", "5"],
|
|
1230
|
-
source_component_id: "source_component_0"
|
|
1231
|
-
},
|
|
1232
|
-
{
|
|
1233
|
-
type: "source_port",
|
|
1234
|
-
source_port_id: "source_port_5",
|
|
1235
|
-
name: "pin6",
|
|
1236
|
-
pin_number: 6,
|
|
1237
|
-
port_hints: ["pin6", "6"],
|
|
1238
|
-
source_component_id: "source_component_0"
|
|
1239
|
-
},
|
|
1240
|
-
{
|
|
1241
|
-
type: "source_port",
|
|
1242
|
-
source_port_id: "source_port_6",
|
|
1243
|
-
name: "pin7",
|
|
1244
|
-
pin_number: 7,
|
|
1245
|
-
port_hints: ["pin7", "7"],
|
|
1246
|
-
source_component_id: "source_component_0"
|
|
1247
|
-
},
|
|
1248
|
-
{
|
|
1249
|
-
type: "source_port",
|
|
1250
|
-
source_port_id: "source_port_7",
|
|
1251
|
-
name: "pin8",
|
|
1252
|
-
pin_number: 8,
|
|
1253
|
-
port_hints: ["pin8", "8"],
|
|
1254
|
-
source_component_id: "source_component_0"
|
|
1255
|
-
},
|
|
1256
|
-
{
|
|
1257
|
-
type: "source_component",
|
|
1258
|
-
source_component_id: "source_component_0",
|
|
1259
|
-
ftype: "simple_chip",
|
|
1260
|
-
name: "U1"
|
|
1261
|
-
},
|
|
1262
|
-
{
|
|
1263
|
-
type: "schematic_component",
|
|
1264
|
-
schematic_component_id: "schematic_component_0",
|
|
1265
|
-
center: {
|
|
1266
|
-
x: 0,
|
|
1267
|
-
y: 0
|
|
1268
|
-
},
|
|
1269
|
-
rotation: 0,
|
|
1270
|
-
size: {
|
|
1271
|
-
width: 1.1,
|
|
1272
|
-
height: 1
|
|
1273
|
-
},
|
|
1274
|
-
pin_spacing: 0.2,
|
|
1275
|
-
port_labels: {},
|
|
1276
|
-
source_component_id: "source_component_0"
|
|
1277
|
-
},
|
|
1278
|
-
{
|
|
1279
|
-
type: "schematic_port",
|
|
1280
|
-
schematic_port_id: "schematic_port_0",
|
|
1281
|
-
schematic_component_id: "schematic_component_0",
|
|
1282
|
-
center: {
|
|
1283
|
-
x: -0.9500000000000001,
|
|
1284
|
-
y: 0.30000000000000004
|
|
1285
|
-
},
|
|
1286
|
-
source_port_id: "source_port_0",
|
|
1287
|
-
facing_direction: "left",
|
|
1288
|
-
distance_from_component_edge: 0.4,
|
|
1289
|
-
side_of_component: "left",
|
|
1290
|
-
pin_number: 1,
|
|
1291
|
-
true_ccw_index: 0
|
|
1292
|
-
},
|
|
1293
|
-
{
|
|
1294
|
-
type: "schematic_port",
|
|
1295
|
-
schematic_port_id: "schematic_port_1",
|
|
1296
|
-
schematic_component_id: "schematic_component_0",
|
|
1297
|
-
center: {
|
|
1298
|
-
x: -0.9500000000000001,
|
|
1299
|
-
y: 0.10000000000000003
|
|
1300
|
-
},
|
|
1301
|
-
source_port_id: "source_port_1",
|
|
1302
|
-
facing_direction: "left",
|
|
1303
|
-
distance_from_component_edge: 0.4,
|
|
1304
|
-
side_of_component: "left",
|
|
1305
|
-
pin_number: 2,
|
|
1306
|
-
true_ccw_index: 1
|
|
1307
|
-
},
|
|
1308
|
-
{
|
|
1309
|
-
type: "schematic_port",
|
|
1310
|
-
schematic_port_id: "schematic_port_2",
|
|
1311
|
-
schematic_component_id: "schematic_component_0",
|
|
1312
|
-
center: {
|
|
1313
|
-
x: -0.9500000000000001,
|
|
1314
|
-
y: -0.09999999999999998
|
|
1315
|
-
},
|
|
1316
|
-
source_port_id: "source_port_2",
|
|
1317
|
-
facing_direction: "left",
|
|
1318
|
-
distance_from_component_edge: 0.4,
|
|
1319
|
-
side_of_component: "left",
|
|
1320
|
-
pin_number: 3,
|
|
1321
|
-
true_ccw_index: 2
|
|
1322
|
-
},
|
|
1323
|
-
{
|
|
1324
|
-
type: "schematic_port",
|
|
1325
|
-
schematic_port_id: "schematic_port_3",
|
|
1326
|
-
schematic_component_id: "schematic_component_0",
|
|
1327
|
-
center: {
|
|
1328
|
-
x: -0.9500000000000001,
|
|
1329
|
-
y: -0.30000000000000004
|
|
1330
|
-
},
|
|
1331
|
-
source_port_id: "source_port_3",
|
|
1332
|
-
facing_direction: "left",
|
|
1333
|
-
distance_from_component_edge: 0.4,
|
|
1334
|
-
side_of_component: "left",
|
|
1335
|
-
pin_number: 4,
|
|
1336
|
-
true_ccw_index: 3
|
|
1337
|
-
},
|
|
1338
|
-
{
|
|
1339
|
-
type: "schematic_port",
|
|
1340
|
-
schematic_port_id: "schematic_port_4",
|
|
1341
|
-
schematic_component_id: "schematic_component_0",
|
|
1342
|
-
center: {
|
|
1343
|
-
x: 0.9500000000000001,
|
|
1344
|
-
y: -0.30000000000000004
|
|
1345
|
-
},
|
|
1346
|
-
source_port_id: "source_port_4",
|
|
1347
|
-
facing_direction: "right",
|
|
1348
|
-
distance_from_component_edge: 0.4,
|
|
1349
|
-
side_of_component: "right",
|
|
1350
|
-
pin_number: 5,
|
|
1351
|
-
true_ccw_index: 4
|
|
1352
|
-
},
|
|
1353
|
-
{
|
|
1354
|
-
type: "schematic_port",
|
|
1355
|
-
schematic_port_id: "schematic_port_5",
|
|
1356
|
-
schematic_component_id: "schematic_component_0",
|
|
1357
|
-
center: {
|
|
1358
|
-
x: 0.9500000000000001,
|
|
1359
|
-
y: -0.10000000000000003
|
|
1360
|
-
},
|
|
1361
|
-
source_port_id: "source_port_5",
|
|
1362
|
-
facing_direction: "right",
|
|
1363
|
-
distance_from_component_edge: 0.4,
|
|
1364
|
-
side_of_component: "right",
|
|
1365
|
-
pin_number: 6,
|
|
1366
|
-
true_ccw_index: 5
|
|
1367
|
-
},
|
|
1368
|
-
{
|
|
1369
|
-
type: "schematic_port",
|
|
1370
|
-
schematic_port_id: "schematic_port_6",
|
|
1371
|
-
schematic_component_id: "schematic_component_0",
|
|
1372
|
-
center: {
|
|
1373
|
-
x: 0.9500000000000001,
|
|
1374
|
-
y: 0.09999999999999998
|
|
1375
|
-
},
|
|
1376
|
-
source_port_id: "source_port_6",
|
|
1377
|
-
facing_direction: "right",
|
|
1378
|
-
distance_from_component_edge: 0.4,
|
|
1379
|
-
side_of_component: "right",
|
|
1380
|
-
pin_number: 7,
|
|
1381
|
-
true_ccw_index: 6
|
|
1382
|
-
},
|
|
1383
|
-
{
|
|
1384
|
-
type: "schematic_port",
|
|
1385
|
-
schematic_port_id: "schematic_port_7",
|
|
1386
|
-
schematic_component_id: "schematic_component_0",
|
|
1387
|
-
center: {
|
|
1388
|
-
x: 0.9500000000000001,
|
|
1389
|
-
y: 0.30000000000000004
|
|
1390
|
-
},
|
|
1391
|
-
source_port_id: "source_port_7",
|
|
1392
|
-
facing_direction: "right",
|
|
1393
|
-
distance_from_component_edge: 0.4,
|
|
1394
|
-
side_of_component: "right",
|
|
1395
|
-
pin_number: 8,
|
|
1396
|
-
true_ccw_index: 7
|
|
1397
|
-
},
|
|
1398
|
-
{
|
|
1399
|
-
type: "pcb_component",
|
|
1400
|
-
pcb_component_id: "pcb_component_0",
|
|
1401
|
-
center: {
|
|
1402
|
-
x: 0,
|
|
1403
|
-
y: 0
|
|
1404
|
-
},
|
|
1405
|
-
width: 8.82,
|
|
1406
|
-
height: 8.82,
|
|
1407
|
-
layer: "top",
|
|
1408
|
-
rotation: 0,
|
|
1409
|
-
source_component_id: "source_component_0"
|
|
1410
|
-
},
|
|
1411
|
-
{
|
|
1412
|
-
type: "pcb_board",
|
|
1413
|
-
pcb_board_id: "pcb_board_0",
|
|
1414
|
-
center: {
|
|
1415
|
-
x: 0,
|
|
1416
|
-
y: 0
|
|
1417
|
-
},
|
|
1418
|
-
thickness: 1.4,
|
|
1419
|
-
num_layers: 4,
|
|
1420
|
-
width: 50,
|
|
1421
|
-
height: 50
|
|
1422
|
-
},
|
|
1423
|
-
{
|
|
1424
|
-
type: "pcb_plated_hole",
|
|
1425
|
-
pcb_plated_hole_id: "pcb_plated_hole_0",
|
|
1426
|
-
pcb_component_id: "pcb_component_0",
|
|
1427
|
-
pcb_port_id: "pcb_port_0",
|
|
1428
|
-
outer_diameter: 1.2,
|
|
1429
|
-
hole_diameter: 1,
|
|
1430
|
-
shape: "circle",
|
|
1431
|
-
port_hints: ["1"],
|
|
1432
|
-
x: -3.81,
|
|
1433
|
-
y: 3.81,
|
|
1434
|
-
layers: ["top", "bottom"]
|
|
1435
|
-
},
|
|
1436
|
-
{
|
|
1437
|
-
type: "pcb_plated_hole",
|
|
1438
|
-
pcb_plated_hole_id: "pcb_plated_hole_1",
|
|
1439
|
-
pcb_component_id: "pcb_component_0",
|
|
1440
|
-
pcb_port_id: "pcb_port_1",
|
|
1441
|
-
outer_diameter: 1.2,
|
|
1442
|
-
hole_diameter: 1,
|
|
1443
|
-
shape: "circle",
|
|
1444
|
-
port_hints: ["2"],
|
|
1445
|
-
x: -3.81,
|
|
1446
|
-
y: 1.27,
|
|
1447
|
-
layers: ["top", "bottom"]
|
|
1448
|
-
},
|
|
1449
|
-
{
|
|
1450
|
-
type: "pcb_plated_hole",
|
|
1451
|
-
pcb_plated_hole_id: "pcb_plated_hole_2",
|
|
1452
|
-
pcb_component_id: "pcb_component_0",
|
|
1453
|
-
pcb_port_id: "pcb_port_2",
|
|
1454
|
-
outer_diameter: 1.2,
|
|
1455
|
-
hole_diameter: 1,
|
|
1456
|
-
shape: "circle",
|
|
1457
|
-
port_hints: ["3"],
|
|
1458
|
-
x: -3.81,
|
|
1459
|
-
y: -1.27,
|
|
1460
|
-
layers: ["top", "bottom"]
|
|
1461
|
-
},
|
|
1462
|
-
{
|
|
1463
|
-
type: "pcb_plated_hole",
|
|
1464
|
-
pcb_plated_hole_id: "pcb_plated_hole_3",
|
|
1465
|
-
pcb_component_id: "pcb_component_0",
|
|
1466
|
-
pcb_port_id: "pcb_port_3",
|
|
1467
|
-
outer_diameter: 1.2,
|
|
1468
|
-
hole_diameter: 1,
|
|
1469
|
-
shape: "circle",
|
|
1470
|
-
port_hints: ["4"],
|
|
1471
|
-
x: -3.81,
|
|
1472
|
-
y: -3.81,
|
|
1473
|
-
layers: ["top", "bottom"]
|
|
1474
|
-
},
|
|
1475
|
-
{
|
|
1476
|
-
type: "pcb_plated_hole",
|
|
1477
|
-
pcb_plated_hole_id: "pcb_plated_hole_4",
|
|
1478
|
-
pcb_component_id: "pcb_component_0",
|
|
1479
|
-
pcb_port_id: "pcb_port_4",
|
|
1480
|
-
outer_diameter: 1.2,
|
|
1481
|
-
hole_diameter: 1,
|
|
1482
|
-
shape: "circle",
|
|
1483
|
-
port_hints: ["5"],
|
|
1484
|
-
x: 3.81,
|
|
1485
|
-
y: -3.81,
|
|
1486
|
-
layers: ["top", "bottom"]
|
|
1487
|
-
},
|
|
1488
|
-
{
|
|
1489
|
-
type: "pcb_plated_hole",
|
|
1490
|
-
pcb_plated_hole_id: "pcb_plated_hole_5",
|
|
1491
|
-
pcb_component_id: "pcb_component_0",
|
|
1492
|
-
pcb_port_id: "pcb_port_5",
|
|
1493
|
-
outer_diameter: 1.2,
|
|
1494
|
-
hole_diameter: 1,
|
|
1495
|
-
shape: "circle",
|
|
1496
|
-
port_hints: ["6"],
|
|
1497
|
-
x: 3.81,
|
|
1498
|
-
y: -1.27,
|
|
1499
|
-
layers: ["top", "bottom"]
|
|
1500
|
-
},
|
|
1501
|
-
{
|
|
1502
|
-
type: "pcb_plated_hole",
|
|
1503
|
-
pcb_plated_hole_id: "pcb_plated_hole_6",
|
|
1504
|
-
pcb_component_id: "pcb_component_0",
|
|
1505
|
-
pcb_port_id: "pcb_port_6",
|
|
1506
|
-
outer_diameter: 1.2,
|
|
1507
|
-
hole_diameter: 1,
|
|
1508
|
-
shape: "circle",
|
|
1509
|
-
port_hints: ["7"],
|
|
1510
|
-
x: 3.81,
|
|
1511
|
-
y: 1.27,
|
|
1512
|
-
layers: ["top", "bottom"]
|
|
1513
|
-
},
|
|
1514
|
-
{
|
|
1515
|
-
type: "pcb_plated_hole",
|
|
1516
|
-
pcb_plated_hole_id: "pcb_plated_hole_7",
|
|
1517
|
-
pcb_component_id: "pcb_component_0",
|
|
1518
|
-
pcb_port_id: "pcb_port_7",
|
|
1519
|
-
outer_diameter: 1.2,
|
|
1520
|
-
hole_diameter: 1,
|
|
1521
|
-
shape: "circle",
|
|
1522
|
-
port_hints: ["8"],
|
|
1523
|
-
x: 3.81,
|
|
1524
|
-
y: 3.81,
|
|
1525
|
-
layers: ["top", "bottom"]
|
|
1526
|
-
},
|
|
1527
|
-
{
|
|
1528
|
-
type: "pcb_silkscreen_path",
|
|
1529
|
-
pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
|
|
1530
|
-
pcb_component_id: "pcb_component_0",
|
|
1531
|
-
layer: "top",
|
|
1532
|
-
route: [
|
|
1533
|
-
{
|
|
1534
|
-
x: -3.01,
|
|
1535
|
-
y: -4.61
|
|
1536
|
-
},
|
|
1537
|
-
{
|
|
1538
|
-
x: -3.01,
|
|
1539
|
-
y: 4.61
|
|
1540
|
-
},
|
|
1541
|
-
{
|
|
1542
|
-
x: -1.0033333333333332,
|
|
1543
|
-
y: 4.61
|
|
1544
|
-
},
|
|
1545
|
-
{
|
|
1546
|
-
x: -0.9269591309529909,
|
|
1547
|
-
y: 4.226040956193693
|
|
1548
|
-
},
|
|
1549
|
-
{
|
|
1550
|
-
x: -0.7094638037905026,
|
|
1551
|
-
y: 3.9005361962094978
|
|
1552
|
-
},
|
|
1553
|
-
{
|
|
1554
|
-
x: -0.3839590438063067,
|
|
1555
|
-
y: 3.6830408690470096
|
|
1556
|
-
},
|
|
1557
|
-
{
|
|
1558
|
-
x: 6143644775722556e-32,
|
|
1559
|
-
y: 3.6066666666666674
|
|
1560
|
-
},
|
|
1561
|
-
{
|
|
1562
|
-
x: 0.38395904380630674,
|
|
1563
|
-
y: 3.6830408690470096
|
|
1564
|
-
},
|
|
1565
|
-
{
|
|
1566
|
-
x: 0.7094638037905027,
|
|
1567
|
-
y: 3.9005361962094978
|
|
1568
|
-
},
|
|
1569
|
-
{
|
|
1570
|
-
x: 0.9269591309529909,
|
|
1571
|
-
y: 4.226040956193693
|
|
1572
|
-
},
|
|
1573
|
-
{
|
|
1574
|
-
x: 1.0033333333333332,
|
|
1575
|
-
y: 4.61
|
|
1576
|
-
},
|
|
1577
|
-
{
|
|
1578
|
-
x: 3.01,
|
|
1579
|
-
y: 4.61
|
|
1580
|
-
},
|
|
1581
|
-
{
|
|
1582
|
-
x: 3.01,
|
|
1583
|
-
y: -4.61
|
|
1584
|
-
},
|
|
1585
|
-
{
|
|
1586
|
-
x: -3.01,
|
|
1587
|
-
y: -4.61
|
|
1588
|
-
}
|
|
1589
|
-
],
|
|
1590
|
-
stroke_width: 0.1
|
|
1591
|
-
},
|
|
1592
|
-
{
|
|
1593
|
-
type: "pcb_port",
|
|
1594
|
-
pcb_port_id: "pcb_port_0",
|
|
1595
|
-
pcb_component_id: "pcb_component_0",
|
|
1596
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1597
|
-
x: -3.81,
|
|
1598
|
-
y: 3.81,
|
|
1599
|
-
source_port_id: "source_port_0"
|
|
1600
|
-
},
|
|
1601
|
-
{
|
|
1602
|
-
type: "pcb_port",
|
|
1603
|
-
pcb_port_id: "pcb_port_1",
|
|
1604
|
-
pcb_component_id: "pcb_component_0",
|
|
1605
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1606
|
-
x: -3.81,
|
|
1607
|
-
y: 1.27,
|
|
1608
|
-
source_port_id: "source_port_1"
|
|
1609
|
-
},
|
|
1610
|
-
{
|
|
1611
|
-
type: "pcb_port",
|
|
1612
|
-
pcb_port_id: "pcb_port_2",
|
|
1613
|
-
pcb_component_id: "pcb_component_0",
|
|
1614
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1615
|
-
x: -3.81,
|
|
1616
|
-
y: -1.27,
|
|
1617
|
-
source_port_id: "source_port_2"
|
|
1618
|
-
},
|
|
1619
|
-
{
|
|
1620
|
-
type: "pcb_port",
|
|
1621
|
-
pcb_port_id: "pcb_port_3",
|
|
1622
|
-
pcb_component_id: "pcb_component_0",
|
|
1623
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1624
|
-
x: -3.81,
|
|
1625
|
-
y: -3.81,
|
|
1626
|
-
source_port_id: "source_port_3"
|
|
1627
|
-
},
|
|
1628
|
-
{
|
|
1629
|
-
type: "pcb_port",
|
|
1630
|
-
pcb_port_id: "pcb_port_4",
|
|
1631
|
-
pcb_component_id: "pcb_component_0",
|
|
1632
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1633
|
-
x: 3.81,
|
|
1634
|
-
y: -3.81,
|
|
1635
|
-
source_port_id: "source_port_4"
|
|
1636
|
-
},
|
|
1637
|
-
{
|
|
1638
|
-
type: "pcb_port",
|
|
1639
|
-
pcb_port_id: "pcb_port_5",
|
|
1640
|
-
pcb_component_id: "pcb_component_0",
|
|
1641
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1642
|
-
x: 3.81,
|
|
1643
|
-
y: -1.27,
|
|
1644
|
-
source_port_id: "source_port_5"
|
|
1645
|
-
},
|
|
1646
|
-
{
|
|
1647
|
-
type: "pcb_port",
|
|
1648
|
-
pcb_port_id: "pcb_port_6",
|
|
1649
|
-
pcb_component_id: "pcb_component_0",
|
|
1650
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1651
|
-
x: 3.81,
|
|
1652
|
-
y: 1.27,
|
|
1653
|
-
source_port_id: "source_port_6"
|
|
1654
|
-
},
|
|
1655
|
-
{
|
|
1656
|
-
type: "pcb_port",
|
|
1657
|
-
pcb_port_id: "pcb_port_7",
|
|
1658
|
-
pcb_component_id: "pcb_component_0",
|
|
1659
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
1660
|
-
x: 3.81,
|
|
1661
|
-
y: 3.81,
|
|
1662
|
-
source_port_id: "source_port_7"
|
|
1663
|
-
},
|
|
1664
|
-
{
|
|
1665
|
-
type: "cad_component",
|
|
1666
|
-
cad_component_id: "cad_component_0",
|
|
1667
|
-
position: {
|
|
1668
|
-
x: 0,
|
|
1669
|
-
y: 0,
|
|
1670
|
-
z: 0.7
|
|
1671
|
-
},
|
|
1672
|
-
rotation: {
|
|
1673
|
-
x: 0,
|
|
1674
|
-
y: 0,
|
|
1675
|
-
z: 0
|
|
1676
|
-
},
|
|
1677
|
-
pcb_component_id: "pcb_component_0",
|
|
1678
|
-
source_component_id: "source_component_0",
|
|
1679
|
-
footprinter_string: "dip8"
|
|
1680
|
-
}
|
|
1681
|
-
]
|
|
1682
|
-
});
|
|
1683
|
-
const { package_release_id: packageReleaseId2 } = db.addSnippet({
|
|
1684
|
-
name: "testuser/a555timer-square-wave",
|
|
1685
|
-
unscoped_name: "a555timer-square-wave",
|
|
1686
|
-
owner_name: "testuser",
|
|
1687
|
-
branch_name: "main",
|
|
1688
|
-
commit_message: "Attempted build of a555timer-square-wave package",
|
|
1689
|
-
commit_author: "testuser",
|
|
1690
|
-
creator_account_id: account_id,
|
|
1691
|
-
code: `
|
|
1692
|
-
import { A555Timer } from "@tsci/seveibar.a555timer"
|
|
1693
|
-
|
|
1694
|
-
export const SquareWaveModule = () => (
|
|
1695
|
-
<A555Timer name="U1" />
|
|
1696
|
-
)
|
|
1697
|
-
`.trim(),
|
|
1698
|
-
dts: 'export declare const SquareWaveModule: () => import("react/jsx-runtime").JSX.Element;\n',
|
|
1699
|
-
compiled_js: '"use strict";\n\nObject.defineProperty(exports, "__esModule", {\n value: true\n});\nexports.SquareWaveModule = void 0;\nvar _seveibar = require("@tsci/seveibar.a555timer");\nconst SquareWaveModule = () => /*#__PURE__*/React.createElement(_seveibar.A555Timer, {\n name: "U1"\n});\nexports.SquareWaveModule = SquareWaveModule;',
|
|
1700
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1701
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1702
|
-
snippet_type: "package",
|
|
1703
|
-
github_repo_full_name: "testuser/test",
|
|
1704
|
-
description: "A simple package that outputs a square waveform using the a555timer",
|
|
1705
|
-
circuit_json: [
|
|
1706
|
-
{
|
|
1707
|
-
type: "source_port",
|
|
1708
|
-
source_port_id: "source_port_0",
|
|
1709
|
-
name: "pin1",
|
|
1710
|
-
pin_number: 1,
|
|
1711
|
-
port_hints: ["pin1", "1"],
|
|
1712
|
-
source_component_id: "source_component_0"
|
|
1713
|
-
},
|
|
1714
|
-
{
|
|
1715
|
-
type: "source_port",
|
|
1716
|
-
source_port_id: "source_port_1",
|
|
1717
|
-
name: "pin2",
|
|
1718
|
-
pin_number: 2,
|
|
1719
|
-
port_hints: ["pin2", "2"],
|
|
1720
|
-
source_component_id: "source_component_0"
|
|
1721
|
-
},
|
|
1722
|
-
{
|
|
1723
|
-
type: "source_port",
|
|
1724
|
-
source_port_id: "source_port_2",
|
|
1725
|
-
name: "pin3",
|
|
1726
|
-
pin_number: 3,
|
|
1727
|
-
port_hints: ["pin3", "3"],
|
|
1728
|
-
source_component_id: "source_component_0"
|
|
1729
|
-
},
|
|
1730
|
-
{
|
|
1731
|
-
type: "source_port",
|
|
1732
|
-
source_port_id: "source_port_3",
|
|
1733
|
-
name: "pin4",
|
|
1734
|
-
pin_number: 4,
|
|
1735
|
-
port_hints: ["pin4", "4"],
|
|
1736
|
-
source_component_id: "source_component_0"
|
|
1737
|
-
},
|
|
1738
|
-
{
|
|
1739
|
-
type: "source_port",
|
|
1740
|
-
source_port_id: "source_port_4",
|
|
1741
|
-
name: "pin5",
|
|
1742
|
-
pin_number: 5,
|
|
1743
|
-
port_hints: ["pin5", "5"],
|
|
1744
|
-
source_component_id: "source_component_0"
|
|
1745
|
-
},
|
|
1746
|
-
{
|
|
1747
|
-
type: "source_port",
|
|
1748
|
-
source_port_id: "source_port_5",
|
|
1749
|
-
name: "pin6",
|
|
1750
|
-
pin_number: 6,
|
|
1751
|
-
port_hints: ["pin6", "6"],
|
|
1752
|
-
source_component_id: "source_component_0"
|
|
1753
|
-
},
|
|
1754
|
-
{
|
|
1755
|
-
type: "source_port",
|
|
1756
|
-
source_port_id: "source_port_6",
|
|
1757
|
-
name: "pin7",
|
|
1758
|
-
pin_number: 7,
|
|
1759
|
-
port_hints: ["pin7", "7"],
|
|
1760
|
-
source_component_id: "source_component_0"
|
|
1761
|
-
},
|
|
1762
|
-
{
|
|
1763
|
-
type: "source_port",
|
|
1764
|
-
source_port_id: "source_port_7",
|
|
1765
|
-
name: "pin8",
|
|
1766
|
-
pin_number: 8,
|
|
1767
|
-
port_hints: ["pin8", "8"],
|
|
1768
|
-
source_component_id: "source_component_0"
|
|
1769
|
-
},
|
|
1770
|
-
{
|
|
1771
|
-
type: "source_component",
|
|
1772
|
-
source_component_id: "source_component_0",
|
|
1773
|
-
ftype: "simple_chip",
|
|
1774
|
-
name: "U1"
|
|
1775
|
-
},
|
|
1776
|
-
{
|
|
1777
|
-
type: "schematic_component",
|
|
1778
|
-
schematic_component_id: "schematic_component_0",
|
|
1779
|
-
center: {
|
|
1780
|
-
x: 0,
|
|
1781
|
-
y: 0
|
|
1782
|
-
},
|
|
1783
|
-
rotation: 0,
|
|
1784
|
-
size: {
|
|
1785
|
-
width: 1.1,
|
|
1786
|
-
height: 1
|
|
1787
|
-
},
|
|
1788
|
-
pin_spacing: 0.2,
|
|
1789
|
-
port_labels: {},
|
|
1790
|
-
source_component_id: "source_component_0"
|
|
1791
|
-
},
|
|
1792
|
-
{
|
|
1793
|
-
type: "schematic_port",
|
|
1794
|
-
schematic_port_id: "schematic_port_0",
|
|
1795
|
-
schematic_component_id: "schematic_component_0",
|
|
1796
|
-
center: {
|
|
1797
|
-
x: -0.9500000000000001,
|
|
1798
|
-
y: 0.30000000000000004
|
|
1799
|
-
},
|
|
1800
|
-
source_port_id: "source_port_0",
|
|
1801
|
-
facing_direction: "left",
|
|
1802
|
-
distance_from_component_edge: 0.4,
|
|
1803
|
-
side_of_component: "left",
|
|
1804
|
-
pin_number: 1,
|
|
1805
|
-
true_ccw_index: 0
|
|
1806
|
-
},
|
|
1807
|
-
{
|
|
1808
|
-
type: "schematic_port",
|
|
1809
|
-
schematic_port_id: "schematic_port_1",
|
|
1810
|
-
schematic_component_id: "schematic_component_0",
|
|
1811
|
-
center: {
|
|
1812
|
-
x: -0.9500000000000001,
|
|
1813
|
-
y: 0.10000000000000003
|
|
1814
|
-
},
|
|
1815
|
-
source_port_id: "source_port_1",
|
|
1816
|
-
facing_direction: "left",
|
|
1817
|
-
distance_from_component_edge: 0.4,
|
|
1818
|
-
side_of_component: "left",
|
|
1819
|
-
pin_number: 2,
|
|
1820
|
-
true_ccw_index: 1
|
|
1821
|
-
},
|
|
1822
|
-
{
|
|
1823
|
-
type: "schematic_port",
|
|
1824
|
-
schematic_port_id: "schematic_port_2",
|
|
1825
|
-
schematic_component_id: "schematic_component_0",
|
|
1826
|
-
center: {
|
|
1827
|
-
x: -0.9500000000000001,
|
|
1828
|
-
y: -0.09999999999999998
|
|
1829
|
-
},
|
|
1830
|
-
source_port_id: "source_port_2",
|
|
1831
|
-
facing_direction: "left",
|
|
1832
|
-
distance_from_component_edge: 0.4,
|
|
1833
|
-
side_of_component: "left",
|
|
1834
|
-
pin_number: 3,
|
|
1835
|
-
true_ccw_index: 2
|
|
1836
|
-
},
|
|
1837
|
-
{
|
|
1838
|
-
type: "schematic_port",
|
|
1839
|
-
schematic_port_id: "schematic_port_3",
|
|
1840
|
-
schematic_component_id: "schematic_component_0",
|
|
1841
|
-
center: {
|
|
1842
|
-
x: -0.9500000000000001,
|
|
1843
|
-
y: -0.30000000000000004
|
|
1844
|
-
},
|
|
1845
|
-
source_port_id: "source_port_3",
|
|
1846
|
-
facing_direction: "left",
|
|
1847
|
-
distance_from_component_edge: 0.4,
|
|
1848
|
-
side_of_component: "left",
|
|
1849
|
-
pin_number: 4,
|
|
1850
|
-
true_ccw_index: 3
|
|
1851
|
-
},
|
|
1852
|
-
{
|
|
1853
|
-
type: "schematic_port",
|
|
1854
|
-
schematic_port_id: "schematic_port_4",
|
|
1855
|
-
schematic_component_id: "schematic_component_0",
|
|
1856
|
-
center: {
|
|
1857
|
-
x: 0.9500000000000001,
|
|
1858
|
-
y: -0.30000000000000004
|
|
1859
|
-
},
|
|
1860
|
-
source_port_id: "source_port_4",
|
|
1861
|
-
facing_direction: "right",
|
|
1862
|
-
distance_from_component_edge: 0.4,
|
|
1863
|
-
side_of_component: "right",
|
|
1864
|
-
pin_number: 5,
|
|
1865
|
-
true_ccw_index: 4
|
|
1866
|
-
},
|
|
1867
|
-
{
|
|
1868
|
-
type: "schematic_port",
|
|
1869
|
-
schematic_port_id: "schematic_port_5",
|
|
1870
|
-
schematic_component_id: "schematic_component_0",
|
|
1871
|
-
center: {
|
|
1872
|
-
x: 0.9500000000000001,
|
|
1873
|
-
y: -0.10000000000000003
|
|
1874
|
-
},
|
|
1875
|
-
source_port_id: "source_port_5",
|
|
1876
|
-
facing_direction: "right",
|
|
1877
|
-
distance_from_component_edge: 0.4,
|
|
1878
|
-
side_of_component: "right",
|
|
1879
|
-
pin_number: 6,
|
|
1880
|
-
true_ccw_index: 5
|
|
1881
|
-
},
|
|
1882
|
-
{
|
|
1883
|
-
type: "schematic_port",
|
|
1884
|
-
schematic_port_id: "schematic_port_6",
|
|
1885
|
-
schematic_component_id: "schematic_component_0",
|
|
1886
|
-
center: {
|
|
1887
|
-
x: 0.9500000000000001,
|
|
1888
|
-
y: 0.09999999999999998
|
|
1889
|
-
},
|
|
1890
|
-
source_port_id: "source_port_6",
|
|
1891
|
-
facing_direction: "right",
|
|
1892
|
-
distance_from_component_edge: 0.4,
|
|
1893
|
-
side_of_component: "right",
|
|
1894
|
-
pin_number: 7,
|
|
1895
|
-
true_ccw_index: 6
|
|
1896
|
-
},
|
|
1897
|
-
{
|
|
1898
|
-
type: "schematic_port",
|
|
1899
|
-
schematic_port_id: "schematic_port_7",
|
|
1900
|
-
schematic_component_id: "schematic_component_0",
|
|
1901
|
-
center: {
|
|
1902
|
-
x: 0.9500000000000001,
|
|
1903
|
-
y: 0.30000000000000004
|
|
1904
|
-
},
|
|
1905
|
-
source_port_id: "source_port_7",
|
|
1906
|
-
facing_direction: "right",
|
|
1907
|
-
distance_from_component_edge: 0.4,
|
|
1908
|
-
side_of_component: "right",
|
|
1909
|
-
pin_number: 8,
|
|
1910
|
-
true_ccw_index: 7
|
|
1911
|
-
},
|
|
1912
|
-
{
|
|
1913
|
-
type: "pcb_component",
|
|
1914
|
-
pcb_component_id: "pcb_component_0",
|
|
1915
|
-
center: {
|
|
1916
|
-
x: 0,
|
|
1917
|
-
y: 0
|
|
1918
|
-
},
|
|
1919
|
-
width: 8.82,
|
|
1920
|
-
height: 8.82,
|
|
1921
|
-
layer: "top",
|
|
1922
|
-
rotation: 0,
|
|
1923
|
-
source_component_id: "source_component_0"
|
|
1924
|
-
},
|
|
1925
|
-
{
|
|
1926
|
-
type: "pcb_board",
|
|
1927
|
-
pcb_board_id: "pcb_board_0",
|
|
1928
|
-
center: {
|
|
1929
|
-
x: 0,
|
|
1930
|
-
y: 0
|
|
1931
|
-
},
|
|
1932
|
-
thickness: 1.4,
|
|
1933
|
-
num_layers: 4,
|
|
1934
|
-
width: 50,
|
|
1935
|
-
height: 50
|
|
1936
|
-
},
|
|
1937
|
-
{
|
|
1938
|
-
type: "pcb_plated_hole",
|
|
1939
|
-
pcb_plated_hole_id: "pcb_plated_hole_0",
|
|
1940
|
-
pcb_component_id: "pcb_component_0",
|
|
1941
|
-
pcb_port_id: "pcb_port_0",
|
|
1942
|
-
outer_diameter: 1.2,
|
|
1943
|
-
hole_diameter: 1,
|
|
1944
|
-
shape: "circle",
|
|
1945
|
-
port_hints: ["1"],
|
|
1946
|
-
x: -3.81,
|
|
1947
|
-
y: 3.81,
|
|
1948
|
-
layers: ["top", "bottom"]
|
|
1949
|
-
},
|
|
1950
|
-
{
|
|
1951
|
-
type: "pcb_plated_hole",
|
|
1952
|
-
pcb_plated_hole_id: "pcb_plated_hole_1",
|
|
1953
|
-
pcb_component_id: "pcb_component_0",
|
|
1954
|
-
pcb_port_id: "pcb_port_1",
|
|
1955
|
-
outer_diameter: 1.2,
|
|
1956
|
-
hole_diameter: 1,
|
|
1957
|
-
shape: "circle",
|
|
1958
|
-
port_hints: ["2"],
|
|
1959
|
-
x: -3.81,
|
|
1960
|
-
y: 1.27,
|
|
1961
|
-
layers: ["top", "bottom"]
|
|
1962
|
-
},
|
|
1963
|
-
{
|
|
1964
|
-
type: "pcb_plated_hole",
|
|
1965
|
-
pcb_plated_hole_id: "pcb_plated_hole_2",
|
|
1966
|
-
pcb_component_id: "pcb_component_0",
|
|
1967
|
-
pcb_port_id: "pcb_port_2",
|
|
1968
|
-
outer_diameter: 1.2,
|
|
1969
|
-
hole_diameter: 1,
|
|
1970
|
-
shape: "circle",
|
|
1971
|
-
port_hints: ["3"],
|
|
1972
|
-
x: -3.81,
|
|
1973
|
-
y: -1.27,
|
|
1974
|
-
layers: ["top", "bottom"]
|
|
1975
|
-
},
|
|
1976
|
-
{
|
|
1977
|
-
type: "pcb_plated_hole",
|
|
1978
|
-
pcb_plated_hole_id: "pcb_plated_hole_3",
|
|
1979
|
-
pcb_component_id: "pcb_component_0",
|
|
1980
|
-
pcb_port_id: "pcb_port_3",
|
|
1981
|
-
outer_diameter: 1.2,
|
|
1982
|
-
hole_diameter: 1,
|
|
1983
|
-
shape: "circle",
|
|
1984
|
-
port_hints: ["4"],
|
|
1985
|
-
x: -3.81,
|
|
1986
|
-
y: -3.81,
|
|
1987
|
-
layers: ["top", "bottom"]
|
|
1988
|
-
},
|
|
1989
|
-
{
|
|
1990
|
-
type: "pcb_plated_hole",
|
|
1991
|
-
pcb_plated_hole_id: "pcb_plated_hole_4",
|
|
1992
|
-
pcb_component_id: "pcb_component_0",
|
|
1993
|
-
pcb_port_id: "pcb_port_4",
|
|
1994
|
-
outer_diameter: 1.2,
|
|
1995
|
-
hole_diameter: 1,
|
|
1996
|
-
shape: "circle",
|
|
1997
|
-
port_hints: ["5"],
|
|
1998
|
-
x: 3.81,
|
|
1999
|
-
y: -3.81,
|
|
2000
|
-
layers: ["top", "bottom"]
|
|
2001
|
-
},
|
|
2002
|
-
{
|
|
2003
|
-
type: "pcb_plated_hole",
|
|
2004
|
-
pcb_plated_hole_id: "pcb_plated_hole_5",
|
|
2005
|
-
pcb_component_id: "pcb_component_0",
|
|
2006
|
-
pcb_port_id: "pcb_port_5",
|
|
2007
|
-
outer_diameter: 1.2,
|
|
2008
|
-
hole_diameter: 1,
|
|
2009
|
-
shape: "circle",
|
|
2010
|
-
port_hints: ["6"],
|
|
2011
|
-
x: 3.81,
|
|
2012
|
-
y: -1.27,
|
|
2013
|
-
layers: ["top", "bottom"]
|
|
2014
|
-
},
|
|
2015
|
-
{
|
|
2016
|
-
type: "pcb_plated_hole",
|
|
2017
|
-
pcb_plated_hole_id: "pcb_plated_hole_6",
|
|
2018
|
-
pcb_component_id: "pcb_component_0",
|
|
2019
|
-
pcb_port_id: "pcb_port_6",
|
|
2020
|
-
outer_diameter: 1.2,
|
|
2021
|
-
hole_diameter: 1,
|
|
2022
|
-
shape: "circle",
|
|
2023
|
-
port_hints: ["7"],
|
|
2024
|
-
x: 3.81,
|
|
2025
|
-
y: 1.27,
|
|
2026
|
-
layers: ["top", "bottom"]
|
|
2027
|
-
},
|
|
2028
|
-
{
|
|
2029
|
-
type: "pcb_plated_hole",
|
|
2030
|
-
pcb_plated_hole_id: "pcb_plated_hole_7",
|
|
2031
|
-
pcb_component_id: "pcb_component_0",
|
|
2032
|
-
pcb_port_id: "pcb_port_7",
|
|
2033
|
-
outer_diameter: 1.2,
|
|
2034
|
-
hole_diameter: 1,
|
|
2035
|
-
shape: "circle",
|
|
2036
|
-
port_hints: ["8"],
|
|
2037
|
-
x: 3.81,
|
|
2038
|
-
y: 3.81,
|
|
2039
|
-
layers: ["top", "bottom"]
|
|
2040
|
-
},
|
|
2041
|
-
{
|
|
2042
|
-
type: "pcb_silkscreen_path",
|
|
2043
|
-
pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
|
|
2044
|
-
pcb_component_id: "pcb_component_0",
|
|
2045
|
-
layer: "top",
|
|
2046
|
-
route: [
|
|
2047
|
-
{
|
|
2048
|
-
x: -3.01,
|
|
2049
|
-
y: -4.61
|
|
2050
|
-
},
|
|
2051
|
-
{
|
|
2052
|
-
x: -3.01,
|
|
2053
|
-
y: 4.61
|
|
2054
|
-
},
|
|
2055
|
-
{
|
|
2056
|
-
x: -1.0033333333333332,
|
|
2057
|
-
y: 4.61
|
|
2058
|
-
},
|
|
2059
|
-
{
|
|
2060
|
-
x: -0.9269591309529909,
|
|
2061
|
-
y: 4.226040956193693
|
|
2062
|
-
},
|
|
2063
|
-
{
|
|
2064
|
-
x: -0.7094638037905026,
|
|
2065
|
-
y: 3.9005361962094978
|
|
2066
|
-
},
|
|
2067
|
-
{
|
|
2068
|
-
x: -0.3839590438063067,
|
|
2069
|
-
y: 3.6830408690470096
|
|
2070
|
-
},
|
|
2071
|
-
{
|
|
2072
|
-
x: 6143644775722556e-32,
|
|
2073
|
-
y: 3.6066666666666674
|
|
2074
|
-
},
|
|
2075
|
-
{
|
|
2076
|
-
x: 0.38395904380630674,
|
|
2077
|
-
y: 3.6830408690470096
|
|
2078
|
-
},
|
|
2079
|
-
{
|
|
2080
|
-
x: 0.7094638037905027,
|
|
2081
|
-
y: 3.9005361962094978
|
|
2082
|
-
},
|
|
2083
|
-
{
|
|
2084
|
-
x: 0.9269591309529909,
|
|
2085
|
-
y: 4.226040956193693
|
|
2086
|
-
},
|
|
2087
|
-
{
|
|
2088
|
-
x: 1.0033333333333332,
|
|
2089
|
-
y: 4.61
|
|
2090
|
-
},
|
|
2091
|
-
{
|
|
2092
|
-
x: 3.01,
|
|
2093
|
-
y: 4.61
|
|
2094
|
-
},
|
|
2095
|
-
{
|
|
2096
|
-
x: 3.01,
|
|
2097
|
-
y: -4.61
|
|
2098
|
-
},
|
|
2099
|
-
{
|
|
2100
|
-
x: -3.01,
|
|
2101
|
-
y: -4.61
|
|
2102
|
-
}
|
|
2103
|
-
],
|
|
2104
|
-
stroke_width: 0.1
|
|
2105
|
-
},
|
|
2106
|
-
{
|
|
2107
|
-
type: "pcb_port",
|
|
2108
|
-
pcb_port_id: "pcb_port_0",
|
|
2109
|
-
pcb_component_id: "pcb_component_0",
|
|
2110
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2111
|
-
x: -3.81,
|
|
2112
|
-
y: 3.81,
|
|
2113
|
-
source_port_id: "source_port_0"
|
|
2114
|
-
},
|
|
2115
|
-
{
|
|
2116
|
-
type: "pcb_port",
|
|
2117
|
-
pcb_port_id: "pcb_port_1",
|
|
2118
|
-
pcb_component_id: "pcb_component_0",
|
|
2119
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2120
|
-
x: -3.81,
|
|
2121
|
-
y: 1.27,
|
|
2122
|
-
source_port_id: "source_port_1"
|
|
2123
|
-
},
|
|
2124
|
-
{
|
|
2125
|
-
type: "pcb_port",
|
|
2126
|
-
pcb_port_id: "pcb_port_2",
|
|
2127
|
-
pcb_component_id: "pcb_component_0",
|
|
2128
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2129
|
-
x: -3.81,
|
|
2130
|
-
y: -1.27,
|
|
2131
|
-
source_port_id: "source_port_2"
|
|
2132
|
-
},
|
|
2133
|
-
{
|
|
2134
|
-
type: "pcb_port",
|
|
2135
|
-
pcb_port_id: "pcb_port_3",
|
|
2136
|
-
pcb_component_id: "pcb_component_0",
|
|
2137
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2138
|
-
x: -3.81,
|
|
2139
|
-
y: -3.81,
|
|
2140
|
-
source_port_id: "source_port_3"
|
|
2141
|
-
},
|
|
2142
|
-
{
|
|
2143
|
-
type: "pcb_port",
|
|
2144
|
-
pcb_port_id: "pcb_port_4",
|
|
2145
|
-
pcb_component_id: "pcb_component_0",
|
|
2146
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2147
|
-
x: 3.81,
|
|
2148
|
-
y: -3.81,
|
|
2149
|
-
source_port_id: "source_port_4"
|
|
2150
|
-
},
|
|
2151
|
-
{
|
|
2152
|
-
type: "pcb_port",
|
|
2153
|
-
pcb_port_id: "pcb_port_5",
|
|
2154
|
-
pcb_component_id: "pcb_component_0",
|
|
2155
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2156
|
-
x: 3.81,
|
|
2157
|
-
y: -1.27,
|
|
2158
|
-
source_port_id: "source_port_5"
|
|
2159
|
-
},
|
|
2160
|
-
{
|
|
2161
|
-
type: "pcb_port",
|
|
2162
|
-
pcb_port_id: "pcb_port_6",
|
|
2163
|
-
pcb_component_id: "pcb_component_0",
|
|
2164
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2165
|
-
x: 3.81,
|
|
2166
|
-
y: 1.27,
|
|
2167
|
-
source_port_id: "source_port_6"
|
|
2168
|
-
},
|
|
2169
|
-
{
|
|
2170
|
-
type: "pcb_port",
|
|
2171
|
-
pcb_port_id: "pcb_port_7",
|
|
2172
|
-
pcb_component_id: "pcb_component_0",
|
|
2173
|
-
layers: ["top", "inner1", "inner2", "bottom"],
|
|
2174
|
-
x: 3.81,
|
|
2175
|
-
y: 3.81,
|
|
2176
|
-
source_port_id: "source_port_7"
|
|
2177
|
-
},
|
|
2178
|
-
{
|
|
2179
|
-
type: "cad_component",
|
|
2180
|
-
cad_component_id: "cad_component_0",
|
|
2181
|
-
position: {
|
|
2182
|
-
x: 0,
|
|
2183
|
-
y: 0,
|
|
2184
|
-
z: 0.7
|
|
2185
|
-
},
|
|
2186
|
-
rotation: {
|
|
2187
|
-
x: 0,
|
|
2188
|
-
y: 0,
|
|
2189
|
-
z: 0
|
|
2190
|
-
},
|
|
2191
|
-
pcb_component_id: "pcb_component_0",
|
|
2192
|
-
source_component_id: "source_component_0",
|
|
2193
|
-
footprinter_string: "dip8"
|
|
2194
|
-
}
|
|
2195
|
-
]
|
|
2196
|
-
});
|
|
2197
|
-
const failedBuild = db.addPackageBuild({
|
|
2198
|
-
package_release_id: packageReleaseId2,
|
|
2199
|
-
created_at: new Date(Date.now() - 15e3).toISOString(),
|
|
2200
|
-
// 15 seconds ago
|
|
2201
|
-
transpilation_in_progress: false,
|
|
2202
|
-
transpilation_started_at: new Date(Date.now() - 15e3).toISOString(),
|
|
2203
|
-
transpilation_completed_at: new Date(Date.now() - 14e3).toISOString(),
|
|
2204
|
-
transpilation_logs: [
|
|
2205
|
-
"[INFO] Starting transpilation...",
|
|
2206
|
-
"[INFO] Parsing package code",
|
|
2207
|
-
"[ERROR] Failed to parse TypeScript definitions",
|
|
2208
|
-
"[ERROR] Invalid syntax in component declaration"
|
|
2209
|
-
],
|
|
2210
|
-
transpilation_error: "TypeScript compilation failed: Syntax error in component declaration",
|
|
2211
|
-
circuit_json_build_in_progress: false,
|
|
2212
|
-
circuit_json_build_started_at: null,
|
|
2213
|
-
circuit_json_build_completed_at: null,
|
|
2214
|
-
circuit_json_build_logs: [],
|
|
2215
|
-
circuit_json_build_error: "Build cancelled due to transpilation failure",
|
|
2216
|
-
build_in_progress: false,
|
|
2217
|
-
build_started_at: new Date(Date.now() - 15e3).toISOString(),
|
|
2218
|
-
build_completed_at: new Date(Date.now() - 14e3).toISOString(),
|
|
2219
|
-
build_error: "Build failed: Unable to complete transpilation step",
|
|
2220
|
-
build_error_last_updated_at: new Date(Date.now() - 14e3).toISOString(),
|
|
2221
|
-
preview_url: null,
|
|
2222
|
-
build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - FAILED\nError: Invalid syntax in component declaration\nBuild terminated with errors"
|
|
2223
|
-
});
|
|
2224
|
-
const successfulBuild = db.addPackageBuild({
|
|
2225
|
-
package_release_id: packageReleaseId2,
|
|
2226
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2227
|
-
transpilation_in_progress: false,
|
|
2228
|
-
transpilation_started_at: new Date(Date.now() - 5e3).toISOString(),
|
|
2229
|
-
// Started 5 seconds ago
|
|
2230
|
-
transpilation_completed_at: new Date(Date.now() - 3e3).toISOString(),
|
|
2231
|
-
// Completed 3 seconds ago
|
|
2232
|
-
transpilation_logs: [
|
|
2233
|
-
"[INFO] Starting transpilation...",
|
|
2234
|
-
"[INFO] Parsing package code",
|
|
2235
|
-
"[INFO] Generating TypeScript definitions",
|
|
2236
|
-
"[INFO] Compiling to JavaScript",
|
|
2237
|
-
"[SUCCESS] Transpilation completed successfully"
|
|
2238
|
-
],
|
|
2239
|
-
transpilation_error: null,
|
|
2240
|
-
circuit_json_build_in_progress: false,
|
|
2241
|
-
circuit_json_build_started_at: new Date(Date.now() - 3e3).toISOString(),
|
|
2242
|
-
// Started after transpilation
|
|
2243
|
-
circuit_json_build_completed_at: new Date(Date.now() - 1e3).toISOString(),
|
|
2244
|
-
// Completed 1 second ago
|
|
2245
|
-
circuit_json_build_logs: [
|
|
2246
|
-
"[INFO] Starting circuit JSON build...",
|
|
2247
|
-
"[INFO] Analyzing component structure",
|
|
2248
|
-
"[INFO] Generating port configurations",
|
|
2249
|
-
"[INFO] Validating circuit connections",
|
|
2250
|
-
"[SUCCESS] Circuit JSON build completed"
|
|
2251
|
-
],
|
|
2252
|
-
circuit_json_build_error: null,
|
|
2253
|
-
build_in_progress: false,
|
|
2254
|
-
build_started_at: new Date(Date.now() - 1e4).toISOString(),
|
|
2255
|
-
// Started 10 seconds ago
|
|
2256
|
-
build_completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2257
|
-
// Just completed
|
|
2258
|
-
build_error: null,
|
|
2259
|
-
build_error_last_updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2260
|
-
preview_url: "http://localhost:3000/preview/package_build_1",
|
|
2261
|
-
build_logs: "Build process:\n1. Environment setup - OK\n2. Dependency resolution - OK\n3. Code compilation - OK\n4. Circuit validation - OK\n5. Package assembly - OK\nBuild completed successfully"
|
|
2262
|
-
});
|
|
2263
|
-
const release2 = db.getPackageReleaseById(packageReleaseId2);
|
|
2264
|
-
db.updatePackageRelease({
|
|
2265
|
-
...release2,
|
|
2266
|
-
latest_package_build_id: successfulBuild.package_build_id
|
|
2267
|
-
});
|
|
2268
|
-
db.addOrder({
|
|
2269
|
-
account_id,
|
|
2270
|
-
is_running: false,
|
|
2271
|
-
is_started: false,
|
|
2272
|
-
is_finished: false,
|
|
2273
|
-
error: null,
|
|
2274
|
-
has_error: false,
|
|
2275
|
-
circuit_json: [
|
|
2276
|
-
{
|
|
2277
|
-
type: "source_component",
|
|
2278
|
-
ftype: "simple_resistor",
|
|
2279
|
-
source_component_id: "source_component_1",
|
|
2280
|
-
name: "R1",
|
|
2281
|
-
resistane: "1k"
|
|
2282
|
-
}
|
|
2283
|
-
],
|
|
2284
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2285
|
-
started_at: null,
|
|
2286
|
-
completed_at: null
|
|
2287
|
-
});
|
|
2288
|
-
const testOrg = db.addOrganization({
|
|
2289
|
-
name: "test-organization",
|
|
2290
|
-
github_handle: "tscircuit",
|
|
2291
|
-
owner_account_id: account_id
|
|
2292
|
-
});
|
|
2293
|
-
db.addOrganizationAccount({
|
|
2294
|
-
org_id: testOrg.org_id,
|
|
2295
|
-
account_id,
|
|
2296
|
-
is_owner: true
|
|
2297
|
-
});
|
|
2298
|
-
const { package_release_id: orgPackageReleaseId } = db.addSnippet({
|
|
2299
|
-
name: "test-organization/test-package",
|
|
2300
|
-
unscoped_name: "test-package",
|
|
2301
|
-
owner_name: "test-organization",
|
|
2302
|
-
code: `
|
|
2303
|
-
export const TestComponent = ({ name }: { name: string }) => (
|
|
2304
|
-
<resistor name={name} resistance="10k" />
|
|
2305
|
-
)
|
|
2306
|
-
`.trim(),
|
|
2307
|
-
dts: `
|
|
2308
|
-
declare module "@tsci/test-organization.test-package" {
|
|
2309
|
-
export const TestComponent: ({ name }: {
|
|
2310
|
-
name: string;
|
|
2311
|
-
}) => any;
|
|
2312
|
-
}
|
|
2313
|
-
`.trim(),
|
|
2314
|
-
compiled_js: `
|
|
2315
|
-
"use strict";
|
|
2316
|
-
|
|
2317
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2318
|
-
value: true
|
|
2319
|
-
});
|
|
2320
|
-
exports.TestComponent = void 0;
|
|
2321
|
-
const TestComponent = ({
|
|
2322
|
-
name
|
|
2323
|
-
}) => /*#__PURE__*/React.createElement("resistor", {
|
|
2324
|
-
name: name,
|
|
2325
|
-
resistance: "10k"
|
|
2326
|
-
});
|
|
2327
|
-
exports.TestComponent = TestComponent;
|
|
2328
|
-
`.trim(),
|
|
2329
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2330
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2331
|
-
snippet_type: "package",
|
|
2332
|
-
description: "Test package for organization",
|
|
2333
|
-
circuit_json: [
|
|
2334
|
-
{
|
|
2335
|
-
type: "source_component",
|
|
2336
|
-
source_component_id: "source_component_0",
|
|
2337
|
-
ftype: "simple_resistor",
|
|
2338
|
-
name: "R1",
|
|
2339
|
-
resistance: "10k"
|
|
2340
|
-
}
|
|
2341
|
-
]
|
|
2342
|
-
});
|
|
2343
|
-
const orgPackageBuild = db.addPackageBuild({
|
|
2344
|
-
package_release_id: orgPackageReleaseId,
|
|
2345
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2346
|
-
transpilation_in_progress: false,
|
|
2347
|
-
transpilation_started_at: new Date(Date.now() - 5e3).toISOString(),
|
|
2348
|
-
transpilation_completed_at: new Date(Date.now() - 3e3).toISOString(),
|
|
2349
|
-
transpilation_logs: [
|
|
2350
|
-
"[INFO] Starting transpilation...",
|
|
2351
|
-
"[SUCCESS] Transpilation completed successfully"
|
|
2352
|
-
],
|
|
2353
|
-
transpilation_error: null,
|
|
2354
|
-
circuit_json_build_in_progress: false,
|
|
2355
|
-
circuit_json_build_started_at: new Date(Date.now() - 3e3).toISOString(),
|
|
2356
|
-
circuit_json_build_completed_at: new Date(Date.now() - 1e3).toISOString(),
|
|
2357
|
-
circuit_json_build_logs: [
|
|
2358
|
-
"[INFO] Starting circuit JSON build...",
|
|
2359
|
-
"[SUCCESS] Circuit JSON build completed"
|
|
2360
|
-
],
|
|
2361
|
-
circuit_json_build_error: null,
|
|
2362
|
-
build_in_progress: false,
|
|
2363
|
-
build_started_at: new Date(Date.now() - 1e4).toISOString(),
|
|
2364
|
-
build_completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2365
|
-
build_error: null,
|
|
2366
|
-
build_error_last_updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2367
|
-
preview_url: "http://localhost:3000/preview/org_package_build",
|
|
2368
|
-
build_logs: "Build completed successfully"
|
|
2369
|
-
});
|
|
2370
|
-
const orgRelease = db.getPackageReleaseById(orgPackageReleaseId);
|
|
2371
|
-
db.updatePackageRelease({
|
|
2372
|
-
...orgRelease,
|
|
2373
|
-
latest_package_build_id: orgPackageBuild.package_build_id
|
|
2374
|
-
});
|
|
2375
|
-
db.addOrganization({
|
|
2376
|
-
name: "testuser",
|
|
2377
|
-
owner_account_id: account_id,
|
|
2378
|
-
github_handle: "tscircuit",
|
|
2379
|
-
is_personal_org: true
|
|
2380
|
-
});
|
|
2381
|
-
db.addOrganizationAccount({
|
|
2382
|
-
org_id: testOrg.org_id,
|
|
2383
|
-
account_id: seveibarAcc.account_id
|
|
2384
|
-
});
|
|
2385
|
-
};
|
|
2386
|
-
|
|
2387
|
-
// fake-snippets-api/lib/package_file/generate-fs-sha.ts
|
|
2388
|
-
import md5 from "md5";
|
|
2389
|
-
function generateFsSha(packageFiles) {
|
|
2390
|
-
const fsMap = {};
|
|
2391
|
-
packageFiles.filter((file) => file.content_text).forEach((file) => {
|
|
2392
|
-
fsMap[file.file_path] = file.content_text || "";
|
|
2393
|
-
});
|
|
2394
|
-
const hash = md5(JSON.stringify(fsMap));
|
|
2395
|
-
return `md5-${hash}`;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
// fake-snippets-api/lib/db/db-client.ts
|
|
2399
|
-
var createDatabase = ({ seed: seed2 } = {}) => {
|
|
2400
|
-
const db = hoist(createStore(initializer));
|
|
2401
|
-
if (seed2) {
|
|
2402
|
-
seed(db);
|
|
2403
|
-
}
|
|
2404
|
-
return db;
|
|
2405
|
-
};
|
|
2406
|
-
var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
2407
|
-
addOrder: (order) => {
|
|
2408
|
-
const newOrder = { order_id: `order_${get().idCounter + 1}`, ...order };
|
|
2409
|
-
set((state) => {
|
|
2410
|
-
return {
|
|
2411
|
-
orders: [...state.orders, newOrder],
|
|
2412
|
-
idCounter: state.idCounter + 1
|
|
2413
|
-
};
|
|
2414
|
-
});
|
|
2415
|
-
return newOrder;
|
|
2416
|
-
},
|
|
2417
|
-
getOrderById: (orderId) => {
|
|
2418
|
-
const state = get();
|
|
2419
|
-
return state.orders.find((order) => order.order_id === orderId);
|
|
2420
|
-
},
|
|
2421
|
-
getOrderFilesByOrderId: (orderId) => {
|
|
2422
|
-
const state = get();
|
|
2423
|
-
return state.orderFiles.filter((file) => file.order_id === orderId);
|
|
2424
|
-
},
|
|
2425
|
-
addOrderQuote: ({
|
|
2426
|
-
account_id,
|
|
2427
|
-
package_release_id,
|
|
2428
|
-
vendor_name
|
|
2429
|
-
}) => {
|
|
2430
|
-
const newOrderQuote = {
|
|
2431
|
-
order_quote_id: `order_quote_${get().idCounter + 1}`,
|
|
2432
|
-
account_id,
|
|
2433
|
-
package_release_id: package_release_id ?? null,
|
|
2434
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2435
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2436
|
-
completed_at: null,
|
|
2437
|
-
error: null,
|
|
2438
|
-
has_error: false,
|
|
2439
|
-
is_completed: false,
|
|
2440
|
-
is_processing: true,
|
|
2441
|
-
vendor_name,
|
|
2442
|
-
quoted_components: [],
|
|
2443
|
-
bare_pcb_cost: 0,
|
|
2444
|
-
shipping_options: [],
|
|
2445
|
-
total_cost_without_shipping: 0
|
|
2446
|
-
};
|
|
2447
|
-
set((state) => {
|
|
2448
|
-
return {
|
|
2449
|
-
orderQuotes: [...state.orderQuotes, newOrderQuote],
|
|
2450
|
-
idCounter: state.idCounter + 1
|
|
2451
|
-
};
|
|
2452
|
-
});
|
|
2453
|
-
return newOrderQuote.order_quote_id;
|
|
2454
|
-
},
|
|
2455
|
-
getOrderQuoteById: (orderQuoteId) => {
|
|
2456
|
-
const state = get();
|
|
2457
|
-
return state.orderQuotes.find(
|
|
2458
|
-
(quote) => quote.order_quote_id === orderQuoteId
|
|
2459
|
-
);
|
|
2460
|
-
},
|
|
2461
|
-
getJlcpcbOrderStatesByOrderId: (orderId) => {
|
|
2462
|
-
const state = get();
|
|
2463
|
-
return state.jlcpcbOrderState.find((state2) => state2.order_id === orderId);
|
|
2464
|
-
},
|
|
2465
|
-
getJlcpcbOrderStepRunsByJlcpcbOrderStateId: (jlcpcbOrderStateId) => {
|
|
2466
|
-
const state = get();
|
|
2467
|
-
return state.jlcpcbOrderStepRuns.filter((stepRun) => {
|
|
2468
|
-
const orderState = state.jlcpcbOrderState.find(
|
|
2469
|
-
(state2) => state2.jlcpcb_order_state_id === stepRun.jlcpcb_order_state_id
|
|
2470
|
-
);
|
|
2471
|
-
return orderState?.order_id === jlcpcbOrderStateId;
|
|
2472
|
-
}).sort(
|
|
2473
|
-
(a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
|
|
2474
|
-
);
|
|
2475
|
-
},
|
|
2476
|
-
updateOrder: (orderId, updates) => {
|
|
2477
|
-
set((state) => ({
|
|
2478
|
-
orders: state.orders.map(
|
|
2479
|
-
(order) => order.order_id === orderId ? { ...order, ...updates } : order
|
|
2480
|
-
)
|
|
2481
|
-
}));
|
|
2482
|
-
},
|
|
2483
|
-
addJlcpcbOrderState: (orderState) => {
|
|
2484
|
-
const newOrderState = {
|
|
2485
|
-
jlcpcb_order_state_id: `order_state_${get().idCounter + 1}`,
|
|
2486
|
-
...orderState
|
|
2487
|
-
};
|
|
2488
|
-
set((state) => {
|
|
2489
|
-
return {
|
|
2490
|
-
jlcpcbOrderState: [...state.jlcpcbOrderState, newOrderState],
|
|
2491
|
-
idCounter: state.idCounter + 1
|
|
2492
|
-
};
|
|
2493
|
-
});
|
|
2494
|
-
return newOrderState;
|
|
2495
|
-
},
|
|
2496
|
-
updateJlcpcbOrderState: (orderId, updates) => {
|
|
2497
|
-
set((state) => ({
|
|
2498
|
-
jlcpcbOrderState: state.jlcpcbOrderState.map(
|
|
2499
|
-
(orderState) => orderState.order_id === orderId ? { ...orderState, ...updates } : orderState
|
|
2500
|
-
)
|
|
2501
|
-
}));
|
|
2502
|
-
},
|
|
2503
|
-
addOrderFile: (orderFile) => {
|
|
2504
|
-
const newOrderFile = {
|
|
2505
|
-
order_file_id: `order_file_${get().idCounter + 1}`,
|
|
2506
|
-
...orderFile
|
|
2507
|
-
};
|
|
2508
|
-
set((state) => {
|
|
2509
|
-
return {
|
|
2510
|
-
orderFiles: [...state.orderFiles, newOrderFile],
|
|
2511
|
-
idCounter: state.idCounter + 1
|
|
2512
|
-
};
|
|
2513
|
-
});
|
|
2514
|
-
return newOrderFile;
|
|
2515
|
-
},
|
|
2516
|
-
getOrderFileById: (orderFileId) => {
|
|
2517
|
-
const state = get();
|
|
2518
|
-
return state.orderFiles.find((file) => file.order_file_id === orderFileId);
|
|
2519
|
-
},
|
|
2520
|
-
addAccount: (account) => {
|
|
2521
|
-
const newAccount = {
|
|
2522
|
-
account_id: account.account_id || `account_${get().idCounter + 1}`,
|
|
2523
|
-
...account,
|
|
2524
|
-
is_tscircuit_staff: Boolean(account.is_tscircuit_staff)
|
|
2525
|
-
};
|
|
2526
|
-
set((state) => {
|
|
2527
|
-
return {
|
|
2528
|
-
accounts: [...state.accounts, newAccount],
|
|
2529
|
-
idCounter: state.idCounter + 1
|
|
2530
|
-
};
|
|
2531
|
-
});
|
|
2532
|
-
return newAccount;
|
|
2533
|
-
},
|
|
2534
|
-
addAccountPackage: (accountPackage) => {
|
|
2535
|
-
const newAccountPackage = {
|
|
2536
|
-
account_package_id: `ap_${get().idCounter + 1}`,
|
|
2537
|
-
...accountPackage
|
|
2538
|
-
};
|
|
2539
|
-
set((state) => {
|
|
2540
|
-
return {
|
|
2541
|
-
accountPackages: [...state.accountPackages, newAccountPackage],
|
|
2542
|
-
idCounter: state.idCounter + 1
|
|
2543
|
-
};
|
|
2544
|
-
});
|
|
2545
|
-
return newAccountPackage;
|
|
2546
|
-
},
|
|
2547
|
-
getAccountPackageById: (accountPackageId) => {
|
|
2548
|
-
const state = get();
|
|
2549
|
-
return state.accountPackages.find(
|
|
2550
|
-
(ap) => ap.account_package_id === accountPackageId
|
|
2551
|
-
);
|
|
2552
|
-
},
|
|
2553
|
-
updateAccountPackage: (accountPackageId, updates) => {
|
|
2554
|
-
set((state) => ({
|
|
2555
|
-
accountPackages: state.accountPackages.map(
|
|
2556
|
-
(ap) => ap.account_package_id === accountPackageId ? { ...ap, ...updates } : ap
|
|
2557
|
-
)
|
|
2558
|
-
}));
|
|
2559
|
-
},
|
|
2560
|
-
deleteAccountPackage: (accountPackageId) => {
|
|
2561
|
-
let deleted = false;
|
|
2562
|
-
set((state) => {
|
|
2563
|
-
const index = state.accountPackages.findIndex(
|
|
2564
|
-
(ap) => ap.account_package_id === accountPackageId
|
|
2565
|
-
);
|
|
2566
|
-
if (index !== -1) {
|
|
2567
|
-
state.accountPackages.splice(index, 1);
|
|
2568
|
-
deleted = true;
|
|
2569
|
-
}
|
|
2570
|
-
return state;
|
|
2571
|
-
});
|
|
2572
|
-
return deleted;
|
|
2573
|
-
},
|
|
2574
|
-
addSnippet: (snippet) => {
|
|
2575
|
-
const timestamp = Date.now();
|
|
2576
|
-
const currentTime = new Date(timestamp).toISOString();
|
|
2577
|
-
const newState = get();
|
|
2578
|
-
const nextId = newState.idCounter + 1;
|
|
2579
|
-
const newPackage = {
|
|
2580
|
-
package_id: `pkg_${nextId}`,
|
|
2581
|
-
creator_account_id: snippet.creator_account_id ?? snippet.owner_name,
|
|
2582
|
-
// Using owner_name as account_id since we don't have context
|
|
2583
|
-
owner_org_id: "",
|
|
2584
|
-
// Empty string instead of null to match type
|
|
2585
|
-
owner_github_username: snippet.owner_name,
|
|
2586
|
-
is_source_from_github: false,
|
|
2587
|
-
description: snippet.description || "",
|
|
2588
|
-
name: `${snippet.owner_name}/${snippet.unscoped_name}`,
|
|
2589
|
-
unscoped_name: snippet.unscoped_name,
|
|
2590
|
-
latest_version: "0.0.1",
|
|
2591
|
-
license: null,
|
|
2592
|
-
website: null,
|
|
2593
|
-
star_count: 0,
|
|
2594
|
-
created_at: currentTime,
|
|
2595
|
-
updated_at: currentTime,
|
|
2596
|
-
github_repo_full_name: snippet.github_repo_full_name || null,
|
|
2597
|
-
ai_description: "placeholder ai description",
|
|
2598
|
-
ai_usage_instructions: "placeholder ai usage instructions",
|
|
2599
|
-
is_snippet: true,
|
|
2600
|
-
is_board: snippet.snippet_type === "board",
|
|
2601
|
-
is_package: snippet.snippet_type === "package",
|
|
2602
|
-
is_model: snippet.snippet_type === "model",
|
|
2603
|
-
is_footprint: snippet.snippet_type === "footprint",
|
|
2604
|
-
snippet_type: snippet.snippet_type,
|
|
2605
|
-
is_private: false,
|
|
2606
|
-
is_public: true,
|
|
2607
|
-
is_unlisted: false,
|
|
2608
|
-
latest_package_release_id: `package_release_${nextId}`,
|
|
2609
|
-
latest_package_release_fs_sha: null
|
|
2610
|
-
};
|
|
2611
|
-
const newPackageRelease = packageReleaseSchema.parse({
|
|
2612
|
-
package_release_id: `package_release_${nextId}`,
|
|
2613
|
-
package_id: newPackage.package_id,
|
|
2614
|
-
version: "0.0.1",
|
|
2615
|
-
is_latest: true,
|
|
2616
|
-
is_locked: false,
|
|
2617
|
-
created_at: currentTime,
|
|
2618
|
-
updated_at: currentTime,
|
|
2619
|
-
branch_name: snippet.branch_name,
|
|
2620
|
-
commit_message: snippet.commit_message,
|
|
2621
|
-
commit_author: snippet.commit_author,
|
|
2622
|
-
has_transpiled: true,
|
|
2623
|
-
transpilation_error: null,
|
|
2624
|
-
...snippet.name == "testuser/my-test-board" ? { is_pr_preview: true, github_pr_number: 69 } : {}
|
|
2625
|
-
});
|
|
2626
|
-
const packageFiles = [];
|
|
2627
|
-
let fileIdCounter = nextId;
|
|
2628
|
-
packageFiles.push({
|
|
2629
|
-
package_file_id: `package_file_${fileIdCounter++}`,
|
|
2630
|
-
package_release_id: newPackageRelease.package_release_id,
|
|
2631
|
-
file_path: "index.tsx",
|
|
2632
|
-
content_text: snippet.code || "",
|
|
2633
|
-
created_at: currentTime
|
|
2634
|
-
});
|
|
2635
|
-
if (snippet.dts) {
|
|
2636
|
-
packageFiles.push({
|
|
2637
|
-
package_file_id: `package_file_${fileIdCounter++}`,
|
|
2638
|
-
package_release_id: newPackageRelease.package_release_id,
|
|
2639
|
-
file_path: "/dist/index.d.ts",
|
|
2640
|
-
content_text: snippet.dts,
|
|
2641
|
-
created_at: currentTime
|
|
2642
|
-
});
|
|
2643
|
-
}
|
|
2644
|
-
if (snippet.compiled_js) {
|
|
2645
|
-
packageFiles.push({
|
|
2646
|
-
package_file_id: `package_file_${fileIdCounter++}`,
|
|
2647
|
-
package_release_id: newPackageRelease.package_release_id,
|
|
2648
|
-
file_path: "/dist/index.js",
|
|
2649
|
-
content_text: snippet.compiled_js,
|
|
2650
|
-
created_at: currentTime
|
|
2651
|
-
});
|
|
2652
|
-
}
|
|
2653
|
-
if (snippet.circuit_json && snippet.circuit_json.length > 0) {
|
|
2654
|
-
packageFiles.push({
|
|
2655
|
-
package_file_id: `package_file_${fileIdCounter++}`,
|
|
2656
|
-
package_release_id: newPackageRelease.package_release_id,
|
|
2657
|
-
file_path: "/dist/circuit.json",
|
|
2658
|
-
content_text: JSON.stringify(snippet.circuit_json),
|
|
2659
|
-
created_at: currentTime
|
|
2660
|
-
});
|
|
2661
|
-
}
|
|
2662
|
-
set((state) => ({
|
|
2663
|
-
...state,
|
|
2664
|
-
packages: [...state.packages, newPackage],
|
|
2665
|
-
packageReleases: [...state.packageReleases, newPackageRelease],
|
|
2666
|
-
packageFiles: [...state.packageFiles, ...packageFiles],
|
|
2667
|
-
idCounter: fileIdCounter
|
|
2668
|
-
}));
|
|
2669
|
-
const dbState = get();
|
|
2670
|
-
const releaseFiles = dbState.packageFiles.filter(
|
|
2671
|
-
(pf) => pf.package_release_id === newPackageRelease.package_release_id
|
|
2672
|
-
);
|
|
2673
|
-
const fsSha = generateFsSha(releaseFiles);
|
|
2674
|
-
set((state) => ({
|
|
2675
|
-
...state,
|
|
2676
|
-
packageReleases: state.packageReleases.map(
|
|
2677
|
-
(pr) => pr.package_release_id === newPackageRelease.package_release_id ? { ...pr, fs_sha: fsSha } : pr
|
|
2678
|
-
),
|
|
2679
|
-
packages: state.packages.map(
|
|
2680
|
-
(pkg) => pkg.latest_package_release_id === newPackageRelease.package_release_id ? { ...pkg, latest_package_release_fs_sha: fsSha } : pkg
|
|
2681
|
-
)
|
|
2682
|
-
}));
|
|
2683
|
-
return {
|
|
2684
|
-
snippet_id: newPackage.package_id,
|
|
2685
|
-
package_release_id: newPackageRelease.package_release_id,
|
|
2686
|
-
name: newPackage.name,
|
|
2687
|
-
unscoped_name: newPackage.unscoped_name,
|
|
2688
|
-
owner_name: snippet.owner_name,
|
|
2689
|
-
code: snippet.code || "",
|
|
2690
|
-
dts: snippet.dts,
|
|
2691
|
-
compiled_js: snippet.compiled_js,
|
|
2692
|
-
star_count: 0,
|
|
2693
|
-
created_at: currentTime,
|
|
2694
|
-
updated_at: currentTime,
|
|
2695
|
-
snippet_type: snippet.snippet_type,
|
|
2696
|
-
circuit_json: snippet.circuit_json || [],
|
|
2697
|
-
description: snippet.description || "",
|
|
2698
|
-
is_starred: false,
|
|
2699
|
-
version: "0.0.1",
|
|
2700
|
-
is_private: false,
|
|
2701
|
-
is_public: true,
|
|
2702
|
-
is_unlisted: false
|
|
2703
|
-
};
|
|
2704
|
-
},
|
|
2705
|
-
getLatestSnippets: (limit) => {
|
|
2706
|
-
const state = get();
|
|
2707
|
-
const snippetPackages = state.packages.filter((pkg) => pkg.is_snippet === true).map((pkg) => {
|
|
2708
|
-
const packageRelease = state.packageReleases.find(
|
|
2709
|
-
(pr) => pr.package_release_id === pkg.latest_package_release_id && pr.is_latest === true
|
|
2710
|
-
);
|
|
2711
|
-
if (!packageRelease) return null;
|
|
2712
|
-
const packageFiles = state.packageFiles.filter(
|
|
2713
|
-
(file) => file.package_release_id === packageRelease.package_release_id
|
|
2714
|
-
);
|
|
2715
|
-
const codeFile = packageFiles.find(
|
|
2716
|
-
(file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
|
|
2717
|
-
);
|
|
2718
|
-
const isStarred = state.accountPackages.some(
|
|
2719
|
-
(ap) => ap.package_id === pkg.package_id && ap.is_starred
|
|
2720
|
-
);
|
|
2721
|
-
return {
|
|
2722
|
-
snippet_id: pkg.package_id,
|
|
2723
|
-
package_release_id: pkg.latest_package_release_id || "",
|
|
2724
|
-
unscoped_name: pkg.unscoped_name,
|
|
2725
|
-
name: pkg.name,
|
|
2726
|
-
owner_name: pkg.owner_github_username || "",
|
|
2727
|
-
description: pkg.description || "",
|
|
2728
|
-
snippet_type: pkg.snippet_type || "board",
|
|
2729
|
-
code: codeFile?.content_text || "",
|
|
2730
|
-
dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
|
|
2731
|
-
compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
|
|
2732
|
-
created_at: pkg.created_at,
|
|
2733
|
-
updated_at: pkg.updated_at,
|
|
2734
|
-
star_count: pkg.star_count || 0,
|
|
2735
|
-
is_starred: isStarred,
|
|
2736
|
-
version: pkg.latest_version || "0.0.1",
|
|
2737
|
-
circuit_json: packageFiles.filter((file) => file.file_path === "/dist/circuit.json").flatMap((file) => JSON.parse(file.content_text || "[]")) || [],
|
|
2738
|
-
is_private: pkg.is_private || false,
|
|
2739
|
-
is_public: pkg.is_public || true,
|
|
2740
|
-
is_unlisted: pkg.is_unlisted || false
|
|
2741
|
-
};
|
|
2742
|
-
}).filter(
|
|
2743
|
-
(snippet) => snippet !== null
|
|
2744
|
-
).map((snippet) => ({
|
|
2745
|
-
...snippet,
|
|
2746
|
-
description: snippet.description || ""
|
|
2747
|
-
})).sort(
|
|
2748
|
-
(a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
2749
|
-
).slice(0, limit);
|
|
2750
|
-
return snippetPackages;
|
|
2751
|
-
},
|
|
2752
|
-
getTrendingSnippets: (limit, since) => {
|
|
2753
|
-
const state = get();
|
|
2754
|
-
const sinceDate = new Date(since).getTime();
|
|
2755
|
-
const recentStars = /* @__PURE__ */ new Map();
|
|
2756
|
-
state.accountPackages.forEach((ap) => {
|
|
2757
|
-
if (ap.is_starred && new Date(ap.created_at).getTime() >= sinceDate) {
|
|
2758
|
-
recentStars.set(
|
|
2759
|
-
ap.package_id,
|
|
2760
|
-
(recentStars.get(ap.package_id) || 0) + 1
|
|
2761
|
-
);
|
|
2762
|
-
}
|
|
2763
|
-
});
|
|
2764
|
-
const packagesWithStarCount = [...state.packages].map((pkg) => ({
|
|
2765
|
-
...pkg,
|
|
2766
|
-
star_count: recentStars.get(pkg.package_id) || 0
|
|
2767
|
-
})).sort((a, b) => b.star_count - a.star_count).slice(0, limit);
|
|
2768
|
-
const trendingSnippets = packagesWithStarCount.map((pkg) => {
|
|
2769
|
-
const packageRelease = state.packageReleases.find(
|
|
2770
|
-
(pr) => pr.package_release_id === pkg.latest_package_release_id && pr.is_latest === true
|
|
2771
|
-
);
|
|
2772
|
-
if (!packageRelease) return null;
|
|
2773
|
-
const packageFiles = state.packageFiles.filter(
|
|
2774
|
-
(file) => file.package_release_id === packageRelease.package_release_id
|
|
2775
|
-
);
|
|
2776
|
-
const codeFile = packageFiles.find(
|
|
2777
|
-
(file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
|
|
2778
|
-
);
|
|
2779
|
-
return {
|
|
2780
|
-
snippet_id: pkg.package_id,
|
|
2781
|
-
package_release_id: pkg.latest_package_release_id || "",
|
|
2782
|
-
unscoped_name: pkg.unscoped_name,
|
|
2783
|
-
name: pkg.name,
|
|
2784
|
-
owner_name: pkg.owner_github_username || "",
|
|
2785
|
-
code: codeFile ? codeFile.content_text || "" : "",
|
|
2786
|
-
created_at: pkg.created_at,
|
|
2787
|
-
updated_at: pkg.updated_at,
|
|
2788
|
-
snippet_type: pkg.is_snippet ? "board" : "package",
|
|
2789
|
-
star_count: pkg.star_count
|
|
2790
|
-
};
|
|
2791
|
-
}).filter((snippet) => snippet !== null);
|
|
2792
|
-
return trendingSnippets;
|
|
2793
|
-
},
|
|
2794
|
-
getPackagesByAuthor: (authorName) => {
|
|
2795
|
-
const state = get();
|
|
2796
|
-
const packages = authorName ? state.packages.filter((pkg) => pkg.owner_github_username === authorName) : state.packages;
|
|
2797
|
-
return packages.map((pkg) => ({
|
|
2798
|
-
...pkg,
|
|
2799
|
-
star_count: state.accountPackages.filter(
|
|
2800
|
-
(ap) => ap.package_id === pkg.package_id && ap.is_starred
|
|
2801
|
-
).length
|
|
2802
|
-
}));
|
|
2803
|
-
},
|
|
2804
|
-
getSnippetByAuthorAndName: (authorName, snippetName) => {
|
|
2805
|
-
const state = get();
|
|
2806
|
-
const _package = state.packages.find(
|
|
2807
|
-
(pkg) => pkg.owner_github_username?.toLowerCase() === authorName.toLowerCase() && pkg.name.toLowerCase() === snippetName.toLowerCase() && pkg.is_snippet === true
|
|
2808
|
-
);
|
|
2809
|
-
if (!_package) return void 0;
|
|
2810
|
-
const packageRelease = state.packageReleases.find(
|
|
2811
|
-
(pr) => pr.package_release_id === _package.latest_package_release_id && pr.is_latest === true
|
|
2812
|
-
);
|
|
2813
|
-
if (!packageRelease) return void 0;
|
|
2814
|
-
const packageFiles = state.packageFiles.filter(
|
|
2815
|
-
(file) => file.package_release_id === packageRelease.package_release_id
|
|
2816
|
-
);
|
|
2817
|
-
const codeFile = packageFiles.find(
|
|
2818
|
-
(file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
|
|
2819
|
-
);
|
|
2820
|
-
return {
|
|
2821
|
-
snippet_id: _package.package_id,
|
|
2822
|
-
package_release_id: _package.latest_package_release_id || "",
|
|
2823
|
-
unscoped_name: _package.unscoped_name,
|
|
2824
|
-
name: _package.name,
|
|
2825
|
-
owner_name: _package.owner_github_username || "",
|
|
2826
|
-
description: _package.description || "",
|
|
2827
|
-
snippet_type: _package.snippet_type || "board",
|
|
2828
|
-
code: codeFile?.content_text || "",
|
|
2829
|
-
dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
|
|
2830
|
-
compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
|
|
2831
|
-
created_at: _package.created_at,
|
|
2832
|
-
updated_at: _package.updated_at,
|
|
2833
|
-
star_count: _package.star_count || 0,
|
|
2834
|
-
is_starred: false,
|
|
2835
|
-
version: _package.latest_version || "0.0.1",
|
|
2836
|
-
circuit_json: packageFiles.find(
|
|
2837
|
-
(file) => file.file_path === "/dist/circuit.json"
|
|
2838
|
-
)?.content_text ? JSON.parse(
|
|
2839
|
-
packageFiles.find((file) => file.file_path === "/dist/circuit.json")?.content_text || "[]"
|
|
2840
|
-
) : [],
|
|
2841
|
-
is_private: _package.is_private || false,
|
|
2842
|
-
is_public: _package.is_public || true,
|
|
2843
|
-
is_unlisted: _package.is_unlisted || false
|
|
2844
|
-
};
|
|
2845
|
-
},
|
|
2846
|
-
updateSnippet: (snippetId, updates) => {
|
|
2847
|
-
set((state) => {
|
|
2848
|
-
const packageIndex = state.packages.findIndex(
|
|
2849
|
-
(pkg) => pkg.package_id === snippetId && pkg.is_snippet === true
|
|
2850
|
-
);
|
|
2851
|
-
if (packageIndex === -1) {
|
|
2852
|
-
return state;
|
|
2853
|
-
}
|
|
2854
|
-
const timestamp = Date.now();
|
|
2855
|
-
const currentTime = new Date(timestamp).toISOString();
|
|
2856
|
-
const updatedPackages = [...state.packages];
|
|
2857
|
-
const currentPackage = updatedPackages[packageIndex];
|
|
2858
|
-
updatedPackages[packageIndex] = {
|
|
2859
|
-
...currentPackage,
|
|
2860
|
-
description: updates.description ?? currentPackage.description,
|
|
2861
|
-
is_private: updates.is_private ?? currentPackage.is_private,
|
|
2862
|
-
is_public: updates.is_private !== void 0 ? !updates.is_private : currentPackage.is_public,
|
|
2863
|
-
is_unlisted: updates.is_private ? true : updates.is_unlisted ?? currentPackage.is_unlisted,
|
|
2864
|
-
updated_at: currentTime
|
|
2865
|
-
};
|
|
2866
|
-
const packageRelease2 = state.packageReleases.find(
|
|
2867
|
-
(pr) => pr.package_release_id === currentPackage.latest_package_release_id
|
|
2868
|
-
);
|
|
2869
|
-
if (!packageRelease2) return state;
|
|
2870
|
-
const updatedFiles = [...state.packageFiles];
|
|
2871
|
-
const packageFiles2 = updatedFiles.filter(
|
|
2872
|
-
(file) => file.package_release_id === packageRelease2.package_release_id
|
|
2873
|
-
);
|
|
2874
|
-
if (updates.code !== void 0) {
|
|
2875
|
-
const codeFileIndex = packageFiles2.findIndex(
|
|
2876
|
-
(file) => file.file_path === "index.tsx" || file.file_path === "index.ts"
|
|
2877
|
-
);
|
|
2878
|
-
if (codeFileIndex >= 0) {
|
|
2879
|
-
updatedFiles[codeFileIndex] = {
|
|
2880
|
-
...packageFiles2[codeFileIndex],
|
|
2881
|
-
content_text: updates.code,
|
|
2882
|
-
created_at: currentTime
|
|
2883
|
-
};
|
|
2884
|
-
} else {
|
|
2885
|
-
updatedFiles.push({
|
|
2886
|
-
package_file_id: `package_file_${timestamp}`,
|
|
2887
|
-
package_release_id: packageRelease2.package_release_id,
|
|
2888
|
-
file_path: "index.tsx",
|
|
2889
|
-
content_text: updates.code,
|
|
2890
|
-
created_at: currentTime
|
|
2891
|
-
});
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
if (updates.dts !== void 0) {
|
|
2895
|
-
const dtsFileIndex = packageFiles2.findIndex(
|
|
2896
|
-
(file) => file.file_path === "/dist/index.d.ts"
|
|
2897
|
-
);
|
|
2898
|
-
if (dtsFileIndex >= 0) {
|
|
2899
|
-
updatedFiles[dtsFileIndex] = {
|
|
2900
|
-
...packageFiles2[dtsFileIndex],
|
|
2901
|
-
content_text: updates.dts,
|
|
2902
|
-
created_at: currentTime
|
|
2903
|
-
};
|
|
2904
|
-
} else {
|
|
2905
|
-
updatedFiles.push({
|
|
2906
|
-
package_file_id: `package_file_${timestamp}`,
|
|
2907
|
-
package_release_id: packageRelease2.package_release_id,
|
|
2908
|
-
file_path: "/dist/index.d.ts",
|
|
2909
|
-
content_text: updates.dts,
|
|
2910
|
-
created_at: currentTime
|
|
2911
|
-
});
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
if (updates.compiled_js !== void 0) {
|
|
2915
|
-
const jsFileIndex = packageFiles2.findIndex(
|
|
2916
|
-
(file) => file.file_path === "/dist/index.js"
|
|
2917
|
-
);
|
|
2918
|
-
if (jsFileIndex >= 0) {
|
|
2919
|
-
updatedFiles[jsFileIndex] = {
|
|
2920
|
-
...packageFiles2[jsFileIndex],
|
|
2921
|
-
content_text: updates.compiled_js,
|
|
2922
|
-
created_at: currentTime
|
|
2923
|
-
};
|
|
2924
|
-
} else {
|
|
2925
|
-
updatedFiles.push({
|
|
2926
|
-
package_file_id: `package_file_${timestamp}`,
|
|
2927
|
-
package_release_id: packageRelease2.package_release_id,
|
|
2928
|
-
file_path: "/dist/index.js",
|
|
2929
|
-
content_text: updates.compiled_js,
|
|
2930
|
-
created_at: currentTime
|
|
2931
|
-
});
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
if (updates.circuit_json !== void 0) {
|
|
2935
|
-
const circuitFileIndex = packageFiles2.findIndex(
|
|
2936
|
-
(file) => file.file_path === "/dist/circuit.json"
|
|
2937
|
-
);
|
|
2938
|
-
if (circuitFileIndex >= 0) {
|
|
2939
|
-
updatedFiles[circuitFileIndex] = {
|
|
2940
|
-
...packageFiles2[circuitFileIndex],
|
|
2941
|
-
content_text: JSON.stringify(updates.circuit_json),
|
|
2942
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
return {
|
|
2947
|
-
...state,
|
|
2948
|
-
packages: updatedPackages,
|
|
2949
|
-
packageFiles: updatedFiles
|
|
2950
|
-
};
|
|
2951
|
-
});
|
|
2952
|
-
const updatedPackage = get().packages.find(
|
|
2953
|
-
(pkg) => pkg.package_id === snippetId
|
|
2954
|
-
);
|
|
2955
|
-
if (!updatedPackage) return void 0;
|
|
2956
|
-
const packageRelease = get().packageReleases.find(
|
|
2957
|
-
(pr) => pr.package_release_id === updatedPackage.latest_package_release_id
|
|
2958
|
-
);
|
|
2959
|
-
if (!packageRelease) return void 0;
|
|
2960
|
-
const packageFiles = get().packageFiles.filter(
|
|
2961
|
-
(file) => file.package_release_id === packageRelease.package_release_id
|
|
2962
|
-
);
|
|
2963
|
-
const codeFile = packageFiles.find(
|
|
2964
|
-
(file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
|
|
2965
|
-
);
|
|
2966
|
-
const dtsFile = packageFiles.find(
|
|
2967
|
-
(file) => file.file_path === "/dist/index.d.ts"
|
|
2968
|
-
);
|
|
2969
|
-
const jsFile = packageFiles.find(
|
|
2970
|
-
(file) => file.file_path === "/dist/index.js"
|
|
2971
|
-
);
|
|
2972
|
-
const circuitFile = packageFiles.find(
|
|
2973
|
-
(file) => file.file_path === "/dist/circuit.json"
|
|
2974
|
-
);
|
|
2975
|
-
return {
|
|
2976
|
-
snippet_id: updatedPackage.package_id,
|
|
2977
|
-
package_release_id: updatedPackage.latest_package_release_id || "",
|
|
2978
|
-
unscoped_name: updatedPackage.unscoped_name,
|
|
2979
|
-
name: updatedPackage.name,
|
|
2980
|
-
owner_name: updatedPackage.owner_github_username || "",
|
|
2981
|
-
description: updatedPackage.description || "",
|
|
2982
|
-
snippet_type: updatedPackage.snippet_type || "board",
|
|
2983
|
-
code: codeFile?.content_text || "",
|
|
2984
|
-
dts: dtsFile?.content_text || "",
|
|
2985
|
-
compiled_js: jsFile?.content_text || "",
|
|
2986
|
-
created_at: updatedPackage.created_at,
|
|
2987
|
-
updated_at: updatedPackage.updated_at,
|
|
2988
|
-
star_count: updatedPackage.star_count || 0,
|
|
2989
|
-
is_starred: false,
|
|
2990
|
-
version: updatedPackage.latest_version || "0.0.1",
|
|
2991
|
-
circuit_json: circuitFile ? JSON.parse(circuitFile.content_text || "[]") : [],
|
|
2992
|
-
is_private: updatedPackage.is_private ?? false,
|
|
2993
|
-
is_public: updatedPackage.is_public ?? true,
|
|
2994
|
-
is_unlisted: updatedPackage.is_unlisted ?? false
|
|
2995
|
-
};
|
|
2996
|
-
},
|
|
2997
|
-
getSnippetById: (snippetId, auth) => {
|
|
2998
|
-
const state = get();
|
|
2999
|
-
const _package = state.packages.find(
|
|
3000
|
-
(pkg) => pkg.package_id === snippetId && pkg.is_snippet === true
|
|
3001
|
-
);
|
|
3002
|
-
if (!_package) return void 0;
|
|
3003
|
-
if (!auth) {
|
|
3004
|
-
if (!_package.is_public || _package.is_unlisted) {
|
|
3005
|
-
return void 0;
|
|
3006
|
-
}
|
|
3007
|
-
} else {
|
|
3008
|
-
const isOwnPackage = _package.owner_github_username === auth?.github_username;
|
|
3009
|
-
const isPublicAndNotUnlisted = _package.is_public && !_package.is_unlisted;
|
|
3010
|
-
const isOwnUnlisted = _package.is_unlisted && isOwnPackage;
|
|
3011
|
-
const isOwnPrivate = _package.is_private && isOwnPackage;
|
|
3012
|
-
if (!isPublicAndNotUnlisted && !isOwnUnlisted && !isOwnPrivate) {
|
|
3013
|
-
return void 0;
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
const packageRelease = state.packageReleases.find(
|
|
3017
|
-
(pr) => pr.package_release_id === _package.latest_package_release_id && pr.is_latest === true
|
|
3018
|
-
);
|
|
3019
|
-
if (!packageRelease) return void 0;
|
|
3020
|
-
const packageFiles = state.packageFiles.filter(
|
|
3021
|
-
(file) => file.package_release_id === packageRelease.package_release_id
|
|
3022
|
-
);
|
|
3023
|
-
const codeFile = packageFiles.find(
|
|
3024
|
-
(file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
|
|
3025
|
-
);
|
|
3026
|
-
const isStarred = state.accountPackages.some(
|
|
3027
|
-
(ap) => ap.package_id === snippetId && ap.is_starred
|
|
3028
|
-
);
|
|
3029
|
-
return {
|
|
3030
|
-
snippet_id: _package.package_id,
|
|
3031
|
-
package_release_id: _package.latest_package_release_id || "",
|
|
3032
|
-
unscoped_name: _package.unscoped_name,
|
|
3033
|
-
name: _package.name,
|
|
3034
|
-
owner_name: _package.owner_github_username || "",
|
|
3035
|
-
description: _package.description || "",
|
|
3036
|
-
snippet_type: _package.snippet_type || "board",
|
|
3037
|
-
code: codeFile?.content_text || "",
|
|
3038
|
-
dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
|
|
3039
|
-
compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
|
|
3040
|
-
created_at: _package.created_at,
|
|
3041
|
-
updated_at: _package.updated_at,
|
|
3042
|
-
star_count: _package.star_count || 0,
|
|
3043
|
-
is_starred: isStarred,
|
|
3044
|
-
version: _package.latest_version || "0.0.1",
|
|
3045
|
-
circuit_json: packageFiles.find(
|
|
3046
|
-
(file) => file.file_path === "/dist/circuit.json"
|
|
3047
|
-
)?.content_text ? JSON.parse(
|
|
3048
|
-
packageFiles.find((file) => file.file_path === "/dist/circuit.json")?.content_text || "[]"
|
|
3049
|
-
) : [],
|
|
3050
|
-
is_private: _package.is_private || false,
|
|
3051
|
-
is_public: _package.is_public || true,
|
|
3052
|
-
is_unlisted: _package.is_unlisted || false
|
|
3053
|
-
};
|
|
3054
|
-
},
|
|
3055
|
-
searchSnippets: (query) => {
|
|
3056
|
-
const state = get();
|
|
3057
|
-
const lowercaseQuery = query.toLowerCase();
|
|
3058
|
-
const packages = state.packages.filter((pkg) => pkg.is_snippet === true);
|
|
3059
|
-
const matchingPackagesByMetadata = packages.filter(
|
|
3060
|
-
(pkg) => pkg.name.toLowerCase().includes(lowercaseQuery) || pkg.description?.toLowerCase().includes(lowercaseQuery)
|
|
3061
|
-
);
|
|
3062
|
-
const matchingFilesByContent = state.packageFiles.filter(
|
|
3063
|
-
(file) => file.content_text?.toLowerCase().includes(lowercaseQuery) ?? false
|
|
3064
|
-
);
|
|
3065
|
-
const matchingPackagesByContent = matchingFilesByContent.map((file) => {
|
|
3066
|
-
const packageRelease = state.packageReleases.find(
|
|
3067
|
-
(pr) => pr.package_release_id === file.package_release_id
|
|
3068
|
-
);
|
|
3069
|
-
if (!packageRelease) return null;
|
|
3070
|
-
return packages.find(
|
|
3071
|
-
(pkg) => pkg.latest_package_release_id === packageRelease.package_release_id
|
|
3072
|
-
);
|
|
3073
|
-
}).filter((pkg) => pkg !== null);
|
|
3074
|
-
const matchingPackages = [
|
|
3075
|
-
.../* @__PURE__ */ new Set([...matchingPackagesByMetadata, ...matchingPackagesByContent])
|
|
3076
|
-
];
|
|
3077
|
-
return matchingPackages.map((pkg) => {
|
|
3078
|
-
const packageRelease = state.packageReleases.find(
|
|
3079
|
-
(pr) => pr.package_release_id === pkg.latest_package_release_id && pr.is_latest === true
|
|
3080
|
-
);
|
|
3081
|
-
if (!packageRelease) return null;
|
|
3082
|
-
const packageFiles = state.packageFiles.filter(
|
|
3083
|
-
(file) => file.package_release_id === packageRelease.package_release_id
|
|
3084
|
-
);
|
|
3085
|
-
const codeFile = packageFiles.find(
|
|
3086
|
-
(file) => file.file_path === "index.ts" || file.file_path === "index.tsx"
|
|
3087
|
-
);
|
|
3088
|
-
const isStarred = state.accountPackages.some(
|
|
3089
|
-
(ap) => ap.package_id === pkg.package_id && ap.is_starred
|
|
3090
|
-
);
|
|
3091
|
-
return {
|
|
3092
|
-
snippet_id: pkg.package_id,
|
|
3093
|
-
package_release_id: pkg.latest_package_release_id || "",
|
|
3094
|
-
unscoped_name: pkg.unscoped_name,
|
|
3095
|
-
name: pkg.name,
|
|
3096
|
-
owner_name: pkg.owner_github_username || "",
|
|
3097
|
-
description: pkg.description || "",
|
|
3098
|
-
snippet_type: pkg.snippet_type || "board",
|
|
3099
|
-
code: codeFile?.content_text || "",
|
|
3100
|
-
dts: packageFiles.find((file) => file.file_path === "/dist/index.d.ts")?.content_text || "",
|
|
3101
|
-
compiled_js: packageFiles.find((file) => file.file_path === "/dist/index.js")?.content_text || "",
|
|
3102
|
-
created_at: pkg.created_at,
|
|
3103
|
-
updated_at: pkg.updated_at,
|
|
3104
|
-
star_count: pkg.star_count || 0,
|
|
3105
|
-
is_starred: isStarred,
|
|
3106
|
-
version: pkg.latest_version || "0.0.1",
|
|
3107
|
-
circuit_json: packageFiles.filter((file) => file.file_path === "/dist/circuit.json").flatMap((file) => JSON.parse(file.content_text || "[]")) || []
|
|
3108
|
-
};
|
|
3109
|
-
}).filter((snippet) => snippet !== null);
|
|
3110
|
-
},
|
|
3111
|
-
searchPackages: (query) => {
|
|
3112
|
-
const state = get();
|
|
3113
|
-
const lowercaseQuery = query.toLowerCase();
|
|
3114
|
-
const packages = state.packages.filter((pkg) => pkg.is_public === true);
|
|
3115
|
-
const matchingPackagesByMetadata = packages.filter(
|
|
3116
|
-
(pkg) => pkg.name.toLowerCase().includes(lowercaseQuery) || pkg.description?.toLowerCase().includes(lowercaseQuery)
|
|
3117
|
-
);
|
|
3118
|
-
const matchingFilesByContent = state.packageFiles.filter(
|
|
3119
|
-
(file) => file.content_text?.toLowerCase().includes(lowercaseQuery) ?? false
|
|
3120
|
-
);
|
|
3121
|
-
const matchingPackagesByContent = matchingFilesByContent.map((file) => {
|
|
3122
|
-
const packageRelease = state.packageReleases.find(
|
|
3123
|
-
(pr) => pr.package_release_id === file.package_release_id
|
|
3124
|
-
);
|
|
3125
|
-
if (!packageRelease) return null;
|
|
3126
|
-
return packages.find(
|
|
3127
|
-
(pkg) => pkg.latest_package_release_id === packageRelease.package_release_id
|
|
3128
|
-
);
|
|
3129
|
-
}).filter((pkg) => pkg !== null);
|
|
3130
|
-
const matchingPackages = [
|
|
3131
|
-
.../* @__PURE__ */ new Set([...matchingPackagesByMetadata, ...matchingPackagesByContent])
|
|
3132
|
-
];
|
|
3133
|
-
return matchingPackages;
|
|
3134
|
-
},
|
|
3135
|
-
searchAccounts: (query, limit) => {
|
|
3136
|
-
const state = get();
|
|
3137
|
-
const lowercaseQuery = query.toLowerCase();
|
|
3138
|
-
const accountsWithPublicPackages = /* @__PURE__ */ new Set();
|
|
3139
|
-
state.packages.filter((pkg) => pkg.is_public === true).forEach((pkg) => {
|
|
3140
|
-
if (pkg.creator_account_id) {
|
|
3141
|
-
accountsWithPublicPackages.add(pkg.creator_account_id);
|
|
3142
|
-
}
|
|
3143
|
-
if (pkg.owner_github_username) {
|
|
3144
|
-
const account = state.accounts.find(
|
|
3145
|
-
(acc) => acc.github_username === pkg.owner_github_username
|
|
3146
|
-
);
|
|
3147
|
-
if (account) {
|
|
3148
|
-
accountsWithPublicPackages.add(account.account_id);
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
});
|
|
3152
|
-
const matchingAccounts = state.accounts.filter((account) => {
|
|
3153
|
-
if (!accountsWithPublicPackages.has(account.account_id)) {
|
|
3154
|
-
return false;
|
|
3155
|
-
}
|
|
3156
|
-
return account.github_username.toLowerCase().includes(lowercaseQuery);
|
|
3157
|
-
}).slice(0, limit || 50);
|
|
3158
|
-
return matchingAccounts;
|
|
3159
|
-
},
|
|
3160
|
-
deleteSnippet: (snippetId) => {
|
|
3161
|
-
let deleted = false;
|
|
3162
|
-
set((state) => {
|
|
3163
|
-
const index = state.snippets.findIndex((s) => s.snippet_id === snippetId);
|
|
3164
|
-
if (index !== -1) {
|
|
3165
|
-
state.snippets.splice(index, 1);
|
|
3166
|
-
deleted = true;
|
|
3167
|
-
}
|
|
3168
|
-
return state;
|
|
3169
|
-
});
|
|
3170
|
-
return deleted;
|
|
3171
|
-
},
|
|
3172
|
-
addSession: (session) => {
|
|
3173
|
-
const newSession = { session_id: `session_${Date.now()}`, ...session };
|
|
3174
|
-
set((state) => ({
|
|
3175
|
-
sessions: [...state.sessions, newSession]
|
|
3176
|
-
}));
|
|
3177
|
-
return newSession;
|
|
3178
|
-
},
|
|
3179
|
-
getSessions: ({
|
|
3180
|
-
account_id,
|
|
3181
|
-
is_cli_session
|
|
3182
|
-
}) => {
|
|
3183
|
-
const state = get();
|
|
3184
|
-
return state.sessions.filter(
|
|
3185
|
-
(session) => session.account_id === account_id && (is_cli_session === void 0 || session.is_cli_session === is_cli_session)
|
|
3186
|
-
);
|
|
3187
|
-
},
|
|
3188
|
-
createLoginPage: () => {
|
|
3189
|
-
const newLoginPage = {
|
|
3190
|
-
login_page_id: `login_page_${Date.now()}`,
|
|
3191
|
-
login_page_auth_token: `token_${Date.now()}`,
|
|
3192
|
-
was_login_successful: false,
|
|
3193
|
-
has_been_used_to_create_session: false,
|
|
3194
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3195
|
-
expires_at: new Date(Date.now() + 30 * 60 * 1e3).toISOString()
|
|
3196
|
-
// 30 minutes expiration
|
|
3197
|
-
};
|
|
3198
|
-
set((state) => ({
|
|
3199
|
-
loginPages: [...state.loginPages, newLoginPage]
|
|
3200
|
-
}));
|
|
3201
|
-
return newLoginPage;
|
|
3202
|
-
},
|
|
3203
|
-
getLoginPage: (loginPageId) => {
|
|
3204
|
-
const state = get();
|
|
3205
|
-
return state.loginPages.find((lp) => lp.login_page_id === loginPageId);
|
|
3206
|
-
},
|
|
3207
|
-
updateLoginPage: (loginPageId, updates) => {
|
|
3208
|
-
set((state) => ({
|
|
3209
|
-
loginPages: state.loginPages.map(
|
|
3210
|
-
(lp) => lp.login_page_id === loginPageId ? { ...lp, ...updates } : lp
|
|
3211
|
-
)
|
|
3212
|
-
}));
|
|
3213
|
-
},
|
|
3214
|
-
getAccount: (accountId) => {
|
|
3215
|
-
const state = get();
|
|
3216
|
-
return state.accounts.find((account) => account.account_id === accountId);
|
|
3217
|
-
},
|
|
3218
|
-
updateAccount: (accountId, updates) => {
|
|
3219
|
-
let updatedAccount;
|
|
3220
|
-
set((state) => {
|
|
3221
|
-
const accountIndex = state.accounts.findIndex(
|
|
3222
|
-
(account) => account.account_id === accountId
|
|
3223
|
-
);
|
|
3224
|
-
if (accountIndex !== -1) {
|
|
3225
|
-
updatedAccount = { ...state.accounts[accountIndex] };
|
|
3226
|
-
if (updates.shippingInfo) {
|
|
3227
|
-
updatedAccount.shippingInfo = {
|
|
3228
|
-
...updatedAccount.shippingInfo,
|
|
3229
|
-
...updates.shippingInfo
|
|
3230
|
-
};
|
|
3231
|
-
delete updates.shippingInfo;
|
|
3232
|
-
}
|
|
3233
|
-
updatedAccount = { ...updatedAccount, ...updates };
|
|
3234
|
-
const updatedAccounts = [...state.accounts];
|
|
3235
|
-
updatedAccounts[accountIndex] = updatedAccount;
|
|
3236
|
-
return { ...state, accounts: updatedAccounts };
|
|
3237
|
-
}
|
|
3238
|
-
return state;
|
|
3239
|
-
});
|
|
3240
|
-
return updatedAccount;
|
|
3241
|
-
},
|
|
3242
|
-
createSession: (session) => {
|
|
3243
|
-
const newSession = { session_id: `session_${Date.now()}`, ...session };
|
|
3244
|
-
set((state) => ({
|
|
3245
|
-
sessions: [...state.sessions, newSession]
|
|
3246
|
-
}));
|
|
3247
|
-
return newSession;
|
|
3248
|
-
},
|
|
3249
|
-
addStar: (accountId, packageId) => {
|
|
3250
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3251
|
-
const accountPackage = {
|
|
3252
|
-
account_package_id: `ap_${Date.now()}`,
|
|
3253
|
-
account_id: accountId,
|
|
3254
|
-
package_id: packageId,
|
|
3255
|
-
is_starred: true,
|
|
3256
|
-
created_at: now,
|
|
3257
|
-
updated_at: now
|
|
3258
|
-
};
|
|
3259
|
-
set((state) => {
|
|
3260
|
-
const packageIndex = state.packages.findIndex(
|
|
3261
|
-
(pkg) => pkg.package_id === packageId
|
|
3262
|
-
);
|
|
3263
|
-
if (packageIndex >= 0) {
|
|
3264
|
-
const updatedPackages = [...state.packages];
|
|
3265
|
-
updatedPackages[packageIndex] = {
|
|
3266
|
-
...updatedPackages[packageIndex],
|
|
3267
|
-
star_count: (updatedPackages[packageIndex].star_count || 0) + 1
|
|
3268
|
-
};
|
|
3269
|
-
return {
|
|
3270
|
-
packages: updatedPackages,
|
|
3271
|
-
accountPackages: [...state.accountPackages, accountPackage]
|
|
3272
|
-
};
|
|
3273
|
-
}
|
|
3274
|
-
return {
|
|
3275
|
-
accountPackages: [...state.accountPackages, accountPackage]
|
|
3276
|
-
};
|
|
3277
|
-
});
|
|
3278
|
-
return accountPackage;
|
|
3279
|
-
},
|
|
3280
|
-
removeStar: (accountId, packageId) => {
|
|
3281
|
-
set((state) => {
|
|
3282
|
-
const packageIndex = state.packages.findIndex(
|
|
3283
|
-
(pkg) => pkg.package_id === packageId
|
|
3284
|
-
);
|
|
3285
|
-
if (packageIndex >= 0) {
|
|
3286
|
-
const updatedPackages = [...state.packages];
|
|
3287
|
-
updatedPackages[packageIndex] = {
|
|
3288
|
-
...updatedPackages[packageIndex],
|
|
3289
|
-
star_count: Math.max(
|
|
3290
|
-
0,
|
|
3291
|
-
(updatedPackages[packageIndex].star_count || 0) - 1
|
|
3292
|
-
)
|
|
3293
|
-
};
|
|
3294
|
-
return {
|
|
3295
|
-
packages: updatedPackages,
|
|
3296
|
-
accountPackages: state.accountPackages.filter(
|
|
3297
|
-
(ap) => !(ap.account_id === accountId && ap.package_id === packageId)
|
|
3298
|
-
)
|
|
3299
|
-
};
|
|
3300
|
-
}
|
|
3301
|
-
return {
|
|
3302
|
-
accountPackages: state.accountPackages.filter(
|
|
3303
|
-
(ap) => !(ap.account_id === accountId && ap.package_id === packageId)
|
|
3304
|
-
)
|
|
3305
|
-
};
|
|
3306
|
-
});
|
|
3307
|
-
},
|
|
3308
|
-
hasStarred: (accountId, packageId) => {
|
|
3309
|
-
const state = get();
|
|
3310
|
-
return state.accountPackages.some(
|
|
3311
|
-
(ap) => ap.account_id === accountId && ap.package_id === packageId && ap.is_starred
|
|
3312
|
-
);
|
|
3313
|
-
},
|
|
3314
|
-
addPackage: (_package) => {
|
|
3315
|
-
const timestamp = Date.now();
|
|
3316
|
-
const newPackage = {
|
|
3317
|
-
package_id: `package_${timestamp}`,
|
|
3318
|
-
github_repo_full_name: null,
|
|
3319
|
-
latest_pcb_preview_image_url: _package.latest_pcb_preview_image_url ?? `/api/packages/images/${_package.name}`,
|
|
3320
|
-
latest_cad_preview_image_url: _package.latest_cad_preview_image_url ?? `/api/packages/images/${_package.name}`,
|
|
3321
|
-
latest_sch_preview_image_url: _package.latest_sch_preview_image_url ?? `/api/packages/images/${_package.name}`,
|
|
3322
|
-
..._package
|
|
3323
|
-
};
|
|
3324
|
-
set((state) => ({
|
|
3325
|
-
packages: [...state.packages, newPackage]
|
|
3326
|
-
}));
|
|
3327
|
-
return newPackage;
|
|
3328
|
-
},
|
|
3329
|
-
updatePackage: (packageId, updates) => {
|
|
3330
|
-
let updatedPackage;
|
|
3331
|
-
set((state) => {
|
|
3332
|
-
const packageIndex = state.packages.findIndex(
|
|
3333
|
-
(pkg) => pkg.package_id === packageId
|
|
3334
|
-
);
|
|
3335
|
-
if (packageIndex === -1) return state;
|
|
3336
|
-
const updatedPackages = [...state.packages];
|
|
3337
|
-
updatedPackages[packageIndex] = {
|
|
3338
|
-
...updatedPackages[packageIndex],
|
|
3339
|
-
...updates
|
|
3340
|
-
};
|
|
3341
|
-
updatedPackage = updatedPackages[packageIndex];
|
|
3342
|
-
return { ...state, packages: updatedPackages };
|
|
3343
|
-
});
|
|
3344
|
-
return updatedPackage;
|
|
3345
|
-
},
|
|
3346
|
-
getPackageById: (packageId) => {
|
|
3347
|
-
const state = get();
|
|
3348
|
-
const pkg = state.packages.find((pkg2) => pkg2.package_id === packageId);
|
|
3349
|
-
if (!pkg) return void 0;
|
|
3350
|
-
return {
|
|
3351
|
-
...pkg
|
|
3352
|
-
};
|
|
3353
|
-
},
|
|
3354
|
-
getPackageReleaseById: (packageReleaseId) => {
|
|
3355
|
-
const state = get();
|
|
3356
|
-
return state.packageReleases.find(
|
|
3357
|
-
(pr) => pr.package_release_id === packageReleaseId
|
|
3358
|
-
);
|
|
3359
|
-
},
|
|
3360
|
-
addPackageRelease: (packageRelease) => {
|
|
3361
|
-
const parsed = packageReleaseSchema.parse({
|
|
3362
|
-
package_release_id: `package_release_${Date.now()}`,
|
|
3363
|
-
...packageRelease
|
|
3364
|
-
});
|
|
3365
|
-
set((state) => ({
|
|
3366
|
-
packageReleases: [...state.packageReleases, parsed]
|
|
3367
|
-
}));
|
|
3368
|
-
return parsed;
|
|
3369
|
-
},
|
|
3370
|
-
updatePackageRelease: (packageRelease) => {
|
|
3371
|
-
set((state) => ({
|
|
3372
|
-
packageReleases: state.packageReleases.map(
|
|
3373
|
-
(pr) => pr.package_release_id === packageRelease.package_release_id ? packageRelease : pr
|
|
3374
|
-
)
|
|
3375
|
-
}));
|
|
3376
|
-
},
|
|
3377
|
-
deletePackageFile: (packageFileId) => {
|
|
3378
|
-
let deleted = false;
|
|
3379
|
-
set((state) => {
|
|
3380
|
-
const index = state.packageFiles.findIndex(
|
|
3381
|
-
(file) => file.package_file_id === packageFileId
|
|
3382
|
-
);
|
|
3383
|
-
if (index !== -1) {
|
|
3384
|
-
state.packageFiles.splice(index, 1);
|
|
3385
|
-
deleted = true;
|
|
3386
|
-
}
|
|
3387
|
-
return state;
|
|
3388
|
-
});
|
|
3389
|
-
return deleted;
|
|
3390
|
-
},
|
|
3391
|
-
addPackageFile: (packageFile) => {
|
|
3392
|
-
const newPackageFile = {
|
|
3393
|
-
package_file_id: `package_file_${Date.now()}`,
|
|
3394
|
-
...packageFile
|
|
3395
|
-
};
|
|
3396
|
-
set((state) => ({
|
|
3397
|
-
packageFiles: [...state.packageFiles, newPackageFile]
|
|
3398
|
-
}));
|
|
3399
|
-
return newPackageFile;
|
|
3400
|
-
},
|
|
3401
|
-
updatePackageFile: (packageFileId, updates) => {
|
|
3402
|
-
set((state2) => ({
|
|
3403
|
-
packageFiles: state2.packageFiles.map(
|
|
3404
|
-
(file) => file.package_file_id === packageFileId ? { ...file, ...updates } : file
|
|
3405
|
-
)
|
|
3406
|
-
}));
|
|
3407
|
-
const state = get();
|
|
3408
|
-
return state.packageFiles.find(
|
|
3409
|
-
(file) => file.package_file_id === packageFileId
|
|
3410
|
-
);
|
|
3411
|
-
},
|
|
3412
|
-
getStarCount: (packageId) => {
|
|
3413
|
-
const state = get();
|
|
3414
|
-
return state.accountPackages.filter(
|
|
3415
|
-
(ap) => ap.package_id === packageId && ap.is_starred
|
|
3416
|
-
).length;
|
|
3417
|
-
},
|
|
3418
|
-
getPackageFilesByReleaseId: (packageReleaseId) => {
|
|
3419
|
-
const state = get();
|
|
3420
|
-
return state.packageFiles.filter(
|
|
3421
|
-
(pf) => pf.package_release_id === packageReleaseId
|
|
3422
|
-
);
|
|
3423
|
-
},
|
|
3424
|
-
/**
|
|
3425
|
-
* Update fs_sha for a package release based on its files
|
|
3426
|
-
*/
|
|
3427
|
-
updatePackageReleaseFsSha: (packageReleaseId) => {
|
|
3428
|
-
const state = get();
|
|
3429
|
-
const packageFiles = state.packageFiles.filter(
|
|
3430
|
-
(pf) => pf.package_release_id === packageReleaseId
|
|
3431
|
-
);
|
|
3432
|
-
const fsSha = generateFsSha(packageFiles);
|
|
3433
|
-
set((currentState) => ({
|
|
3434
|
-
...currentState,
|
|
3435
|
-
packageReleases: currentState.packageReleases.map(
|
|
3436
|
-
(pr) => pr.package_release_id === packageReleaseId ? { ...pr, fs_sha: fsSha } : pr
|
|
3437
|
-
),
|
|
3438
|
-
packages: currentState.packages.map(
|
|
3439
|
-
(pkg) => pkg.latest_package_release_id === packageReleaseId ? { ...pkg, latest_package_release_fs_sha: fsSha } : pkg
|
|
3440
|
-
)
|
|
3441
|
-
}));
|
|
3442
|
-
},
|
|
3443
|
-
addAiReview: (review) => {
|
|
3444
|
-
const base = aiReviewSchema.omit({ ai_review_id: true }).parse(review);
|
|
3445
|
-
const newReview = {
|
|
3446
|
-
ai_review_id: crypto.randomUUID(),
|
|
3447
|
-
...base
|
|
3448
|
-
};
|
|
3449
|
-
set((state) => ({
|
|
3450
|
-
aiReviews: [...state.aiReviews, newReview],
|
|
3451
|
-
idCounter: state.idCounter + 1
|
|
3452
|
-
}));
|
|
3453
|
-
return newReview;
|
|
3454
|
-
},
|
|
3455
|
-
updateAiReview: (aiReviewId, updates) => {
|
|
3456
|
-
let updated;
|
|
3457
|
-
set((state) => {
|
|
3458
|
-
const index = state.aiReviews.findIndex(
|
|
3459
|
-
(ar) => ar.ai_review_id === aiReviewId
|
|
3460
|
-
);
|
|
3461
|
-
if (index === -1) return state;
|
|
3462
|
-
const aiReviews = [...state.aiReviews];
|
|
3463
|
-
aiReviews[index] = { ...aiReviews[index], ...updates };
|
|
3464
|
-
updated = aiReviews[index];
|
|
3465
|
-
return { ...state, aiReviews };
|
|
3466
|
-
});
|
|
3467
|
-
return updated;
|
|
3468
|
-
},
|
|
3469
|
-
getAiReviewById: (aiReviewId) => {
|
|
3470
|
-
const state = get();
|
|
3471
|
-
return state.aiReviews.find((ar) => ar.ai_review_id === aiReviewId);
|
|
3472
|
-
},
|
|
3473
|
-
listAiReviews: () => {
|
|
3474
|
-
const state = get();
|
|
3475
|
-
return state.aiReviews;
|
|
3476
|
-
},
|
|
3477
|
-
addDatasheet: ({ chip_name }) => {
|
|
3478
|
-
const newDatasheet = datasheetSchema.parse({
|
|
3479
|
-
datasheet_id: crypto.randomUUID(),
|
|
3480
|
-
chip_name,
|
|
3481
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3482
|
-
pin_information: null,
|
|
3483
|
-
datasheet_pdf_urls: null,
|
|
3484
|
-
ai_description: null
|
|
3485
|
-
});
|
|
3486
|
-
set((state) => ({
|
|
3487
|
-
datasheets: [...state.datasheets, newDatasheet]
|
|
3488
|
-
}));
|
|
3489
|
-
return newDatasheet;
|
|
3490
|
-
},
|
|
3491
|
-
getDatasheetById: (datasheetId) => {
|
|
3492
|
-
const state = get();
|
|
3493
|
-
return state.datasheets.find((d) => d.datasheet_id === datasheetId);
|
|
3494
|
-
},
|
|
3495
|
-
getDatasheetByChipName: (chipName) => {
|
|
3496
|
-
const state = get();
|
|
3497
|
-
return state.datasheets.find(
|
|
3498
|
-
(d) => d.chip_name.toLowerCase() === chipName.toLowerCase()
|
|
3499
|
-
);
|
|
3500
|
-
},
|
|
3501
|
-
listDatasheets: ({
|
|
3502
|
-
chip_name,
|
|
3503
|
-
is_popular
|
|
3504
|
-
} = {}) => {
|
|
3505
|
-
const state = get();
|
|
3506
|
-
if (is_popular) {
|
|
3507
|
-
return state.datasheets;
|
|
3508
|
-
}
|
|
3509
|
-
if (chip_name) {
|
|
3510
|
-
return state.datasheets.filter(
|
|
3511
|
-
(d) => d.chip_name.toLowerCase() === chip_name.toLowerCase()
|
|
3512
|
-
);
|
|
3513
|
-
}
|
|
3514
|
-
return state.datasheets;
|
|
3515
|
-
},
|
|
3516
|
-
updateDatasheet: (datasheetId, updates) => {
|
|
3517
|
-
let updated;
|
|
3518
|
-
set((state) => {
|
|
3519
|
-
const index = state.datasheets.findIndex(
|
|
3520
|
-
(d) => d.datasheet_id === datasheetId
|
|
3521
|
-
);
|
|
3522
|
-
if (index === -1) return state;
|
|
3523
|
-
const datasheets = [...state.datasheets];
|
|
3524
|
-
datasheets[index] = { ...datasheets[index], ...updates };
|
|
3525
|
-
updated = datasheets[index];
|
|
3526
|
-
return { ...state, datasheets };
|
|
3527
|
-
});
|
|
3528
|
-
return updated;
|
|
3529
|
-
},
|
|
3530
|
-
addPackageBuild: (packageBuild) => {
|
|
3531
|
-
const newPackageBuild = packageBuildSchema.parse({
|
|
3532
|
-
package_build_id: crypto.randomUUID(),
|
|
3533
|
-
...packageBuild
|
|
3534
|
-
});
|
|
3535
|
-
set((state) => ({
|
|
3536
|
-
packageBuilds: [...state.packageBuilds, newPackageBuild],
|
|
3537
|
-
// Automatically update the package release to reference this as the latest build
|
|
3538
|
-
packageReleases: state.packageReleases.map(
|
|
3539
|
-
(release) => release.package_release_id === packageBuild.package_release_id ? {
|
|
3540
|
-
...release,
|
|
3541
|
-
latest_package_build_id: newPackageBuild.package_build_id
|
|
3542
|
-
} : release
|
|
3543
|
-
)
|
|
3544
|
-
}));
|
|
3545
|
-
return newPackageBuild;
|
|
3546
|
-
},
|
|
3547
|
-
getPackageBuildById: (packageBuildId) => {
|
|
3548
|
-
const state = get();
|
|
3549
|
-
return state.packageBuilds.find(
|
|
3550
|
-
(pb) => pb.package_build_id === packageBuildId
|
|
3551
|
-
);
|
|
3552
|
-
},
|
|
3553
|
-
getPackageBuildsByReleaseId: (packageReleaseId) => {
|
|
3554
|
-
const state = get();
|
|
3555
|
-
return state.packageBuilds.filter((pb) => pb.package_release_id === packageReleaseId).sort(
|
|
3556
|
-
(a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
3557
|
-
);
|
|
3558
|
-
},
|
|
3559
|
-
updatePackageBuild: (packageBuildId, updates) => {
|
|
3560
|
-
let updated;
|
|
3561
|
-
set((state) => {
|
|
3562
|
-
const index = state.packageBuilds.findIndex(
|
|
3563
|
-
(pb) => pb.package_build_id === packageBuildId
|
|
3564
|
-
);
|
|
3565
|
-
if (index === -1) return state;
|
|
3566
|
-
const packageBuilds = [...state.packageBuilds];
|
|
3567
|
-
packageBuilds[index] = { ...packageBuilds[index], ...updates };
|
|
3568
|
-
updated = packageBuilds[index];
|
|
3569
|
-
return { ...state, packageBuilds };
|
|
3570
|
-
});
|
|
3571
|
-
return updated;
|
|
3572
|
-
},
|
|
3573
|
-
addOrganization: (organization) => {
|
|
3574
|
-
const newOrganization = {
|
|
3575
|
-
org_name: organization.name,
|
|
3576
|
-
org_id: organization.org_id || `org_${get().idCounter + 1}`,
|
|
3577
|
-
github_handle: organization.github_handle,
|
|
3578
|
-
is_personal_org: organization.is_personal_org || false,
|
|
3579
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3580
|
-
...organization
|
|
3581
|
-
};
|
|
3582
|
-
set((state) => ({
|
|
3583
|
-
idCounter: state.idCounter + 1,
|
|
3584
|
-
organizations: [...state.organizations, newOrganization],
|
|
3585
|
-
// Add the creator as a member of the new org by setting their personal_org_id
|
|
3586
|
-
accounts: state.accounts.map(
|
|
3587
|
-
(account) => account.account_id === organization.owner_account_id ? { ...account, personal_org_id: newOrganization.org_id } : account
|
|
3588
|
-
)
|
|
3589
|
-
}));
|
|
3590
|
-
return newOrganization;
|
|
3591
|
-
},
|
|
3592
|
-
getOrgs: (filters, auth) => {
|
|
3593
|
-
let orgs = get().organizations;
|
|
3594
|
-
if (filters?.owner_account_id) {
|
|
3595
|
-
orgs = orgs.filter(
|
|
3596
|
-
(org) => org.owner_account_id === filters.owner_account_id
|
|
3597
|
-
);
|
|
3598
|
-
}
|
|
3599
|
-
if (filters?.github_handle) {
|
|
3600
|
-
orgs = orgs.filter((org) => {
|
|
3601
|
-
const account = get().accounts.find(
|
|
3602
|
-
(account2) => account2.account_id === org.owner_account_id
|
|
3603
|
-
);
|
|
3604
|
-
return account?.github_username === filters.github_handle;
|
|
3605
|
-
});
|
|
3606
|
-
}
|
|
3607
|
-
if (filters?.name) {
|
|
3608
|
-
orgs = orgs.filter((org) => org.github_handle === filters.name);
|
|
3609
|
-
}
|
|
3610
|
-
return orgs.map((org) => {
|
|
3611
|
-
const member_count = get().accounts.filter(
|
|
3612
|
-
(account) => account.personal_org_id === org.org_id
|
|
3613
|
-
).length;
|
|
3614
|
-
const package_count = get().packages.filter(
|
|
3615
|
-
(pkg) => pkg.owner_org_id === org.org_id
|
|
3616
|
-
).length;
|
|
3617
|
-
const can_manage_org = auth ? org.owner_account_id === auth.account_id : false;
|
|
3618
|
-
return {
|
|
3619
|
-
...org,
|
|
3620
|
-
member_count,
|
|
3621
|
-
package_count,
|
|
3622
|
-
can_manage_org
|
|
3623
|
-
};
|
|
3624
|
-
});
|
|
3625
|
-
},
|
|
3626
|
-
getOrg: (filters, auth) => {
|
|
3627
|
-
let orgs = get().organizations;
|
|
3628
|
-
if (filters?.org_id) {
|
|
3629
|
-
orgs = orgs.filter((org2) => org2.org_id === filters.org_id);
|
|
3630
|
-
}
|
|
3631
|
-
if (filters?.org_name) {
|
|
3632
|
-
orgs = orgs.filter((org2) => org2.org_name === filters.org_name);
|
|
3633
|
-
}
|
|
3634
|
-
if (filters?.github_handle) {
|
|
3635
|
-
orgs = orgs.filter((org2) => org2.github_handle === filters.github_handle);
|
|
3636
|
-
}
|
|
3637
|
-
if (orgs.length === 0) {
|
|
3638
|
-
return null;
|
|
3639
|
-
}
|
|
3640
|
-
const org = orgs[0];
|
|
3641
|
-
const member_count = get().accounts.filter(
|
|
3642
|
-
(account) => account.personal_org_id === org.org_id
|
|
3643
|
-
).length;
|
|
3644
|
-
const package_count = get().packages.filter(
|
|
3645
|
-
(pkg) => pkg.owner_org_id === org.org_id
|
|
3646
|
-
).length;
|
|
3647
|
-
const can_manage_org = auth ? org.owner_account_id === auth.account_id : false;
|
|
3648
|
-
return {
|
|
3649
|
-
...org,
|
|
3650
|
-
member_count,
|
|
3651
|
-
package_count,
|
|
3652
|
-
can_manage_org
|
|
3653
|
-
};
|
|
3654
|
-
},
|
|
3655
|
-
addOrganizationAccount: (organizationAccount) => {
|
|
3656
|
-
const newOrgAccount = {
|
|
3657
|
-
org_account_id: `org_account_${get().idCounter + 1}`,
|
|
3658
|
-
org_id: organizationAccount.org_id,
|
|
3659
|
-
account_id: organizationAccount.account_id,
|
|
3660
|
-
is_owner: organizationAccount.is_owner || false,
|
|
3661
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3662
|
-
};
|
|
3663
|
-
set((state) => ({
|
|
3664
|
-
orgAccounts: [...state.orgAccounts, newOrgAccount],
|
|
3665
|
-
idCounter: state.idCounter + 1
|
|
3666
|
-
}));
|
|
3667
|
-
return newOrgAccount;
|
|
3668
|
-
},
|
|
3669
|
-
getOrganizationAccount: (filters) => {
|
|
3670
|
-
const state = get();
|
|
3671
|
-
return state.orgAccounts.find((orgAccount) => {
|
|
3672
|
-
if (filters.org_id && orgAccount.org_id !== filters.org_id) {
|
|
3673
|
-
return false;
|
|
3674
|
-
}
|
|
3675
|
-
if (filters.account_id && orgAccount.account_id !== filters.account_id) {
|
|
3676
|
-
return false;
|
|
3677
|
-
}
|
|
3678
|
-
return true;
|
|
3679
|
-
});
|
|
3680
|
-
},
|
|
3681
|
-
getOrganizationAccounts: (filters) => {
|
|
3682
|
-
const state = get();
|
|
3683
|
-
return state.orgAccounts.filter((orgAccount) => {
|
|
3684
|
-
if (filters?.org_id && orgAccount.org_id !== filters.org_id) {
|
|
3685
|
-
return false;
|
|
3686
|
-
}
|
|
3687
|
-
if (filters?.account_id && orgAccount.account_id !== filters.account_id) {
|
|
3688
|
-
return false;
|
|
3689
|
-
}
|
|
3690
|
-
return true;
|
|
3691
|
-
});
|
|
3692
|
-
},
|
|
3693
|
-
removeOrganizationAccount: (filters) => {
|
|
3694
|
-
let removed = false;
|
|
3695
|
-
set((state) => {
|
|
3696
|
-
const index = state.orgAccounts.findIndex(
|
|
3697
|
-
(orgAccount) => orgAccount.org_id === filters.org_id && orgAccount.account_id === filters.account_id
|
|
3698
|
-
);
|
|
3699
|
-
if (index !== -1) {
|
|
3700
|
-
state.orgAccounts.splice(index, 1);
|
|
3701
|
-
removed = true;
|
|
3702
|
-
}
|
|
3703
|
-
return state;
|
|
3704
|
-
});
|
|
3705
|
-
return removed;
|
|
3706
|
-
},
|
|
3707
|
-
updateOrganization: (orgId, updates) => {
|
|
3708
|
-
let updatedOrg;
|
|
3709
|
-
set((state) => {
|
|
3710
|
-
const orgIndex = state.organizations.findIndex(
|
|
3711
|
-
(org) => org.org_id === orgId
|
|
3712
|
-
);
|
|
3713
|
-
if (orgIndex === -1) return state;
|
|
3714
|
-
const updatedOrganizations = [...state.organizations];
|
|
3715
|
-
updatedOrganizations[orgIndex] = {
|
|
3716
|
-
...updatedOrganizations[orgIndex],
|
|
3717
|
-
...updates
|
|
3718
|
-
};
|
|
3719
|
-
updatedOrg = updatedOrganizations[orgIndex];
|
|
3720
|
-
return { ...state, organizations: updatedOrganizations };
|
|
3721
|
-
});
|
|
3722
|
-
return updatedOrg;
|
|
3723
|
-
}
|
|
3724
|
-
}));
|
|
3725
|
-
|
|
3726
|
-
// fake-snippets-api/lib/middleware/with-db.ts
|
|
3727
|
-
var withDb = async (req, ctx, next) => {
|
|
3728
|
-
if (!ctx.db) {
|
|
3729
|
-
ctx.db = createDatabase();
|
|
3730
|
-
}
|
|
3731
|
-
return next(req, ctx);
|
|
3732
|
-
};
|
|
3733
|
-
export {
|
|
3734
|
-
createDatabase,
|
|
3735
|
-
seed,
|
|
3736
|
-
withDb
|
|
3737
|
-
};
|