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"; | "union";
export type ValueSpec = ValueSpecOf<ValueType>; 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" export type ValueSpecOf<T extends ValueType> = T extends "string"
? ValueSpecString ? ValueSpecString
: T extends "number" : T extends "number"
@@ -53,7 +53,8 @@ export interface ValueSpecSelect extends SelectBase, WithStandalone {
export interface ValueSpecMultiselect extends SelectBase, WithStandalone { export interface ValueSpecMultiselect extends SelectBase, WithStandalone {
type: "multiselect"; 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[]; default: string[];
} }
@@ -70,7 +71,7 @@ export interface ValueSpecUnion {
} }
export interface ValueSpecFile extends WithStandalone { export interface ValueSpecFile extends WithStandalone {
type: 'file'; type: "file";
placeholder: null | string; placeholder: null | string;
nullable: boolean; nullable: boolean;
extensions: string[]; extensions: string[];
@@ -92,14 +93,10 @@ export interface SelectBase {
"value-names": { [value: string]: string }; "value-names": { [value: string]: string };
} }
// no lists of booleans, lists /** no lists of booleans, lists*/
export type ListValueSpecType = export type ListValueSpecType = "string" | "number" | "object" | "union";
| "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" export type ListValueSpecOf<T extends ListValueSpecType> = T extends "string"
? ListValueSpecString ? ListValueSpecString
: T extends "number" : T extends "number"
@@ -110,10 +107,9 @@ export type ListValueSpecOf<T extends ListValueSpecType> = T extends "string"
? ListValueSpecUnion ? ListValueSpecUnion
: never; : never;
// represents a spec for a list /** represents a spec for a list */
export type ValueSpecList = ValueSpecListOf<ListValueSpecType>; export type ValueSpecList = ValueSpecListOf<ListValueSpecType>;
export interface ValueSpecListOf<T extends ListValueSpecType> export interface ValueSpecListOf<T extends ListValueSpecType> extends WithStandalone {
extends WithStandalone {
type: "list"; type: "list";
subtype: T; subtype: T;
spec: ListValueSpecOf<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 // sometimes the type checker needs just a little bit of help
export function isValueSpecListOf<S extends ListValueSpecType>( export function isValueSpecListOf<S extends ListValueSpecType>(t: ValueSpecList, s: S): t is ValueSpecListOf<S> {
t: ValueSpecList,
s: S
): t is ValueSpecListOf<S> {
return t.subtype === s; return t.subtype === s;
} }
@@ -145,16 +138,20 @@ export interface ListValueSpecString {
} }
export interface ListValueSpecNumber { 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; integral: boolean;
units: null | string; units: null | string;
placeholder: null | string; placeholder: null | string;
} }
export interface ListValueSpecObject { 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 /** 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 spec: InputSpec;
"display-as": null | string; // this should be a handlebars template which can make use of the entire config which corresponds to 'spec' /** 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 = export type UniqueBy =
@@ -167,15 +164,18 @@ export type UniqueBy =
export interface ListValueSpecUnion { export interface ListValueSpecUnion {
tag: UnionTagSpec; tag: UnionTagSpec;
variants: { [key: string]: InputSpec }; 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; "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 { 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": { "variant-names": {
// the name of each variant /** the name of each variant*/
[variant: string]: string; [variant: string]: string;
}; };
name: string; name: string;