mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +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 { PackagePropertyGroup } from "../types"
|
||||||
|
import { PropertyPage } from "./PropertyPage"
|
||||||
import { PropertyString } from "./PropertyString"
|
import { PropertyString } from "./PropertyString"
|
||||||
|
|
||||||
export class PropertyGroup {
|
export class PropertyGroup {
|
||||||
private constructor(readonly data: PackagePropertyGroup) {}
|
private constructor(readonly data: PackagePropertyGroup) {}
|
||||||
static of(options: {
|
static of(options: {
|
||||||
description: string
|
header: string | null
|
||||||
value: (PropertyGroup | PropertyString)[]
|
values: (PropertyPage | PropertyString)[]
|
||||||
name: string
|
|
||||||
}) {
|
}) {
|
||||||
return new PropertyGroup({
|
return new PropertyGroup({
|
||||||
type: "object",
|
header: options.header,
|
||||||
name: options.name,
|
value: options.values.map((x) => x.data),
|
||||||
description: options.description,
|
|
||||||
value: options.value.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>(
|
export function setupProperties<WrapperData>(
|
||||||
fn: (args: {
|
fn: (args: {
|
||||||
wrapperData: WrapperData
|
wrapperData: WrapperData
|
||||||
}) => void | Promise<void> | Promise<(PropertyGroup | PropertyString)[]>,
|
}) => void | Promise<void> | Promise<PropertyGroup[]>,
|
||||||
): ExpectedExports.properties {
|
): ExpectedExports.properties {
|
||||||
return (async (options) => {
|
return (async (options) => {
|
||||||
const result = await fn(
|
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]
|
"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 = {
|
export type PackagePropertyString = {
|
||||||
type: "string"
|
type: "string"
|
||||||
name: string
|
name: string
|
||||||
@@ -581,14 +591,8 @@ export type PackagePropertyString = {
|
|||||||
/** Hiding the value unless toggled off for field */
|
/** Hiding the value unless toggled off for field */
|
||||||
masked: boolean
|
masked: boolean
|
||||||
}
|
}
|
||||||
export type PackagePropertyGroup = {
|
|
||||||
value: PackageProperties[]
|
|
||||||
type: "object"
|
|
||||||
name: string
|
|
||||||
description: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Properties = PackageProperties[]
|
export type Properties = PackagePropertyGroup[]
|
||||||
|
|
||||||
export type Dependency = {
|
export type Dependency = {
|
||||||
id: PackageId
|
id: PackageId
|
||||||
|
|||||||
Reference in New Issue
Block a user