Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import type { AnyDeclarationBuilder } from './AnyDeclarationBuilder'; |
| 2 | import type { BasicBuilder } from './BasicBuilder'; |
| 3 | import { Export } from './Export'; |
| 4 | import { Writer } from './Writer'; |
| 5 | |
| 6 | export type NamespaceItem = AnyDeclarationBuilder | Export<AnyDeclarationBuilder>; |
| 7 | export class NamespaceDeclaration implements BasicBuilder { |
| 8 | private items: NamespaceItem[] = []; |
| 9 | constructor(readonly name: string) {} |
| 10 | |
| 11 | add(declaration: NamespaceItem) { |
| 12 | this.items.push(declaration); |
| 13 | } |
| 14 | |
| 15 | write(writer: Writer<undefined>): void { |
| 16 | writer |
| 17 | .writeLine(`namespace ${this.name} {`) |
| 18 | .withIndent(() => { |
| 19 | for (const item of this.items) { |
| 20 | writer.writeLine(item); |
| 21 | } |
| 22 | }) |
| 23 | .write('}'); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | export function namespace(name: string): NamespaceDeclaration { |
| 28 | return new NamespaceDeclaration(name); |
| 29 | } |