@4players/payment 1.0.2-beta.1 → 1.0.2-beta.2
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/index.cjs +14 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -1
- package/dist/index.d.ts +95 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -469,6 +469,20 @@ var PaymentClient = class {
|
|
|
469
469
|
if (error) this.handleError("check feature", error);
|
|
470
470
|
return data;
|
|
471
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Check product dependencies for a project.
|
|
474
|
+
*
|
|
475
|
+
* @param projectId - The unique identifier of the project
|
|
476
|
+
* @param query - Query with the product slug to check
|
|
477
|
+
* @returns Dependency check result with activation status of each dependency
|
|
478
|
+
*/
|
|
479
|
+
async checkProductDependencies(projectId, query) {
|
|
480
|
+
const { data, error } = await this.client.GET("/projects/{projectId}/check-product-dependencies", {
|
|
481
|
+
params: { path: { projectId }, query }
|
|
482
|
+
});
|
|
483
|
+
if (error) this.handleError("check product dependencies", error);
|
|
484
|
+
return data;
|
|
485
|
+
}
|
|
472
486
|
// ==================== Invoices ====================
|
|
473
487
|
/**
|
|
474
488
|
* Get all invoices for the current user, optionally filtered by ID.
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"names":["createClient"],"mappings":";;;;;;;;;;;;;AAcO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,KAAA,CAAM;AAAA,EACtC,WAAA,CACE,OAAA,EACgB,UAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,cAA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6BAAA,EAA+B,KAAK,CAAA;AAChE,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,IAAO,cAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Payment SDK Error Classes\n *\n * Provides structured error handling for Payment API operations.\n */\n\n// V8-specific stack trace capture (available in Node.js, Chrome, etc.)\ndeclare const Error: ErrorConstructor & {\n captureStackTrace?(targetObject: object, constructorOpt?: Function): void;\n};\n\n/**\n * Base error class for all Payment SDK errors.\n */\nexport class PaymentError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly details?: unknown\n ) {\n super(message);\n this.name = \"PaymentError\";\n // Maintains proper stack trace for where error was thrown (V8 engines)\n if (typeof Error.captureStackTrace === \"function\") {\n Error.captureStackTrace(this, PaymentError);\n }\n }\n}\n\n/**\n * Error thrown when the Payment API returns an application-level error\n * in its response envelope.\n *\n * The Payment API wraps all responses in an envelope:\n * ```json\n * { \"data\": T | null, \"error\": { \"code\": number, \"message\": string } }\n * ```\n *\n * A `PaymentApiError` is thrown when:\n * - `error.code !== 0` (application-level error, even if HTTP status is 200)\n * - `data` is `null` (legacy error pattern from before HTTP status codes were used)\n */\nexport class PaymentApiError extends PaymentError {\n /**\n * Application-level error code from the response envelope.\n * A value of `0` means no specific error code was returned (legacy null-data case).\n */\n public readonly code: number;\n\n /**\n * The HTTP status code of the response.\n * Note: This may be `200` even when there is an application error.\n */\n public readonly httpStatus: number;\n\n constructor(message: string, code: number, httpStatus: number) {\n super(message, httpStatus);\n this.name = \"PaymentApiError\";\n this.code = code;\n this.httpStatus = httpStatus;\n }\n}\n\n/**\n * Error thrown when authentication fails or is required.\n */\nexport class PaymentAuthError extends PaymentError {\n constructor(message = \"Authentication required. Please provide a valid session ID.\") {\n super(message, 401);\n this.name = \"PaymentAuthError\";\n }\n}\n\n/**\n * Error thrown when a requested resource is not found.\n */\nexport class PaymentNotFoundError extends PaymentError {\n constructor(resource: string, id: string) {\n super(`${resource} with ID ${id} not found`, 404);\n this.name = \"PaymentNotFoundError\";\n }\n}\n\n/**\n * Error thrown when request validation fails.\n */\nexport class PaymentValidationError extends PaymentError {\n constructor(message: string, details?: unknown) {\n super(message, 422, details);\n this.name = \"PaymentValidationError\";\n }\n}\n\n/**\n * Error thrown when the API rate limit is exceeded.\n */\nexport class PaymentRateLimitError extends PaymentError {\n constructor(retryAfter?: number) {\n super(\n retryAfter\n ? `Rate limit exceeded. Retry after ${retryAfter} seconds.`\n : \"Rate limit exceeded. Please try again later.\",\n 429,\n { retryAfter }\n );\n this.name = \"PaymentRateLimitError\";\n }\n}\n","/**\n * 4Players Payment API Client\n *\n * A type-safe client for the 4Players Payment API.\n * Works in browsers, Node.js, Deno, Bun, and edge runtimes.\n *\n * @example\n * ```typescript\n * import { PaymentClient } from '@4players/payment';\n *\n * const client = new PaymentClient({ sessionId: 'your-session-id' });\n *\n * const projects = await client.getProjects();\n * ```\n */\n\nimport createClient, { type Middleware } from \"openapi-fetch\";\nimport type { paths, components, operations } from \"./types.js\";\nimport {\n PaymentError,\n PaymentApiError,\n PaymentAuthError,\n PaymentNotFoundError,\n PaymentRateLimitError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://secure.4players.de/public/api/v1\";\n\n/**\n * Configuration options for the Payment client.\n */\nexport interface PaymentClientConfig {\n /** Fusion session ID for authentication (sent as fusion-sid header) */\n sessionId: string;\n /** Base URL for the Payment API (default: https://secure.4players.de/public/api/v1) */\n baseUrl?: string;\n /** Custom fetch implementation (useful for testing or special environments) */\n fetch?: typeof fetch;\n}\n\n// ==================== Entity types from components.schemas ====================\n\nexport type PaymentProject = components[\"schemas\"][\"PaymentProject\"];\nexport type BillingAccount = components[\"schemas\"][\"BillingAccount\"];\nexport type OdinAccessKey = components[\"schemas\"][\"OdinAccessKey\"];\nexport type OdinUserPermissions = components[\"schemas\"][\"OdinUserPermissions\"];\nexport type OdinUserRole = components[\"schemas\"][\"OdinUserRole\"];\nexport type TimeSeriesData = components[\"schemas\"][\"TimeSeriesData\"];\nexport type Subscription = components[\"schemas\"][\"Subscription\"];\nexport type Invoice = components[\"schemas\"][\"Invoice\"];\nexport type InvoicePosition = components[\"schemas\"][\"InvoicePosition\"];\nexport type Invoices = components[\"schemas\"][\"Invoices\"];\nexport type SubscriptionPosition = components[\"schemas\"][\"SubscriptionPosition\"];\nexport type TariffParams = components[\"schemas\"][\"TariffParams\"];\nexport type SetupSession = components[\"schemas\"][\"SetupSession\"];\nexport type PortalSession = components[\"schemas\"][\"PortalSession\"];\nexport type TokenPayload = components[\"schemas\"][\"TokenPayload\"];\nexport type BillingOptions = components[\"schemas\"][\"BillingOptions\"];\nexport type BillingChangeOptions = components[\"schemas\"][\"BillingChangeOptions\"];\nexport type BillingStateHistory = components[\"schemas\"][\"BillingStateHistory\"];\nexport type ResourcePackagePrice = components[\"schemas\"][\"ResourcePackagePrice\"];\nexport type SuccessResponse = components[\"schemas\"][\"SuccessResponse\"];\nexport type ProjectProduct = components[\"schemas\"][\"ProjectProduct\"];\nexport type ProjectProductFeature = components[\"schemas\"][\"ProjectProductFeature\"];\nexport type ProductPricing = components[\"schemas\"][\"ProductPricing\"];\nexport type ActivatedProduct = components[\"schemas\"][\"ActivatedProduct\"];\nexport type FeatureAvailability = components[\"schemas\"][\"FeatureAvailability\"];\n\n// Enum types\nexport type APIType = components[\"schemas\"][\"APIType\"];\nexport type BillingState = components[\"schemas\"][\"BillingState\"];\nexport type PermissionRole = components[\"schemas\"][\"PermissionRole\"];\nexport type UserStatus = components[\"schemas\"][\"UserStatus\"];\nexport type InvoiceStatus = components[\"schemas\"][\"InvoiceStatus\"];\nexport type ProductSlug = components[\"schemas\"][\"ProductSlug\"];\nexport type PricingType = components[\"schemas\"][\"PricingType\"];\n\n// ==================== Request/Payload types ====================\n\nexport type ActivateAPIPayload = components[\"schemas\"][\"ActivateAPIPayload\"];\nexport type AddUserToProjectPayload = components[\"schemas\"][\"AddUserToProjectPayload\"];\nexport type ChangeUserRolePayload = components[\"schemas\"][\"ChangeUserRolePayload\"];\nexport type CreateAccessKeyPayload = components[\"schemas\"][\"CreateAccessKeyPayload\"];\nexport type CreateBillingPortalSessionPayload = components[\"schemas\"][\"CreateBillingPortalSessionPayload\"];\nexport type CreateSetupSessionPayload = components[\"schemas\"][\"CreateSetupSessionPayload\"];\nexport type CreateTokenPayload = components[\"schemas\"][\"CreateTokenPayload\"];\nexport type EditAccessKeyPayload = components[\"schemas\"][\"EditAccessKeyPayload\"];\nexport type EditProjectPayload = components[\"schemas\"][\"EditProjectPayload\"];\nexport type ResourcePackagePricePayload = components[\"schemas\"][\"ResourcePackagePricePayload\"];\nexport type ResourcePackagePricesPayload = components[\"schemas\"][\"ResourcePackagePricesPayload\"];\nexport type RevokeUserPayload = components[\"schemas\"][\"RevokeUserPayload\"];\nexport type SetBillingAccountPayload = components[\"schemas\"][\"SetBillingAccountPayload\"];\nexport type ActivateProductPayload = components[\"schemas\"][\"ActivateProductPayload\"];\nexport type DeactivateProductPayload = components[\"schemas\"][\"DeactivateProductPayload\"];\n\n// ==================== Query parameter types ====================\n\nexport type GetProjectsQuery = operations[\"getProjects\"][\"parameters\"][\"query\"];\nexport type GetPeersOverTimeQuery = operations[\"getPeersOverTime\"][\"parameters\"][\"query\"];\nexport type GetRoomsOverTimeQuery = operations[\"getRoomsOverTime\"][\"parameters\"][\"query\"];\nexport type GetInstancesOverTimeQuery = operations[\"getInstancesOverTime\"][\"parameters\"][\"query\"];\nexport type GetInvoicesQuery = operations[\"getInvoices\"][\"parameters\"][\"query\"];\nexport type CheckFeatureQuery = operations[\"checkFeature\"][\"parameters\"][\"query\"];\n\n/**\n * Response envelope used by the Payment API.\n */\ninterface PaymentEnvelope<T = unknown> {\n data: T | null;\n error: {\n code: number;\n message: string;\n };\n}\n\n/**\n * 4Players Payment API Client\n *\n * Provides a type-safe interface to the 4Players Payment REST API for managing\n * projects, billing, invoices, access keys, and user permissions.\n */\nexport class PaymentClient {\n private client: ReturnType<typeof createClient<paths>>;\n\n /**\n * Create a new Payment client instance.\n *\n * @param config - Client configuration\n * @throws {PaymentAuthError} If no session ID is provided\n *\n * @example\n * ```typescript\n * const client = new PaymentClient({\n * sessionId: 'your-fusion-sid'\n * });\n * ```\n */\n constructor(config: PaymentClientConfig) {\n if (!config.sessionId) {\n throw new PaymentAuthError(\"Session ID is required\");\n }\n\n this.client = createClient<paths>({\n baseUrl: config.baseUrl || DEFAULT_BASE_URL,\n headers: {\n \"fusion-sid\": config.sessionId,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n fetch: config.fetch,\n });\n\n // Register the envelope-unwrapping middleware\n this.client.use(this.createEnvelopeMiddleware());\n }\n\n /**\n * Creates middleware that unwraps the Payment API response envelope.\n *\n * The Payment API wraps ALL responses in `{ data, error }`.\n * This middleware:\n * 1. Checks `error.code` — if non-zero, throws `PaymentApiError`\n * 2. Checks `data` — if null, throws `PaymentApiError` (legacy error pattern)\n * 3. Returns a new Response containing only the unwrapped `data`\n */\n private createEnvelopeMiddleware(): Middleware {\n return {\n async onResponse({ response }) {\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return response;\n }\n\n const text = await response.clone().text();\n let body: unknown;\n try {\n body = JSON.parse(text);\n } catch {\n return response;\n }\n\n if (\n body !== null &&\n typeof body === \"object\" &&\n \"error\" in body &&\n \"data\" in body\n ) {\n const envelope = body as PaymentEnvelope;\n\n // Application-level error (can happen even with HTTP 200!)\n if (envelope.error && envelope.error.code !== 0) {\n throw new PaymentApiError(\n envelope.error.message,\n envelope.error.code,\n response.status\n );\n }\n\n // Legacy error pattern: data is null with HTTP 200\n if (envelope.data === null || envelope.data === undefined) {\n throw new PaymentApiError(\n envelope.error?.message || \"Response data is null\",\n envelope.error?.code || 0,\n response.status\n );\n }\n\n // Return unwrapped data so openapi-fetch sees the schema-matching body\n return new Response(JSON.stringify(envelope.data), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n // Not an envelope — return as-is\n return response;\n },\n };\n }\n\n private handleError(operation: string, error: unknown): never {\n if (error && typeof error === \"object\") {\n const errorObj = error as Record<string, unknown>;\n\n if (errorObj.status === 401 || errorObj.status === 403) {\n throw new PaymentAuthError();\n }\n if (errorObj.status === 404) {\n throw new PaymentNotFoundError(operation, \"unknown\");\n }\n if (errorObj.status === 429) {\n throw new PaymentRateLimitError();\n }\n }\n\n throw new PaymentError(\n `Failed to ${operation}: ${JSON.stringify(error)}`,\n undefined,\n error\n );\n }\n\n // ==================== Fleet Apps ====================\n\n /**\n * Get all fleet apps the user has access to (projects with Fleet activated).\n *\n * @returns Array of payment projects with Fleet app IDs\n */\n async getFleetProjects(): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/apps\");\n if (error) this.handleError(\"get fleet projects\", error);\n return data!;\n }\n\n /**\n * Get the details of a specific fleet app including the payment project.\n *\n * @param appId - The ID of the fleet app to retrieve\n * @returns Payment project details\n */\n async getFleetProject(appId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/apps/{app_id}\", {\n params: { path: { app_id: appId } },\n });\n if (error) this.handleError(\"get fleet project\", error);\n return data!;\n }\n\n // ==================== Projects ====================\n\n /**\n * Get all projects the authenticated user has access to.\n *\n * @param query - Optional query parameters to filter by project type\n * @returns Array of payment projects\n */\n async getProjects(query?: GetProjectsQuery): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/projects\", {\n params: { query },\n });\n if (error) this.handleError(\"get projects\", error);\n return data!;\n }\n\n /**\n * Get a specific project by ID.\n *\n * @param projectId - The unique identifier of the project\n * @returns Project details\n */\n async getProject(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project\", error);\n return data!;\n }\n\n /**\n * Update a project's name, description, or peer limit.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Updated project fields\n * @returns Success response\n */\n async editProject(projectId: string, body: EditProjectPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"edit project\", error);\n return data!;\n }\n\n // ==================== Peers / Metrics ====================\n\n /**\n * Get peak peers over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required)\n * @returns Peers over time data\n */\n async getPeersOverTime(projectId: string, query: GetPeersOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/peers-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get peers over time\", error);\n return data!;\n }\n\n /**\n * Get room count over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of active rooms\n */\n async getRoomsOverTime(projectId: string, query: GetRoomsOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/rooms-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get rooms over time\", error);\n return data!;\n }\n\n /**\n * Get Fleet server instances over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of deployed server instances\n */\n async getInstancesOverTime(projectId: string, query: GetInstancesOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/instances-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get instances over time\", error);\n return data!;\n }\n\n // ==================== Billing ====================\n\n /**\n * Get all billing accounts for the current user.\n *\n * @returns Array of billing accounts\n */\n async getBillingAccounts(): Promise<BillingAccount[]> {\n const { data, error } = await this.client.GET(\"/billing\");\n if (error) this.handleError(\"get billing accounts\", error);\n return data!;\n }\n\n /**\n * Get a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Billing account details\n */\n async getBillingAccount(billingAccountId: string): Promise<BillingAccount> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account\", error);\n return data!;\n }\n\n /**\n * Get invoices for a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Array of invoices\n */\n async getBillingAccountInvoices(billingAccountId: string): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}/invoices\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account invoices\", error);\n return data!;\n }\n\n /**\n * Create a Stripe setup session for a new billing account.\n *\n * @param body - Setup session creation payload\n * @returns Setup session with redirect URL\n */\n async createSetupSession(body: CreateSetupSessionPayload): Promise<SetupSession> {\n const { data, error } = await this.client.POST(\"/billing/create-setup-session\", {\n body,\n });\n if (error) this.handleError(\"create setup session\", error);\n return data!;\n }\n\n /**\n * Create a Stripe billing portal session.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @param body - Portal session creation payload\n * @returns Portal session with redirect URL\n */\n async createBillingPortalSession(billingAccountId: string, body: CreateBillingPortalSessionPayload): Promise<PortalSession> {\n const { data, error } = await this.client.POST(\"/billing/{billingAccountId}/create-billing-portal-session\", {\n params: { path: { billingAccountId } },\n body,\n });\n if (error) this.handleError(\"create billing portal session\", error);\n return data!;\n }\n\n /**\n * Get billing options for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Billing options including current state and change options\n */\n async getBillingOptions(projectId: string): Promise<BillingOptions> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/get-billing-options\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get billing options\", error);\n return data!;\n }\n\n /**\n * Set a billing account on a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Billing account and state to set\n * @returns Success response\n */\n async setBillingAccount(projectId: string, body: SetBillingAccountPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/set-billing-account\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"set billing account\", error);\n return data!;\n }\n\n /**\n * Cancel billing for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Success response\n */\n async cancelBilling(projectId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/cancel-billing\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"cancel billing\", error);\n return data!;\n }\n\n // ==================== API Activation ====================\n\n /**\n * Activate an API for the specified project.\n *\n * @deprecated Use {@link activateProduct} instead.\n * @param projectId - The unique identifier of the project\n * @param body - The API slug to activate\n * @returns Success response\n */\n async activateAPI(projectId: string, body: ActivateAPIPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-api\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate API\", error);\n return data!;\n }\n\n // ==================== Products ====================\n\n /**\n * List all available products.\n *\n * @returns Array of available products with features and pricing\n */\n async getProducts(): Promise<ProjectProduct[]> {\n const { data, error } = await this.client.GET(\"/products\");\n if (error) this.handleError(\"get products\", error);\n return data!;\n }\n\n /**\n * Get activated products for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Array of activated products\n */\n async getProjectProducts(projectId: string): Promise<ActivatedProduct[]> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/products\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project products\", error);\n return data!;\n }\n\n /**\n * Activate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug and optional configuration\n * @returns Updated project\n */\n async activateProduct(projectId: string, body: ActivateProductPayload): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate product\", error);\n return data!;\n }\n\n /**\n * Deactivate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug to deactivate\n * @returns Success response\n */\n async deactivateProduct(projectId: string, body: DeactivateProductPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/deactivate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"deactivate product\", error);\n return data!;\n }\n\n /**\n * Check if a feature is available for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query with the feature slug to check\n * @returns Feature availability status\n */\n async checkFeature(projectId: string, query: CheckFeatureQuery): Promise<FeatureAvailability> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/check-feature\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"check feature\", error);\n return data!;\n }\n\n // ==================== Invoices ====================\n\n /**\n * Get all invoices for the current user, optionally filtered by ID.\n *\n * @param query - Optional query parameters for filtering by invoice IDs\n * @returns Array of invoices\n */\n async getInvoices(query?: GetInvoicesQuery): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/invoices\", {\n params: { query },\n });\n if (error) this.handleError(\"get invoices\", error);\n return data!;\n }\n\n /**\n * Get a preview of the current month's invoice for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Invoice preview\n */\n async getInvoicePreview(projectId: string): Promise<Invoice> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/preview-invoice\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get invoice preview\", error);\n return data!;\n }\n\n // ==================== Access Keys ====================\n\n /**\n * Get a specific access key.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Access key details\n */\n async getAccessKey(accessKeyId: string): Promise<OdinAccessKey> {\n const { data, error } = await this.client.GET(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"get access key\", error);\n return data!;\n }\n\n /**\n * Create a new access key for a project.\n *\n * @param body - Access key creation payload\n * @returns Created access key (includes the key value only in this response)\n */\n async createAccessKey(body: CreateAccessKeyPayload): Promise<OdinAccessKey> {\n const { data, error } = await this.client.POST(\"/odin-access-keys/\", {\n body,\n });\n if (error) this.handleError(\"create access key\", error);\n return data!;\n }\n\n /**\n * Update an existing access key's name or description.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @param body - Updated access key fields\n * @returns Success response\n */\n async editAccessKey(accessKeyId: string, body: EditAccessKeyPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n body,\n });\n if (error) this.handleError(\"edit access key\", error);\n return data!;\n }\n\n /**\n * Delete an access key. This operation is irreversible.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Success response\n */\n async deleteAccessKey(accessKeyId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.DELETE(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"delete access key\", error);\n return data!;\n }\n\n // ==================== Project Members ====================\n\n /**\n * Add a user to a project with a specified role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - User email and role\n * @returns The created user role\n */\n async addProjectMember(projectId: string, body: AddUserToProjectPayload): Promise<OdinUserRole> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/add-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"add project member\", error);\n return data!;\n }\n\n /**\n * Revoke a user's permission from a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID to revoke\n * @returns Success response\n */\n async deleteProjectMember(projectId: string, body: RevokeUserPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"delete project member\", error);\n return data!;\n }\n\n /**\n * Change a project member's role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID and new role\n * @returns Success response\n */\n async changeMemberRole(projectId: string, body: ChangeUserRolePayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/change-user-role\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"change member role\", error);\n return data!;\n }\n\n // ==================== Tokens & Secrets ====================\n\n /**\n * Create an ODIN access token for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Token creation payload\n * @returns The created token\n */\n async createAccessToken(projectId: string, body: CreateTokenPayload): Promise<TokenPayload> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/create-token\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"create access token\", error);\n return data!;\n }\n\n /**\n * Revoke the secret for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Updated project with new secret\n */\n async revokeSecret(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-secret\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"revoke secret\", error);\n return data!;\n }\n\n // ==================== Resource Package Pricing ====================\n\n /**\n * Get the price for a single resource package in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package, region, and quantity\n * @returns Price information\n */\n async getResourcePackagePrice(projectId: string, body: ResourcePackagePricePayload): Promise<ResourcePackagePrice> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-price\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package price\", error);\n return data!;\n }\n\n /**\n * Get prices for multiple resource packages in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package IDs, region, and quantity\n * @returns Array of price information\n */\n async getResourcePackagePrices(projectId: string, body: ResourcePackagePricesPayload): Promise<ResourcePackagePrice[]> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-prices\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package prices\", error);\n return data!;\n }\n}\n\nexport default PaymentClient;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"names":["createClient"],"mappings":";;;;;;;;;;;;;AAcO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,KAAA,CAAM;AAAA,EACtC,WAAA,CACE,OAAA,EACgB,UAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;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AA,EAAM,EAAE,WAAU,EAAE;AAAA,MAC9B;AAAA,KACD,CAAA;AACD,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,WAAA,CAAY,4BAAA,EAA8B,KAAK,CAAA;AAC/D,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,wBAAA,CAAyB,SAAA,EAAmB,IAAA,EAAqE;AACrH,IAAA,MAAM,EAAE,MAAM,KAAA,EAAM,GAAI,MAAM,IAAA,CAAK,MAAA,CAAO,KAAK,+CAAA,EAAiD;AAAA,MAC9F,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,WAAU,EAAE;AAAA,MAC9B;AAAA,KACD,CAAA;AACD,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,WAAA,CAAY,6BAAA,EAA+B,KAAK,CAAA;AAChE,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,IAAO,cAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Payment SDK Error Classes\n *\n * Provides structured error handling for Payment API operations.\n */\n\n// V8-specific stack trace capture (available in Node.js, Chrome, etc.)\ndeclare const Error: ErrorConstructor & {\n captureStackTrace?(targetObject: object, constructorOpt?: Function): void;\n};\n\n/**\n * Base error class for all Payment SDK errors.\n */\nexport class PaymentError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly details?: unknown\n ) {\n super(message);\n this.name = \"PaymentError\";\n // Maintains proper stack trace for where error was thrown (V8 engines)\n if (typeof Error.captureStackTrace === \"function\") {\n Error.captureStackTrace(this, PaymentError);\n }\n }\n}\n\n/**\n * Error thrown when the Payment API returns an application-level error\n * in its response envelope.\n *\n * The Payment API wraps all responses in an envelope:\n * ```json\n * { \"data\": T | null, \"error\": { \"code\": number, \"message\": string } }\n * ```\n *\n * A `PaymentApiError` is thrown when:\n * - `error.code !== 0` (application-level error, even if HTTP status is 200)\n * - `data` is `null` (legacy error pattern from before HTTP status codes were used)\n */\nexport class PaymentApiError extends PaymentError {\n /**\n * Application-level error code from the response envelope.\n * A value of `0` means no specific error code was returned (legacy null-data case).\n */\n public readonly code: number;\n\n /**\n * The HTTP status code of the response.\n * Note: This may be `200` even when there is an application error.\n */\n public readonly httpStatus: number;\n\n constructor(message: string, code: number, httpStatus: number) {\n super(message, httpStatus);\n this.name = \"PaymentApiError\";\n this.code = code;\n this.httpStatus = httpStatus;\n }\n}\n\n/**\n * Error thrown when authentication fails or is required.\n */\nexport class PaymentAuthError extends PaymentError {\n constructor(message = \"Authentication required. Please provide a valid session ID.\") {\n super(message, 401);\n this.name = \"PaymentAuthError\";\n }\n}\n\n/**\n * Error thrown when a requested resource is not found.\n */\nexport class PaymentNotFoundError extends PaymentError {\n constructor(resource: string, id: string) {\n super(`${resource} with ID ${id} not found`, 404);\n this.name = \"PaymentNotFoundError\";\n }\n}\n\n/**\n * Error thrown when request validation fails.\n */\nexport class PaymentValidationError extends PaymentError {\n constructor(message: string, details?: unknown) {\n super(message, 422, details);\n this.name = \"PaymentValidationError\";\n }\n}\n\n/**\n * Error thrown when the API rate limit is exceeded.\n */\nexport class PaymentRateLimitError extends PaymentError {\n constructor(retryAfter?: number) {\n super(\n retryAfter\n ? `Rate limit exceeded. Retry after ${retryAfter} seconds.`\n : \"Rate limit exceeded. Please try again later.\",\n 429,\n { retryAfter }\n );\n this.name = \"PaymentRateLimitError\";\n }\n}\n","/**\n * 4Players Payment API Client\n *\n * A type-safe client for the 4Players Payment API.\n * Works in browsers, Node.js, Deno, Bun, and edge runtimes.\n *\n * @example\n * ```typescript\n * import { PaymentClient } from '@4players/payment';\n *\n * const client = new PaymentClient({ sessionId: 'your-session-id' });\n *\n * const projects = await client.getProjects();\n * ```\n */\n\nimport createClient, { type Middleware } from \"openapi-fetch\";\nimport type { paths, components, operations } from \"./types.js\";\nimport {\n PaymentError,\n PaymentApiError,\n PaymentAuthError,\n PaymentNotFoundError,\n PaymentRateLimitError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://secure.4players.de/public/api/v1\";\n\n/**\n * Configuration options for the Payment client.\n */\nexport interface PaymentClientConfig {\n /** Fusion session ID for authentication (sent as fusion-sid header) */\n sessionId: string;\n /** Base URL for the Payment API (default: https://secure.4players.de/public/api/v1) */\n baseUrl?: string;\n /** Custom fetch implementation (useful for testing or special environments) */\n fetch?: typeof fetch;\n}\n\n// ==================== Entity types from components.schemas ====================\n\nexport type PaymentProject = components[\"schemas\"][\"PaymentProject\"];\nexport type BillingAccount = components[\"schemas\"][\"BillingAccount\"];\nexport type OdinAccessKey = components[\"schemas\"][\"OdinAccessKey\"];\nexport type OdinUserPermissions = components[\"schemas\"][\"OdinUserPermissions\"];\nexport type OdinUserRole = components[\"schemas\"][\"OdinUserRole\"];\nexport type TimeSeriesData = components[\"schemas\"][\"TimeSeriesData\"];\nexport type Subscription = components[\"schemas\"][\"Subscription\"];\nexport type Invoice = components[\"schemas\"][\"Invoice\"];\nexport type InvoicePosition = components[\"schemas\"][\"InvoicePosition\"];\nexport type Invoices = components[\"schemas\"][\"Invoices\"];\nexport type SubscriptionPosition = components[\"schemas\"][\"SubscriptionPosition\"];\nexport type TariffParams = components[\"schemas\"][\"TariffParams\"];\nexport type SetupSession = components[\"schemas\"][\"SetupSession\"];\nexport type PortalSession = components[\"schemas\"][\"PortalSession\"];\nexport type TokenPayload = components[\"schemas\"][\"TokenPayload\"];\nexport type BillingOptions = components[\"schemas\"][\"BillingOptions\"];\nexport type BillingChangeOptions = components[\"schemas\"][\"BillingChangeOptions\"];\nexport type BillingStateHistory = components[\"schemas\"][\"BillingStateHistory\"];\nexport type ResourcePackagePrice = components[\"schemas\"][\"ResourcePackagePrice\"];\nexport type SuccessResponse = components[\"schemas\"][\"SuccessResponse\"];\nexport type ProjectProduct = components[\"schemas\"][\"ProjectProduct\"];\nexport type ProjectProductFeature = components[\"schemas\"][\"ProjectProductFeature\"];\nexport type ProductPricing = components[\"schemas\"][\"ProductPricing\"];\nexport type ActivatedProduct = components[\"schemas\"][\"ActivatedProduct\"];\nexport type FeatureAvailability = components[\"schemas\"][\"FeatureAvailability\"];\nexport type ProductDependencyCheck = components[\"schemas\"][\"ProductDependencyCheck\"];\nexport type ProductDependencyStatus = components[\"schemas\"][\"ProductDependencyStatus\"];\n\n// Enum types\nexport type APIType = components[\"schemas\"][\"APIType\"];\nexport type BillingState = components[\"schemas\"][\"BillingState\"];\nexport type PermissionRole = components[\"schemas\"][\"PermissionRole\"];\nexport type UserStatus = components[\"schemas\"][\"UserStatus\"];\nexport type InvoiceStatus = components[\"schemas\"][\"InvoiceStatus\"];\nexport type ProductSlug = components[\"schemas\"][\"ProductSlug\"];\nexport type PricingType = components[\"schemas\"][\"PricingType\"];\n\n// ==================== Request/Payload types ====================\n\nexport type ActivateAPIPayload = components[\"schemas\"][\"ActivateAPIPayload\"];\nexport type AddUserToProjectPayload = components[\"schemas\"][\"AddUserToProjectPayload\"];\nexport type ChangeUserRolePayload = components[\"schemas\"][\"ChangeUserRolePayload\"];\nexport type CreateAccessKeyPayload = components[\"schemas\"][\"CreateAccessKeyPayload\"];\nexport type CreateBillingPortalSessionPayload = components[\"schemas\"][\"CreateBillingPortalSessionPayload\"];\nexport type CreateSetupSessionPayload = components[\"schemas\"][\"CreateSetupSessionPayload\"];\nexport type CreateTokenPayload = components[\"schemas\"][\"CreateTokenPayload\"];\nexport type EditAccessKeyPayload = components[\"schemas\"][\"EditAccessKeyPayload\"];\nexport type EditProjectPayload = components[\"schemas\"][\"EditProjectPayload\"];\nexport type ResourcePackagePricePayload = components[\"schemas\"][\"ResourcePackagePricePayload\"];\nexport type ResourcePackagePricesPayload = components[\"schemas\"][\"ResourcePackagePricesPayload\"];\nexport type RevokeUserPayload = components[\"schemas\"][\"RevokeUserPayload\"];\nexport type SetBillingAccountPayload = components[\"schemas\"][\"SetBillingAccountPayload\"];\nexport type ActivateProductPayload = components[\"schemas\"][\"ActivateProductPayload\"];\nexport type DeactivateProductPayload = components[\"schemas\"][\"DeactivateProductPayload\"];\n\n// ==================== Query parameter types ====================\n\nexport type GetProjectsQuery = operations[\"getProjects\"][\"parameters\"][\"query\"];\nexport type GetPeersOverTimeQuery = operations[\"getPeersOverTime\"][\"parameters\"][\"query\"];\nexport type GetRoomsOverTimeQuery = operations[\"getRoomsOverTime\"][\"parameters\"][\"query\"];\nexport type GetInstancesOverTimeQuery = operations[\"getInstancesOverTime\"][\"parameters\"][\"query\"];\nexport type GetInvoicesQuery = operations[\"getInvoices\"][\"parameters\"][\"query\"];\nexport type CheckFeatureQuery = operations[\"checkFeature\"][\"parameters\"][\"query\"];\nexport type CheckProductDependenciesQuery = operations[\"checkProductDependencies\"][\"parameters\"][\"query\"];\n\n/**\n * Response envelope used by the Payment API.\n */\ninterface PaymentEnvelope<T = unknown> {\n data: T | null;\n error: {\n code: number;\n message: string;\n };\n}\n\n/**\n * 4Players Payment API Client\n *\n * Provides a type-safe interface to the 4Players Payment REST API for managing\n * projects, billing, invoices, access keys, and user permissions.\n */\nexport class PaymentClient {\n private client: ReturnType<typeof createClient<paths>>;\n\n /**\n * Create a new Payment client instance.\n *\n * @param config - Client configuration\n * @throws {PaymentAuthError} If no session ID is provided\n *\n * @example\n * ```typescript\n * const client = new PaymentClient({\n * sessionId: 'your-fusion-sid'\n * });\n * ```\n */\n constructor(config: PaymentClientConfig) {\n if (!config.sessionId) {\n throw new PaymentAuthError(\"Session ID is required\");\n }\n\n this.client = createClient<paths>({\n baseUrl: config.baseUrl || DEFAULT_BASE_URL,\n headers: {\n \"fusion-sid\": config.sessionId,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n fetch: config.fetch,\n });\n\n // Register the envelope-unwrapping middleware\n this.client.use(this.createEnvelopeMiddleware());\n }\n\n /**\n * Creates middleware that unwraps the Payment API response envelope.\n *\n * The Payment API wraps ALL responses in `{ data, error }`.\n * This middleware:\n * 1. Checks `error.code` — if non-zero, throws `PaymentApiError`\n * 2. Checks `data` — if null, throws `PaymentApiError` (legacy error pattern)\n * 3. Returns a new Response containing only the unwrapped `data`\n */\n private createEnvelopeMiddleware(): Middleware {\n return {\n async onResponse({ response }) {\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return response;\n }\n\n const text = await response.clone().text();\n let body: unknown;\n try {\n body = JSON.parse(text);\n } catch {\n return response;\n }\n\n if (\n body !== null &&\n typeof body === \"object\" &&\n \"error\" in body &&\n \"data\" in body\n ) {\n const envelope = body as PaymentEnvelope;\n\n // Application-level error (can happen even with HTTP 200!)\n if (envelope.error && envelope.error.code !== 0) {\n throw new PaymentApiError(\n envelope.error.message,\n envelope.error.code,\n response.status\n );\n }\n\n // Legacy error pattern: data is null with HTTP 200\n if (envelope.data === null || envelope.data === undefined) {\n throw new PaymentApiError(\n envelope.error?.message || \"Response data is null\",\n envelope.error?.code || 0,\n response.status\n );\n }\n\n // Return unwrapped data so openapi-fetch sees the schema-matching body\n return new Response(JSON.stringify(envelope.data), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n // Not an envelope — return as-is\n return response;\n },\n };\n }\n\n private handleError(operation: string, error: unknown): never {\n if (error && typeof error === \"object\") {\n const errorObj = error as Record<string, unknown>;\n\n if (errorObj.status === 401 || errorObj.status === 403) {\n throw new PaymentAuthError();\n }\n if (errorObj.status === 404) {\n throw new PaymentNotFoundError(operation, \"unknown\");\n }\n if (errorObj.status === 429) {\n throw new PaymentRateLimitError();\n }\n }\n\n throw new PaymentError(\n `Failed to ${operation}: ${JSON.stringify(error)}`,\n undefined,\n error\n );\n }\n\n // ==================== Fleet Apps ====================\n\n /**\n * Get all fleet apps the user has access to (projects with Fleet activated).\n *\n * @returns Array of payment projects with Fleet app IDs\n */\n async getFleetProjects(): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/apps\");\n if (error) this.handleError(\"get fleet projects\", error);\n return data!;\n }\n\n /**\n * Get the details of a specific fleet app including the payment project.\n *\n * @param appId - The ID of the fleet app to retrieve\n * @returns Payment project details\n */\n async getFleetProject(appId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/apps/{app_id}\", {\n params: { path: { app_id: appId } },\n });\n if (error) this.handleError(\"get fleet project\", error);\n return data!;\n }\n\n // ==================== Projects ====================\n\n /**\n * Get all projects the authenticated user has access to.\n *\n * @param query - Optional query parameters to filter by project type\n * @returns Array of payment projects\n */\n async getProjects(query?: GetProjectsQuery): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/projects\", {\n params: { query },\n });\n if (error) this.handleError(\"get projects\", error);\n return data!;\n }\n\n /**\n * Get a specific project by ID.\n *\n * @param projectId - The unique identifier of the project\n * @returns Project details\n */\n async getProject(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project\", error);\n return data!;\n }\n\n /**\n * Update a project's name, description, or peer limit.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Updated project fields\n * @returns Success response\n */\n async editProject(projectId: string, body: EditProjectPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"edit project\", error);\n return data!;\n }\n\n // ==================== Peers / Metrics ====================\n\n /**\n * Get peak peers over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required)\n * @returns Peers over time data\n */\n async getPeersOverTime(projectId: string, query: GetPeersOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/peers-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get peers over time\", error);\n return data!;\n }\n\n /**\n * Get room count over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of active rooms\n */\n async getRoomsOverTime(projectId: string, query: GetRoomsOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/rooms-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get rooms over time\", error);\n return data!;\n }\n\n /**\n * Get Fleet server instances over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of deployed server instances\n */\n async getInstancesOverTime(projectId: string, query: GetInstancesOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/instances-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get instances over time\", error);\n return data!;\n }\n\n // ==================== Billing ====================\n\n /**\n * Get all billing accounts for the current user.\n *\n * @returns Array of billing accounts\n */\n async getBillingAccounts(): Promise<BillingAccount[]> {\n const { data, error } = await this.client.GET(\"/billing\");\n if (error) this.handleError(\"get billing accounts\", error);\n return data!;\n }\n\n /**\n * Get a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Billing account details\n */\n async getBillingAccount(billingAccountId: string): Promise<BillingAccount> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account\", error);\n return data!;\n }\n\n /**\n * Get invoices for a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Array of invoices\n */\n async getBillingAccountInvoices(billingAccountId: string): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}/invoices\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account invoices\", error);\n return data!;\n }\n\n /**\n * Create a Stripe setup session for a new billing account.\n *\n * @param body - Setup session creation payload\n * @returns Setup session with redirect URL\n */\n async createSetupSession(body: CreateSetupSessionPayload): Promise<SetupSession> {\n const { data, error } = await this.client.POST(\"/billing/create-setup-session\", {\n body,\n });\n if (error) this.handleError(\"create setup session\", error);\n return data!;\n }\n\n /**\n * Create a Stripe billing portal session.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @param body - Portal session creation payload\n * @returns Portal session with redirect URL\n */\n async createBillingPortalSession(billingAccountId: string, body: CreateBillingPortalSessionPayload): Promise<PortalSession> {\n const { data, error } = await this.client.POST(\"/billing/{billingAccountId}/create-billing-portal-session\", {\n params: { path: { billingAccountId } },\n body,\n });\n if (error) this.handleError(\"create billing portal session\", error);\n return data!;\n }\n\n /**\n * Get billing options for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Billing options including current state and change options\n */\n async getBillingOptions(projectId: string): Promise<BillingOptions> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/get-billing-options\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get billing options\", error);\n return data!;\n }\n\n /**\n * Set a billing account on a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Billing account and state to set\n * @returns Success response\n */\n async setBillingAccount(projectId: string, body: SetBillingAccountPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/set-billing-account\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"set billing account\", error);\n return data!;\n }\n\n /**\n * Cancel billing for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Success response\n */\n async cancelBilling(projectId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/cancel-billing\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"cancel billing\", error);\n return data!;\n }\n\n // ==================== API Activation ====================\n\n /**\n * Activate an API for the specified project.\n *\n * @deprecated Use {@link activateProduct} instead.\n * @param projectId - The unique identifier of the project\n * @param body - The API slug to activate\n * @returns Success response\n */\n async activateAPI(projectId: string, body: ActivateAPIPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-api\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate API\", error);\n return data!;\n }\n\n // ==================== Products ====================\n\n /**\n * List all available products.\n *\n * @returns Array of available products with features and pricing\n */\n async getProducts(): Promise<ProjectProduct[]> {\n const { data, error } = await this.client.GET(\"/products\");\n if (error) this.handleError(\"get products\", error);\n return data!;\n }\n\n /**\n * Get activated products for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Array of activated products\n */\n async getProjectProducts(projectId: string): Promise<ActivatedProduct[]> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/products\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project products\", error);\n return data!;\n }\n\n /**\n * Activate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug and optional configuration\n * @returns Updated project\n */\n async activateProduct(projectId: string, body: ActivateProductPayload): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate product\", error);\n return data!;\n }\n\n /**\n * Deactivate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug to deactivate\n * @returns Success response\n */\n async deactivateProduct(projectId: string, body: DeactivateProductPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/deactivate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"deactivate product\", error);\n return data!;\n }\n\n /**\n * Check if a feature is available for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query with the feature slug to check\n * @returns Feature availability status\n */\n async checkFeature(projectId: string, query: CheckFeatureQuery): Promise<FeatureAvailability> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/check-feature\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"check feature\", error);\n return data!;\n }\n\n /**\n * Check product dependencies for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query with the product slug to check\n * @returns Dependency check result with activation status of each dependency\n */\n async checkProductDependencies(projectId: string, query: CheckProductDependenciesQuery): Promise<ProductDependencyCheck> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/check-product-dependencies\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"check product dependencies\", error);\n return data!;\n }\n\n // ==================== Invoices ====================\n\n /**\n * Get all invoices for the current user, optionally filtered by ID.\n *\n * @param query - Optional query parameters for filtering by invoice IDs\n * @returns Array of invoices\n */\n async getInvoices(query?: GetInvoicesQuery): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/invoices\", {\n params: { query },\n });\n if (error) this.handleError(\"get invoices\", error);\n return data!;\n }\n\n /**\n * Get a preview of the current month's invoice for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Invoice preview\n */\n async getInvoicePreview(projectId: string): Promise<Invoice> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/preview-invoice\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get invoice preview\", error);\n return data!;\n }\n\n // ==================== Access Keys ====================\n\n /**\n * Get a specific access key.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Access key details\n */\n async getAccessKey(accessKeyId: string): Promise<OdinAccessKey> {\n const { data, error } = await this.client.GET(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"get access key\", error);\n return data!;\n }\n\n /**\n * Create a new access key for a project.\n *\n * @param body - Access key creation payload\n * @returns Created access key (includes the key value only in this response)\n */\n async createAccessKey(body: CreateAccessKeyPayload): Promise<OdinAccessKey> {\n const { data, error } = await this.client.POST(\"/odin-access-keys/\", {\n body,\n });\n if (error) this.handleError(\"create access key\", error);\n return data!;\n }\n\n /**\n * Update an existing access key's name or description.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @param body - Updated access key fields\n * @returns Success response\n */\n async editAccessKey(accessKeyId: string, body: EditAccessKeyPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n body,\n });\n if (error) this.handleError(\"edit access key\", error);\n return data!;\n }\n\n /**\n * Delete an access key. This operation is irreversible.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Success response\n */\n async deleteAccessKey(accessKeyId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.DELETE(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"delete access key\", error);\n return data!;\n }\n\n // ==================== Project Members ====================\n\n /**\n * Add a user to a project with a specified role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - User email and role\n * @returns The created user role\n */\n async addProjectMember(projectId: string, body: AddUserToProjectPayload): Promise<OdinUserRole> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/add-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"add project member\", error);\n return data!;\n }\n\n /**\n * Revoke a user's permission from a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID to revoke\n * @returns Success response\n */\n async deleteProjectMember(projectId: string, body: RevokeUserPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"delete project member\", error);\n return data!;\n }\n\n /**\n * Change a project member's role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID and new role\n * @returns Success response\n */\n async changeMemberRole(projectId: string, body: ChangeUserRolePayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/change-user-role\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"change member role\", error);\n return data!;\n }\n\n // ==================== Tokens & Secrets ====================\n\n /**\n * Create an ODIN access token for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Token creation payload\n * @returns The created token\n */\n async createAccessToken(projectId: string, body: CreateTokenPayload): Promise<TokenPayload> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/create-token\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"create access token\", error);\n return data!;\n }\n\n /**\n * Revoke the secret for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Updated project with new secret\n */\n async revokeSecret(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-secret\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"revoke secret\", error);\n return data!;\n }\n\n // ==================== Resource Package Pricing ====================\n\n /**\n * Get the price for a single resource package in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package, region, and quantity\n * @returns Price information\n */\n async getResourcePackagePrice(projectId: string, body: ResourcePackagePricePayload): Promise<ResourcePackagePrice> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-price\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package price\", error);\n return data!;\n }\n\n /**\n * Get prices for multiple resource packages in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package IDs, region, and quantity\n * @returns Array of price information\n */\n async getResourcePackagePrices(projectId: string, body: ResourcePackagePricesPayload): Promise<ResourcePackagePrice[]> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-prices\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package prices\", error);\n return data!;\n }\n}\n\nexport default PaymentClient;\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -556,6 +556,29 @@ interface paths {
|
|
|
556
556
|
patch?: never;
|
|
557
557
|
trace?: never;
|
|
558
558
|
};
|
|
559
|
+
"/projects/{projectId}/check-product-dependencies": {
|
|
560
|
+
parameters: {
|
|
561
|
+
query?: never;
|
|
562
|
+
header?: never;
|
|
563
|
+
path?: never;
|
|
564
|
+
cookie?: never;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Check product dependencies for a project
|
|
568
|
+
* @description Returns whether a product can be activated for the given project by checking all
|
|
569
|
+
* its dependencies. Each dependency is listed with its current activation status.
|
|
570
|
+
* Use this endpoint to build UI that shows missing dependencies before the user
|
|
571
|
+
* attempts to activate a product.
|
|
572
|
+
*/
|
|
573
|
+
get: operations["checkProductDependencies"];
|
|
574
|
+
put?: never;
|
|
575
|
+
post?: never;
|
|
576
|
+
delete?: never;
|
|
577
|
+
options?: never;
|
|
578
|
+
head?: never;
|
|
579
|
+
patch?: never;
|
|
580
|
+
trace?: never;
|
|
581
|
+
};
|
|
559
582
|
"/projects/{projectId}/create-token": {
|
|
560
583
|
parameters: {
|
|
561
584
|
query?: never;
|
|
@@ -1231,6 +1254,20 @@ interface components {
|
|
|
1231
1254
|
/** @description List of product or feature slugs that must be activated first. */
|
|
1232
1255
|
missingDependencies?: string[];
|
|
1233
1256
|
};
|
|
1257
|
+
ProductDependencyCheck: {
|
|
1258
|
+
/** @description The product slug that was checked. */
|
|
1259
|
+
product?: components["schemas"]["ProductSlug"];
|
|
1260
|
+
/** @description Whether all dependencies are satisfied and the product can be activated. */
|
|
1261
|
+
canActivate?: boolean;
|
|
1262
|
+
/** @description List of required products with their activation status. */
|
|
1263
|
+
dependencies?: components["schemas"]["ProductDependencyStatus"][];
|
|
1264
|
+
};
|
|
1265
|
+
ProductDependencyStatus: {
|
|
1266
|
+
/** @description The slug of the required product. */
|
|
1267
|
+
product?: components["schemas"]["ProductSlug"];
|
|
1268
|
+
/** @description Whether this dependency is currently activated for the project. */
|
|
1269
|
+
satisfied?: boolean;
|
|
1270
|
+
};
|
|
1234
1271
|
};
|
|
1235
1272
|
responses: never;
|
|
1236
1273
|
parameters: never;
|
|
@@ -2562,6 +2599,52 @@ interface operations {
|
|
|
2562
2599
|
};
|
|
2563
2600
|
};
|
|
2564
2601
|
};
|
|
2602
|
+
checkProductDependencies: {
|
|
2603
|
+
parameters: {
|
|
2604
|
+
query: {
|
|
2605
|
+
/** @description The product slug to check (e.g. rooms, cortex). */
|
|
2606
|
+
product: components["schemas"]["ProductSlug"];
|
|
2607
|
+
};
|
|
2608
|
+
header?: never;
|
|
2609
|
+
path: {
|
|
2610
|
+
projectId: string;
|
|
2611
|
+
};
|
|
2612
|
+
cookie?: never;
|
|
2613
|
+
};
|
|
2614
|
+
requestBody?: never;
|
|
2615
|
+
responses: {
|
|
2616
|
+
/** @description Product dependency check result. */
|
|
2617
|
+
200: {
|
|
2618
|
+
headers: {
|
|
2619
|
+
[name: string]: unknown;
|
|
2620
|
+
};
|
|
2621
|
+
content: {
|
|
2622
|
+
"application/json": components["schemas"]["ProductDependencyCheck"];
|
|
2623
|
+
};
|
|
2624
|
+
};
|
|
2625
|
+
/** @description Missing product query parameter or unknown product */
|
|
2626
|
+
400: {
|
|
2627
|
+
headers: {
|
|
2628
|
+
[name: string]: unknown;
|
|
2629
|
+
};
|
|
2630
|
+
content?: never;
|
|
2631
|
+
};
|
|
2632
|
+
/** @description Unauthorized */
|
|
2633
|
+
401: {
|
|
2634
|
+
headers: {
|
|
2635
|
+
[name: string]: unknown;
|
|
2636
|
+
};
|
|
2637
|
+
content?: never;
|
|
2638
|
+
};
|
|
2639
|
+
/** @description Project not found */
|
|
2640
|
+
404: {
|
|
2641
|
+
headers: {
|
|
2642
|
+
[name: string]: unknown;
|
|
2643
|
+
};
|
|
2644
|
+
content?: never;
|
|
2645
|
+
};
|
|
2646
|
+
};
|
|
2647
|
+
};
|
|
2565
2648
|
createAccessToken: {
|
|
2566
2649
|
parameters: {
|
|
2567
2650
|
query?: never;
|
|
@@ -2886,6 +2969,8 @@ type ProjectProductFeature = components["schemas"]["ProjectProductFeature"];
|
|
|
2886
2969
|
type ProductPricing = components["schemas"]["ProductPricing"];
|
|
2887
2970
|
type ActivatedProduct = components["schemas"]["ActivatedProduct"];
|
|
2888
2971
|
type FeatureAvailability = components["schemas"]["FeatureAvailability"];
|
|
2972
|
+
type ProductDependencyCheck = components["schemas"]["ProductDependencyCheck"];
|
|
2973
|
+
type ProductDependencyStatus = components["schemas"]["ProductDependencyStatus"];
|
|
2889
2974
|
type APIType = components["schemas"]["APIType"];
|
|
2890
2975
|
type BillingState = components["schemas"]["BillingState"];
|
|
2891
2976
|
type PermissionRole = components["schemas"]["PermissionRole"];
|
|
@@ -2914,6 +2999,7 @@ type GetRoomsOverTimeQuery = operations["getRoomsOverTime"]["parameters"]["query
|
|
|
2914
2999
|
type GetInstancesOverTimeQuery = operations["getInstancesOverTime"]["parameters"]["query"];
|
|
2915
3000
|
type GetInvoicesQuery = operations["getInvoices"]["parameters"]["query"];
|
|
2916
3001
|
type CheckFeatureQuery = operations["checkFeature"]["parameters"]["query"];
|
|
3002
|
+
type CheckProductDependenciesQuery = operations["checkProductDependencies"]["parameters"]["query"];
|
|
2917
3003
|
/**
|
|
2918
3004
|
* 4Players Payment API Client
|
|
2919
3005
|
*
|
|
@@ -3109,6 +3195,14 @@ declare class PaymentClient {
|
|
|
3109
3195
|
* @returns Feature availability status
|
|
3110
3196
|
*/
|
|
3111
3197
|
checkFeature(projectId: string, query: CheckFeatureQuery): Promise<FeatureAvailability>;
|
|
3198
|
+
/**
|
|
3199
|
+
* Check product dependencies for a project.
|
|
3200
|
+
*
|
|
3201
|
+
* @param projectId - The unique identifier of the project
|
|
3202
|
+
* @param query - Query with the product slug to check
|
|
3203
|
+
* @returns Dependency check result with activation status of each dependency
|
|
3204
|
+
*/
|
|
3205
|
+
checkProductDependencies(projectId: string, query: CheckProductDependenciesQuery): Promise<ProductDependencyCheck>;
|
|
3112
3206
|
/**
|
|
3113
3207
|
* Get all invoices for the current user, optionally filtered by ID.
|
|
3114
3208
|
*
|
|
@@ -3276,4 +3370,4 @@ declare class PaymentRateLimitError extends PaymentError {
|
|
|
3276
3370
|
constructor(retryAfter?: number);
|
|
3277
3371
|
}
|
|
3278
3372
|
|
|
3279
|
-
export { type APIType, type ActivateAPIPayload, type ActivateProductPayload, type ActivatedProduct, type AddUserToProjectPayload, type BillingAccount, type BillingChangeOptions, type BillingOptions, type BillingState, type BillingStateHistory, type ChangeUserRolePayload, type CheckFeatureQuery, type CreateAccessKeyPayload, type CreateBillingPortalSessionPayload, type CreateSetupSessionPayload, type CreateTokenPayload, type DeactivateProductPayload, type EditAccessKeyPayload, type EditProjectPayload, type FeatureAvailability, type GetInstancesOverTimeQuery, type GetInvoicesQuery, type GetPeersOverTimeQuery, type GetProjectsQuery, type GetRoomsOverTimeQuery, type Invoice, type InvoicePosition, type InvoiceStatus, type Invoices, type OdinAccessKey, type OdinUserPermissions, type OdinUserRole, PaymentApiError, PaymentAuthError, PaymentClient, type PaymentClientConfig, PaymentError, PaymentNotFoundError, type PaymentProject, PaymentRateLimitError, PaymentValidationError, type PermissionRole, type PortalSession, type PricingType, type ProductPricing, type ProductSlug, type ProjectProduct, type ProjectProductFeature, type ResourcePackagePrice, type ResourcePackagePricePayload, type ResourcePackagePricesPayload, type RevokeUserPayload, type SetBillingAccountPayload, type SetupSession, type Subscription, type SubscriptionPosition, type SuccessResponse, type TariffParams, type TimeSeriesData, type TokenPayload, type UserStatus, type components, PaymentClient as default, type operations, type paths };
|
|
3373
|
+
export { type APIType, type ActivateAPIPayload, type ActivateProductPayload, type ActivatedProduct, type AddUserToProjectPayload, type BillingAccount, type BillingChangeOptions, type BillingOptions, type BillingState, type BillingStateHistory, type ChangeUserRolePayload, type CheckFeatureQuery, type CheckProductDependenciesQuery, type CreateAccessKeyPayload, type CreateBillingPortalSessionPayload, type CreateSetupSessionPayload, type CreateTokenPayload, type DeactivateProductPayload, type EditAccessKeyPayload, type EditProjectPayload, type FeatureAvailability, type GetInstancesOverTimeQuery, type GetInvoicesQuery, type GetPeersOverTimeQuery, type GetProjectsQuery, type GetRoomsOverTimeQuery, type Invoice, type InvoicePosition, type InvoiceStatus, type Invoices, type OdinAccessKey, type OdinUserPermissions, type OdinUserRole, PaymentApiError, PaymentAuthError, PaymentClient, type PaymentClientConfig, PaymentError, PaymentNotFoundError, type PaymentProject, PaymentRateLimitError, PaymentValidationError, type PermissionRole, type PortalSession, type PricingType, type ProductDependencyCheck, type ProductDependencyStatus, type ProductPricing, type ProductSlug, type ProjectProduct, type ProjectProductFeature, type ResourcePackagePrice, type ResourcePackagePricePayload, type ResourcePackagePricesPayload, type RevokeUserPayload, type SetBillingAccountPayload, type SetupSession, type Subscription, type SubscriptionPosition, type SuccessResponse, type TariffParams, type TimeSeriesData, type TokenPayload, type UserStatus, type components, PaymentClient as default, type operations, type paths };
|
package/dist/index.d.ts
CHANGED
|
@@ -556,6 +556,29 @@ interface paths {
|
|
|
556
556
|
patch?: never;
|
|
557
557
|
trace?: never;
|
|
558
558
|
};
|
|
559
|
+
"/projects/{projectId}/check-product-dependencies": {
|
|
560
|
+
parameters: {
|
|
561
|
+
query?: never;
|
|
562
|
+
header?: never;
|
|
563
|
+
path?: never;
|
|
564
|
+
cookie?: never;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Check product dependencies for a project
|
|
568
|
+
* @description Returns whether a product can be activated for the given project by checking all
|
|
569
|
+
* its dependencies. Each dependency is listed with its current activation status.
|
|
570
|
+
* Use this endpoint to build UI that shows missing dependencies before the user
|
|
571
|
+
* attempts to activate a product.
|
|
572
|
+
*/
|
|
573
|
+
get: operations["checkProductDependencies"];
|
|
574
|
+
put?: never;
|
|
575
|
+
post?: never;
|
|
576
|
+
delete?: never;
|
|
577
|
+
options?: never;
|
|
578
|
+
head?: never;
|
|
579
|
+
patch?: never;
|
|
580
|
+
trace?: never;
|
|
581
|
+
};
|
|
559
582
|
"/projects/{projectId}/create-token": {
|
|
560
583
|
parameters: {
|
|
561
584
|
query?: never;
|
|
@@ -1231,6 +1254,20 @@ interface components {
|
|
|
1231
1254
|
/** @description List of product or feature slugs that must be activated first. */
|
|
1232
1255
|
missingDependencies?: string[];
|
|
1233
1256
|
};
|
|
1257
|
+
ProductDependencyCheck: {
|
|
1258
|
+
/** @description The product slug that was checked. */
|
|
1259
|
+
product?: components["schemas"]["ProductSlug"];
|
|
1260
|
+
/** @description Whether all dependencies are satisfied and the product can be activated. */
|
|
1261
|
+
canActivate?: boolean;
|
|
1262
|
+
/** @description List of required products with their activation status. */
|
|
1263
|
+
dependencies?: components["schemas"]["ProductDependencyStatus"][];
|
|
1264
|
+
};
|
|
1265
|
+
ProductDependencyStatus: {
|
|
1266
|
+
/** @description The slug of the required product. */
|
|
1267
|
+
product?: components["schemas"]["ProductSlug"];
|
|
1268
|
+
/** @description Whether this dependency is currently activated for the project. */
|
|
1269
|
+
satisfied?: boolean;
|
|
1270
|
+
};
|
|
1234
1271
|
};
|
|
1235
1272
|
responses: never;
|
|
1236
1273
|
parameters: never;
|
|
@@ -2562,6 +2599,52 @@ interface operations {
|
|
|
2562
2599
|
};
|
|
2563
2600
|
};
|
|
2564
2601
|
};
|
|
2602
|
+
checkProductDependencies: {
|
|
2603
|
+
parameters: {
|
|
2604
|
+
query: {
|
|
2605
|
+
/** @description The product slug to check (e.g. rooms, cortex). */
|
|
2606
|
+
product: components["schemas"]["ProductSlug"];
|
|
2607
|
+
};
|
|
2608
|
+
header?: never;
|
|
2609
|
+
path: {
|
|
2610
|
+
projectId: string;
|
|
2611
|
+
};
|
|
2612
|
+
cookie?: never;
|
|
2613
|
+
};
|
|
2614
|
+
requestBody?: never;
|
|
2615
|
+
responses: {
|
|
2616
|
+
/** @description Product dependency check result. */
|
|
2617
|
+
200: {
|
|
2618
|
+
headers: {
|
|
2619
|
+
[name: string]: unknown;
|
|
2620
|
+
};
|
|
2621
|
+
content: {
|
|
2622
|
+
"application/json": components["schemas"]["ProductDependencyCheck"];
|
|
2623
|
+
};
|
|
2624
|
+
};
|
|
2625
|
+
/** @description Missing product query parameter or unknown product */
|
|
2626
|
+
400: {
|
|
2627
|
+
headers: {
|
|
2628
|
+
[name: string]: unknown;
|
|
2629
|
+
};
|
|
2630
|
+
content?: never;
|
|
2631
|
+
};
|
|
2632
|
+
/** @description Unauthorized */
|
|
2633
|
+
401: {
|
|
2634
|
+
headers: {
|
|
2635
|
+
[name: string]: unknown;
|
|
2636
|
+
};
|
|
2637
|
+
content?: never;
|
|
2638
|
+
};
|
|
2639
|
+
/** @description Project not found */
|
|
2640
|
+
404: {
|
|
2641
|
+
headers: {
|
|
2642
|
+
[name: string]: unknown;
|
|
2643
|
+
};
|
|
2644
|
+
content?: never;
|
|
2645
|
+
};
|
|
2646
|
+
};
|
|
2647
|
+
};
|
|
2565
2648
|
createAccessToken: {
|
|
2566
2649
|
parameters: {
|
|
2567
2650
|
query?: never;
|
|
@@ -2886,6 +2969,8 @@ type ProjectProductFeature = components["schemas"]["ProjectProductFeature"];
|
|
|
2886
2969
|
type ProductPricing = components["schemas"]["ProductPricing"];
|
|
2887
2970
|
type ActivatedProduct = components["schemas"]["ActivatedProduct"];
|
|
2888
2971
|
type FeatureAvailability = components["schemas"]["FeatureAvailability"];
|
|
2972
|
+
type ProductDependencyCheck = components["schemas"]["ProductDependencyCheck"];
|
|
2973
|
+
type ProductDependencyStatus = components["schemas"]["ProductDependencyStatus"];
|
|
2889
2974
|
type APIType = components["schemas"]["APIType"];
|
|
2890
2975
|
type BillingState = components["schemas"]["BillingState"];
|
|
2891
2976
|
type PermissionRole = components["schemas"]["PermissionRole"];
|
|
@@ -2914,6 +2999,7 @@ type GetRoomsOverTimeQuery = operations["getRoomsOverTime"]["parameters"]["query
|
|
|
2914
2999
|
type GetInstancesOverTimeQuery = operations["getInstancesOverTime"]["parameters"]["query"];
|
|
2915
3000
|
type GetInvoicesQuery = operations["getInvoices"]["parameters"]["query"];
|
|
2916
3001
|
type CheckFeatureQuery = operations["checkFeature"]["parameters"]["query"];
|
|
3002
|
+
type CheckProductDependenciesQuery = operations["checkProductDependencies"]["parameters"]["query"];
|
|
2917
3003
|
/**
|
|
2918
3004
|
* 4Players Payment API Client
|
|
2919
3005
|
*
|
|
@@ -3109,6 +3195,14 @@ declare class PaymentClient {
|
|
|
3109
3195
|
* @returns Feature availability status
|
|
3110
3196
|
*/
|
|
3111
3197
|
checkFeature(projectId: string, query: CheckFeatureQuery): Promise<FeatureAvailability>;
|
|
3198
|
+
/**
|
|
3199
|
+
* Check product dependencies for a project.
|
|
3200
|
+
*
|
|
3201
|
+
* @param projectId - The unique identifier of the project
|
|
3202
|
+
* @param query - Query with the product slug to check
|
|
3203
|
+
* @returns Dependency check result with activation status of each dependency
|
|
3204
|
+
*/
|
|
3205
|
+
checkProductDependencies(projectId: string, query: CheckProductDependenciesQuery): Promise<ProductDependencyCheck>;
|
|
3112
3206
|
/**
|
|
3113
3207
|
* Get all invoices for the current user, optionally filtered by ID.
|
|
3114
3208
|
*
|
|
@@ -3276,4 +3370,4 @@ declare class PaymentRateLimitError extends PaymentError {
|
|
|
3276
3370
|
constructor(retryAfter?: number);
|
|
3277
3371
|
}
|
|
3278
3372
|
|
|
3279
|
-
export { type APIType, type ActivateAPIPayload, type ActivateProductPayload, type ActivatedProduct, type AddUserToProjectPayload, type BillingAccount, type BillingChangeOptions, type BillingOptions, type BillingState, type BillingStateHistory, type ChangeUserRolePayload, type CheckFeatureQuery, type CreateAccessKeyPayload, type CreateBillingPortalSessionPayload, type CreateSetupSessionPayload, type CreateTokenPayload, type DeactivateProductPayload, type EditAccessKeyPayload, type EditProjectPayload, type FeatureAvailability, type GetInstancesOverTimeQuery, type GetInvoicesQuery, type GetPeersOverTimeQuery, type GetProjectsQuery, type GetRoomsOverTimeQuery, type Invoice, type InvoicePosition, type InvoiceStatus, type Invoices, type OdinAccessKey, type OdinUserPermissions, type OdinUserRole, PaymentApiError, PaymentAuthError, PaymentClient, type PaymentClientConfig, PaymentError, PaymentNotFoundError, type PaymentProject, PaymentRateLimitError, PaymentValidationError, type PermissionRole, type PortalSession, type PricingType, type ProductPricing, type ProductSlug, type ProjectProduct, type ProjectProductFeature, type ResourcePackagePrice, type ResourcePackagePricePayload, type ResourcePackagePricesPayload, type RevokeUserPayload, type SetBillingAccountPayload, type SetupSession, type Subscription, type SubscriptionPosition, type SuccessResponse, type TariffParams, type TimeSeriesData, type TokenPayload, type UserStatus, type components, PaymentClient as default, type operations, type paths };
|
|
3373
|
+
export { type APIType, type ActivateAPIPayload, type ActivateProductPayload, type ActivatedProduct, type AddUserToProjectPayload, type BillingAccount, type BillingChangeOptions, type BillingOptions, type BillingState, type BillingStateHistory, type ChangeUserRolePayload, type CheckFeatureQuery, type CheckProductDependenciesQuery, type CreateAccessKeyPayload, type CreateBillingPortalSessionPayload, type CreateSetupSessionPayload, type CreateTokenPayload, type DeactivateProductPayload, type EditAccessKeyPayload, type EditProjectPayload, type FeatureAvailability, type GetInstancesOverTimeQuery, type GetInvoicesQuery, type GetPeersOverTimeQuery, type GetProjectsQuery, type GetRoomsOverTimeQuery, type Invoice, type InvoicePosition, type InvoiceStatus, type Invoices, type OdinAccessKey, type OdinUserPermissions, type OdinUserRole, PaymentApiError, PaymentAuthError, PaymentClient, type PaymentClientConfig, PaymentError, PaymentNotFoundError, type PaymentProject, PaymentRateLimitError, PaymentValidationError, type PermissionRole, type PortalSession, type PricingType, type ProductDependencyCheck, type ProductDependencyStatus, type ProductPricing, type ProductSlug, type ProjectProduct, type ProjectProductFeature, type ResourcePackagePrice, type ResourcePackagePricePayload, type ResourcePackagePricesPayload, type RevokeUserPayload, type SetBillingAccountPayload, type SetupSession, type Subscription, type SubscriptionPosition, type SuccessResponse, type TariffParams, type TimeSeriesData, type TokenPayload, type UserStatus, type components, PaymentClient as default, type operations, type paths };
|
package/dist/index.js
CHANGED
|
@@ -461,6 +461,20 @@ var PaymentClient = class {
|
|
|
461
461
|
if (error) this.handleError("check feature", error);
|
|
462
462
|
return data;
|
|
463
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Check product dependencies for a project.
|
|
466
|
+
*
|
|
467
|
+
* @param projectId - The unique identifier of the project
|
|
468
|
+
* @param query - Query with the product slug to check
|
|
469
|
+
* @returns Dependency check result with activation status of each dependency
|
|
470
|
+
*/
|
|
471
|
+
async checkProductDependencies(projectId, query) {
|
|
472
|
+
const { data, error } = await this.client.GET("/projects/{projectId}/check-product-dependencies", {
|
|
473
|
+
params: { path: { projectId }, query }
|
|
474
|
+
});
|
|
475
|
+
if (error) this.handleError("check product dependencies", error);
|
|
476
|
+
return data;
|
|
477
|
+
}
|
|
464
478
|
// ==================== Invoices ====================
|
|
465
479
|
/**
|
|
466
480
|
* Get all invoices for the current user, optionally filtered by ID.
|
package/d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AAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,wBAAA,CAAyB,SAAA,EAAmB,IAAA,EAAqE;AACrH,IAAA,MAAM,EAAE,MAAM,KAAA,EAAM,GAAI,MAAM,IAAA,CAAK,MAAA,CAAO,KAAK,+CAAA,EAAiD;AAAA,MAC9F,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,WAAU,EAAE;AAAA,MAC9B;AAAA,KACD,CAAA;AACD,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,WAAA,CAAY,6BAAA,EAA+B,KAAK,CAAA;AAChE,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,IAAO,cAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * Payment SDK Error Classes\n *\n * Provides structured error handling for Payment API operations.\n */\n\n// V8-specific stack trace capture (available in Node.js, Chrome, etc.)\ndeclare const Error: ErrorConstructor & {\n captureStackTrace?(targetObject: object, constructorOpt?: Function): void;\n};\n\n/**\n * Base error class for all Payment SDK errors.\n */\nexport class PaymentError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly details?: unknown\n ) {\n super(message);\n this.name = \"PaymentError\";\n // Maintains proper stack trace for where error was thrown (V8 engines)\n if (typeof Error.captureStackTrace === \"function\") {\n Error.captureStackTrace(this, PaymentError);\n }\n }\n}\n\n/**\n * Error thrown when the Payment API returns an application-level error\n * in its response envelope.\n *\n * The Payment API wraps all responses in an envelope:\n * ```json\n * { \"data\": T | null, \"error\": { \"code\": number, \"message\": string } }\n * ```\n *\n * A `PaymentApiError` is thrown when:\n * - `error.code !== 0` (application-level error, even if HTTP status is 200)\n * - `data` is `null` (legacy error pattern from before HTTP status codes were used)\n */\nexport class PaymentApiError extends PaymentError {\n /**\n * Application-level error code from the response envelope.\n * A value of `0` means no specific error code was returned (legacy null-data case).\n */\n public readonly code: number;\n\n /**\n * The HTTP status code of the response.\n * Note: This may be `200` even when there is an application error.\n */\n public readonly httpStatus: number;\n\n constructor(message: string, code: number, httpStatus: number) {\n super(message, httpStatus);\n this.name = \"PaymentApiError\";\n this.code = code;\n this.httpStatus = httpStatus;\n }\n}\n\n/**\n * Error thrown when authentication fails or is required.\n */\nexport class PaymentAuthError extends PaymentError {\n constructor(message = \"Authentication required. Please provide a valid session ID.\") {\n super(message, 401);\n this.name = \"PaymentAuthError\";\n }\n}\n\n/**\n * Error thrown when a requested resource is not found.\n */\nexport class PaymentNotFoundError extends PaymentError {\n constructor(resource: string, id: string) {\n super(`${resource} with ID ${id} not found`, 404);\n this.name = \"PaymentNotFoundError\";\n }\n}\n\n/**\n * Error thrown when request validation fails.\n */\nexport class PaymentValidationError extends PaymentError {\n constructor(message: string, details?: unknown) {\n super(message, 422, details);\n this.name = \"PaymentValidationError\";\n }\n}\n\n/**\n * Error thrown when the API rate limit is exceeded.\n */\nexport class PaymentRateLimitError extends PaymentError {\n constructor(retryAfter?: number) {\n super(\n retryAfter\n ? `Rate limit exceeded. Retry after ${retryAfter} seconds.`\n : \"Rate limit exceeded. Please try again later.\",\n 429,\n { retryAfter }\n );\n this.name = \"PaymentRateLimitError\";\n }\n}\n","/**\n * 4Players Payment API Client\n *\n * A type-safe client for the 4Players Payment API.\n * Works in browsers, Node.js, Deno, Bun, and edge runtimes.\n *\n * @example\n * ```typescript\n * import { PaymentClient } from '@4players/payment';\n *\n * const client = new PaymentClient({ sessionId: 'your-session-id' });\n *\n * const projects = await client.getProjects();\n * ```\n */\n\nimport createClient, { type Middleware } from \"openapi-fetch\";\nimport type { paths, components, operations } from \"./types.js\";\nimport {\n PaymentError,\n PaymentApiError,\n PaymentAuthError,\n PaymentNotFoundError,\n PaymentRateLimitError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://secure.4players.de/public/api/v1\";\n\n/**\n * Configuration options for the Payment client.\n */\nexport interface PaymentClientConfig {\n /** Fusion session ID for authentication (sent as fusion-sid header) */\n sessionId: string;\n /** Base URL for the Payment API (default: https://secure.4players.de/public/api/v1) */\n baseUrl?: string;\n /** Custom fetch implementation (useful for testing or special environments) */\n fetch?: typeof fetch;\n}\n\n// ==================== Entity types from components.schemas ====================\n\nexport type PaymentProject = components[\"schemas\"][\"PaymentProject\"];\nexport type BillingAccount = components[\"schemas\"][\"BillingAccount\"];\nexport type OdinAccessKey = components[\"schemas\"][\"OdinAccessKey\"];\nexport type OdinUserPermissions = components[\"schemas\"][\"OdinUserPermissions\"];\nexport type OdinUserRole = components[\"schemas\"][\"OdinUserRole\"];\nexport type TimeSeriesData = components[\"schemas\"][\"TimeSeriesData\"];\nexport type Subscription = components[\"schemas\"][\"Subscription\"];\nexport type Invoice = components[\"schemas\"][\"Invoice\"];\nexport type InvoicePosition = components[\"schemas\"][\"InvoicePosition\"];\nexport type Invoices = components[\"schemas\"][\"Invoices\"];\nexport type SubscriptionPosition = components[\"schemas\"][\"SubscriptionPosition\"];\nexport type TariffParams = components[\"schemas\"][\"TariffParams\"];\nexport type SetupSession = components[\"schemas\"][\"SetupSession\"];\nexport type PortalSession = components[\"schemas\"][\"PortalSession\"];\nexport type TokenPayload = components[\"schemas\"][\"TokenPayload\"];\nexport type BillingOptions = components[\"schemas\"][\"BillingOptions\"];\nexport type BillingChangeOptions = components[\"schemas\"][\"BillingChangeOptions\"];\nexport type BillingStateHistory = components[\"schemas\"][\"BillingStateHistory\"];\nexport type ResourcePackagePrice = components[\"schemas\"][\"ResourcePackagePrice\"];\nexport type SuccessResponse = components[\"schemas\"][\"SuccessResponse\"];\nexport type ProjectProduct = components[\"schemas\"][\"ProjectProduct\"];\nexport type ProjectProductFeature = components[\"schemas\"][\"ProjectProductFeature\"];\nexport type ProductPricing = components[\"schemas\"][\"ProductPricing\"];\nexport type ActivatedProduct = components[\"schemas\"][\"ActivatedProduct\"];\nexport type FeatureAvailability = components[\"schemas\"][\"FeatureAvailability\"];\n\n// Enum types\nexport type APIType = components[\"schemas\"][\"APIType\"];\nexport type BillingState = components[\"schemas\"][\"BillingState\"];\nexport type PermissionRole = components[\"schemas\"][\"PermissionRole\"];\nexport type UserStatus = components[\"schemas\"][\"UserStatus\"];\nexport type InvoiceStatus = components[\"schemas\"][\"InvoiceStatus\"];\nexport type ProductSlug = components[\"schemas\"][\"ProductSlug\"];\nexport type PricingType = components[\"schemas\"][\"PricingType\"];\n\n// ==================== Request/Payload types ====================\n\nexport type ActivateAPIPayload = components[\"schemas\"][\"ActivateAPIPayload\"];\nexport type AddUserToProjectPayload = components[\"schemas\"][\"AddUserToProjectPayload\"];\nexport type ChangeUserRolePayload = components[\"schemas\"][\"ChangeUserRolePayload\"];\nexport type CreateAccessKeyPayload = components[\"schemas\"][\"CreateAccessKeyPayload\"];\nexport type CreateBillingPortalSessionPayload = components[\"schemas\"][\"CreateBillingPortalSessionPayload\"];\nexport type CreateSetupSessionPayload = components[\"schemas\"][\"CreateSetupSessionPayload\"];\nexport type CreateTokenPayload = components[\"schemas\"][\"CreateTokenPayload\"];\nexport type EditAccessKeyPayload = components[\"schemas\"][\"EditAccessKeyPayload\"];\nexport type EditProjectPayload = components[\"schemas\"][\"EditProjectPayload\"];\nexport type ResourcePackagePricePayload = components[\"schemas\"][\"ResourcePackagePricePayload\"];\nexport type ResourcePackagePricesPayload = components[\"schemas\"][\"ResourcePackagePricesPayload\"];\nexport type RevokeUserPayload = components[\"schemas\"][\"RevokeUserPayload\"];\nexport type SetBillingAccountPayload = components[\"schemas\"][\"SetBillingAccountPayload\"];\nexport type ActivateProductPayload = components[\"schemas\"][\"ActivateProductPayload\"];\nexport type DeactivateProductPayload = components[\"schemas\"][\"DeactivateProductPayload\"];\n\n// ==================== Query parameter types ====================\n\nexport type GetProjectsQuery = operations[\"getProjects\"][\"parameters\"][\"query\"];\nexport type GetPeersOverTimeQuery = operations[\"getPeersOverTime\"][\"parameters\"][\"query\"];\nexport type GetRoomsOverTimeQuery = operations[\"getRoomsOverTime\"][\"parameters\"][\"query\"];\nexport type GetInstancesOverTimeQuery = operations[\"getInstancesOverTime\"][\"parameters\"][\"query\"];\nexport type GetInvoicesQuery = operations[\"getInvoices\"][\"parameters\"][\"query\"];\nexport type CheckFeatureQuery = operations[\"checkFeature\"][\"parameters\"][\"query\"];\n\n/**\n * Response envelope used by the Payment API.\n */\ninterface PaymentEnvelope<T = unknown> {\n data: T | null;\n error: {\n code: number;\n message: string;\n };\n}\n\n/**\n * 4Players Payment API Client\n *\n * Provides a type-safe interface to the 4Players Payment REST API for managing\n * projects, billing, invoices, access keys, and user permissions.\n */\nexport class PaymentClient {\n private client: ReturnType<typeof createClient<paths>>;\n\n /**\n * Create a new Payment client instance.\n *\n * @param config - Client configuration\n * @throws {PaymentAuthError} If no session ID is provided\n *\n * @example\n * ```typescript\n * const client = new PaymentClient({\n * sessionId: 'your-fusion-sid'\n * });\n * ```\n */\n constructor(config: PaymentClientConfig) {\n if (!config.sessionId) {\n throw new PaymentAuthError(\"Session ID is required\");\n }\n\n this.client = createClient<paths>({\n baseUrl: config.baseUrl || DEFAULT_BASE_URL,\n headers: {\n \"fusion-sid\": config.sessionId,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n fetch: config.fetch,\n });\n\n // Register the envelope-unwrapping middleware\n this.client.use(this.createEnvelopeMiddleware());\n }\n\n /**\n * Creates middleware that unwraps the Payment API response envelope.\n *\n * The Payment API wraps ALL responses in `{ data, error }`.\n * This middleware:\n * 1. Checks `error.code` — if non-zero, throws `PaymentApiError`\n * 2. Checks `data` — if null, throws `PaymentApiError` (legacy error pattern)\n * 3. Returns a new Response containing only the unwrapped `data`\n */\n private createEnvelopeMiddleware(): Middleware {\n return {\n async onResponse({ response }) {\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return response;\n }\n\n const text = await response.clone().text();\n let body: unknown;\n try {\n body = JSON.parse(text);\n } catch {\n return response;\n }\n\n if (\n body !== null &&\n typeof body === \"object\" &&\n \"error\" in body &&\n \"data\" in body\n ) {\n const envelope = body as PaymentEnvelope;\n\n // Application-level error (can happen even with HTTP 200!)\n if (envelope.error && envelope.error.code !== 0) {\n throw new PaymentApiError(\n envelope.error.message,\n envelope.error.code,\n response.status\n );\n }\n\n // Legacy error pattern: data is null with HTTP 200\n if (envelope.data === null || envelope.data === undefined) {\n throw new PaymentApiError(\n envelope.error?.message || \"Response data is null\",\n envelope.error?.code || 0,\n response.status\n );\n }\n\n // Return unwrapped data so openapi-fetch sees the schema-matching body\n return new Response(JSON.stringify(envelope.data), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n // Not an envelope — return as-is\n return response;\n },\n };\n }\n\n private handleError(operation: string, error: unknown): never {\n if (error && typeof error === \"object\") {\n const errorObj = error as Record<string, unknown>;\n\n if (errorObj.status === 401 || errorObj.status === 403) {\n throw new PaymentAuthError();\n }\n if (errorObj.status === 404) {\n throw new PaymentNotFoundError(operation, \"unknown\");\n }\n if (errorObj.status === 429) {\n throw new PaymentRateLimitError();\n }\n }\n\n throw new PaymentError(\n `Failed to ${operation}: ${JSON.stringify(error)}`,\n undefined,\n error\n );\n }\n\n // ==================== Fleet Apps ====================\n\n /**\n * Get all fleet apps the user has access to (projects with Fleet activated).\n *\n * @returns Array of payment projects with Fleet app IDs\n */\n async getFleetProjects(): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/apps\");\n if (error) this.handleError(\"get fleet projects\", error);\n return data!;\n }\n\n /**\n * Get the details of a specific fleet app including the payment project.\n *\n * @param appId - The ID of the fleet app to retrieve\n * @returns Payment project details\n */\n async getFleetProject(appId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/apps/{app_id}\", {\n params: { path: { app_id: appId } },\n });\n if (error) this.handleError(\"get fleet project\", error);\n return data!;\n }\n\n // ==================== Projects ====================\n\n /**\n * Get all projects the authenticated user has access to.\n *\n * @param query - Optional query parameters to filter by project type\n * @returns Array of payment projects\n */\n async getProjects(query?: GetProjectsQuery): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/projects\", {\n params: { query },\n });\n if (error) this.handleError(\"get projects\", error);\n return data!;\n }\n\n /**\n * Get a specific project by ID.\n *\n * @param projectId - The unique identifier of the project\n * @returns Project details\n */\n async getProject(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project\", error);\n return data!;\n }\n\n /**\n * Update a project's name, description, or peer limit.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Updated project fields\n * @returns Success response\n */\n async editProject(projectId: string, body: EditProjectPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"edit project\", error);\n return data!;\n }\n\n // ==================== Peers / Metrics ====================\n\n /**\n * Get peak peers over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required)\n * @returns Peers over time data\n */\n async getPeersOverTime(projectId: string, query: GetPeersOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/peers-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get peers over time\", error);\n return data!;\n }\n\n /**\n * Get room count over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of active rooms\n */\n async getRoomsOverTime(projectId: string, query: GetRoomsOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/rooms-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get rooms over time\", error);\n return data!;\n }\n\n /**\n * Get Fleet server instances over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of deployed server instances\n */\n async getInstancesOverTime(projectId: string, query: GetInstancesOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/instances-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get instances over time\", error);\n return data!;\n }\n\n // ==================== Billing ====================\n\n /**\n * Get all billing accounts for the current user.\n *\n * @returns Array of billing accounts\n */\n async getBillingAccounts(): Promise<BillingAccount[]> {\n const { data, error } = await this.client.GET(\"/billing\");\n if (error) this.handleError(\"get billing accounts\", error);\n return data!;\n }\n\n /**\n * Get a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Billing account details\n */\n async getBillingAccount(billingAccountId: string): Promise<BillingAccount> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account\", error);\n return data!;\n }\n\n /**\n * Get invoices for a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Array of invoices\n */\n async getBillingAccountInvoices(billingAccountId: string): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}/invoices\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account invoices\", error);\n return data!;\n }\n\n /**\n * Create a Stripe setup session for a new billing account.\n *\n * @param body - Setup session creation payload\n * @returns Setup session with redirect URL\n */\n async createSetupSession(body: CreateSetupSessionPayload): Promise<SetupSession> {\n const { data, error } = await this.client.POST(\"/billing/create-setup-session\", {\n body,\n });\n if (error) this.handleError(\"create setup session\", error);\n return data!;\n }\n\n /**\n * Create a Stripe billing portal session.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @param body - Portal session creation payload\n * @returns Portal session with redirect URL\n */\n async createBillingPortalSession(billingAccountId: string, body: CreateBillingPortalSessionPayload): Promise<PortalSession> {\n const { data, error } = await this.client.POST(\"/billing/{billingAccountId}/create-billing-portal-session\", {\n params: { path: { billingAccountId } },\n body,\n });\n if (error) this.handleError(\"create billing portal session\", error);\n return data!;\n }\n\n /**\n * Get billing options for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Billing options including current state and change options\n */\n async getBillingOptions(projectId: string): Promise<BillingOptions> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/get-billing-options\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get billing options\", error);\n return data!;\n }\n\n /**\n * Set a billing account on a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Billing account and state to set\n * @returns Success response\n */\n async setBillingAccount(projectId: string, body: SetBillingAccountPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/set-billing-account\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"set billing account\", error);\n return data!;\n }\n\n /**\n * Cancel billing for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Success response\n */\n async cancelBilling(projectId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/cancel-billing\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"cancel billing\", error);\n return data!;\n }\n\n // ==================== API Activation ====================\n\n /**\n * Activate an API for the specified project.\n *\n * @deprecated Use {@link activateProduct} instead.\n * @param projectId - The unique identifier of the project\n * @param body - The API slug to activate\n * @returns Success response\n */\n async activateAPI(projectId: string, body: ActivateAPIPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-api\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate API\", error);\n return data!;\n }\n\n // ==================== Products ====================\n\n /**\n * List all available products.\n *\n * @returns Array of available products with features and pricing\n */\n async getProducts(): Promise<ProjectProduct[]> {\n const { data, error } = await this.client.GET(\"/products\");\n if (error) this.handleError(\"get products\", error);\n return data!;\n }\n\n /**\n * Get activated products for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Array of activated products\n */\n async getProjectProducts(projectId: string): Promise<ActivatedProduct[]> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/products\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project products\", error);\n return data!;\n }\n\n /**\n * Activate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug and optional configuration\n * @returns Updated project\n */\n async activateProduct(projectId: string, body: ActivateProductPayload): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate product\", error);\n return data!;\n }\n\n /**\n * Deactivate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug to deactivate\n * @returns Success response\n */\n async deactivateProduct(projectId: string, body: DeactivateProductPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/deactivate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"deactivate product\", error);\n return data!;\n }\n\n /**\n * Check if a feature is available for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query with the feature slug to check\n * @returns Feature availability status\n */\n async checkFeature(projectId: string, query: CheckFeatureQuery): Promise<FeatureAvailability> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/check-feature\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"check feature\", error);\n return data!;\n }\n\n // ==================== Invoices ====================\n\n /**\n * Get all invoices for the current user, optionally filtered by ID.\n *\n * @param query - Optional query parameters for filtering by invoice IDs\n * @returns Array of invoices\n */\n async getInvoices(query?: GetInvoicesQuery): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/invoices\", {\n params: { query },\n });\n if (error) this.handleError(\"get invoices\", error);\n return data!;\n }\n\n /**\n * Get a preview of the current month's invoice for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Invoice preview\n */\n async getInvoicePreview(projectId: string): Promise<Invoice> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/preview-invoice\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get invoice preview\", error);\n return data!;\n }\n\n // ==================== Access Keys ====================\n\n /**\n * Get a specific access key.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Access key details\n */\n async getAccessKey(accessKeyId: string): Promise<OdinAccessKey> {\n const { data, error } = await this.client.GET(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"get access key\", error);\n return data!;\n }\n\n /**\n * Create a new access key for a project.\n *\n * @param body - Access key creation payload\n * @returns Created access key (includes the key value only in this response)\n */\n async createAccessKey(body: CreateAccessKeyPayload): Promise<OdinAccessKey> {\n const { data, error } = await this.client.POST(\"/odin-access-keys/\", {\n body,\n });\n if (error) this.handleError(\"create access key\", error);\n return data!;\n }\n\n /**\n * Update an existing access key's name or description.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @param body - Updated access key fields\n * @returns Success response\n */\n async editAccessKey(accessKeyId: string, body: EditAccessKeyPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n body,\n });\n if (error) this.handleError(\"edit access key\", error);\n return data!;\n }\n\n /**\n * Delete an access key. This operation is irreversible.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Success response\n */\n async deleteAccessKey(accessKeyId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.DELETE(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"delete access key\", error);\n return data!;\n }\n\n // ==================== Project Members ====================\n\n /**\n * Add a user to a project with a specified role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - User email and role\n * @returns The created user role\n */\n async addProjectMember(projectId: string, body: AddUserToProjectPayload): Promise<OdinUserRole> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/add-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"add project member\", error);\n return data!;\n }\n\n /**\n * Revoke a user's permission from a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID to revoke\n * @returns Success response\n */\n async deleteProjectMember(projectId: string, body: RevokeUserPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"delete project member\", error);\n return data!;\n }\n\n /**\n * Change a project member's role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID and new role\n * @returns Success response\n */\n async changeMemberRole(projectId: string, body: ChangeUserRolePayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/change-user-role\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"change member role\", error);\n return data!;\n }\n\n // ==================== Tokens & Secrets ====================\n\n /**\n * Create an ODIN access token for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Token creation payload\n * @returns The created token\n */\n async createAccessToken(projectId: string, body: CreateTokenPayload): Promise<TokenPayload> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/create-token\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"create access token\", error);\n return data!;\n }\n\n /**\n * Revoke the secret for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Updated project with new secret\n */\n async revokeSecret(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-secret\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"revoke secret\", error);\n return data!;\n }\n\n // ==================== Resource Package Pricing ====================\n\n /**\n * Get the price for a single resource package in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package, region, and quantity\n * @returns Price information\n */\n async getResourcePackagePrice(projectId: string, body: ResourcePackagePricePayload): Promise<ResourcePackagePrice> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-price\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package price\", error);\n return data!;\n }\n\n /**\n * Get prices for multiple resource packages in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package IDs, region, and quantity\n * @returns Array of price information\n */\n async getResourcePackagePrices(projectId: string, body: ResourcePackagePricesPayload): Promise<ResourcePackagePrice[]> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-prices\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package prices\", error);\n return data!;\n }\n}\n\nexport default PaymentClient;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"names":[],"mappings":";;;;;AAcO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,KAAA,CAAM;AAAA,EACtC,WAAA,CACE,OAAA,EACgB,UAAA,EACA,OAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAEZ,IAAA,IAAI,OAAO,KAAA,CAAM,iBAAA,KAAsB,UAAA,EAAY;AACjD,MAAA,KAAA,CAAM,iBAAA,CAAkB,MAAM,aAAY,CAAA;AAAA,IAC5C;AAAA,EACF;AACF;AAeO,IAAM,eAAA,GAAN,cAA8B,YAAA,CAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhC,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA,EAEhB,WAAA,CAAY,OAAA,EAAiB,IAAA,EAAc,UAAA,EAAoB;AAC7D,IAAA,KAAA,CAAM,SAAS,UAAU,CAAA;AACzB,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACpB;AACF;AAKO,IAAM,gBAAA,GAAN,cAA+B,YAAA,CAAa;AAAA,EACjD,WAAA,CAAY,UAAU,6DAAA,EAA+D;AACnF,IAAA,KAAA,CAAM,SAAS,GAAG,CAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAAA,EACd;AACF;AAKO,IAAM,oBAAA,GAAN,cAAmC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AACD,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,WAAA,CAAY,eAAA,EAAiB,KAAK,CAAA;AAClD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,uBAAA,CAAwB,SAAA,EAAmB,IAAA,EAAkE;AACjH,IAAA,MAAM,EAAE,MAAM,KAAA,EAAM,GAAI,MAAM,IAAA,CAAK,MAAA,CAAO,KAAK,8CAAA,EAAgD;AAAA,MAC7F,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,WAAU,EAAE;AAAA,MAC9B;AAAA,KACD,CAAA;AACD,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,WAAA,CAAY,4BAAA,EAA8B,KAAK,CAAA;AAC/D,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,wBAAA,CAAyB,SAAA,EAAmB,IAAA,EAAqE;AACrH,IAAA,MAAM,EAAE,MAAM,KAAA,EAAM,GAAI,MAAM,IAAA,CAAK,MAAA,CAAO,KAAK,+CAAA,EAAiD;AAAA,MAC9F,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,WAAU,EAAE;AAAA,MAC9B;AAAA,KACD,CAAA;AACD,IAAA,IAAI,KAAA,EAAO,IAAA,CAAK,WAAA,CAAY,6BAAA,EAA+B,KAAK,CAAA;AAChE,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,IAAO,cAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * Payment SDK Error Classes\n *\n * Provides structured error handling for Payment API operations.\n */\n\n// V8-specific stack trace capture (available in Node.js, Chrome, etc.)\ndeclare const Error: ErrorConstructor & {\n captureStackTrace?(targetObject: object, constructorOpt?: Function): void;\n};\n\n/**\n * Base error class for all Payment SDK errors.\n */\nexport class PaymentError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly details?: unknown\n ) {\n super(message);\n this.name = \"PaymentError\";\n // Maintains proper stack trace for where error was thrown (V8 engines)\n if (typeof Error.captureStackTrace === \"function\") {\n Error.captureStackTrace(this, PaymentError);\n }\n }\n}\n\n/**\n * Error thrown when the Payment API returns an application-level error\n * in its response envelope.\n *\n * The Payment API wraps all responses in an envelope:\n * ```json\n * { \"data\": T | null, \"error\": { \"code\": number, \"message\": string } }\n * ```\n *\n * A `PaymentApiError` is thrown when:\n * - `error.code !== 0` (application-level error, even if HTTP status is 200)\n * - `data` is `null` (legacy error pattern from before HTTP status codes were used)\n */\nexport class PaymentApiError extends PaymentError {\n /**\n * Application-level error code from the response envelope.\n * A value of `0` means no specific error code was returned (legacy null-data case).\n */\n public readonly code: number;\n\n /**\n * The HTTP status code of the response.\n * Note: This may be `200` even when there is an application error.\n */\n public readonly httpStatus: number;\n\n constructor(message: string, code: number, httpStatus: number) {\n super(message, httpStatus);\n this.name = \"PaymentApiError\";\n this.code = code;\n this.httpStatus = httpStatus;\n }\n}\n\n/**\n * Error thrown when authentication fails or is required.\n */\nexport class PaymentAuthError extends PaymentError {\n constructor(message = \"Authentication required. Please provide a valid session ID.\") {\n super(message, 401);\n this.name = \"PaymentAuthError\";\n }\n}\n\n/**\n * Error thrown when a requested resource is not found.\n */\nexport class PaymentNotFoundError extends PaymentError {\n constructor(resource: string, id: string) {\n super(`${resource} with ID ${id} not found`, 404);\n this.name = \"PaymentNotFoundError\";\n }\n}\n\n/**\n * Error thrown when request validation fails.\n */\nexport class PaymentValidationError extends PaymentError {\n constructor(message: string, details?: unknown) {\n super(message, 422, details);\n this.name = \"PaymentValidationError\";\n }\n}\n\n/**\n * Error thrown when the API rate limit is exceeded.\n */\nexport class PaymentRateLimitError extends PaymentError {\n constructor(retryAfter?: number) {\n super(\n retryAfter\n ? `Rate limit exceeded. Retry after ${retryAfter} seconds.`\n : \"Rate limit exceeded. Please try again later.\",\n 429,\n { retryAfter }\n );\n this.name = \"PaymentRateLimitError\";\n }\n}\n","/**\n * 4Players Payment API Client\n *\n * A type-safe client for the 4Players Payment API.\n * Works in browsers, Node.js, Deno, Bun, and edge runtimes.\n *\n * @example\n * ```typescript\n * import { PaymentClient } from '@4players/payment';\n *\n * const client = new PaymentClient({ sessionId: 'your-session-id' });\n *\n * const projects = await client.getProjects();\n * ```\n */\n\nimport createClient, { type Middleware } from \"openapi-fetch\";\nimport type { paths, components, operations } from \"./types.js\";\nimport {\n PaymentError,\n PaymentApiError,\n PaymentAuthError,\n PaymentNotFoundError,\n PaymentRateLimitError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://secure.4players.de/public/api/v1\";\n\n/**\n * Configuration options for the Payment client.\n */\nexport interface PaymentClientConfig {\n /** Fusion session ID for authentication (sent as fusion-sid header) */\n sessionId: string;\n /** Base URL for the Payment API (default: https://secure.4players.de/public/api/v1) */\n baseUrl?: string;\n /** Custom fetch implementation (useful for testing or special environments) */\n fetch?: typeof fetch;\n}\n\n// ==================== Entity types from components.schemas ====================\n\nexport type PaymentProject = components[\"schemas\"][\"PaymentProject\"];\nexport type BillingAccount = components[\"schemas\"][\"BillingAccount\"];\nexport type OdinAccessKey = components[\"schemas\"][\"OdinAccessKey\"];\nexport type OdinUserPermissions = components[\"schemas\"][\"OdinUserPermissions\"];\nexport type OdinUserRole = components[\"schemas\"][\"OdinUserRole\"];\nexport type TimeSeriesData = components[\"schemas\"][\"TimeSeriesData\"];\nexport type Subscription = components[\"schemas\"][\"Subscription\"];\nexport type Invoice = components[\"schemas\"][\"Invoice\"];\nexport type InvoicePosition = components[\"schemas\"][\"InvoicePosition\"];\nexport type Invoices = components[\"schemas\"][\"Invoices\"];\nexport type SubscriptionPosition = components[\"schemas\"][\"SubscriptionPosition\"];\nexport type TariffParams = components[\"schemas\"][\"TariffParams\"];\nexport type SetupSession = components[\"schemas\"][\"SetupSession\"];\nexport type PortalSession = components[\"schemas\"][\"PortalSession\"];\nexport type TokenPayload = components[\"schemas\"][\"TokenPayload\"];\nexport type BillingOptions = components[\"schemas\"][\"BillingOptions\"];\nexport type BillingChangeOptions = components[\"schemas\"][\"BillingChangeOptions\"];\nexport type BillingStateHistory = components[\"schemas\"][\"BillingStateHistory\"];\nexport type ResourcePackagePrice = components[\"schemas\"][\"ResourcePackagePrice\"];\nexport type SuccessResponse = components[\"schemas\"][\"SuccessResponse\"];\nexport type ProjectProduct = components[\"schemas\"][\"ProjectProduct\"];\nexport type ProjectProductFeature = components[\"schemas\"][\"ProjectProductFeature\"];\nexport type ProductPricing = components[\"schemas\"][\"ProductPricing\"];\nexport type ActivatedProduct = components[\"schemas\"][\"ActivatedProduct\"];\nexport type FeatureAvailability = components[\"schemas\"][\"FeatureAvailability\"];\nexport type ProductDependencyCheck = components[\"schemas\"][\"ProductDependencyCheck\"];\nexport type ProductDependencyStatus = components[\"schemas\"][\"ProductDependencyStatus\"];\n\n// Enum types\nexport type APIType = components[\"schemas\"][\"APIType\"];\nexport type BillingState = components[\"schemas\"][\"BillingState\"];\nexport type PermissionRole = components[\"schemas\"][\"PermissionRole\"];\nexport type UserStatus = components[\"schemas\"][\"UserStatus\"];\nexport type InvoiceStatus = components[\"schemas\"][\"InvoiceStatus\"];\nexport type ProductSlug = components[\"schemas\"][\"ProductSlug\"];\nexport type PricingType = components[\"schemas\"][\"PricingType\"];\n\n// ==================== Request/Payload types ====================\n\nexport type ActivateAPIPayload = components[\"schemas\"][\"ActivateAPIPayload\"];\nexport type AddUserToProjectPayload = components[\"schemas\"][\"AddUserToProjectPayload\"];\nexport type ChangeUserRolePayload = components[\"schemas\"][\"ChangeUserRolePayload\"];\nexport type CreateAccessKeyPayload = components[\"schemas\"][\"CreateAccessKeyPayload\"];\nexport type CreateBillingPortalSessionPayload = components[\"schemas\"][\"CreateBillingPortalSessionPayload\"];\nexport type CreateSetupSessionPayload = components[\"schemas\"][\"CreateSetupSessionPayload\"];\nexport type CreateTokenPayload = components[\"schemas\"][\"CreateTokenPayload\"];\nexport type EditAccessKeyPayload = components[\"schemas\"][\"EditAccessKeyPayload\"];\nexport type EditProjectPayload = components[\"schemas\"][\"EditProjectPayload\"];\nexport type ResourcePackagePricePayload = components[\"schemas\"][\"ResourcePackagePricePayload\"];\nexport type ResourcePackagePricesPayload = components[\"schemas\"][\"ResourcePackagePricesPayload\"];\nexport type RevokeUserPayload = components[\"schemas\"][\"RevokeUserPayload\"];\nexport type SetBillingAccountPayload = components[\"schemas\"][\"SetBillingAccountPayload\"];\nexport type ActivateProductPayload = components[\"schemas\"][\"ActivateProductPayload\"];\nexport type DeactivateProductPayload = components[\"schemas\"][\"DeactivateProductPayload\"];\n\n// ==================== Query parameter types ====================\n\nexport type GetProjectsQuery = operations[\"getProjects\"][\"parameters\"][\"query\"];\nexport type GetPeersOverTimeQuery = operations[\"getPeersOverTime\"][\"parameters\"][\"query\"];\nexport type GetRoomsOverTimeQuery = operations[\"getRoomsOverTime\"][\"parameters\"][\"query\"];\nexport type GetInstancesOverTimeQuery = operations[\"getInstancesOverTime\"][\"parameters\"][\"query\"];\nexport type GetInvoicesQuery = operations[\"getInvoices\"][\"parameters\"][\"query\"];\nexport type CheckFeatureQuery = operations[\"checkFeature\"][\"parameters\"][\"query\"];\nexport type CheckProductDependenciesQuery = operations[\"checkProductDependencies\"][\"parameters\"][\"query\"];\n\n/**\n * Response envelope used by the Payment API.\n */\ninterface PaymentEnvelope<T = unknown> {\n data: T | null;\n error: {\n code: number;\n message: string;\n };\n}\n\n/**\n * 4Players Payment API Client\n *\n * Provides a type-safe interface to the 4Players Payment REST API for managing\n * projects, billing, invoices, access keys, and user permissions.\n */\nexport class PaymentClient {\n private client: ReturnType<typeof createClient<paths>>;\n\n /**\n * Create a new Payment client instance.\n *\n * @param config - Client configuration\n * @throws {PaymentAuthError} If no session ID is provided\n *\n * @example\n * ```typescript\n * const client = new PaymentClient({\n * sessionId: 'your-fusion-sid'\n * });\n * ```\n */\n constructor(config: PaymentClientConfig) {\n if (!config.sessionId) {\n throw new PaymentAuthError(\"Session ID is required\");\n }\n\n this.client = createClient<paths>({\n baseUrl: config.baseUrl || DEFAULT_BASE_URL,\n headers: {\n \"fusion-sid\": config.sessionId,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n fetch: config.fetch,\n });\n\n // Register the envelope-unwrapping middleware\n this.client.use(this.createEnvelopeMiddleware());\n }\n\n /**\n * Creates middleware that unwraps the Payment API response envelope.\n *\n * The Payment API wraps ALL responses in `{ data, error }`.\n * This middleware:\n * 1. Checks `error.code` — if non-zero, throws `PaymentApiError`\n * 2. Checks `data` — if null, throws `PaymentApiError` (legacy error pattern)\n * 3. Returns a new Response containing only the unwrapped `data`\n */\n private createEnvelopeMiddleware(): Middleware {\n return {\n async onResponse({ response }) {\n const contentType = response.headers.get(\"content-type\");\n if (!contentType?.includes(\"application/json\")) {\n return response;\n }\n\n const text = await response.clone().text();\n let body: unknown;\n try {\n body = JSON.parse(text);\n } catch {\n return response;\n }\n\n if (\n body !== null &&\n typeof body === \"object\" &&\n \"error\" in body &&\n \"data\" in body\n ) {\n const envelope = body as PaymentEnvelope;\n\n // Application-level error (can happen even with HTTP 200!)\n if (envelope.error && envelope.error.code !== 0) {\n throw new PaymentApiError(\n envelope.error.message,\n envelope.error.code,\n response.status\n );\n }\n\n // Legacy error pattern: data is null with HTTP 200\n if (envelope.data === null || envelope.data === undefined) {\n throw new PaymentApiError(\n envelope.error?.message || \"Response data is null\",\n envelope.error?.code || 0,\n response.status\n );\n }\n\n // Return unwrapped data so openapi-fetch sees the schema-matching body\n return new Response(JSON.stringify(envelope.data), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n // Not an envelope — return as-is\n return response;\n },\n };\n }\n\n private handleError(operation: string, error: unknown): never {\n if (error && typeof error === \"object\") {\n const errorObj = error as Record<string, unknown>;\n\n if (errorObj.status === 401 || errorObj.status === 403) {\n throw new PaymentAuthError();\n }\n if (errorObj.status === 404) {\n throw new PaymentNotFoundError(operation, \"unknown\");\n }\n if (errorObj.status === 429) {\n throw new PaymentRateLimitError();\n }\n }\n\n throw new PaymentError(\n `Failed to ${operation}: ${JSON.stringify(error)}`,\n undefined,\n error\n );\n }\n\n // ==================== Fleet Apps ====================\n\n /**\n * Get all fleet apps the user has access to (projects with Fleet activated).\n *\n * @returns Array of payment projects with Fleet app IDs\n */\n async getFleetProjects(): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/apps\");\n if (error) this.handleError(\"get fleet projects\", error);\n return data!;\n }\n\n /**\n * Get the details of a specific fleet app including the payment project.\n *\n * @param appId - The ID of the fleet app to retrieve\n * @returns Payment project details\n */\n async getFleetProject(appId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/apps/{app_id}\", {\n params: { path: { app_id: appId } },\n });\n if (error) this.handleError(\"get fleet project\", error);\n return data!;\n }\n\n // ==================== Projects ====================\n\n /**\n * Get all projects the authenticated user has access to.\n *\n * @param query - Optional query parameters to filter by project type\n * @returns Array of payment projects\n */\n async getProjects(query?: GetProjectsQuery): Promise<PaymentProject[]> {\n const { data, error } = await this.client.GET(\"/projects\", {\n params: { query },\n });\n if (error) this.handleError(\"get projects\", error);\n return data!;\n }\n\n /**\n * Get a specific project by ID.\n *\n * @param projectId - The unique identifier of the project\n * @returns Project details\n */\n async getProject(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project\", error);\n return data!;\n }\n\n /**\n * Update a project's name, description, or peer limit.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Updated project fields\n * @returns Success response\n */\n async editProject(projectId: string, body: EditProjectPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/projects/{projectId}\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"edit project\", error);\n return data!;\n }\n\n // ==================== Peers / Metrics ====================\n\n /**\n * Get peak peers over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required)\n * @returns Peers over time data\n */\n async getPeersOverTime(projectId: string, query: GetPeersOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/peers-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get peers over time\", error);\n return data!;\n }\n\n /**\n * Get room count over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of active rooms\n */\n async getRoomsOverTime(projectId: string, query: GetRoomsOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/rooms-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get rooms over time\", error);\n return data!;\n }\n\n /**\n * Get Fleet server instances over time for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query parameters (start timestamp is required, end is optional)\n * @returns Time-series data of deployed server instances\n */\n async getInstancesOverTime(projectId: string, query: GetInstancesOverTimeQuery): Promise<TimeSeriesData> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/instances-over-time\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"get instances over time\", error);\n return data!;\n }\n\n // ==================== Billing ====================\n\n /**\n * Get all billing accounts for the current user.\n *\n * @returns Array of billing accounts\n */\n async getBillingAccounts(): Promise<BillingAccount[]> {\n const { data, error } = await this.client.GET(\"/billing\");\n if (error) this.handleError(\"get billing accounts\", error);\n return data!;\n }\n\n /**\n * Get a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Billing account details\n */\n async getBillingAccount(billingAccountId: string): Promise<BillingAccount> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account\", error);\n return data!;\n }\n\n /**\n * Get invoices for a specific billing account.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @returns Array of invoices\n */\n async getBillingAccountInvoices(billingAccountId: string): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/billing/{billingAccountId}/invoices\", {\n params: { path: { billingAccountId } },\n });\n if (error) this.handleError(\"get billing account invoices\", error);\n return data!;\n }\n\n /**\n * Create a Stripe setup session for a new billing account.\n *\n * @param body - Setup session creation payload\n * @returns Setup session with redirect URL\n */\n async createSetupSession(body: CreateSetupSessionPayload): Promise<SetupSession> {\n const { data, error } = await this.client.POST(\"/billing/create-setup-session\", {\n body,\n });\n if (error) this.handleError(\"create setup session\", error);\n return data!;\n }\n\n /**\n * Create a Stripe billing portal session.\n *\n * @param billingAccountId - The unique identifier of the billing account\n * @param body - Portal session creation payload\n * @returns Portal session with redirect URL\n */\n async createBillingPortalSession(billingAccountId: string, body: CreateBillingPortalSessionPayload): Promise<PortalSession> {\n const { data, error } = await this.client.POST(\"/billing/{billingAccountId}/create-billing-portal-session\", {\n params: { path: { billingAccountId } },\n body,\n });\n if (error) this.handleError(\"create billing portal session\", error);\n return data!;\n }\n\n /**\n * Get billing options for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Billing options including current state and change options\n */\n async getBillingOptions(projectId: string): Promise<BillingOptions> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/get-billing-options\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get billing options\", error);\n return data!;\n }\n\n /**\n * Set a billing account on a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Billing account and state to set\n * @returns Success response\n */\n async setBillingAccount(projectId: string, body: SetBillingAccountPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/set-billing-account\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"set billing account\", error);\n return data!;\n }\n\n /**\n * Cancel billing for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Success response\n */\n async cancelBilling(projectId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/cancel-billing\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"cancel billing\", error);\n return data!;\n }\n\n // ==================== API Activation ====================\n\n /**\n * Activate an API for the specified project.\n *\n * @deprecated Use {@link activateProduct} instead.\n * @param projectId - The unique identifier of the project\n * @param body - The API slug to activate\n * @returns Success response\n */\n async activateAPI(projectId: string, body: ActivateAPIPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-api\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate API\", error);\n return data!;\n }\n\n // ==================== Products ====================\n\n /**\n * List all available products.\n *\n * @returns Array of available products with features and pricing\n */\n async getProducts(): Promise<ProjectProduct[]> {\n const { data, error } = await this.client.GET(\"/products\");\n if (error) this.handleError(\"get products\", error);\n return data!;\n }\n\n /**\n * Get activated products for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Array of activated products\n */\n async getProjectProducts(projectId: string): Promise<ActivatedProduct[]> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/products\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get project products\", error);\n return data!;\n }\n\n /**\n * Activate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug and optional configuration\n * @returns Updated project\n */\n async activateProduct(projectId: string, body: ActivateProductPayload): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/activate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"activate product\", error);\n return data!;\n }\n\n /**\n * Deactivate a product for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The product slug to deactivate\n * @returns Success response\n */\n async deactivateProduct(projectId: string, body: DeactivateProductPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/deactivate-product\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"deactivate product\", error);\n return data!;\n }\n\n /**\n * Check if a feature is available for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query with the feature slug to check\n * @returns Feature availability status\n */\n async checkFeature(projectId: string, query: CheckFeatureQuery): Promise<FeatureAvailability> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/check-feature\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"check feature\", error);\n return data!;\n }\n\n /**\n * Check product dependencies for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param query - Query with the product slug to check\n * @returns Dependency check result with activation status of each dependency\n */\n async checkProductDependencies(projectId: string, query: CheckProductDependenciesQuery): Promise<ProductDependencyCheck> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/check-product-dependencies\", {\n params: { path: { projectId }, query },\n });\n if (error) this.handleError(\"check product dependencies\", error);\n return data!;\n }\n\n // ==================== Invoices ====================\n\n /**\n * Get all invoices for the current user, optionally filtered by ID.\n *\n * @param query - Optional query parameters for filtering by invoice IDs\n * @returns Array of invoices\n */\n async getInvoices(query?: GetInvoicesQuery): Promise<Invoice[]> {\n const { data, error } = await this.client.GET(\"/invoices\", {\n params: { query },\n });\n if (error) this.handleError(\"get invoices\", error);\n return data!;\n }\n\n /**\n * Get a preview of the current month's invoice for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Invoice preview\n */\n async getInvoicePreview(projectId: string): Promise<Invoice> {\n const { data, error } = await this.client.GET(\"/projects/{projectId}/preview-invoice\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"get invoice preview\", error);\n return data!;\n }\n\n // ==================== Access Keys ====================\n\n /**\n * Get a specific access key.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Access key details\n */\n async getAccessKey(accessKeyId: string): Promise<OdinAccessKey> {\n const { data, error } = await this.client.GET(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"get access key\", error);\n return data!;\n }\n\n /**\n * Create a new access key for a project.\n *\n * @param body - Access key creation payload\n * @returns Created access key (includes the key value only in this response)\n */\n async createAccessKey(body: CreateAccessKeyPayload): Promise<OdinAccessKey> {\n const { data, error } = await this.client.POST(\"/odin-access-keys/\", {\n body,\n });\n if (error) this.handleError(\"create access key\", error);\n return data!;\n }\n\n /**\n * Update an existing access key's name or description.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @param body - Updated access key fields\n * @returns Success response\n */\n async editAccessKey(accessKeyId: string, body: EditAccessKeyPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.PUT(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n body,\n });\n if (error) this.handleError(\"edit access key\", error);\n return data!;\n }\n\n /**\n * Delete an access key. This operation is irreversible.\n *\n * @param accessKeyId - The unique identifier of the access key\n * @returns Success response\n */\n async deleteAccessKey(accessKeyId: string): Promise<SuccessResponse> {\n const { data, error } = await this.client.DELETE(\"/odin-access-keys/{accessKeyId}\", {\n params: { path: { accessKeyId } },\n });\n if (error) this.handleError(\"delete access key\", error);\n return data!;\n }\n\n // ==================== Project Members ====================\n\n /**\n * Add a user to a project with a specified role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - User email and role\n * @returns The created user role\n */\n async addProjectMember(projectId: string, body: AddUserToProjectPayload): Promise<OdinUserRole> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/add-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"add project member\", error);\n return data!;\n }\n\n /**\n * Revoke a user's permission from a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID to revoke\n * @returns Success response\n */\n async deleteProjectMember(projectId: string, body: RevokeUserPayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-user-permission\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"delete project member\", error);\n return data!;\n }\n\n /**\n * Change a project member's role.\n *\n * @param projectId - The unique identifier of the project\n * @param body - The permission ID and new role\n * @returns Success response\n */\n async changeMemberRole(projectId: string, body: ChangeUserRolePayload): Promise<SuccessResponse> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/change-user-role\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"change member role\", error);\n return data!;\n }\n\n // ==================== Tokens & Secrets ====================\n\n /**\n * Create an ODIN access token for a project.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Token creation payload\n * @returns The created token\n */\n async createAccessToken(projectId: string, body: CreateTokenPayload): Promise<TokenPayload> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/create-token\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"create access token\", error);\n return data!;\n }\n\n /**\n * Revoke the secret for a project.\n *\n * @param projectId - The unique identifier of the project\n * @returns Updated project with new secret\n */\n async revokeSecret(projectId: string): Promise<PaymentProject> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/revoke-secret\", {\n params: { path: { projectId } },\n });\n if (error) this.handleError(\"revoke secret\", error);\n return data!;\n }\n\n // ==================== Resource Package Pricing ====================\n\n /**\n * Get the price for a single resource package in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package, region, and quantity\n * @returns Price information\n */\n async getResourcePackagePrice(projectId: string, body: ResourcePackagePricePayload): Promise<ResourcePackagePrice> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-price\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package price\", error);\n return data!;\n }\n\n /**\n * Get prices for multiple resource packages in a specific region.\n *\n * @param projectId - The unique identifier of the project\n * @param body - Resource package IDs, region, and quantity\n * @returns Array of price information\n */\n async getResourcePackagePrices(projectId: string, body: ResourcePackagePricesPayload): Promise<ResourcePackagePrice[]> {\n const { data, error } = await this.client.POST(\"/projects/{projectId}/resource-package-prices\", {\n params: { path: { projectId } },\n body,\n });\n if (error) this.handleError(\"get resource package prices\", error);\n return data!;\n }\n}\n\nexport default PaymentClient;\n"]}
|