@paygentic/sdk 0.9.18 → 0.10.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 (197) hide show
  1. package/README.md +1 -0
  2. package/dist/commonjs/lib/config.d.ts +2 -2
  3. package/dist/commonjs/lib/config.js +2 -2
  4. package/dist/commonjs/models/authorizationdenialreason.d.ts +17 -0
  5. package/dist/commonjs/models/authorizationdenialreason.d.ts.map +1 -0
  6. package/dist/commonjs/models/authorizationdenialreason.js +51 -0
  7. package/dist/commonjs/models/authorizationdenialreason.js.map +1 -0
  8. package/dist/commonjs/models/errors/error.d.ts +17 -0
  9. package/dist/commonjs/models/errors/error.d.ts.map +1 -1
  10. package/dist/commonjs/models/errors/error.js +8 -0
  11. package/dist/commonjs/models/errors/error.js.map +1 -1
  12. package/dist/commonjs/models/errors/recordinvoicepayment.d.ts +16 -0
  13. package/dist/commonjs/models/errors/recordinvoicepayment.d.ts.map +1 -1
  14. package/dist/commonjs/models/errors/recordinvoicepayment.js +7 -0
  15. package/dist/commonjs/models/errors/recordinvoicepayment.js.map +1 -1
  16. package/dist/commonjs/models/index.d.ts +15 -0
  17. package/dist/commonjs/models/index.d.ts.map +1 -1
  18. package/dist/commonjs/models/index.js +15 -0
  19. package/dist/commonjs/models/index.js.map +1 -1
  20. package/dist/commonjs/models/invoicelineitem.d.ts +5 -0
  21. package/dist/commonjs/models/invoicelineitem.d.ts.map +1 -1
  22. package/dist/commonjs/models/invoicelineitem.js +2 -0
  23. package/dist/commonjs/models/invoicelineitem.js.map +1 -1
  24. package/dist/commonjs/models/linecalculationcontribution.d.ts +12 -0
  25. package/dist/commonjs/models/linecalculationcontribution.d.ts.map +1 -0
  26. package/dist/commonjs/models/linecalculationcontribution.js +52 -0
  27. package/dist/commonjs/models/linecalculationcontribution.js.map +1 -0
  28. package/dist/commonjs/models/linecalculationgiven.d.ts +20 -0
  29. package/dist/commonjs/models/linecalculationgiven.d.ts.map +1 -0
  30. package/dist/commonjs/models/linecalculationgiven.js +51 -0
  31. package/dist/commonjs/models/linecalculationgiven.js.map +1 -0
  32. package/dist/commonjs/models/linecalculationinputprice.d.ts +21 -0
  33. package/dist/commonjs/models/linecalculationinputprice.d.ts.map +1 -0
  34. package/dist/commonjs/models/linecalculationinputprice.js +52 -0
  35. package/dist/commonjs/models/linecalculationinputprice.js.map +1 -0
  36. package/dist/commonjs/models/linecalculationinputs.d.ts +34 -0
  37. package/dist/commonjs/models/linecalculationinputs.d.ts.map +1 -0
  38. package/dist/commonjs/models/linecalculationinputs.js +56 -0
  39. package/dist/commonjs/models/linecalculationinputs.js.map +1 -0
  40. package/dist/commonjs/models/linecalculationnotapplied.d.ts +20 -0
  41. package/dist/commonjs/models/linecalculationnotapplied.d.ts.map +1 -0
  42. package/dist/commonjs/models/linecalculationnotapplied.js +51 -0
  43. package/dist/commonjs/models/linecalculationnotapplied.js.map +1 -0
  44. package/dist/commonjs/models/linecalculationperiod.d.ts +14 -0
  45. package/dist/commonjs/models/linecalculationperiod.d.ts.map +1 -0
  46. package/dist/commonjs/models/linecalculationperiod.js +51 -0
  47. package/dist/commonjs/models/linecalculationperiod.js.map +1 -0
  48. package/dist/commonjs/models/linecalculationprecision.d.ts +14 -0
  49. package/dist/commonjs/models/linecalculationprecision.d.ts.map +1 -0
  50. package/dist/commonjs/models/linecalculationprecision.js +51 -0
  51. package/dist/commonjs/models/linecalculationprecision.js.map +1 -0
  52. package/dist/commonjs/models/linecalculationpriceband.d.ts +11 -0
  53. package/dist/commonjs/models/linecalculationpriceband.d.ts.map +1 -0
  54. package/dist/commonjs/models/linecalculationpriceband.js +51 -0
  55. package/dist/commonjs/models/linecalculationpriceband.js.map +1 -0
  56. package/dist/commonjs/models/linecalculationpricefn.d.ts +40 -0
  57. package/dist/commonjs/models/linecalculationpricefn.d.ts.map +1 -0
  58. package/dist/commonjs/models/linecalculationpricefn.js +56 -0
  59. package/dist/commonjs/models/linecalculationpricefn.js.map +1 -0
  60. package/dist/commonjs/models/linecalculationresult.d.ts +24 -0
  61. package/dist/commonjs/models/linecalculationresult.d.ts.map +1 -0
  62. package/dist/commonjs/models/linecalculationresult.js +52 -0
  63. package/dist/commonjs/models/linecalculationresult.js.map +1 -0
  64. package/dist/commonjs/models/linecalculationsource.d.ts +32 -0
  65. package/dist/commonjs/models/linecalculationsource.d.ts.map +1 -0
  66. package/dist/commonjs/models/linecalculationsource.js +53 -0
  67. package/dist/commonjs/models/linecalculationsource.js.map +1 -0
  68. package/dist/commonjs/models/linecalculationstep.d.ts +50 -0
  69. package/dist/commonjs/models/linecalculationstep.d.ts.map +1 -0
  70. package/dist/commonjs/models/linecalculationstep.js +59 -0
  71. package/dist/commonjs/models/linecalculationstep.js.map +1 -0
  72. package/dist/commonjs/models/linecalculationvalue.d.ts +12 -0
  73. package/dist/commonjs/models/linecalculationvalue.d.ts.map +1 -0
  74. package/dist/commonjs/models/linecalculationvalue.js +49 -0
  75. package/dist/commonjs/models/linecalculationvalue.js.map +1 -0
  76. package/dist/commonjs/models/lineitem.d.ts +5 -0
  77. package/dist/commonjs/models/lineitem.d.ts.map +1 -1
  78. package/dist/commonjs/models/lineitem.js +2 -0
  79. package/dist/commonjs/models/lineitem.js.map +1 -1
  80. package/dist/commonjs/models/lineprovenance.d.ts +69 -0
  81. package/dist/commonjs/models/lineprovenance.d.ts.map +1 -0
  82. package/dist/commonjs/models/lineprovenance.js +68 -0
  83. package/dist/commonjs/models/lineprovenance.js.map +1 -0
  84. package/dist/commonjs/models/operations/getinvoice.d.ts +1 -1
  85. package/dist/commonjs/models/operations/getinvoicelineitems.d.ts +1 -1
  86. package/dist/commonjs/models/operations/listlineitems.d.ts +1 -1
  87. package/dist/esm/lib/config.d.ts +2 -2
  88. package/dist/esm/lib/config.js +2 -2
  89. package/dist/esm/models/authorizationdenialreason.d.ts +17 -0
  90. package/dist/esm/models/authorizationdenialreason.d.ts.map +1 -0
  91. package/dist/esm/models/authorizationdenialreason.js +15 -0
  92. package/dist/esm/models/authorizationdenialreason.js.map +1 -0
  93. package/dist/esm/models/errors/error.d.ts +17 -0
  94. package/dist/esm/models/errors/error.d.ts.map +1 -1
  95. package/dist/esm/models/errors/error.js +8 -0
  96. package/dist/esm/models/errors/error.js.map +1 -1
  97. package/dist/esm/models/errors/recordinvoicepayment.d.ts +16 -0
  98. package/dist/esm/models/errors/recordinvoicepayment.d.ts.map +1 -1
  99. package/dist/esm/models/errors/recordinvoicepayment.js +7 -0
  100. package/dist/esm/models/errors/recordinvoicepayment.js.map +1 -1
  101. package/dist/esm/models/index.d.ts +15 -0
  102. package/dist/esm/models/index.d.ts.map +1 -1
  103. package/dist/esm/models/index.js +15 -0
  104. package/dist/esm/models/index.js.map +1 -1
  105. package/dist/esm/models/invoicelineitem.d.ts +5 -0
  106. package/dist/esm/models/invoicelineitem.d.ts.map +1 -1
  107. package/dist/esm/models/invoicelineitem.js +2 -0
  108. package/dist/esm/models/invoicelineitem.js.map +1 -1
  109. package/dist/esm/models/linecalculationcontribution.d.ts +12 -0
  110. package/dist/esm/models/linecalculationcontribution.d.ts.map +1 -0
  111. package/dist/esm/models/linecalculationcontribution.js +15 -0
  112. package/dist/esm/models/linecalculationcontribution.js.map +1 -0
  113. package/dist/esm/models/linecalculationgiven.d.ts +20 -0
  114. package/dist/esm/models/linecalculationgiven.d.ts.map +1 -0
  115. package/dist/esm/models/linecalculationgiven.js +14 -0
  116. package/dist/esm/models/linecalculationgiven.js.map +1 -0
  117. package/dist/esm/models/linecalculationinputprice.d.ts +21 -0
  118. package/dist/esm/models/linecalculationinputprice.d.ts.map +1 -0
  119. package/dist/esm/models/linecalculationinputprice.js +15 -0
  120. package/dist/esm/models/linecalculationinputprice.js.map +1 -0
  121. package/dist/esm/models/linecalculationinputs.d.ts +34 -0
  122. package/dist/esm/models/linecalculationinputs.d.ts.map +1 -0
  123. package/dist/esm/models/linecalculationinputs.js +19 -0
  124. package/dist/esm/models/linecalculationinputs.js.map +1 -0
  125. package/dist/esm/models/linecalculationnotapplied.d.ts +20 -0
  126. package/dist/esm/models/linecalculationnotapplied.d.ts.map +1 -0
  127. package/dist/esm/models/linecalculationnotapplied.js +14 -0
  128. package/dist/esm/models/linecalculationnotapplied.js.map +1 -0
  129. package/dist/esm/models/linecalculationperiod.d.ts +14 -0
  130. package/dist/esm/models/linecalculationperiod.d.ts.map +1 -0
  131. package/dist/esm/models/linecalculationperiod.js +14 -0
  132. package/dist/esm/models/linecalculationperiod.js.map +1 -0
  133. package/dist/esm/models/linecalculationprecision.d.ts +14 -0
  134. package/dist/esm/models/linecalculationprecision.d.ts.map +1 -0
  135. package/dist/esm/models/linecalculationprecision.js +14 -0
  136. package/dist/esm/models/linecalculationprecision.js.map +1 -0
  137. package/dist/esm/models/linecalculationpriceband.d.ts +11 -0
  138. package/dist/esm/models/linecalculationpriceband.d.ts.map +1 -0
  139. package/dist/esm/models/linecalculationpriceband.js +14 -0
  140. package/dist/esm/models/linecalculationpriceband.js.map +1 -0
  141. package/dist/esm/models/linecalculationpricefn.d.ts +40 -0
  142. package/dist/esm/models/linecalculationpricefn.d.ts.map +1 -0
  143. package/dist/esm/models/linecalculationpricefn.js +19 -0
  144. package/dist/esm/models/linecalculationpricefn.js.map +1 -0
  145. package/dist/esm/models/linecalculationresult.d.ts +24 -0
  146. package/dist/esm/models/linecalculationresult.d.ts.map +1 -0
  147. package/dist/esm/models/linecalculationresult.js +15 -0
  148. package/dist/esm/models/linecalculationresult.js.map +1 -0
  149. package/dist/esm/models/linecalculationsource.d.ts +32 -0
  150. package/dist/esm/models/linecalculationsource.d.ts.map +1 -0
  151. package/dist/esm/models/linecalculationsource.js +16 -0
  152. package/dist/esm/models/linecalculationsource.js.map +1 -0
  153. package/dist/esm/models/linecalculationstep.d.ts +50 -0
  154. package/dist/esm/models/linecalculationstep.d.ts.map +1 -0
  155. package/dist/esm/models/linecalculationstep.js +22 -0
  156. package/dist/esm/models/linecalculationstep.js.map +1 -0
  157. package/dist/esm/models/linecalculationvalue.d.ts +12 -0
  158. package/dist/esm/models/linecalculationvalue.d.ts.map +1 -0
  159. package/dist/esm/models/linecalculationvalue.js +12 -0
  160. package/dist/esm/models/linecalculationvalue.js.map +1 -0
  161. package/dist/esm/models/lineitem.d.ts +5 -0
  162. package/dist/esm/models/lineitem.d.ts.map +1 -1
  163. package/dist/esm/models/lineitem.js +2 -0
  164. package/dist/esm/models/lineitem.js.map +1 -1
  165. package/dist/esm/models/lineprovenance.d.ts +69 -0
  166. package/dist/esm/models/lineprovenance.d.ts.map +1 -0
  167. package/dist/esm/models/lineprovenance.js +31 -0
  168. package/dist/esm/models/lineprovenance.js.map +1 -0
  169. package/dist/esm/models/operations/getinvoice.d.ts +1 -1
  170. package/dist/esm/models/operations/getinvoicelineitems.d.ts +1 -1
  171. package/dist/esm/models/operations/listlineitems.d.ts +1 -1
  172. package/jsr.json +1 -1
  173. package/package.json +1 -1
  174. package/src/lib/config.ts +2 -2
  175. package/src/models/authorizationdenialreason.ts +26 -0
  176. package/src/models/errors/error.ts +23 -0
  177. package/src/models/errors/recordinvoicepayment.ts +22 -0
  178. package/src/models/index.ts +15 -0
  179. package/src/models/invoicelineitem.ts +9 -0
  180. package/src/models/linecalculationcontribution.ts +35 -0
  181. package/src/models/linecalculationgiven.ts +42 -0
  182. package/src/models/linecalculationinputprice.ts +46 -0
  183. package/src/models/linecalculationinputs.ts +65 -0
  184. package/src/models/linecalculationnotapplied.ts +42 -0
  185. package/src/models/linecalculationperiod.ts +36 -0
  186. package/src/models/linecalculationprecision.ts +36 -0
  187. package/src/models/linecalculationpriceband.ts +33 -0
  188. package/src/models/linecalculationpricefn.ts +74 -0
  189. package/src/models/linecalculationresult.ts +47 -0
  190. package/src/models/linecalculationsource.ts +52 -0
  191. package/src/models/linecalculationstep.ts +80 -0
  192. package/src/models/linecalculationvalue.ts +34 -0
  193. package/src/models/lineitem.ts +9 -0
  194. package/src/models/lineprovenance.ts +122 -0
  195. package/src/models/operations/getinvoice.ts +1 -1
  196. package/src/models/operations/getinvoicelineitems.ts +1 -1
  197. package/src/models/operations/listlineitems.ts +1 -1
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ /**
11
+ * Equal to the line's stored amount, quantity and unit price.
12
+ */
13
+ export type LineCalculationResult = {
14
+ /**
15
+ * The line's amount before tax.
16
+ */
17
+ amount: string;
18
+ /**
19
+ * The line's quantity.
20
+ */
21
+ quantity: string | null;
22
+ /**
23
+ * The line's unit price. It can be rounded, so quantity times unit price can differ from the amount.
24
+ */
25
+ unitPrice: string | null;
26
+ };
27
+
28
+ /** @internal */
29
+ export const LineCalculationResult$inboundSchema: z.ZodType<
30
+ LineCalculationResult,
31
+ z.ZodTypeDef,
32
+ unknown
33
+ > = z.object({
34
+ amount: z.string(),
35
+ quantity: z.nullable(z.string()),
36
+ unitPrice: z.nullable(z.string()),
37
+ });
38
+
39
+ export function lineCalculationResultFromJSON(
40
+ jsonString: string,
41
+ ): SafeParseResult<LineCalculationResult, SDKValidationError> {
42
+ return safeParse(
43
+ jsonString,
44
+ (x) => LineCalculationResult$inboundSchema.parse(JSON.parse(x)),
45
+ `Failed to parse 'LineCalculationResult' from JSON`,
46
+ );
47
+ }
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ /**
11
+ * Where a value came from: `ref`, a link that can break after the invoice is issued, and `asUsed`, the values the calculation read, which never change.
12
+ */
13
+ export type LineCalculationSource = {
14
+ /**
15
+ * `interval`: a subscription price interval. `price`: a catalog price. `meter`: a billable metric read directly. `entitlement`: the grant engine's reading of an entitlement. `grant`: a grant. `adjustment`: a subscription adjustment. `line`: another line on the invoice. `storedRow`: a figure the line already stored, with `reason`. `merchant`: an amount a merchant entered. `input` is reserved for a value from a system that is not a meter, with `ref` `name` and `eventId` and `asUsed` `value` and `unit`; nothing produces it yet. An open set, so it is a string rather than an enum: known values are `interval`, `price`, `meter`, `entitlement`, `grant`, `adjustment`, `line`, `storedRow`, `merchant`, and new values may be added.
16
+ */
17
+ type: string;
18
+ /**
19
+ * The ids that link to the resource.
20
+ */
21
+ ref?: { [k: string]: any } | undefined;
22
+ /**
23
+ * The values the calculation read from the resource. A `line` source has `amount`, and `unitPrice` where a step read the line's rate.
24
+ */
25
+ asUsed?: { [k: string]: any } | undefined;
26
+ /**
27
+ * `storedRow` only: why the stored figure stands. An open set, so it is a string rather than an enum: known values are `precedes_timeline`, `no_timeline`, `not_derived`, `no_covering_charge`, and new values may be added.
28
+ */
29
+ reason?: string | undefined;
30
+ };
31
+
32
+ /** @internal */
33
+ export const LineCalculationSource$inboundSchema: z.ZodType<
34
+ LineCalculationSource,
35
+ z.ZodTypeDef,
36
+ unknown
37
+ > = z.object({
38
+ type: z.string(),
39
+ ref: z.record(z.any()).optional(),
40
+ asUsed: z.record(z.any()).optional(),
41
+ reason: z.string().optional(),
42
+ });
43
+
44
+ export function lineCalculationSourceFromJSON(
45
+ jsonString: string,
46
+ ): SafeParseResult<LineCalculationSource, SDKValidationError> {
47
+ return safeParse(
48
+ jsonString,
49
+ (x) => LineCalculationSource$inboundSchema.parse(JSON.parse(x)),
50
+ `Failed to parse 'LineCalculationSource' from JSON`,
51
+ );
52
+ }
@@ -0,0 +1,80 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+ import {
10
+ LineCalculationContribution,
11
+ LineCalculationContribution$inboundSchema,
12
+ } from "./linecalculationcontribution.js";
13
+ import {
14
+ LineCalculationValue,
15
+ LineCalculationValue$inboundSchema,
16
+ } from "./linecalculationvalue.js";
17
+
18
+ /**
19
+ * One step: the value it changed (`on`), the value before (`in`) and after (`out`), the rule's parameters, and the source of the rule. A reader that does not know an op shows it as "in → out, because source".
20
+ */
21
+ export type LineCalculationStep = {
22
+ /**
23
+ * `allow`: units a grant covered (`covered`). `clamp`: `min` and `max`, null when open. `scaleToBound`: a minimum or maximum applied to a group of lines by uniform scaling (`bound`, `side`, `measured`, `factor`). `setToBound`: a minimum applied to a group that measured zero (`bound`, `sumOfShares`). `prorate`: `fraction` of the period, with the `billed` and full (`of`) windows and the `basis`. `evaluate`: the one join of quantity and price into an amount (`quantity`, `selector`, `fn`, `applied`); its `in` is null. `cap`: `max` and `scope`; on an `invoice` cap also `total`, what the cap started at, and `usedBefore`, what earlier credits took from it. `replace`: a value set by a rule, with `reason`. `subtract`: `units`. `scale`: ordered `terms`, each `by`, `value` and `label`. A `subtract`, `clamp` or `scale` that did not use the envelope's precision says so in `arithmetic`: `float64` or `decimal120`. `round`: `scale` and `mode`. An open set, so it is a string rather than an enum: known values are `allow`, `clamp`, `scaleToBound`, `setToBound`, `prorate`, `evaluate`, `cap`, `replace`, `subtract`, `scale`, `round`, and new values may be added.
24
+ */
25
+ op: string;
26
+ /**
27
+ * The value the step changes. `quantity`, `selector` (the quantity a volume band is chosen on), `price` and `amount` are reserved; other names may be added.
28
+ */
29
+ on: string;
30
+ /**
31
+ * The value before the step. Null only on `evaluate`.
32
+ */
33
+ in: LineCalculationValue | null;
34
+ /**
35
+ * A decimal string, or a price function.
36
+ */
37
+ out: LineCalculationValue;
38
+ /**
39
+ * The parameters of the op. See `op`.
40
+ */
41
+ params: { [k: string]: any };
42
+ /**
43
+ * The key of the source in `sources` whose rule this is.
44
+ */
45
+ source: string;
46
+ /**
47
+ * The other lines a group rule read, with each one's value and period share.
48
+ */
49
+ inputsFrom?: Array<LineCalculationContribution> | undefined;
50
+ /**
51
+ * Reserved for an `evaluate` of a custom pricing function: the steps inside it, each of the same shape as a step. Free-form here so the schema does not refer to itself. Nothing produces it yet.
52
+ */
53
+ trace?: Array<{ [k: string]: any }> | undefined;
54
+ };
55
+
56
+ /** @internal */
57
+ export const LineCalculationStep$inboundSchema: z.ZodType<
58
+ LineCalculationStep,
59
+ z.ZodTypeDef,
60
+ unknown
61
+ > = z.object({
62
+ op: z.string(),
63
+ on: z.string(),
64
+ in: z.nullable(LineCalculationValue$inboundSchema),
65
+ out: LineCalculationValue$inboundSchema,
66
+ params: z.record(z.any()),
67
+ source: z.string(),
68
+ inputsFrom: z.array(LineCalculationContribution$inboundSchema).optional(),
69
+ trace: z.array(z.record(z.any())).optional(),
70
+ });
71
+
72
+ export function lineCalculationStepFromJSON(
73
+ jsonString: string,
74
+ ): SafeParseResult<LineCalculationStep, SDKValidationError> {
75
+ return safeParse(
76
+ jsonString,
77
+ (x) => LineCalculationStep$inboundSchema.parse(JSON.parse(x)),
78
+ `Failed to parse 'LineCalculationStep' from JSON`,
79
+ );
80
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+ import {
10
+ LineCalculationPriceFn,
11
+ LineCalculationPriceFn$inboundSchema,
12
+ } from "./linecalculationpricefn.js";
13
+
14
+ /**
15
+ * A decimal string, or a price function.
16
+ */
17
+ export type LineCalculationValue = LineCalculationPriceFn | string;
18
+
19
+ /** @internal */
20
+ export const LineCalculationValue$inboundSchema: z.ZodType<
21
+ LineCalculationValue,
22
+ z.ZodTypeDef,
23
+ unknown
24
+ > = z.union([LineCalculationPriceFn$inboundSchema, z.string()]);
25
+
26
+ export function lineCalculationValueFromJSON(
27
+ jsonString: string,
28
+ ): SafeParseResult<LineCalculationValue, SDKValidationError> {
29
+ return safeParse(
30
+ jsonString,
31
+ (x) => LineCalculationValue$inboundSchema.parse(JSON.parse(x)),
32
+ `Failed to parse 'LineCalculationValue' from JSON`,
33
+ );
34
+ }
@@ -7,6 +7,10 @@ import { safeParse } from "../lib/schemas.js";
7
7
  import { ClosedEnum } from "../types/enums.js";
8
8
  import { Result as SafeParseResult } from "../types/fp.js";
9
9
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
+ import {
11
+ LineProvenance,
12
+ LineProvenance$inboundSchema,
13
+ } from "./lineprovenance.js";
10
14
 
11
15
  /**
12
16
  * The type of line item. 'discount' and 'adjustment' line items have negative subtotal/total amounts: 'discount' is a grant discount, 'adjustment' is a discount agreed on the subscription.
@@ -156,6 +160,10 @@ export type LineItem = {
156
160
  * Real-time estimated subtotal for a line whose amount is not final yet: current usage for a metered item, the rate the subscription is on for a fee. Null for manual items, and for any line whose amount is already final or cannot be estimated.
157
161
  */
158
162
  estimatedSubtotal?: string | null | undefined;
163
+ /**
164
+ * How the line's amount before tax was calculated: a trace of one evaluation, saved when the invoice was calculated and fixed once it is issued. Returned only with `expand=lineProvenance`. Every field but `status` is present when `status` is `recorded`. Every number is a plain decimal string.
165
+ */
166
+ provenance?: LineProvenance | undefined;
159
167
  };
160
168
 
161
169
  /** @internal */
@@ -209,6 +217,7 @@ export const LineItem$inboundSchema: z.ZodType<
209
217
  updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
210
218
  estimatedMeteredQuantity: z.nullable(z.string()).optional(),
211
219
  estimatedSubtotal: z.nullable(z.string()).optional(),
220
+ provenance: LineProvenance$inboundSchema.optional(),
212
221
  });
213
222
 
214
223
  export function lineItemFromJSON(
@@ -0,0 +1,122 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+ import {
10
+ LineCalculationInputs,
11
+ LineCalculationInputs$inboundSchema,
12
+ } from "./linecalculationinputs.js";
13
+ import {
14
+ LineCalculationNotApplied,
15
+ LineCalculationNotApplied$inboundSchema,
16
+ } from "./linecalculationnotapplied.js";
17
+ import {
18
+ LineCalculationPeriod,
19
+ LineCalculationPeriod$inboundSchema,
20
+ } from "./linecalculationperiod.js";
21
+ import {
22
+ LineCalculationPrecision,
23
+ LineCalculationPrecision$inboundSchema,
24
+ } from "./linecalculationprecision.js";
25
+ import {
26
+ LineCalculationResult,
27
+ LineCalculationResult$inboundSchema,
28
+ } from "./linecalculationresult.js";
29
+ import {
30
+ LineCalculationSource,
31
+ LineCalculationSource$inboundSchema,
32
+ } from "./linecalculationsource.js";
33
+ import {
34
+ LineCalculationStep,
35
+ LineCalculationStep$inboundSchema,
36
+ } from "./linecalculationstep.js";
37
+
38
+ /**
39
+ * How the line's amount before tax was calculated: a trace of one evaluation, saved when the invoice was calculated and fixed once it is issued. Returned only with `expand=lineProvenance`. Every field but `status` is present when `status` is `recorded`. Every number is a plain decimal string.
40
+ */
41
+ export type LineProvenance = {
42
+ /**
43
+ * `recorded`: the trace is present. `notRecorded`: the line was calculated but has no saved trace, for example a line calculated before traces were saved (show "Calculation not recorded"). `pending`: the line's invoice has not been calculated yet. An open set, so it is a string rather than an enum: known values are `recorded`, `notRecorded`, `pending`, and new values may be added.
44
+ */
45
+ status: string;
46
+ /**
47
+ * The format version. It changes only when a field is removed or renamed, or a field changes meaning. A new op, source type, price model, reason or label is not a new version.
48
+ */
49
+ version?: number | undefined;
50
+ /**
51
+ * The currency of every amount in the trace.
52
+ */
53
+ currency?: string | undefined;
54
+ /**
55
+ * The default arithmetic of every step. Any other rounding is an explicit `round` step.
56
+ */
57
+ precision?: LineCalculationPrecision | undefined;
58
+ /**
59
+ * The period the line bills.
60
+ */
61
+ period?: LineCalculationPeriod | undefined;
62
+ /**
63
+ * When the calculation ran.
64
+ */
65
+ calculatedAt?: Date | undefined;
66
+ /**
67
+ * The subscription the line belongs to.
68
+ */
69
+ subscriptionId?: string | undefined;
70
+ /**
71
+ * The values the evaluation started from.
72
+ */
73
+ inputs?: LineCalculationInputs | undefined;
74
+ /**
75
+ * Every source a step or an input names, by key.
76
+ */
77
+ sources?: { [k: string]: LineCalculationSource } | undefined;
78
+ /**
79
+ * The steps in the order they were applied. Each starts where the last step on the same value ended.
80
+ */
81
+ steps?: Array<LineCalculationStep> | undefined;
82
+ /**
83
+ * Rules in force for the line that did not change it, and why.
84
+ */
85
+ notApplied?: Array<LineCalculationNotApplied> | undefined;
86
+ /**
87
+ * Equal to the line's stored amount, quantity and unit price.
88
+ */
89
+ result?: LineCalculationResult | undefined;
90
+ };
91
+
92
+ /** @internal */
93
+ export const LineProvenance$inboundSchema: z.ZodType<
94
+ LineProvenance,
95
+ z.ZodTypeDef,
96
+ unknown
97
+ > = z.object({
98
+ status: z.string(),
99
+ version: z.number().int().optional(),
100
+ currency: z.string().optional(),
101
+ precision: LineCalculationPrecision$inboundSchema.optional(),
102
+ period: LineCalculationPeriod$inboundSchema.optional(),
103
+ calculatedAt: z.string().datetime({ offset: true }).transform(v =>
104
+ new Date(v)
105
+ ).optional(),
106
+ subscriptionId: z.string().optional(),
107
+ inputs: LineCalculationInputs$inboundSchema.optional(),
108
+ sources: z.record(LineCalculationSource$inboundSchema).optional(),
109
+ steps: z.array(LineCalculationStep$inboundSchema).optional(),
110
+ notApplied: z.array(LineCalculationNotApplied$inboundSchema).optional(),
111
+ result: LineCalculationResult$inboundSchema.optional(),
112
+ });
113
+
114
+ export function lineProvenanceFromJSON(
115
+ jsonString: string,
116
+ ): SafeParseResult<LineProvenance, SDKValidationError> {
117
+ return safeParse(
118
+ jsonString,
119
+ (x) => LineProvenance$inboundSchema.parse(JSON.parse(x)),
120
+ `Failed to parse 'LineProvenance' from JSON`,
121
+ );
122
+ }
@@ -10,7 +10,7 @@ export type GetInvoiceRequest = {
10
10
  */
11
11
  id: string;
12
12
  /**
13
- * Comma-separated list of fields to expand. Supports: lineItems, items. `items` resolves each returned line's item and its external accounting codes into an `items` collection inside the lineItems block; because those ids come from the lines, requesting `items` also expands `lineItems` on its default paging.
13
+ * Comma-separated list of fields to expand. Supports: lineItems, items, lineProvenance. `items` resolves each returned line's item and its external accounting codes into an `items` collection inside the lineItems block; because those ids come from the lines, requesting `items` also expands `lineItems` on its default paging. `lineProvenance` adds `provenance` to each returned line: how its amount before tax was calculated. It also expands `lineItems`.
14
14
  */
15
15
  expand?: string | undefined;
16
16
  /**
@@ -18,7 +18,7 @@ export type GetInvoiceLineItemsRequest = {
18
18
  */
19
19
  pageToken?: string | undefined;
20
20
  /**
21
- * Comma-separated list of fields to expand. Supports: items — resolves each returned line's item and that item's external accounting codes into an `items` collection, so a line can be translated to a GL/SKU code without a second call.
21
+ * Comma-separated list of fields to expand. Supports: items, lineProvenance. `items` resolves each returned line's item and that item's external accounting codes into an `items` collection, so a line can be translated to a GL/SKU code without a second call. `lineProvenance` adds `provenance` to each returned line: how its amount before tax was calculated.
22
22
  */
23
23
  expand?: string | undefined;
24
24
  /**
@@ -31,7 +31,7 @@ export type ListLineItemsRequest = {
31
31
  */
32
32
  invoiceId?: string | undefined;
33
33
  /**
34
- * Comma-separated list of fields to expand. Supports: items — resolves each returned line's item and that item's external accounting codes into an `items` collection, so a line can be translated to a GL/SKU code without a second call.
34
+ * Comma-separated list of fields to expand. Supports: items, lineProvenance. `items` resolves each returned line's item and that item's external accounting codes into an `items` collection, so a line can be translated to a GL/SKU code without a second call. `lineProvenance` adds `provenance` to each returned line: how its amount before tax was calculated.
35
35
  */
36
36
  expand?: string | undefined;
37
37
  /**