mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
chore: Fix testing
This commit is contained in:
256
types.ts
256
types.ts
@@ -1,36 +1,21 @@
|
|||||||
// deno-lint-ignore no-namespace
|
// deno-lint-ignore no-namespace
|
||||||
export namespace ExpectedExports {
|
export namespace ExpectedExports {
|
||||||
/** Set configuration is called after we have modified and saved the configuration in the embassy ui. Use this to make a file for the docker to read from for configuration. */
|
/** Set configuration is called after we have modified and saved the configuration in the embassy ui. Use this to make a file for the docker to read from for configuration. */
|
||||||
export type setConfig = (
|
export type setConfig = (effects: Effects, input: Config) => Promise<ResultType<SetResult>>;
|
||||||
effects: Effects,
|
|
||||||
input: Config,
|
|
||||||
) => Promise<ResultType<SetResult>>;
|
|
||||||
/** Get configuration returns a shape that describes the format that the embassy ui will generate, and later send to the set config */
|
/** Get configuration returns a shape that describes the format that the embassy ui will generate, and later send to the set config */
|
||||||
export type getConfig = (effects: Effects) => Promise<ResultType<ConfigRes>>;
|
export type getConfig = (effects: Effects) => Promise<ResultType<ConfigRes>>;
|
||||||
/** These are how we make sure the our dependency configurations are valid and if not how to fix them. */
|
/** These are how we make sure the our dependency configurations are valid and if not how to fix them. */
|
||||||
export type dependencies = Dependencies;
|
export type dependencies = Dependencies;
|
||||||
/** Properties are used to get values from the docker, like a username + password, what ports we are hosting from */
|
/** Properties are used to get values from the docker, like a username + password, what ports we are hosting from */
|
||||||
export type properties = (
|
export type properties = (effects: Effects) => Promise<ResultType<Properties>>;
|
||||||
effects: Effects,
|
|
||||||
) => Promise<ResultType<Properties>>;
|
|
||||||
|
|
||||||
export type health = {
|
export type health = {
|
||||||
/** Should be the health check id */
|
/** Should be the health check id */
|
||||||
[id: string]: (
|
[id: string]: (effects: Effects, dateMs: number) => Promise<ResultType<unknown>>;
|
||||||
effects: Effects,
|
|
||||||
dateMs: number,
|
|
||||||
) => Promise<ResultType<unknown>>;
|
|
||||||
};
|
};
|
||||||
export type migration = (
|
export type migration = (effects: Effects, version: string, ...args: unknown[]) => Promise<ResultType<MigrationRes>>;
|
||||||
effects: Effects,
|
|
||||||
version: string,
|
|
||||||
...args: unknown[]
|
|
||||||
) => Promise<ResultType<MigrationRes>>;
|
|
||||||
export type action = {
|
export type action = {
|
||||||
[id: string]: (
|
[id: string]: (effects: Effects, config?: Config) => Promise<ResultType<ActionResult>>;
|
||||||
effects: Effects,
|
|
||||||
config?: Config,
|
|
||||||
) => Promise<ResultType<ActionResult>>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,9 +28,7 @@ export namespace ExpectedExports {
|
|||||||
/** Used to reach out from the pure js runtime */
|
/** Used to reach out from the pure js runtime */
|
||||||
export type Effects = {
|
export type Effects = {
|
||||||
/** Usable when not sandboxed */
|
/** Usable when not sandboxed */
|
||||||
writeFile(
|
writeFile(input: { path: string; volumeId: string; toWrite: string }): Promise<void>;
|
||||||
input: { path: string; volumeId: string; toWrite: string },
|
|
||||||
): Promise<void>;
|
|
||||||
readFile(input: { volumeId: string; path: string }): Promise<string>;
|
readFile(input: { volumeId: string; path: string }): Promise<string>;
|
||||||
metadata(input: { volumeId: string; path: string }): Promise<Metadata>;
|
metadata(input: { volumeId: string; path: string }): Promise<Metadata>;
|
||||||
/** Create a directory. Usable when not sandboxed */
|
/** Create a directory. Usable when not sandboxed */
|
||||||
@@ -55,35 +38,18 @@ export type Effects = {
|
|||||||
removeFile(input: { volumeId: string; path: string }): Promise<void>;
|
removeFile(input: { volumeId: string; path: string }): Promise<void>;
|
||||||
|
|
||||||
/** Write a json file into an object. Usable when not sandboxed */
|
/** Write a json file into an object. Usable when not sandboxed */
|
||||||
writeJsonFile(
|
writeJsonFile(input: { volumeId: string; path: string; toWrite: Record<string, unknown> }): Promise<void>;
|
||||||
input: { volumeId: string; path: string; toWrite: Record<string, unknown> },
|
|
||||||
): Promise<void>;
|
|
||||||
|
|
||||||
/** Read a json file into an object */
|
/** Read a json file into an object */
|
||||||
readJsonFile(
|
readJsonFile(input: { volumeId: string; path: string }): Promise<Record<string, unknown>>;
|
||||||
input: { volumeId: string; path: string },
|
|
||||||
): Promise<Record<string, unknown>>;
|
|
||||||
|
|
||||||
runCommand(
|
runCommand(input: { command: string; args?: string[]; timeoutMillis?: number }): Promise<ResultType<string>>;
|
||||||
input: {
|
runDaemon(input: { command: string; args?: string[] }): {
|
||||||
command: string;
|
|
||||||
args?: string[];
|
|
||||||
timeoutMillis?: number;
|
|
||||||
},
|
|
||||||
): Promise<ResultType<string>>;
|
|
||||||
runDaemon(
|
|
||||||
input: {
|
|
||||||
command: string;
|
|
||||||
args?: string[];
|
|
||||||
},
|
|
||||||
): {
|
|
||||||
wait(): Promise<ResultType<string>>;
|
wait(): Promise<ResultType<string>>;
|
||||||
term(): Promise<void>;
|
term(): Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
sleep(
|
sleep(timeMs: number): Promise<null>;
|
||||||
timeMs: number,
|
|
||||||
): Promise<null>;
|
|
||||||
|
|
||||||
/** Log at the trace level */
|
/** Log at the trace level */
|
||||||
trace(whatToPrint: string): void;
|
trace(whatToPrint: string): void;
|
||||||
@@ -101,17 +67,14 @@ export type Effects = {
|
|||||||
|
|
||||||
exists(input: { volumeId: string; path: string }): Promise<boolean>;
|
exists(input: { volumeId: string; path: string }): Promise<boolean>;
|
||||||
|
|
||||||
fetch(url: string, options?: {
|
fetch(
|
||||||
method?:
|
url: string,
|
||||||
| "GET"
|
options?: {
|
||||||
| "POST"
|
method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "PATCH";
|
||||||
| "PUT"
|
headers?: Record<string, string>;
|
||||||
| "DELETE"
|
body?: string;
|
||||||
| "HEAD"
|
}
|
||||||
| "PATCH";
|
): Promise<{
|
||||||
headers?: Record<string, string>;
|
|
||||||
body?: string;
|
|
||||||
}): Promise<{
|
|
||||||
method: string;
|
method: string;
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
status: number;
|
status: number;
|
||||||
@@ -196,8 +159,8 @@ export type Target<T extends string, V> = V & {
|
|||||||
|
|
||||||
export type UniqueBy =
|
export type UniqueBy =
|
||||||
| {
|
| {
|
||||||
any: UniqueBy[];
|
any: UniqueBy[];
|
||||||
}
|
}
|
||||||
| string
|
| string
|
||||||
| null;
|
| null;
|
||||||
|
|
||||||
@@ -207,22 +170,20 @@ export type WithNullable<T> = T & {
|
|||||||
export type DefaultString =
|
export type DefaultString =
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
/** The chars available for the randome generation */
|
/** The chars available for the randome generation */
|
||||||
charset?: string;
|
charset?: string;
|
||||||
/** Length that we generate to */
|
/** Length that we generate to */
|
||||||
len: number;
|
len: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ValueSpecString =
|
export type ValueSpecString = // deno-lint-ignore ban-types
|
||||||
& (
|
(
|
||||||
// deno-lint-ignore ban-types
|
|
||||||
| {}
|
| {}
|
||||||
| {
|
| {
|
||||||
pattern: string;
|
pattern: string;
|
||||||
"pattern-description": string;
|
"pattern-description": string;
|
||||||
}
|
}
|
||||||
)
|
) & {
|
||||||
& {
|
|
||||||
copyable?: boolean;
|
copyable?: boolean;
|
||||||
masked?: boolean;
|
masked?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
@@ -238,71 +199,63 @@ export type ValueSpecNumber = {
|
|||||||
export type ValueSpecBoolean = Record<string, unknown>;
|
export type ValueSpecBoolean = Record<string, unknown>;
|
||||||
export type ValueSpecAny =
|
export type ValueSpecAny =
|
||||||
| Tag<"boolean", WithDescription<WithDefault<ValueSpecBoolean, boolean>>>
|
| Tag<"boolean", WithDescription<WithDefault<ValueSpecBoolean, boolean>>>
|
||||||
|
| Tag<"string", WithDescription<WithNullableDefault<WithNullable<ValueSpecString>, DefaultString>>>
|
||||||
|
| Tag<"number", WithDescription<WithNullableDefault<WithNullable<ValueSpecNumber>, number>>>
|
||||||
| Tag<
|
| Tag<
|
||||||
"string",
|
"enum",
|
||||||
WithDescription<
|
WithDescription<
|
||||||
WithNullableDefault<WithNullable<ValueSpecString>, DefaultString>
|
WithDefault<
|
||||||
>
|
{
|
||||||
>
|
values: readonly string[] | string[];
|
||||||
| Tag<
|
"value-names": {
|
||||||
"number",
|
[key: string]: string;
|
||||||
WithDescription<WithNullableDefault<WithNullable<ValueSpecNumber>, number>>
|
};
|
||||||
>
|
},
|
||||||
| Tag<
|
string
|
||||||
"enum",
|
>
|
||||||
WithDescription<
|
|
||||||
WithDefault<
|
|
||||||
{
|
|
||||||
values: string[];
|
|
||||||
"value-names": {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
string
|
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
>
|
|
||||||
| Tag<"list", ValueSpecList>
|
| Tag<"list", ValueSpecList>
|
||||||
| Tag<"object", WithDescription<WithNullableDefault<ValueSpecObject, Config>>>
|
| Tag<"object", WithDescription<WithNullableDefault<ValueSpecObject, Config>>>
|
||||||
| Tag<"union", WithDescription<WithDefault<ValueSpecUnion, string>>>
|
| Tag<"union", WithDescription<WithDefault<ValueSpecUnion, string>>>
|
||||||
| Tag<
|
| Tag<
|
||||||
"pointer",
|
"pointer",
|
||||||
WithDescription<
|
WithDescription<
|
||||||
| Subtype<
|
| Subtype<
|
||||||
"package",
|
"package",
|
||||||
| Target<
|
| Target<
|
||||||
"tor-key",
|
"tor-key",
|
||||||
{
|
{
|
||||||
"package-id": string;
|
"package-id": string;
|
||||||
interface: string;
|
interface: string;
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
| Target<
|
| Target<
|
||||||
"tor-address",
|
"tor-address",
|
||||||
{
|
{
|
||||||
"package-id": string;
|
"package-id": string;
|
||||||
interface: string;
|
interface: string;
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
| Target<
|
| Target<
|
||||||
"lan-address",
|
"lan-address",
|
||||||
{
|
{
|
||||||
"package-id": string;
|
"package-id": string;
|
||||||
interface: string;
|
interface: string;
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
| Target<
|
| Target<
|
||||||
"config",
|
"config",
|
||||||
{
|
{
|
||||||
"package-id": string;
|
"package-id": string;
|
||||||
selector: string;
|
selector: string;
|
||||||
multi: boolean;
|
multi: boolean;
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
>
|
||||||
|
| Subtype<"system", Record<string, unknown>>
|
||||||
>
|
>
|
||||||
| Subtype<"system", Record<string, unknown>>
|
>;
|
||||||
>
|
|
||||||
>;
|
|
||||||
export type ValueSpecUnion = {
|
export type ValueSpecUnion = {
|
||||||
/** What tag for the specification, for tag unions */
|
/** What tag for the specification, for tag unions */
|
||||||
tag: {
|
tag: {
|
||||||
@@ -326,39 +279,12 @@ export type ValueSpecObject = {
|
|||||||
"unique-by"?: UniqueBy;
|
"unique-by"?: UniqueBy;
|
||||||
};
|
};
|
||||||
export type ValueSpecList =
|
export type ValueSpecList =
|
||||||
| Subtype<
|
| Subtype<"boolean", WithDescription<WithDefault<ListSpec<ValueSpecBoolean>, boolean[]>>>
|
||||||
"boolean",
|
| Subtype<"string", WithDescription<WithDefault<ListSpec<ValueSpecString>, string[]>>>
|
||||||
WithDescription<WithDefault<ListSpec<ValueSpecBoolean>, boolean[]>>
|
| Subtype<"number", WithDescription<WithDefault<ListSpec<ValueSpecNumber>, number[]>>>
|
||||||
>
|
| Subtype<"enum", WithDescription<WithDefault<ListSpec<ValueSpecEnum>, string[]>>>
|
||||||
| Subtype<
|
| Subtype<"object", WithDescription<WithNullableDefault<ListSpec<ValueSpecObject>, Record<string, unknown>[]>>>
|
||||||
"string",
|
| Subtype<"union", WithDescription<WithDefault<ListSpec<ValueSpecUnion>, string[]>>>;
|
||||||
WithDescription<WithDefault<ListSpec<ValueSpecString>, string[]>>
|
|
||||||
>
|
|
||||||
| Subtype<
|
|
||||||
"number",
|
|
||||||
WithDescription<WithDefault<ListSpec<ValueSpecNumber>, number[]>>
|
|
||||||
>
|
|
||||||
| Subtype<
|
|
||||||
"enum",
|
|
||||||
WithDescription<
|
|
||||||
WithDefault<
|
|
||||||
ListSpec<
|
|
||||||
ValueSpecEnum
|
|
||||||
>,
|
|
||||||
string[]
|
|
||||||
>
|
|
||||||
>
|
|
||||||
>
|
|
||||||
| Subtype<
|
|
||||||
"object",
|
|
||||||
WithDescription<
|
|
||||||
WithDefault<ListSpec<ValueSpecObject>, Record<string, unknown>[]>
|
|
||||||
>
|
|
||||||
>
|
|
||||||
| Subtype<
|
|
||||||
"union",
|
|
||||||
WithDescription<WithDefault<ListSpec<ValueSpecUnion>, string[]>>
|
|
||||||
>;
|
|
||||||
export type ValueSpecEnum = {
|
export type ValueSpecEnum = {
|
||||||
values: string[];
|
values: string[];
|
||||||
"value-names": { [key: string]: string };
|
"value-names": { [key: string]: string };
|
||||||
@@ -407,9 +333,11 @@ export type DependsOn = {
|
|||||||
[packageId: string]: string[];
|
[packageId: string]: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type KnownError = { error: string } | {
|
export type KnownError =
|
||||||
"error-code": [number, string] | readonly [number, string];
|
| { error: string }
|
||||||
};
|
| {
|
||||||
|
"error-code": [number, string] | readonly [number, string];
|
||||||
|
};
|
||||||
export type ResultType<T> = KnownError | { result: T };
|
export type ResultType<T> = KnownError | { result: T };
|
||||||
|
|
||||||
export type PackagePropertiesV2 = {
|
export type PackagePropertiesV2 = {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const bitcoinProperties = {
|
|||||||
"Username and hashed password for JSON-RPC connections. RPC clients connect using the usual http basic authentication.",
|
"Username and hashed password for JSON-RPC connections. RPC clients connect using the usual http basic authentication.",
|
||||||
type: "list",
|
type: "list",
|
||||||
subtype: "string",
|
subtype: "string",
|
||||||
default: [],
|
default: Array<string>(),
|
||||||
spec: {
|
spec: {
|
||||||
pattern: "^[a-zA-Z0-9_-]+:([0-9a-fA-F]{2})+\\$([0-9a-fA-F]{2})+$",
|
pattern: "^[a-zA-Z0-9_-]+:([0-9a-fA-F]{2})+\\$([0-9a-fA-F]{2})+$",
|
||||||
"pattern-description": 'Each item must be of the form "<USERNAME>:<SALT>$<HASH>".',
|
"pattern-description": 'Each item must be of the form "<USERNAME>:<SALT>$<HASH>".',
|
||||||
@@ -241,7 +241,7 @@ const bitcoinProperties = {
|
|||||||
type: "list",
|
type: "list",
|
||||||
subtype: "object",
|
subtype: "object",
|
||||||
range: "[0,*)",
|
range: "[0,*)",
|
||||||
default: [],
|
default: Array<Record<string, unknown>>(),
|
||||||
spec: {
|
spec: {
|
||||||
spec: {
|
spec: {
|
||||||
hostname: {
|
hostname: {
|
||||||
@@ -424,7 +424,7 @@ const testUnionValue = anyValue as PM.GuardAll<{
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
variants: {
|
variants: {
|
||||||
disabled: {};
|
disabled: Record<string, never>;
|
||||||
automatic: {
|
automatic: {
|
||||||
size: {
|
size: {
|
||||||
type: "number";
|
type: "number";
|
||||||
@@ -469,7 +469,9 @@ const _testUnionBadUnion:
|
|||||||
size: number;
|
size: number;
|
||||||
} = testUnionValue;
|
} = testUnionValue;
|
||||||
const _testAll: PM.TypeFromProps<BitcoinProperties> = anyValue as {
|
const _testAll: PM.TypeFromProps<BitcoinProperties> = anyValue as {
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
"peer-tor-address": any;
|
"peer-tor-address": any;
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
"rpc-tor-address": any;
|
"rpc-tor-address": any;
|
||||||
rpc: {
|
rpc: {
|
||||||
enable: boolean;
|
enable: boolean;
|
||||||
@@ -790,5 +792,51 @@ const { test } = Deno;
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
).toThrow();
|
).toThrow();
|
||||||
|
checker.unsafeCast({
|
||||||
|
"peer-tor-address": "",
|
||||||
|
"rpc-tor-address": null,
|
||||||
|
rpc: {
|
||||||
|
enable: true,
|
||||||
|
username: "asdf",
|
||||||
|
password: "asdf",
|
||||||
|
advanced: {
|
||||||
|
auth: ["test:34$aa"],
|
||||||
|
serialversion: "non-segwit",
|
||||||
|
servertimeout: 12,
|
||||||
|
threads: 12,
|
||||||
|
workqueue: 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"zmq-enabled": false,
|
||||||
|
txindex: false,
|
||||||
|
wallet: {
|
||||||
|
enable: true,
|
||||||
|
avoidpartialspends: false,
|
||||||
|
discardfee: 0,
|
||||||
|
},
|
||||||
|
advanced: {
|
||||||
|
mempool: {
|
||||||
|
mempoolfullrbf: false,
|
||||||
|
persistmempool: false,
|
||||||
|
maxmempool: 3012,
|
||||||
|
mempoolexpiry: 321,
|
||||||
|
},
|
||||||
|
peers: {
|
||||||
|
listen: false,
|
||||||
|
onlyconnect: false,
|
||||||
|
onlyonion: false,
|
||||||
|
addnode: [{ hostname: "google.com", port: 231 }],
|
||||||
|
},
|
||||||
|
dbcache: 123,
|
||||||
|
pruning: { mode: "automatic", size: 1234 },
|
||||||
|
blockfilters: {
|
||||||
|
blockfilterindex: false,
|
||||||
|
peerblockfilters: false,
|
||||||
|
},
|
||||||
|
bloomfilters: {
|
||||||
|
peerbloomfilters: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user