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