@ocap/indexdb-memory 1.30.12 → 1.30.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/db/base.mjs +15 -36
- package/lib/db/base.cjs +14 -35
- package/package.json +5 -5
package/esm/db/base.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { name } from "../package.mjs";
|
|
2
|
-
import { BaseIndexDB, formatDelegationAfterRead, formatNextPagination, formatPagination, parseDateTime } from "@ocap/indexdb";
|
|
2
|
+
import { BaseIndexDB, formatDelegationAfterRead, formatNextPagination, formatPagination, formatSearchResult, parseDateTime } from "@ocap/indexdb";
|
|
3
3
|
import debugFactory from "debug";
|
|
4
4
|
import { toChecksumAddress } from "@arcblock/did/lib/type";
|
|
5
5
|
import { BN } from "@ocap/util";
|
|
@@ -456,9 +456,10 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
456
456
|
const score = Math.max(nameScore, symbolScore, descScore);
|
|
457
457
|
const title = nameScore >= symbolScore ? row.name || row.symbol || "" : row.symbol || row.name || "";
|
|
458
458
|
results.push({
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
...formatSearchResult("token", {
|
|
460
|
+
...row,
|
|
461
|
+
title
|
|
462
|
+
}),
|
|
462
463
|
score,
|
|
463
464
|
priority: typePriority.token
|
|
464
465
|
});
|
|
@@ -470,9 +471,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
470
471
|
for (const row of accountMatches) {
|
|
471
472
|
const score = scoreMatch(row.moniker, lowerKw);
|
|
472
473
|
results.push({
|
|
473
|
-
|
|
474
|
-
id: row.address,
|
|
475
|
-
title: row.moniker || "",
|
|
474
|
+
...formatSearchResult("account", row),
|
|
476
475
|
score,
|
|
477
476
|
priority: typePriority.account
|
|
478
477
|
});
|
|
@@ -487,9 +486,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
487
486
|
const descScore = row.description ? scoreMatch(row.description, lowerKw) : 0;
|
|
488
487
|
const score = Math.max(nameScore, descScore);
|
|
489
488
|
results.push({
|
|
490
|
-
|
|
491
|
-
id: row.address,
|
|
492
|
-
title: row.name || "",
|
|
489
|
+
...formatSearchResult("factory", row),
|
|
493
490
|
score,
|
|
494
491
|
priority: typePriority.factory
|
|
495
492
|
});
|
|
@@ -505,9 +502,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
505
502
|
const tagScore = Array.isArray(tags) ? Math.max(0, ...tags.map((t) => scoreMatch(t, lowerKw))) : 0;
|
|
506
503
|
const score = Math.max(monikerScore, tagScore);
|
|
507
504
|
results.push({
|
|
508
|
-
|
|
509
|
-
id: row.address,
|
|
510
|
-
title: row.moniker || "",
|
|
505
|
+
...formatSearchResult("asset", row),
|
|
511
506
|
score,
|
|
512
507
|
priority: typePriority.asset
|
|
513
508
|
});
|
|
@@ -523,9 +518,10 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
523
518
|
const score = Math.max(nameScore, monikerScore);
|
|
524
519
|
const title = nameScore >= monikerScore ? row.name || row.moniker || "" : row.moniker || row.name || "";
|
|
525
520
|
results.push({
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
521
|
+
...formatSearchResult("tokenFactory", {
|
|
522
|
+
...row,
|
|
523
|
+
title
|
|
524
|
+
}),
|
|
529
525
|
score,
|
|
530
526
|
priority: typePriority.tokenFactory
|
|
531
527
|
});
|
|
@@ -537,9 +533,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
537
533
|
for (const row of stakeMatches) {
|
|
538
534
|
const score = scoreMatch(row.message, lowerKw);
|
|
539
535
|
results.push({
|
|
540
|
-
|
|
541
|
-
id: row.address,
|
|
542
|
-
title: row.message || "",
|
|
536
|
+
...formatSearchResult("stake", row),
|
|
543
537
|
score,
|
|
544
538
|
priority: typePriority.stake
|
|
545
539
|
});
|
|
@@ -548,14 +542,6 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
548
542
|
const didPrefix = trimmed.replace(/^did:abt:/i, "");
|
|
549
543
|
if (didPrefix.length >= 4) {
|
|
550
544
|
const seen = new Set(results.map((r) => `${r.type}:${r.id}`));
|
|
551
|
-
const titleField = {
|
|
552
|
-
account: "moniker",
|
|
553
|
-
token: "name",
|
|
554
|
-
asset: "moniker",
|
|
555
|
-
factory: "name",
|
|
556
|
-
tokenFactory: "name",
|
|
557
|
-
stake: "message"
|
|
558
|
-
};
|
|
559
545
|
const collections = [
|
|
560
546
|
{
|
|
561
547
|
collection: this.account,
|
|
@@ -592,11 +578,8 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
592
578
|
const key = `${type}:${addr}`;
|
|
593
579
|
if (!seen.has(key)) {
|
|
594
580
|
seen.add(key);
|
|
595
|
-
const title = row[titleField[type]] || addr;
|
|
596
581
|
results.push({
|
|
597
|
-
type,
|
|
598
|
-
id: addr,
|
|
599
|
-
title,
|
|
582
|
+
...formatSearchResult(type, row, { id: addr }),
|
|
600
583
|
score: 2,
|
|
601
584
|
priority: typePriority[type] ?? 99
|
|
602
585
|
});
|
|
@@ -606,11 +589,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
|
|
|
606
589
|
}
|
|
607
590
|
}
|
|
608
591
|
results.sort((a, b) => b.score - a.score || a.priority - b.priority);
|
|
609
|
-
return results.map(({
|
|
610
|
-
type,
|
|
611
|
-
id,
|
|
612
|
-
title
|
|
613
|
-
}));
|
|
592
|
+
return results.map(({ score, priority, ...result }) => result);
|
|
614
593
|
}
|
|
615
594
|
};
|
|
616
595
|
var base_default = LocalBaseIndexDB;
|
package/lib/db/base.cjs
CHANGED
|
@@ -460,9 +460,10 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
460
460
|
const score = Math.max(nameScore, symbolScore, descScore);
|
|
461
461
|
const title = nameScore >= symbolScore ? row.name || row.symbol || "" : row.symbol || row.name || "";
|
|
462
462
|
results.push({
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
463
|
+
...(0, _ocap_indexdb.formatSearchResult)("token", {
|
|
464
|
+
...row,
|
|
465
|
+
title
|
|
466
|
+
}),
|
|
466
467
|
score,
|
|
467
468
|
priority: typePriority.token
|
|
468
469
|
});
|
|
@@ -474,9 +475,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
474
475
|
for (const row of accountMatches) {
|
|
475
476
|
const score = scoreMatch(row.moniker, lowerKw);
|
|
476
477
|
results.push({
|
|
477
|
-
|
|
478
|
-
id: row.address,
|
|
479
|
-
title: row.moniker || "",
|
|
478
|
+
...(0, _ocap_indexdb.formatSearchResult)("account", row),
|
|
480
479
|
score,
|
|
481
480
|
priority: typePriority.account
|
|
482
481
|
});
|
|
@@ -491,9 +490,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
491
490
|
const descScore = row.description ? scoreMatch(row.description, lowerKw) : 0;
|
|
492
491
|
const score = Math.max(nameScore, descScore);
|
|
493
492
|
results.push({
|
|
494
|
-
|
|
495
|
-
id: row.address,
|
|
496
|
-
title: row.name || "",
|
|
493
|
+
...(0, _ocap_indexdb.formatSearchResult)("factory", row),
|
|
497
494
|
score,
|
|
498
495
|
priority: typePriority.factory
|
|
499
496
|
});
|
|
@@ -509,9 +506,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
509
506
|
const tagScore = Array.isArray(tags) ? Math.max(0, ...tags.map((t) => scoreMatch(t, lowerKw))) : 0;
|
|
510
507
|
const score = Math.max(monikerScore, tagScore);
|
|
511
508
|
results.push({
|
|
512
|
-
|
|
513
|
-
id: row.address,
|
|
514
|
-
title: row.moniker || "",
|
|
509
|
+
...(0, _ocap_indexdb.formatSearchResult)("asset", row),
|
|
515
510
|
score,
|
|
516
511
|
priority: typePriority.asset
|
|
517
512
|
});
|
|
@@ -527,9 +522,10 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
527
522
|
const score = Math.max(nameScore, monikerScore);
|
|
528
523
|
const title = nameScore >= monikerScore ? row.name || row.moniker || "" : row.moniker || row.name || "";
|
|
529
524
|
results.push({
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
525
|
+
...(0, _ocap_indexdb.formatSearchResult)("tokenFactory", {
|
|
526
|
+
...row,
|
|
527
|
+
title
|
|
528
|
+
}),
|
|
533
529
|
score,
|
|
534
530
|
priority: typePriority.tokenFactory
|
|
535
531
|
});
|
|
@@ -541,9 +537,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
541
537
|
for (const row of stakeMatches) {
|
|
542
538
|
const score = scoreMatch(row.message, lowerKw);
|
|
543
539
|
results.push({
|
|
544
|
-
|
|
545
|
-
id: row.address,
|
|
546
|
-
title: row.message || "",
|
|
540
|
+
...(0, _ocap_indexdb.formatSearchResult)("stake", row),
|
|
547
541
|
score,
|
|
548
542
|
priority: typePriority.stake
|
|
549
543
|
});
|
|
@@ -552,14 +546,6 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
552
546
|
const didPrefix = trimmed.replace(/^did:abt:/i, "");
|
|
553
547
|
if (didPrefix.length >= 4) {
|
|
554
548
|
const seen = new Set(results.map((r) => `${r.type}:${r.id}`));
|
|
555
|
-
const titleField = {
|
|
556
|
-
account: "moniker",
|
|
557
|
-
token: "name",
|
|
558
|
-
asset: "moniker",
|
|
559
|
-
factory: "name",
|
|
560
|
-
tokenFactory: "name",
|
|
561
|
-
stake: "message"
|
|
562
|
-
};
|
|
563
549
|
const collections = [
|
|
564
550
|
{
|
|
565
551
|
collection: this.account,
|
|
@@ -596,11 +582,8 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
596
582
|
const key = `${type}:${addr}`;
|
|
597
583
|
if (!seen.has(key)) {
|
|
598
584
|
seen.add(key);
|
|
599
|
-
const title = row[titleField[type]] || addr;
|
|
600
585
|
results.push({
|
|
601
|
-
type,
|
|
602
|
-
id: addr,
|
|
603
|
-
title,
|
|
586
|
+
...(0, _ocap_indexdb.formatSearchResult)(type, row, { id: addr }),
|
|
604
587
|
score: 2,
|
|
605
588
|
priority: typePriority[type] ?? 99
|
|
606
589
|
});
|
|
@@ -610,11 +593,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
610
593
|
}
|
|
611
594
|
}
|
|
612
595
|
results.sort((a, b) => b.score - a.score || a.priority - b.priority);
|
|
613
|
-
return results.map(({
|
|
614
|
-
type,
|
|
615
|
-
id,
|
|
616
|
-
title
|
|
617
|
-
}));
|
|
596
|
+
return results.map(({ score, priority, ...result }) => result);
|
|
618
597
|
}
|
|
619
598
|
};
|
|
620
599
|
var base_default = LocalBaseIndexDB;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/indexdb-memory",
|
|
3
3
|
"description": "OCAP indexdb adapter that uses memory as backend, just for test purpose",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.13",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
|
|
7
7
|
"bugs": {
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
},
|
|
79
79
|
"gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@arcblock/did": "1.30.
|
|
82
|
-
"@ocap/indexdb": "1.30.
|
|
83
|
-
"@ocap/types": "1.30.
|
|
84
|
-
"@ocap/util": "1.30.
|
|
81
|
+
"@arcblock/did": "1.30.13",
|
|
82
|
+
"@ocap/indexdb": "1.30.13",
|
|
83
|
+
"@ocap/types": "1.30.13",
|
|
84
|
+
"@ocap/util": "1.30.13",
|
|
85
85
|
"debug": "^4.4.3",
|
|
86
86
|
"lodash": "^4.17.23",
|
|
87
87
|
"lokijs": "^1.5.12"
|