@bpinternal/const 0.4.3 → 0.5.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.
@@ -0,0 +1,23 @@
1
+ export declare const BILLING_METERS_IDS: readonly ["ai_spend_credit_grant", "ai_spend_pay_as_you_go"];
2
+ export declare const billingMetersDefs: {
3
+ readonly ai_spend_credit_grant: {
4
+ readonly id: "ai_spend_credit_grant";
5
+ readonly name: "AI Spend - Credit grant";
6
+ readonly description: "Pre-purchased credits applied toward AI usage";
7
+ readonly currency: "usd";
8
+ readonly unitAmount: 1;
9
+ readonly interval: "month";
10
+ readonly aggregation: "lastDuringPeriod";
11
+ readonly meterType: "creditGrant";
12
+ };
13
+ readonly ai_spend_pay_as_you_go: {
14
+ readonly id: "ai_spend_pay_as_you_go";
15
+ readonly name: "AI Spend - Pay as you go";
16
+ readonly description: "Usage-based charges for AI spend, billed monthly";
17
+ readonly currency: "usd";
18
+ readonly unitAmount: 1;
19
+ readonly interval: "month";
20
+ readonly aggregation: "lastDuringPeriod";
21
+ readonly meterType: "payAsYouGo";
22
+ };
23
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.billingMetersDefs = exports.BILLING_METERS_IDS = void 0;
4
+ exports.BILLING_METERS_IDS = ['ai_spend_credit_grant', 'ai_spend_pay_as_you_go'];
5
+ exports.billingMetersDefs = {
6
+ ai_spend_credit_grant: {
7
+ id: 'ai_spend_credit_grant',
8
+ name: 'AI Spend - Credit grant',
9
+ description: 'Pre-purchased credits applied toward AI usage',
10
+ currency: 'usd',
11
+ unitAmount: 1,
12
+ interval: 'month',
13
+ aggregation: 'lastDuringPeriod',
14
+ meterType: 'creditGrant',
15
+ },
16
+ ai_spend_pay_as_you_go: {
17
+ id: 'ai_spend_pay_as_you_go',
18
+ name: 'AI Spend - Pay as you go',
19
+ description: 'Usage-based charges for AI spend, billed monthly',
20
+ currency: 'usd',
21
+ unitAmount: 1,
22
+ interval: 'month',
23
+ aggregation: 'lastDuringPeriod',
24
+ meterType: 'payAsYouGo',
25
+ },
26
+ };
@@ -22,7 +22,7 @@ export declare const billingPlansDefs: {
22
22
  readonly human_in_the_loop: false;
23
23
  readonly ratelimit: 100;
24
24
  readonly incoming_messages_events: 500;
25
- readonly integration_spend: 5000000000;
25
+ readonly integration_spend: 0;
26
26
  readonly integration_subscription: false;
27
27
  readonly table_rows: 1000;
28
28
  readonly bot_count: 1;
@@ -41,7 +41,7 @@ exports.billingPlansDefs = {
41
41
  human_in_the_loop: false,
42
42
  ratelimit: 100,
43
43
  incoming_messages_events: 500,
44
- integration_spend: 5_000_000_000, // $5 in nano-dollars
44
+ integration_spend: 0,
45
45
  integration_subscription: false,
46
46
  table_rows: 1000,
47
47
  bot_count: 1,
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getBillingVersion = exports.getActiveBillingVersion = exports.billingDefinitions = exports.billingV4Definition = exports.BILLING_VERSIONS = void 0;
8
8
  const billing_plans_1 = require("./billing-plans");
9
9
  const billing_addons_1 = require("./billing-addons");
10
+ const billing_meters_1 = require("./billing-meters");
10
11
  exports.BILLING_VERSIONS = ['v4'];
11
12
  exports.billingV4Definition = {
12
13
  version: 'v4',
@@ -14,6 +15,7 @@ exports.billingV4Definition = {
14
15
  description: 'New billing system with credit grants and entitlements',
15
16
  plans: billing_plans_1.billingPlansDefs,
16
17
  addons: billing_addons_1.billingAddonsDefs,
18
+ meters: billing_meters_1.billingMetersDefs,
17
19
  isActive: true,
18
20
  createdAt: new Date().toISOString(),
19
21
  // stripeMapping will be populated by Pulumi
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from './billing-features';
9
9
  export * from './billing-plans';
10
10
  export * from './billing-versions';
11
11
  export * from './billing-addons';
12
+ export * from './billing-meters';
12
13
  export * from './usage-metadata';
13
14
  export * from './schema';
14
15
  export * from './types';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ __exportStar(require("./billing-features"), exports);
26
26
  __exportStar(require("./billing-plans"), exports);
27
27
  __exportStar(require("./billing-versions"), exports);
28
28
  __exportStar(require("./billing-addons"), exports);
29
+ __exportStar(require("./billing-meters"), exports);
29
30
  __exportStar(require("./usage-metadata"), exports);
30
31
  __exportStar(require("./schema"), exports);
31
32
  __exportStar(require("./types"), exports);
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  export declare const intervalSchema: z.ZodEnum<["month", "year"]>;
3
+ export declare const unitAmountSchema: z.ZodNumber;
4
+ export declare const aggregationSchema: z.ZodEnum<["sum", "lastDuringPeriod", "lastEver", "max"]>;
5
+ export declare const meterTypeSchema: z.ZodEnum<["payAsYouGo", "creditGrant"]>;
3
6
  export declare const priceSchema: z.ZodObject<{
4
7
  providerPriceId: z.ZodString;
5
8
  amount: z.ZodNumber;
@@ -142,6 +145,40 @@ export declare const addOnSchema: z.ZodObject<{
142
145
  prorationDisabled?: boolean | undefined;
143
146
  autoRechargeable?: boolean | undefined;
144
147
  }>;
148
+ export declare const meterSchema: z.ZodObject<{
149
+ id: z.ZodString;
150
+ name: z.ZodString;
151
+ description: z.ZodString;
152
+ providerProductId: z.ZodString;
153
+ currency: z.ZodEnum<["usd"]>;
154
+ unitAmount: z.ZodNumber;
155
+ interval: z.ZodEnum<["month", "year"]>;
156
+ aggregation: z.ZodEnum<["sum", "lastDuringPeriod", "lastEver", "max"]>;
157
+ meterType: z.ZodEnum<["payAsYouGo", "creditGrant"]>;
158
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ currency: "usd";
161
+ interval: "month" | "year";
162
+ id: string;
163
+ name: string;
164
+ description: string;
165
+ providerProductId: string;
166
+ unitAmount: number;
167
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
168
+ meterType: "creditGrant" | "payAsYouGo";
169
+ metadata?: Record<string, string> | undefined;
170
+ }, {
171
+ currency: "usd";
172
+ interval: "month" | "year";
173
+ id: string;
174
+ name: string;
175
+ description: string;
176
+ providerProductId: string;
177
+ unitAmount: number;
178
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
179
+ meterType: "creditGrant" | "payAsYouGo";
180
+ metadata?: Record<string, string> | undefined;
181
+ }>;
145
182
  export declare const billingVersionConfigSchema: z.ZodObject<{
146
183
  version: z.ZodEnum<["v4"]>;
147
184
  name: z.ZodString;
@@ -268,6 +305,40 @@ export declare const billingVersionConfigSchema: z.ZodObject<{
268
305
  prorationDisabled?: boolean | undefined;
269
306
  autoRechargeable?: boolean | undefined;
270
307
  }>>;
308
+ meters: z.ZodRecord<z.ZodString, z.ZodObject<{
309
+ id: z.ZodString;
310
+ name: z.ZodString;
311
+ description: z.ZodString;
312
+ providerProductId: z.ZodString;
313
+ currency: z.ZodEnum<["usd"]>;
314
+ unitAmount: z.ZodNumber;
315
+ interval: z.ZodEnum<["month", "year"]>;
316
+ aggregation: z.ZodEnum<["sum", "lastDuringPeriod", "lastEver", "max"]>;
317
+ meterType: z.ZodEnum<["payAsYouGo", "creditGrant"]>;
318
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
319
+ }, "strip", z.ZodTypeAny, {
320
+ currency: "usd";
321
+ interval: "month" | "year";
322
+ id: string;
323
+ name: string;
324
+ description: string;
325
+ providerProductId: string;
326
+ unitAmount: number;
327
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
328
+ meterType: "creditGrant" | "payAsYouGo";
329
+ metadata?: Record<string, string> | undefined;
330
+ }, {
331
+ currency: "usd";
332
+ interval: "month" | "year";
333
+ id: string;
334
+ name: string;
335
+ description: string;
336
+ providerProductId: string;
337
+ unitAmount: number;
338
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
339
+ meterType: "creditGrant" | "payAsYouGo";
340
+ metadata?: Record<string, string> | undefined;
341
+ }>>;
271
342
  isActive: z.ZodBoolean;
272
343
  createdAt: z.ZodString;
273
344
  }, "strip", z.ZodTypeAny, {
@@ -308,6 +379,18 @@ export declare const billingVersionConfigSchema: z.ZodObject<{
308
379
  prorationDisabled?: boolean | undefined;
309
380
  autoRechargeable?: boolean | undefined;
310
381
  }>;
382
+ meters: Record<string, {
383
+ currency: "usd";
384
+ interval: "month" | "year";
385
+ id: string;
386
+ name: string;
387
+ description: string;
388
+ providerProductId: string;
389
+ unitAmount: number;
390
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
391
+ meterType: "creditGrant" | "payAsYouGo";
392
+ metadata?: Record<string, string> | undefined;
393
+ }>;
311
394
  isActive: boolean;
312
395
  createdAt: string;
313
396
  }, {
@@ -348,6 +431,18 @@ export declare const billingVersionConfigSchema: z.ZodObject<{
348
431
  prorationDisabled?: boolean | undefined;
349
432
  autoRechargeable?: boolean | undefined;
350
433
  }>;
434
+ meters: Record<string, {
435
+ currency: "usd";
436
+ interval: "month" | "year";
437
+ id: string;
438
+ name: string;
439
+ description: string;
440
+ providerProductId: string;
441
+ unitAmount: number;
442
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
443
+ meterType: "creditGrant" | "payAsYouGo";
444
+ metadata?: Record<string, string> | undefined;
445
+ }>;
351
446
  isActive: boolean;
352
447
  createdAt: string;
353
448
  }>;
@@ -477,6 +572,40 @@ export declare const billingConfigSchema: z.ZodRecord<z.ZodEnum<["v4"]>, z.ZodOb
477
572
  prorationDisabled?: boolean | undefined;
478
573
  autoRechargeable?: boolean | undefined;
479
574
  }>>;
575
+ meters: z.ZodRecord<z.ZodString, z.ZodObject<{
576
+ id: z.ZodString;
577
+ name: z.ZodString;
578
+ description: z.ZodString;
579
+ providerProductId: z.ZodString;
580
+ currency: z.ZodEnum<["usd"]>;
581
+ unitAmount: z.ZodNumber;
582
+ interval: z.ZodEnum<["month", "year"]>;
583
+ aggregation: z.ZodEnum<["sum", "lastDuringPeriod", "lastEver", "max"]>;
584
+ meterType: z.ZodEnum<["payAsYouGo", "creditGrant"]>;
585
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
586
+ }, "strip", z.ZodTypeAny, {
587
+ currency: "usd";
588
+ interval: "month" | "year";
589
+ id: string;
590
+ name: string;
591
+ description: string;
592
+ providerProductId: string;
593
+ unitAmount: number;
594
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
595
+ meterType: "creditGrant" | "payAsYouGo";
596
+ metadata?: Record<string, string> | undefined;
597
+ }, {
598
+ currency: "usd";
599
+ interval: "month" | "year";
600
+ id: string;
601
+ name: string;
602
+ description: string;
603
+ providerProductId: string;
604
+ unitAmount: number;
605
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
606
+ meterType: "creditGrant" | "payAsYouGo";
607
+ metadata?: Record<string, string> | undefined;
608
+ }>>;
480
609
  isActive: z.ZodBoolean;
481
610
  createdAt: z.ZodString;
482
611
  }, "strip", z.ZodTypeAny, {
@@ -517,6 +646,18 @@ export declare const billingConfigSchema: z.ZodRecord<z.ZodEnum<["v4"]>, z.ZodOb
517
646
  prorationDisabled?: boolean | undefined;
518
647
  autoRechargeable?: boolean | undefined;
519
648
  }>;
649
+ meters: Record<string, {
650
+ currency: "usd";
651
+ interval: "month" | "year";
652
+ id: string;
653
+ name: string;
654
+ description: string;
655
+ providerProductId: string;
656
+ unitAmount: number;
657
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
658
+ meterType: "creditGrant" | "payAsYouGo";
659
+ metadata?: Record<string, string> | undefined;
660
+ }>;
520
661
  isActive: boolean;
521
662
  createdAt: string;
522
663
  }, {
@@ -557,6 +698,18 @@ export declare const billingConfigSchema: z.ZodRecord<z.ZodEnum<["v4"]>, z.ZodOb
557
698
  prorationDisabled?: boolean | undefined;
558
699
  autoRechargeable?: boolean | undefined;
559
700
  }>;
701
+ meters: Record<string, {
702
+ currency: "usd";
703
+ interval: "month" | "year";
704
+ id: string;
705
+ name: string;
706
+ description: string;
707
+ providerProductId: string;
708
+ unitAmount: number;
709
+ aggregation: "lastDuringPeriod" | "sum" | "lastEver" | "max";
710
+ meterType: "creditGrant" | "payAsYouGo";
711
+ metadata?: Record<string, string> | undefined;
712
+ }>;
560
713
  isActive: boolean;
561
714
  createdAt: string;
562
715
  }>>;
package/dist/schema.js CHANGED
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.billingConfigSchema = exports.billingVersionConfigSchema = exports.addOnSchema = exports.planSchema = exports.featureSchema = exports.priceSchema = exports.intervalSchema = void 0;
3
+ exports.billingConfigSchema = exports.billingVersionConfigSchema = exports.meterSchema = exports.addOnSchema = exports.planSchema = exports.featureSchema = exports.priceSchema = exports.meterTypeSchema = exports.aggregationSchema = exports.unitAmountSchema = exports.intervalSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const billing_versions_1 = require("./billing-versions");
6
6
  const billing_features_1 = require("./billing-features");
7
7
  exports.intervalSchema = zod_1.z.enum(['month', 'year']);
8
+ exports.unitAmountSchema = zod_1.z.number().int().min(1);
9
+ exports.aggregationSchema = zod_1.z.enum(['sum', 'lastDuringPeriod', 'lastEver', 'max']);
10
+ exports.meterTypeSchema = zod_1.z.enum(['payAsYouGo', 'creditGrant']);
8
11
  exports.priceSchema = zod_1.z.object({
9
12
  providerPriceId: zod_1.z.string(),
10
13
  amount: zod_1.z.number(),
@@ -35,12 +38,25 @@ exports.addOnSchema = zod_1.z.object({
35
38
  metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
36
39
  autoRechargeable: zod_1.z.boolean().optional(),
37
40
  });
41
+ exports.meterSchema = zod_1.z.object({
42
+ id: zod_1.z.string(),
43
+ name: zod_1.z.string(),
44
+ description: zod_1.z.string(),
45
+ providerProductId: zod_1.z.string(),
46
+ currency: zod_1.z.enum(['usd']),
47
+ unitAmount: exports.unitAmountSchema,
48
+ interval: exports.intervalSchema,
49
+ aggregation: exports.aggregationSchema,
50
+ meterType: exports.meterTypeSchema,
51
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
52
+ });
38
53
  exports.billingVersionConfigSchema = zod_1.z.object({
39
54
  version: zod_1.z.enum(billing_versions_1.BILLING_VERSIONS),
40
55
  name: zod_1.z.string(),
41
56
  description: zod_1.z.string(),
42
57
  plans: zod_1.z.record(zod_1.z.string(), exports.planSchema),
43
58
  addons: zod_1.z.record(zod_1.z.string(), exports.addOnSchema),
59
+ meters: zod_1.z.record(zod_1.z.string(), exports.meterSchema),
44
60
  isActive: zod_1.z.boolean(),
45
61
  createdAt: zod_1.z.string(),
46
62
  });
package/dist/types.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  import { BILLING_FEATURE_IDS } from './billing-features';
2
+ import { BILLING_METERS_IDS } from './billing-meters';
2
3
  import { BILLING_PLAN_IDS, BILLING_ADDON_IDS } from './billing-plans';
3
4
  import { BILLING_VERSIONS } from './billing-versions';
4
- import { billingVersionConfigSchema, billingConfigSchema, intervalSchema, priceSchema, planSchema, addOnSchema } from './schema';
5
+ import { billingVersionConfigSchema, billingConfigSchema, intervalSchema, unitAmountSchema, aggregationSchema, meterTypeSchema, priceSchema, planSchema, addOnSchema, meterSchema } from './schema';
5
6
  import { z } from 'zod';
6
7
  export type Interval = z.infer<typeof intervalSchema>;
8
+ export type UnitAmount = z.infer<typeof unitAmountSchema>;
9
+ export type Aggregation = z.infer<typeof aggregationSchema>;
10
+ export type MeterType = z.infer<typeof meterTypeSchema>;
7
11
  export type BillingFeatureId = (typeof BILLING_FEATURE_IDS)[number];
8
12
  export type BillingAddonId = (typeof BILLING_ADDON_IDS)[number];
9
13
  export type BillingPlanId = (typeof BILLING_PLAN_IDS)[number];
14
+ export type BillingMeterId = (typeof BILLING_METERS_IDS)[number];
10
15
  export type BillingFeatureDefinition = {
11
16
  name: string;
12
17
  description: string;
@@ -39,6 +44,17 @@ export type BillingAddonDefinition = {
39
44
  prorationDisabled?: boolean;
40
45
  metadata?: Record<string, string>;
41
46
  };
47
+ export type BillingMeterDefinition = {
48
+ id: BillingMeterId;
49
+ name: string;
50
+ description: string;
51
+ currency: 'usd';
52
+ unitAmount: UnitAmount;
53
+ interval: Interval;
54
+ aggregation: Aggregation;
55
+ meterType: MeterType;
56
+ metadata?: Record<string, string>;
57
+ };
42
58
  export type BillingVersionId = (typeof BILLING_VERSIONS)[number];
43
59
  export type BillingVersionDefinition = {
44
60
  version: BillingVersionId;
@@ -46,6 +62,7 @@ export type BillingVersionDefinition = {
46
62
  description: string;
47
63
  plans: Partial<Record<BillingPlanId, BillingPlanDefinition>>;
48
64
  addons: Partial<Record<BillingAddonId, BillingAddonDefinition>>;
65
+ meters: Partial<Record<BillingMeterId, BillingMeterDefinition>>;
49
66
  isActive: boolean;
50
67
  createdAt: string;
51
68
  };
@@ -55,3 +72,4 @@ export type BillingConfig = z.infer<typeof billingConfigSchema>;
55
72
  export type BillingPrice = z.infer<typeof priceSchema>;
56
73
  export type BillingPlan = z.infer<typeof planSchema>;
57
74
  export type BillingAddon = z.infer<typeof addOnSchema>;
75
+ export type BillingMeter = z.infer<typeof meterSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpinternal/const",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Shared constants for Skynet billing refactor (vendored copy of upstream packages/const)",
5
5
  "license": "UNLICENSED",
6
6
  "files": [