codebuff 1.0.243 → 1.0.245

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 (59) hide show
  1. package/dist/cli.js +29 -14
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client.d.ts +15 -7
  4. package/dist/client.js +54 -38
  5. package/dist/client.js.map +1 -1
  6. package/dist/code-map/tsconfig.tsbuildinfo +1 -1
  7. package/dist/common/actions.d.ts +86 -104
  8. package/dist/common/actions.js +0 -1
  9. package/dist/common/actions.js.map +1 -1
  10. package/dist/common/bigquery/client.js +29 -10
  11. package/dist/common/bigquery/client.js.map +1 -1
  12. package/dist/common/constants.d.ts +13 -32
  13. package/dist/common/constants.js +23 -72
  14. package/dist/common/constants.js.map +1 -1
  15. package/dist/common/env.mjs +1 -0
  16. package/dist/common/env.mjs.map +1 -1
  17. package/dist/common/types/usage.d.ts +4 -7
  18. package/dist/common/types/usage.js +0 -1
  19. package/dist/common/types/usage.js.map +1 -1
  20. package/dist/common/util/currency.d.ts +14 -0
  21. package/dist/common/util/currency.js +23 -0
  22. package/dist/common/util/currency.js.map +1 -0
  23. package/dist/common/websockets/websocket-schema.d.ts +172 -202
  24. package/dist/types.d.ts +6 -0
  25. package/dist/utils/analytics.js +9 -3
  26. package/dist/utils/analytics.js.map +1 -1
  27. package/dist/utils/logger.js +54 -38
  28. package/dist/utils/logger.js.map +1 -1
  29. package/dist/utils/terminal.d.ts +3 -0
  30. package/dist/utils/terminal.js +26 -19
  31. package/dist/utils/terminal.js.map +1 -1
  32. package/dist/utils/tool-renderers.js +6 -6
  33. package/dist/utils/tool-renderers.js.map +1 -1
  34. package/package.json +4 -2
  35. package/dist/common/billing/auto-topup.d.ts +0 -8
  36. package/dist/common/billing/auto-topup.js +0 -192
  37. package/dist/common/billing/auto-topup.js.map +0 -1
  38. package/dist/common/billing/balance-calculator.d.ts +0 -57
  39. package/dist/common/billing/balance-calculator.js +0 -218
  40. package/dist/common/billing/balance-calculator.js.map +0 -1
  41. package/dist/common/billing/conversion.d.ts +0 -9
  42. package/dist/common/billing/conversion.js +0 -20
  43. package/dist/common/billing/conversion.js.map +0 -1
  44. package/dist/common/billing/credit-conversion.d.ts +0 -24
  45. package/dist/common/billing/credit-conversion.js +0 -48
  46. package/dist/common/billing/credit-conversion.js.map +0 -1
  47. package/dist/common/billing/grant-credits.d.ts +0 -43
  48. package/dist/common/billing/grant-credits.js +0 -266
  49. package/dist/common/billing/grant-credits.js.map +0 -1
  50. package/dist/common/billing/plans.d.ts +0 -13
  51. package/dist/common/billing/plans.js +0 -44
  52. package/dist/common/billing/plans.js.map +0 -1
  53. package/dist/common/json-config/__tests__/__snapshots__/stringify-schema.test.js.snap +0 -66
  54. package/dist/common/types/plan.d.ts +0 -24
  55. package/dist/common/types/plan.js +0 -3
  56. package/dist/common/types/plan.js.map +0 -1
  57. package/dist/common/util/server/referral.d.ts +0 -14
  58. package/dist/common/util/server/referral.js +0 -85
  59. package/dist/common/util/server/referral.js.map +0 -1
@@ -1,266 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getPreviousFreeGrantAmount = getPreviousFreeGrantAmount;
30
- exports.calculateTotalReferralBonus = calculateTotalReferralBonus;
31
- exports.processAndGrantCredit = processAndGrantCredit;
32
- exports.revokeGrantByOperationId = revokeGrantByOperationId;
33
- exports.triggerMonthlyResetAndGrant = triggerMonthlyResetAndGrant;
34
- const db_1 = __importDefault(require("../db"));
35
- const schema = __importStar(require("../db/schema"));
36
- const logger_1 = require("../util/logger");
37
- const grant_priorities_1 = require("../constants/grant-priorities");
38
- const drizzle_orm_1 = require("drizzle-orm");
39
- const string_1 = require("../util/string");
40
- const constants_1 = require("../constants");
41
- const promise_1 = require("../util/promise");
42
- const sync_failure_1 = require("../util/sync-failure");
43
- const dates_1 = require("../util/dates");
44
- const plans_1 = require("./plans");
45
- const transaction_1 = require("../db/transaction");
46
- /**
47
- * Finds the amount of the most recent expired 'free' grant for a user.
48
- * Finds the amount of the most recent expired 'free' grant for a user,
49
- * excluding migration grants (operation_id starting with 'migration-').
50
- * If there is a previous grant, caps the amount at 2000 credits.
51
- * If no expired 'free' grant is found, returns the default free limit.
52
- * @param userId The ID of the user.
53
- * @returns The amount of the last expired free grant (capped at 2000) or the default.
54
- */
55
- async function getPreviousFreeGrantAmount(userId) {
56
- const now = new Date();
57
- const lastExpiredFreeGrant = await db_1.default
58
- .select({
59
- principal: schema.creditLedger.principal,
60
- })
61
- .from(schema.creditLedger)
62
- .where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema.creditLedger.user_id, userId), (0, drizzle_orm_1.eq)(schema.creditLedger.type, 'free'), (0, drizzle_orm_1.lte)(schema.creditLedger.expires_at, now) // Grant has expired
63
- ))
64
- .orderBy((0, drizzle_orm_1.desc)(schema.creditLedger.expires_at)) // Most recent expiry first
65
- .limit(1);
66
- if (lastExpiredFreeGrant.length > 0) {
67
- // TODO: remove this once it's past May 22nd, after all users have been migrated over
68
- const cappedAmount = Math.min(lastExpiredFreeGrant[0].principal, 2000);
69
- logger_1.logger.debug({ userId, amount: lastExpiredFreeGrant[0].principal }, 'Found previous expired free grant amount.');
70
- return cappedAmount;
71
- }
72
- else {
73
- logger_1.logger.debug({ userId, defaultAmount: constants_1.CREDITS_USAGE_LIMITS.FREE }, 'No previous expired free grant found. Using default.');
74
- return constants_1.CREDITS_USAGE_LIMITS.FREE; // Default if no previous grant found
75
- }
76
- }
77
- /**
78
- * Calculates the total referral bonus credits a user should receive based on
79
- * their referral history (both as referrer and referred).
80
- * @param userId The ID of the user.
81
- * @returns The total referral bonus credits earned.
82
- */
83
- async function calculateTotalReferralBonus(userId) {
84
- try {
85
- const result = await db_1.default
86
- .select({
87
- totalCredits: (0, drizzle_orm_1.sql) `COALESCE(SUM(${schema.referral.credits}), 0)`,
88
- })
89
- .from(schema.referral)
90
- .where((0, drizzle_orm_1.or)((0, drizzle_orm_1.eq)(schema.referral.referrer_id, userId), (0, drizzle_orm_1.eq)(schema.referral.referred_id, userId)));
91
- const totalBonus = parseInt(result[0]?.totalCredits ?? '0');
92
- logger_1.logger.debug({ userId, totalBonus }, 'Calculated total referral bonus.');
93
- return totalBonus;
94
- }
95
- catch (error) {
96
- logger_1.logger.error({ userId, error }, 'Error calculating total referral bonus. Returning 0.');
97
- return 0;
98
- }
99
- }
100
- /**
101
- * Core grant operation wrapped in a single DB transaction.
102
- */
103
- async function grantCreditOperation(userId, amount, type, description, expiresAt, operationId) {
104
- await db_1.default.transaction(async (tx) => {
105
- const now = new Date();
106
- // First check for any negative balances
107
- const negativeGrants = await tx
108
- .select()
109
- .from(schema.creditLedger)
110
- .where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema.creditLedger.user_id, userId), (0, drizzle_orm_1.or)((0, drizzle_orm_1.isNull)(schema.creditLedger.expires_at), (0, drizzle_orm_1.gt)(schema.creditLedger.expires_at, now))))
111
- .then((grants) => grants.filter((g) => g.balance < 0));
112
- if (negativeGrants.length > 0) {
113
- const totalDebt = negativeGrants.reduce((sum, g) => sum + Math.abs(g.balance), 0);
114
- for (const grant of negativeGrants) {
115
- await tx
116
- .update(schema.creditLedger)
117
- .set({ balance: 0 })
118
- .where((0, drizzle_orm_1.eq)(schema.creditLedger.operation_id, grant.operation_id));
119
- }
120
- const remainingAmount = Math.max(0, amount - totalDebt);
121
- if (remainingAmount > 0) {
122
- await tx.insert(schema.creditLedger).values({
123
- operation_id: operationId,
124
- user_id: userId,
125
- principal: amount,
126
- balance: remainingAmount,
127
- type,
128
- description: totalDebt > 0
129
- ? `${description} (${totalDebt} credits used to clear existing debt)`
130
- : description,
131
- priority: grant_priorities_1.GRANT_PRIORITIES[type],
132
- expires_at: expiresAt,
133
- created_at: now,
134
- });
135
- }
136
- }
137
- else {
138
- // No debt - create grant normally
139
- await tx.insert(schema.creditLedger).values({
140
- operation_id: operationId,
141
- user_id: userId,
142
- principal: amount,
143
- balance: amount,
144
- type,
145
- description,
146
- priority: grant_priorities_1.GRANT_PRIORITIES[type],
147
- expires_at: expiresAt,
148
- created_at: now,
149
- });
150
- }
151
- logger_1.logger.info({ userId, operationId, type, amount, expiresAt }, 'Created new credit grant');
152
- });
153
- }
154
- /**
155
- * Processes a credit grant request with retries and failure logging.
156
- */
157
- async function processAndGrantCredit(userId, amount, type, description, expiresAt, operationId) {
158
- try {
159
- await (0, promise_1.withRetry)(() => grantCreditOperation(userId, amount, type, description, expiresAt, operationId), {
160
- maxRetries: 3,
161
- retryIf: () => true,
162
- onRetry: (error, attempt) => {
163
- logger_1.logger.warn({ operationId, attempt, error }, `processAndGrantCredit retry ${attempt}`);
164
- },
165
- });
166
- }
167
- catch (error) {
168
- await (0, sync_failure_1.logSyncFailure)(operationId, error.message, 'internal');
169
- logger_1.logger.error({ operationId, error }, 'processAndGrantCredit failed after retries, logged to sync_failure');
170
- throw error;
171
- }
172
- }
173
- /**
174
- * Revokes credits from a specific grant by operation ID.
175
- * This sets the balance to 0 and updates the description to indicate a refund.
176
- *
177
- * @param operationId The operation ID of the grant to revoke
178
- * @param reason The reason for revoking the credits (e.g. refund)
179
- * @returns true if the grant was found and revoked, false otherwise
180
- */
181
- async function revokeGrantByOperationId(operationId, reason) {
182
- return await db_1.default.transaction(async (tx) => {
183
- const grant = await tx.query.creditLedger.findFirst({
184
- where: (0, drizzle_orm_1.eq)(schema.creditLedger.operation_id, operationId),
185
- });
186
- if (!grant) {
187
- logger_1.logger.warn({ operationId }, 'Attempted to revoke non-existent grant');
188
- return false;
189
- }
190
- if (grant.balance < 0) {
191
- logger_1.logger.warn({ operationId, currentBalance: grant.balance }, 'Cannot revoke grant with negative balance - user has already spent these credits');
192
- return false;
193
- }
194
- await tx
195
- .update(schema.creditLedger)
196
- .set({
197
- principal: 0,
198
- balance: 0,
199
- description: `${grant.description} (Revoked: ${reason})`,
200
- })
201
- .where((0, drizzle_orm_1.eq)(schema.creditLedger.operation_id, operationId));
202
- logger_1.logger.info({
203
- operationId,
204
- userId: grant.user_id,
205
- revokedAmount: grant.balance,
206
- reason,
207
- }, 'Revoked credit grant');
208
- return true;
209
- });
210
- }
211
- /**
212
- * Checks if a user's quota needs to be reset, and if so:
213
- * 1. Calculates their new monthly grant amount
214
- * 2. Issues the grant with the appropriate expiry
215
- * 3. Updates their next_quota_reset date
216
- * All of this is done in a single transaction with SERIALIZABLE isolation
217
- * to prevent concurrent resets from creating duplicate grants.
218
- *
219
- * @param userId The ID of the user
220
- * @returns The effective quota reset date (either existing or new)
221
- */
222
- async function triggerMonthlyResetAndGrant(userId) {
223
- return await (0, transaction_1.withSerializableTransaction)(async (tx) => {
224
- const now = new Date();
225
- // Get user's current reset date and plan
226
- const user = await tx.query.user.findFirst({
227
- where: (0, drizzle_orm_1.eq)(schema.user.id, userId),
228
- columns: {
229
- next_quota_reset: true,
230
- stripe_price_id: true,
231
- },
232
- });
233
- if (!user) {
234
- throw new Error(`User ${userId} not found`);
235
- }
236
- const currentResetDate = user.next_quota_reset;
237
- // If reset date is in the future, no action needed
238
- if (currentResetDate && currentResetDate > now) {
239
- return currentResetDate;
240
- }
241
- // Calculate new reset date
242
- const newResetDate = (0, dates_1.getNextQuotaReset)(currentResetDate);
243
- // Calculate grant amount based on user's plan
244
- const currentPlan = (0, plans_1.getPlanFromPriceId)(user.stripe_price_id, process.env.STRIPE_PRO_PRICE_ID, process.env.STRIPE_MOAR_PRO_PRICE_ID);
245
- const grantAmount = await (0, plans_1.getMonthlyGrantForPlan)(currentPlan, userId);
246
- // Generate a unique operation ID for this grant
247
- const operationId = `free-${userId}-${(0, string_1.generateCompactId)()}`;
248
- // Update the user's next reset date first
249
- await tx
250
- .update(schema.user)
251
- .set({ next_quota_reset: newResetDate })
252
- .where((0, drizzle_orm_1.eq)(schema.user.id, userId));
253
- // Then issue the grant
254
- await grantCreditOperation(userId, grantAmount, 'free', 'Monthly free credits', newResetDate, // Grant expires at next reset
255
- operationId);
256
- logger_1.logger.info({
257
- userId,
258
- operationId,
259
- grantAmount,
260
- newResetDate,
261
- previousResetDate: currentResetDate,
262
- }, 'Processed monthly credit grant and reset');
263
- return newResetDate;
264
- }, { userId });
265
- }
266
- //# sourceMappingURL=grant-credits.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grant-credits.js","sourceRoot":"","sources":["../../src/billing/grant-credits.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,gEAkCC;AAQD,kEA0BC;AAoFD,sDAsCC;AAUD,4DA2CC;AAaD,kEAwEC;AAlWD,+CAAsB;AACtB,qDAAsC;AAEtC,2CAAuC;AAEvC,oEAAgE;AAChE,6CAAqE;AACrE,2CAAkD;AAClD,4CAAmD;AACnD,6CAA2C;AAC3C,uDAAqD;AACrD,yCAAiD;AACjD,mCAAoE;AACpE,mDAA+D;AAI/D;;;;;;;;GAQG;AACI,KAAK,UAAU,0BAA0B,CAC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W,GAAG,QAAQ,MAAM,IAAI,IAAA,0BAAiB,GAAE,EAAE,CAAA;QAE3D,0CAA0C;QAC1C,MAAM,EAAE;aACL,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;aACnB,GAAG,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC;aACvC,KAAK,CAAC,IAAA,gBAAE,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAA;QAEpC,uBAAuB;QACvB,MAAM,oBAAoB,CACxB,MAAM,EACN,WAAW,EACX,MAAM,EACN,sBAAsB,EACtB,YAAY,EAAE,8BAA8B;QAC5C,WAAW,CACZ,CAAA;QAED,eAAM,CAAC,IAAI,CACT;YACE,MAAM;YACN,WAAW;YACX,WAAW;YACX,YAAY;YACZ,iBAAiB,EAAE,gBAAgB;SACpC,EACD,0CAA0C,CAC3C,CAAA;QAED,OAAO,YAAY,CAAA;IACrB,CAAC,EACD,EAAE,MAAM,EAAE,CACX,CAAA;AACH,CAAC"}
@@ -1,13 +0,0 @@
1
- import { UsageLimits } from '../constants';
2
- /**
3
- * Determines the user's plan based on their Stripe Price ID.
4
- * Defaults to FREE if no matching price ID is found.
5
- * NOTE: Requires backend environment variables for Stripe Price IDs.
6
- */
7
- export declare function getPlanFromPriceId(priceId: string | null | undefined, proPriceId?: string, moarProPriceId?: string): UsageLimits;
8
- /**
9
- * Gets the total monthly credit grant amount for a given plan and user.
10
- * This includes both their plan's base credits and any referral bonuses,
11
- * combined into a single number.
12
- */
13
- export declare function getMonthlyGrantForPlan(plan: UsageLimits, userId?: string): Promise<number>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPlanFromPriceId = getPlanFromPriceId;
4
- exports.getMonthlyGrantForPlan = getMonthlyGrantForPlan;
5
- const constants_1 = require("../constants");
6
- const grant_credits_1 = require("./grant-credits");
7
- const logger_1 = require("../util/logger");
8
- /**
9
- * Determines the user's plan based on their Stripe Price ID.
10
- * Defaults to FREE if no matching price ID is found.
11
- * NOTE: Requires backend environment variables for Stripe Price IDs.
12
- */
13
- function getPlanFromPriceId(priceId, proPriceId, moarProPriceId) {
14
- if (!priceId) {
15
- return constants_1.UsageLimits.FREE;
16
- }
17
- if (proPriceId && priceId === proPriceId) {
18
- return constants_1.UsageLimits.PRO;
19
- }
20
- if (moarProPriceId && priceId === moarProPriceId) {
21
- return constants_1.UsageLimits.MOAR_PRO;
22
- }
23
- return constants_1.UsageLimits.FREE; // Default to FREE for unknown or non-matching IDs
24
- }
25
- /**
26
- * Gets the total monthly credit grant amount for a given plan and user.
27
- * This includes both their plan's base credits and any referral bonuses,
28
- * combined into a single number.
29
- */
30
- async function getMonthlyGrantForPlan(plan, userId) {
31
- // If no userId provided, just return the plan's base limit
32
- if (!userId) {
33
- return constants_1.PLAN_CONFIGS[plan]?.limit ?? constants_1.PLAN_CONFIGS[constants_1.UsageLimits.FREE].limit;
34
- }
35
- // Calculate total grant by adding base plan amount and referral bonuses
36
- const [freeGrantAmount, referralBonus] = await Promise.all([
37
- (0, grant_credits_1.getPreviousFreeGrantAmount)(userId),
38
- (0, grant_credits_1.calculateTotalReferralBonus)(userId),
39
- ]);
40
- const totalGrant = freeGrantAmount + referralBonus;
41
- logger_1.logger.debug({ userId, plan, freeGrantAmount, referralBonus, totalGrant }, 'Calculated total monthly grant amount');
42
- return totalGrant;
43
- }
44
- //# sourceMappingURL=plans.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plans.js","sourceRoot":"","sources":["../../src/billing/plans.ts"],"names":[],"mappings":";;AASA,gDAiBC;AAOD,wDAqBC;AAtDD,4CAAwD;AACxD,mDAAyF;AACzF,2CAAuC;AAEvC;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,OAAkC,EAClC,UAAmB,EACnB,cAAuB;IAEvB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,uBAAW,CAAC,IAAI,CAAA;IACzB,CAAC;IAED,IAAI,UAAU,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QACzC,OAAO,uBAAW,CAAC,GAAG,CAAA;IACxB,CAAC;IACD,IAAI,cAAc,IAAI,OAAO,KAAK,cAAc,EAAE,CAAC;QACjD,OAAO,uBAAW,CAAC,QAAQ,CAAA;IAC7B,CAAC;IAED,OAAO,uBAAW,CAAC,IAAI,CAAA,CAAC,kDAAkD;AAC5E,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAC1C,IAAiB,EACjB,MAAe;IAEf,2DAA2D;IAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,wBAAY,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,wBAAY,CAAC,uBAAW,CAAC,IAAI,CAAC,CAAC,KAAK,CAAA;IAC1E,CAAC;IAED,wEAAwE;IACxE,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzD,IAAA,0CAA0B,EAAC,MAAM,CAAC;QAClC,IAAA,2CAA2B,EAAC,MAAM,CAAC;KACpC,CAAC,CAAA;IAEF,MAAM,UAAU,GAAG,eAAe,GAAG,aAAa,CAAA;IAClD,eAAM,CAAC,KAAK,CACV,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,EAC5D,uCAAuC,CACxC,CAAA;IACD,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -1,66 +0,0 @@
1
- // Bun Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`stringifySchemaForLLM should correctly stringify StartupProcessSchema 1`] = `
4
- "Schema: StartupProcessSchema
5
- Object (Defines a single startup process. This validates the structure of an object representing a command that Codebuff can run automatically when it starts.) {
6
- name: String (A user-friendly name for the process.)
7
- command: String (The actual shell command to execute.)
8
- cwd: Optional<String> (The working directory from which to run the command.)
9
- enabled: Default<Optional<Boolean>> (default: true) (Whether this process should be run.)
10
- stdoutFile: Optional<String> (Path to write process stdout output. If not specified, output is not stored.)
11
- stderrFile: Optional<String> (Path to write process stderr output. If not specified, output is not stored.)
12
- }"
13
- `;
14
-
15
- exports[`stringifySchemaForLLM should correctly stringify CodebuffConfigSchema 1`] = `
16
- "Schema: CodebuffConfigSchema
17
- Object (Defines the overall Codebuff configuration file (e.g., codebuff.json). This schema defines the top-level structure of the configuration.) {
18
- startupProcesses: Optional<Array<Object (Defines a single startup process. This validates the structure of an object representing a command that Codebuff can run automatically when it starts.) {
19
- name: String (A user-friendly name for the process.)
20
- command: String (The actual shell command to execute.)
21
- cwd: Optional<String> (The working directory from which to run the command.)
22
- enabled: Default<Optional<Boolean>> (default: true) (Whether this process should be run.)
23
- stdoutFile: Optional<String> (Path to write process stdout output. If not specified, output is not stored.)
24
- stderrFile: Optional<String> (Path to write process stderr output. If not specified, output is not stored.)
25
- }>> (An array of startup processes, each validated by the StartupProcessSchema.)
26
- }"
27
- `;
28
-
29
- exports[`stringifySchemaForLLM should handle a more complex schema 1`] = `
30
- "Schema: ComplexSchema
31
- Object (A complex test schema) {
32
- id: String (Unique identifier)
33
- count: Number (A positive integer count)
34
- isActive: Boolean (Activity status)
35
- tags: Optional<Array<String>> (Optional list of tags)
36
- nested: Object (A nested object structure) {
37
- value: String
38
- config: Object (Nested configuration) {
39
- retries: Default<Number> (default: 3) (Number of retries)
40
- }
41
- }
42
- }"
43
- `;
44
-
45
- exports[`stringifySchemaForLLM should handle an empty object schema 1`] = `
46
- "Schema: EmptySchema
47
- Object (An empty schema) {
48
- }"
49
- `;
50
-
51
- exports[`stringifySchemaForLLM should handle schema with only optional fields 1`] = `
52
- "Schema: OptionalOnlySchema
53
- Object (Schema with only optional fields) {
54
- field1: Optional<String> (Optional field 1)
55
- field2: Optional<Number> (Optional field 2)
56
- }"
57
- `;
58
-
59
- exports[`stringifySchemaForLLM should handle schema with default values 1`] = `
60
- "Schema: DefaultSchema
61
- Object (Schema demonstrating default values) {
62
- name: Default<String> (default: "anonymous") (Name with default)
63
- level: Default<Number> (default: 1) (Level with default)
64
- enabled: Default<Boolean> (default: false) (Enabled with default)
65
- }"
66
- `;
@@ -1,24 +0,0 @@
1
- export interface InvoiceLineItem {
2
- amount: number;
3
- description: string;
4
- period?: {
5
- start: number;
6
- end: number;
7
- };
8
- proration: boolean;
9
- }
10
- export interface SubscriptionPreviewResponse {
11
- currentMonthlyRate: number;
12
- newMonthlyRate: number;
13
- daysRemainingInBillingPeriod: number;
14
- prorationDate: number;
15
- lineItems: InvoiceLineItem[];
16
- overageCredits: number;
17
- newOverageCredits: number;
18
- currentOverageAmount: number;
19
- newOverageAmount: number;
20
- currentOverageRate: number | null;
21
- newOverageRate: number;
22
- currentQuota: number;
23
- creditsUsed: number;
24
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=plan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/types/plan.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- export type ReferralStatus = {
2
- reason: 'Referral Limit Reached' | 'Referrer Not Found' | 'Unknown Error';
3
- details?: {
4
- referralCount?: number;
5
- msg: string;
6
- };
7
- } | {
8
- reason: undefined;
9
- referralLink: string;
10
- details: {
11
- referralCount: number;
12
- };
13
- };
14
- export declare function hasMaxedReferrals(userId: string): Promise<ReferralStatus>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.hasMaxedReferrals = hasMaxedReferrals;
30
- const drizzle_orm_1 = require("drizzle-orm");
31
- const schema = __importStar(require("../../db/schema"));
32
- const db_1 = __importDefault(require("../../db"));
33
- const referral_1 = require("../referral");
34
- const env_mjs_1 = require("../../env.mjs");
35
- async function hasMaxedReferrals(userId) {
36
- try {
37
- const referralCount = await db_1.default
38
- .select({
39
- count: (0, drizzle_orm_1.sql) `count(*)`,
40
- })
41
- .from(schema.referral)
42
- .where((0, drizzle_orm_1.eq)(schema.referral.referrer_id, userId))
43
- .then((result) => (result.length > 0 ? result[0].count : 0));
44
- const user = await db_1.default.query.user.findFirst({
45
- where: (0, drizzle_orm_1.eq)(schema.user.id, userId),
46
- columns: {
47
- referral_code: true,
48
- referral_limit: true,
49
- },
50
- });
51
- if (!user || !user.referral_code) {
52
- return {
53
- reason: 'Referrer Not Found',
54
- details: {
55
- referralCount,
56
- msg: `This referrer isn't registered with us. Please try again and reach out to ${env_mjs_1.env.NEXT_PUBLIC_SUPPORT_EMAIL} if the problem
57
- persists.`,
58
- },
59
- };
60
- }
61
- if (referralCount >= user.referral_limit) {
62
- return {
63
- reason: 'Referral Limit Reached',
64
- details: {
65
- referralCount,
66
- msg: 'This referrer has maxxed out the number of referrals they can make',
67
- },
68
- };
69
- }
70
- return {
71
- reason: undefined,
72
- referralLink: (0, referral_1.getReferralLink)(user.referral_code),
73
- details: { referralCount },
74
- };
75
- }
76
- catch (error) {
77
- return {
78
- reason: 'Unknown Error',
79
- details: {
80
- msg: error instanceof Error ? error.message : String(error),
81
- },
82
- };
83
- }
84
- }
85
- //# sourceMappingURL=referral.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"referral.js","sourceRoot":"","sources":["../../../src/util/server/referral.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,8CAwDC;AA/ED,6CAAqC;AACrC,wDAAyC;AACzC,kDAAyB;AACzB,0CAA6C;AAE7C,2CAAmC;AAkB5B,KAAK,UAAU,iBAAiB,CACrC,MAAc;IAEd,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,YAAE;aAC3B,MAAM,CAAC;YACN,KAAK,EAAE,IAAA,iBAAG,EAAQ,UAAU;SAC7B,CAAC;aACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;aACrB,KAAK,CAAC,IAAA,gBAAE,EAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aAC9C,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAE9D,MAAM,IAAI,GAAG,MAAM,YAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YACzC,KAAK,EAAE,IAAA,gBAAE,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC;YACjC,OAAO,EAAE;gBACP,aAAa,EAAE,IAAI;gBACnB,cAAc,EAAE,IAAI;aACrB;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACjC,OAAO;gBACL,MAAM,EAAE,oBAAoB;gBAC5B,OAAO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