@cslug/core 0.1.0 → 0.3.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.
package/docs/api.md CHANGED
@@ -92,7 +92,7 @@ All extend `CslugError` (`code`, `message`): `BindingNotFoundError` (`container.
92
92
  | `app.setConfig(path, value)` | Override before `start()` (the test kit); config is deep-frozen at start |
93
93
  | `Config`, `Typed<T>`, `ConfigPath<T>`, `ConfigValue<T, P>` | `declare module '@cslug/core' { interface Config extends Typed<typeof configs> {} }` |
94
94
 
95
- `v` and `ValidationError` are re-exported from `@cslug/validation`.
95
+ `v`, `ValidationError`, `sniffType` and `parseSize` are re-exported from `@cslug/validation`.
96
96
 
97
97
  ## Errors
98
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cslug/core",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Application, container and @inject, providers, config, events, logger, errors, context, Clock, Money, i18n, contracts.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,6 +28,6 @@
28
28
  "bun": ">=1.3.14"
29
29
  },
30
30
  "peerDependencies": {
31
- "@cslug/validation": "0.1.0"
31
+ "@cslug/validation": "0.3.0"
32
32
  }
33
33
  }
package/src/contracts.ts CHANGED
@@ -173,6 +173,7 @@ export abstract class Lock {
173
173
  }
174
174
  }
175
175
 
176
+ /** In-process `Lock` (tests and single-process apps); `@cslug/redis` provides the shared one. */
176
177
  export class MemoryLock extends Lock {
177
178
  private readonly held = new Map<string, { token: string; expires: number }>()
178
179
 
@@ -240,6 +241,7 @@ export abstract class RateLimiter {
240
241
  }
241
242
  }
242
243
 
244
+ /** In-process `RateLimiter` (sliding window); `@cslug/redis` provides the shared one. */
243
245
  export class MemoryRateLimiter extends RateLimiter {
244
246
  private readonly hits = new Map<string, number[]>()
245
247
 
@@ -273,6 +275,7 @@ export abstract class SessionStore {
273
275
  abstract destroy(id: string): Promise<void>
274
276
  }
275
277
 
278
+ /** In-process `SessionStore`: sessions are lost on restart (tests, development). */
276
279
  export class MemorySessionStore extends SessionStore {
277
280
  private readonly cache = new MemoryCache()
278
281
 
package/src/index.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * typed errors, Clock, Money, events, logger, i18n, and the Cache/Lock/RateLimiter/SessionStore contracts.
4
4
  */
5
5
 
6
- /** Re-exported so apps can `import { v, ValidationError } from '@cslug/core'` in config/env.ts. */
7
- export { ValidationError, v } from '@cslug/validation'
6
+ /** Re-exported: `v` and `ValidationError` for config/env.ts; `sniffType` and `parseSize` for @cslug/storage. */
7
+ export { parseSize, sniffType, ValidationError, v } from '@cslug/validation'
8
8
  export { Application, type ApplicationOptions, sortProviders } from './application'
9
9
  export { Clock, FakeClock } from './clock'
10
10
  export {
package/src/money.ts CHANGED
@@ -163,7 +163,7 @@ export class Money {
163
163
  /** Localised: `format('fr')` → `2 200,00 €`. Exact for any size (formats the decimal string). */
164
164
  format(locale = 'en', options: Omit<Intl.NumberFormatOptions, 'style' | 'currency'> = {}): string {
165
165
  const f = new Intl.NumberFormat(locale, { ...options, style: 'currency', currency: this.currency })
166
- return f.format(this.toDecimal() as unknown as number)
166
+ return f.format(this.toDecimal() as `${number}`)
167
167
  }
168
168
 
169
169
  /** JSON has no bigint: `{ amount: "220000", currency: "EUR" }`. */