Skip to main content

ProjectStructure API

Project Structure API

import { CodeBoltClient } from '@codebolt/clientsdk';

const client = new CodeBoltClient();

Quick Reference

MethodDescription
addItemAdds an item to a specific section within a package.
createPackageCreates a new package definition in the project structure.
deleteItemRemoves an item from a package section.
deletePackageDeletes a package and all its sections and items from the project structure.
getMetadataRetrieves the full workspace metadata including package definitions and structure.
getPackageRetrieves a single package by its unique identifier.
getPackagesRetrieves all package definitions in the workspace.
saveMetadataSaves the complete workspace metadata, replacing any existing structure.
updatePackageUpdates an existing package definition.

Methods


addItem

client.projectStructure.addItem(packageId: string, section: string, data: AddSectionItemRequest): Promise<void>

Adds an item to a specific section within a package.

Registers a new item (e.g., a file, class, or endpoint reference) under the specified section of a package, enriching the structural metadata.

ParameterTypeRequiredDescription
packageIdstringYesThe unique identifier of the package
sectionstringYesThe name of the section to add the item to (e.g., 'routes', 'models')
dataAddSectionItemRequestYesThe item definition to add

Returns: Promise<void> — A promise that resolves when the item has been added

Full reference →


createPackage

client.projectStructure.createPackage(data: CreatePackageRequest): Promise<PackageDefinition>

Creates a new package definition in the project structure.

Adds a logical package to the workspace structure with the given name and configuration. Packages group related code sections and items together.

ParameterTypeRequiredDescription
dataCreatePackageRequestYesThe package creation payload

Returns: Promise<PackageDefinition> — A promise that resolves to the newly created package definition

Full reference →


deleteItem

client.projectStructure.deleteItem(packageId: string, section: string, itemId: string): Promise<void>

Removes an item from a package section.

Deletes the structural reference to an item within a package section. This only removes the metadata entry, not the actual underlying file or resource.

ParameterTypeRequiredDescription
packageIdstringYesThe unique identifier of the package
sectionstringYesThe name of the section containing the item
itemIdstringYesThe unique identifier of the item to remove

Returns: Promise<void> — A promise that resolves when the item has been removed

Full reference →


deletePackage

client.projectStructure.deletePackage(packageId: string): Promise<void>

Deletes a package and all its sections and items from the project structure.

Permanently removes the package definition. This does not delete actual source files, only the structural metadata describing the package.

ParameterTypeRequiredDescription
packageIdstringYesThe unique identifier of the package to delete

Returns: Promise<void> — A promise that resolves when the package has been deleted

Full reference →


getMetadata

client.projectStructure.getMetadata(): Promise<WorkspaceMetadata>

Retrieves the full workspace metadata including package definitions and structure.

Returns the complete structural representation of the workspace, which describes how the project is organized into packages, modules, and sections.

No parameters.

Returns: Promise<WorkspaceMetadata> — A promise that resolves to the workspace metadata

Full reference →


getPackage

client.projectStructure.getPackage(packageId: string): Promise<PackageDefinition>

Retrieves a single package by its unique identifier.

Returns the full package definition including all its sections and items.

ParameterTypeRequiredDescription
packageIdstringYesThe unique identifier of the package to retrieve

Returns: Promise<PackageDefinition> — A promise that resolves to the package definition

Full reference →


getPackages

client.projectStructure.getPackages(): Promise<PackageDefinition[]>

Retrieves all package definitions in the workspace.

Returns the list of logical packages that make up the project, each containing its sections, items, and metadata.

No parameters.

Returns: Promise<PackageDefinition[]> — A promise that resolves to an array of package definitions

Full reference →


saveMetadata

client.projectStructure.saveMetadata(data: SaveWorkspaceMetadataRequest): Promise<void>

Saves the complete workspace metadata, replacing any existing structure.

Persists a full workspace metadata object. This is a wholesale replacement operation; use the individual package endpoints for targeted updates.

ParameterTypeRequiredDescription
dataSaveWorkspaceMetadataRequestYesThe complete workspace metadata to save

Returns: Promise<void> — A promise that resolves when the metadata has been saved

Full reference →


updatePackage

client.projectStructure.updatePackage(packageId: string, data: UpdatePackageRequest): Promise<PackageDefinition>

Updates an existing package definition.

Modifies the metadata and configuration of a package. Does not affect the package's sections or items; use and for those operations.

ParameterTypeRequiredDescription
packageIdstringYesThe unique identifier of the package to update
dataUpdatePackageRequestYesThe fields to update on the package

Returns: Promise<PackageDefinition> — A promise that resolves to the updated package definition

Full reference →