@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.
Files changed (2) hide show
  1. package/index.mjs +13 -1
  2. 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
- // if (!account_profile_info) throw new Error('missing account_profile_info');
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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1541",
3
+ "version": "1.2.1543",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {