@windrun-huaiin/backend-core 13.0.0 → 14.1.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/dist/_virtual/index.js +7 -3
- package/dist/_virtual/index.mjs +5 -3
- package/dist/_virtual/index2.js +2 -6
- package/dist/_virtual/index2.mjs +2 -6
- package/dist/index.js +3 -1
- package/dist/index.mjs +2 -2
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.mjs +2 -2
- package/dist/lib/stripe-config.d.ts +1 -1
- package/dist/lib/stripe-config.d.ts.map +1 -1
- package/dist/lib/stripe-config.js +25 -16
- package/dist/lib/stripe-config.mjs +25 -16
- package/dist/lib/upstash/qstash.d.ts.map +1 -1
- package/dist/lib/upstash/qstash.js +66 -62
- package/dist/lib/upstash/qstash.mjs +67 -63
- package/dist/lib/upstash/redis-counter.d.ts.map +1 -1
- package/dist/lib/upstash/redis-counter.js +9 -24
- package/dist/lib/upstash/redis-counter.mjs +10 -25
- package/dist/lib/upstash/redis-favorite.d.ts.map +1 -1
- package/dist/lib/upstash/redis-favorite.js +22 -36
- package/dist/lib/upstash/redis-favorite.mjs +23 -37
- package/dist/lib/upstash/redis-like.d.ts.map +1 -1
- package/dist/lib/upstash/redis-like.js +22 -36
- package/dist/lib/upstash/redis-like.mjs +23 -37
- package/dist/lib/upstash/redis-lock.d.ts.map +1 -1
- package/dist/lib/upstash/redis-lock.js +22 -38
- package/dist/lib/upstash/redis-lock.mjs +23 -39
- package/dist/lib/upstash/redis-structures.d.ts.map +1 -1
- package/dist/lib/upstash/redis-structures.js +77 -113
- package/dist/lib/upstash/redis-structures.mjs +78 -114
- package/dist/lib/upstash-config.d.ts +9 -1
- package/dist/lib/upstash-config.d.ts.map +1 -1
- package/dist/lib/upstash-config.js +221 -27
- package/dist/lib/upstash-config.mjs +220 -28
- package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.js → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js} +897 -468
- package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.mjs → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs} +895 -468
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.js → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js} +657 -40
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.mjs → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs} +657 -41
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.js +6 -5
- package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.mjs +2 -2
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +1 -1
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +6 -6
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +2 -2
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +7 -5
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +4 -2
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +1 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +3 -1
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +6 -4
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +6 -4
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +7 -5
- package/dist/services/stripe/webhook-handler.js +4 -2
- package/dist/services/stripe/webhook-handler.mjs +3 -1
- package/package.json +5 -5
- package/src/lib/stripe-config.ts +27 -15
- package/src/lib/upstash/qstash.ts +64 -62
- package/src/lib/upstash/redis-counter.ts +10 -26
- package/src/lib/upstash/redis-favorite.ts +23 -42
- package/src/lib/upstash/redis-like.ts +23 -42
- package/src/lib/upstash/redis-lock.ts +23 -49
- package/src/lib/upstash/redis-structures.ts +82 -131
- package/src/lib/upstash-config.ts +231 -24
- package/src/services/stripe/webhook-handler.ts +3 -1
- package/dist/_virtual/index3.js +0 -5
- package/dist/_virtual/index3.mjs +0 -3
- package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.js +0 -191
- package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.mjs +0 -189
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +0 -54
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +0 -51
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +0 -44
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +0 -35
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +0 -31
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +0 -18
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +0 -587
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +0 -527
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +0 -447
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +0 -399
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +0 -245
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +0 -232
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +0 -68
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +0 -62
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +0 -39
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +0 -37
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +0 -80
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +0 -75
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +0 -101
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +0 -86
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +0 -102
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +0 -76
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +0 -56
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +0 -52
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +0 -1205
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +0 -1157
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +0 -407
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +0 -374
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +0 -7
package/dist/_virtual/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _commonjsHelpers = require('./_commonjsHelpers.js');
|
|
6
|
+
var index = require('../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js');
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
var cryptoJsExports = index.__require();
|
|
9
|
+
var crypto2 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(cryptoJsExports);
|
|
10
|
+
|
|
11
|
+
exports.default = crypto2;
|
package/dist/_virtual/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDefaultExportFromCjs } from './_commonjsHelpers.mjs';
|
|
2
|
+
import { __require as requireCryptoJs } from '../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs';
|
|
2
3
|
|
|
3
|
-
var
|
|
4
|
+
var cryptoJsExports = requireCryptoJs();
|
|
5
|
+
var crypto2 = /*@__PURE__*/getDefaultExportFromCjs(cryptoJsExports);
|
|
4
6
|
|
|
5
|
-
export {
|
|
7
|
+
export { crypto2 as default };
|
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var index = require('../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js');
|
|
3
|
+
var cryptoJs = {exports: {}};
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
var crypto2 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(cryptoJsExports);
|
|
8
|
-
|
|
9
|
-
module.exports = crypto2;
|
|
5
|
+
exports.__module = cryptoJs;
|
package/dist/_virtual/index2.mjs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { __require as requireCryptoJs } from '../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs';
|
|
1
|
+
var cryptoJs = {exports: {}};
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
var crypto2 = /*@__PURE__*/getDefaultExportFromCjs(cryptoJsExports);
|
|
6
|
-
|
|
7
|
-
export { crypto2 as default };
|
|
3
|
+
export { cryptoJs as __module };
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ exports.createCheckoutSession = stripeConfig.createCheckoutSession;
|
|
|
85
85
|
exports.createCustomerPortalSession = stripeConfig.createCustomerPortalSession;
|
|
86
86
|
exports.createOrGetCustomer = stripeConfig.createOrGetCustomer;
|
|
87
87
|
exports.fetchPaymentId = stripeConfig.fetchPaymentId;
|
|
88
|
-
exports.
|
|
88
|
+
exports.getStripe = stripeConfig.getStripe;
|
|
89
89
|
exports.updateSubscription = stripeConfig.updateSubscription;
|
|
90
90
|
exports.validateStripeWebhook = stripeConfig.validateStripeWebhook;
|
|
91
91
|
exports.ApiAuthUtils = authUtils.ApiAuthUtils;
|
|
@@ -94,6 +94,8 @@ exports.requireAuth = authUtils.requireAuth;
|
|
|
94
94
|
exports.requireAuthWithUser = authUtils.requireAuthWithUser;
|
|
95
95
|
exports.getQstash = upstashConfig.getQstash;
|
|
96
96
|
exports.getRedis = upstashConfig.getRedis;
|
|
97
|
+
exports.withQstash = upstashConfig.withQstash;
|
|
98
|
+
exports.withRedis = upstashConfig.withRedis;
|
|
97
99
|
exports.acquireLock = redisLock.acquireLock;
|
|
98
100
|
exports.releaseLock = redisLock.releaseLock;
|
|
99
101
|
exports.withLock = redisLock.withLock;
|
package/dist/index.mjs
CHANGED
|
@@ -16,9 +16,9 @@ export { getActiveProviderConfig, getCreditsFromPriceId, getPriceConfig, moneyPr
|
|
|
16
16
|
export { getMoneyPriceInitUserContext } from './lib/money-price-helper.mjs';
|
|
17
17
|
export { fingerprintConfig } from './lib/fingerprint-config.mjs';
|
|
18
18
|
export { creditsConfig, freeAmount, freeExpiredDays, freeRegisterAmount, oneTimeExpiredDays } from './lib/credit-init.mjs';
|
|
19
|
-
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId,
|
|
19
|
+
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId, getStripe, updateSubscription, validateStripeWebhook } from './lib/stripe-config.mjs';
|
|
20
20
|
export { ApiAuthUtils, getAuthenticatedUser, requireAuth, requireAuthWithUser } from './lib/auth-utils.mjs';
|
|
21
|
-
export { getQstash, getRedis } from './lib/upstash-config.mjs';
|
|
21
|
+
export { getQstash, getRedis, withQstash, withRedis } from './lib/upstash-config.mjs';
|
|
22
22
|
export { acquireLock, releaseLock, withLock } from './lib/upstash/redis-lock.mjs';
|
|
23
23
|
export { getTargetLikeCount, getUserLikedTargets, isTargetLiked, likeTarget, unlikeTarget } from './lib/upstash/redis-like.mjs';
|
|
24
24
|
export { addFavorite, getFavoriteCount, getUserFavorites, isFavorited, removeFavorite } from './lib/upstash/redis-favorite.mjs';
|
package/dist/lib/index.js
CHANGED
|
@@ -33,7 +33,7 @@ exports.createCheckoutSession = stripeConfig.createCheckoutSession;
|
|
|
33
33
|
exports.createCustomerPortalSession = stripeConfig.createCustomerPortalSession;
|
|
34
34
|
exports.createOrGetCustomer = stripeConfig.createOrGetCustomer;
|
|
35
35
|
exports.fetchPaymentId = stripeConfig.fetchPaymentId;
|
|
36
|
-
exports.
|
|
36
|
+
exports.getStripe = stripeConfig.getStripe;
|
|
37
37
|
exports.updateSubscription = stripeConfig.updateSubscription;
|
|
38
38
|
exports.validateStripeWebhook = stripeConfig.validateStripeWebhook;
|
|
39
39
|
exports.ApiAuthUtils = authUtils.ApiAuthUtils;
|
|
@@ -42,6 +42,8 @@ exports.requireAuth = authUtils.requireAuth;
|
|
|
42
42
|
exports.requireAuthWithUser = authUtils.requireAuthWithUser;
|
|
43
43
|
exports.getQstash = upstashConfig.getQstash;
|
|
44
44
|
exports.getRedis = upstashConfig.getRedis;
|
|
45
|
+
exports.withQstash = upstashConfig.withQstash;
|
|
46
|
+
exports.withRedis = upstashConfig.withRedis;
|
|
45
47
|
exports.acquireLock = redisLock.acquireLock;
|
|
46
48
|
exports.releaseLock = redisLock.releaseLock;
|
|
47
49
|
exports.withLock = redisLock.withLock;
|
package/dist/lib/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ export { getActiveProviderConfig, getCreditsFromPriceId, getPriceConfig, moneyPr
|
|
|
2
2
|
export { getMoneyPriceInitUserContext } from './money-price-helper.mjs';
|
|
3
3
|
export { fingerprintConfig } from './fingerprint-config.mjs';
|
|
4
4
|
export { creditsConfig, freeAmount, freeExpiredDays, freeRegisterAmount, oneTimeExpiredDays } from './credit-init.mjs';
|
|
5
|
-
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId,
|
|
5
|
+
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId, getStripe, updateSubscription, validateStripeWebhook } from './stripe-config.mjs';
|
|
6
6
|
export { ApiAuthUtils, getAuthenticatedUser, requireAuth, requireAuthWithUser } from './auth-utils.mjs';
|
|
7
|
-
export { getQstash, getRedis } from './upstash-config.mjs';
|
|
7
|
+
export { getQstash, getRedis, withQstash, withRedis } from './upstash-config.mjs';
|
|
8
8
|
export { acquireLock, releaseLock, withLock } from './upstash/redis-lock.mjs';
|
|
9
9
|
export { getTargetLikeCount, getUserLikedTargets, isTargetLiked, likeTarget, unlikeTarget } from './upstash/redis-like.mjs';
|
|
10
10
|
export { addFavorite, getFavoriteCount, getUserFavorites, isFavorited, removeFavorite } from './upstash/redis-favorite.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Stripe from 'stripe';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getStripe: () => Stripe;
|
|
3
3
|
export declare const validateStripeWebhook: (payload: string | Buffer, signature: string, secret: string) => Stripe.Event;
|
|
4
4
|
export interface BasicCheckoutSessionParams {
|
|
5
5
|
priceId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-config.d.ts","sourceRoot":"","sources":["../../src/lib/stripe-config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"stripe-config.d.ts","sourceRoot":"","sources":["../../src/lib/stripe-config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAK5B,eAAO,MAAM,SAAS,QAAO,MAa5B,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAChC,SAAS,MAAM,GAAG,MAAM,EACxB,WAAW,MAAM,EACjB,QAAQ,MAAM,KACb,MAAM,CAAC,KAET,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAGnB;AAGD,eAAO,MAAM,qBAAqB,GAChC,QAAQ,0BAA0B,EAClC,mBAAmB,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,gBAAgB,KACtE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAgFjC,CAAC;AAGF,eAAO,MAAM,cAAc,GAAU,WAAW,MAAM,KAAI,OAAO,CAAC,MAAM,CAQvE,CAAA;AAGD,eAAO,MAAM,mBAAmB,GAAU,QAAQ;IAChD,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,OAAO,CAAC,MAAM,CA0FjB,CAAC;AAGF,eAAO,MAAM,kBAAkB,GAAU,QAAQ;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,mBAAmB,GAAG,MAAM,GAAG,gBAAgB,CAAC;CACrE,KAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAiC9B,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAU,QAAQ;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAqBvC,CAAC;AAGF,eAAO,MAAM,kBAAkB,GAC7B,gBAAgB,MAAM,EACtB,oBAAmB,OAAc,KAChC,OAAO,CAAC,MAAM,CAAC,YAAY,CAiC7B,CAAC;AAEF,qBAAa,6BAA8B,SAAQ,KAAK;;CAKvD"}
|
|
@@ -9,13 +9,22 @@ require('@prisma/client');
|
|
|
9
9
|
require('../prisma/prisma.js');
|
|
10
10
|
var apilog_service = require('../services/database/apilog.service.js');
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
let stripeInstance = null;
|
|
13
|
+
const getStripe = () => {
|
|
14
|
+
const apiKey = process.env.STRIPE_SECRET_KEY;
|
|
15
|
+
if (!apiKey) {
|
|
16
|
+
throw new Error('STRIPE_SECRET_KEY is not configured');
|
|
17
|
+
}
|
|
18
|
+
if (!stripeInstance) {
|
|
19
|
+
stripeInstance = new Stripe(apiKey, {
|
|
20
|
+
apiVersion: '2025-11-17.clover',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return stripeInstance;
|
|
24
|
+
};
|
|
16
25
|
// Helper function to validate webhook signature
|
|
17
26
|
const validateStripeWebhook = (payload, signature, secret) => {
|
|
18
|
-
return
|
|
27
|
+
return getStripe().webhooks.constructEvent(payload, signature, secret);
|
|
19
28
|
};
|
|
20
29
|
// Helper function to create checkout session
|
|
21
30
|
const createCheckoutSession = (params, subscriptionData) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -64,7 +73,7 @@ const createCheckoutSession = (params, subscriptionData) => tslib_es6.__awaiter(
|
|
|
64
73
|
// Create log record with request
|
|
65
74
|
const logId = yield apilog_service.Apilogger.logStripeOutgoing('createCheckoutSession', params);
|
|
66
75
|
try {
|
|
67
|
-
const session = yield
|
|
76
|
+
const session = yield getStripe().checkout.sessions.create(sessionParams);
|
|
68
77
|
// Update log record with response
|
|
69
78
|
apilog_service.Apilogger.updateResponse(logId, {
|
|
70
79
|
session_id: session.id,
|
|
@@ -84,7 +93,7 @@ const createCheckoutSession = (params, subscriptionData) => tslib_es6.__awaiter(
|
|
|
84
93
|
// 根据发票ID去查支付ID
|
|
85
94
|
const fetchPaymentId = (invoiceId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
86
95
|
var _a, _b;
|
|
87
|
-
const fullInvoice = yield
|
|
96
|
+
const fullInvoice = yield getStripe().invoices.retrieve(invoiceId, {
|
|
88
97
|
expand: ['payments']
|
|
89
98
|
});
|
|
90
99
|
const payment = (_a = fullInvoice.payments) === null || _a === void 0 ? void 0 : _a.data[0];
|
|
@@ -109,7 +118,7 @@ const createOrGetCustomer = (params) => tslib_es6.__awaiter(void 0, void 0, void
|
|
|
109
118
|
});
|
|
110
119
|
if (user.stripeCusId) {
|
|
111
120
|
try {
|
|
112
|
-
const customer = yield
|
|
121
|
+
const customer = yield getStripe().customers.retrieve(user.stripeCusId);
|
|
113
122
|
if ('deleted' in customer) {
|
|
114
123
|
yield setStripeCustomerId(null);
|
|
115
124
|
}
|
|
@@ -127,7 +136,7 @@ const createOrGetCustomer = (params) => tslib_es6.__awaiter(void 0, void 0, void
|
|
|
127
136
|
}
|
|
128
137
|
}
|
|
129
138
|
if (user.email) {
|
|
130
|
-
const existingCustomers = yield
|
|
139
|
+
const existingCustomers = yield getStripe().customers.list({
|
|
131
140
|
email: user.email,
|
|
132
141
|
limit: 1,
|
|
133
142
|
});
|
|
@@ -159,7 +168,7 @@ const createOrGetCustomer = (params) => tslib_es6.__awaiter(void 0, void 0, void
|
|
|
159
168
|
name: customerParams.name,
|
|
160
169
|
});
|
|
161
170
|
try {
|
|
162
|
-
const customer = yield
|
|
171
|
+
const customer = yield getStripe().customers.create(customerParams);
|
|
163
172
|
yield setStripeCustomerId(customer.id);
|
|
164
173
|
// Update log record with response
|
|
165
174
|
apilog_service.Apilogger.updateResponse(logId, {
|
|
@@ -179,11 +188,11 @@ const createOrGetCustomer = (params) => tslib_es6.__awaiter(void 0, void 0, void
|
|
|
179
188
|
// Helper function to update subscription
|
|
180
189
|
const updateSubscription = (params) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
181
190
|
const { subscriptionId, priceId, prorationBehavior = 'create_prorations' } = params;
|
|
182
|
-
const subscription = yield
|
|
191
|
+
const subscription = yield getStripe().subscriptions.retrieve(subscriptionId);
|
|
183
192
|
// Create log record with request
|
|
184
193
|
const logId = yield apilog_service.Apilogger.logStripeOutgoing('updateSubscription', params);
|
|
185
194
|
try {
|
|
186
|
-
const updatedSubscription = yield
|
|
195
|
+
const updatedSubscription = yield getStripe().subscriptions.update(subscriptionId, {
|
|
187
196
|
items: [
|
|
188
197
|
{
|
|
189
198
|
id: subscription.items.data[0].id,
|
|
@@ -210,7 +219,7 @@ const updateSubscription = (params) => tslib_es6.__awaiter(void 0, void 0, void
|
|
|
210
219
|
const createCustomerPortalSession = (params) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
211
220
|
const logId = yield apilog_service.Apilogger.logStripeOutgoing('createCustomerPortalSession', params);
|
|
212
221
|
try {
|
|
213
|
-
const session = yield
|
|
222
|
+
const session = yield getStripe().billingPortal.sessions.create({
|
|
214
223
|
customer: params.customerId,
|
|
215
224
|
return_url: params.returnUrl,
|
|
216
225
|
});
|
|
@@ -237,12 +246,12 @@ const cancelSubscription = (subscriptionId_1, ...args_1) => tslib_es6.__awaiter(
|
|
|
237
246
|
try {
|
|
238
247
|
let result;
|
|
239
248
|
if (cancelAtPeriodEnd) {
|
|
240
|
-
result = yield
|
|
249
|
+
result = yield getStripe().subscriptions.update(subscriptionId, {
|
|
241
250
|
cancel_at_period_end: true,
|
|
242
251
|
});
|
|
243
252
|
}
|
|
244
253
|
else {
|
|
245
|
-
result = yield
|
|
254
|
+
result = yield getStripe().subscriptions.cancel(subscriptionId);
|
|
246
255
|
}
|
|
247
256
|
// Update log record with response
|
|
248
257
|
apilog_service.Apilogger.updateResponse(logId, {
|
|
@@ -273,6 +282,6 @@ exports.createCheckoutSession = createCheckoutSession;
|
|
|
273
282
|
exports.createCustomerPortalSession = createCustomerPortalSession;
|
|
274
283
|
exports.createOrGetCustomer = createOrGetCustomer;
|
|
275
284
|
exports.fetchPaymentId = fetchPaymentId;
|
|
276
|
-
exports.
|
|
285
|
+
exports.getStripe = getStripe;
|
|
277
286
|
exports.updateSubscription = updateSubscription;
|
|
278
287
|
exports.validateStripeWebhook = validateStripeWebhook;
|
|
@@ -7,13 +7,22 @@ import '@prisma/client';
|
|
|
7
7
|
import '../prisma/prisma.mjs';
|
|
8
8
|
import { Apilogger } from '../services/database/apilog.service.mjs';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
let stripeInstance = null;
|
|
11
|
+
const getStripe = () => {
|
|
12
|
+
const apiKey = process.env.STRIPE_SECRET_KEY;
|
|
13
|
+
if (!apiKey) {
|
|
14
|
+
throw new Error('STRIPE_SECRET_KEY is not configured');
|
|
15
|
+
}
|
|
16
|
+
if (!stripeInstance) {
|
|
17
|
+
stripeInstance = new Stripe(apiKey, {
|
|
18
|
+
apiVersion: '2025-11-17.clover',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return stripeInstance;
|
|
22
|
+
};
|
|
14
23
|
// Helper function to validate webhook signature
|
|
15
24
|
const validateStripeWebhook = (payload, signature, secret) => {
|
|
16
|
-
return
|
|
25
|
+
return getStripe().webhooks.constructEvent(payload, signature, secret);
|
|
17
26
|
};
|
|
18
27
|
// Helper function to create checkout session
|
|
19
28
|
const createCheckoutSession = (params, subscriptionData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -62,7 +71,7 @@ const createCheckoutSession = (params, subscriptionData) => __awaiter(void 0, vo
|
|
|
62
71
|
// Create log record with request
|
|
63
72
|
const logId = yield Apilogger.logStripeOutgoing('createCheckoutSession', params);
|
|
64
73
|
try {
|
|
65
|
-
const session = yield
|
|
74
|
+
const session = yield getStripe().checkout.sessions.create(sessionParams);
|
|
66
75
|
// Update log record with response
|
|
67
76
|
Apilogger.updateResponse(logId, {
|
|
68
77
|
session_id: session.id,
|
|
@@ -82,7 +91,7 @@ const createCheckoutSession = (params, subscriptionData) => __awaiter(void 0, vo
|
|
|
82
91
|
// 根据发票ID去查支付ID
|
|
83
92
|
const fetchPaymentId = (invoiceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
93
|
var _a, _b;
|
|
85
|
-
const fullInvoice = yield
|
|
94
|
+
const fullInvoice = yield getStripe().invoices.retrieve(invoiceId, {
|
|
86
95
|
expand: ['payments']
|
|
87
96
|
});
|
|
88
97
|
const payment = (_a = fullInvoice.payments) === null || _a === void 0 ? void 0 : _a.data[0];
|
|
@@ -107,7 +116,7 @@ const createOrGetCustomer = (params) => __awaiter(void 0, void 0, void 0, functi
|
|
|
107
116
|
});
|
|
108
117
|
if (user.stripeCusId) {
|
|
109
118
|
try {
|
|
110
|
-
const customer = yield
|
|
119
|
+
const customer = yield getStripe().customers.retrieve(user.stripeCusId);
|
|
111
120
|
if ('deleted' in customer) {
|
|
112
121
|
yield setStripeCustomerId(null);
|
|
113
122
|
}
|
|
@@ -125,7 +134,7 @@ const createOrGetCustomer = (params) => __awaiter(void 0, void 0, void 0, functi
|
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
if (user.email) {
|
|
128
|
-
const existingCustomers = yield
|
|
137
|
+
const existingCustomers = yield getStripe().customers.list({
|
|
129
138
|
email: user.email,
|
|
130
139
|
limit: 1,
|
|
131
140
|
});
|
|
@@ -157,7 +166,7 @@ const createOrGetCustomer = (params) => __awaiter(void 0, void 0, void 0, functi
|
|
|
157
166
|
name: customerParams.name,
|
|
158
167
|
});
|
|
159
168
|
try {
|
|
160
|
-
const customer = yield
|
|
169
|
+
const customer = yield getStripe().customers.create(customerParams);
|
|
161
170
|
yield setStripeCustomerId(customer.id);
|
|
162
171
|
// Update log record with response
|
|
163
172
|
Apilogger.updateResponse(logId, {
|
|
@@ -177,11 +186,11 @@ const createOrGetCustomer = (params) => __awaiter(void 0, void 0, void 0, functi
|
|
|
177
186
|
// Helper function to update subscription
|
|
178
187
|
const updateSubscription = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
188
|
const { subscriptionId, priceId, prorationBehavior = 'create_prorations' } = params;
|
|
180
|
-
const subscription = yield
|
|
189
|
+
const subscription = yield getStripe().subscriptions.retrieve(subscriptionId);
|
|
181
190
|
// Create log record with request
|
|
182
191
|
const logId = yield Apilogger.logStripeOutgoing('updateSubscription', params);
|
|
183
192
|
try {
|
|
184
|
-
const updatedSubscription = yield
|
|
193
|
+
const updatedSubscription = yield getStripe().subscriptions.update(subscriptionId, {
|
|
185
194
|
items: [
|
|
186
195
|
{
|
|
187
196
|
id: subscription.items.data[0].id,
|
|
@@ -208,7 +217,7 @@ const updateSubscription = (params) => __awaiter(void 0, void 0, void 0, functio
|
|
|
208
217
|
const createCustomerPortalSession = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
209
218
|
const logId = yield Apilogger.logStripeOutgoing('createCustomerPortalSession', params);
|
|
210
219
|
try {
|
|
211
|
-
const session = yield
|
|
220
|
+
const session = yield getStripe().billingPortal.sessions.create({
|
|
212
221
|
customer: params.customerId,
|
|
213
222
|
return_url: params.returnUrl,
|
|
214
223
|
});
|
|
@@ -235,12 +244,12 @@ const cancelSubscription = (subscriptionId_1, ...args_1) => __awaiter(void 0, [s
|
|
|
235
244
|
try {
|
|
236
245
|
let result;
|
|
237
246
|
if (cancelAtPeriodEnd) {
|
|
238
|
-
result = yield
|
|
247
|
+
result = yield getStripe().subscriptions.update(subscriptionId, {
|
|
239
248
|
cancel_at_period_end: true,
|
|
240
249
|
});
|
|
241
250
|
}
|
|
242
251
|
else {
|
|
243
|
-
result = yield
|
|
252
|
+
result = yield getStripe().subscriptions.cancel(subscriptionId);
|
|
244
253
|
}
|
|
245
254
|
// Update log record with response
|
|
246
255
|
Apilogger.updateResponse(logId, {
|
|
@@ -265,4 +274,4 @@ class ActiveSubscriptionExistsError extends Error {
|
|
|
265
274
|
}
|
|
266
275
|
}
|
|
267
276
|
|
|
268
|
-
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId,
|
|
277
|
+
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId, getStripe, updateSubscription, validateStripeWebhook };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qstash.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/qstash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qstash.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/qstash.ts"],"names":[],"mappings":"AA8CA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAU,SAAS,qBAAqB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAQ1F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,qBAAqB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,KACpD,OAAO,CAAC,MAAM,GAAG,IAAI,CASvB,CAAC;AAEF,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,sBAAsB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAiB5F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,OAAO,CAexE,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,SAAS,mBAAmB,KAAG,OAAO,CAAC,OAAO,CAqBzF,CAAC"}
|
|
@@ -1,103 +1,107 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tslib_es6 = require('../../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');
|
|
4
|
-
var
|
|
4
|
+
var chunk35B33QW3 = require('../../node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js');
|
|
5
5
|
var upstashConfig = require('../upstash-config.js');
|
|
6
6
|
|
|
7
7
|
let cachedReceiver = null;
|
|
8
|
-
let
|
|
8
|
+
let receiverWarnedMissingEnv = false;
|
|
9
|
+
let receiverWarnedInitError = false;
|
|
9
10
|
const isTruthy = (value) => value === '1' || value === 'true' || value === 'TRUE';
|
|
10
11
|
const shouldSkipVerify = () => process.env.NODE_ENV === 'development' && isTruthy(process.env.SKIP_UPSTASH_QSTASH_VERIFY);
|
|
11
12
|
const getReceiver = () => {
|
|
12
13
|
if (cachedReceiver) {
|
|
13
14
|
return cachedReceiver;
|
|
14
15
|
}
|
|
15
|
-
if (receiverInitAttempted) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
receiverInitAttempted = true;
|
|
19
16
|
const currentSigningKey = process.env.QSTASH_CURRENT_SIGNING_KEY;
|
|
20
17
|
const nextSigningKey = process.env.QSTASH_NEXT_SIGNING_KEY;
|
|
21
18
|
if (!currentSigningKey || !nextSigningKey) {
|
|
19
|
+
if (!receiverWarnedMissingEnv) {
|
|
20
|
+
receiverWarnedMissingEnv = true;
|
|
21
|
+
console.warn('[Upstash Config] QStash Receiver disabled: missing QSTASH_CURRENT_SIGNING_KEY or QSTASH_NEXT_SIGNING_KEY');
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
cachedReceiver = new chunk35B33QW3.Receiver({
|
|
27
|
+
currentSigningKey,
|
|
28
|
+
nextSigningKey,
|
|
29
|
+
});
|
|
30
|
+
return cachedReceiver;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!receiverWarnedInitError) {
|
|
34
|
+
receiverWarnedInitError = true;
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
console.warn(`[Upstash Config] QStash Receiver init failed: ${message}`);
|
|
37
|
+
}
|
|
22
38
|
return null;
|
|
23
39
|
}
|
|
24
|
-
cachedReceiver = new chunkRQPZUJXG.Receiver({
|
|
25
|
-
currentSigningKey,
|
|
26
|
-
nextSigningKey,
|
|
27
|
-
});
|
|
28
|
-
return cachedReceiver;
|
|
29
40
|
};
|
|
30
41
|
/**
|
|
31
42
|
* Publish a message. Returns message id or null if QStash is unavailable.
|
|
32
43
|
*/
|
|
33
44
|
const publishMessage = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
45
|
+
return upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
var _a;
|
|
47
|
+
const result = yield client.publishJSON({
|
|
48
|
+
url: options.url,
|
|
49
|
+
body: options.body,
|
|
50
|
+
});
|
|
51
|
+
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
52
|
+
}));
|
|
44
53
|
});
|
|
45
54
|
/**
|
|
46
55
|
* Publish a delayed message. Returns message id or null if QStash is unavailable.
|
|
47
56
|
*/
|
|
48
57
|
const publishDelayedMessage = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
58
|
+
return upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
var _a;
|
|
60
|
+
const result = yield client.publishJSON({
|
|
61
|
+
url: options.url,
|
|
62
|
+
body: options.body,
|
|
63
|
+
delay: options.delaySec,
|
|
64
|
+
});
|
|
65
|
+
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
66
|
+
}));
|
|
60
67
|
});
|
|
61
68
|
/**
|
|
62
69
|
* Schedule a recurring message. Returns schedule id or null if QStash is unavailable.
|
|
63
70
|
*/
|
|
64
71
|
const scheduleMessage = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})));
|
|
80
|
-
return typeof result === 'string' ? result : (_f = (_e = result === null || result === void 0 ? void 0 : result.scheduleId) !== null && _e !== void 0 ? _e : result === null || result === void 0 ? void 0 : result.id) !== null && _f !== void 0 ? _f : null;
|
|
72
|
+
return upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
var _a, _b, _c, _d, _e, _f;
|
|
74
|
+
const anyClient = client;
|
|
75
|
+
const result = (_c = (yield ((_b = (_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.create) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
76
|
+
url: options.url,
|
|
77
|
+
body: options.body,
|
|
78
|
+
cron: options.cron,
|
|
79
|
+
})))) !== null && _c !== void 0 ? _c : (yield ((_d = anyClient.publishJSON) === null || _d === void 0 ? void 0 : _d.call(anyClient, {
|
|
80
|
+
url: options.url,
|
|
81
|
+
body: options.body,
|
|
82
|
+
cron: options.cron,
|
|
83
|
+
})));
|
|
84
|
+
return typeof result === 'string' ? result : (_f = (_e = result === null || result === void 0 ? void 0 : result.scheduleId) !== null && _e !== void 0 ? _e : result === null || result === void 0 ? void 0 : result.id) !== null && _f !== void 0 ? _f : null;
|
|
85
|
+
}));
|
|
81
86
|
});
|
|
82
87
|
/**
|
|
83
88
|
* Cancel a scheduled message. Returns false if QStash is unavailable.
|
|
84
89
|
*/
|
|
85
90
|
const cancelSchedule = (scheduleId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
const result = yield upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const anyClient = client;
|
|
94
|
+
if ((_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.delete) {
|
|
95
|
+
yield anyClient.schedules.delete(scheduleId);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if ((_b = anyClient.schedules) === null || _b === void 0 ? void 0 : _b.remove) {
|
|
99
|
+
yield anyClient.schedules.remove(scheduleId);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
89
102
|
return false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if ((_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.delete) {
|
|
93
|
-
yield anyClient.schedules.delete(scheduleId);
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
if ((_b = anyClient.schedules) === null || _b === void 0 ? void 0 : _b.remove) {
|
|
97
|
-
yield anyClient.schedules.remove(scheduleId);
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
103
|
+
}));
|
|
104
|
+
return result !== null && result !== void 0 ? result : false;
|
|
101
105
|
});
|
|
102
106
|
/**
|
|
103
107
|
* Verify QStash signature. Throws on failure in non-dev environments.
|