/** * @license * Copyright 2022 Alex Layton * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. */ import type { Except } from 'type-fest'; /** * Symbol to access OADA `_id` key */ export declare const _id: unique symbol; /** * Symbol to access OADA `_rev` key */ export declare const _rev: unique symbol; /** * Symbol to access OADA `_type` key */ export declare const _type: unique symbol; /** * Symbol to access OADA `_meta` key */ export declare const _meta: unique symbol; /** * @todo just declare symbols in here if TS stops being dumb about symbol keys */ declare const Symbols: { readonly _id: typeof _id; readonly _rev: typeof _rev; readonly _type: typeof _type; readonly _meta: typeof _meta; }; export declare type JsonObject = { [Key in string]?: JsonValue; }; export declare type JsonArray = JsonValue[] | readonly JsonValue[]; export declare type JsonValue = string | number | boolean | null | JsonObject | JsonArray; export declare type OADAified = T extends JsonValue ? OADAifiedJsonValue : T; declare type OADAifyKey = K extends keyof T ? T[K] : never; /** * @todo Better name */ export declare type OADAifiedJsonObject = { [_id]: OADAifyKey; [_rev]: OADAifyKey; [_type]: OADAifyKey; /** * @todo OADAify under _meta or not? */ [_meta]: OADAified; } & { [K in keyof Except]: OADAified; }; /** * @todo Better name */ export declare type OADAifiedJsonArray = Array ? R : T extends ReadonlyArray ? R : never>>; /** * @todo Better name */ export declare type OADAifiedJsonValue = T extends JsonArray ? OADAifiedJsonArray : T extends JsonObject ? OADAifiedJsonObject : T; /** * @todo why doesn't TS figure this correctly with for ... in? */ export declare type StringKey = keyof T & string; /** * Converts OADA keys (i.e., ones starting with `_`) to Symbols * * This way when looping etc. you only get actual data keys. * _Should_ turn itself back to original JSON for stringify, ajv, etc. */ export declare function oadaify(value: T, deep?: boolean): OADAified; /** * Inverse of oadaify * * Makes OADA keys normal object properties again. * * @see oadaify */ export declare function deoadaify(value: OADAified): T; export default oadaify; //# sourceMappingURL=index.d.ts.map