@reifydb/core 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare const NONE_VALUE = "\u27EAnone\u27EB";
2
+ declare const ROW_NUMBER_KEY = "#rownum";
2
3
 
3
4
  /**
4
5
  * A binary large object (BLOB) value that can hold arbitrary byte data.
@@ -288,7 +289,7 @@ declare class DateTimeValue implements Value {
288
289
  /**
289
290
  * Get Unix timestamp in seconds
290
291
  */
291
- to_epoch_secs(): number | undefined;
292
+ toEpochSecs(): number | undefined;
292
293
  /**
293
294
  * Get Unix timestamp in nanoseconds
294
295
  */
@@ -929,49 +930,63 @@ declare abstract class Value {
929
930
  abstract equals(other: Value): boolean;
930
931
  }
931
932
 
932
- declare function decode(pair: TypeValuePair): Value;
933
-
934
- declare const TYPE_CODE: {
935
- readonly None: 0;
936
- readonly Boolean: 1;
937
- readonly Float4: 2;
938
- readonly Float8: 3;
939
- readonly Int1: 4;
940
- readonly Int2: 5;
941
- readonly Int4: 6;
942
- readonly Int8: 7;
943
- readonly Int16: 8;
944
- readonly Utf8: 9;
945
- readonly Uint1: 10;
946
- readonly Uint2: 11;
947
- readonly Uint4: 12;
948
- readonly Uint8: 13;
949
- readonly Uint16: 14;
950
- readonly Date: 15;
951
- readonly DateTime: 16;
952
- readonly Time: 17;
953
- readonly Duration: 18;
954
- readonly IdentityId: 19;
955
- readonly Uuid4: 20;
956
- readonly Uuid7: 21;
957
- readonly Blob: 22;
958
- readonly Int: 23;
959
- readonly Uint: 24;
960
- readonly Decimal: 25;
961
- readonly Any: 26;
962
- readonly DictionaryId: 27;
963
- readonly Type: 28;
964
- readonly List: 29;
965
- readonly Record: 30;
966
- readonly Tuple: 31;
967
- };
968
- type TypeName = keyof typeof TYPE_CODE;
969
- declare function type_name_from_code(code: number): TypeName;
970
-
971
- type PrimitiveToTS<T extends BaseType> = T extends 'Blob' ? Uint8Array : T extends 'Boolean' ? boolean : T extends 'Decimal' ? string : T extends 'Float4' ? number : T extends 'Float8' ? number : T extends 'Int1' ? number : T extends 'Int2' ? number : T extends 'Int4' ? number : T extends 'Int8' ? bigint : T extends 'Int16' ? bigint : T extends 'Uint1' ? number : T extends 'Uint2' ? number : T extends 'Uint4' ? number : T extends 'Uint8' ? bigint : T extends 'Uint16' ? bigint : T extends 'Utf8' ? string : T extends 'Date' ? Date : T extends 'DateTime' ? Date : T extends 'Time' ? string : T extends 'Duration' ? string : T extends 'Uuid4' ? string : T extends 'Uuid7' ? string : T extends 'None' ? undefined : T extends 'IdentityId' ? string : never;
972
- type PrimitiveToValue<T extends BaseType> = T extends 'Blob' ? BlobValue : T extends 'Boolean' ? BooleanValue : T extends 'Decimal' ? DecimalValue : T extends 'Float4' ? Float4Value : T extends 'Float8' ? Float8Value : T extends 'Int1' ? Int1Value : T extends 'Int2' ? Int2Value : T extends 'Int4' ? Int4Value : T extends 'Int8' ? Int8Value : T extends 'Int16' ? Int16Value : T extends 'Uint1' ? Uint1Value : T extends 'Uint2' ? Uint2Value : T extends 'Uint4' ? Uint4Value : T extends 'Uint8' ? Uint8Value : T extends 'Uint16' ? Uint16Value : T extends 'Utf8' ? Utf8Value : T extends 'Date' ? DateValue : T extends 'DateTime' ? DateTimeValue : T extends 'Time' ? TimeValue : T extends 'Duration' ? DurationValue : T extends 'Uuid4' ? Uuid4Value : T extends 'Uuid7' ? Uuid7Value : T extends 'None' ? NoneValue : T extends 'IdentityId' ? IdentityIdValue : never;
933
+ interface PrimitiveTSMap {
934
+ Blob: Uint8Array;
935
+ Boolean: boolean;
936
+ Decimal: string;
937
+ Float4: number;
938
+ Float8: number;
939
+ Int1: number;
940
+ Int2: number;
941
+ Int4: number;
942
+ Int8: bigint;
943
+ Int16: bigint;
944
+ Uint1: number;
945
+ Uint2: number;
946
+ Uint4: number;
947
+ Uint8: bigint;
948
+ Uint16: bigint;
949
+ Utf8: string;
950
+ Date: Date;
951
+ DateTime: Date;
952
+ Time: string;
953
+ Duration: string;
954
+ Uuid4: string;
955
+ Uuid7: string;
956
+ None: undefined;
957
+ IdentityId: string;
958
+ }
959
+ interface PrimitiveValueMap {
960
+ Blob: BlobValue;
961
+ Boolean: BooleanValue;
962
+ Decimal: DecimalValue;
963
+ Float4: Float4Value;
964
+ Float8: Float8Value;
965
+ Int1: Int1Value;
966
+ Int2: Int2Value;
967
+ Int4: Int4Value;
968
+ Int8: Int8Value;
969
+ Int16: Int16Value;
970
+ Uint1: Uint1Value;
971
+ Uint2: Uint2Value;
972
+ Uint4: Uint4Value;
973
+ Uint8: Uint8Value;
974
+ Uint16: Uint16Value;
975
+ Utf8: Utf8Value;
976
+ Date: DateValue;
977
+ DateTime: DateTimeValue;
978
+ Time: TimeValue;
979
+ Duration: DurationValue;
980
+ Uuid4: Uuid4Value;
981
+ Uuid7: Uuid7Value;
982
+ None: NoneValue;
983
+ IdentityId: IdentityIdValue;
984
+ }
985
+ type PrimitiveToTS<T extends BaseType> = PrimitiveTSMap[T];
986
+ type PrimitiveToValue<T extends BaseType> = PrimitiveValueMap[T];
987
+ type CamelCase<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S;
973
988
  type InferShape<S> = S extends PrimitiveShapeNode<infer T> ? T extends BaseType ? PrimitiveToTS<T> : never : S extends ValueShapeNode<infer T> ? T extends BaseType ? PrimitiveToValue<T> : never : S extends ObjectShapeNode<infer P> ? {
974
- [K in keyof P]: InferShape<P[K]>;
989
+ [K in keyof P as CamelCase<K & string>]: InferShape<P[K]>;
975
990
  } : S extends ArrayShapeNode<infer T> ? InferShape<T>[] : S extends OptionalShapeNode<infer T> ? InferShape<T> | undefined : never;
976
991
  type InferShapes<S extends readonly ShapeNode[]> = {
977
992
  [K in keyof S]: InferShape<S[K]>[];
@@ -1044,6 +1059,9 @@ declare function parseValue(shape: ShapeNode, value: any): any;
1044
1059
 
1045
1060
  declare function validateShape(shape: ShapeNode, value: any): boolean;
1046
1061
 
1062
+ declare function transformFrames<const S extends readonly ShapeNode[]>(frames: any[][], shapes: S): FrameResults<S>;
1063
+ declare function transformResult(row: any, resultShape: any): any;
1064
+
1047
1065
  interface PrimitiveShapeNode<T extends string = string> {
1048
1066
  kind: 'primitive';
1049
1067
  type: T;
@@ -1128,4 +1146,104 @@ type SingleFrameResult<S extends ShapeNode> = InferShape<S>[];
1128
1146
  */
1129
1147
  declare function asFrameResults<S extends readonly ShapeNode[]>(results: any): FrameResults<S>;
1130
1148
 
1131
- export { type ArrayShapeNode, type BaseType, BlobValue, BooleanValue, type Column, DateTimeValue, DateValue, DecimalValue, type Diagnostic, type DiagnosticColumn, DurationValue, type ErrorResponse, Float4Value, Float8Value, type Fragment, type Frame, type FrameResults, IdentityIdValue, type InferShape, type InferShapes, Int16Value, Int1Value, Int2Value, Int4Value, Int8Value, NONE_VALUE, NoneValue, type ObjectShapeNode, type OptionType, type OptionalShapeNode, type Params, type PrimitiveShapeNode, type PrimitiveToTS, type PrimitiveToValue, ReifyError, Shape, ShapeBuilder, type ShapeNode, type SingleFrameResult, TYPE_CODE, TimeValue, type Type, type TypeName, type TypeValuePair, Uint16Value, Uint1Value, Uint2Value, Uint4Value, Uint8Value, Utf8Value, Uuid4Value, Uuid7Value, Value, type ValueShapeNode, asFrameResults, decode, isOptionType, parseValue, type_name_from_code, unwrapOptionType, validateShape };
1149
+ declare function decode(pair: TypeValuePair): Value;
1150
+ declare function columnsToRows(columns: Column[]): Record<string, Value>[];
1151
+
1152
+ declare function encodeValue(value: any): TypeValuePair;
1153
+ declare function encodeParams(params: any): TypeValuePair[] | Record<string, TypeValuePair>;
1154
+
1155
+ declare const TYPE_CODE: {
1156
+ readonly None: 0;
1157
+ readonly Boolean: 1;
1158
+ readonly Float4: 2;
1159
+ readonly Float8: 3;
1160
+ readonly Int1: 4;
1161
+ readonly Int2: 5;
1162
+ readonly Int4: 6;
1163
+ readonly Int8: 7;
1164
+ readonly Int16: 8;
1165
+ readonly Utf8: 9;
1166
+ readonly Uint1: 10;
1167
+ readonly Uint2: 11;
1168
+ readonly Uint4: 12;
1169
+ readonly Uint8: 13;
1170
+ readonly Uint16: 14;
1171
+ readonly Date: 15;
1172
+ readonly DateTime: 16;
1173
+ readonly Time: 17;
1174
+ readonly Duration: 18;
1175
+ readonly IdentityId: 19;
1176
+ readonly Uuid4: 20;
1177
+ readonly Uuid7: 21;
1178
+ readonly Blob: 22;
1179
+ readonly Int: 23;
1180
+ readonly Uint: 24;
1181
+ readonly Decimal: 25;
1182
+ readonly Any: 26;
1183
+ readonly DictionaryId: 27;
1184
+ readonly Type: 28;
1185
+ readonly List: 29;
1186
+ readonly Record: 30;
1187
+ readonly Tuple: 31;
1188
+ };
1189
+ type TypeName = keyof typeof TYPE_CODE;
1190
+ declare function typeNameFromCode(code: number): TypeName;
1191
+
1192
+ interface MissingPresentation {
1193
+ text: string;
1194
+ italic: boolean;
1195
+ muted: boolean;
1196
+ }
1197
+ declare const NONE_PRESENTATION: MissingPresentation;
1198
+ type ValueRole = 'none' | 'boolean' | 'number' | 'temporal' | 'uuid' | 'string' | 'blob' | 'unknown';
1199
+ declare function valueTypeName(value: unknown): string | undefined;
1200
+ declare function valueRole(value: unknown): ValueRole;
1201
+ declare function formatValue(value: unknown): string;
1202
+
1203
+ declare function graphemeWidth(grapheme: string): number;
1204
+ declare function displayWidth(text: string): number;
1205
+ declare function truncateToWidth(text: string, width: number, ellipsis?: string): string;
1206
+ declare function padToWidth(text: string, width: number, align: 'left' | 'right' | 'center'): string;
1207
+
1208
+ type ColumnAlign = 'left' | 'right';
1209
+ interface ResultColumn {
1210
+ name: string;
1211
+ type?: string;
1212
+ role: ValueRole;
1213
+ align: ColumnAlign;
1214
+ }
1215
+ interface PlannedColumn {
1216
+ column: ResultColumn;
1217
+ width: number;
1218
+ }
1219
+ interface TablePlan {
1220
+ columns: PlannedColumn[];
1221
+ dropped: ResultColumn[];
1222
+ truncated: boolean;
1223
+ }
1224
+ interface TableLayoutOptions {
1225
+ width?: number;
1226
+ maxColumnWidth?: number;
1227
+ sample?: number;
1228
+ columnOverhead?: number;
1229
+ tableOverhead?: number;
1230
+ }
1231
+ declare function inferColumns(rows: ReadonlyArray<Record<string, unknown>>): ResultColumn[];
1232
+ declare function planTable(rows: ReadonlyArray<Record<string, unknown>>, columns: ReadonlyArray<ResultColumn>, options?: TableLayoutOptions): TablePlan;
1233
+ declare function cellText(value: unknown, width: number): string;
1234
+
1235
+ declare const RQL_KEYWORDS: readonly string[];
1236
+ declare const RQL_LITERALS: readonly string[];
1237
+ declare const RQL_TYPES: readonly string[];
1238
+ declare const RQL_OPERATORS: readonly string[];
1239
+ declare const RQL_SYSTEM_COLUMNS: readonly string[];
1240
+
1241
+ type RqlTokenKind = 'keyword' | 'type' | 'constant' | 'identifier' | 'namespace' | 'entity' | 'function' | 'key' | 'variable' | 'variable.predefined' | 'comment' | 'string' | 'number' | 'operator' | 'delimiter' | 'bracket' | 'white';
1242
+ interface RqlToken {
1243
+ kind: RqlTokenKind;
1244
+ start: number;
1245
+ end: number;
1246
+ }
1247
+ declare function tokenizeRql(source: string): RqlToken[];
1248
+
1249
+ export { type ArrayShapeNode, type BaseType, BlobValue, BooleanValue, type Column, type ColumnAlign, DateTimeValue, DateValue, DecimalValue, type Diagnostic, type DiagnosticColumn, DurationValue, type ErrorResponse, Float4Value, Float8Value, type Fragment, type Frame, type FrameResults, IdentityIdValue, type InferShape, type InferShapes, Int16Value, Int1Value, Int2Value, Int4Value, Int8Value, type MissingPresentation, NONE_PRESENTATION, NONE_VALUE, NoneValue, type ObjectShapeNode, type OptionType, type OptionalShapeNode, type Params, type PlannedColumn, type PrimitiveShapeNode, type PrimitiveToTS, type PrimitiveToValue, ROW_NUMBER_KEY, RQL_KEYWORDS, RQL_LITERALS, RQL_OPERATORS, RQL_SYSTEM_COLUMNS, RQL_TYPES, ReifyError, type ResultColumn, type RqlToken, type RqlTokenKind, Shape, ShapeBuilder, type ShapeNode, type SingleFrameResult, TYPE_CODE, type TableLayoutOptions, type TablePlan, TimeValue, type Type, type TypeName, type TypeValuePair, Uint16Value, Uint1Value, Uint2Value, Uint4Value, Uint8Value, Utf8Value, Uuid4Value, Uuid7Value, Value, type ValueRole, type ValueShapeNode, asFrameResults, cellText, columnsToRows, decode, displayWidth, encodeParams, encodeValue, formatValue, graphemeWidth, inferColumns, isOptionType, padToWidth, parseValue, planTable, tokenizeRql, transformFrames, transformResult, truncateToWidth, typeNameFromCode, unwrapOptionType, validateShape, valueRole, valueTypeName };