All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.cesium.Resource.kt Maven / Gradle / Ivy

// Automatically generated - do not modify!

@file:Suppress(
    "NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package cesium

/**
 * A resource that includes the location and any other parameters we need to retrieve it or create derived resources. It also provides the ability to retry requests.
 * ```
 * function refreshTokenRetryCallback(resource, error) {
 *   if (error.statusCode === 403) {
 *     // 403 status code means a new token should be generated
 *     return getNewAccessToken()
 *       .then(function(token) {
 *         resource.queryParameters.access_token = token;
 *         return true;
 *       })
 *       .otherwise(function() {
 *         return false;
 *       });
 *   }
 *
 *   return false;
 * }
 *
 * var resource = new Resource({
 *    url: 'http://server.com/path/to/resource.json',
 *    proxy: new DefaultProxy('/proxy/'),
 *    headers: {
 *      'X-My-Header': 'valueOfHeader'
 *    },
 *    queryParameters: {
 *      'access_token': '123-435-456-000'
 *    },
 *    retryCallback: refreshTokenRetryCallback,
 *    retryAttempts: 1
 * });
 * ```
 * @see Online Documentation
 *
 * @constructor
 * @param [options] A url or an object with the following properties
 * @see Online Documentation
 */
@JsName("\$cesium__Resource")
external class Resource(options: ConstructorOptions) {
    /**
     * @property [url] The url of the resource.
     * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
     * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
     * @property [headers] Additional HTTP headers that will be sent.
     *   Default value - `{}`
     * @property [proxy] A proxy to be used when loading the resource.
     * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
     * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
     *   Default value - `0`
     * @property [request] A Request object that will be used. Intended for internal use only.
     */
    interface ConstructorOptions {
        var url: String
        var queryParameters: Any?
        var templateValues: Any?
        var headers: Any?
        var proxy: Proxy?
        var retryCallback: RetryCallback?
        var retryAttempts: Int?
        var request: Request?
    }

    /**
     * Additional HTTP headers that will be sent with the request.
     * @see Online Documentation
     */
    var headers: Any

    /**
     * A Request object that will be used. Intended for internal use only.
     * @see Online Documentation
     */
    var request: Request

    /**
     * A proxy to be used when loading the resource.
     * @see Online Documentation
     */
    var proxy: Proxy

    /**
     * Function to call when a request for this resource fails. If it returns true or a Promise that resolves to true, the request will be retried.
     * @see Online Documentation
     */
    var retryCallback: Function<*>

    /**
     * The number of times the retryCallback should be called before giving up.
     * @see Online Documentation
     */
    var retryAttempts: Int

    /**
     * Query parameters appended to the url.
     * @see Online Documentation
     */
    val queryParameters: Any

    /**
     * The key/value pairs used to replace template parameters in the url.
     * @see Online Documentation
     */
    val templateValues: Any

    /**
     * The url to the resource with template values replaced, query string appended and encoded by proxy if one was set.
     * @see Online Documentation
     */
    var url: String

    /**
     * The file extension of the resource.
     * @see Online Documentation
     */
    val extension: String

    /**
     * True if the Resource refers to a data URI.
     * @see Online Documentation
     */
    var isDataUri: Boolean

    /**
     * True if the Resource refers to a blob URI.
     * @see Online Documentation
     */
    var isBlobUri: Boolean

    /**
     * True if the Resource refers to a cross origin URL.
     * @see Online Documentation
     */
    var isCrossOriginUrl: Boolean

    /**
     * True if the Resource has request headers. This is equivalent to checking if the headers property has any keys.
     * @see Online Documentation
     */
    var hasHeaders: Boolean

    /**
     * Returns the url, optional with the query string and processed by a proxy.
     * @param [query] If true, the query string is included.
     *   Default value - `false`
     * @param [proxy] If true, the url is processed by the proxy object, if defined.
     *   Default value - `false`
     * @return The url with all the requested components.
     * @see Online Documentation
     */
    fun getUrlComponent(
        query: Boolean? = definedExternally,
        proxy: Boolean? = definedExternally,
    ): String

    /**
     * Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
     *  as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
     * @param [params] The query parameters
     * @param [useAsDefault] If true the params will be used as the default values, so they will only be set if they are undefined.
     *   Default value - `false`
     * @see Online Documentation
     */
    fun setQueryParameters(
        params: Any,
        useAsDefault: Boolean? = definedExternally,
    )

    /**
     * Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
     *  as opposed to adding them one at a time to the queryParameters property.
     * @param [params] The query parameters
     * @see Online Documentation
     */
    fun appendQueryParameters(params: Any)

    /**
     * Combines the specified object and the existing template values. This allows you to add many values at once,
     *  as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.
     * @param [template] The template values
     * @param [useAsDefault] If true the values will be used as the default values, so they will only be set if they are undefined.
     *   Default value - `false`
     * @see Online Documentation
     */
    fun setTemplateValues(
        template: Any,
        useAsDefault: Boolean? = definedExternally,
    )

    /**
     * Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.
     * @param [options] An object with the following properties
     * @return The resource derived from the current one.
     * @see Online Documentation
     */
    fun getDerivedResource(options: GetDerivedResourceOptions): Resource

    /**
     * @property [url] The url that will be resolved relative to the url of the current instance.
     * @property [queryParameters] An object containing query parameters that will be combined with those of the current instance.
     * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}). These will be combined with those of the current instance.
     * @property [headers] Additional HTTP headers that will be sent.
     *   Default value - `{}`
     * @property [proxy] A proxy to be used when loading the resource.
     * @property [retryCallback] The function to call when loading the resource fails.
     * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
     * @property [request] A Request object that will be used. Intended for internal use only.
     * @property [preserveQueryParameters] If true, this will keep all query parameters from the current resource and derived resource. If false, derived parameters will replace those of the current resource.
     *   Default value - `false`
     */
    interface GetDerivedResourceOptions {
        var url: String?
        var queryParameters: Any?
        var templateValues: Any?
        var headers: Any?
        var proxy: Proxy?
        var retryCallback: RetryCallback?
        var retryAttempts: Int?
        var request: Request?
        var preserveQueryParameters: Boolean?
    }

    /**
     * Duplicates a Resource instance.
     * @param [result] The object onto which to store the result.
     * @return The modified result parameter or a new Resource instance if one was not provided.
     * @see Online Documentation
     */
    fun clone(result: Resource? = definedExternally): Resource

    /**
     * Returns the base path of the Resource.
     * @param [includeQuery] Whether or not to include the query string and fragment form the uri
     *   Default value - `false`
     * @return The base URI of the resource
     * @see Online Documentation
     */
    fun getBaseUri(includeQuery: Boolean? = definedExternally): String

    /**
     * Appends a forward slash to the URL.
     * @see Online Documentation
     */
    fun appendForwardSlash()

    /**
     * Asynchronously loads the resource as raw binary data.  Returns a promise that will resolve to
     * an ArrayBuffer once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * // load a single URL asynchronously
     * resource.fetchArrayBuffer().then(function(arrayBuffer) {
     *     // use the data
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchArrayBuffer(): kotlin.js.Promise?

    /**
     * Asynchronously loads the given resource as a blob.  Returns a promise that will resolve to
     * a Blob once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * // load a single URL asynchronously
     * resource.fetchBlob().then(function(blob) {
     *     // use the data
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchBlob(): kotlin.js.Promise?

    /**
     * Asynchronously loads the given image resource.  Returns a promise that will resolve to
     * an [ImageBitmap](https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap) if `preferImageBitmap` is true and the browser supports `createImageBitmap` or otherwise an
     * [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement) once loaded, or reject if the image failed to load.
     * ```
     * // load a single image asynchronously
     * resource.fetchImage().then(function(image) {
     *     // use the loaded image
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     *
     * // load several images in parallel
     * when.all([resource1.fetchImage(), resource2.fetchImage()]).then(function(images) {
     *     // images is an array containing all the loaded images
     * });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchImage(options: FetchImageOptions? = definedExternally): dynamic

    /**
     * @property [preferBlob] If true, we will load the image via a blob.
     *   Default value - `false`
     * @property [preferImageBitmap] If true, image will be decoded during fetch and an `ImageBitmap` is returned.
     *   Default value - `false`
     * @property [flipY] If true, image will be vertically flipped during decode. Only applies if the browser supports `createImageBitmap`.
     *   Default value - `false`
     * @property [skipColorSpaceConversion] If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports `createImageBitmap`.
     *   Default value - `false`
     */
    interface FetchImageOptions {
        var preferBlob: Boolean?
        var preferImageBitmap: Boolean?
        var flipY: Boolean?
        var skipColorSpaceConversion: Boolean?
    }

    /**
     * Asynchronously loads the given resource as text.  Returns a promise that will resolve to
     * a String once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * // load text from a URL, setting a custom header
     * var resource = new Resource({
     *   url: 'http://someUrl.com/someJson.txt',
     *   headers: {
     *     'X-Custom-Header' : 'some value'
     *   }
     * });
     * resource.fetchText().then(function(text) {
     *     // Do something with the text
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchText(): kotlin.js.Promise?

    /**
     * Asynchronously loads the given resource as JSON.  Returns a promise that will resolve to
     * a JSON object once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled. This function
     * adds 'Accept: application/json,*/*;q=0.01' to the request headers, if not
     * already specified.
     * ```
     * resource.fetchJson().then(function(jsonData) {
     *     // Do something with the JSON object
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchJson(): kotlin.js.Promise?

    /**
     * Asynchronously loads the given resource as XML.  Returns a promise that will resolve to
     * an XML Document once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * // load XML from a URL, setting a custom header
     * loadXML('http://someUrl.com/someXML.xml', {
     *   'X-Custom-Header' : 'some value'
     * }).then(function(document) {
     *     // Do something with the document
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchXML(): kotlin.js.Promise?

    /**
     * Requests a resource using JSONP.
     * ```
     * // load a data asynchronously
     * resource.fetchJsonp().then(function(data) {
     *     // use the loaded data
     * }).otherwise(function(error) {
     *     // an error occurred
     * });
     * ```
     * @param [callbackParameterName] The callback parameter name that the server expects.
     *   Default value - `'callback'`
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetchJsonp(callbackParameterName: String? = definedExternally): kotlin.js.Promise?

    /**
     * Asynchronously loads the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled. It's recommended that you use
     * the more specific functions eg. fetchJson, fetchBlob, etc.
     * ```
     * resource.fetch()
     *   .then(function(body) {
     *       // use the data
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun fetch(options: FetchOptions? = definedExternally): kotlin.js.Promise?

    /**
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface FetchOptions {
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    /**
     * Asynchronously deletes the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * resource.delete()
     *   .then(function(body) {
     *       // use the data
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun delete(options: DeleteOptions? = definedExternally): kotlin.js.Promise?

    /**
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface DeleteOptions {
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    /**
     * Asynchronously gets headers the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * resource.head()
     *   .then(function(headers) {
     *       // use the data
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun head(options: HeadOptions? = definedExternally): kotlin.js.Promise?

    /**
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface HeadOptions {
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    /**
     * Asynchronously gets options the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * resource.options()
     *   .then(function(headers) {
     *       // use the data
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun options(options: OptionsOptions? = definedExternally): kotlin.js.Promise?

    /**
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface OptionsOptions {
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    /**
     * Asynchronously posts data to the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * resource.post(data)
     *   .then(function(result) {
     *       // use the result
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @param [data] Data that is posted with the resource.
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun post(
        data: Any,
        options: PostOptions? = definedExternally,
    ): kotlin.js.Promise?

    /**
     * @property [data] Data that is posted with the resource.
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface PostOptions {
        var data: Any?
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    /**
     * Asynchronously puts data to the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * resource.put(data)
     *   .then(function(result) {
     *       // use the result
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @param [data] Data that is posted with the resource.
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun put(
        data: Any,
        options: PutOptions? = definedExternally,
    ): kotlin.js.Promise?

    /**
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface PutOptions {
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    /**
     * Asynchronously patches data to the given resource.  Returns a promise that will resolve to
     * the result once loaded, or reject if the resource failed to load.  The data is loaded
     * using XMLHttpRequest, which means that in order to make requests to another origin,
     * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
     * ```
     * resource.patch(data)
     *   .then(function(result) {
     *       // use the result
     *   }).otherwise(function(error) {
     *       // an error occurred
     *   });
     * ```
     * @param [data] Data that is posted with the resource.
     * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
     * @see Online Documentation
     */
    fun patch(
        data: Any,
        options: PatchOptions? = definedExternally,
    ): kotlin.js.Promise?

    /**
     * @property [responseType] The type of response.  This controls the type of item returned.
     * @property [headers] Additional HTTP headers to send with the request, if any.
     * @property [overrideMimeType] Overrides the MIME type returned by the server.
     */
    interface PatchOptions {
        var responseType: String?
        var headers: Any?
        var overrideMimeType: String?
    }

    companion object {
        /**
         * Returns true if blobs are supported.
         * @see Online Documentation
         */
        val isBlobSupported: Boolean

        /**
         * Creates a Resource and calls fetchArrayBuffer() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchArrayBuffer(options: FetchArrayBufferOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         */
        interface FetchArrayBufferOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
        }

        /**
         * Creates a Resource and calls fetchBlob() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchBlob(options: FetchBlobOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         */
        interface FetchBlobOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
        }

        /**
         * Creates a Resource and calls fetchImage() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchImage(options: FetchImageOptions): dynamic

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [flipY] Whether to vertically flip the image during fetch and decode. Only applies when requesting an image and the browser supports `createImageBitmap`.
         *   Default value - `false`
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [preferBlob] If true, we will load the image via a blob.
         *   Default value - `false`
         * @property [preferImageBitmap] If true, image will be decoded during fetch and an `ImageBitmap` is returned.
         *   Default value - `false`
         * @property [skipColorSpaceConversion] If true, any custom gamma or color profiles in the image will be ignored. Only applies when requesting an image and the browser supports `createImageBitmap`.
         *   Default value - `false`
         */
        interface FetchImageOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var flipY: Boolean?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var preferBlob: Boolean?
            var preferImageBitmap: Boolean?
            var skipColorSpaceConversion: Boolean?
        }

        /**
         * Creates a Resource and calls fetchText() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchText(options: FetchTextOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         */
        interface FetchTextOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
        }

        /**
         * Creates a Resource and calls fetchJson() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchJson(options: FetchJsonOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         */
        interface FetchJsonOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
        }

        /**
         * Creates a Resource and calls fetchXML() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchXML(options: FetchXMLOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         */
        interface FetchXMLOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
        }

        /**
         * Creates a Resource from a URL and calls fetchJsonp() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetchJsonp(options: FetchJsonpOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [callbackParameterName] The callback parameter name that the server expects.
         *   Default value - `'callback'`
         */
        interface FetchJsonpOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var callbackParameterName: String?
        }

        /**
         * Creates a Resource from a URL and calls fetch() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun fetch(options: FetchOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface FetchOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * Creates a Resource from a URL and calls delete() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun delete(options: DeleteOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [data] Data that is posted with the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface DeleteOptions {
            var url: String
            var data: Any?
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * Creates a Resource from a URL and calls head() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun head(options: HeadOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface HeadOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * Creates a Resource from a URL and calls options() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun options(options: OptionsOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface OptionsOptions {
            var url: String
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * Creates a Resource from a URL and calls post() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun post(options: PostOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [data] Data that is posted with the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface PostOptions {
            var url: String
            var data: Any
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * Creates a Resource from a URL and calls put() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun put(options: PutOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [data] Data that is posted with the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface PutOptions {
            var url: String
            var data: Any
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * Creates a Resource from a URL and calls patch() on it.
         * @param [options] A url or an object with the following properties
         * @return a promise that will resolve to the requested data when loaded. Returns undefined if `request.throttle` is true and the request does not have high enough priority.
         * @see Online Documentation
         */
        fun patch(options: PatchOptions): kotlin.js.Promise?

        /**
         * @property [url] The url of the resource.
         * @property [data] Data that is posted with the resource.
         * @property [queryParameters] An object containing query parameters that will be sent when retrieving the resource.
         * @property [templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
         * @property [headers] Additional HTTP headers that will be sent.
         *   Default value - `{}`
         * @property [proxy] A proxy to be used when loading the resource.
         * @property [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
         * @property [retryAttempts] The number of times the retryCallback should be called before giving up.
         *   Default value - `0`
         * @property [request] A Request object that will be used. Intended for internal use only.
         * @property [responseType] The type of response.  This controls the type of item returned.
         * @property [overrideMimeType] Overrides the MIME type returned by the server.
         */
        interface PatchOptions {
            var url: String
            var data: Any
            var queryParameters: Any?
            var templateValues: Any?
            var headers: Any?
            var proxy: Proxy?
            var retryCallback: RetryCallback?
            var retryAttempts: Int?
            var request: Request?
            var responseType: String?
            var overrideMimeType: String?
        }

        /**
         * A resource instance initialized to the current browser location
         * @see Online Documentation
         */
        val DEFAULT: Resource
    }
}

/**
 * A function that returns the value of the property.
 * @param [resource] The resource that failed to load.
 * @param [error] The error that occurred during the loading of the resource.
 * @see Online Documentation
 */
typealias RetryCallback = (resource: Resource?, error: Error?) -> dynamic




© 2015 - 2024 Weber Informatics LLC | Privacy Policy