@solvapay/server 2.8.0 → 2.9.0-preview-0b7998345be4ea7f15666fa77c72ea02a914ea65
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 +22 -92
- package/dist/edge.js +1 -12
- package/dist/fetch/index.cjs +1 -12
- package/dist/fetch/index.d.cts +11 -77
- package/dist/fetch/index.d.ts +11 -77
- package/dist/fetch/index.js +1 -12
- package/dist/index.cjs +1 -12
- package/dist/index.d.cts +22 -92
- package/dist/index.d.ts +22 -92
- package/dist/index.js +1 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -320,12 +320,9 @@ interface components {
|
|
|
320
320
|
label?: string;
|
|
321
321
|
meter: string;
|
|
322
322
|
/** @enum {string} */
|
|
323
|
-
onExceed: 'block' | '
|
|
324
|
-
onExceedPricingId?: string;
|
|
323
|
+
onExceed: 'block' | 'top_up';
|
|
325
324
|
/** @enum {string} */
|
|
326
325
|
scope: 'billing_period' | 'lifetime' | 'rolling_window';
|
|
327
|
-
/** @enum {string} */
|
|
328
|
-
uiHint?: 'upgrade_prompt' | 'soft_warning';
|
|
329
326
|
windowDays?: number;
|
|
330
327
|
} | {
|
|
331
328
|
feature: string;
|
|
@@ -336,12 +333,11 @@ interface components {
|
|
|
336
333
|
value: boolean | number | string;
|
|
337
334
|
} | {
|
|
338
335
|
days: number;
|
|
339
|
-
downgradeToPricingId?: string;
|
|
340
336
|
/** @enum {string} */
|
|
341
337
|
kind: 'trial';
|
|
342
338
|
label?: string;
|
|
343
339
|
/** @enum {string} */
|
|
344
|
-
onEnd: 'convert' | 'cancel'
|
|
340
|
+
onEnd: 'convert' | 'cancel';
|
|
345
341
|
} | {
|
|
346
342
|
/** @enum {string} */
|
|
347
343
|
appliesTo?: 'recurring' | 'setup' | 'usage' | 'all';
|
|
@@ -355,17 +351,6 @@ interface components {
|
|
|
355
351
|
/** @enum {string} */
|
|
356
352
|
mode: 'percentage' | 'fixed';
|
|
357
353
|
value: number;
|
|
358
|
-
} | {
|
|
359
|
-
capUnits?: number;
|
|
360
|
-
currency?: string;
|
|
361
|
-
/** @enum {string} */
|
|
362
|
-
kind: 'rollover';
|
|
363
|
-
label?: string;
|
|
364
|
-
maxCycles?: number;
|
|
365
|
-
meter: string;
|
|
366
|
-
rateMinor?: number;
|
|
367
|
-
/** @enum {string} */
|
|
368
|
-
treatment: 'forfeit' | 'carry_forward' | 'credit_units' | 'credit_money';
|
|
369
354
|
} | {
|
|
370
355
|
/** @enum {string} */
|
|
371
356
|
kind: 'autoAssigned';
|
|
@@ -516,12 +501,9 @@ interface components {
|
|
|
516
501
|
label?: string;
|
|
517
502
|
meter: string;
|
|
518
503
|
/** @enum {string} */
|
|
519
|
-
onExceed: 'block' | '
|
|
520
|
-
onExceedPricingId?: string;
|
|
504
|
+
onExceed: 'block' | 'top_up';
|
|
521
505
|
/** @enum {string} */
|
|
522
506
|
scope: 'billing_period' | 'lifetime' | 'rolling_window';
|
|
523
|
-
/** @enum {string} */
|
|
524
|
-
uiHint?: 'upgrade_prompt' | 'soft_warning';
|
|
525
507
|
windowDays?: number;
|
|
526
508
|
} | {
|
|
527
509
|
feature: string;
|
|
@@ -532,12 +514,11 @@ interface components {
|
|
|
532
514
|
value: boolean | number | string;
|
|
533
515
|
} | {
|
|
534
516
|
days: number;
|
|
535
|
-
downgradeToPricingId?: string;
|
|
536
517
|
/** @enum {string} */
|
|
537
518
|
kind: 'trial';
|
|
538
519
|
label?: string;
|
|
539
520
|
/** @enum {string} */
|
|
540
|
-
onEnd: 'convert' | 'cancel'
|
|
521
|
+
onEnd: 'convert' | 'cancel';
|
|
541
522
|
} | {
|
|
542
523
|
/** @enum {string} */
|
|
543
524
|
appliesTo?: 'recurring' | 'setup' | 'usage' | 'all';
|
|
@@ -551,17 +532,6 @@ interface components {
|
|
|
551
532
|
/** @enum {string} */
|
|
552
533
|
mode: 'percentage' | 'fixed';
|
|
553
534
|
value: number;
|
|
554
|
-
} | {
|
|
555
|
-
capUnits?: number;
|
|
556
|
-
currency?: string;
|
|
557
|
-
/** @enum {string} */
|
|
558
|
-
kind: 'rollover';
|
|
559
|
-
label?: string;
|
|
560
|
-
maxCycles?: number;
|
|
561
|
-
meter: string;
|
|
562
|
-
rateMinor?: number;
|
|
563
|
-
/** @enum {string} */
|
|
564
|
-
treatment: 'forfeit' | 'carry_forward' | 'credit_units' | 'credit_money';
|
|
565
535
|
} | {
|
|
566
536
|
/** @enum {string} */
|
|
567
537
|
kind: 'autoAssigned';
|
|
@@ -664,7 +634,7 @@ interface components {
|
|
|
664
634
|
* @example duplicate
|
|
665
635
|
* @enum {string}
|
|
666
636
|
*/
|
|
667
|
-
reason: 'duplicate' | 'no_product_ref' | 'customer_not_found' | 'no_active_purchase' | 'plan_not_credit_based' | '
|
|
637
|
+
reason: 'duplicate' | 'no_product_ref' | 'customer_not_found' | 'no_active_purchase' | 'plan_not_credit_based' | 'not_credit_drawn' | 'within_included';
|
|
668
638
|
};
|
|
669
639
|
CreditDebitSuccessResponse: {
|
|
670
640
|
/**
|
|
@@ -908,11 +878,9 @@ interface components {
|
|
|
908
878
|
* @example requests
|
|
909
879
|
*/
|
|
910
880
|
meterName?: string;
|
|
911
|
-
/** @description Access is blocked
|
|
881
|
+
/** @description Access is blocked until prepaid credits cover the next unit — past an included cap with `onExceed: top_up`, or from the first unit on a recurring meter with no limit. */
|
|
912
882
|
needsTopUp?: boolean;
|
|
913
|
-
/** @description Access is
|
|
914
|
-
needsUpgrade?: boolean;
|
|
915
|
-
/** @description Access is granted and usage beyond the included cap accrues an overage charge — `onExceed: charge`. */
|
|
883
|
+
/** @description Access is granted past the included cap and the usage is paid from prepaid credits — `onExceed: top_up`. */
|
|
916
884
|
overage?: boolean;
|
|
917
885
|
/**
|
|
918
886
|
* Authoritative paywall classification shared with Managed MCP. Present on denial responses only.
|
|
@@ -934,10 +902,6 @@ interface components {
|
|
|
934
902
|
* @example 997
|
|
935
903
|
*/
|
|
936
904
|
remaining: number;
|
|
937
|
-
/** @description Access is granted but the caller should degrade/throttle service — the limit was exceeded with `onExceed: throttle`. */
|
|
938
|
-
throttled?: boolean;
|
|
939
|
-
/** @description The customer was auto-upgraded to the target pricing to restore access — `onExceed: auto_upgrade` succeeded. */
|
|
940
|
-
upgraded?: boolean;
|
|
941
905
|
/** @description Consumed usage units this period. Present only when the backend measured a finite cap. */
|
|
942
906
|
used?: number;
|
|
943
907
|
/**
|
|
@@ -1005,12 +969,9 @@ interface components {
|
|
|
1005
969
|
label?: string;
|
|
1006
970
|
meter: string;
|
|
1007
971
|
/** @enum {string} */
|
|
1008
|
-
onExceed: 'block' | '
|
|
1009
|
-
onExceedPricingId?: string;
|
|
972
|
+
onExceed: 'block' | 'top_up';
|
|
1010
973
|
/** @enum {string} */
|
|
1011
974
|
scope: 'billing_period' | 'lifetime' | 'rolling_window';
|
|
1012
|
-
/** @enum {string} */
|
|
1013
|
-
uiHint?: 'upgrade_prompt' | 'soft_warning';
|
|
1014
975
|
windowDays?: number;
|
|
1015
976
|
} | {
|
|
1016
977
|
feature: string;
|
|
@@ -1021,12 +982,11 @@ interface components {
|
|
|
1021
982
|
value: boolean | number | string;
|
|
1022
983
|
} | {
|
|
1023
984
|
days: number;
|
|
1024
|
-
downgradeToPricingId?: string;
|
|
1025
985
|
/** @enum {string} */
|
|
1026
986
|
kind: 'trial';
|
|
1027
987
|
label?: string;
|
|
1028
988
|
/** @enum {string} */
|
|
1029
|
-
onEnd: 'convert' | 'cancel'
|
|
989
|
+
onEnd: 'convert' | 'cancel';
|
|
1030
990
|
} | {
|
|
1031
991
|
/** @enum {string} */
|
|
1032
992
|
appliesTo?: 'recurring' | 'setup' | 'usage' | 'all';
|
|
@@ -1040,17 +1000,6 @@ interface components {
|
|
|
1040
1000
|
/** @enum {string} */
|
|
1041
1001
|
mode: 'percentage' | 'fixed';
|
|
1042
1002
|
value: number;
|
|
1043
|
-
} | {
|
|
1044
|
-
capUnits?: number;
|
|
1045
|
-
currency?: string;
|
|
1046
|
-
/** @enum {string} */
|
|
1047
|
-
kind: 'rollover';
|
|
1048
|
-
label?: string;
|
|
1049
|
-
maxCycles?: number;
|
|
1050
|
-
meter: string;
|
|
1051
|
-
rateMinor?: number;
|
|
1052
|
-
/** @enum {string} */
|
|
1053
|
-
treatment: 'forfeit' | 'carry_forward' | 'credit_units' | 'credit_money';
|
|
1054
1003
|
} | {
|
|
1055
1004
|
/** @enum {string} */
|
|
1056
1005
|
kind: 'autoAssigned';
|
|
@@ -1921,12 +1870,9 @@ interface components {
|
|
|
1921
1870
|
label?: string;
|
|
1922
1871
|
meter: string;
|
|
1923
1872
|
/** @enum {string} */
|
|
1924
|
-
onExceed: 'block' | '
|
|
1925
|
-
onExceedPricingId?: string;
|
|
1873
|
+
onExceed: 'block' | 'top_up';
|
|
1926
1874
|
/** @enum {string} */
|
|
1927
1875
|
scope: 'billing_period' | 'lifetime' | 'rolling_window';
|
|
1928
|
-
/** @enum {string} */
|
|
1929
|
-
uiHint?: 'upgrade_prompt' | 'soft_warning';
|
|
1930
1876
|
windowDays?: number;
|
|
1931
1877
|
} | {
|
|
1932
1878
|
feature: string;
|
|
@@ -1937,12 +1883,11 @@ interface components {
|
|
|
1937
1883
|
value: boolean | number | string;
|
|
1938
1884
|
} | {
|
|
1939
1885
|
days: number;
|
|
1940
|
-
downgradeToPricingId?: string;
|
|
1941
1886
|
/** @enum {string} */
|
|
1942
1887
|
kind: 'trial';
|
|
1943
1888
|
label?: string;
|
|
1944
1889
|
/** @enum {string} */
|
|
1945
|
-
onEnd: 'convert' | 'cancel'
|
|
1890
|
+
onEnd: 'convert' | 'cancel';
|
|
1946
1891
|
} | {
|
|
1947
1892
|
/** @enum {string} */
|
|
1948
1893
|
appliesTo?: 'recurring' | 'setup' | 'usage' | 'all';
|
|
@@ -1956,17 +1901,6 @@ interface components {
|
|
|
1956
1901
|
/** @enum {string} */
|
|
1957
1902
|
mode: 'percentage' | 'fixed';
|
|
1958
1903
|
value: number;
|
|
1959
|
-
} | {
|
|
1960
|
-
capUnits?: number;
|
|
1961
|
-
currency?: string;
|
|
1962
|
-
/** @enum {string} */
|
|
1963
|
-
kind: 'rollover';
|
|
1964
|
-
label?: string;
|
|
1965
|
-
maxCycles?: number;
|
|
1966
|
-
meter: string;
|
|
1967
|
-
rateMinor?: number;
|
|
1968
|
-
/** @enum {string} */
|
|
1969
|
-
treatment: 'forfeit' | 'carry_forward' | 'credit_units' | 'credit_money';
|
|
1970
1904
|
} | {
|
|
1971
1905
|
/** @enum {string} */
|
|
1972
1906
|
kind: 'autoAssigned';
|
|
@@ -3941,12 +3875,11 @@ type FreeLimit = Required<Omit<GeneratedFreeAllowance, 'windowDays'>> & Pick<Gen
|
|
|
3941
3875
|
/**
|
|
3942
3876
|
* `LimitResponse` plus a deprecated SDK-only `plan` alias.
|
|
3943
3877
|
*
|
|
3944
|
-
* The backend `LimitResponse`
|
|
3945
|
-
* (`
|
|
3946
|
-
*
|
|
3947
|
-
*
|
|
3948
|
-
*
|
|
3949
|
-
* others accompany a gate outcome.
|
|
3878
|
+
* The backend `LimitResponse` carries the `onExceed` outcome flags
|
|
3879
|
+
* (`overage` / `needsTopUp`, resolved by `decideLimit`), so they flow
|
|
3880
|
+
* through from `generated.ts`. `overage` rides the allow path
|
|
3881
|
+
* (`withinLimits: true`) so a protected handler can read it from
|
|
3882
|
+
* `decision.limits`; `needsTopUp` accompanies a gate outcome.
|
|
3950
3883
|
*
|
|
3951
3884
|
* Read `planRef` for the active plan. `plan` is never populated by the
|
|
3952
3885
|
* backend — it remains optional so older fixtures and callers still type-check.
|
|
@@ -4397,13 +4330,11 @@ type PaywallDecision<T> = {
|
|
|
4397
4330
|
limits: LimitResponseWithPlan;
|
|
4398
4331
|
customerRef: string;
|
|
4399
4332
|
/**
|
|
4400
|
-
* Set when access is granted
|
|
4401
|
-
* `onExceed:
|
|
4402
|
-
*
|
|
4403
|
-
* cap. Absent on a plain allow. Derived from `limits`; not new
|
|
4404
|
-
* wire data.
|
|
4333
|
+
* Set when access is granted past the included cap and the usage
|
|
4334
|
+
* is paid from prepaid credits (`onExceed: top_up`). Absent on a
|
|
4335
|
+
* plain allow. Derived from `limits`; not new wire data.
|
|
4405
4336
|
*/
|
|
4406
|
-
consequence?: '
|
|
4337
|
+
consequence?: 'overage';
|
|
4407
4338
|
/**
|
|
4408
4339
|
* Id minted by `decide()` and reused by `runAllow()` so success /
|
|
4409
4340
|
* fail tracking shares one idempotency key with the decision.
|
|
@@ -5056,8 +4987,7 @@ interface SolvaPay {
|
|
|
5056
4987
|
* @param params.customerRef - Customer reference
|
|
5057
4988
|
* @param params.productRef - Product reference
|
|
5058
4989
|
* @returns Full `LimitResponseWithPlan`, including the `onExceed` outcome
|
|
5059
|
-
* flags (`
|
|
5060
|
-
* `upgraded`) the backend already sends on `/v1/sdk/limits`
|
|
4990
|
+
* flags (`overage` / `needsTopUp`) the backend sends on `/v1/sdk/limits`
|
|
5061
4991
|
*
|
|
5062
4992
|
* @example
|
|
5063
4993
|
* ```typescript
|
|
@@ -5755,7 +5685,7 @@ declare function nextActionFor(state: PaywallState): PaywallNextAction;
|
|
|
5755
5685
|
* (no purchaseRef / planRef) must not fall through to upgrade_required.
|
|
5756
5686
|
* 3. `paywallReason === 'topup_required'` — backend stays authoritative
|
|
5757
5687
|
* for credit-based denials (same rule as Managed MCP).
|
|
5758
|
-
* 3. Authoritative `needsTopUp`
|
|
5688
|
+
* 3. Authoritative `needsTopUp` flag from `decideLimit`.
|
|
5759
5689
|
* 4. Credit-field presence + a real shortfall (`balance < cost`).
|
|
5760
5690
|
* 5. Active purchase / plan at included cap → `limit_reached`.
|
|
5761
5691
|
* 6. Floor: never `upgrade_required` when credit fields or a purchase
|
package/dist/index.js
CHANGED
|
@@ -684,9 +684,6 @@ function classifyPaywallState(limits) {
|
|
|
684
684
|
if (limits.needsTopUp === true) {
|
|
685
685
|
return { kind: "topup_required" };
|
|
686
686
|
}
|
|
687
|
-
if (limits.needsUpgrade === true) {
|
|
688
|
-
return { kind: "upgrade_required" };
|
|
689
|
-
}
|
|
690
687
|
const signals = creditSignals(limits);
|
|
691
688
|
if (signals.isCreditBased) {
|
|
692
689
|
if (signals.creditBalance !== void 0 && signals.creditsPerCall !== void 0 && signals.creditBalance < signals.creditsPerCall) {
|
|
@@ -814,14 +811,6 @@ function buildGateMessage(state, gate) {
|
|
|
814
811
|
return `${lead}${topup}${auto}${switchLine}`;
|
|
815
812
|
}
|
|
816
813
|
case "upgrade_required": {
|
|
817
|
-
if (hasActivePlan(gate)) {
|
|
818
|
-
const planName = gate.planName ?? "This plan";
|
|
819
|
-
const lead = `${planName} is active but its included usage is exhausted, and the automatic switch to the next plan did not complete.`;
|
|
820
|
-
if (ladder) {
|
|
821
|
-
return `${lead} Switch here: ${ladder}. ${callViewer("account").replace(/^c/, "C")} for usage and recovery.`;
|
|
822
|
-
}
|
|
823
|
-
return `${lead}${recoverClause(url, "switch plan", "checkout")}`;
|
|
824
|
-
}
|
|
825
814
|
if (ladder) {
|
|
826
815
|
return `You don't have an active plan for this tool. Pick a plan to use this tool: ${ladder} (links expire in ${CHECKOUT_SESSION_TTL_MINUTES} minutes), or ${callViewer("checkout")}. ${callViewer("account").replace(/^c/, "C")} for usage and recovery.`;
|
|
827
816
|
}
|
|
@@ -1361,7 +1350,7 @@ var SolvaPayPaywall = class {
|
|
|
1361
1350
|
requestId
|
|
1362
1351
|
};
|
|
1363
1352
|
}
|
|
1364
|
-
const consequence = lastLimitsCheck.
|
|
1353
|
+
const consequence = lastLimitsCheck.overage ? "overage" : void 0;
|
|
1365
1354
|
return {
|
|
1366
1355
|
outcome: "allow",
|
|
1367
1356
|
args,
|