@oada/client
Version:
A lightweight client tool to interact with an OADA-compliant server
45 lines (44 loc) • 1.84 kB
TypeScript
/**
* @license
* Copyright 2021 Open Ag Data Alliance
*
* 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 { TimeoutError as PTimeoutError } from "p-timeout";
import type { Tree } from "@oada/types/oada/tree/v1.js";
export declare function toArray<E extends unknown[] | readonly unknown[]>(itemOrArray: E | E[0]): E;
export declare function toStringPath(path: readonly string[]): string;
export declare function toArrayPath(path: string): string[];
export declare function getObjectAtPath(tree: Tree, path: readonly string[]): Tree;
export declare function toTreePath(tree: Tree, path: string[]): string[];
export declare function isResource(tree: Tree, path: string[]): boolean;
export declare function createNestedObject(object: Record<string, unknown>, nestPath: string[]): Record<string, unknown>;
/**
* Use an Error class for timed out requests
*/
export declare class TimeoutError extends PTimeoutError {
get code(): "REQUEST_TIMEDOUT";
readonly name: "TimeoutError";
constructor(request: unknown);
}
/**
* Ensure we throw real `Error`s
*/
export declare function fixError<E extends {
message?: string;
code?: string;
status?: string | number;
statusCode?: string | number;
statusText?: string;
}>(error: E): Promise<E & Error>;
export declare const changeSym: unique symbol;