Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"suspicious": {
"useAwait": "error"
},
"nursery": {
"noFloatingPromises": "error"
}
}
},
"formatter": {
Expand Down
21 changes: 11 additions & 10 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class ConfigClient {
*
* @returns A record mapping field paths to their string values.
*/
async getAll(
getAll(
tenantId: string,
options?: { timeout?: number; signal?: AbortSignal },
): Promise<Record<string, string>> {
Expand Down Expand Up @@ -250,7 +250,7 @@ export class ConfigClient {
* coerces it to the schema-defined type. For type-safe writes, prefer
* setNumber(), setBool(), setTime(), or setDuration().
*/
async set(
set(
tenantId: string,
fieldPath: string,
value: string,
Expand Down Expand Up @@ -281,7 +281,7 @@ export class ConfigClient {
}

/** Set a numeric config value. Sends the native number as a proto numberValue. */
async setNumber(
setNumber(
tenantId: string,
fieldPath: string,
value: number,
Expand All @@ -296,7 +296,7 @@ export class ConfigClient {
}

/** Set a boolean config value. Sends the native boolean as a proto boolValue. */
async setBool(
setBool(
tenantId: string,
fieldPath: string,
value: boolean,
Expand All @@ -311,7 +311,7 @@ export class ConfigClient {
}

/** Set a timestamp config value. Sends the Date as a proto timeValue. */
async setTime(
setTime(
tenantId: string,
fieldPath: string,
value: Date,
Expand All @@ -329,7 +329,7 @@ export class ConfigClient {
* Set a duration config value. The value must be a duration string
* (e.g. "1h30m", "300s") — the server parses and validates the format.
*/
async setDuration(
setDuration(
tenantId: string,
fieldPath: string,
value: string,
Expand All @@ -350,7 +350,7 @@ export class ConfigClient {
* @param options - Optional description for the audit log, idempotency key for safe DEADLINE_EXCEEDED retries,
* and per-field expected checksums for optimistic concurrency control.
*/
async setMany(
setMany(
tenantId: string,
values: Record<string, SetValue>,
options?: {
Expand Down Expand Up @@ -383,7 +383,7 @@ export class ConfigClient {
/**
* Set a config field to null.
*/
async setNull(
setNull(
tenantId: string,
fieldPath: string,
options?: {
Expand Down Expand Up @@ -462,13 +462,14 @@ export class ConfigClient {
/**
* Async dispose pattern support — use with `await using`.
*/
async [Symbol.asyncDispose](): Promise<void> {
[Symbol.asyncDispose](): Promise<void> {
this.close();
return Promise.resolve();
}

// --- Private helpers ---

private async setTyped(
private setTyped(
tenantId: string,
fieldPath: string,
value: SetValue,
Expand Down
5 changes: 3 additions & 2 deletions src/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ export class ConfigWatcher extends EventEmitter {
* Safe to call multiple times. After stopping, registered WatchedField
* async iterators will complete.
*/
async stop(): Promise<void> {
stop(): Promise<void> {
if (this.stopped) {
return;
return Promise.resolve();
}
this.stopped = true;

Expand All @@ -408,6 +408,7 @@ export class ConfigWatcher extends EventEmitter {
for (const field of this.fields.values()) {
field._stop();
}
return Promise.resolve();
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ describe("ConfigClient", () => {
});

it("works with await using", async () => {
// biome-ignore lint/suspicious/useAwait: await using satisfies the await requirement but biome doesn't recognise it yet
await (async () => {
await using c = client;
void c;
Expand Down
1 change: 1 addition & 0 deletions test/watcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ describe("ConfigWatcher", () => {
watcher.field("payments.fee", Number, { default: 0.01 });
await watcher.start();

// biome-ignore lint/suspicious/useAwait: await using satisfies the await requirement but biome doesn't recognise it yet
await (async () => {
await using w = watcher;
void w;
Expand Down