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" };
|
return { error: "Set config type error for config" };
|
||||||
}
|
}
|
||||||
const output = await options.write({ input, effects });
|
const output = await options.write({ input, effects });
|
||||||
return output;
|
if (output) {
|
||||||
|
await effects.setWrapperData({ path: "config", value: output });
|
||||||
|
}
|
||||||
}) as ExpectedExports.setConfig,
|
}) as ExpectedExports.setConfig,
|
||||||
getConfig: (async ({ effects, config }) => {
|
getConfig: (async ({ effects, config }) => {
|
||||||
return {
|
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";
|
export * as configTypes from "./config/configTypes";
|
||||||
import { InputSpec } from "./config/configTypes";
|
import { InputSpec } from "./config/configTypes";
|
||||||
|
import { ActionReceipt } from "./init";
|
||||||
|
|
||||||
export namespace ExpectedExports {
|
export namespace ExpectedExports {
|
||||||
version: 1;
|
version: 1;
|
||||||
@@ -13,8 +14,8 @@ export namespace ExpectedExports {
|
|||||||
effects: Effects;
|
effects: Effects;
|
||||||
config: unknown;
|
config: unknown;
|
||||||
}) => Promise<ConfigRes>;
|
}) => Promise<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;
|
||||||
/** For backing up service data though the embassyOS UI */
|
/** For backing up service data though the embassyOS UI */
|
||||||
export type createBackup = (options: {
|
export type createBackup = (options: {
|
||||||
effects: Effects;
|
effects: Effects;
|
||||||
@@ -28,16 +29,13 @@ export namespace ExpectedExports {
|
|||||||
effects: Effects;
|
effects: Effects;
|
||||||
}) => Promise<Properties | null | undefined | void>;
|
}) => Promise<Properties | null | undefined | void>;
|
||||||
|
|
||||||
/** Health checks are used to determine if the service is working properly after starting
|
// /** 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.
|
// * A good use case is if we are using a web server, seeing if we can get to the web server.
|
||||||
*/
|
// */
|
||||||
export type health = {
|
// export type health = {
|
||||||
/** Should be the health check id */
|
// /** Should be the health check id */
|
||||||
[id: string]: (options: {
|
// [id: string]: (options: { effects: Effects; input: TimeMs }) => Promise<unknown>;
|
||||||
effects: Effects;
|
// };
|
||||||
input: TimeMs;
|
|
||||||
}) => Promise<unknown>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions are used so we can effect the service, like deleting a directory.
|
* Actions are used so we can effect the service, like deleting a directory.
|
||||||
@@ -308,12 +306,12 @@ export type Effects = {
|
|||||||
description: string;
|
description: string;
|
||||||
id: string;
|
id: string;
|
||||||
input: null | InputSpec;
|
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
|
* So the ordering of the actions is by alphabetical order of the group, then followed by the alphabetical of the actions
|
||||||
*/
|
*/
|
||||||
group?: string;
|
group?: string;
|
||||||
}): Promise<void>;
|
}): Promise<void & ActionReceipt>;
|
||||||
/**
|
/**
|
||||||
* Remove an action that was exported. Used problably during main or during setConfig.
|
* Remove an action that was exported. Used problably during main or during setConfig.
|
||||||
*/
|
*/
|
||||||
@@ -448,6 +446,11 @@ export type PackagePropertyString = {
|
|||||||
qr?: boolean;
|
qr?: boolean;
|
||||||
/** Hiding the value unless toggled off for field */
|
/** Hiding the value unless toggled off for field */
|
||||||
masked?: boolean;
|
masked?: boolean;
|
||||||
|
|
||||||
|
watch?: {
|
||||||
|
packageId?: string;
|
||||||
|
path: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
export type PackagePropertyObject = {
|
export type PackagePropertyObject = {
|
||||||
value: PackagePropertiesV2;
|
value: PackagePropertiesV2;
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie20",
|
"version": "0.4.0-lib0.charlie21",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie20",
|
"version": "0.4.0-lib0.charlie21",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"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.",
|
"description": "For making the patterns that are wanted in making services for the startOS.",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user