FsApi
TypeScript SDK: the Fs - FileSystem operations, 16 methods, each with its parameters, result and a complete example.
TypeScript SDK · @bimworks/sdk · class · 16 methods
BIM.works repository's virtual filesystem related calls.
Construct it with the client of the connect step: new FsApi(client). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
createNode | CreateNode | Create a new Node |
deleteNode | DeleteNode | Delete a Node |
deleteNodeError | DeleteNodeError | Clear an error of a Node |
deleteVersion | DeleteVersion | Delete a Version of a Node |
downloadAsZip | DownloadAsZip | Download a folder Node and everything below it as a ZIP file |
getNode | GetNode | Get Node based on a given path, by its UUID or by the UUID of one of its Versions. |
getRootNodeUuid | GetRootNodeUuid | Get the UUID of the current root Node. |
getVersion | GetVersion | Get a Version by its UUID |
listNodeErrors | ListNodeErrors | Get the errors of the given Node |
listNodes | ListNodes | Get a list of Nodes that are children of the given Node |
listNodesRecursive | ListNodesRecursive | Get all Nodes below the given Node, recursively |
listVersions | ListVersions | Get a list of all the Versions of the given Node, or the given Versions |
moveNode | MoveNode | Move a Node to another parent folder |
undeleteNode | UndeleteNode | Restore a previously deleted Node |
updateNode | UpdateNode | Update a Node |
updateVersion | UpdateVersion | Change a Version's disciplines or alignment |
createNode#
createNode(requestParameters: { createNodeRequest: CreateNodeRequest }): Promise<Node>Create a new Node.
| Operation | CreateNode · POST /openapi/fs/CreateNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
createNodeRequest | CreateNodeRequestrequired | The request: its properties are those of the model, its JSON that of CreateNode's request body. |
Returns#
Node — The new Node
Example#
import { AuthApi, Configuration, CreateNodeRequestFromJSON, FsApi, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = CreateNodeRequestFromJSON({
"name": "",
"folder": false,
"input_file_type": "IFC",
"parent_node_uuid": "00000000-0000-0000-0000-000000000000",
"allow_existing": false
});
// 3. The call
const result = await new FsApi(client).createNode({ createNodeRequest: request });
// 4. The result
console.log(JSON.stringify(NodeToJSON(result), null, 2));deleteNode#
deleteNode(requestParameters: { deleteNodeRequest: DeleteNodeRequest }): Promise<void>Delete a Node. Deletes the given Node, named by uuid or by path. This is a soft delete, a deleted Node can be restored with UndeleteNode. The Root Node of the current token cannot be deleted. With if_exists a Node that does not exist is no error.
| Operation | DeleteNode · POST /openapi/fs/DeleteNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
deleteNodeRequest | DeleteNodeRequestrequired | The request: its properties are those of the model, its JSON that of DeleteNode's request body. |
Returns#
Nothing: the operation answers without a body (The Node was deleted).
Example#
import { AuthApi, Configuration, DeleteNodeRequestFromJSON, FsApi } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = DeleteNodeRequestFromJSON({
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
await new FsApi(client).deleteNode({ deleteNodeRequest: request });
// 4. The result
// (DeleteNode answers no content: the call returns once it succeeded and throws a ResponseError otherwise)
console.log("Done");deleteNodeError#
deleteNodeError(requestParameters: { deleteNodeErrorRequest: DeleteNodeErrorRequest }): Promise<void>Clear an error of a Node. Removes an error record (a failed upload or checkin, see ListNodeErrors) once its cause is dealt with. Needs write rights on the Node.
| Operation | DeleteNodeError · POST /openapi/fs/DeleteNodeError |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
deleteNodeErrorRequest | DeleteNodeErrorRequestrequired | The request: its properties are those of the model, its JSON that of DeleteNodeError's request body. |
Returns#
Nothing: the operation answers without a body (The error is cleared).
Example#
import { AuthApi, Configuration, DeleteNodeErrorRequestFromJSON, FsApi } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = DeleteNodeErrorRequestFromJSON({
"node_uuid": "00000000-0000-0000-0000-000000000000",
"error_uuid": "00000000-0000-0000-0000-000000000000"
});
// 3. The call
await new FsApi(client).deleteNodeError({ deleteNodeErrorRequest: request });
// 4. The result
// (DeleteNodeError answers no content: the call returns once it succeeded and throws a ResponseError otherwise)
console.log("Done");deleteVersion#
deleteVersion(requestParameters: { deleteVersionRequest: DeleteVersionRequest }): Promise<void>Delete a Version of a Node. Only the last Version of a Node can be deleted, intermediate Versions must stay available.
| Operation | DeleteVersion · POST /openapi/fs/DeleteVersion |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
deleteVersionRequest | DeleteVersionRequestrequired | The request: its properties are those of the model, its JSON that of DeleteVersion's request body. |
Returns#
Nothing: the operation answers without a body (The Version was deleted).
Example#
import { AuthApi, Configuration, DeleteVersionRequestFromJSON, FsApi } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = DeleteVersionRequestFromJSON({
"node_uuid": "00000000-0000-0000-0000-000000000000",
"version_uuid": "<version uuid of the first demo model>"
});
// 3. The call
await new FsApi(client).deleteVersion({ deleteVersionRequest: request });
// 4. The result
// (DeleteVersion answers no content: the call returns once it succeeded and throws a ResponseError otherwise)
console.log("Done");downloadAsZip#
downloadAsZip(requestParameters: { downloadAsZipRequest: DownloadAsZipRequest }): Promise<Blob>Download a folder Node and everything below it as a ZIP file. The ZIP file contains the original model files of the last Version of every Node below the given folder Node, with their tree paths as ZIP entry paths. With format ZIP_ZST the same ZIP comes compressed as a whole with zstd, a .zip.zst file.
| Operation | DownloadAsZip · POST /openapi/fs/DownloadAsZip |
|---|---|
| Scope | model:read |
Parameters#
| Name | Type | Description |
|---|---|---|
downloadAsZipRequest | DownloadAsZipRequestrequired | The request: its properties are those of the model, its JSON that of DownloadAsZip's request body. |
Returns#
Blob — The ZIP file, or with format ZIP_ZST the zstd-compressed ZIP file
Example#
import { writeFileSync } from "node:fs";
import { AuthApi, Configuration, DownloadAsZipRequestFromJSON, FsApi } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = DownloadAsZipRequestFromJSON({
"uuid": "<version uuid of the first demo model>",
"include_deleted": false,
"format": "ZIP"
});
// 3. The call
const result = await new FsApi(client).downloadAsZip({ downloadAsZipRequest: request });
// 4. The result
writeFileSync("download-as-zip.zip", Buffer.from(await result.arrayBuffer()));getNode#
getNode(requestParameters: { getNodeRequest: GetNodeRequest }): Promise<Node>Get Node based on a given path, by its UUID or by the UUID of one of its Versions. A path is always relative to the Root Node of the used Token.
| Operation | GetNode · POST /openapi/fs/GetNode |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
getNodeRequest | GetNodeRequestrequired | The request: its properties are those of the model, its JSON that of GetNode's request body. |
Returns#
Node — All information of the Node on this path
Example#
import { AuthApi, Configuration, FsApi, GetNodeRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = GetNodeRequestFromJSON({
"path": "",
"uuid": "<version uuid of the first demo model>",
"version_uuid": "<version uuid of the first demo model>"
});
// 3. The call
const result = await new FsApi(client).getNode({ getNodeRequest: request });
// 4. The result
console.log(JSON.stringify(NodeToJSON(result), null, 2));getRootNodeUuid#
getRootNodeUuid(): Promise<string>Get the UUID of the current root Node. This depends on the API Token/Auth Token that is being used.
| Operation | GetRootNodeUuid · GET /openapi/fs/GetRootNodeUuid |
|---|---|
| Scope | fs:read |
Parameters#
None: the operation takes no request.
Returns#
string — The UUID of the Root Node
Example#
import { AuthApi, Configuration, FsApi } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
// (GetRootNodeUuid takes no request)
// 3. The call
const result = await new FsApi(client).getRootNodeUuid();
// 4. The result
console.log(result);getVersion#
getVersion(requestParameters: { getVersionRequest: GetVersionRequest }): Promise<ModelVersion>Get a Version by its UUID.
| Operation | GetVersion · POST /openapi/fs/GetVersion |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
getVersionRequest | GetVersionRequestrequired | The request: its properties are those of the model, its JSON that of GetVersion's request body. |
Returns#
ModelVersion — Version information
Example#
import { AuthApi, Configuration, FsApi, GetVersionRequestFromJSON, ModelVersionToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = GetVersionRequestFromJSON({
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
const result = await new FsApi(client).getVersion({ getVersionRequest: request });
// 4. The result
console.log(JSON.stringify(ModelVersionToJSON(result), null, 2));listNodeErrors#
listNodeErrors(requestParameters: { listNodeErrorsRequest: ListNodeErrorsRequest }): Promise<Array<ModelError>>Get the errors of the given Node. Model uploads are processed asynchronously. When processing fails, the resulting errors can be retrieved with this call. Errors are sorted oldest first.
| Operation | ListNodeErrors · POST /openapi/fs/ListNodeErrors |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
listNodeErrorsRequest | ListNodeErrorsRequestrequired | The request: its properties are those of the model, its JSON that of ListNodeErrors's request body. |
Returns#
Array<ModelError> — The errors of the given Node
Example#
import { AuthApi, Configuration, FsApi, ListNodeErrorsRequestFromJSON, ModelErrorToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = ListNodeErrorsRequestFromJSON({
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
const result = await new FsApi(client).listNodeErrors({ listNodeErrorsRequest: request });
// 4. The result
console.log(JSON.stringify(result.map(ModelErrorToJSON), null, 2));listNodes#
listNodes(requestParameters: { listNodesRequest: ListNodesRequest }): Promise<Array<Node>>Get a list of Nodes that are children of the given Node.
| Operation | ListNodes · POST /openapi/fs/ListNodes |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
listNodesRequest | ListNodesRequestrequired | The request: its properties are those of the model, its JSON that of ListNodes's request body. |
Returns#
Array<Node> — All information of the sub Nodes of the provided Node
Example#
import { AuthApi, Configuration, FsApi, ListNodesRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = ListNodesRequestFromJSON({
"path": "",
"uuid": "<version uuid of the first demo model>",
"version_uuid": "<version uuid of the first demo model>",
"show_deleted_nodes": false
});
// 3. The call
const result = await new FsApi(client).listNodes({ listNodesRequest: request });
// 4. The result
console.log(JSON.stringify(result.map(NodeToJSON), null, 2));listNodesRecursive#
listNodesRecursive(requestParameters: { listNodesRecursiveRequest: ListNodesRecursiveRequest }): Promise<Array<Node>>Get all Nodes below the given Node, recursively. Returns the given Node and all Nodes below it. Use caution on large trees, there is no pagination.
| Operation | ListNodesRecursive · POST /openapi/fs/ListNodesRecursive |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
listNodesRecursiveRequest | ListNodesRecursiveRequestrequired | The request: its properties are those of the model, its JSON that of ListNodesRecursive's request body. |
Returns#
Array<Node> — The Node and all Nodes below it
Example#
import { AuthApi, Configuration, FsApi, ListNodesRecursiveRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = ListNodesRecursiveRequestFromJSON({
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
const result = await new FsApi(client).listNodesRecursive({ listNodesRecursiveRequest: request });
// 4. The result
console.log(JSON.stringify(result.map(NodeToJSON), null, 2));listVersions#
listVersions(requestParameters: { listVersionsRequest: ListVersionsRequest }): Promise<Array<ModelVersion>>Get a list of all the Versions of the given Node, or the given Versions. Name the Node with one of path, uuid and version_uuid (a Version of the Node), or pass version_uuids to get those Versions, which may belong to different Nodes. Each Version needs read rights.
| Operation | ListVersions · POST /openapi/fs/ListVersions |
|---|---|
| Scope | fs:read |
Parameters#
| Name | Type | Description |
|---|---|---|
listVersionsRequest | ListVersionsRequestrequired | The request: its properties are those of the model, its JSON that of ListVersions's request body. |
Returns#
Array<ModelVersion> — All information of the Versions of the given Node, or of the given Versions
Example#
import { AuthApi, Configuration, FsApi, ListVersionsRequestFromJSON, ModelVersionToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = ListVersionsRequestFromJSON({
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
const result = await new FsApi(client).listVersions({ listVersionsRequest: request });
// 4. The result
console.log(JSON.stringify(result.map(ModelVersionToJSON), null, 2));moveNode#
moveNode(requestParameters: { moveNodeRequest: MoveNodeRequest }): Promise<Node>Move a Node to another parent folder. Moves the given Node under a new parent Node. The target Node must be a folder. Renaming is done with UpdateNode.
| Operation | MoveNode · POST /openapi/fs/MoveNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
moveNodeRequest | MoveNodeRequestrequired | The request: its properties are those of the model, its JSON that of MoveNode's request body. |
Returns#
Node — The moved Node
Example#
import { AuthApi, Configuration, FsApi, MoveNodeRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = MoveNodeRequestFromJSON({
"uuid": "<version uuid of the first demo model>",
"target_parent_uuid": "00000000-0000-0000-0000-000000000000"
});
// 3. The call
const result = await new FsApi(client).moveNode({ moveNodeRequest: request });
// 4. The result
console.log(JSON.stringify(NodeToJSON(result), null, 2));undeleteNode#
undeleteNode(requestParameters: { undeleteNodeRequest: UndeleteNodeRequest }): Promise<void>Restore a previously deleted Node.
| Operation | UndeleteNode · POST /openapi/fs/UndeleteNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
undeleteNodeRequest | UndeleteNodeRequestrequired | The request: its properties are those of the model, its JSON that of UndeleteNode's request body. |
Returns#
Nothing: the operation answers without a body (The Node was restored).
Example#
import { AuthApi, Configuration, FsApi, UndeleteNodeRequestFromJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = UndeleteNodeRequestFromJSON({
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
await new FsApi(client).undeleteNode({ undeleteNodeRequest: request });
// 4. The result
// (UndeleteNode answers no content: the call returns once it succeeded and throws a ResponseError otherwise)
console.log("Done");updateNode#
updateNode(requestParameters: { updateNodeRequest: UpdateNodeRequest }): Promise<Node>Update a Node.
| Operation | UpdateNode · POST /openapi/fs/UpdateNode |
|---|---|
| Scope | fs:write |
Parameters#
| Name | Type | Description |
|---|---|---|
updateNodeRequest | UpdateNodeRequestrequired | The request: its properties are those of the model, its JSON that of UpdateNode's request body. |
Returns#
Node — The updated Node
Example#
import { AuthApi, Configuration, FsApi, NodeToJSON, UpdateNodeRequestFromJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = UpdateNodeRequestFromJSON({
"path": "",
"uuid": "<version uuid of the first demo model>",
"version_uuid": "<version uuid of the first demo model>",
"name": "",
"user_data": {}
});
// 3. The call
const result = await new FsApi(client).updateNode({ updateNodeRequest: request });
// 4. The result
console.log(JSON.stringify(NodeToJSON(result), null, 2));updateVersion#
updateVersion(requestParameters: { updateVersionRequest: UpdateVersionRequest }): Promise<ModelVersion>Change a Version's disciplines or alignment. Changes the fields that are passed in one transaction; the others stay as they are. disciplines: [] clears the disciplines, clear: [alignment] the alignment. Needs write rights on the Version.
| Operation | UpdateVersion · POST /openapi/fs/UpdateVersion |
|---|---|
| Scope | model:write |
Parameters#
| Name | Type | Description |
|---|---|---|
updateVersionRequest | UpdateVersionRequestrequired | The request: its properties are those of the model, its JSON that of UpdateVersion's request body. |
Returns#
ModelVersion — The Version as it is now
Example#
import { AuthApi, Configuration, FsApi, ModelVersionToJSON, UpdateVersionRequestFromJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = UpdateVersionRequestFromJSON({
"version_uuid": "<version uuid of the first demo model>",
"disciplines": [
"STRUCTURAL",
"ARCHITECTURAL"
]
});
// 3. The call
const result = await new FsApi(client).updateVersion({ updateVersionRequest: request });
// 4. The result
console.log(JSON.stringify(ModelVersionToJSON(result), null, 2));