mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
add select spec to union list items
This commit is contained in:
@@ -5,9 +5,8 @@ import {
|
|||||||
InputSpec,
|
InputSpec,
|
||||||
UniqueBy,
|
UniqueBy,
|
||||||
ValueSpecList,
|
ValueSpecList,
|
||||||
ValueSpecListOf,
|
|
||||||
} from "../config-types";
|
} from "../config-types";
|
||||||
import { guardAll, typeFromProps } from "../../util";
|
import { guardAll } from "../../util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as a subtype of Value.list
|
* Used as a subtype of Value.list
|
||||||
@@ -116,6 +115,11 @@ export class List<A extends ValueSpecList> extends IBuilder<A> {
|
|||||||
default: Record<string, unknown>[];
|
default: Record<string, unknown>[];
|
||||||
range: string;
|
range: string;
|
||||||
spec: {
|
spec: {
|
||||||
|
select: {
|
||||||
|
name: string;
|
||||||
|
description: string | null;
|
||||||
|
warning: string | null;
|
||||||
|
}
|
||||||
variants: Variants<{
|
variants: Variants<{
|
||||||
[key: string]: { name: string; spec: InputSpec };
|
[key: string]: { name: string; spec: InputSpec };
|
||||||
}>;
|
}>;
|
||||||
|
|||||||
@@ -159,17 +159,22 @@ export interface ListValueSpecObject {
|
|||||||
|
|
||||||
export type UniqueBy =
|
export type UniqueBy =
|
||||||
| null
|
| null
|
||||||
| undefined
|
|
||||||
| string
|
| string
|
||||||
| { any: readonly UniqueBy[] | UniqueBy[] }
|
| { any: readonly UniqueBy[] | UniqueBy[] }
|
||||||
| { all: readonly UniqueBy[] | UniqueBy[] };
|
| { all: readonly UniqueBy[] | UniqueBy[] };
|
||||||
|
|
||||||
export interface ListValueSpecUnion {
|
export interface ListValueSpecUnion {
|
||||||
|
select: {
|
||||||
|
name: string
|
||||||
|
description: null | string
|
||||||
|
warning: null | string
|
||||||
|
}
|
||||||
variants: { [key: string]: { name: string; spec: InputSpec } };
|
variants: { [key: string]: { name: string; spec: InputSpec } };
|
||||||
/** 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*/
|
/** a handlebars template for labeling each union list item */
|
||||||
displayAs: null | string;
|
displayAs: null | string;
|
||||||
|
/** indicates whether duplicates can be permitted in the list */
|
||||||
uniqueBy: UniqueBy;
|
uniqueBy: UniqueBy;
|
||||||
/** this should be the variantName which one prefers a user to start with by default when creating a new union instance in a list*/
|
/** the default variant when creating a new union instance in the list*/
|
||||||
default: null | string;
|
default: null | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ const matchVariant = object({
|
|||||||
const recordString = dictionary([string, unknown]);
|
const recordString = dictionary([string, unknown]);
|
||||||
const matchDefault = object({ default: unknown });
|
const matchDefault = object({ default: unknown });
|
||||||
const matchNullable = object({ nullable: literals(true) });
|
const matchNullable = object({ nullable: literals(true) });
|
||||||
const matchPattern = object({ pattern: string });
|
|
||||||
const rangeRegex = /(\[|\()(\*|(\d|\.)+),(\*|(\d|\.)+)(\]|\))/;
|
const rangeRegex = /(\[|\()(\*|(\d|\.)+),(\*|(\d|\.)+)(\]|\))/;
|
||||||
const matchRange = object({ range: string });
|
const matchRange = object({ range: string });
|
||||||
const matchIntegral = object({ integral: literals(true) });
|
const matchIntegral = object({ integral: literals(true) });
|
||||||
|
|||||||
@@ -253,10 +253,21 @@ export default async function makeFileContent(
|
|||||||
name:${JSON.stringify(value.name || null)},
|
name:${JSON.stringify(value.name || null)},
|
||||||
range:${JSON.stringify(value.range || null)},
|
range:${JSON.stringify(value.range || null)},
|
||||||
spec: {
|
spec: {
|
||||||
|
select: {
|
||||||
|
"name": ${JSON.stringify(
|
||||||
|
value?.spec?.tag?.["name"] || null
|
||||||
|
)},
|
||||||
|
"description": ${JSON.stringify(
|
||||||
|
value?.spec?.tag?.["description"] || null
|
||||||
|
)},
|
||||||
|
"warning": ${JSON.stringify(
|
||||||
|
value?.spec?.tag?.["warning"] || null
|
||||||
|
)},
|
||||||
|
},
|
||||||
variants: ${variants},
|
variants: ${variants},
|
||||||
displayAs: ${JSON.stringify(
|
displayAs: ${JSON.stringify(
|
||||||
value?.spec?.["display-as"] || null
|
value?.spec?.["display-as"] || null
|
||||||
)},
|
)},
|
||||||
uniqueBy: ${JSON.stringify(value?.spec?.["unique-by"] || null)},
|
uniqueBy: ${JSON.stringify(value?.spec?.["unique-by"] || null)},
|
||||||
default: ${JSON.stringify(value?.spec?.default || null)},
|
default: ${JSON.stringify(value?.spec?.default || null)},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user