/** * Palantir Foundry Filesystem API. * Folders, resources, and spaces. * * Base paths: * - Folders: /api/v2/filesystem/folders/ * - Resources: /api/v2/filesystem/resources/ * - Spaces: /api/v2/filesystem/spaces * * All filesystem endpoints require preview=true query parameter. * Folder children use /children endpoint (NOT /contents). * Resource lookup by path uses /getByPath endpoint. * * @see https://www.palantir.com/docs/foundry/api/v2/filesystem-v2-resources/ */ import type { PalantirClient } from "./client.js"; import type { Folder, Resource, CreateFolderParams, PageResponse, PageParams } from "./types.js"; /** A Foundry space (project or space). */ export interface Space { rid: string; displayName?: string; description?: string; spaceType?: string; } export class FilesystemNamespace { constructor(private client: PalantirClient) {} // ─── Folders ──────────────────────────────────────────────────── // All endpoints require preview=true /** Get a folder by RID. */ async getFolder(folderRid: string): Promise { return this.client.get( `/api/v2/filesystem/folders/${folderRid}`, { preview: true } as Record ); } /** Create a folder. */ async createFolder(params: CreateFolderParams): Promise { return this.client.post( "/api/v2/filesystem/folders?preview=true", params ); } /** List children of a folder. */ async listFolderChildren( folderRid: string, params?: PageParams ): Promise> { return this.client.get( `/api/v2/filesystem/folders/${folderRid}/children`, { ...params, preview: true } as Record ); } // ─── Resources ────────────────────────────────────────────────── /** Get a resource by RID. */ async getResource(resourceRid: string): Promise { return this.client.get( `/api/v2/filesystem/resources/${resourceRid}`, { preview: true } as Record ); } /** Get a resource by its full path. */ async getResourceByPath( path: string, params?: { domainTag?: string } ): Promise { return this.client.get( "/api/v2/filesystem/resources/getByPath", { path, ...params, preview: true } as Record ); } /** Delete a resource. */ async deleteResource(resourceRid: string): Promise { return this.client.delete( `/api/v2/filesystem/resources/${resourceRid}?preview=true` ); } // ─── Spaces ───────────────────────────────────────────────────── /** List spaces (projects). */ async listSpaces(params?: PageParams): Promise> { return this.client.get( "/api/v2/filesystem/spaces", { ...params, preview: true } as Record ); } }