@foldspace-fe/casdoor-next-auth-kit 0.1.19 → 0.1.21
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/billing/index.d.ts +20 -3
- package/dist/billing/index.js +10 -2
- package/dist/{chunk-46V73LSW.js → chunk-FL6LOXEG.js} +95 -1
- package/dist/chunk-FL6LOXEG.js.map +1 -0
- package/dist/{chunk-ZCHLJYLN.js → chunk-NWYEHQNK.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -2
- package/dist/react/index.d.ts +43 -2
- package/dist/react/index.js +285 -7
- package/dist/react/index.js.map +1 -1
- package/dist/skills/casdoor-next-auth-kit/SKILL.md +14 -6
- package/dist/{types-xgHVGy75.d.ts → types-oVIQpMut.d.ts} +122 -1
- package/package.json +1 -1
- package/dist/chunk-46V73LSW.js.map +0 -1
- /package/dist/{chunk-ZCHLJYLN.js.map → chunk-NWYEHQNK.js.map} +0 -0
package/dist/billing/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BillingActionPayload, b as BillingRuntimeConfig,
|
|
2
|
-
export { f as BillingActionExecutor,
|
|
1
|
+
import { B as BillingActionPayload, b as BillingRuntimeConfig, a7 as BillingPaymentCallbackContext, aq as BillingPurchaseRequest, m as BillingCreditsState, j as BillingProductState, h as BillingSubscriptionState, n as BillingEntitlementState, a as BillingItem, c as BillingCatalogConfig, p as BillingPurchaseStatus, k as BillingOrderHistoryItem, l as BillingPaymentHistoryItem, t as BillingCasdoorOrderDetail, x as BillingCasdoorSubscriptionDetail, i as BillingSubscriptionHistoryItem, a4 as BillingInterval, r as BillingProductSnapshot, ak as BillingPurchasableEntry, M as BillingCasdoorBuyProductRequest, w as BillingCasdoorProductDetail, N as BillingCasdoorBuyProductResponse, z as BillingActionExecutionResult, af as BillingPaymentSuccessRouteOptions, aa as BillingPaymentFinishedRouteOptions } from '../types-oVIQpMut.js';
|
|
2
|
+
export { f as BillingActionExecutor, A as BillingActionKind, d as BillingApiClient, C as BillingCasdoorAccountDetail, D as BillingCasdoorAccountMultiFactorAuthDetail, E as BillingCasdoorAccountResponse, F as BillingCasdoorApiResponse, G as BillingCasdoorApplicationDetail, H as BillingCasdoorApplicationProviderDetail, I as BillingCasdoorApplicationResponse, J as BillingCasdoorApplicationSigninItemDetail, K as BillingCasdoorApplicationSigninMethodDetail, L as BillingCasdoorApplicationSignupItemDetail, O as BillingCasdoorErrorDetail, P as BillingCasdoorErrorPayload, Q as BillingCasdoorOrderResponse, R as BillingCasdoorOrdersResponse, S as BillingCasdoorOrganizationDetail, T as BillingCasdoorOrganizationNamesResponse, U as BillingCasdoorOrganizationOption, V as BillingCasdoorPaymentDetail, W as BillingCasdoorPaymentResponse, u as BillingCasdoorPlanDetail, X as BillingCasdoorPlanResponse, v as BillingCasdoorPricingDetail, Y as BillingCasdoorPricingResponse, Z as BillingCasdoorProductResponse, _ as BillingCasdoorProviderDetail, $ as BillingCasdoorProviderOption, s as BillingCasdoorQueryState, a0 as BillingCasdoorSubscriptionResponse, a1 as BillingCasdoorSubscriptionsResponse, a2 as BillingConversionRule, y as BillingCoreContextValue, a3 as BillingCreditsContextValue, g as BillingDefaults, a5 as BillingItemKind, e as BillingLoaders, a6 as BillingOrderCreatedContext, a8 as BillingPaymentFinishedContext, a9 as BillingPaymentFinishedHandler, ab as BillingPaymentRouteBaseOptions, ac as BillingPaymentSuccessContext, ad as BillingPaymentSuccessHandler, ae as BillingPaymentSuccessHandlerResult, ag as BillingProductContextValue, ah as BillingProductDetailState, ai as BillingProductPurchasableEntry, aj as BillingProductPurchaseConfig, al as BillingPurchasableEntryBase, am as BillingPurchasableKind, an as BillingPurchasableWhitelist, ao as BillingPurchaseCompleteContext, ap as BillingPurchaseErrorContext, q as BillingPurchaseHooks, o as BillingStatusState, ar as BillingSubscriptionContextValue, as as BillingSubscriptionPurchasableEntry, at as BillingSubscriptionPurchaseConfig } from '../types-oVIQpMut.js';
|
|
3
3
|
|
|
4
4
|
declare function normalizeBillingRuntimeConfig(config?: Partial<BillingRuntimeConfig> | null): BillingRuntimeConfig;
|
|
5
5
|
declare function normalizeBillingCatalogConfig(config?: Partial<BillingCatalogConfig> | null): BillingCatalogConfig;
|
|
@@ -9,6 +9,23 @@ declare function buildBillingPurchaseRequest(payload: BillingActionPayload, runt
|
|
|
9
9
|
declare function filterBillingPurchasableItems(items: BillingItem[] | undefined, runtimeConfig?: BillingRuntimeConfig | null): BillingItem[];
|
|
10
10
|
declare function buildBillingPaymentCallbackContext(request: Request, phase?: 'success' | 'failure' | 'finished'): Promise<BillingPaymentCallbackContext>;
|
|
11
11
|
declare function resolveBillingSubscriptionProduct(subscription: BillingSubscriptionState | undefined, runtimeConfig: BillingRuntimeConfig | undefined): BillingProductSnapshot | undefined;
|
|
12
|
+
declare function normalizeCasdoorSubscriptionDetail(record: BillingCasdoorSubscriptionDetail | undefined): BillingSubscriptionState | undefined;
|
|
13
|
+
declare function normalizeCasdoorSubscriptionHistoryItem(record: BillingCasdoorSubscriptionDetail): BillingSubscriptionHistoryItem;
|
|
14
|
+
declare function normalizeCasdoorOrderHistoryItem(record: BillingCasdoorOrderDetail): BillingOrderHistoryItem;
|
|
15
|
+
declare function normalizeCasdoorPaymentHistoryItem(record: {
|
|
16
|
+
name: string;
|
|
17
|
+
order?: string;
|
|
18
|
+
outOrderId?: string;
|
|
19
|
+
product?: string;
|
|
20
|
+
productName?: string;
|
|
21
|
+
productDisplayName?: string;
|
|
22
|
+
price?: number;
|
|
23
|
+
currency?: string;
|
|
24
|
+
state?: string;
|
|
25
|
+
transactionId?: string;
|
|
26
|
+
createdTime?: string;
|
|
27
|
+
updatedTime?: string;
|
|
28
|
+
}): BillingPaymentHistoryItem;
|
|
12
29
|
declare function resolveBillingProductSnapshot(item?: BillingItem | null): BillingProductSnapshot | undefined;
|
|
13
30
|
declare function deriveBillingCreditsState(credits?: BillingCreditsState | null, products?: BillingProductState[] | null, conversionRules?: BillingRuntimeConfig['conversionRules']): BillingCreditsState;
|
|
14
31
|
declare function deriveBillingEntitlements(subscription: BillingSubscriptionState | undefined, products: BillingProductState[] | undefined, credits: BillingCreditsState | undefined, runtimeConfig: BillingRuntimeConfig | undefined): BillingEntitlementState;
|
|
@@ -33,4 +50,4 @@ declare function createBillingPaymentSuccessRouteHandler(options?: BillingPaymen
|
|
|
33
50
|
declare function createBillingPaymentFinishedResponse(request: Request, options?: BillingPaymentFinishedRouteOptions): Promise<Response>;
|
|
34
51
|
declare function createBillingPaymentFinishedRouteHandler(options?: BillingPaymentFinishedRouteOptions): (request: Request) => Promise<Response>;
|
|
35
52
|
|
|
36
|
-
export { BillingActionExecutionResult, BillingActionPayload, BillingCasdoorBuyProductRequest, BillingCasdoorBuyProductResponse, BillingCasdoorProductDetail, BillingCatalogConfig, BillingCreditsState, BillingEntitlementState, BillingInterval, BillingItem, BillingOrderHistoryItem, BillingPaymentCallbackContext, BillingPaymentFinishedRouteOptions, BillingPaymentHistoryItem, BillingPaymentSuccessRouteOptions, BillingProductSnapshot, BillingProductState, BillingPurchasableEntry, BillingPurchaseRequest, BillingPurchaseStatus, BillingRuntimeConfig, BillingSubscriptionState, type NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorProductId, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct };
|
|
53
|
+
export { BillingActionExecutionResult, BillingActionPayload, BillingCasdoorBuyProductRequest, BillingCasdoorBuyProductResponse, BillingCasdoorOrderDetail, BillingCasdoorProductDetail, BillingCasdoorSubscriptionDetail, BillingCatalogConfig, BillingCreditsState, BillingEntitlementState, BillingInterval, BillingItem, BillingOrderHistoryItem, BillingPaymentCallbackContext, BillingPaymentFinishedRouteOptions, BillingPaymentHistoryItem, BillingPaymentSuccessRouteOptions, BillingProductSnapshot, BillingProductState, BillingPurchasableEntry, BillingPurchaseRequest, BillingPurchaseStatus, BillingRuntimeConfig, BillingSubscriptionHistoryItem, BillingSubscriptionState, type NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorOrderHistoryItem, normalizeCasdoorPaymentHistoryItem, normalizeCasdoorProductId, normalizeCasdoorSubscriptionDetail, normalizeCasdoorSubscriptionHistoryItem, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct };
|
package/dist/billing/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createBillingPaymentFinishedRouteHandler,
|
|
4
4
|
createBillingPaymentSuccessResponse,
|
|
5
5
|
createBillingPaymentSuccessRouteHandler
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-NWYEHQNK.js";
|
|
7
7
|
import {
|
|
8
8
|
buildBillingActionPayload,
|
|
9
9
|
buildBillingPaymentCallbackContext,
|
|
@@ -18,14 +18,18 @@ import {
|
|
|
18
18
|
normalizeBillingPurchaseStatus,
|
|
19
19
|
normalizeBillingRuntimeConfig,
|
|
20
20
|
normalizeCasdoorBuyProductResponse,
|
|
21
|
+
normalizeCasdoorOrderHistoryItem,
|
|
22
|
+
normalizeCasdoorPaymentHistoryItem,
|
|
21
23
|
normalizeCasdoorProductId,
|
|
24
|
+
normalizeCasdoorSubscriptionDetail,
|
|
25
|
+
normalizeCasdoorSubscriptionHistoryItem,
|
|
22
26
|
readBuyProductRedirectTo,
|
|
23
27
|
resolveBillingInterval,
|
|
24
28
|
resolveBillingItem,
|
|
25
29
|
resolveBillingProductSnapshot,
|
|
26
30
|
resolveBillingPurchasable,
|
|
27
31
|
resolveBillingSubscriptionProduct
|
|
28
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-FL6LOXEG.js";
|
|
29
33
|
export {
|
|
30
34
|
buildBillingActionPayload,
|
|
31
35
|
buildBillingPaymentCallbackContext,
|
|
@@ -44,7 +48,11 @@ export {
|
|
|
44
48
|
normalizeBillingPurchaseStatus,
|
|
45
49
|
normalizeBillingRuntimeConfig,
|
|
46
50
|
normalizeCasdoorBuyProductResponse,
|
|
51
|
+
normalizeCasdoorOrderHistoryItem,
|
|
52
|
+
normalizeCasdoorPaymentHistoryItem,
|
|
47
53
|
normalizeCasdoorProductId,
|
|
54
|
+
normalizeCasdoorSubscriptionDetail,
|
|
55
|
+
normalizeCasdoorSubscriptionHistoryItem,
|
|
48
56
|
readBuyProductRedirectTo,
|
|
49
57
|
resolveBillingInterval,
|
|
50
58
|
resolveBillingItem,
|
|
@@ -202,6 +202,96 @@ function resolveBillingSubscriptionProduct(subscription, runtimeConfig) {
|
|
|
202
202
|
metadata: item.metadata
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
+
function normalizeCasdoorSubscriptionStatus(status) {
|
|
206
|
+
const normalized = typeof status === "string" ? status.toLowerCase() : "";
|
|
207
|
+
if (normalized.includes("active") || normalized.includes("paid")) return "active";
|
|
208
|
+
if (normalized.includes("trial")) return "trialing";
|
|
209
|
+
if (normalized.includes("past_due") || normalized.includes("pastdue") || normalized.includes("due")) return "past_due";
|
|
210
|
+
if (normalized.includes("suspend")) return "inactive";
|
|
211
|
+
if (normalized.includes("expire")) return "inactive";
|
|
212
|
+
if (normalized.includes("cancel")) return "canceled";
|
|
213
|
+
if (normalized.includes("fail") || normalized.includes("error")) return "inactive";
|
|
214
|
+
return "inactive";
|
|
215
|
+
}
|
|
216
|
+
function normalizeBillingOrderStatus(status) {
|
|
217
|
+
const normalized = typeof status === "string" ? status.toLowerCase() : "";
|
|
218
|
+
if (normalized.includes("paid") || normalized.includes("success") || normalized.includes("complete")) return "paid";
|
|
219
|
+
if (normalized.includes("pend") || normalized.includes("wait")) return "pending";
|
|
220
|
+
if (normalized.includes("fail") || normalized.includes("error")) return "failed";
|
|
221
|
+
if (normalized.includes("refund")) return "refunded";
|
|
222
|
+
if (normalized.includes("cancel")) return "canceled";
|
|
223
|
+
return "pending";
|
|
224
|
+
}
|
|
225
|
+
function normalizeBillingPaymentStatus(status) {
|
|
226
|
+
const normalized = typeof status === "string" ? status.toLowerCase() : "";
|
|
227
|
+
if (normalized.includes("paid") || normalized.includes("success") || normalized.includes("complete")) return "paid";
|
|
228
|
+
if (normalized.includes("pend") || normalized.includes("wait") || normalized.includes("process")) return "pending";
|
|
229
|
+
if (normalized.includes("fail") || normalized.includes("error")) return "failed";
|
|
230
|
+
if (normalized.includes("refund")) return "refunded";
|
|
231
|
+
if (normalized.includes("cancel")) return "canceled";
|
|
232
|
+
return "pending";
|
|
233
|
+
}
|
|
234
|
+
function pickLatestBillingTimestamp(values) {
|
|
235
|
+
return values.filter((value) => typeof value === "string" && value.length > 0).sort((left, right) => Date.parse(right) - Date.parse(left))[0];
|
|
236
|
+
}
|
|
237
|
+
function normalizeCasdoorSubscriptionDetail(record) {
|
|
238
|
+
if (!record) return void 0;
|
|
239
|
+
const status = normalizeCasdoorSubscriptionStatus(record.state);
|
|
240
|
+
return {
|
|
241
|
+
subscriptionId: record.name,
|
|
242
|
+
planKey: record.plan ?? record.pricing ?? record.name,
|
|
243
|
+
planName: record.displayName ?? record.plan ?? record.pricing,
|
|
244
|
+
status,
|
|
245
|
+
interval: record.duration === 12 ? "year" : record.duration === 1 ? "month" : void 0,
|
|
246
|
+
renewAt: record.endTime,
|
|
247
|
+
currentPeriodStart: record.startTime,
|
|
248
|
+
currentPeriodEnd: record.endTime
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function normalizeCasdoorSubscriptionHistoryItem(record) {
|
|
252
|
+
const status = normalizeCasdoorSubscriptionStatus(record.state);
|
|
253
|
+
return {
|
|
254
|
+
subscriptionId: record.name,
|
|
255
|
+
planKey: record.plan ?? record.pricing ?? record.name,
|
|
256
|
+
planName: record.displayName ?? record.plan ?? record.pricing,
|
|
257
|
+
status,
|
|
258
|
+
startedAt: record.startTime,
|
|
259
|
+
endedAt: record.endTime,
|
|
260
|
+
updatedAt: pickLatestBillingTimestamp([record.endTime, record.startTime, record.createdTime])
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function normalizeCasdoorOrderHistoryItem(record) {
|
|
264
|
+
const productKey = record.product ?? record.products?.[0];
|
|
265
|
+
const createdAt = record.createdTime ?? record.updatedTime;
|
|
266
|
+
return {
|
|
267
|
+
orderId: record.name,
|
|
268
|
+
productKey,
|
|
269
|
+
productId: record.product,
|
|
270
|
+
productTitle: record.productDisplayName ?? record.displayName ?? record.product,
|
|
271
|
+
kind: productKey ? "product" : void 0,
|
|
272
|
+
quantity: record.quantity,
|
|
273
|
+
amount: record.amount ?? record.price,
|
|
274
|
+
currency: record.currency,
|
|
275
|
+
status: normalizeBillingOrderStatus(record.state),
|
|
276
|
+
paymentId: record.payment,
|
|
277
|
+
transactionId: record.transaction,
|
|
278
|
+
createdAt,
|
|
279
|
+
updatedAt: pickLatestBillingTimestamp([createdAt, record.successUrl])
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function normalizeCasdoorPaymentHistoryItem(record) {
|
|
283
|
+
return {
|
|
284
|
+
paymentId: record.name,
|
|
285
|
+
orderId: record.order ?? record.outOrderId,
|
|
286
|
+
productKey: record.product,
|
|
287
|
+
amount: record.price,
|
|
288
|
+
currency: record.currency,
|
|
289
|
+
status: normalizeBillingPaymentStatus(record.state),
|
|
290
|
+
transactionId: record.transactionId,
|
|
291
|
+
createdAt: record.createdTime,
|
|
292
|
+
updatedAt: pickLatestBillingTimestamp([record.updatedTime, record.createdTime])
|
|
293
|
+
};
|
|
294
|
+
}
|
|
205
295
|
function resolveBillingProductSnapshot(item) {
|
|
206
296
|
if (!item) return void 0;
|
|
207
297
|
return {
|
|
@@ -478,6 +568,10 @@ export {
|
|
|
478
568
|
filterBillingPurchasableItems,
|
|
479
569
|
buildBillingPaymentCallbackContext,
|
|
480
570
|
resolveBillingSubscriptionProduct,
|
|
571
|
+
normalizeCasdoorSubscriptionDetail,
|
|
572
|
+
normalizeCasdoorSubscriptionHistoryItem,
|
|
573
|
+
normalizeCasdoorOrderHistoryItem,
|
|
574
|
+
normalizeCasdoorPaymentHistoryItem,
|
|
481
575
|
resolveBillingProductSnapshot,
|
|
482
576
|
deriveBillingCreditsState,
|
|
483
577
|
deriveBillingEntitlements,
|
|
@@ -491,4 +585,4 @@ export {
|
|
|
491
585
|
buildCasdoorBuyProductRequest,
|
|
492
586
|
normalizeCasdoorBuyProductResponse
|
|
493
587
|
};
|
|
494
|
-
//# sourceMappingURL=chunk-
|
|
588
|
+
//# sourceMappingURL=chunk-FL6LOXEG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/billing/runtime.ts","../src/billing/casdoor-purchase.ts"],"sourcesContent":["import type {\n BillingActionPayload,\n BillingCatalogConfig,\n BillingCreditsState,\n BillingCasdoorOrderDetail,\n BillingCasdoorSubscriptionDetail,\n BillingEntitlementState,\n BillingInterval,\n BillingItem,\n BillingPurchasableEntry,\n BillingOrderHistoryItem,\n BillingPaymentHistoryItem,\n BillingPaymentCallbackContext,\n BillingPurchaseRequest,\n BillingProductSnapshot,\n BillingProductState,\n BillingPurchaseStatus,\n BillingRuntimeConfig,\n BillingSubscriptionState,\n BillingSubscriptionHistoryItem,\n} from './types';\n\nfunction normalizeCasdoorProductId(id: string): { owner: string; name: string } {\n const [owner, ...rest] = id.split('/');\n const name = rest.join('/');\n\n if (!owner || !name) {\n throw new Error(`Invalid Casdoor product id: ${id}`);\n }\n\n return { owner, name };\n}\n\nexport function normalizeBillingRuntimeConfig(config?: Partial<BillingRuntimeConfig> | null): BillingRuntimeConfig {\n return {\n catalogKey: config?.catalogKey ?? 'default',\n items: config?.items ?? [],\n purchasableIds: config?.purchasableIds ?? [],\n purchasables: config?.purchasables ?? [],\n conversionRules: config?.conversionRules ?? [],\n defaults: config?.defaults ?? {},\n };\n}\n\nexport function normalizeBillingCatalogConfig(config?: Partial<BillingCatalogConfig> | null): BillingCatalogConfig {\n return {\n ...normalizeBillingRuntimeConfig(config),\n title: config?.title,\n description: config?.description,\n portalPath: config?.portalPath,\n successPath: config?.successPath,\n cancelPath: config?.cancelPath,\n };\n}\n\nexport function resolveBillingItem(items: BillingItem[] | undefined, key?: string | null): BillingItem | undefined {\n if (!key) return undefined;\n return items?.find((item) => item.key === key || item.backendRef.productId === key || item.backendRef.planId === key);\n}\n\nfunction isBillingPurchasableIdMatch(id: string, item: BillingItem | BillingPurchasableEntry): boolean {\n return id === item.key || id === item.backendRef.productId || ('planId' in item.backendRef && id === item.backendRef.planId);\n}\n\nexport function resolveBillingPurchasable(\n runtimeConfig: BillingRuntimeConfig | undefined,\n key?: string | null,\n): BillingPurchasableEntry | undefined {\n if (!runtimeConfig || !key) {\n return undefined;\n }\n\n const explicit = runtimeConfig.purchasables?.find(\n (item) => item.key === key || item.backendRef.productId === key || ('planId' in item.backendRef && item.backendRef.planId === key),\n );\n if (explicit) {\n return explicit;\n }\n\n if (runtimeConfig.purchasableIds?.length) {\n const matchingItem = resolveBillingItem(runtimeConfig.items, key);\n if (!matchingItem) {\n return undefined;\n }\n\n const allowed = runtimeConfig.purchasableIds.some((itemKey) => isBillingPurchasableIdMatch(itemKey, matchingItem));\n if (!allowed) {\n return undefined;\n }\n }\n\n const item = resolveBillingItem(runtimeConfig.items, key);\n if (!item) {\n return undefined;\n }\n\n if (item.kind === 'subscription') {\n return {\n key: item.key,\n kind: 'subscription',\n title: item.title,\n description: item.description,\n enabled: true,\n backendRef: {\n productId: item.backendRef.productId,\n planId: item.backendRef.planId,\n priceId: item.backendRef.priceId,\n },\n interval: item.interval,\n hooks: undefined,\n };\n }\n\n return {\n key: item.key,\n kind: 'product',\n title: item.title,\n description: item.description,\n enabled: true,\n backendRef: {\n productId: item.backendRef.productId,\n priceId: item.backendRef.priceId,\n },\n quantity: undefined,\n creditGrant: item.creditGrant,\n creditRedeem: item.creditRedeem,\n hooks: undefined,\n };\n}\n\nexport function buildBillingPurchaseRequest(\n payload: BillingActionPayload,\n runtimeConfig?: BillingRuntimeConfig | null,\n): BillingPurchaseRequest | null {\n const config = normalizeBillingRuntimeConfig(runtimeConfig);\n const purchasable = resolveBillingPurchasable(config, payload.key) ?? resolveBillingPurchasable(config, payload.productId);\n if (!purchasable) {\n return null;\n }\n\n let productOwner: string | undefined;\n let productName: string | undefined;\n try {\n const normalized = normalizeCasdoorProductId(purchasable.backendRef.productId);\n productOwner = normalized.owner;\n productName = normalized.name;\n } catch {\n productOwner = undefined;\n productName = undefined;\n }\n\n return {\n kind: purchasable.kind,\n key: purchasable.key,\n productId: purchasable.backendRef.productId,\n productOwner,\n productName,\n providerName: payload.providerName,\n pricingName: payload.pricingName,\n planName: payload.planName,\n userName: payload.userName,\n paymentEnv: payload.paymentEnv,\n customPrice: payload.customPrice,\n quantity: payload.quantity ?? 1,\n returnTo: payload.returnTo,\n metadata: payload.metadata,\n };\n}\n\nexport function filterBillingPurchasableItems(\n items: BillingItem[] | undefined,\n runtimeConfig?: BillingRuntimeConfig | null,\n): BillingItem[] {\n if (!runtimeConfig) {\n return items ?? [];\n }\n\n const config = normalizeBillingRuntimeConfig(runtimeConfig);\n if (!config.purchasableIds?.length && !config.purchasables?.length) {\n return items ?? [];\n }\n\n return (items ?? []).filter((item) => {\n const purchasable = resolveBillingPurchasable(config, item.key);\n return Boolean(purchasable);\n });\n}\n\nasync function readRequestBody(request: Request): Promise<unknown> {\n if (request.method === 'GET' || request.method === 'HEAD') {\n return null;\n }\n\n const rawBody = await request.clone().text();\n if (!rawBody) {\n return null;\n }\n\n const contentType = request.headers.get('content-type') ?? '';\n if (contentType.includes('application/json')) {\n try {\n return JSON.parse(rawBody);\n } catch {\n return rawBody;\n }\n }\n\n if (contentType.includes('application/x-www-form-urlencoded')) {\n return Object.fromEntries(new URLSearchParams(rawBody).entries());\n }\n\n return rawBody;\n}\n\nexport async function buildBillingPaymentCallbackContext(\n request: Request,\n phase?: 'success' | 'failure' | 'finished',\n): Promise<BillingPaymentCallbackContext> {\n const url = new URL(request.url);\n const params: Record<string, string> = {};\n\n for (const [key, value] of url.searchParams.entries()) {\n params[key] = value;\n }\n\n const paymentOwner = url.searchParams.get('paymentOwner') ?? url.searchParams.get('owner');\n const paymentName = url.searchParams.get('paymentName') ?? url.searchParams.get('name');\n const paymentId = url.searchParams.get('paymentId');\n const orderId = url.searchParams.get('orderId');\n const redirectTo = url.searchParams.get('redirect') ?? url.searchParams.get('returnTo');\n const failureSignal = url.searchParams.get('error') || url.searchParams.get('status') === 'failed';\n const status: BillingPaymentCallbackContext['status'] = failureSignal\n ? 'failure'\n : phase === 'finished'\n ? 'finished'\n : phase === 'failure'\n ? 'failure'\n : 'success';\n\n return {\n request,\n url,\n searchParams: url.searchParams,\n params,\n paymentOwner,\n paymentName,\n paymentId,\n orderId,\n redirectTo,\n status,\n body: await readRequestBody(request),\n };\n}\n\nexport function resolveBillingSubscriptionProduct(\n subscription: BillingSubscriptionState | undefined,\n runtimeConfig: BillingRuntimeConfig | undefined,\n): BillingProductSnapshot | undefined {\n if (!subscription) return undefined;\n if (subscription.product) return subscription.product;\n\n const item = resolveBillingItem(runtimeConfig?.items, subscription.planKey ?? subscription.subscriptionId);\n if (!item) return undefined;\n\n return {\n productKey: item.key,\n productId: item.backendRef.productId,\n title: item.title,\n kind: item.kind,\n planId: item.backendRef.planId,\n priceId: item.backendRef.priceId,\n interval: item.interval,\n creditGrant: item.creditGrant,\n creditRedeem: item.creditRedeem,\n metadata: item.metadata,\n };\n}\n\nfunction normalizeCasdoorSubscriptionStatus(status?: string | null): BillingSubscriptionState['status'] {\n const normalized = typeof status === 'string' ? status.toLowerCase() : '';\n if (normalized.includes('active') || normalized.includes('paid')) return 'active';\n if (normalized.includes('trial')) return 'trialing';\n if (normalized.includes('past_due') || normalized.includes('pastdue') || normalized.includes('due')) return 'past_due';\n if (normalized.includes('suspend')) return 'inactive';\n if (normalized.includes('expire')) return 'inactive';\n if (normalized.includes('cancel')) return 'canceled';\n if (normalized.includes('fail') || normalized.includes('error')) return 'inactive';\n return 'inactive';\n}\n\nfunction normalizeBillingOrderStatus(status?: string | null): BillingOrderHistoryItem['status'] {\n const normalized = typeof status === 'string' ? status.toLowerCase() : '';\n if (normalized.includes('paid') || normalized.includes('success') || normalized.includes('complete')) return 'paid';\n if (normalized.includes('pend') || normalized.includes('wait')) return 'pending';\n if (normalized.includes('fail') || normalized.includes('error')) return 'failed';\n if (normalized.includes('refund')) return 'refunded';\n if (normalized.includes('cancel')) return 'canceled';\n return 'pending';\n}\n\nfunction normalizeBillingPaymentStatus(status?: string | null): BillingPaymentHistoryItem['status'] {\n const normalized = typeof status === 'string' ? status.toLowerCase() : '';\n if (normalized.includes('paid') || normalized.includes('success') || normalized.includes('complete')) return 'paid';\n if (normalized.includes('pend') || normalized.includes('wait') || normalized.includes('process')) return 'pending';\n if (normalized.includes('fail') || normalized.includes('error')) return 'failed';\n if (normalized.includes('refund')) return 'refunded';\n if (normalized.includes('cancel')) return 'canceled';\n return 'pending';\n}\n\nfunction pickLatestBillingTimestamp(values: Array<string | undefined>): string | undefined {\n return values\n .filter((value): value is string => typeof value === 'string' && value.length > 0)\n .sort((left, right) => Date.parse(right) - Date.parse(left))[0];\n}\n\nexport function normalizeCasdoorSubscriptionDetail(\n record: BillingCasdoorSubscriptionDetail | undefined,\n): BillingSubscriptionState | undefined {\n if (!record) return undefined;\n const status = normalizeCasdoorSubscriptionStatus(record.state);\n return {\n subscriptionId: record.name,\n planKey: record.plan ?? record.pricing ?? record.name,\n planName: record.displayName ?? record.plan ?? record.pricing,\n status,\n interval: record.duration === 12 ? 'year' : record.duration === 1 ? 'month' : undefined,\n renewAt: record.endTime,\n currentPeriodStart: record.startTime,\n currentPeriodEnd: record.endTime,\n };\n}\n\nexport function normalizeCasdoorSubscriptionHistoryItem(\n record: BillingCasdoorSubscriptionDetail,\n): BillingSubscriptionHistoryItem {\n const status = normalizeCasdoorSubscriptionStatus(record.state);\n return {\n subscriptionId: record.name,\n planKey: record.plan ?? record.pricing ?? record.name,\n planName: record.displayName ?? record.plan ?? record.pricing,\n status,\n startedAt: record.startTime,\n endedAt: record.endTime,\n updatedAt: pickLatestBillingTimestamp([record.endTime, record.startTime, record.createdTime]),\n };\n}\n\nexport function normalizeCasdoorOrderHistoryItem(\n record: BillingCasdoorOrderDetail,\n): BillingOrderHistoryItem {\n const productKey = record.product ?? record.products?.[0];\n const createdAt = record.createdTime ?? (record as { updatedTime?: string }).updatedTime;\n return {\n orderId: record.name,\n productKey,\n productId: record.product,\n productTitle: record.productDisplayName ?? record.displayName ?? record.product,\n kind: productKey ? 'product' : undefined,\n quantity: record.quantity,\n amount: record.amount ?? record.price,\n currency: record.currency,\n status: normalizeBillingOrderStatus(record.state),\n paymentId: record.payment,\n transactionId: record.transaction,\n createdAt,\n updatedAt: pickLatestBillingTimestamp([createdAt, record.successUrl]),\n };\n}\n\nexport function normalizeCasdoorPaymentHistoryItem(\n record: {\n name: string;\n order?: string;\n outOrderId?: string;\n product?: string;\n productName?: string;\n productDisplayName?: string;\n price?: number;\n currency?: string;\n state?: string;\n transactionId?: string;\n createdTime?: string;\n updatedTime?: string;\n },\n): BillingPaymentHistoryItem {\n return {\n paymentId: record.name,\n orderId: record.order ?? record.outOrderId,\n productKey: record.product,\n amount: record.price,\n currency: record.currency,\n status: normalizeBillingPaymentStatus(record.state),\n transactionId: record.transactionId,\n createdAt: record.createdTime,\n updatedAt: pickLatestBillingTimestamp([record.updatedTime, record.createdTime]),\n };\n}\n\nexport function resolveBillingProductSnapshot(item?: BillingItem | null): BillingProductSnapshot | undefined {\n if (!item) return undefined;\n return {\n productKey: item.key,\n productId: item.backendRef.productId,\n title: item.title,\n kind: item.kind,\n planId: item.backendRef.planId,\n priceId: item.backendRef.priceId,\n interval: item.interval,\n creditGrant: item.creditGrant,\n creditRedeem: item.creditRedeem,\n metadata: item.metadata,\n };\n}\n\nexport function deriveBillingCreditsState(\n credits?: BillingCreditsState | null,\n products?: BillingProductState[] | null,\n conversionRules?: BillingRuntimeConfig['conversionRules'],\n): BillingCreditsState {\n if (credits) return credits;\n\n const fromProducts = products?.reduce((total, product) => {\n if (typeof product.creditsBalance === 'number') {\n return total + Number(product.creditsBalance);\n }\n\n if (!product.creditGrant) {\n return total;\n }\n\n const quantity = Number(product.quantity ?? 1);\n return total + Number(product.creditGrant.creditsPerUnit || 0) * quantity;\n }, 0);\n\n const fromRules = conversionRules?.reduce((total, rule) => {\n if (rule.kind !== 'grant-credits') return total;\n return total + Number(rule.creditsPerUnit || 0);\n }, 0);\n\n return {\n balance: Number(fromProducts ?? fromRules ?? 0),\n };\n}\n\nexport function deriveBillingEntitlements(\n subscription: BillingSubscriptionState | undefined,\n products: BillingProductState[] | undefined,\n credits: BillingCreditsState | undefined,\n runtimeConfig: BillingRuntimeConfig | undefined,\n): BillingEntitlementState {\n const features = new Set<string>();\n const limits: Record<string, number> = {};\n const flags: Record<string, boolean> = {};\n const creditBalance = credits?.balance ?? 0;\n\n for (const item of runtimeConfig?.items ?? []) {\n for (const feature of item.features ?? []) {\n features.add(feature);\n }\n if (item.metadata?.tier) {\n flags[item.metadata.tier] = true;\n }\n }\n\n if (subscription?.status === 'active' || subscription?.status === 'trialing') {\n flags.subscribed = true;\n }\n\n if (creditBalance > 0) {\n flags.hasCredits = true;\n limits.credits = creditBalance;\n }\n\n for (const product of products ?? []) {\n if (product.owned) {\n flags[`product:${product.productKey}`] = true;\n }\n }\n\n return {\n features: [...features],\n limits,\n flags,\n };\n}\n\nexport function normalizeBillingPurchaseStatus(\n status?: Partial<BillingPurchaseStatus> | null,\n order?: BillingOrderHistoryItem | null,\n payment?: BillingPaymentHistoryItem | null,\n): BillingPurchaseStatus {\n if (status) {\n return {\n actionKey: status.actionKey,\n orderId: status.orderId,\n paymentId: status.paymentId,\n transactionId: status.transactionId,\n status: status.status ?? 'idle',\n orderStatus: status.orderStatus,\n paymentStatus: status.paymentStatus,\n transactionStatus: status.transactionStatus,\n redirectTo: status.redirectTo,\n updatedAt: status.updatedAt,\n };\n }\n\n const orderStatus = order?.status;\n const paymentStatus = payment?.status;\n const normalizedStatus =\n paymentStatus === 'paid' || orderStatus === 'paid'\n ? 'paid'\n : paymentStatus === 'pending' || orderStatus === 'pending'\n ? 'pending'\n : paymentStatus === 'failed' || orderStatus === 'failed'\n ? 'failed'\n : paymentStatus === 'canceled' || orderStatus === 'canceled'\n ? 'canceled'\n : paymentStatus === 'refunded' || orderStatus === 'refunded'\n ? 'refunded'\n : paymentStatus === 'pending'\n ? 'requires_payment'\n : 'idle';\n\n return {\n actionKey: order?.orderId ?? payment?.paymentId,\n orderId: order?.orderId,\n paymentId: payment?.paymentId,\n transactionId: payment?.transactionId ?? order?.transactionId,\n status: normalizedStatus,\n orderStatus,\n paymentStatus,\n transactionStatus: payment?.transactionId ? 'linked' : undefined,\n updatedAt: payment?.updatedAt ?? order?.updatedAt,\n };\n}\n\nexport function resolveBillingInterval(interval?: BillingInterval | null): BillingInterval | undefined {\n return interval === 'month' || interval === 'year' ? interval : undefined;\n}\n\nexport function buildBillingActionPayload(\n payload: BillingActionPayload,\n runtimeConfig?: BillingRuntimeConfig | null,\n): BillingActionPayload {\n const config = normalizeBillingRuntimeConfig(runtimeConfig);\n const item = resolveBillingItem(config.items, payload.key) ?? resolveBillingItem(config.items, payload.productId);\n\n if (payload.kind === 'subscribe' && item) {\n return {\n ...payload,\n subscriptionConfig: payload.subscriptionConfig ?? {\n productKey: item.key,\n productId: item.backendRef.productId,\n planId: item.backendRef.planId,\n priceId: item.backendRef.priceId,\n interval: item.interval ?? config.defaults?.defaultInterval,\n quantity: payload.quantity ?? config.defaults?.defaultQuantity,\n metadata: item.metadata,\n },\n };\n }\n\n if ((payload.kind === 'purchase' || payload.kind === 'manage' || payload.kind === 'upgrade' || payload.kind === 'cancel') && item) {\n return {\n ...payload,\n productConfig: payload.productConfig ?? {\n productKey: item.key,\n productId: item.backendRef.productId,\n priceId: item.backendRef.priceId,\n quantity: payload.quantity ?? config.defaults?.defaultQuantity,\n creditGrant: item.creditGrant,\n creditRedeem: item.creditRedeem,\n metadata: item.metadata,\n },\n };\n }\n\n return payload;\n}\n","import type {\n BillingActionExecutionResult,\n BillingCasdoorBuyProductRequest,\n BillingCasdoorBuyProductResponse,\n BillingCasdoorErrorPayload,\n BillingCasdoorProductDetail,\n BillingCasdoorProviderOption,\n BillingPurchaseRequest,\n} from './types';\n\nexport interface NormalizedCasdoorProductId {\n owner: string;\n name: string;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction extractString(value: unknown): string | undefined {\n return isNonEmptyString(value) ? value : undefined;\n}\n\nfunction parseCasdoorErrorPayload(message: string | undefined): BillingCasdoorErrorPayload | undefined {\n if (!isNonEmptyString(message)) {\n return undefined;\n }\n\n const trimmed = message.trim();\n if (!trimmed.startsWith('{')) {\n return { message: trimmed };\n }\n\n try {\n const parsed = JSON.parse(trimmed) as unknown;\n if (!isRecord(parsed)) {\n return { message: trimmed };\n }\n\n const detail = isRecord(parsed.detail)\n ? {\n ...parsed.detail,\n field: extractString(parsed.detail.field),\n value: extractString(parsed.detail.value),\n issue: extractString(parsed.detail.issue),\n location: extractString(parsed.detail.location),\n }\n : undefined;\n\n return {\n ...parsed,\n code: extractString(parsed.code),\n message: extractString(parsed.message) ?? extractString(parsed.msg) ?? extractString(detail?.issue) ?? trimmed,\n detail,\n };\n } catch {\n return { message: trimmed };\n }\n}\n\nexport function readBuyProductRedirectTo(value: unknown): string | undefined {\n if (!isRecord(value)) {\n return undefined;\n }\n\n for (const key of ['redirectTo', 'redirectUrl', 'redirect_url', 'url', 'href', 'location']) {\n const candidate = value[key];\n if (isNonEmptyString(candidate)) {\n return candidate;\n }\n }\n\n return undefined;\n}\n\nexport function normalizeCasdoorProductId(id: string): NormalizedCasdoorProductId {\n const [owner, ...rest] = id.split('/');\n const name = rest.join('/');\n\n if (!isNonEmptyString(owner) || !isNonEmptyString(name)) {\n throw new Error(`Invalid Casdoor product id: ${id}`);\n }\n\n return { owner, name };\n}\n\nfunction chooseProviderFromObjects(\n providerObjs: BillingCasdoorProviderOption[] | undefined,\n preferredProviderName?: string,\n): string | undefined {\n if (isNonEmptyString(preferredProviderName)) {\n return preferredProviderName;\n }\n\n return providerObjs?.find((provider) => isNonEmptyString(provider.name))?.name;\n}\n\nexport function chooseCasdoorProviderName(\n product: Pick<BillingCasdoorProductDetail, 'providers' | 'providerObjs'>,\n preferredProviderName?: string,\n): string {\n if (isNonEmptyString(preferredProviderName)) {\n return preferredProviderName;\n }\n\n const fromProviders = product.providers?.find(isNonEmptyString);\n if (fromProviders) {\n return fromProviders;\n }\n\n const fromProviderObjs = chooseProviderFromObjects(product.providerObjs, preferredProviderName);\n if (fromProviderObjs) {\n return fromProviderObjs;\n }\n\n throw new Error('No providerName available for Casdoor buy-product request.');\n}\n\nexport function buildCasdoorBuyProductParams(\n input: BillingCasdoorBuyProductRequest,\n): URLSearchParams {\n const params = new URLSearchParams();\n params.set('id', input.id);\n params.set('providerName', input.providerName);\n params.set('pricingName', input.pricingName ?? '');\n params.set('planName', input.planName ?? '');\n params.set('userName', input.userName ?? '');\n params.set('paymentEnv', input.paymentEnv ?? '');\n params.set('customPrice', String(input.customPrice ?? 0));\n return params;\n}\n\nexport function buildCasdoorBuyProductRequest(\n purchase: BillingPurchaseRequest,\n product: BillingCasdoorProductDetail,\n preferredProviderName?: string,\n): BillingCasdoorBuyProductRequest {\n const providerName = chooseCasdoorProviderName(product, purchase.providerName ?? preferredProviderName);\n const productId = `${product.owner}/${product.name}`;\n\n return {\n id: productId,\n providerName,\n pricingName: purchase.pricingName ?? '',\n planName: purchase.planName ?? '',\n userName: purchase.userName ?? '',\n paymentEnv: purchase.paymentEnv ?? '',\n customPrice: purchase.customPrice ?? 0,\n };\n}\n\nfunction normalizeCasdoorBuyProductStatus(status: string | undefined): 'succeeded' | 'pending' | 'failed' {\n const statusText = typeof status === 'string' ? status.toLowerCase() : '';\n if (statusText.includes('error') || statusText.includes('fail') || statusText.includes('cancel')) {\n return 'failed';\n }\n if (statusText.includes('pend') || statusText.includes('require')) {\n return 'pending';\n }\n return 'succeeded';\n}\n\nexport function normalizeCasdoorBuyProductResponse(\n response: BillingCasdoorBuyProductResponse,\n fallbackRedirectTo?: string,\n): BillingActionExecutionResult {\n const errorPayload = parseCasdoorErrorPayload(response.msg);\n const redirectTo =\n readBuyProductRedirectTo(response.data) ??\n readBuyProductRedirectTo(response.data2) ??\n readBuyProductRedirectTo(response.data3) ??\n fallbackRedirectTo;\n const status = normalizeCasdoorBuyProductStatus(response.status);\n\n if (status === 'failed') {\n return {\n status,\n redirectTo,\n message: errorPayload?.message ?? response.msg ?? 'Casdoor buy-product failed.',\n errorCode: errorPayload?.code,\n rawResult: response,\n };\n }\n\n return {\n status,\n redirectTo,\n rawResult: response,\n };\n}\n"],"mappings":";AAsBA,SAAS,0BAA0B,IAA6C;AAC9E,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI,GAAG,MAAM,GAAG;AACrC,QAAM,OAAO,KAAK,KAAK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ACvE,MAAI,WAAW,SAAS,OAAO,KAAK,WAAW,SAAS,MAAM,KAAK,WAAW,SAAS,QAAQ,GAAG;AAChG,WAAO;AAAA,EACT;AACA,MAAI,WAAW,SAAS,MAAM,KAAK,WAAW,SAAS,SAAS,GAAG;AACjE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,SAAS,mCACd,UACA,oBAC8B;AAC9B,QAAM,eAAe,yBAAyB,SAAS,GAAG;AAC1D,QAAM,aACJ,yBAAyB,SAAS,IAAI,KACtC,yBAAyB,SAAS,KAAK,KACvC,yBAAyB,SAAS,KAAK,KACvC;AACF,QAAM,SAAS,iCAAiC,SAAS,MAAM;AAE/D,MAAI,WAAW,UAAU;AACvB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,SAAS,cAAc,WAAW,SAAS,OAAO;AAAA,MAClD,WAAW,cAAc;AAAA,MACzB,WAAW;AAAA,IACb;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW;AAAA,EACb;AACF;","names":["item","normalizeCasdoorProductId"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildBillingPaymentCallbackContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FL6LOXEG.js";
|
|
4
4
|
|
|
5
5
|
// src/billing/payment-route.ts
|
|
6
6
|
import { NextResponse } from "next/server";
|
|
@@ -139,4 +139,4 @@ export {
|
|
|
139
139
|
createBillingPaymentFinishedResponse,
|
|
140
140
|
createBillingPaymentFinishedRouteHandler
|
|
141
141
|
};
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-NWYEHQNK.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { createAuthorizeEntryResponse, createCasdoorApiProxyHandler, createCasdo
|
|
|
5
5
|
export { C as CallbackHandlerOptions, c as createCallbackHandler, a as createCallbackResponse } from './callback-rEWxVGyL.js';
|
|
6
6
|
export { createAuthorizeRouteHandler, createLoginRouteHandler, createLogoutHandler, createSignupRouteHandler } from './next/index.js';
|
|
7
7
|
export { A as AuthSession, a as AuthSessionUser, b as AuthTokenPayload, N as NextAuthRouteOptions, c as createNextAuthOptions, d as createNextAuthRouteHandler } from './options-D2YQdRWu.js';
|
|
8
|
-
export {
|
|
9
|
-
export { NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorProductId, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct } from './billing/index.js';
|
|
8
|
+
export { z as BillingActionExecutionResult, f as BillingActionExecutor, A as BillingActionKind, B as BillingActionPayload, d as BillingApiClient, C as BillingCasdoorAccountDetail, D as BillingCasdoorAccountMultiFactorAuthDetail, E as BillingCasdoorAccountResponse, F as BillingCasdoorApiResponse, G as BillingCasdoorApplicationDetail, H as BillingCasdoorApplicationProviderDetail, I as BillingCasdoorApplicationResponse, J as BillingCasdoorApplicationSigninItemDetail, K as BillingCasdoorApplicationSigninMethodDetail, L as BillingCasdoorApplicationSignupItemDetail, M as BillingCasdoorBuyProductRequest, N as BillingCasdoorBuyProductResponse, O as BillingCasdoorErrorDetail, P as BillingCasdoorErrorPayload, t as BillingCasdoorOrderDetail, Q as BillingCasdoorOrderResponse, R as BillingCasdoorOrdersResponse, S as BillingCasdoorOrganizationDetail, T as BillingCasdoorOrganizationNamesResponse, U as BillingCasdoorOrganizationOption, V as BillingCasdoorPaymentDetail, W as BillingCasdoorPaymentResponse, u as BillingCasdoorPlanDetail, X as BillingCasdoorPlanResponse, v as BillingCasdoorPricingDetail, Y as BillingCasdoorPricingResponse, w as BillingCasdoorProductDetail, Z as BillingCasdoorProductResponse, _ as BillingCasdoorProviderDetail, $ as BillingCasdoorProviderOption, s as BillingCasdoorQueryState, x as BillingCasdoorSubscriptionDetail, a0 as BillingCasdoorSubscriptionResponse, a1 as BillingCasdoorSubscriptionsResponse, c as BillingCatalogConfig, a2 as BillingConversionRule, y as BillingCoreContextValue, a3 as BillingCreditsContextValue, m as BillingCreditsState, g as BillingDefaults, n as BillingEntitlementState, a4 as BillingInterval, a as BillingItem, a5 as BillingItemKind, e as BillingLoaders, a6 as BillingOrderCreatedContext, k as BillingOrderHistoryItem, a7 as BillingPaymentCallbackContext, a8 as BillingPaymentFinishedContext, a9 as BillingPaymentFinishedHandler, aa as BillingPaymentFinishedRouteOptions, l as BillingPaymentHistoryItem, ab as BillingPaymentRouteBaseOptions, ac as BillingPaymentSuccessContext, ad as BillingPaymentSuccessHandler, ae as BillingPaymentSuccessHandlerResult, af as BillingPaymentSuccessRouteOptions, ag as BillingProductContextValue, ah as BillingProductDetailState, ai as BillingProductPurchasableEntry, aj as BillingProductPurchaseConfig, r as BillingProductSnapshot, j as BillingProductState, ak as BillingPurchasableEntry, al as BillingPurchasableEntryBase, am as BillingPurchasableKind, an as BillingPurchasableWhitelist, ao as BillingPurchaseCompleteContext, ap as BillingPurchaseErrorContext, q as BillingPurchaseHooks, aq as BillingPurchaseRequest, p as BillingPurchaseStatus, b as BillingRuntimeConfig, o as BillingStatusState, ar as BillingSubscriptionContextValue, i as BillingSubscriptionHistoryItem, as as BillingSubscriptionPurchasableEntry, at as BillingSubscriptionPurchaseConfig, h as BillingSubscriptionState } from './types-oVIQpMut.js';
|
|
9
|
+
export { NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorOrderHistoryItem, normalizeCasdoorPaymentHistoryItem, normalizeCasdoorProductId, normalizeCasdoorSubscriptionDetail, normalizeCasdoorSubscriptionHistoryItem, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct } from './billing/index.js';
|
|
10
10
|
import 'next/server';
|
|
11
11
|
import 'next-auth';
|
|
12
12
|
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
createBillingPaymentFinishedRouteHandler,
|
|
15
15
|
createBillingPaymentSuccessResponse,
|
|
16
16
|
createBillingPaymentSuccessRouteHandler
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NWYEHQNK.js";
|
|
18
18
|
import {
|
|
19
19
|
createCasdoorApiProxyHandler,
|
|
20
20
|
createCasdoorCommerceProxyHandler,
|
|
@@ -80,14 +80,18 @@ import {
|
|
|
80
80
|
normalizeBillingPurchaseStatus,
|
|
81
81
|
normalizeBillingRuntimeConfig,
|
|
82
82
|
normalizeCasdoorBuyProductResponse,
|
|
83
|
+
normalizeCasdoorOrderHistoryItem,
|
|
84
|
+
normalizeCasdoorPaymentHistoryItem,
|
|
83
85
|
normalizeCasdoorProductId,
|
|
86
|
+
normalizeCasdoorSubscriptionDetail,
|
|
87
|
+
normalizeCasdoorSubscriptionHistoryItem,
|
|
84
88
|
readBuyProductRedirectTo,
|
|
85
89
|
resolveBillingInterval,
|
|
86
90
|
resolveBillingItem,
|
|
87
91
|
resolveBillingProductSnapshot,
|
|
88
92
|
resolveBillingPurchasable,
|
|
89
93
|
resolveBillingSubscriptionProduct
|
|
90
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-FL6LOXEG.js";
|
|
91
95
|
import {
|
|
92
96
|
buildAuthJumpHref,
|
|
93
97
|
resolvePostLoginRedirect
|
|
@@ -157,7 +161,11 @@ export {
|
|
|
157
161
|
normalizeBillingPurchaseStatus,
|
|
158
162
|
normalizeBillingRuntimeConfig,
|
|
159
163
|
normalizeCasdoorBuyProductResponse,
|
|
164
|
+
normalizeCasdoorOrderHistoryItem,
|
|
165
|
+
normalizeCasdoorPaymentHistoryItem,
|
|
160
166
|
normalizeCasdoorProductId,
|
|
167
|
+
normalizeCasdoorSubscriptionDetail,
|
|
168
|
+
normalizeCasdoorSubscriptionHistoryItem,
|
|
161
169
|
parseStateToken,
|
|
162
170
|
pkceCookiePrefix,
|
|
163
171
|
readBuyProductRedirectTo,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Session } from 'next-auth';
|
|
|
5
5
|
import { useSession } from 'next-auth/react';
|
|
6
6
|
import { A as AuthSession } from '../options-D2YQdRWu.js';
|
|
7
7
|
export { a as AuthSessionUser, b as AuthTokenPayload } from '../options-D2YQdRWu.js';
|
|
8
|
-
import { B as BillingActionPayload, a as BillingItem, b as BillingRuntimeConfig, c as BillingCatalogConfig, d as BillingApiClient, e as BillingLoaders, f as BillingActionExecutor, g as BillingDefaults, h as BillingSubscriptionState, i as BillingSubscriptionHistoryItem, j as BillingProductState, k as BillingOrderHistoryItem, l as BillingPaymentHistoryItem, m as BillingCreditsState, n as BillingEntitlementState, o as BillingStatusState, p as BillingPurchaseStatus, q as BillingPurchaseHooks, r as BillingProductSnapshot, s as
|
|
8
|
+
import { B as BillingActionPayload, a as BillingItem, b as BillingRuntimeConfig, c as BillingCatalogConfig, d as BillingApiClient, e as BillingLoaders, f as BillingActionExecutor, g as BillingDefaults, h as BillingSubscriptionState, i as BillingSubscriptionHistoryItem, j as BillingProductState, k as BillingOrderHistoryItem, l as BillingPaymentHistoryItem, m as BillingCreditsState, n as BillingEntitlementState, o as BillingStatusState, p as BillingPurchaseStatus, q as BillingPurchaseHooks, r as BillingProductSnapshot, s as BillingCasdoorQueryState, t as BillingCasdoorOrderDetail, u as BillingCasdoorPlanDetail, v as BillingCasdoorPricingDetail, w as BillingCasdoorProductDetail, x as BillingCasdoorSubscriptionDetail, y as BillingCoreContextValue } from '../types-oVIQpMut.js';
|
|
9
9
|
import 'next-auth/jwt';
|
|
10
10
|
import '../types-BJv6j3NZ.js';
|
|
11
11
|
|
|
@@ -132,6 +132,47 @@ interface BillingProductPurchaseOptionsState {
|
|
|
132
132
|
refresh: () => Promise<void>;
|
|
133
133
|
}
|
|
134
134
|
declare function useBillingProductPurchaseOptions(productId: string, preferredProviderName?: string): BillingProductPurchaseOptionsState;
|
|
135
|
+
type BillingPricingState = BillingCasdoorQueryState<BillingCasdoorPricingDetail>;
|
|
136
|
+
type BillingPlanState = BillingCasdoorQueryState<BillingCasdoorPlanDetail>;
|
|
137
|
+
type BillingOrderState = BillingCasdoorQueryState<BillingCasdoorOrderDetail>;
|
|
138
|
+
type BillingOrdersState = BillingCasdoorQueryState<BillingCasdoorOrderDetail[]>;
|
|
139
|
+
type BillingSubscriptionRecordState = BillingCasdoorQueryState<BillingCasdoorSubscriptionDetail>;
|
|
140
|
+
type BillingSubscriptionsState = BillingCasdoorQueryState<BillingCasdoorSubscriptionDetail[]>;
|
|
141
|
+
declare function useBillingPricing(pricingId: string): BillingPricingState;
|
|
142
|
+
declare function useBillingPlan(planId: string, includeOption?: boolean): BillingPlanState;
|
|
143
|
+
declare function useBillingOrder(orderId: string): BillingOrderState;
|
|
144
|
+
declare function useBillingSubscriptionRecord(subscriptionId: string): BillingSubscriptionRecordState;
|
|
145
|
+
declare function useBillingOrders(options?: {
|
|
146
|
+
owner?: string;
|
|
147
|
+
user?: string;
|
|
148
|
+
product?: string;
|
|
149
|
+
}): BillingOrdersState;
|
|
150
|
+
declare function useBillingSubscriptions(options?: {
|
|
151
|
+
owner?: string;
|
|
152
|
+
user?: string;
|
|
153
|
+
}): BillingSubscriptionsState;
|
|
154
|
+
interface BillingPricingPlansState {
|
|
155
|
+
pricing?: BillingCasdoorPricingDetail;
|
|
156
|
+
plans: BillingCasdoorPlanDetail[];
|
|
157
|
+
selectedPlanName?: string;
|
|
158
|
+
selectedPlan?: BillingCasdoorPlanDetail;
|
|
159
|
+
setSelectedPlanName: (planName?: string) => void;
|
|
160
|
+
loading: boolean;
|
|
161
|
+
error: string | null;
|
|
162
|
+
refresh: () => Promise<void>;
|
|
163
|
+
}
|
|
164
|
+
declare function useBillingPricingPlans(pricingId: string, includeOption?: boolean, preferredPlanName?: string): BillingPricingPlansState;
|
|
165
|
+
interface BillingSubscriptionPurchaseOptionsState {
|
|
166
|
+
pricing?: BillingCasdoorPricingDetail;
|
|
167
|
+
plans: BillingCasdoorPlanDetail[];
|
|
168
|
+
selectedPlanName?: string;
|
|
169
|
+
selectedPlan?: BillingCasdoorPlanDetail;
|
|
170
|
+
setSelectedPlanName: (planName?: string) => void;
|
|
171
|
+
loading: boolean;
|
|
172
|
+
error: string | null;
|
|
173
|
+
refresh: () => Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
declare function useBillingSubscriptionPurchaseOptions(pricingId: string, includeOption?: boolean, preferredPlanName?: string): BillingSubscriptionPurchaseOptionsState;
|
|
135
176
|
interface BillingProductsState {
|
|
136
177
|
products: BillingProductState[];
|
|
137
178
|
loading: boolean;
|
|
@@ -254,4 +295,4 @@ interface BillingProductStateView {
|
|
|
254
295
|
declare function useBillingProduct(productKey: string): BillingProductStateView;
|
|
255
296
|
declare function useBillingCatalogConfig(): BillingCatalogState;
|
|
256
297
|
|
|
257
|
-
export { type AuthActions, type AuthActionsOptions, AuthProvider, type AuthRole, AuthSession, type AuthUserSummary, type BillingActionHookResult, type BillingAvailablePlansState, type BillingAvailableProductsState, type BillingCatalogState, BillingCoreProvider, type BillingCoreProviderProps, type BillingCreditsProviderProps, type BillingCreditsStateView, type BillingEntitlementsStateView, type BillingItemState, type BillingOrderHistoryState, type BillingPaymentHistoryState, type BillingPipelineOptions, type BillingPipelineResult, type BillingProductDetailState, type BillingProductProviderProps, type BillingProductPurchaseOptionsState, type BillingProductStateView, type BillingProductsState, BillingProvider, type BillingProviderProps, type BillingPurchaseStatusView, type BillingRefreshView, type BillingStatusView, type BillingSubscriptionHistoryState, type BillingSubscriptionProductState, type BillingSubscriptionProviderProps, type BillingSubscriptionStateView, CreditsProvider, ProductProvider, SubscriptionProvider, useAuthActions, useAuthRole, useAuthSession, useAuthUser, useBillingAvailablePlans, useBillingAvailableProducts, useBillingCatalog, useBillingCatalogConfig, useBillingContext, useBillingCredits, useBillingEntitlements, useBillingItem, useBillingOrderHistory, useBillingPaymentHistory, useBillingPipeline, useBillingProduct, useBillingProductDetail, useBillingProductPurchaseOptions, useBillingProducts, useBillingPurchaseStatus, useBillingRefresh, useBillingStatus, useBillingSubscription, useBillingSubscriptionHistory, useBillingSubscriptionProduct, useCancelSubscription, useManageSubscription, usePurchaseProduct, useSubscribePlan, useUpgradePlan };
|
|
298
|
+
export { type AuthActions, type AuthActionsOptions, AuthProvider, type AuthRole, AuthSession, type AuthUserSummary, type BillingActionHookResult, type BillingAvailablePlansState, type BillingAvailableProductsState, type BillingCatalogState, BillingCoreProvider, type BillingCoreProviderProps, type BillingCreditsProviderProps, type BillingCreditsStateView, type BillingEntitlementsStateView, type BillingItemState, type BillingOrderHistoryState, type BillingOrderState, type BillingOrdersState, type BillingPaymentHistoryState, type BillingPipelineOptions, type BillingPipelineResult, type BillingPlanState, type BillingPricingPlansState, type BillingPricingState, type BillingProductDetailState, type BillingProductProviderProps, type BillingProductPurchaseOptionsState, type BillingProductStateView, type BillingProductsState, BillingProvider, type BillingProviderProps, type BillingPurchaseStatusView, type BillingRefreshView, type BillingStatusView, type BillingSubscriptionHistoryState, type BillingSubscriptionProductState, type BillingSubscriptionProviderProps, type BillingSubscriptionPurchaseOptionsState, type BillingSubscriptionRecordState, type BillingSubscriptionStateView, type BillingSubscriptionsState, CreditsProvider, ProductProvider, SubscriptionProvider, useAuthActions, useAuthRole, useAuthSession, useAuthUser, useBillingAvailablePlans, useBillingAvailableProducts, useBillingCatalog, useBillingCatalogConfig, useBillingContext, useBillingCredits, useBillingEntitlements, useBillingItem, useBillingOrder, useBillingOrderHistory, useBillingOrders, useBillingPaymentHistory, useBillingPipeline, useBillingPlan, useBillingPricing, useBillingPricingPlans, useBillingProduct, useBillingProductDetail, useBillingProductPurchaseOptions, useBillingProducts, useBillingPurchaseStatus, useBillingRefresh, useBillingStatus, useBillingSubscription, useBillingSubscriptionHistory, useBillingSubscriptionProduct, useBillingSubscriptionPurchaseOptions, useBillingSubscriptionRecord, useBillingSubscriptions, useCancelSubscription, useManageSubscription, usePurchaseProduct, useSubscribePlan, useUpgradePlan };
|