ticlo-tsdb 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,162 @@
1
+ import type { StorageBackend } from './backend.ts';
2
+ import type { TsdbStore } from './store.ts';
3
+ export type TimestampInput = number | Date | {
4
+ toMillis(): number;
5
+ };
6
+ export type StandardInterval = '15s' | '30s' | '1m' | '5m' | '10m' | '15m' | '30m' | '1h' | '3h' | '6h' | '12h' | '1d' | '1w' | '2w' | '1n' | '3n' | '6n' | '1y';
7
+ export type IntervalUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'n' | 'y';
8
+ export type IntervalString = StandardInterval | `${number}${IntervalUnit}`;
9
+ export type RollupType = 'avg' | 'min' | 'max' | 'sum' | 'count' | 'initial' | 'final' | 'first' | 'delta' | 'and' | 'or';
10
+ export type RollupTier = '15s' | '5m' | '1h' | '1d';
11
+ export type SeriesKind = 'number' | 'boolean' | 'value';
12
+ export type TierOption = boolean | {
13
+ enabled: boolean;
14
+ retentionMs?: number;
15
+ };
16
+ export type RawOption = boolean | {
17
+ enabled: boolean;
18
+ retentionMs?: number;
19
+ maxRecords?: number;
20
+ };
21
+ export type MemoryCacheConfig = boolean | {
22
+ enabled: boolean;
23
+ maxEntries?: number;
24
+ maxAgeMs?: number;
25
+ };
26
+ export interface SeriesConfig {
27
+ kind: SeriesKind;
28
+ raw?: RawOption;
29
+ rollup15s?: TierOption;
30
+ rollup5m?: TierOption;
31
+ rollup1h?: TierOption;
32
+ rollup1d?: TierOption;
33
+ memoryCache?: MemoryCacheConfig;
34
+ }
35
+ export interface NormalizedTierConfig {
36
+ enabled: boolean;
37
+ retentionMs?: number;
38
+ }
39
+ export interface NormalizedRawConfig {
40
+ enabled: boolean;
41
+ retentionMs?: number;
42
+ maxRecords?: number;
43
+ }
44
+ export interface NormalizedMemoryCacheConfig {
45
+ enabled: boolean;
46
+ maxEntries: number;
47
+ maxAgeMs?: number;
48
+ }
49
+ export interface NormalizedSeriesConfig {
50
+ kind: SeriesKind;
51
+ raw: NormalizedRawConfig;
52
+ rollup15s: NormalizedTierConfig;
53
+ rollup5m: NormalizedTierConfig;
54
+ rollup1h: NormalizedTierConfig;
55
+ rollup1d: NormalizedTierConfig;
56
+ memoryCache: NormalizedMemoryCacheConfig;
57
+ }
58
+ export interface SeriesMeta {
59
+ id: string;
60
+ dirKey: string;
61
+ config: NormalizedSeriesConfig;
62
+ }
63
+ export interface ValueCodec {
64
+ stringify(value: unknown): string;
65
+ parse(text: string): unknown;
66
+ }
67
+ export interface EncodedValueRecord {
68
+ ts: number;
69
+ isString: boolean;
70
+ /** Raw string when `isString` is true, codec-encoded text when false, or `null` for `undefined`. */
71
+ payload: string | null;
72
+ }
73
+ export interface StorageLimitOptions {
74
+ /** Total byte limit across all numeric/boolean series raw stores. */
75
+ rawNumericMaxBytes?: number;
76
+ /** Total byte limit across all non-numeric (`value`) series raw stores. */
77
+ rawValueMaxBytes?: number;
78
+ /** Total byte limit across all rollup tiers (`15s`, `5m`, `1h`, `1d`) combined. */
79
+ rollupMaxBytes?: number;
80
+ /** Target fraction of max size to trim down to when limit is exceeded (default: 0.7, range (0, 1)). */
81
+ trimTargetRatio?: number;
82
+ /** Minimum interval in ms between automatic size checks during flush (default: 0). */
83
+ checkIntervalMs?: number;
84
+ }
85
+ export interface ChunkSizeOptions {
86
+ /** Target max byte size per numeric raw chunk file (default: 65536). */
87
+ rawNumericChunkBytes?: number;
88
+ /** Target byte size threshold per value raw chunk file (default: 65536). */
89
+ rawValueChunkBytes?: number;
90
+ /** Maximum slots per rollup chunk file (default: 512). */
91
+ rollupChunkSlots?: number;
92
+ }
93
+ export interface StorageChunkInfo {
94
+ id: number;
95
+ minKey: number;
96
+ maxKey: number;
97
+ byteSize: number;
98
+ count: number;
99
+ }
100
+ export interface StorageUsageStats {
101
+ rawNumericBytes: number;
102
+ rawValueBytes: number;
103
+ rollupBytes: number;
104
+ rollupTierBytes: Record<RollupTier, number>;
105
+ }
106
+ export interface TsdbOptions {
107
+ dir?: string;
108
+ backend?: StorageBackend;
109
+ store?: TsdbStore;
110
+ valueCodec?: ValueCodec;
111
+ timezone?: string;
112
+ weekStartsOn?: 0 | 1;
113
+ flushIntervalMs?: number;
114
+ defaultSeriesConfig?: Partial<Omit<SeriesConfig, 'kind'>>;
115
+ storageLimits?: StorageLimitOptions;
116
+ chunkSize?: ChunkSizeOptions;
117
+ }
118
+ export interface NumericQueryOptions {
119
+ start: TimestampInput;
120
+ end: TimestampInput;
121
+ interval?: IntervalString | null;
122
+ rollup?: RollupType;
123
+ limit?: number;
124
+ useMemoryCache?: boolean;
125
+ }
126
+ export interface NumericPoint {
127
+ ts: number;
128
+ value: number;
129
+ }
130
+ export interface NumericColumnResult {
131
+ timestamps: Float64Array;
132
+ values: Float64Array;
133
+ length: number;
134
+ interval: IntervalString | null;
135
+ fallbackInterval?: IntervalString;
136
+ hybridSplitTs?: number;
137
+ truncated: boolean;
138
+ timezone: string;
139
+ }
140
+ export interface NumericQueryResult {
141
+ points: NumericPoint[];
142
+ interval: IntervalString | null;
143
+ fallbackInterval?: IntervalString;
144
+ hybridSplitTs?: number;
145
+ truncated: boolean;
146
+ timezone: string;
147
+ }
148
+ export interface ValueQueryOptions {
149
+ start: TimestampInput;
150
+ end: TimestampInput;
151
+ limit?: number;
152
+ order?: 'asc' | 'desc';
153
+ }
154
+ export interface ValuePoint {
155
+ ts: number;
156
+ value: unknown;
157
+ }
158
+ export interface ValueQueryResult {
159
+ points: ValuePoint[];
160
+ truncated: boolean;
161
+ timezone: string;
162
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "ticlo-tsdb",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "High-performance embedded TypeScript time-series database with configurable dense rollups",
5
+ "license": "MPL-2.0",
6
+ "author": {
7
+ "name": "Rick Zhou",
8
+ "email": "rinick@gmail.com"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "type": "module",
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "tsgo -p tsconfig.build.json",
26
+ "test": "node --test test/*.test.ts",
27
+ "bench": "node bench/benchmark.ts",
28
+ "prepublishOnly": "npm run build && npm test"
29
+ },
30
+ "dependencies": {},
31
+ "devDependencies": {
32
+ "@types/node": "^26.5.0",
33
+ "@typescript/native-preview": "7.0.0-dev.20260707.2"
34
+ },
35
+ "engines": {
36
+ "node": ">=24.0.0"
37
+ }
38
+ }