@platform/cell.schema
Version:
URI and database schemas for the `cell.os`.
179 lines (178 loc) • 5.95 kB
TypeScript
import { t, coord, Mime } from '../common';
import { Uri } from '../Uri';
import { Urls, Url } from '../Url';
export declare const Schema: {
Mime: typeof Mime;
File: {
ERROR: {
HTTP: {
SERVER: "HTTP/server";
CLIENT: "HTTP/client";
CONFIG: "HTTP/config";
NOT_FOUND: "HTTP/notFound";
NOT_LINKED: "HTTP/notLinked";
FILE: "HTTP/file";
MALFORMED_URI: "HTTP/uri/malformed";
HASH_MISMATCH: "HTTP/hash/mismatch";
TYPE: "HTTP/type";
};
TYPE: {
DEF: "TYPE/def";
DEF_INVALID: "TYPE/def/invalid";
NOT_FOUND: "TYPE/notFound";
TARGET: "TYPE/target";
REF: "TYPE/ref";
REF_CIRCULAR: "TYPE/ref/circular";
REF_TYPENAME: "TYPE/ref/typename";
DUPLICATE_PROP: "TYPE/duplicate/prop";
DUPLICATE_TYPENAME: "TYPE/duplicate/typename";
SHEET: "TYPE/sheet";
};
};
Links: {
prefix: string;
is: {
fileKey(input?: string | undefined): boolean;
fileValue(input?: string | undefined): boolean;
fileUploading(value?: string | undefined): boolean;
};
total(links?: t.IUriMap): number;
toKey(filename: string): string;
parseKey(linkKey: string): t.ILinkKey;
parseValue(linkValue: string): {
toString: t.FileLinkToString;
uri: t.IFileUri;
value: string;
query: t.IFileLinkQuery;
};
parse(linkKey: string, linkValue: string): t.IFileLink;
toList(links?: t.IUriMap): t.IFileLink[];
find(links?: t.IUriMap): {
byName(path?: string | undefined): t.IFileLink | undefined;
};
};
Path: {
fromUrl(input: string): {
ok: boolean;
path: string;
dir: string;
filename: string;
error: string | undefined;
toString: () => string;
};
Local: {
toAbsolutePath(args: {
path: string;
root: string;
}): string;
toRelativePath(args: {
path: string;
root: string;
}): string;
toAbsoluteLocation(args: {
path: string;
root: string;
}): string;
toRelativeLocation(args: {
path: string;
root: string;
}): string;
};
};
type: "FILE";
toObject(args: {
nsPath: string;
fileid: string;
uri: string;
}): {
fileid: string;
uri: string;
path: string;
};
uri(args: {
path: string;
}): string;
toFileLocation(input?: string): string;
};
Ref: {
Links: typeof import("../Ref").RefLinks;
};
cuid: () => string;
slug: () => string;
Hash: {
sha256(input: any): string;
};
coord: typeof coord;
encoding: {
escapePath: (value: string) => string;
unescapePath: (value: string) => string;
escapeNamespace: (value: string) => string;
unescapeNamespace: (value: string) => string;
escapeKey: (input: string) => string;
unescapeKey: (input: string) => string;
transformKeys(obj: Record<string, any>, fn: (input: string) => string): {};
transformValues(obj: Record<string, any>, fn: (input: string) => string): {};
};
Squash: {
props<T = Record<string, unknown>>(props?: t.ICellProps | t.IRowProps | t.IColumnProps | undefined): T | undefined;
cell<T_1 = t.ICellData<t.ICellProps>>(cell?: Record<string, unknown> | undefined, options?: {
empty?: Record<string, unknown> | undefined;
}): T_1 | undefined;
object<T_2 = Record<string, unknown>>(obj: Record<string, unknown> | undefined, options?: {
empty?: Record<string, unknown> | undefined;
}): T_2 | undefined;
};
Uri: typeof Uri;
Url: typeof Url;
Urls: typeof Urls;
urls: (host: string | number) => t.IUrls;
ns: (id: string) => NsSchema;
query: {
cells: string;
rows: string;
columns: string;
files: string;
};
from: {
ns(input: string | t.IDbModelNs): t.SchemaType<t.INsUri>;
cell(input: string | t.IDbModelCell): t.SchemaType<t.ICellUri>;
row(input: string | t.IDbModelRow): t.SchemaType<t.IRowUri>;
column(input: string | t.IDbModelColumn): t.SchemaType<t.IColumnUri>;
file(input: string | t.IDbModelFile): t.SchemaType<t.IFileUri>;
};
};
export declare class NsSchema {
readonly id: string;
readonly path: string;
readonly uri: string;
constructor(args: {
id: string;
});
cell(key: string): CoordSchema<t.ICellUri>;
column(key: string): CoordSchema<t.IColumnUri>;
row(key: string): CoordSchema<t.IRowUri>;
file(fileid: string): {
fileid: string;
uri: string;
path: string;
};
static uri(args: {
path: string;
}): string;
}
export declare class CoordSchema<T extends t.ICellUri | t.IRowUri | t.IColumnUri> {
static uri(args: {
path: string;
}): string;
constructor(args: {
type: t.SchemaCoordType;
nsPath: string;
id: string;
uri: string;
});
readonly type: t.SchemaCoordType;
readonly id: string;
readonly path: string;
private readonly _uri;
get uri(): T;
}