@classytic/primitives 0.9.0 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
4
  adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [0.9.1] - 2026-07-04
7
+
8
+ ### Added
9
+
10
+ - **`CURRENCY_PATTERN` exported from `/currency`** — the ISO 4217 regex
11
+ (`/^[A-Z]{3}$/`) behind `isCurrencyCode` / `toCurrencyCode`. Consumers
12
+ embed the SAME pattern in JSON-Schema-representable validators (zod
13
+ `.regex`, Mongoose `match`, OpenAPI `pattern`) instead of hand-rolling
14
+ copies — `.refine(isCurrencyCode)` validates at runtime but is dropped
15
+ by `z.toJSONSchema`, silently losing the constraint from generated API
16
+ docs.
17
+
6
18
  ## [0.9.0] - 2026-07-02
7
19
 
8
20
  ### Added — `/timezone`: IANA resolution + civil dates (the door for `/calendar`'s escape hatch)
@@ -43,6 +43,15 @@ declare const CURRENCIES: {
43
43
  * isn't in this table, {@link minorUnitFactor} returns 100 as the safe default.
44
44
  */
45
45
  declare const MINOR_UNIT_FACTOR: Readonly<Record<string, number>>;
46
+ /**
47
+ * ISO 4217 format — 3 uppercase letters. Exported so consumers can embed
48
+ * the SAME pattern in JSON-Schema-representable validators (zod `.regex`,
49
+ * Mongoose `match`, OpenAPI `pattern`) instead of hand-rolling a copy:
50
+ * `.refine(isCurrencyCode)` validates at runtime but is dropped by
51
+ * `z.toJSONSchema`, losing the constraint from generated API docs.
52
+ * `isCurrencyCode` / `toCurrencyCode` remain the runtime API.
53
+ */
54
+ declare const CURRENCY_PATTERN: RegExp;
46
55
  /**
47
56
  * Narrow a raw string to a {@link CurrencyCode}. Returns `null` if the string
48
57
  * is not a valid ISO 4217 format (3 uppercase letters). This does not verify
@@ -107,4 +116,4 @@ declare function reverseWithSnapshot(baseAmount: number, fx: FxSnapshot): number
107
116
  */
108
117
  declare function isFxSnapshot(value: unknown): value is FxSnapshot;
109
118
  //#endregion
110
- export { convertWithSnapshot as a, minorUnitFactor as c, MINOR_UNIT_FACTOR as i, reverseWithSnapshot as l, CurrencyCode as n, isCurrencyCode as o, FxSnapshot as r, isFxSnapshot as s, CURRENCIES as t, toCurrencyCode as u };
119
+ export { MINOR_UNIT_FACTOR as a, isFxSnapshot as c, toCurrencyCode as d, FxSnapshot as i, minorUnitFactor as l, CURRENCY_PATTERN as n, convertWithSnapshot as o, CurrencyCode as r, isCurrencyCode as s, CURRENCIES as t, reverseWithSnapshot as u };
@@ -1,2 +1,2 @@
1
- import { a as convertWithSnapshot, c as minorUnitFactor, i as MINOR_UNIT_FACTOR, l as reverseWithSnapshot, n as CurrencyCode, o as isCurrencyCode, r as FxSnapshot, s as isFxSnapshot, t as CURRENCIES, u as toCurrencyCode } from "./currency-B4rSdN7D.mjs";
2
- export { CURRENCIES, CurrencyCode, FxSnapshot, MINOR_UNIT_FACTOR, convertWithSnapshot, isCurrencyCode, isFxSnapshot, minorUnitFactor, reverseWithSnapshot, toCurrencyCode };
1
+ import { a as MINOR_UNIT_FACTOR, c as isFxSnapshot, d as toCurrencyCode, i as FxSnapshot, l as minorUnitFactor, n as CURRENCY_PATTERN, o as convertWithSnapshot, r as CurrencyCode, s as isCurrencyCode, t as CURRENCIES, u as reverseWithSnapshot } from "./currency-BCJnJBlb.mjs";
2
+ export { CURRENCIES, CURRENCY_PATTERN, CurrencyCode, FxSnapshot, MINOR_UNIT_FACTOR, convertWithSnapshot, isCurrencyCode, isFxSnapshot, minorUnitFactor, reverseWithSnapshot, toCurrencyCode };
package/dist/currency.mjs CHANGED
@@ -61,6 +61,14 @@ const MINOR_UNIT_FACTOR = {
61
61
  OMR: 1e3,
62
62
  TND: 1e3
63
63
  };
64
+ /**
65
+ * ISO 4217 format — 3 uppercase letters. Exported so consumers can embed
66
+ * the SAME pattern in JSON-Schema-representable validators (zod `.regex`,
67
+ * Mongoose `match`, OpenAPI `pattern`) instead of hand-rolling a copy:
68
+ * `.refine(isCurrencyCode)` validates at runtime but is dropped by
69
+ * `z.toJSONSchema`, losing the constraint from generated API docs.
70
+ * `isCurrencyCode` / `toCurrencyCode` remain the runtime API.
71
+ */
64
72
  const CURRENCY_PATTERN = /^[A-Z]{3}$/;
65
73
  /**
66
74
  * Narrow a raw string to a {@link CurrencyCode}. Returns `null` if the string
@@ -113,4 +121,4 @@ function isFxSnapshot(value) {
113
121
  return typeof v.sourceCurrency === "string" && typeof v.baseCurrency === "string" && typeof v.rate === "number" && Number.isFinite(v.rate) && v.rate > 0 && v.snapshotAt instanceof Date;
114
122
  }
115
123
  //#endregion
116
- export { CURRENCIES, MINOR_UNIT_FACTOR, convertWithSnapshot, isCurrencyCode, isFxSnapshot, minorUnitFactor, reverseWithSnapshot, toCurrencyCode };
124
+ export { CURRENCIES, CURRENCY_PATTERN, MINOR_UNIT_FACTOR, convertWithSnapshot, isCurrencyCode, isFxSnapshot, minorUnitFactor, reverseWithSnapshot, toCurrencyCode };
package/dist/money.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as CurrencyCode } from "./currency-B4rSdN7D.mjs";
1
+ import { r as CurrencyCode } from "./currency-BCJnJBlb.mjs";
2
2
 
3
3
  //#region src/money/money.d.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/primitives",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Framework-agnostic TypeScript primitives shared across Classytic packages — Money, events, pagination, tenant config, and other building blocks.",
5
5
  "author": "Classytic",
6
6
  "license": "MIT",