@solvapay/server 2.4.0 → 2.4.1-preview-b3e6bc5f2e85e523b10a041dc93fd194640e4b76
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/edge.d.ts +48 -1
- package/dist/edge.js +51 -14
- package/package.json +1 -1
package/dist/edge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
|
|
2
3
|
|
|
3
4
|
interface components {
|
|
@@ -5421,6 +5422,52 @@ declare class PaywallError extends Error {
|
|
|
5421
5422
|
/** JSON body shape for HTTP adapters and MCP text content (stable fields for clients). */
|
|
5422
5423
|
declare function paywallErrorToClientPayload(error: PaywallError): Record<string, unknown>;
|
|
5423
5424
|
|
|
5425
|
+
/**
|
|
5426
|
+
* Zod schemas for `PaywallStructuredContent`. Declared so MCP hosts can
|
|
5427
|
+
* hydrate `structuredContent` and so we fail loud when a required field
|
|
5428
|
+
* the narrator claims to print is missing. Every recovery field is
|
|
5429
|
+
* optional — a default here would invent data the backend did not send.
|
|
5430
|
+
*/
|
|
5431
|
+
|
|
5432
|
+
declare const PaywallStructuredContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5433
|
+
planRef: z.ZodOptional<z.ZodString>;
|
|
5434
|
+
plans: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
5435
|
+
meterName: z.ZodOptional<z.ZodString>;
|
|
5436
|
+
unitPriceMinor: z.ZodOptional<z.ZodNumber>;
|
|
5437
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
5438
|
+
included: z.ZodOptional<z.ZodObject<{
|
|
5439
|
+
total: z.ZodNumber;
|
|
5440
|
+
used: z.ZodNumber;
|
|
5441
|
+
remaining: z.ZodNumber;
|
|
5442
|
+
}, z.core.$strip>>;
|
|
5443
|
+
creditBalance: z.ZodOptional<z.ZodNumber>;
|
|
5444
|
+
balance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
5445
|
+
productDetails: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
5446
|
+
kind: z.ZodLiteral<"payment_required">;
|
|
5447
|
+
product: z.ZodString;
|
|
5448
|
+
checkoutUrl: z.ZodString;
|
|
5449
|
+
message: z.ZodString;
|
|
5450
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5451
|
+
planRef: z.ZodOptional<z.ZodString>;
|
|
5452
|
+
plans: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
5453
|
+
meterName: z.ZodOptional<z.ZodString>;
|
|
5454
|
+
unitPriceMinor: z.ZodOptional<z.ZodNumber>;
|
|
5455
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
5456
|
+
included: z.ZodOptional<z.ZodObject<{
|
|
5457
|
+
total: z.ZodNumber;
|
|
5458
|
+
used: z.ZodNumber;
|
|
5459
|
+
remaining: z.ZodNumber;
|
|
5460
|
+
}, z.core.$strip>>;
|
|
5461
|
+
creditBalance: z.ZodOptional<z.ZodNumber>;
|
|
5462
|
+
balance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
5463
|
+
productDetails: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
5464
|
+
kind: z.ZodLiteral<"activation_required">;
|
|
5465
|
+
product: z.ZodString;
|
|
5466
|
+
checkoutUrl: z.ZodString;
|
|
5467
|
+
message: z.ZodString;
|
|
5468
|
+
confirmationUrl: z.ZodOptional<z.ZodString>;
|
|
5469
|
+
}, z.core.$strip>], "kind">;
|
|
5470
|
+
|
|
5424
5471
|
/**
|
|
5425
5472
|
* Pure state engine that classifies a `LimitResponseWithPlan` into a
|
|
5426
5473
|
* recovery-tool-specific `PaywallState`, and produces the human-readable
|
|
@@ -6262,4 +6309,4 @@ declare function verifyWebhook({ body, signature, secret, }: {
|
|
|
6262
6309
|
secret: string;
|
|
6263
6310
|
}): Promise<WebhookEvent>;
|
|
6264
6311
|
|
|
6265
|
-
export { type ActivatePlanResult, type AuthenticatedUser, type ConfigureMcpPlansRequest, type ConfigureMcpPlansResponse, type CreateSolvaPayConfig, type CustomerBalanceResult, type CustomerResponseMapped, type CustomerWebhookObject, type ErrorResult, type GetUsageResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type LimitResponseWithPlan, type McpBootstrapPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type McpToolPlanMappingInput, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableAllowResult, type PayableFunction, type PayableGateOptions, type PayableGateResult, type PayableOptions, type PayablePaywallResult, type PaymentMethodInfo, type PaywallArgs, type PaywallDecision, PaywallError, type PaywallMetadata, type PaywallState, type PaywallStructuredContent, type ProcessPaymentResult, type ProductConfigurationStatus, type PurchaseCheckResult, type RetryOptions, type SdkMerchantResponse, type SdkProductResponse, type ServerClientOptions, type SolvaPay, type SolvaPayClient, type ToolPlanMappingInput, type TopupProcessResult, type VerifyProductConfigurationOptions, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, attachBusinessDetailsCore, buildGateMessage, buildNudgeMessage, buildPaywallGate, cancelPurchaseCore, checkLimitsCore, checkPurchaseCore, classifyPaywallState, type components, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, deriveUsageSnapshot, disableAutoRechargeCore, getAuthenticatedUserCore, getAutoRechargeCore, getCustomerBalanceCore, getHistoryCore, getMerchantCore, getPaymentMethodCore, getProductCore, getUsageCore, handleRouteError, isErrorResult, isPaywallStructuredContent, listPlansCore, paywallErrorToClientPayload, processPaymentIntentCore, processTopupPaymentIntentCore, reactivatePurchaseCore, saveAutoRechargeCore, syncCustomerCore, trackUsageCore, verifyProductConfiguration, verifyWebhook, withRetry };
|
|
6312
|
+
export { type ActivatePlanResult, type AuthenticatedUser, type ConfigureMcpPlansRequest, type ConfigureMcpPlansResponse, type CreateSolvaPayConfig, type CustomerBalanceResult, type CustomerResponseMapped, type CustomerWebhookObject, type ErrorResult, type GetUsageResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type LimitResponseWithPlan, type McpBootstrapPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type McpToolPlanMappingInput, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableAllowResult, type PayableFunction, type PayableGateOptions, type PayableGateResult, type PayableOptions, type PayablePaywallResult, type PaymentMethodInfo, type PaywallArgs, type PaywallDecision, PaywallError, type PaywallMetadata, type PaywallState, type PaywallStructuredContent, PaywallStructuredContentSchema, type ProcessPaymentResult, type ProductConfigurationStatus, type PurchaseCheckResult, type RetryOptions, type SdkMerchantResponse, type SdkProductResponse, type ServerClientOptions, type SolvaPay, type SolvaPayClient, type ToolPlanMappingInput, type TopupProcessResult, type VerifyProductConfigurationOptions, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, attachBusinessDetailsCore, buildGateMessage, buildNudgeMessage, buildPaywallGate, cancelPurchaseCore, checkLimitsCore, checkPurchaseCore, classifyPaywallState, type components, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, deriveUsageSnapshot, disableAutoRechargeCore, getAuthenticatedUserCore, getAutoRechargeCore, getCustomerBalanceCore, getHistoryCore, getMerchantCore, getPaymentMethodCore, getProductCore, getUsageCore, handleRouteError, isErrorResult, isPaywallStructuredContent, listPlansCore, paywallErrorToClientPayload, processPaymentIntentCore, processTopupPaymentIntentCore, reactivatePurchaseCore, saveAutoRechargeCore, syncCustomerCore, trackUsageCore, verifyProductConfiguration, verifyWebhook, withRetry };
|
package/dist/edge.js
CHANGED
|
@@ -2129,34 +2129,34 @@ function isJsonSchemaObject(value) {
|
|
|
2129
2129
|
return Boolean(value && typeof value === "object");
|
|
2130
2130
|
}
|
|
2131
2131
|
function toZodSchema(property) {
|
|
2132
|
-
const
|
|
2132
|
+
const z2 = getZod();
|
|
2133
2133
|
if (Array.isArray(property.enum) && property.enum.length > 0) {
|
|
2134
2134
|
if (property.enum.every((value) => typeof value === "string")) {
|
|
2135
2135
|
const [first, ...rest] = property.enum;
|
|
2136
|
-
return
|
|
2136
|
+
return z2.enum([first, ...rest]);
|
|
2137
2137
|
}
|
|
2138
2138
|
if (property.enum.length === 1) {
|
|
2139
|
-
return
|
|
2139
|
+
return z2.literal(property.enum[0]);
|
|
2140
2140
|
}
|
|
2141
|
-
return
|
|
2141
|
+
return z2.union(property.enum.map((value) => z2.literal(value)));
|
|
2142
2142
|
}
|
|
2143
2143
|
switch (property.type) {
|
|
2144
2144
|
case "string":
|
|
2145
|
-
return
|
|
2145
|
+
return z2.string();
|
|
2146
2146
|
case "number":
|
|
2147
|
-
return
|
|
2147
|
+
return z2.number();
|
|
2148
2148
|
case "integer":
|
|
2149
|
-
return
|
|
2149
|
+
return z2.number().int();
|
|
2150
2150
|
case "boolean":
|
|
2151
|
-
return
|
|
2151
|
+
return z2.boolean();
|
|
2152
2152
|
case "array":
|
|
2153
|
-
return
|
|
2154
|
-
isJsonSchemaObject(property.items) ? toZodSchema(property.items) :
|
|
2153
|
+
return z2.array(
|
|
2154
|
+
isJsonSchemaObject(property.items) ? toZodSchema(property.items) : z2.any()
|
|
2155
2155
|
);
|
|
2156
2156
|
case "object":
|
|
2157
|
-
return
|
|
2157
|
+
return z2.object(jsonSchemaToZodRawShape(property.properties || {}));
|
|
2158
2158
|
default:
|
|
2159
|
-
return
|
|
2159
|
+
return z2.any();
|
|
2160
2160
|
}
|
|
2161
2161
|
}
|
|
2162
2162
|
function jsonSchemaToZodRawShape(properties, required = []) {
|
|
@@ -2191,12 +2191,12 @@ function registerVirtualToolsMcpImpl(server, apiClient, options) {
|
|
|
2191
2191
|
if (filter && !filter(toolDefinition)) continue;
|
|
2192
2192
|
const mappedDefinition = mapDefinition ? mapDefinition(toolDefinition) : toolDefinition;
|
|
2193
2193
|
const wrappedHandler = wrapHandler ? wrapHandler(mappedDefinition.handler, mappedDefinition) : mappedDefinition.handler;
|
|
2194
|
-
const
|
|
2194
|
+
const z2 = getZod();
|
|
2195
2195
|
server.registerTool(
|
|
2196
2196
|
mappedDefinition.name,
|
|
2197
2197
|
{
|
|
2198
2198
|
description: mappedDefinition.description,
|
|
2199
|
-
inputSchema:
|
|
2199
|
+
inputSchema: z2.object(
|
|
2200
2200
|
jsonSchemaToZodRawShape(
|
|
2201
2201
|
mappedDefinition.inputSchema.properties,
|
|
2202
2202
|
mappedDefinition.inputSchema.required || []
|
|
@@ -2483,6 +2483,42 @@ function isPaywallStructuredContent(value) {
|
|
|
2483
2483
|
return kind === "payment_required" || kind === "activation_required";
|
|
2484
2484
|
}
|
|
2485
2485
|
|
|
2486
|
+
// src/types/paywall-schema.ts
|
|
2487
|
+
import { z } from "zod";
|
|
2488
|
+
var includedSchema = z.object({
|
|
2489
|
+
total: z.number(),
|
|
2490
|
+
used: z.number(),
|
|
2491
|
+
remaining: z.number()
|
|
2492
|
+
});
|
|
2493
|
+
var recoveryFields2 = {
|
|
2494
|
+
planRef: z.string().optional(),
|
|
2495
|
+
plans: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
2496
|
+
meterName: z.string().optional(),
|
|
2497
|
+
unitPriceMinor: z.number().optional(),
|
|
2498
|
+
currency: z.string().optional(),
|
|
2499
|
+
included: includedSchema.optional(),
|
|
2500
|
+
creditBalance: z.number().optional(),
|
|
2501
|
+
balance: z.record(z.string(), z.unknown()).optional(),
|
|
2502
|
+
productDetails: z.record(z.string(), z.unknown()).optional()
|
|
2503
|
+
};
|
|
2504
|
+
var PaywallStructuredContentSchema = z.discriminatedUnion("kind", [
|
|
2505
|
+
z.object({
|
|
2506
|
+
kind: z.literal("payment_required"),
|
|
2507
|
+
product: z.string(),
|
|
2508
|
+
checkoutUrl: z.string(),
|
|
2509
|
+
message: z.string(),
|
|
2510
|
+
...recoveryFields2
|
|
2511
|
+
}),
|
|
2512
|
+
z.object({
|
|
2513
|
+
kind: z.literal("activation_required"),
|
|
2514
|
+
product: z.string(),
|
|
2515
|
+
checkoutUrl: z.string(),
|
|
2516
|
+
message: z.string(),
|
|
2517
|
+
confirmationUrl: z.string().optional(),
|
|
2518
|
+
...recoveryFields2
|
|
2519
|
+
})
|
|
2520
|
+
]);
|
|
2521
|
+
|
|
2486
2522
|
// src/helpers/error.ts
|
|
2487
2523
|
import { SolvaPayError as SolvaPayError5 } from "@solvapay/core";
|
|
2488
2524
|
function isErrorResult(result) {
|
|
@@ -3612,6 +3648,7 @@ async function verifyWebhook({
|
|
|
3612
3648
|
}
|
|
3613
3649
|
export {
|
|
3614
3650
|
PaywallError,
|
|
3651
|
+
PaywallStructuredContentSchema,
|
|
3615
3652
|
activatePlanCore,
|
|
3616
3653
|
attachBusinessDetailsCore,
|
|
3617
3654
|
buildGateMessage,
|