Skip to content

Class: ModelManager

devtools.ModelManager

import { ModelManager } from '@glazed/devtools'

Constructors

constructor

new ModelManager(ceramic, model?)

Parameters

Name Type
ceramic CeramicApi
model? ManagedModel<DagJWSResult>

Accessors

definitions

get definitions(): string[]

Returns

string[]


model

get model(): ManagedModel<DagJWSResult>

Returns

ManagedModel<DagJWSResult>


schemas

get schemas(): string[]

Returns

string[]


tiles

get tiles(): string[]

Returns

string[]

Methods

addJSONModel

addJSONModel(encoded): void

Parameters

Name Type
encoded EncodedManagedModel

Returns

void


addModel

addModel(model): void

Parameters

Name Type
model ManagedModel<DagJWSResult>

Returns

void


create

create<T, Content>(type, alias, content, meta?): Promise<string>

Type parameters

Name Type
T extends keyof CreateContentType
Content CreateContentType[T]

Parameters

Name Type
type T
alias string
content Content
meta? Partial<StreamMetadata>

Returns

Promise<string>


createDefinition

createDefinition(alias, definition): Promise<string>

Parameters

Name Type
alias string
definition Definition<Record<string, any>>

Returns

Promise<string>


createSchema

createSchema(alias, schema): Promise<string>

Parameters

Name Type
alias string
schema Schema<Record<string, any>>

Returns

Promise<string>


createTile

createTile<T>(alias, contents, meta?): Promise<string>

Type parameters

Name Type
T extends Record<string, unknown>

Parameters

Name Type
alias string
contents T
meta Partial<StreamMetadata>

Returns

Promise<string>


getDefinition

getDefinition(id): null | ManagedEntry<DagJWSResult>

Parameters

Name Type
id string

Returns

null | ManagedEntry<DagJWSResult>


getDefinitionID

getDefinitionID(alias): null | string

Parameters

Name Type
alias string

Returns

null | string


getSchema

getSchema(id): null | ManagedSchema<DagJWSResult>

Parameters

Name Type
id string

Returns

null | ManagedSchema<DagJWSResult>


getSchemaByAlias

getSchemaByAlias(alias): null | ManagedSchema<DagJWSResult>

Parameters

Name Type
alias string

Returns

null | ManagedSchema<DagJWSResult>


getSchemaID

getSchemaID(alias): null | string

Parameters

Name Type
alias string

Returns

null | string


getSchemaURL

getSchemaURL(id): null | string

Parameters

Name Type
id string

Returns

null | string


getTile

getTile(id): null | ManagedEntry<DagJWSResult>

Parameters

Name Type
id string

Returns

null | ManagedEntry<DagJWSResult>


getTileID

getTileID(alias): null | string

Parameters

Name Type
alias string

Returns

null | string


hasDefinitionAlias

hasDefinitionAlias(alias): boolean

Parameters

Name Type
alias string

Returns

boolean


hasSchemaAlias

hasSchemaAlias(alias): boolean

Parameters

Name Type
alias string

Returns

boolean


hasTileAlias

hasTileAlias(alias): boolean

Parameters

Name Type
alias string

Returns

boolean


loadCommits

loadCommits(id): Promise<DagJWSResult[]>

Parameters

Name Type
id string

Returns

Promise<DagJWSResult[]>


loadSchema

loadSchema(id, alias?): Promise<string>

Parameters

Name Type
id string | StreamRef
alias? string

Returns

Promise<string>


loadSchemaDependencies

loadSchemaDependencies(schema): Promise<Record<string, string[]>>

Parameters

Name Type
schema Schema<Record<string, any>>

Returns

Promise<Record<string, string[]>>


loadStream

loadStream(streamID): Promise<TileDocument<Record<string, any>>>

Parameters

Name Type
streamID string | StreamRef

Returns

Promise<TileDocument<Record<string, any>>>


toJSON

toJSON(): EncodedManagedModel

Returns

EncodedManagedModel


toPublished

toPublished(): Promise<ModelData<string>>

Returns

Promise<ModelData<string>>


usePublished

usePublished<T, ID>(type, alias, id): Promise<string>

Type parameters

Name Type
T extends keyof UsePublishedIDType
ID UsePublishedIDType[T]

Parameters

Name Type
type T
alias string
id ID

Returns

Promise<string>


usePublishedDefinition

usePublishedDefinition(alias, id): Promise<string>

Parameters

Name Type
alias string
id string | StreamID

Returns

Promise<string>


usePublishedSchema

usePublishedSchema(alias, id): Promise<string>

Parameters

Name Type
alias string
id string | StreamRef

Returns

Promise<string>


usePublishedTile

usePublishedTile(alias, id): Promise<string>

Parameters

Name Type
alias string
id string | StreamID

Returns

Promise<string>


fromJSON

Static fromJSON(ceramic, encoded): ModelManager

Parameters

Name Type
ceramic CeramicApi
encoded EncodedManagedModel

Returns

ModelManager