@stigg/typescript 0.1.0-beta.57 → 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 (82) hide show
  1. package/CHANGELOG.md +58 -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/credits/consumption.d.mts +50 -0
  20. package/resources/v1/credits/consumption.d.mts.map +1 -1
  21. package/resources/v1/credits/consumption.d.ts +50 -0
  22. package/resources/v1/credits/consumption.d.ts.map +1 -1
  23. package/resources/v1/customers/customers.d.mts +20 -0
  24. package/resources/v1/customers/customers.d.mts.map +1 -1
  25. package/resources/v1/customers/customers.d.ts +20 -0
  26. package/resources/v1/customers/customers.d.ts.map +1 -1
  27. package/resources/v1/customers/customers.js.map +1 -1
  28. package/resources/v1/customers/customers.mjs.map +1 -1
  29. package/resources/v1/usage.d.mts +4 -1
  30. package/resources/v1/usage.d.mts.map +1 -1
  31. package/resources/v1/usage.d.ts +4 -1
  32. package/resources/v1/usage.d.ts.map +1 -1
  33. package/resources/v1/usage.js +4 -1
  34. package/resources/v1/usage.js.map +1 -1
  35. package/resources/v1/usage.mjs +4 -1
  36. package/resources/v1/usage.mjs.map +1 -1
  37. package/resources/v2/index.d.mts +3 -0
  38. package/resources/v2/index.d.mts.map +1 -0
  39. package/resources/v2/index.d.ts +3 -0
  40. package/resources/v2/index.d.ts.map +1 -0
  41. package/resources/v2/index.js +9 -0
  42. package/resources/v2/index.js.map +1 -0
  43. package/resources/v2/index.mjs +4 -0
  44. package/resources/v2/index.mjs.map +1 -0
  45. package/resources/v2/usage.d.mts +284 -0
  46. package/resources/v2/usage.d.mts.map +1 -0
  47. package/resources/v2/usage.d.ts +284 -0
  48. package/resources/v2/usage.d.ts.map +1 -0
  49. package/resources/v2/usage.js +32 -0
  50. package/resources/v2/usage.js.map +1 -0
  51. package/resources/v2/usage.mjs +28 -0
  52. package/resources/v2/usage.mjs.map +1 -0
  53. package/resources/v2/v2.d.mts +10 -0
  54. package/resources/v2/v2.d.mts.map +1 -0
  55. package/resources/v2/v2.d.ts +10 -0
  56. package/resources/v2/v2.d.ts.map +1 -0
  57. package/resources/v2/v2.js +17 -0
  58. package/resources/v2/v2.js.map +1 -0
  59. package/resources/v2/v2.mjs +12 -0
  60. package/resources/v2/v2.mjs.map +1 -0
  61. package/resources/v2.d.mts +2 -0
  62. package/resources/v2.d.mts.map +1 -0
  63. package/resources/v2.d.ts +2 -0
  64. package/resources/v2.d.ts.map +1 -0
  65. package/resources/v2.js +6 -0
  66. package/resources/v2.js.map +1 -0
  67. package/resources/v2.mjs +3 -0
  68. package/resources/v2.mjs.map +1 -0
  69. package/src/client.ts +5 -0
  70. package/src/resources/index.ts +1 -0
  71. package/src/resources/v1/credits/consumption.ts +60 -0
  72. package/src/resources/v1/customers/customers.ts +24 -0
  73. package/src/resources/v1/usage.ts +4 -1
  74. package/src/resources/v2/index.ts +4 -0
  75. package/src/resources/v2/usage.ts +344 -0
  76. package/src/resources/v2/v2.ts +19 -0
  77. package/src/resources/v2.ts +3 -0
  78. package/src/version.ts +1 -1
  79. package/version.d.mts +1 -1
  80. package/version.d.ts +1 -1
  81. package/version.js +1 -1
  82. package/version.mjs +1 -1
@@ -0,0 +1,284 @@
1
+ import { APIResource } from "../../core/resource.js";
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,+BAA4B;AAClD,OAAO,EAAE,UAAU,EAAE,kCAA+B;AAEpD,OAAO,EAAE,cAAc,EAAE,0CAAuC;A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ACH,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/resources/v2/v2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,KAAK,QAAQ,mBAAgB;AACpC,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAgB;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,17 @@
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.V2 = void 0;
5
+ const tslib_1 = require("../../internal/tslib.js");
6
+ const resource_1 = require("../../core/resource.js");
7
+ const UsageAPI = tslib_1.__importStar(require("./usage.js"));
8
+ const usage_1 = require("./usage.js");
9
+ class V2 extends resource_1.APIResource {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.usage = new UsageAPI.Usage(this._client);
13
+ }
14
+ }
15
+ exports.V2 = V2;
16
+ V2.Usage = usage_1.Usage;
17
+ //# sourceMappingURL=v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.js","sourceRoot":"","sources":["../../src/resources/v2/v2.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAClD,6DAAoC;AACpC,sCAAwE;AAExE,MAAa,EAAG,SAAQ,sBAAW;IAAnC;;QACE,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;CAAA;AAFD,gBAEC;AAED,EAAE,CAAC,KAAK,GAAG,aAAK,CAAC"}
@@ -0,0 +1,12 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../core/resource.mjs";
3
+ import * as UsageAPI from "./usage.mjs";
4
+ import { Usage } from "./usage.mjs";
5
+ export class V2 extends APIResource {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.usage = new UsageAPI.Usage(this._client);
9
+ }
10
+ }
11
+ V2.Usage = Usage;
12
+ //# sourceMappingURL=v2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.mjs","sourceRoot":"","sources":["../../src/resources/v2/v2.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,QAAQ,oBAAgB;AACpC,OAAO,EAAE,KAAK,EAA0C,oBAAgB;AAExE,MAAM,OAAO,EAAG,SAAQ,WAAW;IAAnC;;QACE,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;CAAA;AAED,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./v2/index.mjs";
2
+ //# sourceMappingURL=v2.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.d.mts","sourceRoot":"","sources":["../src/resources/v2.ts"],"names":[],"mappings":"AAEA,+BAA2B"}
@@ -0,0 +1,2 @@
1
+ export * from "./v2/index.js";
2
+ //# sourceMappingURL=v2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../src/resources/v2.ts"],"names":[],"mappings":"AAEA,8BAA2B"}
@@ -0,0 +1,6 @@
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
+ const tslib_1 = require("../internal/tslib.js");
5
+ tslib_1.__exportStar(require("./v2/index.js"), exports);
6
+ //# sourceMappingURL=v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.js","sourceRoot":"","sources":["../src/resources/v2.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAA2B"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export * from "./v2/index.mjs";
3
+ //# sourceMappingURL=v2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.mjs","sourceRoot":"","sources":["../src/resources/v2.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,+BAA2B"}
package/src/client.ts CHANGED
@@ -21,6 +21,7 @@ import * as API from './resources/index';
21
21
  import { APIPromise } from './core/api-promise';
22
22
  import { V1Beta } from './resources/v1-beta/v1-beta';
23
23
  import { V1 } from './resources/v1/v1';
24
+ import { V2 } from './resources/v2/v2';
24
25
  import { type Fetch } from './internal/builtin-types';
25
26
  import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
26
27
  import { FinalRequestOptions, RequestOptions } from './internal/request-options';
@@ -764,10 +765,12 @@ export class Stigg {
764
765
 
765
766
  v1: API.V1 = new API.V1(this);
766
767
  v1Beta: API.V1Beta = new API.V1Beta(this);
768
+ v2: API.V2 = new API.V2(this);
767
769
  }
768
770
 
769
771
  Stigg.V1 = V1;
770
772
  Stigg.V1Beta = V1Beta;
773
+ Stigg.V2 = V2;
771
774
 
772
775
  export declare namespace Stigg {
773
776
  export type RequestOptions = Opts.RequestOptions;
@@ -781,4 +784,6 @@ export declare namespace Stigg {
781
784
  export { V1 as V1 };
782
785
 
783
786
  export { V1Beta as V1Beta };
787
+
788
+ export { V2 as V2 };
784
789
  }
@@ -2,3 +2,4 @@
2
2
 
3
3
  export { V1 } from './v1/v1';
4
4
  export { V1Beta } from './v1-beta/v1-beta';
5
+ export { V2 } from './v2/v2';
@@ -92,6 +92,14 @@ export namespace ConsumptionConsumeResponse {
92
92
  */
93
93
  credit?: Data.Credit | null;
94
94
 
95
+ /**
96
+ * The current usage of each governance entitlement this request counted towards.
97
+ * Absent when governance is not enabled or the usage is unknown. Entitlements
98
+ * whose usage could not be read, and those of repeated idempotent requests, are
99
+ * left out
100
+ */
101
+ entities?: Array<Data.Entity>;
102
+
95
103
  /**
96
104
  * The resource the consumption was attributed to
97
105
  */
@@ -134,6 +142,58 @@ export namespace ConsumptionConsumeResponse {
134
142
  */
135
143
  usagePeriodEnd?: string | null;
136
144
  }
145
+
146
+ /**
147
+ * The usage counted against one governance entitlement
148
+ */
149
+ export interface Entity {
150
+ /**
151
+ * The absolute usage counted against the entitlement
152
+ */
153
+ currentUsage: number;
154
+
155
+ /**
156
+ * The customer whose usage counted towards the entitlement
157
+ */
158
+ customerId: string;
159
+
160
+ /**
161
+ * The governance entitlement the usage counts towards
162
+ */
163
+ entitlementId: string;
164
+
165
+ /**
166
+ * The governance entity the entitlement belongs to
167
+ */
168
+ entityId: string;
169
+
170
+ /**
171
+ * The customer resource the usage counted from; `null` for customer-level usage
172
+ */
173
+ resourceId: string | null;
174
+
175
+ /**
176
+ * The entities the entitlement is scoped to (empty when it is not scoped)
177
+ */
178
+ scopeEntityIds: Array<string>;
179
+
180
+ /**
181
+ * When the entitlement usage was last updated
182
+ */
183
+ usageUpdatedAt: string;
184
+
185
+ /**
186
+ * The credit currency the entitlement governs (exactly one of featureId and
187
+ * currencyId is set)
188
+ */
189
+ currencyId?: string;
190
+
191
+ /**
192
+ * The feature the entitlement governs (exactly one of featureId and currencyId is
193
+ * set)
194
+ */
195
+ featureId?: string;
196
+ }
137
197
  }
138
198
  }
139
199
 
@@ -641,6 +641,12 @@ export namespace CustomerResponse {
641
641
  */
642
642
  billingId: string | null;
643
643
 
644
+ /**
645
+ * The card brand of the default payment method, as reported by the billing
646
+ * provider (e.g. visa, mastercard, amex)
647
+ */
648
+ cardBrand: string | null;
649
+
644
650
  /**
645
651
  * The expiration month of the default payment method
646
652
  */
@@ -660,6 +666,12 @@ export namespace CustomerResponse {
660
666
  * The default payment method type
661
667
  */
662
668
  type: 'CARD' | 'BANK' | 'CASH_APP' | 'PAYPAL' | null;
669
+
670
+ /**
671
+ * The digital wallet used to add the default card payment method, as reported by
672
+ * the billing provider (e.g. apple_pay, google_pay)
673
+ */
674
+ walletType: string | null;
663
675
  }
664
676
 
665
677
  /**
@@ -1239,6 +1251,12 @@ export namespace CustomerListResponse {
1239
1251
  */
1240
1252
  billingId: string | null;
1241
1253
 
1254
+ /**
1255
+ * The card brand of the default payment method, as reported by the billing
1256
+ * provider (e.g. visa, mastercard, amex)
1257
+ */
1258
+ cardBrand: string | null;
1259
+
1242
1260
  /**
1243
1261
  * The expiration month of the default payment method
1244
1262
  */
@@ -1258,6 +1276,12 @@ export namespace CustomerListResponse {
1258
1276
  * The default payment method type
1259
1277
  */
1260
1278
  type: 'CARD' | 'BANK' | 'CASH_APP' | 'PAYPAL' | null;
1279
+
1280
+ /**
1281
+ * The digital wallet used to add the default card payment method, as reported by
1282
+ * the billing provider (e.g. apple_pay, google_pay)
1283
+ */
1284
+ walletType: string | null;
1261
1285
  }
1262
1286
 
1263
1287
  /**
@@ -54,7 +54,10 @@ export class Usage extends APIResource {
54
54
 
55
55
  /**
56
56
  * Reports usage measurements for metered features. The reported usage is used to
57
- * track, limit, and bill customer consumption.
57
+ * track, limit, and bill customer consumption. Deprecated: use
58
+ * `POST /api/v2/usage`.
59
+ *
60
+ * @deprecated
58
61
  */
59
62
  report(params: UsageReportParams, options?: RequestOptions): APIPromise<UsageReportResponse> {
60
63
  const { 'X-ACCOUNT-ID': xAccountID, 'X-ENVIRONMENT-ID': xEnvironmentID, ...body } = params;
@@ -0,0 +1,4 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export { Usage, type UsageReportResponse, type UsageReportParams } from './usage';
4
+ export { V2 } from './v2';