@mesub/node 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +840 -2
- package/dist/chunk-43Q4PNF7.cjs +480 -0
- package/dist/chunk-43Q4PNF7.cjs.map +1 -0
- package/dist/chunk-4AAPR37Y.js +120 -0
- package/dist/chunk-4AAPR37Y.js.map +1 -0
- package/dist/chunk-4JSJOX35.cjs +2040 -0
- package/dist/chunk-4JSJOX35.cjs.map +1 -0
- package/dist/chunk-66VVEXMU.cjs +340 -0
- package/dist/chunk-66VVEXMU.cjs.map +1 -0
- package/dist/chunk-J2CE4QWV.js +340 -0
- package/dist/chunk-J2CE4QWV.js.map +1 -0
- package/dist/chunk-JJWHMB2X.js +480 -0
- package/dist/chunk-JJWHMB2X.js.map +1 -0
- package/dist/chunk-NOS4FWWQ.js +2040 -0
- package/dist/chunk-NOS4FWWQ.js.map +1 -0
- package/dist/chunk-SJRQDWTI.cjs +120 -0
- package/dist/chunk-SJRQDWTI.cjs.map +1 -0
- package/dist/client-BEuDegEY.d.cts +765 -0
- package/dist/client-CXQLkSAJ.d.ts +765 -0
- package/dist/errors-BN4ZWUfM.d.ts +112 -0
- package/dist/errors-DcLfunS-.d.cts +112 -0
- package/dist/express.cjs +129 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.cts +57 -0
- package/dist/express.d.ts +57 -0
- package/dist/express.js +129 -0
- package/dist/express.js.map +1 -0
- package/dist/guard-CaXiHMVF.d.ts +51 -0
- package/dist/guard-D4AB5HtN.d.cts +51 -0
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/nest.cjs +62 -0
- package/dist/nest.cjs.map +1 -0
- package/dist/nest.d.cts +57 -0
- package/dist/nest.d.ts +57 -0
- package/dist/nest.js +62 -0
- package/dist/nest.js.map +1 -0
- package/dist/next.cjs +113 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +63 -0
- package/dist/next.d.ts +63 -0
- package/dist/next.js +113 -0
- package/dist/next.js.map +1 -0
- package/dist/routes-B7wN4sby.d.ts +130 -0
- package/dist/routes-CMzB52P6.d.cts +130 -0
- package/dist/situations.cjs +15 -0
- package/dist/situations.cjs.map +1 -0
- package/dist/situations.d.cts +607 -0
- package/dist/situations.d.ts +607 -0
- package/dist/situations.js +15 -0
- package/dist/situations.js.map +1 -0
- package/dist/subscriptions-B6Lin6i_.d.cts +775 -0
- package/dist/subscriptions-B6Lin6i_.d.ts +775 -0
- package/dist/testing.cjs +1488 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +331 -0
- package/dist/testing.d.ts +331 -0
- package/dist/testing.js +1488 -0
- package/dist/testing.js.map +1 -0
- package/package.json +158 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk43Q4PNF7cjs = require('./chunk-43Q4PNF7.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.ACCESS_LINE = _chunk43Q4PNF7cjs.ACCESS_LINE; exports.CONFIRMATIONS = _chunk43Q4PNF7cjs.CONFIRMATIONS; exports.SITUATIONS = _chunk43Q4PNF7cjs.SITUATIONS; exports.explain = _chunk43Q4PNF7cjs.explain; exports.situationOf = _chunk43Q4PNF7cjs.situationOf;
|
|
15
|
+
//# sourceMappingURL=situations.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/node-sdk/node-sdk/dist/situations.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,kQAAC","file":"/home/runner/work/node-sdk/node-sdk/dist/situations.cjs"}
|
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import { A as AccessAnswer, j as ServerSubscription } from './subscriptions-B6Lin6i_.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One sentence per subscription situation, for the subscriber and for the
|
|
5
|
+
* merchant, and what each of them can do about it: the canonical wording of
|
|
6
|
+
* 2026-10-05, agreed with the backend. Show these instead of writing your
|
|
7
|
+
* own: hand-written ones drift, and some are false ("add funds" on a removed
|
|
8
|
+
* approval, "nothing more is charged" on a stopped subscription).
|
|
9
|
+
*
|
|
10
|
+
* Browser-safe: this module imports types only, so `@mesub/node/situations`
|
|
11
|
+
* loads in a page, a widget or a docs site with nothing of Node.
|
|
12
|
+
*
|
|
13
|
+
* Templates carry `{placeholders}`. A `[segment]` holds a placeholder `/v1`
|
|
14
|
+
* does not always serve: it is shown when every placeholder in it has a
|
|
15
|
+
* value, and left out otherwise, so the sentence stays true without it.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Who acts. */
|
|
19
|
+
type SituationActor = 'subscriber' | 'merchant';
|
|
20
|
+
/**
|
|
21
|
+
* What can be done. `add_funds` has no route (the wallet does it).
|
|
22
|
+
* `transaction` hands a pending checkout a fresh transaction to sign
|
|
23
|
+
* (`subscriptions.transaction`, Mesub-io/backend#427). `retry` is
|
|
24
|
+
* the subscriber's "Pay now" with the API key (`subscriptions.retry`,
|
|
25
|
+
* Mesub-io/backend#354), and the merchant's on the Mesub dashboard; `upgrade`
|
|
26
|
+
* exists on the dashboard only.
|
|
27
|
+
*/
|
|
28
|
+
type SituationActionId = 'subscribe' | 'transaction' | 'submit' | 'cancel' | 'resume' | 'close' | 'add_funds' | 'retry' | 'upgrade' | 'retrieve' | 'list';
|
|
29
|
+
/** One action of a situation, as the table lists it. */
|
|
30
|
+
interface SituationActionTemplate {
|
|
31
|
+
readonly by: SituationActor;
|
|
32
|
+
readonly action: SituationActionId;
|
|
33
|
+
/** The method of `@mesub/node`, when there is one: `subscriptions.cancel`, … */
|
|
34
|
+
readonly sdk?: string;
|
|
35
|
+
/** The API route behind it. */
|
|
36
|
+
readonly route?: string;
|
|
37
|
+
/** On the Mesub dashboard only: an API key cannot call it. */
|
|
38
|
+
readonly dashboard?: true;
|
|
39
|
+
/** The sentence to show before the subscriber signs it, a key of `CONFIRMATIONS`. */
|
|
40
|
+
readonly confirm?: ConfirmationKey;
|
|
41
|
+
/** Only while the date in this field of the subscription is ahead. */
|
|
42
|
+
readonly until?: 'access_until' | 'retry_deadline';
|
|
43
|
+
/**
|
|
44
|
+
* Only while the subscription is `closable` (Mesub-io/backend#402): left
|
|
45
|
+
* out where Mesub says `closable: false`, its `closable_from` in the
|
|
46
|
+
* sentence when a date is known.
|
|
47
|
+
*/
|
|
48
|
+
readonly when?: 'closable';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A sentence, or one per tier where the canonical sentence names both:
|
|
52
|
+
* `retries` for Dev and Business (Mesub retries on its own), `free` for Free
|
|
53
|
+
* (hand retries until `retry_deadline`).
|
|
54
|
+
*/
|
|
55
|
+
type SituationText = string | {
|
|
56
|
+
readonly retries: string;
|
|
57
|
+
readonly free: string;
|
|
58
|
+
};
|
|
59
|
+
interface Situation {
|
|
60
|
+
readonly subscriber: SituationText;
|
|
61
|
+
readonly merchant: SituationText;
|
|
62
|
+
readonly actions: readonly SituationActionTemplate[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The canonical table, by situation key. The renewal checks
|
|
66
|
+
* (`active_renewal_*`) are left out: Mesub serves them on its dashboard
|
|
67
|
+
* only, never on `/v1`.
|
|
68
|
+
*/
|
|
69
|
+
declare const SITUATIONS: {
|
|
70
|
+
readonly none: {
|
|
71
|
+
readonly subscriber: "You are not subscribed to {plan_name}.";
|
|
72
|
+
readonly merchant: "This customer has no subscription to {plan_name}.";
|
|
73
|
+
readonly actions: readonly [{
|
|
74
|
+
readonly by: "subscriber";
|
|
75
|
+
readonly action: "subscribe";
|
|
76
|
+
readonly sdk: "subscriptions.create";
|
|
77
|
+
readonly route: "POST /v1/subscriptions";
|
|
78
|
+
}];
|
|
79
|
+
};
|
|
80
|
+
readonly active: {
|
|
81
|
+
readonly subscriber: "Active. Your next payment of {amount} is on {next_charge_at}.";
|
|
82
|
+
readonly merchant: "Active and paid up. Next payment of {amount} on {next_charge_at}.";
|
|
83
|
+
readonly actions: readonly [{
|
|
84
|
+
readonly confirm: "confirm_cancel_paid";
|
|
85
|
+
readonly by: "subscriber";
|
|
86
|
+
readonly action: "cancel";
|
|
87
|
+
readonly sdk: "subscriptions.cancel";
|
|
88
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
89
|
+
}];
|
|
90
|
+
};
|
|
91
|
+
readonly active_last_period: {
|
|
92
|
+
readonly subscriber: "Active until {access_until}: {plan_name} is ending, and no further payment will be taken.";
|
|
93
|
+
readonly merchant: "Active and paid up, in its last period: the plan is ending, so no further payment is taken. Access ends on {access_until}.";
|
|
94
|
+
readonly actions: readonly [{
|
|
95
|
+
readonly confirm: "confirm_cancel_paid";
|
|
96
|
+
readonly by: "subscriber";
|
|
97
|
+
readonly action: "cancel";
|
|
98
|
+
readonly sdk: "subscriptions.cancel";
|
|
99
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
100
|
+
}];
|
|
101
|
+
};
|
|
102
|
+
readonly active_unbilled: {
|
|
103
|
+
readonly subscriber: "Active until {access_until}. No further payment is scheduled.";
|
|
104
|
+
readonly merchant: "Not billed: this subscription's terms were never signed through Mesub, so Mesub never takes a payment for it. Access ends on {access_until}.";
|
|
105
|
+
readonly actions: readonly [];
|
|
106
|
+
};
|
|
107
|
+
readonly unpaid_last_period: {
|
|
108
|
+
readonly subscriber: "Your payment of {amount} is late, and Mesub will not try again on its own: {plan_name} is ending. You keep access until {access_until}.";
|
|
109
|
+
readonly merchant: "Payment late, with no retry ahead: the plan ends before the next one. Access continues until {access_until}, and the subscription ends with the plan.";
|
|
110
|
+
readonly actions: readonly [{
|
|
111
|
+
readonly by: "subscriber";
|
|
112
|
+
readonly action: "retry";
|
|
113
|
+
readonly sdk: "subscriptions.retry";
|
|
114
|
+
readonly route: "POST /v1/subscriptions/:id/retry";
|
|
115
|
+
}, {
|
|
116
|
+
readonly confirm: "confirm_cancel_behind";
|
|
117
|
+
readonly by: "subscriber";
|
|
118
|
+
readonly action: "cancel";
|
|
119
|
+
readonly sdk: "subscriptions.cancel";
|
|
120
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
121
|
+
}, {
|
|
122
|
+
readonly by: "merchant";
|
|
123
|
+
readonly action: "retry";
|
|
124
|
+
readonly route: "POST /merchant/subscriptions/:id/retry";
|
|
125
|
+
readonly dashboard: true;
|
|
126
|
+
}];
|
|
127
|
+
};
|
|
128
|
+
readonly unpaid_insufficient_balance_retries: {
|
|
129
|
+
readonly subscriber: "Your payment of {amount} is late because your wallet held too little, and nothing was taken. Add {amount} to your wallet, then pay it now, with nothing to sign; otherwise Mesub tries again on {next_retry_at}. Your subscription stops if no payment goes through by {access_until}.";
|
|
130
|
+
readonly merchant: "Payment late: the wallet was short. Retry[ {next_retry_number} of {retries_allowed}] on {next_retry_at}, or sooner by hand, yours or the subscriber's. Access continues until {access_until}; the subscription stops then if every retry fails.";
|
|
131
|
+
readonly actions: readonly [{
|
|
132
|
+
readonly by: "subscriber";
|
|
133
|
+
readonly action: "add_funds";
|
|
134
|
+
}, {
|
|
135
|
+
readonly by: "subscriber";
|
|
136
|
+
readonly action: "retry";
|
|
137
|
+
readonly sdk: "subscriptions.retry";
|
|
138
|
+
readonly route: "POST /v1/subscriptions/:id/retry";
|
|
139
|
+
}, {
|
|
140
|
+
readonly confirm: "confirm_cancel_behind";
|
|
141
|
+
readonly by: "subscriber";
|
|
142
|
+
readonly action: "cancel";
|
|
143
|
+
readonly sdk: "subscriptions.cancel";
|
|
144
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
145
|
+
}, {
|
|
146
|
+
readonly by: "merchant";
|
|
147
|
+
readonly action: "retry";
|
|
148
|
+
readonly route: "POST /merchant/subscriptions/:id/retry";
|
|
149
|
+
readonly dashboard: true;
|
|
150
|
+
}];
|
|
151
|
+
};
|
|
152
|
+
readonly unpaid_insufficient_balance_free: {
|
|
153
|
+
readonly subscriber: "Your payment of {amount} is late because your wallet held too little, so your access is off. Add {amount} to your wallet, then pay it now, with nothing to sign, before {retry_deadline}; if no payment goes through by then, the subscription stops.";
|
|
154
|
+
readonly merchant: "Payment late: the wallet was short. On Free, Mesub does not retry on its own: you or the subscriber can retry by hand, up to 3 times between you, 10 minutes apart, until {retry_deadline}. Access is off meanwhile, and it stops after that.";
|
|
155
|
+
readonly actions: readonly [{
|
|
156
|
+
readonly by: "subscriber";
|
|
157
|
+
readonly action: "add_funds";
|
|
158
|
+
}, {
|
|
159
|
+
readonly until: "retry_deadline";
|
|
160
|
+
readonly by: "subscriber";
|
|
161
|
+
readonly action: "retry";
|
|
162
|
+
readonly sdk: "subscriptions.retry";
|
|
163
|
+
readonly route: "POST /v1/subscriptions/:id/retry";
|
|
164
|
+
}, {
|
|
165
|
+
readonly confirm: "confirm_cancel_behind";
|
|
166
|
+
readonly by: "subscriber";
|
|
167
|
+
readonly action: "cancel";
|
|
168
|
+
readonly sdk: "subscriptions.cancel";
|
|
169
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
170
|
+
}, {
|
|
171
|
+
readonly until: "retry_deadline";
|
|
172
|
+
readonly by: "merchant";
|
|
173
|
+
readonly action: "retry";
|
|
174
|
+
readonly route: "POST /merchant/subscriptions/:id/retry";
|
|
175
|
+
readonly dashboard: true;
|
|
176
|
+
}];
|
|
177
|
+
};
|
|
178
|
+
readonly unpaid_approval_revoked: {
|
|
179
|
+
readonly subscriber: "Mesub could not take your payment of {amount}: your wallet no longer approves it (the approval was removed, or replaced by another app's). Adding funds will not fix this, and removing the approval did not cancel the subscription: Cancel it if you want to stop.";
|
|
180
|
+
readonly merchant: {
|
|
181
|
+
readonly retries: "Payment late: the subscriber's wallet no longer approves Mesub (removed in the wallet, or replaced by another app's approval). Every retry fails until it is back, and no Mesub route restores it today. It stops on {access_until}.";
|
|
182
|
+
readonly free: "Payment late: the subscriber's wallet no longer approves Mesub (removed in the wallet, or replaced by another app's approval). Every retry fails until it is back, and no Mesub route restores it today. It stops at {retry_deadline}.";
|
|
183
|
+
};
|
|
184
|
+
readonly actions: readonly [{
|
|
185
|
+
readonly confirm: "confirm_cancel_behind";
|
|
186
|
+
readonly by: "subscriber";
|
|
187
|
+
readonly action: "cancel";
|
|
188
|
+
readonly sdk: "subscriptions.cancel";
|
|
189
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
190
|
+
}];
|
|
191
|
+
};
|
|
192
|
+
readonly unpaid_authority_closed: {
|
|
193
|
+
readonly subscriber: "Mesub can no longer take payments for this subscription: your wallet's approval for {token} was closed for good, so adding funds will not help. Cancel it, then close it once its period ends if you want to subscribe again.";
|
|
194
|
+
readonly merchant: {
|
|
195
|
+
readonly retries: "Payment late, for good: the subscriber's subscription authority for {token} was closed (or re-created), so no retry can succeed. It stops on {access_until}, unless the subscriber cancels first.";
|
|
196
|
+
readonly free: "Payment late, for good: the subscriber's subscription authority for {token} was closed (or re-created), so no retry can succeed. It stops at {retry_deadline}, unless the subscriber cancels first.";
|
|
197
|
+
};
|
|
198
|
+
readonly actions: readonly [{
|
|
199
|
+
readonly confirm: "confirm_cancel_behind";
|
|
200
|
+
readonly by: "subscriber";
|
|
201
|
+
readonly action: "cancel";
|
|
202
|
+
readonly sdk: "subscriptions.cancel";
|
|
203
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
204
|
+
}];
|
|
205
|
+
};
|
|
206
|
+
readonly unpaid_unknown: {
|
|
207
|
+
readonly subscriber: "Your wallet refused the payment of {amount}, so nothing was taken. Check that it still holds {amount} in {token} and can send it, then pay it now, or Cancel to stop.";
|
|
208
|
+
readonly merchant: "Payment late: the network refused the payment for a reason Mesub does not name (for example a frozen {token} account). See the last attempt's reason.";
|
|
209
|
+
readonly actions: readonly [{
|
|
210
|
+
readonly by: "subscriber";
|
|
211
|
+
readonly action: "retry";
|
|
212
|
+
readonly sdk: "subscriptions.retry";
|
|
213
|
+
readonly route: "POST /v1/subscriptions/:id/retry";
|
|
214
|
+
}, {
|
|
215
|
+
readonly confirm: "confirm_cancel_behind";
|
|
216
|
+
readonly by: "subscriber";
|
|
217
|
+
readonly action: "cancel";
|
|
218
|
+
readonly sdk: "subscriptions.cancel";
|
|
219
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
220
|
+
}, {
|
|
221
|
+
readonly by: "merchant";
|
|
222
|
+
readonly action: "retry";
|
|
223
|
+
readonly route: "POST /merchant/subscriptions/:id/retry";
|
|
224
|
+
readonly dashboard: true;
|
|
225
|
+
}];
|
|
226
|
+
};
|
|
227
|
+
readonly blocked_mesub: {
|
|
228
|
+
readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of a problem on Mesub's side: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
|
|
229
|
+
readonly merchant: "Payments blocked[ since {blocked_since}] by a problem on Mesub's side: nothing to fix on yours, and none of it is the subscriber's doing. Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
|
|
230
|
+
readonly actions: readonly [{
|
|
231
|
+
readonly by: "subscriber";
|
|
232
|
+
readonly action: "cancel";
|
|
233
|
+
readonly sdk: "subscriptions.cancel";
|
|
234
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
235
|
+
}];
|
|
236
|
+
};
|
|
237
|
+
readonly blocked_puller_not_allowed: {
|
|
238
|
+
readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
|
|
239
|
+
readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: Mesub's puller was taken off the plan on chain, so Mesub can take no payment for it. Add Mesub back to the plan's pullers, with the wallet that owns the plan; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
|
|
240
|
+
readonly actions: readonly [{
|
|
241
|
+
readonly by: "subscriber";
|
|
242
|
+
readonly action: "cancel";
|
|
243
|
+
readonly sdk: "subscriptions.cancel";
|
|
244
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
245
|
+
}];
|
|
246
|
+
};
|
|
247
|
+
readonly blocked_receiver_not_allowed: {
|
|
248
|
+
readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
|
|
249
|
+
readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the wallet that receives its payments is not among the plan's destinations on chain. Choose one that is; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
|
|
250
|
+
readonly actions: readonly [{
|
|
251
|
+
readonly by: "subscriber";
|
|
252
|
+
readonly action: "cancel";
|
|
253
|
+
readonly sdk: "subscriptions.cancel";
|
|
254
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
255
|
+
}];
|
|
256
|
+
};
|
|
257
|
+
readonly blocked_receiver_account_missing: {
|
|
258
|
+
readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
|
|
259
|
+
readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the wallet that receives its payments has no token account for the plan's token, and nobody else on the plan can be paid. Open that account; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
|
|
260
|
+
readonly actions: readonly [{
|
|
261
|
+
readonly by: "subscriber";
|
|
262
|
+
readonly action: "cancel";
|
|
263
|
+
readonly sdk: "subscriptions.cancel";
|
|
264
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
265
|
+
}];
|
|
266
|
+
};
|
|
267
|
+
readonly blocked_receiver_account_frozen: {
|
|
268
|
+
readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
|
|
269
|
+
readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the token account of the wallet that receives its payments is frozen, so it cannot take payments. Choose another receiving wallet, or ask the token's issuer to unfreeze that account; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
|
|
270
|
+
readonly actions: readonly [{
|
|
271
|
+
readonly by: "subscriber";
|
|
272
|
+
readonly action: "cancel";
|
|
273
|
+
readonly sdk: "subscriptions.cancel";
|
|
274
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
275
|
+
}];
|
|
276
|
+
};
|
|
277
|
+
readonly blocked_mint_gone: {
|
|
278
|
+
readonly subscriber: "Mesub can no longer take your payments for {plan_name}: the token it is paid in no longer exists. This is not because of anything you did, and there is nothing for you to do or sign.[ You keep access until {access_until}.] No payment can go through on this plan again, so once access ends it does not come back.";
|
|
279
|
+
readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the plan's token no longer exists on chain, so nothing can be collected on it. Create a new plan with another token.[ Access ends on {access_until}.] No payment can go through on this plan again, so once access ends it does not come back.";
|
|
280
|
+
readonly actions: readonly [{
|
|
281
|
+
readonly by: "subscriber";
|
|
282
|
+
readonly action: "cancel";
|
|
283
|
+
readonly sdk: "subscriptions.cancel";
|
|
284
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
285
|
+
}];
|
|
286
|
+
};
|
|
287
|
+
readonly cancelled_with_access: {
|
|
288
|
+
readonly subscriber: "Cancelled: nothing more will be taken, and you keep access until {access_until}. Resume before then to keep it going.";
|
|
289
|
+
readonly merchant: "Cancelled[ on {cancelled_at}]: access runs until {access_until}, and nothing more will be taken.";
|
|
290
|
+
readonly actions: readonly [{
|
|
291
|
+
readonly confirm: "confirm_resume";
|
|
292
|
+
readonly by: "subscriber";
|
|
293
|
+
readonly action: "resume";
|
|
294
|
+
readonly sdk: "subscriptions.resume";
|
|
295
|
+
readonly route: "POST /v1/subscriptions/:id/resume";
|
|
296
|
+
readonly until: "access_until";
|
|
297
|
+
}];
|
|
298
|
+
};
|
|
299
|
+
readonly cancelled_no_access: {
|
|
300
|
+
readonly subscriber: "Cancelled. Your last payment was missed, so you have no access, and Mesub will not collect it; you can close the subscription[ from {closable_from}] to get your deposit back.";
|
|
301
|
+
readonly merchant: "Cancelled while behind[ on {cancelled_at}]: no access, and Mesub will not collect the missed payment. The subscriber can close it[ from {closable_from}], and must do so before subscribing again.";
|
|
302
|
+
readonly actions: readonly [{
|
|
303
|
+
readonly by: "subscriber";
|
|
304
|
+
readonly action: "close";
|
|
305
|
+
readonly sdk: "subscriptions.close";
|
|
306
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
307
|
+
readonly confirm: "confirm_close";
|
|
308
|
+
readonly when: "closable";
|
|
309
|
+
}];
|
|
310
|
+
};
|
|
311
|
+
readonly cancelled_ended: {
|
|
312
|
+
readonly subscriber: "This subscription has ended. Close it to get your deposit back; you need to close it before subscribing to {plan_name} again.";
|
|
313
|
+
readonly merchant: "Ended by the subscriber's cancellation. Its subscription account stays open until the subscriber closes it, which they must do before subscribing again.";
|
|
314
|
+
readonly actions: readonly [{
|
|
315
|
+
readonly by: "subscriber";
|
|
316
|
+
readonly action: "close";
|
|
317
|
+
readonly sdk: "subscriptions.close";
|
|
318
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
319
|
+
readonly confirm: "confirm_close";
|
|
320
|
+
readonly when: "closable";
|
|
321
|
+
}];
|
|
322
|
+
};
|
|
323
|
+
readonly stopped: {
|
|
324
|
+
readonly subscriber: "Your subscription stopped after missed payments, and your access has ended; Mesub will not take payments for it again. Its subscription account stays open on your wallet, so the plan's owner could still charge it: Cancel if you are not coming back.";
|
|
325
|
+
readonly merchant: "Stopped[: {stop_cause}]. Mesub takes nothing more and access is off. The subscription account stays open on chain, and you, as the plan's owner, could still pull from it, until the subscriber cancels and closes it. The subscriber can come back over it.";
|
|
326
|
+
readonly actions: readonly [{
|
|
327
|
+
readonly confirm: "confirm_cancel_behind";
|
|
328
|
+
readonly by: "subscriber";
|
|
329
|
+
readonly action: "cancel";
|
|
330
|
+
readonly sdk: "subscriptions.cancel";
|
|
331
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
332
|
+
}, {
|
|
333
|
+
readonly by: "subscriber";
|
|
334
|
+
readonly action: "subscribe";
|
|
335
|
+
readonly sdk: "subscriptions.create";
|
|
336
|
+
readonly route: "POST /v1/subscriptions";
|
|
337
|
+
}, {
|
|
338
|
+
readonly by: "subscriber";
|
|
339
|
+
readonly action: "close";
|
|
340
|
+
readonly sdk: "subscriptions.close";
|
|
341
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
342
|
+
readonly confirm: "confirm_close";
|
|
343
|
+
readonly when: "closable";
|
|
344
|
+
}];
|
|
345
|
+
};
|
|
346
|
+
readonly stopped_authority_closed: {
|
|
347
|
+
readonly subscriber: "Your wallet's approval for {token} was closed for good, so no payment can go through for this subscription any more: it has stopped, your access is over, and it cannot be restarted. Close it to get your deposit back; you can then subscribe to {plan_name} again.";
|
|
348
|
+
readonly merchant: "Stopped for good: the subscriber's wallet approval for {token} was closed, so nobody can take payments from this subscription any more, you as the plan's owner included, and the subscriber cannot come back over it. They can close it at once to get their deposit back.";
|
|
349
|
+
readonly actions: readonly [{
|
|
350
|
+
readonly by: "subscriber";
|
|
351
|
+
readonly action: "close";
|
|
352
|
+
readonly sdk: "subscriptions.close";
|
|
353
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
354
|
+
readonly confirm: "confirm_close";
|
|
355
|
+
readonly when: "closable";
|
|
356
|
+
}];
|
|
357
|
+
};
|
|
358
|
+
readonly paused: {
|
|
359
|
+
readonly subscriber: "Paused by {merchant_name}: nothing will be taken, and you keep access until {access_until}.";
|
|
360
|
+
readonly merchant: "Paused: your project is over its tier's subscriber limit, so Mesub takes nothing from this subscriber. Access runs to the end of the paid period ({access_until}). Move back up a tier to restart payments.";
|
|
361
|
+
readonly actions: readonly [{
|
|
362
|
+
readonly confirm: "confirm_cancel_paid";
|
|
363
|
+
readonly by: "subscriber";
|
|
364
|
+
readonly action: "cancel";
|
|
365
|
+
readonly sdk: "subscriptions.cancel";
|
|
366
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
367
|
+
}, {
|
|
368
|
+
readonly by: "merchant";
|
|
369
|
+
readonly action: "upgrade";
|
|
370
|
+
readonly route: "POST /projects/:id/upgrade";
|
|
371
|
+
readonly dashboard: true;
|
|
372
|
+
}];
|
|
373
|
+
};
|
|
374
|
+
readonly paused_access_over: {
|
|
375
|
+
readonly subscriber: "Paused by {merchant_name}: nothing is taken, and your access has ended. If {merchant_name} unpauses it, a payment is due at once; Cancel to stop for good.";
|
|
376
|
+
readonly merchant: "Paused over your tier limit, and its paid period is over, so access is off. Moving back up a tier makes a payment due at once.";
|
|
377
|
+
readonly actions: readonly [{
|
|
378
|
+
readonly by: "subscriber";
|
|
379
|
+
readonly action: "cancel";
|
|
380
|
+
readonly sdk: "subscriptions.cancel";
|
|
381
|
+
readonly route: "POST /v1/subscriptions/:id/cancel";
|
|
382
|
+
}, {
|
|
383
|
+
readonly by: "merchant";
|
|
384
|
+
readonly action: "upgrade";
|
|
385
|
+
readonly route: "POST /projects/:id/upgrade";
|
|
386
|
+
readonly dashboard: true;
|
|
387
|
+
}];
|
|
388
|
+
};
|
|
389
|
+
readonly paused_cancelled: {
|
|
390
|
+
readonly subscriber: "Cancelled: nothing more will be taken, and you keep access until {access_until}. You can resume before then, but it stays paused, with no payment, until {merchant_name} unpauses it.";
|
|
391
|
+
readonly merchant: "Cancelled while paused over your tier limit; access until {access_until}.";
|
|
392
|
+
readonly actions: readonly [{
|
|
393
|
+
readonly confirm: "confirm_resume_paused";
|
|
394
|
+
readonly by: "subscriber";
|
|
395
|
+
readonly action: "resume";
|
|
396
|
+
readonly sdk: "subscriptions.resume";
|
|
397
|
+
readonly route: "POST /v1/subscriptions/:id/resume";
|
|
398
|
+
readonly until: "access_until";
|
|
399
|
+
}];
|
|
400
|
+
};
|
|
401
|
+
readonly ended_closed: {
|
|
402
|
+
readonly subscriber: "You closed this subscription, and its deposit is back in your wallet. You can subscribe to {plan_name} again at any time.";
|
|
403
|
+
readonly merchant: "Ended: the subscriber closed it and got the deposit back. They can subscribe again.";
|
|
404
|
+
readonly actions: readonly [{
|
|
405
|
+
readonly by: "subscriber";
|
|
406
|
+
readonly action: "subscribe";
|
|
407
|
+
readonly sdk: "subscriptions.create";
|
|
408
|
+
readonly route: "POST /v1/subscriptions";
|
|
409
|
+
}];
|
|
410
|
+
};
|
|
411
|
+
readonly ended_authority_closed: {
|
|
412
|
+
readonly subscriber: "This subscription's account was closed outside Mesub, so it has ended and nothing more can be taken. You can subscribe to {plan_name} again.";
|
|
413
|
+
readonly merchant: "Ended: its subscription account was found closed on chain, without Mesub. The subscriber can subscribe again.";
|
|
414
|
+
readonly actions: readonly [{
|
|
415
|
+
readonly by: "subscriber";
|
|
416
|
+
readonly action: "subscribe";
|
|
417
|
+
readonly sdk: "subscriptions.create";
|
|
418
|
+
readonly route: "POST /v1/subscriptions";
|
|
419
|
+
}];
|
|
420
|
+
};
|
|
421
|
+
readonly ended_plan_removed: {
|
|
422
|
+
readonly subscriber: "{merchant_name} removed {plan_name}, so your subscription has ended and nothing more will be taken.";
|
|
423
|
+
readonly merchant: "Ended: the plan account was deleted. The subscriber's subscription account may still hold their deposit, which they get back by closing it.";
|
|
424
|
+
readonly actions: readonly [{
|
|
425
|
+
readonly confirm: "confirm_close_over";
|
|
426
|
+
readonly by: "subscriber";
|
|
427
|
+
readonly action: "close";
|
|
428
|
+
readonly sdk: "subscriptions.close";
|
|
429
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
430
|
+
readonly when: "closable";
|
|
431
|
+
}];
|
|
432
|
+
};
|
|
433
|
+
readonly ended_plan_replaced: {
|
|
434
|
+
readonly subscriber: "{merchant_name} replaced {plan_name} with another plan, so this subscription has ended and nothing more will be taken.";
|
|
435
|
+
readonly merchant: "Ended: another plan now stands at this plan's address, and this subscription was never signed for it.";
|
|
436
|
+
readonly actions: readonly [{
|
|
437
|
+
readonly confirm: "confirm_close_over";
|
|
438
|
+
readonly by: "subscriber";
|
|
439
|
+
readonly action: "close";
|
|
440
|
+
readonly sdk: "subscriptions.close";
|
|
441
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
442
|
+
readonly when: "closable";
|
|
443
|
+
}];
|
|
444
|
+
};
|
|
445
|
+
readonly ended_plan_ended: {
|
|
446
|
+
readonly subscriber: "{plan_name} reached its end date[ ({plan_ends_at})], so your subscription has ended and nothing more will be taken.";
|
|
447
|
+
readonly merchant: "Ended: the plan passed its end date.";
|
|
448
|
+
readonly actions: readonly [{
|
|
449
|
+
readonly confirm: "confirm_close_over";
|
|
450
|
+
readonly by: "subscriber";
|
|
451
|
+
readonly action: "close";
|
|
452
|
+
readonly sdk: "subscriptions.close";
|
|
453
|
+
readonly route: "POST /v1/subscriptions/:id/close";
|
|
454
|
+
readonly when: "closable";
|
|
455
|
+
}];
|
|
456
|
+
};
|
|
457
|
+
readonly ended_unknown: {
|
|
458
|
+
readonly subscriber: "This subscription has ended, and nothing more will be taken.";
|
|
459
|
+
readonly merchant: "Ended (before Mesub recorded reasons).";
|
|
460
|
+
readonly actions: readonly [];
|
|
461
|
+
};
|
|
462
|
+
readonly pending: {
|
|
463
|
+
readonly subscriber: "Not signed yet. Approve it in your wallet to pay the first {amount} and start the subscription.";
|
|
464
|
+
readonly merchant: "Checkout started, not signed yet: nothing is on chain and nothing was charged.";
|
|
465
|
+
readonly actions: readonly [{
|
|
466
|
+
readonly by: "merchant";
|
|
467
|
+
readonly action: "transaction";
|
|
468
|
+
readonly sdk: "subscriptions.transaction";
|
|
469
|
+
readonly route: "POST /v1/subscriptions/:id/transaction";
|
|
470
|
+
}, {
|
|
471
|
+
readonly by: "merchant";
|
|
472
|
+
readonly action: "submit";
|
|
473
|
+
readonly sdk: "subscriptions.submit";
|
|
474
|
+
readonly route: "POST /v1/subscriptions/:id/submit";
|
|
475
|
+
}];
|
|
476
|
+
};
|
|
477
|
+
readonly expired: {
|
|
478
|
+
readonly subscriber: "This checkout was never signed, so nothing was charged. Subscribe again to start.";
|
|
479
|
+
readonly merchant: "Checkout expired unsigned. Nothing on chain.";
|
|
480
|
+
readonly actions: readonly [{
|
|
481
|
+
readonly by: "subscriber";
|
|
482
|
+
readonly action: "subscribe";
|
|
483
|
+
readonly sdk: "subscriptions.create";
|
|
484
|
+
readonly route: "POST /v1/subscriptions";
|
|
485
|
+
}];
|
|
486
|
+
};
|
|
487
|
+
readonly failed: {
|
|
488
|
+
readonly subscriber: "This subscription did not start: what reached the network was not the transaction prepared for it. If money left your wallet for it, contact {merchant_name}.";
|
|
489
|
+
readonly merchant: "Failed: what landed on chain is not what Mesub built (see the submit reason). Check the wallet's transactions before creating a new one.";
|
|
490
|
+
readonly actions: readonly [{
|
|
491
|
+
readonly by: "merchant";
|
|
492
|
+
readonly action: "retrieve";
|
|
493
|
+
readonly sdk: "subscriptions.retrieve";
|
|
494
|
+
readonly route: "GET /v1/subscriptions/:id";
|
|
495
|
+
}, {
|
|
496
|
+
readonly by: "subscriber";
|
|
497
|
+
readonly action: "subscribe";
|
|
498
|
+
readonly sdk: "subscriptions.create";
|
|
499
|
+
readonly route: "POST /v1/subscriptions";
|
|
500
|
+
}];
|
|
501
|
+
};
|
|
502
|
+
readonly superseded: {
|
|
503
|
+
readonly subscriber: "Replaced by your newer subscription to {plan_name}.";
|
|
504
|
+
readonly merchant: "An earlier subscription of this wallet, replaced when it subscribed again[ on {replaced_at}]. Read the current one.";
|
|
505
|
+
readonly actions: readonly [{
|
|
506
|
+
readonly by: "merchant";
|
|
507
|
+
readonly action: "list";
|
|
508
|
+
readonly sdk: "subscriptions.list";
|
|
509
|
+
readonly route: "GET /v1/subscriptions";
|
|
510
|
+
}];
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
/** The sentences to show before the subscriber signs an action. */
|
|
514
|
+
declare const CONFIRMATIONS: {
|
|
515
|
+
readonly confirm_cancel_paid: "Cancel {plan_name}? Nothing more will be taken, and you keep access until {access_until}.";
|
|
516
|
+
readonly confirm_cancel_behind: "Cancel {plan_name}? Your access ends now and Mesub will not collect the missed payment; you can close it once the current period ends.";
|
|
517
|
+
readonly confirm_resume: "Resume {plan_name}? Nothing is taken now; your next payment of {amount} is on {access_until}.";
|
|
518
|
+
readonly confirm_resume_paused: "Resume {plan_name}? Nothing is taken now, and nothing will be until {merchant_name} unpauses it.";
|
|
519
|
+
readonly confirm_close: "Close {plan_name}? This deletes its subscription account and returns its deposit to your wallet; you can then subscribe again.";
|
|
520
|
+
readonly confirm_close_over: "Close {plan_name}? This deletes its subscription account and returns its deposit to your wallet.";
|
|
521
|
+
};
|
|
522
|
+
/** Shown beside every sentence, which therefore need not repeat it. */
|
|
523
|
+
declare const ACCESS_LINE: {
|
|
524
|
+
readonly granted: "Access until {access_until}";
|
|
525
|
+
readonly denied: "No access";
|
|
526
|
+
};
|
|
527
|
+
type ConfirmationKey = keyof typeof CONFIRMATIONS;
|
|
528
|
+
/**
|
|
529
|
+
* A situation of the table, or `unknown`: a status or a reason newer than
|
|
530
|
+
* this release, whose sentences are the access line, true of any situation.
|
|
531
|
+
*/
|
|
532
|
+
type SituationKey = keyof typeof SITUATIONS | 'unknown';
|
|
533
|
+
interface ExplainOptions {
|
|
534
|
+
/** What "now" is, for actions open until a date. Defaults to the clock. */
|
|
535
|
+
now?: Date;
|
|
536
|
+
/** What neither `/v1/access` nor a subscription carries, as you show it. */
|
|
537
|
+
names?: {
|
|
538
|
+
/** `{plan_name}`. Defaults to the plan's slug. */
|
|
539
|
+
plan?: string;
|
|
540
|
+
/** `{merchant_name}`: your name, as subscribers know it. */
|
|
541
|
+
merchant?: string;
|
|
542
|
+
/** `{amount}`: the plan's amount with its symbol, such as `9.99 USDC`. */
|
|
543
|
+
amount?: string;
|
|
544
|
+
/** `{token}`: the plan's token symbol, such as `USDC`. */
|
|
545
|
+
token?: string;
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* How a date is written. Defaults to the ISO 8601 string as Mesub serves
|
|
549
|
+
* it, the same in every locale: pass your own to show local time.
|
|
550
|
+
*/
|
|
551
|
+
formatDate?: (iso: string) => string;
|
|
552
|
+
}
|
|
553
|
+
interface ExplainedAction {
|
|
554
|
+
by: SituationActor;
|
|
555
|
+
action: SituationActionId;
|
|
556
|
+
sdk?: string;
|
|
557
|
+
route?: string;
|
|
558
|
+
dashboard?: true;
|
|
559
|
+
/** Until when it can be done, as served (ISO 8601). */
|
|
560
|
+
until?: string;
|
|
561
|
+
/** The sentence to show before the subscriber signs it, filled. */
|
|
562
|
+
confirm?: string;
|
|
563
|
+
}
|
|
564
|
+
interface Explanation {
|
|
565
|
+
key: SituationKey;
|
|
566
|
+
/** For the subscriber, filled. */
|
|
567
|
+
subscriber: string;
|
|
568
|
+
/** For the merchant, filled. */
|
|
569
|
+
merchant: string;
|
|
570
|
+
/** "Access until …" or "No access", to show beside either sentence. */
|
|
571
|
+
access: string;
|
|
572
|
+
/** What can be done now, by whom. */
|
|
573
|
+
actions: ExplainedAction[];
|
|
574
|
+
/**
|
|
575
|
+
* Placeholders left as `{name}` in a sentence, since nothing gave them a
|
|
576
|
+
* value: pass them in `options.names`, or check the answer's fields.
|
|
577
|
+
*/
|
|
578
|
+
missing: string[];
|
|
579
|
+
}
|
|
580
|
+
/** What `explain` reads: an answer of `/v1/access` or a subscription. */
|
|
581
|
+
type Explainable = AccessAnswer | ServerSubscription;
|
|
582
|
+
/**
|
|
583
|
+
* Which situation an answer is in, in the canonical order: status first,
|
|
584
|
+
* then paused, then blocked, then the end or late reason. Never throws: a
|
|
585
|
+
* status or a reason this release does not know is `unknown`.
|
|
586
|
+
*
|
|
587
|
+
* A plan's end is read from what it leaves on the answer, which carries no
|
|
588
|
+
* `ends_at`: access with no charge or retry ahead is the last period, and a
|
|
589
|
+
* running status without access is the minutes between the end and the job
|
|
590
|
+
* that ends the row. That one reads as ended already.
|
|
591
|
+
*/
|
|
592
|
+
declare function situationOf(input: Explainable): SituationKey;
|
|
593
|
+
/**
|
|
594
|
+
* The situation of a subscription, in words: one sentence for the
|
|
595
|
+
* subscriber, one for the merchant, the access line, and what each can do
|
|
596
|
+
* now. Takes an answer of `/v1/access` or a subscription as `@mesub/node`
|
|
597
|
+
* returns them. Never throws.
|
|
598
|
+
*
|
|
599
|
+
* ```ts
|
|
600
|
+
* const { subscriber, access, actions } = explain(answer, {
|
|
601
|
+
* names: { plan: 'Pro', merchant: 'Acme', amount: '9.99 USDC', token: 'USDC' },
|
|
602
|
+
* });
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
declare function explain(input: Explainable, options?: ExplainOptions): Explanation;
|
|
606
|
+
|
|
607
|
+
export { ACCESS_LINE, CONFIRMATIONS, type ConfirmationKey, type ExplainOptions, type Explainable, type ExplainedAction, type Explanation, SITUATIONS, type Situation, type SituationActionId, type SituationActionTemplate, type SituationActor, type SituationKey, type SituationText, explain, situationOf };
|