import { CellValue } from 'exceljs'; type SecretStoreKind = "keyring" | "file"; interface SharePointCredentials { readonly tenantId: string; readonly clientId: string; readonly clientSecret: string; } interface SharePointSiteRef { readonly hostname: string; readonly sitePath: string; } interface SharePointTarget { readonly credentials: SharePointCredentials; readonly site: SharePointSiteRef; } interface AccessTokenInfo { readonly accessToken: string; readonly expiresOn: number; readonly tokenType: string; readonly scope?: string; } interface SharePointSite { readonly id: string; readonly name: string; readonly displayName: string; readonly webUrl: string; } interface SharePointDrive { readonly id: string; readonly name: string; readonly driveType: string; readonly webUrl: string; } interface DriveItemSummary { readonly id: string; readonly name: string; readonly isFolder: boolean; readonly size: number; readonly eTag?: string; readonly cTag?: string; readonly webUrl?: string; } interface StoredProfile { readonly name: string; readonly tenantId: string; readonly clientId: string; readonly site: string; readonly drive?: string; readonly secretStore: SecretStoreKind; readonly updatedAt: string; } interface RedactedProfile extends Omit { readonly clientId: string; readonly hasClientSecret: boolean; } type JsonCellValue = string | number | boolean | null; type JsonRow = readonly JsonCellValue[]; type JsonRecord = Readonly>; type WorkbookInputRow = JsonRow | JsonRecord; interface WorkbookCreateInput { readonly sheetName: string; readonly headers: readonly string[]; readonly rows: readonly WorkbookInputRow[]; readonly tableName?: string; } interface WorkbookReadOptions { readonly sheetName?: string; readonly range?: string; } interface WorkbookSheetReadResult { readonly name: string; readonly rowCount: number; readonly columnCount: number; readonly rows: readonly JsonRow[]; } interface WorkbookReadResult { readonly sheets: readonly WorkbookSheetReadResult[]; } interface WorkbookMutationResult { readonly bytes: Uint8Array; readonly sheetName: string; readonly rowCount: number; readonly columnCount: number; } declare const DEFAULT_PROFILE_NAME = "default"; declare const DEFAULT_AUTH_BASE = "https://login.microsoftonline.com"; declare const DEFAULT_GRAPH_BASE = "https://graph.microsoft.com/v1.0"; declare const ENV_TENANT = "SHAREPOINT_EXCEL_TENANT_ID"; declare const ENV_CLIENT_ID = "SHAREPOINT_EXCEL_CLIENT_ID"; declare const ENV_CLIENT_SECRET = "SHAREPOINT_EXCEL_CLIENT_SECRET"; declare const ENV_SITE = "SHAREPOINT_EXCEL_SITE"; declare const ENV_DRIVE = "SHAREPOINT_EXCEL_DRIVE"; declare const ENV_PROFILE = "SHAREPOINT_EXCEL_PROFILE"; declare const ENV_AUTH_BASE = "SHAREPOINT_EXCEL_AUTH_BASE"; declare const ENV_GRAPH_BASE = "SHAREPOINT_EXCEL_GRAPH_BASE"; declare const ENV_HOME = "SAPTOOLS_SHAREPOINT_EXCEL_HOME"; declare const ENV_ALLOW_PLAINTEXT = "SAPTOOLS_SHAREPOINT_EXCEL_ALLOW_PLAINTEXT"; declare const FALLBACK_ENV_TENANT = "SHAREPOINT_TENANT_ID"; declare const FALLBACK_ENV_CLIENT_ID = "SHAREPOINT_CLIENT_ID"; declare const FALLBACK_ENV_CLIENT_SECRET = "SHAREPOINT_CLIENT_SECRET"; declare const FALLBACK_ENV_SITE = "SHAREPOINT_SITE"; declare const FALLBACK_ENV_DRIVE = "SHAREPOINT_DRIVE"; type FetchLike = typeof fetch; interface GraphRetryOptions { readonly maxRetries?: number; readonly baseDelayMs?: number; readonly sleepFn?: (ms: number) => Promise; } interface GraphClientOptions { readonly accessToken: string; readonly baseUrl?: string; readonly fetchFn?: FetchLike; readonly retry?: GraphRetryOptions; readonly env?: NodeJS.ProcessEnv; } interface GraphRequestOptions { readonly method?: string; readonly body?: unknown; readonly rawBody?: Uint8Array | string; readonly headers?: Readonly>; readonly includeAuthorization?: boolean; } interface GraphClient { readonly baseUrl: string; requestJson: (path: string, options?: GraphRequestOptions) => Promise; requestBytes: (path: string, options?: GraphRequestOptions) => Promise; requestNoContent: (path: string, options?: GraphRequestOptions) => Promise; } declare class GraphHttpError extends Error { readonly status: number; readonly code: string | undefined; readonly detail: string; constructor(status: number, code: string | undefined, detail: string); } declare function createGraphClient(options: GraphClientOptions): GraphClient; interface AcquireTokenOptions { readonly authBase?: string; readonly scope?: string; readonly fetchFn?: FetchLike; readonly env?: NodeJS.ProcessEnv; } declare function acquireAppToken(credentials: SharePointCredentials, options?: AcquireTokenOptions): Promise; declare function packageDataDir(env?: NodeJS.ProcessEnv): string; declare function profilesPath(env?: NodeJS.ProcessEnv): string; declare function fileSecretsPath(env?: NodeJS.ProcessEnv): string; interface SecretVault { getSecret: (profileName: string) => Promise; setSecret: (profileName: string, secret: string) => Promise; deleteSecret: (profileName: string) => Promise; } declare function createKeyringSecretVault(serviceName?: string): SecretVault; declare function createFileSecretVault(path?: string): SecretVault; interface ProfileStore { readProfiles: () => Promise; writeProfiles: (profiles: readonly StoredProfile[]) => Promise; } interface UpsertProfileInput { readonly name?: string; readonly tenantId: string; readonly clientId: string; readonly clientSecret: string; readonly site: string; readonly drive?: string; readonly secretStore: SecretStoreKind; readonly updatedAt?: Date; } declare function createProfileStore(path?: string): ProfileStore; declare function findProfile(profiles: readonly StoredProfile[], name?: string): StoredProfile | undefined; declare function upsertProfile(store: ProfileStore, vault: SecretVault, input: UpsertProfileInput): Promise; declare function removeProfile(store: ProfileStore, vault: SecretVault, name?: string): Promise; declare function redactProfile(profile: StoredProfile, vault: SecretVault): Promise; interface RuntimeOverrides { readonly profile?: string | undefined; readonly tenant?: string | undefined; readonly clientId?: string | undefined; readonly clientSecret?: string | undefined; readonly site?: string | undefined; readonly drive?: string | undefined; } interface ResolveRuntimeOptions { readonly env?: NodeJS.ProcessEnv; readonly overrides?: RuntimeOverrides; readonly profileStore?: ProfileStore; readonly keyringVault?: SecretVault; readonly fileVault?: SecretVault; } interface ResolvedRuntime { readonly target: SharePointTarget; readonly drive?: string; readonly profileName: string; readonly source: "profile" | "env"; } declare function resolveRuntime(options?: ResolveRuntimeOptions): Promise; declare function parseSecretStoreKind(value: string | undefined): SecretStoreKind; declare function encodeDrivePath(relativePath: string): string; declare function listDrives(client: GraphClient, siteId: string): Promise; declare function selectDrive(drives: readonly SharePointDrive[], driveHint: string | undefined): SharePointDrive; declare function getDriveItemByPath(client: GraphClient, driveId: string, relativePath: string): Promise; declare function downloadDriveFile(client: GraphClient, driveId: string, relativePath: string): Promise; declare function uploadNewDriveFile(client: GraphClient, driveId: string, relativePath: string, bytes: Uint8Array): Promise; declare function replaceDriveFile(client: GraphClient, driveId: string, relativePath: string, eTag: string, bytes: Uint8Array): Promise; declare function parseSiteRef(input: string): SharePointSiteRef; declare function resolveSite(client: GraphClient, ref: SharePointSiteRef): Promise; interface SessionOptions { readonly fetchFn?: FetchLike; readonly authBase?: string; readonly graphBase?: string; readonly retry?: GraphRetryOptions; } interface SharePointExcelSession { readonly token: AccessTokenInfo; readonly client: GraphClient; readonly site: SharePointSite; readonly drives: readonly SharePointDrive[]; } declare function openSession(target: SharePointTarget, options?: SessionOptions): Promise; interface A1CellRef { readonly row: number; readonly column: number; } interface A1RangeRef { readonly start: A1CellRef; readonly end: A1CellRef; } declare function columnNameToNumber(columnName: string): number; declare function parseA1Cell(input: string): A1CellRef; declare function parseA1Range(input: string): A1RangeRef; declare function createWorkbookBytes(input: WorkbookCreateInput): Promise; declare function readWorkbookBytes(bytes: Uint8Array, options?: WorkbookReadOptions): Promise; declare function appendWorkbookRows(bytes: Uint8Array, sheetName: string, rows: readonly WorkbookInputRow[], matchHeader: boolean): Promise; declare function updateWorkbookCell(bytes: Uint8Array, sheetName: string, cellRef: string, value: CellValue): Promise; declare function addWorkbookSheet(bytes: Uint8Array, sheetName: string, headers: readonly string[]): Promise; declare function parseHeaders(input: string | undefined): readonly string[]; declare function parseCellValue(input: string): JsonCellValue; declare function parseWorkbookRows(input: string | undefined): readonly WorkbookInputRow[]; interface WorkbookServiceTarget { readonly session: SharePointExcelSession; readonly driveHint?: string; } interface RemoteWorkbookResult { readonly driveId: string; readonly driveName: string; readonly path: string; readonly item: DriveItemSummary; } interface RemoteReadResult extends RemoteWorkbookResult { readonly workbook: WorkbookReadResult; } interface RemoteMutationResult extends RemoteWorkbookResult { readonly mutation: WorkbookMutationResult; } declare function createRemoteWorkbook(target: WorkbookServiceTarget, path: string, input: WorkbookCreateInput): Promise; declare function readRemoteWorkbook(target: WorkbookServiceTarget, path: string, options?: WorkbookReadOptions): Promise; declare function appendRemoteWorkbookRows(target: WorkbookServiceTarget, path: string, sheetName: string, rows: readonly WorkbookInputRow[], matchHeader: boolean): Promise; declare function updateRemoteWorkbookCell(target: WorkbookServiceTarget, path: string, sheetName: string, cellRef: string, value: string | number | boolean | null): Promise; declare function addRemoteWorkbookSheet(target: WorkbookServiceTarget, path: string, sheetName: string, headers: readonly string[]): Promise; export { type AccessTokenInfo, type AcquireTokenOptions, DEFAULT_AUTH_BASE, DEFAULT_GRAPH_BASE, DEFAULT_PROFILE_NAME, type DriveItemSummary, ENV_ALLOW_PLAINTEXT, ENV_AUTH_BASE, ENV_CLIENT_ID, ENV_CLIENT_SECRET, ENV_DRIVE, ENV_GRAPH_BASE, ENV_HOME, ENV_PROFILE, ENV_SITE, ENV_TENANT, FALLBACK_ENV_CLIENT_ID, FALLBACK_ENV_CLIENT_SECRET, FALLBACK_ENV_DRIVE, FALLBACK_ENV_SITE, FALLBACK_ENV_TENANT, type FetchLike, type GraphClient, type GraphClientOptions, GraphHttpError, type GraphRequestOptions, type GraphRetryOptions, type JsonCellValue, type JsonRecord, type JsonRow, type ProfileStore, type RedactedProfile, type RemoteMutationResult, type RemoteReadResult, type RemoteWorkbookResult, type ResolveRuntimeOptions, type ResolvedRuntime, type RuntimeOverrides, type SecretStoreKind, type SecretVault, type SessionOptions, type SharePointCredentials, type SharePointDrive, type SharePointExcelSession, type SharePointSite, type SharePointSiteRef, type SharePointTarget, type StoredProfile, type UpsertProfileInput, type WorkbookCreateInput, type WorkbookInputRow, type WorkbookMutationResult, type WorkbookReadOptions, type WorkbookReadResult, type WorkbookServiceTarget, type WorkbookSheetReadResult, acquireAppToken, addRemoteWorkbookSheet, addWorkbookSheet, appendRemoteWorkbookRows, appendWorkbookRows, columnNameToNumber, createFileSecretVault, createGraphClient, createKeyringSecretVault, createProfileStore, createRemoteWorkbook, createWorkbookBytes, downloadDriveFile, encodeDrivePath, fileSecretsPath, findProfile, getDriveItemByPath, listDrives, openSession, packageDataDir, parseA1Cell, parseA1Range, parseCellValue, parseHeaders, parseSecretStoreKind, parseSiteRef, parseWorkbookRows, profilesPath, readRemoteWorkbook, readWorkbookBytes, redactProfile, removeProfile, replaceDriveFile, resolveRuntime, resolveSite, selectDrive, updateRemoteWorkbookCell, updateWorkbookCell, uploadNewDriveFile, upsertProfile };