Skip to content

Commit eca185c

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(plaid): remove unrelated Brex refactor
1 parent cf2df15 commit eca185c

2 files changed

Lines changed: 18 additions & 24 deletions

File tree

apps/sim/blocks/blocks/brex.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BrexIcon } from '@/components/icons'
22
import type { BlockConfig, BlockMeta } from '@/blocks/types'
33
import { AuthMode, IntegrationType } from '@/blocks/types'
4-
import { normalizeFileInput, toOptionalBoolean, toOptionalFiniteNumber } from '@/blocks/utils'
4+
import { normalizeFileInput } from '@/blocks/utils'
55
import type { BrexResponse } from '@/tools/brex/types'
66

77
/** Coerces a required money-amount field to a finite number, throwing on blank/non-numeric input rather than silently sending 0 or NaN to Brex. */
@@ -16,6 +16,23 @@ function toRequiredAmount(value: unknown, fieldLabel: string): number {
1616
return parsed
1717
}
1818

19+
/** Coerces an optional numeric field to a finite number, throwing on non-numeric input instead of silently forwarding NaN. Preserves explicit 0. */
20+
function toOptionalFiniteNumber(value: unknown, fieldLabel: string): number | undefined {
21+
if (value == null || (typeof value === 'string' && value.trim() === '')) return undefined
22+
const parsed = Number(value)
23+
if (!Number.isFinite(parsed)) {
24+
throw new Error(`${fieldLabel} must be a valid number`)
25+
}
26+
return parsed
27+
}
28+
29+
/** Normalizes a boolean field that may arrive as a string (e.g. from a dynamic <Block.output> reference) instead of an actual boolean. */
30+
function toOptionalBoolean(value: unknown): boolean | undefined {
31+
if (value == null) return undefined
32+
if (typeof value === 'boolean') return value
33+
return String(value).toLowerCase() === 'true'
34+
}
35+
1936
const PAGINATED_OPERATIONS = new Set([
2037
'list_expenses',
2138
'list_card_transactions',

apps/sim/blocks/utils.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -795,26 +795,3 @@ Example 3 (Array Input):
795795
placeholder: 'Describe the JSON schema structure you need...',
796796
generationType: 'json-schema' as const,
797797
}
798-
799-
/**
800-
* Coerces an optional numeric subblock value to a finite number, throwing on
801-
* non-numeric input instead of silently forwarding NaN. Preserves explicit 0.
802-
*/
803-
export function toOptionalFiniteNumber(value: unknown, fieldLabel: string): number | undefined {
804-
if (value == null || (typeof value === 'string' && value.trim() === '')) return undefined
805-
const parsed = Number(value)
806-
if (!Number.isFinite(parsed)) {
807-
throw new Error(`${fieldLabel} must be a valid number`)
808-
}
809-
return parsed
810-
}
811-
812-
/**
813-
* Normalizes a boolean subblock value that may arrive as a string (e.g. from a
814-
* dynamic <Block.output> reference) instead of an actual boolean.
815-
*/
816-
export function toOptionalBoolean(value: unknown): boolean | undefined {
817-
if (value == null) return undefined
818-
if (typeof value === 'boolean') return value
819-
return String(value).trim().toLowerCase() === 'true'
820-
}

0 commit comments

Comments
 (0)