项目文件夹

文件
wehub-resource-sync 6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:33:44 +08:00

88 行
3.0 KiB
TypeScript

import {
type AutoReloadSettingsResponse,
autoReloadSettingsResponse,
type CreateAutoReloadSetupSessionRequest,
type CreateAutoReloadSetupSessionResponse,
type CreateCreditCheckoutSessionRequest,
type CreateCreditCheckoutSessionResponse,
type CreditStripeStatusResponse,
createAutoReloadSetupSessionResponse,
createCreditCheckoutSessionResponse,
creditStripeStatusResponse,
type FinalizeCheckoutResponse,
finalizeCheckoutResponse,
type GetCreditPurchasesResponse,
type GetPagePurchasesResponse,
getCreditPurchasesResponse,
getPagePurchasesResponse,
type UpdateAutoReloadSettingsRequest,
} from "@/contracts/types/stripe.types";
import { baseApiService } from "./base-api.service";
class StripeApiService {
createCreditCheckoutSession = async (
request: CreateCreditCheckoutSessionRequest
): Promise<CreateCreditCheckoutSessionResponse> => {
const { workspace_id, ...body } = request;
return baseApiService.post(
"/api/v1/stripe/create-credit-checkout-session",
createCreditCheckoutSessionResponse,
{ body: { ...body, workspace_id } }
);
};
getCreditStatus = async (): Promise<CreditStripeStatusResponse> => {
return baseApiService.get("/api/v1/stripe/credit-status", creditStripeStatusResponse);
};
getCreditPurchases = async (): Promise<GetCreditPurchasesResponse> => {
return baseApiService.get("/api/v1/stripe/credit-purchases", getCreditPurchasesResponse);
};
/** Legacy page-purchase history (read-only; page buying is removed). */
getPagePurchases = async (): Promise<GetPagePurchasesResponse> => {
return baseApiService.get("/api/v1/stripe/purchases", getPagePurchasesResponse);
};
/**
* Synchronously fulfil a credit checkout session from the success page.
*
* Solves the race where the user lands on /purchase-success before
* Stripe's checkout.session.completed webhook arrives. Idempotent —
* safe to call concurrently with the webhook.
*/
finalizeCheckout = async (sessionId: string): Promise<FinalizeCheckoutResponse> => {
return baseApiService.get(
`/api/v1/stripe/finalize-checkout?session_id=${encodeURIComponent(sessionId)}`,
finalizeCheckoutResponse
);
};
// --- Auto-reload --------------------------------------------------------
getAutoReloadSettings = async (): Promise<AutoReloadSettingsResponse> => {
return baseApiService.get("/api/v1/stripe/auto-reload", autoReloadSettingsResponse);
};
updateAutoReloadSettings = async (
request: UpdateAutoReloadSettingsRequest
): Promise<AutoReloadSettingsResponse> => {
return baseApiService.put("/api/v1/stripe/auto-reload", autoReloadSettingsResponse, {
body: request,
});
};
createAutoReloadSetupSession = async (
request: CreateAutoReloadSetupSessionRequest
): Promise<CreateAutoReloadSetupSessionResponse> => {
const { workspace_id } = request;
return baseApiService.post(
"/api/v1/stripe/auto-reload/setup",
createAutoReloadSetupSessionResponse,
{ body: { workspace_id } }
);
};
}
export const stripeApiService = new StripeApiService();