lark-billing 0.2.0 → 0.4.0

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 (78) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +22 -31
  3. package/client.d.mts +2 -2
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +2 -2
  6. package/client.d.ts.map +1 -1
  7. package/client.js +3 -3
  8. package/client.js.map +1 -1
  9. package/client.mjs +3 -3
  10. package/client.mjs.map +1 -1
  11. package/package.json +2 -2
  12. package/resources/customer-access.d.mts +8 -0
  13. package/resources/customer-access.d.mts.map +1 -1
  14. package/resources/customer-access.d.ts +8 -0
  15. package/resources/customer-access.d.ts.map +1 -1
  16. package/resources/customer-access.js +8 -0
  17. package/resources/customer-access.js.map +1 -1
  18. package/resources/customer-access.mjs +8 -0
  19. package/resources/customer-access.mjs.map +1 -1
  20. package/resources/invoices.d.mts +7 -0
  21. package/resources/invoices.d.mts.map +1 -1
  22. package/resources/invoices.d.ts +7 -0
  23. package/resources/invoices.d.ts.map +1 -1
  24. package/resources/invoices.js +7 -0
  25. package/resources/invoices.js.map +1 -1
  26. package/resources/invoices.mjs +7 -0
  27. package/resources/invoices.mjs.map +1 -1
  28. package/resources/pricing-metrics.d.mts +10 -2
  29. package/resources/pricing-metrics.d.mts.map +1 -1
  30. package/resources/pricing-metrics.d.ts +10 -2
  31. package/resources/pricing-metrics.d.ts.map +1 -1
  32. package/resources/pricing-metrics.js +2 -2
  33. package/resources/pricing-metrics.mjs +2 -2
  34. package/resources/rate-cards.d.mts +151 -4
  35. package/resources/rate-cards.d.mts.map +1 -1
  36. package/resources/rate-cards.d.ts +151 -4
  37. package/resources/rate-cards.d.ts.map +1 -1
  38. package/resources/rate-cards.js +44 -0
  39. package/resources/rate-cards.js.map +1 -1
  40. package/resources/rate-cards.mjs +44 -0
  41. package/resources/rate-cards.mjs.map +1 -1
  42. package/resources/subjects.d.mts +7 -2
  43. package/resources/subjects.d.mts.map +1 -1
  44. package/resources/subjects.d.ts +7 -2
  45. package/resources/subjects.d.ts.map +1 -1
  46. package/resources/subjects.js +7 -2
  47. package/resources/subjects.js.map +1 -1
  48. package/resources/subjects.mjs +7 -2
  49. package/resources/subjects.mjs.map +1 -1
  50. package/resources/subscriptions.d.mts +9 -5
  51. package/resources/subscriptions.d.mts.map +1 -1
  52. package/resources/subscriptions.d.ts +9 -5
  53. package/resources/subscriptions.d.ts.map +1 -1
  54. package/resources/subscriptions.js +9 -5
  55. package/resources/subscriptions.js.map +1 -1
  56. package/resources/subscriptions.mjs +9 -5
  57. package/resources/subscriptions.mjs.map +1 -1
  58. package/resources/usage-events.d.mts +4 -3
  59. package/resources/usage-events.d.mts.map +1 -1
  60. package/resources/usage-events.d.ts +4 -3
  61. package/resources/usage-events.d.ts.map +1 -1
  62. package/resources/usage-events.js +4 -3
  63. package/resources/usage-events.js.map +1 -1
  64. package/resources/usage-events.mjs +4 -3
  65. package/resources/usage-events.mjs.map +1 -1
  66. package/src/client.ts +4 -4
  67. package/src/resources/customer-access.ts +8 -0
  68. package/src/resources/invoices.ts +7 -0
  69. package/src/resources/pricing-metrics.ts +12 -2
  70. package/src/resources/rate-cards.ts +179 -4
  71. package/src/resources/subjects.ts +7 -2
  72. package/src/resources/subscriptions.ts +9 -5
  73. package/src/resources/usage-events.ts +4 -3
  74. package/src/version.ts +1 -1
  75. package/version.d.mts +1 -1
  76. package/version.d.ts +1 -1
  77. package/version.js +1 -1
  78. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -165,7 +165,7 @@ export class Lark {
165
165
  baseURL: string;
166
166
  maxRetries: number;
167
167
  timeout: number;
168
- logger: Logger | undefined;
168
+ logger: Logger;
169
169
  logLevel: LogLevel | undefined;
170
170
  fetchOptions: MergedRequestInit | undefined;
171
171
 
@@ -178,7 +178,7 @@ export class Lark {
178
178
  * API Client for interfacing with the Lark API.
179
179
  *
180
180
  * @param {string | undefined} [opts.apiKey=process.env['LARK_API_KEY'] ?? undefined]
181
- * @param {string} [opts.baseURL=process.env['LARK_BASE_URL'] ?? https://api.example.com] - Override the default base URL for the API.
181
+ * @param {string} [opts.baseURL=process.env['LARK_BASE_URL'] ?? https://api.uselark.ai] - Override the default base URL for the API.
182
182
  * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
183
183
  * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
184
184
  * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -200,7 +200,7 @@ export class Lark {
200
200
  const options: ClientOptions = {
201
201
  apiKey,
202
202
  ...opts,
203
- baseURL: baseURL || `https://api.example.com`,
203
+ baseURL: baseURL || `https://api.uselark.ai`,
204
204
  };
205
205
 
206
206
  this.baseURL = options.baseURL!;
@@ -246,7 +246,7 @@ export class Lark {
246
246
  * Check whether the base URL is set to its default.
247
247
  */
248
248
  #baseURLOverridden(): boolean {
249
- return this.baseURL !== 'https://api.example.com';
249
+ return this.baseURL !== 'https://api.uselark.ai';
250
250
  }
251
251
 
252
252
  protected defaultQuery(): Record<string, string | undefined> | undefined {
@@ -8,6 +8,14 @@ import { path } from '../internal/utils/path';
8
8
  export class CustomerAccess extends APIResource {
9
9
  /**
10
10
  * Get Billing State
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const response =
15
+ * await client.customerAccess.retrieveBillingState(
16
+ * 'user_1234567890',
17
+ * );
18
+ * ```
11
19
  */
12
20
  retrieveBillingState(
13
21
  subjectID: string,
@@ -8,6 +8,13 @@ import { RequestOptions } from '../internal/request-options';
8
8
  export class Invoices extends APIResource {
9
9
  /**
10
10
  * List Invoices
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const invoices = await client.invoices.list({
15
+ * subject_id: 'user_1234567890',
16
+ * });
17
+ * ```
11
18
  */
12
19
  list(query: InvoiceListParams, options?: RequestOptions): APIPromise<InvoiceListResponse> {
13
20
  return this._client.get('/invoices', { query, ...options });
@@ -61,11 +61,11 @@ export class PricingMetrics extends APIResource {
61
61
  * @example
62
62
  * ```ts
63
63
  * const response = await client.pricingMetrics.createSummary(
64
- * 'pricing_metric_id',
64
+ * 'pmtr_GlX5Tcm2HOn00CoRTFxw2Amw',
65
65
  * {
66
66
  * period: {
67
- * end: '2025-11-01T00:00:00Z',
68
67
  * start: '2025-10-01T00:00:00Z',
68
+ * end: '2025-11-01T00:00:00Z',
69
69
  * },
70
70
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
71
71
  * },
@@ -120,6 +120,11 @@ export interface PricingMetricResource {
120
120
  * The unit of the value computed by the pricing metric.
121
121
  */
122
122
  unit: string;
123
+
124
+ /**
125
+ * The dimensions by which the events are grouped to compute the pricing metric.
126
+ */
127
+ dimensions?: Array<string> | null;
123
128
  }
124
129
 
125
130
  export namespace PricingMetricResource {
@@ -214,6 +219,11 @@ export interface PricingMetricCreateParams {
214
219
  * Unit of measurement for the pricing metric.
215
220
  */
216
221
  unit: string;
222
+
223
+ /**
224
+ * The dimensions by which the events are grouped to compute the pricing metric.
225
+ */
226
+ dimensions?: Array<string> | null;
217
227
  }
218
228
 
219
229
  export namespace PricingMetricCreateParams {
@@ -10,6 +10,38 @@ import { path } from '../internal/utils/path';
10
10
  export class RateCards extends APIResource {
11
11
  /**
12
12
  * Create Rate Card
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const rateCardResource = await client.rateCards.create({
17
+ * billing_interval: 'monthly',
18
+ * name: 'Pro Plan',
19
+ * description:
20
+ * 'For production applicatidddons with moderate usage.',
21
+ * fixed_rates: [
22
+ * {
23
+ * name: 'Base Rate',
24
+ * price: {
25
+ * price_type: 'flat',
26
+ * amount: { value: 2500, currency_code: 'usd' },
27
+ * },
28
+ * },
29
+ * ],
30
+ * metadata: {},
31
+ * usage_based_rates: [
32
+ * {
33
+ * usage_based_rate_type: 'simple',
34
+ * name: 'Compute Hours',
35
+ * price: {
36
+ * price_type: 'flat',
37
+ * amount: { value: 100, currency_code: 'usd' },
38
+ * },
39
+ * included_units: 30,
40
+ * pricing_metric_id: 'pmtr_GlX5Tcm2HOn00CoRTFxw2Amw',
41
+ * },
42
+ * ],
43
+ * });
44
+ * ```
13
45
  */
14
46
  create(body: RateCardCreateParams, options?: RequestOptions): APIPromise<RateCardResource> {
15
47
  return this._client.post('/rate-cards', { body, ...options });
@@ -17,6 +49,13 @@ export class RateCards extends APIResource {
17
49
 
18
50
  /**
19
51
  * Get Rate Card
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const rateCardResource = await client.rateCards.retrieve(
56
+ * 'rate_card_id',
57
+ * );
58
+ * ```
20
59
  */
21
60
  retrieve(rateCardID: string, options?: RequestOptions): APIPromise<RateCardResource> {
22
61
  return this._client.get(path`/rate-cards/${rateCardID}`, options);
@@ -24,6 +63,11 @@ export class RateCards extends APIResource {
24
63
 
25
64
  /**
26
65
  * List Rate Cards
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const rateCards = await client.rateCards.list();
70
+ * ```
27
71
  */
28
72
  list(
29
73
  query: RateCardListParams | null | undefined = {},
@@ -99,6 +143,9 @@ export interface RateCardResource {
99
143
  */
100
144
  id: string;
101
145
 
146
+ /**
147
+ * How often the customer will be billed for this rate card.
148
+ */
102
149
  billing_interval: 'monthly' | 'yearly';
103
150
 
104
151
  /**
@@ -111,6 +158,10 @@ export interface RateCardResource {
111
158
  */
112
159
  fixed_rates: Array<RateCardResource.FixedRate>;
113
160
 
161
+ /**
162
+ * Additional metadata about the rate card. You may use this to store any custom
163
+ * data about the rate card.
164
+ */
114
165
  metadata: { [key: string]: string };
115
166
 
116
167
  /**
@@ -126,7 +177,9 @@ export interface RateCardResource {
126
177
  /**
127
178
  * The usage based rates of the rate card.
128
179
  */
129
- usage_based_rates: Array<RateCardResource.UsageBasedRate>;
180
+ usage_based_rates: Array<
181
+ RateCardResource.SimpleUsageBasedRateInterface | RateCardResource.DimensionalUsageBasedRateInterface
182
+ >;
130
183
 
131
184
  /**
132
185
  * The description of the rate card.
@@ -148,7 +201,7 @@ export namespace RateCardResource {
148
201
  price: RateCardsAPI.FlatPriceOutput | RateCardsAPI.PackagePriceOutput;
149
202
  }
150
203
 
151
- export interface UsageBasedRate {
204
+ export interface SimpleUsageBasedRateInterface {
152
205
  id: string;
153
206
 
154
207
  description: string | null;
@@ -166,6 +219,49 @@ export namespace RateCardResource {
166
219
 
167
220
  usage_based_rate_type?: 'simple';
168
221
  }
222
+
223
+ export interface DimensionalUsageBasedRateInterface {
224
+ id: string;
225
+
226
+ description: string | null;
227
+
228
+ dimensions: Array<DimensionalUsageBasedRateInterface.Dimension>;
229
+
230
+ included_units: number;
231
+
232
+ name: string;
233
+
234
+ pricing_matrix: DimensionalUsageBasedRateInterface.PricingMatrix;
235
+
236
+ pricing_metric_id: string;
237
+
238
+ usage_based_rate_type?: 'dimensional';
239
+ }
240
+
241
+ export namespace DimensionalUsageBasedRateInterface {
242
+ export interface Dimension {
243
+ description: string | null;
244
+
245
+ key: string;
246
+
247
+ values: Array<string>;
248
+ }
249
+
250
+ export interface PricingMatrix {
251
+ cells: Array<PricingMatrix.Cell>;
252
+ }
253
+
254
+ export namespace PricingMatrix {
255
+ export interface Cell {
256
+ dimension_coordinates: { [key: string]: string };
257
+
258
+ /**
259
+ * Flat price is a price that linearly scales with the quantity.
260
+ */
261
+ price: RateCardsAPI.FlatPriceOutput | RateCardsAPI.PackagePriceOutput;
262
+ }
263
+ }
264
+ }
169
265
  }
170
266
 
171
267
  export interface RateCardListResponse {
@@ -202,7 +298,10 @@ export interface RateCardCreateParams {
202
298
  * The usage based rates of the rate card. These are billed at the end of each
203
299
  * billing cycle.
204
300
  */
205
- usage_based_rates?: Array<RateCardCreateParams.UsageBasedRate>;
301
+ usage_based_rates?: Array<
302
+ | RateCardCreateParams.CreateSimpleUsageBasedRateRequest
303
+ | RateCardCreateParams.CreateDimensionalUsageBasedRateRequest
304
+ >;
206
305
  }
207
306
 
208
307
  export namespace RateCardCreateParams {
@@ -223,7 +322,7 @@ export namespace RateCardCreateParams {
223
322
  description?: string | null;
224
323
  }
225
324
 
226
- export interface UsageBasedRate {
325
+ export interface CreateSimpleUsageBasedRateRequest {
227
326
  /**
228
327
  * The name of the rate displayed to the customer.
229
328
  */
@@ -251,6 +350,82 @@ export namespace RateCardCreateParams {
251
350
  */
252
351
  included_units?: number;
253
352
  }
353
+
354
+ export interface CreateDimensionalUsageBasedRateRequest {
355
+ /**
356
+ * The dimensions of the rate.
357
+ */
358
+ dimensions: Array<CreateDimensionalUsageBasedRateRequest.Dimension>;
359
+
360
+ /**
361
+ * The name of the rate displayed to the customer.
362
+ */
363
+ name: string;
364
+
365
+ /**
366
+ * The pricing matrix of the rate.
367
+ */
368
+ pricing_matrix: CreateDimensionalUsageBasedRateRequest.PricingMatrix;
369
+
370
+ /**
371
+ * The ID of the pricing metric to use for this rate.
372
+ */
373
+ pricing_metric_id: string;
374
+
375
+ usage_based_rate_type: 'dimensional';
376
+
377
+ /**
378
+ * The description of the rate displayed to the customer.
379
+ */
380
+ description?: string | null;
381
+
382
+ /**
383
+ * The number of units included in the rate before the price is applied.
384
+ */
385
+ included_units?: number;
386
+ }
387
+
388
+ export namespace CreateDimensionalUsageBasedRateRequest {
389
+ export interface Dimension {
390
+ /**
391
+ * The name of the dimension. This is used to identify the dimension in the pricing
392
+ * matrix.
393
+ */
394
+ key: string;
395
+
396
+ /**
397
+ * A list of possible values for the dimension.
398
+ */
399
+ values: Array<string>;
400
+
401
+ /**
402
+ * The description of the dimension.
403
+ */
404
+ description?: string | null;
405
+ }
406
+
407
+ /**
408
+ * The pricing matrix of the rate.
409
+ */
410
+ export interface PricingMatrix {
411
+ cells: Array<PricingMatrix.Cell>;
412
+ }
413
+
414
+ export namespace PricingMatrix {
415
+ export interface Cell {
416
+ /**
417
+ * A key-value mapping of dimension keys and values to identify the price for a
418
+ * given set of dimension values.
419
+ */
420
+ dimension_coordinates: { [key: string]: string };
421
+
422
+ /**
423
+ * The price for the cell.
424
+ */
425
+ price: RateCardsAPI.FlatPriceInput | RateCardsAPI.PackagePriceInput;
426
+ }
427
+ }
428
+ }
254
429
  }
255
430
 
256
431
  export interface RateCardListParams {
@@ -11,7 +11,12 @@ export class Subjects extends APIResource {
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
- * const subject = await client.subjects.create();
14
+ * const subject = await client.subjects.create({
15
+ * email: 'john.doe@example.com',
16
+ * external_id: 'user_1234567890',
17
+ * metadata: {},
18
+ * name: 'John Doe',
19
+ * });
15
20
  * ```
16
21
  */
17
22
  create(body: SubjectCreateParams, options?: RequestOptions): APIPromise<SubjectCreateResponse> {
@@ -41,7 +46,7 @@ export class Subjects extends APIResource {
41
46
  * 'subject_id',
42
47
  * {
43
48
  * email: 'john.doe@example.com',
44
- * metadata: { foo: 'string' },
49
+ * metadata: {},
45
50
  * name: 'John Doe',
46
51
  * },
47
52
  * );
@@ -14,11 +14,12 @@ export class Subscriptions extends APIResource {
14
14
  * ```ts
15
15
  * const subscription = await client.subscriptions.create({
16
16
  * checkout_callback_urls: {
17
- * cancelled_url: 'https://example.com/callback',
18
- * success_url: 'https://example.com/callback',
17
+ * cancelled_url: 'https://example.com/try-again',
18
+ * success_url: 'https://example.com/welcome',
19
19
  * },
20
20
  * rate_card_id: 'rc_AJWMxR81jxoRlli6p13uf3JB',
21
21
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
22
+ * metadata: {},
22
23
  * });
23
24
  * ```
24
25
  */
@@ -60,7 +61,9 @@ export class Subscriptions extends APIResource {
60
61
  * @example
61
62
  * ```ts
62
63
  * const subscriptionResource =
63
- * await client.subscriptions.cancel('subscription_id');
64
+ * await client.subscriptions.cancel('subscription_id', {
65
+ * cancel_at_end_of_cycle: true,
66
+ * });
64
67
  * ```
65
68
  */
66
69
  cancel(
@@ -80,10 +83,11 @@ export class Subscriptions extends APIResource {
80
83
  * 'subscription_id',
81
84
  * {
82
85
  * checkout_callback_urls: {
83
- * cancelled_url: 'https://example.com/callback',
84
- * success_url: 'https://example.com/callback',
86
+ * cancelled_url: 'https://example.com/try-again',
87
+ * success_url: 'https://example.com/completed',
85
88
  * },
86
89
  * rate_card_id: 'rc_jQK2n0wutCj6bBcAIrL6o07g',
90
+ * upgrade_behavior: 'prorate',
87
91
  * },
88
92
  * );
89
93
  * ```
@@ -12,13 +12,14 @@ export class UsageEvents extends APIResource {
12
12
  * ```ts
13
13
  * const usageEvent = await client.usageEvents.create({
14
14
  * data: {
15
- * compute_hours: 100,
15
+ * compute_hours: '100.5',
16
16
  * instance_type: 't2.micro',
17
17
  * region: 'us-east-1',
18
18
  * },
19
- * event_name: 'compute_hours',
20
- * idempotency_key: 'dd187757-47af-4a69-8a89-6285b9fe1cb6',
19
+ * event_name: 'job_completed',
20
+ * idempotency_key: '168fbd3a-4d39-4db3-a204-15e014857d10',
21
21
  * subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
22
+ * timestamp: '2025-12-03T22:13:28.294419+00:00',
22
23
  * });
23
24
  * ```
24
25
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.0'; // x-release-please-version
1
+ export const VERSION = '0.4.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.0";
1
+ export declare const VERSION = "0.4.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.0";
1
+ export declare const VERSION = "0.4.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.2.0'; // x-release-please-version
4
+ exports.VERSION = '0.4.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.2.0'; // x-release-please-version
1
+ export const VERSION = '0.4.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map