@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.
@@ -191,7 +191,43 @@ interface BillingCasdoorApiResponse<TData = unknown> {
191
191
  data2: unknown | null;
192
192
  data3: unknown | null;
193
193
  }
194
+ interface BillingCasdoorQueryState<TData> {
195
+ data?: TData;
196
+ loading: boolean;
197
+ error: string | null;
198
+ refresh: () => Promise<void>;
199
+ }
194
200
  type BillingCasdoorProductResponse = BillingCasdoorApiResponse<BillingCasdoorProductDetail>;
201
+ interface BillingCasdoorPricingDetail {
202
+ owner: string;
203
+ name: string;
204
+ createdTime?: string;
205
+ displayName?: string;
206
+ description?: string;
207
+ plans?: string[];
208
+ isEnabled?: boolean;
209
+ trialDuration?: number;
210
+ application?: string;
211
+ [key: string]: unknown;
212
+ }
213
+ type BillingCasdoorPricingResponse = BillingCasdoorApiResponse<BillingCasdoorPricingDetail>;
214
+ interface BillingCasdoorPlanDetail {
215
+ owner: string;
216
+ name: string;
217
+ createdTime?: string;
218
+ displayName?: string;
219
+ description?: string;
220
+ price?: number;
221
+ currency?: string;
222
+ period?: string;
223
+ product?: string;
224
+ paymentProviders?: string[];
225
+ isEnabled?: boolean;
226
+ role?: string;
227
+ options?: unknown;
228
+ [key: string]: unknown;
229
+ }
230
+ type BillingCasdoorPlanResponse = BillingCasdoorApiResponse<BillingCasdoorPlanDetail>;
195
231
  interface BillingCasdoorAccountMultiFactorAuthDetail {
196
232
  enabled: boolean;
197
233
  isPreferred: boolean;
@@ -425,6 +461,47 @@ interface BillingCasdoorPaymentDetail {
425
461
  [key: string]: unknown;
426
462
  }
427
463
  type BillingCasdoorPaymentResponse = BillingCasdoorApiResponse<BillingCasdoorPaymentDetail>;
464
+ interface BillingCasdoorOrderDetail {
465
+ owner: string;
466
+ name: string;
467
+ createdTime?: string;
468
+ displayName?: string;
469
+ user?: string;
470
+ product?: string;
471
+ productDisplayName?: string;
472
+ products?: string[];
473
+ price?: number;
474
+ amount?: number;
475
+ currency?: string;
476
+ quantity?: number;
477
+ provider?: string;
478
+ payment?: string;
479
+ transaction?: string;
480
+ successUrl?: string;
481
+ returnUrl?: string;
482
+ state?: string;
483
+ [key: string]: unknown;
484
+ }
485
+ type BillingCasdoorOrderResponse = BillingCasdoorApiResponse<BillingCasdoorOrderDetail>;
486
+ type BillingCasdoorOrdersResponse = BillingCasdoorApiResponse<BillingCasdoorOrderDetail[]>;
487
+ interface BillingCasdoorSubscriptionDetail {
488
+ owner: string;
489
+ name: string;
490
+ createdTime?: string;
491
+ displayName?: string;
492
+ description?: string;
493
+ duration?: number;
494
+ startTime?: string;
495
+ endTime?: string;
496
+ pricing?: string;
497
+ plan?: string;
498
+ payment?: string;
499
+ user?: string;
500
+ state?: 'Pending' | 'Error' | 'Suspended' | 'Active' | 'Upcoming' | 'Expired' | string;
501
+ [key: string]: unknown;
502
+ }
503
+ type BillingCasdoorSubscriptionResponse = BillingCasdoorApiResponse<BillingCasdoorSubscriptionDetail>;
504
+ type BillingCasdoorSubscriptionsResponse = BillingCasdoorApiResponse<BillingCasdoorSubscriptionDetail[]>;
428
505
  type BillingCasdoorOrganizationNamesResponse = BillingCasdoorApiResponse<BillingCasdoorOrganizationDetail[]>;
429
506
  interface BillingCasdoorBuyProductRequest {
430
507
  id: string;
@@ -743,6 +820,28 @@ interface BillingApiClient {
743
820
  userId?: string;
744
821
  catalogKey?: string;
745
822
  }) => Promise<BillingEntitlementState>;
823
+ fetchPricing?: (args: {
824
+ id: string;
825
+ }) => Promise<BillingCasdoorPricingResponse>;
826
+ fetchPlan?: (args: {
827
+ id: string;
828
+ includeOption?: boolean;
829
+ }) => Promise<BillingCasdoorPlanResponse>;
830
+ fetchOrder?: (args: {
831
+ id: string;
832
+ }) => Promise<BillingCasdoorOrderResponse>;
833
+ fetchOrders?: (args: {
834
+ owner?: string;
835
+ user?: string;
836
+ product?: string;
837
+ }) => Promise<BillingCasdoorOrdersResponse>;
838
+ fetchSubscriptionRecord?: (args: {
839
+ id: string;
840
+ }) => Promise<BillingCasdoorSubscriptionResponse>;
841
+ fetchSubscriptions?: (args: {
842
+ owner?: string;
843
+ user?: string;
844
+ }) => Promise<BillingCasdoorSubscriptionsResponse>;
746
845
  fetchAccount?: (args: {
747
846
  id?: string;
748
847
  }) => Promise<BillingCasdoorAccountResponse>;
@@ -812,6 +911,28 @@ interface BillingLoaders {
812
911
  userId?: string;
813
912
  catalogKey?: string;
814
913
  }) => Promise<BillingEntitlementState>;
914
+ pricingLoader?: (args: {
915
+ id: string;
916
+ }) => Promise<BillingCasdoorPricingResponse>;
917
+ planLoader?: (args: {
918
+ id: string;
919
+ includeOption?: boolean;
920
+ }) => Promise<BillingCasdoorPlanResponse>;
921
+ orderLoader?: (args: {
922
+ id: string;
923
+ }) => Promise<BillingCasdoorOrderResponse>;
924
+ ordersLoader?: (args: {
925
+ owner?: string;
926
+ user?: string;
927
+ product?: string;
928
+ }) => Promise<BillingCasdoorOrdersResponse>;
929
+ subscriptionRecordLoader?: (args: {
930
+ id: string;
931
+ }) => Promise<BillingCasdoorSubscriptionResponse>;
932
+ subscriptionsLoader?: (args: {
933
+ owner?: string;
934
+ user?: string;
935
+ }) => Promise<BillingCasdoorSubscriptionsResponse>;
815
936
  accountLoader?: (args: {
816
937
  id?: string;
817
938
  }) => Promise<BillingCasdoorAccountResponse>;
@@ -892,4 +1013,4 @@ interface BillingCoreContextValue {
892
1013
  setStatus: (status: BillingStatusState | ((current: BillingStatusState) => BillingStatusState)) => void;
893
1014
  }
894
1015
 
895
- export type { BillingPaymentFinishedRouteOptions as $, BillingCasdoorApplicationDetail as A, BillingActionPayload as B, BillingCasdoorApplicationProviderDetail as C, BillingCasdoorApplicationResponse as D, BillingCasdoorApplicationSigninItemDetail as E, BillingCasdoorApplicationSigninMethodDetail as F, BillingCasdoorApplicationSignupItemDetail as G, BillingCasdoorBuyProductRequest as H, BillingCasdoorBuyProductResponse as I, BillingCasdoorErrorDetail as J, BillingCasdoorErrorPayload as K, BillingCasdoorOrganizationDetail as L, BillingCasdoorOrganizationNamesResponse as M, BillingCasdoorOrganizationOption as N, BillingCasdoorPaymentDetail as O, BillingCasdoorPaymentResponse as P, BillingCasdoorProductResponse as Q, BillingCasdoorProviderDetail as R, BillingCasdoorProviderOption as S, BillingConversionRule as T, BillingCreditsContextValue as U, BillingInterval as V, BillingItemKind as W, BillingOrderCreatedContext as X, BillingPaymentCallbackContext as Y, BillingPaymentFinishedContext as Z, BillingPaymentFinishedHandler as _, BillingItem as a, BillingPaymentRouteBaseOptions as a0, BillingPaymentSuccessContext as a1, BillingPaymentSuccessHandler as a2, BillingPaymentSuccessHandlerResult as a3, BillingPaymentSuccessRouteOptions as a4, BillingProductContextValue as a5, BillingProductDetailState as a6, BillingProductPurchasableEntry as a7, BillingProductPurchaseConfig as a8, BillingPurchasableEntry as a9, BillingPurchasableEntryBase as aa, BillingPurchasableKind as ab, BillingPurchasableWhitelist as ac, BillingPurchaseCompleteContext as ad, BillingPurchaseErrorContext as ae, BillingPurchaseRequest as af, BillingSubscriptionContextValue as ag, BillingSubscriptionPurchasableEntry as ah, BillingSubscriptionPurchaseConfig as ai, BillingRuntimeConfig as b, BillingCatalogConfig as c, BillingApiClient as d, BillingLoaders as e, BillingActionExecutor as f, BillingDefaults as g, BillingSubscriptionState as h, BillingSubscriptionHistoryItem as i, BillingProductState as j, BillingOrderHistoryItem as k, BillingPaymentHistoryItem as l, BillingCreditsState as m, BillingEntitlementState as n, BillingStatusState as o, BillingPurchaseStatus as p, BillingPurchaseHooks as q, BillingProductSnapshot as r, BillingCasdoorProductDetail as s, BillingCoreContextValue as t, BillingActionExecutionResult as u, BillingActionKind as v, BillingCasdoorAccountDetail as w, BillingCasdoorAccountMultiFactorAuthDetail as x, BillingCasdoorAccountResponse as y, BillingCasdoorApiResponse as z };
1016
+ export type { BillingCasdoorProviderOption as $, BillingActionKind as A, BillingActionPayload as B, BillingCasdoorAccountDetail as C, BillingCasdoorAccountMultiFactorAuthDetail as D, BillingCasdoorAccountResponse as E, BillingCasdoorApiResponse as F, BillingCasdoorApplicationDetail as G, BillingCasdoorApplicationProviderDetail as H, BillingCasdoorApplicationResponse as I, BillingCasdoorApplicationSigninItemDetail as J, BillingCasdoorApplicationSigninMethodDetail as K, BillingCasdoorApplicationSignupItemDetail as L, BillingCasdoorBuyProductRequest as M, BillingCasdoorBuyProductResponse as N, BillingCasdoorErrorDetail as O, BillingCasdoorErrorPayload as P, BillingCasdoorOrderResponse as Q, BillingCasdoorOrdersResponse as R, BillingCasdoorOrganizationDetail as S, BillingCasdoorOrganizationNamesResponse as T, BillingCasdoorOrganizationOption as U, BillingCasdoorPaymentDetail as V, BillingCasdoorPaymentResponse as W, BillingCasdoorPlanResponse as X, BillingCasdoorPricingResponse as Y, BillingCasdoorProductResponse as Z, BillingCasdoorProviderDetail as _, BillingItem as a, BillingCasdoorSubscriptionResponse as a0, BillingCasdoorSubscriptionsResponse as a1, BillingConversionRule as a2, BillingCreditsContextValue as a3, BillingInterval as a4, BillingItemKind as a5, BillingOrderCreatedContext as a6, BillingPaymentCallbackContext as a7, BillingPaymentFinishedContext as a8, BillingPaymentFinishedHandler as a9, BillingPaymentFinishedRouteOptions as aa, BillingPaymentRouteBaseOptions as ab, BillingPaymentSuccessContext as ac, BillingPaymentSuccessHandler as ad, BillingPaymentSuccessHandlerResult as ae, BillingPaymentSuccessRouteOptions as af, BillingProductContextValue as ag, BillingProductDetailState as ah, BillingProductPurchasableEntry as ai, BillingProductPurchaseConfig as aj, BillingPurchasableEntry as ak, BillingPurchasableEntryBase as al, BillingPurchasableKind as am, BillingPurchasableWhitelist as an, BillingPurchaseCompleteContext as ao, BillingPurchaseErrorContext as ap, BillingPurchaseRequest as aq, BillingSubscriptionContextValue as ar, BillingSubscriptionPurchasableEntry as as, BillingSubscriptionPurchaseConfig as at, BillingRuntimeConfig as b, BillingCatalogConfig as c, BillingApiClient as d, BillingLoaders as e, BillingActionExecutor as f, BillingDefaults as g, BillingSubscriptionState as h, BillingSubscriptionHistoryItem as i, BillingProductState as j, BillingOrderHistoryItem as k, BillingPaymentHistoryItem as l, BillingCreditsState as m, BillingEntitlementState as n, BillingStatusState as o, BillingPurchaseStatus as p, BillingPurchaseHooks as q, BillingProductSnapshot as r, BillingCasdoorQueryState as s, BillingCasdoorOrderDetail as t, BillingCasdoorPlanDetail as u, BillingCasdoorPricingDetail as v, BillingCasdoorProductDetail as w, BillingCasdoorSubscriptionDetail as x, BillingCoreContextValue as y, BillingActionExecutionResult as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldspace-fe/casdoor-next-auth-kit",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/billing/runtime.ts","../src/billing/casdoor-purchase.ts"],"sourcesContent":["import type {\n BillingActionPayload,\n BillingCatalogConfig,\n BillingCreditsState,\n BillingEntitlementState,\n BillingInterval,\n BillingItem,\n BillingPurchasableEntry,\n BillingPaymentCallbackContext,\n BillingPurchaseRequest,\n BillingOrderHistoryItem,\n BillingPaymentHistoryItem,\n BillingProductSnapshot,\n BillingProductState,\n BillingPurchaseStatus,\n BillingRuntimeConfig,\n BillingSubscriptionHistoryItem,\n BillingSubscriptionState,\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\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":";AAoBA,SAAS,0BAA0B,IAA6C;AAC9E,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI,GAAG,MAAM,GAAG;AACrC,QAAM,OAAO,KAAK,KAAK,GAAG;AAE1B,MAAI,CAAC,SAAS,CAAC,MAAM;AACnB,UAAM,IAAI,MAAM,+BAA+B,EAAE,EAAE;AAAA,EACrD;AAEA,SAAO,EAAE,OAAO,KAAK;AACvB;AAEO,SAAS,8BAA8B,QAAqE;AACjH,SAAO;AAAA,IACL,YAAY,QAAQ,cAAc;AAAA,IAClC,OAAO,QAAQ,SAAS,CAAC;AAAA,IACzB,gBAAgB,QAAQ,kBAAkB,CAAC;AAAA,IAC3C,cAAc,QAAQ,gBAAgB,CAAC;AAAA,IACvC,iBAAiB,QAAQ,mBAAmB,CAAC;AAAA,IAC7C,UAAU,QAAQ,YAAY,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,8BAA8B,QAA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