@ocap/indexdb-sqlite 1.30.14 → 1.30.15
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 +14 -22
- package/lib/db/base.cjs +14 -22
- package/package.json +5 -5
package/esm/db/base.mjs
CHANGED
|
@@ -759,12 +759,12 @@ var SqliteBaseIndexDB = class extends BaseIndexDB {
|
|
|
759
759
|
const doDidSearch = isDidLike && didPrefix.length >= 4;
|
|
760
760
|
const queries = [
|
|
761
761
|
sql`
|
|
762
|
-
SELECT address, name, symbol, description, totalSupply, issuer, type, renaissanceTime, genesisTime FROM token
|
|
762
|
+
SELECT address, name, symbol, description, decimal, totalSupply, issuer, type, renaissanceTime, genesisTime FROM token
|
|
763
763
|
WHERE LOWER(name) LIKE LOWER(${containsPattern}) ESCAPE '\\' OR LOWER(symbol) LIKE LOWER(${containsPattern}) ESCAPE '\\' OR LOWER(description) LIKE LOWER(${containsPattern}) ESCAPE '\\'
|
|
764
764
|
LIMIT ${limit}
|
|
765
765
|
`.execute(this.db),
|
|
766
766
|
sql`
|
|
767
|
-
SELECT address, moniker, numTxs, numAssets,
|
|
767
|
+
SELECT address, moniker, numTxs, numAssets, tokens, renaissanceTime, genesisTime FROM account
|
|
768
768
|
WHERE LOWER(moniker) LIKE LOWER(${containsPattern}) ESCAPE '\\'
|
|
769
769
|
LIMIT ${limit}
|
|
770
770
|
`.execute(this.db),
|
|
@@ -779,7 +779,7 @@ var SqliteBaseIndexDB = class extends BaseIndexDB {
|
|
|
779
779
|
LIMIT ${limit}
|
|
780
780
|
`.execute(this.db),
|
|
781
781
|
sql`
|
|
782
|
-
SELECT address, name, moniker, status, currentSupply, reserveBalance, tokenAddress, reserveAddress, renaissanceTime, genesisTime FROM tokenFactory
|
|
782
|
+
SELECT address, name, moniker, status, currentSupply, reserveBalance, tokenAddress, reserveAddress, token, reserveToken, renaissanceTime, genesisTime FROM tokenFactory
|
|
783
783
|
WHERE LOWER(name) LIKE LOWER(${containsPattern}) ESCAPE '\\' OR LOWER(moniker) LIKE LOWER(${containsPattern}) ESCAPE '\\'
|
|
784
784
|
LIMIT ${limit}
|
|
785
785
|
`.execute(this.db),
|
|
@@ -792,12 +792,12 @@ var SqliteBaseIndexDB = class extends BaseIndexDB {
|
|
|
792
792
|
if (doDidSearch) {
|
|
793
793
|
const prefixPattern = `${escapeLikePattern(didPrefix)}%`;
|
|
794
794
|
queries.push(sql`
|
|
795
|
-
SELECT * FROM (SELECT address, 'account' as
|
|
796
|
-
UNION ALL SELECT * FROM (SELECT address, 'token',
|
|
797
|
-
UNION ALL SELECT * FROM (SELECT address, 'asset', COALESCE(moniker, address), moniker, NULL, NULL, NULL, tags, NULL, NULL, NULL,
|
|
798
|
-
UNION ALL SELECT * FROM (SELECT address, 'factory', COALESCE(name, address), NULL, name, NULL, description, NULL, NULL, NULL, NULL,
|
|
799
|
-
UNION ALL SELECT * FROM (SELECT address, 'tokenFactory',
|
|
800
|
-
UNION ALL SELECT * FROM (SELECT address, 'stake', COALESCE(message, address), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, sender, receiver, revocable, NULL, renaissanceTime, genesisTime FROM stake WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
795
|
+
SELECT * FROM (SELECT address, 'account' as entityType, COALESCE(moniker, address) as title, moniker, NULL as name, NULL as symbol, NULL as description, NULL as tags, numTxs, numAssets, NULL as owner, NULL as parent, NULL as issuer, NULL as totalSupply, NULL as decimal, NULL as status, NULL as currentSupply, NULL as reserveBalance, NULL as tokenAddress, NULL as reserveAddress, NULL as token, NULL as reserveToken, NULL as sender, NULL as receiver, NULL as revocable, NULL as consumedTime, tokens, renaissanceTime, genesisTime, NULL as type FROM account WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
796
|
+
UNION ALL SELECT * FROM (SELECT address, 'token', NULL, NULL, name, symbol, description, NULL, NULL, NULL, NULL, NULL, issuer, totalSupply, decimal, NULL, NULL, NULL, tokenFactoryAddress, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, renaissanceTime, genesisTime, type FROM token WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
797
|
+
UNION ALL SELECT * FROM (SELECT address, 'asset', COALESCE(moniker, address), moniker, NULL, NULL, NULL, tags, NULL, NULL, owner, parent, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, consumedTime, NULL, renaissanceTime, genesisTime, NULL FROM asset WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
798
|
+
UNION ALL SELECT * FROM (SELECT address, 'factory', COALESCE(name, address), NULL, name, NULL, description, NULL, NULL, NULL, owner, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, renaissanceTime, genesisTime, NULL FROM factory WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
799
|
+
UNION ALL SELECT * FROM (SELECT address, 'tokenFactory', NULL, moniker, name, NULL, description, NULL, NULL, NULL, owner, NULL, NULL, NULL, NULL, status, currentSupply, reserveBalance, tokenAddress, reserveAddress, token, reserveToken, NULL, NULL, NULL, NULL, NULL, renaissanceTime, genesisTime, NULL FROM tokenFactory WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
800
|
+
UNION ALL SELECT * FROM (SELECT address, 'stake', COALESCE(message, address), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, sender, receiver, revocable, NULL, NULL, renaissanceTime, genesisTime, NULL FROM stake WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
801
801
|
`.execute(this.db));
|
|
802
802
|
}
|
|
803
803
|
const allResults = await Promise.all(queries);
|
|
@@ -808,12 +808,8 @@ var SqliteBaseIndexDB = class extends BaseIndexDB {
|
|
|
808
808
|
const symbolScore = row.symbol ? scoreMatch(row.symbol, lowerKw) : 0;
|
|
809
809
|
const descScore = row.description ? scoreMatch(row.description, lowerKw) : 0;
|
|
810
810
|
const score = Math.max(nameScore, symbolScore, descScore);
|
|
811
|
-
const title = nameScore >= symbolScore ? row.name || row.symbol || "" : row.symbol || row.name || "";
|
|
812
811
|
results.push({
|
|
813
|
-
...formatSearchResult("token",
|
|
814
|
-
...row,
|
|
815
|
-
title
|
|
816
|
-
}),
|
|
812
|
+
...formatSearchResult("token", row),
|
|
817
813
|
score,
|
|
818
814
|
priority: typePriority.token
|
|
819
815
|
});
|
|
@@ -854,12 +850,8 @@ var SqliteBaseIndexDB = class extends BaseIndexDB {
|
|
|
854
850
|
const nameScore = row.name ? scoreMatch(row.name, lowerKw) : 0;
|
|
855
851
|
const monikerScore = row.moniker ? scoreMatch(row.moniker, lowerKw) : 0;
|
|
856
852
|
const score = Math.max(nameScore, monikerScore);
|
|
857
|
-
const title = nameScore >= monikerScore ? row.name || row.moniker || "" : row.moniker || row.name || "";
|
|
858
853
|
results.push({
|
|
859
|
-
...formatSearchResult("tokenFactory",
|
|
860
|
-
...row,
|
|
861
|
-
title
|
|
862
|
-
}),
|
|
854
|
+
...formatSearchResult("tokenFactory", row),
|
|
863
855
|
score,
|
|
864
856
|
priority: typePriority.tokenFactory
|
|
865
857
|
});
|
|
@@ -876,13 +868,13 @@ var SqliteBaseIndexDB = class extends BaseIndexDB {
|
|
|
876
868
|
const didRows = allResults[6];
|
|
877
869
|
const seen = new Set(results.map((r) => `${r.type}:${r.id}`));
|
|
878
870
|
for (const row of didRows.rows) {
|
|
879
|
-
const key = `${row.
|
|
871
|
+
const key = `${row.entityType}:${row.address}`;
|
|
880
872
|
if (!seen.has(key)) {
|
|
881
873
|
seen.add(key);
|
|
882
874
|
results.push({
|
|
883
|
-
...formatSearchResult(row.
|
|
875
|
+
...formatSearchResult(row.entityType, row),
|
|
884
876
|
score: 2,
|
|
885
|
-
priority: typePriority[row.
|
|
877
|
+
priority: typePriority[row.entityType] ?? 99
|
|
886
878
|
});
|
|
887
879
|
}
|
|
888
880
|
}
|
package/lib/db/base.cjs
CHANGED
|
@@ -763,12 +763,12 @@ var SqliteBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
763
763
|
const doDidSearch = isDidLike && didPrefix.length >= 4;
|
|
764
764
|
const queries = [
|
|
765
765
|
kysely.sql`
|
|
766
|
-
SELECT address, name, symbol, description, totalSupply, issuer, type, renaissanceTime, genesisTime FROM token
|
|
766
|
+
SELECT address, name, symbol, description, decimal, totalSupply, issuer, type, renaissanceTime, genesisTime FROM token
|
|
767
767
|
WHERE LOWER(name) LIKE LOWER(${containsPattern}) ESCAPE '\\' OR LOWER(symbol) LIKE LOWER(${containsPattern}) ESCAPE '\\' OR LOWER(description) LIKE LOWER(${containsPattern}) ESCAPE '\\'
|
|
768
768
|
LIMIT ${limit}
|
|
769
769
|
`.execute(this.db),
|
|
770
770
|
kysely.sql`
|
|
771
|
-
SELECT address, moniker, numTxs, numAssets,
|
|
771
|
+
SELECT address, moniker, numTxs, numAssets, tokens, renaissanceTime, genesisTime FROM account
|
|
772
772
|
WHERE LOWER(moniker) LIKE LOWER(${containsPattern}) ESCAPE '\\'
|
|
773
773
|
LIMIT ${limit}
|
|
774
774
|
`.execute(this.db),
|
|
@@ -783,7 +783,7 @@ var SqliteBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
783
783
|
LIMIT ${limit}
|
|
784
784
|
`.execute(this.db),
|
|
785
785
|
kysely.sql`
|
|
786
|
-
SELECT address, name, moniker, status, currentSupply, reserveBalance, tokenAddress, reserveAddress, renaissanceTime, genesisTime FROM tokenFactory
|
|
786
|
+
SELECT address, name, moniker, status, currentSupply, reserveBalance, tokenAddress, reserveAddress, token, reserveToken, renaissanceTime, genesisTime FROM tokenFactory
|
|
787
787
|
WHERE LOWER(name) LIKE LOWER(${containsPattern}) ESCAPE '\\' OR LOWER(moniker) LIKE LOWER(${containsPattern}) ESCAPE '\\'
|
|
788
788
|
LIMIT ${limit}
|
|
789
789
|
`.execute(this.db),
|
|
@@ -796,12 +796,12 @@ var SqliteBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
796
796
|
if (doDidSearch) {
|
|
797
797
|
const prefixPattern = `${escapeLikePattern(didPrefix)}%`;
|
|
798
798
|
queries.push(kysely.sql`
|
|
799
|
-
SELECT * FROM (SELECT address, 'account' as
|
|
800
|
-
UNION ALL SELECT * FROM (SELECT address, 'token',
|
|
801
|
-
UNION ALL SELECT * FROM (SELECT address, 'asset', COALESCE(moniker, address), moniker, NULL, NULL, NULL, tags, NULL, NULL, NULL,
|
|
802
|
-
UNION ALL SELECT * FROM (SELECT address, 'factory', COALESCE(name, address), NULL, name, NULL, description, NULL, NULL, NULL, NULL,
|
|
803
|
-
UNION ALL SELECT * FROM (SELECT address, 'tokenFactory',
|
|
804
|
-
UNION ALL SELECT * FROM (SELECT address, 'stake', COALESCE(message, address), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, sender, receiver, revocable, NULL, renaissanceTime, genesisTime FROM stake WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
799
|
+
SELECT * FROM (SELECT address, 'account' as entityType, COALESCE(moniker, address) as title, moniker, NULL as name, NULL as symbol, NULL as description, NULL as tags, numTxs, numAssets, NULL as owner, NULL as parent, NULL as issuer, NULL as totalSupply, NULL as decimal, NULL as status, NULL as currentSupply, NULL as reserveBalance, NULL as tokenAddress, NULL as reserveAddress, NULL as token, NULL as reserveToken, NULL as sender, NULL as receiver, NULL as revocable, NULL as consumedTime, tokens, renaissanceTime, genesisTime, NULL as type FROM account WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
800
|
+
UNION ALL SELECT * FROM (SELECT address, 'token', NULL, NULL, name, symbol, description, NULL, NULL, NULL, NULL, NULL, issuer, totalSupply, decimal, NULL, NULL, NULL, tokenFactoryAddress, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, renaissanceTime, genesisTime, type FROM token WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
801
|
+
UNION ALL SELECT * FROM (SELECT address, 'asset', COALESCE(moniker, address), moniker, NULL, NULL, NULL, tags, NULL, NULL, owner, parent, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, consumedTime, NULL, renaissanceTime, genesisTime, NULL FROM asset WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
802
|
+
UNION ALL SELECT * FROM (SELECT address, 'factory', COALESCE(name, address), NULL, name, NULL, description, NULL, NULL, NULL, owner, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, renaissanceTime, genesisTime, NULL FROM factory WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
803
|
+
UNION ALL SELECT * FROM (SELECT address, 'tokenFactory', NULL, moniker, name, NULL, description, NULL, NULL, NULL, owner, NULL, NULL, NULL, NULL, status, currentSupply, reserveBalance, tokenAddress, reserveAddress, token, reserveToken, NULL, NULL, NULL, NULL, NULL, renaissanceTime, genesisTime, NULL FROM tokenFactory WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
804
|
+
UNION ALL SELECT * FROM (SELECT address, 'stake', COALESCE(message, address), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, sender, receiver, revocable, NULL, NULL, renaissanceTime, genesisTime, NULL FROM stake WHERE address LIKE ${prefixPattern} ESCAPE '\\' LIMIT ${limit})
|
|
805
805
|
`.execute(this.db));
|
|
806
806
|
}
|
|
807
807
|
const allResults = await Promise.all(queries);
|
|
@@ -812,12 +812,8 @@ var SqliteBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
812
812
|
const symbolScore = row.symbol ? scoreMatch(row.symbol, lowerKw) : 0;
|
|
813
813
|
const descScore = row.description ? scoreMatch(row.description, lowerKw) : 0;
|
|
814
814
|
const score = Math.max(nameScore, symbolScore, descScore);
|
|
815
|
-
const title = nameScore >= symbolScore ? row.name || row.symbol || "" : row.symbol || row.name || "";
|
|
816
815
|
results.push({
|
|
817
|
-
...(0, _ocap_indexdb.formatSearchResult)("token",
|
|
818
|
-
...row,
|
|
819
|
-
title
|
|
820
|
-
}),
|
|
816
|
+
...(0, _ocap_indexdb.formatSearchResult)("token", row),
|
|
821
817
|
score,
|
|
822
818
|
priority: typePriority.token
|
|
823
819
|
});
|
|
@@ -858,12 +854,8 @@ var SqliteBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
858
854
|
const nameScore = row.name ? scoreMatch(row.name, lowerKw) : 0;
|
|
859
855
|
const monikerScore = row.moniker ? scoreMatch(row.moniker, lowerKw) : 0;
|
|
860
856
|
const score = Math.max(nameScore, monikerScore);
|
|
861
|
-
const title = nameScore >= monikerScore ? row.name || row.moniker || "" : row.moniker || row.name || "";
|
|
862
857
|
results.push({
|
|
863
|
-
...(0, _ocap_indexdb.formatSearchResult)("tokenFactory",
|
|
864
|
-
...row,
|
|
865
|
-
title
|
|
866
|
-
}),
|
|
858
|
+
...(0, _ocap_indexdb.formatSearchResult)("tokenFactory", row),
|
|
867
859
|
score,
|
|
868
860
|
priority: typePriority.tokenFactory
|
|
869
861
|
});
|
|
@@ -880,13 +872,13 @@ var SqliteBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
|
|
|
880
872
|
const didRows = allResults[6];
|
|
881
873
|
const seen = new Set(results.map((r) => `${r.type}:${r.id}`));
|
|
882
874
|
for (const row of didRows.rows) {
|
|
883
|
-
const key = `${row.
|
|
875
|
+
const key = `${row.entityType}:${row.address}`;
|
|
884
876
|
if (!seen.has(key)) {
|
|
885
877
|
seen.add(key);
|
|
886
878
|
results.push({
|
|
887
|
-
...(0, _ocap_indexdb.formatSearchResult)(row.
|
|
879
|
+
...(0, _ocap_indexdb.formatSearchResult)(row.entityType, row),
|
|
888
880
|
score: 2,
|
|
889
|
-
priority: typePriority[row.
|
|
881
|
+
priority: typePriority[row.entityType] ?? 99
|
|
890
882
|
});
|
|
891
883
|
}
|
|
892
884
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/indexdb-sqlite",
|
|
3
3
|
"description": "OCAP indexdb adapter that uses SQLite as backend",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.15",
|
|
5
5
|
"author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/ArcBlock/blockchain/issues",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"clean": "rm -rf lib esm"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@arcblock/did": "1.30.
|
|
65
|
-
"@ocap/indexdb": "1.30.
|
|
66
|
-
"@ocap/types": "1.30.
|
|
67
|
-
"@ocap/util": "1.30.
|
|
64
|
+
"@arcblock/did": "1.30.15",
|
|
65
|
+
"@ocap/indexdb": "1.30.15",
|
|
66
|
+
"@ocap/types": "1.30.15",
|
|
67
|
+
"@ocap/util": "1.30.15",
|
|
68
68
|
"debug": "^4.4.3",
|
|
69
69
|
"better-sqlite3": "^11.8.1",
|
|
70
70
|
"kysely": "^0.28.14",
|