/** * Palantir Foundry v2 API types. * All types derived from the public API documentation. * @see https://www.palantir.com/docs/foundry/api/v2 */ // ─── Auth & Config ────────────────────────────────────────────────── export interface PalantirConfig { /** Foundry stack URL, e.g. https://foundry.example.com */ stackUrl: string; /** OAuth2 client ID from Developer Console */ clientId: string; /** OAuth2 client secret (for confidential/client credentials grant) */ clientSecret?: string; /** OAuth2 redirect URL (for public/authorization code grant) */ redirectUrl?: string; /** Bearer token (if already obtained) */ token?: string; /** Refresh token for token renewal */ refreshToken?: string; /** OAuth2 scopes to request */ scopes?: string[]; } export type TokenProvider = () => Promise | string; export interface OAuth2TokenResponse { access_token: string; token_type: "Bearer"; expires_in: number; refresh_token?: string; scope?: string; } // ─── Pagination ───────────────────────────────────────────────────── export interface PageParams { pageSize?: number; pageToken?: string; [key: string]: unknown; } export interface PageResponse { data: T[]; nextPageToken?: string; totalCount?: number; } // ─── Admin — Users ────────────────────────────────────────────────── export type UserStatus = "ACTIVE" | "DELETED"; export interface User { id: string; username: string; givenName?: string; familyName?: string; email?: string; realm: string; organization?: string; status: UserStatus; attributes?: Record; } // ─── Ontologies ───────────────────────────────────────────────────── export interface Ontology { apiName: string; displayName: string; description?: string; rid: string; } export interface ObjectType { apiName: string; displayName?: string; description?: string; primaryKey: ObjectTypePrimaryKey; rid: string; status?: string; icon?: string; visibility?: string; } export interface ObjectTypePrimaryKey { objectTypeApiName?: string; primaryKeyPropertyApiName?: string; propertyApiNames?: string[]; } export interface OntologyObject { __rid?: string; __primaryKey: string | number; __apiName?: string; __title?: string; [property: string]: unknown; } export interface ListObjectsParams extends PageParams { select?: string[]; orderBy?: string; excludeRid?: boolean; snapshot?: boolean; branch?: string; } // ─── Action Types ─────────────────────────────────────────────────── export interface ActionType { apiName: string; description?: string; parameters: Record; rid: string; status?: string; operations?: ActionOperation[]; } export interface ActionParameter { dataType: ActionParameterDataType; description?: string; displayName?: string; required?: boolean; } export interface ActionParameterDataType { type: string; objectType?: ObjectType; subConstraints?: ActionParameterDataType[]; } export interface ActionOperation { readonly: boolean; objectTypeApiName: string; objectSetParameterApiName?: string; } export interface ApplyActionParams { parameters: Record; options?: { mode?: "VALIDATE_ONLY" | "VALIDATE_AND_EXECUTE"; }; } export interface ApplyActionResponse { eid: string; validation?: Record; } // ─── Function Types ───────────────────────────────────────────────── export interface FunctionType { rid: string; apiName: string; displayName?: string; description?: string; parameters: FunctionParameter[]; output: FunctionParameter; version?: string; } export interface FunctionParameter { apiName: string; dataType: ActionParameterDataType; description?: string; required?: boolean; } export interface ExecuteFunctionParams { parameters: Record; branch?: string; } // ─── Query Types ──────────────────────────────────────────────────── export interface QueryType { apiName: string; rid: string; displayName?: string; description?: string; parameters: QueryParameter[]; output: QueryParameter; } export interface QueryParameter { apiName: string; dataType: ActionParameterDataType; description?: string; required?: boolean; } // ─── Datasets ─────────────────────────────────────────────────────── export type TransactionType = "SNAPSHOT" | "UPDATE" | "APPEND" | "DELETE"; export type TransactionStatus = "OPEN" | "COMMITTED" | "ABORTED"; export interface Dataset { rid: string; name: string; parentFolderRid: string; } export interface CreateDatasetParams { parentFolderRid: string; name: string; } export interface Branch { rid: string; name: string; datasetRid: string; parentBranchId?: string; } export interface CreateBranchParams { branchId: string; parentBranchId?: string; } export interface Transaction { rid: string; datasetRid: string; branchId: string; type: TransactionType; status: TransactionStatus; startTime?: string; endTime?: string; } export interface CreateTransactionParams { branchId?: string; type: TransactionType; record?: Record; } export interface FileMetadata { path: string; sizeBytes?: number; lastModified?: string; transactionRid?: string; } export interface DatasetSchema { schemaId: string; datasetRid: string; branchId?: string; fieldSchemaList: FieldSchema[]; } export interface FieldSchema { name: string; type: string; nullable?: boolean; description?: string; } // ─── Filesystem ───────────────────────────────────────────────────── export interface Folder { rid: string; displayName?: string; description?: string; parentFolderRid?: string; path?: string; createdTime?: string; modifiedTime?: string; lastModifiedBy?: string; } export interface Resource { rid: string; name: string; path: string; type: "FOLDER" | "OBJECT_SET" | "DATASET" | "OBJECT_TYPE" | "LINK_TYPE" | "INTERFACE_TYPE" | "ACTION_TYPE" | "QUERY_TYPE" | "CONSTRAINT" | "OND"; description?: string; lastModified?: string; createdBy?: string; } export interface CreateFolderParams { parentFolderRid: string; name: string; } // ─── Operations ───────────────────────────────────────────────────── export interface Operation { rid: string; status: string; createdTime?: string; endTime?: string; type?: string; [key: string]: unknown; } // ─── Connectivity ─────────────────────────────────────────────────── export interface Connection { rid: string; apiName: string; displayName?: string; description?: string; connectionType?: string; status?: string; } // ─── Orchestration (Schedules) ────────────────────────────────────── export interface Schedule { rid: string; displayName?: string; description?: string; /** Cron expression, e.g. "0 9 * * MON-FRI" */ scheduleTrigger?: { cronExpression?: string; timezone?: string; }; /** The action or build to run */ action?: { type: string; rid: string; }; paused?: boolean; createdTime?: string; modifiedTime?: string; [key: string]: unknown; } export interface CreateScheduleParams { displayName?: string; description?: string; scheduleTrigger?: { cronExpression: string; timezone?: string; }; action: { type: string; rid: string; }; } export interface ScheduleRun { rid: string; scheduleRid: string; status: "SCHEDULED" | "RUNNING" | "SUCCEEDED" | "FAILED" | "CANCELLED"; startTime?: string; endTime?: string; createdTime?: string; [key: string]: unknown; } // ─── AIP Agents ───────────────────────────────────────────────────── export interface AipAgent { rid: string; apiName: string; displayName?: string; description?: string; } export interface AipAgentSession { sessionId: string; agentRid: string; createdTime?: string; metadata?: Record; } export interface AipAgentMessage { messageId: string; role: "USER" | "AI" | "SYSTEM"; content: string; createdTime?: string; attachments?: unknown[]; } export interface AipContinueParams { userMessage: string; attachments?: unknown[]; /** Abort previous in-flight request */ force?: boolean; } export interface AipContinueResponse { sessionId: string; messages: AipAgentMessage[]; /** Final response text from the agent */ text?: string; } export interface AipStreamingChunk { type: "text" | "tool_call" | "tool_result" | "done" | "error"; text?: string; toolCall?: { name: string; arguments?: Record; }; toolResult?: unknown; error?: string; [key: string]: unknown; } // ─── Language Models ──────────────────────────────────────────────── export interface LanguageModel { modelId: string; displayName?: string; provider?: string; } export interface ChatCompletionParams { modelId: string; messages: ChatMessage[]; temperature?: number; maxTokens?: number; stopSequences?: string[]; } export interface ChatMessage { role: "system" | "user" | "assistant"; content: string; } export interface ChatCompletionResponse { id: string; modelId: string; choices: ChatChoice[]; usage?: { promptTokens: number; completionTokens: number; totalTokens: number; }; } export interface ChatChoice { index: number; message: ChatMessage; finishReason?: string; } // ─── Streams ──────────────────────────────────────────────────────── export interface Stream { rid: string; apiName: string; displayName?: string; } // ─── SQL Queries ──────────────────────────────────────────────────── export interface SqlQuery { rid: string; apiName?: string; displayName?: string; query: string; } export interface SqlQueryResult { rows: Record[]; columns: { name: string; type: string }[]; } // ─── Audit ────────────────────────────────────────────────────────── export interface AuditLog { eventId: string; timestamp: string; userId?: string; operation: string; resourceRid?: string; resourceType?: string; [key: string]: unknown; } // ─── Data Health ──────────────────────────────────────────────────── export interface DataHealthCheck { rid: string; status: string; checks?: DataHealthCheckItem[]; } export interface DataHealthCheckItem { checkId: string; status: string; message?: string; } // ─── Checkpoints ──────────────────────────────────────────────────── export interface Checkpoint { rid: string; datasetRid: string; transactionRid: string; createdTime?: string; } // ─── Mediasets ────────────────────────────────────────────────────── export interface Mediaset { rid: string; apiName: string; displayName?: string; } // ─── Models ───────────────────────────────────────────────────────── export interface Model { rid: string; apiName: string; displayName?: string; description?: string; } // ─── Notepad ──────────────────────────────────────────────────────── export interface Notepad { rid: string; displayName?: string; content?: string; } // ─── Third Party Applications ─────────────────────────────────────── export interface ThirdPartyApplication { rid: string; clientId: string; displayName?: string; description?: string; status?: string; } // ─── Geo ──────────────────────────────────────────────────────────── export interface GeoPoint { type: "Point"; coordinates: [number, number]; } export interface GeoPolygon { type: "Polygon"; coordinates: number[][][]; } // ─── Widgets ──────────────────────────────────────────────────────── export interface Widget { rid: string; apiName: string; displayName?: string; type?: string; } // ─── Public APIs ──────────────────────────────────────────────────── export interface PublicApi { rid: string; apiName: string; displayName?: string; endpoints?: PublicApiEndpoint[]; } export interface PublicApiEndpoint { path: string; method: string; description?: string; } // ─── OAuth Scopes ─────────────────────────────────────────────────── export const ApiScopes = { admin: { read: "api:admin-read", write: "api:admin-write" }, ontologies: { read: "api:ontologies-read", write: "api:ontologies-write" }, datasets: { read: "api:datasets-read", write: "api:datasets-write" }, connectivity: { read: "api:connectivity-read", write: "api:connectivity-write" }, orchestration: { read: "api:orchestration-read", write: "api:orchestration-write" }, mediadata: { read: "api:mediadata-read", write: "api:mediadata-write" }, compass: { read: "api:compass-read", write: "api:compass-write" }, useLanguageModels: "api:use-language-models-execute", offlineAccess: "offline_access", } as const; export type ApiScope = (typeof ApiScopes)[keyof typeof ApiScopes] | string;