@self.id/core
Version:
Read public records in Node and browsers environments
28 lines (27 loc) • 1.15 kB
TypeScript
import type { DefinitionContentType } from '@glazed/did-datastore';
import type { ModelTypeAliases } from '@glazed/types';
import type { ModelTypes as CoreModelTypes } from './__generated__/model.js';
import type { Core } from './core.js';
export declare type PublicIDParams<ModelTypes extends ModelTypeAliases = CoreModelTypes> = {
/** {@linkcode Core} instance to use. */
core: Core<ModelTypes>;
/** DID string. */
id: string;
};
/**
* A PublicID instance provides a client associated to a specific DID.
*
* It is exported by the {@linkcode core} module.
*
* ```sh
* import { PublicID } from '@self.id/core'
* ```
*/
export declare class PublicID<ModelTypes extends ModelTypeAliases = CoreModelTypes, Alias extends keyof ModelTypes['definitions'] = keyof ModelTypes['definitions']> {
#private;
constructor(params: PublicIDParams<ModelTypes>);
/** DID string associated to the PublicID instance. */
get id(): string;
/** Load the record contents for a given definition alias. */
get<Key extends Alias, ContentType = DefinitionContentType<ModelTypes, Key>>(key: Key): Promise<ContentType | null>;
}