vibezcheck 0.1.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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -0
  3. package/dist/ai-sdk/index.d.mts +34 -0
  4. package/dist/ai-sdk/index.d.ts +34 -0
  5. package/dist/ai-sdk/index.js +982 -0
  6. package/dist/ai-sdk/index.js.map +1 -0
  7. package/dist/ai-sdk/index.mjs +944 -0
  8. package/dist/ai-sdk/index.mjs.map +1 -0
  9. package/dist/auth/index.d.mts +59 -0
  10. package/dist/auth/index.d.ts +59 -0
  11. package/dist/auth/index.js +129 -0
  12. package/dist/auth/index.js.map +1 -0
  13. package/dist/auth/index.mjs +90 -0
  14. package/dist/auth/index.mjs.map +1 -0
  15. package/dist/billing/index.d.mts +48 -0
  16. package/dist/billing/index.d.ts +48 -0
  17. package/dist/billing/index.js +128 -0
  18. package/dist/billing/index.js.map +1 -0
  19. package/dist/billing/index.mjs +90 -0
  20. package/dist/billing/index.mjs.map +1 -0
  21. package/dist/client-MJ3tl7bz.d.mts +44 -0
  22. package/dist/client-txrE0D_D.d.ts +44 -0
  23. package/dist/customers/index.d.mts +49 -0
  24. package/dist/customers/index.d.ts +49 -0
  25. package/dist/customers/index.js +158 -0
  26. package/dist/customers/index.js.map +1 -0
  27. package/dist/customers/index.mjs +119 -0
  28. package/dist/customers/index.mjs.map +1 -0
  29. package/dist/index.d.mts +92 -0
  30. package/dist/index.d.ts +92 -0
  31. package/dist/index.js +1458 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/index.mjs +1386 -0
  34. package/dist/index.mjs.map +1 -0
  35. package/dist/meter/index.d.mts +131 -0
  36. package/dist/meter/index.d.ts +131 -0
  37. package/dist/meter/index.js +895 -0
  38. package/dist/meter/index.js.map +1 -0
  39. package/dist/meter/index.mjs +843 -0
  40. package/dist/meter/index.mjs.map +1 -0
  41. package/dist/pricing/index.d.mts +40 -0
  42. package/dist/pricing/index.d.ts +40 -0
  43. package/dist/pricing/index.js +178 -0
  44. package/dist/pricing/index.js.map +1 -0
  45. package/dist/pricing/index.mjs +146 -0
  46. package/dist/pricing/index.mjs.map +1 -0
  47. package/dist/types-CSrSmsd1.d.mts +159 -0
  48. package/dist/types-CSrSmsd1.d.ts +159 -0
  49. package/package.json +131 -0
@@ -0,0 +1,119 @@
1
+ // src/customers/manager.ts
2
+ import Stripe from "stripe";
3
+
4
+ // src/customers/cache.ts
5
+ var CustomerCache = class {
6
+ cache = /* @__PURE__ */ new Map();
7
+ defaultTtlMs;
8
+ constructor(defaultTtlMs = 1e3 * 60 * 60) {
9
+ this.defaultTtlMs = defaultTtlMs;
10
+ }
11
+ get(key) {
12
+ const entry = this.cache.get(key);
13
+ if (!entry) return null;
14
+ if (Date.now() > entry.expiresAt) {
15
+ this.cache.delete(key);
16
+ return null;
17
+ }
18
+ return entry.customerId;
19
+ }
20
+ set(key, customerId, ttlMs) {
21
+ const expiresAt = Date.now() + (ttlMs ?? this.defaultTtlMs);
22
+ this.cache.set(key, { customerId, expiresAt });
23
+ }
24
+ delete(key) {
25
+ this.cache.delete(key);
26
+ }
27
+ clear() {
28
+ this.cache.clear();
29
+ }
30
+ };
31
+
32
+ // src/customers/manager.ts
33
+ var CustomerManager = class {
34
+ stripe;
35
+ cache;
36
+ constructor(options = {}) {
37
+ if (options.stripe) {
38
+ this.stripe = options.stripe;
39
+ } else {
40
+ const apiKey = options.apiKey || process.env.STRIPE_SECRET_KEY;
41
+ if (!apiKey) {
42
+ throw new Error("[vibezcheck] Stripe API key required for customer management.");
43
+ }
44
+ this.stripe = new Stripe(apiKey);
45
+ }
46
+ this.cache = new CustomerCache(options.cacheTtlMs);
47
+ }
48
+ /**
49
+ * Retrieves existing Stripe Customer or automatically provisions a new one
50
+ */
51
+ async getOrCreate(params) {
52
+ const cacheKey = params.userId || params.email;
53
+ if (cacheKey) {
54
+ const cachedId = this.cache.get(cacheKey);
55
+ if (cachedId) {
56
+ return {
57
+ id: cachedId,
58
+ isNew: false,
59
+ customer: { id: cachedId }
60
+ };
61
+ }
62
+ }
63
+ if (params.userId) {
64
+ try {
65
+ const searchResult = await this.stripe.customers.search({
66
+ query: `metadata['vibez_user_id']:'${params.userId}'`,
67
+ limit: 1
68
+ });
69
+ if (searchResult.data.length > 0) {
70
+ const customer = searchResult.data[0];
71
+ if (cacheKey) this.cache.set(cacheKey, customer.id);
72
+ if (params.email) this.cache.set(params.email, customer.id);
73
+ return { id: customer.id, isNew: false, customer };
74
+ }
75
+ } catch {
76
+ }
77
+ }
78
+ if (params.email) {
79
+ const listResult = await this.stripe.customers.list({
80
+ email: params.email,
81
+ limit: 1
82
+ });
83
+ if (listResult.data.length > 0) {
84
+ const customer = listResult.data[0];
85
+ if (cacheKey) this.cache.set(cacheKey, customer.id);
86
+ if (params.userId) this.cache.set(params.userId, customer.id);
87
+ return { id: customer.id, isNew: false, customer };
88
+ }
89
+ }
90
+ const newCustomer = await this.stripe.customers.create({
91
+ email: params.email,
92
+ name: params.name,
93
+ metadata: {
94
+ vibez_user_id: params.userId,
95
+ created_by: "vibezcheck",
96
+ ...params.metadata || {}
97
+ }
98
+ });
99
+ if (cacheKey) this.cache.set(cacheKey, newCustomer.id);
100
+ if (params.userId) this.cache.set(params.userId, newCustomer.id);
101
+ if (params.email) this.cache.set(params.email, newCustomer.id);
102
+ return { id: newCustomer.id, isNew: true, customer: newCustomer };
103
+ }
104
+ /**
105
+ * Clears in-memory resolution cache
106
+ */
107
+ clearCache() {
108
+ this.cache.clear();
109
+ }
110
+ };
111
+ function createCustomerManager(options = {}) {
112
+ return new CustomerManager(options);
113
+ }
114
+ export {
115
+ CustomerCache,
116
+ CustomerManager,
117
+ createCustomerManager
118
+ };
119
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/customers/manager.ts","../../src/customers/cache.ts"],"sourcesContent":["import Stripe from 'stripe';\nimport { CustomerCache } from './cache';\n\nexport interface GetOrCreateCustomerParams {\n userId: string;\n email?: string;\n name?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface CustomerManagerOptions {\n apiKey?: string;\n stripe?: Stripe;\n cacheTtlMs?: number;\n}\n\nexport class CustomerManager {\n private stripe: Stripe;\n private cache: CustomerCache;\n\n constructor(options: CustomerManagerOptions = {}) {\n if (options.stripe) {\n this.stripe = options.stripe;\n } else {\n const apiKey = options.apiKey || process.env.STRIPE_SECRET_KEY;\n if (!apiKey) {\n throw new Error('[vibezcheck] Stripe API key required for customer management.');\n }\n this.stripe = new Stripe(apiKey);\n }\n\n this.cache = new CustomerCache(options.cacheTtlMs);\n }\n\n /**\n * Retrieves existing Stripe Customer or automatically provisions a new one\n */\n public async getOrCreate(\n params: GetOrCreateCustomerParams\n ): Promise<{ id: string; isNew: boolean; customer: Stripe.Customer }> {\n const cacheKey = params.userId || params.email;\n if (cacheKey) {\n const cachedId = this.cache.get(cacheKey);\n if (cachedId) {\n return {\n id: cachedId,\n isNew: false,\n customer: { id: cachedId } as Stripe.Customer,\n };\n }\n }\n\n // 1. Search by userId in Stripe metadata\n if (params.userId) {\n try {\n const searchResult = await this.stripe.customers.search({\n query: `metadata['vibez_user_id']:'${params.userId}'`,\n limit: 1,\n });\n\n if (searchResult.data.length > 0) {\n const customer = searchResult.data[0];\n if (cacheKey) this.cache.set(cacheKey, customer.id);\n if (params.email) this.cache.set(params.email, customer.id);\n return { id: customer.id, isNew: false, customer };\n }\n } catch {\n // Fallback to email search if search query is unsupported or errors\n }\n }\n\n // 2. Search by email if provided\n if (params.email) {\n const listResult = await this.stripe.customers.list({\n email: params.email,\n limit: 1,\n });\n\n if (listResult.data.length > 0) {\n const customer = listResult.data[0];\n if (cacheKey) this.cache.set(cacheKey, customer.id);\n if (params.userId) this.cache.set(params.userId, customer.id);\n return { id: customer.id, isNew: false, customer };\n }\n }\n\n // 3. Create new Customer in Stripe\n const newCustomer = await this.stripe.customers.create({\n email: params.email,\n name: params.name,\n metadata: {\n vibez_user_id: params.userId,\n created_by: 'vibezcheck',\n ...(params.metadata || {}),\n },\n });\n\n if (cacheKey) this.cache.set(cacheKey, newCustomer.id);\n if (params.userId) this.cache.set(params.userId, newCustomer.id);\n if (params.email) this.cache.set(params.email, newCustomer.id);\n\n return { id: newCustomer.id, isNew: true, customer: newCustomer };\n }\n\n /**\n * Clears in-memory resolution cache\n */\n public clearCache(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Factory to create CustomerManager\n */\nexport function createCustomerManager(options: CustomerManagerOptions = {}): CustomerManager {\n return new CustomerManager(options);\n}\n","interface CacheEntry {\n customerId: string;\n expiresAt: number;\n}\n\n/**\n * In-memory Customer Resolution Cache with TTL\n */\nexport class CustomerCache {\n private cache = new Map<string, CacheEntry>();\n private readonly defaultTtlMs: number;\n\n constructor(defaultTtlMs: number = 1000 * 60 * 60) {\n // Default TTL: 1 hour\n this.defaultTtlMs = defaultTtlMs;\n }\n\n public get(key: string): string | null {\n const entry = this.cache.get(key);\n if (!entry) return null;\n\n if (Date.now() > entry.expiresAt) {\n this.cache.delete(key);\n return null;\n }\n\n return entry.customerId;\n }\n\n public set(key: string, customerId: string, ttlMs?: number): void {\n const expiresAt = Date.now() + (ttlMs ?? this.defaultTtlMs);\n this.cache.set(key, { customerId, expiresAt });\n }\n\n public delete(key: string): void {\n this.cache.delete(key);\n }\n\n public clear(): void {\n this.cache.clear();\n }\n}\n"],"mappings":";AAAA,OAAO,YAAY;;;ACQZ,IAAM,gBAAN,MAAoB;AAAA,EACjB,QAAQ,oBAAI,IAAwB;AAAA,EAC3B;AAAA,EAEjB,YAAY,eAAuB,MAAO,KAAK,IAAI;AAEjD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEO,IAAI,KAA4B;AACrC,UAAM,QAAQ,KAAK,MAAM,IAAI,GAAG;AAChC,QAAI,CAAC,MAAO,QAAO;AAEnB,QAAI,KAAK,IAAI,IAAI,MAAM,WAAW;AAChC,WAAK,MAAM,OAAO,GAAG;AACrB,aAA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AgB,OAAO;AACpC;","names":[]}
@@ -0,0 +1,92 @@
1
+ import { M as MeterOptions, S as StreamWrapOptions, C as CustomerParam, U as UsageEvent, a as UsageSummary } from './types-CSrSmsd1.mjs';
2
+ export { I as InferenceCost, b as ModelPricingRates, R as RecordUsageOptions, T as TokenUsage } from './types-CSrSmsd1.mjs';
3
+ import { V as VibezMeter } from './client-MJ3tl7bz.mjs';
4
+ export { c as createMeter } from './client-MJ3tl7bz.mjs';
5
+ import { CustomerManager } from './customers/index.mjs';
6
+ export { CustomerCache, CustomerManagerOptions, GetOrCreateCustomerParams, createCustomerManager } from './customers/index.mjs';
7
+ import { ApiKeyAuth } from './auth/index.mjs';
8
+ export { ApiKeyRecord, CreateApiKeyParams, VerifyAuthResult, createApiKeyAuth, extractAuthToken } from './auth/index.mjs';
9
+ import { BillingHelper } from './billing/index.mjs';
10
+ export { CreateCheckoutSessionParams, CreatePortalSessionParams, CreateTopUpSessionParams, createBillingHelper } from './billing/index.mjs';
11
+ export { AnthropicStreamAccumulator, ExtractedUsage, MeterBatcher, UsageDispatchedCallback, detectAndExtractUsage, extractAnthropicResponseUsage, extractGeminiResponseUsage, extractGenericResponseUsage, extractOpenAIResponseUsage, inspectOpenAIStreamChunk, trackTokens, wrapAnthropicStream, wrapGeminiStream, wrapOpenAIStream, wrapStream, wrapUniversalStream } from './meter/index.mjs';
12
+ export { CalculateCostParams, MODEL_PRICING_TABLE, calculateCost, calculateUsageCost, getModelPricing, normalizeModelKey, registerModelPricing } from './pricing/index.mjs';
13
+ export { WithBillingOptions, meteredModel, withBilling } from './ai-sdk/index.mjs';
14
+ import 'stripe';
15
+
16
+ /**
17
+ * VibezCheck Unified Client Configuration
18
+ */
19
+ interface VibezCheckConfig extends MeterOptions {
20
+ /** Auto-initialize CustomerManager (default: true if Stripe key present) */
21
+ autoCustomers?: boolean;
22
+ }
23
+ /**
24
+ * VibezCheck Unified Client Instance
25
+ */
26
+ declare class VibezCheckClient {
27
+ meter: VibezMeter;
28
+ customers?: CustomerManager;
29
+ auth?: ApiKeyAuth;
30
+ billing?: BillingHelper;
31
+ private stripeClient?;
32
+ constructor(config?: VibezCheckConfig);
33
+ /**
34
+ * 1-Line Zero-Latency Stream Wrapper for OpenAI, Anthropic, Gemini, etc.
35
+ */
36
+ wrapStream<T>(stream: T, options?: StreamWrapOptions): T;
37
+ /**
38
+ * Track token usage from a non-streaming response object
39
+ */
40
+ track(response: any, options?: {
41
+ customer?: CustomerParam;
42
+ model?: string;
43
+ }): UsageEvent | null;
44
+ /**
45
+ * 1-Line Wrapper for Vercel AI SDK LanguageModel
46
+ */
47
+ withBilling<T extends object>(model: T, options?: {
48
+ customer?: CustomerParam;
49
+ }): T;
50
+ /**
51
+ * 1-Line Universal Stream Responder for API Routes (Next.js, Express, Hono)
52
+ */
53
+ stream(params: {
54
+ model: string;
55
+ messages: Array<{
56
+ role: string;
57
+ content: string;
58
+ }>;
59
+ customer?: CustomerParam;
60
+ temperature?: number;
61
+ }): Promise<Response>;
62
+ /**
63
+ * Flush pending meter events (vital for serverless runtimes)
64
+ */
65
+ flush(): Promise<void>;
66
+ /**
67
+ * In-memory usage statistics
68
+ */
69
+ getUsageSummary(): UsageSummary;
70
+ }
71
+ /**
72
+ * Factory to create VibezCheck client
73
+ */
74
+ declare function createVibezCheck(config?: VibezCheckConfig): VibezCheckClient;
75
+ /**
76
+ * vibezcheck factory alias
77
+ */
78
+ declare const vibezcheck: typeof createVibezCheck;
79
+ /**
80
+ * vibescheck alias (tolerates spelling difference)
81
+ */
82
+ declare const vibescheck: typeof createVibezCheck;
83
+ /**
84
+ * Singleton instance initialized with process.env
85
+ */
86
+ declare const vibez: VibezCheckClient;
87
+ /**
88
+ * Singleton alias
89
+ */
90
+ declare const vibes: VibezCheckClient;
91
+
92
+ export { ApiKeyAuth, BillingHelper, CustomerManager, CustomerParam, MeterOptions, StreamWrapOptions, UsageEvent, UsageSummary, VibezCheckClient, type VibezCheckConfig, VibezMeter, createVibezCheck, vibes, vibescheck, vibez, vibezcheck };
@@ -0,0 +1,92 @@
1
+ import { M as MeterOptions, S as StreamWrapOptions, C as CustomerParam, U as UsageEvent, a as UsageSummary } from './types-CSrSmsd1.js';
2
+ export { I as InferenceCost, b as ModelPricingRates, R as RecordUsageOptions, T as TokenUsage } from './types-CSrSmsd1.js';
3
+ import { V as VibezMeter } from './client-txrE0D_D.js';
4
+ export { c as createMeter } from './client-txrE0D_D.js';
5
+ import { CustomerManager } from './customers/index.js';
6
+ export { CustomerCache, CustomerManagerOptions, GetOrCreateCustomerParams, createCustomerManager } from './customers/index.js';
7
+ import { ApiKeyAuth } from './auth/index.js';
8
+ export { ApiKeyRecord, CreateApiKeyParams, VerifyAuthResult, createApiKeyAuth, extractAuthToken } from './auth/index.js';
9
+ import { BillingHelper } from './billing/index.js';
10
+ export { CreateCheckoutSessionParams, CreatePortalSessionParams, CreateTopUpSessionParams, createBillingHelper } from './billing/index.js';
11
+ export { AnthropicStreamAccumulator, ExtractedUsage, MeterBatcher, UsageDispatchedCallback, detectAndExtractUsage, extractAnthropicResponseUsage, extractGeminiResponseUsage, extractGenericResponseUsage, extractOpenAIResponseUsage, inspectOpenAIStreamChunk, trackTokens, wrapAnthropicStream, wrapGeminiStream, wrapOpenAIStream, wrapStream, wrapUniversalStream } from './meter/index.js';
12
+ export { CalculateCostParams, MODEL_PRICING_TABLE, calculateCost, calculateUsageCost, getModelPricing, normalizeModelKey, registerModelPricing } from './pricing/index.js';
13
+ export { WithBillingOptions, meteredModel, withBilling } from './ai-sdk/index.js';
14
+ import 'stripe';
15
+
16
+ /**
17
+ * VibezCheck Unified Client Configuration
18
+ */
19
+ interface VibezCheckConfig extends MeterOptions {
20
+ /** Auto-initialize CustomerManager (default: true if Stripe key present) */
21
+ autoCustomers?: boolean;
22
+ }
23
+ /**
24
+ * VibezCheck Unified Client Instance
25
+ */
26
+ declare class VibezCheckClient {
27
+ meter: VibezMeter;
28
+ customers?: CustomerManager;
29
+ auth?: ApiKeyAuth;
30
+ billing?: BillingHelper;
31
+ private stripeClient?;
32
+ constructor(config?: VibezCheckConfig);
33
+ /**
34
+ * 1-Line Zero-Latency Stream Wrapper for OpenAI, Anthropic, Gemini, etc.
35
+ */
36
+ wrapStream<T>(stream: T, options?: StreamWrapOptions): T;
37
+ /**
38
+ * Track token usage from a non-streaming response object
39
+ */
40
+ track(response: any, options?: {
41
+ customer?: CustomerParam;
42
+ model?: string;
43
+ }): UsageEvent | null;
44
+ /**
45
+ * 1-Line Wrapper for Vercel AI SDK LanguageModel
46
+ */
47
+ withBilling<T extends object>(model: T, options?: {
48
+ customer?: CustomerParam;
49
+ }): T;
50
+ /**
51
+ * 1-Line Universal Stream Responder for API Routes (Next.js, Express, Hono)
52
+ */
53
+ stream(params: {
54
+ model: string;
55
+ messages: Array<{
56
+ role: string;
57
+ content: string;
58
+ }>;
59
+ customer?: CustomerParam;
60
+ temperature?: number;
61
+ }): Promise<Response>;
62
+ /**
63
+ * Flush pending meter events (vital for serverless runtimes)
64
+ */
65
+ flush(): Promise<void>;
66
+ /**
67
+ * In-memory usage statistics
68
+ */
69
+ getUsageSummary(): UsageSummary;
70
+ }
71
+ /**
72
+ * Factory to create VibezCheck client
73
+ */
74
+ declare function createVibezCheck(config?: VibezCheckConfig): VibezCheckClient;
75
+ /**
76
+ * vibezcheck factory alias
77
+ */
78
+ declare const vibezcheck: typeof createVibezCheck;
79
+ /**
80
+ * vibescheck alias (tolerates spelling difference)
81
+ */
82
+ declare const vibescheck: typeof createVibezCheck;
83
+ /**
84
+ * Singleton instance initialized with process.env
85
+ */
86
+ declare const vibez: VibezCheckClient;
87
+ /**
88
+ * Singleton alias
89
+ */
90
+ declare const vibes: VibezCheckClient;
91
+
92
+ export { ApiKeyAuth, BillingHelper, CustomerManager, CustomerParam, MeterOptions, StreamWrapOptions, UsageEvent, UsageSummary, VibezCheckClient, type VibezCheckConfig, VibezMeter, createVibezCheck, vibes, vibescheck, vibez, vibezcheck };