From ece5577f260a67b7cfd832ae99c24e9cfa4dc060 Mon Sep 17 00:00:00 2001 From: Jade <2364004+Blu-J@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:20:18 -0600 Subject: [PATCH] feat: Adding in the effects to the startSdk (#2722) Currently the start sdk that we expose calls some of the effects. And there are others that need to be called via the effects object. The idea is that all the effects that could and should be called are from the startsdk side --- sdk/lib/StartSdk.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ sdk/lib/types.ts | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/sdk/lib/StartSdk.ts b/sdk/lib/StartSdk.ts index 390e8e87f..658597bc2 100644 --- a/sdk/lib/StartSdk.ts +++ b/sdk/lib/StartSdk.ts @@ -139,7 +139,51 @@ export class StartSdk { }]?: Dependency } + type NestedEffects = "subcontainer" | "store" + type InterfaceEffects = + | "getServiceInterface" + | "listServiceInterfaces" + | "exportServiceInterface" + | "clearServiceInterfaces" + | "bind" + | "getHostInfo" + | "getPrimaryUrl" + type MainUsedEffects = "setMainStatus" | "setHealth" + type AlreadyExposed = "getSslCertificate" | "getSystemSmtp" + + // prettier-ignore + type StartSdkEffectWrapper = { + [K in keyof Omit]: (effects: Effects, ...args: Parameters) => ReturnType + } + const startSdkEffectWrapper: StartSdkEffectWrapper = { + executeAction: (effects, ...args) => effects.executeAction(...args), + exportAction: (effects, ...args) => effects.exportAction(...args), + clearActions: (effects, ...args) => effects.clearActions(...args), + getConfigured: (effects, ...args) => effects.getConfigured(...args), + setConfigured: (effects, ...args) => effects.setConfigured(...args), + restart: (effects, ...args) => effects.restart(...args), + setDependencies: (effects, ...args) => effects.setDependencies(...args), + checkDependencies: (effects, ...args) => + effects.checkDependencies(...args), + mount: (effects, ...args) => effects.mount(...args), + getInstalledPackages: (effects, ...args) => + effects.getInstalledPackages(...args), + exposeForDependents: (effects, ...args) => + effects.exposeForDependents(...args), + getServicePortForward: (effects, ...args) => + effects.getServicePortForward(...args), + clearBindings: (effects, ...args) => effects.clearBindings(...args), + getContainerIp: (effects, ...args) => effects.getContainerIp(...args), + getSslKey: (effects, ...args) => effects.getSslKey(...args), + setDataVersion: (effects, ...args) => effects.setDataVersion(...args), + getDataVersion: (effects, ...args) => effects.getDataVersion(...args), + shutdown: (effects, ...args) => effects.shutdown(...args), + getDependencies: (effects, ...args) => effects.getDependencies(...args), + } + return { + ...startSdkEffectWrapper, + checkDependencies: checkDependencies as < DependencyId extends keyof Manifest["dependencies"] & PackageId = keyof Manifest["dependencies"] & PackageId, diff --git a/sdk/lib/types.ts b/sdk/lib/types.ts index 772609ea0..4820f419d 100644 --- a/sdk/lib/types.ts +++ b/sdk/lib/types.ts @@ -382,7 +382,7 @@ export type Effects = { hostId: HostId internalPort: number }): Promise - /** Removes all network bindings */ + /** Removes all network bindings, called in the setupConfig */ clearBindings(): Promise // host /** Returns information about the specified host, if it exists */