@peable.to/contracts 0.4.0 → 1.0.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 (316) 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/errors.js +174 -0
  92. package/dist/cjs/vocabulary/events.js +176 -0
  93. package/dist/cjs/vocabulary/files.js +44 -0
  94. package/dist/cjs/vocabulary/index.js +37 -0
  95. package/dist/cjs/vocabulary/invoices.js +52 -0
  96. package/dist/cjs/vocabulary/lists.js +22 -0
  97. package/dist/cjs/vocabulary/merchants.js +23 -0
  98. package/dist/cjs/vocabulary/money.js +104 -0
  99. package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
  100. package/dist/cjs/vocabulary/payments.js +195 -0
  101. package/dist/cjs/vocabulary/reporting.js +27 -0
  102. package/dist/cjs/vocabulary/subscriptions.js +60 -0
  103. package/dist/cjs/vocabulary/tax.js +237 -0
  104. package/dist/cjs/vocabulary/version.js +12 -0
  105. package/dist/esm/common/address.js +76 -0
  106. package/dist/esm/common/envelopes.js +95 -0
  107. package/dist/esm/common/objects.js +74 -0
  108. package/dist/esm/common/params.js +203 -0
  109. package/dist/esm/common/primitives.js +35 -0
  110. package/dist/esm/contributions.js +5 -0
  111. package/dist/esm/index.js +26 -134
  112. package/dist/esm/openapi/document.js +294 -0
  113. package/dist/esm/openapi/index.js +2 -0
  114. package/dist/esm/openapi/webhooks.js +14 -0
  115. package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
  116. package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
  117. package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
  118. package/dist/esm/resources/billingEngine/index.js +26 -0
  119. package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
  120. package/dist/esm/resources/billingEngine/invoices.js +506 -0
  121. package/dist/esm/resources/billingEngine/params.js +39 -0
  122. package/dist/esm/resources/billingEngine/public.js +323 -0
  123. package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
  124. package/dist/esm/resources/catalog/billing.js +752 -0
  125. package/dist/esm/resources/catalog/billingSettings.js +128 -0
  126. package/dist/esm/resources/catalog/coupons.js +219 -0
  127. package/dist/esm/resources/catalog/entitlements.js +254 -0
  128. package/dist/esm/resources/catalog/index.js +38 -0
  129. package/dist/esm/resources/catalog/meters.js +276 -0
  130. package/dist/esm/resources/catalog/prices.js +419 -0
  131. package/dist/esm/resources/catalog/products.js +225 -0
  132. package/dist/esm/resources/catalog/promotionCodes.js +171 -0
  133. package/dist/esm/resources/catalog/shared.js +67 -0
  134. package/dist/esm/resources/catalog/testClocks.js +124 -0
  135. package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
  136. package/dist/esm/resources/checkout/contributions.js +167 -0
  137. package/dist/esm/resources/checkout/files.js +130 -0
  138. package/dist/esm/resources/checkout/index.js +25 -0
  139. package/dist/esm/resources/checkout/merchants.js +287 -0
  140. package/dist/esm/resources/checkout/paymentLinks.js +327 -0
  141. package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
  142. package/dist/esm/resources/checkout/shared.js +363 -0
  143. package/dist/esm/resources/connect/account.js +329 -0
  144. package/dist/esm/resources/connect/applicationFees.js +110 -0
  145. package/dist/esm/resources/connect/balance.js +209 -0
  146. package/dist/esm/resources/connect/connectedAccounts.js +257 -0
  147. package/dist/esm/resources/connect/index.js +34 -0
  148. package/dist/esm/resources/connect/onboarding.js +79 -0
  149. package/dist/esm/resources/connect/payouts.js +193 -0
  150. package/dist/esm/resources/connect/reporting.js +232 -0
  151. package/dist/esm/resources/connect/requestLogs.js +107 -0
  152. package/dist/esm/resources/connect/transfers.js +224 -0
  153. package/dist/esm/resources/core/customers.js +191 -0
  154. package/dist/esm/resources/core/index.js +6 -0
  155. package/dist/esm/resources/core/paymentMethods.js +131 -0
  156. package/dist/esm/resources/events/events.js +353 -0
  157. package/dist/esm/resources/events/index.js +12 -0
  158. package/dist/esm/resources/events/webhookDeliveries.js +90 -0
  159. package/dist/esm/resources/events/webhookEndpoints.js +212 -0
  160. package/dist/esm/resources/payments/charges.js +154 -0
  161. package/dist/esm/resources/payments/disputes.js +201 -0
  162. package/dist/esm/resources/payments/index.js +24 -0
  163. package/dist/esm/resources/payments/paymentIntents.js +526 -0
  164. package/dist/esm/resources/payments/refunds.js +242 -0
  165. package/dist/esm/resources/payments/setupIntents.js +155 -0
  166. package/dist/esm/resources/payments/social.js +179 -0
  167. package/dist/esm/resources/payments/testHelpers.js +36 -0
  168. package/dist/esm/resources/tax/assessments.js +214 -0
  169. package/dist/esm/resources/tax/businessProfile.js +96 -0
  170. package/dist/esm/resources/tax/calculations.js +173 -0
  171. package/dist/esm/resources/tax/capabilities.js +39 -0
  172. package/dist/esm/resources/tax/codes.js +34 -0
  173. package/dist/esm/resources/tax/complianceActions.js +53 -0
  174. package/dist/esm/resources/tax/deadlines.js +56 -0
  175. package/dist/esm/resources/tax/documents.js +125 -0
  176. package/dist/esm/resources/tax/index.js +63 -0
  177. package/dist/esm/resources/tax/locationEvidence.js +128 -0
  178. package/dist/esm/resources/tax/operatingLocations.js +95 -0
  179. package/dist/esm/resources/tax/products.js +64 -0
  180. package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
  181. package/dist/esm/resources/tax/registrations.js +79 -0
  182. package/dist/esm/resources/tax/reports.js +89 -0
  183. package/dist/esm/resources/tax/reviewItems.js +113 -0
  184. package/dist/esm/resources/tax/ruleSet.js +65 -0
  185. package/dist/esm/resources/tax/salesDestinations.js +91 -0
  186. package/dist/esm/resources/tax/settings.js +101 -0
  187. package/dist/esm/resources/tax/shared.js +58 -0
  188. package/dist/esm/resources/tax/transactions.js +99 -0
  189. package/dist/esm/route.js +16 -0
  190. package/dist/esm/routes.js +27 -0
  191. package/dist/esm/vocabulary/billingPortal.js +12 -0
  192. package/dist/esm/vocabulary/catalog.js +106 -0
  193. package/dist/esm/vocabulary/checkout.js +50 -0
  194. package/dist/esm/vocabulary/connect.js +92 -0
  195. package/dist/esm/vocabulary/errors.js +169 -0
  196. package/dist/esm/vocabulary/events.js +173 -0
  197. package/dist/esm/vocabulary/files.js +41 -0
  198. package/dist/esm/vocabulary/index.js +21 -0
  199. package/dist/esm/vocabulary/invoices.js +49 -0
  200. package/dist/esm/vocabulary/lists.js +19 -0
  201. package/dist/esm/vocabulary/merchants.js +20 -0
  202. package/dist/esm/vocabulary/money.js +98 -0
  203. package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
  204. package/dist/esm/vocabulary/payments.js +192 -0
  205. package/dist/esm/vocabulary/reporting.js +24 -0
  206. package/dist/esm/vocabulary/subscriptions.js +57 -0
  207. package/dist/esm/vocabulary/tax.js +233 -0
  208. package/dist/esm/vocabulary/version.js +9 -0
  209. package/dist/types/common/address.d.ts +62 -0
  210. package/dist/types/common/envelopes.d.ts +88 -0
  211. package/dist/types/common/objects.d.ts +107 -0
  212. package/dist/types/common/params.d.ts +156 -0
  213. package/dist/types/common/primitives.d.ts +56 -0
  214. package/dist/types/contributions.d.ts +1 -0
  215. package/dist/types/index.d.ts +16 -171
  216. package/dist/types/openapi/document.d.ts +16 -0
  217. package/dist/types/openapi/index.d.ts +2 -0
  218. package/dist/types/openapi/webhooks.d.ts +15 -0
  219. package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
  220. package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
  221. package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
  222. package/dist/types/resources/billingEngine/index.d.ts +6071 -0
  223. package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
  224. package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
  225. package/dist/types/resources/billingEngine/params.d.ts +51 -0
  226. package/dist/types/resources/billingEngine/public.d.ts +1860 -0
  227. package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
  228. package/dist/types/resources/catalog/billing.d.ts +1723 -0
  229. package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
  230. package/dist/types/resources/catalog/coupons.d.ts +403 -0
  231. package/dist/types/resources/catalog/entitlements.d.ts +422 -0
  232. package/dist/types/resources/catalog/index.d.ts +3155 -0
  233. package/dist/types/resources/catalog/meters.d.ts +474 -0
  234. package/dist/types/resources/catalog/prices.d.ts +1091 -0
  235. package/dist/types/resources/catalog/products.d.ts +430 -0
  236. package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
  237. package/dist/types/resources/catalog/shared.d.ts +34 -0
  238. package/dist/types/resources/catalog/testClocks.d.ts +220 -0
  239. package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
  240. package/dist/types/resources/checkout/contributions.d.ts +375 -0
  241. package/dist/types/resources/checkout/files.d.ts +280 -0
  242. package/dist/types/resources/checkout/index.d.ts +5678 -0
  243. package/dist/types/resources/checkout/merchants.d.ts +395 -0
  244. package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
  245. package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
  246. package/dist/types/resources/checkout/shared.d.ts +419 -0
  247. package/dist/types/resources/connect/account.d.ts +483 -0
  248. package/dist/types/resources/connect/applicationFees.d.ts +198 -0
  249. package/dist/types/resources/connect/balance.d.ts +399 -0
  250. package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
  251. package/dist/types/resources/connect/index.d.ts +2094 -0
  252. package/dist/types/resources/connect/onboarding.d.ts +95 -0
  253. package/dist/types/resources/connect/payouts.d.ts +527 -0
  254. package/dist/types/resources/connect/reporting.d.ts +506 -0
  255. package/dist/types/resources/connect/requestLogs.d.ts +236 -0
  256. package/dist/types/resources/connect/transfers.d.ts +436 -0
  257. package/dist/types/resources/core/customers.d.ts +619 -0
  258. package/dist/types/resources/core/index.d.ts +679 -0
  259. package/dist/types/resources/core/paymentMethods.d.ts +336 -0
  260. package/dist/types/resources/events/events.d.ts +731 -0
  261. package/dist/types/resources/events/index.d.ts +1727 -0
  262. package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
  263. package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
  264. package/dist/types/resources/payments/charges.d.ts +390 -0
  265. package/dist/types/resources/payments/disputes.d.ts +822 -0
  266. package/dist/types/resources/payments/index.d.ts +3517 -0
  267. package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
  268. package/dist/types/resources/payments/refunds.d.ts +684 -0
  269. package/dist/types/resources/payments/setupIntents.d.ts +391 -0
  270. package/dist/types/resources/payments/social.d.ts +266 -0
  271. package/dist/types/resources/payments/testHelpers.d.ts +178 -0
  272. package/dist/types/resources/tax/assessments.d.ts +787 -0
  273. package/dist/types/resources/tax/businessProfile.d.ts +134 -0
  274. package/dist/types/resources/tax/calculations.d.ts +261 -0
  275. package/dist/types/resources/tax/capabilities.d.ts +81 -0
  276. package/dist/types/resources/tax/codes.d.ts +29 -0
  277. package/dist/types/resources/tax/complianceActions.d.ts +97 -0
  278. package/dist/types/resources/tax/deadlines.d.ts +133 -0
  279. package/dist/types/resources/tax/documents.d.ts +257 -0
  280. package/dist/types/resources/tax/index.d.ts +1946 -0
  281. package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
  282. package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
  283. package/dist/types/resources/tax/products.d.ts +68 -0
  284. package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
  285. package/dist/types/resources/tax/registrations.d.ts +103 -0
  286. package/dist/types/resources/tax/reports.d.ts +129 -0
  287. package/dist/types/resources/tax/reviewItems.d.ts +226 -0
  288. package/dist/types/resources/tax/ruleSet.d.ts +219 -0
  289. package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
  290. package/dist/types/resources/tax/settings.d.ts +122 -0
  291. package/dist/types/resources/tax/shared.d.ts +43 -0
  292. package/dist/types/resources/tax/transactions.d.ts +404 -0
  293. package/dist/types/route.d.ts +86 -0
  294. package/dist/types/routes.d.ts +23 -0
  295. package/dist/types/vocabulary/billingPortal.d.ts +15 -0
  296. package/dist/types/vocabulary/catalog.d.ts +97 -0
  297. package/dist/types/vocabulary/checkout.d.ts +49 -0
  298. package/dist/types/vocabulary/connect.d.ts +62 -0
  299. package/dist/types/vocabulary/errors.d.ts +145 -0
  300. package/dist/types/vocabulary/events.d.ts +171 -0
  301. package/dist/types/vocabulary/files.d.ts +30 -0
  302. package/dist/types/vocabulary/index.d.ts +17 -0
  303. package/dist/types/vocabulary/invoices.d.ts +39 -0
  304. package/dist/types/vocabulary/lists.d.ts +9 -0
  305. package/dist/types/vocabulary/merchants.d.ts +9 -0
  306. package/dist/types/vocabulary/money.d.ts +59 -0
  307. package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
  308. package/dist/types/vocabulary/payments.d.ts +117 -0
  309. package/dist/types/vocabulary/reporting.d.ts +18 -0
  310. package/dist/types/vocabulary/subscriptions.d.ts +45 -0
  311. package/dist/types/vocabulary/tax.d.ts +163 -0
  312. package/dist/types/vocabulary/version.d.ts +10 -0
  313. package/package.json +51 -11
  314. package/dist/cjs/openapi.js +0 -165
  315. package/dist/esm/openapi.js +0 -161
  316. package/dist/types/openapi.d.ts +0 -148
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.priceRoutes = exports.listPricesQuery = exports.updatePriceParams = exports.createPriceParams = exports.defaultPriceDataParams = exports.priceDataParams = exports.priceSchema = exports.priceRecurringSchema = exports.priceTransformQuantitySchema = exports.priceTierSchema = void 0;
4
+ exports.priceShapeOf = priceShapeOf;
5
+ const zod_1 = require("zod");
6
+ const envelopes_1 = require("../../common/envelopes");
7
+ const objects_1 = require("../../common/objects");
8
+ const params_1 = require("../../common/params");
9
+ const primitives_1 = require("../../common/primitives");
10
+ const route_1 = require("../../route");
11
+ const catalog_1 = require("../../vocabulary/catalog");
12
+ const shared_1 = require("./shared");
13
+ /**
14
+ * Prices (`price_…`, ADR 0018) — how much a product costs, in one currency,
15
+ * once or per interval. A price is never deleted and its amount never
16
+ * changes: archive it (`active: false`) and create another.
17
+ */
18
+ /**
19
+ * One tier of a tiered price. `up_to` is the last quantity the tier covers
20
+ * (inclusive), and `null` on the last tier, which covers everything above —
21
+ * sent as `'inf'`. Each amount is a base-unit string; at least one is set.
22
+ */
23
+ exports.priceTierSchema = (0, objects_1.defineComponent)('PriceTier', zod_1.z
24
+ .object({
25
+ up_to: zod_1.z
26
+ .number()
27
+ .int()
28
+ .nullable()
29
+ .describe('The last quantity this tier covers; `null` on the last tier.'),
30
+ unit_amount: primitives_1.amount.nullable(),
31
+ flat_amount: primitives_1.amount.nullable(),
32
+ })
33
+ .strict());
34
+ /**
35
+ * Divide the quantity before pricing it: `divide_by: 10, round: 'up'` bills
36
+ * 11 units as 2 packs of ten. Per-unit prices only.
37
+ */
38
+ exports.priceTransformQuantitySchema = (0, objects_1.defineComponent)('PriceTransformQuantity', zod_1.z
39
+ .object({
40
+ divide_by: zod_1.z.number().int(),
41
+ round: zod_1.z.enum(catalog_1.TRANSFORM_QUANTITY_ROUNDS),
42
+ })
43
+ .strict());
44
+ exports.priceRecurringSchema = (0, objects_1.defineComponent)('PriceRecurring', zod_1.z
45
+ .object({
46
+ interval: zod_1.z.enum(catalog_1.RECURRING_INTERVALS),
47
+ interval_count: zod_1.z
48
+ .number()
49
+ .int()
50
+ .describe("Intervals between billings: `interval: 'month', interval_count: 3` is quarterly. At most three years."),
51
+ usage_type: zod_1.z.enum(catalog_1.RECURRING_USAGE_TYPES),
52
+ meter: zod_1.z
53
+ .string()
54
+ .nullable()
55
+ .describe('The meter (`mtr_…`) a `metered` price bills; `null` when `licensed`.'),
56
+ })
57
+ .strict());
58
+ exports.priceSchema = (0, objects_1.defineObject)('price', 'Price', zod_1.z
59
+ .object({
60
+ id: zod_1.z.string(),
61
+ object: zod_1.z.literal('price'),
62
+ livemode: primitives_1.livemode,
63
+ active: zod_1.z.boolean(),
64
+ product: (0, objects_1.expandable)('product', 'The product it prices: `prod_…`, or the Product with `expand[]=product`.'),
65
+ currency: primitives_1.currency,
66
+ unit_amount: primitives_1.amount.nullable().describe('Base units per unit; `null` on a tiered price.'),
67
+ billing_scheme: zod_1.z.enum(catalog_1.PRICE_BILLING_SCHEMES),
68
+ tiers: zod_1.z
69
+ .array(exports.priceTierSchema)
70
+ .nullable()
71
+ .describe('`null` unless `billing_scheme` is `tiered`.'),
72
+ tiers_mode: zod_1.z.enum(catalog_1.PRICE_TIERS_MODES).nullable(),
73
+ transform_quantity: exports.priceTransformQuantitySchema.nullable(),
74
+ type: zod_1.z.enum(catalog_1.PRICE_TYPES),
75
+ recurring: exports.priceRecurringSchema
76
+ .nullable()
77
+ .describe('`null` exactly when `type` is `one_time`.'),
78
+ tax_behavior: zod_1.z
79
+ .enum(catalog_1.PRICE_TAX_BEHAVIORS)
80
+ .describe('Whether the price includes tax (Peable Tax). `unspecified` defers to the merchant default; once `inclusive` or `exclusive` it never changes.'),
81
+ lookup_key: zod_1.z
82
+ .string()
83
+ .nullable()
84
+ .describe("The merchant's own stable name for this price, unique among its prices (per mode): retrieve the current price of a plan with `lookup_keys[]`."),
85
+ nickname: zod_1.z.string().nullable(),
86
+ metadata: primitives_1.metadata,
87
+ created: primitives_1.unixSeconds,
88
+ })
89
+ .strict(), {
90
+ description: 'How much a product costs, in one currency, once or per interval. Immutable once created except for `active`, `nickname`, `metadata`, `lookup_key` and — while `unspecified` — `tax_behavior`.',
91
+ examples: [
92
+ {
93
+ id: 'price_0193b8f2c1a87d3e9f4b',
94
+ object: 'price',
95
+ livemode: false,
96
+ active: true,
97
+ product: 'prod_0193b8f2c1a87d3e9f4a',
98
+ currency: 'EUR',
99
+ unit_amount: '999',
100
+ billing_scheme: 'per_unit',
101
+ tiers: null,
102
+ tiers_mode: null,
103
+ transform_quantity: null,
104
+ type: 'recurring',
105
+ recurring: { interval: 'month', interval_count: 1, usage_type: 'licensed', meter: null },
106
+ tax_behavior: 'inclusive',
107
+ lookup_key: 'plus_monthly',
108
+ nickname: 'Plus, monthly',
109
+ metadata: {},
110
+ created: 1793750400,
111
+ },
112
+ ],
113
+ });
114
+ // ---- The price shape, as a request names it --------------------------------------
115
+ const recurringParams = zod_1.z
116
+ .object({
117
+ interval: zod_1.z.enum(catalog_1.RECURRING_INTERVALS),
118
+ interval_count: shared_1.countParam.optional().describe('Default 1.'),
119
+ usage_type: zod_1.z.enum(catalog_1.RECURRING_USAGE_TYPES).optional().describe('Default `licensed`.'),
120
+ meter: zod_1.z
121
+ .string()
122
+ .min(1)
123
+ .max(255)
124
+ .optional()
125
+ .describe("Required with `usage_type: 'metered'`: the meter (`mtr_…`) it bills."),
126
+ })
127
+ .strict();
128
+ const tierParams = zod_1.z
129
+ .object({
130
+ up_to: zod_1.z
131
+ .union([zod_1.z.number().int().min(1).max(Number.MAX_SAFE_INTEGER), zod_1.z.literal('inf')])
132
+ .describe("A positive integer, ascending; the last tier is `'inf'`."),
133
+ unit_amount: shared_1.baseUnitAmountParam.optional(),
134
+ flat_amount: shared_1.baseUnitAmountParam.optional(),
135
+ })
136
+ .strict();
137
+ const transformQuantityParams = zod_1.z
138
+ .object({
139
+ divide_by: shared_1.countParam,
140
+ round: zod_1.z.enum(catalog_1.TRANSFORM_QUANTITY_ROUNDS),
141
+ })
142
+ .strict();
143
+ /** The fields that make up a price's shape, as a request names them. */
144
+ const priceShapeFields = {
145
+ currency: primitives_1.currency,
146
+ unit_amount: shared_1.baseUnitAmountParam
147
+ .optional()
148
+ .describe('Required for `per_unit`; absent for `tiered`.'),
149
+ billing_scheme: zod_1.z.enum(catalog_1.PRICE_BILLING_SCHEMES).optional().describe('Default `per_unit`.'),
150
+ tiers: zod_1.z.array(tierParams).min(1).max(catalog_1.CATALOG_LIMITS.priceTiersMax).optional(),
151
+ tiers_mode: zod_1.z.enum(catalog_1.PRICE_TIERS_MODES).optional(),
152
+ transform_quantity: transformQuantityParams.optional(),
153
+ recurring: recurringParams.optional().describe('Present: a recurring price. Absent: one-time.'),
154
+ tax_behavior: zod_1.z.enum(catalog_1.PRICE_TAX_BEHAVIORS).optional().describe('Default `unspecified`.'),
155
+ };
156
+ function tiersOf(input, currency, issue) {
157
+ let previous = 0;
158
+ return input.map((tier, index) => {
159
+ const last = index === input.length - 1;
160
+ const path = ['tiers', index];
161
+ if (last && tier.up_to !== 'inf') {
162
+ issue([...path, 'up_to'], "the last tier's up_to must be 'inf'");
163
+ }
164
+ else if (!last && tier.up_to === 'inf') {
165
+ issue([...path, 'up_to'], "only the last tier's up_to may be 'inf'");
166
+ }
167
+ else if (tier.up_to !== 'inf') {
168
+ if (tier.up_to <= previous) {
169
+ issue([...path, 'up_to'], 'tier up_to values must ascend');
170
+ }
171
+ previous = tier.up_to;
172
+ }
173
+ if (tier.unit_amount === undefined && tier.flat_amount === undefined) {
174
+ issue(path, 'a tier needs a unit_amount, a flat_amount or both');
175
+ }
176
+ (0, shared_1.amountWithinBound)(issue, tier.unit_amount, currency, [...path, 'unit_amount']);
177
+ (0, shared_1.amountWithinBound)(issue, tier.flat_amount, currency, [...path, 'flat_amount']);
178
+ return {
179
+ up_to: tier.up_to === 'inf' ? null : tier.up_to,
180
+ unit_amount: tier.unit_amount ?? null,
181
+ flat_amount: tier.flat_amount ?? null,
182
+ };
183
+ });
184
+ }
185
+ /**
186
+ * Decide the stored shape of a price from its request fields, adding an issue
187
+ * (with the field's path) for every rule it breaks. Returns `null` when any
188
+ * rule was broken. Amounts are bounded per currency by its decimals
189
+ * (`maxBaseUnits`).
190
+ */
191
+ function priceShapeOf(input, ctx) {
192
+ const { issue, failed } = (0, shared_1.issuer)(ctx);
193
+ const scheme = input.billing_scheme ?? 'per_unit';
194
+ let tiers = null;
195
+ if (scheme === 'per_unit') {
196
+ if (input.unit_amount === undefined) {
197
+ issue(['unit_amount'], 'unit_amount is required for a per_unit price');
198
+ }
199
+ if (input.tiers !== undefined)
200
+ issue(['tiers'], 'tiers are only for a tiered price');
201
+ if (input.tiers_mode !== undefined) {
202
+ issue(['tiers_mode'], 'tiers_mode is only for a tiered price');
203
+ }
204
+ (0, shared_1.amountWithinBound)(issue, input.unit_amount, input.currency, ['unit_amount']);
205
+ }
206
+ else {
207
+ if (input.unit_amount !== undefined) {
208
+ issue(['unit_amount'], 'a tiered price takes its amounts from tiers, not unit_amount');
209
+ }
210
+ if (input.tiers_mode === undefined)
211
+ issue(['tiers_mode'], 'tiers_mode is required');
212
+ if (input.transform_quantity !== undefined) {
213
+ issue(['transform_quantity'], 'transform_quantity is only for a per_unit price');
214
+ }
215
+ if (input.tiers === undefined)
216
+ issue(['tiers'], 'tiers are required for a tiered price');
217
+ else
218
+ tiers = tiersOf(input.tiers, input.currency, issue);
219
+ }
220
+ let recurring = null;
221
+ if (input.recurring) {
222
+ const count = input.recurring.interval_count ?? 1;
223
+ const max = catalog_1.RECURRING_INTERVAL_COUNT_MAX[input.recurring.interval];
224
+ if (count > max) {
225
+ issue(['recurring', 'interval_count'], `an interval is at most three years (${max} ${input.recurring.interval}s)`);
226
+ }
227
+ const usageType = input.recurring.usage_type ?? 'licensed';
228
+ const meter = input.recurring.meter;
229
+ if (usageType === 'metered' && meter === undefined) {
230
+ issue(['recurring', 'meter'], 'a metered price names the meter (mtr_…) it bills');
231
+ }
232
+ if (usageType === 'licensed' && meter !== undefined) {
233
+ issue(['recurring', 'meter'], 'only a metered price has a meter');
234
+ }
235
+ recurring = {
236
+ interval: input.recurring.interval,
237
+ intervalCount: count,
238
+ usageType,
239
+ ...(meter !== undefined ? { meterPublicId: meter } : {}),
240
+ };
241
+ }
242
+ if (failed())
243
+ return null;
244
+ return {
245
+ currency: input.currency,
246
+ unitAmount: scheme === 'per_unit' ? (input.unit_amount ?? null) : null,
247
+ billingScheme: scheme,
248
+ tiers,
249
+ tiersMode: scheme === 'tiered' ? (input.tiers_mode ?? null) : null,
250
+ transformQuantity: input.transform_quantity
251
+ ? { divideBy: input.transform_quantity.divide_by, round: input.transform_quantity.round }
252
+ : null,
253
+ recurring,
254
+ taxBehavior: input.tax_behavior ?? 'unspecified',
255
+ };
256
+ }
257
+ /**
258
+ * Inline `price_data` (Stripe's): a one-off per-unit price for a checkout
259
+ * line item or an invoice item that names no stored price. Never stored as a
260
+ * `price_…` by itself.
261
+ */
262
+ const inlinePriceFields = {
263
+ currency: primitives_1.currency,
264
+ unit_amount: shared_1.baseUnitAmountParam,
265
+ recurring: recurringParams.omit({ usage_type: true, meter: true }).optional(),
266
+ tax_behavior: zod_1.z.enum(catalog_1.PRICE_TAX_BEHAVIORS).optional(),
267
+ };
268
+ /** `price_data` — an inline price of an existing product (`product: 'prod_…'`). */
269
+ exports.priceDataParams = zod_1.z
270
+ .object({
271
+ ...inlinePriceFields,
272
+ product: zod_1.z.string().min(1).max(255).describe('The `prod_…` it prices.'),
273
+ })
274
+ .strict()
275
+ .transform((input, ctx) => {
276
+ const shape = priceShapeOf(input, ctx);
277
+ return shape === null ? zod_1.z.NEVER : { product: input.product, shape };
278
+ });
279
+ /** `default_price_data` on a product create — `price_data` for the product being made. */
280
+ exports.defaultPriceDataParams = zod_1.z
281
+ .object(inlinePriceFields)
282
+ .strict()
283
+ .transform((input, ctx) => priceShapeOf(input, ctx) ?? zod_1.z.NEVER);
284
+ const lookupKey = zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.lookupKeyMax);
285
+ const nickname = zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.priceNicknameMax);
286
+ exports.createPriceParams = zod_1.z
287
+ .object({
288
+ ...priceShapeFields,
289
+ product: zod_1.z.string().min(1).max(255),
290
+ lookup_key: lookupKey.optional(),
291
+ transfer_lookup_key: zod_1.z
292
+ .boolean()
293
+ .optional()
294
+ .describe('Move `lookup_key` here from the price that holds it.'),
295
+ nickname: nickname.optional(),
296
+ active: zod_1.z.boolean().optional(),
297
+ metadata: params_1.metadataCreateParam.optional(),
298
+ expand: params_1.expandParam.optional(),
299
+ })
300
+ .strict()
301
+ .transform((input, ctx) => {
302
+ if (input.transfer_lookup_key && input.lookup_key === undefined) {
303
+ ctx.addIssue({
304
+ code: 'custom',
305
+ path: ['transfer_lookup_key'],
306
+ message: 'transfer_lookup_key needs a lookup_key',
307
+ });
308
+ }
309
+ const shape = priceShapeOf(input, ctx);
310
+ return shape === null ? zod_1.z.NEVER : { ...input, shape };
311
+ });
312
+ /** The only mutable fields. `""` clears `nickname` and `lookup_key`. */
313
+ exports.updatePriceParams = zod_1.z
314
+ .object({
315
+ active: zod_1.z.boolean().optional(),
316
+ nickname: (0, shared_1.clearing)(nickname).optional(),
317
+ lookup_key: (0, shared_1.clearing)(lookupKey).optional(),
318
+ transfer_lookup_key: zod_1.z.boolean().optional(),
319
+ tax_behavior: zod_1.z
320
+ .enum(catalog_1.PRICE_TAX_BEHAVIORS)
321
+ .optional()
322
+ .describe("Only while the price's is `unspecified`."),
323
+ metadata: params_1.metadataUpdateParam.optional(),
324
+ expand: params_1.expandParam.optional(),
325
+ })
326
+ .strict()
327
+ .superRefine((body, ctx) => {
328
+ if (body.transfer_lookup_key && (body.lookup_key === undefined || body.lookup_key === null)) {
329
+ ctx.addIssue({
330
+ code: 'custom',
331
+ path: ['transfer_lookup_key'],
332
+ message: 'transfer_lookup_key needs a lookup_key',
333
+ });
334
+ }
335
+ });
336
+ exports.listPricesQuery = (0, params_1.listQuery)({
337
+ product: params_1.idParam.optional(),
338
+ active: shared_1.queryFlag.optional(),
339
+ type: zod_1.z.enum(catalog_1.PRICE_TYPES).optional(),
340
+ currency: primitives_1.currency.optional(),
341
+ lookup_keys: (0, shared_1.queryIdList)(catalog_1.CATALOG_LIMITS.lookupKeysFilterMax).optional().describe('At most 10.'),
342
+ recurring: zod_1.z
343
+ .object({
344
+ interval: zod_1.z.enum(catalog_1.RECURRING_INTERVALS).optional(),
345
+ usage_type: zod_1.z.enum(catalog_1.RECURRING_USAGE_TYPES).optional(),
346
+ })
347
+ .strict()
348
+ .optional(),
349
+ });
350
+ exports.priceRoutes = [
351
+ (0, route_1.defineRoute)({
352
+ operationId: 'createPrice',
353
+ method: 'post',
354
+ path: '/v1/prices',
355
+ tag: 'Prices',
356
+ summary: 'Create a price',
357
+ auth: 'service',
358
+ scope: 'payments:write',
359
+ idempotent: true,
360
+ body: exports.createPriceParams,
361
+ response: exports.priceSchema,
362
+ sdk: 'prices.create',
363
+ expandable: 'price',
364
+ }),
365
+ (0, route_1.defineRoute)({
366
+ operationId: 'listPrices',
367
+ method: 'get',
368
+ path: '/v1/prices',
369
+ tag: 'Prices',
370
+ summary: 'List prices',
371
+ description: '`lookup_keys` (at most 10) finds the current price of a plan by its stable name.',
372
+ auth: 'service',
373
+ scope: 'payments:read',
374
+ query: exports.listPricesQuery,
375
+ response: (0, envelopes_1.listOf)(exports.priceSchema),
376
+ sdk: 'prices.list',
377
+ expandable: 'price',
378
+ }),
379
+ (0, route_1.defineRoute)({
380
+ operationId: 'retrievePrice',
381
+ method: 'get',
382
+ path: '/v1/prices/{id}',
383
+ tag: 'Prices',
384
+ summary: 'Retrieve a price',
385
+ auth: 'service',
386
+ scope: 'payments:read',
387
+ params: { id: 'The price (`price_…`).' },
388
+ query: params_1.expandOnlyQuery,
389
+ response: exports.priceSchema,
390
+ sdk: 'prices.retrieve',
391
+ expandable: 'price',
392
+ }),
393
+ (0, route_1.defineRoute)({
394
+ operationId: 'updatePrice',
395
+ method: 'post',
396
+ path: '/v1/prices/{id}',
397
+ tag: 'Prices',
398
+ summary: 'Update a price',
399
+ description: 'Only `active`, `nickname`, `metadata`, `lookup_key` and — while it is `unspecified` — `tax_behavior` change. To change an amount, create a new price and archive this one.',
400
+ auth: 'service',
401
+ scope: 'payments:write',
402
+ idempotent: true,
403
+ params: { id: 'The price (`price_…`).' },
404
+ body: exports.updatePriceParams,
405
+ response: exports.priceSchema,
406
+ sdk: 'prices.update',
407
+ expandable: 'price',
408
+ }),
409
+ (0, route_1.defineRoute)({
410
+ operationId: 'searchPrices',
411
+ method: 'get',
412
+ path: '/v1/prices/search',
413
+ tag: 'Prices',
414
+ summary: 'Search prices',
415
+ description: "Stripe's query language over `active`, `currency`, `product`, `type`, `lookup_key`, `created` and `metadata['key']`.",
416
+ auth: 'service',
417
+ scope: 'payments:read',
418
+ query: params_1.searchQuery,
419
+ response: (0, envelopes_1.searchResultOf)(exports.priceSchema),
420
+ sdk: 'prices.search',
421
+ expandable: 'price',
422
+ }),
423
+ ];
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.productRoutes = exports.listProductsQuery = exports.updateProductParams = exports.createProductParams = exports.deletedProductSchema = exports.productSchema = exports.productMarketingFeatureSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const envelopes_1 = require("../../common/envelopes");
6
+ const objects_1 = require("../../common/objects");
7
+ const params_1 = require("../../common/params");
8
+ const primitives_1 = require("../../common/primitives");
9
+ const route_1 = require("../../route");
10
+ const catalog_1 = require("../../vocabulary/catalog");
11
+ const tax_1 = require("../../vocabulary/tax");
12
+ const prices_1 = require("./prices");
13
+ const shared_1 = require("./shared");
14
+ /**
15
+ * Products (`prod_…`, ADR 0018) — what a merchant sells; its prices say how
16
+ * much. A product with prices cannot be deleted: archive it with
17
+ * `active: false`.
18
+ */
19
+ /** A product feature shown on pricing tables and checkout (Stripe's marketing features). */
20
+ exports.productMarketingFeatureSchema = (0, objects_1.defineComponent)('ProductMarketingFeature', zod_1.z.object({ name: zod_1.z.string() }).strict());
21
+ exports.productSchema = (0, objects_1.defineObject)('product', 'Product', zod_1.z
22
+ .object({
23
+ id: zod_1.z.string(),
24
+ object: zod_1.z.literal('product'),
25
+ livemode: primitives_1.livemode,
26
+ active: zod_1.z.boolean(),
27
+ name: zod_1.z.string(),
28
+ description: zod_1.z.string().nullable(),
29
+ images: zod_1.z.array(zod_1.z.string()).describe('Up to 8 image URLs.'),
30
+ metadata: primitives_1.metadata,
31
+ tax_code: zod_1.z
32
+ .string()
33
+ .nullable()
34
+ .describe("A Peable Tax code (`txcd_…`), or `null` for the merchant's default."),
35
+ default_price: (0, objects_1.expandable)('price', "The product's default price: `price_…`, or the Price with `expand[]=default_price`.").nullable(),
36
+ unit_label: zod_1.z
37
+ .string()
38
+ .nullable()
39
+ .describe('The unit a quantity counts (`seat`), shown on receipts and invoices.'),
40
+ url: zod_1.z.string().nullable(),
41
+ statement_descriptor: zod_1.z
42
+ .string()
43
+ .nullable()
44
+ .describe('What appears on a card statement; at most 22 characters.'),
45
+ marketing_features: zod_1.z.array(exports.productMarketingFeatureSchema),
46
+ created: primitives_1.unixSeconds,
47
+ updated: primitives_1.unixSeconds,
48
+ })
49
+ .strict(), {
50
+ description: 'What a merchant sells. Its prices say how much. A product with prices cannot be deleted; set `active: false` to archive it.',
51
+ examples: [
52
+ {
53
+ id: 'prod_0193b8f2c1a87d3e9f4a',
54
+ object: 'product',
55
+ livemode: false,
56
+ active: true,
57
+ name: 'Mention Plus',
58
+ description: 'Everything in Mention, plus the Plus features.',
59
+ images: [],
60
+ metadata: {},
61
+ tax_code: 'txcd_10103000',
62
+ default_price: 'price_0193b8f2c1a87d3e9f4b',
63
+ unit_label: null,
64
+ url: null,
65
+ statement_descriptor: null,
66
+ marketing_features: [{ name: 'Longer posts' }],
67
+ created: 1793750400,
68
+ updated: 1793750400,
69
+ },
70
+ ],
71
+ });
72
+ /** What `DELETE /v1/products/{id}` answers. */
73
+ exports.deletedProductSchema = (0, objects_1.defineComponent)('DeletedProduct', (0, envelopes_1.deletedOf)('product'));
74
+ const url = zod_1.z
75
+ .string()
76
+ .max(catalog_1.CATALOG_LIMITS.urlMax)
77
+ .regex(/^https?:\/\/\S+$/, 'must be an http(s) URL');
78
+ const fields = {
79
+ name: zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.productNameMax),
80
+ description: zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.productDescriptionMax),
81
+ images: zod_1.z.array(url).max(catalog_1.CATALOG_LIMITS.productImagesMax),
82
+ tax_code: zod_1.z
83
+ .string()
84
+ .refine(tax_1.isKnownTaxCode, 'is not a Peable Tax code (GET /v1/tax/codes lists them)'),
85
+ unit_label: zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.unitLabelMax),
86
+ url,
87
+ // Card networks print at most 22 characters, need one letter, and refuse
88
+ // `< > \ ' " *`.
89
+ statement_descriptor: zod_1.z
90
+ .string()
91
+ .min(1)
92
+ .max(catalog_1.CATALOG_LIMITS.statementDescriptorMax)
93
+ .regex(/[A-Za-z]/, 'must contain at least one letter')
94
+ .refine((value) => !/[<>\\'"*]/.test(value), 'cannot contain < > \\ \' " or *'),
95
+ marketing_features: zod_1.z
96
+ .array(zod_1.z.object({ name: zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.marketingFeatureNameMax) }).strict())
97
+ .max(catalog_1.CATALOG_LIMITS.marketingFeaturesMax),
98
+ };
99
+ exports.createProductParams = zod_1.z
100
+ .object({
101
+ name: fields.name,
102
+ active: zod_1.z.boolean().optional(),
103
+ description: fields.description.optional(),
104
+ images: fields.images.optional(),
105
+ metadata: params_1.metadataCreateParam.optional(),
106
+ tax_code: fields.tax_code.optional(),
107
+ default_price_data: prices_1.defaultPriceDataParams
108
+ .optional()
109
+ .describe("Create the product's default price with it."),
110
+ unit_label: fields.unit_label.optional(),
111
+ url: fields.url.optional(),
112
+ statement_descriptor: fields.statement_descriptor.optional(),
113
+ marketing_features: fields.marketing_features.optional(),
114
+ expand: params_1.expandParam.optional(),
115
+ })
116
+ .strict();
117
+ /** `""` clears an optional text field; `metadata` is a patch. */
118
+ exports.updateProductParams = zod_1.z
119
+ .object({
120
+ name: fields.name.optional(),
121
+ active: zod_1.z.boolean().optional(),
122
+ description: (0, shared_1.clearing)(fields.description).optional(),
123
+ images: fields.images.optional(),
124
+ metadata: params_1.metadataUpdateParam.optional(),
125
+ tax_code: (0, shared_1.clearing)(fields.tax_code).optional(),
126
+ default_price: (0, shared_1.clearing)(zod_1.z.string().min(1).max(255))
127
+ .optional()
128
+ .describe('One of this product\'s active prices; `""` clears it.'),
129
+ unit_label: (0, shared_1.clearing)(fields.unit_label).optional(),
130
+ url: (0, shared_1.clearing)(fields.url).optional(),
131
+ statement_descriptor: (0, shared_1.clearing)(fields.statement_descriptor).optional(),
132
+ marketing_features: fields.marketing_features.optional(),
133
+ expand: params_1.expandParam.optional(),
134
+ })
135
+ .strict();
136
+ exports.listProductsQuery = (0, params_1.listQuery)({
137
+ active: shared_1.queryFlag.optional(),
138
+ ids: (0, shared_1.queryIdList)(catalog_1.CATALOG_LIMITS.idsFilterMax)
139
+ .optional()
140
+ .describe('Only these products (at most 100).'),
141
+ });
142
+ exports.productRoutes = [
143
+ (0, route_1.defineRoute)({
144
+ operationId: 'createProduct',
145
+ method: 'post',
146
+ path: '/v1/products',
147
+ tag: 'Products',
148
+ summary: 'Create a product',
149
+ description: '`default_price_data` creates its default price in the same request.',
150
+ auth: 'service',
151
+ scope: 'payments:write',
152
+ idempotent: true,
153
+ body: exports.createProductParams,
154
+ response: exports.productSchema,
155
+ sdk: 'products.create',
156
+ expandable: 'product',
157
+ }),
158
+ (0, route_1.defineRoute)({
159
+ operationId: 'listProducts',
160
+ method: 'get',
161
+ path: '/v1/products',
162
+ tag: 'Products',
163
+ summary: 'List products',
164
+ auth: 'service',
165
+ scope: 'payments:read',
166
+ query: exports.listProductsQuery,
167
+ response: (0, envelopes_1.listOf)(exports.productSchema),
168
+ sdk: 'products.list',
169
+ expandable: 'product',
170
+ }),
171
+ (0, route_1.defineRoute)({
172
+ operationId: 'retrieveProduct',
173
+ method: 'get',
174
+ path: '/v1/products/{id}',
175
+ tag: 'Products',
176
+ summary: 'Retrieve a product',
177
+ auth: 'service',
178
+ scope: 'payments:read',
179
+ params: { id: 'The product (`prod_…`).' },
180
+ query: params_1.expandOnlyQuery,
181
+ response: exports.productSchema,
182
+ sdk: 'products.retrieve',
183
+ expandable: 'product',
184
+ }),
185
+ (0, route_1.defineRoute)({
186
+ operationId: 'updateProduct',
187
+ method: 'post',
188
+ path: '/v1/products/{id}',
189
+ tag: 'Products',
190
+ summary: 'Update a product',
191
+ description: 'A field sent as `""` is cleared; `metadata` is a patch.',
192
+ auth: 'service',
193
+ scope: 'payments:write',
194
+ idempotent: true,
195
+ params: { id: 'The product (`prod_…`).' },
196
+ body: exports.updateProductParams,
197
+ response: exports.productSchema,
198
+ sdk: 'products.update',
199
+ expandable: 'product',
200
+ }),
201
+ (0, route_1.defineRoute)({
202
+ operationId: 'deleteProduct',
203
+ method: 'delete',
204
+ path: '/v1/products/{id}',
205
+ tag: 'Products',
206
+ summary: 'Delete a product',
207
+ description: 'Only a product nothing names; one with prices is archived with `active: false`.',
208
+ auth: 'service',
209
+ scope: 'payments:write',
210
+ params: { id: 'The product (`prod_…`).' },
211
+ response: exports.deletedProductSchema,
212
+ sdk: 'products.del',
213
+ }),
214
+ (0, route_1.defineRoute)({
215
+ operationId: 'searchProducts',
216
+ method: 'get',
217
+ path: '/v1/products/search',
218
+ tag: 'Products',
219
+ summary: 'Search products',
220
+ description: "Stripe's query language over `active`, `name`, `description`, `url`, `created` and `metadata['key']`.",
221
+ auth: 'service',
222
+ scope: 'payments:read',
223
+ query: params_1.searchQuery,
224
+ response: (0, envelopes_1.searchResultOf)(exports.productSchema),
225
+ sdk: 'products.search',
226
+ expandable: 'product',
227
+ }),
228
+ ];