allow for arbitrary grouping of property values and intro PropertyPage

This commit is contained in:
Matt Hill
2023-05-03 14:56:41 -06:00
parent 8801760aa6
commit e645854d18
4 changed files with 36 additions and 16 deletions

View File

@@ -1,18 +1,16 @@
import { PackagePropertyGroup } from "../types"
import { PropertyPage } from "./PropertyPage"
import { PropertyString } from "./PropertyString"
export class PropertyGroup {
private constructor(readonly data: PackagePropertyGroup) {}
static of(options: {
description: string
value: (PropertyGroup | PropertyString)[]
name: string
header: string | null
values: (PropertyPage | PropertyString)[]
}) {
return new PropertyGroup({
type: "object",
name: options.name,
description: options.description,
value: options.value.map((x) => x.data),
header: options.header,
value: options.values.map((x) => x.data),
})
}
}

View File

@@ -0,0 +1,18 @@
import { PackagePropertyPage } from "../types"
import { PropertyGroup } from "./PropertyGroup"
export class PropertyPage {
private constructor(readonly data: PackagePropertyPage) {}
static of(options: {
name: string
description: string | null
groups: PropertyGroup[]
}) {
return new PropertyPage({
type: "page",
name: options.name,
description: options.description,
value: options.groups.map((x) => x.data),
})
}
}

View File

@@ -19,7 +19,7 @@ export type UnionToIntersection<T> = ((x: T) => any) extends (x: infer R) => any
export function setupProperties<WrapperData>(
fn: (args: {
wrapperData: WrapperData
}) => void | Promise<void> | Promise<(PropertyGroup | PropertyString)[]>,
}) => void | Promise<void> | Promise<PropertyGroup[]>,
): ExpectedExports.properties {
return (async (options) => {
const result = await fn(

View File

@@ -568,7 +568,17 @@ export type KnownError =
"error-code": [number, string] | readonly [number, string]
}
export type PackageProperties = PackagePropertyGroup | PackagePropertyString
export type PackagePropertyGroup = {
header: string | null
value: PackageProperties[]
}
export type PackageProperties = PackagePropertyPage | PackagePropertyString
export type PackagePropertyPage = {
type: "page"
name: string
description: string | null
value: Properties
}
export type PackagePropertyString = {
type: "string"
name: string
@@ -581,14 +591,8 @@ export type PackagePropertyString = {
/** Hiding the value unless toggled off for field */
masked: boolean
}
export type PackagePropertyGroup = {
value: PackageProperties[]
type: "object"
name: string
description: string
}
export type Properties = PackageProperties[]
export type Properties = PackagePropertyGroup[]
export type Dependency = {
id: PackageId