UNPKG

@deep-foundation/deeplinks

Version:

[![npm](https://img.shields.io/npm/v/@deep-foundation/deeplinks.svg)](https://www.npmjs.com/package/@deep-foundation/deeplinks) [![Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/deep-fo

128 lines (127 loc) 5.5 kB
import React from "react"; import { Id, Link, MinilinkCollection } from './minilinks.js'; import { Traveler as NativeTraveler } from './traveler.js'; import { CyberClient } from '@cybercongress/cyber-js'; import { Helia } from 'helia'; import { AsyncSerialParams, DeepClient, DeepClientAuthResult, DeepClientGuestOptions, DeepClientInstance, DeepClientJWTOptions, DeepClientOptions, DeepClientResult, Exp, InsertObjects, Options, ReadOptions, UpdateValue, WriteOptions } from './client.js'; export interface Models { [model: string]: { out: { [field: string]: string; }; in: { [model: string]: { [field: string]: true; }; }; }; } export declare const model: (name: string, fields: { [field: string]: string; }, models?: Models) => void; export interface Schemas { byType?: { [type: string]: { from: string; to: string; get?: (deep: any, id: any) => Promise<any>; }; }; byFrom?: { [type: string]: string[]; }; byTo?: { [type: string]: string[]; }; } export declare const schema: (type: any, from?: string, to?: string, schemas?: Schemas) => void; export declare const getValue: (cid: any, deep: any) => Promise<string>; export interface CONFIG { "CYBER_CONGRESS_ADDRESS": string; "DIVISOR_CYBER_G": number; "HYDROGEN": string; "CHAIN_ID": string; "DENOM_CYBER": string; "DENOM_LIQUID_TOKEN": string; "DENOM_CYBER_G": string; "CYBER_NODE_URL_API": string; "CYBER_WEBSOCKET_URL": string; "CYBER_NODE_URL_LCD": string; "CYBER_INDEX_HTTPS": string; "CYBER_INDEX_WEBSOCKET": string; "BECH32_PREFIX_ACC_ADDR_CYBER": string; "BECH32_PREFIX_ACC_ADDR_CYBERVALOPER": string; "MEMO_KEPLR": string; "CYBER_GATEWAY": string; } export declare function generateCyberDeepClient(options: { config: CONFIG; minilinks?: MinilinkCollection<any, Link<Id>>; namespace?: string; }): Promise<CyberDeepClient<Link<string>>>; export interface CyberDeepClientInstance<L extends Link<Id> = Link<Id>> extends DeepClientInstance<L> { } export interface CyberDeepClientOptions<L extends Link<Id>> extends DeepClientOptions<L> { cyberClient: CyberClient; config: CONFIG; helia: Helia; minilinks?: MinilinkCollection<any, Link<Id>>; namespace?: string; } export declare class CyberDeepClient<L extends Link<string> = Link<string>> extends DeepClient<L> implements CyberDeepClientInstance<L> { static resolveDependency?: (path: string) => Promise<any>; cyberClient: CyberClient; helia: Helia; config: CONFIG; accountPrefix: string; _byId: { [id: string]: any; }; schemas: Schemas; models: Models; useDeep: typeof useCyberDeep; DeepProvider: typeof CyberDeepProvider; DeepContext: React.Context<CyberDeepClient<Link<string>>>; constructor(options: CyberDeepClientOptions<L>); _generateQuery<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers'>(exp: Exp<TTable>, options: Options<TTable>): { query: import("./gql/query.js").IGenerateQueryResult; queryData: import("./gql/query.js").IGenerateQueryDataBuilder; }; _loadedValues: any; _generateResult<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers'>(exp: Exp<TTable>, options: Options<TTable>, data: any): Promise<any[]>; select<TTable extends 'links' | 'numbers' | 'strings' | 'objects' | 'can' | 'selectors' | 'tree' | 'handlers', LL = L>(exp: Exp<TTable>, options?: ReadOptions<TTable>): Promise<DeepClientResult<LL[]>>; insert<TTable extends 'links' | 'numbers' | 'strings' | 'objects', LL = L>(objects: InsertObjects<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{ id: any; }[]>>; update<TTable extends 'links' | 'numbers' | 'strings' | 'objects'>(exp: Exp<TTable>, value: UpdateValue<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{ id: any; }[]>>; delete<TTable extends 'links' | 'numbers' | 'strings' | 'objects'>(exp: Exp<TTable>, options?: WriteOptions<TTable>): Promise<DeepClientResult<{ id: any; }[]>>; serial({ name, operations, returning, silent }: AsyncSerialParams): Promise<DeepClientResult<{ id: Id; }[]>>; reserve<LL = L>(count: number): Promise<Id[]>; await(id: Id, options?: { results: boolean; }): Promise<any>; guest(options?: DeepClientGuestOptions): Promise<DeepClientAuthResult>; jwt(options: DeepClientJWTOptions): Promise<DeepClientAuthResult>; whoami(): Promise<number | undefined>; login(options: DeepClientJWTOptions): Promise<DeepClientAuthResult>; logout(): Promise<DeepClientAuthResult>; can(objectIds: null | Id | Id[], subjectIds: null | Id | Id[], actionIds: null | Id | Id[], userIds?: Id | Id[]): Promise<boolean>; Traveler(links: Link<Id>[]): NativeTraveler; } export declare function useCyberDeepGenerator({ minilinks, namespace, }: { minilinks: MinilinkCollection<any, Link<Id>>; namespace?: string; }): any; declare function useCyberDeep(): CyberDeepClient<Link<string>>; export declare function CyberDeepProvider({ minilinks: inputMinilinks, namespace, children, }: { minilinks?: MinilinkCollection<any, Link<Id>>; namespace?: string; children?: any; }): React.JSX.Element; export {};