@tscircuit/fake-snippets 0.0.110 → 0.0.112

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.
Files changed (48) hide show
  1. package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +1 -0
  2. package/bun-tests/fake-snippets-api/routes/orgs/create.test.ts +2 -2
  3. package/bun-tests/fake-snippets-api/routes/orgs/get.test.ts +3 -2
  4. package/bun-tests/fake-snippets-api/routes/orgs/update.test.ts +52 -0
  5. package/bun-tests/fake-snippets-api/routes/packages/list_latest.test.ts +4 -4
  6. package/bun.lock +19 -7
  7. package/dist/bundle.js +85 -36
  8. package/dist/index.d.ts +33 -13
  9. package/dist/index.js +13 -6
  10. package/dist/schema.d.ts +27 -8
  11. package/dist/schema.js +6 -3
  12. package/fake-snippets-api/lib/db/db-client.ts +7 -3
  13. package/fake-snippets-api/lib/db/schema.ts +4 -2
  14. package/fake-snippets-api/lib/db/seed.ts +2 -0
  15. package/fake-snippets-api/lib/middleware/with-session-auth.ts +59 -7
  16. package/fake-snippets-api/lib/public-mapping/public-map-org.ts +4 -2
  17. package/fake-snippets-api/routes/api/orgs/create.ts +4 -2
  18. package/fake-snippets-api/routes/api/orgs/get.ts +1 -1
  19. package/fake-snippets-api/routes/api/orgs/list_members.ts +1 -8
  20. package/fake-snippets-api/routes/api/orgs/update.ts +31 -6
  21. package/fake-snippets-api/routes/api/packages/create.ts +5 -2
  22. package/package.json +7 -5
  23. package/src/App.tsx +3 -5
  24. package/src/components/CmdKMenu.tsx +1 -1
  25. package/src/components/DownloadButtonAndMenu.tsx +14 -1
  26. package/src/components/GithubAvatarWithFallback.tsx +33 -0
  27. package/src/components/PackageCard.tsx +2 -5
  28. package/src/components/PackagesList.tsx +2 -2
  29. package/src/components/ProfileRouter.tsx +2 -2
  30. package/src/components/SentryNotFoundReporter.tsx +44 -0
  31. package/src/components/TrendingPackagesCarousel.tsx +2 -2
  32. package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +2 -2
  33. package/src/components/organization/OrganizationCard.tsx +15 -18
  34. package/src/components/organization/OrganizationHeader.tsx +14 -32
  35. package/src/components/organization/OrganizationMembers.tsx +1 -3
  36. package/src/components/preview/ConnectedPackagesList.tsx +1 -1
  37. package/src/hooks/use-hydration.ts +30 -0
  38. package/src/hooks/use-org-by-github-handle.ts +1 -3
  39. package/src/hooks/use-org-by-org-name.ts +24 -0
  40. package/src/lib/download-fns/download-kicad-files.ts +10 -0
  41. package/src/lib/download-fns/download-step.ts +12 -0
  42. package/src/pages/create-organization.tsx +1 -0
  43. package/src/pages/editor.tsx +1 -3
  44. package/src/pages/organization-settings.tsx +4 -1
  45. package/src/pages/search.tsx +7 -2
  46. package/src/pages/user-profile.tsx +1 -1
  47. package/src/pages/user-settings.tsx +161 -0
  48. package/src/pages/view-package.tsx +23 -3
package/dist/index.d.ts CHANGED
@@ -151,9 +151,11 @@ declare const accountSchema: z.ZodObject<{
151
151
  apartment?: string | undefined;
152
152
  }>>;
153
153
  personal_org_id: z.ZodOptional<z.ZodString>;
154
+ is_tscircuit_staff: z.ZodDefault<z.ZodBoolean>;
154
155
  }, "strip", z.ZodTypeAny, {
155
156
  account_id: string;
156
157
  github_username: string;
158
+ is_tscircuit_staff: boolean;
157
159
  shippingInfo?: {
158
160
  firstName: string;
159
161
  lastName: string;
@@ -183,6 +185,7 @@ declare const accountSchema: z.ZodObject<{
183
185
  apartment?: string | undefined;
184
186
  } | undefined;
185
187
  personal_org_id?: string | undefined;
188
+ is_tscircuit_staff?: boolean | undefined;
186
189
  }>;
187
190
  type Account = z.infer<typeof accountSchema>;
188
191
  declare const orderSchema: z.ZodObject<{
@@ -945,23 +948,26 @@ declare const packageBuildSchema: z.ZodObject<{
945
948
  type PackageBuild = z.infer<typeof packageBuildSchema>;
946
949
  declare const orgSchema: z.ZodObject<{
947
950
  org_id: z.ZodString;
948
- github_handle: z.ZodString;
951
+ github_handle: z.ZodOptional<z.ZodString>;
949
952
  owner_account_id: z.ZodString;
950
953
  is_personal_org: z.ZodDefault<z.ZodBoolean>;
951
954
  created_at: z.ZodString;
952
955
  org_display_name: z.ZodOptional<z.ZodString>;
956
+ org_name: z.ZodString;
953
957
  }, "strip", z.ZodTypeAny, {
954
958
  created_at: string;
955
959
  org_id: string;
956
- github_handle: string;
957
960
  owner_account_id: string;
958
961
  is_personal_org: boolean;
962
+ org_name: string;
963
+ github_handle?: string | undefined;
959
964
  org_display_name?: string | undefined;
960
965
  }, {
961
966
  created_at: string;
962
967
  org_id: string;
963
- github_handle: string;
964
968
  owner_account_id: string;
969
+ org_name: string;
970
+ github_handle?: string | undefined;
965
971
  is_personal_org?: boolean | undefined;
966
972
  org_display_name?: string | undefined;
967
973
  }>;
@@ -1091,6 +1097,7 @@ declare const createDatabase: ({ seed }?: {
1091
1097
  accounts: {
1092
1098
  account_id: string;
1093
1099
  github_username: string;
1100
+ is_tscircuit_staff: boolean;
1094
1101
  shippingInfo?: {
1095
1102
  firstName: string;
1096
1103
  lastName: string;
@@ -1158,9 +1165,10 @@ declare const createDatabase: ({ seed }?: {
1158
1165
  organizations: {
1159
1166
  created_at: string;
1160
1167
  org_id: string;
1161
- github_handle: string;
1162
1168
  owner_account_id: string;
1163
1169
  is_personal_org: boolean;
1170
+ org_name: string;
1171
+ github_handle?: string | undefined;
1164
1172
  org_display_name?: string | undefined;
1165
1173
  }[];
1166
1174
  orgAccounts: {
@@ -1338,7 +1346,8 @@ declare const createDatabase: ({ seed }?: {
1338
1346
  updateJlcpcbOrderState: (orderId: string, updates: Partial<JlcpcbOrderState>) => void;
1339
1347
  addOrderFile: (orderFile: Omit<OrderFile, "order_file_id">) => OrderFile;
1340
1348
  getOrderFileById: (orderFileId: string) => OrderFile | undefined;
1341
- addAccount: (account: Omit<Account, "account_id"> & Partial<Pick<Account, "account_id">>) => {
1349
+ addAccount: (account: Omit<Account, "account_id" | "is_tscircuit_staff"> & Partial<Pick<Account, "account_id" | "is_tscircuit_staff">>) => {
1350
+ is_tscircuit_staff: boolean;
1342
1351
  github_username: string;
1343
1352
  shippingInfo?: {
1344
1353
  firstName: string;
@@ -1430,12 +1439,14 @@ declare const createDatabase: ({ seed }?: {
1430
1439
  org_id?: string;
1431
1440
  is_personal_org?: boolean;
1432
1441
  owner_account_id: string;
1442
+ github_handle?: string;
1433
1443
  }) => {
1434
1444
  created_at: string;
1435
1445
  org_id: string;
1436
- github_handle: string;
1437
1446
  owner_account_id: string;
1438
1447
  is_personal_org: boolean;
1448
+ org_name: string;
1449
+ github_handle?: string | undefined;
1439
1450
  org_display_name?: string | undefined;
1440
1451
  };
1441
1452
  getOrgs: (filters?: {
@@ -1450,9 +1461,10 @@ declare const createDatabase: ({ seed }?: {
1450
1461
  can_manage_org: boolean;
1451
1462
  created_at: string;
1452
1463
  org_id: string;
1453
- github_handle: string;
1454
1464
  owner_account_id: string;
1455
1465
  is_personal_org: boolean;
1466
+ org_name: string;
1467
+ github_handle?: string | undefined;
1456
1468
  org_display_name?: string | undefined;
1457
1469
  }[];
1458
1470
  getOrg: (filters: {
@@ -1467,9 +1479,10 @@ declare const createDatabase: ({ seed }?: {
1467
1479
  can_manage_org: boolean;
1468
1480
  created_at: string;
1469
1481
  org_id: string;
1470
- github_handle: string;
1471
1482
  owner_account_id: string;
1472
1483
  is_personal_org: boolean;
1484
+ org_name: string;
1485
+ github_handle?: string | undefined;
1473
1486
  org_display_name?: string | undefined;
1474
1487
  } | null;
1475
1488
  addOrganizationAccount: (organizationAccount: {
@@ -1598,6 +1611,7 @@ declare const createDatabase: ({ seed }?: {
1598
1611
  accounts: {
1599
1612
  account_id: string;
1600
1613
  github_username: string;
1614
+ is_tscircuit_staff: boolean;
1601
1615
  shippingInfo?: {
1602
1616
  firstName: string;
1603
1617
  lastName: string;
@@ -1665,9 +1679,10 @@ declare const createDatabase: ({ seed }?: {
1665
1679
  organizations: {
1666
1680
  created_at: string;
1667
1681
  org_id: string;
1668
- github_handle: string;
1669
1682
  owner_account_id: string;
1670
1683
  is_personal_org: boolean;
1684
+ org_name: string;
1685
+ github_handle?: string | undefined;
1671
1686
  org_display_name?: string | undefined;
1672
1687
  }[];
1673
1688
  orgAccounts: {
@@ -1845,7 +1860,8 @@ declare const createDatabase: ({ seed }?: {
1845
1860
  updateJlcpcbOrderState: (orderId: string, updates: Partial<JlcpcbOrderState>) => void;
1846
1861
  addOrderFile: (orderFile: Omit<OrderFile, "order_file_id">) => OrderFile;
1847
1862
  getOrderFileById: (orderFileId: string) => OrderFile | undefined;
1848
- addAccount: (account: Omit<Account, "account_id"> & Partial<Pick<Account, "account_id">>) => {
1863
+ addAccount: (account: Omit<Account, "account_id" | "is_tscircuit_staff"> & Partial<Pick<Account, "account_id" | "is_tscircuit_staff">>) => {
1864
+ is_tscircuit_staff: boolean;
1849
1865
  github_username: string;
1850
1866
  shippingInfo?: {
1851
1867
  firstName: string;
@@ -1937,12 +1953,14 @@ declare const createDatabase: ({ seed }?: {
1937
1953
  org_id?: string;
1938
1954
  is_personal_org?: boolean;
1939
1955
  owner_account_id: string;
1956
+ github_handle?: string;
1940
1957
  }) => {
1941
1958
  created_at: string;
1942
1959
  org_id: string;
1943
- github_handle: string;
1944
1960
  owner_account_id: string;
1945
1961
  is_personal_org: boolean;
1962
+ org_name: string;
1963
+ github_handle?: string | undefined;
1946
1964
  org_display_name?: string | undefined;
1947
1965
  };
1948
1966
  getOrgs: (filters?: {
@@ -1957,9 +1975,10 @@ declare const createDatabase: ({ seed }?: {
1957
1975
  can_manage_org: boolean;
1958
1976
  created_at: string;
1959
1977
  org_id: string;
1960
- github_handle: string;
1961
1978
  owner_account_id: string;
1962
1979
  is_personal_org: boolean;
1980
+ org_name: string;
1981
+ github_handle?: string | undefined;
1963
1982
  org_display_name?: string | undefined;
1964
1983
  }[];
1965
1984
  getOrg: (filters: {
@@ -1974,9 +1993,10 @@ declare const createDatabase: ({ seed }?: {
1974
1993
  can_manage_org: boolean;
1975
1994
  created_at: string;
1976
1995
  org_id: string;
1977
- github_handle: string;
1978
1996
  owner_account_id: string;
1979
1997
  is_personal_org: boolean;
1998
+ org_name: string;
1999
+ github_handle?: string | undefined;
1980
2000
  org_display_name?: string | undefined;
1981
2001
  } | null;
1982
2002
  addOrganizationAccount: (organizationAccount: {
package/dist/index.js CHANGED
@@ -66,7 +66,8 @@ var accountSchema = z.object({
66
66
  account_id: z.string(),
67
67
  github_username: z.string(),
68
68
  shippingInfo: shippingInfoSchema.optional(),
69
- personal_org_id: z.string().optional()
69
+ personal_org_id: z.string().optional(),
70
+ is_tscircuit_staff: z.boolean().default(false)
70
71
  });
71
72
  var orderSchema = z.object({
72
73
  order_id: z.string(),
@@ -336,11 +337,12 @@ var packageBuildSchema = z.object({
336
337
  });
337
338
  var orgSchema = z.object({
338
339
  org_id: z.string(),
339
- github_handle: z.string(),
340
+ github_handle: z.string().optional(),
340
341
  owner_account_id: z.string(),
341
342
  is_personal_org: z.boolean().default(false),
342
343
  created_at: z.string().datetime(),
343
- org_display_name: z.string().optional()
344
+ org_display_name: z.string().optional(),
345
+ org_name: z.string()
344
346
  });
345
347
  var orgAccountSchema = z.object({
346
348
  org_account_id: z.string(),
@@ -359,6 +361,7 @@ var publicOrgSchema = z.object({
359
361
  is_personal_org: z.boolean(),
360
362
  display_name: z.string().optional(),
361
363
  package_count: z.number(),
364
+ github_handle: z.string().optional(),
362
365
  created_at: z.string(),
363
366
  user_permissions: z.object({
364
367
  can_manage_org: z.boolean().optional(),
@@ -2276,6 +2279,7 @@ export const SquareWaveModule = () => (
2276
2279
  });
2277
2280
  const testOrg = db.addOrganization({
2278
2281
  name: "test-organization",
2282
+ github_handle: "tscircuit",
2279
2283
  owner_account_id: account_id
2280
2284
  });
2281
2285
  db.addOrganizationAccount({
@@ -2363,6 +2367,7 @@ exports.TestComponent = TestComponent;
2363
2367
  db.addOrganization({
2364
2368
  name: "testuser",
2365
2369
  owner_account_id: account_id,
2370
+ github_handle: "tscircuit",
2366
2371
  is_personal_org: true
2367
2372
  });
2368
2373
  };
@@ -2503,7 +2508,8 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
2503
2508
  addAccount: (account) => {
2504
2509
  const newAccount = {
2505
2510
  account_id: account.account_id || `account_${get().idCounter + 1}`,
2506
- ...account
2511
+ ...account,
2512
+ is_tscircuit_staff: Boolean(account.is_tscircuit_staff)
2507
2513
  };
2508
2514
  set((state) => {
2509
2515
  return {
@@ -3551,8 +3557,9 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
3551
3557
  },
3552
3558
  addOrganization: (organization) => {
3553
3559
  const newOrganization = {
3560
+ org_name: organization.name,
3554
3561
  org_id: organization.org_id || `org_${get().idCounter + 1}`,
3555
- github_handle: organization.name,
3562
+ github_handle: organization.github_handle,
3556
3563
  is_personal_org: organization.is_personal_org || false,
3557
3564
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
3558
3565
  ...organization
@@ -3607,7 +3614,7 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
3607
3614
  orgs = orgs.filter((org2) => org2.org_id === filters.org_id);
3608
3615
  }
3609
3616
  if (filters?.org_name) {
3610
- orgs = orgs.filter((org2) => org2.github_handle === filters.org_name);
3617
+ orgs = orgs.filter((org2) => org2.org_name === filters.org_name);
3611
3618
  }
3612
3619
  if (filters?.github_handle) {
3613
3620
  orgs = orgs.filter((org2) => org2.github_handle === filters.github_handle);
package/dist/schema.d.ts CHANGED
@@ -219,9 +219,11 @@ declare const accountSchema: z.ZodObject<{
219
219
  apartment?: string | undefined;
220
220
  }>>;
221
221
  personal_org_id: z.ZodOptional<z.ZodString>;
222
+ is_tscircuit_staff: z.ZodDefault<z.ZodBoolean>;
222
223
  }, "strip", z.ZodTypeAny, {
223
224
  account_id: string;
224
225
  github_username: string;
226
+ is_tscircuit_staff: boolean;
225
227
  shippingInfo?: {
226
228
  firstName: string;
227
229
  lastName: string;
@@ -251,6 +253,7 @@ declare const accountSchema: z.ZodObject<{
251
253
  apartment?: string | undefined;
252
254
  } | undefined;
253
255
  personal_org_id?: string | undefined;
256
+ is_tscircuit_staff?: boolean | undefined;
254
257
  }>;
255
258
  type Account = z.infer<typeof accountSchema>;
256
259
  declare const orderSchema: z.ZodObject<{
@@ -1118,23 +1121,26 @@ declare const packageBuildSchema: z.ZodObject<{
1118
1121
  type PackageBuild = z.infer<typeof packageBuildSchema>;
1119
1122
  declare const orgSchema: z.ZodObject<{
1120
1123
  org_id: z.ZodString;
1121
- github_handle: z.ZodString;
1124
+ github_handle: z.ZodOptional<z.ZodString>;
1122
1125
  owner_account_id: z.ZodString;
1123
1126
  is_personal_org: z.ZodDefault<z.ZodBoolean>;
1124
1127
  created_at: z.ZodString;
1125
1128
  org_display_name: z.ZodOptional<z.ZodString>;
1129
+ org_name: z.ZodString;
1126
1130
  }, "strip", z.ZodTypeAny, {
1127
1131
  created_at: string;
1128
1132
  org_id: string;
1129
- github_handle: string;
1130
1133
  owner_account_id: string;
1131
1134
  is_personal_org: boolean;
1135
+ org_name: string;
1136
+ github_handle?: string | undefined;
1132
1137
  org_display_name?: string | undefined;
1133
1138
  }, {
1134
1139
  created_at: string;
1135
1140
  org_id: string;
1136
- github_handle: string;
1137
1141
  owner_account_id: string;
1142
+ org_name: string;
1143
+ github_handle?: string | undefined;
1138
1144
  is_personal_org?: boolean | undefined;
1139
1145
  org_display_name?: string | undefined;
1140
1146
  }>;
@@ -1167,6 +1173,7 @@ declare const publicOrgSchema: z.ZodObject<{
1167
1173
  is_personal_org: z.ZodBoolean;
1168
1174
  display_name: z.ZodOptional<z.ZodString>;
1169
1175
  package_count: z.ZodNumber;
1176
+ github_handle: z.ZodOptional<z.ZodString>;
1170
1177
  created_at: z.ZodString;
1171
1178
  user_permissions: z.ZodOptional<z.ZodObject<{
1172
1179
  can_manage_org: z.ZodOptional<z.ZodBoolean>;
@@ -1186,6 +1193,7 @@ declare const publicOrgSchema: z.ZodObject<{
1186
1193
  is_personal_org: boolean;
1187
1194
  member_count: number;
1188
1195
  package_count: number;
1196
+ github_handle?: string | undefined;
1189
1197
  display_name?: string | undefined;
1190
1198
  user_permissions?: {
1191
1199
  can_manage_org?: boolean | undefined;
@@ -1199,6 +1207,7 @@ declare const publicOrgSchema: z.ZodObject<{
1199
1207
  is_personal_org: boolean;
1200
1208
  member_count: number;
1201
1209
  package_count: number;
1210
+ github_handle?: string | undefined;
1202
1211
  display_name?: string | undefined;
1203
1212
  user_permissions?: {
1204
1213
  can_manage_org?: boolean | undefined;
@@ -1527,9 +1536,11 @@ declare const databaseSchema: z.ZodObject<{
1527
1536
  apartment?: string | undefined;
1528
1537
  }>>;
1529
1538
  personal_org_id: z.ZodOptional<z.ZodString>;
1539
+ is_tscircuit_staff: z.ZodDefault<z.ZodBoolean>;
1530
1540
  }, "strip", z.ZodTypeAny, {
1531
1541
  account_id: string;
1532
1542
  github_username: string;
1543
+ is_tscircuit_staff: boolean;
1533
1544
  shippingInfo?: {
1534
1545
  firstName: string;
1535
1546
  lastName: string;
@@ -1559,6 +1570,7 @@ declare const databaseSchema: z.ZodObject<{
1559
1570
  apartment?: string | undefined;
1560
1571
  } | undefined;
1561
1572
  personal_org_id?: string | undefined;
1573
+ is_tscircuit_staff?: boolean | undefined;
1562
1574
  }>, "many">>;
1563
1575
  packages: z.ZodDefault<z.ZodArray<z.ZodObject<{
1564
1576
  package_id: z.ZodString;
@@ -1714,23 +1726,26 @@ declare const databaseSchema: z.ZodObject<{
1714
1726
  }>, "many">>;
1715
1727
  organizations: z.ZodDefault<z.ZodArray<z.ZodObject<{
1716
1728
  org_id: z.ZodString;
1717
- github_handle: z.ZodString;
1729
+ github_handle: z.ZodOptional<z.ZodString>;
1718
1730
  owner_account_id: z.ZodString;
1719
1731
  is_personal_org: z.ZodDefault<z.ZodBoolean>;
1720
1732
  created_at: z.ZodString;
1721
1733
  org_display_name: z.ZodOptional<z.ZodString>;
1734
+ org_name: z.ZodString;
1722
1735
  }, "strip", z.ZodTypeAny, {
1723
1736
  created_at: string;
1724
1737
  org_id: string;
1725
- github_handle: string;
1726
1738
  owner_account_id: string;
1727
1739
  is_personal_org: boolean;
1740
+ org_name: string;
1741
+ github_handle?: string | undefined;
1728
1742
  org_display_name?: string | undefined;
1729
1743
  }, {
1730
1744
  created_at: string;
1731
1745
  org_id: string;
1732
- github_handle: string;
1733
1746
  owner_account_id: string;
1747
+ org_name: string;
1748
+ github_handle?: string | undefined;
1734
1749
  is_personal_org?: boolean | undefined;
1735
1750
  org_display_name?: string | undefined;
1736
1751
  }>, "many">>;
@@ -2326,6 +2341,7 @@ declare const databaseSchema: z.ZodObject<{
2326
2341
  accounts: {
2327
2342
  account_id: string;
2328
2343
  github_username: string;
2344
+ is_tscircuit_staff: boolean;
2329
2345
  shippingInfo?: {
2330
2346
  firstName: string;
2331
2347
  lastName: string;
@@ -2393,9 +2409,10 @@ declare const databaseSchema: z.ZodObject<{
2393
2409
  organizations: {
2394
2410
  created_at: string;
2395
2411
  org_id: string;
2396
- github_handle: string;
2397
2412
  owner_account_id: string;
2398
2413
  is_personal_org: boolean;
2414
+ org_name: string;
2415
+ github_handle?: string | undefined;
2399
2416
  org_display_name?: string | undefined;
2400
2417
  }[];
2401
2418
  orgAccounts: {
@@ -2671,6 +2688,7 @@ declare const databaseSchema: z.ZodObject<{
2671
2688
  apartment?: string | undefined;
2672
2689
  } | undefined;
2673
2690
  personal_org_id?: string | undefined;
2691
+ is_tscircuit_staff?: boolean | undefined;
2674
2692
  }[] | undefined;
2675
2693
  packages?: {
2676
2694
  name: string;
@@ -2725,8 +2743,9 @@ declare const databaseSchema: z.ZodObject<{
2725
2743
  organizations?: {
2726
2744
  created_at: string;
2727
2745
  org_id: string;
2728
- github_handle: string;
2729
2746
  owner_account_id: string;
2747
+ org_name: string;
2748
+ github_handle?: string | undefined;
2730
2749
  is_personal_org?: boolean | undefined;
2731
2750
  org_display_name?: string | undefined;
2732
2751
  }[] | undefined;
package/dist/schema.js CHANGED
@@ -61,7 +61,8 @@ var accountSchema = z.object({
61
61
  account_id: z.string(),
62
62
  github_username: z.string(),
63
63
  shippingInfo: shippingInfoSchema.optional(),
64
- personal_org_id: z.string().optional()
64
+ personal_org_id: z.string().optional(),
65
+ is_tscircuit_staff: z.boolean().default(false)
65
66
  });
66
67
  var orderSchema = z.object({
67
68
  order_id: z.string(),
@@ -331,11 +332,12 @@ var packageBuildSchema = z.object({
331
332
  });
332
333
  var orgSchema = z.object({
333
334
  org_id: z.string(),
334
- github_handle: z.string(),
335
+ github_handle: z.string().optional(),
335
336
  owner_account_id: z.string(),
336
337
  is_personal_org: z.boolean().default(false),
337
338
  created_at: z.string().datetime(),
338
- org_display_name: z.string().optional()
339
+ org_display_name: z.string().optional(),
340
+ org_name: z.string()
339
341
  });
340
342
  var orgAccountSchema = z.object({
341
343
  org_account_id: z.string(),
@@ -354,6 +356,7 @@ var publicOrgSchema = z.object({
354
356
  is_personal_org: z.boolean(),
355
357
  display_name: z.string().optional(),
356
358
  package_count: z.number(),
359
+ github_handle: z.string().optional(),
357
360
  created_at: z.string(),
358
361
  user_permissions: z.object({
359
362
  can_manage_org: z.boolean().optional(),
@@ -178,11 +178,13 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
178
178
  return state.orderFiles.find((file) => file.order_file_id === orderFileId)
179
179
  },
180
180
  addAccount: (
181
- account: Omit<Account, "account_id"> & Partial<Pick<Account, "account_id">>,
181
+ account: Omit<Account, "account_id" | "is_tscircuit_staff"> &
182
+ Partial<Pick<Account, "account_id" | "is_tscircuit_staff">>,
182
183
  ) => {
183
184
  const newAccount = {
184
185
  account_id: account.account_id || `account_${get().idCounter + 1}`,
185
186
  ...account,
187
+ is_tscircuit_staff: Boolean(account.is_tscircuit_staff),
186
188
  }
187
189
 
188
190
  set((state) => {
@@ -1549,10 +1551,12 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
1549
1551
  org_id?: string
1550
1552
  is_personal_org?: boolean
1551
1553
  owner_account_id: string
1554
+ github_handle?: string
1552
1555
  }) => {
1553
1556
  const newOrganization: Organization = {
1557
+ org_name: organization.name,
1554
1558
  org_id: organization.org_id || `org_${get().idCounter + 1}`,
1555
- github_handle: organization.name,
1559
+ github_handle: organization.github_handle,
1556
1560
  is_personal_org: organization.is_personal_org || false,
1557
1561
  created_at: new Date().toISOString(),
1558
1562
  ...organization,
@@ -1630,7 +1634,7 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
1630
1634
  orgs = orgs.filter((org) => org.org_id === filters.org_id)
1631
1635
  }
1632
1636
  if (filters?.org_name) {
1633
- orgs = orgs.filter((org) => org.github_handle === filters.org_name)
1637
+ orgs = orgs.filter((org) => org.org_name === filters.org_name)
1634
1638
  }
1635
1639
  // if (filters?.org_name && auth?.account_id) {
1636
1640
  // const account = get().accounts.find(x => x.account_id == auth?.account_id)
@@ -67,12 +67,12 @@ export const shippingInfoSchema = z.object({
67
67
  country: z.string(),
68
68
  phone: z.string(),
69
69
  })
70
-
71
70
  export const accountSchema = z.object({
72
71
  account_id: z.string(),
73
72
  github_username: z.string(),
74
73
  shippingInfo: shippingInfoSchema.optional(),
75
74
  personal_org_id: z.string().optional(),
75
+ is_tscircuit_staff: z.boolean().default(false),
76
76
  })
77
77
  export type Account = z.infer<typeof accountSchema>
78
78
 
@@ -401,11 +401,12 @@ export type PackageBuild = z.infer<typeof packageBuildSchema>
401
401
 
402
402
  export const orgSchema = z.object({
403
403
  org_id: z.string(),
404
- github_handle: z.string(),
404
+ github_handle: z.string().optional(),
405
405
  owner_account_id: z.string(),
406
406
  is_personal_org: z.boolean().default(false),
407
407
  created_at: z.string().datetime(),
408
408
  org_display_name: z.string().optional(),
409
+ org_name: z.string(),
409
410
  })
410
411
  export type Organization = z.infer<typeof orgSchema>
411
412
 
@@ -426,6 +427,7 @@ export const publicOrgSchema = z.object({
426
427
  is_personal_org: z.boolean(),
427
428
  display_name: z.string().optional(),
428
429
  package_count: z.number(),
430
+ github_handle: z.string().optional(),
429
431
  created_at: z.string(),
430
432
  user_permissions: z
431
433
  .object({
@@ -1736,6 +1736,7 @@ export const SquareWaveModule = () => (
1736
1736
 
1737
1737
  const testOrg = db.addOrganization({
1738
1738
  name: "test-organization",
1739
+ github_handle: "tscircuit",
1739
1740
  owner_account_id: account_id,
1740
1741
  })
1741
1742
 
@@ -1831,6 +1832,7 @@ exports.TestComponent = TestComponent;
1831
1832
  db.addOrganization({
1832
1833
  name: "testuser",
1833
1834
  owner_account_id: account_id,
1835
+ github_handle: "tscircuit",
1834
1836
  is_personal_org: true,
1835
1837
  })
1836
1838
  }
@@ -1,10 +1,11 @@
1
1
  import type { Middleware } from "winterspec/middleware"
2
2
  import type { CtxErrorFn } from "./with-ctx-error"
3
+ import type { DbClient } from "../db/db-client"
3
4
 
4
5
  export const withSessionAuth: Middleware<
5
6
  {
6
7
  error: CtxErrorFn
7
- db: any
8
+ db: DbClient
8
9
  },
9
10
  {
10
11
  auth: {
@@ -13,6 +14,13 @@ export const withSessionAuth: Middleware<
13
14
  personal_org_id: string
14
15
  github_username: string
15
16
  session_id: string
17
+ orgs: Array<{
18
+ org_id: string
19
+ name: string
20
+ user_permissions: {
21
+ can_manage_packages: boolean
22
+ }
23
+ }>
16
24
  }
17
25
  },
18
26
  {}
@@ -22,28 +30,72 @@ export const withSessionAuth: Middleware<
22
30
  const token = req.headers.get("authorization")?.split("Bearer ")?.[1]
23
31
 
24
32
  // Only check database accounts when we're in a Bun test environment
25
- if (process.env.BUN_TEST === "true" && ctx.db?.accounts) {
26
- const account = ctx.db.accounts.find((acc: any) => acc.account_id === token)
27
-
33
+ if (process.env.BUN_TEST === "true" && ctx.db?.getState) {
34
+ const state = ctx.db.getState()
35
+ const account = state.accounts.find((acc: any) => acc.account_id === token)
28
36
  if (account) {
37
+ // Fetch orgs for this account
38
+ const orgAccounts = state.orgAccounts.filter(
39
+ (oa: any) => oa.account_id === account.account_id,
40
+ )
41
+
42
+ const orgs = orgAccounts.map((oa: any) => {
43
+ const org = state.organizations.find((o: any) => o.org_id === oa.org_id)
44
+ return {
45
+ org_id: oa.org_id,
46
+ name:
47
+ org?.org_display_name ||
48
+ org?.org_name ||
49
+ org?.github_handle ||
50
+ oa.org_id,
51
+ user_permissions: { can_manage_packages: true },
52
+ }
53
+ })
54
+
29
55
  ctx.auth = {
30
56
  type: "session",
31
57
  account_id: account.account_id,
32
58
  personal_org_id: account.personal_org_id || `org-${account.account_id}`,
33
59
  github_username: account.github_username,
34
60
  session_id: `session-${account.account_id}`,
61
+ orgs:
62
+ orgs.length > 0
63
+ ? orgs
64
+ : [
65
+ {
66
+ org_id:
67
+ account.personal_org_id || `org-${account.account_id}`,
68
+ name:
69
+ account.github_username ||
70
+ account.personal_org_id ||
71
+ `org-${account.account_id}`,
72
+ user_permissions: { can_manage_packages: true },
73
+ },
74
+ ],
35
75
  }
36
76
  return next(req, ctx)
37
77
  }
38
78
  }
39
79
 
40
- // For all other environments or if account not found in test, use hardcoded auth
80
+ // Fallback auth for non-test environments or when no token is found
81
+ const fallbackAccountId = "account-1234"
82
+ const fallbackOrgId = "org-1234"
83
+
84
+ const fallbackOrgs = [
85
+ {
86
+ org_id: fallbackOrgId,
87
+ name: "org-1234",
88
+ user_permissions: { can_manage_packages: true },
89
+ },
90
+ ]
91
+
41
92
  ctx.auth = {
42
93
  type: "session",
43
- account_id: "account-1234",
44
- personal_org_id: "org-1234",
94
+ account_id: fallbackAccountId,
95
+ personal_org_id: fallbackOrgId,
45
96
  github_username: "testuser",
46
97
  session_id: "session-1234",
98
+ orgs: fallbackOrgs,
47
99
  }
48
100
 
49
101
  return next(req, ctx)
@@ -16,17 +16,19 @@ export const publicMapOrg = (
16
16
  created_at,
17
17
  is_personal_org,
18
18
  org_display_name,
19
+ org_name,
19
20
  ...org
20
21
  } = internal_org
21
22
  return {
22
23
  org_id: org.org_id,
23
- display_name: org_display_name ?? github_handle ?? "",
24
+ display_name: org_display_name ?? org_name,
24
25
  owner_account_id: org.owner_account_id,
25
- name: github_handle,
26
+ name: org_name,
26
27
  member_count: Number(member_count) || 0,
27
28
  package_count: Number(package_count) || 0,
28
29
  is_personal_org: Boolean(is_personal_org),
29
30
  created_at: String(created_at),
31
+ ...(github_handle ? { github_handle } : {}),
30
32
  ...(can_manage_org ? { user_permissions: { can_manage_org: true } } : {}),
31
33
  }
32
34
  }