@ethisyscore/foundation-utils
Platform-free utilities shared by the EthisysCore web app, the plugin SDK and plugins. Pure TypeScript, no React. The npm side of EthisysCore Foundation: it follows the same rules as the .NET packages (no platform types, one behaviour per concept, changes rarely).
Install
npm install @ethisyscore/foundation-utils
date-fns and mutative are runtime dependencies. dayjs and zod are optional peer dependencies,
needed only for the ./date/dayjs and ./phone/zod sub-paths.
Entry points
| Sub-path | Contents |
|---|---|
. | Everything below except ./date/dayjs and ./phone/zod |
./date | Format constants, ISO and timezone-safe helpers, display formatting, durations, <input> to DateTimeOffset wire helpers, ranges, format-string validation |
./date/dayjs | dayjsToIsoDayBoundary |
./date/org-format | Organisation-driven display: formatDate, formatDateTime, formatTime, formatDateOrPresent, formatRelativeTime and the dayjs picker masks. Each takes the organisation's { dateFormat, timeFormat }; a missing or invalid format falls back to UK dd/MM/yyyy and HH:mm |
./patch | RFC 6902 JSON Patch: generateJsonPatch, applyJsonPatch, deepClone and the JsonPatchOperation type |
./list | unwrapList: normalises list responses returned bare or in an envelope. PAGE_SIZE_OPTIONS and DEFAULT_PAGE_SIZE |
./money | formatMoney, formatCompactMoney, getCurrencySymbol, parseMoney. The caller always names the currency |
./number | formatNumber, formatPercent, formatBytes (1 KB = 1024 bytes) and formatDecimalBytes (1 KB = 1000 bytes, for storage allowances and their charges) |
./wire | decodeWireEnum, decodeWireEnumName: enum values sent as an ordinal or a name |
./route | RouteMetaEntry, Breadcrumb, sortBySpecificity, matchRoute, resolvePattern, buildBreadcrumbs: match a pathname against flat route metadata and build its breadcrumb trail |
./types | Base DTO and query shapes: Guid, asGuid, EMPTY_GUID, Auditable, AuditableDetailed, HasRowVersion, PagedQuery, SearchQuery, LookupItem |
./phone | isValidPhone, normalisePhone, formatPhone, sanitisePhoneInput: E.164-compatible phone numbers (optional leading +, 7-15 digits) |
./phone/zod | optionalPhoneSchema, requiredPhoneSchema |
Nothing here holds state. The caller keeps the organisation's formats and currency (the plugin SDK in module-level refs stamped from the host, the web app in React context) and passes them in.
Scripts
npm run build # tsup: ESM + CJS + d.ts
npm test # vitest
npm run lint # tsc --noEmit + eslint
npm run lint:package # publint + attw against the packed tarball
Published to npm by .github/workflows/release.yml at the same version as the Foundation NuGet packages.