Skip to content

Commit

Permalink
Type Options.withConfig (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF authored Mar 6, 2025
1 parent 12d19d8 commit f02ffa3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 1 addition & 11 deletions packages/gel/src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* limitations under the License.
*/

import type { Duration } from "./datatypes/datetime";
import type { Codecs } from "./codecs/codecs";
import { CodecsRegistry } from "./codecs/registry";
import type {
Expand All @@ -36,6 +35,7 @@ import {
} from "./ifaces";
import type {
RetryOptions,
SimpleConfig,
SimpleRetryOptions,
SimpleTransactionOptions,
TransactionOptions,
Expand Down Expand Up @@ -552,16 +552,6 @@ export interface ClientOptions {

export type ConnectOptions = ConnectConfig & ClientOptions;

type SimpleConfig = Partial<{
session_idle_transaction_timeout: Duration;
query_execution_timeout: Duration;
allow_bare_ddl: "AlwaysAllow" | "NeverAllow";
allow_dml_in_functions: boolean;
allow_user_specified_id: boolean;
apply_access_policies: boolean;
[k: string]: unknown;
}>;

export class Client implements Executor {
private pool: BaseClientPool;
private options: Options;
Expand Down
13 changes: 12 additions & 1 deletion packages/gel/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Codecs } from "./codecs/codecs";
import { SQLRowModeArray } from "./codecs/record";
import type { ReadonlyCodecMap, MutableCodecMap } from "./codecs/context";
import { CodecContext, NOOP_CODEC_CONTEXT } from "./codecs/context";
import type { Duration } from "./datatypes/datetime";

export type BackoffFunction = (n: number) => number;

Expand Down Expand Up @@ -147,6 +148,16 @@ export interface CodecSpec {
decode: (data: any) => any;
}

export type SimpleConfig = Partial<{
session_idle_transaction_timeout: Duration;
query_execution_timeout: Duration;
allow_bare_ddl: "AlwaysAllow" | "NeverAllow";
allow_dml_in_functions: boolean;
allow_user_specified_id: boolean;
apply_access_policies: boolean;
[k: string]: unknown;
}>;

export type OptionsList = {
module?: string;
moduleAliases?: Record<string, string>;
Expand Down Expand Up @@ -345,7 +356,7 @@ export class Options {
});
}

withConfig(config: Record<string, any>): Options {
withConfig(config: SimpleConfig): Options {
return this._cloneWith({ config });
}

Expand Down

0 comments on commit f02ffa3

Please sign in to comment.