From f936f5ce3592b1cb4d00d3528690cb0d7101d944 Mon Sep 17 00:00:00 2001 From: BluJ Date: Fri, 14 Apr 2023 17:53:08 -0600 Subject: [PATCH] chore: charlie21 --- lib/config/setupConfigExports.ts | 4 ++- lib/init/index.ts | 50 ++++++++++++++++++++++++++++++++ lib/types.ts | 31 +++++++++++--------- package-lock.json | 4 +-- package.json | 2 +- 5 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 lib/init/index.ts diff --git a/lib/config/setupConfigExports.ts b/lib/config/setupConfigExports.ts index f90b89d..40190aa 100644 --- a/lib/config/setupConfigExports.ts +++ b/lib/config/setupConfigExports.ts @@ -31,7 +31,9 @@ export function setupConfigExports(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 { diff --git a/lib/init/index.ts b/lib/init/index.ts new file mode 100644 index 0000000..b28a1f0 --- /dev/null +++ b/lib/init/index.ts @@ -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): 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 +): MigrationDownReceipt { + fn(); + return {} as MigrationDownReceipt; +} + +export function setupInit( + fn: ( + ...args: Parameters + ) => Promise<[MigrationReceipt, ActionReceipt]> +) { + const initFn: ExpectedExports.init = (...args) => fn(...args); + return initFn; +} + +export function setupUninit( + fn: ( + ...args: Parameters + ) => Promise<[MigrationDownReceipt]> +) { + const uninitFn: ExpectedExports.uninit = (...args) => fn(...args); + return uninitFn; +} diff --git a/lib/types.ts b/lib/types.ts index 5f2703e..807418d 100644 --- a/lib/types.ts +++ b/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; - /** 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; - /** 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; - }; + // /** 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; + // }; /** * 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; + }): Promise; /** * 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; diff --git a/package-lock.json b/package-lock.json index 0b15c12..b5b183d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 14aa15d..53f8d05 100644 --- a/package.json +++ b/package.json @@ -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",