UNPKG

5.81 kBTypeScriptView Raw
1/**
2 * Copyright 2020 Inrupt Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal in
6 * the Software without restriction, including without limitation the rights to use,
7 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 * Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21import { Thing, SolidDataset, UrlString, Url, getBoolean, getDatetime, getDecimal, getInteger, getUrl, getStringNoLocale, getStringWithLocale, getBooleanAll, getDatetimeAll, getDecimalAll, getIntegerAll, getStringNoLocaleAll, getStringWithLocaleAll, getUrlAll } from "@inrupt/solid-client";
22export declare type CommonProperties = {
23 thing?: Thing;
24 solidDataset?: SolidDataset;
25 property?: Url | UrlString;
26 properties?: Url[] | UrlString[];
27 edit?: boolean;
28 autosave?: boolean;
29 onSave?: (savedDataset?: SolidDataset, savedThing?: Thing) => void;
30 onError?: (error: Error) => void;
31};
32export declare const overwriteFile: (src: string, file: File, input: EventTarget & HTMLInputElement, fetch: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>) & typeof fetch, maxSize?: number, onSave?: () => void, onError?: ((error: Error) => void) | undefined) => Promise<string | null>;
33export declare const retrieveFile: (src: string, fetch: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>) & typeof fetch) => Promise<Blob>;
34export declare type DataType = "boolean" | "datetime" | "decimal" | "integer" | "string" | "url";
35export declare function getValueByType(type: "boolean", thing: Thing, property: UrlString | Url): ReturnType<typeof getBoolean>;
36export declare function getValueByType(type: "datetime", thing: Thing, property: UrlString | Url): ReturnType<typeof getDatetime>;
37export declare function getValueByType(type: "decimal", thing: Thing, property: UrlString | Url): ReturnType<typeof getDecimal>;
38export declare function getValueByType(type: "integer", thing: Thing, property: UrlString | Url): ReturnType<typeof getInteger>;
39export declare function getValueByType(type: "string", thing: Thing, property: UrlString | Url): ReturnType<typeof getStringNoLocale>;
40export declare function getValueByType(type: "string", thing: Thing, property: UrlString | Url, locale: string): ReturnType<typeof getStringWithLocale>;
41export declare function getValueByType(type: "string", thing: Thing, property: UrlString | Url): ReturnType<typeof getStringNoLocale>;
42export declare function getValueByType(type: "url", thing: Thing, property: UrlString | Url): ReturnType<typeof getUrl>;
43export declare function getValueByType(type: DataType, thing: Thing, property: UrlString | Url, locale?: string): string | boolean | number | Date | null;
44export declare function getValueByTypeAll(type: "boolean", thing: Thing, property: UrlString | Url): ReturnType<typeof getBooleanAll>;
45export declare function getValueByTypeAll(type: "datetime", thing: Thing, property: UrlString | Url): ReturnType<typeof getDatetimeAll>;
46export declare function getValueByTypeAll(type: "decimal", thing: Thing, property: UrlString | Url): ReturnType<typeof getDecimalAll>;
47export declare function getValueByTypeAll(type: "integer", thing: Thing, property: UrlString | Url): ReturnType<typeof getIntegerAll>;
48export declare function getValueByTypeAll(type: "string", thing: Thing, property: UrlString | Url): ReturnType<typeof getStringNoLocaleAll>;
49export declare function getValueByTypeAll(type: "string", thing: Thing, property: UrlString | Url, locale: string): ReturnType<typeof getStringWithLocaleAll>;
50export declare function getValueByTypeAll(type: "string", thing: Thing, property: UrlString | Url): ReturnType<typeof getStringNoLocaleAll>;
51export declare function getValueByTypeAll(type: "url", thing: Thing, property: UrlString | Url): ReturnType<typeof getUrlAll>;
52export declare function getValueByTypeAll(type: DataType, thing: Thing, property: UrlString | Url, locale?: string): Array<string | boolean | number | Date | null>;
53export declare function getPropertyForThing(propertySelector: typeof getValueByType | typeof getValueByTypeAll, type: DataType, thing: Thing, properties: Array<Url | UrlString>, locale?: string): Url | UrlString | undefined;
54export declare type UseProperty = {
55 dataset?: SolidDataset;
56 thing?: Thing;
57 error?: Error;
58 property: Url | UrlString;
59 value: string | boolean | number | Date | null;
60 setDataset: (dataset: SolidDataset) => void;
61 setThing: (thing: Thing) => void;
62};
63export declare type UsePropertyProps = {
64 thing?: Thing;
65 dataset?: SolidDataset;
66 property?: Url | UrlString;
67 properties?: Url[] | UrlString[];
68 type: DataType;
69 locale?: string;
70};
71export declare function useProperty(props: UsePropertyProps): UseProperty;
72export declare function useDatetimeBrowserSupport(): boolean | null;
73export declare function updateDataset(datasetUrl: string | Url, setDataset: (dataset: SolidDataset) => void): Promise<void>;
74//# sourceMappingURL=index.d.ts.map
\No newline at end of file