vibezcheck 0.5.4 → 0.5.5

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 (97) hide show
  1. package/bin/examples.js +8 -0
  2. package/dist/ai-sdk/index.d.mts +4 -4
  3. package/dist/ai-sdk/index.d.ts +4 -4
  4. package/dist/ai-sdk/index.js +4 -2
  5. package/dist/ai-sdk/index.js.map +1 -1
  6. package/dist/ai-sdk/index.mjs +4 -2
  7. package/dist/ai-sdk/index.mjs.map +1 -1
  8. package/dist/ai-sdk/middleware.d.mts +3 -3
  9. package/dist/ai-sdk/middleware.d.ts +3 -3
  10. package/dist/ai-sdk/middleware.js +4 -2
  11. package/dist/ai-sdk/middleware.js.map +1 -1
  12. package/dist/ai-sdk/middleware.mjs +4 -2
  13. package/dist/ai-sdk/middleware.mjs.map +1 -1
  14. package/dist/billing/index.d.mts +3 -3
  15. package/dist/billing/index.d.ts +3 -3
  16. package/dist/billing/index.js +4 -2
  17. package/dist/billing/index.js.map +1 -1
  18. package/dist/billing/index.mjs +4 -2
  19. package/dist/billing/index.mjs.map +1 -1
  20. package/dist/cli/index.js +231 -24
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/cli/index.mjs +255 -41
  23. package/dist/cli/index.mjs.map +1 -1
  24. package/dist/{client-CbuXmoXz.d.mts → client-BzwEHQlC.d.mts} +1 -1
  25. package/dist/{client-BORmJy8s.d.ts → client-CbO6vLUe.d.ts} +1 -1
  26. package/dist/compat/stripe-meter.d.mts +3 -3
  27. package/dist/compat/stripe-meter.d.ts +3 -3
  28. package/dist/compat/stripe-meter.js +4 -2
  29. package/dist/compat/stripe-meter.js.map +1 -1
  30. package/dist/compat/stripe-meter.mjs +4 -2
  31. package/dist/compat/stripe-meter.mjs.map +1 -1
  32. package/dist/compat/stripe-provider.js +4 -2
  33. package/dist/compat/stripe-provider.js.map +1 -1
  34. package/dist/compat/stripe-provider.mjs +4 -2
  35. package/dist/compat/stripe-provider.mjs.map +1 -1
  36. package/dist/compat/token-meter.js +4 -2
  37. package/dist/compat/token-meter.js.map +1 -1
  38. package/dist/compat/token-meter.mjs +4 -2
  39. package/dist/compat/token-meter.mjs.map +1 -1
  40. package/dist/customers/index.d.mts +1 -1
  41. package/dist/customers/index.d.ts +1 -1
  42. package/dist/index.d.mts +5 -5
  43. package/dist/index.d.ts +5 -5
  44. package/dist/index.js +4 -2
  45. package/dist/index.js.map +1 -1
  46. package/dist/index.mjs +4 -2
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/meter/index.d.mts +2 -2
  49. package/dist/meter/index.d.ts +2 -2
  50. package/dist/meter/index.js +4 -2
  51. package/dist/meter/index.js.map +1 -1
  52. package/dist/meter/index.mjs +4 -2
  53. package/dist/meter/index.mjs.map +1 -1
  54. package/dist/pricing/index.d.mts +1 -1
  55. package/dist/pricing/index.d.ts +1 -1
  56. package/dist/pricing/index.js +2 -0
  57. package/dist/pricing/index.js.map +1 -1
  58. package/dist/pricing/index.mjs +2 -0
  59. package/dist/pricing/index.mjs.map +1 -1
  60. package/dist/react/index.d.mts +1 -1
  61. package/dist/react/index.d.ts +1 -1
  62. package/dist/react/index.js +14 -0
  63. package/dist/react/index.js.map +1 -1
  64. package/dist/react/index.mjs +14 -0
  65. package/dist/react/index.mjs.map +1 -1
  66. package/dist/{types-6P71CXAD.d.mts → types-Btf2OhIr.d.mts} +6 -0
  67. package/dist/{types-6P71CXAD.d.ts → types-Btf2OhIr.d.ts} +6 -0
  68. package/dist/{with-billing-DndWGxL8.d.mts → with-billing-BEqiJtCR.d.mts} +2 -2
  69. package/dist/{with-billing-Bj6Ya_Iy.d.ts → with-billing-D7QRoNHM.d.ts} +2 -2
  70. package/examples/01-local-cost-meter.ts +63 -0
  71. package/examples/02-vercel-ai-sdk.ts +43 -0
  72. package/examples/03-native-openai-stream.ts +40 -0
  73. package/examples/04-claude-thinking.ts +41 -0
  74. package/examples/05-reasoning-agent-stream.ts +54 -0
  75. package/examples/nextjs-app-router-openai/.env.example +5 -0
  76. package/examples/nextjs-app-router-openai/README.md +29 -0
  77. package/examples/nextjs-app-router-openai/app/api/chat/route.ts +22 -0
  78. package/examples/nextjs-app-router-openai/app/globals.css +21 -0
  79. package/examples/nextjs-app-router-openai/app/layout.tsx +21 -0
  80. package/examples/nextjs-app-router-openai/app/page.tsx +43 -0
  81. package/examples/nextjs-app-router-openai/next.config.mjs +7 -0
  82. package/examples/nextjs-app-router-openai/package.json +31 -0
  83. package/examples/nextjs-app-router-openai/postcss.config.mjs +9 -0
  84. package/examples/nextjs-app-router-openai/tailwind.config.ts +13 -0
  85. package/examples/nextjs-app-router-openai/tsconfig.json +27 -0
  86. package/examples/nextjs-saas-starter/README.md +29 -0
  87. package/examples/nextjs-saas-starter/app/api/chat/route.ts +65 -0
  88. package/examples/nextjs-saas-starter/app/api/checkout/route.ts +51 -0
  89. package/examples/nextjs-saas-starter/app/globals.css +14 -0
  90. package/examples/nextjs-saas-starter/app/layout.tsx +24 -0
  91. package/examples/nextjs-saas-starter/app/page.tsx +326 -0
  92. package/examples/nextjs-saas-starter/next.config.mjs +7 -0
  93. package/examples/nextjs-saas-starter/package.json +34 -0
  94. package/examples/nextjs-saas-starter/postcss.config.mjs +9 -0
  95. package/examples/nextjs-saas-starter/tailwind.config.ts +20 -0
  96. package/examples/nextjs-saas-starter/tsconfig.json +27 -0
  97. package/package.json +5 -3
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Forward execution with 'examples' as default command
4
+ if (!process.argv.slice(2).some(arg => ['examples', 'example'].includes(arg))) {
5
+ process.argv.splice(2, 0, 'examples');
6
+ }
7
+
8
+ require('../dist/cli/index.js');
@@ -1,7 +1,7 @@
1
- import { W as WithBillingOptions } from '../with-billing-DndWGxL8.mjs';
2
- export { m as meteredModel, w as withBilling } from '../with-billing-DndWGxL8.mjs';
3
- import { C as CustomerParam } from '../types-6P71CXAD.mjs';
4
- import { V as VibezMeter } from '../client-CbuXmoXz.mjs';
1
+ import { W as WithBillingOptions } from '../with-billing-BEqiJtCR.mjs';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-BEqiJtCR.mjs';
3
+ import { C as CustomerParam } from '../types-Btf2OhIr.mjs';
4
+ import { V as VibezMeter } from '../client-BzwEHQlC.mjs';
5
5
  import 'stripe';
6
6
 
7
7
  interface VibezCheckModelOptions extends WithBillingOptions {
@@ -1,7 +1,7 @@
1
- import { W as WithBillingOptions } from '../with-billing-Bj6Ya_Iy.js';
2
- export { m as meteredModel, w as withBilling } from '../with-billing-Bj6Ya_Iy.js';
3
- import { C as CustomerParam } from '../types-6P71CXAD.js';
4
- import { V as VibezMeter } from '../client-BORmJy8s.js';
1
+ import { W as WithBillingOptions } from '../with-billing-D7QRoNHM.js';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-D7QRoNHM.js';
3
+ import { C as CustomerParam } from '../types-Btf2OhIr.js';
4
+ import { V as VibezMeter } from '../client-CbO6vLUe.js';
5
5
  import 'stripe';
6
6
 
7
7
  interface VibezCheckModelOptions extends WithBillingOptions {
@@ -844,8 +844,10 @@ function calculateCost(params) {
844
844
  outputCostUSD: Number(outputCostUSD.toFixed(8)),
845
845
  reasoningCostUSD: reasoningTokens > 0n ? Number(reasoningCostUSD.toFixed(8)) : void 0,
846
846
  cachedDiscountUSD: cachedTokens > 0n ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
847
+ savingsUSD: cachedTokens > 0n ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
847
848
  totalUSD: Number(totalUSD.toFixed(8)),
848
849
  wholesaleTotalUSD: Number(wholesaleTotalUSD.toFixed(8)),
850
+ wholesaleUSD: Number(wholesaleTotalUSD.toFixed(8)),
849
851
  billedUSD: Number(billedUSD.toFixed(8)),
850
852
  profitUSD: Number(profitUSD.toFixed(8)),
851
853
  retailUSD: retailUSD !== void 0 ? Number(retailUSD.toFixed(8)) : void 0,
@@ -1067,7 +1069,7 @@ var VibezMeter = class {
1067
1069
  stripeClient;
1068
1070
  markupMultiplier;
1069
1071
  constructor(options = {}) {
1070
- this.markupMultiplier = options.markupMultiplier;
1072
+ this.markupMultiplier = options.pricing?.margin ?? options.markupMultiplier;
1071
1073
  if (options.stripe) {
1072
1074
  this.stripeClient = options.stripe;
1073
1075
  } else if (options.apiKey || process.env.STRIPE_SECRET_KEY) {
@@ -1075,7 +1077,7 @@ var VibezMeter = class {
1075
1077
  this.stripeClient = new import_stripe.default(key, {
1076
1078
  appInfo: {
1077
1079
  name: "vibezcheck",
1078
- version: "0.5.3",
1080
+ version: "0.5.5",
1079
1081
  url: "https://vibezcheck.xyz"
1080
1082
  }
1081
1083
  });