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/cli.js
CHANGED
|
@@ -2764,6 +2764,9 @@ function resolveDbPath(homeDir) {
|
|
|
2764
2764
|
function nowIso() {
|
|
2765
2765
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
2766
2766
|
}
|
|
2767
|
+
function normalizeWalletAddress(value) {
|
|
2768
|
+
return value.trim().toLowerCase();
|
|
2769
|
+
}
|
|
2767
2770
|
async function createCloudDatastore(homeDir) {
|
|
2768
2771
|
const dbPath = resolveDbPath(homeDir);
|
|
2769
2772
|
let db = null;
|
|
@@ -2863,6 +2866,19 @@ async function createCloudDatastore(homeDir) {
|
|
|
2863
2866
|
CREATE INDEX IF NOT EXISTS idx_friendly_names_wallet ON friendly_names(wallet_address);
|
|
2864
2867
|
CREATE INDEX IF NOT EXISTS idx_friendly_names_created_at ON friendly_names(created_at);
|
|
2865
2868
|
`);
|
|
2869
|
+
nextDb.exec(`
|
|
2870
|
+
UPDATE objects
|
|
2871
|
+
SET wallet_address = lower(trim(wallet_address))
|
|
2872
|
+
WHERE wallet_address <> lower(trim(wallet_address));
|
|
2873
|
+
|
|
2874
|
+
UPDATE payments
|
|
2875
|
+
SET wallet_address = lower(trim(wallet_address))
|
|
2876
|
+
WHERE wallet_address <> lower(trim(wallet_address));
|
|
2877
|
+
|
|
2878
|
+
UPDATE friendly_names
|
|
2879
|
+
SET wallet_address = lower(trim(wallet_address))
|
|
2880
|
+
WHERE wallet_address <> lower(trim(wallet_address));
|
|
2881
|
+
`);
|
|
2866
2882
|
const addOperationsColumn = (columnName, sqlType) => {
|
|
2867
2883
|
try {
|
|
2868
2884
|
nextDb.exec(`ALTER TABLE operations ADD COLUMN ${columnName} ${sqlType}`);
|
|
@@ -2901,6 +2917,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
2901
2917
|
ensureReady,
|
|
2902
2918
|
upsertObject: async (row) => {
|
|
2903
2919
|
await safe(() => {
|
|
2920
|
+
const normalizedWalletAddress = normalizeWalletAddress(row.wallet_address);
|
|
2904
2921
|
const ts = nowIso();
|
|
2905
2922
|
db.prepare(
|
|
2906
2923
|
`INSERT INTO objects(object_id, object_key, wallet_address, quote_id, provider, bucket_name, region, sha256, status, created_at, updated_at)
|
|
@@ -2918,7 +2935,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
2918
2935
|
).run(
|
|
2919
2936
|
row.object_id,
|
|
2920
2937
|
row.object_key,
|
|
2921
|
-
|
|
2938
|
+
normalizedWalletAddress,
|
|
2922
2939
|
row.quote_id,
|
|
2923
2940
|
row.provider,
|
|
2924
2941
|
row.bucket_name,
|
|
@@ -2951,6 +2968,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
2951
2968
|
}, null),
|
|
2952
2969
|
upsertPayment: async (row) => {
|
|
2953
2970
|
await safe(() => {
|
|
2971
|
+
const normalizedWalletAddress = normalizeWalletAddress(row.wallet_address);
|
|
2954
2972
|
const ts = nowIso();
|
|
2955
2973
|
db.prepare(
|
|
2956
2974
|
`INSERT INTO payments(quote_id, wallet_address, trans_id, amount, network, status, settled_at, created_at, updated_at)
|
|
@@ -2965,7 +2983,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
2965
2983
|
updated_at=excluded.updated_at`
|
|
2966
2984
|
).run(
|
|
2967
2985
|
row.quote_id,
|
|
2968
|
-
|
|
2986
|
+
normalizedWalletAddress,
|
|
2969
2987
|
row.trans_id,
|
|
2970
2988
|
row.amount,
|
|
2971
2989
|
row.network,
|
|
@@ -3087,6 +3105,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3087
3105
|
}, null),
|
|
3088
3106
|
upsertFriendlyName: async (row) => {
|
|
3089
3107
|
await safe(() => {
|
|
3108
|
+
const normalizedWalletAddress = normalizeWalletAddress(row.wallet_address);
|
|
3090
3109
|
const ts = nowIso();
|
|
3091
3110
|
db.prepare(
|
|
3092
3111
|
`INSERT INTO friendly_names(friendly_name_id, friendly_name, object_id, object_key, quote_id, wallet_address, created_at, updated_at, is_active)
|
|
@@ -3097,7 +3116,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3097
3116
|
row.object_id,
|
|
3098
3117
|
row.object_key,
|
|
3099
3118
|
row.quote_id,
|
|
3100
|
-
|
|
3119
|
+
normalizedWalletAddress,
|
|
3101
3120
|
ts,
|
|
3102
3121
|
ts,
|
|
3103
3122
|
row.is_active ?? 1
|
|
@@ -3105,6 +3124,7 @@ async function createCloudDatastore(homeDir) {
|
|
|
3105
3124
|
}, void 0);
|
|
3106
3125
|
},
|
|
3107
3126
|
resolveFriendlyName: async (params) => safe(() => {
|
|
3127
|
+
const normalizedWalletAddress = normalizeWalletAddress(params.walletAddress);
|
|
3108
3128
|
const atIso = params.at ? new Date(params.at).toISOString() : null;
|
|
3109
3129
|
const row = params.latest || !atIso ? db.prepare(
|
|
3110
3130
|
`SELECT friendly_name_id, friendly_name, object_id, object_key, quote_id, wallet_address, created_at
|
|
@@ -3112,13 +3132,13 @@ async function createCloudDatastore(homeDir) {
|
|
|
3112
3132
|
WHERE wallet_address = ? AND friendly_name = ? AND is_active = 1
|
|
3113
3133
|
ORDER BY created_at DESC
|
|
3114
3134
|
LIMIT 1`
|
|
3115
|
-
).get(
|
|
3135
|
+
).get(normalizedWalletAddress, params.friendlyName) : db.prepare(
|
|
3116
3136
|
`SELECT friendly_name_id, friendly_name, object_id, object_key, quote_id, wallet_address, created_at
|
|
3117
3137
|
FROM friendly_names
|
|
3118
3138
|
WHERE wallet_address = ? AND friendly_name = ? AND is_active = 1 AND created_at <= ?
|
|
3119
3139
|
ORDER BY created_at DESC
|
|
3120
3140
|
LIMIT 1`
|
|
3121
|
-
).get(
|
|
3141
|
+
).get(normalizedWalletAddress, params.friendlyName, atIso);
|
|
3122
3142
|
if (!row) return null;
|
|
3123
3143
|
return {
|
|
3124
3144
|
friendlyNameId: row.friendly_name_id,
|
|
@@ -3131,11 +3151,12 @@ async function createCloudDatastore(homeDir) {
|
|
|
3131
3151
|
};
|
|
3132
3152
|
}, null),
|
|
3133
3153
|
countFriendlyNameMatches: async (walletAddress, friendlyName) => safe(() => {
|
|
3154
|
+
const normalizedWalletAddress = normalizeWalletAddress(walletAddress);
|
|
3134
3155
|
const row = db.prepare(
|
|
3135
3156
|
`SELECT COUNT(1) AS cnt
|
|
3136
3157
|
FROM friendly_names
|
|
3137
3158
|
WHERE wallet_address = ? AND friendly_name = ? AND is_active = 1`
|
|
3138
|
-
).get(
|
|
3159
|
+
).get(normalizedWalletAddress, friendlyName);
|
|
3139
3160
|
return Number(row?.cnt ?? 0);
|
|
3140
3161
|
}, 0)
|
|
3141
3162
|
};
|
|
@@ -3266,7 +3287,7 @@ function parseNamedFlagsTokens(tokens, booleanFlags = /* @__PURE__ */ new Set())
|
|
|
3266
3287
|
if (!keyToken.startsWith("--")) {
|
|
3267
3288
|
return null;
|
|
3268
3289
|
}
|
|
3269
|
-
const key = keyToken.slice(2).toLowerCase();
|
|
3290
|
+
const key = keyToken.slice(2).toLowerCase().replace(/_/g, "-");
|
|
3270
3291
|
const value = tokens[i + 1];
|
|
3271
3292
|
if (!value || value.startsWith("--")) {
|
|
3272
3293
|
if (booleanFlags.has(key)) {
|
|
@@ -4270,7 +4291,7 @@ async function resolveFriendlyNameFromManifest(params, homeDir) {
|
|
|
4270
4291
|
} catch {
|
|
4271
4292
|
return { objectKey: null, matchCount: 0 };
|
|
4272
4293
|
}
|
|
4273
|
-
const wallet = params.walletAddress.trim();
|
|
4294
|
+
const wallet = params.walletAddress.trim().toLowerCase();
|
|
4274
4295
|
const name = params.friendlyName.trim();
|
|
4275
4296
|
const atMs = params.at ? Date.parse(params.at) : Number.NaN;
|
|
4276
4297
|
const hasAt = Number.isFinite(atMs);
|
|
@@ -4284,7 +4305,7 @@ async function resolveFriendlyNameFromManifest(params, homeDir) {
|
|
|
4284
4305
|
if (!row.object_key || !row.friendly_name || !row.wallet_address || !row.created_at)
|
|
4285
4306
|
return false;
|
|
4286
4307
|
if (row.friendly_name !== name) return false;
|
|
4287
|
-
if (row.wallet_address.trim() !== wallet) return false;
|
|
4308
|
+
if (row.wallet_address.trim().toLowerCase() !== wallet) return false;
|
|
4288
4309
|
if (params.latest || !hasAt) return true;
|
|
4289
4310
|
const createdAtMs = Date.parse(row.created_at);
|
|
4290
4311
|
return Number.isFinite(createdAtMs) && createdAtMs <= atMs;
|