mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
Feature/sdk040dependencies (#2609)
* update registry upload to take id for new admin permissions (#2605) * wip * wip: Get the get dependencies * wip check_dependencies * wip: Get the build working to the vm * wip: Add in the last of the things that where needed for the new sdk * Add fix * wip: implement the changes * wip: Fix the naming --------- Co-authored-by: Lucy <12953208+elvece@users.noreply.github.com>
This commit is contained in:
44
sdk/lib/dependencies/DependencyConfig.ts
Normal file
44
sdk/lib/dependencies/DependencyConfig.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
DependencyConfig as DependencyConfigType,
|
||||
DeepPartial,
|
||||
Effects,
|
||||
} from "../types"
|
||||
import { deepEqual } from "../util/deepEqual"
|
||||
import { deepMerge } from "../util/deepMerge"
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
|
||||
export type Update<QueryResults, RemoteConfig> = (options: {
|
||||
remoteConfig: RemoteConfig
|
||||
queryResults: QueryResults
|
||||
}) => Promise<RemoteConfig>
|
||||
|
||||
export class DependencyConfig<
|
||||
Manifest extends SDKManifest,
|
||||
Store,
|
||||
Input extends Record<string, any>,
|
||||
RemoteConfig extends Record<string, any>,
|
||||
> {
|
||||
static defaultUpdate = async (options: {
|
||||
queryResults: unknown
|
||||
remoteConfig: unknown
|
||||
}): Promise<unknown> => {
|
||||
return deepMerge({}, options.remoteConfig, options.queryResults || {})
|
||||
}
|
||||
constructor(
|
||||
readonly dependencyConfig: (options: {
|
||||
effects: Effects
|
||||
localConfig: Input
|
||||
}) => Promise<void | DeepPartial<RemoteConfig>>,
|
||||
readonly update: Update<
|
||||
void | DeepPartial<RemoteConfig>,
|
||||
RemoteConfig
|
||||
> = DependencyConfig.defaultUpdate as any,
|
||||
) {}
|
||||
|
||||
async query(options: { effects: Effects; localConfig: unknown }) {
|
||||
return this.dependencyConfig({
|
||||
localConfig: options.localConfig as Input,
|
||||
effects: options.effects,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user