@stigg/typescript 0.1.0-beta.56 → 0.1.0-beta.58

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 (133) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/client.d.mts +3 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +3 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/index.d.mts +1 -0
  12. package/resources/index.d.mts.map +1 -1
  13. package/resources/index.d.ts +1 -0
  14. package/resources/index.d.ts.map +1 -1
  15. package/resources/index.js +3 -1
  16. package/resources/index.js.map +1 -1
  17. package/resources/index.mjs +1 -0
  18. package/resources/index.mjs.map +1 -1
  19. package/resources/v1/contracts.d.mts +18 -10
  20. package/resources/v1/contracts.d.mts.map +1 -1
  21. package/resources/v1/contracts.d.ts +18 -10
  22. package/resources/v1/contracts.d.ts.map +1 -1
  23. package/resources/v1/contracts.js +3 -4
  24. package/resources/v1/contracts.js.map +1 -1
  25. package/resources/v1/contracts.mjs +3 -4
  26. package/resources/v1/contracts.mjs.map +1 -1
  27. package/resources/v1/coupons.d.mts +10 -6
  28. package/resources/v1/coupons.d.mts.map +1 -1
  29. package/resources/v1/coupons.d.ts +10 -6
  30. package/resources/v1/coupons.d.ts.map +1 -1
  31. package/resources/v1/credits/consumption.d.mts +50 -0
  32. package/resources/v1/credits/consumption.d.mts.map +1 -1
  33. package/resources/v1/credits/consumption.d.ts +50 -0
  34. package/resources/v1/credits/consumption.d.ts.map +1 -1
  35. package/resources/v1/customers/customers.d.mts +28 -9
  36. package/resources/v1/customers/customers.d.mts.map +1 -1
  37. package/resources/v1/customers/customers.d.ts +28 -9
  38. package/resources/v1/customers/customers.d.ts.map +1 -1
  39. package/resources/v1/customers/customers.js +3 -4
  40. package/resources/v1/customers/customers.js.map +1 -1
  41. package/resources/v1/customers/customers.mjs +3 -4
  42. package/resources/v1/customers/customers.mjs.map +1 -1
  43. package/resources/v1/customers/integrations.d.mts +5 -6
  44. package/resources/v1/customers/integrations.d.mts.map +1 -1
  45. package/resources/v1/customers/integrations.d.ts +5 -6
  46. package/resources/v1/customers/integrations.d.ts.map +1 -1
  47. package/resources/v1/events/data-export/data-export.d.mts +1 -61
  48. package/resources/v1/events/data-export/data-export.d.mts.map +1 -1
  49. package/resources/v1/events/data-export/data-export.d.ts +1 -61
  50. package/resources/v1/events/data-export/data-export.d.ts.map +1 -1
  51. package/resources/v1/events/data-export/data-export.js +0 -18
  52. package/resources/v1/events/data-export/data-export.js.map +1 -1
  53. package/resources/v1/events/data-export/data-export.mjs +0 -18
  54. package/resources/v1/events/data-export/data-export.mjs.map +1 -1
  55. package/resources/v1/events/data-export/index.d.mts +1 -1
  56. package/resources/v1/events/data-export/index.d.mts.map +1 -1
  57. package/resources/v1/events/data-export/index.d.ts +1 -1
  58. package/resources/v1/events/data-export/index.d.ts.map +1 -1
  59. package/resources/v1/events/data-export/index.js.map +1 -1
  60. package/resources/v1/events/data-export/index.mjs.map +1 -1
  61. package/resources/v1/events/events.d.mts +2 -2
  62. package/resources/v1/events/events.d.mts.map +1 -1
  63. package/resources/v1/events/events.d.ts +2 -2
  64. package/resources/v1/events/events.d.ts.map +1 -1
  65. package/resources/v1/events/events.js.map +1 -1
  66. package/resources/v1/events/events.mjs.map +1 -1
  67. package/resources/v1/events/index.d.mts +1 -1
  68. package/resources/v1/events/index.d.mts.map +1 -1
  69. package/resources/v1/events/index.d.ts +1 -1
  70. package/resources/v1/events/index.d.ts.map +1 -1
  71. package/resources/v1/events/index.js.map +1 -1
  72. package/resources/v1/events/index.mjs.map +1 -1
  73. package/resources/v1/usage.d.mts +4 -1
  74. package/resources/v1/usage.d.mts.map +1 -1
  75. package/resources/v1/usage.d.ts +4 -1
  76. package/resources/v1/usage.d.ts.map +1 -1
  77. package/resources/v1/usage.js +4 -1
  78. package/resources/v1/usage.js.map +1 -1
  79. package/resources/v1/usage.mjs +4 -1
  80. package/resources/v1/usage.mjs.map +1 -1
  81. package/resources/v2/index.d.mts +3 -0
  82. package/resources/v2/index.d.mts.map +1 -0
  83. package/resources/v2/index.d.ts +3 -0
  84. package/resources/v2/index.d.ts.map +1 -0
  85. package/resources/v2/index.js +9 -0
  86. package/resources/v2/index.js.map +1 -0
  87. package/resources/v2/index.mjs +4 -0
  88. package/resources/v2/index.mjs.map +1 -0
  89. package/resources/v2/usage.d.mts +284 -0
  90. package/resources/v2/usage.d.mts.map +1 -0
  91. package/resources/v2/usage.d.ts +284 -0
  92. package/resources/v2/usage.d.ts.map +1 -0
  93. package/resources/v2/usage.js +32 -0
  94. package/resources/v2/usage.js.map +1 -0
  95. package/resources/v2/usage.mjs +28 -0
  96. package/resources/v2/usage.mjs.map +1 -0
  97. package/resources/v2/v2.d.mts +10 -0
  98. package/resources/v2/v2.d.mts.map +1 -0
  99. package/resources/v2/v2.d.ts +10 -0
  100. package/resources/v2/v2.d.ts.map +1 -0
  101. package/resources/v2/v2.js +17 -0
  102. package/resources/v2/v2.js.map +1 -0
  103. package/resources/v2/v2.mjs +12 -0
  104. package/resources/v2/v2.mjs.map +1 -0
  105. package/resources/v2.d.mts +2 -0
  106. package/resources/v2.d.mts.map +1 -0
  107. package/resources/v2.d.ts +2 -0
  108. package/resources/v2.d.ts.map +1 -0
  109. package/resources/v2.js +6 -0
  110. package/resources/v2.js.map +1 -0
  111. package/resources/v2.mjs +3 -0
  112. package/resources/v2.mjs.map +1 -0
  113. package/src/client.ts +5 -0
  114. package/src/resources/index.ts +1 -0
  115. package/src/resources/v1/contracts.ts +20 -11
  116. package/src/resources/v1/coupons.ts +10 -6
  117. package/src/resources/v1/credits/consumption.ts +60 -0
  118. package/src/resources/v1/customers/customers.ts +32 -23
  119. package/src/resources/v1/customers/integrations.ts +5 -49
  120. package/src/resources/v1/events/data-export/data-export.ts +0 -86
  121. package/src/resources/v1/events/data-export/index.ts +0 -2
  122. package/src/resources/v1/events/events.ts +0 -4
  123. package/src/resources/v1/events/index.ts +0 -2
  124. package/src/resources/v1/usage.ts +4 -1
  125. package/src/resources/v2/index.ts +4 -0
  126. package/src/resources/v2/usage.ts +344 -0
  127. package/src/resources/v2/v2.ts +19 -0
  128. package/src/resources/v2.ts +3 -0
  129. package/src/version.ts +1 -1
  130. package/version.d.mts +1 -1
  131. package/version.d.ts +1 -1
  132. package/version.js +1 -1
  133. package/version.mjs +1 -1
@@ -0,0 +1,284 @@
1
+ import { APIResource } from "../../core/resource.mjs";
2
+ import { APIPromise } from "../../core/api-promise.mjs";
3
+ import { RequestOptions } from "../../internal/request-options.mjs";
4
+ /**
5
+ * Operations related to usage & metering
6
+ */
7
+ export declare class Usage extends APIResource {
8
+ /**
9
+ * Reports usage measurements for metered features. The reported usage is used to
10
+ * track, limit, and bill customer consumption. Credit balances are returned once
11
+ * per wallet in `credits`, not on each measurement.
12
+ */
13
+ report(params: UsageReportParams, options?: RequestOptions): APIPromise<UsageReportResponse>;
14
+ }
15
+ /**
16
+ * Response containing reported usage measurements with current usage values,
17
+ * period information and reset dates, plus the balance of each credit wallet they
18
+ * drew from.
19
+ */
20
+ export interface UsageReportResponse {
21
+ /**
22
+ * Reported usage measurements and the credit balances they drew from
23
+ */
24
+ data: UsageReportResponse.Data;
25
+ }
26
+ export declare namespace UsageReportResponse {
27
+ /**
28
+ * Reported usage measurements and the credit balances they drew from
29
+ */
30
+ interface Data {
31
+ /**
32
+ * Usage measurements, in request order, with current values and period info
33
+ */
34
+ usages: Array<Data.Usage>;
35
+ /**
36
+ * The balance of each credit wallet the request drew from. Omitted when no
37
+ * reported feature consumes credits, or when credit balances aren't computed
38
+ * synchronously for the environment; each usage's `credit` is then `null`.
39
+ */
40
+ credits?: Array<Data.Credit>;
41
+ /**
42
+ * The current usage of each governance entitlement this request counted towards.
43
+ * Absent when governance is not enabled or the usage is unknown. Entitlements
44
+ * whose usage could not be read, and those of repeated idempotent requests, are
45
+ * left out
46
+ */
47
+ entities?: Array<Data.Entity>;
48
+ }
49
+ namespace Data {
50
+ /**
51
+ * Recorded usage with period info and the credits it deducted
52
+ */
53
+ interface Usage {
54
+ /**
55
+ * Unique identifier for the entity
56
+ */
57
+ id: string;
58
+ /**
59
+ * Timestamp of when the record was created
60
+ */
61
+ createdAt: string;
62
+ /**
63
+ * Customer id
64
+ */
65
+ customerId: string;
66
+ /**
67
+ * Feature id
68
+ */
69
+ featureId: string;
70
+ /**
71
+ * Timestamp
72
+ */
73
+ timestamp: string;
74
+ /**
75
+ * The usage measurement record
76
+ */
77
+ value: number;
78
+ /**
79
+ * The credits this measurement deducted. `null` when the measurement drew from no
80
+ * wallet listed in `credits`. The balance of the wallet it drew from is in the
81
+ * response `credits` list, matched by customer, resource and currency.
82
+ */
83
+ credit?: Usage.Credit | null;
84
+ /**
85
+ * The current measured usage value
86
+ */
87
+ currentUsage?: number | null;
88
+ /**
89
+ * The date when the next usage reset will occur
90
+ */
91
+ nextResetDate?: string | null;
92
+ /**
93
+ * The customer resource this usage applies to. Optional — only required if the
94
+ * customer has multiple resources (for example, one subscription per workspace or
95
+ * site) and usage needs to be tracked separately per resource; omit it to report
96
+ * usage at the customer level.
97
+ */
98
+ resourceId?: string | null;
99
+ /**
100
+ * The end date of the usage period in which this measurement resides (for
101
+ * entitlements with a reset period)
102
+ */
103
+ usagePeriodEnd?: string | null;
104
+ /**
105
+ * The start date of the usage period in which this measurement resides (for
106
+ * entitlements with a reset period)
107
+ */
108
+ usagePeriodStart?: string | null;
109
+ }
110
+ namespace Usage {
111
+ /**
112
+ * The credits this measurement deducted. `null` when the measurement drew from no
113
+ * wallet listed in `credits`. The balance of the wallet it drew from is in the
114
+ * response `credits` list, matched by customer, resource and currency.
115
+ */
116
+ interface Credit {
117
+ /**
118
+ * The credits this single reportUsage call deducted, in credit units — scoped to
119
+ * this one measurement (0 for idempotency duplicates). Contrast `currentUsage`,
120
+ * which is the wallet-wide running total shared across all features on this
121
+ * currency. Use it to reconcile expected per-call deductions.
122
+ */
123
+ consumed: number;
124
+ /**
125
+ * The credit currency identifier
126
+ */
127
+ currencyId: string;
128
+ }
129
+ }
130
+ /**
131
+ * Optimistic credit balance of one wallet (customer, resource and currency) after
132
+ * the request, listed once however many measurements drew from it
133
+ */
134
+ interface Credit {
135
+ /**
136
+ * The credit currency identifier
137
+ */
138
+ currencyId: string;
139
+ /**
140
+ * The wallet's total consumed credits for this currency (optimistic — includes
141
+ * not-yet-reconciled usage), shared across every feature that draws on the
142
+ * currency. This is the running balance, not this call's deduction — see
143
+ * `consumed` for that.
144
+ */
145
+ currentUsage: number;
146
+ /**
147
+ * Customer id
148
+ */
149
+ customerId: string;
150
+ /**
151
+ * The wallet's resource; `null` for the customer-level wallet
152
+ */
153
+ resourceId: string | null;
154
+ /**
155
+ * The grant-version timestamp of this balance, used by the SDK for last-write-wins
156
+ * reconciliation
157
+ */
158
+ timestamp: string;
159
+ /**
160
+ * The total credits granted
161
+ */
162
+ usageLimit: number;
163
+ /**
164
+ * End of the current credit grant period (when recurring credits reset), if
165
+ * applicable
166
+ */
167
+ usagePeriodEnd?: string | null;
168
+ }
169
+ /**
170
+ * The usage counted against one governance entitlement
171
+ */
172
+ interface Entity {
173
+ /**
174
+ * The absolute usage counted against the entitlement
175
+ */
176
+ currentUsage: number;
177
+ /**
178
+ * The customer whose usage counted towards the entitlement
179
+ */
180
+ customerId: string;
181
+ /**
182
+ * The governance entitlement the usage counts towards
183
+ */
184
+ entitlementId: string;
185
+ /**
186
+ * The governance entity the entitlement belongs to
187
+ */
188
+ entityId: string;
189
+ /**
190
+ * The customer resource the usage counted from; `null` for customer-level usage
191
+ */
192
+ resourceId: string | null;
193
+ /**
194
+ * The entities the entitlement is scoped to (empty when it is not scoped)
195
+ */
196
+ scopeEntityIds: Array<string>;
197
+ /**
198
+ * When the entitlement usage was last updated
199
+ */
200
+ usageUpdatedAt: string;
201
+ /**
202
+ * The credit currency the entitlement governs (exactly one of featureId and
203
+ * currencyId is set)
204
+ */
205
+ currencyId?: string;
206
+ /**
207
+ * The feature the entitlement governs (exactly one of featureId and currencyId is
208
+ * set)
209
+ */
210
+ featureId?: string;
211
+ }
212
+ }
213
+ }
214
+ export interface UsageReportParams {
215
+ /**
216
+ * Body param: A list of usage reports to be submitted in bulk
217
+ */
218
+ usages: Array<UsageReportParams.Usage>;
219
+ /**
220
+ * Header param: Account ID — optional when authenticating with a user JWT (Bearer
221
+ * token); falls back to the user's first membership. Ignored for API-key auth.
222
+ */
223
+ 'X-ACCOUNT-ID'?: string;
224
+ /**
225
+ * Header param: Environment ID — required when authenticating with a user JWT
226
+ * (Bearer token) on environment-scoped endpoints. Ignored for API-key auth (env is
227
+ * intrinsic to the key).
228
+ */
229
+ 'X-ENVIRONMENT-ID'?: string;
230
+ }
231
+ export declare namespace UsageReportParams {
232
+ /**
233
+ * Single usage measurement
234
+ */
235
+ interface Usage {
236
+ /**
237
+ * Customer id
238
+ */
239
+ customerId: string;
240
+ /**
241
+ * Feature id
242
+ */
243
+ featureId: string;
244
+ /**
245
+ * The value to report for usage. Must be a whole number — the REST API does not
246
+ * accept fractional (float) usage values; scale up (e.g. report cents instead of
247
+ * dollars, or milliseconds instead of seconds) if you need sub-unit precision.
248
+ */
249
+ value: number;
250
+ /**
251
+ * Timestamp of when the record was created
252
+ */
253
+ createdAt?: string;
254
+ /**
255
+ * Additional dimensions for the usage report
256
+ */
257
+ dimensions?: {
258
+ [key: string]: string | number | boolean;
259
+ };
260
+ /**
261
+ * A key you provide to safely retry the same usage report without double-counting
262
+ * it. Reports with a previously-seen idempotency key are deduplicated for 7 days;
263
+ * after that window a retry is treated as new usage.
264
+ */
265
+ idempotencyKey?: string;
266
+ /**
267
+ * The customer resource this usage applies to. Optional — only required if the
268
+ * customer has multiple resources (for example, one subscription per workspace or
269
+ * site) and usage needs to be tracked separately per resource; omit it to report
270
+ * usage at the customer level.
271
+ */
272
+ resourceId?: string | null;
273
+ /**
274
+ * How the reported value is applied: DELTA (default) adds it to the feature's
275
+ * current usage; SET treats it as the new absolute usage total, and Stigg computes
276
+ * the delta internally.
277
+ */
278
+ updateBehavior?: 'DELTA' | 'SET';
279
+ }
280
+ }
281
+ export declare namespace Usage {
282
+ export { type UsageReportResponse as UsageReportResponse, type UsageReportParams as UsageReportParams };
283
+ }
284
+ //# sourceMappingURL=usage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.mts","sourceRoot":"","sources":["../../src/resources/v2/usage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAEpD,OAAO,EAAE,cAAc,EAAE,2CAAuC;AAEhE;;GAEG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;CAc7F;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAC,IAAI,CAAC;CAChC;AAED,yBAAiB,mBAAmB,CAAC;IACnC;;OAEG;IACH,UAAiB,IAAI;QACnB;;WAEG;QACH,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE1B;;;;WAIG;QACH,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE7B;;;;;WAKG;QACH,QAAQ,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC/B;IAED,UAAiB,IAAI,CAAC;QACpB;;WAEG;QACH,UAAiB,KAAK;YACpB;;eAEG;YACH,EAAE,EAAE,MAAM,CAAC;YAEX;;eAEG;YACH,SAAS,EAAE,MAAM,CAAC;YAElB;;eAEG;YACH,UAAU,EAAE,MAAM,CAAC;YAEnB;;eAEG;YACH,SAAS,E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
2
+ import { APIPromise } from "../../core/api-promise.js";
3
+ import { RequestOptions } from "../../internal/request-options.js";
4
+ /**
5
+ * Operations related to usage & metering
6
+ */
7
+ export declare class Usage extends APIResource {
8
+ /**
9
+ * Reports usage measurements for metered features. The reported usage is used to
10
+ * track, limit, and bill customer consumption. Credit balances are returned once
11
+ * per wallet in `credits`, not on each measurement.
12
+ */
13
+ report(params: UsageReportParams, options?: RequestOptions): APIPromise<UsageReportResponse>;
14
+ }
15
+ /**
16
+ * Response containing reported usage measurements with current usage values,
17
+ * period information and reset dates, plus the balance of each credit wallet they
18
+ * drew from.
19
+ */
20
+ export interface UsageReportResponse {
21
+ /**
22
+ * Reported usage measurements and the credit balances they drew from
23
+ */
24
+ data: UsageReportResponse.Data;
25
+ }
26
+ export declare namespace UsageReportResponse {
27
+ /**
28
+ * Reported usage measurements and the credit balances they drew from
29
+ */
30
+ interface Data {
31
+ /**
32
+ * Usage measurements, in request order, with current values and period info
33
+ */
34
+ usages: Array<Data.Usage>;
35
+ /**
36
+ * The balance of each credit wallet the request drew from. Omitted when no
37
+ * reported feature consumes credits, or when credit balances aren't computed
38
+ * synchronously for the environment; each usage's `credit` is then `null`.
39
+ */
40
+ credits?: Array<Data.Credit>;
41
+ /**
42
+ * The current usage of each governance entitlement this request counted towards.
43
+ * Absent when governance is not enabled or the usage is unknown. Entitlements
44
+ * whose usage could not be read, and those of repeated idempotent requests, are
45
+ * left out
46
+ */
47
+ entities?: Array<Data.Entity>;
48
+ }
49
+ namespace Data {
50
+ /**
51
+ * Recorded usage with period info and the credits it deducted
52
+ */
53
+ interface Usage {
54
+ /**
55
+ * Unique identifier for the entity
56
+ */
57
+ id: string;
58
+ /**
59
+ * Timestamp of when the record was created
60
+ */
61
+ createdAt: string;
62
+ /**
63
+ * Customer id
64
+ */
65
+ customerId: string;
66
+ /**
67
+ * Feature id
68
+ */
69
+ featureId: string;
70
+ /**
71
+ * Timestamp
72
+ */
73
+ timestamp: string;
74
+ /**
75
+ * The usage measurement record
76
+ */
77
+ value: number;
78
+ /**
79
+ * The credits this measurement deducted. `null` when the measurement drew from no
80
+ * wallet listed in `credits`. The balance of the wallet it drew from is in the
81
+ * response `credits` list, matched by customer, resource and currency.
82
+ */
83
+ credit?: Usage.Credit | null;
84
+ /**
85
+ * The current measured usage value
86
+ */
87
+ currentUsage?: number | null;
88
+ /**
89
+ * The date when the next usage reset will occur
90
+ */
91
+ nextResetDate?: string | null;
92
+ /**
93
+ * The customer resource this usage applies to. Optional — only required if the
94
+ * customer has multiple resources (for example, one subscription per workspace or
95
+ * site) and usage needs to be tracked separately per resource; omit it to report
96
+ * usage at the customer level.
97
+ */
98
+ resourceId?: string | null;
99
+ /**
100
+ * The end date of the usage period in which this measurement resides (for
101
+ * entitlements with a reset period)
102
+ */
103
+ usagePeriodEnd?: string | null;
104
+ /**
105
+ * The start date of the usage period in which this measurement resides (for
106
+ * entitlements with a reset period)
107
+ */
108
+ usagePeriodStart?: string | null;
109
+ }
110
+ namespace Usage {
111
+ /**
112
+ * The credits this measurement deducted. `null` when the measurement drew from no
113
+ * wallet listed in `credits`. The balance of the wallet it drew from is in the
114
+ * response `credits` list, matched by customer, resource and currency.
115
+ */
116
+ interface Credit {
117
+ /**
118
+ * The credits this single reportUsage call deducted, in credit units — scoped to
119
+ * this one measurement (0 for idempotency duplicates). Contrast `currentUsage`,
120
+ * which is the wallet-wide running total shared across all features on this
121
+ * currency. Use it to reconcile expected per-call deductions.
122
+ */
123
+ consumed: number;
124
+ /**
125
+ * The credit currency identifier
126
+ */
127
+ currencyId: string;
128
+ }
129
+ }
130
+ /**
131
+ * Optimistic credit balance of one wallet (customer, resource and currency) after
132
+ * the request, listed once however many measurements drew from it
133
+ */
134
+ interface Credit {
135
+ /**
136
+ * The credit currency identifier
137
+ */
138
+ currencyId: string;
139
+ /**
140
+ * The wallet's total consumed credits for this currency (optimistic — includes
141
+ * not-yet-reconciled usage), shared across every feature that draws on the
142
+ * currency. This is the running balance, not this call's deduction — see
143
+ * `consumed` for that.
144
+ */
145
+ currentUsage: number;
146
+ /**
147
+ * Customer id
148
+ */
149
+ customerId: string;
150
+ /**
151
+ * The wallet's resource; `null` for the customer-level wallet
152
+ */
153
+ resourceId: string | null;
154
+ /**
155
+ * The grant-version timestamp of this balance, used by the SDK for last-write-wins
156
+ * reconciliation
157
+ */
158
+ timestamp: string;
159
+ /**
160
+ * The total credits granted
161
+ */
162
+ usageLimit: number;
163
+ /**
164
+ * End of the current credit grant period (when recurring credits reset), if
165
+ * applicable
166
+ */
167
+ usagePeriodEnd?: string | null;
168
+ }
169
+ /**
170
+ * The usage counted against one governance entitlement
171
+ */
172
+ interface Entity {
173
+ /**
174
+ * The absolute usage counted against the entitlement
175
+ */
176
+ currentUsage: number;
177
+ /**
178
+ * The customer whose usage counted towards the entitlement
179
+ */
180
+ customerId: string;
181
+ /**
182
+ * The governance entitlement the usage counts towards
183
+ */
184
+ entitlementId: string;
185
+ /**
186
+ * The governance entity the entitlement belongs to
187
+ */
188
+ entityId: string;
189
+ /**
190
+ * The customer resource the usage counted from; `null` for customer-level usage
191
+ */
192
+ resourceId: string | null;
193
+ /**
194
+ * The entities the entitlement is scoped to (empty when it is not scoped)
195
+ */
196
+ scopeEntityIds: Array<string>;
197
+ /**
198
+ * When the entitlement usage was last updated
199
+ */
200
+ usageUpdatedAt: string;
201
+ /**
202
+ * The credit currency the entitlement governs (exactly one of featureId and
203
+ * currencyId is set)
204
+ */
205
+ currencyId?: string;
206
+ /**
207
+ * The feature the entitlement governs (exactly one of featureId and currencyId is
208
+ * set)
209
+ */
210
+ featureId?: string;
211
+ }
212
+ }
213
+ }
214
+ export interface UsageReportParams {
215
+ /**
216
+ * Body param: A list of usage reports to be submitted in bulk
217
+ */
218
+ usages: Array<UsageReportParams.Usage>;
219
+ /**
220
+ * Header param: Account ID — optional when authenticating with a user JWT (Bearer
221
+ * token); falls back to the user's first membership. Ignored for API-key auth.
222
+ */
223
+ 'X-ACCOUNT-ID'?: string;
224
+ /**
225
+ * Header param: Environment ID — required when authenticating with a user JWT
226
+ * (Bearer token) on environment-scoped endpoints. Ignored for API-key auth (env is
227
+ * intrinsic to the key).
228
+ */
229
+ 'X-ENVIRONMENT-ID'?: string;
230
+ }
231
+ export declare namespace UsageReportParams {
232
+ /**
233
+ * Single usage measurement
234
+ */
235
+ interface Usage {
236
+ /**
237
+ * Customer id
238
+ */
239
+ customerId: string;
240
+ /**
241
+ * Feature id
242
+ */
243
+ featureId: string;
244
+ /**
245
+ * The value to report for usage. Must be a whole number — the REST API does not
246
+ * accept fractional (float) usage values; scale up (e.g. report cents instead of
247
+ * dollars, or milliseconds instead of seconds) if you need sub-unit precision.
248
+ */
249
+ value: number;
250
+ /**
251
+ * Timestamp of when the record was created
252
+ */
253
+ createdAt?: string;
254
+ /**
255
+ * Additional dimensions for the usage report
256
+ */
257
+ dimensions?: {
258
+ [key: string]: string | number | boolean;
259
+ };
260
+ /**
261
+ * A key you provide to safely retry the same usage report without double-counting
262
+ * it. Reports with a previously-seen idempotency key are deduplicated for 7 days;
263
+ * after that window a retry is treated as new usage.
264
+ */
265
+ idempotencyKey?: string;
266
+ /**
267
+ * The customer resource this usage applies to. Optional — only required if the
268
+ * customer has multiple resources (for example, one subscription per workspace or
269
+ * site) and usage needs to be tracked separately per resource; omit it to report
270
+ * usage at the customer level.
271
+ */
272
+ resourceId?: string | null;
273
+ /**
274
+ * How the reported value is applied: DELTA (default) adds it to the feature's
275
+ * current usage; SET treats it as the new absolute usage total, and Stigg computes
276
+ * the delta internally.
277
+ */
278
+ updateBehavior?: 'DELTA' | 'SET';
279
+ }
280
+ }
281
+ export declare namespace Usage {
282
+ export { type UsageReportResponse as UsageReportResponse, type UsageReportParams as UsageReportParams };
283
+ }
284
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/v2/usage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4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K,CAAC,CAAC;IAEvC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,yBAAiB,iBAAiB,CAAC;IACjC;;OAEG;IACH,UAAiB,KAAK;QACpB;;WAEG;QACH,UAAU,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC;QAElB;;;;WAIG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,UAAU,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;QAE1D;;;;WAIG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB;;;;;WAKG;QACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE3B;;;;WAIG;QACH,cAAc,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;KAClC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,OAAO,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,KAAK,iBAAiB,IAAI,iBAAiB,EAAE,CAAC;CACzG"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Usage = void 0;
5
+ const resource_1 = require("../../core/resource.js");
6
+ const headers_1 = require("../../internal/headers.js");
7
+ /**
8
+ * Operations related to usage & metering
9
+ */
10
+ class Usage extends resource_1.APIResource {
11
+ /**
12
+ * Reports usage measurements for metered features. The reported usage is used to
13
+ * track, limit, and bill customer consumption. Credit balances are returned once
14
+ * per wallet in `credits`, not on each measurement.
15
+ */
16
+ report(params, options) {
17
+ const { 'X-ACCOUNT-ID': xAccountID, 'X-ENVIRONMENT-ID': xEnvironmentID, ...body } = params;
18
+ return this._client.post('/api/v2/usage', {
19
+ body,
20
+ ...options,
21
+ headers: (0, headers_1.buildHeaders)([
22
+ {
23
+ ...(xAccountID != null ? { 'X-ACCOUNT-ID': xAccountID } : undefined),
24
+ ...(xEnvironmentID != null ? { 'X-ENVIRONMENT-ID': xEnvironmentID } : undefined),
25
+ },
26
+ options?.headers,
27
+ ]),
28
+ });
29
+ }
30
+ }
31
+ exports.Usage = Usage;
32
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/resources/v2/usage.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAElD,uDAAsD;AAGtD;;GAEG;AACH,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;;OAIG;IACH,MAAM,CAAC,MAAyB,EAAE,OAAwB;QACxD,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YACxC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB;oBACE,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBACpE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACjF;gBACD,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AApBD,sBAoBC"}
@@ -0,0 +1,28 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../core/resource.mjs";
3
+ import { buildHeaders } from "../../internal/headers.mjs";
4
+ /**
5
+ * Operations related to usage & metering
6
+ */
7
+ export class Usage extends APIResource {
8
+ /**
9
+ * Reports usage measurements for metered features. The reported usage is used to
10
+ * track, limit, and bill customer consumption. Credit balances are returned once
11
+ * per wallet in `credits`, not on each measurement.
12
+ */
13
+ report(params, options) {
14
+ const { 'X-ACCOUNT-ID': xAccountID, 'X-ENVIRONMENT-ID': xEnvironmentID, ...body } = params;
15
+ return this._client.post('/api/v2/usage', {
16
+ body,
17
+ ...options,
18
+ headers: buildHeaders([
19
+ {
20
+ ...(xAccountID != null ? { 'X-ACCOUNT-ID': xAccountID } : undefined),
21
+ ...(xEnvironmentID != null ? { 'X-ENVIRONMENT-ID': xEnvironmentID } : undefined),
22
+ },
23
+ options?.headers,
24
+ ]),
25
+ });
26
+ }
27
+ }
28
+ //# sourceMappingURL=usage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.mjs","sourceRoot":"","sources":["../../src/resources/v2/usage.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAElD,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAGtD;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;;OAIG;IACH,MAAM,CAAC,MAAyB,EAAE,OAAwB;QACxD,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YACxC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC;gBACpB;oBACE,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBACpE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACjF;gBACD,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { APIResource } from "../../core/resource.mjs";
2
+ import * as UsageAPI from "./usage.mjs";
3
+ import { Usage, UsageReportParams, UsageReportResponse } from "./usage.mjs";
4
+ export declare class V2 extends APIResource {
5
+ usage: UsageAPI.Usage;
6
+ }
7
+ export declare namespace V2 {
8
+ export { Usage as Usage, type UsageReportResponse as UsageReportResponse, type UsageReportParams as UsageReportParams, };
9
+ }
10
+ //# sourceMappingURL=v2.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.d.mts","sourceRoot":"","sources":["../../src/resources/v2/v2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,QAAQ,oBAAgB;AACpC,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAgB;AAExE,qBAAa,EAAG,SAAQ,WAAW;IACjC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAoC;CAC1D;AAID,MAAM,CAAC,OAAO,WAAW,EAAE,CAAC;IAC1B,OAAO,EACL,KAAK,IAAI,KAAK,EACd,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
@@ -0,0 +1,10 @@
1
+ import { APIResource } from "../../core/resource.js";
2
+ import * as UsageAPI from "./usage.js";
3
+ import { Usage, UsageReportParams, UsageReportResponse } from "./usage.js";
4
+ export declare class V2 extends APIResource {
5
+ usage: UsageAPI.Usage;
6
+ }
7
+ export declare namespace V2 {
8
+ export { Usage as Usage, type UsageReportResponse as UsageReportResponse, type UsageReportParams as UsageReportParams, };
9
+ }
10
+ //# sourceMappingURL=v2.d.ts.map