Fix tests
This commit is contained in:
parent
e583770518
commit
74c61ca9ba
@ -18,7 +18,6 @@
|
||||
"@void-cat/api": "^1.0.4",
|
||||
"debug": "^4.3.4",
|
||||
"dexie": "^3.2.4",
|
||||
"dns-over-http-resolver": "^2.1.1",
|
||||
"emojilib": "^3.0.10",
|
||||
"light-bolt11-decoder": "^2.1.0",
|
||||
"match-sorter": "^6.3.1",
|
||||
@ -102,8 +101,8 @@
|
||||
"prop-types": "^15.8.1",
|
||||
"source-map-loader": "^4.0.1",
|
||||
"terser-webpack-plugin": "^5.3.9",
|
||||
"tinybench": "^2.5.0",
|
||||
"ts-jest": "^29.1.0",
|
||||
"tinybench": "^2.5.1",
|
||||
"ts-jest": "^29.1.1",
|
||||
"ts-loader": "^9.4.4",
|
||||
"typescript": "^5.2.2",
|
||||
"webpack": "^5.88.2",
|
||||
|
@ -1,7 +1,3 @@
|
||||
import DnsOverHttpResolver from "dns-over-http-resolver";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
|
||||
const resolver = new DnsOverHttpResolver();
|
||||
interface NostrJson {
|
||||
names: Record<string, string>;
|
||||
}
|
||||
@ -23,12 +19,5 @@ export async function fetchNip05Pubkey(name: string, domain: string, timeout = 2
|
||||
// ignored
|
||||
}
|
||||
|
||||
// Check as DoH TXT entry
|
||||
try {
|
||||
const resDns = await resolver.resolveTxt(`${name}._nostr.${domain}`);
|
||||
return bech32ToHex(resDns[0][0]);
|
||||
} catch {
|
||||
// ignored
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import { bytesToHex } from "@noble/hashes/utils";
|
||||
import { DefaultQueryOptimizer, EventExt, FlatReqFilter, PowMiner, QueryOptimizer, ReqFilter } from "@snort/system";
|
||||
import { compress, expand_filter, flat_merge, get_diff, pow, default as wasmInit } from "@snort/system-wasm";
|
||||
import WasmPath from "@snort/system-wasm/pkg/system_wasm_bg.wasm";
|
||||
import { Bench } from "tinybench";
|
||||
|
||||
const WasmQueryOptimizer = {
|
||||
expandFilter: (f: ReqFilter) => {
|
||||
@ -87,10 +86,17 @@ const testCompress = (q: QueryOptimizer) => {
|
||||
]);
|
||||
};
|
||||
|
||||
const runAll = async () => {
|
||||
await wasmInit(WasmPath);
|
||||
|
||||
const tinybench = await import("tinybench");
|
||||
|
||||
const { Bench } = tinybench;
|
||||
const wasmSuite = new Bench({ time: 1_000 });
|
||||
const suite = new Bench({ time: 1_000 });
|
||||
|
||||
const addTests = (s: Bench, q: QueryOptimizer, p: PowMiner) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const addTests = (s: any, q: QueryOptimizer, p: PowMiner) => {
|
||||
s.add("expand", () => testExpand(q));
|
||||
s.add("get_diff", () => testGetDiff(q));
|
||||
s.add("flat_merge", () => testFlatMerge(q));
|
||||
@ -120,9 +126,6 @@ addTests(wasmSuite, WasmQueryOptimizer, {
|
||||
},
|
||||
});
|
||||
|
||||
const runAll = async () => {
|
||||
await wasmInit(WasmPath);
|
||||
|
||||
console.log("DefaultQueryOptimizer");
|
||||
await suite.run();
|
||||
console.table(suite.table());
|
||||
|
@ -1,16 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"target": "es2020",
|
||||
"module": "es2020",
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"jsx": "react-jsx",
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "NodeNext",
|
||||
"sourceMap": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"allowJs": true
|
||||
"allowSyntheticDefaultImports": true
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
"@noble/hashes": "^1.3.2",
|
||||
"@scure/base": "^1.1.2",
|
||||
"debug": "^4.3.4",
|
||||
"dexie": "^3.2.4",
|
||||
"light-bolt11-decoder": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
87
packages/shared/src/dexie-like.ts
Normal file
87
packages/shared/src/dexie-like.ts
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Dexie proxy type
|
||||
*/
|
||||
export abstract class DexieLike {
|
||||
constructor(name: string) {}
|
||||
version(n: number) {
|
||||
return {
|
||||
stores(schema: object) {},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export type DexieIndexableTypePart =
|
||||
| string
|
||||
| number
|
||||
| Date
|
||||
| ArrayBuffer
|
||||
| ArrayBufferView
|
||||
| DataView
|
||||
| Array<Array<void>>;
|
||||
export type DexieIndexableTypeArray = Array<DexieIndexableTypePart>;
|
||||
export type DexieIndexableTypeArrayReadonly = ReadonlyArray<DexieIndexableTypePart>;
|
||||
export type DexieIndexableType = DexieIndexableTypePart | DexieIndexableTypeArrayReadonly;
|
||||
|
||||
export interface DexiePromiseExtended<T = any> extends Promise<T> {
|
||||
then<TResult1 = T, TResult2 = never>(
|
||||
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
||||
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
||||
): DexiePromiseExtended<TResult1 | TResult2>;
|
||||
catch<TResult = never>(
|
||||
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
||||
): DexiePromiseExtended<T | TResult>;
|
||||
catch<TResult = never>(
|
||||
ErrorConstructor: Function,
|
||||
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
||||
): DexiePromiseExtended<T | TResult>;
|
||||
catch<TResult = never>(
|
||||
errorName: string,
|
||||
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
||||
): DexiePromiseExtended<T | TResult>;
|
||||
finally<U>(onFinally?: () => U | PromiseLike<U>): DexiePromiseExtended<T>;
|
||||
timeout(ms: number, msg?: string): DexiePromiseExtended<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dexie Table<T> like structure
|
||||
*/
|
||||
export interface DexieTableLike<T = any, TKey = DexieIndexableType> {
|
||||
toCollection(): {
|
||||
get primaryKeys(): {
|
||||
(): DexiePromiseExtended<Array<TKey>>;
|
||||
<R>(thenShortcut: DexieThenShortcut<Array<TKey>, R>): DexiePromiseExtended<R>;
|
||||
};
|
||||
};
|
||||
get(key: TKey): DexiePromiseExtended<T | undefined>;
|
||||
bulkGet(keys: Array<TKey>): DexiePromiseExtended<Array<T | undefined>>;
|
||||
put(item: T, key?: TKey): DexiePromiseExtended<TKey>;
|
||||
bulkPut(
|
||||
items: readonly T[],
|
||||
keys?: DexieIndexableTypeArrayReadonly,
|
||||
options?: {
|
||||
allKeys: boolean;
|
||||
},
|
||||
): DexiePromiseExtended<TKey>;
|
||||
clear(): DexiePromiseExtended<void>;
|
||||
where(index: string | string[]): DexieWhereClause<T, TKey>;
|
||||
toArray(): DexiePromiseExtended<Array<T>>;
|
||||
orderBy(index: string | string[]): DexieCollection<T, TKey>;
|
||||
}
|
||||
|
||||
export interface DexieCollection<T = any, TKey = DexieIndexableType> {
|
||||
first(): DexiePromiseExtended<T | undefined>;
|
||||
or(indexOrPrimayKey: string): DexieWhereClause<T, TKey>;
|
||||
toArray(): DexiePromiseExtended<Array<T>>;
|
||||
reverse(): DexieCollection<T, TKey>;
|
||||
sortBy(keyPath: string): DexiePromiseExtended<T[]>;
|
||||
limit(n: number): DexieCollection<T, TKey>;
|
||||
delete(): DexiePromiseExtended<number>;
|
||||
}
|
||||
|
||||
export interface DexieWhereClause<T = any, TKey = DexieIndexableType> {
|
||||
startsWithIgnoreCase(key: string): DexieCollection<T, TKey>;
|
||||
below(key: any): DexieCollection<T, TKey>;
|
||||
between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): DexieCollection<T, TKey>;
|
||||
}
|
||||
|
||||
export type DexieThenShortcut<T, TResult> = (value: T) => TResult | PromiseLike<TResult>;
|
@ -1,6 +1,6 @@
|
||||
import debug from "debug";
|
||||
import { Table } from "dexie";
|
||||
import { unixNowMs, unwrap } from "./utils";
|
||||
import { DexieTableLike } from "./dexie-like";
|
||||
|
||||
type HookFn = () => void;
|
||||
|
||||
@ -19,11 +19,11 @@ export abstract class FeedCache<TCached> {
|
||||
#changed = true;
|
||||
#hits = 0;
|
||||
#miss = 0;
|
||||
protected table?: Table<TCached>;
|
||||
protected table?: DexieTableLike<TCached>;
|
||||
protected onTable: Set<string> = new Set();
|
||||
protected cache: Map<string, TCached> = new Map();
|
||||
|
||||
constructor(name: string, table?: Table<TCached>) {
|
||||
constructor(name: string, table?: DexieTableLike<TCached>) {
|
||||
this.#name = name;
|
||||
this.table = table;
|
||||
setInterval(() => {
|
||||
|
@ -4,3 +4,4 @@ export * from "./utils";
|
||||
export * from "./work-queue";
|
||||
export * from "./feed-cache";
|
||||
export * from "./invoices";
|
||||
export * from "./dexie-like";
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"target": "ES2020",
|
||||
"moduleResolution": "node",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"noImplicitOverride": true,
|
||||
"module": "CommonJS",
|
||||
"module": "NodeNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
@ -13,6 +13,6 @@
|
||||
"outDir": "dist",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"include": ["src/**/*.ts", "src/.d.ts"],
|
||||
"files": ["src/index.ts"]
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"target": "ES2020",
|
||||
"moduleResolution": "node",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"esModuleInterop": true,
|
||||
"noImplicitOverride": true,
|
||||
"module": "CommonJS",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"target": "ES2020",
|
||||
"moduleResolution": "node",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"noImplicitOverride": true,
|
||||
"module": "CommonJS",
|
||||
"module": "NodeNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
|
@ -36,7 +36,6 @@
|
||||
"@snort/shared": "^1.0.6",
|
||||
"@stablelib/xchacha20": "^1.0.1",
|
||||
"debug": "^4.3.4",
|
||||
"dexie": "^3.2.4",
|
||||
"isomorphic-ws": "^5.0.0",
|
||||
"uuid": "^9.0.0",
|
||||
"ws": "^8.14.0"
|
||||
|
14
packages/system/src/cache/db.ts
vendored
14
packages/system/src/cache/db.ts
vendored
@ -1,6 +1,6 @@
|
||||
import { DexieLike, DexieTableLike } from "@snort/shared";
|
||||
import { MetadataCache, RelayMetrics, UsersRelays } from ".";
|
||||
import { NostrEvent } from "../nostr";
|
||||
import Dexie, { Table } from "dexie";
|
||||
|
||||
const NAME = "snort-system";
|
||||
const VERSION = 2;
|
||||
@ -12,13 +12,13 @@ const STORES = {
|
||||
events: "++id, pubkey, created_at",
|
||||
};
|
||||
|
||||
export class SnortSystemDb extends Dexie {
|
||||
export class SnortSystemDb extends DexieLike {
|
||||
ready = false;
|
||||
users!: Table<MetadataCache>;
|
||||
relayMetrics!: Table<RelayMetrics>;
|
||||
userRelays!: Table<UsersRelays>;
|
||||
events!: Table<NostrEvent>;
|
||||
dms!: Table<NostrEvent>;
|
||||
users!: DexieTableLike<MetadataCache>;
|
||||
relayMetrics!: DexieTableLike<RelayMetrics>;
|
||||
userRelays!: DexieTableLike<UsersRelays>;
|
||||
events!: DexieTableLike<NostrEvent>;
|
||||
dms!: DexieTableLike<NostrEvent>;
|
||||
|
||||
constructor() {
|
||||
super(NAME);
|
||||
|
@ -344,7 +344,7 @@ export class Connection extends ExternalStore<ConnectionStateSnapshot> {
|
||||
|
||||
#sendJson(obj: object) {
|
||||
const authPending = !this.Authed && (this.AwaitingAuth.size > 0 || this.Info?.limitation?.auth_required === true);
|
||||
if (this.Socket?.readyState !== WebSocket.OPEN || authPending) {
|
||||
if (!this.Socket || this.Socket?.readyState !== WebSocket.OPEN || authPending) {
|
||||
this.PendingRaw.push(obj);
|
||||
if (this.Socket?.readyState === WebSocket.CLOSED && this.Ephemeral && this.IsClosed) {
|
||||
this.Connect();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { schnorr, secp256k1 } from "@noble/curves/secp256k1";
|
||||
import { Nip4WebCryptoEncryptor } from "../src/impl/nip4";
|
||||
import { Nip44Encryptor } from "../src/impl/nip44";
|
||||
import { XChaCha20Encryptor } from "../src/impl/nip44";
|
||||
import { bytesToHex } from "@noble/curves/abstract/utils";
|
||||
|
||||
const aKey = secp256k1.utils.randomPrivateKey();
|
||||
@ -14,12 +14,14 @@ describe("NIP-04", () => {
|
||||
const enc = new Nip4WebCryptoEncryptor();
|
||||
const sec = enc.getSharedSecret(bytesToHex(aKey), bytesToHex(bPubKey));
|
||||
|
||||
const ciphertext = await enc.encryptData(msg, sec);
|
||||
expect(ciphertext).toMatch(/^.*\?iv=.*$/i);
|
||||
const payload = await enc.encryptData(msg, sec);
|
||||
expect(payload).toHaveProperty("ciphertext");
|
||||
expect(payload).toHaveProperty("nonce");
|
||||
expect(payload.v).toBe(0);
|
||||
|
||||
const dec = new Nip4WebCryptoEncryptor();
|
||||
const sec2 = enc.getSharedSecret(bytesToHex(bKey), bytesToHex(aPubKey));
|
||||
const plaintext = await dec.decryptData(ciphertext, sec2);
|
||||
const plaintext = await dec.decryptData(payload, sec2);
|
||||
expect(plaintext).toEqual(msg);
|
||||
});
|
||||
});
|
||||
@ -27,18 +29,17 @@ describe("NIP-04", () => {
|
||||
describe("NIP-44", () => {
|
||||
it("should encrypt/decrypt", () => {
|
||||
const msg = "test hello, 123";
|
||||
const enc = new Nip44Encryptor();
|
||||
const enc = new XChaCha20Encryptor();
|
||||
const sec = enc.getSharedSecret(bytesToHex(aKey), bytesToHex(bPubKey));
|
||||
|
||||
const ciphertext = enc.encryptData(msg, sec);
|
||||
const jObj = JSON.parse(ciphertext);
|
||||
expect(jObj).toHaveProperty("ciphertext");
|
||||
expect(jObj).toHaveProperty("nonce");
|
||||
expect(jObj.v).toBe(1);
|
||||
const payload = enc.encryptData(msg, sec);
|
||||
expect(payload).toHaveProperty("ciphertext");
|
||||
expect(payload).toHaveProperty("nonce");
|
||||
expect(payload.v).toBe(1);
|
||||
|
||||
const dec = new Nip44Encryptor();
|
||||
const dec = new XChaCha20Encryptor();
|
||||
const sec2 = enc.getSharedSecret(bytesToHex(bKey), bytesToHex(aPubKey));
|
||||
const plaintext = dec.decryptData(ciphertext, sec2);
|
||||
const plaintext = dec.decryptData(payload, sec2);
|
||||
expect(plaintext).toEqual(msg);
|
||||
});
|
||||
});
|
||||
|
@ -64,50 +64,4 @@ describe("query", () => {
|
||||
q.sendToRelay(c2, qs);
|
||||
expect(q.progress).toBe(4 / 5);
|
||||
});
|
||||
|
||||
it("should merge all sub-query filters", () => {
|
||||
const q = new Query("test", "", new FlatNoteStore());
|
||||
const c0 = new Connection("wss://test.com", { read: true, write: true });
|
||||
q.sendToRelay(c0, {
|
||||
filters: [
|
||||
{
|
||||
authors: ["a"],
|
||||
kinds: [1],
|
||||
},
|
||||
],
|
||||
relay: "",
|
||||
strategy: RequestStrategy.DefaultRelays,
|
||||
});
|
||||
q.sendToRelay(c0, {
|
||||
filters: [
|
||||
{
|
||||
authors: ["b"],
|
||||
kinds: [1, 2],
|
||||
},
|
||||
],
|
||||
relay: "",
|
||||
strategy: RequestStrategy.DefaultRelays,
|
||||
});
|
||||
q.sendToRelay(c0, {
|
||||
filters: [
|
||||
{
|
||||
authors: ["c"],
|
||||
kinds: [2],
|
||||
},
|
||||
],
|
||||
relay: "",
|
||||
strategy: RequestStrategy.DefaultRelays,
|
||||
});
|
||||
|
||||
expect(q.filters).toEqual([
|
||||
{
|
||||
authors: ["a", "b"],
|
||||
kinds: [1],
|
||||
},
|
||||
{
|
||||
authors: ["b", "c"],
|
||||
kinds: [2],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { RelayCache } from "../src/gossip-model";
|
||||
import { RequestBuilder, RequestStrategy } from "../src/request-builder";
|
||||
import { describe, expect } from "@jest/globals";
|
||||
import { expandFilter } from "../src/request-expander";
|
||||
import { bytesToHex } from "@noble/curves/abstract/utils";
|
||||
import { unixNow, unixNowMs } from "@snort/shared";
|
||||
import { FeedCache, unixNow, unixNowMs } from "@snort/shared";
|
||||
import { NostrSystem, UsersRelays } from "../src";
|
||||
|
||||
const DummyCache = {
|
||||
getFromCache: (pk?: string) => {
|
||||
@ -23,7 +23,11 @@ const DummyCache = {
|
||||
],
|
||||
};
|
||||
},
|
||||
} as RelayCache;
|
||||
} as FeedCache<UsersRelays>;
|
||||
|
||||
const System = new NostrSystem({
|
||||
relayCache: DummyCache,
|
||||
});
|
||||
|
||||
describe("RequestBuilder", () => {
|
||||
describe("basic", () => {
|
||||
@ -95,7 +99,7 @@ describe("RequestBuilder", () => {
|
||||
f0.authors(["a"]);
|
||||
expect(a).toEqual([{}]);
|
||||
|
||||
const b = rb.buildDiff(DummyCache, a.flatMap(expandFilter));
|
||||
const b = rb.buildDiff(System, a);
|
||||
expect(b).toMatchObject([
|
||||
{
|
||||
filters: [{ authors: ["a"] }],
|
||||
@ -107,7 +111,7 @@ describe("RequestBuilder", () => {
|
||||
const rb = new RequestBuilder("test");
|
||||
rb.withFilter().authors(["a", "b"]).kinds([0]);
|
||||
|
||||
const a = rb.build(DummyCache);
|
||||
const a = rb.build(System);
|
||||
expect(a).toEqual([
|
||||
{
|
||||
strategy: RequestStrategy.AuthorsRelays,
|
||||
@ -138,7 +142,7 @@ describe("RequestBuilder", () => {
|
||||
rb.withFilter().authors(["a", "b"]).kinds([10002]);
|
||||
rb.withFilter().authors(["a"]).limit(10).kinds([4]);
|
||||
|
||||
const a = rb.build(DummyCache);
|
||||
const a = rb.build(System);
|
||||
expect(a).toEqual([
|
||||
{
|
||||
strategy: RequestStrategy.AuthorsRelays,
|
||||
@ -170,7 +174,7 @@ describe("RequestBuilder", () => {
|
||||
});
|
||||
|
||||
describe("build diff, large follow list", () => {
|
||||
const f = [];
|
||||
const f: Array<string> = [];
|
||||
for (let x = 0; x < 2500; x++) {
|
||||
const bytes = crypto.getRandomValues(new Uint8Array(32));
|
||||
f.push(bytesToHex(bytes));
|
||||
@ -180,7 +184,7 @@ describe("build diff, large follow list", () => {
|
||||
rb.withFilter().authors(f).kinds([1, 6, 10002, 3, 6969]);
|
||||
|
||||
const start = unixNowMs();
|
||||
const a = rb.build(DummyCache);
|
||||
const a = rb.build(System);
|
||||
expect(a).toEqual(
|
||||
f.map(a => {
|
||||
return {
|
||||
@ -198,7 +202,7 @@ describe("build diff, large follow list", () => {
|
||||
expect(unixNowMs() - start).toBeLessThan(500);
|
||||
|
||||
const start2 = unixNowMs();
|
||||
const b = rb.buildDiff(DummyCache, rb.buildRaw().flatMap(expandFilter));
|
||||
const b = rb.buildDiff(System, rb.buildRaw());
|
||||
expect(b).toEqual([]);
|
||||
expect(unixNowMs() - start2).toBeLessThan(100);
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { expandFilter } from "../src/request-expander";
|
||||
import { expandFilter } from "../src/query-optimizer/request-expander";
|
||||
|
||||
describe("RequestExpander", () => {
|
||||
test("expand filter", () => {
|
||||
|
@ -1,6 +1,13 @@
|
||||
import { ReqFilter } from "../src";
|
||||
import { canMergeFilters, filterIncludes, flatMerge, mergeSimilar, simpleMerge } from "../src/request-merger";
|
||||
import { FlatReqFilter, expandFilter } from "../src/request-expander";
|
||||
import {
|
||||
canMergeFilters,
|
||||
filterIncludes,
|
||||
flatMerge,
|
||||
mergeSimilar,
|
||||
simpleMerge,
|
||||
} from "../src/query-optimizer/request-merger";
|
||||
import { FlatReqFilter } from "../src/query-optimizer";
|
||||
import { expandFilter } from "../src/query-optimizer/request-expander";
|
||||
|
||||
describe("RequestMerger", () => {
|
||||
it("should simple merge authors", () => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ReqFilter } from "../src";
|
||||
import { describe, expect } from "@jest/globals";
|
||||
import { diffFilters } from "../src/request-splitter";
|
||||
import { expandFilter } from "../src/request-expander";
|
||||
import { diffFilters } from "../src/query-optimizer/request-splitter";
|
||||
import { expandFilter } from "../src/query-optimizer/request-expander";
|
||||
|
||||
describe("RequestSplitter", () => {
|
||||
test("single filter add value", () => {
|
||||
|
@ -1,17 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"target": "ES2020",
|
||||
"moduleResolution": "node",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"noImplicitOverride": true,
|
||||
"module": "CommonJS",
|
||||
"module": "NodeNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSourceMap": true,
|
||||
"outDir": "dist",
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"allowJs": true
|
||||
},
|
||||
"include": ["./src/**/*.ts"],
|
||||
"files": ["./src/index.ts"]
|
||||
|
76
yarn.lock
76
yarn.lock
@ -2715,7 +2715,6 @@ __metadata:
|
||||
css-minimizer-webpack-plugin: ^5.0.0
|
||||
debug: ^4.3.4
|
||||
dexie: ^3.2.4
|
||||
dns-over-http-resolver: ^2.1.1
|
||||
emojilib: ^3.0.10
|
||||
eslint: ^8.48.0
|
||||
eslint-webpack-plugin: ^4.0.1
|
||||
@ -2737,8 +2736,8 @@ __metadata:
|
||||
react-twitter-embed: ^4.0.4
|
||||
source-map-loader: ^4.0.1
|
||||
terser-webpack-plugin: ^5.3.9
|
||||
tinybench: ^2.5.0
|
||||
ts-jest: ^29.1.0
|
||||
tinybench: ^2.5.1
|
||||
ts-jest: ^29.1.1
|
||||
ts-loader: ^9.4.4
|
||||
typescript: ^5.2.2
|
||||
use-long-press: ^2.0.3
|
||||
@ -2765,7 +2764,6 @@ __metadata:
|
||||
"@scure/base": ^1.1.2
|
||||
"@types/debug": ^4.1.8
|
||||
debug: ^4.3.4
|
||||
dexie: ^3.2.4
|
||||
light-bolt11-decoder: ^3.0.0
|
||||
typescript: ^5.2.2
|
||||
languageName: unknown
|
||||
@ -2817,7 +2815,6 @@ __metadata:
|
||||
"@types/uuid": ^9.0.2
|
||||
"@types/ws": ^8.5.5
|
||||
debug: ^4.3.4
|
||||
dexie: ^3.2.4
|
||||
isomorphic-ws: ^5.0.0
|
||||
jest: ^29.5.0
|
||||
jest-environment-jsdom: ^29.5.0
|
||||
@ -4784,15 +4781,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"busboy@npm:^1.6.0":
|
||||
version: 1.6.0
|
||||
resolution: "busboy@npm:1.6.0"
|
||||
dependencies:
|
||||
streamsearch: ^1.1.0
|
||||
checksum: 32801e2c0164e12106bf236291a00795c3c4e4b709ae02132883fe8478ba2ae23743b11c5735a0aae8afe65ac4b6ca4568b91f0d9fed1fdbc32ede824a73746e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"bytes@npm:3.0.0":
|
||||
version: 3.0.0
|
||||
resolution: "bytes@npm:3.0.0"
|
||||
@ -5720,7 +5708,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4":
|
||||
"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4":
|
||||
version: 4.3.4
|
||||
resolution: "debug@npm:4.3.4"
|
||||
dependencies:
|
||||
@ -5931,18 +5919,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dns-over-http-resolver@npm:^2.1.1":
|
||||
version: 2.1.2
|
||||
resolution: "dns-over-http-resolver@npm:2.1.2"
|
||||
dependencies:
|
||||
debug: ^4.3.1
|
||||
native-fetch: ^4.0.2
|
||||
receptacle: ^1.3.2
|
||||
undici: ^5.12.0
|
||||
checksum: 7b02c87c843595245c6df16310c4507606802de999f8d271c553c7206e44e3f1f7552cdcabc3a0fde762525b7b0e7344fd77ea44d2ca61c6487d3ee4e777fda6
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dns-packet@npm:^5.2.2":
|
||||
version: 5.6.1
|
||||
resolution: "dns-packet@npm:5.6.1"
|
||||
@ -9628,7 +9604,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ms@npm:2.1.3, ms@npm:^2.0.0, ms@npm:^2.1.1":
|
||||
"ms@npm:2.1.3, ms@npm:^2.0.0":
|
||||
version: 2.1.3
|
||||
resolution: "ms@npm:2.1.3"
|
||||
checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d
|
||||
@ -9676,15 +9652,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"native-fetch@npm:^4.0.2":
|
||||
version: 4.0.2
|
||||
resolution: "native-fetch@npm:4.0.2"
|
||||
peerDependencies:
|
||||
undici: "*"
|
||||
checksum: 11e6d075aa03d40665a5fc438c56b535622fb4ee98eb2b035277c5ba47733cb4c7bc3ddb45e5ab8154869b509fc18ca1c0188ab271139ae89db14f9f552fc064
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"natural-compare@npm:^1.4.0":
|
||||
version: 1.4.0
|
||||
resolution: "natural-compare@npm:1.4.0"
|
||||
@ -11446,15 +11413,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"receptacle@npm:^1.3.2":
|
||||
version: 1.3.2
|
||||
resolution: "receptacle@npm:1.3.2"
|
||||
dependencies:
|
||||
ms: ^2.1.1
|
||||
checksum: 7c5011f19e6ddcb759c1e6756877cee3c9eb78fbd1278eca4572d75f74993f0ccdc1e5f7761de6e682dff5344ee94f7a69bc492e2e8eb81d8777774a2399ce9c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rechoir@npm:^0.6.2":
|
||||
version: 0.6.2
|
||||
resolution: "rechoir@npm:0.6.2"
|
||||
@ -12368,13 +12326,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"streamsearch@npm:^1.1.0":
|
||||
version: 1.1.0
|
||||
resolution: "streamsearch@npm:1.1.0"
|
||||
checksum: 1cce16cea8405d7a233d32ca5e00a00169cc0e19fbc02aa839959985f267335d435c07f96e5e0edd0eadc6d39c98d5435fb5bbbdefc62c41834eadc5622ad942
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"string-length@npm:^4.0.1":
|
||||
version: 4.0.2
|
||||
resolution: "string-length@npm:4.0.2"
|
||||
@ -12778,10 +12729,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tinybench@npm:^2.5.0":
|
||||
version: 2.5.0
|
||||
resolution: "tinybench@npm:2.5.0"
|
||||
checksum: 284bb9428f197ec8b869c543181315e65e41ccfdad3c4b6c916bb1fdae1b5c6785661b0d90cf135b48d833b03cb84dc5357b2d33ec65a1f5971fae0ab2023821
|
||||
"tinybench@npm:^2.5.1":
|
||||
version: 2.5.1
|
||||
resolution: "tinybench@npm:2.5.1"
|
||||
checksum: 6d98526c00b68b50ab0a37590b3cc6713b96fee7dd6756a2a77bab071ed1b4a4fc54e7b11e28b35ec2f761c6a806c2befa95f10acf2fee111c49327b6fc3386f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -12884,7 +12835,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ts-jest@npm:^29.1.0":
|
||||
"ts-jest@npm:^29.1.0, ts-jest@npm:^29.1.1":
|
||||
version: 29.1.1
|
||||
resolution: "ts-jest@npm:29.1.1"
|
||||
dependencies:
|
||||
@ -13128,15 +13079,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"undici@npm:^5.12.0":
|
||||
version: 5.23.0
|
||||
resolution: "undici@npm:5.23.0"
|
||||
dependencies:
|
||||
busboy: ^1.6.0
|
||||
checksum: 906ca4fb1d47163d2cee2ecbbc664a1d92508a2cdf1558146621109f525c983a83597910b36e6ba468240e95259be5939cea6babc99fc0c36360b16630f66784
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"unicode-canonical-property-names-ecmascript@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "unicode-canonical-property-names-ecmascript@npm:2.0.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user