Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 1809x 13x 1x 1x 10x 118x 1x 1x 827x 7x 7x 13x 206x 551x 7x 10x 7x 7x 4x 1x 4x 1x 1x 10x 1x 2551x 1809x 134x 3x 5x 476x 475x 1x | import * as Ydb from '@ydbjs/api/value'
import type { DictType } from './dict.js'
import type { ListType } from './list.js'
import type { OptionalType } from './optional.ts'
import type { PrimitiveType } from './primitive.js'
import type { StructType } from './struct.js'
import type { TupleType } from './tuple.js'
import { type Type, TypeKind } from './type.js'
function primitiveTypeToString(pTypeId: Ydb.Type_PrimitiveTypeId) {
switch (pTypeId) {
case Ydb.Type_PrimitiveTypeId.BOOL:
return 'Bool'
case Ydb.Type_PrimitiveTypeId.UINT8:
return 'Uint8'
case Ydb.Type_PrimitiveTypeId.UINT16:
return 'Uint16'
case Ydb.Type_PrimitiveTypeId.UINT32:
return 'Uint32'
case Ydb.Type_PrimitiveTypeId.UINT64:
return 'Uint64'
case Ydb.Type_PrimitiveTypeId.INT8:
return 'Int8'
case Ydb.Type_PrimitiveTypeId.INT16:
return 'Int16'
case Ydb.Type_PrimitiveTypeId.INT32:
return 'Int32'
case Ydb.Type_PrimitiveTypeId.INT64:
return 'Int64'
case Ydb.Type_PrimitiveTypeId.FLOAT:
return 'Float'
case Ydb.Type_PrimitiveTypeId.DOUBLE:
return 'Double'
case Ydb.Type_PrimitiveTypeId.STRING:
return 'String'
case Ydb.Type_PrimitiveTypeId.UTF8:
return 'Utf8'
case Ydb.Type_PrimitiveTypeId.YSON:
return 'Yson'
case Ydb.Type_PrimitiveTypeId.JSON:
return 'Json'
case Ydb.Type_PrimitiveTypeId.JSON_DOCUMENT:
return 'JsonDocument'
case Ydb.Type_PrimitiveTypeId.UUID:
return 'Uuid'
case Ydb.Type_PrimitiveTypeId.DATE:
return 'Date'
case Ydb.Type_PrimitiveTypeId.TZ_DATE:
return 'TzDate'
case Ydb.Type_PrimitiveTypeId.DATETIME:
return 'Datetime'
case Ydb.Type_PrimitiveTypeId.TZ_DATETIME:
return 'TzDatetime'
case Ydb.Type_PrimitiveTypeId.INTERVAL:
return 'Interval'
case Ydb.Type_PrimitiveTypeId.TIMESTAMP:
return 'Timestamp'
case Ydb.Type_PrimitiveTypeId.TZ_TIMESTAMP:
return 'TzTimestamp'
case Ydb.Type_PrimitiveTypeId.DYNUMBER:
return 'DyNumber'
default:
throw new Error(`Unknown primitive type id: ${pTypeId}`)
}
}
export function typeToString(type: Type): string {
switch (type.kind) {
case TypeKind.PRIMITIVE:
return primitiveTypeToString((type as PrimitiveType).id)
case TypeKind.DECIMAL:
return 'Decimal'
case TypeKind.LIST:
return `List<${typeToString((type as ListType).item)}>`
case TypeKind.DICT:
return `Dict<${typeToString((type as DictType).key)},${typeToString((type as DictType).value)}>`
case TypeKind.TUPLE:
return `Tuple<${(type as TupleType).elements.map((element) => typeToString(element)).join(',')}>`
case TypeKind.STRUCT:
return `Struct<${(type as StructType).names.map((name, index) => `${name}:${typeToString((type as StructType).types[index]!)}`).join(',')}>`
case TypeKind.OPTIONAL:
return `Optional<${typeToString((type as OptionalType).itemType)}>`
case TypeKind.NULL:
return 'Null'
}
throw new Error(`Unsupported type: ${type}`)
}
|