Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/haruki-nikaidou/od-tree

List all files in onedrive
https://github.com/haruki-nikaidou/od-tree

Last synced: 7 days ago
JSON representation

List all files in onedrive

Awesome Lists containing this project

README

        

# OD Tree
List all files in onedrive as a file tree.

## Usage

### Easiest way: `OdTree`

```ts
import OdTree from "onedrive-tree";
await OdTree({clientId, clientSecret, refreshToken});
```

If you have got the `accessToken`, you can use

```ts
import {buildTree} from "onedrive-tree";
await buildTree(accessToken)
```

## API

### Data Structure

```ts
export type FileNode = {
name: string,
size: number,
downloadUrl: string,
type: FileNodeType.File,
}

export type DirectoryNode = {
name: string,
type: FileNodeType.Directory,
size?: number,
children: (FileNode | DirectoryNode)[]
}

export type FileTree = DirectoryNode;
```

The `token`'s type is

```ts
export type DriveToken = {
driveId: string,
accessToken: string,
}
```

### Auth

+ `getAccessToken(clientId: string, clientSecret: string, tenantId: string): Promise`
+ `getOneDriveDriveId(accessToken: string): Promise`

### Request But not Parse

+ `requestList(directoryId: string, token: DriveToken): Promise<(FileResponse | DirectoryResponse)[]>`

### Request and Parse

+ `recursiveBuildDirectory(directoryId: string, token: DriveToken, name: string, size?: number): Promise`
+ `buildFileTree(directoryId: string, token: DriveToken): Promise`