@tscircuit/fake-snippets 0.0.109 → 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 +349 -453
- package/bunfig.toml +2 -1
- package/dist/bundle.js +1253 -624
- package/dist/index.d.ts +291 -4
- package/dist/index.js +323 -23
- package/dist/schema.d.ts +274 -1
- package/dist/schema.js +52 -1
- 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 +61 -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 +24 -20
- package/renovate.json +1 -1
- package/scripts/generate-sitemap.ts +1 -1
- package/src/App.tsx +29 -8
- 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 +3 -4
- package/src/components/FileSidebar.tsx +11 -17
- package/src/components/Footer.tsx +8 -9
- 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 +43 -15
- package/src/components/NotFound.tsx +5 -5
- package/src/components/PackageBreadcrumb.tsx +6 -12
- 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/build-status.tsx +1 -1
- package/src/components/ViewPackagePage/components/important-files-view.tsx +105 -34
- package/src/components/ViewPackagePage/components/main-content-header.tsx +10 -6
- package/src/components/ViewPackagePage/components/main-content-view-selector.tsx +1 -1
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +54 -19
- package/src/components/ViewPackagePage/components/package-header.tsx +25 -33
- package/src/components/ViewPackagePage/components/preview-image-squares.tsx +11 -18
- package/src/components/ViewPackagePage/components/repo-page-content.tsx +12 -5
- 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/tab-views/pcb-view.tsx +1 -2
- package/src/components/ViewPackagePage/components/tab-views/schematic-view.tsx +2 -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 +15 -12
- package/src/components/package-port/CodeEditor.tsx +4 -30
- package/src/components/package-port/CodeEditorHeader.tsx +123 -61
- 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 +23 -11
- 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-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 +51 -22
- package/src/hooks/useOptimizedPackageFilesLoader.ts +11 -24
- package/src/hooks/usePackageFilesLoader.ts +2 -2
- package/src/hooks/useUpdatePackageFilesMutation.ts +13 -1
- package/src/lib/download-fns/download-gltf-from-circuit-json.ts +1 -1
- 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 +2 -1
- package/src/main.tsx +2 -1
- 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 -6
- 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 +75 -145
- 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 +7 -13
- package/vite.config.ts +9 -0
- package/fake-snippets-api/routes/api/autocomplete/create_autocomplete.ts +0 -133
- package/src/components/JLCPCBImportDialog.tsx +0 -280
- package/src/components/PackageBuildsPage/LogContent.tsx +0 -72
- package/src/components/PackageBuildsPage/PackageBuildDetailsPage.tsx +0 -113
- package/src/components/PackageBuildsPage/build-preview-content.tsx +0 -56
- 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/pages/package-builds.tsx +0 -33
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(),
|
|
@@ -311,6 +321,11 @@ var packageBuildSchema = z.object({
|
|
|
311
321
|
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
312
322
|
circuit_json_build_logs: z.array(z.any()).default([]),
|
|
313
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(),
|
|
314
329
|
build_in_progress: z.boolean().default(false),
|
|
315
330
|
build_started_at: z.string().datetime().nullable().optional(),
|
|
316
331
|
build_completed_at: z.string().datetime().nullable().optional(),
|
|
@@ -319,6 +334,37 @@ var packageBuildSchema = z.object({
|
|
|
319
334
|
preview_url: z.string().nullable().optional(),
|
|
320
335
|
build_logs: z.string().nullable().optional()
|
|
321
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
|
+
});
|
|
322
368
|
var databaseSchema = z.object({
|
|
323
369
|
idCounter: z.number().default(0),
|
|
324
370
|
snippets: z.array(snippetSchema).default([]),
|
|
@@ -329,6 +375,8 @@ var databaseSchema = z.object({
|
|
|
329
375
|
accounts: z.array(accountSchema).default([]),
|
|
330
376
|
packages: z.array(packageSchema).default([]),
|
|
331
377
|
orders: z.array(orderSchema).default([]),
|
|
378
|
+
organizations: z.array(orgSchema).default([]),
|
|
379
|
+
orgAccounts: z.array(orgAccountSchema).default([]),
|
|
332
380
|
orderFiles: z.array(orderFileSchema).default([]),
|
|
333
381
|
accountSnippets: z.array(accountSnippetSchema).default([]),
|
|
334
382
|
accountPackages: z.array(accountPackageSchema).default([]),
|
|
@@ -354,7 +402,7 @@ var extractTsciDependencies = (code) => {
|
|
|
354
402
|
}));
|
|
355
403
|
};
|
|
356
404
|
var registryApi = axios.create({
|
|
357
|
-
baseURL: "https://
|
|
405
|
+
baseURL: "https://api.tscircuit.com",
|
|
358
406
|
headers: {
|
|
359
407
|
Accept: "application/json",
|
|
360
408
|
"Content-Type": "application/json"
|
|
@@ -362,7 +410,7 @@ var registryApi = axios.create({
|
|
|
362
410
|
});
|
|
363
411
|
var fetchPackageFromRegistry = async (owner, name) => {
|
|
364
412
|
const fullName = `${owner}/${name}`;
|
|
365
|
-
console.log(`Fetching package ${fullName}...`);
|
|
413
|
+
console.log(`[autoload-dev-pkgs] \u{1F4E6} Fetching package ${fullName}...`);
|
|
366
414
|
let packageData;
|
|
367
415
|
try {
|
|
368
416
|
const response = await registryApi.post("/packages/get", {
|
|
@@ -381,32 +429,39 @@ var fetchPackageFromRegistry = async (owner, name) => {
|
|
|
381
429
|
});
|
|
382
430
|
releaseData = response.data;
|
|
383
431
|
} catch (e) {
|
|
384
|
-
console.error(
|
|
432
|
+
console.error(
|
|
433
|
+
`[autoload-dev-pkgs] \u274C Failed to fetch release data for ${fullName}:`,
|
|
434
|
+
e
|
|
435
|
+
);
|
|
385
436
|
throw e;
|
|
386
437
|
}
|
|
387
438
|
let filesData;
|
|
388
439
|
try {
|
|
389
|
-
const response = await registryApi.post(
|
|
390
|
-
package_release_id
|
|
391
|
-
|
|
440
|
+
const response = await registryApi.post(
|
|
441
|
+
`package_files/list?package_release_id=${releaseData.package_release.package_release_id}`,
|
|
442
|
+
{}
|
|
443
|
+
);
|
|
392
444
|
filesData = response.data;
|
|
393
445
|
for (const file of filesData.package_files) {
|
|
394
446
|
try {
|
|
395
|
-
const fileResponse = await registryApi.post(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
447
|
+
const fileResponse = await registryApi.post(
|
|
448
|
+
`/package_files/get?package_file_id=${file.package_file_id}`,
|
|
449
|
+
{}
|
|
450
|
+
);
|
|
399
451
|
file.content_text = fileResponse.data.package_file.content_text;
|
|
400
452
|
} catch (e) {
|
|
401
453
|
console.error(
|
|
402
|
-
`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}:`,
|
|
403
455
|
e
|
|
404
456
|
);
|
|
405
457
|
throw e;
|
|
406
458
|
}
|
|
407
459
|
}
|
|
408
460
|
} catch (e) {
|
|
409
|
-
console.error(
|
|
461
|
+
console.error(
|
|
462
|
+
`[autoload-dev-pkgs] \u274C Failed to fetch files data for ${fullName}:`,
|
|
463
|
+
e
|
|
464
|
+
);
|
|
410
465
|
throw e;
|
|
411
466
|
}
|
|
412
467
|
return {
|
|
@@ -424,12 +479,12 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
424
479
|
try {
|
|
425
480
|
result = await fetchPackageFromRegistry(owner, name);
|
|
426
481
|
} catch (e) {
|
|
427
|
-
console.error(
|
|
482
|
+
console.error(`[autoload-dev-pkgs] \u274C Failed to load ${packageKey}`);
|
|
428
483
|
return false;
|
|
429
484
|
}
|
|
430
485
|
const { package: pkg, release, files } = result;
|
|
431
486
|
if (db.getPackageById(pkg.package_id)) {
|
|
432
|
-
console.log(
|
|
487
|
+
console.log(`[autoload-dev-pkgs] \u26A1 Package ${packageKey} already exists`);
|
|
433
488
|
return true;
|
|
434
489
|
}
|
|
435
490
|
db.addPackage({
|
|
@@ -453,7 +508,7 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
453
508
|
});
|
|
454
509
|
}
|
|
455
510
|
loadedPackages.add(packageKey);
|
|
456
|
-
console.log(
|
|
511
|
+
console.log(`[autoload-dev-pkgs] \u{1F4E6} Loaded ${packageKey}`);
|
|
457
512
|
const mainFile = files.find(
|
|
458
513
|
(f) => f.file_path === "index.tsx" || f.file_path === "index.ts"
|
|
459
514
|
);
|
|
@@ -472,7 +527,7 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
472
527
|
if (!depLoaded) {
|
|
473
528
|
allDepsLoaded = false;
|
|
474
529
|
console.warn(
|
|
475
|
-
|
|
530
|
+
`[autoload-dev-pkgs] \u26A0\uFE0F Failed to load dependency ${dep.owner}/${dep.name} for ${packageKey}`
|
|
476
531
|
);
|
|
477
532
|
}
|
|
478
533
|
}
|
|
@@ -485,7 +540,7 @@ var loadAutoloadPackages = async (db) => {
|
|
|
485
540
|
"autoload-packages.json"
|
|
486
541
|
);
|
|
487
542
|
if (!fs.existsSync(autoloadPath)) {
|
|
488
|
-
console.error("No autoload-packages.json found");
|
|
543
|
+
console.error("[autoload-dev-pkgs] \u274C No autoload-packages.json found");
|
|
489
544
|
return;
|
|
490
545
|
}
|
|
491
546
|
const autoloadContent = JSON.parse(fs.readFileSync(autoloadPath, "utf8"));
|
|
@@ -506,10 +561,14 @@ var loadAutoloadPackages = async (db) => {
|
|
|
506
561
|
}
|
|
507
562
|
}
|
|
508
563
|
console.log(`
|
|
509
|
-
Package loading complete:`);
|
|
510
|
-
console.log(
|
|
564
|
+
[autoload-dev-pkgs] \u{1F4CB} Package loading complete:`);
|
|
565
|
+
console.log(
|
|
566
|
+
`[autoload-dev-pkgs] \u2705 Successfully loaded: ${successCount} packages`
|
|
567
|
+
);
|
|
511
568
|
if (failureCount > 0) {
|
|
512
|
-
console.log(
|
|
569
|
+
console.log(
|
|
570
|
+
`[autoload-dev-pkgs] \u274C Failed to load: ${failureCount} packages`
|
|
571
|
+
);
|
|
513
572
|
}
|
|
514
573
|
};
|
|
515
574
|
|
|
@@ -2215,6 +2274,97 @@ export const SquareWaveModule = () => (
|
|
|
2215
2274
|
started_at: null,
|
|
2216
2275
|
completed_at: null
|
|
2217
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
|
+
});
|
|
2218
2368
|
};
|
|
2219
2369
|
|
|
2220
2370
|
// fake-snippets-api/lib/package_file/generate-fs-sha.ts
|
|
@@ -3357,10 +3507,10 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3357
3507
|
return updated;
|
|
3358
3508
|
},
|
|
3359
3509
|
addPackageBuild: (packageBuild) => {
|
|
3360
|
-
const newPackageBuild = {
|
|
3510
|
+
const newPackageBuild = packageBuildSchema.parse({
|
|
3361
3511
|
package_build_id: crypto.randomUUID(),
|
|
3362
3512
|
...packageBuild
|
|
3363
|
-
};
|
|
3513
|
+
});
|
|
3364
3514
|
set((state) => ({
|
|
3365
3515
|
packageBuilds: [...state.packageBuilds, newPackageBuild],
|
|
3366
3516
|
// Automatically update the package release to reference this as the latest build
|
|
@@ -3398,6 +3548,156 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3398
3548
|
return { ...state, packageBuilds };
|
|
3399
3549
|
});
|
|
3400
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;
|
|
3401
3701
|
}
|
|
3402
3702
|
}));
|
|
3403
3703
|
|