@xuda.io/account_module 1.2.1541 → 1.2.1543
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/index.mjs +13 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -3050,7 +3050,19 @@ export const record_ai_usage = async function (uid, input_tokens, output_tokens,
|
|
|
3050
3050
|
|
|
3051
3051
|
export const record_ai_credit = async function (uid, credits = 0, source, details, credited_uid) {
|
|
3052
3052
|
try {
|
|
3053
|
-
|
|
3053
|
+
var dup = await db_module.find_app_couch_query(app_id, {
|
|
3054
|
+
selector: {
|
|
3055
|
+
docType: 'ai_credit',
|
|
3056
|
+
credited_uid,
|
|
3057
|
+
details,
|
|
3058
|
+
},
|
|
3059
|
+
fields: ['_id'],
|
|
3060
|
+
limit: 1,
|
|
3061
|
+
});
|
|
3062
|
+
|
|
3063
|
+
if (dup.docs.length) {
|
|
3064
|
+
throw new Error(`${details} already credited!`);
|
|
3065
|
+
}
|
|
3054
3066
|
|
|
3055
3067
|
const t = Date.now();
|
|
3056
3068
|
let credit_doc = {
|