Class default

Hierarchy

  • default

Constructors

  • initialize the API with accessToken

    Parameters

    • accessToken: string

    Returns default

Accessors

  • get detailFetch(): Readonly<{
        endpoint: string;
        error?: {
            code: string;
            innererror: {
                code: string;
            };
            message: string;
        };
        headers: Headers;
        status: number;
        statusText: string;
    }>
  • A getter that expose the error info needed by the error handler

    Returns Readonly<{
        endpoint: string;
        error?: {
            code: string;
            innererror: {
                code: string;
            };
            message: string;
        };
        headers: Headers;
        status: number;
        statusText: string;
    }>

Methods

  • Return a collection of DriveItems in the children relationship of a DriveItem. DriveItems with a non-null folder or package facet can have one or more child DriveItems.

    Example

    children(""); children("/"); // both is for root
    

    See

    https://docs.microsoft.com/onedrive/developer/rest-api/api/driveitem_list_children

    Parameters

    • itemLocator: ItemLocator

      bare string only if you know the API, otherwise use {path: "/path/to/file"} or {id: "id"}

    • Optional appendix: ODataAppendix

      ODataAppendix, like {select: "id,name,size,@microsoft.graph.downloadUrl"}

    Returns Promise<{
        @odata.context: string;
        @odata.count: number;
        value: Readonly<{
            @microsoft.graph.downloadUrl: string;
            createdBy: IdentitySet;
            createdDateTime: string;
            file: {
                hashes: {
                    crc32Hash: string;
                    quickXorHash: string;
                    sha1Hash: string;
                };
                mimeType: string;
                processingMetadata: boolean;
            };
            fileSystemInfo: {
                createdDateTime: string;
                lastAccessedDateTime: string;
                lastModifiedDateTime: string;
            };
            folder: {
                childCount: number;
                view: {
                    sortBy: "default" | "name" | "type" | "size" | "takenOrCreatedDateTime" | "lastModifiedDateTime" | "sequence";
                    sortOrder: "ascending" | "descending";
                    viewType: "default" | "icons" | "details" | "thumbnails";
                };
            };
            id: string;
            lastModifiedBy: IdentitySet;
            lastModifiedDateTime: string;
            name: string;
            package: {
                type: "oneNote";
            };
            parentReference: ItemReference;
            shared: {
                owner: IdentitySet;
                scope: "anonymous" | "organization" | "users";
                sharedBy: IdentitySet;
                sharedDateTime: string;
            };
            sharepointIds: SharePointIds;
            size: number;
            specialFolder: {
                name: string;
            };
            webDavUrl: string;
            webUrl: string;
        }>[];
    }>

  • (Only return monitor url) Asynchronously creates a copy of an driveItem (including any children), under a new parent item or with a new name.

    Example

    const monitorUrl = await copy({ path: "path/to/file" }, { path: "path/to/folder" });
    const copyResult = await monitorCopy(monitorUrl);

    See

    https://docs.microsoft.com/onedrive/developer/rest-api/api/driveitem_copy

    Parameters

    • itemLocator: ItemLocator
    • parentLocator: {
          path: string;
      } | {
          id: string;
      }
    • Optional name: string

    Returns Promise<string>

  • customize a request if not shipped by this library

    Example

    custom({id}, "versions"); // Listing versions of a DriveItem
    custom({id}, "versions", "/{version-id}"); // Get a DriveItemVersion resource
    custom({id}, "versions", "/{version-id}/restoreVersion", undefined, "POST"); // Restore a previous version of a DriveItem

    Parameters

    • itemLocator: ItemLocator

      bare string only if you know the API, otherwise use {path: "/path/to/file"} or {id: "id"}

    • command: string

      the command name, such as children, versions, checkin, checkout, ...

    • Optional appendix: ODataAppendix

      the ODataAppendix or some suffix to the API

    • Optional body: any

      the body of fetch, if method is not specified, it will set to "POST"

    • Optional method: string

      the method of fetch

    Returns Promise<any>

  • Parameters

    • monitorUrl: string

      the url returned by copy()

    Returns Promise<{
        errorCode?: string;
        operation: string;
        percentageComplete?: number;
        resourceId?: string;
        status: "completed" | "inProgress" | "failed" | "notStarted";
        statusDescription: string;
    }>

  • Move a DriveItem to a new folder This is a special case of the Update method. Your app can combine moving an item to a new container and updating other properties of the item into a single request. Items cannot be moved between Drives using this request.

    Example

    move({ path: "path/to/file" }, { path: "path/to/folder" });
    

    See

    https://docs.microsoft.com/onedrive/developer/rest-api/api/driveitem_move

    Parameters

    • itemLocator: ItemLocator
    • Optional parentLocator: {
          path: string;
      } | {
          id: string;
      }

      like parentReference, but is {path: "/path/to/file"} or {id: "id"}, string is not allowed

    • Optional name: string

      optional, new name for the item, has the same effect as rename

    Returns Promise<SingleRemoteItem>

  • This action allows you to obtain short-lived embeddable URLs for an item.

    See

    https://docs.microsoft.com/onedrive/developer/rest-api/api/driveitem_preview

    Parameters

    • itemLocator: ItemLocator
    • options: {
          allowEdit?: boolean;
          chromeless?: boolean;
          page?: string | number;
          viewer?: null | "onedrive" | "office";
          zoom?: number;
      }
      • Optional allowEdit?: boolean
      • Optional chromeless?: boolean
      • Optional page?: string | number
      • Optional viewer?: null | "onedrive" | "office"
      • Optional zoom?: number

    Returns Promise<{
        getUrl: string;
        postParameters: string;
        postUrl: string;
    }>

  • Search the hierarchy of items for items matching a query. You can search within a folder hierarchy, a whole drive, or files shared with the current user.

    See

    https://docs.microsoft.com/onedrive/developer/rest-api/api/driveitem_search

    Parameters

    Returns Promise<{
        @odata.context: string;
        @odata.nextLink?: string;
        value: (Readonly<{
            @microsoft.graph.downloadUrl: string;
            createdBy: IdentitySet;
            createdDateTime: string;
            file: {
                hashes: {
                    crc32Hash: string;
                    quickXorHash: string;
                    sha1Hash: string;
                };
                mimeType: string;
                processingMetadata: boolean;
            };
            fileSystemInfo: {
                createdDateTime: string;
                lastAccessedDateTime: string;
                lastModifiedDateTime: string;
            };
            folder: {
                childCount: number;
                view: {
                    sortBy: "default" | "name" | "type" | "size" | "takenOrCreatedDateTime" | "lastModifiedDateTime" | "sequence";
                    sortOrder: "ascending" | "descending";
                    viewType: "default" | "icons" | "details" | "thumbnails";
                };
            };
            id: string;
            lastModifiedBy: IdentitySet;
            lastModifiedDateTime: string;
            name: string;
            package: {
                type: "oneNote";
            };
            parentReference: ItemReference;
            shared: {
                owner: IdentitySet;
                scope: "anonymous" | "organization" | "users";
                sharedBy: IdentitySet;
                sharedDateTime: string;
            };
            sharepointIds: SharePointIds;
            size: number;
            specialFolder: {
                name: string;
            };
            webDavUrl: string;
            webUrl: string;
        }> & {
            @odata.type: string;
            searchResult: any;
        })[];
    }>

  • Parameters

    • accessToken: string

      set accessToken if you want to use another token

    Returns default

  • set drive if you want to change current drive, default might be user's onedrive

    Parameters

    • type: "users" | "me" | "drives" | "groups" | "sites" | "approot"
    • Optional id: string

    Returns default

  • set the max duration of fetch, default is unlimited

    Parameters

    • maxDuration: number

      (unit is milliseconds) if pass 0 or negative number, no timeout will be set

    Returns default

  • This only returns {uploadUrl, expirationDateTime}, where the uploadUrl need not authorization, use upload-node.ts to upload the file (unavailable at present)

    See

    https://docs.microsoft.com/onedrive/developer/rest-api/api/driveitem_createuploadsession

    Parameters

    • itemLocator: ItemLocator
    • Optional item: {
          @microsoft.graph.conflictBehavior: "rename" | "fail" | "replace";
          description: string;
          name: string;
      }
      • @microsoft.graph.conflictBehavior: "rename" | "fail" | "replace"
      • description: string
      • name: string

    Returns Promise<{
        expirationDateTime: string;
        nextExpectedRanges?: string[];
        uploadUrl: string;
    }>

Generated using TypeDoc