mnemospark 0.2.1 → 0.2.2
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/dist/cli.js +30 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.js +30 -9
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2815,6 +2815,9 @@ function resolveDbPath(homeDir) {
|
|
|
2815
2815
|
function nowIso() {
|
|
2816
2816
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
2817
2817
|
}
|
|
2818
|
+
function normalizeWalletAddress(value) {
|
|
2819
|
+
return value.trim().toLowerCase();
|
|
2820
|
+
}
|
|
2818
2821
|
async function createCloudDatastore(homeDir) {
|
|
2819
2822
|
const dbPath = resolveDbPath(homeDir);
|
|
2820
2823
|
let db = null;
|
|
@@ -2914,6 +2917,19 @@ async function createCloudDatastore(homeDir) {
|
|
|
2914
2917
|
CREATE INDEX IF NOT EXISTS idx_friendly_names_wallet ON friendly_names(wallet_address);
|
|
2915
2918
|
CREATE INDEX IF NOT EXISTS idx_friendly_names_created_at ON friendly_names(created_at);
|
|
2916
2919
|
`);
|
|
2920
|
+
nextDb.exec(`
|
|
2921
|
+
UPDATE objects
|
|
2922
|
+
SET wallet_address = lower(trim(wallet_address))
|
|
2923
|
+
WHERE wallet_address <> lower(trim(wallet_address));
|
|
2924
|
+
|
|
2925
|
+
UPDATE payments
|
|
2926
|
+
SET wallet_address = lower(trim(wallet_address))
|
|
2927
|
+
WHERE wallet_address <> lower(trim(wallet_address));
|
|
2928
|
+
|
|
2929
|
+
UPDATE friendly_names
|
|
2930
|
+
SET wallet_address = lower(trim(wallet_address))
|
|
2931
|
+
WHERE wallet_address <> lower(trim(wallet_address));
|
|
2932
|
+
`);
|
|
2917
2933
|
const addOperationsColumn = (columnName, sqlType) => {
|
|
2918
2934
|
try {
|
|
2919
2935
|
nextDb.exec(`ALTER TABLE operations ADD COLUMN ${columnName} ${sqlType}`);
|
|
@@ -2952,6 +2968,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
2952
2968
|
ensureReady,
|
|
2953
2969
|
upsertObject: async (row) => {
|
|
2954
2970
|
await safe(() => {
|
|
2971
|
+
const normalizedWalletAddress = normalizeWalletAddress(row.wallet_address);
|
|
2955
2972
|
const ts = nowIso();
|
|
2956
2973
|
db.prepare(
|
|
2957
2974
|
`INSERT INTO objects(object_id, object_key, wallet_address, quote_id, provider, bucket_name, region, sha256, status, created_at, updated_at)
|
|
@@ -2969,7 +2986,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
2969
2986
|
).run(
|
|
2970
2987
|
row.object_id,
|
|
2971
2988
|
row.object_key,
|
|
2972
|
-
|
|
2989
|
+
normalizedWalletAddress,
|
|
2973
2990
|
row.quote_id,
|
|
2974
2991
|
row.provider,
|
|
2975
2992
|
row.bucket_name,
|
|
@@ -3002,6 +3019,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3002
3019
|
}, null),
|
|
3003
3020
|
upsertPayment: async (row) => {
|
|
3004
3021
|
await safe(() => {
|
|
3022
|
+
const normalizedWalletAddress = normalizeWalletAddress(row.wallet_address);
|
|
3005
3023
|
const ts = nowIso();
|
|
3006
3024
|
db.prepare(
|
|
3007
3025
|
`INSERT INTO payments(quote_id, wallet_address, trans_id, amount, network, status, settled_at, created_at, updated_at)
|
|
@@ -3016,7 +3034,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3016
3034
|
updated_at=excluded.updated_at`
|
|
3017
3035
|
).run(
|
|
3018
3036
|
row.quote_id,
|
|
3019
|
-
|
|
3037
|
+
normalizedWalletAddress,
|
|
3020
3038
|
row.trans_id,
|
|
3021
3039
|
row.amount,
|
|
3022
3040
|
row.network,
|
|
@@ -3138,6 +3156,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3138
3156
|
}, null),
|
|
3139
3157
|
upsertFriendlyName: async (row) => {
|
|
3140
3158
|
await safe(() => {
|
|
3159
|
+
const normalizedWalletAddress = normalizeWalletAddress(row.wallet_address);
|
|
3141
3160
|
const ts = nowIso();
|
|
3142
3161
|
db.prepare(
|
|
3143
3162
|
`INSERT INTO friendly_names(friendly_name_id, friendly_name, object_id, object_key, quote_id, wallet_address, created_at, updated_at, is_active)
|
|
@@ -3148,7 +3167,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3148
3167
|
row.object_id,
|
|
3149
3168
|
row.object_key,
|
|
3150
3169
|
row.quote_id,
|
|
3151
|
-
|
|
3170
|
+
normalizedWalletAddress,
|
|
3152
3171
|
ts,
|
|
3153
3172
|
ts,
|
|
3154
3173
|
row.is_active ?? 1
|
|
@@ -3156,6 +3175,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3156
3175
|
}, void 0);
|
|
3157
3176
|
},
|
|
3158
3177
|
resolveFriendlyName: async (params) => safe(() => {
|
|
3178
|
+
const normalizedWalletAddress = normalizeWalletAddress(params.walletAddress);
|
|
3159
3179
|
const atIso = params.at ? new Date(params.at).toISOString() : null;
|
|
3160
3180
|
const row = params.latest || !atIso ? db.prepare(
|
|
3161
3181
|
`SELECT friendly_name_id, friendly_name, object_id, object_key, quote_id, wallet_address, created_at
|
|
@@ -3163,13 +3183,13 @@ async function createCloudDatastore(homeDir) {
|
|
|
3163
3183
|
WHERE wallet_address = ? AND friendly_name = ? AND is_active = 1
|
|
3164
3184
|
ORDER BY created_at DESC
|
|
3165
3185
|
LIMIT 1`
|
|
3166
|
-
).get(
|
|
3186
|
+
).get(normalizedWalletAddress, params.friendlyName) : db.prepare(
|
|
3167
3187
|
`SELECT friendly_name_id, friendly_name, object_id, object_key, quote_id, wallet_address, created_at
|
|
3168
3188
|
FROM friendly_names
|
|
3169
3189
|
WHERE wallet_address = ? AND friendly_name = ? AND is_active = 1 AND created_at <= ?
|
|
3170
3190
|
ORDER BY created_at DESC
|
|
3171
3191
|
LIMIT 1`
|
|
3172
|
-
).get(
|
|
3192
|
+
).get(normalizedWalletAddress, params.friendlyName, atIso);
|
|
3173
3193
|
if (!row) return null;
|
|
3174
3194
|
return {
|
|
3175
3195
|
friendlyNameId: row.friendly_name_id,
|
|
@@ -3182,11 +3202,12 @@ async function createCloudDatastore(homeDir) {
|
|
|
3182
3202
|
};
|
|
3183
3203
|
}, null),
|
|
3184
3204
|
countFriendlyNameMatches: async (walletAddress, friendlyName) => safe(() => {
|
|
3205
|
+
const normalizedWalletAddress = normalizeWalletAddress(walletAddress);
|
|
3185
3206
|
const row = db.prepare(
|
|
3186
3207
|
`SELECT COUNT(1) AS cnt
|
|
3187
3208
|
FROM friendly_names
|
|
3188
3209
|
WHERE wallet_address = ? AND friendly_name = ? AND is_active = 1`
|
|
3189
|
-
).get(
|
|
3210
|
+
).get(normalizedWalletAddress, friendlyName);
|
|
3190
3211
|
return Number(row?.cnt ?? 0);
|
|
3191
3212
|
}, 0)
|
|
3192
3213
|
};
|
|
@@ -3317,7 +3338,7 @@ function parseNamedFlagsTokens(tokens, booleanFlags = /* @__PURE__ */ new Set())
|
|
|
3317
3338
|
if (!keyToken.startsWith("--")) {
|
|
3318
3339
|
return null;
|
|
3319
3340
|
}
|
|
3320
|
-
const key = keyToken.slice(2).toLowerCase();
|
|
3341
|
+
const key = keyToken.slice(2).toLowerCase().replace(/_/g, "-");
|
|
3321
3342
|
const value = tokens[i + 1];
|
|
3322
3343
|
if (!value || value.startsWith("--")) {
|
|
3323
3344
|
if (booleanFlags.has(key)) {
|
|
@@ -4321,7 +4342,7 @@ async function resolveFriendlyNameFromManifest(params, homeDir) {
|
|
|
4321
4342
|
} catch {
|
|
4322
4343
|
return { objectKey: null, matchCount: 0 };
|
|
4323
4344
|
}
|
|
4324
|
-
const wallet = params.walletAddress.trim();
|
|
4345
|
+
const wallet = params.walletAddress.trim().toLowerCase();
|
|
4325
4346
|
const name = params.friendlyName.trim();
|
|
4326
4347
|
const atMs = params.at ? Date.parse(params.at) : Number.NaN;
|
|
4327
4348
|
const hasAt = Number.isFinite(atMs);
|
|
@@ -4335,7 +4356,7 @@ async function resolveFriendlyNameFromManifest(params, homeDir) {
|
|
|
4335
4356
|
if (!row.object_key || !row.friendly_name || !row.wallet_address || !row.created_at)
|
|
4336
4357
|
return false;
|
|
4337
4358
|
if (row.friendly_name !== name) return false;
|
|
4338
|
-
if (row.wallet_address.trim() !== wallet) return false;
|
|
4359
|
+
if (row.wallet_address.trim().toLowerCase() !== wallet) return false;
|
|
4339
4360
|
if (params.latest || !hasAt) return true;
|
|
4340
4361
|
const createdAtMs = Date.parse(row.created_at);
|
|
4341
4362
|
return Number.isFinite(createdAtMs) && createdAtMs <= atMs;
|