BSB Node.js Type Definitions
    Preparing search index...

    Variable bsbConst

    bsb: {
        string(
            options?: {
                min?: number;
                max?: number;
                pattern?: string;
                description?: string;
            },
        ): BSBStringType;
        uuid(description?: string): BSBStringType;
        datetime(description?: string): BSBStringType;
        email(description?: string): BSBStringType;
        uri(description?: string): BSBStringType;
        url(description?: string): BSBStringType;
        int32(
            options?: { min?: number; max?: number; description?: string },
        ): BSBNumberType;
        int64(
            options?: { min?: number; max?: number; description?: string },
        ): BSBNumberType;
        float(
            options?: { min?: number; max?: number; description?: string },
        ): BSBNumberType;
        double(
            options?: { min?: number; max?: number; description?: string },
        ): BSBNumberType;
        boolean(description?: string): BSBBooleanType;
        bytes(description?: string): BSBBytesType;
        array(
            items: BSBType,
            options?: { min?: number; max?: number; description?: string },
        ): BSBArrayType;
        object<const T>(
            properties: T,
            description?: string,
        ): {
            _bsb: "object";
            properties: T;
            required: string[];
            description?: string;
            optional?: boolean;
            nullable?: boolean;
        };
        enum(values: readonly string[], description?: string): BSBEnumType;
        union(types: BSBType[], description?: string): BSBUnionType;
        number(
            options?: { min?: number; max?: number; description?: string },
        ): BSBNumberType;
        void(): BSBType;
        unknown(description?: string): BSBType;
        record<K extends BSBType, V extends BSBType>(
            keyType: K,
            valueType: V,
            description?: string,
        ): BSBType;
    } = ...

    BSB type builder providing a fluent API for creating cross-language type definitions.

    Type Declaration

    • string: function
      • Create a string type with optional constraints.

        Parameters

        • Optionaloptions: { min?: number; max?: number; pattern?: string; description?: string }

        Returns BSBStringType

    • uuid: function
      • Create a UUID string type (RFC 4122).

        Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

        Language mappings:

        • JavaScript/TypeScript: string
        • C#: Guid
        • Go: uuid.UUID
        • Java: UUID

        Parameters

        • Optionaldescription: string

        Returns BSBStringType

    • datetime: function
      • Create an ISO 8601 datetime string type.

        Format: 2024-01-01T12:00:00Z

        Language mappings:

        • JavaScript/TypeScript: Date | string
        • C#: DateTime
        • Go: time.Time
        • Java: Instant

        Parameters

        • Optionaldescription: string

        Returns BSBStringType

    • email: function
      • Create an email address string type.

        Parameters

        • Optionaldescription: string

        Returns BSBStringType

    • uri: function
      • Create a URI string type.

        Parameters

        • Optionaldescription: string

        Returns BSBStringType

    • url: function
      • Create a URL string type.

        Parameters

        • Optionaldescription: string

        Returns BSBStringType

    • int32: function
      • Create a 32-bit signed integer type.

        Range: -2,147,483,648 to 2,147,483,647

        Language mappings:

        • JavaScript/TypeScript: number
        • C#: int
        • Go: int32
        • Java: int

        Parameters

        • Optionaloptions: { min?: number; max?: number; description?: string }

        Returns BSBNumberType

    • int64: function
      • Create a 64-bit signed integer type.

        Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

        Note: JavaScript can only safely represent integers up to 2^53.

        Language mappings:

        • JavaScript/TypeScript: number
        • C#: long
        • Go: int64
        • Java: long

        Parameters

        • Optionaloptions: { min?: number; max?: number; description?: string }

        Returns BSBNumberType

    • float: function
      • Create a 32-bit floating point number type.

        Language mappings:

        • JavaScript/TypeScript: number
        • C#: float
        • Go: float32
        • Java: float

        Parameters

        • Optionaloptions: { min?: number; max?: number; description?: string }

        Returns BSBNumberType

    • double: function
      • Create a 64-bit floating point number type.

        Language mappings:

        • JavaScript/TypeScript: number
        • C#: double
        • Go: float64
        • Java: double

        Parameters

        • Optionaloptions: { min?: number; max?: number; description?: string }

        Returns BSBNumberType

    • boolean: function
      • Create a boolean type.

        Language mappings:

        • JavaScript/TypeScript: boolean
        • C#: bool
        • Go: bool
        • Java: boolean

        Parameters

        • Optionaldescription: string

        Returns BSBBooleanType

    • bytes: function
      • Create a bytes type for binary data. Maps to:

        • JavaScript/TypeScript: Uint8Array or Buffer
        • C#: byte[]
        • Go: []byte
        • Java: byte[]
        • Python: bytes

        Parameters

        • Optionaldescription: string

        Returns BSBBytesType

    • array: function
      • Create an array type with element type and optional size constraints.

        Parameters

        • items: BSBType
        • Optionaloptions: { min?: number; max?: number; description?: string }

        Returns BSBArrayType

        const TagsSchema = bsb.array(
        bsb.string({ max: 50 }),
        { min: 1, max: 10, description: 'List of tags' }
        );
    • object: function
      • Create an object type with named properties.

        Required fields are automatically determined based on the optional flag.

        Type Parameters

        • const T

        Parameters

        • properties: T
        • Optionaldescription: string

        Returns {
            _bsb: "object";
            properties: T;
            required: string[];
            description?: string;
            optional?: boolean;
            nullable?: boolean;
        }

        const UserSchema = bsb.object({
        id: bsb.uuid('User ID'),
        name: bsb.string({ min: 1, max: 100, description: 'Full name' }),
        email: optional(bsb.email('Email address')),
        }, 'User object');
    • enum: function
      • Create an enum type with fixed string values.

        Parameters

        • values: readonly string[]
        • Optionaldescription: string

        Returns BSBEnumType

        const StatusSchema = bsb.enum(
        ['pending', 'in-progress', 'completed', 'failed'],
        'Task status'
        );
    • union: function
      • Create a union type representing one of multiple possible types.

        Parameters

        • types: BSBType[]
        • Optionaldescription: string

        Returns BSBUnionType

        const IdSchema = bsb.union([
        bsb.uuid('UUID identifier'),
        bsb.int32({ description: 'Numeric identifier' }),
        ], 'Flexible identifier');
    • number: function
      • Create a generic number type (defaults to double for floating point). This is a convenience wrapper for double().

        Parameters

        • Optionaloptions: { min?: number; max?: number; description?: string }

        Returns BSBNumberType

    • void: function
      • Create a void type for functions that don't return a value.

        Returns BSBType

    • unknown: function
      • Create an unknown type for dynamic/any data.

        Parameters

        • Optionaldescription: string

        Returns BSBType

    • record: function
      • Create a record/map type with string keys and a value type.

        Type Parameters

        Parameters

        • keyType: K
        • valueType: V
        • Optionaldescription: string

        Returns BSBType

    import { bsb, optional } from '@bsb/base';

    const UserSchema = bsb.object({
    id: bsb.uuid('User unique identifier'),
    name: bsb.string({ min: 1, max: 100, description: 'User full name' }),
    email: bsb.string({ description: 'User email address' }),
    age: optional(bsb.int32({ min: 0, max: 150, description: 'User age' })),
    });