mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 10:46:01 +00:00
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2017 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
import { RequestInfo } from './requestinfo';
|
|
import { Headers, XhrIo } from './xhrio';
|
|
import { XhrIoPool } from './xhriopool';
|
|
/**
|
|
* @template T
|
|
*/
|
|
export interface Request<T> {
|
|
getPromise(): Promise<T>;
|
|
/**
|
|
* Cancels the request. IMPORTANT: the promise may still be resolved with an
|
|
* appropriate value (if the request is finished before you call this method,
|
|
* but the promise has not yet been resolved), so don't just assume it will be
|
|
* rejected if you call this function.
|
|
* @param appDelete True if the cancelation came from the app being deleted.
|
|
*/
|
|
cancel(appDelete?: boolean): void;
|
|
}
|
|
/**
|
|
* A collection of information about the result of a network request.
|
|
* @param opt_canceled Defaults to false.
|
|
* @struct
|
|
*/
|
|
export declare class RequestEndStatus {
|
|
wasSuccessCode: boolean;
|
|
xhr: XhrIo | null;
|
|
/**
|
|
* True if the request was canceled.
|
|
*/
|
|
canceled: boolean;
|
|
constructor(wasSuccessCode: boolean, xhr: XhrIo | null, canceled?: boolean);
|
|
}
|
|
export declare function addAuthHeader_(headers: Headers, authToken: string | null): void;
|
|
export declare function addVersionHeader_(headers: Headers): void;
|
|
/**
|
|
* @template T
|
|
*/
|
|
export declare function makeRequest<T>(requestInfo: RequestInfo<T>, authToken: string | null, pool: XhrIoPool): Request<T>;
|