From cd9fd6354d92acf2cdc210f02e828ce6d9c58926 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 21 Feb 2024 17:48:43 -0700 Subject: [PATCH] Add a method for initializing a client. --- src/lib/client.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/client.ts b/src/lib/client.ts index 58a43e4..5cb774b 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -253,7 +253,26 @@ export class SindriClient { return !!(this._clientConfig.BASE && this._clientConfig.TOKEN); } - // }[tags=["latest"]] + /** + * Creates a new {@link SindriClient} client instance. The class itself is not exported, so use + * this method on the exported (or any other) client instance to create a new instance. The new + * instance can be configured and used completely independently from any other instances. For + * example it can use different credentials or a different log level. + * + * @param authOptions - The authentication options for the client, including + * credentials like API keys or tokens. Defaults to an empty object if not provided. + * + * @example + * import sindri from 'sindri'; + * + * // Equivalent to: const myClient = new SindriClient({ ... }); + * const myClient = sindri.create({ apiKey: 'sindri-mykey-1234'}); + * + * @returns The new client instance. + */ + create(authOptions: AuthOptions | undefined): SindriClient { + return new SindriClient(authOptions); + } /** * Asynchronously creates and deploys a new circuit, initiating its compilation process. This