@openmeter/client 1.0.0-beta.231 → 1.0.0-beta.232

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 (44) hide show
  1. package/README.md +24 -14
  2. package/dist/core.js +7 -4
  3. package/dist/funcs/addons.js +59 -11
  4. package/dist/funcs/apps.d.ts +41 -1
  5. package/dist/funcs/apps.js +164 -3
  6. package/dist/funcs/billing.js +34 -7
  7. package/dist/funcs/currencies.d.ts +9 -1
  8. package/dist/funcs/currencies.js +62 -5
  9. package/dist/funcs/customers.js +214 -43
  10. package/dist/funcs/entitlements.js +12 -3
  11. package/dist/funcs/events.js +3 -0
  12. package/dist/funcs/features.js +48 -9
  13. package/dist/funcs/invoices.d.ts +58 -1
  14. package/dist/funcs/invoices.js +202 -7
  15. package/dist/funcs/llmCost.js +26 -5
  16. package/dist/funcs/meters.js +59 -11
  17. package/dist/funcs/planAddons.js +65 -17
  18. package/dist/funcs/plans.js +59 -11
  19. package/dist/funcs/subscriptions.js +87 -17
  20. package/dist/funcs/tax.js +34 -7
  21. package/dist/index.d.ts +1 -2
  22. package/dist/index.js +0 -1
  23. package/dist/lib/config.d.ts +2 -2
  24. package/dist/lib/paginate.d.ts +1 -1
  25. package/dist/lib/version.d.ts +1 -1
  26. package/dist/lib/version.js +1 -1
  27. package/dist/lib/wire.d.ts +1 -0
  28. package/dist/lib/wire.js +26 -4
  29. package/dist/models/operations/apps.d.ts +25 -1
  30. package/dist/models/operations/currencies.d.ts +10 -0
  31. package/dist/models/operations/customers.d.ts +2 -1
  32. package/dist/models/operations/invoices.d.ts +16 -0
  33. package/dist/models/schemas.d.ts +15256 -9856
  34. package/dist/models/schemas.js +938 -447
  35. package/dist/models/types.d.ts +503 -259
  36. package/dist/sdk/apps.d.ts +44 -2
  37. package/dist/sdk/apps.js +53 -1
  38. package/dist/sdk/internal.d.ts +151 -3
  39. package/dist/sdk/internal.js +182 -2
  40. package/dist/sdk/invoices.d.ts +15 -0
  41. package/dist/sdk/invoices.js +32 -0
  42. package/dist/sdk/sdk.d.ts +0 -3
  43. package/dist/sdk/sdk.js +0 -5
  44. package/package.json +3 -3
package/dist/lib/wire.js CHANGED
@@ -201,6 +201,9 @@ function walk(data, schema, dir, depth = 0) {
201
201
  const valueSchema = needsWalk(d.valueType) ? d.valueType : undefined;
202
202
  const out = Object.create(null);
203
203
  for (const [key, value] of Object.entries(record)) {
204
+ if (dir.omitUndefinedObjectEntries && value === undefined) {
205
+ continue;
206
+ }
204
207
  out[key] = valueSchema ? walk(value, valueSchema, dir, depth + 1) : value;
205
208
  }
206
209
  Object.setPrototypeOf(out, Object.prototype);
@@ -223,6 +226,9 @@ function walk(data, schema, dir, depth = 0) {
223
226
  // loop reassigning `out`'s own prototype instead of adding a visible key.
224
227
  const out = Object.create(null);
225
228
  for (const [key, value] of Object.entries(record)) {
229
+ if (dir.omitUndefinedObjectEntries && value === undefined) {
230
+ continue;
231
+ }
226
232
  const fieldSchema = fieldFor(shape, key);
227
233
  // Keys the schema does not declare are dropped, so the result matches the
228
234
  // typed shape exactly (a server-added field has no place in the type).
@@ -346,6 +352,14 @@ const toWireDirection = {
346
352
  return Number(value);
347
353
  },
348
354
  applyDefaults: true,
355
+ omitUndefinedObjectEntries: true,
356
+ };
357
+ // Path binding names are transport metadata, not JSON object member names, so
358
+ // they must remain exactly as declared while their values receive the same
359
+ // Date/bigint/default mapping used by request bodies and query parameters.
360
+ const toPathWireDirection = {
361
+ ...toWireDirection,
362
+ rename: (key) => key,
349
363
  };
350
364
  const fromWireDirection = {
351
365
  rename: toCamelCase,
@@ -355,18 +369,26 @@ const fromWireDirection = {
355
369
  ? BigInt(value)
356
370
  : value,
357
371
  applyDefaults: false,
372
+ omitUndefinedObjectEntries: false,
358
373
  };
359
374
  // Rewrite a request body or query object from the camelCase public shape to the
360
375
  // snake_case wire shape, driven by its schema. Record keys (label/dimension names)
361
376
  // are preserved; `Date` values serialize to RFC 3339 strings; `bigint` values
362
377
  // (int64 fields) become JSON numbers; omitted required-with-default fields are
363
- // filled with their declared default (see requiredDefault). The return is typed
364
- // as the input `T` so call sites stay cast-free (the runtime object has snake keys
365
- // and wire-encoded dates, but the value is write-only it flows straight into
366
- // `json:`/`toURLSearchParams`, both of which accept any object).
378
+ // filled with their declared default (see requiredDefault); explicit undefined
379
+ // object/record entries are omitted just as JSON.stringify would omit them. The
380
+ // return is typed as the input `T` so call sites stay cast-free (the runtime object
381
+ // has snake keys and wire-encoded dates, but the value is write-only — it flows
382
+ // straight into `json:`/`toURLSearchParams`, both of which accept any object).
367
383
  export function toWire(data, schema) {
368
384
  return walk(data, schema, toWireDirection);
369
385
  }
386
+ // Rewrite path-parameter values to their transport representation without
387
+ // renaming the path binding keys. The returned object is subsequently validated
388
+ // against the generated `…PathParamsWire` schema and URL-encoded by the func.
389
+ export function toPathWire(data, schema) {
390
+ return walk(data, schema, toPathWireDirection);
391
+ }
370
392
  // Rewrite a response body from the snake_case wire shape to the camelCase public
371
393
  // shape: renames keys and revives RFC 3339 strings into `Date`s at date-typed
372
394
  // nodes — never applies defaults or any other coercion. The result is the
@@ -1,5 +1,5 @@
1
1
  import type { AcceptDateStrings } from '../../lib/wire.js';
2
- import type { App, AppPagePaginatedResponse } from '../types.js';
2
+ import type { App, AppCatalogItem, AppCatalogItemPagePaginatedResponse, AppPagePaginatedResponse, BillingInstallAppResponse, InstallAppRequest as InstallAppRequestBody, UpdateAppRequest as UpdateAppRequestBody } from '../types.js';
3
3
  export interface ListAppsQuery {
4
4
  /** Determines which page of the collection to retrieve. */
5
5
  page?: {
@@ -13,3 +13,27 @@ export type GetAppRequest = {
13
13
  appId: string;
14
14
  };
15
15
  export type GetAppResponse = App;
16
+ export type UninstallAppRequest = {
17
+ appId: string;
18
+ };
19
+ export type UninstallAppResponse = void;
20
+ export type UpdateAppRequest = AcceptDateStrings<{
21
+ appId: string;
22
+ body: UpdateAppRequestBody;
23
+ }>;
24
+ export type UpdateAppResponse = App;
25
+ export interface ListAppCatalogQuery {
26
+ /** Determines which page of the collection to retrieve. */
27
+ page?: {
28
+ size?: number;
29
+ number?: number;
30
+ };
31
+ }
32
+ export type ListAppCatalogRequest = AcceptDateStrings<ListAppCatalogQuery>;
33
+ export type ListAppCatalogResponse = AppCatalogItemPagePaginatedResponse;
34
+ export type GetAppCatalogItemRequest = {
35
+ appType: string;
36
+ };
37
+ export type GetAppCatalogItemResponse = AppCatalogItem;
38
+ export type InstallAppRequest = AcceptDateStrings<InstallAppRequestBody>;
39
+ export type InstallAppResponse = BillingInstallAppResponse;
@@ -22,11 +22,21 @@ export interface ListCurrenciesQuery {
22
22
  * To filter currencies by type add the following query param: filter[type]=custom
23
23
  */
24
24
  filter?: ListCurrenciesParamsFilter;
25
+ /**
26
+ * Expand the currencies returned in the response.
27
+ *
28
+ * To include the active and scheduled cost basis add: expand=cost_basis
29
+ */
30
+ expand?: 'cost_basis'[];
25
31
  }
26
32
  export type ListCurrenciesRequest = AcceptDateStrings<ListCurrenciesQuery>;
27
33
  export type ListCurrenciesResponse = CurrencyPagePaginatedResponse;
28
34
  export type CreateCustomCurrencyRequest = AcceptDateStrings<CreateCurrencyCustomRequest>;
29
35
  export type CreateCustomCurrencyResponse = CurrencyCustom;
36
+ export type GetCustomCurrencyRequest = {
37
+ currencyId: string;
38
+ };
39
+ export type GetCustomCurrencyResponse = CurrencyCustom;
30
40
  export interface ListCostBasesQuery {
31
41
  /**
32
42
  * Filter cost bases returned in the response.
@@ -92,7 +92,8 @@ export interface GetCustomerCreditBalanceQuery {
92
92
  /**
93
93
  * Return the credit balance as of this timestamp.
94
94
  *
95
- * Defaults to the current time.
95
+ * Defaults to the current time. Historical responses return `live` as zero because
96
+ * live charge impacts are only available for current balances.
96
97
  */
97
98
  timestamp?: Date;
98
99
  filter?: GetCreditBalanceParamsFilter;
@@ -43,3 +43,19 @@ export type DeleteInvoiceRequest = {
43
43
  invoiceId: string;
44
44
  };
45
45
  export type DeleteInvoiceResponse = void;
46
+ export type AdvanceInvoiceRequest = {
47
+ invoiceId: string;
48
+ };
49
+ export type AdvanceInvoiceResponse = Invoice;
50
+ export type ApproveInvoiceRequest = {
51
+ invoiceId: string;
52
+ };
53
+ export type ApproveInvoiceResponse = Invoice;
54
+ export type RetryInvoiceRequest = {
55
+ invoiceId: string;
56
+ };
57
+ export type RetryInvoiceResponse = Invoice;
58
+ export type SnapshotQuantitiesInvoiceRequest = {
59
+ invoiceId: string;
60
+ };
61
+ export type SnapshotQuantitiesInvoiceResponse = Invoice;