Skip to content

Commit b28aedb

Browse files
committed
change WithDefaults to OptionalFields
1 parent e405e7a commit b28aedb

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

backend/src/main-prompt.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export const mainPrompt = async (
2626
ws: WebSocket
2727
action: ClientAction<'prompt'>
2828

29-
userId: string | undefined
30-
clientSessionId: string
3129
onResponseChunk: (chunk: string | PrintModeEvent) => void
3230
localAgentTemplates: Record<string, AgentTemplate>
3331

@@ -51,8 +49,7 @@ export const mainPrompt = async (
5149
sessionState: SessionState
5250
output: AgentOutput
5351
}> => {
54-
const { ws, action, userId, clientSessionId, localAgentTemplates, logger } =
55-
params
52+
const { ws, action, localAgentTemplates, logger } = params
5653

5754
const {
5855
prompt,

backend/src/tools/handlers/tool/spawn-agent-utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import type {
1414
Subgoal,
1515
} from '@codebuff/common/types/session-state'
1616
import type { ProjectFileContext } from '@codebuff/common/util/file'
17-
import type { ParamsExcluding, WithDefaults } from '@codebuff/common/types/function-params'
17+
import type {
18+
ParamsExcluding,
19+
OptionalFields,
20+
} from '@codebuff/common/types/function-params'
1821
import type { Logger } from '@codebuff/common/types/contracts/logger'
1922
import type { WebSocket } from 'ws'
2023

@@ -310,7 +313,7 @@ export function logAgentSpawn(params: {
310313
* Executes a subagent using loopAgentSteps
311314
*/
312315
export async function executeSubagent(
313-
options: WithDefaults<
316+
options: OptionalFields<
314317
{
315318
agentTemplate: AgentTemplate
316319
parentAgentState: AgentState

common/src/types/function-params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type ParamsOf<T> = Prettify<
1616
T extends any[] ? ParamsOfArray<T> : ParamsOfUnion<T>
1717
>
1818

19-
export type WithDefaults<T, K extends keyof T> = Prettify<
19+
export type OptionalFields<T, K extends keyof T> = Prettify<
2020
Omit<T, K> & Partial<Pick<T, K>>
2121
>
2222

packages/billing/src/balance-calculator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { failure, success } from '@codebuff/common/util/error'
77
import { and, asc, gt, isNull, or, eq, sql } from 'drizzle-orm'
88

99
import type { GrantType } from '@codebuff/common/db/schema'
10-
import type { ErrorOr } from '@codebuff/common/util/error'
10+
import type { Logger } from '@codebuff/common/types/contracts/logger'
1111
import type {
1212
ParamsExcluding,
1313
ParamsOf,
14-
WithDefaults,
14+
OptionalFields,
1515
} from '@codebuff/common/types/function-params'
16-
import type { Logger } from '@codebuff/common/types/contracts/logger'
16+
import type { ErrorOr } from '@codebuff/common/util/error'
1717

1818
export interface CreditBalance {
1919
totalRemaining: number
@@ -200,7 +200,7 @@ export async function consumeFromOrderedGrants(
200200
* This is more efficient than calculating them separately.
201201
*/
202202
export async function calculateUsageAndBalance(
203-
params: WithDefaults<
203+
params: OptionalFields<
204204
{
205205
userId: string
206206
quotaResetDate: Date

packages/billing/src/org-billing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import type {
1515
CreditConsumptionResult,
1616
} from './balance-calculator'
1717
import type { GrantType } from '@codebuff/common/db/schema'
18-
import type { WithDefaults } from '@codebuff/common/types/function-params'
1918
import type { Logger } from '@codebuff/common/types/contracts/logger'
19+
import type { OptionalFields } from '@codebuff/common/types/function-params'
2020

2121
// Add a minimal structural type that both `db` and `tx` satisfy
2222
type DbConn = Pick<typeof db, 'select' | 'update'>
@@ -128,7 +128,7 @@ export async function syncOrganizationBillingCycle(params: {
128128
* Gets active grants for an organization, ordered by expiration, priority, and creation date.
129129
*/
130130
export async function getOrderedActiveOrganizationGrants(
131-
params: WithDefaults<
131+
params: OptionalFields<
132132
{
133133
organizationId: string
134134
now: Date
@@ -163,7 +163,7 @@ export async function getOrderedActiveOrganizationGrants(
163163
* Calculates both the current balance and usage in this cycle for an organization.
164164
*/
165165
export async function calculateOrganizationUsageAndBalance(
166-
params: WithDefaults<
166+
params: OptionalFields<
167167
{
168168
organizationId: string
169169
quotaResetDate: Date
@@ -310,7 +310,7 @@ export async function consumeOrganizationCredits(params: {
310310
* Grants credits to an organization.
311311
*/
312312
export async function grantOrganizationCredits(
313-
params: WithDefaults<
313+
params: OptionalFields<
314314
{
315315
organizationId: string
316316
userId: string

packages/internal/src/loops/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { eq } from 'drizzle-orm'
44
import { LoopsClient, APIError } from 'loops'
55

66
import type { LoopsEmailData, SendEmailResult } from './types'
7-
import type { ParamsExcluding, WithDefaults } from '@codebuff/common/types/function-params'
7+
import type {
8+
ParamsExcluding,
9+
OptionalFields,
10+
} from '@codebuff/common/types/function-params'
811
import type { Logger } from '@codebuff/common/types/contracts/logger'
912

1013
const ORGANIZATION_INVITATION_TRANSACTIONAL_ID = 'cmbikixxm15xo4a0iiemzkzw1'
@@ -17,7 +20,7 @@ if (process.env.LOOPS_API_KEY) {
1720
}
1821

1922
async function sendTransactionalEmail(
20-
params: WithDefaults<
23+
params: OptionalFields<
2124
{
2225
transactionalId: string
2326
email: string

0 commit comments

Comments
 (0)