@peable.to/contracts 0.4.0 → 1.1.0

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 (322) hide show
  1. package/dist/cjs/common/address.js +81 -0
  2. package/dist/cjs/common/envelopes.js +101 -0
  3. package/dist/cjs/common/objects.js +85 -0
  4. package/dist/cjs/common/params.js +211 -0
  5. package/dist/cjs/common/primitives.js +39 -0
  6. package/dist/cjs/contributions.js +22 -0
  7. package/dist/cjs/index.js +40 -137
  8. package/dist/cjs/openapi/document.js +297 -0
  9. package/dist/cjs/openapi/index.js +7 -0
  10. package/dist/cjs/openapi/webhooks.js +17 -0
  11. package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
  12. package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
  13. package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
  14. package/dist/cjs/resources/billingEngine/index.js +43 -0
  15. package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
  16. package/dist/cjs/resources/billingEngine/invoices.js +509 -0
  17. package/dist/cjs/resources/billingEngine/params.js +43 -0
  18. package/dist/cjs/resources/billingEngine/public.js +326 -0
  19. package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
  20. package/dist/cjs/resources/catalog/billing.js +755 -0
  21. package/dist/cjs/resources/catalog/billingSettings.js +131 -0
  22. package/dist/cjs/resources/catalog/coupons.js +222 -0
  23. package/dist/cjs/resources/catalog/entitlements.js +257 -0
  24. package/dist/cjs/resources/catalog/index.js +58 -0
  25. package/dist/cjs/resources/catalog/meters.js +279 -0
  26. package/dist/cjs/resources/catalog/prices.js +423 -0
  27. package/dist/cjs/resources/catalog/products.js +228 -0
  28. package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
  29. package/dist/cjs/resources/catalog/shared.js +75 -0
  30. package/dist/cjs/resources/catalog/testClocks.js +127 -0
  31. package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
  32. package/dist/cjs/resources/checkout/contributions.js +172 -0
  33. package/dist/cjs/resources/checkout/files.js +133 -0
  34. package/dist/cjs/resources/checkout/index.js +57 -0
  35. package/dist/cjs/resources/checkout/merchants.js +290 -0
  36. package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
  37. package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
  38. package/dist/cjs/resources/checkout/shared.js +368 -0
  39. package/dist/cjs/resources/connect/account.js +332 -0
  40. package/dist/cjs/resources/connect/applicationFees.js +113 -0
  41. package/dist/cjs/resources/connect/balance.js +212 -0
  42. package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
  43. package/dist/cjs/resources/connect/index.js +51 -0
  44. package/dist/cjs/resources/connect/onboarding.js +82 -0
  45. package/dist/cjs/resources/connect/payouts.js +196 -0
  46. package/dist/cjs/resources/connect/reporting.js +235 -0
  47. package/dist/cjs/resources/connect/requestLogs.js +110 -0
  48. package/dist/cjs/resources/connect/transfers.js +227 -0
  49. package/dist/cjs/resources/core/customers.js +194 -0
  50. package/dist/cjs/resources/core/index.js +23 -0
  51. package/dist/cjs/resources/core/paymentMethods.js +134 -0
  52. package/dist/cjs/resources/events/events.js +357 -0
  53. package/dist/cjs/resources/events/index.js +29 -0
  54. package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
  55. package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
  56. package/dist/cjs/resources/payments/charges.js +157 -0
  57. package/dist/cjs/resources/payments/disputes.js +204 -0
  58. package/dist/cjs/resources/payments/index.js +41 -0
  59. package/dist/cjs/resources/payments/paymentIntents.js +529 -0
  60. package/dist/cjs/resources/payments/refunds.js +245 -0
  61. package/dist/cjs/resources/payments/setupIntents.js +158 -0
  62. package/dist/cjs/resources/payments/social.js +182 -0
  63. package/dist/cjs/resources/payments/testHelpers.js +39 -0
  64. package/dist/cjs/resources/tax/assessments.js +217 -0
  65. package/dist/cjs/resources/tax/businessProfile.js +99 -0
  66. package/dist/cjs/resources/tax/calculations.js +176 -0
  67. package/dist/cjs/resources/tax/capabilities.js +42 -0
  68. package/dist/cjs/resources/tax/codes.js +37 -0
  69. package/dist/cjs/resources/tax/complianceActions.js +56 -0
  70. package/dist/cjs/resources/tax/deadlines.js +59 -0
  71. package/dist/cjs/resources/tax/documents.js +128 -0
  72. package/dist/cjs/resources/tax/index.js +80 -0
  73. package/dist/cjs/resources/tax/locationEvidence.js +131 -0
  74. package/dist/cjs/resources/tax/operatingLocations.js +98 -0
  75. package/dist/cjs/resources/tax/products.js +67 -0
  76. package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
  77. package/dist/cjs/resources/tax/registrations.js +82 -0
  78. package/dist/cjs/resources/tax/reports.js +92 -0
  79. package/dist/cjs/resources/tax/reviewItems.js +116 -0
  80. package/dist/cjs/resources/tax/ruleSet.js +68 -0
  81. package/dist/cjs/resources/tax/salesDestinations.js +94 -0
  82. package/dist/cjs/resources/tax/settings.js +104 -0
  83. package/dist/cjs/resources/tax/shared.js +62 -0
  84. package/dist/cjs/resources/tax/transactions.js +102 -0
  85. package/dist/cjs/route.js +22 -0
  86. package/dist/cjs/routes.js +31 -0
  87. package/dist/cjs/vocabulary/billingPortal.js +15 -0
  88. package/dist/cjs/vocabulary/catalog.js +110 -0
  89. package/dist/cjs/vocabulary/checkout.js +53 -0
  90. package/dist/cjs/vocabulary/connect.js +95 -0
  91. package/dist/cjs/vocabulary/dashboard.js +68 -0
  92. package/dist/cjs/vocabulary/errors.js +175 -0
  93. package/dist/cjs/vocabulary/events.js +176 -0
  94. package/dist/cjs/vocabulary/files.js +44 -0
  95. package/dist/cjs/vocabulary/identity.js +12 -0
  96. package/dist/cjs/vocabulary/index.js +39 -0
  97. package/dist/cjs/vocabulary/invoices.js +52 -0
  98. package/dist/cjs/vocabulary/lists.js +22 -0
  99. package/dist/cjs/vocabulary/merchants.js +23 -0
  100. package/dist/cjs/vocabulary/money.js +104 -0
  101. package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
  102. package/dist/cjs/vocabulary/payments.js +195 -0
  103. package/dist/cjs/vocabulary/reporting.js +27 -0
  104. package/dist/cjs/vocabulary/subscriptions.js +60 -0
  105. package/dist/cjs/vocabulary/tax.js +237 -0
  106. package/dist/cjs/vocabulary/version.js +12 -0
  107. package/dist/esm/common/address.js +76 -0
  108. package/dist/esm/common/envelopes.js +95 -0
  109. package/dist/esm/common/objects.js +74 -0
  110. package/dist/esm/common/params.js +203 -0
  111. package/dist/esm/common/primitives.js +35 -0
  112. package/dist/esm/contributions.js +5 -0
  113. package/dist/esm/index.js +26 -134
  114. package/dist/esm/openapi/document.js +294 -0
  115. package/dist/esm/openapi/index.js +2 -0
  116. package/dist/esm/openapi/webhooks.js +14 -0
  117. package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
  118. package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
  119. package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
  120. package/dist/esm/resources/billingEngine/index.js +26 -0
  121. package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
  122. package/dist/esm/resources/billingEngine/invoices.js +506 -0
  123. package/dist/esm/resources/billingEngine/params.js +39 -0
  124. package/dist/esm/resources/billingEngine/public.js +323 -0
  125. package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
  126. package/dist/esm/resources/catalog/billing.js +752 -0
  127. package/dist/esm/resources/catalog/billingSettings.js +128 -0
  128. package/dist/esm/resources/catalog/coupons.js +219 -0
  129. package/dist/esm/resources/catalog/entitlements.js +254 -0
  130. package/dist/esm/resources/catalog/index.js +38 -0
  131. package/dist/esm/resources/catalog/meters.js +276 -0
  132. package/dist/esm/resources/catalog/prices.js +419 -0
  133. package/dist/esm/resources/catalog/products.js +225 -0
  134. package/dist/esm/resources/catalog/promotionCodes.js +171 -0
  135. package/dist/esm/resources/catalog/shared.js +67 -0
  136. package/dist/esm/resources/catalog/testClocks.js +124 -0
  137. package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
  138. package/dist/esm/resources/checkout/contributions.js +167 -0
  139. package/dist/esm/resources/checkout/files.js +130 -0
  140. package/dist/esm/resources/checkout/index.js +25 -0
  141. package/dist/esm/resources/checkout/merchants.js +287 -0
  142. package/dist/esm/resources/checkout/paymentLinks.js +327 -0
  143. package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
  144. package/dist/esm/resources/checkout/shared.js +363 -0
  145. package/dist/esm/resources/connect/account.js +329 -0
  146. package/dist/esm/resources/connect/applicationFees.js +110 -0
  147. package/dist/esm/resources/connect/balance.js +209 -0
  148. package/dist/esm/resources/connect/connectedAccounts.js +257 -0
  149. package/dist/esm/resources/connect/index.js +34 -0
  150. package/dist/esm/resources/connect/onboarding.js +79 -0
  151. package/dist/esm/resources/connect/payouts.js +193 -0
  152. package/dist/esm/resources/connect/reporting.js +232 -0
  153. package/dist/esm/resources/connect/requestLogs.js +107 -0
  154. package/dist/esm/resources/connect/transfers.js +224 -0
  155. package/dist/esm/resources/core/customers.js +191 -0
  156. package/dist/esm/resources/core/index.js +6 -0
  157. package/dist/esm/resources/core/paymentMethods.js +131 -0
  158. package/dist/esm/resources/events/events.js +353 -0
  159. package/dist/esm/resources/events/index.js +12 -0
  160. package/dist/esm/resources/events/webhookDeliveries.js +90 -0
  161. package/dist/esm/resources/events/webhookEndpoints.js +212 -0
  162. package/dist/esm/resources/payments/charges.js +154 -0
  163. package/dist/esm/resources/payments/disputes.js +201 -0
  164. package/dist/esm/resources/payments/index.js +24 -0
  165. package/dist/esm/resources/payments/paymentIntents.js +526 -0
  166. package/dist/esm/resources/payments/refunds.js +242 -0
  167. package/dist/esm/resources/payments/setupIntents.js +155 -0
  168. package/dist/esm/resources/payments/social.js +179 -0
  169. package/dist/esm/resources/payments/testHelpers.js +36 -0
  170. package/dist/esm/resources/tax/assessments.js +214 -0
  171. package/dist/esm/resources/tax/businessProfile.js +96 -0
  172. package/dist/esm/resources/tax/calculations.js +173 -0
  173. package/dist/esm/resources/tax/capabilities.js +39 -0
  174. package/dist/esm/resources/tax/codes.js +34 -0
  175. package/dist/esm/resources/tax/complianceActions.js +53 -0
  176. package/dist/esm/resources/tax/deadlines.js +56 -0
  177. package/dist/esm/resources/tax/documents.js +125 -0
  178. package/dist/esm/resources/tax/index.js +63 -0
  179. package/dist/esm/resources/tax/locationEvidence.js +128 -0
  180. package/dist/esm/resources/tax/operatingLocations.js +95 -0
  181. package/dist/esm/resources/tax/products.js +64 -0
  182. package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
  183. package/dist/esm/resources/tax/registrations.js +79 -0
  184. package/dist/esm/resources/tax/reports.js +89 -0
  185. package/dist/esm/resources/tax/reviewItems.js +113 -0
  186. package/dist/esm/resources/tax/ruleSet.js +65 -0
  187. package/dist/esm/resources/tax/salesDestinations.js +91 -0
  188. package/dist/esm/resources/tax/settings.js +101 -0
  189. package/dist/esm/resources/tax/shared.js +58 -0
  190. package/dist/esm/resources/tax/transactions.js +99 -0
  191. package/dist/esm/route.js +16 -0
  192. package/dist/esm/routes.js +27 -0
  193. package/dist/esm/vocabulary/billingPortal.js +12 -0
  194. package/dist/esm/vocabulary/catalog.js +106 -0
  195. package/dist/esm/vocabulary/checkout.js +50 -0
  196. package/dist/esm/vocabulary/connect.js +92 -0
  197. package/dist/esm/vocabulary/dashboard.js +64 -0
  198. package/dist/esm/vocabulary/errors.js +170 -0
  199. package/dist/esm/vocabulary/events.js +173 -0
  200. package/dist/esm/vocabulary/files.js +41 -0
  201. package/dist/esm/vocabulary/identity.js +9 -0
  202. package/dist/esm/vocabulary/index.js +23 -0
  203. package/dist/esm/vocabulary/invoices.js +49 -0
  204. package/dist/esm/vocabulary/lists.js +19 -0
  205. package/dist/esm/vocabulary/merchants.js +20 -0
  206. package/dist/esm/vocabulary/money.js +98 -0
  207. package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
  208. package/dist/esm/vocabulary/payments.js +192 -0
  209. package/dist/esm/vocabulary/reporting.js +24 -0
  210. package/dist/esm/vocabulary/subscriptions.js +57 -0
  211. package/dist/esm/vocabulary/tax.js +233 -0
  212. package/dist/esm/vocabulary/version.js +9 -0
  213. package/dist/types/common/address.d.ts +62 -0
  214. package/dist/types/common/envelopes.d.ts +88 -0
  215. package/dist/types/common/objects.d.ts +107 -0
  216. package/dist/types/common/params.d.ts +156 -0
  217. package/dist/types/common/primitives.d.ts +56 -0
  218. package/dist/types/contributions.d.ts +1 -0
  219. package/dist/types/index.d.ts +16 -171
  220. package/dist/types/openapi/document.d.ts +16 -0
  221. package/dist/types/openapi/index.d.ts +2 -0
  222. package/dist/types/openapi/webhooks.d.ts +15 -0
  223. package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
  224. package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
  225. package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
  226. package/dist/types/resources/billingEngine/index.d.ts +6071 -0
  227. package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
  228. package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
  229. package/dist/types/resources/billingEngine/params.d.ts +51 -0
  230. package/dist/types/resources/billingEngine/public.d.ts +1860 -0
  231. package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
  232. package/dist/types/resources/catalog/billing.d.ts +1723 -0
  233. package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
  234. package/dist/types/resources/catalog/coupons.d.ts +403 -0
  235. package/dist/types/resources/catalog/entitlements.d.ts +422 -0
  236. package/dist/types/resources/catalog/index.d.ts +3155 -0
  237. package/dist/types/resources/catalog/meters.d.ts +474 -0
  238. package/dist/types/resources/catalog/prices.d.ts +1091 -0
  239. package/dist/types/resources/catalog/products.d.ts +430 -0
  240. package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
  241. package/dist/types/resources/catalog/shared.d.ts +34 -0
  242. package/dist/types/resources/catalog/testClocks.d.ts +220 -0
  243. package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
  244. package/dist/types/resources/checkout/contributions.d.ts +375 -0
  245. package/dist/types/resources/checkout/files.d.ts +280 -0
  246. package/dist/types/resources/checkout/index.d.ts +5678 -0
  247. package/dist/types/resources/checkout/merchants.d.ts +395 -0
  248. package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
  249. package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
  250. package/dist/types/resources/checkout/shared.d.ts +419 -0
  251. package/dist/types/resources/connect/account.d.ts +483 -0
  252. package/dist/types/resources/connect/applicationFees.d.ts +198 -0
  253. package/dist/types/resources/connect/balance.d.ts +399 -0
  254. package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
  255. package/dist/types/resources/connect/index.d.ts +2094 -0
  256. package/dist/types/resources/connect/onboarding.d.ts +95 -0
  257. package/dist/types/resources/connect/payouts.d.ts +527 -0
  258. package/dist/types/resources/connect/reporting.d.ts +506 -0
  259. package/dist/types/resources/connect/requestLogs.d.ts +236 -0
  260. package/dist/types/resources/connect/transfers.d.ts +436 -0
  261. package/dist/types/resources/core/customers.d.ts +619 -0
  262. package/dist/types/resources/core/index.d.ts +679 -0
  263. package/dist/types/resources/core/paymentMethods.d.ts +336 -0
  264. package/dist/types/resources/events/events.d.ts +731 -0
  265. package/dist/types/resources/events/index.d.ts +1727 -0
  266. package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
  267. package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
  268. package/dist/types/resources/payments/charges.d.ts +390 -0
  269. package/dist/types/resources/payments/disputes.d.ts +822 -0
  270. package/dist/types/resources/payments/index.d.ts +3517 -0
  271. package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
  272. package/dist/types/resources/payments/refunds.d.ts +684 -0
  273. package/dist/types/resources/payments/setupIntents.d.ts +391 -0
  274. package/dist/types/resources/payments/social.d.ts +266 -0
  275. package/dist/types/resources/payments/testHelpers.d.ts +178 -0
  276. package/dist/types/resources/tax/assessments.d.ts +787 -0
  277. package/dist/types/resources/tax/businessProfile.d.ts +134 -0
  278. package/dist/types/resources/tax/calculations.d.ts +261 -0
  279. package/dist/types/resources/tax/capabilities.d.ts +81 -0
  280. package/dist/types/resources/tax/codes.d.ts +29 -0
  281. package/dist/types/resources/tax/complianceActions.d.ts +97 -0
  282. package/dist/types/resources/tax/deadlines.d.ts +133 -0
  283. package/dist/types/resources/tax/documents.d.ts +257 -0
  284. package/dist/types/resources/tax/index.d.ts +1946 -0
  285. package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
  286. package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
  287. package/dist/types/resources/tax/products.d.ts +68 -0
  288. package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
  289. package/dist/types/resources/tax/registrations.d.ts +103 -0
  290. package/dist/types/resources/tax/reports.d.ts +129 -0
  291. package/dist/types/resources/tax/reviewItems.d.ts +226 -0
  292. package/dist/types/resources/tax/ruleSet.d.ts +219 -0
  293. package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
  294. package/dist/types/resources/tax/settings.d.ts +122 -0
  295. package/dist/types/resources/tax/shared.d.ts +43 -0
  296. package/dist/types/resources/tax/transactions.d.ts +404 -0
  297. package/dist/types/route.d.ts +86 -0
  298. package/dist/types/routes.d.ts +23 -0
  299. package/dist/types/vocabulary/billingPortal.d.ts +15 -0
  300. package/dist/types/vocabulary/catalog.d.ts +97 -0
  301. package/dist/types/vocabulary/checkout.d.ts +49 -0
  302. package/dist/types/vocabulary/connect.d.ts +62 -0
  303. package/dist/types/vocabulary/dashboard.d.ts +44 -0
  304. package/dist/types/vocabulary/errors.d.ts +146 -0
  305. package/dist/types/vocabulary/events.d.ts +171 -0
  306. package/dist/types/vocabulary/files.d.ts +30 -0
  307. package/dist/types/vocabulary/identity.d.ts +9 -0
  308. package/dist/types/vocabulary/index.d.ts +19 -0
  309. package/dist/types/vocabulary/invoices.d.ts +39 -0
  310. package/dist/types/vocabulary/lists.d.ts +9 -0
  311. package/dist/types/vocabulary/merchants.d.ts +9 -0
  312. package/dist/types/vocabulary/money.d.ts +59 -0
  313. package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
  314. package/dist/types/vocabulary/payments.d.ts +117 -0
  315. package/dist/types/vocabulary/reporting.d.ts +18 -0
  316. package/dist/types/vocabulary/subscriptions.d.ts +45 -0
  317. package/dist/types/vocabulary/tax.d.ts +163 -0
  318. package/dist/types/vocabulary/version.d.ts +10 -0
  319. package/package.json +51 -11
  320. package/dist/cjs/openapi.js +0 -165
  321. package/dist/esm/openapi.js +0 -161
  322. package/dist/types/openapi.d.ts +0 -148
package/dist/cjs/index.js CHANGED
@@ -1,139 +1,42 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contributionPatchSchema = exports.contributionOperationKeySchema = exports.contributionMintSchema = exports.contributionPageQuerySchema = exports.listQueryShape = exports.contributionCollectionListSchema = exports.contributionCollectionSchema = exports.contributionListSchema = exports.contributionLinkSchema = exports.createContributionSchema = exports.contributionDetailsSchema = exports.contributionAmountSchema = void 0;
4
- exports.decimalContributionAmount = decimalContributionAmount;
5
- exports.formatContributionAmount = formatContributionAmount;
6
- const zod_1 = require("zod");
7
- exports.contributionAmountSchema = zod_1.z
8
- .string()
9
- .regex(/^[1-9][0-9]{0,15}$/)
10
- .refine((v) => /^[1-9][0-9]{0,15}$/.test(v) && BigInt(v) <= 9007199254740991n, 'Enter a positive FairCoin base-unit amount within the supported range');
11
- /** Every instant on the wire is integer Unix seconds (ADR 0014 D1). */
12
- const unixSecondsSchema = zod_1.z.number().int().nonnegative();
13
- exports.contributionDetailsSchema = zod_1.z
14
- .object({
15
- organization_id: zod_1.z.string().min(1).max(200),
16
- purpose: zod_1.z.string().trim().min(1).max(500),
17
- amount_mode: zod_1.z.enum(['fixed', 'free']),
18
- expires_at: unixSecondsSchema.nullable(),
19
- })
20
- .strict();
21
- exports.createContributionSchema = zod_1.z
22
- .object({
23
- purpose: exports.contributionDetailsSchema.shape.purpose,
24
- amount_mode: exports.contributionDetailsSchema.shape.amount_mode,
25
- amount: exports.contributionAmountSchema.optional(),
26
- currency: zod_1.z.literal('FAIR'),
27
- expires_at: unixSecondsSchema.nullable().optional(),
28
- })
29
- .strict()
30
- .refine((v) => (v.amount_mode === 'free' ? v.amount === undefined : v.amount !== undefined), 'Fixed contributions require an amount; free contributions omit it');
31
- exports.contributionLinkSchema = zod_1.z
32
- .object({
33
- id: zod_1.z.string(),
34
- object: zod_1.z.literal('payment_link'),
35
- amount: zod_1.z.string(),
36
- currency: zod_1.z.literal('FAIR'),
37
- network: zod_1.z.enum(['mainnet', 'testnet']),
38
- active: zod_1.z.boolean(),
39
- url: zod_1.z.url(),
40
- contribution: exports.contributionDetailsSchema,
41
- created: unixSecondsSchema,
42
- })
43
- .strict();
44
- /**
45
- * The one list envelope (ADR 0014 D1): `url` is the path that was listed.
46
- */
47
- function listSchema(item) {
48
- return zod_1.z
49
- .object({
50
- object: zod_1.z.literal('list'),
51
- data: zod_1.z.array(item),
52
- has_more: zod_1.z.boolean(),
53
- url: zod_1.z.string(),
54
- })
55
- .strict();
56
- }
57
- exports.contributionListSchema = listSchema(exports.contributionLinkSchema);
58
- exports.contributionCollectionSchema = zod_1.z
59
- .object({
60
- id: zod_1.z.string(),
61
- object: zod_1.z.literal('payment_intent'),
62
- amount: zod_1.z.string(),
63
- currency: zod_1.z.literal('FAIR'),
64
- status: zod_1.z.string(),
65
- created: unixSecondsSchema,
66
- refund_capability: zod_1.z.literal('unsupported_non_custodial'),
67
- refunds: zod_1.z.array(zod_1.z
68
- .object({
69
- id: zod_1.z.string(),
70
- object: zod_1.z.literal('refund'),
71
- amount: zod_1.z.string(),
72
- status: zod_1.z.string(),
73
- created: unixSecondsSchema,
74
- })
75
- .strict()),
76
- })
77
- .strict();
78
- exports.contributionCollectionListSchema = listSchema(exports.contributionCollectionSchema);
79
- const unixSecondsQuery = zod_1.z.coerce.number().int().nonnegative();
80
- /**
81
- * The list parameters every list accepts (ADR 0014 D1), newest first:
82
- *
83
- * - `limit` 1–100, default 10;
84
- * - `starting_after` — the id of the last object of the previous page — or
85
- * `ending_before` — the id of the first object of the current one, which
86
- * pages backwards and still answers newest first. Never both;
87
- * - `created` (one second) or `created[gt|gte|lt|lte]`, Unix seconds.
88
- *
89
- * Cursors are resolved by the gateway inside the caller's scope; one naming
90
- * anything else is a 400 with `param` naming the cursor.
91
- */
92
- exports.listQueryShape = {
93
- limit: zod_1.z.coerce.number().int().min(1).max(100).default(10),
94
- starting_after: zod_1.z.string().min(1).max(255).optional(),
95
- ending_before: zod_1.z.string().min(1).max(255).optional(),
96
- created: zod_1.z
97
- .union([
98
- unixSecondsQuery.transform((x) => ({ gte: x, lte: x })),
99
- zod_1.z
100
- .object({
101
- gt: unixSecondsQuery.optional(),
102
- gte: unixSecondsQuery.optional(),
103
- lt: unixSecondsQuery.optional(),
104
- lte: unixSecondsQuery.optional(),
105
- })
106
- .strict(),
107
- ])
108
- .optional(),
2
+ // @peable.to/contracts — the Peable wire, declared once (ADR 0014 D5).
3
+ //
4
+ // Every public route's request and response schema is a Zod schema here. The
5
+ // backend validates with these exact objects, the OpenAPI document
6
+ // (`@peable.to/contracts/openapi`) is generated from them, `@peable.to/shared-types`
7
+ // re-exports their inferred types, and `@peable.to/sdk`'s resource methods are
8
+ // generated from the route list.
9
+ //
10
+ // Importing this root constructs every schema. A bundle that only needs the
11
+ // closed value sets imports `@peable.to/contracts/vocabulary`.
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
24
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
109
25
  };
110
- /**
111
- * Paging a contribution list: the list parameters (`link_…` cursors for links,
112
- * `pi_…` for collections) plus the environment the Test/Live toggle selects.
113
- */
114
- exports.contributionPageQuerySchema = zod_1.z
115
- .object({
116
- ...exports.listQueryShape,
117
- environment: zod_1.z.enum(['development', 'staging', 'production']),
118
- })
119
- .strict()
120
- .refine((query) => query.starting_after === undefined || query.ending_before === undefined, {
121
- message: 'starting_after and ending_before are mutually exclusive',
122
- path: ['ending_before'],
123
- });
124
- exports.contributionMintSchema = zod_1.z
125
- .object({ amount: exports.contributionAmountSchema.optional() })
126
- .strict();
127
- exports.contributionOperationKeySchema = zod_1.z.string().uuid();
128
- exports.contributionPatchSchema = zod_1.z.object({ active: zod_1.z.boolean() }).strict();
129
- function decimalContributionAmount(value) {
130
- if (!/^(0|[1-9][0-9]{0,7})(\.[0-9]{1,8})?$/.test(value))
131
- throw new Error('Enter a FAIR amount with at most eight decimals');
132
- const [whole = '0', fraction = ''] = value.split('.');
133
- return exports.contributionAmountSchema.parse((BigInt(whole) * 100000000n + BigInt(fraction.padEnd(8, '0'))).toString());
134
- }
135
- function formatContributionAmount(value) {
136
- const units = BigInt(value);
137
- const fraction = (units % 100000000n).toString().padStart(8, '0').replace(/0+$/, '');
138
- return (units / 100000000n).toString() + (fraction ? `.${fraction}` : '');
139
- }
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ __exportStar(require("./common/address"), exports);
28
+ __exportStar(require("./common/envelopes"), exports);
29
+ __exportStar(require("./common/objects"), exports);
30
+ __exportStar(require("./common/params"), exports);
31
+ __exportStar(require("./common/primitives"), exports);
32
+ __exportStar(require("./route"), exports);
33
+ __exportStar(require("./routes"), exports);
34
+ __exportStar(require("./vocabulary"), exports);
35
+ __exportStar(require("./resources/core"), exports);
36
+ __exportStar(require("./resources/payments"), exports);
37
+ __exportStar(require("./resources/checkout"), exports);
38
+ __exportStar(require("./resources/catalog"), exports);
39
+ __exportStar(require("./resources/billingEngine"), exports);
40
+ __exportStar(require("./resources/connect"), exports);
41
+ __exportStar(require("./resources/tax"), exports);
42
+ __exportStar(require("./resources/events"), exports);
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildOpenApiDocument = buildOpenApiDocument;
4
+ const zod_1 = require("zod");
5
+ const envelopes_1 = require("../common/envelopes");
6
+ const objects_1 = require("../common/objects");
7
+ const route_1 = require("../route");
8
+ const routes_1 = require("../routes");
9
+ const version_1 = require("../vocabulary/version");
10
+ const webhooks_1 = require("./webhooks");
11
+ const COMPONENT_PREFIX = '#/components/schemas/';
12
+ /** Apply the registry's documentation (`jsonSchema` replacements, `x-peable-expandable`) to a generated node. */
13
+ function override(ctx) {
14
+ const meta = objects_1.contractRegistry.get(ctx.zodSchema);
15
+ const global = zod_1.z.globalRegistry.get(ctx.zodSchema);
16
+ if (meta?.jsonSchema) {
17
+ for (const key of Object.keys(ctx.jsonSchema))
18
+ delete ctx.jsonSchema[key];
19
+ Object.assign(ctx.jsonSchema, meta.jsonSchema);
20
+ }
21
+ const description = meta?.description ?? global?.description;
22
+ if (description !== undefined && ctx.jsonSchema.description === undefined)
23
+ ctx.jsonSchema.description = description;
24
+ if (meta?.['x-peable-expandable'] !== undefined)
25
+ ctx.jsonSchema['x-peable-expandable'] = meta['x-peable-expandable'];
26
+ if (meta?.examples !== undefined)
27
+ ctx.jsonSchema.examples = [...meta.examples];
28
+ // `jsonSchema`/`id` are registry bookkeeping, never document fields.
29
+ delete ctx.jsonSchema.jsonSchema;
30
+ delete ctx.jsonSchema.id;
31
+ }
32
+ function toJson(schema, io) {
33
+ const json = zod_1.z.toJSONSchema(schema, {
34
+ target: 'draft-2020-12',
35
+ metadata: objects_1.contractRegistry,
36
+ io,
37
+ unrepresentable: 'any',
38
+ reused: 'inline',
39
+ cycles: 'ref',
40
+ override,
41
+ });
42
+ delete json.$schema;
43
+ return hoistDefinitions(json);
44
+ }
45
+ /** Every `$defs` entry produced while converting one schema, by component name. */
46
+ const collected = new Map();
47
+ /**
48
+ * `z.toJSONSchema` puts the registered objects a schema reaches into its own
49
+ * `$defs` and points at them with `#/components/schemas/<id>`; lift them into
50
+ * the document's components once.
51
+ */
52
+ function hoistDefinitions(json) {
53
+ const defs = json.$defs;
54
+ delete json.$defs;
55
+ const rewritten = rewriteRefs(json);
56
+ if (defs) {
57
+ for (const [id, def] of Object.entries(defs)) {
58
+ if (id.startsWith('__schema'))
59
+ throw new Error(`an unregistered recursive schema produced '${id}'; register it with defineComponent`);
60
+ if (!collected.has(id))
61
+ collected.set(id, rewriteRefs(def));
62
+ }
63
+ }
64
+ return rewritten;
65
+ }
66
+ /** `#/$defs/<id>` → `#/components/schemas/<id>`, everywhere in a node. */
67
+ function rewriteRefs(value) {
68
+ if (Array.isArray(value))
69
+ return value.map(rewriteRefs);
70
+ if (value === null || typeof value !== 'object')
71
+ return value;
72
+ return Object.fromEntries(Object.entries(value).map(([key, inner]) => [
73
+ key,
74
+ key === '$ref' && typeof inner === 'string'
75
+ ? inner.replace(/^#\/\$defs\//, COMPONENT_PREFIX)
76
+ : rewriteRefs(inner),
77
+ ]));
78
+ }
79
+ /** The JSON Schema of a registered component, or the inline one. */
80
+ function schemaRef(schema, io) {
81
+ const id = objects_1.contractRegistry.get(schema)?.id;
82
+ if (id !== undefined) {
83
+ if (!collected.has(id)) {
84
+ // A registered root converts to a `$ref` plus its own definition in
85
+ // `$defs`, which `hoistDefinitions` has just collected under `id`.
86
+ const json = toJson(schema, io);
87
+ if (!collected.has(id)) {
88
+ delete json.$id;
89
+ collected.set(id, json);
90
+ }
91
+ }
92
+ return { $ref: `${COMPONENT_PREFIX}${id}` };
93
+ }
94
+ return toJson(schema, io);
95
+ }
96
+ const requestIdHeader = {
97
+ 'Request-Id': {
98
+ description: 'Identifies this request to Peable support.',
99
+ schema: { type: 'string' },
100
+ },
101
+ 'Peable-Version': {
102
+ description: 'The date of the wire this answer is spelled in.',
103
+ schema: { type: 'string', example: version_1.PEABLE_API_VERSION },
104
+ },
105
+ };
106
+ const SECURITY = {
107
+ service: [{ oxyServiceToken: [] }],
108
+ user: [{ oxyUserSession: [] }],
109
+ public: [],
110
+ };
111
+ /** A query schema's properties as OpenAPI parameters. */
112
+ function queryParameters(query) {
113
+ const json = toJson(query, 'input');
114
+ const properties = (json.properties ?? {});
115
+ const required = new Set(json.required ?? []);
116
+ return Object.entries(properties).map(([name, schema]) => {
117
+ const { description, ...rest } = schema;
118
+ const isArray = rest.type === 'array';
119
+ const isObject = rest.type === 'object' || Array.isArray(rest.oneOf);
120
+ return {
121
+ in: 'query',
122
+ name: isArray ? `${name}[]` : name,
123
+ ...(required.has(name) ? { required: true } : {}),
124
+ ...(description === undefined ? {} : { description }),
125
+ ...(isObject ? { style: 'deepObject', explode: true } : {}),
126
+ schema: rest,
127
+ };
128
+ });
129
+ }
130
+ function operation(route) {
131
+ const parameters = (0, route_1.pathParamNames)(route.path).map((name) => ({
132
+ in: 'path',
133
+ name,
134
+ required: true,
135
+ ...(route.params?.[name] === undefined ? {} : { description: route.params[name] }),
136
+ schema: { type: 'string' },
137
+ }));
138
+ if (route.query)
139
+ parameters.push(...queryParameters(route.query));
140
+ if (route.idempotent)
141
+ parameters.push({
142
+ in: 'header',
143
+ name: 'Idempotency-Key',
144
+ description: 'Makes a retry safe: the same key with the same request answers the stored response for 24 hours (ADR 0014 D3). The SDK sends one on every POST.',
145
+ schema: { type: 'string', maxLength: 255 },
146
+ });
147
+ if (route.peableAccount)
148
+ parameters.push({
149
+ in: 'header',
150
+ name: 'Peable-Account',
151
+ description: 'A platform acting on one of its connected accounts (`ca_…`).',
152
+ schema: { type: 'string' },
153
+ });
154
+ parameters.push({
155
+ in: 'header',
156
+ name: 'Peable-Version',
157
+ description: `The wire date the caller was written against. Only \`${version_1.PEABLE_API_VERSION}\` exists.`,
158
+ schema: { type: 'string', enum: [version_1.PEABLE_API_VERSION] },
159
+ });
160
+ const status = String(route.status ?? 200);
161
+ const response = route.response;
162
+ let content;
163
+ if ((0, route_1.isJsonResponse)(response)) {
164
+ content = { 'application/json': { schema: schemaRef(response, 'output') } };
165
+ }
166
+ else if (response.kind === 'binary') {
167
+ content = { [response.contentType]: { schema: { type: 'string', format: 'binary' } } };
168
+ }
169
+ else {
170
+ content = {
171
+ 'text/event-stream': {
172
+ schema: { type: 'string' },
173
+ 'x-peable-event': schemaRef(response.event, 'output'),
174
+ },
175
+ };
176
+ }
177
+ return {
178
+ operationId: route.operationId,
179
+ tags: [route.tag],
180
+ summary: route.summary,
181
+ ...(route.description === undefined ? {} : { description: route.description }),
182
+ security: SECURITY[route.auth],
183
+ ...(route.scope === undefined ? {} : { 'x-peable-scope': route.scope }),
184
+ ...(route.sdk === undefined ? {} : { 'x-peable-sdk': route.sdk }),
185
+ ...(route.expandable === undefined ? {} : { 'x-peable-expandable': route.expandable }),
186
+ ...(route.testModeOnly ? { 'x-peable-test-mode-only': true } : {}),
187
+ parameters,
188
+ ...(route.body
189
+ ? {
190
+ requestBody: {
191
+ required: true,
192
+ content: {
193
+ [route.bodyEncoding === 'multipart' ? 'multipart/form-data' : 'application/json']: {
194
+ schema: toJson(route.body, 'input'),
195
+ },
196
+ },
197
+ },
198
+ }
199
+ : {}),
200
+ responses: {
201
+ [status]: {
202
+ description: 'Success',
203
+ headers: requestIdHeader,
204
+ ...(status === '204' ? {} : { content }),
205
+ },
206
+ default: {
207
+ description: 'The error envelope; the HTTP status and `error.type` identify the failure.',
208
+ headers: requestIdHeader,
209
+ content: { 'application/json': { schema: schemaRef(envelopes_1.errorEnvelopeSchema, 'output') } },
210
+ },
211
+ },
212
+ };
213
+ }
214
+ /** Sort an object's keys, recursively, so the document is byte-stable. */
215
+ function sortKeys(value, depth = 0) {
216
+ if (Array.isArray(value))
217
+ return value.map((item) => sortKeys(item, depth + 1));
218
+ if (value === null || typeof value !== 'object')
219
+ return value;
220
+ const entries = Object.entries(value);
221
+ // Only component and path maps are sorted: a schema's own key order (type
222
+ // before properties) reads better as generated.
223
+ return Object.fromEntries(entries.map(([k, v]) => [k, sortKeys(v, depth + 1)]));
224
+ }
225
+ /** Generate the whole document. Pure: the same contracts give the same bytes. */
226
+ function buildOpenApiDocument() {
227
+ var _a;
228
+ collected.clear();
229
+ const paths = {};
230
+ const tags = new Set();
231
+ for (const route of routes_1.routes) {
232
+ paths[_a = route.path] ?? (paths[_a] = {});
233
+ const methods = paths[route.path];
234
+ if (methods[route.method] !== undefined)
235
+ throw new Error(`${route.method.toUpperCase()} ${route.path} is declared twice`);
236
+ methods[route.method] = operation(route);
237
+ tags.add(route.tag);
238
+ }
239
+ const webhooks = {};
240
+ for (const event of (0, webhooks_1.webhookEvents)()) {
241
+ webhooks[event.type] = {
242
+ post: {
243
+ operationId: `webhook_${event.type.replace(/[^a-z0-9]+/g, '_')}`,
244
+ summary: event.type,
245
+ ...(event.description === undefined ? {} : { description: event.description }),
246
+ tags: ['Webhook events'],
247
+ parameters: [
248
+ {
249
+ in: 'header',
250
+ name: 'Peable-Signature',
251
+ required: true,
252
+ description: '`t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">`, one `v1=` per active secret while a secret is rolling. Verify with `peable.webhooks.constructEvent`.',
253
+ schema: { type: 'string' },
254
+ },
255
+ ],
256
+ requestBody: {
257
+ required: true,
258
+ content: { 'application/json': { schema: schemaRef(event.schema, 'output') } },
259
+ },
260
+ responses: { '2XX': { description: 'Acknowledged. Anything else is retried.' } },
261
+ },
262
+ };
263
+ tags.add('Webhook events');
264
+ }
265
+ const schemas = Object.fromEntries([...collected.entries()].sort(([a], [b]) => a.localeCompare(b)));
266
+ return sortKeys({
267
+ openapi: '3.1.0',
268
+ info: {
269
+ title: 'Peable API',
270
+ version: version_1.PEABLE_API_VERSION,
271
+ description: 'The Peable payments API (Orbit): FairCoin and card payments, Checkout, Payment Links, Billing, Connect and Tax. Amounts are base-unit integer strings; instants are Unix seconds; every object carries `id`, `object` and `livemode`. Guides: https://oxy.so/developers/docs/peable/.',
272
+ contact: { name: 'Peable', url: 'https://oxy.so/developers/docs/peable/' },
273
+ license: { name: 'MIT', identifier: 'MIT' },
274
+ },
275
+ servers: [{ url: 'https://api.peable.to', description: 'Production (test and live modes)' }],
276
+ tags: [...tags].sort().map((name) => ({ name })),
277
+ paths: Object.fromEntries(Object.entries(paths).sort(([a], [b]) => a.localeCompare(b))),
278
+ webhooks: Object.fromEntries(Object.entries(webhooks).sort(([a], [b]) => a.localeCompare(b))),
279
+ components: {
280
+ securitySchemes: {
281
+ oxyServiceToken: {
282
+ type: 'http',
283
+ scheme: 'bearer',
284
+ bearerFormat: 'Oxy service token (EdDSA JWT)',
285
+ description: "Your server's Oxy service token, minted from its application credential. `@peable.to/sdk` mints and refreshes it for you.",
286
+ },
287
+ oxyUserSession: {
288
+ type: 'http',
289
+ scheme: 'bearer',
290
+ bearerFormat: 'Oxy user session',
291
+ description: 'A signed-in Oxy user (the Peable app, an Oxy app acting for its user).',
292
+ },
293
+ },
294
+ schemas,
295
+ },
296
+ });
297
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhookEvents = exports.buildOpenApiDocument = void 0;
4
+ var document_1 = require("./document");
5
+ Object.defineProperty(exports, "buildOpenApiDocument", { enumerable: true, get: function () { return document_1.buildOpenApiDocument; } });
6
+ var webhooks_1 = require("./webhooks");
7
+ Object.defineProperty(exports, "webhookEvents", { enumerable: true, get: function () { return webhooks_1.webhookEvents; } });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhookEvents = webhookEvents;
4
+ const events_1 = require("../resources/events/events");
5
+ const events_2 = require("../vocabulary/events");
6
+ /**
7
+ * Every event type the gateway emits, with its payload: one entry per member
8
+ * of `WEBHOOK_EVENT_TYPES`, its body the `Event` envelope with `type` fixed and
9
+ * `data.object` the object `WEBHOOK_EVENT_OBJECTS` names.
10
+ */
11
+ function webhookEvents() {
12
+ return events_2.WEBHOOK_EVENT_TYPES.map((type) => ({
13
+ type,
14
+ description: events_1.WEBHOOK_EVENT_DESCRIPTIONS[type],
15
+ schema: (0, events_1.eventSchemaOf)(type),
16
+ }));
17
+ }