@bazariodev/docket 0.0.0-stage → 1.0.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.
- package/CHANGELOG.md +37 -0
- package/LICENSE +21 -0
- package/README.md +985 -2
- package/dist/browser/constants.d.cts +14 -0
- package/dist/browser/constants.d.ts +14 -0
- package/dist/browser/index.cjs +192 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +29 -0
- package/dist/browser/index.d.ts +29 -0
- package/dist/browser/index.js +187 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/chunk-7ld72rnl.js +376 -0
- package/dist/chunk-7ld72rnl.js.map +1 -0
- package/dist/chunk-BLf-eCDO.cjs +53 -0
- package/dist/chunk-BLf-eCDO.cjs.map +1 -0
- package/dist/chunk-CEhpwtwJ.cjs +379 -0
- package/dist/chunk-CEhpwtwJ.cjs.map +1 -0
- package/dist/chunk-CSS3f4_M.js +46 -0
- package/dist/chunk-CSS3f4_M.js.map +1 -0
- package/dist/chunk-CXZYNALm.cjs +124 -0
- package/dist/chunk-CXZYNALm.cjs.map +1 -0
- package/dist/chunk-DYcNnkOV.js +50 -0
- package/dist/chunk-DYcNnkOV.js.map +1 -0
- package/dist/chunk-DkvWLziD.js +437 -0
- package/dist/chunk-DkvWLziD.js.map +1 -0
- package/dist/chunk-DqK_3eFr.cjs +53 -0
- package/dist/chunk-DqK_3eFr.cjs.map +1 -0
- package/dist/chunk-LRCHwVuE.js +110 -0
- package/dist/chunk-LRCHwVuE.js.map +1 -0
- package/dist/chunk-ieB8yTEn.cjs +439 -0
- package/dist/chunk-ieB8yTEn.cjs.map +1 -0
- package/dist/client/index.cjs +167 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +40 -0
- package/dist/client/index.d.ts +40 -0
- package/dist/client/index.js +165 -0
- package/dist/client/index.js.map +1 -0
- package/dist/constants.d.cts +4 -0
- package/dist/constants.d.ts +4 -0
- package/dist/core/constants.d.cts +43 -0
- package/dist/core/constants.d.ts +43 -0
- package/dist/devtools/index.cjs +37 -0
- package/dist/devtools/index.cjs.map +1 -0
- package/dist/devtools/index.d.cts +11 -0
- package/dist/devtools/index.d.ts +11 -0
- package/dist/devtools/index.js +35 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/export/index.cjs +139 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +49 -0
- package/dist/export/index.d.ts +49 -0
- package/dist/export/index.js +137 -0
- package/dist/export/index.js.map +1 -0
- package/dist/history/index.cjs +30 -0
- package/dist/history/index.cjs.map +1 -0
- package/dist/history/index.d.cts +11 -0
- package/dist/history/index.d.ts +11 -0
- package/dist/history/index.js +28 -0
- package/dist/history/index.js.map +1 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +159 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/indexeddb/index.cjs +26 -0
- package/dist/indexeddb/index.cjs.map +1 -0
- package/dist/indexeddb/index.d.cts +61 -0
- package/dist/indexeddb/index.d.ts +61 -0
- package/dist/indexeddb/index.js +23 -0
- package/dist/indexeddb/index.js.map +1 -0
- package/dist/redaction/index.cjs +154 -0
- package/dist/redaction/index.cjs.map +1 -0
- package/dist/redaction/index.d.cts +70 -0
- package/dist/redaction/index.d.ts +70 -0
- package/dist/redaction/index.js +152 -0
- package/dist/redaction/index.js.map +1 -0
- package/dist/sip/index.cjs +336 -0
- package/dist/sip/index.cjs.map +1 -0
- package/dist/sip/index.d.cts +34 -0
- package/dist/sip/index.d.ts +34 -0
- package/dist/sip/index.js +333 -0
- package/dist/sip/index.js.map +1 -0
- package/dist/storage/constants.d.cts +11 -0
- package/dist/storage/constants.d.ts +11 -0
- package/dist/storage/contracts.d.cts +31 -0
- package/dist/storage/contracts.d.ts +31 -0
- package/dist/upload/constants.d.cts +17 -0
- package/dist/upload/constants.d.ts +17 -0
- package/dist/upload/index.cjs +246 -0
- package/dist/upload/index.cjs.map +1 -0
- package/dist/upload/index.d.cts +51 -0
- package/dist/upload/index.d.ts +51 -0
- package/dist/upload/index.js +244 -0
- package/dist/upload/index.js.map +1 -0
- package/package.json +150 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LEVELS,
|
|
3
|
+
LIMITS,
|
|
4
|
+
LOGGING_ERROR_CODES,
|
|
5
|
+
LOGGING_ERROR_SOURCES,
|
|
6
|
+
STORE_MODES,
|
|
7
|
+
} from "./constants.cjs";
|
|
8
|
+
|
|
9
|
+
type ValueOf<Values> = Values[keyof Values];
|
|
10
|
+
export type LogLevel = ValueOf<typeof LEVELS>;
|
|
11
|
+
export type LogValue =
|
|
12
|
+
| null
|
|
13
|
+
| boolean
|
|
14
|
+
| number
|
|
15
|
+
| string
|
|
16
|
+
| readonly LogValue[]
|
|
17
|
+
| { readonly [key: string]: LogValue };
|
|
18
|
+
export type LogFields = Readonly<Record<string, LogValue>>;
|
|
19
|
+
export type LogContext = Readonly<Record<string, string | number>>;
|
|
20
|
+
export type SerializedError = Readonly<{
|
|
21
|
+
name: string;
|
|
22
|
+
message: string;
|
|
23
|
+
stack?: string;
|
|
24
|
+
fields?: Readonly<Record<string, LogValue>>;
|
|
25
|
+
cause?: SerializedError;
|
|
26
|
+
errors?: readonly SerializedError[];
|
|
27
|
+
}>;
|
|
28
|
+
export type LogRecord = Readonly<{
|
|
29
|
+
runId: string;
|
|
30
|
+
seq: number;
|
|
31
|
+
at: number;
|
|
32
|
+
level: LogLevel;
|
|
33
|
+
area: string;
|
|
34
|
+
scope: string;
|
|
35
|
+
message: string;
|
|
36
|
+
redactionVersion: string;
|
|
37
|
+
fields?: LogFields;
|
|
38
|
+
context?: LogContext;
|
|
39
|
+
error?: SerializedError;
|
|
40
|
+
truncated?: true;
|
|
41
|
+
}>;
|
|
42
|
+
export type LogDraft = Readonly<
|
|
43
|
+
Omit<LogRecord, 'fields' | 'error' | 'redactionVersion' | 'truncated'> & {
|
|
44
|
+
data?: unknown;
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
47
|
+
export type Logger = Readonly<{
|
|
48
|
+
debug: (message: string, data?: unknown) => void;
|
|
49
|
+
info: (message: string, data?: unknown) => void;
|
|
50
|
+
warn: (message: string, data?: unknown) => void;
|
|
51
|
+
error: (message: string, data?: unknown) => void;
|
|
52
|
+
child: (
|
|
53
|
+
binding: Readonly<{ scope?: string; context?: LogContext }>,
|
|
54
|
+
) => Logger;
|
|
55
|
+
}>;
|
|
56
|
+
export type AreaDefinition<TArea extends string = string> = Readonly<{
|
|
57
|
+
id: TArea;
|
|
58
|
+
level?: LogLevel;
|
|
59
|
+
}>;
|
|
60
|
+
export type LevelState = Readonly<{
|
|
61
|
+
level: LogLevel;
|
|
62
|
+
defaultLevel: LogLevel;
|
|
63
|
+
until?: number;
|
|
64
|
+
}>;
|
|
65
|
+
export type LoggingScheduler = Readonly<{
|
|
66
|
+
setTimeout: (callback: () => void, delayMs: number) => unknown;
|
|
67
|
+
clearTimeout: (handle: unknown) => void;
|
|
68
|
+
}>;
|
|
69
|
+
export type KeyValueStorage = Readonly<{
|
|
70
|
+
getItem: (key: string) => string | null;
|
|
71
|
+
setItem: (key: string, value: string) => void;
|
|
72
|
+
}>;
|
|
73
|
+
export type LoggingErrorSource = ValueOf<typeof LOGGING_ERROR_SOURCES>;
|
|
74
|
+
export type LoggingError = Error &
|
|
75
|
+
Readonly<{ code: ValueOf<typeof LOGGING_ERROR_CODES> }>;
|
|
76
|
+
export type LoggingOptions<TArea extends string> = Readonly<{
|
|
77
|
+
areas: readonly AreaDefinition<TArea>[];
|
|
78
|
+
redactor: Redactor;
|
|
79
|
+
sinks?: readonly LogSink[];
|
|
80
|
+
context?: LogContext;
|
|
81
|
+
levelStorage?: Readonly<{ storage: KeyValueStorage; key: string }>;
|
|
82
|
+
maxOverrideMs?: number;
|
|
83
|
+
stormLimit?: number | false;
|
|
84
|
+
scheduler?: LoggingScheduler;
|
|
85
|
+
now?: () => number;
|
|
86
|
+
monotonicNow?: () => number;
|
|
87
|
+
createRunId?: () => string;
|
|
88
|
+
onError?: (error: unknown, source: LoggingErrorSource) => void;
|
|
89
|
+
isActive?: () => boolean;
|
|
90
|
+
}>;
|
|
91
|
+
export type Logging<TArea extends string> = Readonly<{
|
|
92
|
+
runId: string;
|
|
93
|
+
getLogger: (area: TArea, scope: string) => Logger;
|
|
94
|
+
setLevel: (
|
|
95
|
+
area: TArea,
|
|
96
|
+
level: LogLevel,
|
|
97
|
+
options?: Readonly<{ durationMs?: number }>,
|
|
98
|
+
) => void;
|
|
99
|
+
resetLevel: (area?: TArea) => void;
|
|
100
|
+
reloadLevels: () => void;
|
|
101
|
+
getLevels: () => Readonly<Record<TArea, LevelState>>;
|
|
102
|
+
setContext: (
|
|
103
|
+
context: Readonly<Record<string, string | number | undefined>>,
|
|
104
|
+
) => void;
|
|
105
|
+
addSink: (sink: LogSink) => () => void;
|
|
106
|
+
flush: () => Promise<void>;
|
|
107
|
+
stop: () => Promise<void>;
|
|
108
|
+
}>;
|
|
109
|
+
export declare function createLogging<TArea extends string>(
|
|
110
|
+
options: LoggingOptions<TArea>,
|
|
111
|
+
): Logging<TArea>;
|
|
112
|
+
|
|
113
|
+
export type Redactor = Readonly<{
|
|
114
|
+
version: string;
|
|
115
|
+
limits: Readonly<{ [Key in keyof typeof LIMITS]: number }>;
|
|
116
|
+
redact: (draft: LogDraft) => LogRecord;
|
|
117
|
+
redactValue: (value: unknown) => LogValue;
|
|
118
|
+
redactText: (text: string) => string;
|
|
119
|
+
mask: (value: string) => string;
|
|
120
|
+
hash?: (value: string) => string;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
export type LogSink = Readonly<{
|
|
124
|
+
// Finish admission synchronously. The hub ignores the return value.
|
|
125
|
+
write: (record: LogRecord) => void;
|
|
126
|
+
flush?: () => Promise<void>;
|
|
127
|
+
stop?: () => Promise<void>;
|
|
128
|
+
}>;
|
|
129
|
+
export type LogQuery<TArea extends string = string> = Readonly<{
|
|
130
|
+
areas?: readonly TArea[];
|
|
131
|
+
from?: number;
|
|
132
|
+
to?: number;
|
|
133
|
+
}>;
|
|
134
|
+
export type LogStoreStatus = Readonly<{
|
|
135
|
+
mode: ValueOf<typeof STORE_MODES>;
|
|
136
|
+
droppedRecords: number;
|
|
137
|
+
unavailableHistory: boolean;
|
|
138
|
+
unprotected: boolean;
|
|
139
|
+
canRecover: boolean;
|
|
140
|
+
}>;
|
|
141
|
+
export type LogSource = Readonly<{
|
|
142
|
+
query: (query?: LogQuery) => Promise<readonly LogRecord[]>;
|
|
143
|
+
getStatus?: () => LogStoreStatus;
|
|
144
|
+
}>;
|
|
145
|
+
export type LogStore = LogSink &
|
|
146
|
+
LogSource &
|
|
147
|
+
Readonly<{
|
|
148
|
+
flush: () => Promise<void>;
|
|
149
|
+
stop: (options?: Readonly<{ discard?: boolean }>) => Promise<void>;
|
|
150
|
+
clear: () => Promise<void>;
|
|
151
|
+
getStatus: () => LogStoreStatus;
|
|
152
|
+
}>;
|
|
153
|
+
export type ConsoleLike = Readonly<
|
|
154
|
+
Record<LogLevel, (...values: unknown[]) => void>
|
|
155
|
+
>;
|
|
156
|
+
export declare function createConsoleSink(
|
|
157
|
+
options?: Readonly<{ level?: LogLevel; console?: ConsoleLike }>,
|
|
158
|
+
): LogSink;
|
|
159
|
+
export declare function formatRecord(record: LogRecord): string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LEVELS,
|
|
3
|
+
LIMITS,
|
|
4
|
+
LOGGING_ERROR_CODES,
|
|
5
|
+
LOGGING_ERROR_SOURCES,
|
|
6
|
+
STORE_MODES,
|
|
7
|
+
} from './constants.js';
|
|
8
|
+
|
|
9
|
+
type ValueOf<Values> = Values[keyof Values];
|
|
10
|
+
export type LogLevel = ValueOf<typeof LEVELS>;
|
|
11
|
+
export type LogValue =
|
|
12
|
+
| null
|
|
13
|
+
| boolean
|
|
14
|
+
| number
|
|
15
|
+
| string
|
|
16
|
+
| readonly LogValue[]
|
|
17
|
+
| { readonly [key: string]: LogValue };
|
|
18
|
+
export type LogFields = Readonly<Record<string, LogValue>>;
|
|
19
|
+
export type LogContext = Readonly<Record<string, string | number>>;
|
|
20
|
+
export type SerializedError = Readonly<{
|
|
21
|
+
name: string;
|
|
22
|
+
message: string;
|
|
23
|
+
stack?: string;
|
|
24
|
+
fields?: Readonly<Record<string, LogValue>>;
|
|
25
|
+
cause?: SerializedError;
|
|
26
|
+
errors?: readonly SerializedError[];
|
|
27
|
+
}>;
|
|
28
|
+
export type LogRecord = Readonly<{
|
|
29
|
+
runId: string;
|
|
30
|
+
seq: number;
|
|
31
|
+
at: number;
|
|
32
|
+
level: LogLevel;
|
|
33
|
+
area: string;
|
|
34
|
+
scope: string;
|
|
35
|
+
message: string;
|
|
36
|
+
redactionVersion: string;
|
|
37
|
+
fields?: LogFields;
|
|
38
|
+
context?: LogContext;
|
|
39
|
+
error?: SerializedError;
|
|
40
|
+
truncated?: true;
|
|
41
|
+
}>;
|
|
42
|
+
export type LogDraft = Readonly<
|
|
43
|
+
Omit<LogRecord, 'fields' | 'error' | 'redactionVersion' | 'truncated'> & {
|
|
44
|
+
data?: unknown;
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
47
|
+
export type Logger = Readonly<{
|
|
48
|
+
debug: (message: string, data?: unknown) => void;
|
|
49
|
+
info: (message: string, data?: unknown) => void;
|
|
50
|
+
warn: (message: string, data?: unknown) => void;
|
|
51
|
+
error: (message: string, data?: unknown) => void;
|
|
52
|
+
child: (
|
|
53
|
+
binding: Readonly<{ scope?: string; context?: LogContext }>,
|
|
54
|
+
) => Logger;
|
|
55
|
+
}>;
|
|
56
|
+
export type AreaDefinition<TArea extends string = string> = Readonly<{
|
|
57
|
+
id: TArea;
|
|
58
|
+
level?: LogLevel;
|
|
59
|
+
}>;
|
|
60
|
+
export type LevelState = Readonly<{
|
|
61
|
+
level: LogLevel;
|
|
62
|
+
defaultLevel: LogLevel;
|
|
63
|
+
until?: number;
|
|
64
|
+
}>;
|
|
65
|
+
export type LoggingScheduler = Readonly<{
|
|
66
|
+
setTimeout: (callback: () => void, delayMs: number) => unknown;
|
|
67
|
+
clearTimeout: (handle: unknown) => void;
|
|
68
|
+
}>;
|
|
69
|
+
export type KeyValueStorage = Readonly<{
|
|
70
|
+
getItem: (key: string) => string | null;
|
|
71
|
+
setItem: (key: string, value: string) => void;
|
|
72
|
+
}>;
|
|
73
|
+
export type LoggingErrorSource = ValueOf<typeof LOGGING_ERROR_SOURCES>;
|
|
74
|
+
export type LoggingError = Error &
|
|
75
|
+
Readonly<{ code: ValueOf<typeof LOGGING_ERROR_CODES> }>;
|
|
76
|
+
export type LoggingOptions<TArea extends string> = Readonly<{
|
|
77
|
+
areas: readonly AreaDefinition<TArea>[];
|
|
78
|
+
redactor: Redactor;
|
|
79
|
+
sinks?: readonly LogSink[];
|
|
80
|
+
context?: LogContext;
|
|
81
|
+
levelStorage?: Readonly<{ storage: KeyValueStorage; key: string }>;
|
|
82
|
+
maxOverrideMs?: number;
|
|
83
|
+
stormLimit?: number | false;
|
|
84
|
+
scheduler?: LoggingScheduler;
|
|
85
|
+
now?: () => number;
|
|
86
|
+
monotonicNow?: () => number;
|
|
87
|
+
createRunId?: () => string;
|
|
88
|
+
onError?: (error: unknown, source: LoggingErrorSource) => void;
|
|
89
|
+
isActive?: () => boolean;
|
|
90
|
+
}>;
|
|
91
|
+
export type Logging<TArea extends string> = Readonly<{
|
|
92
|
+
runId: string;
|
|
93
|
+
getLogger: (area: TArea, scope: string) => Logger;
|
|
94
|
+
setLevel: (
|
|
95
|
+
area: TArea,
|
|
96
|
+
level: LogLevel,
|
|
97
|
+
options?: Readonly<{ durationMs?: number }>,
|
|
98
|
+
) => void;
|
|
99
|
+
resetLevel: (area?: TArea) => void;
|
|
100
|
+
reloadLevels: () => void;
|
|
101
|
+
getLevels: () => Readonly<Record<TArea, LevelState>>;
|
|
102
|
+
setContext: (
|
|
103
|
+
context: Readonly<Record<string, string | number | undefined>>,
|
|
104
|
+
) => void;
|
|
105
|
+
addSink: (sink: LogSink) => () => void;
|
|
106
|
+
flush: () => Promise<void>;
|
|
107
|
+
stop: () => Promise<void>;
|
|
108
|
+
}>;
|
|
109
|
+
export declare function createLogging<TArea extends string>(
|
|
110
|
+
options: LoggingOptions<TArea>,
|
|
111
|
+
): Logging<TArea>;
|
|
112
|
+
|
|
113
|
+
export type Redactor = Readonly<{
|
|
114
|
+
version: string;
|
|
115
|
+
limits: Readonly<{ [Key in keyof typeof LIMITS]: number }>;
|
|
116
|
+
redact: (draft: LogDraft) => LogRecord;
|
|
117
|
+
redactValue: (value: unknown) => LogValue;
|
|
118
|
+
redactText: (text: string) => string;
|
|
119
|
+
mask: (value: string) => string;
|
|
120
|
+
hash?: (value: string) => string;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
export type LogSink = Readonly<{
|
|
124
|
+
// Finish admission synchronously. The hub ignores the return value.
|
|
125
|
+
write: (record: LogRecord) => void;
|
|
126
|
+
flush?: () => Promise<void>;
|
|
127
|
+
stop?: () => Promise<void>;
|
|
128
|
+
}>;
|
|
129
|
+
export type LogQuery<TArea extends string = string> = Readonly<{
|
|
130
|
+
areas?: readonly TArea[];
|
|
131
|
+
from?: number;
|
|
132
|
+
to?: number;
|
|
133
|
+
}>;
|
|
134
|
+
export type LogStoreStatus = Readonly<{
|
|
135
|
+
mode: ValueOf<typeof STORE_MODES>;
|
|
136
|
+
droppedRecords: number;
|
|
137
|
+
unavailableHistory: boolean;
|
|
138
|
+
unprotected: boolean;
|
|
139
|
+
canRecover: boolean;
|
|
140
|
+
}>;
|
|
141
|
+
export type LogSource = Readonly<{
|
|
142
|
+
query: (query?: LogQuery) => Promise<readonly LogRecord[]>;
|
|
143
|
+
getStatus?: () => LogStoreStatus;
|
|
144
|
+
}>;
|
|
145
|
+
export type LogStore = LogSink &
|
|
146
|
+
LogSource &
|
|
147
|
+
Readonly<{
|
|
148
|
+
flush: () => Promise<void>;
|
|
149
|
+
stop: (options?: Readonly<{ discard?: boolean }>) => Promise<void>;
|
|
150
|
+
clear: () => Promise<void>;
|
|
151
|
+
getStatus: () => LogStoreStatus;
|
|
152
|
+
}>;
|
|
153
|
+
export type ConsoleLike = Readonly<
|
|
154
|
+
Record<LogLevel, (...values: unknown[]) => void>
|
|
155
|
+
>;
|
|
156
|
+
export declare function createConsoleSink(
|
|
157
|
+
options?: Readonly<{ level?: LogLevel; console?: ConsoleLike }>,
|
|
158
|
+
): LogSink;
|
|
159
|
+
export declare function formatRecord(record: LogRecord): string;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { c as createConsoleSink, f as formatRecord } from './chunk-DYcNnkOV.js';
|
|
2
|
+
export { c as createLogging } from './chunk-DkvWLziD.js';
|
|
3
|
+
import './chunk-LRCHwVuE.js';
|
|
4
|
+
import './chunk-CSS3f4_M.js';
|
|
5
|
+
import './chunk-7ld72rnl.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function createIndexedDbLogStore(options, createStore) {
|
|
4
|
+
if (typeof createStore !== 'function')
|
|
5
|
+
throw new TypeError('An IndexedDB store factory is required');
|
|
6
|
+
return createStore(databaseOptions(options));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async function clearIndexedDbLogStore(options, clearStore) {
|
|
10
|
+
if (typeof clearStore !== 'function')
|
|
11
|
+
throw new TypeError('An IndexedDB cleanup function is required');
|
|
12
|
+
return clearStore(databaseOptions(options));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function databaseOptions(options) {
|
|
16
|
+
const { databaseName, lockName } = options ?? {};
|
|
17
|
+
if (typeof databaseName !== 'string' || !databaseName)
|
|
18
|
+
throw new TypeError('An IndexedDB database name is required');
|
|
19
|
+
if (typeof lockName !== 'string' || !lockName)
|
|
20
|
+
throw new TypeError('An IndexedDB lock name is required');
|
|
21
|
+
return options;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.clearIndexedDbLogStore = clearIndexedDbLogStore;
|
|
25
|
+
exports.createIndexedDbLogStore = createIndexedDbLogStore;
|
|
26
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/indexeddb/index.js"],"sourcesContent":["export function createIndexedDbLogStore(options, createStore) {\n if (typeof createStore !== 'function')\n throw new TypeError('An IndexedDB store factory is required');\n return createStore(databaseOptions(options));\n}\n\nexport async function clearIndexedDbLogStore(options, clearStore) {\n if (typeof clearStore !== 'function')\n throw new TypeError('An IndexedDB cleanup function is required');\n return clearStore(databaseOptions(options));\n}\n\nfunction databaseOptions(options) {\n const { databaseName, lockName } = options ?? {};\n if (typeof databaseName !== 'string' || !databaseName)\n throw new TypeError('An IndexedDB database name is required');\n if (typeof lockName !== 'string' || !lockName)\n throw new TypeError('An IndexedDB lock name is required');\n return options;\n}\n"],"names":[],"mappings":";;AAAO,SAAS,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE;AAC9D,EAAE,IAAI,OAAO,WAAW,KAAK,UAAU;AACvC,IAAI,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC;AACjE,EAAE,OAAO,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC9C;;AAEO,eAAe,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE;AAClE,EAAE,IAAI,OAAO,UAAU,KAAK,UAAU;AACtC,IAAI,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC;AACpE,EAAE,OAAO,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC7C;;AAEA,SAAS,eAAe,CAAC,OAAO,EAAE;AAClC,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE;AAClD,EAAE,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,CAAC,YAAY;AACvD,IAAI,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC;AACjE,EAAE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ;AAC/C,IAAI,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC;AAC7D,EAAE,OAAO,OAAO;AAChB;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { LogRecord, LogStore } from "../index.cjs";
|
|
2
|
+
import type { MemoryLogStoreOptions } from "../storage/contracts.cjs";
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
LogOverflowStrategy,
|
|
6
|
+
LogStoreError,
|
|
7
|
+
MemoryLogStoreOptions,
|
|
8
|
+
} from "../storage/contracts.cjs";
|
|
9
|
+
|
|
10
|
+
export type IndexedDbLogStoreOptions = Omit<
|
|
11
|
+
MemoryLogStoreOptions,
|
|
12
|
+
'isRotationEnabled'
|
|
13
|
+
> &
|
|
14
|
+
Readonly<{
|
|
15
|
+
databaseName: string;
|
|
16
|
+
lockName: string;
|
|
17
|
+
indexedDB?: IDBFactory;
|
|
18
|
+
keyRange?: Pick<typeof IDBKeyRange, 'bound' | 'lowerBound'> | null;
|
|
19
|
+
locks?: Pick<LockManager, 'request'>;
|
|
20
|
+
allowUnprotected?: boolean;
|
|
21
|
+
flushIntervalMs?: number;
|
|
22
|
+
maxBatchSize?: number;
|
|
23
|
+
maxQueuedRecords?: number;
|
|
24
|
+
maxQueuedSize?: number;
|
|
25
|
+
onStatusChange?: () => void;
|
|
26
|
+
fallback?: Omit<
|
|
27
|
+
MemoryLogStoreOptions,
|
|
28
|
+
| 'overflowStrategy'
|
|
29
|
+
| 'onRotate'
|
|
30
|
+
| 'onError'
|
|
31
|
+
| 'scheduler'
|
|
32
|
+
| 'isRotationEnabled'
|
|
33
|
+
>;
|
|
34
|
+
}>;
|
|
35
|
+
export type IndexedDbStoreFactory = (
|
|
36
|
+
options: IndexedDbLogStoreOptions &
|
|
37
|
+
Readonly<{
|
|
38
|
+
isRotationEnabled?: () => boolean;
|
|
39
|
+
}>,
|
|
40
|
+
) => LogStore;
|
|
41
|
+
export declare function createIndexedDbLogStore(
|
|
42
|
+
options: IndexedDbLogStoreOptions,
|
|
43
|
+
createStore: IndexedDbStoreFactory,
|
|
44
|
+
): LogStore;
|
|
45
|
+
export type IndexedDbLogCleanupOptions = Pick<
|
|
46
|
+
IndexedDbLogStoreOptions,
|
|
47
|
+
| 'databaseName'
|
|
48
|
+
| 'lockName'
|
|
49
|
+
| 'indexedDB'
|
|
50
|
+
| 'locks'
|
|
51
|
+
| 'allowUnprotected'
|
|
52
|
+
| 'scheduler'
|
|
53
|
+
>;
|
|
54
|
+
export type IndexedDbCleanup = (
|
|
55
|
+
options: IndexedDbLogCleanupOptions,
|
|
56
|
+
) => Promise<void>;
|
|
57
|
+
export declare function clearIndexedDbLogStore(
|
|
58
|
+
options: IndexedDbLogCleanupOptions,
|
|
59
|
+
clearStore: IndexedDbCleanup,
|
|
60
|
+
): Promise<void>;
|
|
61
|
+
export type { LogRecord };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { LogRecord, LogStore } from '../index.js';
|
|
2
|
+
import type { MemoryLogStoreOptions } from '../storage/contracts.js';
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
LogOverflowStrategy,
|
|
6
|
+
LogStoreError,
|
|
7
|
+
MemoryLogStoreOptions,
|
|
8
|
+
} from '../storage/contracts.js';
|
|
9
|
+
|
|
10
|
+
export type IndexedDbLogStoreOptions = Omit<
|
|
11
|
+
MemoryLogStoreOptions,
|
|
12
|
+
'isRotationEnabled'
|
|
13
|
+
> &
|
|
14
|
+
Readonly<{
|
|
15
|
+
databaseName: string;
|
|
16
|
+
lockName: string;
|
|
17
|
+
indexedDB?: IDBFactory;
|
|
18
|
+
keyRange?: Pick<typeof IDBKeyRange, 'bound' | 'lowerBound'> | null;
|
|
19
|
+
locks?: Pick<LockManager, 'request'>;
|
|
20
|
+
allowUnprotected?: boolean;
|
|
21
|
+
flushIntervalMs?: number;
|
|
22
|
+
maxBatchSize?: number;
|
|
23
|
+
maxQueuedRecords?: number;
|
|
24
|
+
maxQueuedSize?: number;
|
|
25
|
+
onStatusChange?: () => void;
|
|
26
|
+
fallback?: Omit<
|
|
27
|
+
MemoryLogStoreOptions,
|
|
28
|
+
| 'overflowStrategy'
|
|
29
|
+
| 'onRotate'
|
|
30
|
+
| 'onError'
|
|
31
|
+
| 'scheduler'
|
|
32
|
+
| 'isRotationEnabled'
|
|
33
|
+
>;
|
|
34
|
+
}>;
|
|
35
|
+
export type IndexedDbStoreFactory = (
|
|
36
|
+
options: IndexedDbLogStoreOptions &
|
|
37
|
+
Readonly<{
|
|
38
|
+
isRotationEnabled?: () => boolean;
|
|
39
|
+
}>,
|
|
40
|
+
) => LogStore;
|
|
41
|
+
export declare function createIndexedDbLogStore(
|
|
42
|
+
options: IndexedDbLogStoreOptions,
|
|
43
|
+
createStore: IndexedDbStoreFactory,
|
|
44
|
+
): LogStore;
|
|
45
|
+
export type IndexedDbLogCleanupOptions = Pick<
|
|
46
|
+
IndexedDbLogStoreOptions,
|
|
47
|
+
| 'databaseName'
|
|
48
|
+
| 'lockName'
|
|
49
|
+
| 'indexedDB'
|
|
50
|
+
| 'locks'
|
|
51
|
+
| 'allowUnprotected'
|
|
52
|
+
| 'scheduler'
|
|
53
|
+
>;
|
|
54
|
+
export type IndexedDbCleanup = (
|
|
55
|
+
options: IndexedDbLogCleanupOptions,
|
|
56
|
+
) => Promise<void>;
|
|
57
|
+
export declare function clearIndexedDbLogStore(
|
|
58
|
+
options: IndexedDbLogCleanupOptions,
|
|
59
|
+
clearStore: IndexedDbCleanup,
|
|
60
|
+
): Promise<void>;
|
|
61
|
+
export type { LogRecord };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function createIndexedDbLogStore(options, createStore) {
|
|
2
|
+
if (typeof createStore !== 'function')
|
|
3
|
+
throw new TypeError('An IndexedDB store factory is required');
|
|
4
|
+
return createStore(databaseOptions(options));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async function clearIndexedDbLogStore(options, clearStore) {
|
|
8
|
+
if (typeof clearStore !== 'function')
|
|
9
|
+
throw new TypeError('An IndexedDB cleanup function is required');
|
|
10
|
+
return clearStore(databaseOptions(options));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function databaseOptions(options) {
|
|
14
|
+
const { databaseName, lockName } = options ?? {};
|
|
15
|
+
if (typeof databaseName !== 'string' || !databaseName)
|
|
16
|
+
throw new TypeError('An IndexedDB database name is required');
|
|
17
|
+
if (typeof lockName !== 'string' || !lockName)
|
|
18
|
+
throw new TypeError('An IndexedDB lock name is required');
|
|
19
|
+
return options;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { clearIndexedDbLogStore, createIndexedDbLogStore };
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/indexeddb/index.js"],"sourcesContent":["export function createIndexedDbLogStore(options, createStore) {\n if (typeof createStore !== 'function')\n throw new TypeError('An IndexedDB store factory is required');\n return createStore(databaseOptions(options));\n}\n\nexport async function clearIndexedDbLogStore(options, clearStore) {\n if (typeof clearStore !== 'function')\n throw new TypeError('An IndexedDB cleanup function is required');\n return clearStore(databaseOptions(options));\n}\n\nfunction databaseOptions(options) {\n const { databaseName, lockName } = options ?? {};\n if (typeof databaseName !== 'string' || !databaseName)\n throw new TypeError('An IndexedDB database name is required');\n if (typeof lockName !== 'string' || !lockName)\n throw new TypeError('An IndexedDB lock name is required');\n return options;\n}\n"],"names":[],"mappings":"AAAO,SAAS,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE;AAC9D,EAAE,IAAI,OAAO,WAAW,KAAK,UAAU;AACvC,IAAI,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC;AACjE,EAAE,OAAO,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC9C;;AAEO,eAAe,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE;AAClE,EAAE,IAAI,OAAO,UAAU,KAAK,UAAU;AACtC,IAAI,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC;AACpE,EAAE,OAAO,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC7C;;AAEA,SAAS,eAAe,CAAC,OAAO,EAAE;AAClC,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE;AAClD,EAAE,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,CAAC,YAAY;AACvD,IAAI,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC;AACjE,EAAE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ;AAC/C,IAAI,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC;AAC7D,EAAE,OAAO,OAAO;AAChB;;"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var common = require('../chunk-CXZYNALm.cjs');
|
|
4
|
+
var constants = require('../chunk-BLf-eCDO.cjs');
|
|
5
|
+
|
|
6
|
+
function createRedactor(
|
|
7
|
+
policy = {},
|
|
8
|
+
{ createRedactor: createValueRedactor, TEXT_RULES: providerTextRules } = {},
|
|
9
|
+
) {
|
|
10
|
+
if (typeof createValueRedactor !== 'function')
|
|
11
|
+
throw new TypeError('A value redactor factory is required');
|
|
12
|
+
if (!Array.isArray(policy.text) && !providerTextRules)
|
|
13
|
+
throw new TypeError('Default text rules are required');
|
|
14
|
+
const limits = common.resolveLimits(policy.limits);
|
|
15
|
+
const version = policy.version ?? '1';
|
|
16
|
+
if (
|
|
17
|
+
typeof version !== 'string' ||
|
|
18
|
+
!version ||
|
|
19
|
+
version.length > limits.maxStringLength
|
|
20
|
+
)
|
|
21
|
+
throw new TypeError('Invalid redaction version');
|
|
22
|
+
const { fields, unknownFields, hash, text } = policy;
|
|
23
|
+
const textRules = text ?? Object.values(providerTextRules);
|
|
24
|
+
const engine = createValueRedactor({
|
|
25
|
+
fields,
|
|
26
|
+
unknownFields,
|
|
27
|
+
hash:
|
|
28
|
+
typeof hash === 'function' ? (value) => hash.call(policy, value) : hash,
|
|
29
|
+
limits: { ...limits, maxOutputSize: limits.maxRecordSize },
|
|
30
|
+
text: text
|
|
31
|
+
? textRules.map(({ name, pattern, requiresHash, replace }) => ({
|
|
32
|
+
name,
|
|
33
|
+
pattern,
|
|
34
|
+
requiresHash,
|
|
35
|
+
replace:
|
|
36
|
+
typeof replace === 'function'
|
|
37
|
+
? function (match) {
|
|
38
|
+
return replace.call(this, match, api);
|
|
39
|
+
}
|
|
40
|
+
: replace,
|
|
41
|
+
}))
|
|
42
|
+
: textRules,
|
|
43
|
+
});
|
|
44
|
+
let active;
|
|
45
|
+
const api = {
|
|
46
|
+
version,
|
|
47
|
+
limits,
|
|
48
|
+
mask: engine.mask,
|
|
49
|
+
redactText(value) {
|
|
50
|
+
return (active?.walk ?? engine.createSession()).redactText(value);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
redactValue(value) {
|
|
54
|
+
const walk = engine.createSession();
|
|
55
|
+
const result = walk.redactValue(value);
|
|
56
|
+
if (active && walk.truncated) active.truncated = true;
|
|
57
|
+
return JSON.stringify(result).length <= limits.maxRecordSize
|
|
58
|
+
? result
|
|
59
|
+
: constants.MARKERS.LIMIT;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
redact(draft) {
|
|
63
|
+
const previous = active;
|
|
64
|
+
const walk = engine.createSession();
|
|
65
|
+
active = { walk, truncated: false };
|
|
66
|
+
try {
|
|
67
|
+
let didTruncate = false;
|
|
68
|
+
const record = {};
|
|
69
|
+
for (const key of [
|
|
70
|
+
'runId',
|
|
71
|
+
'seq',
|
|
72
|
+
'at',
|
|
73
|
+
'level',
|
|
74
|
+
'area',
|
|
75
|
+
'scope',
|
|
76
|
+
'message',
|
|
77
|
+
])
|
|
78
|
+
common.define(
|
|
79
|
+
record,
|
|
80
|
+
key,
|
|
81
|
+
typeof draft[key] === 'string' && !['runId', 'level'].includes(key)
|
|
82
|
+
? walk.redactText(draft[key])
|
|
83
|
+
: draft[key],
|
|
84
|
+
);
|
|
85
|
+
record.redactionVersion = version;
|
|
86
|
+
if (draft.context) record.context = walk.redactValue(draft.context);
|
|
87
|
+
const data = draft.data;
|
|
88
|
+
if (common.isError(data)) {
|
|
89
|
+
const converted = walk.redactValue(data);
|
|
90
|
+
record.error =
|
|
91
|
+
typeof converted === 'string'
|
|
92
|
+
? { name: 'Error', message: converted }
|
|
93
|
+
: converted;
|
|
94
|
+
} else if (data !== undefined) {
|
|
95
|
+
if (
|
|
96
|
+
data &&
|
|
97
|
+
typeof data === 'object' &&
|
|
98
|
+
!Array.isArray(data) &&
|
|
99
|
+
[Object.prototype, null].includes(Object.getPrototypeOf(data))
|
|
100
|
+
) {
|
|
101
|
+
const error =
|
|
102
|
+
walk.fieldRule('error') === 'drop'
|
|
103
|
+
? undefined
|
|
104
|
+
: common.own(data, 'error');
|
|
105
|
+
const promoted = common.isError(error);
|
|
106
|
+
if (promoted) {
|
|
107
|
+
const converted = walk.redactError(error, 'error');
|
|
108
|
+
if (converted !== undefined) record.error = converted;
|
|
109
|
+
}
|
|
110
|
+
const values = {};
|
|
111
|
+
let count = 0;
|
|
112
|
+
for (const key of Reflect.ownKeys(data)) {
|
|
113
|
+
if (++count > limits.maxKeys) {
|
|
114
|
+
common.define(values, '[truncated]', constants.MARKERS.LIMIT);
|
|
115
|
+
didTruncate = true;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (key === 'error' && promoted) continue;
|
|
119
|
+
const descriptor = Object.getOwnPropertyDescriptor(data, key);
|
|
120
|
+
if (typeof key === 'string' && descriptor?.enumerable)
|
|
121
|
+
Object.defineProperty(values, key, descriptor);
|
|
122
|
+
}
|
|
123
|
+
const converted = walk.redactValue(values);
|
|
124
|
+
record.fields =
|
|
125
|
+
converted &&
|
|
126
|
+
typeof converted === 'object' &&
|
|
127
|
+
!Array.isArray(converted)
|
|
128
|
+
? converted
|
|
129
|
+
: { value: converted };
|
|
130
|
+
} else record.fields = { value: walk.redactValue(data) };
|
|
131
|
+
}
|
|
132
|
+
if (walk.truncated || active.truncated || didTruncate)
|
|
133
|
+
record.truncated = true;
|
|
134
|
+
if (JSON.stringify(record).length > limits.maxRecordSize) {
|
|
135
|
+
delete record.fields;
|
|
136
|
+
delete record.context;
|
|
137
|
+
delete record.error;
|
|
138
|
+
record.fields = { value: constants.MARKERS.LIMIT };
|
|
139
|
+
record.truncated = true;
|
|
140
|
+
if (JSON.stringify(record).length > limits.maxRecordSize)
|
|
141
|
+
throw new TypeError('Record headers exceed size limit');
|
|
142
|
+
}
|
|
143
|
+
return record;
|
|
144
|
+
} finally {
|
|
145
|
+
active = previous;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
if (engine.hash) api.hash = engine.hash;
|
|
150
|
+
return Object.freeze(api);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
exports.createRedactor = createRedactor;
|
|
154
|
+
//# sourceMappingURL=index.cjs.map
|