@solvapay/mcp-core 0.4.3 → 0.4.4
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 +12 -5
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +12 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2047,7 +2047,7 @@ function snapshotFromLimits(params) {
|
|
|
2047
2047
|
};
|
|
2048
2048
|
}
|
|
2049
2049
|
function buildResponseContext(params) {
|
|
2050
|
-
const { customerRef, limits, product, bootstrapProduct, solvaPay } = params;
|
|
2050
|
+
const { customerRef, limits, product, bootstrapProduct, solvaPay, freeLimit } = params;
|
|
2051
2051
|
const bootstrapPlan = params.bootstrapPlan ?? synthesizePlanStub(limits);
|
|
2052
2052
|
const emittedBlocks = [];
|
|
2053
2053
|
const abortController = new AbortController();
|
|
@@ -2055,7 +2055,8 @@ function buildResponseContext(params) {
|
|
|
2055
2055
|
const freshLimits = await solvaPay.checkLimits({
|
|
2056
2056
|
customerRef,
|
|
2057
2057
|
productRef: product,
|
|
2058
|
-
meterName: "requests"
|
|
2058
|
+
meterName: freeLimit?.meter ?? "requests",
|
|
2059
|
+
...freeLimit ? { freeAllowance: freeLimit } : {}
|
|
2059
2060
|
});
|
|
2060
2061
|
return snapshotFromLimits({
|
|
2061
2062
|
customerRef,
|
|
@@ -2109,7 +2110,7 @@ function buildResponseContext(params) {
|
|
|
2109
2110
|
|
|
2110
2111
|
// src/payable-handler.ts
|
|
2111
2112
|
function buildPayableHandler(solvaPay, ctx, handler) {
|
|
2112
|
-
const { product, getCustomerRef, toolName } = ctx;
|
|
2113
|
+
const { product, getCustomerRef, toolName, freeLimit } = ctx;
|
|
2113
2114
|
const wrappedBusinessLogic = async (args, handlerContext) => {
|
|
2114
2115
|
const limits = handlerContext?.limits ?? null;
|
|
2115
2116
|
const customerRef = handlerContext?.customerRef ?? "";
|
|
@@ -2117,11 +2118,17 @@ function buildPayableHandler(solvaPay, ctx, handler) {
|
|
|
2117
2118
|
customerRef,
|
|
2118
2119
|
limits,
|
|
2119
2120
|
product,
|
|
2120
|
-
solvaPay
|
|
2121
|
+
solvaPay,
|
|
2122
|
+
...freeLimit ? { freeLimit } : {}
|
|
2121
2123
|
});
|
|
2122
2124
|
return handler(args, responseCtx);
|
|
2123
2125
|
};
|
|
2124
|
-
const protectedHandler = solvaPay.payable({
|
|
2126
|
+
const protectedHandler = solvaPay.payable({
|
|
2127
|
+
product,
|
|
2128
|
+
getCustomerRef,
|
|
2129
|
+
...toolName ? { toolName } : {},
|
|
2130
|
+
...freeLimit ? { freeLimit } : {}
|
|
2131
|
+
}).mcp(wrappedBusinessLogic);
|
|
2125
2132
|
return async (args, extra) => {
|
|
2126
2133
|
const result = await protectedHandler(args, extra);
|
|
2127
2134
|
if ((0, import_server6.isPaywallStructuredContent)(result.structuredContent)) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZodTypeAny, z } from 'zod';
|
|
2
|
-
import { PurchaseCheckResult, PaymentMethodInfo, CustomerBalanceResult, GetUsageResult, LimitResponseWithPlan, LimitAutoRechargeDto, PaywallNextAction, SdkMerchantResponse, SdkProductResponse, components, SolvaPay, PaywallError, PaywallStructuredContent } from '@solvapay/server';
|
|
2
|
+
import { PurchaseCheckResult, PaymentMethodInfo, CustomerBalanceResult, GetUsageResult, LimitResponseWithPlan, LimitAutoRechargeDto, PaywallNextAction, SdkMerchantResponse, SdkProductResponse, components, SolvaPay, PaywallError, PaywallStructuredContent, FreeLimit } from '@solvapay/server';
|
|
3
3
|
import { PricingOptionLike } from '@solvapay/core';
|
|
4
4
|
export { ProductReadinessInput, ProductReadinessResult, SOLVAPAY_PRODUCT_REF_PLACEHOLDER, assertValidProductRef, creditsToDisplayMinorUnits, evaluateProductReadiness, isZeroDecimalCurrency, minorUnitsPerMajor } from '@solvapay/core';
|
|
5
5
|
|
|
@@ -1500,6 +1500,11 @@ interface BuildPayableHandlerContext {
|
|
|
1500
1500
|
* events are attributable to a tool.
|
|
1501
1501
|
*/
|
|
1502
1502
|
toolName?: string;
|
|
1503
|
+
/**
|
|
1504
|
+
* SDK-only free-tool allowance. When set, the paywall kernel counts
|
|
1505
|
+
* against this free meter instead of the plan meter.
|
|
1506
|
+
*/
|
|
1507
|
+
freeLimit?: FreeLimit;
|
|
1503
1508
|
}
|
|
1504
1509
|
/**
|
|
1505
1510
|
* Merchant handler contract: `(args, ctx) => ctx.respond(data, options?)`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZodTypeAny, z } from 'zod';
|
|
2
|
-
import { PurchaseCheckResult, PaymentMethodInfo, CustomerBalanceResult, GetUsageResult, LimitResponseWithPlan, LimitAutoRechargeDto, PaywallNextAction, SdkMerchantResponse, SdkProductResponse, components, SolvaPay, PaywallError, PaywallStructuredContent } from '@solvapay/server';
|
|
2
|
+
import { PurchaseCheckResult, PaymentMethodInfo, CustomerBalanceResult, GetUsageResult, LimitResponseWithPlan, LimitAutoRechargeDto, PaywallNextAction, SdkMerchantResponse, SdkProductResponse, components, SolvaPay, PaywallError, PaywallStructuredContent, FreeLimit } from '@solvapay/server';
|
|
3
3
|
import { PricingOptionLike } from '@solvapay/core';
|
|
4
4
|
export { ProductReadinessInput, ProductReadinessResult, SOLVAPAY_PRODUCT_REF_PLACEHOLDER, assertValidProductRef, creditsToDisplayMinorUnits, evaluateProductReadiness, isZeroDecimalCurrency, minorUnitsPerMajor } from '@solvapay/core';
|
|
5
5
|
|
|
@@ -1500,6 +1500,11 @@ interface BuildPayableHandlerContext {
|
|
|
1500
1500
|
* events are attributable to a tool.
|
|
1501
1501
|
*/
|
|
1502
1502
|
toolName?: string;
|
|
1503
|
+
/**
|
|
1504
|
+
* SDK-only free-tool allowance. When set, the paywall kernel counts
|
|
1505
|
+
* against this free meter instead of the plan meter.
|
|
1506
|
+
*/
|
|
1507
|
+
freeLimit?: FreeLimit;
|
|
1503
1508
|
}
|
|
1504
1509
|
/**
|
|
1505
1510
|
* Merchant handler contract: `(args, ctx) => ctx.respond(data, options?)`.
|
package/dist/index.js
CHANGED
|
@@ -1991,7 +1991,7 @@ function snapshotFromLimits(params) {
|
|
|
1991
1991
|
};
|
|
1992
1992
|
}
|
|
1993
1993
|
function buildResponseContext(params) {
|
|
1994
|
-
const { customerRef, limits, product, bootstrapProduct, solvaPay } = params;
|
|
1994
|
+
const { customerRef, limits, product, bootstrapProduct, solvaPay, freeLimit } = params;
|
|
1995
1995
|
const bootstrapPlan = params.bootstrapPlan ?? synthesizePlanStub(limits);
|
|
1996
1996
|
const emittedBlocks = [];
|
|
1997
1997
|
const abortController = new AbortController();
|
|
@@ -1999,7 +1999,8 @@ function buildResponseContext(params) {
|
|
|
1999
1999
|
const freshLimits = await solvaPay.checkLimits({
|
|
2000
2000
|
customerRef,
|
|
2001
2001
|
productRef: product,
|
|
2002
|
-
meterName: "requests"
|
|
2002
|
+
meterName: freeLimit?.meter ?? "requests",
|
|
2003
|
+
...freeLimit ? { freeAllowance: freeLimit } : {}
|
|
2003
2004
|
});
|
|
2004
2005
|
return snapshotFromLimits({
|
|
2005
2006
|
customerRef,
|
|
@@ -2053,7 +2054,7 @@ function buildResponseContext(params) {
|
|
|
2053
2054
|
|
|
2054
2055
|
// src/payable-handler.ts
|
|
2055
2056
|
function buildPayableHandler(solvaPay, ctx, handler) {
|
|
2056
|
-
const { product, getCustomerRef, toolName } = ctx;
|
|
2057
|
+
const { product, getCustomerRef, toolName, freeLimit } = ctx;
|
|
2057
2058
|
const wrappedBusinessLogic = async (args, handlerContext) => {
|
|
2058
2059
|
const limits = handlerContext?.limits ?? null;
|
|
2059
2060
|
const customerRef = handlerContext?.customerRef ?? "";
|
|
@@ -2061,11 +2062,17 @@ function buildPayableHandler(solvaPay, ctx, handler) {
|
|
|
2061
2062
|
customerRef,
|
|
2062
2063
|
limits,
|
|
2063
2064
|
product,
|
|
2064
|
-
solvaPay
|
|
2065
|
+
solvaPay,
|
|
2066
|
+
...freeLimit ? { freeLimit } : {}
|
|
2065
2067
|
});
|
|
2066
2068
|
return handler(args, responseCtx);
|
|
2067
2069
|
};
|
|
2068
|
-
const protectedHandler = solvaPay.payable({
|
|
2070
|
+
const protectedHandler = solvaPay.payable({
|
|
2071
|
+
product,
|
|
2072
|
+
getCustomerRef,
|
|
2073
|
+
...toolName ? { toolName } : {},
|
|
2074
|
+
...freeLimit ? { freeLimit } : {}
|
|
2075
|
+
}).mcp(wrappedBusinessLogic);
|
|
2069
2076
|
return async (args, extra) => {
|
|
2070
2077
|
const result = await protectedHandler(args, extra);
|
|
2071
2078
|
if (isPaywallStructuredContent(result.structuredContent)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solvapay/mcp-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Framework-neutral MCP contracts for the SolvaPay SDK (tool names, descriptors, payable handler, paywall meta, CSP, bootstrap payload, OAuth discovery JSON builders, bearer/JWT helpers).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"vitest": "^4.1.2",
|
|
43
43
|
"zod": "^4.3.6",
|
|
44
|
-
"@solvapay/server": "2.
|
|
44
|
+
"@solvapay/server": "2.8.0",
|
|
45
45
|
"@solvapay/test-utils": "^0.0.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|