mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
@@ -354,7 +354,9 @@ pub enum ImageSource {
|
||||
Packed,
|
||||
#[serde(rename_all = "camelCase")]
|
||||
DockerBuild {
|
||||
#[ts(optional)]
|
||||
workdir: Option<PathBuf>,
|
||||
#[ts(optional)]
|
||||
dockerfile: Option<PathBuf>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
@@ -366,8 +368,15 @@ impl ImageSource {
|
||||
pub fn ingredients(&self) -> Vec<PathBuf> {
|
||||
match self {
|
||||
Self::Packed => Vec::new(),
|
||||
Self::DockerBuild { dockerfile, .. } => {
|
||||
vec![dockerfile.clone().unwrap_or_else(|| "Dockerfile".into())]
|
||||
Self::DockerBuild {
|
||||
dockerfile,
|
||||
workdir,
|
||||
..
|
||||
} => {
|
||||
vec![workdir
|
||||
.as_deref()
|
||||
.unwrap_or(Path::new("."))
|
||||
.join(dockerfile.as_deref().unwrap_or(Path::new("Dockerfile")))]
|
||||
}
|
||||
Self::DockerTag(_) => Vec::new(),
|
||||
}
|
||||
|
||||
@@ -122,7 +122,8 @@ impl<'a> std::ops::DerefMut for ExtendedCommand<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Invoke<'a> for tokio::process::Command {
|
||||
type Extended<'ext> = ExtendedCommand<'ext>
|
||||
type Extended<'ext>
|
||||
= ExtendedCommand<'ext>
|
||||
where
|
||||
Self: 'ext,
|
||||
'ext: 'a;
|
||||
@@ -162,7 +163,8 @@ impl<'a> Invoke<'a> for tokio::process::Command {
|
||||
}
|
||||
|
||||
impl<'a> Invoke<'a> for ExtendedCommand<'a> {
|
||||
type Extended<'ext> = &'ext mut ExtendedCommand<'ext>
|
||||
type Extended<'ext>
|
||||
= &'ext mut ExtendedCommand<'ext>
|
||||
where
|
||||
Self: 'ext,
|
||||
'ext: 'a;
|
||||
@@ -663,8 +665,8 @@ impl FromStr for PathOrUrl {
|
||||
type Err = <PathBuf as FromStr>::Err;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if let Ok(url) = s.parse::<Url>() {
|
||||
if url.scheme() == "file" {
|
||||
Ok(Self::Path(url.path().parse()?))
|
||||
if let Some(path) = s.strip_prefix("file://") {
|
||||
Ok(Self::Path(path.parse()?))
|
||||
} else {
|
||||
Ok(Self::Url(url))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { ValueSpec } from "../inputSpecTypes"
|
||||
import { PartialValue, Value } from "./value"
|
||||
import { Value } from "./value"
|
||||
import { _ } from "../../../util"
|
||||
import { Effects } from "../../../Effects"
|
||||
import { Parser, object } from "ts-matches"
|
||||
import { DeepPartial } from "../../../types"
|
||||
|
||||
export type LazyBuildOptions<Store> = {
|
||||
effects: Effects
|
||||
@@ -22,8 +23,8 @@ export type ExtractPartialInputSpecType<
|
||||
| InputSpec<Record<string, any>, any>
|
||||
| InputSpec<Record<string, any>, never>,
|
||||
> = A extends InputSpec<infer B, any> | InputSpec<infer B, never>
|
||||
? PartialValue<B>
|
||||
: PartialValue<A>
|
||||
? DeepPartial<B>
|
||||
: DeepPartial<A>
|
||||
|
||||
export type InputSpecOf<A extends Record<string, any>, Store = never> = {
|
||||
[K in keyof A]: Value<A[K], Store>
|
||||
@@ -94,7 +95,7 @@ export class InputSpec<Type extends Record<string, any>, Store = never> {
|
||||
public validator: Parser<unknown, Type>,
|
||||
) {}
|
||||
_TYPE: Type = null as any as Type
|
||||
_PARTIAL: PartialValue<Type> = null as any as PartialValue<Type>
|
||||
_PARTIAL: DeepPartial<Type> = null as any as DeepPartial<Type>
|
||||
async build(options: LazyBuildOptions<Store>) {
|
||||
const answer = {} as {
|
||||
[K in keyof Type]: ValueSpec
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { InputSpec, LazyBuild } from "./inputSpec"
|
||||
import { List } from "./list"
|
||||
import { PartialUnionRes, UnionRes, Variants } from "./variants"
|
||||
import { Variants } from "./variants"
|
||||
import {
|
||||
FilePath,
|
||||
Pattern,
|
||||
@@ -30,7 +30,7 @@ import { DeepPartial } from "../../../types"
|
||||
|
||||
type AsRequired<T, Required extends boolean> = Required extends true
|
||||
? T
|
||||
: T | null | undefined
|
||||
: T | null
|
||||
|
||||
const testForAsRequiredParser = once(
|
||||
() => object({ required: literal(true) }).test,
|
||||
@@ -38,21 +38,12 @@ const testForAsRequiredParser = once(
|
||||
function asRequiredParser<
|
||||
Type,
|
||||
Input,
|
||||
Return extends
|
||||
| Parser<unknown, Type>
|
||||
| Parser<unknown, Type | null | undefined>,
|
||||
Return extends Parser<unknown, Type> | Parser<unknown, Type | null>,
|
||||
>(parser: Parser<unknown, Type>, input: Input): Return {
|
||||
if (testForAsRequiredParser()(input)) return parser as any
|
||||
return parser.optional() as any
|
||||
return parser.nullable() as any
|
||||
}
|
||||
|
||||
export type PartialValue<T> =
|
||||
T extends UnionRes<infer A, infer B>
|
||||
? PartialUnionRes<A, B>
|
||||
: T extends {}
|
||||
? { [P in keyof T]?: PartialValue<T[P]> }
|
||||
: T
|
||||
|
||||
export class Value<Type, Store> {
|
||||
protected constructor(
|
||||
public build: LazyBuild<Store, ValueSpec>,
|
||||
@@ -196,7 +187,7 @@ export class Value<Type, Store> {
|
||||
}
|
||||
>,
|
||||
) {
|
||||
return new Value<string | null | undefined, Store>(async (options) => {
|
||||
return new Value<string | null, Store>(async (options) => {
|
||||
const a = await getA(options)
|
||||
return {
|
||||
type: "text" as const,
|
||||
@@ -213,7 +204,7 @@ export class Value<Type, Store> {
|
||||
generate: a.generate ?? null,
|
||||
...a,
|
||||
}
|
||||
}, string.optional())
|
||||
}, string.nullable())
|
||||
}
|
||||
static textarea<Required extends boolean>(a: {
|
||||
name: string
|
||||
@@ -265,7 +256,7 @@ export class Value<Type, Store> {
|
||||
}
|
||||
>,
|
||||
) {
|
||||
return new Value<string | null | undefined, Store>(async (options) => {
|
||||
return new Value<string | null, Store>(async (options) => {
|
||||
const a = await getA(options)
|
||||
return {
|
||||
description: null,
|
||||
@@ -278,7 +269,7 @@ export class Value<Type, Store> {
|
||||
immutable: false,
|
||||
...a,
|
||||
}
|
||||
}, string.optional())
|
||||
}, string.nullable())
|
||||
}
|
||||
static number<Required extends boolean>(a: {
|
||||
name: string
|
||||
@@ -351,7 +342,7 @@ export class Value<Type, Store> {
|
||||
}
|
||||
>,
|
||||
) {
|
||||
return new Value<number | null | undefined, Store>(async (options) => {
|
||||
return new Value<number | null, Store>(async (options) => {
|
||||
const a = await getA(options)
|
||||
return {
|
||||
type: "number" as const,
|
||||
@@ -366,7 +357,7 @@ export class Value<Type, Store> {
|
||||
immutable: false,
|
||||
...a,
|
||||
}
|
||||
}, number.optional())
|
||||
}, number.nullable())
|
||||
}
|
||||
static color<Required extends boolean>(a: {
|
||||
name: string
|
||||
@@ -413,7 +404,7 @@ export class Value<Type, Store> {
|
||||
}
|
||||
>,
|
||||
) {
|
||||
return new Value<string | null | undefined, Store>(async (options) => {
|
||||
return new Value<string | null, Store>(async (options) => {
|
||||
const a = await getA(options)
|
||||
return {
|
||||
type: "color" as const,
|
||||
@@ -423,7 +414,7 @@ export class Value<Type, Store> {
|
||||
immutable: false,
|
||||
...a,
|
||||
}
|
||||
}, string.optional())
|
||||
}, string.nullable())
|
||||
}
|
||||
static datetime<Required extends boolean>(a: {
|
||||
name: string
|
||||
@@ -483,7 +474,7 @@ export class Value<Type, Store> {
|
||||
}
|
||||
>,
|
||||
) {
|
||||
return new Value<string | null | undefined, Store>(async (options) => {
|
||||
return new Value<string | null, Store>(async (options) => {
|
||||
const a = await getA(options)
|
||||
return {
|
||||
type: "datetime" as const,
|
||||
@@ -496,7 +487,7 @@ export class Value<Type, Store> {
|
||||
immutable: false,
|
||||
...a,
|
||||
}
|
||||
}, string.optional())
|
||||
}, string.nullable())
|
||||
}
|
||||
static select<Values extends Record<string, string>>(a: {
|
||||
name: string
|
||||
@@ -690,14 +681,14 @@ export class Value<Type, Store> {
|
||||
// }
|
||||
// >,
|
||||
// ) {
|
||||
// return new Value<FilePath | null | undefined, Store>(
|
||||
// return new Value<FilePath | null, Store>(
|
||||
// async (options) => ({
|
||||
// type: "file" as const,
|
||||
// description: null,
|
||||
// warning: null,
|
||||
// ...(await a(options)),
|
||||
// }),
|
||||
// object({ filePath: string }).optional(),
|
||||
// object({ filePath: string }).nullable(),
|
||||
// )
|
||||
// }
|
||||
static union<
|
||||
@@ -822,6 +813,10 @@ export class Value<Type, Store> {
|
||||
}, parser)
|
||||
}
|
||||
|
||||
map<U>(fn: (value: Type) => U): Value<U, Store> {
|
||||
return new Value(this.build, this.validator.map(fn))
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this during the times that the input needs a more specific type.
|
||||
* Used in types that the value/ variant/ list/ inputSpec is constructed somewhere else.
|
||||
|
||||
@@ -29,27 +29,6 @@ export type UnionRes<
|
||||
}
|
||||
}[K]
|
||||
|
||||
export type PartialUnionRes<
|
||||
Store,
|
||||
VariantValues extends {
|
||||
[K in string]: {
|
||||
name: string
|
||||
spec: InputSpec<any, Store> | InputSpec<any, never>
|
||||
}
|
||||
},
|
||||
K extends keyof VariantValues & string = keyof VariantValues & string,
|
||||
> = {
|
||||
[key in keyof VariantValues]: {
|
||||
selection?: key
|
||||
value?: ExtractPartialInputSpecType<VariantValues[key]["spec"]>
|
||||
other?: {
|
||||
[key2 in Exclude<keyof VariantValues & string, key>]?: DeepPartial<
|
||||
ExtractInputSpecType<VariantValues[key2]["spec"]>
|
||||
>
|
||||
}
|
||||
}
|
||||
}[K]
|
||||
|
||||
/**
|
||||
* Used in the the Value.select { @link './value.ts' }
|
||||
* to indicate the type of select variants that are available. The key for the record passed in will be the
|
||||
|
||||
@@ -1,12 +1,42 @@
|
||||
import * as T from "../types"
|
||||
import { once } from "../util"
|
||||
|
||||
type DependencyType<Manifest extends T.SDKManifest> = {
|
||||
[K in keyof Manifest["dependencies"]]: Omit<T.DependencyRequirement, "id">
|
||||
}
|
||||
export type RequiredDependenciesOf<Manifest extends T.SDKManifest> = {
|
||||
[K in keyof Manifest["dependencies"]]: Manifest["dependencies"][K]["optional"] extends false
|
||||
? K
|
||||
: never
|
||||
}[keyof Manifest["dependencies"]]
|
||||
export type OptionalDependenciesOf<Manifest extends T.SDKManifest> = Exclude<
|
||||
keyof Manifest["dependencies"],
|
||||
RequiredDependenciesOf<Manifest>
|
||||
>
|
||||
|
||||
type DependencyRequirement =
|
||||
| {
|
||||
kind: "running"
|
||||
healthChecks: Array<T.HealthCheckId>
|
||||
versionRange: string
|
||||
}
|
||||
| {
|
||||
kind: "exists"
|
||||
versionRange: string
|
||||
}
|
||||
type Matches<T, U> = T extends U ? (U extends T ? null : never) : never
|
||||
const _checkType: Matches<
|
||||
DependencyRequirement & { id: T.PackageId },
|
||||
T.DependencyRequirement
|
||||
> = null
|
||||
|
||||
export type CurrentDependenciesResult<Manifest extends T.SDKManifest> = {
|
||||
[K in RequiredDependenciesOf<Manifest>]: DependencyRequirement
|
||||
} & {
|
||||
[K in OptionalDependenciesOf<Manifest>]?: DependencyRequirement
|
||||
} & Record<string, DependencyRequirement>
|
||||
|
||||
export function setupDependencies<Manifest extends T.SDKManifest>(
|
||||
fn: (options: { effects: T.Effects }) => Promise<DependencyType<Manifest>>,
|
||||
fn: (options: {
|
||||
effects: T.Effects
|
||||
}) => Promise<CurrentDependenciesResult<Manifest>>,
|
||||
): (options: { effects: T.Effects }) => Promise<null> {
|
||||
const cell = { updater: async (_: { effects: T.Effects }) => null }
|
||||
cell.updater = async (options: { effects: T.Effects }) => {
|
||||
@@ -21,7 +51,7 @@ export function setupDependencies<Manifest extends T.SDKManifest>(
|
||||
dependencies: Object.entries(dependencyType).map(
|
||||
([id, { versionRange, ...x }, ,]) =>
|
||||
({
|
||||
id,
|
||||
// id,
|
||||
...x,
|
||||
versionRange: versionRange.toString(),
|
||||
}) as T.DependencyRequirement,
|
||||
|
||||
@@ -5,8 +5,8 @@ export type ImageSource =
|
||||
| "packed"
|
||||
| {
|
||||
dockerBuild: {
|
||||
workdir: string | null
|
||||
dockerfile: string | null
|
||||
workdir?: string
|
||||
dockerfile?: string
|
||||
buildArgs?: { [key: string]: BuildArg }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ import { Effects } from "./Effects"
|
||||
export { Effects }
|
||||
export * from "./osBindings"
|
||||
export { SDKManifest } from "./types/ManifestTypes"
|
||||
export {
|
||||
RequiredDependenciesOf as RequiredDependencies,
|
||||
OptionalDependenciesOf as OptionalDependencies,
|
||||
CurrentDependenciesResult,
|
||||
} from "./dependencies/setupDependencies"
|
||||
|
||||
export type ExposedStorePaths = string[] & Affine<"ExposedStorePaths">
|
||||
declare const HealthProof: unique symbol
|
||||
@@ -224,6 +229,8 @@ export type KnownError =
|
||||
|
||||
export type Dependencies = Array<DependencyRequirement>
|
||||
|
||||
export type DeepPartial<T> = T extends {}
|
||||
? { [P in keyof T]?: DeepPartial<T[P]> }
|
||||
: T
|
||||
export type DeepPartial<T> = T extends unknown[]
|
||||
? T
|
||||
: T extends {}
|
||||
? { [P in keyof T]?: DeepPartial<T[P]> }
|
||||
: T
|
||||
|
||||
@@ -150,10 +150,19 @@ export type SDKManifest = {
|
||||
}
|
||||
}
|
||||
|
||||
export type SDKImageInputSpec = {
|
||||
source: Exclude<ImageSource, "packed">
|
||||
arch?: string[]
|
||||
emulateMissingAs?: string | null
|
||||
// this is hacky but idk a more elegant way
|
||||
type ArchOptions = {
|
||||
0: ["x86_64", "aarch64"]
|
||||
1: ["aarch64", "x86_64"]
|
||||
2: ["x86_64"]
|
||||
3: ["aarch64"]
|
||||
}
|
||||
export type SDKImageInputSpec = {
|
||||
[A in keyof ArchOptions]: {
|
||||
source: Exclude<ImageSource, "packed">
|
||||
arch?: ArchOptions[A]
|
||||
emulateMissingAs?: ArchOptions[A][number] | null
|
||||
}
|
||||
}[keyof ArchOptions]
|
||||
|
||||
export type ManifestDependency = T.Manifest["dependencies"][string]
|
||||
|
||||
8
sdk/base/package-lock.json
generated
8
sdk/base/package-lock.json
generated
@@ -14,7 +14,7 @@
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"ts-matches": "^6.0.0",
|
||||
"ts-matches": "^6.1.0",
|
||||
"yaml": "^2.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -3897,9 +3897,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ts-matches": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.0.0.tgz",
|
||||
"integrity": "sha512-vR4hhz9bYMW30qIJUuLaeAWlsR54vse6ZI2riVhVLMBE6/vss43jwrOvbHheiyU7e26ssT/yWx69aJHD2REJSA==",
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.1.0.tgz",
|
||||
"integrity": "sha512-01qvbIpOiKdbzzXDH84JeHunvCwBGFdZw94jS6kOGLSN5ms+1nBZtfe8WSuYMIPb1xPA+qyAiVgznFi2VCQ6UQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ts-morph": {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"ts-matches": "^6.0.0",
|
||||
"ts-matches": "^6.1.0",
|
||||
"yaml": "^2.2.2"
|
||||
},
|
||||
"prettier": {
|
||||
|
||||
@@ -135,6 +135,7 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
|
||||
}
|
||||
|
||||
return {
|
||||
manifest: this.manifest,
|
||||
...startSdkEffectWrapper,
|
||||
action: {
|
||||
run: actions.runAction,
|
||||
|
||||
@@ -59,7 +59,9 @@ export function buildManifest<
|
||||
(images, [k, v]) => {
|
||||
v.arch = v.arch || ["aarch64", "x86_64"]
|
||||
if (v.emulateMissingAs === undefined)
|
||||
v.emulateMissingAs = v.arch[0] || null
|
||||
v.emulateMissingAs = (v.arch as string[]).includes("aarch64")
|
||||
? "aarch64"
|
||||
: v.arch[0] || null
|
||||
images[k] = v as ImageConfig
|
||||
return images
|
||||
},
|
||||
|
||||
@@ -87,7 +87,7 @@ describe("values", () => {
|
||||
const rawIs = await value.build({} as any)
|
||||
validator.unsafeCast("test text")
|
||||
validator.unsafeCast(null)
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
})
|
||||
test("color", async () => {
|
||||
const value = Value.color({
|
||||
@@ -99,7 +99,7 @@ describe("values", () => {
|
||||
})
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("#000000")
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
})
|
||||
test("datetime", async () => {
|
||||
const value = Value.datetime({
|
||||
@@ -129,7 +129,7 @@ describe("values", () => {
|
||||
})
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("2021-01-01")
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
})
|
||||
test("textarea", async () => {
|
||||
const value = Value.textarea({
|
||||
@@ -144,7 +144,7 @@ describe("values", () => {
|
||||
})
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("test text")
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
})
|
||||
test("number", async () => {
|
||||
const value = Value.number({
|
||||
@@ -180,7 +180,7 @@ describe("values", () => {
|
||||
})
|
||||
const validator = value.validator
|
||||
validator.unsafeCast(2)
|
||||
testOutput<typeof validator._TYPE, number | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, number | null>()(null)
|
||||
})
|
||||
test("select", async () => {
|
||||
const value = Value.select({
|
||||
@@ -319,33 +319,33 @@ describe("values", () => {
|
||||
test("text", async () => {
|
||||
const value = Value.dynamicText(async () => ({
|
||||
name: "Testing",
|
||||
required: true,
|
||||
required: false,
|
||||
default: null,
|
||||
}))
|
||||
const validator = value.validator
|
||||
const rawIs = await value.build({} as any)
|
||||
validator.unsafeCast("test text")
|
||||
validator.unsafeCast(null)
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: true,
|
||||
required: false,
|
||||
default: null,
|
||||
})
|
||||
})
|
||||
test("text with default", async () => {
|
||||
const value = Value.dynamicText(async () => ({
|
||||
name: "Testing",
|
||||
required: true,
|
||||
required: false,
|
||||
default: "this is a default value",
|
||||
}))
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("test text")
|
||||
validator.unsafeCast(null)
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: true,
|
||||
required: false,
|
||||
default: "this is a default value",
|
||||
})
|
||||
})
|
||||
@@ -359,7 +359,7 @@ describe("values", () => {
|
||||
const rawIs = await value.build({} as any)
|
||||
validator.unsafeCast("test text")
|
||||
validator.unsafeCast(null)
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: false,
|
||||
@@ -377,7 +377,7 @@ describe("values", () => {
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("#000000")
|
||||
validator.unsafeCast(null)
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: false,
|
||||
@@ -445,7 +445,7 @@ describe("values", () => {
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("2021-01-01")
|
||||
validator.unsafeCast(null)
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: true,
|
||||
@@ -468,7 +468,7 @@ describe("values", () => {
|
||||
}))
|
||||
const validator = value.validator
|
||||
validator.unsafeCast("test text")
|
||||
testOutput<typeof validator._TYPE, string | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, string | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: false,
|
||||
@@ -492,7 +492,7 @@ describe("values", () => {
|
||||
validator.unsafeCast(2)
|
||||
validator.unsafeCast(null)
|
||||
expect(() => validator.unsafeCast("null")).toThrowError()
|
||||
testOutput<typeof validator._TYPE, number | null | undefined>()(null)
|
||||
testOutput<typeof validator._TYPE, number | null>()(null)
|
||||
expect(await value.build(fakeOptions)).toMatchObject({
|
||||
name: "Testing",
|
||||
required: true,
|
||||
@@ -795,7 +795,7 @@ describe("Nested nullable values", () => {
|
||||
validator.unsafeCast({ a: null })
|
||||
validator.unsafeCast({ a: "test" })
|
||||
expect(() => validator.unsafeCast({ a: 4 })).toThrowError()
|
||||
testOutput<typeof validator._TYPE, { a: string | null | undefined }>()(null)
|
||||
testOutput<typeof validator._TYPE, { a: string | null }>()(null)
|
||||
})
|
||||
test("Testing number", async () => {
|
||||
const value = InputSpec.of({
|
||||
@@ -818,7 +818,7 @@ describe("Nested nullable values", () => {
|
||||
validator.unsafeCast({ a: null })
|
||||
validator.unsafeCast({ a: 5 })
|
||||
expect(() => validator.unsafeCast({ a: "4" })).toThrowError()
|
||||
testOutput<typeof validator._TYPE, { a: number | null | undefined }>()(null)
|
||||
testOutput<typeof validator._TYPE, { a: number | null }>()(null)
|
||||
})
|
||||
test("Testing color", async () => {
|
||||
const value = InputSpec.of({
|
||||
@@ -835,7 +835,7 @@ describe("Nested nullable values", () => {
|
||||
validator.unsafeCast({ a: null })
|
||||
validator.unsafeCast({ a: "5" })
|
||||
expect(() => validator.unsafeCast({ a: 4 })).toThrowError()
|
||||
testOutput<typeof validator._TYPE, { a: string | null | undefined }>()(null)
|
||||
testOutput<typeof validator._TYPE, { a: string | null }>()(null)
|
||||
})
|
||||
test("Testing select", async () => {
|
||||
const value = InputSpec.of({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CurrentDependenciesResult } from "../../../base/lib/dependencies/setupDependencies"
|
||||
import { StartSdk } from "../StartSdk"
|
||||
import { setupManifest } from "../manifest/setupManifest"
|
||||
import { VersionInfo } from "../version/VersionInfo"
|
||||
import { VersionGraph } from "../version/VersionGraph"
|
||||
|
||||
export type Manifest = any
|
||||
@@ -21,7 +21,15 @@ export const sdk = StartSdk.of()
|
||||
long: "",
|
||||
},
|
||||
containers: {},
|
||||
images: {},
|
||||
images: {
|
||||
main: {
|
||||
source: {
|
||||
dockerTag: "start9/hello-world",
|
||||
},
|
||||
arch: ["aarch64", "x86_64"],
|
||||
emulateMissingAs: "aarch64",
|
||||
},
|
||||
},
|
||||
volumes: [],
|
||||
assets: [],
|
||||
alerts: {
|
||||
|
||||
@@ -22,7 +22,7 @@ testOutput<
|
||||
testOutput<InputSpecSpec["rpc"]["advanced"]["servertimeout"], number>()(null)
|
||||
testOutput<
|
||||
InputSpecSpec["advanced"]["peers"]["addnode"][0]["hostname"],
|
||||
string | null | undefined
|
||||
string | null
|
||||
>()(null)
|
||||
testOutput<
|
||||
InputSpecSpec["testListUnion"][0]["union"]["value"]["name"],
|
||||
|
||||
12
sdk/package/package-lock.json
generated
12
sdk/package/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@start9labs/start-sdk",
|
||||
"version": "0.3.6-alpha.16",
|
||||
"version": "0.3.6-alpha.21",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@start9labs/start-sdk",
|
||||
"version": "0.3.6-alpha.16",
|
||||
"version": "0.3.6-alpha.21",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
@@ -15,7 +15,7 @@
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"ts-matches": "^6.0.0",
|
||||
"ts-matches": "^6.1.0",
|
||||
"yaml": "^2.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -3918,9 +3918,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ts-matches": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.0.0.tgz",
|
||||
"integrity": "sha512-vR4hhz9bYMW30qIJUuLaeAWlsR54vse6ZI2riVhVLMBE6/vss43jwrOvbHheiyU7e26ssT/yWx69aJHD2REJSA==",
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.1.0.tgz",
|
||||
"integrity": "sha512-01qvbIpOiKdbzzXDH84JeHunvCwBGFdZw94jS6kOGLSN5ms+1nBZtfe8WSuYMIPb1xPA+qyAiVgznFi2VCQ6UQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ts-morph": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@start9labs/start-sdk",
|
||||
"version": "0.3.6-alpha.17",
|
||||
"version": "0.3.6-alpha.21",
|
||||
"description": "Software development kit to facilitate packaging services for StartOS",
|
||||
"main": "./package/lib/index.js",
|
||||
"types": "./package/lib/index.d.ts",
|
||||
@@ -33,7 +33,7 @@
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"ts-matches": "^6.0.0",
|
||||
"ts-matches": "^6.1.0",
|
||||
"yaml": "^2.2.2",
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"@noble/curves": "^1.4.0",
|
||||
|
||||
Reference in New Issue
Block a user