Type Parameters

Implements

Constructors

Properties

DeepContext: Context<DeepClient<Link<number>>> = DeepContext
DeepProvider: ((__namedParameters) => Element) = DeepProvider

Type declaration

    • (__namedParameters): Element
    • Parameters

      • __namedParameters: {
            apolloClient?: IApolloClient<any>;
            children: any;
        }
        • Optional apolloClient?: IApolloClient<any>
        • children: any

      Returns Element

apolloClient: IApolloClient<any>
client: IApolloClient<any>
defaultDeleteName?: string
defaultInsertName?: string
defaultSelectName?: string
defaultUpdateName?: string
deleteReturning?: string
filesSelectReturning?: string
handleAuth?: ((linkId?, token?) => any)

Type declaration

    • (linkId?, token?): any
    • Parameters

      • Optional linkId: number
      • Optional token: string

      Returns any

insertReturning?: string
linkId?: number
linksSelectReturning?: string
minilinks: MinilinksResult<L>
returning?: string
selectReturning?: string
selectorsSelectReturning?: string
serializeQuery: ((exp, env?) => any) = serializeQuery

Type declaration

    • (exp, env?): any
    • Parameters

      • exp: any
      • env: string = 'links'

      Returns any

serializeWhere: ((exp, env?) => any) = serializeWhere

Type declaration

    • (exp, env?): any
    • Parameters

      • exp: any
      • env: string = 'links'

      Returns any

silent: boolean
table?: string
token?: string
unsafe?: any
updateReturning?: string
useDeep: (() => DeepClient<Link<number>>) = useDeep

Type declaration

useDeepQuery: (<Table, LL>(query, options?) => {
    data?: LL[];
    error?: any;
    loading: boolean;
}) = useDeepQuery

Type declaration

    • <Table, LL>(query, options?): {
          data?: LL[];
          error?: any;
          loading: boolean;
      }
    • Type Parameters

      • Table extends "objects" | "links" | "numbers" | "strings" | "can" | "selectors" | "tree" | "handlers"

      • LL = Link<number>

      Parameters

      • query: QueryLink
      • Optional options: {
            mini?: string;
            name?: string;
            returning?: string;
            table?: Table;
            tableNamePostfix?: string;
            variables?: any;
        }
        • Optional mini?: string
        • Optional name?: string
        • Optional returning?: string
        • Optional table?: Table
        • Optional tableNamePostfix?: string
        • Optional variables?: any

      Returns {
          data?: LL[];
          error?: any;
          loading: boolean;
      }

      • Optional data?: LL[]
      • Optional error?: any
      • loading: boolean
useDeepSubscription: (<Table, LL>(query, options?) => UseDeepSubscriptionResult<LL>) = useDeepSubscription

Type declaration

    • <Table, LL>(query, options?): UseDeepSubscriptionResult<LL>
    • Type Parameters

      • Table extends "objects" | "links" | "numbers" | "strings" | "can" | "selectors" | "tree" | "handlers"

      • LL = Link<number>

      Parameters

      • query: QueryLink
      • Optional options: {
            mini?: string;
            name?: string;
            returning?: string;
            table?: Table;
            tableNamePostfix?: string;
            variables?: any;
        }
        • Optional mini?: string
        • Optional name?: string
        • Optional returning?: string
        • Optional table?: Table
        • Optional tableNamePostfix?: string
        • Optional variables?: any

      Returns UseDeepSubscriptionResult<LL>

valuesSelectReturning?: string
resolveDependency?: ((path) => Promise<any>)

Type declaration

    • (path): Promise<any>
    • Parameters

      • path: string

      Returns Promise<any>

Methods

  • Await for a promise

    Parameters

    • id: number

      Id of a link which is processed by a handler

    • options: {
          results: boolean;
      } = ...

      An object with options for the await operation

      • results: boolean

    Returns Promise<any>

    A promise that resolves to the result of the awaited promise

    Example

    Await a promise of npm-packager

    Let us imagine you have published a package and want to programatically wait until it is published or failed to publish

    await deep.await(
    await deep.id('my-package-name')
    )

    In this case you will await all the promises for 'my-package-name' link

  • Checks whether subjectUds can perform actionIds on objectIds

    Parameters

    • objectIds: number | number[]

      A link id or an array of link ids to check whether the subjectUds can perform the actionIds on

    • subjectIds: number | number[]

      A link id or an array of link ids to check whether they can perform the actionIds on the objectIds

    • actionIds: number | number[]

      A link id or an array of link ids to check whether the subjectUds can perform on the objectIds

    • userIds: number | number[] = ...

      A link id or an array of link ids from which perspective the check is performed

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether the subjectUds can perform the actionIds on the objectIds

  • Deletes a value in the database. By default deletes a link in the links table

    Type Parameters

    • TTable extends "objects" | "links" | "numbers" | "strings"

    Parameters

    • exp: Exp<TTable>

      An expression to filter the objects to delete

    • Optional options: WriteOptions<TTable>

      An object with options for the delete operation

    Returns Promise<DeepClientResult<{
        id: any;
    }[]>>

    A promise that resolves to the deleted object or an array of deleted objects with the fields configured by options.returning which is by default 'id'

    Example

    Delete by id

    await deep.delete({
    id: 888
    })

    In this case the link with id 888 will be deleted

    Delete by type_id

    await deep.delete({
    type_id: 888
    })

    In this case all the links with type_id 888 will be deleted

    Delete by from_id

    await deep.delete({
    from_id: 888
    })

    In this case all the links with from_id 888 will be deleted

    Delete by to_id

    await deep.delete({
    to_id: 888
    })

    In this case all the links with to_id 888 will be deleted

    Delete by string value

    await deep.delete({
    string: {
    value: {
    _eq: 'MyString'
    }
    }
    })

    In this case all the links with string value 'MyString' will be deleted

    Delete by number value

    await deep.delete({
    number: {
    value: {
    _eq: 888
    }
    }
    })

    In this case all the links with number value 888 will be deleted

    Delete by object value

    await deep.delete({
    object: {
    value: {
    _eq: {
    myFieldKey: "myFieldValue"
    }
    }
    }
    })

    In this case all the links with object value { myFieldName: "myFieldValue" } will be deleted

    Delete string value by link id

    await deep.delete({
    link_id: 888
    }, {
    table: 'strings'
    })

    In this case string value of a link with id 888 will be deleted

    Delete number value by link id

    await deep.delete({
    link_id: 888
    }, {
    table: 'numbers'
    })

    In this case number value of a link with id 888 will be deleted

    Delete object value by link id

    await deep.delete({
    link_id: 888
    }, {
    table: 'objects'
    })

    In this case object value of a link with id 888 will be deleted

  • This function fetches the corresponding IDs from the Deep for each specified path.

    Parameters

    • Rest ...paths: [DeepClientStartItem, ...DeepClientPathItem[]][]

      An array of [start, ...path] tuples. Each tuple specifies a path to a link, where 'start' is the package name or id and ...path further specifies the path to the id using Contain link values (names).

    Returns Promise<any>

    • Returns a Promise that resolves to an object. The object has keys corresponding to the package name or id of each path. The value for each package key is an object where keys are the items in the corresponding path, and the values are the IDs retrieved from the Deep.

    Async

    Function

    ids

    Throws

    Will throw an error if the id retrieval fails in this.id() function.

    Example

      const ids = await deep.ids([
    ['@deep-foundation/core', 'Package'],
    ['@deep-foundation/core', 'PackageVersion']
    ]);

    // Outputs
    // {
    // "@deep-foundation/core": {
    // "Package": 2,
    // "PackageVersion": 46
    // }
    // }
  • Imports from a library

    Parameters

    • path: string

      A path to import from

    Returns Promise<any>

    A promise that resolves to the imported value

    Remarks

    Is able to import CommoJS and ESModule libraries. This is the recommended way to import from libraries in deep handlers

    Example

    Async handler using import

    async ({deep}) => {
    const importResult = await deep.import("my-lib-name");
    }
  • Inserts a value into the database. By default inserts a link to the links table

    Type Parameters

    • TTable extends "objects" | "links" | "numbers" | "strings"

    • LL = L

    Parameters

    Returns Promise<DeepClientResult<{
        id: any;
    }[]>>

    A promise that resolves to the inserted object or an array of inserted objects with the fields configured by options.returning which is by default 'id'

    Remarks

    If a link already has value you should update its value, not insert

    Example

    Insert Type

    await deep.insert({
    type_id: await deep.id("@deep-foundation/core", "Type")
    })

    In this case instances of your type will not have from and to

    Insert Type from Package to User

    await deep.insert({
    type_id: await deep.id("@deep-foundation/core", "Type"),
    from_id: await deep.id("@deep-foundation/core", "Package"),
    to_id: await deep.id("@deep-foundation/core", "User")
    })

    In this case instances of your type will must go from instances of Package to instances of User

    Insert Type with from Any to Any

    await deep.insert({
    type_id: await deep.id("@deep-foundation/core", "Type"),
    from_id: await deep.id("@deep-foundation/core", "Any"),
    to_id: await deep.id("@deep-foundation/core", "Any")
    })

    In this case instances of your type may go from instances of any link to instances of any link without restrictions

    Insert Type with from Package to Any

    await deep.insert({
    type_id: await deep.id("@deep-foundation/core", "Type"),
    from_id: await deep.id("@deep-foundation/core", "Package"),
    to_id: await deep.id("@deep-foundation/core", "Any")
    })

    In this case instances of your type may go from instances of Package to instances of any link without restrictions

    Insert Type with from Any to Package

    await deep.insert({
    type_id: await deep.id("@deep-foundation/core", "Type"),
    from_id: await deep.id("@deep-foundation/core", "Any"),
    to_id: await deep.id("@deep-foundation/core", "Package")
    })

    In this case instances of your type may go from instances of any link without restrictions to instances of Package

    Insert string

    await deep.insert({
    link_id: 888,
    value: 'MyString'
    }, {
    table: 'strings'
    })

    Note: If a link already has value you should update its value, not insert

    Insert number

    await deep.insert({
    link_id: 888,
    value: 888
    }, {
    table: 'numbers'
    })

    Note: If a link already has value you should update its value, not insert

    Insert object

    await deep.insert({
    link_id: 888,
    value: {
    myFieldName: 'myFieldValue'
    }
    }, {
    table: 'objects'
    })

    Note: If a link already has value you should update its value, not insert

  • Performs a login operation

    Parameters

    Returns Promise<DeepClientAuthResult>

    A promsie that resolves to the result of the login operation

    Example

    const apolloClient = generateApolloClient({
    path: NEXT_PUBLIC_GQL_PATH,
    ssl: true,
    });
    const unloginedDeep = new DeepClient({ apolloClient });
    const guestLoginResult = await unloginedDeep.guest();
    const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult });
    const adminLoginResult = await guestDeep.login({
    linkId: await guestDeep.id('deep', 'admin'),
    });
    const deep = new DeepClient({ deep: guestDeep, ...adminLoginResult });
  • Returns a name of a link input that is located in a value of a contain link pointing to the link input

    Parameters

    • input: number | Link<number>

    Returns Promise<string>

    Example

    const userTypeLinkId = await deep.id("@deep-foundation/core", "User");
    const userTypeLinkName = await deep.name(userTypeLinkId);
  • Returns a name of a link input that is located in a value of a contain link pointing to the link input according to links stored in minilinks

    Parameters

    • input: number | Link<number>

    Returns string

    Example

    const userTypeLinkId = await deep.id("@deep-foundation/core", "User");
    const userTypeLinkName = deep.nameLocal(userTypeLinkId);

    Note: "@deep-foundation/core" package, "User" link, Contain link pointing from "@deep-foundation/core" to "User" must be in minilinks

  • Updates a value in the database. By default updates a link in the links table

    Type Parameters

    • TTable extends "objects" | "links" | "numbers" | "strings"

    Parameters

    Returns Promise<DeepClientResult<{
        id: any;
    }[]>>

    A promise that resolves to the updated object or an array of updated objects with the fields configured by options.returning which is by default 'id'

    Example

    Update from by id

    await deep.update({
    id: 888
    }, {
    from_id: 1
    })

    In this case from_id will be updated to 1 for link with id 888

    Update to by id

    await deep.update({
    id: 888
    }, {
    to_id: 1
    })

    In this case to_id will be updated to 1 for link with id 888

    Update string value by link id

    await deep.update(
    {
    link_id: 888
    },
    {
    value: "MyStringValue"
    },
    {
    table: 'strings'
    }
    )

    In this case string value will be updated to "MyStringValue" for link with id 888

    Update number value by link id

    await deep.update(
    {
    link_id: 888
    },
    {
    value: 888
    },
    {
    table: 'numbers'
    }
    )

    In this case number value will be updated to 888 for link with id 888

    Update object value by link id

    await deep.update(
    {
    link_id: 888
    },
    {
    value: {
    myFieldName: "myFieldValue"
    }
    },
    {
    table: 'numbers'
    }
    )

    In this case number value will be updated to { myFieldName: "myFieldValue" } for link with id 888

Generated using TypeDoc