@tinyshed/tinystore 0.1.0-rc.5 → 0.1.0-rc.6
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/README.md +37 -37
- package/bin/tinystore.js +12 -1
- package/dist/backup.d.ts +33 -0
- package/dist/backup.js +49 -0
- package/dist/blobs.d.ts +160 -79
- package/dist/blobs.js +510 -217
- package/dist/channels.d.ts +90 -0
- package/dist/channels.js +291 -0
- package/dist/clock.js +3 -3
- package/dist/config.d.ts +209 -86
- package/dist/config.js +581 -538
- package/dist/connection.d.ts +64 -2
- package/dist/connection.js +201 -16
- package/dist/console.d.ts +27 -3
- package/dist/console.js +165 -12
- package/dist/dotenv.d.ts +7 -0
- package/dist/dotenv.js +79 -0
- package/dist/errors.d.ts +61 -1
- package/dist/errors.js +81 -1
- package/dist/handles.d.ts +44 -2
- package/dist/handles.js +81 -2
- package/dist/index.d.ts +17 -11
- package/dist/index.js +5 -3
- package/dist/instruments.d.ts +177 -0
- package/dist/instruments.js +819 -0
- package/dist/jobs.d.ts +335 -239
- package/dist/jobs.js +716 -536
- package/dist/json.d.ts +2 -0
- package/dist/json.js +122 -0
- package/dist/kv.d.ts +130 -243
- package/dist/kv.js +273 -640
- package/dist/limits.d.ts +80 -0
- package/dist/limits.js +139 -0
- package/dist/locks.d.ts +62 -0
- package/dist/locks.js +237 -0
- package/dist/logger.d.ts +45 -9
- package/dist/logger.js +150 -38
- package/dist/metrics.d.ts +210 -209
- package/dist/metrics.js +319 -556
- package/dist/once.d.ts +19 -18
- package/dist/once.js +74 -63
- package/dist/query.d.ts +181 -0
- package/dist/query.js +788 -0
- package/dist/records.d.ts +241 -150
- package/dist/records.js +507 -291
- package/dist/runtime/addon.d.ts +14 -0
- package/dist/runtime/addon.js +69 -0
- package/dist/runtime/bun.js +5 -7
- package/dist/runtime/node.js +5 -7
- package/dist/runtime/pipe.d.ts +17 -0
- package/dist/runtime/pipe.js +133 -0
- package/dist/runtime/shared.d.ts +6 -0
- package/dist/runtime/shared.js +19 -0
- package/dist/runtime.d.ts +5 -2
- package/dist/search.d.ts +189 -0
- package/dist/search.js +281 -0
- package/dist/session.d.ts +31 -3
- package/dist/session.js +153 -41
- package/dist/sql.d.ts +228 -78
- package/dist/sql.js +745 -240
- package/dist/store.d.ts +244 -24
- package/dist/store.js +270 -67
- package/dist/time.d.ts +5 -1
- package/dist/time.js +22 -2
- package/dist/tx.d.ts +61 -0
- package/dist/tx.js +314 -0
- package/dist/wire/codec.d.ts +23 -7
- package/dist/wire/codec.js +56 -35
- package/dist/wire/frame.d.ts +2 -0
- package/dist/wire/frame.js +31 -14
- package/dist/wire/messages.d.ts +259 -0
- package/dist/wire/messages.js +22 -0
- package/dist/wire/msgpack.d.ts +49 -1
- package/dist/wire/msgpack.js +293 -56
- package/dist/wire/protocol.d.ts +2683 -0
- package/dist/wire/protocol.js +10846 -0
- package/package.json +39 -38
- package/src/backup.ts +81 -0
- package/src/blobs.ts +678 -301
- package/src/channels.ts +377 -0
- package/src/clock.ts +4 -4
- package/src/config.ts +902 -612
- package/src/connection.ts +279 -21
- package/src/console.ts +180 -12
- package/src/dotenv.ts +82 -0
- package/src/errors.ts +105 -0
- package/src/handles.ts +157 -8
- package/src/index.ts +158 -52
- package/src/instruments.ts +1042 -0
- package/src/jobs.ts +1017 -733
- package/src/json.ts +133 -0
- package/src/kv.ts +424 -847
- package/src/limits.ts +202 -0
- package/src/locks.ts +320 -0
- package/src/logger.ts +209 -40
- package/src/metrics.ts +557 -752
- package/src/once.ts +86 -83
- package/src/query.ts +1005 -0
- package/src/records.ts +795 -418
- package/src/runtime/addon.ts +99 -0
- package/src/runtime/bun.ts +5 -7
- package/src/runtime/node.ts +5 -7
- package/src/runtime/pipe.ts +178 -0
- package/src/runtime/shared.ts +20 -0
- package/src/runtime.ts +5 -2
- package/src/search.ts +480 -0
- package/src/session.ts +187 -41
- package/src/sql.ts +993 -306
- package/src/store.ts +473 -78
- package/src/time.ts +48 -3
- package/src/tx.ts +426 -0
- package/src/wire/codec.ts +78 -37
- package/src/wire/frame.ts +44 -14
- package/src/wire/messages.ts +25 -0
- package/src/wire/msgpack.ts +327 -56
- package/src/wire/protocol.ts +11709 -0
- package/dist/limiter.d.ts +0 -45
- package/dist/limiter.js +0 -68
- package/dist/quota.d.ts +0 -44
- package/dist/quota.js +0 -98
- package/src/limiter.ts +0 -99
- package/src/quota.ts +0 -137
package/dist/records.d.ts
CHANGED
|
@@ -1,182 +1,273 @@
|
|
|
1
1
|
import { type Link } from './connection.ts';
|
|
2
|
-
import type
|
|
3
|
-
import { type Logger, type LoggerOptions } from './logger.ts';
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { type ConsoleLine } from './console.ts';
|
|
3
|
+
import { type LogConfig, type Logger, type LoggerOptions } from './logger.ts';
|
|
4
|
+
import type { Stream } from './session.ts';
|
|
5
|
+
import { type Duration, type DurationText } from './time.ts';
|
|
6
|
+
import { methods } from './wire/protocol.ts';
|
|
7
|
+
/** A level a logger logs at: one of its four names, or slog's number between them. */
|
|
6
8
|
export type Level = 'debug' | 'info' | 'warn' | 'error' | number;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
9
|
+
/** An event's level: what loggers and the programs whose lines are kept write. */
|
|
10
|
+
export type EventLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
11
|
+
/** What happened, or what it happened in: an object, or its pairs in their order. */
|
|
11
12
|
export type Fields = Record<string, unknown> | readonly (readonly [string, unknown])[];
|
|
12
|
-
/**
|
|
13
|
-
export interface
|
|
14
|
-
/** its time
|
|
15
|
-
at
|
|
16
|
-
/** the namespace the application names: 'web', 'billing' */
|
|
13
|
+
/** An event as a read gives it. */
|
|
14
|
+
export interface Event {
|
|
15
|
+
/** its time, which the file keeps to the nanosecond */
|
|
16
|
+
at: Date;
|
|
17
17
|
stream: string;
|
|
18
|
-
/**
|
|
18
|
+
/** what happened; `log` for a logger's line */
|
|
19
19
|
name: string;
|
|
20
|
-
level?:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/** what happened */
|
|
30
|
-
attrs?: Fields;
|
|
20
|
+
level?: EventLevel;
|
|
21
|
+
message?: string;
|
|
22
|
+
/** each value as JSON.parse reads it, an integer past 2^53 a bigint */
|
|
23
|
+
fields: Record<string, unknown>;
|
|
24
|
+
context: Record<string, unknown>;
|
|
25
|
+
/** 32 hex digits */
|
|
26
|
+
traceId?: string;
|
|
27
|
+
/** 16 hex digits */
|
|
28
|
+
spanId?: string;
|
|
31
29
|
}
|
|
32
|
-
/**
|
|
33
|
-
export interface
|
|
34
|
-
/** unix nanoseconds */
|
|
35
|
-
at: bigint;
|
|
36
|
-
stream: string;
|
|
30
|
+
/** An event to append: its name, what happened, and what it carries beside. */
|
|
31
|
+
export interface NewEvent {
|
|
37
32
|
name: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
fields?: Fields;
|
|
34
|
+
/** its time: now unless given, from what the stream keeps to ten minutes ahead */
|
|
35
|
+
at?: Date;
|
|
36
|
+
context?: Fields;
|
|
37
|
+
level?: EventLevel | number;
|
|
38
|
+
message?: string;
|
|
39
|
+
/** a trace's 32 hex digits, with its span's 16: the current trace's unless given */
|
|
40
|
+
traceId?: string;
|
|
41
|
+
spanId?: string;
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* const { page, from } = fields(record.attrs)
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare function fields(pairs: LogRecord['attrs']): Record<string, unknown>;
|
|
58
|
-
/**
|
|
59
|
-
* The records in a range that meet every condition given.
|
|
60
|
-
*
|
|
61
|
-
* ```ts
|
|
62
|
-
* { since: '1h', minLevel: 'warn' } // the last hour's warnings
|
|
63
|
-
* { since: '1h', search: 'connection reset' } // whose text holds it, case ignored
|
|
64
|
-
* { from: start, to: end, streams: ['api'] }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export interface RecordsQuery {
|
|
68
|
-
/** the span before now the range covers: '1h', '15m', or milliseconds; or from and to */
|
|
43
|
+
export type AppendOptions = Omit<NewEvent, 'name' | 'fields'>;
|
|
44
|
+
export interface EventsOptions {
|
|
45
|
+
/** how long the stream keeps its events: its own, kept in the file; 14 days until one says */
|
|
46
|
+
keep?: Duration;
|
|
47
|
+
}
|
|
48
|
+
/** What a read finds: every condition given holds; one given as undefined is InvalidError. */
|
|
49
|
+
export interface Query {
|
|
50
|
+
/** the span before now, '1h'; or from and to */
|
|
69
51
|
since?: Duration;
|
|
70
|
-
/** the range's start, included
|
|
71
|
-
from?: Date
|
|
72
|
-
/** the range's end, excluded
|
|
73
|
-
to?: Date
|
|
74
|
-
/**
|
|
75
|
-
streams?: string[];
|
|
76
|
-
names
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* text a record's body or name holds, its case ignored: every record the
|
|
85
|
-
* rest of the query leaves is read for it, so a search over much text ends
|
|
86
|
-
* pages early at the budget, and next goes on
|
|
87
|
-
*/
|
|
52
|
+
/** the range's start, included */
|
|
53
|
+
from?: Date;
|
|
54
|
+
/** the range's end, excluded */
|
|
55
|
+
to?: Date;
|
|
56
|
+
/** any of these streams, for every stream's read */
|
|
57
|
+
streams?: readonly string[];
|
|
58
|
+
/** any of these names: ['log'] is the lines */
|
|
59
|
+
names?: readonly string[];
|
|
60
|
+
/** this level and worse; an event without a level is not found */
|
|
61
|
+
minLevel?: EventLevel;
|
|
62
|
+
traceId?: string;
|
|
63
|
+
/** each key with this value, by the JSON it was written as, in fields or in context */
|
|
64
|
+
where?: Record<string, unknown>;
|
|
65
|
+
/** this text in the message, the name or a value, its case ignored */
|
|
88
66
|
search?: string;
|
|
89
|
-
/** newest first; oldest first
|
|
67
|
+
/** newest first; oldest first without it */
|
|
90
68
|
newest?: boolean;
|
|
91
|
-
/** the
|
|
69
|
+
/** the events of a page: 1000, and 10,000 at most */
|
|
92
70
|
limit?: number;
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
after
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export interface
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
/** A row
|
|
71
|
+
/** a page's next, with the rest of the query as it was */
|
|
72
|
+
after?: string;
|
|
73
|
+
}
|
|
74
|
+
/** A query of every event it finds, for what counts them. */
|
|
75
|
+
export type Counted = Omit<Query, 'newest' | 'limit' | 'after'>;
|
|
76
|
+
export interface Page {
|
|
77
|
+
events: Event[];
|
|
78
|
+
/** the page after it; the last page has none */
|
|
79
|
+
next?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface Top {
|
|
82
|
+
value: unknown;
|
|
83
|
+
count: number;
|
|
84
|
+
}
|
|
85
|
+
/** A field's numbers in a row: a sum of integers exact, a bigint past 2^53. */
|
|
86
|
+
export interface Stats {
|
|
87
|
+
samples: number;
|
|
88
|
+
sum: number | bigint;
|
|
89
|
+
min: number | bigint;
|
|
90
|
+
max: number | bigint;
|
|
91
|
+
avg: number;
|
|
92
|
+
}
|
|
93
|
+
export interface Row {
|
|
94
|
+
/** where the row's span begins, counted from 1970 in UTC */
|
|
95
|
+
at: Date;
|
|
96
|
+
count: number;
|
|
97
|
+
by: Record<string, unknown>;
|
|
98
|
+
stats: Record<string, Stats>;
|
|
99
|
+
distinct: Record<string, number>;
|
|
100
|
+
}
|
|
101
|
+
export interface Aggregate extends Counted {
|
|
102
|
+
/** the span of a row: the range is one without it */
|
|
103
|
+
every?: Duration;
|
|
104
|
+
/** keys whose every value has rows of its own */
|
|
105
|
+
by?: readonly string[];
|
|
106
|
+
/** fields whose numbers a row sums */
|
|
107
|
+
stats?: readonly string[];
|
|
108
|
+
/** fields whose different values a row counts */
|
|
109
|
+
distinct?: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
export interface StreamInfo {
|
|
112
|
+
name: string;
|
|
113
|
+
keep: DurationText;
|
|
114
|
+
/** its oldest event, or where its keep begins while it holds older */
|
|
115
|
+
retainedFrom: Date;
|
|
116
|
+
newest: Date;
|
|
117
|
+
}
|
|
118
|
+
export interface PollBatch {
|
|
119
|
+
events: Event[];
|
|
120
|
+
/** where the next poll begins, kept once these events are safe */
|
|
121
|
+
cursor: string;
|
|
122
|
+
/** the events keep removed before the cursor reached them */
|
|
123
|
+
expired: number;
|
|
124
|
+
}
|
|
125
|
+
/** What a tail finds: a query's conditions, and no range, order or limit. */
|
|
126
|
+
export type TailQuery = Pick<Query, 'streams' | 'names' | 'minLevel' | 'traceId' | 'where' | 'search'>;
|
|
127
|
+
/** A tail's batch: the events written since the last, and how many it missed. */
|
|
128
|
+
export interface TailBatch {
|
|
129
|
+
events: Event[];
|
|
130
|
+
/** the events that left the store's hold before the tail read them */
|
|
131
|
+
missed: number;
|
|
132
|
+
}
|
|
133
|
+
/** A head row or a segment that no longer reads, as `damaged` lists it and `drop` takes it. */
|
|
108
134
|
export interface Damage {
|
|
135
|
+
/** a head row holds events not packed yet, a segment packed ones */
|
|
136
|
+
part: 'head row' | 'segment';
|
|
137
|
+
id: number;
|
|
109
138
|
stream: string;
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
/** its events' oldest and newest times */
|
|
140
|
+
first: Date;
|
|
141
|
+
last: Date;
|
|
142
|
+
/** what broke */
|
|
143
|
+
error: string;
|
|
144
|
+
}
|
|
145
|
+
type Method = keyof typeof methods;
|
|
146
|
+
/** What every read takes: a stream's handle, or every stream without one. */
|
|
147
|
+
declare abstract class Reads {
|
|
148
|
+
protected abstract ask(method: Method, body: (handle: number | undefined) => Uint8Array): Promise<Uint8Array>;
|
|
149
|
+
protected abstract opened(method: Method, body: (handle: number | undefined) => Uint8Array): Promise<Stream>;
|
|
150
|
+
/** One page, from one moment of the file: `{ events, next }`. */
|
|
151
|
+
list(query?: Query): Promise<Page>;
|
|
152
|
+
/** Every event the query finds, a page after another. */
|
|
153
|
+
all(query?: Query): AsyncGenerator<Event>;
|
|
154
|
+
/** How many events the query finds. */
|
|
155
|
+
count(query?: Counted): Promise<number>;
|
|
122
156
|
/**
|
|
123
|
-
* A
|
|
124
|
-
*
|
|
157
|
+
* A key's most frequent values and how many events hold each: ten unless
|
|
158
|
+
* `limit` asks for more, at most 1000. The key is a field's or a
|
|
159
|
+
* context's, or `stream`, `name` or `level`.
|
|
125
160
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
161
|
+
top(key: string, query?: Counted & {
|
|
162
|
+
limit?: number;
|
|
163
|
+
}): Promise<Top[]>;
|
|
164
|
+
/** A row for each span of `every` and each value of the keys of `by`, with its count. */
|
|
165
|
+
aggregate(query?: Aggregate): Promise<Row[]>;
|
|
166
|
+
/** The keys the events hold, in fields and in context, sorted; `prefix` narrows them. */
|
|
167
|
+
fieldNames(query?: Omit<Query, 'newest' | 'after'> & {
|
|
168
|
+
prefix?: string;
|
|
169
|
+
}): Promise<string[]>;
|
|
129
170
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
171
|
+
* The events written from now on that the query finds, a batch as they
|
|
172
|
+
* are written: `{ events, missed }`. A reader slower than the writers
|
|
173
|
+
* skips what left the store's hold, and the batch after says how many.
|
|
174
|
+
* It ends when its loop is left, and when the server's store closes.
|
|
133
175
|
*/
|
|
134
|
-
|
|
176
|
+
tail(query?: TailQuery): AsyncGenerator<TailBatch>;
|
|
177
|
+
}
|
|
178
|
+
/** Opens a stream of events: lazily, at its first call on a connection. */
|
|
179
|
+
export declare function openEvents(link: Link, stream: string, options?: EventsOptions): Events;
|
|
180
|
+
/** A stream of events: written with `append`, which waits for the file, and read back. */
|
|
181
|
+
export declare class Events extends Reads {
|
|
182
|
+
#private;
|
|
183
|
+
readonly stream: string;
|
|
184
|
+
/** Events come from `store.events(stream)`. */
|
|
185
|
+
constructor(link: Link, stream: string, open: Uint8Array);
|
|
135
186
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
187
|
+
* Writes an event, or a list of them whole or not at all: it returns once
|
|
188
|
+
* they are written, and a read finds them at once. A refused event names
|
|
189
|
+
* its place in the list and its name.
|
|
139
190
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
191
|
+
append(name: string, fields?: Fields, options?: AppendOptions): Promise<void>;
|
|
192
|
+
append(events: readonly NewEvent[]): Promise<void>;
|
|
193
|
+
/** A logger's lines, each an event of this stream. */
|
|
194
|
+
appendLines(lines: readonly ConsoleLine[]): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* A writer of another program's output into this stream: each line it is
|
|
197
|
+
* given becomes an event at the time it arrived, a stack trace's or a JSON
|
|
198
|
+
* value's lines one, and a write never waits.
|
|
199
|
+
*
|
|
200
|
+
* const out = store.events('worker').lines()
|
|
201
|
+
* child.stdout.on('data', chunk => out.write(chunk))
|
|
202
|
+
* child.on('close', () => out.end())
|
|
203
|
+
*/
|
|
204
|
+
lines(): Lines;
|
|
205
|
+
protected ask(method: Method, body: (handle: number | undefined) => Uint8Array): Promise<Uint8Array>;
|
|
206
|
+
protected opened(method: Method, body: (handle: number | undefined) => Uint8Array): Promise<Stream>;
|
|
207
|
+
}
|
|
208
|
+
/** Every stream's events, to read: `store.events()`. */
|
|
209
|
+
export declare class AllEvents extends Reads {
|
|
210
|
+
#private;
|
|
211
|
+
/** AllEvents come from `store.events()`. */
|
|
212
|
+
constructor(link: Link);
|
|
213
|
+
/** Every stream with events, by name, with what it keeps, where that begins and its newest event's time. */
|
|
214
|
+
streams(): Promise<StreamInfo[]>;
|
|
143
215
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* the cursor
|
|
216
|
+
* Every event once, a batch a call, from a cursor the program keeps, the
|
|
217
|
+
* oldest event kept without one: `{ events, cursor, expired }`. With no
|
|
218
|
+
* event past the cursor, the batch is empty and its cursor the one given.
|
|
147
219
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}>;
|
|
220
|
+
poll(cursor?: string, options?: {
|
|
221
|
+
limit?: number;
|
|
222
|
+
}): Promise<PollBatch>;
|
|
223
|
+
protected ask(method: Method, body: (handle: number | undefined) => Uint8Array): Promise<Uint8Array>;
|
|
153
224
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* fields kept. What does not fit its buffer is dropped and counted.
|
|
225
|
+
* What reads met that no longer reads, which `drop` removes: each head
|
|
226
|
+
* row and segment with its stream and its events' times. What the store
|
|
227
|
+
* has not met since it opened is not listed.
|
|
158
228
|
*/
|
|
159
|
-
lines(stream: string, options?: {
|
|
160
|
-
buffer?: number;
|
|
161
|
-
}): LinesWriter;
|
|
162
|
-
/** The rows the server's records have met that no longer read. */
|
|
163
229
|
damaged(): Promise<Damage[]>;
|
|
164
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* Removes a head row or a segment that `damaged` listed, so that the
|
|
232
|
+
* reads over it work again; what still reads is refused.
|
|
233
|
+
*
|
|
234
|
+
* for (const damage of await store.events().damaged()) await store.events().drop(damage)
|
|
235
|
+
*/
|
|
165
236
|
drop(damage: Damage): Promise<void>;
|
|
237
|
+
protected opened(method: Method, body: (handle: number | undefined) => Uint8Array): Promise<Stream>;
|
|
238
|
+
}
|
|
239
|
+
/** A writer's stream, and the bytes a piece of it carries. */
|
|
240
|
+
interface Opened {
|
|
241
|
+
stream: Stream;
|
|
242
|
+
piece: number;
|
|
166
243
|
}
|
|
167
244
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* uploads on the next connection.
|
|
245
|
+
* A writer of another program's output into a stream, as `events.lines()`
|
|
246
|
+
* begins it: each line becomes an event, and a write never waits. It sends
|
|
247
|
+
* whole lines, so that what it has no room for, `dropped` counts as lines.
|
|
172
248
|
*/
|
|
173
|
-
export declare class
|
|
249
|
+
export declare class Lines {
|
|
174
250
|
#private;
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
251
|
+
/** Lines come from `events.lines()`. */
|
|
252
|
+
constructor(open: () => Promise<Opened>);
|
|
253
|
+
/** The lines dropped: past what the writer holds, and, once it ended, by the store. */
|
|
254
|
+
get dropped(): number;
|
|
255
|
+
/** Takes a piece of output, cut anywhere; it never waits. */
|
|
256
|
+
write(chunk: Uint8Array | string): void;
|
|
257
|
+
/**
|
|
258
|
+
* Ends the writer: what it holds goes, a last line without its newline
|
|
259
|
+
* too, and it returns once the store wrote them.
|
|
260
|
+
*/
|
|
181
261
|
end(): Promise<void>;
|
|
182
262
|
}
|
|
263
|
+
/** What a store's logger is told: a logger's options, and how long its stream keeps. */
|
|
264
|
+
export interface StoreLoggerOptions extends LoggerOptions {
|
|
265
|
+
/** how long the stream keeps its events, as store.events takes it */
|
|
266
|
+
keep?: Duration;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A logger of `stream` that keeps its lines there through an append of their
|
|
270
|
+
* own, and what it declares its config `log` with.
|
|
271
|
+
*/
|
|
272
|
+
export declare function storeLogger(link: Link, stream: string, options?: StoreLoggerOptions): [Logger, LogConfig];
|
|
273
|
+
export {};
|