@peerbit/indexer-interface
Advanced tools
Comparing version 1.1.0 to 1.1.1-01f2c90
@@ -48,3 +48,3 @@ import type { AbstractType } from "@dao-xyz/borsh"; | ||
export type ReturnTypeFromShape<T, S> = S extends Shape ? ShapeReturnType<S> : T; | ||
export type IndexIterator<T, S extends Shape | undefined> = { | ||
export type IndexIterator<T extends Record<string, any>, S extends Shape | undefined> = { | ||
next: (amount: number) => MaybePromise<IndexedResults<ReturnTypeFromShape<T, S>>>; | ||
@@ -74,3 +74,3 @@ all: () => MaybePromise<IndexedResults<ReturnTypeFromShape<T, S>>>; | ||
} | ||
export declare const iteratorInSeries: <T, S extends Shape | undefined>(...iterators: IndexIterator<T, S>[]) => IndexIterator<T, S>; | ||
export declare const iteratorInSeries: <T extends Record<string, any>, S extends Shape | undefined>(...iterators: IndexIterator<T, S>[]) => IndexIterator<T, S>; | ||
export interface Indices { | ||
@@ -77,0 +77,0 @@ init<T extends Record<string, any>, NestedType>(properties: IndexEngineInitProperties<T, NestedType>): MaybePromise<Index<T, NestedType>>; |
import {} from "./id.js"; | ||
/* | ||
export type IndexIterator<T> = ReturnType<typeof iterate<T>>; | ||
export const iterate = <T>(index: Index<T, any>, query: SearchRequest) => { | ||
let isDone = false; | ||
let fetchedOnce = false; | ||
const next = async (count: number, options?: { shape?: Shape }) => { | ||
let res: IndexedResults<T>; | ||
if (!fetchedOnce) { | ||
fetchedOnce = true; | ||
query.fetch = count; | ||
res = await index.query(query, options); | ||
} else { | ||
res = await index.next( | ||
new CollectNextRequest({ id: query.id, amount: count }), | ||
options, | ||
); | ||
} | ||
isDone = res.kept === 0; | ||
return res; | ||
}; | ||
const done = () => isDone; | ||
const close = () => { | ||
return index.close(new CloseIteratorRequest({ id: query.id })); | ||
}; | ||
return { | ||
next, | ||
done, | ||
close, | ||
all: async (options?: { shape: Shape }) => { | ||
const results: IndexedResult<T>[] = []; | ||
while (!done()) { | ||
for (const element of (await next(100, options)).results) { | ||
results.push(element); | ||
} | ||
} | ||
await close(); | ||
return results; | ||
}, | ||
}; | ||
}; | ||
export type ResultsIterator<T> = ReturnType<typeof iterate<T>>; */ | ||
export const iteratorInSeries = (...iterators) => { | ||
@@ -45,0 +3,0 @@ let i = 0; |
126
package.json
{ | ||
"name": "@peerbit/indexer-interface", | ||
"version": "1.1.0", | ||
"description": "Indexer store interface", | ||
"sideEffects": false, | ||
"type": "module", | ||
"types": "./dist/src/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
], | ||
"src/*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"src", | ||
"dist", | ||
"!dist/e2e", | ||
"!dist/test", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./dist/src/index.js" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": "peerbit", | ||
"parserOptions": { | ||
"project": true, | ||
"sourceType": "module" | ||
}, | ||
"ignorePatterns": [ | ||
"!.aegir.js", | ||
"test/ts-use", | ||
"*.d.ts" | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"clean": "aegir clean", | ||
"build": "aegir build --no-bundle", | ||
"test": "aegir test", | ||
"lint": "aegir lint" | ||
}, | ||
"author": "dao.xyz", | ||
"license": "MIT", | ||
"dependencies": { | ||
"uuid": "^10.0.0", | ||
"@dao-xyz/borsh": "^5.2.3", | ||
"@peerbit/crypto": "^2.3.2" | ||
} | ||
"name": "@peerbit/indexer-interface", | ||
"version": "1.1.1-01f2c90", | ||
"description": "Indexer store interface", | ||
"sideEffects": false, | ||
"type": "module", | ||
"types": "./dist/src/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
], | ||
"src/*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"src", | ||
"dist", | ||
"!dist/e2e", | ||
"!dist/test", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./dist/src/index.js" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": "peerbit", | ||
"parserOptions": { | ||
"project": true, | ||
"sourceType": "module" | ||
}, | ||
"ignorePatterns": [ | ||
"!.aegir.js", | ||
"test/ts-use", | ||
"*.d.ts" | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"clean": "aegir clean", | ||
"build": "aegir build --no-bundle", | ||
"test": "aegir test", | ||
"lint": "aegir lint" | ||
}, | ||
"author": "dao.xyz", | ||
"license": "MIT", | ||
"dependencies": { | ||
"uuid": "^10.0.0", | ||
"@dao-xyz/borsh": "^5.2.3", | ||
"@peerbit/crypto": "2.3.2-01f2c90" | ||
} | ||
} |
@@ -96,3 +96,3 @@ import { field, variant } from "@dao-xyz/borsh"; | ||
private _keyString: string; | ||
private _keyString!: string; | ||
get primitive(): string { | ||
@@ -99,0 +99,0 @@ return this._keyString || (this._keyString = toBase64(this.key)); |
@@ -81,3 +81,6 @@ import type { AbstractType } from "@dao-xyz/borsh"; | ||
export type IndexIterator<T, S extends Shape | undefined> = { | ||
export type IndexIterator< | ||
T extends Record<string, any>, | ||
S extends Shape | undefined, | ||
> = { | ||
next: ( | ||
@@ -109,17 +112,3 @@ amount: number, | ||
): IndexIterator<T, S>; | ||
/* query<O extends { shape?: Shape } | undefined>( | ||
query: SearchRequest, | ||
options?: O & { reference?: boolean }, | ||
): MaybePromise<IndexedResults<O extends { shape: infer S extends Shape } ? ShapeReturnType<S> : T>>; | ||
next<O extends { shape?: Shape } | undefined>( | ||
query: CollectNextRequest, | ||
options?: O | ||
): MaybePromise<IndexedResults<O extends { shape: infer S extends Shape } ? ShapeReturnType<S> : T>> | ||
close(query: CloseIteratorRequest): MaybePromise<void>;; */ | ||
/* | ||
query<O extends QueryOptions>(query: SearchRequest, options?: O): MaybePromise<IndexedResults<ReturnTypeFromQueryOptions<T, O>>>; | ||
next<O extends QueryOptions>(query: CollectNextRequest, options?: O): MaybePromise<IndexedResults<ReturnTypeFromQueryOptions<T, O>>>; | ||
*/ | ||
getSize(): MaybePromise<number>; | ||
@@ -129,46 +118,7 @@ start(): MaybePromise<void>; | ||
} | ||
/* | ||
export type IndexIterator<T> = ReturnType<typeof iterate<T>>; | ||
export const iterate = <T>(index: Index<T, any>, query: SearchRequest) => { | ||
let isDone = false; | ||
let fetchedOnce = false; | ||
const next = async (count: number, options?: { shape?: Shape }) => { | ||
let res: IndexedResults<T>; | ||
if (!fetchedOnce) { | ||
fetchedOnce = true; | ||
query.fetch = count; | ||
res = await index.query(query, options); | ||
} else { | ||
res = await index.next( | ||
new CollectNextRequest({ id: query.id, amount: count }), | ||
options, | ||
); | ||
} | ||
isDone = res.kept === 0; | ||
return res; | ||
}; | ||
const done = () => isDone; | ||
const close = () => { | ||
return index.close(new CloseIteratorRequest({ id: query.id })); | ||
}; | ||
return { | ||
next, | ||
done, | ||
close, | ||
all: async (options?: { shape: Shape }) => { | ||
const results: IndexedResult<T>[] = []; | ||
while (!done()) { | ||
for (const element of (await next(100, options)).results) { | ||
results.push(element); | ||
} | ||
} | ||
await close(); | ||
return results; | ||
}, | ||
}; | ||
}; | ||
export type ResultsIterator<T> = ReturnType<typeof iterate<T>>; */ | ||
export const iteratorInSeries = <T, S extends Shape | undefined>( | ||
export const iteratorInSeries = < | ||
T extends Record<string, any>, | ||
S extends Shape | undefined, | ||
>( | ||
...iterators: IndexIterator<T, S>[] | ||
@@ -175,0 +125,0 @@ ): IndexIterator<T, S> => { |
@@ -156,3 +156,3 @@ import { deserialize, field, serialize, variant, vec } from "@dao-xyz/borsh"; | ||
_valueString: string; | ||
_valueString!: string; | ||
/** | ||
@@ -159,0 +159,0 @@ * value `asString` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
80305
1766
2
+ Added@peerbit/cache@2.1.0-01f2c90(transitive)
+ Added@peerbit/crypto@2.3.2-01f2c90(transitive)
- Removed@peerbit/cache@2.1.2(transitive)
- Removed@peerbit/crypto@2.3.5(transitive)