@@ -9,13 +9,11 @@ import type { ConnectionOptions } from './connection';
99 *
1010 * It is defined as a tagged union, to be consumed by other parts of the SDK.
1111 */
12-
1312export type DataSource = { path : string } | { data : string | Buffer } ;
1413
1514interface ClientConfigTLSJSON {
1615 disabled ?: boolean ;
1716 serverName ?: string ;
18- // TODO(assess): name Ca -> CA ?
1917 serverCaCert ?: Record < string , string > ;
2018 clientCert ?: Record < string , string > ;
2119 clientKey ?: Record < string , string > ;
@@ -29,14 +27,14 @@ interface ClientConfigProfileJSON {
2927 grpcMeta ?: Record < string , string > ;
3028}
3129
32- function recordToSource ( d ?: Record < string , any > ) : DataSource | undefined {
30+ function recordToSource ( d ?: Record < string , string > ) : DataSource | undefined {
3331 if ( d === undefined ) {
3432 return undefined ;
3533 }
36- if ( d . data !== undefined ) {
34+ if ( d . data != null ) {
3735 return { data : d . data } ;
3836 }
39- if ( d . path !== undefined && typeof d . path === 'string' ) {
37+ if ( d . path != null && typeof d . path === 'string' ) {
4038 return { path : d . path } ;
4139 }
4240 return undefined ;
@@ -83,7 +81,6 @@ function readSourceSync(source?: DataSource): Buffer | undefined {
8381 }
8482
8583 if ( 'path' in source ) {
86- // This is correct. It reads the whole file into a Buffer asynchronously.
8784 return fs . readFileSync ( source . path ) ;
8885 }
8986
@@ -198,7 +195,12 @@ export class ClientConfigTLS {
198195 } ) ;
199196 }
200197
201- // TODO(assess): add doc string
198+ /**
199+ * Converts this TLS configuration to a {@link TLSConfig} object for use with connections.
200+ *
201+ * @returns A TLSConfig object with the certificate data loaded from the configured sources,
202+ * or undefined if TLS is disabled.
203+ */
202204 public toTLSConfig ( ) : TLSConfig | undefined {
203205 if ( this . disabled ) {
204206 return undefined ;
@@ -222,7 +224,6 @@ export class ClientConfigTLS {
222224 }
223225}
224226
225- // TODO(assess): determine need for "ClientConnectConfig"
226227interface ClientConnectConfig {
227228 connectionOptions : ConnectionOptions ;
228229 namespace ?: string ;
@@ -269,7 +270,33 @@ export interface LoadClientProfileOptions {
269270 overrideEnvVars ?: Record < string , string > ;
270271}
271272
272- // TODO(assess): docstring
273+ /**
274+ * A client configuration profile loaded from environment variables and/or TOML configuration.
275+ *
276+ * This class represents a single named profile within a client configuration, containing
277+ * all the necessary settings to establish a connection to a Temporal server, including
278+ * address, namespace, authentication, TLS settings, and gRPC metadata.
279+ *
280+ * Configuration sources are loaded and merged in the following precedence (highest to lowest):
281+ * 1. Environment variable overrides
282+ * 2. TOML configuration file settings
283+ * 3. Default values
284+ *
285+ * @example
286+ * ```ts
287+ * // Load the default profile from environment and default config locations
288+ * const profile = ClientConfigProfile.load();
289+ * const { connectionOptions, namespace } = profile.toClientConnectConfig();
290+ *
291+ * // Load a specific profile with custom config source
292+ * const customProfile = ClientConfigProfile.load({
293+ * profile: 'production',
294+ * configSource: { path: '/path/to/config.toml' }
295+ * });
296+ * ```
297+ *
298+ * @experimental
299+ */
273300export class ClientConfigProfile {
274301 public readonly address ?: string ;
275302 public readonly namespace ?: string ;
@@ -322,7 +349,24 @@ export class ClientConfigProfile {
322349 } ) ;
323350 }
324351
325- // TODO(assess): docstring
352+ /**
353+ * Converts this configuration profile to connection options for creating a Temporal client.
354+ *
355+ * This method validates that required settings are present and transforms the profile
356+ * into the format expected by {@link Connection.connect} and related client constructors.
357+ *
358+ * @returns An object containing connection options and namespace settings
359+ * @throws {Error } If the profile does not contain a required address field
360+ *
361+ * @example
362+ * ```ts
363+ * const profile = ClientConfigProfile.load({ profile: 'production' });
364+ * const { connectionOptions, namespace } = profile.toClientConnectConfig();
365+ *
366+ * const connection = await Connection.connect(connectionOptions);
367+ * const client = new Client({ connection, namespace });
368+ * ```
369+ */
326370 public toClientConnectConfig ( ) : ClientConnectConfig {
327371 if ( ! this . address ) {
328372 throw new Error ( "Configuration profile must contain an 'address' to be used for client connection" ) ;
@@ -372,12 +416,45 @@ interface ClientConfigJSON {
372416 profiles : Record < string , ClientConfigProfileJSON > ;
373417}
374418
375- // TODO(assess): update docstrings
376419/**
377- * Client configuration loaded from TOML and environment variables.
420+ * Client configuration container that manages multiple named profiles.
421+ *
422+ * This class loads and manages client configuration profiles from TOML files and
423+ * environment variables, providing a centralized way to handle multiple Temporal
424+ * server connection configurations. Each profile contains settings for server
425+ * address, authentication, TLS, and other connection parameters.
426+ *
427+ * The configuration supports:
428+ * - Loading from TOML configuration files
429+ * - Environment variable-based profile discovery via `TEMPORAL_CONFIG_FILE`
430+ * - Multiple named profiles within a single configuration
431+ * - JSON serialization for configuration persistence
432+ * - Strict mode validation for configuration files
433+ *
434+ * This is the TypeScript equivalent of the Python SDK's `ClientConfig`.
378435 *
379- * This class is the TypeScript equivalent of the Python SDK's `ClientConfig`.
380- * It contains a mapping of profile names to client profiles.
436+ * @example
437+ * ```ts
438+ * // Load all profiles from default config locations
439+ * const config = ClientConfig.load();
440+ *
441+ * // Access a specific profile
442+ * const prodProfile = config.profiles['production'];
443+ * if (prodProfile) {
444+ * const { connectionOptions, namespace } = prodProfile.toClientConnectConfig();
445+ * }
446+ *
447+ * // Load from a specific TOML file with strict validation
448+ * const strictConfig = ClientConfig.load({
449+ * configSource: { path: './temporal-config.toml' },
450+ * configFileStrict: true
451+ * });
452+ *
453+ * // Convenience method to load a single profile directly
454+ * const connectConfig = ClientConfig.loadClientConnectConfig({
455+ * profile: 'development'
456+ * });
457+ * ```
381458 *
382459 * @experimental
383460 */
0 commit comments