@windrun-huaiin/backend-core 10.0.1
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 +21 -0
- package/dist/app/api/stripe/checkout/route.d.ts +19 -0
- package/dist/app/api/stripe/checkout/route.d.ts.map +1 -0
- package/dist/app/api/stripe/checkout/route.js +120 -0
- package/dist/app/api/stripe/checkout/route.mjs +118 -0
- package/dist/app/api/stripe/customer-portal/route.d.ts +11 -0
- package/dist/app/api/stripe/customer-portal/route.d.ts.map +1 -0
- package/dist/app/api/stripe/customer-portal/route.js +73 -0
- package/dist/app/api/stripe/customer-portal/route.mjs +71 -0
- package/dist/app/api/user/anonymous/init/route.d.ts +7 -0
- package/dist/app/api/user/anonymous/init/route.d.ts.map +1 -0
- package/dist/app/api/user/anonymous/init/route.js +210 -0
- package/dist/app/api/user/anonymous/init/route.mjs +208 -0
- package/dist/app/api/webhook/clerk/user/route.d.ts +7 -0
- package/dist/app/api/webhook/clerk/user/route.d.ts.map +1 -0
- package/dist/app/api/webhook/clerk/user/route.js +202 -0
- package/dist/app/api/webhook/clerk/user/route.mjs +200 -0
- package/dist/app/api/webhook/stripe/route.d.ts +8 -0
- package/dist/app/api/webhook/stripe/route.d.ts.map +1 -0
- package/dist/app/api/webhook/stripe/route.js +70 -0
- package/dist/app/api/webhook/stripe/route.mjs +67 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.mjs +18 -0
- package/dist/lib/auth-utils.d.ts +46 -0
- package/dist/lib/auth-utils.d.ts.map +1 -0
- package/dist/lib/auth-utils.js +107 -0
- package/dist/lib/auth-utils.mjs +102 -0
- package/dist/lib/credit-init.d.ts +8 -0
- package/dist/lib/credit-init.d.ts.map +1 -0
- package/dist/lib/credit-init.js +16 -0
- package/dist/lib/credit-init.mjs +10 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +31 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/money-price-config.d.ts +51 -0
- package/dist/lib/money-price-config.d.ts.map +1 -0
- package/dist/lib/money-price-config.js +156 -0
- package/dist/lib/money-price-config.mjs +151 -0
- package/dist/lib/stripe-config.d.ts +31 -0
- package/dist/lib/stripe-config.d.ts.map +1 -0
- package/dist/lib/stripe-config.js +278 -0
- package/dist/lib/stripe-config.mjs +268 -0
- 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 +48 -0
- 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 +45 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +54 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +51 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +44 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +35 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +31 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +18 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +587 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +527 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +447 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +399 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +245 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +232 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +68 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +62 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +39 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +37 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +80 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +75 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +101 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +86 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +102 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +76 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +56 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +52 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +1205 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +1157 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +407 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +374 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +7 -0
- package/dist/prisma/client.d.ts +2 -0
- package/dist/prisma/client.d.ts.map +1 -0
- package/dist/prisma/client.js +12 -0
- package/dist/prisma/client.mjs +1 -0
- package/dist/prisma/index.d.ts +4 -0
- package/dist/prisma/index.d.ts.map +1 -0
- package/dist/prisma/index.js +10 -0
- package/dist/prisma/index.mjs +2 -0
- package/dist/prisma/prisma-transaction-util.d.ts +3 -0
- package/dist/prisma/prisma-transaction-util.d.ts.map +1 -0
- package/dist/prisma/prisma-transaction-util.js +29 -0
- package/dist/prisma/prisma-transaction-util.mjs +27 -0
- package/dist/prisma/prisma.d.ts +4 -0
- package/dist/prisma/prisma.d.ts.map +1 -0
- package/dist/prisma/prisma.js +109 -0
- package/dist/prisma/prisma.mjs +106 -0
- package/dist/services/aggregate/billing.aggregate.service.d.ts +83 -0
- package/dist/services/aggregate/billing.aggregate.service.d.ts.map +1 -0
- package/dist/services/aggregate/billing.aggregate.service.js +308 -0
- package/dist/services/aggregate/billing.aggregate.service.mjs +306 -0
- package/dist/services/aggregate/index.d.ts +3 -0
- package/dist/services/aggregate/index.d.ts.map +1 -0
- package/dist/services/aggregate/index.js +9 -0
- package/dist/services/aggregate/index.mjs +2 -0
- package/dist/services/aggregate/user.aggregate.service.d.ts +34 -0
- package/dist/services/aggregate/user.aggregate.service.d.ts.map +1 -0
- package/dist/services/aggregate/user.aggregate.service.js +136 -0
- package/dist/services/aggregate/user.aggregate.service.mjs +133 -0
- package/dist/services/context/index.d.ts +2 -0
- package/dist/services/context/index.d.ts.map +1 -0
- package/dist/services/context/index.js +13 -0
- package/dist/services/context/index.mjs +1 -0
- package/dist/services/context/user-context-service.d.ts +30 -0
- package/dist/services/context/user-context-service.d.ts.map +1 -0
- package/dist/services/context/user-context-service.js +170 -0
- package/dist/services/context/user-context-service.mjs +162 -0
- package/dist/services/database/apilog.service.d.ts +39 -0
- package/dist/services/database/apilog.service.d.ts.map +1 -0
- package/dist/services/database/apilog.service.js +174 -0
- package/dist/services/database/apilog.service.mjs +170 -0
- package/dist/services/database/constants.d.ts +73 -0
- package/dist/services/database/constants.d.ts.map +1 -0
- package/dist/services/database/constants.js +135 -0
- package/dist/services/database/constants.mjs +117 -0
- package/dist/services/database/credit.service.d.ts +107 -0
- package/dist/services/database/credit.service.d.ts.map +1 -0
- package/dist/services/database/credit.service.js +515 -0
- package/dist/services/database/credit.service.mjs +512 -0
- package/dist/services/database/creditAuditLog.service.d.ts +73 -0
- package/dist/services/database/creditAuditLog.service.d.ts.map +1 -0
- package/dist/services/database/creditAuditLog.service.js +305 -0
- package/dist/services/database/creditAuditLog.service.mjs +302 -0
- package/dist/services/database/index.d.ts +10 -0
- package/dist/services/database/index.d.ts.map +1 -0
- package/dist/services/database/index.js +38 -0
- package/dist/services/database/index.mjs +8 -0
- package/dist/services/database/prisma-model-type.d.ts +3 -0
- package/dist/services/database/prisma-model-type.d.ts.map +1 -0
- package/dist/services/database/subscription.service.d.ts +48 -0
- package/dist/services/database/subscription.service.d.ts.map +1 -0
- package/dist/services/database/subscription.service.js +267 -0
- package/dist/services/database/subscription.service.mjs +264 -0
- package/dist/services/database/transaction.service.d.ts +92 -0
- package/dist/services/database/transaction.service.d.ts.map +1 -0
- package/dist/services/database/transaction.service.js +326 -0
- package/dist/services/database/transaction.service.mjs +323 -0
- package/dist/services/database/user.service.d.ts +45 -0
- package/dist/services/database/user.service.d.ts.map +1 -0
- package/dist/services/database/user.service.js +180 -0
- package/dist/services/database/user.service.mjs +177 -0
- package/dist/services/database/userBackup.service.d.ts +45 -0
- package/dist/services/database/userBackup.service.d.ts.map +1 -0
- package/dist/services/database/userBackup.service.js +249 -0
- package/dist/services/database/userBackup.service.mjs +246 -0
- package/dist/services/stripe/index.d.ts +2 -0
- package/dist/services/stripe/index.d.ts.map +1 -0
- package/dist/services/stripe/index.js +7 -0
- package/dist/services/stripe/index.mjs +1 -0
- package/dist/services/stripe/webhook-handler.d.ts +6 -0
- package/dist/services/stripe/webhook-handler.d.ts.map +1 -0
- package/dist/services/stripe/webhook-handler.js +537 -0
- package/dist/services/stripe/webhook-handler.mjs +535 -0
- package/migrations/create.sql +176 -0
- package/migrations/db.init.sql +13 -0
- package/migrations/init-schema.sql +19 -0
- package/migrations/purge.sql +27 -0
- package/migrations/test-check.sql +167 -0
- package/package.json +123 -0
- package/prisma/schema.prisma +191 -0
- package/src/app/api/stripe/checkout/route.ts +145 -0
- package/src/app/api/stripe/customer-portal/route.ts +83 -0
- package/src/app/api/user/anonymous/init/route.ts +284 -0
- package/src/app/api/webhook/clerk/user/route.ts +249 -0
- package/src/app/api/webhook/stripe/route.ts +93 -0
- package/src/index.ts +6 -0
- package/src/lib/auth-utils.ts +101 -0
- package/src/lib/credit-init.ts +9 -0
- package/src/lib/index.ts +4 -0
- package/src/lib/money-price-config.ts +168 -0
- package/src/lib/stripe-config.ts +333 -0
- package/src/prisma/client.ts +2 -0
- package/src/prisma/index.ts +3 -0
- package/src/prisma/prisma-transaction-util.ts +24 -0
- package/src/prisma/prisma.ts +122 -0
- package/src/services/aggregate/billing.aggregate.service.ts +498 -0
- package/src/services/aggregate/index.ts +2 -0
- package/src/services/aggregate/user.aggregate.service.ts +168 -0
- package/src/services/context/index.ts +1 -0
- package/src/services/context/user-context-service.ts +200 -0
- package/src/services/database/apilog.service.ts +185 -0
- package/src/services/database/constants.ts +148 -0
- package/src/services/database/credit.service.ts +747 -0
- package/src/services/database/creditAuditLog.service.ts +402 -0
- package/src/services/database/index.ts +41 -0
- package/src/services/database/prisma-model-type.ts +13 -0
- package/src/services/database/subscription.service.ts +319 -0
- package/src/services/database/transaction.service.ts +447 -0
- package/src/services/database/user.service.ts +218 -0
- package/src/services/database/userBackup.service.ts +290 -0
- package/src/services/stripe/index.ts +1 -0
- package/src/services/stripe/webhook-handler.ts +648 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { __awaiter } from '../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';
|
|
2
|
+
import Stripe from 'stripe';
|
|
3
|
+
import { userService } from '../services/database/user.service.mjs';
|
|
4
|
+
import { subscriptionService } from '../services/database/subscription.service.mjs';
|
|
5
|
+
import '../services/database/credit.service.mjs';
|
|
6
|
+
import '@prisma/client';
|
|
7
|
+
import '../prisma/prisma.mjs';
|
|
8
|
+
import { Apilogger } from '../services/database/apilog.service.mjs';
|
|
9
|
+
|
|
10
|
+
// Stripe Configuration
|
|
11
|
+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
|
|
12
|
+
apiVersion: '2025-10-29.clover',
|
|
13
|
+
});
|
|
14
|
+
// Helper function to validate webhook signature
|
|
15
|
+
const validateStripeWebhook = (payload, signature, secret) => {
|
|
16
|
+
return stripe.webhooks.constructEvent(payload, signature, secret);
|
|
17
|
+
};
|
|
18
|
+
// Helper function to create checkout session
|
|
19
|
+
const createCheckoutSession = (params, subscriptionData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const { priceId, customerId, clientReferenceId, successUrl, cancelUrl, metadata, interval } = params;
|
|
21
|
+
// ✅ Dynamic mode determination: subscription if interval is not 'onetime'
|
|
22
|
+
const mode = interval && interval !== 'onetime' ? 'subscription' : 'payment';
|
|
23
|
+
const isSubscriptionMode = mode === 'subscription';
|
|
24
|
+
if (isSubscriptionMode) {
|
|
25
|
+
if (!subscriptionData) {
|
|
26
|
+
throw new Error('Subscription data is required for subscription mode');
|
|
27
|
+
}
|
|
28
|
+
const activeSubscription = yield subscriptionService.getActiveSubscription(clientReferenceId);
|
|
29
|
+
if (activeSubscription) {
|
|
30
|
+
throw new ActiveSubscriptionExistsError();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const sessionParams = {
|
|
34
|
+
mode, // ✅ Dynamic mode
|
|
35
|
+
payment_method_types: ['card'],
|
|
36
|
+
line_items: [
|
|
37
|
+
{
|
|
38
|
+
price: priceId,
|
|
39
|
+
quantity: 1,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
success_url: successUrl,
|
|
43
|
+
cancel_url: cancelUrl,
|
|
44
|
+
client_reference_id: clientReferenceId,
|
|
45
|
+
metadata: Object.assign(Object.assign({}, metadata), { mode }),
|
|
46
|
+
};
|
|
47
|
+
// Add customer if provided
|
|
48
|
+
if (customerId) {
|
|
49
|
+
sessionParams.customer = customerId;
|
|
50
|
+
}
|
|
51
|
+
// One-time payment specific configuration
|
|
52
|
+
if (isSubscriptionMode) {
|
|
53
|
+
// 在这里注入订单元数据,以保证后续事件处理能根据订单去匹配处理,只能在订阅模式里设置数据,否则Stripe报错
|
|
54
|
+
sessionParams.subscription_data = subscriptionData;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// One-time payments don't create invoices
|
|
58
|
+
sessionParams.invoice_creation = {
|
|
59
|
+
enabled: false,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Create log record with request
|
|
63
|
+
const logId = yield Apilogger.logStripeOutgoing('createCheckoutSession', params);
|
|
64
|
+
try {
|
|
65
|
+
const session = yield stripe.checkout.sessions.create(sessionParams);
|
|
66
|
+
// Update log record with response
|
|
67
|
+
Apilogger.updateResponse(logId, {
|
|
68
|
+
session_id: session.id,
|
|
69
|
+
url: session.url,
|
|
70
|
+
mode: session.mode
|
|
71
|
+
});
|
|
72
|
+
return session;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// Update log record with error
|
|
76
|
+
Apilogger.updateResponse(logId, {
|
|
77
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
78
|
+
});
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
// 根据发票ID去查支付ID
|
|
83
|
+
const fetchPaymentId = (invoiceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const fullInvoice = yield stripe.invoices.retrieve(invoiceId, {
|
|
86
|
+
expand: ['payments']
|
|
87
|
+
});
|
|
88
|
+
const payment = (_a = fullInvoice.payments) === null || _a === void 0 ? void 0 : _a.data[0];
|
|
89
|
+
const paymentIntentInfo = (_b = payment === null || payment === void 0 ? void 0 : payment.payment) === null || _b === void 0 ? void 0 : _b.payment_intent;
|
|
90
|
+
const paymentIntentId = typeof paymentIntentInfo === 'string' ? paymentIntentInfo : paymentIntentInfo === null || paymentIntentInfo === void 0 ? void 0 : paymentIntentInfo.id;
|
|
91
|
+
return paymentIntentId;
|
|
92
|
+
});
|
|
93
|
+
// Helper function to create or retrieve customer
|
|
94
|
+
const createOrGetCustomer = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const { userId } = params;
|
|
96
|
+
const user = yield userService.findByUserId(userId);
|
|
97
|
+
if (!user) {
|
|
98
|
+
throw new Error(`User not found for userId: ${userId}`);
|
|
99
|
+
}
|
|
100
|
+
const setStripeCustomerId = (stripeCusId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
try {
|
|
102
|
+
yield userService.updateStripeCustomerId(userId, stripeCusId);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error('Failed to update stripe customer id', { userId, stripeCusId, error });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (user.stripeCusId) {
|
|
109
|
+
try {
|
|
110
|
+
const customer = yield stripe.customers.retrieve(user.stripeCusId);
|
|
111
|
+
if ('deleted' in customer) {
|
|
112
|
+
yield setStripeCustomerId(null);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return customer.id;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
yield setStripeCustomerId(null);
|
|
120
|
+
console.warn('Failed to retrieve Stripe customer, fallback to lookup by email', {
|
|
121
|
+
userId,
|
|
122
|
+
stripeCusId: user.stripeCusId,
|
|
123
|
+
error,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (user.email) {
|
|
128
|
+
const existingCustomers = yield stripe.customers.list({
|
|
129
|
+
email: user.email,
|
|
130
|
+
limit: 1,
|
|
131
|
+
});
|
|
132
|
+
if (existingCustomers.data.length > 0) {
|
|
133
|
+
const stripeCustomer = existingCustomers.data[0];
|
|
134
|
+
if (!user.stripeCusId || user.stripeCusId !== stripeCustomer.id) {
|
|
135
|
+
yield setStripeCustomerId(stripeCustomer.id);
|
|
136
|
+
}
|
|
137
|
+
return stripeCustomer.id;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// 创建新客户
|
|
141
|
+
const customerParams = {
|
|
142
|
+
metadata: {
|
|
143
|
+
user_id: userId,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
if (user.email) {
|
|
147
|
+
customerParams.email = user.email;
|
|
148
|
+
}
|
|
149
|
+
const derivedName = user.email ? user.email.split('@')[0] : undefined;
|
|
150
|
+
if (derivedName) {
|
|
151
|
+
customerParams.name = derivedName;
|
|
152
|
+
}
|
|
153
|
+
// Create log record with request
|
|
154
|
+
const logId = yield Apilogger.logStripeOutgoing('createCustomer', {
|
|
155
|
+
userId,
|
|
156
|
+
email: customerParams.email,
|
|
157
|
+
name: customerParams.name,
|
|
158
|
+
});
|
|
159
|
+
try {
|
|
160
|
+
const customer = yield stripe.customers.create(customerParams);
|
|
161
|
+
yield setStripeCustomerId(customer.id);
|
|
162
|
+
// Update log record with response
|
|
163
|
+
Apilogger.updateResponse(logId, {
|
|
164
|
+
customer_id: customer.id,
|
|
165
|
+
email: customer.email
|
|
166
|
+
});
|
|
167
|
+
return customer.id;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
// Update log record with error
|
|
171
|
+
Apilogger.updateResponse(logId, {
|
|
172
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
173
|
+
});
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
// Helper function to update subscription
|
|
178
|
+
const updateSubscription = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
+
const { subscriptionId, priceId, prorationBehavior = 'create_prorations' } = params;
|
|
180
|
+
const subscription = yield stripe.subscriptions.retrieve(subscriptionId);
|
|
181
|
+
// Create log record with request
|
|
182
|
+
const logId = yield Apilogger.logStripeOutgoing('updateSubscription', params);
|
|
183
|
+
try {
|
|
184
|
+
const updatedSubscription = yield stripe.subscriptions.update(subscriptionId, {
|
|
185
|
+
items: [
|
|
186
|
+
{
|
|
187
|
+
id: subscription.items.data[0].id,
|
|
188
|
+
price: priceId,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
proration_behavior: prorationBehavior,
|
|
192
|
+
});
|
|
193
|
+
// Update log record with response
|
|
194
|
+
Apilogger.updateResponse(logId, {
|
|
195
|
+
subscription_id: updatedSubscription.id,
|
|
196
|
+
status: updatedSubscription.status
|
|
197
|
+
});
|
|
198
|
+
return updatedSubscription;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
// Update log record with error
|
|
202
|
+
Apilogger.updateResponse(logId, {
|
|
203
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
204
|
+
});
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const createCustomerPortalSession = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
209
|
+
const logId = yield Apilogger.logStripeOutgoing('createCustomerPortalSession', params);
|
|
210
|
+
try {
|
|
211
|
+
const session = yield stripe.billingPortal.sessions.create({
|
|
212
|
+
customer: params.customerId,
|
|
213
|
+
return_url: params.returnUrl,
|
|
214
|
+
});
|
|
215
|
+
Apilogger.updateResponse(logId, {
|
|
216
|
+
session_id: session.id,
|
|
217
|
+
url: session.url,
|
|
218
|
+
});
|
|
219
|
+
return session;
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
Apilogger.updateResponse(logId, {
|
|
223
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
224
|
+
});
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
// Helper function to cancel subscription
|
|
229
|
+
const cancelSubscription = (subscriptionId_1, ...args_1) => __awaiter(void 0, [subscriptionId_1, ...args_1], void 0, function* (subscriptionId, cancelAtPeriodEnd = true) {
|
|
230
|
+
// Create log record with request
|
|
231
|
+
const logId = yield Apilogger.logStripeOutgoing('cancelSubscription', {
|
|
232
|
+
subscriptionId,
|
|
233
|
+
cancelAtPeriodEnd
|
|
234
|
+
});
|
|
235
|
+
try {
|
|
236
|
+
let result;
|
|
237
|
+
if (cancelAtPeriodEnd) {
|
|
238
|
+
result = yield stripe.subscriptions.update(subscriptionId, {
|
|
239
|
+
cancel_at_period_end: true,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
result = yield stripe.subscriptions.cancel(subscriptionId);
|
|
244
|
+
}
|
|
245
|
+
// Update log record with response
|
|
246
|
+
Apilogger.updateResponse(logId, {
|
|
247
|
+
subscription_id: result.id,
|
|
248
|
+
status: result.status,
|
|
249
|
+
cancel_at_period_end: result.cancel_at_period_end
|
|
250
|
+
});
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
// Update log record with error
|
|
255
|
+
Apilogger.updateResponse(logId, {
|
|
256
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
257
|
+
});
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
class ActiveSubscriptionExistsError extends Error {
|
|
262
|
+
constructor() {
|
|
263
|
+
super('ACTIVE_SUBSCRIPTION_EXISTS');
|
|
264
|
+
this.name = 'ActiveSubscriptionExistsError';
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId, stripe, updateSubscription, validateStripeWebhook };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function __rest(s, e) {
|
|
21
|
+
var t = {};
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
27
|
+
t[p[i]] = s[p[i]];
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
33
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
43
|
+
var e = new Error(message);
|
|
44
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.__awaiter = __awaiter;
|
|
48
|
+
exports.__rest = __rest;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function __rest(s, e) {
|
|
19
|
+
var t = {};
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
23
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25
|
+
t[p[i]] = s[p[i]];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
31
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
32
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
36
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
41
|
+
var e = new Error(message);
|
|
42
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { __awaiter, __rest };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('../core/core.js');
|
|
4
|
+
var errors = require('../core/errors.js');
|
|
5
|
+
var util = require('../core/util.js');
|
|
6
|
+
|
|
7
|
+
const initializer = (inst, issues) => {
|
|
8
|
+
errors.$ZodError.init(inst, issues);
|
|
9
|
+
inst.name = "ZodError";
|
|
10
|
+
Object.defineProperties(inst, {
|
|
11
|
+
format: {
|
|
12
|
+
value: (mapper) => errors.formatError(inst, mapper),
|
|
13
|
+
// enumerable: false,
|
|
14
|
+
},
|
|
15
|
+
flatten: {
|
|
16
|
+
value: (mapper) => errors.flattenError(inst, mapper),
|
|
17
|
+
// enumerable: false,
|
|
18
|
+
},
|
|
19
|
+
addIssue: {
|
|
20
|
+
value: (issue) => {
|
|
21
|
+
inst.issues.push(issue);
|
|
22
|
+
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
23
|
+
},
|
|
24
|
+
// enumerable: false,
|
|
25
|
+
},
|
|
26
|
+
addIssues: {
|
|
27
|
+
value: (issues) => {
|
|
28
|
+
inst.issues.push(...issues);
|
|
29
|
+
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
30
|
+
},
|
|
31
|
+
// enumerable: false,
|
|
32
|
+
},
|
|
33
|
+
isEmpty: {
|
|
34
|
+
get() {
|
|
35
|
+
return inst.issues.length === 0;
|
|
36
|
+
},
|
|
37
|
+
// enumerable: false,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
// Object.defineProperty(inst, "isEmpty", {
|
|
41
|
+
// get() {
|
|
42
|
+
// return inst.issues.length === 0;
|
|
43
|
+
// },
|
|
44
|
+
// });
|
|
45
|
+
};
|
|
46
|
+
const ZodError = core.$constructor("ZodError", initializer);
|
|
47
|
+
const ZodRealError = core.$constructor("ZodError", initializer, {
|
|
48
|
+
Parent: Error,
|
|
49
|
+
});
|
|
50
|
+
// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
|
|
51
|
+
// export type ErrorMapCtx = core.$ZodErrorMapCtx;
|
|
52
|
+
|
|
53
|
+
exports.ZodError = ZodError;
|
|
54
|
+
exports.ZodRealError = ZodRealError;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { $constructor } from '../core/core.mjs';
|
|
2
|
+
import { $ZodError, flattenError, formatError } from '../core/errors.mjs';
|
|
3
|
+
import { jsonStringifyReplacer } from '../core/util.mjs';
|
|
4
|
+
|
|
5
|
+
const initializer = (inst, issues) => {
|
|
6
|
+
$ZodError.init(inst, issues);
|
|
7
|
+
inst.name = "ZodError";
|
|
8
|
+
Object.defineProperties(inst, {
|
|
9
|
+
format: {
|
|
10
|
+
value: (mapper) => formatError(inst, mapper),
|
|
11
|
+
// enumerable: false,
|
|
12
|
+
},
|
|
13
|
+
flatten: {
|
|
14
|
+
value: (mapper) => flattenError(inst, mapper),
|
|
15
|
+
// enumerable: false,
|
|
16
|
+
},
|
|
17
|
+
addIssue: {
|
|
18
|
+
value: (issue) => {
|
|
19
|
+
inst.issues.push(issue);
|
|
20
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
21
|
+
},
|
|
22
|
+
// enumerable: false,
|
|
23
|
+
},
|
|
24
|
+
addIssues: {
|
|
25
|
+
value: (issues) => {
|
|
26
|
+
inst.issues.push(...issues);
|
|
27
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
28
|
+
},
|
|
29
|
+
// enumerable: false,
|
|
30
|
+
},
|
|
31
|
+
isEmpty: {
|
|
32
|
+
get() {
|
|
33
|
+
return inst.issues.length === 0;
|
|
34
|
+
},
|
|
35
|
+
// enumerable: false,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
// Object.defineProperty(inst, "isEmpty", {
|
|
39
|
+
// get() {
|
|
40
|
+
// return inst.issues.length === 0;
|
|
41
|
+
// },
|
|
42
|
+
// });
|
|
43
|
+
};
|
|
44
|
+
const ZodError = $constructor("ZodError", initializer);
|
|
45
|
+
const ZodRealError = $constructor("ZodError", initializer, {
|
|
46
|
+
Parent: Error,
|
|
47
|
+
});
|
|
48
|
+
// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
|
|
49
|
+
// export type ErrorMapCtx = core.$ZodErrorMapCtx;
|
|
50
|
+
|
|
51
|
+
export { ZodError, ZodRealError };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('../core/core.js');
|
|
4
|
+
var schemas = require('../core/schemas.js');
|
|
5
|
+
var api = require('../core/api.js');
|
|
6
|
+
var schemas$1 = require('./schemas.js');
|
|
7
|
+
|
|
8
|
+
const ZodISODateTime = /*@__PURE__*/ core.$constructor("ZodISODateTime", (inst, def) => {
|
|
9
|
+
schemas.$ZodISODateTime.init(inst, def);
|
|
10
|
+
schemas$1.ZodStringFormat.init(inst, def);
|
|
11
|
+
});
|
|
12
|
+
function datetime(params) {
|
|
13
|
+
return api._isoDateTime(ZodISODateTime, params);
|
|
14
|
+
}
|
|
15
|
+
const ZodISODate = /*@__PURE__*/ core.$constructor("ZodISODate", (inst, def) => {
|
|
16
|
+
schemas.$ZodISODate.init(inst, def);
|
|
17
|
+
schemas$1.ZodStringFormat.init(inst, def);
|
|
18
|
+
});
|
|
19
|
+
function date(params) {
|
|
20
|
+
return api._isoDate(ZodISODate, params);
|
|
21
|
+
}
|
|
22
|
+
const ZodISOTime = /*@__PURE__*/ core.$constructor("ZodISOTime", (inst, def) => {
|
|
23
|
+
schemas.$ZodISOTime.init(inst, def);
|
|
24
|
+
schemas$1.ZodStringFormat.init(inst, def);
|
|
25
|
+
});
|
|
26
|
+
function time(params) {
|
|
27
|
+
return api._isoTime(ZodISOTime, params);
|
|
28
|
+
}
|
|
29
|
+
const ZodISODuration = /*@__PURE__*/ core.$constructor("ZodISODuration", (inst, def) => {
|
|
30
|
+
schemas.$ZodISODuration.init(inst, def);
|
|
31
|
+
schemas$1.ZodStringFormat.init(inst, def);
|
|
32
|
+
});
|
|
33
|
+
function duration(params) {
|
|
34
|
+
return api._isoDuration(ZodISODuration, params);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.ZodISODate = ZodISODate;
|
|
38
|
+
exports.ZodISODateTime = ZodISODateTime;
|
|
39
|
+
exports.ZodISODuration = ZodISODuration;
|
|
40
|
+
exports.ZodISOTime = ZodISOTime;
|
|
41
|
+
exports.date = date;
|
|
42
|
+
exports.datetime = datetime;
|
|
43
|
+
exports.duration = duration;
|
|
44
|
+
exports.time = time;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { $constructor } from '../core/core.mjs';
|
|
2
|
+
import { $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration } from '../core/schemas.mjs';
|
|
3
|
+
import { _isoDateTime, _isoDate, _isoTime, _isoDuration } from '../core/api.mjs';
|
|
4
|
+
import { ZodStringFormat } from './schemas.mjs';
|
|
5
|
+
|
|
6
|
+
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
7
|
+
$ZodISODateTime.init(inst, def);
|
|
8
|
+
ZodStringFormat.init(inst, def);
|
|
9
|
+
});
|
|
10
|
+
function datetime(params) {
|
|
11
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
12
|
+
}
|
|
13
|
+
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
14
|
+
$ZodISODate.init(inst, def);
|
|
15
|
+
ZodStringFormat.init(inst, def);
|
|
16
|
+
});
|
|
17
|
+
function date(params) {
|
|
18
|
+
return _isoDate(ZodISODate, params);
|
|
19
|
+
}
|
|
20
|
+
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
21
|
+
$ZodISOTime.init(inst, def);
|
|
22
|
+
ZodStringFormat.init(inst, def);
|
|
23
|
+
});
|
|
24
|
+
function time(params) {
|
|
25
|
+
return _isoTime(ZodISOTime, params);
|
|
26
|
+
}
|
|
27
|
+
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
28
|
+
$ZodISODuration.init(inst, def);
|
|
29
|
+
ZodStringFormat.init(inst, def);
|
|
30
|
+
});
|
|
31
|
+
function duration(params) {
|
|
32
|
+
return _isoDuration(ZodISODuration, params);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { ZodISODate, ZodISODateTime, ZodISODuration, ZodISOTime, date, datetime, duration, time };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var parse$1 = require('../core/parse.js');
|
|
4
|
+
var errors = require('./errors.js');
|
|
5
|
+
|
|
6
|
+
const parse = /* @__PURE__ */ parse$1._parse(errors.ZodRealError);
|
|
7
|
+
const parseAsync = /* @__PURE__ */ parse$1._parseAsync(errors.ZodRealError);
|
|
8
|
+
const safeParse = /* @__PURE__ */ parse$1._safeParse(errors.ZodRealError);
|
|
9
|
+
const safeParseAsync = /* @__PURE__ */ parse$1._safeParseAsync(errors.ZodRealError);
|
|
10
|
+
// Codec functions
|
|
11
|
+
const encode = /* @__PURE__ */ parse$1._encode(errors.ZodRealError);
|
|
12
|
+
const decode = /* @__PURE__ */ parse$1._decode(errors.ZodRealError);
|
|
13
|
+
const encodeAsync = /* @__PURE__ */ parse$1._encodeAsync(errors.ZodRealError);
|
|
14
|
+
const decodeAsync = /* @__PURE__ */ parse$1._decodeAsync(errors.ZodRealError);
|
|
15
|
+
const safeEncode = /* @__PURE__ */ parse$1._safeEncode(errors.ZodRealError);
|
|
16
|
+
const safeDecode = /* @__PURE__ */ parse$1._safeDecode(errors.ZodRealError);
|
|
17
|
+
const safeEncodeAsync = /* @__PURE__ */ parse$1._safeEncodeAsync(errors.ZodRealError);
|
|
18
|
+
const safeDecodeAsync = /* @__PURE__ */ parse$1._safeDecodeAsync(errors.ZodRealError);
|
|
19
|
+
|
|
20
|
+
exports.decode = decode;
|
|
21
|
+
exports.decodeAsync = decodeAsync;
|
|
22
|
+
exports.encode = encode;
|
|
23
|
+
exports.encodeAsync = encodeAsync;
|
|
24
|
+
exports.parse = parse;
|
|
25
|
+
exports.parseAsync = parseAsync;
|
|
26
|
+
exports.safeDecode = safeDecode;
|
|
27
|
+
exports.safeDecodeAsync = safeDecodeAsync;
|
|
28
|
+
exports.safeEncode = safeEncode;
|
|
29
|
+
exports.safeEncodeAsync = safeEncodeAsync;
|
|
30
|
+
exports.safeParse = safeParse;
|
|
31
|
+
exports.safeParseAsync = safeParseAsync;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _parse, _safeParse, _parseAsync, _safeParseAsync, _encode, _decode, _encodeAsync, _decodeAsync, _safeEncode, _safeDecode, _safeEncodeAsync, _safeDecodeAsync } from '../core/parse.mjs';
|
|
2
|
+
import { ZodRealError } from './errors.mjs';
|
|
3
|
+
|
|
4
|
+
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
5
|
+
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
6
|
+
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
7
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
8
|
+
// Codec functions
|
|
9
|
+
const encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
10
|
+
const decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
11
|
+
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
12
|
+
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
13
|
+
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
14
|
+
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
15
|
+
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
16
|
+
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
17
|
+
|
|
18
|
+
export { decode, decodeAsync, encode, encodeAsync, parse, parseAsync, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync };
|