chore: small update

This commit is contained in:
BluJ
2023-05-03 10:16:00 -06:00
parent 31c2131ca9
commit e2867420b6
4 changed files with 8 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ export type ExtractConfigType<A extends Record<string, any> | Config<Record<stri
A extends Config<infer B, any> | Config<infer B, never> ? B : A extends Config<infer B, any> | Config<infer B, never> ? B :
A A
export type TypeAsConfigOf<A extends Record<string, any>, WD> = { export type TypeAsConfigOf<A extends Record<string, any>, WD = never> = {
[K in keyof A]: Value<A[K], WD> [K in keyof A]: Value<A[K], WD>
} }
@@ -82,7 +82,7 @@ export const addNodesSpec = Config.of({ hostname: hostname, port: port });
export class Config<Type extends Record<string, any>, WD> { export class Config<Type extends Record<string, any>, WD> {
private constructor( private constructor(
private readonly spec: { private readonly spec: {
[K in keyof Type]: Value<Type[K], WD> [K in keyof Type]: Value<Type[K], WD> | Value<Type[K], never>
}, },
public validator: Parser<unknown, Type>, public validator: Parser<unknown, Type>,
) {} ) {}
@@ -91,7 +91,7 @@ export class Config<Type extends Record<string, any>, WD> {
[K in keyof Type]: ValueSpec [K in keyof Type]: ValueSpec
} }
for (const k in this.spec) { for (const k in this.spec) {
answer[k] = await this.spec[k].build(options) answer[k] = await this.spec[k].build(options as any)
} }
return answer return answer
} }
@@ -117,7 +117,7 @@ export class Config<Type extends Record<string, any>, WD> {
{ {
[K in keyof Spec]: Spec[K] extends Value<any, infer WD> ? WD : never [K in keyof Spec]: Spec[K] extends Value<any, infer WD> ? WD : never
}[keyof Spec] }[keyof Spec]
>(spec as any, validator as any) >(spec, validator as any)
} }
/** /**

View File

@@ -14,7 +14,7 @@ export const smtpConfig = Value.union(
system: { name: "System Credentials", spec: Config.of({}) }, system: { name: "System Credentials", spec: Config.of({}) },
custom: { custom: {
name: "Custom Credentials", name: "Custom Credentials",
spec: Config.of<TypeAsConfigOf<SmtpValue, never>>({ spec: Config.of<TypeAsConfigOf<SmtpValue>>({
server: Value.text({ server: Value.text({
name: "SMTP Server", name: "SMTP Server",
required: { required: {

View File

@@ -65,7 +65,7 @@ export class EmVer {
* Or an already made emver * Or an already made emver
* IsUnsafe * IsUnsafe
*/ */
static from(range: ValidEmVer | EmVer): EmVer { static from(range: string | EmVer): EmVer {
if (range instanceof EmVer) { if (range instanceof EmVer) {
return range return range
} }

View File

@@ -1,4 +1,4 @@
import { ValidEmVer, ValidEmVerRange } from "../emverLite/mod" import { ValidEmVer } from "../emverLite/mod"
import { ActionMetaData } from "../types" import { ActionMetaData } from "../types"
export interface Container { export interface Container {
@@ -70,7 +70,7 @@ export interface Dependency {
/** The range of versions that would satisfy the dependency /** The range of versions that would satisfy the dependency
* ie: >=3.4.5 && <4.0.0 * ie: >=3.4.5 && <4.0.0
*/ */
version: ValidEmVerRange version: string
/** /**
* A human readable explanation on what the dependency is used for * A human readable explanation on what the dependency is used for
*/ */