From bf8d718cf918ac8d8a2cb1f57fde80535284642d Mon Sep 17 00:00:00 2001
From: Daniel Holmgren <dtholmgren@gmail.com>
Date: Thu, 18 Jan 2024 15:24:38 -0600
Subject: [PATCH] Namespace lexicon codegen (#2039)

* namespace codegen

* fix test that uses namespace prototype

* changeset
---
 .changeset/old-cups-jog.md                 |   6 ++
 packages/api/src/client/index.ts           | 102 ++++++++++-----------
 packages/bsky/src/lexicon/index.ts         | 102 ++++++++++-----------
 packages/lex-cli/src/codegen/util.ts       |   5 +-
 packages/ozone/src/lexicon/index.ts        | 102 ++++++++++-----------
 packages/pds/src/lexicon/index.ts          | 102 ++++++++++-----------
 packages/pds/tests/proxied/feedgen.test.ts |   8 +-
 7 files changed, 217 insertions(+), 210 deletions(-)
 create mode 100644 .changeset/old-cups-jog.md

diff --git a/.changeset/old-cups-jog.md b/.changeset/old-cups-jog.md
new file mode 100644
index 00000000000..971237f66d6
--- /dev/null
+++ b/.changeset/old-cups-jog.md
@@ -0,0 +1,6 @@
+---
+'@atproto/lex-cli': minor
+'@atproto/api': minor
+---
+
+Namespace lexicon codegen
diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts
index 6c215f308e6..4383439d7f4 100644
--- a/packages/api/src/client/index.ts
+++ b/packages/api/src/client/index.ts
@@ -338,39 +338,39 @@ export class AtpServiceClient {
 
 export class ComNS {
   _service: AtpServiceClient
-  atproto: AtprotoNS
+  atproto: ComAtprotoNS
 
   constructor(service: AtpServiceClient) {
     this._service = service
-    this.atproto = new AtprotoNS(service)
+    this.atproto = new ComAtprotoNS(service)
   }
 }
 
-export class AtprotoNS {
+export class ComAtprotoNS {
   _service: AtpServiceClient
-  admin: AdminNS
-  identity: IdentityNS
-  label: LabelNS
-  moderation: ModerationNS
-  repo: RepoNS
-  server: ServerNS
-  sync: SyncNS
-  temp: TempNS
+  admin: ComAtprotoAdminNS
+  identity: ComAtprotoIdentityNS
+  label: ComAtprotoLabelNS
+  moderation: ComAtprotoModerationNS
+  repo: ComAtprotoRepoNS
+  server: ComAtprotoServerNS
+  sync: ComAtprotoSyncNS
+  temp: ComAtprotoTempNS
 
   constructor(service: AtpServiceClient) {
     this._service = service
-    this.admin = new AdminNS(service)
-    this.identity = new IdentityNS(service)
-    this.label = new LabelNS(service)
-    this.moderation = new ModerationNS(service)
-    this.repo = new RepoNS(service)
-    this.server = new ServerNS(service)
-    this.sync = new SyncNS(service)
-    this.temp = new TempNS(service)
+    this.admin = new ComAtprotoAdminNS(service)
+    this.identity = new ComAtprotoIdentityNS(service)
+    this.label = new ComAtprotoLabelNS(service)
+    this.moderation = new ComAtprotoModerationNS(service)
+    this.repo = new ComAtprotoRepoNS(service)
+    this.server = new ComAtprotoServerNS(service)
+    this.sync = new ComAtprotoSyncNS(service)
+    this.temp = new ComAtprotoTempNS(service)
   }
 }
 
-export class AdminNS {
+export class ComAtprotoAdminNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -592,7 +592,7 @@ export class AdminNS {
   }
 }
 
-export class IdentityNS {
+export class ComAtprotoIdentityNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -622,7 +622,7 @@ export class IdentityNS {
   }
 }
 
-export class LabelNS {
+export class ComAtprotoLabelNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -641,7 +641,7 @@ export class LabelNS {
   }
 }
 
-export class ModerationNS {
+export class ComAtprotoModerationNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -660,7 +660,7 @@ export class ModerationNS {
   }
 }
 
-export class RepoNS {
+export class ComAtprotoRepoNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -756,7 +756,7 @@ export class RepoNS {
   }
 }
 
-export class ServerNS {
+export class ComAtprotoServerNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -995,7 +995,7 @@ export class ServerNS {
   }
 }
 
-export class SyncNS {
+export class ComAtprotoSyncNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -1124,7 +1124,7 @@ export class SyncNS {
   }
 }
 
-export class TempNS {
+export class ComAtprotoTempNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -1189,37 +1189,37 @@ export class TempNS {
 
 export class AppNS {
   _service: AtpServiceClient
-  bsky: BskyNS
+  bsky: AppBskyNS
 
   constructor(service: AtpServiceClient) {
     this._service = service
-    this.bsky = new BskyNS(service)
+    this.bsky = new AppBskyNS(service)
   }
 }
 
-export class BskyNS {
+export class AppBskyNS {
   _service: AtpServiceClient
-  actor: ActorNS
-  embed: EmbedNS
-  feed: FeedNS
-  graph: GraphNS
-  notification: NotificationNS
-  richtext: RichtextNS
-  unspecced: UnspeccedNS
+  actor: AppBskyActorNS
+  embed: AppBskyEmbedNS
+  feed: AppBskyFeedNS
+  graph: AppBskyGraphNS
+  notification: AppBskyNotificationNS
+  richtext: AppBskyRichtextNS
+  unspecced: AppBskyUnspeccedNS
 
   constructor(service: AtpServiceClient) {
     this._service = service
-    this.actor = new ActorNS(service)
-    this.embed = new EmbedNS(service)
-    this.feed = new FeedNS(service)
-    this.graph = new GraphNS(service)
-    this.notification = new NotificationNS(service)
-    this.richtext = new RichtextNS(service)
-    this.unspecced = new UnspeccedNS(service)
+    this.actor = new AppBskyActorNS(service)
+    this.embed = new AppBskyEmbedNS(service)
+    this.feed = new AppBskyFeedNS(service)
+    this.graph = new AppBskyGraphNS(service)
+    this.notification = new AppBskyNotificationNS(service)
+    this.richtext = new AppBskyRichtextNS(service)
+    this.unspecced = new AppBskyUnspeccedNS(service)
   }
 }
 
-export class ActorNS {
+export class AppBskyActorNS {
   _service: AtpServiceClient
   profile: ProfileRecord
 
@@ -1367,7 +1367,7 @@ export class ProfileRecord {
   }
 }
 
-export class EmbedNS {
+export class AppBskyEmbedNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -1375,7 +1375,7 @@ export class EmbedNS {
   }
 }
 
-export class FeedNS {
+export class AppBskyFeedNS {
   _service: AtpServiceClient
   generator: GeneratorRecord
   like: LikeRecord
@@ -1878,7 +1878,7 @@ export class ThreadgateRecord {
   }
 }
 
-export class GraphNS {
+export class AppBskyGraphNS {
   _service: AtpServiceClient
   block: BlockRecord
   follow: FollowRecord
@@ -2353,7 +2353,7 @@ export class ListitemRecord {
   }
 }
 
-export class NotificationNS {
+export class AppBskyNotificationNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -2405,7 +2405,7 @@ export class NotificationNS {
   }
 }
 
-export class RichtextNS {
+export class AppBskyRichtextNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
@@ -2413,7 +2413,7 @@ export class RichtextNS {
   }
 }
 
-export class UnspeccedNS {
+export class AppBskyUnspeccedNS {
   _service: AtpServiceClient
 
   constructor(service: AtpServiceClient) {
diff --git a/packages/bsky/src/lexicon/index.ts b/packages/bsky/src/lexicon/index.ts
index b1693881c5b..42af2fb6cb0 100644
--- a/packages/bsky/src/lexicon/index.ts
+++ b/packages/bsky/src/lexicon/index.ts
@@ -161,39 +161,39 @@ export class Server {
 
 export class ComNS {
   _server: Server
-  atproto: AtprotoNS
+  atproto: ComAtprotoNS
 
   constructor(server: Server) {
     this._server = server
-    this.atproto = new AtprotoNS(server)
+    this.atproto = new ComAtprotoNS(server)
   }
 }
 
-export class AtprotoNS {
+export class ComAtprotoNS {
   _server: Server
-  admin: AdminNS
-  identity: IdentityNS
-  label: LabelNS
-  moderation: ModerationNS
-  repo: RepoNS
-  server: ServerNS
-  sync: SyncNS
-  temp: TempNS
+  admin: ComAtprotoAdminNS
+  identity: ComAtprotoIdentityNS
+  label: ComAtprotoLabelNS
+  moderation: ComAtprotoModerationNS
+  repo: ComAtprotoRepoNS
+  server: ComAtprotoServerNS
+  sync: ComAtprotoSyncNS
+  temp: ComAtprotoTempNS
 
   constructor(server: Server) {
     this._server = server
-    this.admin = new AdminNS(server)
-    this.identity = new IdentityNS(server)
-    this.label = new LabelNS(server)
-    this.moderation = new ModerationNS(server)
-    this.repo = new RepoNS(server)
-    this.server = new ServerNS(server)
-    this.sync = new SyncNS(server)
-    this.temp = new TempNS(server)
+    this.admin = new ComAtprotoAdminNS(server)
+    this.identity = new ComAtprotoIdentityNS(server)
+    this.label = new ComAtprotoLabelNS(server)
+    this.moderation = new ComAtprotoModerationNS(server)
+    this.repo = new ComAtprotoRepoNS(server)
+    this.server = new ComAtprotoServerNS(server)
+    this.sync = new ComAtprotoSyncNS(server)
+    this.temp = new ComAtprotoTempNS(server)
   }
 }
 
-export class AdminNS {
+export class ComAtprotoAdminNS {
   _server: Server
 
   constructor(server: Server) {
@@ -410,7 +410,7 @@ export class AdminNS {
   }
 }
 
-export class IdentityNS {
+export class ComAtprotoIdentityNS {
   _server: Server
 
   constructor(server: Server) {
@@ -440,7 +440,7 @@ export class IdentityNS {
   }
 }
 
-export class LabelNS {
+export class ComAtprotoLabelNS {
   _server: Server
 
   constructor(server: Server) {
@@ -470,7 +470,7 @@ export class LabelNS {
   }
 }
 
-export class ModerationNS {
+export class ComAtprotoModerationNS {
   _server: Server
 
   constructor(server: Server) {
@@ -489,7 +489,7 @@ export class ModerationNS {
   }
 }
 
-export class RepoNS {
+export class ComAtprotoRepoNS {
   _server: Server
 
   constructor(server: Server) {
@@ -585,7 +585,7 @@ export class RepoNS {
   }
 }
 
-export class ServerNS {
+export class ComAtprotoServerNS {
   _server: Server
 
   constructor(server: Server) {
@@ -824,7 +824,7 @@ export class ServerNS {
   }
 }
 
-export class SyncNS {
+export class ComAtprotoSyncNS {
   _server: Server
 
   constructor(server: Server) {
@@ -964,7 +964,7 @@ export class SyncNS {
   }
 }
 
-export class TempNS {
+export class ComAtprotoTempNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1029,37 +1029,37 @@ export class TempNS {
 
 export class AppNS {
   _server: Server
-  bsky: BskyNS
+  bsky: AppBskyNS
 
   constructor(server: Server) {
     this._server = server
-    this.bsky = new BskyNS(server)
+    this.bsky = new AppBskyNS(server)
   }
 }
 
-export class BskyNS {
+export class AppBskyNS {
   _server: Server
-  actor: ActorNS
-  embed: EmbedNS
-  feed: FeedNS
-  graph: GraphNS
-  notification: NotificationNS
-  richtext: RichtextNS
-  unspecced: UnspeccedNS
+  actor: AppBskyActorNS
+  embed: AppBskyEmbedNS
+  feed: AppBskyFeedNS
+  graph: AppBskyGraphNS
+  notification: AppBskyNotificationNS
+  richtext: AppBskyRichtextNS
+  unspecced: AppBskyUnspeccedNS
 
   constructor(server: Server) {
     this._server = server
-    this.actor = new ActorNS(server)
-    this.embed = new EmbedNS(server)
-    this.feed = new FeedNS(server)
-    this.graph = new GraphNS(server)
-    this.notification = new NotificationNS(server)
-    this.richtext = new RichtextNS(server)
-    this.unspecced = new UnspeccedNS(server)
+    this.actor = new AppBskyActorNS(server)
+    this.embed = new AppBskyEmbedNS(server)
+    this.feed = new AppBskyFeedNS(server)
+    this.graph = new AppBskyGraphNS(server)
+    this.notification = new AppBskyNotificationNS(server)
+    this.richtext = new AppBskyRichtextNS(server)
+    this.unspecced = new AppBskyUnspeccedNS(server)
   }
 }
 
-export class ActorNS {
+export class AppBskyActorNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1144,7 +1144,7 @@ export class ActorNS {
   }
 }
 
-export class EmbedNS {
+export class AppBskyEmbedNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1152,7 +1152,7 @@ export class EmbedNS {
   }
 }
 
-export class FeedNS {
+export class AppBskyFeedNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1336,7 +1336,7 @@ export class FeedNS {
   }
 }
 
-export class GraphNS {
+export class AppBskyGraphNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1487,7 +1487,7 @@ export class GraphNS {
   }
 }
 
-export class NotificationNS {
+export class AppBskyNotificationNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1539,7 +1539,7 @@ export class NotificationNS {
   }
 }
 
-export class RichtextNS {
+export class AppBskyRichtextNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1547,7 +1547,7 @@ export class RichtextNS {
   }
 }
 
-export class UnspeccedNS {
+export class AppBskyUnspeccedNS {
   _server: Server
 
   constructor(server: Server) {
diff --git a/packages/lex-cli/src/codegen/util.ts b/packages/lex-cli/src/codegen/util.ts
index 043821e4715..c3b7a7322d4 100644
--- a/packages/lex-cli/src/codegen/util.ts
+++ b/packages/lex-cli/src/codegen/util.ts
@@ -28,12 +28,13 @@ export function lexiconsToDefTree(lexicons: LexiconDoc[]): DefTreeNode[] {
 
 function getOrCreateNode(tree: DefTreeNode[], path: string[]): DefTreeNode {
   let node: DefTreeNode | undefined
-  for (const segment of path) {
+  for (let i = 0; i < path.length; i++) {
+    const segment = path[i]
     node = tree.find((v) => v.name === segment)
     if (!node) {
       node = {
         name: segment,
-        className: `${toTitleCase(segment)}NS`,
+        className: `${toTitleCase(path.slice(0, i + 1).join('-'))}NS`,
         propName: toCamelCase(segment),
         children: [],
         userTypes: [],
diff --git a/packages/ozone/src/lexicon/index.ts b/packages/ozone/src/lexicon/index.ts
index b1693881c5b..42af2fb6cb0 100644
--- a/packages/ozone/src/lexicon/index.ts
+++ b/packages/ozone/src/lexicon/index.ts
@@ -161,39 +161,39 @@ export class Server {
 
 export class ComNS {
   _server: Server
-  atproto: AtprotoNS
+  atproto: ComAtprotoNS
 
   constructor(server: Server) {
     this._server = server
-    this.atproto = new AtprotoNS(server)
+    this.atproto = new ComAtprotoNS(server)
   }
 }
 
-export class AtprotoNS {
+export class ComAtprotoNS {
   _server: Server
-  admin: AdminNS
-  identity: IdentityNS
-  label: LabelNS
-  moderation: ModerationNS
-  repo: RepoNS
-  server: ServerNS
-  sync: SyncNS
-  temp: TempNS
+  admin: ComAtprotoAdminNS
+  identity: ComAtprotoIdentityNS
+  label: ComAtprotoLabelNS
+  moderation: ComAtprotoModerationNS
+  repo: ComAtprotoRepoNS
+  server: ComAtprotoServerNS
+  sync: ComAtprotoSyncNS
+  temp: ComAtprotoTempNS
 
   constructor(server: Server) {
     this._server = server
-    this.admin = new AdminNS(server)
-    this.identity = new IdentityNS(server)
-    this.label = new LabelNS(server)
-    this.moderation = new ModerationNS(server)
-    this.repo = new RepoNS(server)
-    this.server = new ServerNS(server)
-    this.sync = new SyncNS(server)
-    this.temp = new TempNS(server)
+    this.admin = new ComAtprotoAdminNS(server)
+    this.identity = new ComAtprotoIdentityNS(server)
+    this.label = new ComAtprotoLabelNS(server)
+    this.moderation = new ComAtprotoModerationNS(server)
+    this.repo = new ComAtprotoRepoNS(server)
+    this.server = new ComAtprotoServerNS(server)
+    this.sync = new ComAtprotoSyncNS(server)
+    this.temp = new ComAtprotoTempNS(server)
   }
 }
 
-export class AdminNS {
+export class ComAtprotoAdminNS {
   _server: Server
 
   constructor(server: Server) {
@@ -410,7 +410,7 @@ export class AdminNS {
   }
 }
 
-export class IdentityNS {
+export class ComAtprotoIdentityNS {
   _server: Server
 
   constructor(server: Server) {
@@ -440,7 +440,7 @@ export class IdentityNS {
   }
 }
 
-export class LabelNS {
+export class ComAtprotoLabelNS {
   _server: Server
 
   constructor(server: Server) {
@@ -470,7 +470,7 @@ export class LabelNS {
   }
 }
 
-export class ModerationNS {
+export class ComAtprotoModerationNS {
   _server: Server
 
   constructor(server: Server) {
@@ -489,7 +489,7 @@ export class ModerationNS {
   }
 }
 
-export class RepoNS {
+export class ComAtprotoRepoNS {
   _server: Server
 
   constructor(server: Server) {
@@ -585,7 +585,7 @@ export class RepoNS {
   }
 }
 
-export class ServerNS {
+export class ComAtprotoServerNS {
   _server: Server
 
   constructor(server: Server) {
@@ -824,7 +824,7 @@ export class ServerNS {
   }
 }
 
-export class SyncNS {
+export class ComAtprotoSyncNS {
   _server: Server
 
   constructor(server: Server) {
@@ -964,7 +964,7 @@ export class SyncNS {
   }
 }
 
-export class TempNS {
+export class ComAtprotoTempNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1029,37 +1029,37 @@ export class TempNS {
 
 export class AppNS {
   _server: Server
-  bsky: BskyNS
+  bsky: AppBskyNS
 
   constructor(server: Server) {
     this._server = server
-    this.bsky = new BskyNS(server)
+    this.bsky = new AppBskyNS(server)
   }
 }
 
-export class BskyNS {
+export class AppBskyNS {
   _server: Server
-  actor: ActorNS
-  embed: EmbedNS
-  feed: FeedNS
-  graph: GraphNS
-  notification: NotificationNS
-  richtext: RichtextNS
-  unspecced: UnspeccedNS
+  actor: AppBskyActorNS
+  embed: AppBskyEmbedNS
+  feed: AppBskyFeedNS
+  graph: AppBskyGraphNS
+  notification: AppBskyNotificationNS
+  richtext: AppBskyRichtextNS
+  unspecced: AppBskyUnspeccedNS
 
   constructor(server: Server) {
     this._server = server
-    this.actor = new ActorNS(server)
-    this.embed = new EmbedNS(server)
-    this.feed = new FeedNS(server)
-    this.graph = new GraphNS(server)
-    this.notification = new NotificationNS(server)
-    this.richtext = new RichtextNS(server)
-    this.unspecced = new UnspeccedNS(server)
+    this.actor = new AppBskyActorNS(server)
+    this.embed = new AppBskyEmbedNS(server)
+    this.feed = new AppBskyFeedNS(server)
+    this.graph = new AppBskyGraphNS(server)
+    this.notification = new AppBskyNotificationNS(server)
+    this.richtext = new AppBskyRichtextNS(server)
+    this.unspecced = new AppBskyUnspeccedNS(server)
   }
 }
 
-export class ActorNS {
+export class AppBskyActorNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1144,7 +1144,7 @@ export class ActorNS {
   }
 }
 
-export class EmbedNS {
+export class AppBskyEmbedNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1152,7 +1152,7 @@ export class EmbedNS {
   }
 }
 
-export class FeedNS {
+export class AppBskyFeedNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1336,7 +1336,7 @@ export class FeedNS {
   }
 }
 
-export class GraphNS {
+export class AppBskyGraphNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1487,7 +1487,7 @@ export class GraphNS {
   }
 }
 
-export class NotificationNS {
+export class AppBskyNotificationNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1539,7 +1539,7 @@ export class NotificationNS {
   }
 }
 
-export class RichtextNS {
+export class AppBskyRichtextNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1547,7 +1547,7 @@ export class RichtextNS {
   }
 }
 
-export class UnspeccedNS {
+export class AppBskyUnspeccedNS {
   _server: Server
 
   constructor(server: Server) {
diff --git a/packages/pds/src/lexicon/index.ts b/packages/pds/src/lexicon/index.ts
index b1693881c5b..42af2fb6cb0 100644
--- a/packages/pds/src/lexicon/index.ts
+++ b/packages/pds/src/lexicon/index.ts
@@ -161,39 +161,39 @@ export class Server {
 
 export class ComNS {
   _server: Server
-  atproto: AtprotoNS
+  atproto: ComAtprotoNS
 
   constructor(server: Server) {
     this._server = server
-    this.atproto = new AtprotoNS(server)
+    this.atproto = new ComAtprotoNS(server)
   }
 }
 
-export class AtprotoNS {
+export class ComAtprotoNS {
   _server: Server
-  admin: AdminNS
-  identity: IdentityNS
-  label: LabelNS
-  moderation: ModerationNS
-  repo: RepoNS
-  server: ServerNS
-  sync: SyncNS
-  temp: TempNS
+  admin: ComAtprotoAdminNS
+  identity: ComAtprotoIdentityNS
+  label: ComAtprotoLabelNS
+  moderation: ComAtprotoModerationNS
+  repo: ComAtprotoRepoNS
+  server: ComAtprotoServerNS
+  sync: ComAtprotoSyncNS
+  temp: ComAtprotoTempNS
 
   constructor(server: Server) {
     this._server = server
-    this.admin = new AdminNS(server)
-    this.identity = new IdentityNS(server)
-    this.label = new LabelNS(server)
-    this.moderation = new ModerationNS(server)
-    this.repo = new RepoNS(server)
-    this.server = new ServerNS(server)
-    this.sync = new SyncNS(server)
-    this.temp = new TempNS(server)
+    this.admin = new ComAtprotoAdminNS(server)
+    this.identity = new ComAtprotoIdentityNS(server)
+    this.label = new ComAtprotoLabelNS(server)
+    this.moderation = new ComAtprotoModerationNS(server)
+    this.repo = new ComAtprotoRepoNS(server)
+    this.server = new ComAtprotoServerNS(server)
+    this.sync = new ComAtprotoSyncNS(server)
+    this.temp = new ComAtprotoTempNS(server)
   }
 }
 
-export class AdminNS {
+export class ComAtprotoAdminNS {
   _server: Server
 
   constructor(server: Server) {
@@ -410,7 +410,7 @@ export class AdminNS {
   }
 }
 
-export class IdentityNS {
+export class ComAtprotoIdentityNS {
   _server: Server
 
   constructor(server: Server) {
@@ -440,7 +440,7 @@ export class IdentityNS {
   }
 }
 
-export class LabelNS {
+export class ComAtprotoLabelNS {
   _server: Server
 
   constructor(server: Server) {
@@ -470,7 +470,7 @@ export class LabelNS {
   }
 }
 
-export class ModerationNS {
+export class ComAtprotoModerationNS {
   _server: Server
 
   constructor(server: Server) {
@@ -489,7 +489,7 @@ export class ModerationNS {
   }
 }
 
-export class RepoNS {
+export class ComAtprotoRepoNS {
   _server: Server
 
   constructor(server: Server) {
@@ -585,7 +585,7 @@ export class RepoNS {
   }
 }
 
-export class ServerNS {
+export class ComAtprotoServerNS {
   _server: Server
 
   constructor(server: Server) {
@@ -824,7 +824,7 @@ export class ServerNS {
   }
 }
 
-export class SyncNS {
+export class ComAtprotoSyncNS {
   _server: Server
 
   constructor(server: Server) {
@@ -964,7 +964,7 @@ export class SyncNS {
   }
 }
 
-export class TempNS {
+export class ComAtprotoTempNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1029,37 +1029,37 @@ export class TempNS {
 
 export class AppNS {
   _server: Server
-  bsky: BskyNS
+  bsky: AppBskyNS
 
   constructor(server: Server) {
     this._server = server
-    this.bsky = new BskyNS(server)
+    this.bsky = new AppBskyNS(server)
   }
 }
 
-export class BskyNS {
+export class AppBskyNS {
   _server: Server
-  actor: ActorNS
-  embed: EmbedNS
-  feed: FeedNS
-  graph: GraphNS
-  notification: NotificationNS
-  richtext: RichtextNS
-  unspecced: UnspeccedNS
+  actor: AppBskyActorNS
+  embed: AppBskyEmbedNS
+  feed: AppBskyFeedNS
+  graph: AppBskyGraphNS
+  notification: AppBskyNotificationNS
+  richtext: AppBskyRichtextNS
+  unspecced: AppBskyUnspeccedNS
 
   constructor(server: Server) {
     this._server = server
-    this.actor = new ActorNS(server)
-    this.embed = new EmbedNS(server)
-    this.feed = new FeedNS(server)
-    this.graph = new GraphNS(server)
-    this.notification = new NotificationNS(server)
-    this.richtext = new RichtextNS(server)
-    this.unspecced = new UnspeccedNS(server)
+    this.actor = new AppBskyActorNS(server)
+    this.embed = new AppBskyEmbedNS(server)
+    this.feed = new AppBskyFeedNS(server)
+    this.graph = new AppBskyGraphNS(server)
+    this.notification = new AppBskyNotificationNS(server)
+    this.richtext = new AppBskyRichtextNS(server)
+    this.unspecced = new AppBskyUnspeccedNS(server)
   }
 }
 
-export class ActorNS {
+export class AppBskyActorNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1144,7 +1144,7 @@ export class ActorNS {
   }
 }
 
-export class EmbedNS {
+export class AppBskyEmbedNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1152,7 +1152,7 @@ export class EmbedNS {
   }
 }
 
-export class FeedNS {
+export class AppBskyFeedNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1336,7 +1336,7 @@ export class FeedNS {
   }
 }
 
-export class GraphNS {
+export class AppBskyGraphNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1487,7 +1487,7 @@ export class GraphNS {
   }
 }
 
-export class NotificationNS {
+export class AppBskyNotificationNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1539,7 +1539,7 @@ export class NotificationNS {
   }
 }
 
-export class RichtextNS {
+export class AppBskyRichtextNS {
   _server: Server
 
   constructor(server: Server) {
@@ -1547,7 +1547,7 @@ export class RichtextNS {
   }
 }
 
-export class UnspeccedNS {
+export class AppBskyUnspeccedNS {
   _server: Server
 
   constructor(server: Server) {
diff --git a/packages/pds/tests/proxied/feedgen.test.ts b/packages/pds/tests/proxied/feedgen.test.ts
index 6f06ce0d020..b2189e995d6 100644
--- a/packages/pds/tests/proxied/feedgen.test.ts
+++ b/packages/pds/tests/proxied/feedgen.test.ts
@@ -1,5 +1,5 @@
 import { makeAlgos } from '@atproto/bsky'
-import AtpAgent, { AtUri, FeedNS } from '@atproto/api'
+import AtpAgent, { AtUri, AppBskyFeedNS } from '@atproto/api'
 import { TestNetwork, SeedClient } from '@atproto/dev-env'
 import basicSeed from '../seeds/basic'
 import { forSnapshot } from '../_util'
@@ -9,7 +9,7 @@ describe('feedgen proxy view', () => {
   let agent: AtpAgent
   let sc: SeedClient
 
-  const origGetFeedGenerator = FeedNS.prototype.getFeedGenerator
+  const origGetFeedGenerator = AppBskyFeedNS.prototype.getFeedGenerator
   const feedUri = AtUri.make(
     'did:example:feed-publisher',
     'app.bsky.feed.generator',
@@ -36,7 +36,7 @@ describe('feedgen proxy view', () => {
     )
     await network.processAll()
     // mock getFeedGenerator() for use by pds's getFeed since we don't have a proper feedGenDid or feed publisher
-    FeedNS.prototype.getFeedGenerator = async function (params, opts) {
+    AppBskyFeedNS.prototype.getFeedGenerator = async function (params, opts) {
       if (params?.feed === feedUri.toString()) {
         return {
           success: true,
@@ -60,7 +60,7 @@ describe('feedgen proxy view', () => {
   })
 
   afterAll(async () => {
-    FeedNS.prototype.getFeedGenerator = origGetFeedGenerator
+    AppBskyFeedNS.prototype.getFeedGenerator = origGetFeedGenerator
     await network.close()
   })