mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
37 lines
765 B
TypeScript
37 lines
765 B
TypeScript
import {
|
|
PackagePropertiesV2,
|
|
PackagePropertyObject,
|
|
PackagePropertyString,
|
|
Properties as P,
|
|
} from "../types";
|
|
import { PropertyObject } from "./PropertyObject";
|
|
import { PropertyString } from "./PropertyString";
|
|
|
|
export class Properties<X extends PackagePropertiesV2> {
|
|
constructor(readonly data: X) {}
|
|
|
|
static of<
|
|
X extends Record<
|
|
string,
|
|
| PropertyObject<PackagePropertyObject>
|
|
| PropertyString<PackagePropertyString>
|
|
>
|
|
>(x: X) {
|
|
const answer = {} as {
|
|
[key in keyof X]: X[key]["data"];
|
|
};
|
|
|
|
for (const [key, value] of x.entries()) {
|
|
answer[key] = value.data;
|
|
}
|
|
return new Properties(answer);
|
|
}
|
|
|
|
build() {
|
|
return {
|
|
version: 2,
|
|
data: this.data,
|
|
} satisfies P;
|
|
}
|
|
}
|