@glazed/types
Advanced tools
Comparing version 0.2.0-alpha.2 to 0.2.0-alpha.3
@@ -0,3 +1,9 @@ | ||
/** | ||
* Common types used by Glaze packages. | ||
* | ||
* @module types | ||
*/ | ||
import type { JSONSchemaType } from 'ajv'; | ||
import type { DagJWSResult, JWSSignature } from 'dids'; | ||
/** JSON-encoded DAG-JWS. */ | ||
export declare type EncodedDagJWS = { | ||
@@ -8,2 +14,3 @@ payload: string; | ||
}; | ||
/** JSON-encoded DAG-JWS result representing a Ceramic stream commit. */ | ||
export declare type EncodedDagJWSResult = { | ||
@@ -13,2 +20,3 @@ jws: EncodedDagJWS; | ||
}; | ||
/** JSON schema declaration, used for validating Ceramic streams. */ | ||
export declare type Schema<T = Record<string, any>> = JSONSchemaType<T> & { | ||
@@ -18,2 +26,3 @@ $comment?: string; | ||
}; | ||
/** Generic structure for storing model data. */ | ||
export declare type ModelData<T> = { | ||
@@ -24,2 +33,3 @@ definitions: Record<string, T>; | ||
}; | ||
/** Utility type for mapping a model structure of a given type to another. */ | ||
export declare type MapModelTypes<Model extends ModelData<any>, ToType> = { | ||
@@ -30,4 +40,10 @@ schemas: Record<keyof Model['schemas'], ToType>; | ||
}; | ||
/** Utility type for mapping a model structure to a given type. */ | ||
export declare type CastModelTo<Model extends ModelData<any> | void, ToType> = Model extends ModelData<any> ? MapModelTypes<Model, ToType> : ModelData<ToType>; | ||
/** | ||
* Data model aliases created by {@linkcode devtools.ModelManager.deploy deploying a managed model} | ||
* and used at runtime by the {@linkcode datamodel.DataModel DataModel} class. | ||
*/ | ||
export declare type ModelAliases<Model extends ModelData<any> | void = void> = CastModelTo<Model, string>; | ||
/** Model aliases relations between schemas and the definitions and tiles using them. */ | ||
export declare type ModelTypeAliases<Schemas extends Record<string, any> = Record<string, any>, Definitions extends Record<string, keyof Schemas> = Record<string, string>, Tiles extends Record<string, keyof Schemas> = Record<string, string>> = { | ||
@@ -38,4 +54,7 @@ schemas: Schemas; | ||
}; | ||
/** Utility type to cast {@linkcode ModelTypeAliases} to {@linkcode ModelAliases}. */ | ||
export declare type ModelTypesToAliases<TypeAliases extends ModelTypeAliases> = MapModelTypes<TypeAliases, string>; | ||
/** ID of a stream used in a {@linkcode ManagedModel}. */ | ||
export declare type ManagedID = string; | ||
/** Shared structure for representing streams used in a {@linkcode ManagedModel}. */ | ||
export declare type ManagedDoc<CommitType = DagJWSResult> = { | ||
@@ -46,8 +65,20 @@ alias: string; | ||
}; | ||
/** | ||
* Structure for representing streams having a schema dependency, used in a | ||
* {@linkcode ManagedModel}. | ||
*/ | ||
export declare type ManagedEntry<CommitType = DagJWSResult> = ManagedDoc<CommitType> & { | ||
schema: ManagedID; | ||
}; | ||
/** | ||
* Structure for representing schema streams and their dependencies, used in a | ||
* {@linkcode ManagedModel}. | ||
*/ | ||
export declare type ManagedSchema<CommitType = DagJWSResult> = ManagedDoc<CommitType> & { | ||
dependencies: Record<string, Array<ManagedID>>; | ||
}; | ||
/** | ||
* Structure used internally by the {@linkcode devtools.ModelManager ModelManager} to represent a | ||
* data model. | ||
*/ | ||
export declare type ManagedModel<CommitType = DagJWSResult> = { | ||
@@ -58,2 +89,6 @@ schemas: Record<ManagedID, ManagedSchema<CommitType>>; | ||
}; | ||
/** | ||
* JSON-encoded version of the {@linkcode ManagedModel}, used by the | ||
* {@linkcode devtools.ModelManager ModelManager}. | ||
*/ | ||
export declare type EncodedManagedModel = ManagedModel<EncodedDagJWSResult>; |
@@ -1,1 +0,5 @@ | ||
export { }; | ||
/** | ||
* Common types used by Glaze packages. | ||
* | ||
* @module types | ||
*/ export { }; |
{ | ||
"name": "@glazed/types", | ||
"version": "0.2.0-alpha.2", | ||
"version": "0.2.0-alpha.3", | ||
"author": "3Box Labs", | ||
@@ -26,3 +26,3 @@ "license": "(Apache-2.0 OR MIT)", | ||
"engines": { | ||
"node": ">=16" | ||
"node": ">=14.14" | ||
}, | ||
@@ -29,0 +29,0 @@ "sideEffects": false, |
8225
91