Skip to content

TypeScript fundamentals

@cratis/fundamentals provides typed domain values, GUIDs, dates, and JSON conversion for TypeScript applications. Use it in browser or Node.js code without a Cratis backend.

Install the npm package:

Terminal window
npm install @cratis/fundamentals

Add this to your TypeScript application’s entry point:

import { Guid } from '@cratis/fundamentals';
const emptyGuid = Guid.empty;
console.log(emptyGuid.toString());

Run the application with its usual development command. The console prints 00000000-0000-0000-0000-000000000000, the empty GUID formatted as a string. This checks that the package import and identifier conversion work in your application.

Choose a utility for the value or conversion your application needs:

Topic Description
ConceptAs Domain-Driven Design pattern for creating strongly-typed domain identifiers and value objects that wrap primitive types.
GUID GUID creation, manipulation, and utility functions for unique identifiers.
Constructor Runtime constructor type alias for class-based APIs and metadata-driven tooling.
PropertyAccessor Property accessor function type for typed property selection and path utilities.
TimeSpan .NET-compatible time interval parsing, formatting, and JSON serialization.
ValueMap A value-based map for complex object keys with stable lookup semantics.
Serialization Type-safe JSON serialization and deserialization system with polymorphic support and runtime type preservation.

Use the package root for shared types, or import from @cratis/fundamentals/geospatial, @cratis/fundamentals/json, and @cratis/fundamentals/reflection. These entry points work in Node.js ESM, CommonJS, and TypeScript projects using NodeNext or Bundler module resolution.

import { Guid } from '@cratis/fundamentals';
import { Point } from '@cratis/fundamentals/geospatial';
const origin = new Point(0, 0);
const id = Guid.empty;