try again
This commit is contained in:
parent
3bd52e9672
commit
356d8f1503
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/lingdocs-main",
|
||||
"version": "0.2.6",
|
||||
"version": "0.2.7",
|
||||
"description": "types and functions for lingdocs stuff",
|
||||
"main": "dist/library.js",
|
||||
"module": "dist/library.js",
|
||||
|
|
|
@ -92,7 +92,7 @@ export class DictionaryDb {
|
|||
unique: ["ts"],
|
||||
});
|
||||
this.collection.insert(dictionary.entries);
|
||||
this.lokidb.saveDatabase((err) => {
|
||||
this.lokidb.saveDatabase((err: any) => {
|
||||
/* istanbul ignore next */
|
||||
if (err) {
|
||||
console.error("error saving database: " + err);
|
||||
|
|
|
@ -31,6 +31,22 @@ const dictionaryCollectionName = "dictionary3";
|
|||
// const dictionaryDatabaseName = "dictdb.db";
|
||||
export const pageSize = 35;
|
||||
|
||||
export type DictionaryAPI = {
|
||||
initialize: () => Promise<{
|
||||
response: "loaded first time" | "loaded from saved",
|
||||
dictionaryInfo: T.DictionaryInfo,
|
||||
}>,
|
||||
update: (updateComing: () => void) => Promise<{
|
||||
response: "no need for update" | "updated" | "unable to check",
|
||||
dictionaryInfo: T.DictionaryInfo,
|
||||
}>,
|
||||
search: (state: State) => T.DictionaryEntry[],
|
||||
exactPashtoSearch: (search: string) => T.DictionaryEntry[],
|
||||
getNewWordsThisMonth: () => T.DictionaryEntry[],
|
||||
findOneByTs: (ts: number) => T.DictionaryEntry | undefined,
|
||||
findRelatedEntries: (entry: T.DictionaryEntry) => T.DictionaryEntry[],
|
||||
}
|
||||
|
||||
const relevancySorter = new relevancy.Sorter();
|
||||
|
||||
const db = indexedDB.open('inPrivate');
|
||||
|
@ -101,7 +117,7 @@ function alphabeticalLookup({ searchString, page }: {
|
|||
page: number,
|
||||
}): T.DictionaryEntry[] {
|
||||
const r = new RegExp("^" + sanitizePashto(makeSearchStringSafe(searchString)));
|
||||
const regexResults = dictDb.collection.find({
|
||||
const regexResults: T.DictionaryEntry[] = dictDb.collection.find({
|
||||
$or: [
|
||||
{p: { $regex: r }},
|
||||
{g: { $regex: r }},
|
||||
|
@ -155,7 +171,7 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
|
|||
.limit(exactResultsLimit)
|
||||
.simplesort("i")
|
||||
.data();
|
||||
resultsGiven = exactResults.map((mpd) => mpd.$loki);
|
||||
resultsGiven = exactResults.map((mpd: any) => mpd.$loki);
|
||||
// get results with full word match at beginning of string
|
||||
const startingQuery = {
|
||||
e: {
|
||||
|
@ -169,7 +185,7 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
|
|||
.limit(startingResultsLimit)
|
||||
.simplesort("i")
|
||||
.data();
|
||||
resultsGiven = [...resultsGiven, ...startingResults.map((mpd) => mpd.$loki)];
|
||||
resultsGiven = [...resultsGiven, ...startingResults.map((mpd: any) => mpd.$loki)];
|
||||
// get results with full word match anywhere
|
||||
const fullWordQuery = {
|
||||
e: {
|
||||
|
@ -183,7 +199,7 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
|
|||
.limit(fullWordResultsLimit)
|
||||
.simplesort("i")
|
||||
.data();
|
||||
resultsGiven = [...resultsGiven, ...fullWordResults.map((mpd) => mpd.$loki)]
|
||||
resultsGiven = [...resultsGiven, ...fullWordResults.map((mpd: any) => mpd.$loki)]
|
||||
// get results with partial match anywhere
|
||||
const partialMatchQuery = {
|
||||
e: {
|
||||
|
|
|
@ -92,22 +92,6 @@ type TextOptionsAction = {
|
|||
payload: boolean,
|
||||
};
|
||||
|
||||
type DictionaryAPI = {
|
||||
initialize: () => Promise<{
|
||||
response: "loaded first time" | "loaded from saved",
|
||||
dictionaryInfo: import("@lingdocs/pashto-inflector").Types.DictionaryInfo,
|
||||
}>,
|
||||
update: (updateComing: () => void) => Promise<{
|
||||
response: "no need for update" | "updated" | "unable to check",
|
||||
dictionaryInfo: import("@lingdocs/pashto-inflector").Types.DictionaryInfo,
|
||||
}>,
|
||||
search: (state: State) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[],
|
||||
exactPashtoSearch: (search: string) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[],
|
||||
getNewWordsThisMonth: () => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[],
|
||||
findOneByTs: (ts: number) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry | undefined,
|
||||
findRelatedEntries: (entry: import("@lingdocs/pashto-inflector").Types.DictionaryEntry) => import("@lingdocs/pashto-inflector").Types.DictionaryEntry[],
|
||||
}
|
||||
|
||||
type AttachmentToPut = {
|
||||
content_type: string,
|
||||
data: string | blob,
|
||||
|
|
Loading…
Reference in New Issue