Skip to content

Commit

Permalink
Merge pull request #1291 from polywrap/pileks/make-config-props-read-…
Browse files Browse the repository at this point in the history
…only

Make config props read only
  • Loading branch information
cbrzn authored Oct 5, 2022
2 parents fe40e5f + 12eea9a commit 6436804
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/cli/src/lib/helpers/validate-client-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

export function validateRedirects<
TUri extends PluginPackage<unknown> | Uri | string
>(redirects: UriRedirect<TUri>[]): void {
>(redirects: readonly UriRedirect<TUri>[]): void {
if (!Array.isArray(redirects)) {
throw new Error(intlMsg.commands_run_error_redirectsExportNotArray());
}
Expand Down Expand Up @@ -44,7 +44,7 @@ export function validateRedirects<
}

export function validatePlugins<TUri extends Uri | string = string>(
plugins: PluginRegistration<TUri>[]
plugins: readonly PluginRegistration<TUri>[]
): void {
if (!Array.isArray(plugins)) {
throw new Error(intlMsg.commands_run_error_pluginsExportNotArray());
Expand Down Expand Up @@ -88,7 +88,7 @@ export function validatePlugins<TUri extends Uri | string = string>(
}

export function validateInterfaces<TUri extends Uri | string = string>(
interfaces: InterfaceImplementations<TUri>[]
interfaces: readonly InterfaceImplementations<TUri>[]
): void {
if (!Array.isArray(interfaces)) {
throw new Error(intlMsg.commands_run_error_interfacesExportNotArray());
Expand Down Expand Up @@ -138,7 +138,7 @@ export function validateInterfaces<TUri extends Uri | string = string>(
}

export function validateEnvs<TUri extends Uri | string = string>(
envs: Env<TUri>[]
envs: readonly Env<TUri>[]
): void {
if (!Array.isArray(envs)) {
throw new Error(intlMsg.commands_run_error_envsExportNotArray());
Expand Down
9 changes: 6 additions & 3 deletions packages/js/client/src/PolywrapClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import { Result, ResultErr, ResultOk } from "@polywrap/result";

export interface PolywrapClientConfig<TUri extends Uri | string = string>
extends ClientConfig<TUri> {
tracerConfig: Partial<TracerConfig>;
wrapperCache?: IWrapperCache;
readonly tracerConfig: Readonly<Partial<TracerConfig>>;
readonly wrapperCache?: Readonly<IWrapperCache>;
}

export class PolywrapClient implements Client {
Expand Down Expand Up @@ -111,7 +111,10 @@ export class PolywrapClient implements Client {
} else {
Tracer.disableTracing();
}
this._config.tracerConfig = tracerConfig ?? {};
this._config = {
...this._config,
tracerConfig: tracerConfig ?? {},
};
}

@Tracer.traceMethod("PolywrapClient: getRedirects")
Expand Down
10 changes: 5 additions & 5 deletions packages/js/core/src/types/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { WrapManifest } from "@polywrap/wrap-manifest-types-js";
import { Result } from "@polywrap/result";

export interface ClientConfig<TUri extends Uri | string = string> {
redirects: UriRedirect<TUri>[];
plugins: PluginRegistration<TUri>[];
interfaces: InterfaceImplementations<TUri>[];
envs: Env<TUri>[];
resolver: IUriResolver<unknown>;
readonly redirects: Readonly<UriRedirect<TUri>[]>;
readonly plugins: Readonly<PluginRegistration<TUri>[]>;
readonly interfaces: Readonly<InterfaceImplementations<TUri>[]>;
readonly envs: Readonly<Env<TUri>[]>;
readonly resolver: Readonly<IUriResolver<unknown>>;
}

export interface GetManifestOptions {
Expand Down

0 comments on commit 6436804

Please sign in to comment.