@openmeter/client 1.0.0-beta-0abbaf78837c → 1.0.0-beta-3a2cce989354

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.
@@ -628,15 +628,27 @@ export interface CreateCurrencyCustomRequest {
628
628
  thousandSeparator: string;
629
629
  code: string;
630
630
  }
631
- /** Balance details of a metered entitlement. */
631
+ /**
632
+ * Balance details of a metered entitlement at the evaluation time, which is the
633
+ * `at` query parameter when given and the current time otherwise.
634
+ */
632
635
  export interface EntitlementAccessValue {
633
- /** The remaining balance of the entitlement in the current usage period. */
636
+ /**
637
+ * The remaining balance of the entitlement in the usage period at the evaluation
638
+ * time.
639
+ */
634
640
  balance: string;
635
- /** The usage recorded in the current usage period. */
641
+ /** The usage recorded in the usage period at the evaluation time. */
636
642
  usage: string;
637
- /** The usage exceeding the available balance in the current usage period. */
643
+ /**
644
+ * The usage exceeding the available balance in the usage period at the evaluation
645
+ * time.
646
+ */
638
647
  overage: string;
639
- /** The total amount granted and currently available to the entitlement. */
648
+ /**
649
+ * The total amount granted and available to the entitlement at the evaluation
650
+ * time.
651
+ */
640
652
  totalAvailableGrantAmount: string;
641
653
  /** The remaining balance of each grant, keyed by grant ID. */
642
654
  grantBalances: Record<string, string>;
@@ -1838,6 +1850,26 @@ export interface CustomerStripeCreateCustomerPortalSessionRequest {
1838
1850
  /** Options for configuring the Stripe Customer Portal Session. */
1839
1851
  stripeOptions: AppStripeCreateCustomerPortalSessionOptions;
1840
1852
  }
1853
+ /** Entitlement access check result. */
1854
+ export interface EntitlementAccessCheckResult {
1855
+ /**
1856
+ * Whether the customer has access to the feature. Always true for `boolean` and
1857
+ * `static` entitlements. Depends on balance for `metered` entitlements.
1858
+ */
1859
+ hasAccess: boolean;
1860
+ /**
1861
+ * Only available for static entitlements. Config is the JSON parsable
1862
+ * configuration of the entitlement. Useful to describe per customer configuration.
1863
+ */
1864
+ config?: string;
1865
+ /**
1866
+ * The type of the entitlement.
1867
+ *
1868
+ * If not provided, the feature has no entitlement defined (has access is always
1869
+ * false in this case)
1870
+ */
1871
+ type?: 'metered' | 'static' | 'boolean';
1872
+ }
1841
1873
  /**
1842
1874
  * Recurring period input. The anchor is optional; the owning resource defines the
1843
1875
  * default, typically its creation time.
@@ -2497,8 +2529,8 @@ export interface CurrencyAmount {
2497
2529
  /** The fiat or custom currency code of the amount. */
2498
2530
  currency: BillingCurrencyCode;
2499
2531
  }
2500
- /** Entitlement access result. */
2501
- export interface EntitlementAccessResult {
2532
+ /** Entitlement value result. */
2533
+ export interface EntitlementValueResult {
2502
2534
  /** The type of the entitlement. */
2503
2535
  type: 'metered' | 'static' | 'boolean';
2504
2536
  /** The feature key of the entitlement. */
@@ -2514,8 +2546,8 @@ export interface EntitlementAccessResult {
2514
2546
  */
2515
2547
  config?: string;
2516
2548
  /**
2517
- * Only available for metered entitlements. The current balance details of the
2518
- * entitlement. Requires the `value` expand.
2549
+ * Only available for metered entitlements. The balance details of the entitlement
2550
+ * at the evaluation time. Requires the `value` expand.
2519
2551
  */
2520
2552
  value?: EntitlementAccessValue;
2521
2553
  }
@@ -2695,6 +2727,13 @@ export interface ListEntitlementsParamsFilter {
2695
2727
  /** Filter entitlements by customer ID. */
2696
2728
  customerId?: UlidFieldFilter;
2697
2729
  }
2730
+ /** Filter options for listing grants. */
2731
+ export interface ListGrantsParamsFilter {
2732
+ /** Filter grants by the ID of the customer that owns the entitlement. */
2733
+ customerId?: UlidFieldFilter;
2734
+ /** Filter grants by the ID of the entitlement's feature. */
2735
+ featureId?: UlidFieldFilter;
2736
+ }
2698
2737
  /** Filter options for listing subscriptions. */
2699
2738
  export interface ListSubscriptionsParamsFilter {
2700
2739
  id?: UlidFieldFilter;
@@ -4090,7 +4129,7 @@ export interface ChargeFlatFeeSystemIntent {
4090
4129
  /** List customer entitlement access response data. */
4091
4130
  export interface ListCustomerEntitlementAccessResponseData {
4092
4131
  /** The list of entitlement access results. */
4093
- data: EntitlementAccessResult[];
4132
+ data: EntitlementValueResult[];
4094
4133
  }
4095
4134
  /**
4096
4135
  * Graduated tiered price.
@@ -1,7 +1,8 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type RequestOptions } from '../lib/types.js';
3
3
  import type { CreateCustomerEntitlementRequest, CreateCustomerEntitlementResponse, OverrideCustomerEntitlementRequest, OverrideCustomerEntitlementResponse, GetCustomerEntitlementHistoryRequest, GetCustomerEntitlementHistoryResponse, GetCustomerEntitlementRequest, GetCustomerEntitlementResponse, ListCustomerEntitlementsRequest, ListCustomerEntitlementsResponse, ResetCustomerEntitlementUsageRequest, ResetCustomerEntitlementUsageResponse, DeleteCustomerEntitlementRequest, DeleteCustomerEntitlementResponse, CreateCustomerEntitlementGrantRequest, CreateCustomerEntitlementGrantResponse, ListCustomerEntitlementGrantsRequest, ListCustomerEntitlementGrantsResponse, VoidCreditGrantRequest, VoidCreditGrantResponse, ListCustomerChargesRequest, ListCustomerChargesResponse, CreateCustomerChargesRequest, CreateCustomerChargesResponse } from '../models/operations/customers.js';
4
- import type { GetCustomerEntitlementAccessRequest, GetCustomerEntitlementAccessResponse, ListEntitlementsRequest, ListEntitlementsResponse, GetEntitlementRequest, GetEntitlementResponse } from '../models/operations/entitlements.js';
4
+ import type { GetCustomerEntitlementAccessRequest, GetCustomerEntitlementAccessResponse, ListEntitlementsRequest, ListEntitlementsResponse, GetEntitlementRequest, GetEntitlementResponse, GetCustomerEntitlementValueRequest, GetCustomerEntitlementValueResponse } from '../models/operations/entitlements.js';
5
+ import type { ListGrantsRequest, ListGrantsResponse, VoidGrantRequest, VoidGrantResponse } from '../models/operations/grants.js';
5
6
  import type { UnscheduleSubscriptionRequest, UnscheduleSubscriptionResponse, RestoreSubscriptionRequest, RestoreSubscriptionResponse, MigrateSubscriptionRequest, MigrateSubscriptionResponse, CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse, UpdateSubscriptionAddonRequest, UpdateSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
6
7
  import type { UninstallAppRequest, UninstallAppResponse, UpdateAppRequest, UpdateAppResponse, ListAppCatalogRequest, ListAppCatalogResponse, GetAppCatalogItemRequest, GetAppCatalogItemResponse, InstallAppRequest, InstallAppResponse } from '../models/operations/apps.js';
7
8
  import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse, DeleteInvoiceRequest, DeleteInvoiceResponse, AdvanceInvoiceRequest, AdvanceInvoiceResponse, ApproveInvoiceRequest, ApproveInvoiceResponse, RetryInvoiceRequest, RetryInvoiceResponse, SnapshotQuantitiesInvoiceRequest, SnapshotQuantitiesInvoiceResponse } from '../models/operations/invoices.js';
@@ -23,6 +24,8 @@ export declare class Internal {
23
24
  get customers(): InternalCustomers;
24
25
  private _entitlements?;
25
26
  get entitlements(): InternalEntitlements;
27
+ private _grants?;
28
+ get grants(): InternalGrants;
26
29
  private _subscriptions?;
27
30
  get subscriptions(): InternalSubscriptions;
28
31
  private _apps?;
@@ -301,6 +304,54 @@ export declare class InternalEntitlements {
301
304
  * GET /openmeter/entitlements/{entitlementId}
302
305
  */
303
306
  get(request: GetEntitlementRequest, options?: RequestOptions): Promise<GetEntitlementResponse>;
307
+ /**
308
+ * Get customer entitlement value
309
+ *
310
+ * Get the customer's access through a single entitlement, optionally evaluated at
311
+ * a point in time.
312
+ *
313
+ * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
314
+ */
315
+ getCustomerValue(request: GetCustomerEntitlementValueRequest, options?: RequestOptions): Promise<GetCustomerEntitlementValueResponse>;
316
+ }
317
+ export declare class InternalGrants {
318
+ private readonly _client;
319
+ constructor(_client: Client);
320
+ /**
321
+ * List grants
322
+ *
323
+ * List the grants of all customers and entitlements. To list the grants of a
324
+ * single entitlement, use the customer entitlement grants endpoint.
325
+ *
326
+ * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
327
+ * grants are always included, as they are part of the balance history.
328
+ *
329
+ * GET /openmeter/grants
330
+ */
331
+ list(request?: ListGrantsRequest, options?: RequestOptions): Promise<ListGrantsResponse>;
332
+ /**
333
+ * List grants
334
+ *
335
+ * List the grants of all customers and entitlements. To list the grants of a
336
+ * single entitlement, use the customer entitlement grants endpoint.
337
+ *
338
+ * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
339
+ * grants are always included, as they are part of the balance history.
340
+ *
341
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
342
+ *
343
+ * GET /openmeter/grants
344
+ */
345
+ listAll(request?: ListGrantsRequest, options?: RequestOptions): AsyncIterable<EntitlementGrant>;
346
+ /**
347
+ * Void grant
348
+ *
349
+ * Void a grant so it no longer adds to the balance. Usage already deducted from
350
+ * the grant is kept.
351
+ *
352
+ * DELETE /openmeter/grants/{grantId}
353
+ */
354
+ void(request: VoidGrantRequest, options?: RequestOptions): Promise<VoidGrantResponse>;
304
355
  }
305
356
  export declare class InternalSubscriptions {
306
357
  private readonly _client;
@@ -2,7 +2,8 @@
2
2
  import { unwrap } from '../lib/types.js';
3
3
  import { paginatePages } from '../lib/paginate.js';
4
4
  import { createCustomerEntitlement, overrideCustomerEntitlement, getCustomerEntitlementHistory, getCustomerEntitlement, listCustomerEntitlements, resetCustomerEntitlementUsage, deleteCustomerEntitlement, createCustomerEntitlementGrant, listCustomerEntitlementGrants, voidCreditGrant, listCustomerCharges, createCustomerCharges, } from '../funcs/customers.js';
5
- import { getCustomerEntitlementAccess, listEntitlements, getEntitlement, } from '../funcs/entitlements.js';
5
+ import { getCustomerEntitlementAccess, listEntitlements, getEntitlement, getCustomerEntitlementValue, } from '../funcs/entitlements.js';
6
+ import { listGrants, voidGrant } from '../funcs/grants.js';
6
7
  import { unscheduleSubscription, restoreSubscription, migrateSubscription, createSubscriptionAddon, updateSubscriptionAddon, } from '../funcs/subscriptions.js';
7
8
  import { uninstallApp, updateApp, listAppCatalog, getAppCatalogItem, installApp, } from '../funcs/apps.js';
8
9
  import { listInvoices, getInvoice, updateInvoice, deleteInvoice, advanceInvoice, approveInvoice, retryInvoice, snapshotQuantitiesInvoice, } from '../funcs/invoices.js';
@@ -29,6 +30,10 @@ export class Internal {
29
30
  get entitlements() {
30
31
  return (this._entitlements ??= new InternalEntitlements(this._client));
31
32
  }
33
+ _grants;
34
+ get grants() {
35
+ return (this._grants ??= new InternalGrants(this._client));
36
+ }
32
37
  _subscriptions;
33
38
  get subscriptions() {
34
39
  return (this._subscriptions ??= new InternalSubscriptions(this._client));
@@ -385,6 +390,64 @@ export class InternalEntitlements {
385
390
  async get(request, options) {
386
391
  return unwrap(await getEntitlement(this._client, request, options));
387
392
  }
393
+ /**
394
+ * Get customer entitlement value
395
+ *
396
+ * Get the customer's access through a single entitlement, optionally evaluated at
397
+ * a point in time.
398
+ *
399
+ * GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
400
+ */
401
+ async getCustomerValue(request, options) {
402
+ return unwrap(await getCustomerEntitlementValue(this._client, request, options));
403
+ }
404
+ }
405
+ export class InternalGrants {
406
+ _client;
407
+ constructor(_client) {
408
+ this._client = _client;
409
+ }
410
+ /**
411
+ * List grants
412
+ *
413
+ * List the grants of all customers and entitlements. To list the grants of a
414
+ * single entitlement, use the customer entitlement grants endpoint.
415
+ *
416
+ * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
417
+ * grants are always included, as they are part of the balance history.
418
+ *
419
+ * GET /openmeter/grants
420
+ */
421
+ async list(request, options) {
422
+ return unwrap(await listGrants(this._client, request, options));
423
+ }
424
+ /**
425
+ * List grants
426
+ *
427
+ * List the grants of all customers and entitlements. To list the grants of a
428
+ * single entitlement, use the customer entitlement grants endpoint.
429
+ *
430
+ * Deleted grants are excluded unless `include_deleted` is set. Voided and expired
431
+ * grants are always included, as they are part of the balance history.
432
+ *
433
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
434
+ *
435
+ * GET /openmeter/grants
436
+ */
437
+ listAll(request, options) {
438
+ return paginatePages((req, opts) => listGrants(this._client, req, opts), request ?? {}, options);
439
+ }
440
+ /**
441
+ * Void grant
442
+ *
443
+ * Void a grant so it no longer adds to the balance. Usage already deducted from
444
+ * the grant is kept.
445
+ *
446
+ * DELETE /openmeter/grants/{grantId}
447
+ */
448
+ async void(request, options) {
449
+ return unwrap(await voidGrant(this._client, request, options));
450
+ }
388
451
  }
389
452
  export class InternalSubscriptions {
390
453
  _client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmeter/client",
3
- "version": "1.0.0-beta-0abbaf78837c",
3
+ "version": "1.0.0-beta-3a2cce989354",
4
4
  "description": "Official TypeScript SDK for the OpenMeter API — usage metering and billing",
5
5
  "keywords": [
6
6
  "openmeter",