@metronome/sdk 0.1.0-alpha.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 (284) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +201 -0
  3. package/README.md +313 -0
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/_shims/auto/runtime-bun.js +21 -0
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +90 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +237 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +868 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +837 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +53 -0
  81. package/error.d.ts.map +1 -0
  82. package/error.js +143 -0
  83. package/error.js.map +1 -0
  84. package/error.mjs +127 -0
  85. package/error.mjs.map +1 -0
  86. package/index.d.mts +210 -0
  87. package/index.d.ts +210 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +133 -0
  90. package/index.js.map +1 -0
  91. package/index.mjs +105 -0
  92. package/index.mjs.map +1 -0
  93. package/package.json +106 -0
  94. package/resource.d.ts +6 -0
  95. package/resource.d.ts.map +1 -0
  96. package/resource.js +11 -0
  97. package/resource.js.map +1 -0
  98. package/resource.mjs +7 -0
  99. package/resource.mjs.map +1 -0
  100. package/resources/alerts.d.ts +103 -0
  101. package/resources/alerts.d.ts.map +1 -0
  102. package/resources/alerts.js +23 -0
  103. package/resources/alerts.js.map +1 -0
  104. package/resources/alerts.mjs +19 -0
  105. package/resources/alerts.mjs.map +1 -0
  106. package/resources/audit-logs.d.ts +83 -0
  107. package/resources/audit-logs.d.ts.map +1 -0
  108. package/resources/audit-logs.js +18 -0
  109. package/resources/audit-logs.js.map +1 -0
  110. package/resources/audit-logs.mjs +14 -0
  111. package/resources/audit-logs.mjs.map +1 -0
  112. package/resources/billable-metrics.d.ts +236 -0
  113. package/resources/billable-metrics.d.ts.map +1 -0
  114. package/resources/billable-metrics.js +36 -0
  115. package/resources/billable-metrics.js.map +1 -0
  116. package/resources/billable-metrics.mjs +32 -0
  117. package/resources/billable-metrics.mjs.map +1 -0
  118. package/resources/credit-grants.d.ts +469 -0
  119. package/resources/credit-grants.d.ts.map +1 -0
  120. package/resources/credit-grants.js +50 -0
  121. package/resources/credit-grants.js.map +1 -0
  122. package/resources/credit-grants.mjs +46 -0
  123. package/resources/credit-grants.mjs.map +1 -0
  124. package/resources/custom-fields.d.ts +82 -0
  125. package/resources/custom-fields.d.ts.map +1 -0
  126. package/resources/custom-fields.js +66 -0
  127. package/resources/custom-fields.js.map +1 -0
  128. package/resources/custom-fields.mjs +62 -0
  129. package/resources/custom-fields.mjs.map +1 -0
  130. package/resources/customers/alerts.d.ts +146 -0
  131. package/resources/customers/alerts.d.ts.map +1 -0
  132. package/resources/customers/alerts.js +35 -0
  133. package/resources/customers/alerts.js.map +1 -0
  134. package/resources/customers/alerts.mjs +31 -0
  135. package/resources/customers/alerts.mjs.map +1 -0
  136. package/resources/customers/billing-config.d.ts +64 -0
  137. package/resources/customers/billing-config.d.ts.map +1 -0
  138. package/resources/customers/billing-config.js +37 -0
  139. package/resources/customers/billing-config.js.map +1 -0
  140. package/resources/customers/billing-config.mjs +33 -0
  141. package/resources/customers/billing-config.mjs.map +1 -0
  142. package/resources/customers/customers.d.ts +313 -0
  143. package/resources/customers/customers.d.ts.map +1 -0
  144. package/resources/customers/customers.js +116 -0
  145. package/resources/customers/customers.js.map +1 -0
  146. package/resources/customers/customers.mjs +89 -0
  147. package/resources/customers/customers.mjs.map +1 -0
  148. package/resources/customers/index.d.ts +6 -0
  149. package/resources/customers/index.d.ts.map +1 -0
  150. package/resources/customers/index.js +15 -0
  151. package/resources/customers/index.js.map +1 -0
  152. package/resources/customers/index.mjs +7 -0
  153. package/resources/customers/index.mjs.map +1 -0
  154. package/resources/customers/invoices.d.ts +331 -0
  155. package/resources/customers/invoices.d.ts.map +1 -0
  156. package/resources/customers/invoices.js +30 -0
  157. package/resources/customers/invoices.js.map +1 -0
  158. package/resources/customers/invoices.mjs +26 -0
  159. package/resources/customers/invoices.mjs.map +1 -0
  160. package/resources/customers/plans.d.ts +239 -0
  161. package/resources/customers/plans.d.ts.map +1 -0
  162. package/resources/customers/plans.js +41 -0
  163. package/resources/customers/plans.js.map +1 -0
  164. package/resources/customers/plans.mjs +37 -0
  165. package/resources/customers/plans.mjs.map +1 -0
  166. package/resources/dashboards.d.ts +61 -0
  167. package/resources/dashboards.d.ts.map +1 -0
  168. package/resources/dashboards.js +19 -0
  169. package/resources/dashboards.js.map +1 -0
  170. package/resources/dashboards.mjs +15 -0
  171. package/resources/dashboards.mjs.map +1 -0
  172. package/resources/index.d.ts +13 -0
  173. package/resources/index.d.ts.map +1 -0
  174. package/resources/index.js +42 -0
  175. package/resources/index.js.map +1 -0
  176. package/resources/index.mjs +14 -0
  177. package/resources/index.mjs.map +1 -0
  178. package/resources/plans.d.ts +217 -0
  179. package/resources/plans.d.ts.map +1 -0
  180. package/resources/plans.js +36 -0
  181. package/resources/plans.js.map +1 -0
  182. package/resources/plans.mjs +32 -0
  183. package/resources/plans.mjs.map +1 -0
  184. package/resources/services.d.ts +26 -0
  185. package/resources/services.d.ts.map +1 -0
  186. package/resources/services.js +20 -0
  187. package/resources/services.js.map +1 -0
  188. package/resources/services.mjs +16 -0
  189. package/resources/services.mjs.map +1 -0
  190. package/resources/shared.d.ts +540 -0
  191. package/resources/shared.d.ts.map +1 -0
  192. package/resources/shared.js +4 -0
  193. package/resources/shared.js.map +1 -0
  194. package/resources/shared.mjs +3 -0
  195. package/resources/shared.mjs.map +1 -0
  196. package/resources/usage.d.ts +182 -0
  197. package/resources/usage.d.ts.map +1 -0
  198. package/resources/usage.js +41 -0
  199. package/resources/usage.js.map +1 -0
  200. package/resources/usage.mjs +37 -0
  201. package/resources/usage.mjs.map +1 -0
  202. package/resources/webhooks.d.ts +22 -0
  203. package/resources/webhooks.d.ts.map +1 -0
  204. package/resources/webhooks.js +91 -0
  205. package/resources/webhooks.js.map +1 -0
  206. package/resources/webhooks.mjs +87 -0
  207. package/resources/webhooks.mjs.map +1 -0
  208. package/shims/node.d.ts +29 -0
  209. package/shims/node.d.ts.map +1 -0
  210. package/shims/node.js +31 -0
  211. package/shims/node.js.map +1 -0
  212. package/shims/node.mjs +5 -0
  213. package/shims/node.mjs.map +1 -0
  214. package/shims/web.d.ts +26 -0
  215. package/shims/web.d.ts.map +1 -0
  216. package/shims/web.js +31 -0
  217. package/shims/web.js.map +1 -0
  218. package/shims/web.mjs +5 -0
  219. package/shims/web.mjs.map +1 -0
  220. package/src/_shims/MultipartBody.ts +9 -0
  221. package/src/_shims/README.md +46 -0
  222. package/src/_shims/auto/runtime-bun.ts +4 -0
  223. package/src/_shims/auto/runtime-node.ts +4 -0
  224. package/src/_shims/auto/runtime.ts +4 -0
  225. package/src/_shims/auto/types-node.ts +4 -0
  226. package/src/_shims/auto/types.d.ts +101 -0
  227. package/src/_shims/auto/types.js +3 -0
  228. package/src/_shims/auto/types.mjs +3 -0
  229. package/src/_shims/bun-runtime.ts +14 -0
  230. package/src/_shims/index.d.ts +81 -0
  231. package/src/_shims/index.js +13 -0
  232. package/src/_shims/index.mjs +7 -0
  233. package/src/_shims/manual-types.d.ts +12 -0
  234. package/src/_shims/manual-types.js +3 -0
  235. package/src/_shims/manual-types.mjs +3 -0
  236. package/src/_shims/node-runtime.ts +83 -0
  237. package/src/_shims/node-types.d.ts +42 -0
  238. package/src/_shims/node-types.js +3 -0
  239. package/src/_shims/node-types.mjs +3 -0
  240. package/src/_shims/registry.ts +67 -0
  241. package/src/_shims/web-runtime.ts +103 -0
  242. package/src/_shims/web-types.d.ts +83 -0
  243. package/src/_shims/web-types.js +3 -0
  244. package/src/_shims/web-types.mjs +3 -0
  245. package/src/core.ts +1146 -0
  246. package/src/error.ts +146 -0
  247. package/src/index.ts +303 -0
  248. package/src/lib/.keep +4 -0
  249. package/src/resource.ts +11 -0
  250. package/src/resources/alerts.ts +144 -0
  251. package/src/resources/audit-logs.ts +116 -0
  252. package/src/resources/billable-metrics.ts +341 -0
  253. package/src/resources/credit-grants.ts +627 -0
  254. package/src/resources/custom-fields.ts +242 -0
  255. package/src/resources/customers/alerts.ts +214 -0
  256. package/src/resources/customers/billing-config.ts +183 -0
  257. package/src/resources/customers/customers.ts +500 -0
  258. package/src/resources/customers/index.ts +53 -0
  259. package/src/resources/customers/invoices.ts +533 -0
  260. package/src/resources/customers/plans.ts +363 -0
  261. package/src/resources/dashboards.ts +98 -0
  262. package/src/resources/index.ts +90 -0
  263. package/src/resources/plans.ts +333 -0
  264. package/src/resources/services.ts +35 -0
  265. package/src/resources/shared.ts +849 -0
  266. package/src/resources/usage.ts +245 -0
  267. package/src/resources/webhooks.ts +120 -0
  268. package/src/shims/node.ts +50 -0
  269. package/src/shims/web.ts +50 -0
  270. package/src/tsconfig.json +11 -0
  271. package/src/uploads.ts +248 -0
  272. package/src/version.ts +1 -0
  273. package/uploads.d.ts +75 -0
  274. package/uploads.d.ts.map +1 -0
  275. package/uploads.js +165 -0
  276. package/uploads.js.map +1 -0
  277. package/uploads.mjs +152 -0
  278. package/uploads.mjs.map +1 -0
  279. package/version.d.ts +2 -0
  280. package/version.d.ts.map +1 -0
  281. package/version.js +5 -0
  282. package/version.js.map +1 -0
  283. package/version.mjs +2 -0
  284. package/version.mjs.map +1 -0
@@ -0,0 +1,116 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Core from "../core";
4
+ import { APIResource } from "../resource";
5
+ import { isRequestOptions } from "../core";
6
+ import * as AuditLogsAPI from "./audit-logs";
7
+
8
+ export class AuditLogs extends APIResource {
9
+ /**
10
+ * Retrieves a range of audit logs. If no further audit logs are currently
11
+ * available, the data array will be empty. As new audit logs are created,
12
+ * subsequent requests using the same next_page value will be in the returned data
13
+ * array, ensuring a continuous and uninterrupted reading of audit logs.
14
+ */
15
+ list(query?: AuditLogListParams, options?: Core.RequestOptions): Core.APIPromise<AuditLogListResponse>;
16
+ list(options?: Core.RequestOptions): Core.APIPromise<AuditLogListResponse>;
17
+ list(
18
+ query: AuditLogListParams | Core.RequestOptions = {},
19
+ options?: Core.RequestOptions,
20
+ ): Core.APIPromise<AuditLogListResponse> {
21
+ if (isRequestOptions(query)) {
22
+ return this.list({}, query);
23
+ }
24
+ return this._client.get('/auditLogs', { query, ...options });
25
+ }
26
+ }
27
+
28
+ export interface AuditLogListResponse {
29
+ data: Array<AuditLogListResponse.Data>;
30
+
31
+ /**
32
+ * The next_page parameter is always returned to support ongoing log retrieval. It
33
+ * enables continuous querying, even when some requests return no new data. Save
34
+ * the next_page token from each response and use it for future requests to ensure
35
+ * no logs are missed. This setup is ideal for regular updates via automated
36
+ * processes, like cron jobs, to fetch logs continuously as they become available.
37
+ * When you receive an empty data array, it indicates a temporary absence of new
38
+ * logs, but subsequent requests might return new data.
39
+ */
40
+ next_page: string | null;
41
+ }
42
+
43
+ export namespace AuditLogListResponse {
44
+ export interface Data {
45
+ id: string;
46
+
47
+ timestamp: string;
48
+
49
+ action?: string;
50
+
51
+ actor?: Data.Actor;
52
+
53
+ description?: string;
54
+
55
+ resource_id?: string;
56
+
57
+ resource_type?: string;
58
+
59
+ status?: 'success' | 'failure' | 'pending';
60
+ }
61
+
62
+ export namespace Data {
63
+ export interface Actor {
64
+ id: string;
65
+
66
+ name: string;
67
+
68
+ email?: string;
69
+ }
70
+ }
71
+ }
72
+
73
+ export interface AuditLogListParams {
74
+ /**
75
+ * RFC 3339 timestamp (exclusive). Cannot be used with 'next_page'.
76
+ */
77
+ ending_before?: string;
78
+
79
+ /**
80
+ * Max number of results that should be returned
81
+ */
82
+ limit?: number;
83
+
84
+ /**
85
+ * Cursor that indicates where the next page of results should start.
86
+ */
87
+ next_page?: string;
88
+
89
+ /**
90
+ * Optional parameter that can be used to filter which audit logs are returned. If
91
+ * you specify resource_id, you must also specify resource_type.
92
+ */
93
+ resource_id?: string;
94
+
95
+ /**
96
+ * Optional parameter that can be used to filter which audit logs are returned. If
97
+ * you specify resource_type, you must also specify resource_id.
98
+ */
99
+ resource_type?: string;
100
+
101
+ /**
102
+ * Sort order by timestamp, e.g. date_asc or date_desc. Defaults to date_asc.
103
+ */
104
+ sort?: 'date_asc' | 'date_desc';
105
+
106
+ /**
107
+ * RFC 3339 timestamp of the earliest audit log to return. Cannot be used with
108
+ * 'next_page'.
109
+ */
110
+ starting_on?: string;
111
+ }
112
+
113
+ export namespace AuditLogs {
114
+ export import AuditLogListResponse = AuditLogsAPI.AuditLogListResponse;
115
+ export import AuditLogListParams = AuditLogsAPI.AuditLogListParams;
116
+ }
@@ -0,0 +1,341 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Core from "../core";
4
+ import { APIResource } from "../resource";
5
+ import { isRequestOptions } from "../core";
6
+ import * as BillableMetricsAPI from "./billable-metrics";
7
+ import * as Shared from "./shared";
8
+
9
+ export class BillableMetrics extends APIResource {
10
+ /**
11
+ * Creates a new Billable Metric.
12
+ */
13
+ create(
14
+ body: BillableMetricCreateParams,
15
+ options?: Core.RequestOptions,
16
+ ): Core.APIPromise<BillableMetricCreateResponse> {
17
+ return this._client.post('/billable-metrics/create', { body, ...options });
18
+ }
19
+
20
+ /**
21
+ * Get a billable metric
22
+ */
23
+ retrieve(
24
+ billableMetricId: string,
25
+ options?: Core.RequestOptions,
26
+ ): Core.APIPromise<BillableMetricRetrieveResponse> {
27
+ return this._client.get(`/billable-metrics/${billableMetricId}`, options);
28
+ }
29
+
30
+ /**
31
+ * List all billable metrics.
32
+ */
33
+ list(
34
+ customerId: string,
35
+ query?: BillableMetricListParams,
36
+ options?: Core.RequestOptions,
37
+ ): Core.APIPromise<BillableMetricListResponse>;
38
+ list(customerId: string, options?: Core.RequestOptions): Core.APIPromise<BillableMetricListResponse>;
39
+ list(
40
+ customerId: string,
41
+ query: BillableMetricListParams | Core.RequestOptions = {},
42
+ options?: Core.RequestOptions,
43
+ ): Core.APIPromise<BillableMetricListResponse> {
44
+ if (isRequestOptions(query)) {
45
+ return this.list(customerId, {}, query);
46
+ }
47
+ return this._client.get(`/customers/${customerId}/billable-metrics`, { query, ...options });
48
+ }
49
+
50
+ /**
51
+ * Archive an existing billable metric
52
+ */
53
+ archive(
54
+ body: BillableMetricArchiveParams,
55
+ options?: Core.RequestOptions,
56
+ ): Core.APIPromise<BillableMetricArchiveResponse> {
57
+ return this._client.post('/billable-metrics/archive', { body, ...options });
58
+ }
59
+ }
60
+
61
+ export interface BillableMetricCreateResponse {
62
+ data: Shared.ID;
63
+ }
64
+
65
+ export interface BillableMetricRetrieveResponse {
66
+ data: BillableMetricRetrieveResponse.Data;
67
+ }
68
+
69
+ export namespace BillableMetricRetrieveResponse {
70
+ export interface Data {
71
+ /**
72
+ * ID of the billable metric
73
+ */
74
+ id: string;
75
+
76
+ /**
77
+ * Specifies the type of aggregation performed on matching events.
78
+ */
79
+ aggregation_type:
80
+ | 'count'
81
+ | 'Count'
82
+ | 'COUNT'
83
+ | 'latest'
84
+ | 'Latest'
85
+ | 'LATEST'
86
+ | 'max'
87
+ | 'Max'
88
+ | 'MAX'
89
+ | 'sum'
90
+ | 'Sum'
91
+ | 'SUM'
92
+ | 'unique'
93
+ | 'Unique'
94
+ | 'UNIQUE';
95
+
96
+ /**
97
+ * The display name of the billable metric.
98
+ */
99
+ name: string;
100
+
101
+ /**
102
+ * A key that specifies which property of the event is used to aggregate data. This
103
+ * key must be one of the property filter names and is not applicable when the
104
+ * aggregation type is 'count'.
105
+ */
106
+ aggregation_key?: string;
107
+
108
+ custom_fields?: Record<string, string>;
109
+
110
+ /**
111
+ * An optional filtering rule to match the 'event_type' property of an event.
112
+ */
113
+ event_type_filter?: Data.EventTypeFilter;
114
+
115
+ /**
116
+ * Property names that are used to group usage costs on an invoice. Each entry
117
+ * represents a set of properties used to slice events into distinct buckets.
118
+ */
119
+ group_keys?: Array<Array<string>>;
120
+
121
+ /**
122
+ * A list of filters to match events to this billable metric. Each filter defines a
123
+ * rule on an event property. All rules must pass for the event to match the
124
+ * billable metric.
125
+ */
126
+ property_filters?: Array<Data.PropertyFilter>;
127
+ }
128
+
129
+ export namespace Data {
130
+ /**
131
+ * An optional filtering rule to match the 'event_type' property of an event.
132
+ */
133
+ export interface EventTypeFilter {
134
+ /**
135
+ * A list of event types that are explicitly included in the billable metric. If
136
+ * specified, only events of these types will match the billable metric. Must be
137
+ * non-empty if present.
138
+ */
139
+ in_values?: Array<string>;
140
+
141
+ /**
142
+ * A list of event types that are explicitly excluded from the billable metric. If
143
+ * specified, events of these types will not match the billable metric. Must be
144
+ * non-empty if present.
145
+ */
146
+ not_in_values?: Array<string>;
147
+ }
148
+
149
+ export interface PropertyFilter {
150
+ /**
151
+ * The name of the event property.
152
+ */
153
+ name: string;
154
+
155
+ /**
156
+ * Determines whether the property must exist in the event. If true, only events
157
+ * with this property will pass the filter. If false, only events without this
158
+ * property will pass the filter. If null or omitted, the existence of the property
159
+ * is optional.
160
+ */
161
+ exists?: boolean;
162
+
163
+ /**
164
+ * Specifies the allowed values for the property to match an event. An event will
165
+ * pass the filter only if its property value is included in this list. If
166
+ * undefined, all property values will pass the filter. Must be non-empty if
167
+ * present.
168
+ */
169
+ in_values?: Array<string>;
170
+
171
+ /**
172
+ * Specifies the values that prevent an event from matching the filter. An event
173
+ * will not pass the filter if its property value is included in this list. If null
174
+ * or empty, all property values will pass the filter. Must be non-empty if
175
+ * present.
176
+ */
177
+ not_in_values?: Array<string>;
178
+ }
179
+ }
180
+ }
181
+
182
+ export interface BillableMetricListResponse {
183
+ data: Array<BillableMetricListResponse.Data>;
184
+
185
+ next_page: string | null;
186
+ }
187
+
188
+ export namespace BillableMetricListResponse {
189
+ export interface Data {
190
+ id: string;
191
+
192
+ name: string;
193
+
194
+ group_by?: Array<string>;
195
+ }
196
+ }
197
+
198
+ export interface BillableMetricArchiveResponse {
199
+ data: Shared.ID;
200
+ }
201
+
202
+ export interface BillableMetricCreateParams {
203
+ /**
204
+ * Specifies the type of aggregation performed on matching events.
205
+ */
206
+ aggregation_type:
207
+ | 'count'
208
+ | 'Count'
209
+ | 'COUNT'
210
+ | 'latest'
211
+ | 'Latest'
212
+ | 'LATEST'
213
+ | 'max'
214
+ | 'Max'
215
+ | 'MAX'
216
+ | 'sum'
217
+ | 'Sum'
218
+ | 'SUM'
219
+ | 'unique'
220
+ | 'Unique'
221
+ | 'UNIQUE';
222
+
223
+ /**
224
+ * The display name of the billable metric.
225
+ */
226
+ name: string;
227
+
228
+ /**
229
+ * A key that specifies which property of the event is used to aggregate data. This
230
+ * key must be one of the property filter names and is not applicable when the
231
+ * aggregation type is 'count'.
232
+ */
233
+ aggregation_key?: string;
234
+
235
+ /**
236
+ * Custom fields to attach to the billable metric.
237
+ */
238
+ custom_fields?: Record<string, string>;
239
+
240
+ /**
241
+ * An optional filtering rule to match the 'event_type' property of an event.
242
+ */
243
+ event_type_filter?: BillableMetricCreateParams.EventTypeFilter;
244
+
245
+ /**
246
+ * Property names that are used to group usage costs on an invoice. Each entry
247
+ * represents a set of properties used to slice events into distinct buckets.
248
+ */
249
+ group_keys?: Array<Array<string>>;
250
+
251
+ /**
252
+ * A list of filters to match events to this billable metric. Each filter defines a
253
+ * rule on an event property. All rules must pass for the event to match the
254
+ * billable metric.
255
+ */
256
+ property_filters?: Array<BillableMetricCreateParams.PropertyFilter>;
257
+ }
258
+
259
+ export namespace BillableMetricCreateParams {
260
+ /**
261
+ * An optional filtering rule to match the 'event_type' property of an event.
262
+ */
263
+ export interface EventTypeFilter {
264
+ /**
265
+ * A list of event types that are explicitly included in the billable metric. If
266
+ * specified, only events of these types will match the billable metric. Must be
267
+ * non-empty if present.
268
+ */
269
+ in_values?: Array<string>;
270
+
271
+ /**
272
+ * A list of event types that are explicitly excluded from the billable metric. If
273
+ * specified, events of these types will not match the billable metric. Must be
274
+ * non-empty if present.
275
+ */
276
+ not_in_values?: Array<string>;
277
+ }
278
+
279
+ export interface PropertyFilter {
280
+ /**
281
+ * The name of the event property.
282
+ */
283
+ name: string;
284
+
285
+ /**
286
+ * Determines whether the property must exist in the event. If true, only events
287
+ * with this property will pass the filter. If false, only events without this
288
+ * property will pass the filter. If null or omitted, the existence of the property
289
+ * is optional.
290
+ */
291
+ exists?: boolean;
292
+
293
+ /**
294
+ * Specifies the allowed values for the property to match an event. An event will
295
+ * pass the filter only if its property value is included in this list. If
296
+ * undefined, all property values will pass the filter. Must be non-empty if
297
+ * present.
298
+ */
299
+ in_values?: Array<string>;
300
+
301
+ /**
302
+ * Specifies the values that prevent an event from matching the filter. An event
303
+ * will not pass the filter if its property value is included in this list. If null
304
+ * or empty, all property values will pass the filter. Must be non-empty if
305
+ * present.
306
+ */
307
+ not_in_values?: Array<string>;
308
+ }
309
+ }
310
+
311
+ export interface BillableMetricListParams {
312
+ /**
313
+ * Max number of results that should be returned
314
+ */
315
+ limit?: number;
316
+
317
+ /**
318
+ * Cursor that indicates where the next page of results should start.
319
+ */
320
+ next_page?: string;
321
+
322
+ /**
323
+ * If true, the list of metrics will be filtered to just ones that are on the
324
+ * customer's current plan
325
+ */
326
+ on_current_plan?: boolean;
327
+ }
328
+
329
+ export interface BillableMetricArchiveParams {
330
+ id: string;
331
+ }
332
+
333
+ export namespace BillableMetrics {
334
+ export import BillableMetricCreateResponse = BillableMetricsAPI.BillableMetricCreateResponse;
335
+ export import BillableMetricRetrieveResponse = BillableMetricsAPI.BillableMetricRetrieveResponse;
336
+ export import BillableMetricListResponse = BillableMetricsAPI.BillableMetricListResponse;
337
+ export import BillableMetricArchiveResponse = BillableMetricsAPI.BillableMetricArchiveResponse;
338
+ export import BillableMetricCreateParams = BillableMetricsAPI.BillableMetricCreateParams;
339
+ export import BillableMetricListParams = BillableMetricsAPI.BillableMetricListParams;
340
+ export import BillableMetricArchiveParams = BillableMetricsAPI.BillableMetricArchiveParams;
341
+ }