@yaks/host 0.0.0-stage → 0.2.36

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.
Files changed (69) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +306 -2
  3. package/_dist/anatomy.d.ts +35 -0
  4. package/_dist/anatomy.d.ts.map +1 -0
  5. package/_dist/assembly.d.ts +94 -0
  6. package/_dist/assembly.d.ts.map +1 -0
  7. package/_dist/config.d.ts +150 -0
  8. package/_dist/config.d.ts.map +1 -0
  9. package/_dist/documents.d.ts +9 -0
  10. package/_dist/documents.d.ts.map +1 -0
  11. package/_dist/facets.d.ts +164 -0
  12. package/_dist/facets.d.ts.map +1 -0
  13. package/_dist/keepers.d.ts +15 -0
  14. package/_dist/keepers.d.ts.map +1 -0
  15. package/_dist/keywords.d.ts +3 -0
  16. package/_dist/keywords.d.ts.map +1 -0
  17. package/_dist/lending.d.ts +34 -0
  18. package/_dist/lending.d.ts.map +1 -0
  19. package/_dist/mod.d.ts +260 -0
  20. package/_dist/mod.d.ts.map +1 -0
  21. package/_dist/payments.d.ts +501 -0
  22. package/_dist/payments.d.ts.map +1 -0
  23. package/_dist/roles.d.ts +10 -0
  24. package/_dist/roles.d.ts.map +1 -0
  25. package/_dist/senders.d.ts +180 -0
  26. package/_dist/senders.d.ts.map +1 -0
  27. package/_dist/words.d.ts +27 -0
  28. package/_dist/words.d.ts.map +1 -0
  29. package/anatomy.js +432 -0
  30. package/anatomy.js.map +1 -0
  31. package/anatomy.ts +439 -0
  32. package/assembly.js +737 -0
  33. package/assembly.js.map +1 -0
  34. package/assembly.ts +930 -0
  35. package/config.js +149 -0
  36. package/config.js.map +1 -0
  37. package/config.ts +287 -0
  38. package/deno.json +1 -0
  39. package/documents.js +80 -0
  40. package/documents.js.map +1 -0
  41. package/documents.ts +105 -0
  42. package/facets.js +2 -0
  43. package/facets.js.map +1 -0
  44. package/facets.ts +236 -0
  45. package/keepers.js +7 -0
  46. package/keepers.js.map +1 -0
  47. package/keepers.ts +17 -0
  48. package/keywords.js +24 -0
  49. package/keywords.js.map +1 -0
  50. package/keywords.ts +25 -0
  51. package/lending.js +46 -0
  52. package/lending.js.map +1 -0
  53. package/lending.ts +77 -0
  54. package/mod.js +5 -0
  55. package/mod.js.map +1 -0
  56. package/mod.ts +356 -0
  57. package/package.json +79 -4
  58. package/payments.js +66 -0
  59. package/payments.js.map +1 -0
  60. package/payments.ts +665 -0
  61. package/roles.js +22 -0
  62. package/roles.js.map +1 -0
  63. package/roles.ts +18 -0
  64. package/senders.js +58 -0
  65. package/senders.js.map +1 -0
  66. package/senders.ts +272 -0
  67. package/words.js +134 -0
  68. package/words.js.map +1 -0
  69. package/words.ts +210 -0
@@ -0,0 +1,501 @@
1
+ /** What a payment provider lends a host that takes money through it (the
2
+ * lending kind `payments`, ./lending.ts): its name, for the sentences people
3
+ * read, the plans it sells a party, the shops a party sells through on an
4
+ * account of its own, and the webhook doors it hears both at. Each is
5
+ * functions over the provider's own wire, answering in words that name no
6
+ * provider, so a host's billing keeps its rules and refusals and a second
7
+ * provider has one contract to meet. */ /** One line of a cart: which product, how many, and its variant. */ export type Item = {
8
+ product: string;
9
+ qty: number;
10
+ options?: string;
11
+ };
12
+ /** The items as they ride the checkout and come back on the event: the product,
13
+ * how many, and the variant, in the shortest form that survives a round
14
+ * trip. They ride one tag, so its length is what decides how many lines fit
15
+ * in an order. Dashes come off the uuid to buy back four
16
+ * characters a line: a uuid without them is 32 characters and a line about
17
+ * 45. */ export declare let packed: (items: Item[]) => string;
18
+ /** The cart read back out of a checkout's tags — {@link packed}, undone.
19
+ * Junk answers an empty list rather than throwing: an order whose items cannot
20
+ * be read is still an order somebody paid for, and losing the money over the
21
+ * label would be the worse mistake. */ export declare let unpacked: (items: unknown) => Item[];
22
+ /** A party's details and tags as a payer is minted with them, and what every
23
+ * object the provider makes for that party carries back: the host's own
24
+ * words, such as whose it is and where it was bought. */ export type Tags = Record<string, string>;
25
+ /** How often a plan is paid for. */ export type Per = 'month' | 'year';
26
+ /** Where a subscription stands, as its provider reads its status: `paying`
27
+ * and billed as it should be, `owing` still held while a failed charge is
28
+ * retried, `awaiting` made but not yet paid for the first time, `lapsed` no
29
+ * longer paid for though it may be again, `ended` over for good, which no
30
+ * later word of the provider undoes. Only `paying` and `owing` hold a plan. */ export type Standing = 'paying' | 'owing' | 'awaiting' | 'lapsed' | 'ended';
31
+ /** A subscription as its provider reads it. */ export type Subscription = {
32
+ id: string;
33
+ /** the payer it bills */ payer: string;
34
+ /** the tier its price buys, one of those the provider was configured to
35
+ * sell, whatever it stands at */ tier: string;
36
+ /** How often the subscription bills, where the provider names it. */ per?: Per;
37
+ /** the provider's own word for where it stands ({@link Plans.standing}) */ status: string;
38
+ /** when the period paid for runs out */ until: string | null;
39
+ /** set only when it will not renew: when it stops, or stopped */ ending: string | null;
40
+ /** what it was bought with ({@link Checkout.tags}) */ tags: Tags;
41
+ };
42
+ /** A hosted checkout for a plan: where to send the person, and what it
43
+ * subscribes them to. */ export type Checkout = {
44
+ payer: string;
45
+ tier: string;
46
+ per: Per;
47
+ /** where the provider hands them back when they paid, and when they did
48
+ * not */ done: string;
49
+ cancel: string;
50
+ /** the host's own name for what is bought, carried back on the checkout */ reference: string;
51
+ /** carried on the checkout and the subscription it makes */ tags: Tags;
52
+ /** the day time already given free runs through, which the subscription
53
+ * starts with as a trial so its first charge falls after it */ trial?: string | null;
54
+ };
55
+ /** A subscription to a plan paid by invoice rather than at a checkout: the
56
+ * provider sends `to` an invoice for each period, payable `due` days after
57
+ * it is sent, by bank transfer or by a check the seller records as paid. */ export type Invoice = {
58
+ payer: string;
59
+ tier: string;
60
+ per: Per;
61
+ /** where the invoices go, and the name they are made out to */ to: {
62
+ email: string;
63
+ name: string;
64
+ };
65
+ /** days from an invoice being sent to its falling due */ due: number;
66
+ /** A durable request identity: the same key asked twice subscribes
67
+ * once. */ key: string;
68
+ /** carried on the subscription, as {@link Checkout.tags} */ tags: Tags;
69
+ /** as {@link Checkout.trial}: the first invoice is sent when it ends */ trial?: string | null;
70
+ addOn?: RecurringAddOn;
71
+ };
72
+ export type RecurringAddOn = {
73
+ key: string;
74
+ name: string;
75
+ cents: number;
76
+ start: string;
77
+ renewal: string;
78
+ };
79
+ export type OneTimeInvoice = {
80
+ payer: string;
81
+ key: string;
82
+ name: string;
83
+ cents: number;
84
+ due: number;
85
+ tags: Tags;
86
+ };
87
+ /** A subscription as one call made it, and when the provider made it, which
88
+ * orders it among the events about it that follow. */ export type Subscribed = {
89
+ subscription: Subscription;
90
+ at: string;
91
+ };
92
+ /** A hosted checkout for one thing paid for once, such as a block of
93
+ * credit: its price whole, in the currency's smallest unit, tax included,
94
+ * and what the buyer reads it as. Paid before anything is given for it. */ export type Once = {
95
+ payer: string;
96
+ name: string;
97
+ cents: number;
98
+ currency: string;
99
+ done: string;
100
+ cancel: string;
101
+ /** the host's own name for what is bought, carried back on the checkout */ reference: string;
102
+ /** carried on the checkout and every event about it */ tags: Tags;
103
+ };
104
+ /** A one-off checkout paid, as one verified event the provider posted says:
105
+ * the checkout, which names the purchase however often it is told, whether
106
+ * the money is there (a checkout can complete with its payment still on its
107
+ * way, and a later event says it arrived), and what it carried. */ export type Bought = {
108
+ about: 'purchase';
109
+ at: string;
110
+ live: boolean;
111
+ checkout: string;
112
+ paid: boolean;
113
+ tags: Tags;
114
+ reference?: string;
115
+ payerName?: PayerName;
116
+ };
117
+ /** The name and address a completed checkout reported for its payer. */ export type PayerName = {
118
+ name: string;
119
+ email?: string;
120
+ };
121
+ /** A subscription changed, as one verified event the provider posted says:
122
+ * when and how it happened, what the object it is about carries, and the
123
+ * subscription it is about. */ export type Changed = {
124
+ about: 'subscription';
125
+ /** when it happened */ at: string;
126
+ /** whether it moved money, rather than happening in a sandbox */ live: boolean;
127
+ /** what the object it is about was tagged with, its own or its
128
+ * subscription's */ tags: Tags;
129
+ /** the reference a checkout it is about carried */ reference?: string;
130
+ /** where the payer said they are billed, from a checkout it is about that
131
+ * asked: never the street or postal code, only the town, its state or
132
+ * province, and the two-letter country */ billed?: {
133
+ city?: string;
134
+ state?: string;
135
+ country?: string;
136
+ };
137
+ payerName?: PayerName;
138
+ /** the subscription it is about, read off it or asked for: undefined
139
+ * where it is about none, null where the provider holds none by the name
140
+ * it gives */ subscription: () => Promise<Subscription | null | undefined>;
141
+ };
142
+ /** What a provider sells a party: a payer minted once, a subscription to a
143
+ * tier bought at its hosted checkout and managed at its hosted portal, and
144
+ * the charges of one moved later. */ export type Plans = {
145
+ /** whether it can be asked anything here: its credentials are set */ on: () => boolean;
146
+ /** whether a tier is on sale here, paid for so often */ offers: (tier: string, per: Per) => boolean;
147
+ /** where a subscription with this status stands */ standing: (status: string) => Standing;
148
+ /** a new payer, its id */ payer: (who: {
149
+ email: string;
150
+ name: string;
151
+ tags: Tags;
152
+ key?: string;
153
+ }) => Promise<string>;
154
+ /** whom a payer is billed to; null where the provider holds none by that
155
+ * id */ billed: (payer: string) => Promise<{
156
+ email: string;
157
+ name: string;
158
+ } | null>;
159
+ /** One payable checkout per payer and reference: reuse the same choice,
160
+ * expire an earlier choice before opening another. */ checkout: (asked: Checkout) => Promise<string>;
161
+ /** a subscription billed by invoice, made now: its first invoice is sent
162
+ * within the hour, and it awaits that invoice's payment before it holds
163
+ * its plan */ invoice: (asked: Invoice) => Promise<Subscribed>;
164
+ /** Whether the provider is configured to set up support billing. */ invoicingOn?: () => boolean;
165
+ /** Attach or revise a yearly item on an existing invoiced yearly plan. */ addOn?: (subscription: string, item: RecurringAddOn) => Promise<string | null>;
166
+ /** Send a stand-alone invoice, once per payer and key. */ invoiceOnce?: (asked: OneTimeInvoice) => Promise<string>;
167
+ /** The smallest standalone payment accepted in this currency. */ minimum?: (currency: string) => number;
168
+ /** the address of a hosted checkout for something paid for once */ once: (asked: Once) => Promise<string>;
169
+ /** A paid {@link once} checkout's payment refunded whole, for what was
170
+ * bought and could not be given, or by the given number of cents. `key`
171
+ * names the request: asked again, it refunds nothing twice. */ refunded: (asked: {
172
+ key: string;
173
+ checkout: string;
174
+ tags: Tags;
175
+ cents?: number;
176
+ }) => Promise<Refunded>;
177
+ /** the address of the hosted portal where a payer manages what it pays,
178
+ * handing them back to `back` */ portal: (payer: string, back: string) => Promise<string>;
179
+ /** a subscription, or null where the provider holds none by that id */ subscription: (id: string) => Promise<Subscription | null>;
180
+ /** Every subscription this payer currently holds. */ subscriptions: (payer: string) => Promise<Subscription[]>;
181
+ /** when a subscription next charges; null where nothing says */ charges: (id: string) => Promise<string | null>;
182
+ /** a subscription's next charge moved to `until`, prorating nothing,
183
+ * unless it falls then or later: asked again, it moves nothing twice */ postpone: (id: string, until: string) => Promise<void>;
184
+ };
185
+ /** A seller's account as its provider reads it: its id, whether it may take
186
+ * payments now, and whether its owner finished the provider's form, which
187
+ * alone does not make it ready.
188
+ *
189
+ * The house is a seller that sells on the host's own account rather than one
190
+ * of its own: the host is the merchant, the provider's fees are the host's,
191
+ * and no fee is taken, since the host would pay it to itself. Its account is
192
+ * '' wherever {@link Shops} names one, and every event about its sales names
193
+ * none ({@link Shopped}). */ export type Seller = {
194
+ account: string;
195
+ ready: boolean;
196
+ submitted: boolean;
197
+ house?: boolean;
198
+ };
199
+ /** One line of a sale: what the buyer reads it as, its price in the
200
+ * currency's smallest unit, and how many. */ export type Line = {
201
+ name: string;
202
+ description?: string;
203
+ cents: number;
204
+ qty: number;
205
+ };
206
+ /** The delivery address verified when a physical service was quoted. */ export type Shipping = {
207
+ name: string;
208
+ phone?: string;
209
+ address: {
210
+ line1: string;
211
+ line2?: string;
212
+ city: string;
213
+ state?: string;
214
+ postal_code: string;
215
+ country: string;
216
+ };
217
+ };
218
+ /** An immutable seller quote. All amounts are in the currency's smallest unit;
219
+ * subtotal covers the complete quantity, and total includes shipping and tax. */ export type Quote = {
220
+ id: string;
221
+ buyer: string;
222
+ source: string;
223
+ seller: string;
224
+ document: string;
225
+ revision: string;
226
+ specification: string;
227
+ name: string;
228
+ quantity: number;
229
+ currency: string;
230
+ destination: Shipping;
231
+ shipping: {
232
+ id: string;
233
+ name: string;
234
+ cents: number;
235
+ };
236
+ subtotal: number;
237
+ tax: number;
238
+ total: number;
239
+ expires: string;
240
+ };
241
+ /** A hosted checkout on a seller's account: paid once, or, where it says
242
+ * how often, a subscription that charges its lines again each period until
243
+ * it is cancelled. */ export type Sale = {
244
+ /** A durable request identity: retries address the same checkout. */ key?: string;
245
+ /** A fixed physical quote; the provider does not offer address edits. */ destination?: Shipping;
246
+ shipping?: {
247
+ name: string;
248
+ cents: number;
249
+ };
250
+ expires?: string;
251
+ lines: Line[];
252
+ currency: string;
253
+ /** how often every line is charged again; none for a sale paid once */ per?: Per;
254
+ /** the host's share of each payment, in basis points (250 is 2.5%), which
255
+ * the provider takes for it, rounded down; none when 0 */ bps: number;
256
+ /** the buyer's address to start the page with, if one is known */ email?: string;
257
+ /** Offer cards and card wallets in the sale currency. */ cardOnly?: boolean;
258
+ /** Offer instantly verified US bank debits alongside cards and wallets. */ bankDebit?: boolean;
259
+ /** the seller's name, which the buyer's card statement reads after the
260
+ * host's on a sale on the host's own account; a seller's own account
261
+ * already names them there */ descriptor?: string;
262
+ /** A card statement suffix requested for a one-time payment. */ statementSuffix?: string;
263
+ /** The description in the provider's payment or subscription records. */ description?: string;
264
+ /** where the provider hands the buyer back when they paid, and when they
265
+ * did not: addresses the host checked as `URL` writes them, so a
266
+ * placeholder the provider fills in on the way back arrives
267
+ * percent-encoded, and the provider writes it back as it reads it */ done: string;
268
+ cancel: string;
269
+ /** carried on the checkout and the payment it makes, so every event about
270
+ * either says whose sale it is, each no longer than {@link Shops.tag} */ tags: Tags;
271
+ };
272
+ /** A checkout a buyer can complete with the provider's Elements on the app page. */ export type PaymentSession = {
273
+ id?: string;
274
+ clientSecret: string;
275
+ publishableKey: string;
276
+ account?: string;
277
+ };
278
+ /** A completed checkout, as its provider reads it. */ export type Paid = {
279
+ currency?: string;
280
+ /** whether the money is there: a checkout can complete with its payment
281
+ * still processing */ paid: boolean;
282
+ expired?: boolean;
283
+ /** Delayed payment failed after checkout. */ failed?: boolean;
284
+ /** The buyer submitted checkout and the payment is still settling. */ processing?: boolean;
285
+ /** the provider's own word for where the payment stands, for a sentence */ status: string;
286
+ /** the checkout's id, and the payment it made, which every later word
287
+ * about the sale names: '' for a subscription's, whose payments are its
288
+ * own */ checkout: string;
289
+ payment: string;
290
+ /** the subscription it started, where it sold one ({@link Term}) */ subscription?: string;
291
+ /** customer on the seller’s account */ payer?: string;
292
+ /** what was paid, in the currency's smallest unit */ total: number;
293
+ /** the address the buyer gave, else the one the checkout started with */ email: string;
294
+ /** the name the buyer gave, where the checkout asked for one */ name?: string;
295
+ /** Time and mode of the provider event that confirmed a gift. */ gift?: {
296
+ at: string;
297
+ live: boolean;
298
+ };
299
+ /** what the checkout carried ({@link Sale.tags}) */ tags: Tags;
300
+ };
301
+ /** A merchant's durable refund request. The key survives retries, including
302
+ * a response lost after the provider accepted the refund. */ export type Refund = {
303
+ key: string;
304
+ payment: string;
305
+ amount: number;
306
+ fee?: boolean;
307
+ tags: Tags;
308
+ };
309
+ /** What the provider says about one refund, including asynchronous changes. */ export type Refunded = {
310
+ id: string;
311
+ payment: string;
312
+ amount: number;
313
+ status: 'pending' | 'succeeded' | 'failed' | 'canceled';
314
+ tags: Tags;
315
+ };
316
+ /** A payment read from a charge or dispute event. Refund amounts are cumulative
317
+ * provider facts; older events may not carry them. */ export type Payment = {
318
+ id: string;
319
+ tags: Tags;
320
+ total?: number;
321
+ refunded?: number;
322
+ fee?: string;
323
+ };
324
+ /** Where an order's payment moved: `refunded` in whole or `partially_refunded`
325
+ * in part, `disputed` by the buyer, then `lost` to them or `restored` to the
326
+ * seller. */ export type Settled = 'refunded' | 'partially_refunded' | 'disputed' | 'lost' | 'restored';
327
+ /** A subscription a buyer took out at a seller's checkout, as the term it
328
+ * is paid for. Whether it is paid for now is `until` against the clock, so
329
+ * nothing about it is a status to keep. */ export type Term = {
330
+ id: string;
331
+ /** when the term paid for ends; null where nothing was paid */ until: string | null;
332
+ /** set only when it will not renew: when it stops, or stopped */ ending: string | null;
333
+ /** what the checkout that started it carried ({@link Sale.tags}) */ tags: Tags;
334
+ };
335
+ /** One period of a subscription on a seller's account, paid: the invoice,
336
+ * the subscription and the payer it billed, what was paid in the currency's
337
+ * smallest unit, when, the address and name it was billed to, and the tags
338
+ * the checkout that started the subscription carried ({@link Sale.tags}). */ export type Billed = {
339
+ id: string;
340
+ subscription: string;
341
+ payer: string;
342
+ total: number;
343
+ at: string;
344
+ email: string;
345
+ name?: string;
346
+ live?: boolean;
347
+ tags: Tags;
348
+ };
349
+ /** One verified event a seller's account posted, read, with the account it
350
+ * happened on ('' where it names none, as an event about a house sale on the
351
+ * host's own account does, whose tags say whose sale it was): the seller's account changed, or it
352
+ * revoked the host's permission to act on it, or a checkout completed, or a
353
+ * payment moved, or a subscription's term moved (it renewed, was cancelled or
354
+ * lapsed), or something the host has no word for. */ export type Shopped = {
355
+ account: string;
356
+ } & ({
357
+ about: 'seller';
358
+ seller: Seller;
359
+ } | {
360
+ about: 'revoked';
361
+ } | {
362
+ about: 'sale';
363
+ sale: Paid;
364
+ } | {
365
+ about: 'refund';
366
+ refund: Refunded;
367
+ } | {
368
+ about: 'payment';
369
+ to: Settled;
370
+ /** the payment it moved and what it carried, read on asking; null
371
+ * where the event names none */ payment: () => Promise<Payment | null>;
372
+ } | {
373
+ about: 'term';
374
+ subscription: string;
375
+ tags: Tags;
376
+ /** the subscription as it stands now, read on asking, so events
377
+ * delivered out of order still leave the latest word; null where the
378
+ * event names none, or the provider holds none by that name */ term: () => Promise<Term | null>;
379
+ /** the period's invoice, where the event is one paid */ invoice?: Billed;
380
+ } | {
381
+ about: 'other';
382
+ });
383
+ /** What a provider charges a seller, as its published pricing says, for
384
+ * the pages that tell a seller what selling costs before they start. */ export type Costs = {
385
+ /** a payment by a card from the seller's own country: a rate in basis
386
+ * points of the payment, plus a fixed amount in cents */ card: {
387
+ bps: number;
388
+ cents: number;
389
+ };
390
+ /** US bank debit rate in basis points and maximum fee in cents. */ bankDebit?: {
391
+ bps: number;
392
+ cap: number;
393
+ };
394
+ /** Additional estimated billing costs for recurring payments. */ recurring?: number;
395
+ /** what a card from another country adds to the rate, in basis points */ abroad: number;
396
+ /** the fee for a payment a buyer disputes with their bank, in cents,
397
+ * returned when the seller wins */ dispute: number;
398
+ /** whether the processing fee comes back when a payment is refunded */ refunded: boolean;
399
+ /** days from a sale to its payout, and from a new account's first sale
400
+ * to its first payout */ payout: {
401
+ days: number;
402
+ first: number;
403
+ };
404
+ /** the country those numbers are for, and where the provider publishes
405
+ * them for every other */ country: string;
406
+ pricing: string;
407
+ };
408
+ /** What a provider keeps of a card payment of `cents`: its rate, rounded to
409
+ * the nearest cent, plus its fixed amount, never more than the payment.
410
+ *
411
+ * ```ts
412
+ * import { charged } from '@yaks/host/payments'
413
+ * import { equal } from '@yaks/testing'
414
+ * let card = { bps: 290, cents: 30 }
415
+ * equal(charged(card, 2000), 88)
416
+ * equal(charged(card, 1999), 88)
417
+ * equal(charged(card, 10), 10)
418
+ * ```
419
+ */ export declare let charged: (card: Costs['card'], cents: number) => number;
420
+ /** What a payer adds to `cents` so that what the provider keeps of the whole
421
+ * ({@link charged}) leaves the seller `cents`: the least that does.
422
+ *
423
+ * ```ts
424
+ * import { charged, covering } from '@yaks/host/payments'
425
+ * import { equal } from '@yaks/testing'
426
+ * let card = { bps: 290, cents: 30 }
427
+ * equal(covering(card, 10000), 330)
428
+ * equal(10330 - charged(card, 10330) >= 10000, true)
429
+ * equal(10329 - charged(card, 10329) < 10000, true)
430
+ * equal(covering(card, 2500), 106)
431
+ * ```
432
+ */ export declare let covering: (card: Costs['card'], cents: number) => number;
433
+ /** What a provider lends a party selling on an account of its own: the
434
+ * account opened once and finished through the provider's onboarding, or one
435
+ * the seller already had and connected at the provider's own page, and
436
+ * hosted checkouts on it, paid once or by subscription, which the host takes
437
+ * a fee from. An account named '' is the host's own, the house's
438
+ * ({@link Seller}): its checkouts take no fee and are paid once. */ export type Shops = {
439
+ /** whether it can be asked anything here: its credentials are set */ on: () => boolean;
440
+ /** what selling through it costs a seller */ costs: Costs;
441
+ /** the least one payment may be in a currency, in its smallest unit */ minimum: (currency: string) => number;
442
+ /** Which mode this connection can charge in. */ mode: () => 'test' | 'live' | undefined;
443
+ /** the most characters one tag's value carries ({@link Sale.tags}): a
444
+ * longer one the provider refuses or cuts short */ tag: number;
445
+ /** a new account for a seller, started with their address if one is known
446
+ * and carrying `tags` */ open: (who: {
447
+ email?: string;
448
+ tags: Tags;
449
+ }) => Promise<Seller>;
450
+ /** the address of the provider's onboarding for an account, handing them
451
+ * back to `back` when they finish or the address goes stale: the provider's
452
+ * own page for an account the seller brought, which only they may change */ onboarding: (account: string, back: string) => Promise<string>;
453
+ /** the address of the provider's page where a seller connects an account
454
+ * they already have, handing them back to `back` with `state` and a code
455
+ * {@link authorized} reads; null where the provider cannot connect one
456
+ * here */ authorize: (state: string, back: string) => string | null;
457
+ /** the account a seller connected at {@link authorize}, from the code they
458
+ * were handed back with, which is good once */ authorized: (code: string) => Promise<Seller>;
459
+ /** the address of a hosted checkout on a seller's account */ checkout: (account: string, sale: Sale) => Promise<string>;
460
+ /** Checkout using provider-owned payment fields on the app's page. */ embedded?: {
461
+ on: () => boolean;
462
+ checkout: (account: string, sale: Sale) => Promise<PaymentSession>;
463
+ resume?: (account: string, checkout: string) => Promise<PaymentSession | null>;
464
+ walletDomain: (account: string, domain: string) => Promise<void>;
465
+ };
466
+ /** a checkout on a seller's account as it stands, read back by its id,
467
+ * completed or not; null where the provider holds none by that id */ paid: (account: string, checkout: string) => Promise<Paid | null>;
468
+ /** a subscription on a seller's account as it stands; null where the
469
+ * provider holds none by that id */ term: (account: string, subscription: string) => Promise<Term | null>;
470
+ /** a subscription on a seller's account set to stop when the period paid
471
+ * for ends, and as it then stands: asked again, it changes nothing */ cancel: (account: string, subscription: string) => Promise<Term>;
472
+ /** Refund on the merchant's account, returning the application fee in
473
+ * proportion. An identical key and request must never refund twice. */ refund: (account: string, request: Refund) => Promise<Refunded>;
474
+ /** the address of the provider's hosted portal on a seller's account,
475
+ * where its payer manages and cancels what it pays, handing them back to
476
+ * `back` */ portal: (account: string, payer: string, subscription: string, back: string, purpose?: 'subscription') => Promise<string>;
477
+ /** Reconcile a dashboard refund's cumulative application-fee reversal. */ refundFee: (fee: string, refunded: number, total: number) => Promise<void>;
478
+ };
479
+ /** One verified event the provider posted, read into the host's words: a
480
+ * subscription changed, a one-off checkout was paid, or something happened
481
+ * on a seller's account. */ export type Heard = Changed | Bought | Shopped;
482
+ /** What a door said of one request posted to it: the event it heard, or why
483
+ * it refused it, `ours` where the refusal can mean the host's own secret is
484
+ * wrong, which is worth reporting. */ export type Said = {
485
+ heard: Heard;
486
+ } | {
487
+ refused: string;
488
+ ours: boolean;
489
+ };
490
+ /** A webhook door: one request the provider posted, verified and read.
491
+ * Undefined where it holds no secret to verify with, so it hears nothing. */ export type Door = (request: Request) => Promise<Said | undefined>;
492
+ /** A payment provider as it is lent. */ export type Payments = {
493
+ /** its name, as people read it: the account they open, the page they pay
494
+ * on */ name: string;
495
+ plans: Plans;
496
+ shops: Shops;
497
+ /** its webhook doors by name, which a host serves at `/<via>/<name>`, `via`
498
+ * the name it is lent under, so the provider is told one address per door
499
+ * and every door's events reach the host read */ doors: Record<string, Door>;
500
+ };
501
+ //# sourceMappingURL=payments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.d.ts","sources":["../payments.ts"],"names":[],"mappings":"AAAA;;;;;;sCAMsC,GAEtC,kEAAkE,GAClE,YAAY;EAAS,SAAS,MAAM;EAAE,KAAK,MAAM;EAAE,UAAU,MAAM;;AAEnE;;;;;OAKO,GACP,OAAO,YAAI,SAAU,OAAO,WAAS,MAAM,CAOxC;AAEH;;;qCAGqC,GACrC,OAAO,YAAI,WAAY,OAAO,OAAO,KAAG,OAkBvC;AAED;;uDAEuD,GACvD,YAAY,OAAO,OAAO,MAAM,EAAE,MAAM;A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AQ,OAAO,IAAI;EAChE;oCACkC,GAClC,OAAO,SAAS,MAAM,EAAE,cAAc,MAAM,KAAK,QAAQ,OAAO,IAAI;EACpE;sEACoE,GACpE,SAAS,SAAS,MAAM,EAAE,cAAc,MAAM,KAAK,QAAQ;EAC3D;uEACqE,GACrE,SAAS,SAAS,MAAM,EAAE,SAAS,WAAW,QAAQ;EACtD;;YAEU,GACV,SACE,SAAS,MAAM,EACf,OAAO,MAAM,EACb,cAAc,MAAM,EACpB,MAAM,MAAM,EACZ,UAAU,mBACP,QAAQ,MAAM;EACnB,wEAAwE,GACxE,YAAY,KAAK,MAAM,EAAE,UAAU,MAAM,EAAE,OAAO,MAAM,KAAK,QAAQ,IAAI;;AAG3E;;0BAE0B,GAC1B,YAAY,QAAQ,UAAU,SAAS;AAEvC;;oCAEoC,GACpC,YAAY;EAAS,OAAO;;EAAY,SAAS,MAAM;EAAE,MAAM,OAAO;;AAEtE;2EAC2E,GAC3E,YAAY,QAAQ,SAAS,YAAY,QAAQ,OAAO,SAAS;AAEjE,sCAAsC,GACtC,YAAY;EACV;QACM,GACN,MAAM,MAAM;EACZ,OAAO;EACP,OAAO;EACP;;iDAE+C,GAC/C,OAAO,OAAO,MAAM,EAAE"}
@@ -0,0 +1,10 @@
1
+ import type { Config } from "./config.js";
2
+ import type { Role } from "./mod.js";
3
+ export declare let ROLES: {
4
+ readonly graph: readonly ['vocab', 'graph', 'tools'];
5
+ readonly web: readonly ['routes', 'ui'];
6
+ readonly effects: readonly ['effects'];
7
+ };
8
+ /** Common roles, followed by each configured plugin's service role. */ export declare let every: (config: Config) => Role[];
9
+ export declare let common: (role: Role) => role is keyof typeof ROLES;
10
+ //# sourceMappingURL=roles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roles.d.ts","sources":["../roles.ts"],"names":[],"mappings":"AACA,cAAc,MAAM,sBAAqB;AAEzC,cAAc,IAAI,mBAAkB;AACpC,OAAO,YAAI;WACT,iBAAQ,SAAS,SAAS;WAC1B,eAAM,UAAU;WAChB,mBAAU;EACF;AACV,qEAAqE,GACrE,OAAO,YAAI,QAAS,QAAQ,WAAS,OAKpC;AACD,OAAO,YAAI,SAAU,MAAM,SAAO,qBAAqB,MAC3B"}