mirror of
https://github.com/ComposioHQ/composio.git
synced 2026-09-22 11:46:35 +08:00
1d02d3e495
Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
30 lines
843 B
TypeScript
30 lines
843 B
TypeScript
import type { AnyDeclarationBuilder } from './AnyDeclarationBuilder';
|
|
import type { BasicBuilder } from './BasicBuilder';
|
|
import { Export } from './Export';
|
|
import { Writer } from './Writer';
|
|
|
|
export type NamespaceItem = AnyDeclarationBuilder | Export<AnyDeclarationBuilder>;
|
|
export class NamespaceDeclaration implements BasicBuilder {
|
|
private items: NamespaceItem[] = [];
|
|
constructor(readonly name: string) {}
|
|
|
|
add(declaration: NamespaceItem) {
|
|
this.items.push(declaration);
|
|
}
|
|
|
|
write(writer: Writer<undefined>): void {
|
|
writer
|
|
.writeLine(`namespace ${this.name} {`)
|
|
.withIndent(() => {
|
|
for (const item of this.items) {
|
|
writer.writeLine(item);
|
|
}
|
|
})
|
|
.write('}');
|
|
}
|
|
}
|
|
|
|
export function namespace(name: string): NamespaceDeclaration {
|
|
return new NamespaceDeclaration(name);
|
|
}
|