mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
filter union for smtp
This commit is contained in:
@@ -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 = never> = {
|
export type ConfigSpecOf<A extends Record<string, any>, WD = never> = {
|
||||||
[K in keyof A]: Value<A[K], WD>
|
[K in keyof A]: Value<A[K], WD>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { SmtpValue } from "../types"
|
import { SmtpValue } from "../types"
|
||||||
import { Config, TypeAsConfigOf } from "./builder/config"
|
import { Config, ConfigSpecOf } from "./builder/config"
|
||||||
import { Value } from "./builder/value"
|
import { Value } from "./builder/value"
|
||||||
import { Variants } from "./builder/variants"
|
import { Variants } from "./builder/variants"
|
||||||
|
|
||||||
export const smtpConfig = Value.union(
|
export const smtpConfig = Value.filteredUnion(async ({ effects, utils }) => {
|
||||||
|
const smtp = await utils.getSystemSmtp().once()
|
||||||
|
return smtp ? [] : ["system"]
|
||||||
|
})(
|
||||||
{
|
{
|
||||||
name: "SMTP",
|
name: "SMTP",
|
||||||
description: "Optionally provide an SMTP server for sending email",
|
description: "Optionally provide an SMTP server for sending email",
|
||||||
@@ -14,7 +17,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>>({
|
spec: Config.of<ConfigSpecOf<SmtpValue>>({
|
||||||
server: Value.text({
|
server: Value.text({
|
||||||
name: "SMTP Server",
|
name: "SMTP Server",
|
||||||
required: {
|
required: {
|
||||||
|
|||||||
@@ -335,6 +335,8 @@ export type Effects = {
|
|||||||
interfaceId: string,
|
interfaceId: string,
|
||||||
packageId?: string,
|
packageId?: string,
|
||||||
): Promise<string>
|
): Promise<string>
|
||||||
|
/** Get the IP address of the container */
|
||||||
|
getContainerIp(): Promise<string>
|
||||||
/**
|
/**
|
||||||
* Get the port address for another service
|
* Get the port address for another service
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { Parser } from "ts-matches"
|
import { Effects } from "../types"
|
||||||
import { Effects, EnsureWrapperDataPath, ExtractWrapperData } from "../types"
|
|
||||||
import { NoAny } from "."
|
|
||||||
|
|
||||||
export class GetSystemSmtp {
|
export class GetSystemSmtp {
|
||||||
constructor(readonly effects: Effects) {}
|
constructor(readonly effects: Effects) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user