@openmeter/client 1.0.0-beta.229 → 1.0.0-beta.230
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.
- package/README.md +49 -30
- package/dist/funcs/addons.js +111 -28
- package/dist/funcs/apps.js +37 -8
- package/dist/funcs/billing.js +79 -16
- package/dist/funcs/currencies.js +82 -22
- package/dist/funcs/customers.d.ts +3 -1
- package/dist/funcs/customers.js +390 -91
- package/dist/funcs/defaults.js +24 -4
- package/dist/funcs/entitlements.js +19 -5
- package/dist/funcs/events.js +26 -8
- package/dist/funcs/features.js +99 -27
- package/dist/funcs/governance.js +27 -9
- package/dist/funcs/index.d.ts +1 -0
- package/dist/funcs/index.js +1 -0
- package/dist/funcs/invoices.d.ts +8 -0
- package/dist/funcs/invoices.js +81 -0
- package/dist/funcs/llmCost.js +77 -23
- package/dist/funcs/meters.d.ts +2 -1
- package/dist/funcs/meters.js +118 -27
- package/dist/funcs/planAddons.js +103 -28
- package/dist/funcs/plans.js +113 -24
- package/dist/funcs/subscriptions.d.ts +2 -1
- package/dist/funcs/subscriptions.js +178 -39
- package/dist/funcs/tax.js +78 -21
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/encodings.d.ts +1 -1
- package/dist/lib/encodings.js +5 -4
- package/dist/lib/wire.d.ts +18 -0
- package/dist/lib/wire.js +312 -0
- package/dist/models/operations/addons.d.ts +17 -5
- package/dist/models/operations/apps.d.ts +2 -1
- package/dist/models/operations/billing.d.ts +5 -4
- package/dist/models/operations/currencies.d.ts +27 -9
- package/dist/models/operations/customers.d.ts +83 -32
- package/dist/models/operations/defaults.d.ts +2 -1
- package/dist/models/operations/events.d.ts +20 -4
- package/dist/models/operations/features.d.ts +24 -8
- package/dist/models/operations/governance.d.ts +3 -2
- package/dist/models/operations/invoices.d.ts +48 -0
- package/dist/models/operations/invoices.js +2 -0
- package/dist/models/operations/llmCost.d.ts +16 -4
- package/dist/models/operations/meters.d.ts +29 -8
- package/dist/models/operations/planAddons.d.ts +7 -6
- package/dist/models/operations/plans.d.ts +14 -5
- package/dist/models/operations/subscriptions.d.ts +36 -10
- package/dist/models/operations/tax.d.ts +6 -5
- package/dist/models/schemas.d.ts +27210 -3012
- package/dist/models/schemas.js +6212 -492
- package/dist/models/types.d.ts +4240 -977
- package/dist/sdk/customers.d.ts +3 -1
- package/dist/sdk/customers.js +7 -1
- package/dist/sdk/invoices.d.ts +12 -0
- package/dist/sdk/invoices.js +21 -0
- package/dist/sdk/meters.d.ts +2 -1
- package/dist/sdk/meters.js +4 -1
- package/dist/sdk/sdk.d.ts +3 -0
- package/dist/sdk/sdk.js +5 -0
- package/dist/sdk/subscriptions.d.ts +2 -1
- package/dist/sdk/subscriptions.js +4 -1
- package/package.json +4 -3
package/dist/lib/wire.js
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
export function toCamelCase(name) {
|
|
2
|
+
return name.replace(/_([a-z0-9])/g, (_m, c) => c.toUpperCase());
|
|
3
|
+
}
|
|
4
|
+
export function toSnakeCase(name) {
|
|
5
|
+
return name.replace(/([A-Z])/g, (_m, c) => `_${c.toLowerCase()}`);
|
|
6
|
+
}
|
|
7
|
+
function def(schema) {
|
|
8
|
+
return schema?.def;
|
|
9
|
+
}
|
|
10
|
+
// Unwrap optional/nullable/default to the schema that describes the value's
|
|
11
|
+
// shape. These wrappers never change keys, so the walker looks through them
|
|
12
|
+
// before classifying a node.
|
|
13
|
+
function unwrap(schema) {
|
|
14
|
+
let current = schema;
|
|
15
|
+
for (let i = 0; i < 100 && current; i++) {
|
|
16
|
+
const d = def(current);
|
|
17
|
+
if (d &&
|
|
18
|
+
(d.type === 'optional' ||
|
|
19
|
+
d.type === 'nullable' ||
|
|
20
|
+
d.type === 'default') &&
|
|
21
|
+
d.innerType) {
|
|
22
|
+
current = d.innerType;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
return current;
|
|
26
|
+
}
|
|
27
|
+
/* v8 ignore next -- loop returns inside; reached only past the cycle guard */
|
|
28
|
+
return current;
|
|
29
|
+
}
|
|
30
|
+
function shapeOf(schema) {
|
|
31
|
+
return schema?.shape;
|
|
32
|
+
}
|
|
33
|
+
// The element schema for array data: the schema's own element when it is an
|
|
34
|
+
// array, or the array variant's element when it is a union of T and T[]
|
|
35
|
+
// (the single-or-batch body shape).
|
|
36
|
+
function arrayElement(schema) {
|
|
37
|
+
const d = def(schema);
|
|
38
|
+
if (d?.type === 'array') {
|
|
39
|
+
return d.element;
|
|
40
|
+
}
|
|
41
|
+
if (d?.type === 'union') {
|
|
42
|
+
for (const option of d.options ?? []) {
|
|
43
|
+
const od = def(unwrap(option));
|
|
44
|
+
if (od?.type === 'array') {
|
|
45
|
+
return od.element;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
// Whether a record value schema needs walking: it carries renamable fields
|
|
52
|
+
// (object/record/array/union of such) or date-typed values that must map
|
|
53
|
+
// between `Date` and the RFC 3339 wire string. Other scalars, literals,
|
|
54
|
+
// unknown, and any are left untouched, so user data (labels, dimensions,
|
|
55
|
+
// event payloads) is never rewritten.
|
|
56
|
+
function needsWalk(schema) {
|
|
57
|
+
const s = unwrap(schema);
|
|
58
|
+
const d = def(s);
|
|
59
|
+
/* v8 ignore next 3 -- a record always has a value schema; defensive only */
|
|
60
|
+
if (!d) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (d.type === 'object' || d.type === 'record' || d.type === 'date') {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (d.type === 'array') {
|
|
67
|
+
return needsWalk(d.element);
|
|
68
|
+
}
|
|
69
|
+
if (d.type === 'union') {
|
|
70
|
+
return (d.options ?? []).some(needsWalk);
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const _literalsSurviveWidening = true;
|
|
75
|
+
void _literalsSurviveWidening;
|
|
76
|
+
// A handful of schemas are genuinely self-referential (e.g. the `and`/`or`
|
|
77
|
+
// legs of a filter tree), so nesting depth is bounded only by the DATA the
|
|
78
|
+
// server sends, not by the schema. Without a limit, a crafted or
|
|
79
|
+
// accidentally-deep response recurses until the JS engine throws a raw
|
|
80
|
+
// `RangeError: Maximum call stack size exceeded` — still caught by request()
|
|
81
|
+
// and surfaced as Result.error, but as an opaque native error instead of a
|
|
82
|
+
// typed one. 500 levels is far beyond any real filter/record/array nesting
|
|
83
|
+
// in the API today; it exists to fail predictably, not to constrain valid data.
|
|
84
|
+
const MAX_WALK_DEPTH = 500;
|
|
85
|
+
export class DepthLimitExceededError extends Error {
|
|
86
|
+
constructor() {
|
|
87
|
+
super(`wire mapping exceeded maximum nesting depth (${MAX_WALK_DEPTH})`);
|
|
88
|
+
this.name = 'DepthLimitExceededError';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function walk(data, schema, dir, depth = 0) {
|
|
92
|
+
if (data === null || data === undefined) {
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
// A Date can only ever mean its wire serialization, wherever it sits — a
|
|
96
|
+
// typed date field, a record value, or an unknown-schema position. Wire→
|
|
97
|
+
// public data never contains Date instances (it comes from JSON.parse), so
|
|
98
|
+
// this only rewrites public→wire.
|
|
99
|
+
if (data instanceof Date) {
|
|
100
|
+
return dir.mapDate(data);
|
|
101
|
+
}
|
|
102
|
+
if (depth > MAX_WALK_DEPTH) {
|
|
103
|
+
throw new DepthLimitExceededError();
|
|
104
|
+
}
|
|
105
|
+
const s = unwrap(schema);
|
|
106
|
+
const d = def(s);
|
|
107
|
+
// A date-typed node maps between the public `Date` and the RFC 3339 wire
|
|
108
|
+
// string (fromWire revives the string; a string handed to toWire by an
|
|
109
|
+
// untyped caller passes through as-is).
|
|
110
|
+
if (d?.type === 'date') {
|
|
111
|
+
return dir.mapDate(data);
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(data)) {
|
|
114
|
+
// The schema may be the array itself or a union with an array variant
|
|
115
|
+
// (e.g. a single-or-batch body `T | T[]`); resolve the element schema from
|
|
116
|
+
// whichever applies so array items are still walked with their shape.
|
|
117
|
+
const element = arrayElement(s);
|
|
118
|
+
return data.map((item) => walk(item, element, dir, depth + 1));
|
|
119
|
+
}
|
|
120
|
+
if (typeof data !== 'object') {
|
|
121
|
+
// A wire datetime can sit behind a union (`DateTime | null`,
|
|
122
|
+
// enum-or-DateTime): revive the string only when the union's date variant
|
|
123
|
+
// is its sole plausible owner, so enum literals and plain-string variants
|
|
124
|
+
// pass through untouched.
|
|
125
|
+
if (typeof data === 'string' &&
|
|
126
|
+
d?.type === 'union' &&
|
|
127
|
+
unionDateClaims(s, data)) {
|
|
128
|
+
return dir.mapDate(data);
|
|
129
|
+
}
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
const record = data;
|
|
133
|
+
if (d?.type === 'record') {
|
|
134
|
+
// Record keys are user data (label/dimension names) — preserved verbatim.
|
|
135
|
+
// Only the value is walked, and only when it needs mapping. A null
|
|
136
|
+
// prototype avoids the `__proto__` key silently reassigning `out`'s own
|
|
137
|
+
// prototype instead of becoming a visible entry (user data may contain
|
|
138
|
+
// any key, including reserved object-literal property names). The
|
|
139
|
+
// prototype is restored once every key is a plain own property, so the
|
|
140
|
+
// returned object still behaves normally for consumers (instanceof,
|
|
141
|
+
// template literals) — `Object.prototype` itself was never touched.
|
|
142
|
+
const valueSchema = needsWalk(d.valueType) ? d.valueType : undefined;
|
|
143
|
+
const out = Object.create(null);
|
|
144
|
+
for (const [key, value] of Object.entries(record)) {
|
|
145
|
+
out[key] = valueSchema ? walk(value, valueSchema, dir, depth + 1) : value;
|
|
146
|
+
}
|
|
147
|
+
Object.setPrototypeOf(out, Object.prototype);
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
if (d?.type === 'union') {
|
|
151
|
+
const variant = selectVariant(record, s, dir);
|
|
152
|
+
if (!variant) {
|
|
153
|
+
// No confident match: leave keys untransformed rather than guess.
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
return walk(data, variant, dir, depth + 1);
|
|
157
|
+
}
|
|
158
|
+
if (d?.type === 'object') {
|
|
159
|
+
const shape = shapeOf(s) ?? {};
|
|
160
|
+
// A null prototype avoids two failure modes from data-controlled keys
|
|
161
|
+
// like `__proto__`/`constructor`: (1) `fieldFor` below reading an
|
|
162
|
+
// inherited Object.prototype member instead of correctly treating the
|
|
163
|
+
// key as schema-undeclared, and (2) the assignment at the end of this
|
|
164
|
+
// loop reassigning `out`'s own prototype instead of adding a visible key.
|
|
165
|
+
const out = Object.create(null);
|
|
166
|
+
for (const [key, value] of Object.entries(record)) {
|
|
167
|
+
const fieldSchema = fieldFor(shape, key);
|
|
168
|
+
// Keys the schema does not declare are dropped, so the result matches the
|
|
169
|
+
// typed shape exactly (a server-added field has no place in the type).
|
|
170
|
+
if (fieldSchema === undefined) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
out[dir.rename(key)] = walk(value, fieldSchema, dir, depth + 1);
|
|
174
|
+
}
|
|
175
|
+
Object.setPrototypeOf(out, Object.prototype);
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
// Scalar or unknown schema: pass through untransformed.
|
|
179
|
+
return data;
|
|
180
|
+
}
|
|
181
|
+
// Resolve a data key to its field schema. The schema is camelCase-keyed; a
|
|
182
|
+
// wire→public data key is snake, so it is camelized to index the shape.
|
|
183
|
+
// Own-property checks (not `shape[key]`) so a data-controlled key like
|
|
184
|
+
// `__proto__` or `constructor` cannot resolve to an inherited
|
|
185
|
+
// Object.prototype member and be mistaken for a declared schema field.
|
|
186
|
+
function fieldFor(shape, dataKey) {
|
|
187
|
+
if (Object.hasOwn(shape, dataKey)) {
|
|
188
|
+
return shape[dataKey];
|
|
189
|
+
}
|
|
190
|
+
const camelKey = toCamelCase(dataKey);
|
|
191
|
+
return Object.hasOwn(shape, camelKey) ? shape[camelKey] : undefined;
|
|
192
|
+
}
|
|
193
|
+
function selectVariant(data, schema, dir) {
|
|
194
|
+
const d = def(schema);
|
|
195
|
+
const options = d?.options ?? [];
|
|
196
|
+
if (d?.discriminator && schema) {
|
|
197
|
+
// O(1) dispatch on the discriminator literal. The data key is the wire-name in
|
|
198
|
+
// fromWire (snake) and the public name in toWire (camel); the variant map is
|
|
199
|
+
// keyed by the literal value, which is identical in both directions.
|
|
200
|
+
const dataKey = dir.discriminatorKey(d.discriminator);
|
|
201
|
+
return variantsByDiscriminator(schema, d).get(data[dataKey]);
|
|
202
|
+
}
|
|
203
|
+
// Non-discriminated union: the codegen gate guarantees at most one object
|
|
204
|
+
// variant (it fails the build for a mapped union with two or more), so the single
|
|
205
|
+
// object-shaped option is unambiguous. Other variants (scalars, arrays) reach the
|
|
206
|
+
// walk through their own data-kind branches, not here.
|
|
207
|
+
return options.find((option) => def(unwrap(option))?.type === 'object');
|
|
208
|
+
}
|
|
209
|
+
// Memoized literal→variant map for a discriminated union, built once per schema.
|
|
210
|
+
const variantMapCache = new WeakMap();
|
|
211
|
+
function variantsByDiscriminator(schema, d) {
|
|
212
|
+
const cached = variantMapCache.get(schema);
|
|
213
|
+
if (cached) {
|
|
214
|
+
return cached;
|
|
215
|
+
}
|
|
216
|
+
const map = new Map();
|
|
217
|
+
for (const option of d.options ?? []) {
|
|
218
|
+
const shape = shapeOf(unwrap(option));
|
|
219
|
+
const literal = literalValue(shape?.[d.discriminator]);
|
|
220
|
+
if (literal !== undefined) {
|
|
221
|
+
map.set(literal, option);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
variantMapCache.set(schema, map);
|
|
225
|
+
return map;
|
|
226
|
+
}
|
|
227
|
+
function literalValue(schema) {
|
|
228
|
+
const s = unwrap(schema);
|
|
229
|
+
if (def(s)?.type === 'literal') {
|
|
230
|
+
return s.value;
|
|
231
|
+
}
|
|
232
|
+
/* v8 ignore next -- a discriminated-union variant's discriminator is a literal */
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
// Whether a union's date variant is the sole plausible owner of a string
|
|
236
|
+
// value: the union carries a date option, no string-capable sibling (a plain
|
|
237
|
+
// string variant, an enum containing the value, an equal string literal)
|
|
238
|
+
// claims it, and the value actually parses as a date. `DateTime | null`
|
|
239
|
+
// revives its RFC 3339 string; `'immediate' | DateTime` keeps the enum
|
|
240
|
+
// literal a string. Fail-open: an unclaimed string stays a string.
|
|
241
|
+
function unionDateClaims(schema, value) {
|
|
242
|
+
let hasDate = false;
|
|
243
|
+
for (const option of def(schema)?.options ?? []) {
|
|
244
|
+
const od = def(unwrap(option));
|
|
245
|
+
if (od?.type === 'date') {
|
|
246
|
+
hasDate = true;
|
|
247
|
+
}
|
|
248
|
+
else if (od?.type === 'string') {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
else if (od?.type === 'enum' &&
|
|
252
|
+
Object.values(od.entries ?? {}).includes(value)) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
else if (od?.type === 'literal' && literalValue(option) === value) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return hasDate && !Number.isNaN(Date.parse(value));
|
|
260
|
+
}
|
|
261
|
+
const toWireDirection = {
|
|
262
|
+
rename: toSnakeCase,
|
|
263
|
+
discriminatorKey: (camelKey) => camelKey,
|
|
264
|
+
mapDate: (value) => (value instanceof Date ? value.toISOString() : value),
|
|
265
|
+
};
|
|
266
|
+
const fromWireDirection = {
|
|
267
|
+
rename: toCamelCase,
|
|
268
|
+
discriminatorKey: (camelKey) => toSnakeCase(camelKey),
|
|
269
|
+
mapDate: (value) => (typeof value === 'string' ? new Date(value) : value),
|
|
270
|
+
};
|
|
271
|
+
// Rewrite a request body or query object from the camelCase public shape to the
|
|
272
|
+
// snake_case wire shape, driven by its schema. Record keys (label/dimension names)
|
|
273
|
+
// are preserved; `Date` values serialize to RFC 3339 strings. The return is typed
|
|
274
|
+
// as the input `T` so call sites stay cast-free (the runtime object has snake keys
|
|
275
|
+
// and wire-encoded dates, but the value is write-only — it flows straight into
|
|
276
|
+
// `json:`/`toURLSearchParams`, both of which accept any object).
|
|
277
|
+
export function toWire(data, schema) {
|
|
278
|
+
return walk(data, schema, toWireDirection);
|
|
279
|
+
}
|
|
280
|
+
// Rewrite a response body from the snake_case wire shape to the camelCase public
|
|
281
|
+
// shape: renames keys and revives RFC 3339 strings into `Date`s at date-typed
|
|
282
|
+
// nodes — never applies defaults or any other coercion. The result is the
|
|
283
|
+
// schema's output shape: `walk` produces exactly the schema's known fields in
|
|
284
|
+
// camelCase, so the inferred `output<S>` type describes the runtime value (the
|
|
285
|
+
// same wire-trust boundary as a plain `.json<T>()`, with no `.parse()`).
|
|
286
|
+
export function fromWire(data, schema) {
|
|
287
|
+
return walk(data, schema, fromWireDirection);
|
|
288
|
+
}
|
|
289
|
+
// Thrown by assertValid when the optional `validate` client option is on and data
|
|
290
|
+
// fails its schema. request() catches it like any Error and surfaces it as
|
|
291
|
+
// Result.error.
|
|
292
|
+
export class ValidationError extends Error {
|
|
293
|
+
issues;
|
|
294
|
+
constructor(message, issues) {
|
|
295
|
+
super(message);
|
|
296
|
+
this.issues = issues;
|
|
297
|
+
this.name = 'ValidationError';
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Opt-in schema check used by the funcs (when the validate option is on) against
|
|
301
|
+
// the snake_case wire payload: the request body after toWire, the raw response
|
|
302
|
+
// before fromWire, each against its generated `…Wire` schema. It is a GATE, not a
|
|
303
|
+
// transform — the safeParse output (coercions/defaults) is discarded, so validation
|
|
304
|
+
// never mutates the payload or return value. Off by default; the SDK does not
|
|
305
|
+
// validate by default (additive server fields must not break clients).
|
|
306
|
+
export function assertValid(schema, data) {
|
|
307
|
+
const result = schema.safeParse(data);
|
|
308
|
+
if (!result.success) {
|
|
309
|
+
throw new ValidationError('schema validation failed', result.error.issues);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=wire.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AcceptDateStrings } from '../../lib/wire.js';
|
|
1
2
|
import type { Addon, AddonPagePaginatedResponse, CreateAddonRequestInput, ListAddonsParamsFilter, SortQueryInput, UpsertAddonRequestInput } from '../types.js';
|
|
2
3
|
export interface ListAddonsQuery {
|
|
3
4
|
/** Determines which page of the collection to retrieve. */
|
|
@@ -5,19 +6,30 @@ export interface ListAddonsQuery {
|
|
|
5
6
|
size?: number;
|
|
6
7
|
number?: number;
|
|
7
8
|
};
|
|
8
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Sort add-ons returned in the response. Supported sort attributes are:
|
|
11
|
+
*
|
|
12
|
+
* - `id`
|
|
13
|
+
* - `key`
|
|
14
|
+
* - `name`
|
|
15
|
+
* - `created_at` (default)
|
|
16
|
+
* - `updated_at`
|
|
17
|
+
*
|
|
18
|
+
* The `asc` suffix is optional as the default sort order is ascending. The `desc`
|
|
19
|
+
* suffix is used to specify a descending order.
|
|
20
|
+
*/
|
|
9
21
|
sort?: SortQueryInput;
|
|
10
22
|
/** Filter add-ons returned in the response. */
|
|
11
23
|
filter?: ListAddonsParamsFilter;
|
|
12
24
|
}
|
|
13
|
-
export type ListAddonsRequest = ListAddonsQuery
|
|
25
|
+
export type ListAddonsRequest = AcceptDateStrings<ListAddonsQuery>;
|
|
14
26
|
export type ListAddonsResponse = AddonPagePaginatedResponse;
|
|
15
|
-
export type CreateAddonRequest = CreateAddonRequestInput
|
|
27
|
+
export type CreateAddonRequest = AcceptDateStrings<CreateAddonRequestInput>;
|
|
16
28
|
export type CreateAddonResponse = Addon;
|
|
17
|
-
export type UpdateAddonRequest = {
|
|
29
|
+
export type UpdateAddonRequest = AcceptDateStrings<{
|
|
18
30
|
addonId: string;
|
|
19
31
|
body: UpsertAddonRequestInput;
|
|
20
|
-
}
|
|
32
|
+
}>;
|
|
21
33
|
export type UpdateAddonResponse = Addon;
|
|
22
34
|
export type GetAddonRequest = {
|
|
23
35
|
addonId: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as schemas from '../schemas.js';
|
|
3
|
+
import type { AcceptDateStrings } from '../../lib/wire.js';
|
|
3
4
|
import type { AppPagePaginatedResponse } from '../types.js';
|
|
4
5
|
export interface ListAppsQuery {
|
|
5
6
|
/** Determines which page of the collection to retrieve. */
|
|
@@ -8,7 +9,7 @@ export interface ListAppsQuery {
|
|
|
8
9
|
number?: number;
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
|
-
export type ListAppsRequest = ListAppsQuery
|
|
12
|
+
export type ListAppsRequest = AcceptDateStrings<ListAppsQuery>;
|
|
12
13
|
export type ListAppsResponse = AppPagePaginatedResponse;
|
|
13
14
|
export type GetAppRequest = {
|
|
14
15
|
appId: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AcceptDateStrings } from '../../lib/wire.js';
|
|
1
2
|
import type { CreateBillingProfileRequestInput, Profile, ProfilePagePaginatedResponse, UpsertBillingProfileRequestInput } from '../types.js';
|
|
2
3
|
export interface ListBillingProfilesQuery {
|
|
3
4
|
/** Determines which page of the collection to retrieve. */
|
|
@@ -6,18 +7,18 @@ export interface ListBillingProfilesQuery {
|
|
|
6
7
|
number?: number;
|
|
7
8
|
};
|
|
8
9
|
}
|
|
9
|
-
export type ListBillingProfilesRequest = ListBillingProfilesQuery
|
|
10
|
+
export type ListBillingProfilesRequest = AcceptDateStrings<ListBillingProfilesQuery>;
|
|
10
11
|
export type ListBillingProfilesResponse = ProfilePagePaginatedResponse;
|
|
11
|
-
export type CreateBillingProfileRequest = CreateBillingProfileRequestInput
|
|
12
|
+
export type CreateBillingProfileRequest = AcceptDateStrings<CreateBillingProfileRequestInput>;
|
|
12
13
|
export type CreateBillingProfileResponse = Profile;
|
|
13
14
|
export type GetBillingProfileRequest = {
|
|
14
15
|
id: string;
|
|
15
16
|
};
|
|
16
17
|
export type GetBillingProfileResponse = Profile;
|
|
17
|
-
export type UpdateBillingProfileRequest = {
|
|
18
|
+
export type UpdateBillingProfileRequest = AcceptDateStrings<{
|
|
18
19
|
id: string;
|
|
19
20
|
body: UpsertBillingProfileRequestInput;
|
|
20
|
-
}
|
|
21
|
+
}>;
|
|
21
22
|
export type UpdateBillingProfileResponse = Profile;
|
|
22
23
|
export type DeleteBillingProfileRequest = {
|
|
23
24
|
id: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AcceptDateStrings } from '../../lib/wire.js';
|
|
1
2
|
import type { CostBasis, CostBasisPagePaginatedResponse, CreateCostBasisRequest as CreateCostBasisRequestBody, CreateCurrencyCustomRequest, CurrencyCustom, CurrencyPagePaginatedResponse, ListCostBasesParamsFilter, ListCurrenciesParamsFilter, SortQueryInput } from '../types.js';
|
|
2
3
|
export interface ListCurrenciesQuery {
|
|
3
4
|
/** Determines which page of the collection to retrieve. */
|
|
@@ -5,17 +6,34 @@ export interface ListCurrenciesQuery {
|
|
|
5
6
|
size?: number;
|
|
6
7
|
number?: number;
|
|
7
8
|
};
|
|
8
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Sort currencies returned in the response. Supported sort attributes are:
|
|
11
|
+
*
|
|
12
|
+
* - `code` (default)
|
|
13
|
+
* - `name`
|
|
14
|
+
*
|
|
15
|
+
* The `asc` suffix is optional as the default sort order is ascending. The `desc`
|
|
16
|
+
* suffix is used to specify a descending order.
|
|
17
|
+
*/
|
|
9
18
|
sort?: SortQueryInput;
|
|
10
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Filter currencies returned in the response.
|
|
21
|
+
*
|
|
22
|
+
* To filter currencies by type add the following query param: filter[type]=custom
|
|
23
|
+
*/
|
|
11
24
|
filter?: ListCurrenciesParamsFilter;
|
|
12
25
|
}
|
|
13
|
-
export type ListCurrenciesRequest = ListCurrenciesQuery
|
|
26
|
+
export type ListCurrenciesRequest = AcceptDateStrings<ListCurrenciesQuery>;
|
|
14
27
|
export type ListCurrenciesResponse = CurrencyPagePaginatedResponse;
|
|
15
|
-
export type CreateCustomCurrencyRequest = CreateCurrencyCustomRequest
|
|
28
|
+
export type CreateCustomCurrencyRequest = AcceptDateStrings<CreateCurrencyCustomRequest>;
|
|
16
29
|
export type CreateCustomCurrencyResponse = CurrencyCustom;
|
|
17
30
|
export interface ListCostBasesQuery {
|
|
18
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Filter cost bases returned in the response.
|
|
33
|
+
*
|
|
34
|
+
* To filter cost bases by fiat currency code add the following query param:
|
|
35
|
+
* filter[fiat_code]=USD
|
|
36
|
+
*/
|
|
19
37
|
filter?: ListCostBasesParamsFilter;
|
|
20
38
|
/** Determines which page of the collection to retrieve. */
|
|
21
39
|
page?: {
|
|
@@ -23,13 +41,13 @@ export interface ListCostBasesQuery {
|
|
|
23
41
|
number?: number;
|
|
24
42
|
};
|
|
25
43
|
}
|
|
26
|
-
export type ListCostBasesRequest = ListCostBasesQuery & {
|
|
44
|
+
export type ListCostBasesRequest = AcceptDateStrings<ListCostBasesQuery & {
|
|
27
45
|
currencyId: string;
|
|
28
|
-
}
|
|
46
|
+
}>;
|
|
29
47
|
export type ListCostBasesResponse = CostBasisPagePaginatedResponse;
|
|
30
|
-
export type CreateCostBasisRequest = {
|
|
48
|
+
export type CreateCostBasisRequest = AcceptDateStrings<{
|
|
31
49
|
currencyId: string;
|
|
32
50
|
body: CreateCostBasisRequestBody;
|
|
33
|
-
}
|
|
51
|
+
}>;
|
|
34
52
|
export type CreateCostBasisResponse = CostBasis;
|
|
35
53
|
//# sourceMappingURL=currencies.d.ts.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
import type { AcceptDateStrings } from '../../lib/wire.js';
|
|
4
|
+
import type { AppCustomerData, AppStripeCreateCheckoutSessionResult, AppStripeCreateCustomerPortalSessionResult, ChargePagePaginatedResponse, CreateChargeFlatFeeRequest, CreateChargeUsageBasedRequest, CreateCreditAdjustmentRequest as CreateCreditAdjustmentRequestBody, CreateCreditGrantRequestInput, CreateCustomerRequest as CreateCustomerRequestBody, CreditAdjustment, CreditBalances, CreditGrant, CreditGrantPagePaginatedResponse, CreditTransactionPaginatedResponse, CursorPaginationQueryPage, Customer, CustomerData, CustomerPagePaginatedResponse, CustomerStripeCreateCheckoutSessionRequestInput, CustomerStripeCreateCustomerPortalSessionRequest, GetCreditBalanceParamsFilter, ListChargesParamsFilter, ListCreditGrantsParamsFilter, ListCreditTransactionsParamsFilter, ListCustomersParamsFilter, SortQueryInput, UpdateCreditGrantExternalSettlementRequest as UpdateCreditGrantExternalSettlementRequestBody, UpsertAppCustomerDataRequest, UpsertCustomerBillingDataRequest, UpsertCustomerRequest as UpsertCustomerRequestBody } from '../types.js';
|
|
5
|
+
export type CreateCustomerRequest = AcceptDateStrings<CreateCustomerRequestBody>;
|
|
3
6
|
export type CreateCustomerResponse = Customer;
|
|
4
7
|
export type GetCustomerRequest = {
|
|
5
8
|
customerId: string;
|
|
@@ -11,17 +14,30 @@ export interface ListCustomersQuery {
|
|
|
11
14
|
size?: number;
|
|
12
15
|
number?: number;
|
|
13
16
|
};
|
|
14
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Sort customers returned in the response. Supported sort attributes are:
|
|
19
|
+
*
|
|
20
|
+
* - `id`
|
|
21
|
+
* - `name` (default)
|
|
22
|
+
* - `created_at`
|
|
23
|
+
*
|
|
24
|
+
* The `asc` suffix is optional as the default sort order is ascending. The `desc`
|
|
25
|
+
* suffix is used to specify a descending order.
|
|
26
|
+
*/
|
|
15
27
|
sort?: SortQueryInput;
|
|
16
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Filter customers returned in the response.
|
|
30
|
+
*
|
|
31
|
+
* To filter customers by key add the following query param: filter[key]=my-db-id
|
|
32
|
+
*/
|
|
17
33
|
filter?: ListCustomersParamsFilter;
|
|
18
34
|
}
|
|
19
|
-
export type ListCustomersRequest = ListCustomersQuery
|
|
35
|
+
export type ListCustomersRequest = AcceptDateStrings<ListCustomersQuery>;
|
|
20
36
|
export type ListCustomersResponse = CustomerPagePaginatedResponse;
|
|
21
|
-
export type UpsertCustomerRequest = {
|
|
37
|
+
export type UpsertCustomerRequest = AcceptDateStrings<{
|
|
22
38
|
customerId: string;
|
|
23
39
|
body: UpsertCustomerRequestBody;
|
|
24
|
-
}
|
|
40
|
+
}>;
|
|
25
41
|
export type UpsertCustomerResponse = Customer;
|
|
26
42
|
export type DeleteCustomerRequest = {
|
|
27
43
|
customerId: string;
|
|
@@ -31,30 +47,30 @@ export type GetCustomerBillingRequest = {
|
|
|
31
47
|
customerId: string;
|
|
32
48
|
};
|
|
33
49
|
export type GetCustomerBillingResponse = CustomerData;
|
|
34
|
-
export type UpdateCustomerBillingRequest = {
|
|
50
|
+
export type UpdateCustomerBillingRequest = AcceptDateStrings<{
|
|
35
51
|
customerId: string;
|
|
36
52
|
body: UpsertCustomerBillingDataRequest;
|
|
37
|
-
}
|
|
53
|
+
}>;
|
|
38
54
|
export type UpdateCustomerBillingResponse = CustomerData;
|
|
39
|
-
export type UpdateCustomerBillingAppDataRequest = {
|
|
55
|
+
export type UpdateCustomerBillingAppDataRequest = AcceptDateStrings<{
|
|
40
56
|
customerId: string;
|
|
41
57
|
body: UpsertAppCustomerDataRequest;
|
|
42
|
-
}
|
|
58
|
+
}>;
|
|
43
59
|
export type UpdateCustomerBillingAppDataResponse = AppCustomerData;
|
|
44
|
-
export type CreateCustomerStripeCheckoutSessionRequest = {
|
|
60
|
+
export type CreateCustomerStripeCheckoutSessionRequest = AcceptDateStrings<{
|
|
45
61
|
customerId: string;
|
|
46
62
|
body: CustomerStripeCreateCheckoutSessionRequestInput;
|
|
47
|
-
}
|
|
63
|
+
}>;
|
|
48
64
|
export type CreateCustomerStripeCheckoutSessionResponse = AppStripeCreateCheckoutSessionResult;
|
|
49
|
-
export type CreateCustomerStripePortalSessionRequest = {
|
|
65
|
+
export type CreateCustomerStripePortalSessionRequest = AcceptDateStrings<{
|
|
50
66
|
customerId: string;
|
|
51
67
|
body: CustomerStripeCreateCustomerPortalSessionRequest;
|
|
52
|
-
}
|
|
68
|
+
}>;
|
|
53
69
|
export type CreateCustomerStripePortalSessionResponse = AppStripeCreateCustomerPortalSessionResult;
|
|
54
|
-
export type CreateCreditGrantRequest = {
|
|
70
|
+
export type CreateCreditGrantRequest = AcceptDateStrings<{
|
|
55
71
|
customerId: string;
|
|
56
72
|
body: CreateCreditGrantRequestInput;
|
|
57
|
-
}
|
|
73
|
+
}>;
|
|
58
74
|
export type CreateCreditGrantResponse = CreditGrant;
|
|
59
75
|
export type GetCreditGrantRequest = {
|
|
60
76
|
customerId: string;
|
|
@@ -70,32 +86,42 @@ export interface ListCreditGrantsQuery {
|
|
|
70
86
|
/** Filter credit grants returned in the response. */
|
|
71
87
|
filter?: ListCreditGrantsParamsFilter;
|
|
72
88
|
}
|
|
73
|
-
export type ListCreditGrantsRequest = ListCreditGrantsQuery & {
|
|
89
|
+
export type ListCreditGrantsRequest = AcceptDateStrings<ListCreditGrantsQuery & {
|
|
74
90
|
customerId: string;
|
|
75
|
-
}
|
|
91
|
+
}>;
|
|
76
92
|
export type ListCreditGrantsResponse = CreditGrantPagePaginatedResponse;
|
|
77
93
|
export interface GetCustomerCreditBalanceQuery {
|
|
78
|
-
/**
|
|
79
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Return the credit balance as of this timestamp.
|
|
96
|
+
*
|
|
97
|
+
* Defaults to the current time.
|
|
98
|
+
*/
|
|
99
|
+
timestamp?: Date;
|
|
80
100
|
filter?: GetCreditBalanceParamsFilter;
|
|
81
101
|
}
|
|
82
|
-
export type GetCustomerCreditBalanceRequest = GetCustomerCreditBalanceQuery & {
|
|
102
|
+
export type GetCustomerCreditBalanceRequest = AcceptDateStrings<GetCustomerCreditBalanceQuery & {
|
|
83
103
|
customerId: string;
|
|
84
|
-
}
|
|
104
|
+
}>;
|
|
85
105
|
export type GetCustomerCreditBalanceResponse = CreditBalances;
|
|
86
|
-
export type CreateCreditAdjustmentRequest = {
|
|
106
|
+
export type CreateCreditAdjustmentRequest = AcceptDateStrings<{
|
|
87
107
|
customerId: string;
|
|
88
108
|
body: CreateCreditAdjustmentRequestBody;
|
|
89
|
-
}
|
|
109
|
+
}>;
|
|
90
110
|
export type CreateCreditAdjustmentResponse = CreditAdjustment;
|
|
111
|
+
export type UpdateCreditGrantExternalSettlementRequest = AcceptDateStrings<{
|
|
112
|
+
customerId: string;
|
|
113
|
+
creditGrantId: string;
|
|
114
|
+
body: UpdateCreditGrantExternalSettlementRequestBody;
|
|
115
|
+
}>;
|
|
116
|
+
export type UpdateCreditGrantExternalSettlementResponse = CreditGrant;
|
|
91
117
|
export interface ListCreditTransactionsQuery {
|
|
92
118
|
page?: CursorPaginationQueryPage;
|
|
93
119
|
/** Filter credit transactions returned in the response. */
|
|
94
120
|
filter?: ListCreditTransactionsParamsFilter;
|
|
95
121
|
}
|
|
96
|
-
export type ListCreditTransactionsRequest = ListCreditTransactionsQuery & {
|
|
122
|
+
export type ListCreditTransactionsRequest = AcceptDateStrings<ListCreditTransactionsQuery & {
|
|
97
123
|
customerId: string;
|
|
98
|
-
}
|
|
124
|
+
}>;
|
|
99
125
|
export type ListCreditTransactionsResponse = CreditTransactionPaginatedResponse;
|
|
100
126
|
export interface ListCustomerChargesQuery {
|
|
101
127
|
/** Determines which page of the collection to retrieve. */
|
|
@@ -103,15 +129,40 @@ export interface ListCustomerChargesQuery {
|
|
|
103
129
|
size?: number;
|
|
104
130
|
number?: number;
|
|
105
131
|
};
|
|
106
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Sort charges returned in the response.
|
|
134
|
+
*
|
|
135
|
+
* Supported sort attributes are:
|
|
136
|
+
*
|
|
137
|
+
* - `id`
|
|
138
|
+
* - `created_at`
|
|
139
|
+
* - `service_period.from`
|
|
140
|
+
* - `billing_period.from`
|
|
141
|
+
*/
|
|
107
142
|
sort?: SortQueryInput;
|
|
108
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Filter charges.
|
|
145
|
+
*
|
|
146
|
+
* To filter charges by status add the following query param:
|
|
147
|
+
* `filter[status][oeq]=created,active`
|
|
148
|
+
*/
|
|
109
149
|
filter?: ListChargesParamsFilter;
|
|
110
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Expand full objects for referenced entities.
|
|
152
|
+
*
|
|
153
|
+
* Supported values are:
|
|
154
|
+
*
|
|
155
|
+
* - `real_time_usage`: Expand the charge's real-time usage.
|
|
156
|
+
*/
|
|
111
157
|
expand?: 'real_time_usage'[];
|
|
112
158
|
}
|
|
113
|
-
export type ListCustomerChargesRequest = ListCustomerChargesQuery & {
|
|
159
|
+
export type ListCustomerChargesRequest = AcceptDateStrings<ListCustomerChargesQuery & {
|
|
114
160
|
customerId: string;
|
|
115
|
-
}
|
|
161
|
+
}>;
|
|
116
162
|
export type ListCustomerChargesResponse = ChargePagePaginatedResponse;
|
|
163
|
+
export type CreateCustomerChargesRequest = AcceptDateStrings<{
|
|
164
|
+
customerId: string;
|
|
165
|
+
body: CreateChargeFlatFeeRequest | CreateChargeUsageBasedRequest;
|
|
166
|
+
}>;
|
|
167
|
+
export type CreateCustomerChargesResponse = z.output<typeof schemas.createCustomerChargesResponse>;
|
|
117
168
|
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { AcceptDateStrings } from '../../lib/wire.js';
|
|
1
2
|
import type { OrganizationDefaultTaxCodes, UpdateOrganizationDefaultTaxCodesRequest as UpdateOrganizationDefaultTaxCodesRequestBody } from '../types.js';
|
|
2
3
|
export type GetOrganizationDefaultTaxCodesRequest = Record<string, never>;
|
|
3
4
|
export type GetOrganizationDefaultTaxCodesResponse = OrganizationDefaultTaxCodes;
|
|
4
|
-
export type UpdateOrganizationDefaultTaxCodesRequest = UpdateOrganizationDefaultTaxCodesRequestBody
|
|
5
|
+
export type UpdateOrganizationDefaultTaxCodesRequest = AcceptDateStrings<UpdateOrganizationDefaultTaxCodesRequestBody>;
|
|
5
6
|
export type UpdateOrganizationDefaultTaxCodesResponse = OrganizationDefaultTaxCodes;
|
|
6
7
|
//# sourceMappingURL=defaults.d.ts.map
|