@windrun-huaiin/backend-core 15.0.0 → 16.0.0
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/LICENSE +1 -1
- package/dist/app/api/stripe/checkout/route.js +2 -2
- package/dist/app/api/stripe/checkout/route.mjs +1 -1
- package/dist/app/api/stripe/customer-portal/route.js +2 -2
- package/dist/app/api/stripe/customer-portal/route.mjs +1 -1
- package/dist/app/api/user/anonymous/init/route.js +6 -6
- package/dist/app/api/user/anonymous/init/route.mjs +1 -1
- package/dist/app/api/webhook/clerk/user/route.js +4 -4
- package/dist/app/api/webhook/clerk/user/route.mjs +1 -1
- package/dist/app/api/webhook/stripe/route.js +2 -2
- package/dist/app/api/webhook/stripe/route.mjs +1 -1
- package/dist/auth/auth-middleware.js +3 -3
- package/dist/auth/auth-middleware.mjs +1 -1
- package/dist/auth/auth-utils.js +10 -10
- package/dist/auth/auth-utils.mjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -0
- package/dist/index.mjs +8 -1
- package/dist/lib/index.js +19 -0
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/money-price-helper.js +3 -3
- package/dist/lib/money-price-helper.mjs +1 -1
- package/dist/lib/stripe-config.js +8 -8
- package/dist/lib/stripe-config.mjs +1 -1
- package/dist/lib/upstash/qstash.d.ts +20 -7
- package/dist/lib/upstash/qstash.d.ts.map +1 -1
- package/dist/lib/upstash/qstash.js +45 -19
- package/dist/lib/upstash/qstash.mjs +35 -9
- package/dist/lib/upstash/redis-counter.js +7 -7
- package/dist/lib/upstash/redis-counter.mjs +1 -1
- package/dist/lib/upstash/redis-favorite.js +9 -9
- package/dist/lib/upstash/redis-favorite.mjs +1 -1
- package/dist/lib/upstash/redis-like.js +9 -9
- package/dist/lib/upstash/redis-like.mjs +1 -1
- package/dist/lib/upstash/redis-lock.js +6 -6
- package/dist/lib/upstash/redis-lock.mjs +1 -1
- package/dist/lib/upstash/redis-structures.d.ts +83 -0
- package/dist/lib/upstash/redis-structures.d.ts.map +1 -1
- package/dist/lib/upstash/redis-structures.js +245 -25
- package/dist/lib/upstash/redis-structures.mjs +203 -2
- package/dist/lib/upstash-config.d.ts.map +1 -1
- package/dist/lib/upstash-config.js +90 -18
- package/dist/lib/upstash-config.mjs +80 -8
- package/dist/prisma/prisma-transaction-util.js +2 -2
- package/dist/prisma/prisma-transaction-util.mjs +1 -1
- package/dist/services/aggregate/anonymous.aggregate.service.js +6 -6
- package/dist/services/aggregate/anonymous.aggregate.service.mjs +1 -1
- package/dist/services/aggregate/billing.aggregate.service.js +21 -21
- package/dist/services/aggregate/billing.aggregate.service.mjs +1 -1
- package/dist/services/aggregate/user.aggregate.service.js +10 -10
- package/dist/services/aggregate/user.aggregate.service.mjs +1 -1
- package/dist/services/ai/abort.d.ts +2 -0
- package/dist/services/ai/abort.d.ts.map +1 -0
- package/dist/services/ai/abort.js +24 -0
- package/dist/services/ai/abort.mjs +22 -0
- package/dist/services/ai/env.d.ts +21 -0
- package/dist/services/ai/env.d.ts.map +1 -0
- package/dist/services/ai/env.js +85 -0
- package/dist/services/ai/env.mjs +80 -0
- package/dist/services/ai/error.d.ts +3 -0
- package/dist/services/ai/error.d.ts.map +1 -0
- package/dist/services/ai/error.js +54 -0
- package/dist/services/ai/error.mjs +52 -0
- package/dist/services/ai/index.d.ts +9 -0
- package/dist/services/ai/index.d.ts.map +1 -0
- package/dist/services/ai/index.js +30 -0
- package/dist/services/ai/index.mjs +7 -0
- package/dist/services/ai/message-builder.d.ts +4 -0
- package/dist/services/ai/message-builder.d.ts.map +1 -0
- package/dist/services/ai/message-builder.js +15 -0
- package/dist/services/ai/message-builder.mjs +13 -0
- package/dist/services/ai/mock.d.ts +30 -0
- package/dist/services/ai/mock.d.ts.map +1 -0
- package/dist/services/ai/mock.js +314 -0
- package/dist/services/ai/mock.mjs +308 -0
- package/dist/services/ai/openrouter-client.d.ts +12 -0
- package/dist/services/ai/openrouter-client.d.ts.map +1 -0
- package/dist/services/ai/openrouter-client.js +81 -0
- package/dist/services/ai/openrouter-client.mjs +78 -0
- package/dist/services/ai/route.d.ts +6 -0
- package/dist/services/ai/route.d.ts.map +1 -0
- package/dist/services/ai/route.js +178 -0
- package/dist/services/ai/route.mjs +173 -0
- package/dist/services/ai/types.d.ts +98 -0
- package/dist/services/ai/types.d.ts.map +1 -0
- package/dist/services/context/user-context-service.js +3 -3
- package/dist/services/context/user-context-service.mjs +1 -1
- package/dist/services/database/apilog.service.js +14 -14
- package/dist/services/database/apilog.service.mjs +1 -1
- package/dist/services/database/credit.service.js +20 -20
- package/dist/services/database/credit.service.mjs +1 -1
- package/dist/services/database/creditAuditLog.service.js +13 -13
- package/dist/services/database/creditAuditLog.service.mjs +1 -1
- package/dist/services/database/subscription.service.js +16 -16
- package/dist/services/database/subscription.service.mjs +1 -1
- package/dist/services/database/transaction.service.js +18 -18
- package/dist/services/database/transaction.service.mjs +1 -1
- package/dist/services/database/user.service.js +14 -14
- package/dist/services/database/user.service.mjs +1 -1
- package/dist/services/database/userBackup.service.js +15 -15
- package/dist/services/database/userBackup.service.mjs +1 -1
- package/dist/services/stripe/webhook-handler.js +13 -13
- package/dist/services/stripe/webhook-handler.mjs +3 -3
- package/package.json +14 -4
- package/src/index.ts +1 -0
- package/src/lib/upstash/qstash.ts +55 -15
- package/src/lib/upstash/redis-structures.ts +248 -0
- package/src/lib/upstash-config.ts +106 -4
- package/src/services/ai/abort.ts +26 -0
- package/src/services/ai/env.ts +120 -0
- package/src/services/ai/error.ts +64 -0
- package/src/services/ai/index.ts +8 -0
- package/src/services/ai/message-builder.ts +17 -0
- package/src/services/ai/mock.ts +378 -0
- package/src/services/ai/openrouter-client.ts +94 -0
- package/src/services/ai/route.ts +218 -0
- package/src/services/ai/types.ts +131 -0
- package/dist/_virtual/_commonjs-dynamic-modules.js +0 -7
- package/dist/_virtual/_commonjs-dynamic-modules.mjs +0 -5
- package/dist/_virtual/_commonjsHelpers.js +0 -10
- package/dist/_virtual/_commonjsHelpers.mjs +0 -7
- package/dist/_virtual/aes.js +0 -5
- package/dist/_virtual/aes.mjs +0 -3
- package/dist/_virtual/blowfish.js +0 -5
- package/dist/_virtual/blowfish.mjs +0 -3
- package/dist/_virtual/cipher-core.js +0 -5
- package/dist/_virtual/cipher-core.mjs +0 -3
- package/dist/_virtual/core.js +0 -5
- package/dist/_virtual/core.mjs +0 -3
- package/dist/_virtual/enc-base64.js +0 -5
- package/dist/_virtual/enc-base64.mjs +0 -3
- package/dist/_virtual/enc-base64url.js +0 -5
- package/dist/_virtual/enc-base64url.mjs +0 -3
- package/dist/_virtual/enc-utf16.js +0 -5
- package/dist/_virtual/enc-utf16.mjs +0 -3
- package/dist/_virtual/evpkdf.js +0 -5
- package/dist/_virtual/evpkdf.mjs +0 -3
- package/dist/_virtual/format-hex.js +0 -5
- package/dist/_virtual/format-hex.mjs +0 -3
- package/dist/_virtual/hmac.js +0 -5
- package/dist/_virtual/hmac.mjs +0 -3
- package/dist/_virtual/index.js +0 -11
- package/dist/_virtual/index.mjs +0 -7
- package/dist/_virtual/index2.js +0 -5
- package/dist/_virtual/index2.mjs +0 -3
- package/dist/_virtual/lib-typedarrays.js +0 -5
- package/dist/_virtual/lib-typedarrays.mjs +0 -3
- package/dist/_virtual/md5.js +0 -5
- package/dist/_virtual/md5.mjs +0 -3
- package/dist/_virtual/mode-cfb.js +0 -5
- package/dist/_virtual/mode-cfb.mjs +0 -3
- package/dist/_virtual/mode-ctr-gladman.js +0 -5
- package/dist/_virtual/mode-ctr-gladman.mjs +0 -3
- package/dist/_virtual/mode-ctr.js +0 -5
- package/dist/_virtual/mode-ctr.mjs +0 -3
- package/dist/_virtual/mode-ecb.js +0 -5
- package/dist/_virtual/mode-ecb.mjs +0 -3
- package/dist/_virtual/mode-ofb.js +0 -5
- package/dist/_virtual/mode-ofb.mjs +0 -3
- package/dist/_virtual/pad-ansix923.js +0 -5
- package/dist/_virtual/pad-ansix923.mjs +0 -3
- package/dist/_virtual/pad-iso10126.js +0 -5
- package/dist/_virtual/pad-iso10126.mjs +0 -3
- package/dist/_virtual/pad-iso97971.js +0 -5
- package/dist/_virtual/pad-iso97971.mjs +0 -3
- package/dist/_virtual/pad-nopadding.js +0 -5
- package/dist/_virtual/pad-nopadding.mjs +0 -3
- package/dist/_virtual/pad-zeropadding.js +0 -5
- package/dist/_virtual/pad-zeropadding.mjs +0 -3
- package/dist/_virtual/pbkdf2.js +0 -5
- package/dist/_virtual/pbkdf2.mjs +0 -3
- package/dist/_virtual/rabbit-legacy.js +0 -5
- package/dist/_virtual/rabbit-legacy.mjs +0 -3
- package/dist/_virtual/rabbit.js +0 -5
- package/dist/_virtual/rabbit.mjs +0 -3
- package/dist/_virtual/rc4.js +0 -5
- package/dist/_virtual/rc4.mjs +0 -3
- package/dist/_virtual/ripemd160.js +0 -5
- package/dist/_virtual/ripemd160.mjs +0 -3
- package/dist/_virtual/sha1.js +0 -5
- package/dist/_virtual/sha1.mjs +0 -3
- package/dist/_virtual/sha224.js +0 -5
- package/dist/_virtual/sha224.mjs +0 -3
- package/dist/_virtual/sha256.js +0 -5
- package/dist/_virtual/sha256.mjs +0 -3
- package/dist/_virtual/sha3.js +0 -5
- package/dist/_virtual/sha3.mjs +0 -3
- package/dist/_virtual/sha384.js +0 -5
- package/dist/_virtual/sha384.mjs +0 -3
- package/dist/_virtual/sha512.js +0 -5
- package/dist/_virtual/sha512.mjs +0 -3
- package/dist/_virtual/tripledes.js +0 -5
- package/dist/_virtual/tripledes.mjs +0 -3
- package/dist/_virtual/x64-core.js +0 -5
- package/dist/_virtual/x64-core.mjs +0 -3
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js +0 -48
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs +0 -45
- package/dist/node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js +0 -1848
- package/dist/node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs +0 -1830
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js +0 -5308
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs +0 -5302
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/nodejs.js +0 -116
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/nodejs.mjs +0 -113
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js +0 -248
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.mjs +0 -246
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.js +0 -485
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.mjs +0 -483
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js +0 -906
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.mjs +0 -904
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js +0 -818
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.mjs +0 -816
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js +0 -146
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.mjs +0 -144
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.js +0 -158
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.mjs +0 -156
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.js +0 -159
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.mjs +0 -157
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js +0 -146
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.mjs +0 -144
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.js +0 -77
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.mjs +0 -75
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js +0 -153
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.mjs +0 -151
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +0 -62
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +0 -60
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.js +0 -86
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.mjs +0 -84
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js +0 -278
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.mjs +0 -276
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.js +0 -91
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.mjs +0 -89
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.js +0 -127
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.mjs +0 -125
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.js +0 -69
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.mjs +0 -67
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js +0 -51
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.mjs +0 -49
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.js +0 -65
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.mjs +0 -63
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.js +0 -60
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.mjs +0 -58
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.js +0 -55
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.mjs +0 -53
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.js +0 -51
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.mjs +0 -49
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.js +0 -41
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.mjs +0 -39
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.js +0 -58
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.mjs +0 -56
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.js +0 -157
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.mjs +0 -155
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.js +0 -204
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.mjs +0 -202
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.js +0 -206
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.mjs +0 -204
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.js +0 -153
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.mjs +0 -151
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.js +0 -277
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.mjs +0 -275
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js +0 -160
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.mjs +0 -158
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.js +0 -91
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.mjs +0 -89
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.js +0 -209
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.mjs +0 -207
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.js +0 -337
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.mjs +0 -335
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.js +0 -95
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.mjs +0 -93
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.js +0 -337
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.mjs +0 -335
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.js +0 -793
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.mjs +0 -791
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.js +0 -314
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.mjs +0 -312
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/compact/verify.js +0 -26
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/compact/verify.mjs +0 -24
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +0 -127
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.mjs +0 -125
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +0 -20
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.mjs +0 -18
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +0 -31
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.mjs +0 -29
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/buffer_utils.js +0 -18
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/buffer_utils.mjs +0 -14
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/check_key_type.js +0 -82
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/check_key_type.mjs +0 -80
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/crypto_key.js +0 -103
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/crypto_key.mjs +0 -101
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +0 -7
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.mjs +0 -3
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/invalid_key_input.js +0 -38
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/invalid_key_input.mjs +0 -33
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +0 -27
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.mjs +0 -23
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +0 -21
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.mjs +0 -16
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +0 -22
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.mjs +0 -18
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +0 -111
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.mjs +0 -107
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +0 -61
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.mjs +0 -57
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +0 -16
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.mjs +0 -12
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +0 -40
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.mjs +0 -36
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/base64url.js +0 -15
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/base64url.mjs +0 -13
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +0 -23
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.mjs +0 -19
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +0 -30
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.mjs +0 -26
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +0 -60
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.mjs +0 -56
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +0 -35
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.mjs +0 -31
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +0 -20
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.mjs +0 -16
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +0 -15
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.mjs +0 -10
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +0 -28
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.mjs +0 -5
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +0 -14
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.mjs +0 -10
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +0 -115
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.mjs +0 -111
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +0 -42
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.mjs +0 -19
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +0 -54
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.mjs +0 -31
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/webcrypto.js +0 -32
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/webcrypto.mjs +0 -7
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/util/errors.js +0 -69
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/util/errors.mjs +0 -60
- package/dist/node_modules/.pnpm/neverthrow@7.2.0/node_modules/neverthrow/dist/index.es.js +0 -422
- package/dist/node_modules/.pnpm/neverthrow@7.2.0/node_modules/neverthrow/dist/index.es.mjs +0 -415
- package/dist/node_modules/.pnpm/uncrypto@0.1.3/node_modules/uncrypto/dist/crypto.web.js +0 -6
- package/dist/node_modules/.pnpm/uncrypto@0.1.3/node_modules/uncrypto/dist/crypto.web.mjs +0 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var prisma = require('../../prisma/prisma.js');
|
|
5
5
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
7
|
class ApilogService {
|
|
8
8
|
// Create API log record with request
|
|
9
9
|
createApilog(data, tx) {
|
|
10
|
-
return
|
|
10
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
11
11
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
12
12
|
const log = yield client.apilog.create({
|
|
13
13
|
data: {
|
|
@@ -22,7 +22,7 @@ class ApilogService {
|
|
|
22
22
|
}
|
|
23
23
|
// Update API log record with response
|
|
24
24
|
updateApilogResponse(logId, response, tx) {
|
|
25
|
-
return
|
|
25
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
27
27
|
yield client.apilog.update({
|
|
28
28
|
where: { id: BigInt(logId) },
|
|
@@ -34,7 +34,7 @@ class ApilogService {
|
|
|
34
34
|
}
|
|
35
35
|
// Get API log by ID
|
|
36
36
|
getApilog(logId, tx) {
|
|
37
|
-
return
|
|
37
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
39
39
|
return yield client.apilog.findUnique({
|
|
40
40
|
where: { id: BigInt(logId) },
|
|
@@ -43,7 +43,7 @@ class ApilogService {
|
|
|
43
43
|
}
|
|
44
44
|
// Get API logs with filters
|
|
45
45
|
getApilogList(params, tx) {
|
|
46
|
-
return
|
|
46
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
47
47
|
const { apiType, methodName, limit = 50, offset = 0 } = params;
|
|
48
48
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
49
49
|
return yield client.apilog.findMany({
|
|
@@ -56,7 +56,7 @@ class ApilogService {
|
|
|
56
56
|
}
|
|
57
57
|
// Delete old API logs (cleanup)
|
|
58
58
|
deleteOldLogList() {
|
|
59
|
-
return
|
|
59
|
+
return tslib.__awaiter(this, arguments, void 0, function* (daysOld = 30, tx) {
|
|
60
60
|
const cutoffDate = new Date();
|
|
61
61
|
cutoffDate.setDate(cutoffDate.getDate() - daysOld);
|
|
62
62
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
@@ -72,7 +72,7 @@ class ApilogService {
|
|
|
72
72
|
}
|
|
73
73
|
// Get API log statistics
|
|
74
74
|
getApilogStats(tx) {
|
|
75
|
-
return
|
|
75
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
76
76
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
77
77
|
const [total, clerkIn, clerkOut, stripeIn, stripeOut] = yield Promise.all([
|
|
78
78
|
client.apilog.count(),
|
|
@@ -94,7 +94,7 @@ class ApilogService {
|
|
|
94
94
|
// API Logger Helper Class for convenience
|
|
95
95
|
class Apilogger {
|
|
96
96
|
static createLogAsync(data) {
|
|
97
|
-
return
|
|
97
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
98
98
|
try {
|
|
99
99
|
return yield apilogService.createApilog(data);
|
|
100
100
|
}
|
|
@@ -105,9 +105,9 @@ class Apilogger {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
static updateResponseAsync(logId, response) {
|
|
108
|
-
return
|
|
108
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
109
109
|
try {
|
|
110
|
-
setImmediate(() =>
|
|
110
|
+
setImmediate(() => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
try {
|
|
112
112
|
yield apilogService.updateApilogResponse(logId, response);
|
|
113
113
|
}
|
|
@@ -122,7 +122,7 @@ class Apilogger {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
static logClerkIncoming(methodName, summary, originalRequest) {
|
|
125
|
-
return
|
|
125
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
126
126
|
return yield this.createLogAsync({
|
|
127
127
|
methodName,
|
|
128
128
|
request: originalRequest,
|
|
@@ -132,7 +132,7 @@ class Apilogger {
|
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
static logClerkOutgoing(methodName, request, summary) {
|
|
135
|
-
return
|
|
135
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
136
136
|
return yield this.createLogAsync({
|
|
137
137
|
methodName,
|
|
138
138
|
request,
|
|
@@ -142,7 +142,7 @@ class Apilogger {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
static logStripeIncoming(methodName, summary, originalRequest) {
|
|
145
|
-
return
|
|
145
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
146
146
|
return yield this.createLogAsync({
|
|
147
147
|
methodName,
|
|
148
148
|
request: originalRequest,
|
|
@@ -152,7 +152,7 @@ class Apilogger {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
static logStripeOutgoing(methodName, request, summary) {
|
|
155
|
-
return
|
|
155
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
156
156
|
return yield this.createLogAsync({
|
|
157
157
|
methodName,
|
|
158
158
|
request,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter } from '
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
2
|
import { checkAndFallbackWithNonTCClient } from '../../prisma/prisma.mjs';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var client = require('@prisma/client');
|
|
5
5
|
var constants = require('./constants.js');
|
|
6
6
|
var creditInit = require('../../lib/credit-init.js');
|
|
@@ -114,7 +114,7 @@ class CreditService {
|
|
|
114
114
|
return data;
|
|
115
115
|
}
|
|
116
116
|
executeCreditOperation(userId, amounts, options, tx) {
|
|
117
|
-
return
|
|
117
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
118
118
|
var _a;
|
|
119
119
|
const normalized = this.normalizeAmounts(amounts);
|
|
120
120
|
this.ensureNonNegative(normalized, options.context);
|
|
@@ -155,7 +155,7 @@ class CreditService {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
recordCreditAuditLog(client, userId, operationType, amounts, options) {
|
|
158
|
-
return
|
|
158
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
159
159
|
const auditPayload = [];
|
|
160
160
|
if (amounts.free > 0) {
|
|
161
161
|
auditPayload.push({
|
|
@@ -200,7 +200,7 @@ class CreditService {
|
|
|
200
200
|
}
|
|
201
201
|
// Initialize User Credits, use upsert for easy handle anonymous upgrade to register
|
|
202
202
|
initializeCreditWithFree(init, tx) {
|
|
203
|
-
return
|
|
203
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
204
204
|
const now = new Date();
|
|
205
205
|
const freeStart = now;
|
|
206
206
|
const freeEnd = new Date(now);
|
|
@@ -233,14 +233,14 @@ class CreditService {
|
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
payFailedWatcher(data, tx) {
|
|
236
|
-
return
|
|
236
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
237
237
|
yield creditAuditLog_service.creditAuditLogService.recordAuditLog(data, tx);
|
|
238
238
|
console.warn('payFailedWatcher completed');
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
// Get User Credits
|
|
242
242
|
getCredit(userId, tx) {
|
|
243
|
-
return
|
|
243
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
244
244
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
245
245
|
const credit = yield client.credit.findUnique({
|
|
246
246
|
where: { userId },
|
|
@@ -265,7 +265,7 @@ class CreditService {
|
|
|
265
265
|
}
|
|
266
266
|
// Get Total Credit Balance
|
|
267
267
|
getTotalBalance(userId, tx) {
|
|
268
|
-
return
|
|
268
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
269
269
|
const credits = yield this.getCredit(userId, tx);
|
|
270
270
|
if (!credits)
|
|
271
271
|
return 0;
|
|
@@ -274,7 +274,7 @@ class CreditService {
|
|
|
274
274
|
}
|
|
275
275
|
// Recharge Credits (Transactional)
|
|
276
276
|
rechargeCredit(userId, amounts, options, tx) {
|
|
277
|
-
return
|
|
277
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
278
278
|
return this.executeCreditOperation(userId, amounts, {
|
|
279
279
|
context: 'rechargeCredit',
|
|
280
280
|
operationType: constants.OperationType.RECHARGE,
|
|
@@ -288,7 +288,7 @@ class CreditService {
|
|
|
288
288
|
}
|
|
289
289
|
// Consume Credits (Transactional)
|
|
290
290
|
consumeCredit(userId, amounts, options, tx) {
|
|
291
|
-
return
|
|
291
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
292
292
|
return this.executeCreditOperation(userId, amounts, {
|
|
293
293
|
context: 'consumeCredit',
|
|
294
294
|
operationType: constants.OperationType.CONSUME,
|
|
@@ -301,7 +301,7 @@ class CreditService {
|
|
|
301
301
|
}
|
|
302
302
|
// Freeze Credits
|
|
303
303
|
freezeCredit(userId, amounts, reason, operationReferId, tx) {
|
|
304
|
-
return
|
|
304
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
305
305
|
return this.executeCreditOperation(userId, amounts, {
|
|
306
306
|
context: 'freezeCredit',
|
|
307
307
|
operationType: constants.OperationType.FREEZE,
|
|
@@ -314,7 +314,7 @@ class CreditService {
|
|
|
314
314
|
}
|
|
315
315
|
// Unfreeze Credits
|
|
316
316
|
unfreezeCredit(userId, amounts, reason, operationReferId, tx) {
|
|
317
|
-
return
|
|
317
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
318
318
|
return this.executeCreditOperation(userId, amounts, {
|
|
319
319
|
context: 'unfreezeCredit',
|
|
320
320
|
operationType: constants.OperationType.UNFREEZE,
|
|
@@ -326,7 +326,7 @@ class CreditService {
|
|
|
326
326
|
}
|
|
327
327
|
// Refund Credits
|
|
328
328
|
refundCredit(userId_1, amounts_1, operationReferId_1) {
|
|
329
|
-
return
|
|
329
|
+
return tslib.__awaiter(this, arguments, void 0, function* (userId, amounts, operationReferId, options = {}, tx) {
|
|
330
330
|
var _a;
|
|
331
331
|
return this.executeCreditOperation(userId, amounts, {
|
|
332
332
|
context: 'refundCredit',
|
|
@@ -343,7 +343,7 @@ class CreditService {
|
|
|
343
343
|
}
|
|
344
344
|
// Batch Update Credits (Admin Operation)
|
|
345
345
|
adjustCredit(userId, operationReferId, adjustments, tx) {
|
|
346
|
-
return
|
|
346
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
347
347
|
var _a, _b, _c, _d, _e, _f;
|
|
348
348
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
349
349
|
const currentCredit = yield client.credit.findUnique({
|
|
@@ -403,7 +403,7 @@ class CreditService {
|
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
405
|
purgeCreditsByTypes(userId, reason, operationReferId, types, tx) {
|
|
406
|
-
return
|
|
406
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
407
407
|
const uniqueTypes = Array.from(new Set(types));
|
|
408
408
|
if (uniqueTypes.length === 0) {
|
|
409
409
|
throw new Error('purgeCreditsByTypes: no credit types specified');
|
|
@@ -437,23 +437,23 @@ class CreditService {
|
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
439
|
purgePaidCredit(userId, reason, operationReferId, tx) {
|
|
440
|
-
return
|
|
440
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
441
441
|
return this.purgeCreditsByTypes(userId, reason, operationReferId, [constants.CreditType.PAID], tx);
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
purgeFreeCredit(userId, reason, operationReferId, tx) {
|
|
445
|
-
return
|
|
445
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
446
446
|
return this.purgeCreditsByTypes(userId, reason, operationReferId, [constants.CreditType.FREE], tx);
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
449
|
purgeCredit(userId, reason, operationReferId, tx) {
|
|
450
|
-
return
|
|
450
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
451
451
|
return this.purgeCreditsByTypes(userId, reason, operationReferId, [constants.CreditType.FREE, constants.CreditType.PAID, constants.CreditType.ONE_TIME_PAID], tx);
|
|
452
452
|
});
|
|
453
453
|
}
|
|
454
454
|
// Get Users with Low Credit Balance
|
|
455
455
|
getLowBalanceUsers() {
|
|
456
|
-
return
|
|
456
|
+
return tslib.__awaiter(this, arguments, void 0, function* (threshold = 10, tx) {
|
|
457
457
|
const client$1 = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
458
458
|
const query = client.Prisma.sql `
|
|
459
459
|
SELECT * FROM credits
|
|
@@ -465,7 +465,7 @@ class CreditService {
|
|
|
465
465
|
}
|
|
466
466
|
// Get Credit Statistics
|
|
467
467
|
getCreditStats(tx) {
|
|
468
|
-
return
|
|
468
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
469
469
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
470
470
|
const stats = yield client.credit.aggregate({
|
|
471
471
|
_count: true,
|
|
@@ -503,7 +503,7 @@ class CreditService {
|
|
|
503
503
|
}
|
|
504
504
|
// Check if User has Enough Credits
|
|
505
505
|
hasEnoughCredits(userId, amount, tx) {
|
|
506
|
-
return
|
|
506
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
507
507
|
const totalBalance = yield this.getTotalBalance(userId, tx);
|
|
508
508
|
return totalBalance >= amount;
|
|
509
509
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter } from '
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
2
|
import { Prisma } from '@prisma/client';
|
|
3
3
|
import { CreditType, OperationType } from './constants.mjs';
|
|
4
4
|
import { freeExpiredDays } from '../../lib/credit-init.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var client = require('@prisma/client');
|
|
5
5
|
var constants = require('./constants.js');
|
|
6
6
|
var prisma = require('../../prisma/prisma.js');
|
|
@@ -9,7 +9,7 @@ var prisma = require('../../prisma/prisma.js');
|
|
|
9
9
|
class CreditAuditLogService {
|
|
10
10
|
// Record Credit Audit
|
|
11
11
|
recordAuditLog(data, tx) {
|
|
12
|
-
return
|
|
12
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
13
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
14
14
|
return yield client.creditAuditLog.create({
|
|
15
15
|
data: {
|
|
@@ -25,13 +25,13 @@ class CreditAuditLogService {
|
|
|
25
25
|
}
|
|
26
26
|
// Record Credit Operation (alias for recordUsage)
|
|
27
27
|
recordCreditOperation(data, tx) {
|
|
28
|
-
return
|
|
28
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
return this.recordAuditLog(data, tx);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
// Batch Record Credit Audit
|
|
33
33
|
recordBatchAudit(auditLogs, tx) {
|
|
34
|
-
return
|
|
34
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
36
36
|
const result = yield client.creditAuditLog.createMany({
|
|
37
37
|
data: auditLogs,
|
|
@@ -41,7 +41,7 @@ class CreditAuditLogService {
|
|
|
41
41
|
}
|
|
42
42
|
// Get User Credit Audit History
|
|
43
43
|
getUserCreditAuditHistory(userId, params, tx) {
|
|
44
|
-
return
|
|
44
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
46
46
|
const where = { userId, deleted: 0 };
|
|
47
47
|
if (params === null || params === void 0 ? void 0 : params.creditType) {
|
|
@@ -74,7 +74,7 @@ class CreditAuditLogService {
|
|
|
74
74
|
}
|
|
75
75
|
// Get Credit Audit Record by operationReferId
|
|
76
76
|
getCreditAuditList(operationReferId, tx) {
|
|
77
|
-
return
|
|
77
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
78
78
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
79
79
|
return yield client.creditAuditLog.findMany({
|
|
80
80
|
where: { operationReferId, deleted: 0 },
|
|
@@ -84,7 +84,7 @@ class CreditAuditLogService {
|
|
|
84
84
|
}
|
|
85
85
|
// Get User Credit Audit Statistics
|
|
86
86
|
getUserCreditAuditStats(userId, startDate, endDate, tx) {
|
|
87
|
-
return
|
|
87
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
88
88
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
89
89
|
const where = { userId, deleted: 0 };
|
|
90
90
|
if (startDate || endDate) {
|
|
@@ -148,7 +148,7 @@ class CreditAuditLogService {
|
|
|
148
148
|
}
|
|
149
149
|
// Get Popular Features
|
|
150
150
|
getPopularFeatures() {
|
|
151
|
-
return
|
|
151
|
+
return tslib.__awaiter(this, arguments, void 0, function* (limit = 10, startDate, endDate, tx) {
|
|
152
152
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
153
153
|
const where = {
|
|
154
154
|
operationType: constants.OperationType.CONSUME,
|
|
@@ -185,7 +185,7 @@ class CreditAuditLogService {
|
|
|
185
185
|
}
|
|
186
186
|
// Get Daily Credit Usage Trend
|
|
187
187
|
getDailyUsageTrend() {
|
|
188
|
-
return
|
|
188
|
+
return tslib.__awaiter(this, arguments, void 0, function* (days = 30, userId, tx) {
|
|
189
189
|
const startDate = new Date();
|
|
190
190
|
startDate.setDate(startDate.getDate() - days);
|
|
191
191
|
const client$1 = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
@@ -212,7 +212,7 @@ class CreditAuditLogService {
|
|
|
212
212
|
}
|
|
213
213
|
// Get Recent Credit Usage Operations
|
|
214
214
|
getRecentOperations(userId_1) {
|
|
215
|
-
return
|
|
215
|
+
return tslib.__awaiter(this, arguments, void 0, function* (userId, limit = 10, tx) {
|
|
216
216
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
217
217
|
return yield client.creditAuditLog.findMany({
|
|
218
218
|
where: { userId, deleted: 0 },
|
|
@@ -223,7 +223,7 @@ class CreditAuditLogService {
|
|
|
223
223
|
}
|
|
224
224
|
// Soft Delete Old Credit Usage Records
|
|
225
225
|
deleteOldRecords() {
|
|
226
|
-
return
|
|
226
|
+
return tslib.__awaiter(this, arguments, void 0, function* (daysToKeep = 365, tx) {
|
|
227
227
|
const cutoffDate = new Date();
|
|
228
228
|
cutoffDate.setDate(cutoffDate.getDate() - daysToKeep);
|
|
229
229
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
@@ -243,7 +243,7 @@ class CreditAuditLogService {
|
|
|
243
243
|
}
|
|
244
244
|
// Get System-wide Credit Usage Statistics
|
|
245
245
|
getSystemStats(tx) {
|
|
246
|
-
return
|
|
246
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
247
247
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
248
248
|
const [totalUsers, totalOperations, consumeStats, rechargeStats,] = yield Promise.all([
|
|
249
249
|
client.creditAuditLog.groupBy({
|
|
@@ -285,7 +285,7 @@ class CreditAuditLogService {
|
|
|
285
285
|
}
|
|
286
286
|
// Check for Duplicate Operations
|
|
287
287
|
isDuplicateOperation(userId, operationReferId, operationType, tx) {
|
|
288
|
-
return
|
|
288
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
289
289
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
290
290
|
const count = yield client.creditAuditLog.count({
|
|
291
291
|
where: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter } from '
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
2
|
import { Prisma } from '@prisma/client';
|
|
3
3
|
import { OperationType, CreditType } from './constants.mjs';
|
|
4
4
|
import { checkAndFallbackWithNonTCClient } from '../../prisma/prisma.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var constants = require('./constants.js');
|
|
5
5
|
var prisma = require('../../prisma/prisma.js');
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ class SubscriptionService {
|
|
|
16
16
|
* @returns The created placeholder subscription record
|
|
17
17
|
*/
|
|
18
18
|
initializeSubscription(userId, tx) {
|
|
19
|
-
return
|
|
19
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
21
21
|
return yield client.subscription.create({
|
|
22
22
|
data: {
|
|
@@ -29,7 +29,7 @@ class SubscriptionService {
|
|
|
29
29
|
}
|
|
30
30
|
// Create a new subscription
|
|
31
31
|
createSubscription(data, tx) {
|
|
32
|
-
return
|
|
32
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
34
34
|
return yield client.subscription.create({
|
|
35
35
|
data: {
|
|
@@ -48,7 +48,7 @@ class SubscriptionService {
|
|
|
48
48
|
}
|
|
49
49
|
// Find subscription by pay subscription ID
|
|
50
50
|
findByPaySubscriptionId(paySubscriptionId, tx) {
|
|
51
|
-
return
|
|
51
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
52
52
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
53
53
|
return yield client.subscription.findFirst({
|
|
54
54
|
where: { paySubscriptionId, deleted: 0 }
|
|
@@ -57,7 +57,7 @@ class SubscriptionService {
|
|
|
57
57
|
}
|
|
58
58
|
// Get user's active subscription
|
|
59
59
|
getActiveSubscription(userId, tx) {
|
|
60
|
-
return
|
|
60
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
62
62
|
return yield client.subscription.findUnique({
|
|
63
63
|
where: {
|
|
@@ -69,7 +69,7 @@ class SubscriptionService {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
getNonActiveSubscription(userId, tx) {
|
|
72
|
-
return
|
|
72
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
74
74
|
return yield client.subscription.findUnique({
|
|
75
75
|
where: {
|
|
@@ -82,7 +82,7 @@ class SubscriptionService {
|
|
|
82
82
|
}
|
|
83
83
|
// Update subscription
|
|
84
84
|
updateSubscription(id, data, tx) {
|
|
85
|
-
return
|
|
85
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
86
86
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
87
87
|
return yield client.subscription.update({
|
|
88
88
|
where: { id },
|
|
@@ -92,7 +92,7 @@ class SubscriptionService {
|
|
|
92
92
|
}
|
|
93
93
|
// Update subscription status
|
|
94
94
|
updateStatus(id, status, tx) {
|
|
95
|
-
return
|
|
95
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
96
96
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
97
97
|
return yield client.subscription.update({
|
|
98
98
|
where: { id },
|
|
@@ -102,7 +102,7 @@ class SubscriptionService {
|
|
|
102
102
|
}
|
|
103
103
|
// Update subscription period
|
|
104
104
|
updatePeriod(id, subPeriodStart, subPeriodEnd, tx) {
|
|
105
|
-
return
|
|
105
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
106
106
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
107
107
|
return yield client.subscription.update({
|
|
108
108
|
where: { id },
|
|
@@ -115,7 +115,7 @@ class SubscriptionService {
|
|
|
115
115
|
}
|
|
116
116
|
// Cancel subscription
|
|
117
117
|
cancelSubscription(id_1) {
|
|
118
|
-
return
|
|
118
|
+
return tslib.__awaiter(this, arguments, void 0, function* (id, cancelAtPeriodEnd = true, tx) {
|
|
119
119
|
const updateData = {
|
|
120
120
|
status: constants.SubscriptionStatus.CANCELED,
|
|
121
121
|
};
|
|
@@ -131,7 +131,7 @@ class SubscriptionService {
|
|
|
131
131
|
}
|
|
132
132
|
// Renew subscription
|
|
133
133
|
renewSubscription(id, newPeriodEnd, creditsToAdd, tx) {
|
|
134
|
-
return
|
|
134
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
135
135
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
136
136
|
const subscription = yield client.subscription.findFirst({
|
|
137
137
|
where: { id },
|
|
@@ -154,7 +154,7 @@ class SubscriptionService {
|
|
|
154
154
|
}
|
|
155
155
|
// Soft Delete subscription
|
|
156
156
|
deleteSubscription(id, tx) {
|
|
157
|
-
return
|
|
157
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
158
158
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
159
159
|
yield client.subscription.update({
|
|
160
160
|
where: { id },
|
|
@@ -164,7 +164,7 @@ class SubscriptionService {
|
|
|
164
164
|
}
|
|
165
165
|
// Get expiring subscriptions (within 7 days)
|
|
166
166
|
getExpiringSubscriptions() {
|
|
167
|
-
return
|
|
167
|
+
return tslib.__awaiter(this, arguments, void 0, function* (days = 7, tx) {
|
|
168
168
|
const now = new Date();
|
|
169
169
|
const expiryDate = new Date();
|
|
170
170
|
expiryDate.setDate(expiryDate.getDate() + days);
|
|
@@ -183,7 +183,7 @@ class SubscriptionService {
|
|
|
183
183
|
}
|
|
184
184
|
// Get expired subscriptions
|
|
185
185
|
getExpiredSubscriptions(tx) {
|
|
186
|
-
return
|
|
186
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
187
187
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
188
188
|
return yield client.subscription.findMany({
|
|
189
189
|
where: {
|
|
@@ -198,7 +198,7 @@ class SubscriptionService {
|
|
|
198
198
|
}
|
|
199
199
|
// Update expired subscriptions status
|
|
200
200
|
updateExpiredSubscriptions(tx) {
|
|
201
|
-
return
|
|
201
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
202
202
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
203
203
|
const result = yield client.subscription.updateMany({
|
|
204
204
|
where: {
|
|
@@ -217,7 +217,7 @@ class SubscriptionService {
|
|
|
217
217
|
}
|
|
218
218
|
// Get subscription statistics
|
|
219
219
|
getSubscriptionStats(tx) {
|
|
220
|
-
return
|
|
220
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
221
221
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
222
222
|
const [total, active, canceled, pastDue, incomplete, trialing] = yield Promise.all([
|
|
223
223
|
client.subscription.count({ where: { deleted: 0 } }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter } from '
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
2
|
import { SubscriptionStatus } from './constants.mjs';
|
|
3
3
|
import { checkAndFallbackWithNonTCClient } from '../../prisma/prisma.mjs';
|
|
4
4
|
|