chore: charlie21

This commit is contained in:
BluJ
2023-04-14 17:53:08 -06:00
parent 3052bbe85d
commit f936f5ce35
5 changed files with 73 additions and 18 deletions

View File

@@ -31,7 +31,9 @@ export function setupConfigExports<A extends InputSpec, ConfigType>(options: {
return { error: "Set config type error for config" };
}
const output = await options.write({ input, effects });
return output;
if (output) {
await effects.setWrapperData({ path: "config", value: output });
}
}) as ExpectedExports.setConfig,
getConfig: (async ({ effects, config }) => {
return {

50
lib/init/index.ts Normal file
View File

@@ -0,0 +1,50 @@
import { ExpectedExports } from "../types";
declare const ActionProof: unique symbol;
export type ActionReceipt = {
[ActionProof]: never;
};
declare const MigrationProof: unique symbol;
export type MigrationReceipt = {
[MigrationProof]: never;
};
export function noMigration(): MigrationReceipt {
return {} as MigrationReceipt;
}
export function migrationUp(fn: () => Promise<unknown>): MigrationReceipt {
fn();
return {} as MigrationReceipt;
}
declare const MigrationDownProof: unique symbol;
export type MigrationDownReceipt = {
[MigrationDownProof]: never;
};
export function noMigrationDown(): MigrationDownReceipt {
return {} as MigrationDownReceipt;
}
export function migrationDown(
fn: () => Promise<unknown>
): MigrationDownReceipt {
fn();
return {} as MigrationDownReceipt;
}
export function setupInit(
fn: (
...args: Parameters<ExpectedExports.init>
) => Promise<[MigrationReceipt, ActionReceipt]>
) {
const initFn: ExpectedExports.init = (...args) => fn(...args);
return initFn;
}
export function setupUninit(
fn: (
...args: Parameters<ExpectedExports.uninit>
) => Promise<[MigrationDownReceipt]>
) {
const uninitFn: ExpectedExports.uninit = (...args) => fn(...args);
return uninitFn;
}

View File

@@ -1,5 +1,6 @@
export * as configTypes from "./config/configTypes";
import { InputSpec } from "./config/configTypes";
import { ActionReceipt } from "./init";
export namespace ExpectedExports {
version: 1;
@@ -13,8 +14,8 @@ export namespace ExpectedExports {
effects: Effects;
config: unknown;
}) => Promise<ConfigRes>;
/** These are how we make sure the our dependency configurations are valid and if not how to fix them. */
export type dependencies = Dependencies;
// /** These are how we make sure the our dependency configurations are valid and if not how to fix them. */
// export type dependencies = Dependencies;
/** For backing up service data though the embassyOS UI */
export type createBackup = (options: {
effects: Effects;
@@ -28,16 +29,13 @@ export namespace ExpectedExports {
effects: Effects;
}) => Promise<Properties | null | undefined | void>;
/** Health checks are used to determine if the service is working properly after starting
* A good use case is if we are using a web server, seeing if we can get to the web server.
*/
export type health = {
/** Should be the health check id */
[id: string]: (options: {
effects: Effects;
input: TimeMs;
}) => Promise<unknown>;
};
// /** Health checks are used to determine if the service is working properly after starting
// * A good use case is if we are using a web server, seeing if we can get to the web server.
// */
// export type health = {
// /** Should be the health check id */
// [id: string]: (options: { effects: Effects; input: TimeMs }) => Promise<unknown>;
// };
/**
* Actions are used so we can effect the service, like deleting a directory.
@@ -308,12 +306,12 @@ export type Effects = {
description: string;
id: string;
input: null | InputSpec;
runningOnly: boolean;
/**
* So the ordering of the actions is by alphabetical order of the group, then followed by the alphabetical of the actions
*/
group?: string;
}): Promise<void>;
}): Promise<void & ActionReceipt>;
/**
* Remove an action that was exported. Used problably during main or during setConfig.
*/
@@ -448,6 +446,11 @@ export type PackagePropertyString = {
qr?: boolean;
/** Hiding the value unless toggled off for field */
masked?: boolean;
watch?: {
packageId?: string;
path: string;
};
};
export type PackagePropertyObject = {
value: PackagePropertiesV2;