Client config builder methods
Closes #1122
Possible future tasks:
- [ ]
PolywrapClientprobably shouldn't know aboutClientConfigBuilderand shouldn't know aboutdefaults. Add issue?- Should remove the
noDefaultsoption within the constructor - PolywrapClient should just apply the config it's provided, not modify/add to it upon construction
- Good separation of concerns, simpler client code.
- Should remove the
Initial set of the ClientConfigBuilder methods.
Methods implemented:
Plugin methods
addPlugin(uri: string, plugin: PluginPackage)
Adds specified plugin registered under the uri. If a plugin already exists, overwrites it.
removePlugin(uri: string)
Removes the plugin registered under the uri.
Env methods
addEnv(uri: string, env: Record<string, unknown>)
Adds specified env registered under the uri. If an env is already registered under the uri, it performs a merge (currently using naive implementation - spread operator).
setEnv(uri: string, env: Record<string, unknown>)
Adds specified env registered under the uri if none exists. Otherwise, overwrites the env that is already registered under the uri.
removeEnv(uri: string)
Removes the env registered under the uri if one exists. Otherwise, does nothing.
InterfaceImplementation methods
addInterfaceImplementation(interfaceUri: Uri | string, implementationUri: Uri | string)
Adds the interfaceImplementationUri to the implementations collection for the specified interfaceUri. Creates the InterfaceImplementation if none exists for interfaceUri.
addInterfaceImplementations(interfaceUri: Uri | string, implementationUris: Array<Uri | string>)
Appends all interfaceImplementationUris to the the implementations collection for the specified interfaceUri. Creates the InterfaceImplementation if none exists for interfaceUri.
removeInterfaceImplementation(interfaceUri: Uri | string, implementationUri: Uri | string)
Removes the interfaceImplementationUri from the implementations collection for the specified interfaceUri. Removes the InterfaceImplementation if the implementations collection would remain empty.
UriRedirect methods
addUriRedirect(from: Uri | string, to: Uri | string)
Adds the specified UriRedirect. If an existing UriRedirect has the same from, overwrites it.
removeUriRedirect(from: Uri | string)
Removes the specified UriRedirect.
UriResolver methods
addUriResolver(resolver: UriResolver)
Adds the specified UriResolver to the end of the uriResolvers collection.
setUriResolvers(resolvers: UriResolver[])
Sets the uriResolvers collection to resolvers.