@paid-ai/paid-node 0.5.0-alpha3 → 0.5.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 (253) hide show
  1. package/README.md +118 -36
  2. package/dist/cjs/Client.d.ts +35 -3
  3. package/dist/cjs/Client.js +57 -19
  4. package/dist/cjs/api/errors/InternalServerError.d.ts +9 -0
  5. package/dist/cjs/api/errors/InternalServerError.js +52 -0
  6. package/dist/cjs/api/errors/index.d.ts +1 -0
  7. package/dist/cjs/api/errors/index.js +1 -0
  8. package/dist/cjs/api/index.d.ts +1 -1
  9. package/dist/cjs/api/index.js +1 -1
  10. package/dist/cjs/api/resources/agents/client/Client.d.ts +16 -0
  11. package/dist/cjs/api/resources/agents/client/Client.js +16 -0
  12. package/dist/cjs/api/resources/customers/client/Client.d.ts +38 -0
  13. package/dist/cjs/api/resources/customers/client/Client.js +164 -0
  14. package/dist/cjs/api/resources/customers/client/requests/CustomerCreate.d.ts +2 -0
  15. package/dist/cjs/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.ts +30 -0
  16. package/dist/cjs/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.ts +30 -0
  17. package/dist/cjs/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.js +5 -0
  18. package/dist/cjs/api/resources/customers/client/requests/index.d.ts +2 -0
  19. package/dist/cjs/api/resources/index.d.ts +8 -1
  20. package/dist/cjs/api/resources/index.js +9 -2
  21. package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +2 -0
  22. package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +0 -2
  23. package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +0 -2
  24. package/dist/cjs/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.ts +0 -2
  25. package/dist/cjs/api/resources/plans/client/Client.d.ts +75 -0
  26. package/dist/cjs/api/resources/plans/client/Client.js +272 -0
  27. package/dist/cjs/api/resources/plans/client/index.d.ts +1 -0
  28. package/dist/cjs/api/resources/plans/client/index.js +17 -0
  29. package/dist/cjs/api/resources/plans/client/requests/PlansGetUsageRequest.d.ts +35 -0
  30. package/dist/cjs/api/resources/plans/client/requests/PlansGetUsageRequest.js +5 -0
  31. package/dist/cjs/api/resources/plans/client/requests/index.d.ts +1 -0
  32. package/dist/cjs/api/resources/plans/client/requests/index.js +2 -0
  33. package/dist/cjs/api/resources/plans/index.d.ts +1 -0
  34. package/dist/cjs/api/resources/plans/index.js +17 -0
  35. package/dist/cjs/api/resources/products/client/Client.d.ts +109 -0
  36. package/dist/cjs/api/resources/products/client/Client.js +470 -0
  37. package/dist/cjs/api/resources/products/client/index.d.ts +1 -0
  38. package/dist/cjs/api/resources/products/client/index.js +17 -0
  39. package/dist/cjs/api/resources/products/client/requests/ProductCreate.d.ts +29 -0
  40. package/dist/cjs/api/resources/products/client/requests/ProductCreate.js +14 -0
  41. package/dist/cjs/api/resources/products/client/requests/index.d.ts +1 -0
  42. package/dist/cjs/api/resources/products/client/requests/index.js +2 -0
  43. package/dist/cjs/api/resources/products/index.d.ts +1 -0
  44. package/dist/cjs/api/resources/products/index.js +17 -0
  45. package/dist/cjs/api/resources/traces/client/Client.d.ts +52 -0
  46. package/dist/cjs/api/resources/traces/client/Client.js +166 -0
  47. package/dist/cjs/api/resources/traces/client/index.d.ts +1 -0
  48. package/dist/cjs/api/resources/traces/client/index.js +17 -0
  49. package/dist/cjs/api/resources/traces/client/requests/GetTracesRequest.d.ts +50 -0
  50. package/dist/cjs/api/resources/traces/client/requests/GetTracesRequest.js +5 -0
  51. package/dist/cjs/api/resources/traces/client/requests/index.d.ts +1 -0
  52. package/dist/cjs/api/resources/traces/client/requests/index.js +2 -0
  53. package/dist/cjs/api/resources/traces/index.d.ts +1 -0
  54. package/dist/cjs/api/resources/traces/index.js +17 -0
  55. package/dist/cjs/api/resources/usage/client/Client.d.ts +47 -0
  56. package/dist/cjs/api/resources/usage/client/Client.js +146 -0
  57. package/dist/cjs/api/resources/usage/client/requests/UsageCheckUsageRequest.d.ts +28 -0
  58. package/dist/cjs/api/resources/usage/client/requests/UsageCheckUsageRequest.js +5 -0
  59. package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.ts +29 -0
  60. package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.js +5 -0
  61. package/dist/cjs/api/resources/usage/client/requests/index.d.ts +2 -0
  62. package/dist/cjs/api/resources/usage/index.d.ts +1 -0
  63. package/dist/cjs/api/resources/usage/index.js +1 -0
  64. package/dist/cjs/api/resources/usage/types/UsageCheckUsageResponse.d.ts +17 -0
  65. package/dist/cjs/api/resources/usage/types/UsageCheckUsageResponse.js +5 -0
  66. package/dist/cjs/api/resources/usage/types/index.d.ts +1 -0
  67. package/dist/cjs/api/resources/usage/types/index.js +17 -0
  68. package/dist/cjs/api/types/CostAmount.d.ts +12 -0
  69. package/dist/cjs/api/types/CostAmount.js +5 -0
  70. package/dist/cjs/api/types/CostTrace.d.ts +22 -0
  71. package/dist/cjs/api/types/CostTrace.js +5 -0
  72. package/dist/cjs/api/types/CostTracesResponse.d.ts +11 -0
  73. package/dist/cjs/api/types/CostTracesResponse.js +5 -0
  74. package/dist/cjs/api/types/Customer.d.ts +2 -0
  75. package/dist/cjs/api/types/CustomerUpdate.d.ts +2 -0
  76. package/dist/cjs/api/types/OrderLineAttributeCreateOne.d.ts +4 -0
  77. package/dist/cjs/api/types/OrderLineAttributeCreateOne.js +5 -0
  78. package/dist/cjs/api/types/OrderLineCreate.d.ts +10 -4
  79. package/dist/cjs/api/types/PaginationMeta.d.ts +28 -0
  80. package/dist/cjs/api/types/PaginationMeta.js +5 -0
  81. package/dist/cjs/api/types/Plan.d.ts +58 -0
  82. package/dist/cjs/api/types/Plan.js +5 -0
  83. package/dist/cjs/api/types/PlanGroup.d.ts +23 -0
  84. package/dist/cjs/api/types/PlanGroup.js +5 -0
  85. package/dist/cjs/api/types/Product.d.ts +36 -0
  86. package/dist/cjs/api/types/Product.js +14 -0
  87. package/dist/cjs/api/types/ProductUpdate.d.ts +23 -0
  88. package/dist/cjs/api/types/ProductUpdate.js +14 -0
  89. package/dist/cjs/api/types/Signal.d.ts +7 -2
  90. package/dist/cjs/api/types/SignalV2.d.ts +22 -0
  91. package/dist/cjs/api/types/SignalV2.js +5 -0
  92. package/dist/cjs/api/types/Trace.d.ts +26 -0
  93. package/dist/cjs/api/types/Trace.js +5 -0
  94. package/dist/cjs/api/types/TracesResponse.d.ts +11 -0
  95. package/dist/cjs/api/types/TracesResponse.js +5 -0
  96. package/dist/cjs/api/types/UsagePaginationMeta.d.ts +16 -0
  97. package/dist/cjs/api/types/UsagePaginationMeta.js +5 -0
  98. package/dist/cjs/api/types/UsageSummariesResponse.d.ts +11 -0
  99. package/dist/cjs/api/types/UsageSummariesResponse.js +5 -0
  100. package/dist/cjs/api/types/UsageSummary.d.ts +58 -0
  101. package/dist/cjs/api/types/UsageSummary.js +5 -0
  102. package/dist/cjs/api/types/index.d.ts +15 -1
  103. package/dist/cjs/api/types/index.js +15 -1
  104. package/dist/cjs/index.d.ts +1 -0
  105. package/dist/cjs/index.js +4 -0
  106. package/dist/cjs/tracing/autoInstrumentation.d.ts +10 -0
  107. package/dist/cjs/tracing/autoInstrumentation.js +57 -0
  108. package/dist/cjs/tracing/index.d.ts +4 -0
  109. package/dist/cjs/tracing/index.js +12 -0
  110. package/dist/cjs/tracing/signal.d.ts +18 -1
  111. package/dist/cjs/tracing/signal.js +29 -13
  112. package/dist/cjs/tracing/spanProcessor.d.ts +10 -0
  113. package/dist/cjs/tracing/spanProcessor.js +82 -0
  114. package/dist/cjs/tracing/tracing.d.ts +12 -6
  115. package/dist/cjs/tracing/tracing.js +65 -58
  116. package/dist/cjs/tracing/tracingContext.d.ts +8 -0
  117. package/dist/cjs/tracing/tracingContext.js +28 -0
  118. package/dist/cjs/tracing/wrappers/anthropicWrapper.js +11 -7
  119. package/dist/cjs/tracing/wrappers/langchainCallback.js +11 -7
  120. package/dist/cjs/tracing/wrappers/mistralWrapper.js +11 -7
  121. package/dist/cjs/tracing/wrappers/openAiWrapper.js +24 -23
  122. package/dist/cjs/tracing/wrappers/vercelAIWrapper.js +68 -43
  123. package/dist/cjs/version.d.ts +1 -1
  124. package/dist/cjs/version.js +1 -1
  125. package/dist/esm/Client.d.mts +35 -3
  126. package/dist/esm/Client.mjs +54 -16
  127. package/dist/esm/api/errors/InternalServerError.d.mts +9 -0
  128. package/dist/esm/api/errors/InternalServerError.mjs +15 -0
  129. package/dist/esm/api/errors/index.d.mts +1 -0
  130. package/dist/esm/api/errors/index.mjs +1 -0
  131. package/dist/esm/api/index.d.mts +1 -1
  132. package/dist/esm/api/index.mjs +1 -1
  133. package/dist/esm/api/resources/agents/client/Client.d.mts +16 -0
  134. package/dist/esm/api/resources/agents/client/Client.mjs +16 -0
  135. package/dist/esm/api/resources/customers/client/Client.d.mts +38 -0
  136. package/dist/esm/api/resources/customers/client/Client.mjs +164 -0
  137. package/dist/esm/api/resources/customers/client/requests/CustomerCreate.d.mts +2 -0
  138. package/dist/esm/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.mts +30 -0
  139. package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.mts +30 -0
  140. package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.mjs +4 -0
  141. package/dist/esm/api/resources/customers/client/requests/index.d.mts +2 -0
  142. package/dist/esm/api/resources/index.d.mts +8 -1
  143. package/dist/esm/api/resources/index.mjs +8 -1
  144. package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +2 -0
  145. package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +0 -2
  146. package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +0 -2
  147. package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.mts +0 -2
  148. package/dist/esm/api/resources/plans/client/Client.d.mts +75 -0
  149. package/dist/esm/api/resources/plans/client/Client.mjs +232 -0
  150. package/dist/esm/api/resources/plans/client/index.d.mts +1 -0
  151. package/dist/esm/api/resources/plans/client/index.mjs +1 -0
  152. package/dist/esm/api/resources/plans/client/requests/PlansGetUsageRequest.d.mts +35 -0
  153. package/dist/esm/api/resources/plans/client/requests/PlansGetUsageRequest.mjs +4 -0
  154. package/dist/esm/api/resources/plans/client/requests/index.d.mts +1 -0
  155. package/dist/esm/api/resources/plans/client/requests/index.mjs +1 -0
  156. package/dist/esm/api/resources/plans/index.d.mts +1 -0
  157. package/dist/esm/api/resources/plans/index.mjs +1 -0
  158. package/dist/esm/api/resources/products/client/Client.d.mts +109 -0
  159. package/dist/esm/api/resources/products/client/Client.mjs +430 -0
  160. package/dist/esm/api/resources/products/client/index.d.mts +1 -0
  161. package/dist/esm/api/resources/products/client/index.mjs +1 -0
  162. package/dist/esm/api/resources/products/client/requests/ProductCreate.d.mts +29 -0
  163. package/dist/esm/api/resources/products/client/requests/ProductCreate.mjs +11 -0
  164. package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -0
  165. package/dist/esm/api/resources/products/client/requests/index.mjs +1 -0
  166. package/dist/esm/api/resources/products/index.d.mts +1 -0
  167. package/dist/esm/api/resources/products/index.mjs +1 -0
  168. package/dist/esm/api/resources/traces/client/Client.d.mts +52 -0
  169. package/dist/esm/api/resources/traces/client/Client.mjs +126 -0
  170. package/dist/esm/api/resources/traces/client/index.d.mts +1 -0
  171. package/dist/esm/api/resources/traces/client/index.mjs +1 -0
  172. package/dist/esm/api/resources/traces/client/requests/GetTracesRequest.d.mts +50 -0
  173. package/dist/esm/api/resources/traces/client/requests/GetTracesRequest.mjs +4 -0
  174. package/dist/esm/api/resources/traces/client/requests/index.d.mts +1 -0
  175. package/dist/esm/api/resources/traces/client/requests/index.mjs +1 -0
  176. package/dist/esm/api/resources/traces/index.d.mts +1 -0
  177. package/dist/esm/api/resources/traces/index.mjs +1 -0
  178. package/dist/esm/api/resources/usage/client/Client.d.mts +47 -0
  179. package/dist/esm/api/resources/usage/client/Client.mjs +146 -0
  180. package/dist/esm/api/resources/usage/client/requests/UsageCheckUsageRequest.d.mts +28 -0
  181. package/dist/esm/api/resources/usage/client/requests/UsageCheckUsageRequest.mjs +4 -0
  182. package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.mts +29 -0
  183. package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.mjs +4 -0
  184. package/dist/esm/api/resources/usage/client/requests/index.d.mts +2 -0
  185. package/dist/esm/api/resources/usage/index.d.mts +1 -0
  186. package/dist/esm/api/resources/usage/index.mjs +1 -0
  187. package/dist/esm/api/resources/usage/types/UsageCheckUsageResponse.d.mts +17 -0
  188. package/dist/esm/api/resources/usage/types/UsageCheckUsageResponse.mjs +4 -0
  189. package/dist/esm/api/resources/usage/types/index.d.mts +1 -0
  190. package/dist/esm/api/resources/usage/types/index.mjs +1 -0
  191. package/dist/esm/api/types/CostAmount.d.mts +12 -0
  192. package/dist/esm/api/types/CostAmount.mjs +4 -0
  193. package/dist/esm/api/types/CostTrace.d.mts +22 -0
  194. package/dist/esm/api/types/CostTrace.mjs +4 -0
  195. package/dist/esm/api/types/CostTracesResponse.d.mts +11 -0
  196. package/dist/esm/api/types/CostTracesResponse.mjs +4 -0
  197. package/dist/esm/api/types/Customer.d.mts +2 -0
  198. package/dist/esm/api/types/CustomerUpdate.d.mts +2 -0
  199. package/dist/esm/api/types/OrderLineAttributeCreateOne.d.mts +4 -0
  200. package/dist/esm/api/types/OrderLineAttributeCreateOne.mjs +4 -0
  201. package/dist/esm/api/types/OrderLineCreate.d.mts +10 -4
  202. package/dist/esm/api/types/PaginationMeta.d.mts +28 -0
  203. package/dist/esm/api/types/PaginationMeta.mjs +4 -0
  204. package/dist/esm/api/types/Plan.d.mts +58 -0
  205. package/dist/esm/api/types/Plan.mjs +4 -0
  206. package/dist/esm/api/types/PlanGroup.d.mts +23 -0
  207. package/dist/esm/api/types/PlanGroup.mjs +4 -0
  208. package/dist/esm/api/types/Product.d.mts +36 -0
  209. package/dist/esm/api/types/Product.mjs +11 -0
  210. package/dist/esm/api/types/ProductUpdate.d.mts +23 -0
  211. package/dist/esm/api/types/ProductUpdate.mjs +11 -0
  212. package/dist/esm/api/types/Signal.d.mts +7 -2
  213. package/dist/esm/api/types/SignalV2.d.mts +22 -0
  214. package/dist/esm/api/types/SignalV2.mjs +4 -0
  215. package/dist/esm/api/types/Trace.d.mts +26 -0
  216. package/dist/esm/api/types/Trace.mjs +4 -0
  217. package/dist/esm/api/types/TracesResponse.d.mts +11 -0
  218. package/dist/esm/api/types/TracesResponse.mjs +4 -0
  219. package/dist/esm/api/types/UsagePaginationMeta.d.mts +16 -0
  220. package/dist/esm/api/types/UsagePaginationMeta.mjs +4 -0
  221. package/dist/esm/api/types/UsageSummariesResponse.d.mts +11 -0
  222. package/dist/esm/api/types/UsageSummariesResponse.mjs +4 -0
  223. package/dist/esm/api/types/UsageSummary.d.mts +58 -0
  224. package/dist/esm/api/types/UsageSummary.mjs +4 -0
  225. package/dist/esm/api/types/index.d.mts +15 -1
  226. package/dist/esm/api/types/index.mjs +15 -1
  227. package/dist/esm/index.d.mts +1 -0
  228. package/dist/esm/index.mjs +1 -0
  229. package/dist/esm/tracing/autoInstrumentation.d.mts +10 -0
  230. package/dist/esm/tracing/autoInstrumentation.mjs +54 -0
  231. package/dist/esm/tracing/index.d.mts +4 -0
  232. package/dist/esm/tracing/index.mjs +4 -0
  233. package/dist/esm/tracing/signal.d.mts +18 -1
  234. package/dist/esm/tracing/signal.mjs +28 -12
  235. package/dist/esm/tracing/spanProcessor.d.mts +10 -0
  236. package/dist/esm/tracing/spanProcessor.mjs +78 -0
  237. package/dist/esm/tracing/tracing.d.mts +12 -6
  238. package/dist/esm/tracing/tracing.mjs +59 -52
  239. package/dist/esm/tracing/tracingContext.d.mts +8 -0
  240. package/dist/esm/tracing/tracingContext.mjs +23 -0
  241. package/dist/esm/tracing/wrappers/anthropicWrapper.mjs +11 -7
  242. package/dist/esm/tracing/wrappers/langchainCallback.mjs +11 -7
  243. package/dist/esm/tracing/wrappers/mistralWrapper.mjs +11 -7
  244. package/dist/esm/tracing/wrappers/openAiWrapper.mjs +24 -23
  245. package/dist/esm/tracing/wrappers/vercelAIWrapper.mjs +68 -43
  246. package/dist/esm/version.d.mts +1 -1
  247. package/dist/esm/version.mjs +1 -1
  248. package/package.json +18 -10
  249. package/reference.md +1147 -153
  250. package/dist/cjs/api/types/OrderLineAttributeCreate.d.ts +0 -12
  251. package/dist/esm/api/types/OrderLineAttributeCreate.d.mts +0 -12
  252. /package/dist/cjs/api/{types/OrderLineAttributeCreate.js → resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.js} +0 -0
  253. /package/dist/esm/api/{types/OrderLineAttributeCreate.mjs → resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.mjs} +0 -0
@@ -0,0 +1,126 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ import * as environments from "../../../../environments.mjs";
14
+ import * as core from "../../../../core/index.mjs";
15
+ import * as Paid from "../../../index.mjs";
16
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
17
+ import urlJoin from "url-join";
18
+ import * as errors from "../../../../errors/index.mjs";
19
+ export class Traces {
20
+ constructor(_options = {}) {
21
+ this._options = _options;
22
+ }
23
+ /**
24
+ * @param {Paid.GetTracesRequest} request
25
+ * @param {Traces.RequestOptions} requestOptions - Request-specific configuration.
26
+ *
27
+ * @throws {@link Paid.BadRequestError}
28
+ * @throws {@link Paid.ForbiddenError}
29
+ *
30
+ * @example
31
+ * await client.traces.getTraces({
32
+ * limit: 1,
33
+ * offset: 1,
34
+ * startTime: "2024-01-15T09:30:00Z",
35
+ * endTime: "2024-01-15T09:30:00Z",
36
+ * externalCustomerId: "externalCustomerId",
37
+ * externalProductId: "externalProductId",
38
+ * externalAgentId: "externalAgentId",
39
+ * metadata: "metadata"
40
+ * })
41
+ */
42
+ getTraces(request = {}, requestOptions) {
43
+ return core.HttpResponsePromise.fromPromise(this.__getTraces(request, requestOptions));
44
+ }
45
+ __getTraces() {
46
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
47
+ var _a, _b, _c;
48
+ const { limit, offset, startTime, endTime, externalCustomerId, externalProductId, externalAgentId, metadata } = request;
49
+ const _queryParams = {};
50
+ if (limit != null) {
51
+ _queryParams["limit"] = limit.toString();
52
+ }
53
+ if (offset != null) {
54
+ _queryParams["offset"] = offset.toString();
55
+ }
56
+ if (startTime != null) {
57
+ _queryParams["startTime"] = startTime;
58
+ }
59
+ if (endTime != null) {
60
+ _queryParams["endTime"] = endTime;
61
+ }
62
+ if (externalCustomerId != null) {
63
+ _queryParams["externalCustomerId"] = externalCustomerId;
64
+ }
65
+ if (externalProductId != null) {
66
+ _queryParams["externalProductId"] = externalProductId;
67
+ }
68
+ if (externalAgentId != null) {
69
+ _queryParams["externalAgentId"] = externalAgentId;
70
+ }
71
+ if (metadata != null) {
72
+ _queryParams["metadata"] = metadata;
73
+ }
74
+ const _response = yield core.fetcher({
75
+ url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, "traces"),
76
+ method: "GET",
77
+ headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
78
+ queryParameters: _queryParams,
79
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
80
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
81
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
82
+ });
83
+ if (_response.ok) {
84
+ return { data: _response.body, rawResponse: _response.rawResponse };
85
+ }
86
+ if (_response.error.reason === "status-code") {
87
+ switch (_response.error.statusCode) {
88
+ case 400:
89
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
90
+ case 403:
91
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
92
+ default:
93
+ throw new errors.PaidError({
94
+ statusCode: _response.error.statusCode,
95
+ body: _response.error.body,
96
+ rawResponse: _response.rawResponse,
97
+ });
98
+ }
99
+ }
100
+ switch (_response.error.reason) {
101
+ case "non-json":
102
+ throw new errors.PaidError({
103
+ statusCode: _response.error.statusCode,
104
+ body: _response.error.rawBody,
105
+ rawResponse: _response.rawResponse,
106
+ });
107
+ case "timeout":
108
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /traces.");
109
+ case "unknown":
110
+ throw new errors.PaidError({
111
+ message: _response.error.errorMessage,
112
+ rawResponse: _response.rawResponse,
113
+ });
114
+ }
115
+ });
116
+ }
117
+ _getAuthorizationHeader() {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const bearer = yield core.Supplier.get(this._options.token);
120
+ if (bearer != null) {
121
+ return `Bearer ${bearer}`;
122
+ }
123
+ return undefined;
124
+ });
125
+ }
126
+ }
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * limit: 1,
8
+ * offset: 1,
9
+ * startTime: "2024-01-15T09:30:00Z",
10
+ * endTime: "2024-01-15T09:30:00Z",
11
+ * externalCustomerId: "externalCustomerId",
12
+ * externalProductId: "externalProductId",
13
+ * externalAgentId: "externalAgentId",
14
+ * metadata: "metadata"
15
+ * }
16
+ */
17
+ export interface GetTracesRequest {
18
+ /**
19
+ * Maximum number of traces to return (1-1000)
20
+ */
21
+ limit?: number;
22
+ /**
23
+ * Number of traces to skip for pagination
24
+ */
25
+ offset?: number;
26
+ /**
27
+ * Filter traces starting from this time (ISO 8601 format)
28
+ */
29
+ startTime?: string;
30
+ /**
31
+ * Filter traces up to this time (ISO 8601 format)
32
+ */
33
+ endTime?: string;
34
+ /**
35
+ * Filter traces by external customer ID
36
+ */
37
+ externalCustomerId?: string;
38
+ /**
39
+ * Filter traces by external product ID
40
+ */
41
+ externalProductId?: string;
42
+ /**
43
+ * DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
44
+ */
45
+ externalAgentId?: string;
46
+ /**
47
+ * Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
48
+ */
49
+ metadata?: string;
50
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export { type GetTracesRequest } from "./GetTracesRequest.mjs";
@@ -0,0 +1 @@
1
+ export * from "./client/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./client/index.mjs";
@@ -28,6 +28,8 @@ export declare class Usage {
28
28
  protected readonly _options: Usage.Options;
29
29
  constructor(_options?: Usage.Options);
30
30
  /**
31
+ * DEPRECATED: Use POST /usage/v2/signals/bulk instead for cleaner field names.
32
+ *
31
33
  * @param {Paid.UsageRecordBulkRequest} request
32
34
  * @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
33
35
  *
@@ -38,5 +40,50 @@ export declare class Usage {
38
40
  */
39
41
  recordBulk(request?: Paid.UsageRecordBulkRequest, requestOptions?: Usage.RequestOptions): core.HttpResponsePromise<void>;
40
42
  private __recordBulk;
43
+ /**
44
+ * @param {Paid.UsageRecordBulkV2Request} request
45
+ * @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
46
+ *
47
+ * @throws {@link Paid.BadRequestError}
48
+ *
49
+ * @example
50
+ * await client.usage.usageRecordBulkV2({
51
+ * signals: [{
52
+ * event_name: "emails_sent",
53
+ * product_id: "63fd642c-569d-44f9-8d67-5cf4944a16cc",
54
+ * customer_id: "7d0b6fce-d82a-433d-8315-c994f8f1d68d"
55
+ * }, {
56
+ * event_name: "emails_sent",
57
+ * external_product_id: "acme-product",
58
+ * external_customer_id: "acme-inc"
59
+ * }, {
60
+ * event_name: "meeting_booked",
61
+ * product_id: "63fd642c-569d-44f9-8d67-5cf4944a16cc",
62
+ * external_customer_id: "acme-inc",
63
+ * data: {
64
+ * "meeting_duration": 30,
65
+ * "meeting_type": "demo"
66
+ * }
67
+ * }]
68
+ * })
69
+ */
70
+ usageRecordBulkV2(request?: Paid.UsageRecordBulkV2Request, requestOptions?: Usage.RequestOptions): core.HttpResponsePromise<void>;
71
+ private __usageRecordBulkV2;
72
+ /**
73
+ * @param {Paid.UsageCheckUsageRequest} request
74
+ * @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
75
+ *
76
+ * @throws {@link Paid.BadRequestError}
77
+ * @throws {@link Paid.NotFoundError}
78
+ * @throws {@link Paid.InternalServerError}
79
+ *
80
+ * @example
81
+ * await client.usage.checkUsage({
82
+ * externalCustomerId: "acme-inc",
83
+ * externalProductId: "acme-agent"
84
+ * })
85
+ */
86
+ checkUsage(request: Paid.UsageCheckUsageRequest, requestOptions?: Usage.RequestOptions): core.HttpResponsePromise<Paid.UsageCheckUsageResponse>;
87
+ private __checkUsage;
41
88
  protected _getAuthorizationHeader(): Promise<string | undefined>;
42
89
  }
@@ -12,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  };
13
13
  import * as environments from "../../../../environments.mjs";
14
14
  import * as core from "../../../../core/index.mjs";
15
+ import * as Paid from "../../../index.mjs";
15
16
  import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
16
17
  import urlJoin from "url-join";
17
18
  import * as errors from "../../../../errors/index.mjs";
@@ -20,6 +21,8 @@ export class Usage {
20
21
  this._options = _options;
21
22
  }
22
23
  /**
24
+ * DEPRECATED: Use POST /usage/v2/signals/bulk instead for cleaner field names.
25
+ *
23
26
  * @param {Paid.UsageRecordBulkRequest} request
24
27
  * @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
25
28
  *
@@ -72,6 +75,149 @@ export class Usage {
72
75
  }
73
76
  });
74
77
  }
78
+ /**
79
+ * @param {Paid.UsageRecordBulkV2Request} request
80
+ * @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
81
+ *
82
+ * @throws {@link Paid.BadRequestError}
83
+ *
84
+ * @example
85
+ * await client.usage.usageRecordBulkV2({
86
+ * signals: [{
87
+ * event_name: "emails_sent",
88
+ * product_id: "63fd642c-569d-44f9-8d67-5cf4944a16cc",
89
+ * customer_id: "7d0b6fce-d82a-433d-8315-c994f8f1d68d"
90
+ * }, {
91
+ * event_name: "emails_sent",
92
+ * external_product_id: "acme-product",
93
+ * external_customer_id: "acme-inc"
94
+ * }, {
95
+ * event_name: "meeting_booked",
96
+ * product_id: "63fd642c-569d-44f9-8d67-5cf4944a16cc",
97
+ * external_customer_id: "acme-inc",
98
+ * data: {
99
+ * "meeting_duration": 30,
100
+ * "meeting_type": "demo"
101
+ * }
102
+ * }]
103
+ * })
104
+ */
105
+ usageRecordBulkV2(request = {}, requestOptions) {
106
+ return core.HttpResponsePromise.fromPromise(this.__usageRecordBulkV2(request, requestOptions));
107
+ }
108
+ __usageRecordBulkV2() {
109
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
110
+ var _a, _b, _c;
111
+ const _response = yield core.fetcher({
112
+ url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, "usage/v2/signals/bulk"),
113
+ method: "POST",
114
+ headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
115
+ contentType: "application/json",
116
+ requestType: "json",
117
+ body: request,
118
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
119
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
120
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
121
+ });
122
+ if (_response.ok) {
123
+ return { data: undefined, rawResponse: _response.rawResponse };
124
+ }
125
+ if (_response.error.reason === "status-code") {
126
+ switch (_response.error.statusCode) {
127
+ case 400:
128
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
129
+ default:
130
+ throw new errors.PaidError({
131
+ statusCode: _response.error.statusCode,
132
+ body: _response.error.body,
133
+ rawResponse: _response.rawResponse,
134
+ });
135
+ }
136
+ }
137
+ switch (_response.error.reason) {
138
+ case "non-json":
139
+ throw new errors.PaidError({
140
+ statusCode: _response.error.statusCode,
141
+ body: _response.error.rawBody,
142
+ rawResponse: _response.rawResponse,
143
+ });
144
+ case "timeout":
145
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /usage/v2/signals/bulk.");
146
+ case "unknown":
147
+ throw new errors.PaidError({
148
+ message: _response.error.errorMessage,
149
+ rawResponse: _response.rawResponse,
150
+ });
151
+ }
152
+ });
153
+ }
154
+ /**
155
+ * @param {Paid.UsageCheckUsageRequest} request
156
+ * @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
157
+ *
158
+ * @throws {@link Paid.BadRequestError}
159
+ * @throws {@link Paid.NotFoundError}
160
+ * @throws {@link Paid.InternalServerError}
161
+ *
162
+ * @example
163
+ * await client.usage.checkUsage({
164
+ * externalCustomerId: "acme-inc",
165
+ * externalProductId: "acme-agent"
166
+ * })
167
+ */
168
+ checkUsage(request, requestOptions) {
169
+ return core.HttpResponsePromise.fromPromise(this.__checkUsage(request, requestOptions));
170
+ }
171
+ __checkUsage(request, requestOptions) {
172
+ return __awaiter(this, void 0, void 0, function* () {
173
+ var _a, _b, _c;
174
+ const _response = yield core.fetcher({
175
+ url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, "usage/check-usage"),
176
+ method: "POST",
177
+ headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
178
+ contentType: "application/json",
179
+ requestType: "json",
180
+ body: request,
181
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
182
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
183
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
184
+ });
185
+ if (_response.ok) {
186
+ return { data: _response.body, rawResponse: _response.rawResponse };
187
+ }
188
+ if (_response.error.reason === "status-code") {
189
+ switch (_response.error.statusCode) {
190
+ case 400:
191
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
192
+ case 404:
193
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
194
+ case 500:
195
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
196
+ default:
197
+ throw new errors.PaidError({
198
+ statusCode: _response.error.statusCode,
199
+ body: _response.error.body,
200
+ rawResponse: _response.rawResponse,
201
+ });
202
+ }
203
+ }
204
+ switch (_response.error.reason) {
205
+ case "non-json":
206
+ throw new errors.PaidError({
207
+ statusCode: _response.error.statusCode,
208
+ body: _response.error.rawBody,
209
+ rawResponse: _response.rawResponse,
210
+ });
211
+ case "timeout":
212
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /usage/check-usage.");
213
+ case "unknown":
214
+ throw new errors.PaidError({
215
+ message: _response.error.errorMessage,
216
+ rawResponse: _response.rawResponse,
217
+ });
218
+ }
219
+ });
220
+ }
75
221
  _getAuthorizationHeader() {
76
222
  return __awaiter(this, void 0, void 0, function* () {
77
223
  const bearer = yield core.Supplier.get(this._options.token);
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * externalCustomerId: "acme-inc",
8
+ * externalProductId: "acme-agent"
9
+ * }
10
+ *
11
+ * @example
12
+ * {
13
+ * externalCustomerId: "acme-inc",
14
+ * externalProductId: "acme-agent"
15
+ * }
16
+ *
17
+ * @example
18
+ * {
19
+ * externalCustomerId: "acme-inc",
20
+ * externalProductId: "acme-agent"
21
+ * }
22
+ */
23
+ export interface UsageCheckUsageRequest {
24
+ /** External customer ID */
25
+ externalCustomerId: string;
26
+ /** External product ID (the external ID of the product/agent) */
27
+ externalProductId: string;
28
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Paid from "../../../../index.mjs";
5
+ /**
6
+ * @example
7
+ * {
8
+ * signals: [{
9
+ * event_name: "emails_sent",
10
+ * product_id: "63fd642c-569d-44f9-8d67-5cf4944a16cc",
11
+ * customer_id: "7d0b6fce-d82a-433d-8315-c994f8f1d68d"
12
+ * }, {
13
+ * event_name: "emails_sent",
14
+ * external_product_id: "acme-product",
15
+ * external_customer_id: "acme-inc"
16
+ * }, {
17
+ * event_name: "meeting_booked",
18
+ * product_id: "63fd642c-569d-44f9-8d67-5cf4944a16cc",
19
+ * external_customer_id: "acme-inc",
20
+ * data: {
21
+ * "meeting_duration": 30,
22
+ * "meeting_type": "demo"
23
+ * }
24
+ * }]
25
+ * }
26
+ */
27
+ export interface UsageRecordBulkV2Request {
28
+ signals?: Paid.SignalV2[];
29
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -1 +1,3 @@
1
1
  export { type UsageRecordBulkRequest } from "./UsageRecordBulkRequest.mjs";
2
+ export { type UsageRecordBulkV2Request } from "./UsageRecordBulkV2Request.mjs";
3
+ export { type UsageCheckUsageRequest } from "./UsageCheckUsageRequest.mjs";
@@ -1 +1,2 @@
1
+ export * from "./types/index.mjs";
1
2
  export * from "./client/index.mjs";
@@ -1 +1,2 @@
1
+ export * from "./types/index.mjs";
1
2
  export * from "./client/index.mjs";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface UsageCheckUsageResponse {
5
+ /** Whether usage is allowed */
6
+ allowed?: boolean;
7
+ /** Human-readable message about the usage check result */
8
+ message?: string;
9
+ /** Event name (only present when usage is not allowed) */
10
+ eventName?: string;
11
+ /** Available credits (only present for PrepaidCredits when insufficient) */
12
+ available?: number;
13
+ /** Current events quantity (only present when usage exceeds limit) */
14
+ eventsQuantity?: number;
15
+ /** Usage limit (only present when usage exceeds limit) */
16
+ limit?: number;
17
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./UsageCheckUsageResponse.mjs";
@@ -0,0 +1 @@
1
+ export * from "./UsageCheckUsageResponse.mjs";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Cost amount with currency
6
+ */
7
+ export interface CostAmount {
8
+ /** The cost amount */
9
+ amount: number;
10
+ /** The currency code (e.g., "USD") */
11
+ currency: string;
12
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Paid from "../index.mjs";
5
+ /**
6
+ * A single cost trace record
7
+ */
8
+ export interface CostTrace {
9
+ /** The name/type of the operation (e.g., "trace.openai.agents.on_agent") */
10
+ name: string;
11
+ /** The vendor/provider (e.g., "openai", "anthropic", "mistral") */
12
+ vendor: string;
13
+ /** The model used for the operation (e.g., "gpt-4o-mini", "claude-3-sonnet") */
14
+ model?: string;
15
+ cost: Paid.CostAmount;
16
+ /** Unix timestamp in nanoseconds when the operation started */
17
+ startTimeUnixNano: string;
18
+ /** Unix timestamp in nanoseconds when the operation completed */
19
+ endTimeUnixNano: string;
20
+ /** Additional metadata about the trace (e.g., tokens, etc.) */
21
+ attributes: Record<string, unknown>;
22
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Paid from "../index.mjs";
5
+ /**
6
+ * Response containing cost traces and pagination metadata
7
+ */
8
+ export interface CostTracesResponse {
9
+ traces: Paid.CostTrace[];
10
+ meta: Paid.PaginationMeta;
11
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -15,4 +15,6 @@ export interface Customer {
15
15
  creationState?: Paid.CreationState;
16
16
  website?: string;
17
17
  billingAddress?: Paid.Address;
18
+ /** Flexible JSON field for storing custom metadata about the customer */
19
+ metadata?: Record<string, unknown>;
18
20
  }
@@ -12,4 +12,6 @@ export interface CustomerUpdate {
12
12
  creationSource?: Paid.CreationSource;
13
13
  website?: string;
14
14
  billingAddress?: Paid.Address;
15
+ /** Flexible JSON field for storing custom metadata about the customer */
16
+ metadata?: Record<string, unknown>;
15
17
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type OrderLineAttributeCreateOne = unknown;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};