mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
chore: charlie21
This commit is contained in:
@@ -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
50
lib/init/index.ts
Normal 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;
|
||||
}
|
||||
31
lib/types.ts
31
lib/types.ts
@@ -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;
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "start-sdk",
|
||||
"version": "0.4.0-lib0.charlie20",
|
||||
"version": "0.4.0-lib0.charlie21",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "start-sdk",
|
||||
"version": "0.4.0-lib0.charlie20",
|
||||
"version": "0.4.0-lib0.charlie21",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "start-sdk",
|
||||
"version": "0.4.0-lib0.charlie20",
|
||||
"version": "0.4.0-lib0.charlie21",
|
||||
"description": "For making the patterns that are wanted in making services for the startOS.",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user