mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
allow for arbitrary grouping of property values and intro PropertyPage
This commit is contained in:
@@ -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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
18
lib/properties/PropertyPage.ts
Normal file
18
lib/properties/PropertyPage.ts
Normal 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),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
20
lib/types.ts
20
lib/types.ts
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user