@usync/drive 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import { IRequestOptions } from '@gera2ld/common';
2
- import { OAuth2Authorizer } from '@usync/oauth2';
3
- import { IAuthConfig, IFilePath, IRemoteFile, IUserInfo } from '../types';
1
+ import { type IRequestOptions } from "@gera2ld/common";
2
+ import { OAuth2Authorizer } from "@usync/oauth2";
3
+ import type { IAuthConfig, IFilePath, IRemoteFile, IUserInfo } from "../types";
4
4
  export type ITypedRequestOptions = IRequestOptions & {
5
- responseType: 'json' | 'blob' | 'text';
5
+ responseType: "json" | "blob" | "text";
6
6
  };
7
7
  export type IRequestFunction = <T>(url: string, options: ITypedRequestOptions) => Promise<T>;
8
8
  export declare function withDelay(request: IRequestFunction): <T>(url: string, options: ITypedRequestOptions) => Promise<T>;
@@ -26,8 +26,9 @@ export declare abstract class AuthenticatedDriveBase extends DriveBase {
26
26
  protected context: Record<string, unknown>;
27
27
  baseUrl: string | undefined;
28
28
  request: IRequestFunction;
29
+ account: IUserInfo | undefined;
29
30
  constructor(authConfig: IAuthConfig, context: Record<string, unknown>);
30
31
  initRequest(): IRequestFunction;
31
- getAccount(): Promise<IUserInfo>;
32
+ abstract getAccount(): Promise<IUserInfo>;
32
33
  }
33
34
  export declare function unicodeReplacer(_key: string, value: unknown): unknown;
@@ -1,13 +1,9 @@
1
- import type { IFilePath, IRemoteFile } from '../types';
2
- import { AuthenticatedDriveBase } from './base';
1
+ import type { IFilePath, IRemoteFile } from "../types";
2
+ import { AuthenticatedDriveBase } from "./base";
3
3
  export declare class Dropbox extends AuthenticatedDriveBase {
4
4
  private normalizeEntry;
5
5
  private getDropboxPath;
6
- getAccount(): Promise<{
7
- id: string;
8
- name: string;
9
- avatar: string;
10
- }>;
6
+ getAccount(): Promise<import("..").IUserInfo>;
11
7
  mkdir(param: {
12
8
  parent?: IFilePath;
13
9
  name: string;
@@ -1,13 +1,9 @@
1
- import type { IFilePath, IRemoteFile } from '../types';
2
- import { AuthenticatedDriveBase } from './base';
1
+ import type { IFilePath, IRemoteFile } from "../types";
2
+ import { AuthenticatedDriveBase } from "./base";
3
3
  export declare class GoogleDrive extends AuthenticatedDriveBase {
4
4
  baseUrl: string;
5
5
  rootId: string;
6
- getAccount(): Promise<{
7
- id: string;
8
- name: string;
9
- avatar: string;
10
- }>;
6
+ getAccount(): Promise<import("..").IUserInfo>;
11
7
  private normalizeEntry;
12
8
  private stat;
13
9
  private resolveId;
@@ -1,11 +1,13 @@
1
- import { Dropbox } from './dropbox';
2
- import { GoogleDrive } from './googledrive';
3
- import { OneDrive } from './onedrive';
4
- import { WebDav } from './webdav';
5
- export * from './base';
1
+ import { Dropbox } from "./dropbox";
2
+ import { GoogleDrive } from "./googledrive";
3
+ import { OneDrive } from "./onedrive";
4
+ import { S3 } from "./s3";
5
+ import { WebDav } from "./webdav";
6
+ export * from "./base";
6
7
  export declare const DriveProviders: {
7
8
  dropbox: typeof Dropbox;
8
9
  googledrive: typeof GoogleDrive;
9
10
  onedrive: typeof OneDrive;
11
+ s3: typeof S3;
10
12
  webdav: typeof WebDav;
11
13
  };
@@ -1,11 +1,11 @@
1
- import type { IFilePath, IRemoteFile, IUserInfo } from '../types';
2
- import { AuthenticatedDriveBase } from './base';
1
+ import type { IFilePath, IRemoteFile, IUserInfo } from "../types";
2
+ import { AuthenticatedDriveBase } from "./base";
3
3
  export interface IOneDriveItem {
4
4
  id: string;
5
5
  name: string;
6
6
  size: number;
7
7
  lastModifiedDateTime: string;
8
- '@microsoft.graph.downloadUrl': string;
8
+ "@microsoft.graph.downloadUrl": string;
9
9
  }
10
10
  export declare class OneDrive extends AuthenticatedDriveBase {
11
11
  baseUrl: string;
@@ -0,0 +1,23 @@
1
+ import type { IFilePath, IRemoteFile, IUserInfo } from "../types";
2
+ import { type ITypedRequestOptions, AuthenticatedDriveBase } from "./base";
3
+ export declare class S3 extends AuthenticatedDriveBase {
4
+ private getOptions;
5
+ private getRootPrefix;
6
+ private resolveKey;
7
+ private resolveFullKey;
8
+ private normalizeFile;
9
+ initRequest(): <T>(url: string, options: ITypedRequestOptions) => Promise<T>;
10
+ getAccount(): Promise<IUserInfo>;
11
+ mkdir(_param: {
12
+ parent?: IFilePath;
13
+ name: string;
14
+ }): Promise<IRemoteFile>;
15
+ find(param: IFilePath): Promise<IRemoteFile>;
16
+ list(parent?: IFilePath): AsyncGenerator<IRemoteFile[], void, unknown>;
17
+ get(param: IFilePath): Promise<Blob>;
18
+ remove(param: IFilePath): Promise<void>;
19
+ put(param: IFilePath & {
20
+ parent?: IFilePath;
21
+ name?: string;
22
+ }, data: Blob): Promise<IRemoteFile>;
23
+ }
@@ -1,5 +1,5 @@
1
- import type { IAuthConfig, IFilePath, IRemoteFile } from '../types';
2
- import { AuthenticatedDriveBase, IRequestFunction } from './base';
1
+ import type { IAuthConfig, IFilePath, IRemoteFile } from "../types";
2
+ import { AuthenticatedDriveBase, type IRequestFunction } from "./base";
3
3
  export interface IWebDavAuthInfo {
4
4
  anonymous?: boolean;
5
5
  user?: string;
@@ -14,11 +14,7 @@ export interface IWebDavAuthInfo {
14
14
  export declare class WebDav extends AuthenticatedDriveBase {
15
15
  constructor(authConfig: IAuthConfig, context: Record<string, unknown>);
16
16
  initRequest(): IRequestFunction;
17
- getAccount(): Promise<{
18
- id: string;
19
- name: string;
20
- avatar: string;
21
- }>;
17
+ getAccount(): Promise<import("..").IUserInfo>;
22
18
  private getWebDavPath;
23
19
  private getFullUrl;
24
20
  mkdir(param: {
package/dist/types.d.ts CHANGED
@@ -7,20 +7,20 @@ export interface IServerConfig {
7
7
  }>;
8
8
  }
9
9
  export interface IAuthConfig {
10
- authProvider: 'google' | 'dropbox' | 'microsoft' | 'password';
10
+ authProvider: "google" | "dropbox" | "microsoft" | "password";
11
11
  user: string;
12
12
  password?: string;
13
13
  serverOptions?: Record<string, unknown>;
14
14
  }
15
15
  export interface IDriveConfig {
16
- driveProvider: 'googledrive' | 'dropbox' | 'onedrive' | 'webdav';
16
+ driveProvider: "googledrive" | "dropbox" | "onedrive" | "s3" | "webdav";
17
17
  auth: IAuthConfig;
18
18
  }
19
19
  export interface IRemoteFile {
20
20
  id: string;
21
21
  name: string;
22
22
  size: number;
23
- kind: 'file' | 'folder';
23
+ kind: "file" | "folder";
24
24
  modifiedTime: string;
25
25
  }
26
26
  export interface IUserInfo {
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@usync/drive",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
+ "files": [
5
+ "dist"
6
+ ],
4
7
  "type": "module",
5
8
  "exports": {
6
9
  ".": {
@@ -8,16 +11,13 @@
8
11
  "types": "./dist/index.d.ts"
9
12
  }
10
13
  },
11
- "files": [
12
- "dist"
13
- ],
14
14
  "publishConfig": {
15
15
  "access": "public",
16
16
  "registry": "https://registry.npmjs.org/"
17
17
  },
18
18
  "dependencies": {
19
- "fast-xml-parser": "^5.3.3",
20
- "@usync/oauth2": "^0.0.3"
19
+ "fast-xml-parser": "^5.8.0",
20
+ "@usync/oauth2": "^0.0.4"
21
21
  },
22
22
  "scripts": {
23
23
  "clean": "del-cli dist tsconfig.tsbuildinfo",