npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sthg-sdk/filesystem.api

v1.2.7

Published

Filesystem API client for STHG Tiangong SDK

Readme

@sthg-sdk/filesystem.api

Filesystem API client for STHG Tiangong SDK - provides a comprehensive interface for managing spaces, projects, folders, and resources in the filesystem service.

Installation

npm install @sthg-sdk/filesystem.api

Usage

import { HttpClient } from '@sthg-sdk/shared.client';
import * as FilesystemAPI from '@sthg-sdk/filesystem.api';

// Initialize the HTTP client
const client = new HttpClient({
  baseUrl: 'https://your-api-endpoint.com',
  defaultHeaders: {
    'Authorization': 'Bearer your-auth-token',
    'Content-Type': 'application/json'
  }
});

// Create a space
const space = await FilesystemAPI.createSpace(client, {
  enName: 'my-workspace',
  displayName: 'My Workspace',
  description: 'A workspace for my projects'
});

// Create a project in the space
const project = await FilesystemAPI.createProject(client, space.data.rid, {
  displayName: 'My Project',
  description: 'A sample project'
});

// Create a folder in the project
const folder = await FilesystemAPI.createFolder(client, project.data.rid, {
  displayName: 'Data',
  description: 'Data storage folder'
});

// Upload a file
const formData = new FormData();
formData.append('file', fileBlob);
formData.append('projectRid', project.data.rid);
formData.append('spaceRid', space.data.rid);
formData.append('parentFolderRid', folder.data.rid);

const uploadResult = await FilesystemAPI.uploadFile(client, formData);

API Methods

Spaces

  • listSpaces(client, params?) - List all spaces with pagination
  • createSpace(client, request) - Create a new space
  • getSpace(client, spaceRid) - Get space details
  • updateSpace(client, spaceRid, request) - Update space information
  • deleteSpace(client, spaceRid) - Delete a space
  • getSpaceConfig(client, spaceRid) - Get space configuration
  • getSpaceStatistics(client, spaceRid) - Get space statistics
  • getAllFolderAndResource(client, spaceRid, params?) - Get all visible folders and resources

Projects

  • listProjects(client, spaceRid, params?) - List projects in a space
  • createProject(client, spaceRid, request) - Create a new project
  • getProject(client, projectRid) - Get project details
  • updateProject(client, projectRid, request) - Update project information
  • deleteProject(client, projectRid) - Permanently delete a project
  • moveProjectToTrash(client, projectRid) - Move project to trash
  • restoreProjectFromTrash(client, projectRid) - Restore project from trash
  • getProjectTree(client, projectRid) - Get project tree structure
  • getProjectStatistics(client, projectRid) - Get project statistics
  • getProjectContent(client, projectRid, params?) - Get project content
  • listProjectResources(client, projectRid, params?) - List project resources

Folders

  • listFolders(client, projectRid, params?) - List folders in a project
  • createFolder(client, projectRid, request) - Create a new folder
  • getFolder(client, folderRid) - Get folder details
  • updateFolder(client, folderRid, request) - Update folder information
  • deleteFolder(client, folderRid) - Permanently delete a folder
  • moveFolder(client, folderRid, request) - Move folder to new location
  • moveFolderToTrash(client, folderRid, projectRid) - Move folder to trash
  • restoreFolderFromTrash(client, folderRid) - Restore folder from trash
  • getFolderTree(client, folderRid) - Get folder tree structure
  • getFolderStatistics(client, folderRid) - Get folder statistics
  • getFolderContent(client, folderRid, params?) - Get folder content

Resources

  • createResource(client, request, params?) - Create a new resource
  • getResource(client, resourceRid) - Get resource details
  • updateResource(client, resourceRid, request) - Update resource information
  • deleteResource(client, resourceRid) - Permanently delete a resource
  • moveResource(client, resourceRid, request) - Move resource to new location
  • batchMoveResources(client, request) - Move multiple resources
  • copyResource(client, resourceRid, request) - Copy resource to new location
  • addResourceMarkings(client, resourceRid, request) - Add security markings
  • removeResourceMarkings(client, resourceRid, request) - Remove security markings
  • moveResourceToTrash(client, resourceRid, projectRid) - Move resource to trash
  • restoreResourceFromTrash(client, resourceRid) - Restore resource from trash
  • getProjectResourceStatistics(client, projectRid) - Get project resource statistics

File Upload/Download

  • uploadFile(client, formData) - Upload a single file
  • batchUploadFiles(client, formData) - Upload multiple files
  • uploadDocumentation(client, formData) - Upload documentation
  • getDownloadUrl(client, resourceRid, spaceRid, expiresInHours?) - Get download URL
  • deleteFile(client, resourceRid) - Delete file from storage

Trash Management

  • getTrashItems(client, params?) - List items in trash
  • getTrashFolders(client, params?) - List folders in trash

Utilities

  • generateRid(client, resourceType, namespace?, scope?) - Generate unique RID
  • getEntityInfo(client, rid) - Get entity information by RID
  • getTreeStructure(client, rid, params?) - Get tree structure
  • healthCheck(client) - Check service health

Types

All TypeScript types are re-exported from @sthg-sdk/tiangong.core for convenience:

import type {
  Space,
  Project,
  Folder,
  Resource,
  CreateSpaceRequest,
  CreateProjectRequest,
  // ... and many more
} from '@sthg-sdk/filesystem.api';

Error Handling

The client returns responses wrapped in ApiResponseUnion which includes both success and error cases:

const result = await client.getSpace(spaceRid);

if (result.success) {
  console.log('Space:', result.data);
} else {
  console.error('Error:', result.error);
}

License

Apache-2.0