@open-mercato/shared 0.6.6-develop.6384.1.f06fc0b42c → 0.6.6-develop.6386.1.391a1afb9e

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.
@@ -0,0 +1,14 @@
1
+ export function parseNumberWithDefault(
2
+ raw: string | null | undefined,
3
+ fallback: number,
4
+ options?: { min?: number; integer?: boolean },
5
+ ): number {
6
+ if (raw == null) return fallback
7
+ const trimmed = raw.trim()
8
+ if (!trimmed) return fallback
9
+ const value = options?.integer ? Number.parseInt(trimmed, 10) : Number(trimmed)
10
+ if (!Number.isFinite(value)) return fallback
11
+ const min = options?.min ?? -Infinity
12
+ if (value < min) return fallback
13
+ return value
14
+ }
@@ -1,4 +1,5 @@
1
1
  import { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'
2
+ import { parseNumberWithDefault } from '@open-mercato/shared/lib/number'
2
3
 
3
4
  export type SearchConfig = {
4
5
  enabled: boolean
@@ -18,11 +19,7 @@ function parseBoolean(raw: string | undefined, fallback: boolean): boolean {
18
19
  }
19
20
 
20
21
  function parseNumber(raw: string | undefined, fallback: number, min = 1): number {
21
- if (raw == null) return fallback
22
- const value = Number.parseInt(raw, 10)
23
- if (!Number.isFinite(value)) return fallback
24
- if (value < min) return fallback
25
- return value
22
+ return parseNumberWithDefault(raw, fallback, { integer: true, min })
26
23
  }
27
24
 
28
25
  function parseHashAlgorithm(raw: string | undefined): 'sha256' | 'sha1' | 'md5' {
@@ -178,6 +178,7 @@ export type ModuleCli = {
178
178
 
179
179
  export type ModuleSubscriber = {
180
180
  id: string
181
+ moduleId?: string
181
182
  event: string
182
183
  persistent?: boolean
183
184
  sync?: boolean
@@ -187,6 +188,7 @@ export type ModuleSubscriber = {
187
188
 
188
189
  export type ModuleWorker = {
189
190
  id: string
191
+ moduleId?: string
190
192
  queue: string
191
193
  concurrency: number
192
194
  handler: ModuleWorkerHandler