@openmeter/client 1.0.0-beta-097ee6357e90 → 1.0.0-beta-d8b5c0006ffd

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.
@@ -423,11 +423,6 @@ export const resourceManagedBy = z
423
423
  export const chargeStatus = z
424
424
  .enum(['created', 'active', 'final', 'deleted'])
425
425
  .describe('Lifecycle status of a charge. Values: - `created`: The charge has been created but is not active yet. - `active`: The charge is active. - `final`: The charge is fully finalized and no further changes are expected. - `deleted`: The charge has been deleted.');
426
- export const priceFree = z
427
- .object({
428
- type: z.literal('free').describe('The type of the price.'),
429
- })
430
- .describe('Free price.');
431
426
  export const settlementMode = z
432
427
  .enum(['credit_then_invoice', 'credit_only'])
433
428
  .describe('Settlement mode for billing. Values: - `credit_then_invoice`: Credits are applied first, then any remainder is invoiced. - `credit_only`: Usage is settled exclusively against credits.');
@@ -463,6 +458,11 @@ export const flatFeeDiscounts = z
463
458
  export const rateCardProrationMode = z
464
459
  .enum(['no_proration', 'prorate_prices'])
465
460
  .describe('The proration mode of the rate card. Values: - `no_proration`: No proration. - `prorate_prices`: Prorate the price based on the time remaining in the billing period.');
461
+ export const priceFree = z
462
+ .object({
463
+ type: z.literal('free').describe('The type of the price.'),
464
+ })
465
+ .describe('Free price.');
466
466
  export const subscriptionStatus = z
467
467
  .enum(['active', 'inactive', 'canceled', 'scheduled'])
468
468
  .describe('Subscription status.');
@@ -889,6 +889,12 @@ export const listCostBasesParamsFilter = z
889
889
  fiat_code: currencyCode.optional(),
890
890
  })
891
891
  .describe('Filter options for listing cost bases.');
892
+ export const currencyAmount = z
893
+ .object({
894
+ amount: numeric,
895
+ currency: currencyCode,
896
+ })
897
+ .describe('Monetary amount in a specific currency.');
892
898
  export const priceFlat = z
893
899
  .object({
894
900
  type: z.literal('flat').describe('The type of the price.'),
@@ -901,12 +907,6 @@ export const priceUnit = z
901
907
  amount: numeric,
902
908
  })
903
909
  .describe('Unit price. Charges a fixed rate per billing unit. When UnitConfig is present on the rate card, billing units are the converted quantities (e.g. GB instead of bytes).');
904
- export const currencyAmount = z
905
- .object({
906
- amount: numeric,
907
- currency: currencyCode,
908
- })
909
- .describe('Monetary amount in a specific currency.');
910
910
  export const rateCardDiscounts = z
911
911
  .object({
912
912
  percentage: z
@@ -2794,6 +2794,41 @@ export const creditGrant = z
2794
2794
  status: creditGrantStatus,
2795
2795
  })
2796
2796
  .describe('A credit grant allocates credits to a customer. Credits are drawn down against charges according to the settlement mode configured on the rate card.');
2797
+ export const createFlatFeeChargeRequest = z
2798
+ .object({
2799
+ name: z
2800
+ .string()
2801
+ .min(1)
2802
+ .max(256)
2803
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
2804
+ description: z
2805
+ .string()
2806
+ .max(1024)
2807
+ .optional()
2808
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
2809
+ labels: labels.optional(),
2810
+ type: z.literal('flat_fee').describe('The type of the charge.'),
2811
+ currency: currencyCode,
2812
+ invoice_at: dateTime,
2813
+ service_period: closedPeriod,
2814
+ unique_reference_id: z
2815
+ .string()
2816
+ .optional()
2817
+ .describe('Unique reference ID of the charge.'),
2818
+ settlement_mode: settlementMode,
2819
+ tax_config: taxConfig.optional(),
2820
+ payment_term: pricePaymentTerm,
2821
+ discounts: flatFeeDiscounts.optional(),
2822
+ feature_key: z
2823
+ .string()
2824
+ .optional()
2825
+ .describe('The feature associated with the charge, when applicable.'),
2826
+ proration_configuration: rateCardProrationConfiguration,
2827
+ amount_before_proration: currencyAmount,
2828
+ full_service_period: closedPeriod.optional(),
2829
+ billing_period: closedPeriod.optional(),
2830
+ })
2831
+ .describe('Flat fee charge create request.');
2797
2832
  export const workflowTaxSettings = z
2798
2833
  .object({
2799
2834
  enabled: z
@@ -3088,7 +3123,6 @@ export const flatFeeCharge = z
3088
3123
  full_service_period: closedPeriod,
3089
3124
  billing_period: closedPeriod,
3090
3125
  advance_after: dateTime.optional(),
3091
- price: price,
3092
3126
  unique_reference_id: z
3093
3127
  .string()
3094
3128
  .optional()
@@ -3102,7 +3136,9 @@ export const flatFeeCharge = z
3102
3136
  .optional()
3103
3137
  .describe('The feature associated with the charge, when applicable.'),
3104
3138
  proration_configuration: rateCardProrationConfiguration,
3139
+ amount_before_proration: currencyAmount,
3105
3140
  amount_after_proration: currencyAmount,
3141
+ price: price,
3106
3142
  })
3107
3143
  .describe('A flat fee charge for a customer.');
3108
3144
  export const usageBasedCharge = z
@@ -3133,7 +3169,6 @@ export const usageBasedCharge = z
3133
3169
  full_service_period: closedPeriod,
3134
3170
  billing_period: closedPeriod,
3135
3171
  advance_after: dateTime.optional(),
3136
- price: price,
3137
3172
  unique_reference_id: z
3138
3173
  .string()
3139
3174
  .optional()
@@ -3143,8 +3178,39 @@ export const usageBasedCharge = z
3143
3178
  discounts: rateCardDiscounts.optional(),
3144
3179
  feature_key: z.string().describe('The feature associated with the charge.'),
3145
3180
  totals: chargeTotals,
3181
+ price: price,
3146
3182
  })
3147
3183
  .describe('A usage-based charge for a customer.');
3184
+ export const createUsageBasedChargeRequest = z
3185
+ .object({
3186
+ name: z
3187
+ .string()
3188
+ .min(1)
3189
+ .max(256)
3190
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
3191
+ description: z
3192
+ .string()
3193
+ .max(1024)
3194
+ .optional()
3195
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
3196
+ labels: labels.optional(),
3197
+ type: z.literal('usage_based').describe('The type of the charge.'),
3198
+ currency: currencyCode,
3199
+ invoice_at: dateTime,
3200
+ service_period: closedPeriod,
3201
+ unique_reference_id: z
3202
+ .string()
3203
+ .optional()
3204
+ .describe('Unique reference ID of the charge.'),
3205
+ settlement_mode: settlementMode,
3206
+ tax_config: taxConfig.optional(),
3207
+ discounts: rateCardDiscounts.optional(),
3208
+ feature_key: z.string().describe('The feature associated with the charge.'),
3209
+ price: price,
3210
+ full_service_period: closedPeriod.optional(),
3211
+ billing_period: closedPeriod.optional(),
3212
+ })
3213
+ .describe('Usage-based charge create request.');
3148
3214
  export const rateCard = z
3149
3215
  .object({
3150
3216
  name: z
@@ -3186,6 +3252,12 @@ export const workflow = z
3186
3252
  export const charge = z
3187
3253
  .discriminatedUnion('type', [flatFeeCharge, usageBasedCharge])
3188
3254
  .describe('Customer charge.');
3255
+ export const createChargeRequest = z
3256
+ .discriminatedUnion('type', [
3257
+ createFlatFeeChargeRequest,
3258
+ createUsageBasedChargeRequest,
3259
+ ])
3260
+ .describe('Customer charge.');
3189
3261
  export const planPhase = z
3190
3262
  .object({
3191
3263
  name: z
@@ -3656,6 +3728,11 @@ export const listCustomerChargesResponse = z.object({
3656
3728
  data: z.array(charge),
3657
3729
  meta: paginatedMeta,
3658
3730
  });
3731
+ export const createCustomerChargesPathParams = z.object({
3732
+ customerId: ulid,
3733
+ });
3734
+ export const createCustomerChargesBody = createChargeRequest;
3735
+ export const createCustomerChargesResponse = charge;
3659
3736
  export const createSubscriptionBody = subscriptionCreate;
3660
3737
  export const createSubscriptionResponse = subscription;
3661
3738
  export const listSubscriptionsQueryParams = z.object({
@@ -110,11 +110,6 @@ export interface AppStripeCreateCustomerPortalSessionOptions {
110
110
  }
111
111
  /** Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "\_". */
112
112
  export type CreateLabels = Record<string, string>;
113
- /** Free price. */
114
- export interface PriceFree {
115
- /** The type of the price. */
116
- type: 'free';
117
- }
118
113
  /** The tax config for Stripe. */
119
114
  export interface TaxConfigStripe {
120
115
  /** Product [tax code](https://docs.stripe.com/tax/tax-codes). */
@@ -130,6 +125,11 @@ export interface FlatFeeDiscounts {
130
125
  /** Percentage discount applied to the price (0–100). */
131
126
  percentage?: number;
132
127
  }
128
+ /** Free price. */
129
+ export interface PriceFree {
130
+ /** The type of the price. */
131
+ type: 'free';
132
+ }
133
133
  /** BillingWorkflowCollectionAlignmentSubscription specifies the alignment for collecting the pending line items into an invoice. */
134
134
  export interface WorkflowCollectionAlignmentSubscription {
135
135
  /** The type of alignment. */
@@ -306,6 +306,11 @@ export interface ListCostBasesParamsFilter {
306
306
  /** Filter cost bases by fiat currency code. */
307
307
  fiat_code?: string;
308
308
  }
309
+ /** Monetary amount in a specific currency. */
310
+ export interface CurrencyAmount {
311
+ amount: string;
312
+ currency: string;
313
+ }
309
314
  /** Flat price. */
310
315
  export interface PriceFlat {
311
316
  /** The type of the price. */
@@ -320,11 +325,6 @@ export interface PriceUnit {
320
325
  /** The amount of the unit price. */
321
326
  amount: string;
322
327
  }
323
- /** Monetary amount in a specific currency. */
324
- export interface CurrencyAmount {
325
- amount: string;
326
- currency: string;
327
- }
328
328
  /** Discount configuration for a rate card. */
329
329
  export interface RateCardDiscounts {
330
330
  /** Percentage discount applied to the price (0–100). */
@@ -2336,6 +2336,42 @@ export interface CreditGrant {
2336
2336
  /** Current lifecycle status of the grant. */
2337
2337
  status: 'pending' | 'active' | 'expired' | 'voided';
2338
2338
  }
2339
+ /** Flat fee charge create request. */
2340
+ export interface CreateFlatFeeChargeRequest {
2341
+ /** Display name of the resource. Between 1 and 256 characters. */
2342
+ name: string;
2343
+ /** Optional description of the resource. Maximum 1024 characters. */
2344
+ description?: string;
2345
+ labels?: Labels;
2346
+ /** The type of the charge. */
2347
+ type: 'flat_fee';
2348
+ /** The currency of the charge. */
2349
+ currency: string;
2350
+ /** The timestamp when the charge is intended to be invoiced. */
2351
+ invoice_at: string;
2352
+ /** The effective service period covered by the charge. */
2353
+ service_period: ClosedPeriod;
2354
+ /** Unique reference ID of the charge. */
2355
+ unique_reference_id?: string;
2356
+ /** Settlement mode of the charge. */
2357
+ settlement_mode: 'credit_then_invoice' | 'credit_only';
2358
+ /** Tax configuration of the charge. */
2359
+ tax_config?: TaxConfig;
2360
+ /** Payment term of the flat fee charge. */
2361
+ payment_term: 'in_advance' | 'in_arrears';
2362
+ /** The discounts applied to the charge. */
2363
+ discounts?: FlatFeeDiscounts;
2364
+ /** The feature associated with the charge, when applicable. */
2365
+ feature_key?: string;
2366
+ /** The proration configuration of the charge. */
2367
+ proration_configuration: RateCardProrationConfiguration;
2368
+ /** The amount before proration of the charge. */
2369
+ amount_before_proration: CurrencyAmount;
2370
+ /** The full, unprorated service period of the charge. */
2371
+ full_service_period?: ClosedPeriod;
2372
+ /** The billing period the charge belongs to. */
2373
+ billing_period?: ClosedPeriod;
2374
+ }
2339
2375
  /** Tax settings for a billing workflow. */
2340
2376
  export interface WorkflowTaxSettings {
2341
2377
  /** Enable automatic tax calculation when tax is supported by the app. For example, with Stripe Invoicing when enabled, tax is calculated via Stripe Tax. */
@@ -2570,8 +2606,6 @@ export interface FlatFeeCharge {
2570
2606
  billing_period: ClosedPeriod;
2571
2607
  /** The earliest time when the charge should be advanced again by background processing. */
2572
2608
  advance_after?: string;
2573
- /** The price of the charge. */
2574
- price: PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
2575
2609
  /** Unique reference ID of the charge. */
2576
2610
  unique_reference_id?: string;
2577
2611
  /** Settlement mode of the charge. */
@@ -2586,8 +2620,12 @@ export interface FlatFeeCharge {
2586
2620
  feature_key?: string;
2587
2621
  /** The proration configuration of the charge. */
2588
2622
  proration_configuration: RateCardProrationConfiguration;
2623
+ /** The amount before proration of the charge. */
2624
+ amount_before_proration: CurrencyAmount;
2589
2625
  /** The amount after proration of the charge. */
2590
2626
  amount_after_proration: CurrencyAmount;
2627
+ /** The price of the charge. */
2628
+ price: PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
2591
2629
  }
2592
2630
  /** A usage-based charge for a customer. */
2593
2631
  export interface UsageBasedCharge {
@@ -2625,8 +2663,6 @@ export interface UsageBasedCharge {
2625
2663
  billing_period: ClosedPeriod;
2626
2664
  /** The earliest time when the charge should be advanced again by background processing. */
2627
2665
  advance_after?: string;
2628
- /** The price of the charge. */
2629
- price: PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
2630
2666
  /** Unique reference ID of the charge. */
2631
2667
  unique_reference_id?: string;
2632
2668
  /** Settlement mode of the charge. */
@@ -2639,6 +2675,40 @@ export interface UsageBasedCharge {
2639
2675
  feature_key: string;
2640
2676
  /** Aggregated booked and realtime totals for the charge. */
2641
2677
  totals: ChargeTotals;
2678
+ /** The price of the charge. */
2679
+ price: PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
2680
+ }
2681
+ /** Usage-based charge create request. */
2682
+ export interface CreateUsageBasedChargeRequest {
2683
+ /** Display name of the resource. Between 1 and 256 characters. */
2684
+ name: string;
2685
+ /** Optional description of the resource. Maximum 1024 characters. */
2686
+ description?: string;
2687
+ labels?: Labels;
2688
+ /** The type of the charge. */
2689
+ type: 'usage_based';
2690
+ /** The currency of the charge. */
2691
+ currency: string;
2692
+ /** The timestamp when the charge is intended to be invoiced. */
2693
+ invoice_at: string;
2694
+ /** The effective service period covered by the charge. */
2695
+ service_period: ClosedPeriod;
2696
+ /** Unique reference ID of the charge. */
2697
+ unique_reference_id?: string;
2698
+ /** Settlement mode of the charge. */
2699
+ settlement_mode: 'credit_then_invoice' | 'credit_only';
2700
+ /** Tax configuration of the charge. */
2701
+ tax_config?: TaxConfig;
2702
+ /** Discounts applied to the usage-based charge. */
2703
+ discounts?: RateCardDiscounts;
2704
+ /** The feature associated with the charge. */
2705
+ feature_key: string;
2706
+ /** The price of the charge. */
2707
+ price: PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
2708
+ /** The full, unprorated service period of the charge. */
2709
+ full_service_period?: ClosedPeriod;
2710
+ /** The billing period the charge belongs to. */
2711
+ billing_period?: ClosedPeriod;
2642
2712
  }
2643
2713
  /** A rate card defines the pricing and entitlement of a feature or service. */
2644
2714
  export interface RateCard {
@@ -1,6 +1,6 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type RequestOptions } from '../lib/types.js';
3
- import type { CreateCustomerRequest, CreateCustomerResponse, GetCustomerRequest, GetCustomerResponse, ListCustomersRequest, ListCustomersResponse, UpsertCustomerRequest, UpsertCustomerResponse, DeleteCustomerRequest, DeleteCustomerResponse, GetCustomerBillingRequest, GetCustomerBillingResponse, UpdateCustomerBillingRequest, UpdateCustomerBillingResponse, UpdateCustomerBillingAppDataRequest, UpdateCustomerBillingAppDataResponse, CreateCustomerStripeCheckoutSessionRequest, CreateCustomerStripeCheckoutSessionResponse, CreateCustomerStripePortalSessionRequest, CreateCustomerStripePortalSessionResponse, CreateCreditGrantRequest, CreateCreditGrantResponse, GetCreditGrantRequest, GetCreditGrantResponse, ListCreditGrantsRequest, ListCreditGrantsResponse, GetCustomerCreditBalanceRequest, GetCustomerCreditBalanceResponse, CreateCreditAdjustmentRequest, CreateCreditAdjustmentResponse, UpdateCreditGrantExternalSettlementRequest, UpdateCreditGrantExternalSettlementResponse, ListCreditTransactionsRequest, ListCreditTransactionsResponse, ListCustomerChargesRequest, ListCustomerChargesResponse } from '../models/operations/customers.js';
3
+ import type { CreateCustomerRequest, CreateCustomerResponse, GetCustomerRequest, GetCustomerResponse, ListCustomersRequest, ListCustomersResponse, UpsertCustomerRequest, UpsertCustomerResponse, DeleteCustomerRequest, DeleteCustomerResponse, GetCustomerBillingRequest, GetCustomerBillingResponse, UpdateCustomerBillingRequest, UpdateCustomerBillingResponse, UpdateCustomerBillingAppDataRequest, UpdateCustomerBillingAppDataResponse, CreateCustomerStripeCheckoutSessionRequest, CreateCustomerStripeCheckoutSessionResponse, CreateCustomerStripePortalSessionRequest, CreateCustomerStripePortalSessionResponse, CreateCreditGrantRequest, CreateCreditGrantResponse, GetCreditGrantRequest, GetCreditGrantResponse, ListCreditGrantsRequest, ListCreditGrantsResponse, GetCustomerCreditBalanceRequest, GetCustomerCreditBalanceResponse, CreateCreditAdjustmentRequest, CreateCreditAdjustmentResponse, UpdateCreditGrantExternalSettlementRequest, UpdateCreditGrantExternalSettlementResponse, ListCreditTransactionsRequest, ListCreditTransactionsResponse, ListCustomerChargesRequest, ListCustomerChargesResponse, CreateCustomerChargesRequest, CreateCustomerChargesResponse } from '../models/operations/customers.js';
4
4
  export declare class Customers {
5
5
  private readonly _client;
6
6
  constructor(_client: Client);
@@ -64,5 +64,6 @@ export declare class CustomersCharges {
64
64
  private readonly _client;
65
65
  constructor(_client: Client);
66
66
  list(request: ListCustomerChargesRequest, options?: RequestOptions): Promise<ListCustomerChargesResponse>;
67
+ create(request: CreateCustomerChargesRequest, options?: RequestOptions): Promise<CreateCustomerChargesResponse>;
67
68
  }
68
69
  //# sourceMappingURL=customers.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { unwrap } from '../lib/types.js';
2
- import { createCustomer, getCustomer, listCustomers, upsertCustomer, deleteCustomer, getCustomerBilling, updateCustomerBilling, updateCustomerBillingAppData, createCustomerStripeCheckoutSession, createCustomerStripePortalSession, createCreditGrant, getCreditGrant, listCreditGrants, getCustomerCreditBalance, createCreditAdjustment, updateCreditGrantExternalSettlement, listCreditTransactions, listCustomerCharges, } from '../funcs/customers.js';
2
+ import { createCustomer, getCustomer, listCustomers, upsertCustomer, deleteCustomer, getCustomerBilling, updateCustomerBilling, updateCustomerBillingAppData, createCustomerStripeCheckoutSession, createCustomerStripePortalSession, createCreditGrant, getCreditGrant, listCreditGrants, getCustomerCreditBalance, createCreditAdjustment, updateCreditGrantExternalSettlement, listCreditTransactions, listCustomerCharges, createCustomerCharges, } from '../funcs/customers.js';
3
3
  export class Customers {
4
4
  _client;
5
5
  constructor(_client) {
@@ -129,5 +129,8 @@ export class CustomersCharges {
129
129
  async list(request, options) {
130
130
  return unwrap(await listCustomerCharges(this._client, request, options));
131
131
  }
132
+ async create(request, options) {
133
+ return unwrap(await createCustomerCharges(this._client, request, options));
134
+ }
132
135
  }
133
136
  //# sourceMappingURL=customers.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmeter/client",
3
- "version": "1.0.0-beta-097ee6357e90",
3
+ "version": "1.0.0-beta-d8b5c0006ffd",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://openmeter.io",
6
6
  "repository": {