@futdevpro/nts-dynamo 1.15.250 → 1.15.253
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/build/_collections/progress-handle.interface.d.ts +20 -0
- package/build/_collections/progress-handle.interface.d.ts.map +1 -0
- package/build/_collections/progress-handle.interface.js +3 -0
- package/build/_collections/progress-handle.interface.js.map +1 -0
- package/build/_collections/progress-line.util.d.ts +67 -0
- package/build/_collections/progress-line.util.d.ts.map +1 -0
- package/build/_collections/progress-line.util.js +379 -0
- package/build/_collections/progress-line.util.js.map +1 -0
- package/build/_collections/progress-options.interface.d.ts +21 -0
- package/build/_collections/progress-options.interface.d.ts.map +1 -0
- package/build/_collections/progress-options.interface.js +3 -0
- package/build/_collections/progress-options.interface.js.map +1 -0
- package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.d.ts +15 -0
- package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.d.ts.map +1 -0
- package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.js +20 -0
- package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.js.map +1 -0
- package/build/_modules/privacy-lifecycle/_models/privacy-rights-notification.interface.d.ts +63 -0
- package/build/_modules/privacy-lifecycle/_models/privacy-rights-notification.interface.d.ts.map +1 -0
- package/build/_modules/privacy-lifecycle/_models/privacy-rights-notification.interface.js +3 -0
- package/build/_modules/privacy-lifecycle/_models/privacy-rights-notification.interface.js.map +1 -0
- package/build/_modules/privacy-lifecycle/index.d.ts +3 -0
- package/build/_modules/privacy-lifecycle/index.d.ts.map +1 -1
- package/build/_modules/privacy-lifecycle/index.js +6 -1
- package/build/_modules/privacy-lifecycle/index.js.map +1 -1
- package/build/_modules/privacy-lifecycle/privacy-rights-notification.mongo-store.d.ts +72 -0
- package/build/_modules/privacy-lifecycle/privacy-rights-notification.mongo-store.d.ts.map +1 -0
- package/build/_modules/privacy-lifecycle/privacy-rights-notification.mongo-store.js +681 -0
- package/build/_modules/privacy-lifecycle/privacy-rights-notification.mongo-store.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Controller for a started progress line. */
|
|
2
|
+
export interface DyNTS_Progress_Handle {
|
|
3
|
+
/** Whether the line updates in place (TTY). Callers may use this to decide about extra output. */
|
|
4
|
+
readonly isInteractive: boolean;
|
|
5
|
+
/** Reports progress. `current` may be omitted, in which case the counter advances by one. */
|
|
6
|
+
update(set?: {
|
|
7
|
+
current?: number;
|
|
8
|
+
total?: number;
|
|
9
|
+
note?: string;
|
|
10
|
+
}): void;
|
|
11
|
+
/** Closes the line as SUCCESSFUL, replacing it with a permanent line. Idempotent. */
|
|
12
|
+
done(set?: {
|
|
13
|
+
summary?: string;
|
|
14
|
+
}): void;
|
|
15
|
+
/** Closes the line as FAILED. Same as `done`, but the final line marks the failure. Idempotent. */
|
|
16
|
+
fail(set?: {
|
|
17
|
+
summary?: string;
|
|
18
|
+
}): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=progress-handle.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-handle.interface.d.ts","sourceRoot":"","sources":["../../src/_collections/progress-handle.interface.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,kGAAkG;IAClG,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,6FAA6F;IAC7F,MAAM,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxE,qFAAqF;IACrF,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACvC,mGAAmG;IACnG,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-handle.interface.js","sourceRoot":"","sources":["../../src/_collections/progress-handle.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DyNTS_Progress_Handle } from './progress-handle.interface';
|
|
2
|
+
import { DyNTS_Progress_Options } from './progress-options.interface';
|
|
3
|
+
type ProgressStream = NonNullable<DyNTS_Progress_Options['stream']>;
|
|
4
|
+
/**
|
|
5
|
+
* `DyNTS_Progress_Util` — the public surface of the progress line, plus the **pure** formatting
|
|
6
|
+
* helpers, so the behaviour can be unit-tested without a terminal.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DyNTS_Progress_Util {
|
|
9
|
+
/**
|
|
10
|
+
* Starts a new progress line.
|
|
11
|
+
*
|
|
12
|
+
* **At most one progress line can be active at a time**, because there is only one physical
|
|
13
|
+
* "bottom line" in a terminal; two lines overwriting each other would only produce confusion.
|
|
14
|
+
* If one is already active when `start` is called, that one is closed (`done()`) and the new
|
|
15
|
+
* line takes its place.
|
|
16
|
+
*/
|
|
17
|
+
static start(options: DyNTS_Progress_Options): DyNTS_Progress_Handle;
|
|
18
|
+
/**
|
|
19
|
+
* Decides whether an in-place line makes sense.
|
|
20
|
+
*
|
|
21
|
+
* Order of precedence: explicit `enabled`, then `DYNTS_NO_PROGRESS`, then the stream's TTY flag.
|
|
22
|
+
* `stdout` is never accepted, because machine-readable output goes there.
|
|
23
|
+
*/
|
|
24
|
+
static isInteractive(set?: {
|
|
25
|
+
stream?: ProgressStream;
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
}): boolean;
|
|
28
|
+
/** Whether the next plain line is due in non-TTY mode. Pure, therefore testable. */
|
|
29
|
+
static shouldEmitPlain(set: {
|
|
30
|
+
nowMs: number;
|
|
31
|
+
lastEmitMs: number;
|
|
32
|
+
everyMs: number;
|
|
33
|
+
}): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Renders the bar. `current` is always clamped to `[0, total]`, so a caller that miscounts
|
|
36
|
+
* cannot produce a broken (negative or overflowing) bar.
|
|
37
|
+
*/
|
|
38
|
+
static renderBar(set: {
|
|
39
|
+
current: number;
|
|
40
|
+
total: number;
|
|
41
|
+
width: number;
|
|
42
|
+
}): string;
|
|
43
|
+
/** Percentage, rounded to an integer and clamped to `[0, 100]`. */
|
|
44
|
+
static percent(set: {
|
|
45
|
+
current: number;
|
|
46
|
+
total: number;
|
|
47
|
+
}): number;
|
|
48
|
+
/** Elapsed time in a short, human-readable form; the line has to fit on one terminal row. */
|
|
49
|
+
static formatElapsed(ms: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Builds the full progress text.
|
|
52
|
+
*
|
|
53
|
+
* With a known `total`: bar, percentage and `current/total`. With an unknown `total`: spinner and
|
|
54
|
+
* counter only — a ratio is never invented for a number that was never provided.
|
|
55
|
+
*/
|
|
56
|
+
static formatLine(set: {
|
|
57
|
+
label: string;
|
|
58
|
+
current: number;
|
|
59
|
+
total?: number;
|
|
60
|
+
note?: string;
|
|
61
|
+
barWidth: number;
|
|
62
|
+
spinner: string;
|
|
63
|
+
elapsedMs: number;
|
|
64
|
+
}): string;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=progress-line.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-line.util.d.ts","sourceRoot":"","sources":["../../src/_collections/progress-line.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,KAAK,cAAc,GAAG,WAAW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;
|
|
5
|
+
(function (ConsoleMethod) {
|
|
6
|
+
ConsoleMethod["log"] = "log";
|
|
7
|
+
ConsoleMethod["info"] = "info";
|
|
8
|
+
ConsoleMethod["warn"] = "warn";
|
|
9
|
+
ConsoleMethod["error"] = "error";
|
|
10
|
+
ConsoleMethod["debug"] = "debug";
|
|
11
|
+
})(ConsoleMethod || (ConsoleMethod = {}));
|
|
12
|
+
/**
|
|
13
|
+
* `DyNTS_Progress_Util` — a **single-line, in-place progress indicator** (progress line / bar) for
|
|
14
|
+
* long-running work: scans, imports, embeddings, migrations, batch processing.
|
|
15
|
+
*
|
|
16
|
+
* ---
|
|
17
|
+
* ## Why this exists — and why a `console.log` inside the loop is not enough
|
|
18
|
+
*
|
|
19
|
+
* A long run has only ever offered two bad options:
|
|
20
|
+
*
|
|
21
|
+
* 1. **Silence.** The operator cannot tell whether the process is alive or where it is. A run that
|
|
22
|
+
* takes minutes is indistinguishable from a hang.
|
|
23
|
+
* 2. **A flood of lines.** One log line every N items drowns the output and pushes the messages that
|
|
24
|
+
* actually matter (warnings, errors) off the screen.
|
|
25
|
+
*
|
|
26
|
+
* This util provides the third option: **one line that is rewritten in place**.
|
|
27
|
+
*
|
|
28
|
+
* ## The important part: it does NOT disturb other logging
|
|
29
|
+
*
|
|
30
|
+
* A naive `\r`-based progress line collides with every other write to the console: if anything else
|
|
31
|
+
* prints while the line is on screen, the half-drawn progress text is left stuck to the start or the
|
|
32
|
+
* end of that message and the output becomes unreadable.
|
|
33
|
+
*
|
|
34
|
+
* Therefore, while a progress line is **active**, this util **wraps
|
|
35
|
+
* `console.log` / `info` / `warn` / `error` / `debug`**: it **erases** the progress line before any
|
|
36
|
+
* foreign write and **redraws** it afterwards.
|
|
37
|
+
*
|
|
38
|
+
* The consequence is that calling code needs to know **nothing** about the progress line. Messages
|
|
39
|
+
* from the framework logger, from raw `console` calls, and from third-party libraries all appear
|
|
40
|
+
* intact, and the progress line stays pinned to the bottom of the output.
|
|
41
|
+
*
|
|
42
|
+
* ## Non-TTY output (redirected to a file or a pipe): `\r` would be harmful
|
|
43
|
+
*
|
|
44
|
+
* When the destination is not a terminal (a CI log, `2> app.log`, a nodemon pipe), `\r` and ANSI
|
|
45
|
+
* escapes produce **garbage**: the lines overwrite each other and the file stops being readable by
|
|
46
|
+
* humans or machines. In that case this util **never rewrites anything**. It emits **throttled,
|
|
47
|
+
* standalone lines** instead (every 5 seconds by default), so the log file stays readable while the
|
|
48
|
+
* progress is still visible.
|
|
49
|
+
*
|
|
50
|
+
* ## Where it writes — and where it never writes
|
|
51
|
+
*
|
|
52
|
+
* **Always to `stderr`, never to `stdout`.** Reason: for the CLI tools in this fleet the purity of
|
|
53
|
+
* `--json` output is an invariant (`… --json | jq`), so stdout may carry the result envelope only.
|
|
54
|
+
* Progress is diagnostics, which belongs on stderr.
|
|
55
|
+
*
|
|
56
|
+
* ## Turning it off
|
|
57
|
+
*
|
|
58
|
+
* `DYNTS_NO_PROGRESS=1` (disables it entirely) or `enabled: false` at the call site.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* const progress: DyNTS_Progress_Handle = DyNTS_Progress_Util.start({ label: 'scan', total: files.length });
|
|
62
|
+
* for (const file of files) {
|
|
63
|
+
* progress.update({ note: file.name }); // no argument needed: it advances by one
|
|
64
|
+
* }
|
|
65
|
+
* progress.done({ summary: `${files.length} files` });
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Erase sequence: return to the start of the line, then clear the whole line (ANSI `EL 2`).
|
|
69
|
+
*
|
|
70
|
+
* The `\x1b` escape is written **explicitly** rather than as a raw ESC byte in the source: an
|
|
71
|
+
* invisible control character can be swallowed silently by an editor, an encoding change or a bulk
|
|
72
|
+
* search-and-replace, and the progress line would then print the literal text `[2K` instead of
|
|
73
|
+
* erasing anything.
|
|
74
|
+
*/
|
|
75
|
+
const CLEAR_LINE = '\r\x1b[2K';
|
|
76
|
+
/** Spinner frames, used when `total` is unknown, to show that the process is alive. */
|
|
77
|
+
const SPINNER_FRAMES = [
|
|
78
|
+
'⠋',
|
|
79
|
+
'⠙',
|
|
80
|
+
'⠹',
|
|
81
|
+
'⠸',
|
|
82
|
+
'⠼',
|
|
83
|
+
'⠴',
|
|
84
|
+
'⠦',
|
|
85
|
+
'⠧',
|
|
86
|
+
'⠇',
|
|
87
|
+
'⠏',
|
|
88
|
+
];
|
|
89
|
+
/** The currently active progress line; at most one at a time (see `start`). */
|
|
90
|
+
let activeLine = undefined;
|
|
91
|
+
/** Console methods that are wrapped while a progress line is active. */
|
|
92
|
+
const CONSOLE_METHODS = Object.values(ConsoleMethod);
|
|
93
|
+
let originalConsole = {};
|
|
94
|
+
/** Our own wrappers; restoration only happens while these are still the installed functions. */
|
|
95
|
+
let installedConsole = {};
|
|
96
|
+
/** Internal state of a running progress line. Not exported: callers receive the handle interface. */
|
|
97
|
+
class ProgressLine {
|
|
98
|
+
isInteractive;
|
|
99
|
+
stream;
|
|
100
|
+
label;
|
|
101
|
+
throttleMs;
|
|
102
|
+
plainEveryMs;
|
|
103
|
+
barWidth;
|
|
104
|
+
total;
|
|
105
|
+
current = 0;
|
|
106
|
+
note = '';
|
|
107
|
+
frame = 0;
|
|
108
|
+
lastDrawMs = 0;
|
|
109
|
+
lastPlainMs = 0;
|
|
110
|
+
isDrawn = false;
|
|
111
|
+
isFinished = false;
|
|
112
|
+
startedMs = Date.now();
|
|
113
|
+
/** Creates one progress line using already bounded caller options. */
|
|
114
|
+
constructor(options) {
|
|
115
|
+
this.stream = options.stream ?? process.stderr;
|
|
116
|
+
this.label = options.label;
|
|
117
|
+
this.total = options.total;
|
|
118
|
+
this.throttleMs = options.throttleMs ?? 80;
|
|
119
|
+
this.plainEveryMs = options.plainEveryMs ?? 5000;
|
|
120
|
+
this.barWidth = options.barWidth ?? 24;
|
|
121
|
+
this.isInteractive = DyNTS_Progress_Util.isInteractive({
|
|
122
|
+
stream: this.stream,
|
|
123
|
+
enabled: options.enabled,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** Advances or replaces the current progress counters and optional note. */
|
|
127
|
+
update(set) {
|
|
128
|
+
if (this.isFinished) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.current = set?.current ?? this.current + 1;
|
|
132
|
+
if (set?.total !== undefined) {
|
|
133
|
+
this.total = set.total;
|
|
134
|
+
}
|
|
135
|
+
if (set?.note !== undefined) {
|
|
136
|
+
this.note = set.note;
|
|
137
|
+
}
|
|
138
|
+
const now = Date.now();
|
|
139
|
+
if (this.isInteractive) {
|
|
140
|
+
if (now - this.lastDrawMs < this.throttleMs) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.lastDrawMs = now;
|
|
144
|
+
this.frame += 1;
|
|
145
|
+
this.draw();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
// Non-TTY: never overwrite. Throttled standalone lines keep the log file readable.
|
|
149
|
+
if (DyNTS_Progress_Util.shouldEmitPlain({
|
|
150
|
+
nowMs: now,
|
|
151
|
+
lastEmitMs: this.lastPlainMs,
|
|
152
|
+
everyMs: this.plainEveryMs,
|
|
153
|
+
})) {
|
|
154
|
+
this.lastPlainMs = now;
|
|
155
|
+
this.stream.write(`${this.buildText()}\n`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Finalizes the line once with a success marker. */
|
|
159
|
+
done(set) {
|
|
160
|
+
this.finish({ summary: set?.summary, ok: true });
|
|
161
|
+
}
|
|
162
|
+
/** Finalizes the line once with a failure marker. */
|
|
163
|
+
fail(set) {
|
|
164
|
+
this.finish({ summary: set?.summary, ok: false });
|
|
165
|
+
}
|
|
166
|
+
/** Erases the progress line; called by the console wrapper before every foreign write. */
|
|
167
|
+
clear() {
|
|
168
|
+
if (!this.isInteractive || !this.isDrawn) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.stream.write(CLEAR_LINE);
|
|
172
|
+
this.isDrawn = false;
|
|
173
|
+
}
|
|
174
|
+
/** Redraws the line after a foreign write, so it stays pinned to the bottom of the output. */
|
|
175
|
+
redraw() {
|
|
176
|
+
if (!this.isInteractive || this.isFinished) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.draw();
|
|
180
|
+
}
|
|
181
|
+
/** Current text of the progress line; the final line is built from the same text. */
|
|
182
|
+
buildText() {
|
|
183
|
+
return DyNTS_Progress_Util.formatLine({
|
|
184
|
+
label: this.label,
|
|
185
|
+
current: this.current,
|
|
186
|
+
total: this.total,
|
|
187
|
+
note: this.note,
|
|
188
|
+
barWidth: this.barWidth,
|
|
189
|
+
spinner: SPINNER_FRAMES[this.frame % SPINNER_FRAMES.length],
|
|
190
|
+
elapsedMs: Date.now() - this.startedMs,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/** Draws on a TTY: erase, then rewrite without a newline, which is what keeps it on one line. */
|
|
194
|
+
draw() {
|
|
195
|
+
this.stream.write(`${CLEAR_LINE}${this.buildText()}`);
|
|
196
|
+
this.isDrawn = true;
|
|
197
|
+
}
|
|
198
|
+
/** Shared close path. The final line is always emitted, on TTY and non-TTY alike, exactly once. */
|
|
199
|
+
finish(set) {
|
|
200
|
+
if (this.isFinished) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.isFinished = true;
|
|
204
|
+
this.clear();
|
|
205
|
+
const mark = set.ok ? '✔' : '✖';
|
|
206
|
+
const tail = set.summary ? ` — ${set.summary}` : '';
|
|
207
|
+
this.stream.write(`${mark} ${this.buildText()}${tail}\n`);
|
|
208
|
+
if (activeLine === this) {
|
|
209
|
+
activeLine = undefined;
|
|
210
|
+
restoreConsole();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Installs the console wrappers; only while a progress line is active. */
|
|
215
|
+
function installConsole() {
|
|
216
|
+
if (Object.keys(originalConsole).length > 0) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
for (const method of CONSOLE_METHODS) {
|
|
220
|
+
// The ORIGINAL reference is stored, not a `.bind()` copy. A bound copy is functionally
|
|
221
|
+
// equivalent but has a different identity, so restoring it would not give the caller back
|
|
222
|
+
// the exact function it had, and repeated start/close cycles would stack bind layers.
|
|
223
|
+
const original = getConsoleMethod(method);
|
|
224
|
+
originalConsole[method] = original;
|
|
225
|
+
/** Preserves foreign console output by temporarily removing and then redrawing the progress line. */
|
|
226
|
+
const wrapper = (...args) => {
|
|
227
|
+
// The core behaviour: erase before the foreign message, redraw after it.
|
|
228
|
+
activeLine?.clear();
|
|
229
|
+
original.apply(console, args);
|
|
230
|
+
activeLine?.redraw();
|
|
231
|
+
};
|
|
232
|
+
installedConsole[method] = wrapper;
|
|
233
|
+
setConsoleMethod(method, wrapper);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Restores the console methods.
|
|
238
|
+
*
|
|
239
|
+
* Restoration happens only while **our** wrapper is still the installed function. If something else
|
|
240
|
+
* (a test harness, a file logger) installed its own wrapper on top of ours in the meantime, a blind
|
|
241
|
+
* restore would silently knock that wrapper out of place.
|
|
242
|
+
*/
|
|
243
|
+
function restoreConsole() {
|
|
244
|
+
for (const method of CONSOLE_METHODS) {
|
|
245
|
+
const current = getConsoleMethod(method);
|
|
246
|
+
const original = originalConsole[method];
|
|
247
|
+
if (original && current === installedConsole[method]) {
|
|
248
|
+
setConsoleMethod(method, original);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
originalConsole = {};
|
|
252
|
+
installedConsole = {};
|
|
253
|
+
}
|
|
254
|
+
/** Returns a console method through an exhaustive, cast-free mapping. */
|
|
255
|
+
function getConsoleMethod(method) {
|
|
256
|
+
switch (method) {
|
|
257
|
+
case ConsoleMethod.log:
|
|
258
|
+
return console.log;
|
|
259
|
+
case ConsoleMethod.info:
|
|
260
|
+
return console.info;
|
|
261
|
+
case ConsoleMethod.warn:
|
|
262
|
+
return console.warn;
|
|
263
|
+
case ConsoleMethod.error:
|
|
264
|
+
return console.error;
|
|
265
|
+
case ConsoleMethod.debug:
|
|
266
|
+
return console.debug;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/** Replaces exactly one known console method without an index-signature cast. */
|
|
270
|
+
function setConsoleMethod(method, fn) {
|
|
271
|
+
switch (method) {
|
|
272
|
+
case ConsoleMethod.log:
|
|
273
|
+
console.log = fn;
|
|
274
|
+
break;
|
|
275
|
+
case ConsoleMethod.info:
|
|
276
|
+
console.info = fn;
|
|
277
|
+
break;
|
|
278
|
+
case ConsoleMethod.warn:
|
|
279
|
+
console.warn = fn;
|
|
280
|
+
break;
|
|
281
|
+
case ConsoleMethod.error:
|
|
282
|
+
console.error = fn;
|
|
283
|
+
break;
|
|
284
|
+
case ConsoleMethod.debug:
|
|
285
|
+
console.debug = fn;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* `DyNTS_Progress_Util` — the public surface of the progress line, plus the **pure** formatting
|
|
291
|
+
* helpers, so the behaviour can be unit-tested without a terminal.
|
|
292
|
+
*/
|
|
293
|
+
class DyNTS_Progress_Util {
|
|
294
|
+
/**
|
|
295
|
+
* Starts a new progress line.
|
|
296
|
+
*
|
|
297
|
+
* **At most one progress line can be active at a time**, because there is only one physical
|
|
298
|
+
* "bottom line" in a terminal; two lines overwriting each other would only produce confusion.
|
|
299
|
+
* If one is already active when `start` is called, that one is closed (`done()`) and the new
|
|
300
|
+
* line takes its place.
|
|
301
|
+
*/
|
|
302
|
+
static start(options) {
|
|
303
|
+
activeLine?.done();
|
|
304
|
+
const line = new ProgressLine(options);
|
|
305
|
+
activeLine = line;
|
|
306
|
+
if (line.isInteractive) {
|
|
307
|
+
installConsole();
|
|
308
|
+
}
|
|
309
|
+
return line;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Decides whether an in-place line makes sense.
|
|
313
|
+
*
|
|
314
|
+
* Order of precedence: explicit `enabled`, then `DYNTS_NO_PROGRESS`, then the stream's TTY flag.
|
|
315
|
+
* `stdout` is never accepted, because machine-readable output goes there.
|
|
316
|
+
*/
|
|
317
|
+
static isInteractive(set) {
|
|
318
|
+
if (set?.enabled !== undefined) {
|
|
319
|
+
return set.enabled;
|
|
320
|
+
}
|
|
321
|
+
if (process.env.DYNTS_NO_PROGRESS) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
const stream = set?.stream ?? process.stderr;
|
|
325
|
+
if (stream === process.stdout) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
return Boolean(stream.isTTY);
|
|
329
|
+
}
|
|
330
|
+
/** Whether the next plain line is due in non-TTY mode. Pure, therefore testable. */
|
|
331
|
+
static shouldEmitPlain(set) {
|
|
332
|
+
return set.nowMs - set.lastEmitMs >= set.everyMs;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Renders the bar. `current` is always clamped to `[0, total]`, so a caller that miscounts
|
|
336
|
+
* cannot produce a broken (negative or overflowing) bar.
|
|
337
|
+
*/
|
|
338
|
+
static renderBar(set) {
|
|
339
|
+
if (set.total <= 0 || set.width <= 0) {
|
|
340
|
+
return '';
|
|
341
|
+
}
|
|
342
|
+
const ratio = Math.min(1, Math.max(0, set.current / set.total));
|
|
343
|
+
const filled = Math.round(ratio * set.width);
|
|
344
|
+
return `[${'█'.repeat(filled)}${'░'.repeat(set.width - filled)}]`;
|
|
345
|
+
}
|
|
346
|
+
/** Percentage, rounded to an integer and clamped to `[0, 100]`. */
|
|
347
|
+
static percent(set) {
|
|
348
|
+
if (set.total <= 0) {
|
|
349
|
+
return 0;
|
|
350
|
+
}
|
|
351
|
+
return Math.min(100, Math.max(0, Math.round((set.current / set.total) * 100)));
|
|
352
|
+
}
|
|
353
|
+
/** Elapsed time in a short, human-readable form; the line has to fit on one terminal row. */
|
|
354
|
+
static formatElapsed(ms) {
|
|
355
|
+
const totalSeconds = Math.max(0, Math.floor(ms / 1000));
|
|
356
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
357
|
+
const seconds = totalSeconds % 60;
|
|
358
|
+
return minutes > 0
|
|
359
|
+
? `${minutes}m${String(seconds).padStart(2, '0')}s`
|
|
360
|
+
: `${seconds}s`;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Builds the full progress text.
|
|
364
|
+
*
|
|
365
|
+
* With a known `total`: bar, percentage and `current/total`. With an unknown `total`: spinner and
|
|
366
|
+
* counter only — a ratio is never invented for a number that was never provided.
|
|
367
|
+
*/
|
|
368
|
+
static formatLine(set) {
|
|
369
|
+
const head = set.total !== undefined && set.total > 0
|
|
370
|
+
? `${DyNTS_Progress_Util.renderBar({ current: set.current, total: set.total, width: set.barWidth })} ` +
|
|
371
|
+
`${String(DyNTS_Progress_Util.percent({ current: set.current, total: set.total })).padStart(3)}% ` +
|
|
372
|
+
`${set.current}/${set.total}`
|
|
373
|
+
: `${set.spinner} ${set.current}`;
|
|
374
|
+
const tail = set.note ? ` · ${set.note}` : '';
|
|
375
|
+
return `${set.label} ${head} · ${DyNTS_Progress_Util.formatElapsed(set.elapsedMs)}${tail}`;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
exports.DyNTS_Progress_Util = DyNTS_Progress_Util;
|
|
379
|
+
//# sourceMappingURL=progress-line.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-line.util.js","sourceRoot":"","sources":["../../src/_collections/progress-line.util.ts"],"names":[],"mappings":";;;AAIA,IAAK,aAMJ;AAND,WAAK,aAAa;IAChB,4BAAW,CAAA;IACX,8BAAa,CAAA;IACb,8BAAa,CAAA;IACb,gCAAe,CAAA;IACf,gCAAe,CAAA;AACjB,CAAC,EANI,aAAa,KAAb,aAAa,QAMjB;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,GAAW,WAAW,CAAC;AAEvC,uFAAuF;AACvF,M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2
|
+
export interface DyNTS_Progress_Options {
|
|
3
|
+
/** Name of the operation; rendered at the start of the line (for example `'scan: agent-memory'`). */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Total number of steps, when known up front. Without it a spinner and a counter are shown. */
|
|
6
|
+
total?: number;
|
|
7
|
+
/** Destination stream. Defaults to `process.stderr`; stdout is refused (pipe purity). */
|
|
8
|
+
stream?: {
|
|
9
|
+
readonly isTTY?: boolean;
|
|
10
|
+
write(chunk: string): boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Minimum delay between two redraws on a TTY, in ms. Default 80 — without it drawing burns CPU. */
|
|
13
|
+
throttleMs?: number;
|
|
14
|
+
/** Minimum delay between two plain lines in non-TTY mode, in ms. Default 5000. */
|
|
15
|
+
plainEveryMs?: number;
|
|
16
|
+
/** Width of the bar in characters; only used when `total` is known. Default 24. */
|
|
17
|
+
barWidth?: number;
|
|
18
|
+
/** Explicit on/off. When omitted, the stream's TTY flag and `DYNTS_NO_PROGRESS` decide. */
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=progress-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-options.interface.d.ts","sourceRoot":"","sources":["../../src/_collections/progress-options.interface.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,WAAW,sBAAsB;IACrC,qGAAqG;IACrG,KAAK,EAAE,MAAM,CAAC;IACd,gGAAgG;IAChG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACrE,oGAAoG;IACpG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-options.interface.js","sourceRoot":"","sources":["../../src/_collections/progress-options.interface.ts"],"names":[],"mappings":""}
|
package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Durable notification states; ambiguous SMTP delivery is terminal until an operator resolves it. */
|
|
2
|
+
export declare enum DyNTS_PrivacyRightsNotificationState_Type {
|
|
3
|
+
pending = "pending",
|
|
4
|
+
dispatching = "dispatching",
|
|
5
|
+
submitted = "submitted",
|
|
6
|
+
rejected = "rejected",
|
|
7
|
+
manualReview = "manual-review"
|
|
8
|
+
}
|
|
9
|
+
/** Persisted submission channel, including the explicit not-yet-submitted state. */
|
|
10
|
+
export declare enum DyNTS_PrivacyRightsNotificationChannel_Type {
|
|
11
|
+
none = "none",
|
|
12
|
+
smtp = "smtp",
|
|
13
|
+
testSink = "test-sink"
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=privacy-rights-notification-state.type-enum.d.ts.map
|
package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-rights-notification-state.type-enum.d.ts","sourceRoot":"","sources":["../../../../src/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,oBAAY,yCAAyC;IACnD,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,kBAAkB;CAC/B;AAED,oFAAoF;AACpF,oBAAY,2CAA2C;IACrD,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,cAAc;CACvB"}
|
package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DyNTS_PrivacyRightsNotificationChannel_Type = exports.DyNTS_PrivacyRightsNotificationState_Type = void 0;
|
|
4
|
+
/** Durable notification states; ambiguous SMTP delivery is terminal until an operator resolves it. */
|
|
5
|
+
var DyNTS_PrivacyRightsNotificationState_Type;
|
|
6
|
+
(function (DyNTS_PrivacyRightsNotificationState_Type) {
|
|
7
|
+
DyNTS_PrivacyRightsNotificationState_Type["pending"] = "pending";
|
|
8
|
+
DyNTS_PrivacyRightsNotificationState_Type["dispatching"] = "dispatching";
|
|
9
|
+
DyNTS_PrivacyRightsNotificationState_Type["submitted"] = "submitted";
|
|
10
|
+
DyNTS_PrivacyRightsNotificationState_Type["rejected"] = "rejected";
|
|
11
|
+
DyNTS_PrivacyRightsNotificationState_Type["manualReview"] = "manual-review";
|
|
12
|
+
})(DyNTS_PrivacyRightsNotificationState_Type || (exports.DyNTS_PrivacyRightsNotificationState_Type = DyNTS_PrivacyRightsNotificationState_Type = {}));
|
|
13
|
+
/** Persisted submission channel, including the explicit not-yet-submitted state. */
|
|
14
|
+
var DyNTS_PrivacyRightsNotificationChannel_Type;
|
|
15
|
+
(function (DyNTS_PrivacyRightsNotificationChannel_Type) {
|
|
16
|
+
DyNTS_PrivacyRightsNotificationChannel_Type["none"] = "none";
|
|
17
|
+
DyNTS_PrivacyRightsNotificationChannel_Type["smtp"] = "smtp";
|
|
18
|
+
DyNTS_PrivacyRightsNotificationChannel_Type["testSink"] = "test-sink";
|
|
19
|
+
})(DyNTS_PrivacyRightsNotificationChannel_Type || (exports.DyNTS_PrivacyRightsNotificationChannel_Type = DyNTS_PrivacyRightsNotificationChannel_Type = {}));
|
|
20
|
+
//# sourceMappingURL=privacy-rights-notification-state.type-enum.js.map
|
package/build/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-rights-notification-state.type-enum.js","sourceRoot":"","sources":["../../../../src/_modules/privacy-lifecycle/_enums/privacy-rights-notification-state.type-enum.ts"],"names":[],"mappings":";;;AAAA,sGAAsG;AACtG,IAAY,yCAMX;AAND,WAAY,yCAAyC;IACnD,gEAAmB,CAAA;IACnB,wEAA2B,CAAA;IAC3B,oEAAuB,CAAA;IACvB,kEAAqB,CAAA;IACrB,2EAA8B,CAAA;AAChC,CAAC,EANW,yCAAyC,yDAAzC,yCAAyC,QAMpD;AAED,oFAAoF;AACpF,IAAY,2CAIX;AAJD,WAAY,2CAA2C;IACrD,4DAAa,CAAA;IACb,4DAAa,CAAA;IACb,qEAAsB,CAAA;AACxB,CAAC,EAJW,2CAA2C,2DAA3C,2CAA2C,QAItD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ClientSession, Connection } from 'mongoose';
|
|
2
|
+
import { DyNTS_EmailSubmissionOutcome_Enum } from '../../../_enums/email-submission-outcome.enum';
|
|
3
|
+
import { DyNTS_EmailSubmissionReceipt_Interface } from '../../../_models/interfaces/email-submission-receipt.interface';
|
|
4
|
+
import { DyNTS_PrivacyRightsNotificationChannel_Type, DyNTS_PrivacyRightsNotificationState_Type } from '../_enums/privacy-rights-notification-state.type-enum';
|
|
5
|
+
import { DyNTS_PrivacyRightsAuthority_Interface } from './privacy-rights-custody.interface';
|
|
6
|
+
import { DyNTS_PrivacyRightsExecutionReceipt_Interface } from './privacy-rights-execution.interface';
|
|
7
|
+
/** Content-free durable notification projection. Recipient, subject and body are deliberately absent. */
|
|
8
|
+
export interface DyNTS_PrivacyRightsNotificationView_Interface extends DyNTS_PrivacyRightsAuthority_Interface {
|
|
9
|
+
readonly contractVersion: 'dynts-privacy-rights-notification/1';
|
|
10
|
+
readonly executionReference: string;
|
|
11
|
+
readonly executionCompletedAt: string;
|
|
12
|
+
readonly templateCode: string;
|
|
13
|
+
readonly state: DyNTS_PrivacyRightsNotificationState_Type;
|
|
14
|
+
readonly attemptCount: number;
|
|
15
|
+
readonly channel: DyNTS_PrivacyRightsNotificationChannel_Type;
|
|
16
|
+
readonly outcome: '' | DyNTS_EmailSubmissionOutcome_Enum;
|
|
17
|
+
readonly submissionReference: string;
|
|
18
|
+
readonly acceptedCount: number;
|
|
19
|
+
readonly rejectedCount: number;
|
|
20
|
+
readonly pendingCount: number;
|
|
21
|
+
readonly completedAt: string;
|
|
22
|
+
readonly created: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Internal strict-schema record. The raw claim token and all message content are forbidden. */
|
|
25
|
+
export interface DyNTS_PrivacyRightsNotificationRecord_Interface extends Omit<DyNTS_PrivacyRightsNotificationView_Interface, 'created'> {
|
|
26
|
+
_id: string;
|
|
27
|
+
readonly revision: number;
|
|
28
|
+
readonly claimTokenHash: string;
|
|
29
|
+
readonly claimedAt: string;
|
|
30
|
+
readonly claimExpiresAt: string;
|
|
31
|
+
}
|
|
32
|
+
/** A claim token is returned only to the worker that won the durable dispatch fence. */
|
|
33
|
+
export interface DyNTS_PrivacyRightsNotificationClaimResult_Interface {
|
|
34
|
+
readonly contractVersion: 'dynts-privacy-rights-notification-claim/1';
|
|
35
|
+
readonly claimed: boolean;
|
|
36
|
+
readonly claimToken: string;
|
|
37
|
+
readonly notification: DyNTS_PrivacyRightsNotificationView_Interface;
|
|
38
|
+
}
|
|
39
|
+
/** Terminal completion input from the existing content-free email submission boundary. */
|
|
40
|
+
export interface DyNTS_PrivacyRightsNotificationCompletion_Interface extends DyNTS_PrivacyRightsAuthority_Interface {
|
|
41
|
+
readonly contractVersion: 'dynts-privacy-rights-notification-completion/1';
|
|
42
|
+
readonly claimToken: string;
|
|
43
|
+
readonly submission: DyNTS_EmailSubmissionReceipt_Interface;
|
|
44
|
+
}
|
|
45
|
+
/** Marks an attempted submission as unknown without retaining the transport error. */
|
|
46
|
+
export interface DyNTS_PrivacyRightsNotificationIndeterminate_Interface extends DyNTS_PrivacyRightsAuthority_Interface {
|
|
47
|
+
readonly contractVersion: 'dynts-privacy-rights-notification-indeterminate/1';
|
|
48
|
+
readonly claimToken: string;
|
|
49
|
+
}
|
|
50
|
+
/** Shared durable outbox settings. Product code chooses a closed set of server-owned template codes. */
|
|
51
|
+
export interface DyNTS_PrivacyRightsNotificationSettings_Interface {
|
|
52
|
+
readonly connection: Connection;
|
|
53
|
+
readonly maxOperationTimeMs: number;
|
|
54
|
+
readonly claimTimeMs: number;
|
|
55
|
+
readonly templateCodes: readonly string[];
|
|
56
|
+
}
|
|
57
|
+
/** Transactional schedule input intentionally carries the already validated execution receipt. */
|
|
58
|
+
export interface DyNTS_PrivacyRightsNotificationSchedule_Interface {
|
|
59
|
+
readonly execution: DyNTS_PrivacyRightsExecutionReceipt_Interface;
|
|
60
|
+
readonly templateCode: string;
|
|
61
|
+
readonly session: ClientSession;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=privacy-rights-notification.interface.d.ts.map
|
package/build/_modules/privacy-lifecycle/_models/privacy-rights-notification.interface.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-rights-notification.interface.d.ts","sourceRoot":"","sources":["../../../../src/_modules/privacy-lifecycle/_models/privacy-rights-notification.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,iCAAiC,EAAE,MAAM,+CAA+C,CAAC;AAClG,OAAO,EAAE,sCAAsC,EAAE,MAAM,gEAAgE,CAAC;AACxH,OAAO,EACL,2CAA2C,EAC3C,yCAAyC,EAC1C,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EAAE,6CAA6C,EAAE,MAAM,sCAAsC,CAAC;AAErG,yGAAyG;AACzG,MAAM,WAAW,6CAA8C,SAAQ,sCA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