@gati-framework/types
Version:
Gati Type System - TypeScript-first branded types and schema system
70 lines • 1.75 kB
JavaScript
/**
* @module gtype
* @description GType schema definitions - Gati's runtime type representation
*
* GType is a JSON-serializable schema format that:
* - Represents TypeScript branded types at runtime
* - Enables schema diffing for Timescape version management
* - Compiles to Ajv validators for high-performance validation
* - Generates OpenAPI specifications automatically
* - Supports version migration with schema version field
*/
/**
* Schema version for migration support
*/
export const GTYPE_SCHEMA_VERSION = '1.0';
/**
* Type guard: Check if a GType is a primitive
*/
export function isPrimitive(gtype) {
return ['string', 'number', 'boolean', 'null', 'bigint', 'symbol'].includes(gtype.type);
}
/**
* Type guard: Check if a GType is an object
*/
export function isObject(gtype) {
return gtype.type === 'object';
}
/**
* Type guard: Check if a GType is an array
*/
export function isArray(gtype) {
return gtype.type === 'array';
}
/**
* Type guard: Check if a GType is a tuple
*/
export function isTuple(gtype) {
return gtype.type === 'tuple';
}
/**
* Type guard: Check if a GType is a union
*/
export function isUnion(gtype) {
return gtype.type === 'union';
}
/**
* Type guard: Check if a GType is an intersection
*/
export function isIntersection(gtype) {
return gtype.type === 'intersection';
}
/**
* Type guard: Check if a GType is an enum
*/
export function isEnum(gtype) {
return gtype.type === 'enum';
}
/**
* Type guard: Check if a GType is a reference
*/
export function isRef(gtype) {
return gtype.type === 'ref';
}
/**
* Type guard: Check if a GType is a literal
*/
export function isLiteral(gtype) {
return gtype.type === 'literal';
}
//# sourceMappingURL=gtype.js.map