Bump versions, move getAdapter to context

This commit is contained in:
Jon Staab
2025-04-01 14:24:32 -07:00
parent 540726531f
commit 1cbcb0ae4a
15 changed files with 91 additions and 126 deletions
+1 -3
View File
@@ -99,9 +99,7 @@ export class MockAdapter extends AbstractAdapter {
}
}
export type AdapterContext = Partial<NetContext> & {
getAdapter?: (url: string, context: AdapterContext) => AbstractAdapter
}
export type AdapterContext = Partial<NetContext>
export const getAdapter = (url: string, adapterContext: AdapterContext = {}) => {
const context = mergeRight(netContext, adapterContext as any)
+2
View File
@@ -1,5 +1,6 @@
import {Repository} from "@welshman/relay"
import {verifyEvent, TrustedEvent, SignedEvent} from "@welshman/util"
import {AbstractAdapter} from "./adapter.js"
import {Pool} from "./pool.js"
export type NetContext = {
@@ -7,6 +8,7 @@ export type NetContext = {
repository: Repository
isEventValid: (event: TrustedEvent, url: string) => boolean
isEventDeleted: (event: TrustedEvent, url: string) => boolean
getAdapter?: (url: string, context: NetContext) => AbstractAdapter
}
export const netContext: NetContext = {
+2 -2
View File
@@ -124,8 +124,8 @@ export class SingleRequest extends (EventEmitter as new () => TypedEmitter<Singl
}
// Timeout our subscription
if (this.options.timeout) {
setTimeout(() => this.close(), this.options.timeout)
if (this.options.timeout || this.options.autoClose) {
setTimeout(() => this.close(), this.options.timeout || 10000)
}
// Start asynchronously so the caller can set up listeners