chore: Update to docstrings

This commit is contained in:
BluJ
2023-03-25 18:35:14 -06:00
parent 16fed45f4b
commit fa2d9367c6

View File

@@ -12,7 +12,7 @@ export type ValueType =
| "union";
export type ValueSpec = ValueSpecOf<ValueType>;
// core spec types. These types provide the metadata for performing validations
/** core spec types. These types provide the metadata for performing validations */
export type ValueSpecOf<T extends ValueType> = T extends "string"
? ValueSpecString
: T extends "number"
@@ -53,7 +53,8 @@ export interface ValueSpecSelect extends SelectBase, WithStandalone {
export interface ValueSpecMultiselect extends SelectBase, WithStandalone {
type: "multiselect";
range: string; // '[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules
/**'[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules */
range: string;
default: string[];
}
@@ -70,7 +71,7 @@ export interface ValueSpecUnion {
}
export interface ValueSpecFile extends WithStandalone {
type: 'file';
type: "file";
placeholder: null | string;
nullable: boolean;
extensions: string[];
@@ -92,14 +93,10 @@ export interface SelectBase {
"value-names": { [value: string]: string };
}
// no lists of booleans, lists
export type ListValueSpecType =
| "string"
| "number"
| "object"
| "union";
/** no lists of booleans, lists*/
export type ListValueSpecType = "string" | "number" | "object" | "union";
// represents a spec for the values of a list
/** represents a spec for the values of a list */
export type ListValueSpecOf<T extends ListValueSpecType> = T extends "string"
? ListValueSpecString
: T extends "number"
@@ -110,10 +107,9 @@ export type ListValueSpecOf<T extends ListValueSpecType> = T extends "string"
? ListValueSpecUnion
: never;
// represents a spec for a list
/** represents a spec for a list */
export type ValueSpecList = ValueSpecListOf<ListValueSpecType>;
export interface ValueSpecListOf<T extends ListValueSpecType>
extends WithStandalone {
export interface ValueSpecListOf<T extends ListValueSpecType> extends WithStandalone {
type: "list";
subtype: T;
spec: ListValueSpecOf<T>;
@@ -130,10 +126,7 @@ export interface ValueSpecListOf<T extends ListValueSpecType>
}
// sometimes the type checker needs just a little bit of help
export function isValueSpecListOf<S extends ListValueSpecType>(
t: ValueSpecList,
s: S
): t is ValueSpecListOf<S> {
export function isValueSpecListOf<S extends ListValueSpecType>(t: ValueSpecList, s: S): t is ValueSpecListOf<S> {
return t.subtype === s;
}
@@ -145,16 +138,20 @@ export interface ListValueSpecString {
}
export interface ListValueSpecNumber {
range: string; // '[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules
/** '[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules */
range: string;
integral: boolean;
units: null | string;
placeholder: null | string;
}
export interface ListValueSpecObject {
spec: InputSpec; // this is a mapped type of the config object at this level, replacing the object's values with specs on those values
"unique-by": UniqueBy; // indicates whether duplicates can be permitted in the list
"display-as": null | string; // this should be a handlebars template which can make use of the entire config which corresponds to 'spec'
/** this is a mapped type of the config object at this level, replacing the object's values with specs on those values */
spec: InputSpec;
/** indicates whether duplicates can be permitted in the list */
"unique-by": UniqueBy;
/** this should be a handlebars template which can make use of the entire config which corresponds to 'spec' */
"display-as": null | string;
}
export type UniqueBy =
@@ -167,15 +164,18 @@ export type UniqueBy =
export interface ListValueSpecUnion {
tag: UnionTagSpec;
variants: { [key: string]: InputSpec };
"display-as": null | string; // this may be a handlebars template which can conditionally (on tag.id) make use of each union's entries, or if left blank will display as tag.id
/** this may be a handlebars template which can conditionally (on tag.id) make use of each union's entries, or if left blank will display as tag.id*/
"display-as": null | string;
"unique-by": UniqueBy;
default: string; // this should be the variantName which one prefers a user to start with by default when creating a new union instance in a list
/** this should be the variantName which one prefers a user to start with by default when creating a new union instance in a list*/
default: string;
}
export interface UnionTagSpec {
id: string; // The name of the field containing one of the union variants
/** The name of the field containing one of the union variants*/
id: string;
"variant-names": {
// the name of each variant
/** the name of each variant*/
[variant: string]: string;
};
name: string;