@tscircuit/fake-snippets 0.0.108 → 0.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/bun-formatcheck.yml +2 -2
- package/.github/workflows/bun-pver-release.yml +3 -3
- package/.github/workflows/bun-test.yml +1 -1
- package/.github/workflows/bun-typecheck.yml +2 -2
- package/.github/workflows/update-snapshots.yml +1 -1
- package/README.md +4 -0
- package/api/generated-index.js +37 -3
- package/biome.json +2 -1
- package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +31 -3
- package/bun-tests/fake-snippets-api/fixtures/preload.ts +18 -0
- package/bun-tests/fake-snippets-api/routes/orgs/add_member.test.ts +26 -0
- package/bun-tests/fake-snippets-api/routes/orgs/create.test.ts +37 -0
- package/bun-tests/fake-snippets-api/routes/orgs/get.test.ts +52 -0
- package/bun-tests/fake-snippets-api/routes/orgs/list.test.ts +17 -0
- package/bun-tests/fake-snippets-api/routes/orgs/list_members.test.ts +23 -0
- package/bun-tests/fake-snippets-api/routes/orgs/remove_member.test.ts +81 -0
- package/bun-tests/fake-snippets-api/routes/orgs/update.test.ts +99 -0
- package/bun-tests/fake-snippets-api/routes/package_builds/get.test.ts +1 -1
- package/bun-tests/fake-snippets-api/routes/package_files/create.test.ts +15 -13
- package/bun-tests/fake-snippets-api/routes/package_files/create_or_update.test.ts +26 -24
- package/bun-tests/fake-snippets-api/routes/package_files/delete.test.ts +9 -9
- package/bun-tests/fake-snippets-api/routes/package_files/download.test.ts +4 -4
- package/bun-tests/fake-snippets-api/routes/package_files/get.test.ts +38 -28
- package/bun-tests/fake-snippets-api/routes/package_files/list.test.ts +23 -15
- package/bun-tests/fake-snippets-api/routes/package_releases/create.test.ts +33 -0
- package/bun-tests/fake-snippets-api/routes/package_releases/get.test.ts +4 -4
- package/bun-tests/fake-snippets-api/routes/package_releases/get_image_generation_fields.test.ts +38 -0
- package/bun-tests/fake-snippets-api/routes/packages/create.test.ts +19 -0
- package/bun-tests/fake-snippets-api/routes/packages/fork.test.ts +3 -4
- package/bun-tests/fake-snippets-api/routes/packages/get.test.ts +30 -0
- package/bun-tests/fake-snippets-api/routes/packages/images.test.ts +4 -2
- package/bun-tests/fake-snippets-api/routes/packages/list-1.test.ts +34 -0
- package/bun.lock +389 -450
- package/bunfig.toml +2 -1
- package/dist/bundle.js +1255 -625
- package/dist/index.d.ts +296 -4
- package/dist/index.js +325 -24
- package/dist/schema.d.ts +282 -1
- package/dist/schema.js +54 -2
- package/fake-snippets-api/lib/db/autoload-dev-packages.ts +31 -20
- package/fake-snippets-api/lib/db/db-client.ts +214 -3
- package/fake-snippets-api/lib/db/schema.ts +62 -0
- package/fake-snippets-api/lib/db/seed.ts +100 -0
- package/fake-snippets-api/lib/middleware/with-session-auth.ts +1 -1
- package/fake-snippets-api/lib/package_file/get-package-file-id-from-file-descriptor.ts +2 -2
- package/fake-snippets-api/lib/public-mapping/public-map-org.ts +32 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package-build.ts +10 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +17 -0
- package/fake-snippets-api/routes/api/orgs/add_member.ts +52 -0
- package/fake-snippets-api/routes/api/orgs/create.ts +46 -0
- package/fake-snippets-api/routes/api/orgs/get.ts +39 -0
- package/fake-snippets-api/routes/api/orgs/list.ts +31 -0
- package/fake-snippets-api/routes/api/orgs/list_members.ts +67 -0
- package/fake-snippets-api/routes/api/orgs/remove_member.ts +46 -0
- package/fake-snippets-api/routes/api/orgs/update.ts +93 -0
- package/fake-snippets-api/routes/api/package_files/get.ts +3 -6
- package/fake-snippets-api/routes/api/package_files/list.ts +7 -4
- package/fake-snippets-api/routes/api/packages/create.ts +54 -10
- package/fake-snippets-api/routes/api/packages/get.ts +23 -0
- package/fake-snippets-api/routes/api/packages/images/[owner_github_username]/[unscoped_name]/[view_format].ts +13 -11
- package/fake-snippets-api/routes/api/packages/list.ts +29 -2
- package/fake-snippets-api/routes/api/packages/update_ai_description.ts +37 -0
- package/package.json +27 -24
- package/renovate.json +1 -1
- package/scripts/generate-sitemap.ts +1 -1
- package/src/App.tsx +29 -10
- package/src/ContextProviders.tsx +25 -2
- package/src/components/CircuitJsonImportDialog.tsx +1 -1
- package/src/components/CmdKMenu.tsx +281 -247
- package/src/components/DownloadButtonAndMenu.tsx +133 -36
- package/src/components/FileSidebar.tsx +41 -50
- package/src/components/Footer.tsx +8 -10
- package/src/components/Header.tsx +19 -32
- package/src/components/Header2.tsx +16 -32
- package/src/components/HeaderDropdown.tsx +13 -8
- package/src/components/HeaderLogin.tsx +44 -16
- package/src/components/HiddenFilesDropdown.tsx +0 -2
- package/src/components/NotFound.tsx +5 -5
- package/src/components/PackageBreadcrumb.tsx +6 -12
- package/src/components/PackageCard.tsx +0 -1
- package/src/components/PackageSearchResults.tsx +1 -1
- package/src/components/PrefetchPageLink.tsx +7 -1
- package/src/components/ProfileRouter.tsx +32 -0
- package/src/components/SearchComponent.tsx +12 -8
- package/src/components/UserCard.tsx +80 -0
- package/src/components/ViewPackagePage/components/ShikiCodeViewer.tsx +20 -11
- package/src/components/ViewPackagePage/components/build-status.tsx +1 -1
- package/src/components/ViewPackagePage/components/important-files-view.tsx +174 -87
- package/src/components/ViewPackagePage/components/main-content-header.tsx +8 -4
- package/src/components/ViewPackagePage/components/main-content-view-selector.tsx +1 -2
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +54 -20
- package/src/components/ViewPackagePage/components/package-header.tsx +26 -37
- package/src/components/ViewPackagePage/components/preview-image-squares.tsx +11 -19
- package/src/components/ViewPackagePage/components/repo-page-content.tsx +33 -25
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +16 -10
- package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +11 -11
- package/src/components/ViewPackagePage/components/sidebar.tsx +0 -2
- package/src/components/ViewPackagePage/components/tab-views/files-view.tsx +18 -17
- package/src/components/ViewPackagePage/components/tab-views/pcb-view.tsx +1 -2
- package/src/components/ViewPackagePage/components/tab-views/schematic-view.tsx +2 -1
- package/src/components/ViewPackagePage/components/theme-toggle.tsx +0 -2
- package/src/components/ViewPackagePage/hooks/use-toast.tsx +0 -1
- package/src/components/dialogs/GitHubRepositorySelector.tsx +56 -49
- package/src/components/dialogs/edit-package-details-dialog.tsx +5 -6
- package/src/components/dialogs/import-component-dialog.tsx +16 -9
- package/src/components/dialogs/import-package-dialog.tsx +3 -2
- package/src/components/dialogs/new-package-save-prompt-dialog.tsx +190 -0
- package/src/components/organization/OrganizationCard.tsx +204 -0
- package/src/components/organization/OrganizationCardSkeleton.tsx +55 -0
- package/src/components/organization/OrganizationHeader.tsx +154 -0
- package/src/components/organization/OrganizationMembers.tsx +146 -0
- package/src/components/package-port/CodeAndPreview.tsx +32 -46
- package/src/components/package-port/CodeEditor.tsx +28 -31
- package/src/components/package-port/CodeEditorHeader.tsx +128 -63
- package/src/components/package-port/EditorNav.tsx +32 -49
- package/src/components/preview/ConnectedPackagesList.tsx +8 -8
- package/src/components/preview/ConnectedRepoOverview.tsx +102 -2
- package/src/components/preview/PackageReleasesDashboard.tsx +53 -36
- package/src/components/ui/tree-view.tsx +6 -3
- package/src/hooks/use-add-org-member-mutation.ts +51 -0
- package/src/hooks/use-create-org-mutation.ts +38 -0
- package/src/hooks/use-create-package-mutation.ts +3 -0
- package/src/hooks/use-current-package-id.ts +5 -30
- package/src/hooks/use-current-package-info.ts +29 -5
- package/src/hooks/use-current-package-release.ts +4 -3
- package/src/hooks/use-download-zip.ts +2 -2
- package/src/hooks/use-global-store.ts +6 -4
- package/src/hooks/use-jlcpcb-component-import.tsx +164 -0
- package/src/hooks/use-list-org-members.ts +27 -0
- package/src/hooks/use-list-user-orgs.ts +25 -0
- package/src/hooks/use-org-by-github-handle.ts +26 -0
- package/src/hooks/use-org.ts +24 -0
- package/src/hooks/use-organization.ts +42 -0
- package/src/hooks/use-package-as-snippet.ts +4 -2
- package/src/hooks/use-package-builds.ts +6 -2
- package/src/hooks/use-package-files.ts +5 -3
- package/src/hooks/use-package-release-by-id-or-version.ts +29 -20
- package/src/hooks/use-package-release-images.ts +105 -0
- package/src/hooks/use-package-release.ts +2 -2
- package/src/hooks/use-package-stars.ts +80 -4
- package/src/hooks/use-preview-images.ts +6 -3
- package/src/hooks/use-remove-org-member-mutation.ts +32 -0
- package/src/hooks/use-update-ai-description-mutation.ts +42 -0
- package/src/hooks/use-update-org-mutation.ts +41 -0
- package/src/hooks/use-warn-user-on-page-change.ts +71 -4
- package/src/hooks/useFileManagement.ts +183 -35
- package/src/hooks/useOptimizedPackageFilesLoader.ts +136 -0
- package/src/hooks/usePackageFilesLoader.ts +2 -2
- package/src/hooks/useUpdatePackageFilesMutation.ts +15 -1
- package/src/lib/download-fns/download-circuit-png.ts +11 -3
- package/src/lib/download-fns/download-gltf-from-circuit-json.ts +44 -0
- package/src/lib/download-fns/download-kicad-files.ts +12 -11
- package/src/lib/normalize-svg-for-tile.ts +50 -0
- package/src/lib/posthog.ts +11 -9
- package/src/lib/react-query-api-failure-tracking.ts +148 -0
- package/src/lib/sentry.ts +14 -0
- package/src/lib/templates/blank-circuit-board-template.ts +0 -4
- package/src/lib/ts-lib-cache.ts +122 -7
- package/src/lib/utils/checkIfManualEditsImported.ts +4 -4
- package/src/lib/utils/findTargetFile.ts +45 -10
- package/src/lib/utils/isComponentExported.ts +10 -0
- package/src/main.tsx +2 -1
- package/src/pages/authorize.tsx +0 -2
- package/src/pages/create-organization.tsx +168 -0
- package/src/pages/dashboard.tsx +38 -6
- package/src/pages/datasheet.tsx +1 -1
- package/src/pages/datasheets.tsx +3 -3
- package/src/pages/editor.tsx +4 -6
- package/src/pages/landing.tsx +6 -7
- package/src/pages/latest.tsx +3 -0
- package/src/pages/organization-profile.tsx +199 -0
- package/src/pages/organization-settings.tsx +566 -0
- package/src/pages/package-editor.tsx +21 -21
- package/src/pages/preview-release.tsx +76 -136
- package/src/pages/quickstart.tsx +159 -123
- package/src/pages/release-detail.tsx +119 -31
- package/src/pages/search.tsx +192 -57
- package/src/pages/settings-redirect.tsx +44 -0
- package/src/pages/trending.tsx +29 -20
- package/src/pages/user-profile.tsx +58 -7
- package/src/pages/view-package.tsx +21 -26
- package/vite.config.ts +9 -0
- package/fake-snippets-api/routes/api/autocomplete/create_autocomplete.ts +0 -133
- package/src/components/Footer2.tsx +0 -100
- package/src/components/JLCPCBImportDialog.tsx +0 -280
- package/src/components/PackageBuildsPage/LogContent.tsx +0 -72
- package/src/components/PackageBuildsPage/PackageBuildDetailsPage.tsx +0 -115
- package/src/components/PackageBuildsPage/build-preview-content.tsx +0 -27
- package/src/components/PackageBuildsPage/collapsible-section.tsx +0 -63
- package/src/components/PackageBuildsPage/package-build-details-panel.tsx +0 -166
- package/src/components/PackageBuildsPage/package-build-header.tsx +0 -79
- package/src/components/PageSearchComponent.tsx +0 -148
- package/src/components/ShippingInformationForm.tsx +0 -423
- package/src/components/StaticViewSnippetHeader.tsx +0 -70
- package/src/components/ViewPackagePage/components/file-explorer.tsx +0 -67
- package/src/components/ViewPackagePage/components/readme-view.tsx +0 -58
- package/src/components/ViewPackagePage/components/repo-header-button.tsx +0 -36
- package/src/components/ViewPackagePage/components/repo-header.tsx +0 -4
- package/src/components/ViewPackagePage/components/sidebar-contributors-section.tsx +0 -31
- package/src/components/ViewSnippetHeader.tsx +0 -181
- package/src/components/ui/input-otp.tsx +0 -69
- package/src/pages/package-builds.tsx +0 -33
- package/src/pages/settings.tsx +0 -25
package/dist/index.js
CHANGED
|
@@ -65,7 +65,8 @@ var shippingInfoSchema = z.object({
|
|
|
65
65
|
var accountSchema = z.object({
|
|
66
66
|
account_id: z.string(),
|
|
67
67
|
github_username: z.string(),
|
|
68
|
-
shippingInfo: shippingInfoSchema.optional()
|
|
68
|
+
shippingInfo: shippingInfoSchema.optional(),
|
|
69
|
+
personal_org_id: z.string().optional()
|
|
69
70
|
});
|
|
70
71
|
var orderSchema = z.object({
|
|
71
72
|
order_id: z.string(),
|
|
@@ -203,6 +204,15 @@ var packageReleaseSchema = z.object({
|
|
|
203
204
|
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
204
205
|
circuit_json_build_logs: z.array(z.any()).default([]),
|
|
205
206
|
circuit_json_build_is_stale: z.boolean().default(false),
|
|
207
|
+
// Image Generation Process
|
|
208
|
+
image_generation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
209
|
+
image_generation_in_progress: z.boolean().default(false),
|
|
210
|
+
image_generation_started_at: z.string().datetime().nullable().optional(),
|
|
211
|
+
image_generation_completed_at: z.string().datetime().nullable().optional(),
|
|
212
|
+
image_generation_logs: z.array(z.any()).nullable().default(null),
|
|
213
|
+
image_generation_is_stale: z.boolean().default(false),
|
|
214
|
+
image_generation_error: z.string().nullable().optional(),
|
|
215
|
+
image_generation_error_last_updated_at: z.string().datetime().nullable().optional(),
|
|
206
216
|
// AI Review
|
|
207
217
|
ai_review_text: z.string().nullable().default(null).optional(),
|
|
208
218
|
ai_review_started_at: z.string().datetime().nullable().optional(),
|
|
@@ -260,7 +270,8 @@ var packageSchema = z.object({
|
|
|
260
270
|
ai_usage_instructions: z.string().nullable(),
|
|
261
271
|
latest_package_release_fs_sha: z.string().nullable().default(null),
|
|
262
272
|
default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional(),
|
|
263
|
-
allow_pr_previews: z.boolean().default(false).optional()
|
|
273
|
+
allow_pr_previews: z.boolean().default(false).optional(),
|
|
274
|
+
is_starred: z.boolean().default(false).optional()
|
|
264
275
|
});
|
|
265
276
|
var jlcpcbOrderStateSchema = z.object({
|
|
266
277
|
jlcpcb_order_state_id: z.string(),
|
|
@@ -310,6 +321,11 @@ var packageBuildSchema = z.object({
|
|
|
310
321
|
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
311
322
|
circuit_json_build_logs: z.array(z.any()).default([]),
|
|
312
323
|
circuit_json_build_error: z.string().nullable().optional(),
|
|
324
|
+
image_generation_in_progress: z.boolean().default(false),
|
|
325
|
+
image_generation_started_at: z.string().datetime().nullable().optional(),
|
|
326
|
+
image_generation_completed_at: z.string().datetime().nullable().optional(),
|
|
327
|
+
image_generation_logs: z.array(z.any()).default([]),
|
|
328
|
+
image_generation_error: z.string().nullable().optional(),
|
|
313
329
|
build_in_progress: z.boolean().default(false),
|
|
314
330
|
build_started_at: z.string().datetime().nullable().optional(),
|
|
315
331
|
build_completed_at: z.string().datetime().nullable().optional(),
|
|
@@ -318,6 +334,37 @@ var packageBuildSchema = z.object({
|
|
|
318
334
|
preview_url: z.string().nullable().optional(),
|
|
319
335
|
build_logs: z.string().nullable().optional()
|
|
320
336
|
});
|
|
337
|
+
var orgSchema = z.object({
|
|
338
|
+
org_id: z.string(),
|
|
339
|
+
github_handle: z.string(),
|
|
340
|
+
owner_account_id: z.string(),
|
|
341
|
+
is_personal_org: z.boolean().default(false),
|
|
342
|
+
created_at: z.string().datetime(),
|
|
343
|
+
org_display_name: z.string().optional()
|
|
344
|
+
});
|
|
345
|
+
var orgAccountSchema = z.object({
|
|
346
|
+
org_account_id: z.string(),
|
|
347
|
+
org_id: z.string(),
|
|
348
|
+
account_id: z.string(),
|
|
349
|
+
is_owner: z.boolean().default(false),
|
|
350
|
+
created_at: z.string().datetime()
|
|
351
|
+
});
|
|
352
|
+
var publicOrgSchema = z.object({
|
|
353
|
+
org_id: z.string(),
|
|
354
|
+
//.uuid(),
|
|
355
|
+
owner_account_id: z.string(),
|
|
356
|
+
//.uuid(),
|
|
357
|
+
name: z.string().nullable(),
|
|
358
|
+
member_count: z.number(),
|
|
359
|
+
is_personal_org: z.boolean(),
|
|
360
|
+
display_name: z.string().optional(),
|
|
361
|
+
package_count: z.number(),
|
|
362
|
+
created_at: z.string(),
|
|
363
|
+
user_permissions: z.object({
|
|
364
|
+
can_manage_org: z.boolean().optional(),
|
|
365
|
+
can_manage_package: z.boolean().optional()
|
|
366
|
+
}).optional()
|
|
367
|
+
});
|
|
321
368
|
var databaseSchema = z.object({
|
|
322
369
|
idCounter: z.number().default(0),
|
|
323
370
|
snippets: z.array(snippetSchema).default([]),
|
|
@@ -328,6 +375,8 @@ var databaseSchema = z.object({
|
|
|
328
375
|
accounts: z.array(accountSchema).default([]),
|
|
329
376
|
packages: z.array(packageSchema).default([]),
|
|
330
377
|
orders: z.array(orderSchema).default([]),
|
|
378
|
+
organizations: z.array(orgSchema).default([]),
|
|
379
|
+
orgAccounts: z.array(orgAccountSchema).default([]),
|
|
331
380
|
orderFiles: z.array(orderFileSchema).default([]),
|
|
332
381
|
accountSnippets: z.array(accountSnippetSchema).default([]),
|
|
333
382
|
accountPackages: z.array(accountPackageSchema).default([]),
|
|
@@ -353,7 +402,7 @@ var extractTsciDependencies = (code) => {
|
|
|
353
402
|
}));
|
|
354
403
|
};
|
|
355
404
|
var registryApi = axios.create({
|
|
356
|
-
baseURL: "https://
|
|
405
|
+
baseURL: "https://api.tscircuit.com",
|
|
357
406
|
headers: {
|
|
358
407
|
Accept: "application/json",
|
|
359
408
|
"Content-Type": "application/json"
|
|
@@ -361,7 +410,7 @@ var registryApi = axios.create({
|
|
|
361
410
|
});
|
|
362
411
|
var fetchPackageFromRegistry = async (owner, name) => {
|
|
363
412
|
const fullName = `${owner}/${name}`;
|
|
364
|
-
console.log(`Fetching package ${fullName}...`);
|
|
413
|
+
console.log(`[autoload-dev-pkgs] \u{1F4E6} Fetching package ${fullName}...`);
|
|
365
414
|
let packageData;
|
|
366
415
|
try {
|
|
367
416
|
const response = await registryApi.post("/packages/get", {
|
|
@@ -380,32 +429,39 @@ var fetchPackageFromRegistry = async (owner, name) => {
|
|
|
380
429
|
});
|
|
381
430
|
releaseData = response.data;
|
|
382
431
|
} catch (e) {
|
|
383
|
-
console.error(
|
|
432
|
+
console.error(
|
|
433
|
+
`[autoload-dev-pkgs] \u274C Failed to fetch release data for ${fullName}:`,
|
|
434
|
+
e
|
|
435
|
+
);
|
|
384
436
|
throw e;
|
|
385
437
|
}
|
|
386
438
|
let filesData;
|
|
387
439
|
try {
|
|
388
|
-
const response = await registryApi.post(
|
|
389
|
-
package_release_id
|
|
390
|
-
|
|
440
|
+
const response = await registryApi.post(
|
|
441
|
+
`package_files/list?package_release_id=${releaseData.package_release.package_release_id}`,
|
|
442
|
+
{}
|
|
443
|
+
);
|
|
391
444
|
filesData = response.data;
|
|
392
445
|
for (const file of filesData.package_files) {
|
|
393
446
|
try {
|
|
394
|
-
const fileResponse = await registryApi.post(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
447
|
+
const fileResponse = await registryApi.post(
|
|
448
|
+
`/package_files/get?package_file_id=${file.package_file_id}`,
|
|
449
|
+
{}
|
|
450
|
+
);
|
|
398
451
|
file.content_text = fileResponse.data.package_file.content_text;
|
|
399
452
|
} catch (e) {
|
|
400
453
|
console.error(
|
|
401
|
-
`Failed to fetch content for file ${file.file_path} in package ${fullName}:`,
|
|
454
|
+
`[autoload-dev-pkgs] \u274C Failed to fetch content for file ${file.file_path} in package ${fullName}:`,
|
|
402
455
|
e
|
|
403
456
|
);
|
|
404
457
|
throw e;
|
|
405
458
|
}
|
|
406
459
|
}
|
|
407
460
|
} catch (e) {
|
|
408
|
-
console.error(
|
|
461
|
+
console.error(
|
|
462
|
+
`[autoload-dev-pkgs] \u274C Failed to fetch files data for ${fullName}:`,
|
|
463
|
+
e
|
|
464
|
+
);
|
|
409
465
|
throw e;
|
|
410
466
|
}
|
|
411
467
|
return {
|
|
@@ -423,12 +479,12 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
423
479
|
try {
|
|
424
480
|
result = await fetchPackageFromRegistry(owner, name);
|
|
425
481
|
} catch (e) {
|
|
426
|
-
console.error(
|
|
482
|
+
console.error(`[autoload-dev-pkgs] \u274C Failed to load ${packageKey}`);
|
|
427
483
|
return false;
|
|
428
484
|
}
|
|
429
485
|
const { package: pkg, release, files } = result;
|
|
430
486
|
if (db.getPackageById(pkg.package_id)) {
|
|
431
|
-
console.log(
|
|
487
|
+
console.log(`[autoload-dev-pkgs] \u26A1 Package ${packageKey} already exists`);
|
|
432
488
|
return true;
|
|
433
489
|
}
|
|
434
490
|
db.addPackage({
|
|
@@ -452,7 +508,7 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
452
508
|
});
|
|
453
509
|
}
|
|
454
510
|
loadedPackages.add(packageKey);
|
|
455
|
-
console.log(
|
|
511
|
+
console.log(`[autoload-dev-pkgs] \u{1F4E6} Loaded ${packageKey}`);
|
|
456
512
|
const mainFile = files.find(
|
|
457
513
|
(f) => f.file_path === "index.tsx" || f.file_path === "index.ts"
|
|
458
514
|
);
|
|
@@ -471,7 +527,7 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
471
527
|
if (!depLoaded) {
|
|
472
528
|
allDepsLoaded = false;
|
|
473
529
|
console.warn(
|
|
474
|
-
|
|
530
|
+
`[autoload-dev-pkgs] \u26A0\uFE0F Failed to load dependency ${dep.owner}/${dep.name} for ${packageKey}`
|
|
475
531
|
);
|
|
476
532
|
}
|
|
477
533
|
}
|
|
@@ -484,7 +540,7 @@ var loadAutoloadPackages = async (db) => {
|
|
|
484
540
|
"autoload-packages.json"
|
|
485
541
|
);
|
|
486
542
|
if (!fs.existsSync(autoloadPath)) {
|
|
487
|
-
console.error("No autoload-packages.json found");
|
|
543
|
+
console.error("[autoload-dev-pkgs] \u274C No autoload-packages.json found");
|
|
488
544
|
return;
|
|
489
545
|
}
|
|
490
546
|
const autoloadContent = JSON.parse(fs.readFileSync(autoloadPath, "utf8"));
|
|
@@ -505,10 +561,14 @@ var loadAutoloadPackages = async (db) => {
|
|
|
505
561
|
}
|
|
506
562
|
}
|
|
507
563
|
console.log(`
|
|
508
|
-
Package loading complete:`);
|
|
509
|
-
console.log(
|
|
564
|
+
[autoload-dev-pkgs] \u{1F4CB} Package loading complete:`);
|
|
565
|
+
console.log(
|
|
566
|
+
`[autoload-dev-pkgs] \u2705 Successfully loaded: ${successCount} packages`
|
|
567
|
+
);
|
|
510
568
|
if (failureCount > 0) {
|
|
511
|
-
console.log(
|
|
569
|
+
console.log(
|
|
570
|
+
`[autoload-dev-pkgs] \u274C Failed to load: ${failureCount} packages`
|
|
571
|
+
);
|
|
512
572
|
}
|
|
513
573
|
};
|
|
514
574
|
|
|
@@ -2214,6 +2274,97 @@ export const SquareWaveModule = () => (
|
|
|
2214
2274
|
started_at: null,
|
|
2215
2275
|
completed_at: null
|
|
2216
2276
|
});
|
|
2277
|
+
const testOrg = db.addOrganization({
|
|
2278
|
+
name: "test-organization",
|
|
2279
|
+
owner_account_id: account_id
|
|
2280
|
+
});
|
|
2281
|
+
db.addOrganizationAccount({
|
|
2282
|
+
org_id: testOrg.org_id,
|
|
2283
|
+
account_id,
|
|
2284
|
+
is_owner: true
|
|
2285
|
+
});
|
|
2286
|
+
const { package_release_id: orgPackageReleaseId } = db.addSnippet({
|
|
2287
|
+
name: "test-organization/test-package",
|
|
2288
|
+
unscoped_name: "test-package",
|
|
2289
|
+
owner_name: "test-organization",
|
|
2290
|
+
code: `
|
|
2291
|
+
export const TestComponent = ({ name }: { name: string }) => (
|
|
2292
|
+
<resistor name={name} resistance="10k" />
|
|
2293
|
+
)
|
|
2294
|
+
`.trim(),
|
|
2295
|
+
dts: `
|
|
2296
|
+
declare module "@tsci/test-organization.test-package" {
|
|
2297
|
+
export const TestComponent: ({ name }: {
|
|
2298
|
+
name: string;
|
|
2299
|
+
}) => any;
|
|
2300
|
+
}
|
|
2301
|
+
`.trim(),
|
|
2302
|
+
compiled_js: `
|
|
2303
|
+
"use strict";
|
|
2304
|
+
|
|
2305
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2306
|
+
value: true
|
|
2307
|
+
});
|
|
2308
|
+
exports.TestComponent = void 0;
|
|
2309
|
+
const TestComponent = ({
|
|
2310
|
+
name
|
|
2311
|
+
}) => /*#__PURE__*/React.createElement("resistor", {
|
|
2312
|
+
name: name,
|
|
2313
|
+
resistance: "10k"
|
|
2314
|
+
});
|
|
2315
|
+
exports.TestComponent = TestComponent;
|
|
2316
|
+
`.trim(),
|
|
2317
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2318
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2319
|
+
snippet_type: "package",
|
|
2320
|
+
description: "Test package for organization",
|
|
2321
|
+
circuit_json: [
|
|
2322
|
+
{
|
|
2323
|
+
type: "source_component",
|
|
2324
|
+
source_component_id: "source_component_0",
|
|
2325
|
+
ftype: "simple_resistor",
|
|
2326
|
+
name: "R1",
|
|
2327
|
+
resistance: "10k"
|
|
2328
|
+
}
|
|
2329
|
+
]
|
|
2330
|
+
});
|
|
2331
|
+
const orgPackageBuild = db.addPackageBuild({
|
|
2332
|
+
package_release_id: orgPackageReleaseId,
|
|
2333
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2334
|
+
transpilation_in_progress: false,
|
|
2335
|
+
transpilation_started_at: new Date(Date.now() - 5e3).toISOString(),
|
|
2336
|
+
transpilation_completed_at: new Date(Date.now() - 3e3).toISOString(),
|
|
2337
|
+
transpilation_logs: [
|
|
2338
|
+
"[INFO] Starting transpilation...",
|
|
2339
|
+
"[SUCCESS] Transpilation completed successfully"
|
|
2340
|
+
],
|
|
2341
|
+
transpilation_error: null,
|
|
2342
|
+
circuit_json_build_in_progress: false,
|
|
2343
|
+
circuit_json_build_started_at: new Date(Date.now() - 3e3).toISOString(),
|
|
2344
|
+
circuit_json_build_completed_at: new Date(Date.now() - 1e3).toISOString(),
|
|
2345
|
+
circuit_json_build_logs: [
|
|
2346
|
+
"[INFO] Starting circuit JSON build...",
|
|
2347
|
+
"[SUCCESS] Circuit JSON build completed"
|
|
2348
|
+
],
|
|
2349
|
+
circuit_json_build_error: null,
|
|
2350
|
+
build_in_progress: false,
|
|
2351
|
+
build_started_at: new Date(Date.now() - 1e4).toISOString(),
|
|
2352
|
+
build_completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2353
|
+
build_error: null,
|
|
2354
|
+
build_error_last_updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2355
|
+
preview_url: "http://localhost:3000/preview/org_package_build",
|
|
2356
|
+
build_logs: "Build completed successfully"
|
|
2357
|
+
});
|
|
2358
|
+
const orgRelease = db.getPackageReleaseById(orgPackageReleaseId);
|
|
2359
|
+
db.updatePackageRelease({
|
|
2360
|
+
...orgRelease,
|
|
2361
|
+
latest_package_build_id: orgPackageBuild.package_build_id
|
|
2362
|
+
});
|
|
2363
|
+
db.addOrganization({
|
|
2364
|
+
name: "testuser",
|
|
2365
|
+
owner_account_id: account_id,
|
|
2366
|
+
is_personal_org: true
|
|
2367
|
+
});
|
|
2217
2368
|
};
|
|
2218
2369
|
|
|
2219
2370
|
// fake-snippets-api/lib/package_file/generate-fs-sha.ts
|
|
@@ -3356,10 +3507,10 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3356
3507
|
return updated;
|
|
3357
3508
|
},
|
|
3358
3509
|
addPackageBuild: (packageBuild) => {
|
|
3359
|
-
const newPackageBuild = {
|
|
3510
|
+
const newPackageBuild = packageBuildSchema.parse({
|
|
3360
3511
|
package_build_id: crypto.randomUUID(),
|
|
3361
3512
|
...packageBuild
|
|
3362
|
-
};
|
|
3513
|
+
});
|
|
3363
3514
|
set((state) => ({
|
|
3364
3515
|
packageBuilds: [...state.packageBuilds, newPackageBuild],
|
|
3365
3516
|
// Automatically update the package release to reference this as the latest build
|
|
@@ -3397,6 +3548,156 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3397
3548
|
return { ...state, packageBuilds };
|
|
3398
3549
|
});
|
|
3399
3550
|
return updated;
|
|
3551
|
+
},
|
|
3552
|
+
addOrganization: (organization) => {
|
|
3553
|
+
const newOrganization = {
|
|
3554
|
+
org_id: organization.org_id || `org_${get().idCounter + 1}`,
|
|
3555
|
+
github_handle: organization.name,
|
|
3556
|
+
is_personal_org: organization.is_personal_org || false,
|
|
3557
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3558
|
+
...organization
|
|
3559
|
+
};
|
|
3560
|
+
set((state) => ({
|
|
3561
|
+
idCounter: state.idCounter + 1,
|
|
3562
|
+
organizations: [...state.organizations, newOrganization],
|
|
3563
|
+
// Add the creator as a member of the new org by setting their personal_org_id
|
|
3564
|
+
accounts: state.accounts.map(
|
|
3565
|
+
(account) => account.account_id === organization.owner_account_id ? { ...account, personal_org_id: newOrganization.org_id } : account
|
|
3566
|
+
)
|
|
3567
|
+
}));
|
|
3568
|
+
return newOrganization;
|
|
3569
|
+
},
|
|
3570
|
+
getOrgs: (filters, auth) => {
|
|
3571
|
+
let orgs = get().organizations;
|
|
3572
|
+
if (filters?.owner_account_id) {
|
|
3573
|
+
orgs = orgs.filter(
|
|
3574
|
+
(org) => org.owner_account_id === filters.owner_account_id
|
|
3575
|
+
);
|
|
3576
|
+
}
|
|
3577
|
+
if (filters?.github_handle) {
|
|
3578
|
+
orgs = orgs.filter((org) => {
|
|
3579
|
+
const account = get().accounts.find(
|
|
3580
|
+
(account2) => account2.account_id === org.owner_account_id
|
|
3581
|
+
);
|
|
3582
|
+
return account?.github_username === filters.github_handle;
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3585
|
+
if (filters?.name) {
|
|
3586
|
+
orgs = orgs.filter((org) => org.github_handle === filters.name);
|
|
3587
|
+
}
|
|
3588
|
+
return orgs.map((org) => {
|
|
3589
|
+
const member_count = get().accounts.filter(
|
|
3590
|
+
(account) => account.personal_org_id === org.org_id
|
|
3591
|
+
).length;
|
|
3592
|
+
const package_count = get().packages.filter(
|
|
3593
|
+
(pkg) => pkg.owner_org_id === org.org_id
|
|
3594
|
+
).length;
|
|
3595
|
+
const can_manage_org = auth ? org.owner_account_id === auth.account_id : false;
|
|
3596
|
+
return {
|
|
3597
|
+
...org,
|
|
3598
|
+
member_count,
|
|
3599
|
+
package_count,
|
|
3600
|
+
can_manage_org
|
|
3601
|
+
};
|
|
3602
|
+
});
|
|
3603
|
+
},
|
|
3604
|
+
getOrg: (filters, auth) => {
|
|
3605
|
+
let orgs = get().organizations;
|
|
3606
|
+
if (filters?.org_id) {
|
|
3607
|
+
orgs = orgs.filter((org2) => org2.org_id === filters.org_id);
|
|
3608
|
+
}
|
|
3609
|
+
if (filters?.org_name) {
|
|
3610
|
+
orgs = orgs.filter((org2) => org2.github_handle === filters.org_name);
|
|
3611
|
+
}
|
|
3612
|
+
if (filters?.github_handle) {
|
|
3613
|
+
orgs = orgs.filter((org2) => org2.github_handle === filters.github_handle);
|
|
3614
|
+
}
|
|
3615
|
+
if (orgs.length === 0) {
|
|
3616
|
+
return null;
|
|
3617
|
+
}
|
|
3618
|
+
const org = orgs[0];
|
|
3619
|
+
const member_count = get().accounts.filter(
|
|
3620
|
+
(account) => account.personal_org_id === org.org_id
|
|
3621
|
+
).length;
|
|
3622
|
+
const package_count = get().packages.filter(
|
|
3623
|
+
(pkg) => pkg.owner_org_id === org.org_id
|
|
3624
|
+
).length;
|
|
3625
|
+
const can_manage_org = auth ? org.owner_account_id === auth.account_id : false;
|
|
3626
|
+
return {
|
|
3627
|
+
...org,
|
|
3628
|
+
member_count,
|
|
3629
|
+
package_count,
|
|
3630
|
+
can_manage_org
|
|
3631
|
+
};
|
|
3632
|
+
},
|
|
3633
|
+
addOrganizationAccount: (organizationAccount) => {
|
|
3634
|
+
const newOrgAccount = {
|
|
3635
|
+
org_account_id: `org_account_${get().idCounter + 1}`,
|
|
3636
|
+
org_id: organizationAccount.org_id,
|
|
3637
|
+
account_id: organizationAccount.account_id,
|
|
3638
|
+
is_owner: organizationAccount.is_owner || false,
|
|
3639
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3640
|
+
};
|
|
3641
|
+
set((state) => ({
|
|
3642
|
+
orgAccounts: [...state.orgAccounts, newOrgAccount],
|
|
3643
|
+
idCounter: state.idCounter + 1
|
|
3644
|
+
}));
|
|
3645
|
+
return newOrgAccount;
|
|
3646
|
+
},
|
|
3647
|
+
getOrganizationAccount: (filters) => {
|
|
3648
|
+
const state = get();
|
|
3649
|
+
return state.orgAccounts.find((orgAccount) => {
|
|
3650
|
+
if (filters.org_id && orgAccount.org_id !== filters.org_id) {
|
|
3651
|
+
return false;
|
|
3652
|
+
}
|
|
3653
|
+
if (filters.account_id && orgAccount.account_id !== filters.account_id) {
|
|
3654
|
+
return false;
|
|
3655
|
+
}
|
|
3656
|
+
return true;
|
|
3657
|
+
});
|
|
3658
|
+
},
|
|
3659
|
+
getOrganizationAccounts: (filters) => {
|
|
3660
|
+
const state = get();
|
|
3661
|
+
return state.orgAccounts.filter((orgAccount) => {
|
|
3662
|
+
if (filters?.org_id && orgAccount.org_id !== filters.org_id) {
|
|
3663
|
+
return false;
|
|
3664
|
+
}
|
|
3665
|
+
if (filters?.account_id && orgAccount.account_id !== filters.account_id) {
|
|
3666
|
+
return false;
|
|
3667
|
+
}
|
|
3668
|
+
return true;
|
|
3669
|
+
});
|
|
3670
|
+
},
|
|
3671
|
+
removeOrganizationAccount: (filters) => {
|
|
3672
|
+
let removed = false;
|
|
3673
|
+
set((state) => {
|
|
3674
|
+
const index = state.orgAccounts.findIndex(
|
|
3675
|
+
(orgAccount) => orgAccount.org_id === filters.org_id && orgAccount.account_id === filters.account_id
|
|
3676
|
+
);
|
|
3677
|
+
if (index !== -1) {
|
|
3678
|
+
state.orgAccounts.splice(index, 1);
|
|
3679
|
+
removed = true;
|
|
3680
|
+
}
|
|
3681
|
+
return state;
|
|
3682
|
+
});
|
|
3683
|
+
return removed;
|
|
3684
|
+
},
|
|
3685
|
+
updateOrganization: (orgId, updates) => {
|
|
3686
|
+
let updatedOrg;
|
|
3687
|
+
set((state) => {
|
|
3688
|
+
const orgIndex = state.organizations.findIndex(
|
|
3689
|
+
(org) => org.org_id === orgId
|
|
3690
|
+
);
|
|
3691
|
+
if (orgIndex === -1) return state;
|
|
3692
|
+
const updatedOrganizations = [...state.organizations];
|
|
3693
|
+
updatedOrganizations[orgIndex] = {
|
|
3694
|
+
...updatedOrganizations[orgIndex],
|
|
3695
|
+
...updates
|
|
3696
|
+
};
|
|
3697
|
+
updatedOrg = updatedOrganizations[orgIndex];
|
|
3698
|
+
return { ...state, organizations: updatedOrganizations };
|
|
3699
|
+
});
|
|
3700
|
+
return updatedOrg;
|
|
3400
3701
|
}
|
|
3401
3702
|
}));
|
|
3402
3703
|
|