anonyma 1.0.0 → 1.1.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 +273 -144
- package/README.md +427 -143
- package/dist/ai/index.cjs +522 -0
- package/dist/ai/index.cjs.map +1 -0
- package/dist/ai/index.d.cts +322 -0
- package/dist/ai/index.d.ts +322 -0
- package/dist/ai/index.js +505 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/audit/index.cjs +359 -0
- package/dist/audit/index.cjs.map +1 -0
- package/dist/audit/index.d.cts +287 -0
- package/dist/audit/index.d.ts +287 -0
- package/dist/audit/index.js +340 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/chunk-26IHMQHL.cjs +662 -0
- package/dist/chunk-26IHMQHL.cjs.map +1 -0
- package/dist/chunk-2F2GWGTB.js +174 -0
- package/dist/chunk-2F2GWGTB.js.map +1 -0
- package/dist/chunk-2NNMJ55L.cjs +45 -0
- package/dist/chunk-2NNMJ55L.cjs.map +1 -0
- package/dist/chunk-2YG7R4KJ.cjs +114 -0
- package/dist/chunk-2YG7R4KJ.cjs.map +1 -0
- package/dist/chunk-2ZZHLCEJ.js +237 -0
- package/dist/chunk-2ZZHLCEJ.js.map +1 -0
- package/dist/chunk-3CY6ATKS.cjs +308 -0
- package/dist/chunk-3CY6ATKS.cjs.map +1 -0
- package/dist/chunk-3D5ZCJ7R.js +268 -0
- package/dist/chunk-3D5ZCJ7R.js.map +1 -0
- package/dist/chunk-6LDAIJBL.js +103 -0
- package/dist/chunk-6LDAIJBL.js.map +1 -0
- package/dist/chunk-7HK2V5Q4.js +111 -0
- package/dist/chunk-7HK2V5Q4.js.map +1 -0
- package/dist/chunk-AAP472NG.js +177 -0
- package/dist/chunk-AAP472NG.js.map +1 -0
- package/dist/chunk-AP4JIUNW.js +42 -0
- package/dist/chunk-AP4JIUNW.js.map +1 -0
- package/dist/chunk-BBJPQPGP.js +457 -0
- package/dist/chunk-BBJPQPGP.js.map +1 -0
- package/dist/chunk-CRXRJZEV.cjs +82 -0
- package/dist/chunk-CRXRJZEV.cjs.map +1 -0
- package/dist/chunk-E3PICZYI.js +20 -0
- package/dist/chunk-E3PICZYI.js.map +1 -0
- package/dist/chunk-F7O2FA3F.cjs +1255 -0
- package/dist/chunk-F7O2FA3F.cjs.map +1 -0
- package/dist/chunk-FB56NAAH.cjs +243 -0
- package/dist/chunk-FB56NAAH.cjs.map +1 -0
- package/dist/chunk-G4AN7FND.js +1063 -0
- package/dist/chunk-G4AN7FND.js.map +1 -0
- package/dist/chunk-GS3FRH4K.js +294 -0
- package/dist/chunk-GS3FRH4K.js.map +1 -0
- package/dist/chunk-GYMG5OI3.cjs +186 -0
- package/dist/chunk-GYMG5OI3.cjs.map +1 -0
- package/dist/chunk-IHEIYZPL.cjs +301 -0
- package/dist/chunk-IHEIYZPL.cjs.map +1 -0
- package/dist/chunk-IJAMLYOT.cjs +1087 -0
- package/dist/chunk-IJAMLYOT.cjs.map +1 -0
- package/dist/chunk-ISL5B4LU.cjs +181 -0
- package/dist/chunk-ISL5B4LU.cjs.map +1 -0
- package/dist/chunk-JKW36IPT.js +179 -0
- package/dist/chunk-JKW36IPT.js.map +1 -0
- package/dist/chunk-KOCQBDI4.cjs +179 -0
- package/dist/chunk-KOCQBDI4.cjs.map +1 -0
- package/dist/chunk-OGNLB2KA.js +79 -0
- package/dist/chunk-OGNLB2KA.js.map +1 -0
- package/dist/chunk-PKHZ7CVI.js +28 -0
- package/dist/chunk-PKHZ7CVI.js.map +1 -0
- package/dist/chunk-QYD4F6T7.cjs +114 -0
- package/dist/chunk-QYD4F6T7.cjs.map +1 -0
- package/dist/chunk-RCW5IPPR.js +1288 -0
- package/dist/chunk-RCW5IPPR.js.map +1 -0
- package/dist/chunk-RMMKYHUN.cjs +35 -0
- package/dist/chunk-RMMKYHUN.cjs.map +1 -0
- package/dist/chunk-S4BJ2ADB.cjs +22 -0
- package/dist/chunk-S4BJ2ADB.cjs.map +1 -0
- package/dist/chunk-S7NH6CHY.cjs +462 -0
- package/dist/chunk-S7NH6CHY.cjs.map +1 -0
- package/dist/chunk-SIHPDZXA.js +176 -0
- package/dist/chunk-SIHPDZXA.js.map +1 -0
- package/dist/chunk-TW7PM3UJ.cjs +30 -0
- package/dist/chunk-TW7PM3UJ.cjs.map +1 -0
- package/dist/chunk-UA3EOFBS.cjs +1322 -0
- package/dist/chunk-UA3EOFBS.cjs.map +1 -0
- package/dist/chunk-VE4CCW7W.js +32 -0
- package/dist/chunk-VE4CCW7W.js.map +1 -0
- package/dist/chunk-W6RBCHYF.js +651 -0
- package/dist/chunk-W6RBCHYF.js.map +1 -0
- package/dist/chunk-WLJN7GIS.cjs +189 -0
- package/dist/chunk-WLJN7GIS.cjs.map +1 -0
- package/dist/chunk-YMLR375Z.js +1244 -0
- package/dist/chunk-YMLR375Z.js.map +1 -0
- package/dist/compliance/index.cjs +88 -0
- package/dist/compliance/index.cjs.map +1 -0
- package/dist/compliance/index.d.cts +277 -0
- package/dist/compliance/index.d.ts +277 -0
- package/dist/compliance/index.js +47 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/crypto.cjs +12 -136
- package/dist/crypto.cjs.map +1 -1
- package/dist/crypto.d.cts +4 -3
- package/dist/crypto.d.ts +4 -3
- package/dist/crypto.js +3 -137
- package/dist/crypto.js.map +1 -1
- package/dist/detectors/index.cjs +146 -1483
- package/dist/detectors/index.cjs.map +1 -1
- package/dist/detectors/index.d.cts +1 -1
- package/dist/detectors/index.d.ts +1 -1
- package/dist/detectors/index.js +3 -1449
- package/dist/detectors/index.js.map +1 -1
- package/dist/engine/index.cjs +441 -0
- package/dist/engine/index.cjs.map +1 -0
- package/dist/engine/index.d.cts +728 -0
- package/dist/engine/index.d.ts +728 -0
- package/dist/engine/index.js +189 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/hash-2PSYNDMM.cjs +14 -0
- package/dist/hash-2PSYNDMM.cjs.map +1 -0
- package/dist/hash-CELLDNKN.js +5 -0
- package/dist/hash-CELLDNKN.js.map +1 -0
- package/dist/index.cjs +153 -2816
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -11
- package/dist/index.d.ts +93 -11
- package/dist/index.js +13 -2791
- package/dist/index.js.map +1 -1
- package/dist/json-CKDvlRtl.d.ts +147 -0
- package/dist/json-s8ny-RCo.d.cts +147 -0
- package/dist/mcp/index.cjs +751 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +226 -0
- package/dist/mcp/index.d.ts +226 -0
- package/dist/mcp/index.js +744 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/middleware/express.cjs +93 -0
- package/dist/middleware/express.cjs.map +1 -0
- package/dist/middleware/express.d.cts +90 -0
- package/dist/middleware/express.d.ts +90 -0
- package/dist/middleware/express.js +91 -0
- package/dist/middleware/express.js.map +1 -0
- package/dist/middleware/hono.cjs +58 -0
- package/dist/middleware/hono.cjs.map +1 -0
- package/dist/middleware/hono.d.cts +75 -0
- package/dist/middleware/hono.d.ts +75 -0
- package/dist/middleware/hono.js +56 -0
- package/dist/middleware/hono.js.map +1 -0
- package/dist/middleware/index.cjs +24 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +106 -0
- package/dist/middleware/index.d.ts +106 -0
- package/dist/middleware/index.js +15 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/schemas.cjs +5 -5
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +20 -10
- package/dist/schemas.d.ts +20 -10
- package/dist/schemas.js +5 -5
- package/dist/schemas.js.map +1 -1
- package/dist/session-BdRftyZ5.d.cts +102 -0
- package/dist/session-Cs2zlNQp.d.ts +102 -0
- package/dist/stream.cjs +13 -2262
- package/dist/stream.cjs.map +1 -1
- package/dist/stream.d.cts +1 -1
- package/dist/stream.d.ts +1 -1
- package/dist/stream.js +6 -2255
- package/dist/stream.js.map +1 -1
- package/dist/types--tPm_AjY.d.ts +199 -0
- package/dist/types-0BJH_wqc.d.cts +199 -0
- package/dist/types-CPUhjvl8.d.cts +629 -0
- package/dist/types-Dtht33aq.d.ts +629 -0
- package/dist/{types-D-9HzVuy.d.cts → types-EJTj_BKY.d.cts} +38 -7
- package/dist/{types-D-9HzVuy.d.ts → types-EJTj_BKY.d.ts} +38 -7
- package/dist/types-Zt_bZvwS.d.cts +182 -0
- package/dist/types-Zt_bZvwS.d.ts +182 -0
- package/dist/validators.cjs +39 -181
- package/dist/validators.cjs.map +1 -1
- package/dist/validators.js +1 -174
- package/dist/validators.js.map +1 -1
- package/dist/vault/index.cjs +688 -0
- package/dist/vault/index.cjs.map +1 -0
- package/dist/vault/index.d.cts +385 -0
- package/dist/vault/index.d.ts +385 -0
- package/dist/vault/index.js +669 -0
- package/dist/vault/index.js.map +1 -0
- package/package.json +128 -11
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkIJAMLYOT_cjs = require('../chunk-IJAMLYOT.cjs');
|
|
4
|
+
var chunk3CY6ATKS_cjs = require('../chunk-3CY6ATKS.cjs');
|
|
5
|
+
require('../chunk-KOCQBDI4.cjs');
|
|
6
|
+
require('../chunk-S4BJ2ADB.cjs');
|
|
7
|
+
require('../chunk-2YG7R4KJ.cjs');
|
|
8
|
+
require('../chunk-IHEIYZPL.cjs');
|
|
9
|
+
require('../chunk-UA3EOFBS.cjs');
|
|
10
|
+
require('../chunk-GYMG5OI3.cjs');
|
|
11
|
+
require('../chunk-TW7PM3UJ.cjs');
|
|
12
|
+
var chunkWLJN7GIS_cjs = require('../chunk-WLJN7GIS.cjs');
|
|
13
|
+
|
|
14
|
+
// src/engine/stream.ts
|
|
15
|
+
var DEFAULT_WINDOW = 256;
|
|
16
|
+
var DEFAULT_BATCH = 4096;
|
|
17
|
+
var DEFAULT_TOKEN_LIMIT = 8192;
|
|
18
|
+
function isTokenCode(code) {
|
|
19
|
+
return code > 32 && code < 127;
|
|
20
|
+
}
|
|
21
|
+
function startOfToken(text, cut, limit) {
|
|
22
|
+
if (cut >= text.length || !isTokenCode(text.charCodeAt(cut))) return cut;
|
|
23
|
+
let at = cut;
|
|
24
|
+
while (at > limit && isTokenCode(text.charCodeAt(at - 1))) at--;
|
|
25
|
+
return at > limit || !isTokenCode(text.charCodeAt(at - 1)) ? at : cut;
|
|
26
|
+
}
|
|
27
|
+
function resolveWindow(pipeline, options) {
|
|
28
|
+
if (options.window !== void 0) {
|
|
29
|
+
if (!Number.isInteger(options.window) || options.window < 1) {
|
|
30
|
+
throw new chunkWLJN7GIS_cjs.ValidationError("window", "must be a positive integer");
|
|
31
|
+
}
|
|
32
|
+
return options.window;
|
|
33
|
+
}
|
|
34
|
+
let window = 1;
|
|
35
|
+
for (const detector of pipeline.detectors) {
|
|
36
|
+
window = Math.max(window, detector.maxMatchLength ?? DEFAULT_WINDOW);
|
|
37
|
+
}
|
|
38
|
+
return window;
|
|
39
|
+
}
|
|
40
|
+
function createBuffer(pipeline, options) {
|
|
41
|
+
const window = resolveWindow(pipeline, options);
|
|
42
|
+
const batch = options.batch ?? DEFAULT_BATCH;
|
|
43
|
+
if (!Number.isInteger(batch) || batch < 0) {
|
|
44
|
+
throw new chunkWLJN7GIS_cjs.ValidationError("batch", "must be a non-negative integer");
|
|
45
|
+
}
|
|
46
|
+
const tokenLimit = options.tokenLimit ?? DEFAULT_TOKEN_LIMIT;
|
|
47
|
+
if (!Number.isInteger(tokenLimit) || tokenLimit < 0) {
|
|
48
|
+
throw new chunkWLJN7GIS_cjs.ValidationError("tokenLimit", "must be a non-negative integer");
|
|
49
|
+
}
|
|
50
|
+
let context = "";
|
|
51
|
+
let pending = "";
|
|
52
|
+
let consumed = 0;
|
|
53
|
+
let ordinal = 0;
|
|
54
|
+
let threshold = window + batch;
|
|
55
|
+
function scheduleNextScan() {
|
|
56
|
+
const held = pending.length;
|
|
57
|
+
threshold = held + Math.max(batch, held > 2 * (window + batch) ? held >> 1 : 0);
|
|
58
|
+
}
|
|
59
|
+
function advance(chunk, final) {
|
|
60
|
+
if (typeof chunk !== "string") {
|
|
61
|
+
throw new chunkWLJN7GIS_cjs.ValidationError("chunk", "must be a string");
|
|
62
|
+
}
|
|
63
|
+
pending += chunk;
|
|
64
|
+
if (!final && (chunk.length === 0 || pending.length < threshold)) return [];
|
|
65
|
+
if (pending.length === 0) {
|
|
66
|
+
reset();
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
const text = context + pending;
|
|
70
|
+
const offset = context.length;
|
|
71
|
+
const spans = pipeline.scan(text);
|
|
72
|
+
let cut = text.length;
|
|
73
|
+
if (!final) {
|
|
74
|
+
cut = text.length - window;
|
|
75
|
+
cut = startOfToken(text, cut, Math.max(offset, cut - tokenLimit));
|
|
76
|
+
const before = text.charCodeAt(cut - 1);
|
|
77
|
+
if (before >= 55296 && before <= 56319) cut--;
|
|
78
|
+
for (const span of spans) {
|
|
79
|
+
if (span.start >= cut) break;
|
|
80
|
+
if (span.end > cut) {
|
|
81
|
+
cut = span.start;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (cut <= offset) {
|
|
86
|
+
scheduleNextScan();
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const pieces = [];
|
|
91
|
+
let cursor = offset;
|
|
92
|
+
for (const span of spans) {
|
|
93
|
+
if (span.end <= offset) continue;
|
|
94
|
+
if (span.start >= cut) break;
|
|
95
|
+
const start = Math.max(span.start, offset);
|
|
96
|
+
if (start > cursor) pieces.push(text.slice(cursor, start));
|
|
97
|
+
pieces.push({
|
|
98
|
+
value: text.slice(start, span.end),
|
|
99
|
+
context: describe(span, start, span.start < offset)
|
|
100
|
+
});
|
|
101
|
+
cursor = span.end;
|
|
102
|
+
}
|
|
103
|
+
if (cut > cursor) pieces.push(text.slice(cursor, cut));
|
|
104
|
+
if (final) {
|
|
105
|
+
reset();
|
|
106
|
+
return pieces;
|
|
107
|
+
}
|
|
108
|
+
const keepFrom = Math.max(0, cut - window);
|
|
109
|
+
consumed += keepFrom;
|
|
110
|
+
context = text.slice(keepFrom, cut);
|
|
111
|
+
pending = text.slice(cut);
|
|
112
|
+
scheduleNextScan();
|
|
113
|
+
return pieces;
|
|
114
|
+
}
|
|
115
|
+
function reset() {
|
|
116
|
+
context = "";
|
|
117
|
+
pending = "";
|
|
118
|
+
consumed = 0;
|
|
119
|
+
ordinal = 0;
|
|
120
|
+
threshold = window + batch;
|
|
121
|
+
}
|
|
122
|
+
function describe(span, start, clipped) {
|
|
123
|
+
return {
|
|
124
|
+
category: span.category,
|
|
125
|
+
detector: span.detector,
|
|
126
|
+
confidence: span.confidence,
|
|
127
|
+
start: consumed + start,
|
|
128
|
+
end: consumed + span.end,
|
|
129
|
+
ordinal: ordinal++,
|
|
130
|
+
residual: span.residual || clipped
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { advance };
|
|
134
|
+
}
|
|
135
|
+
function createChunkTransformer(pipeline, options = {}) {
|
|
136
|
+
const buffer = createBuffer(pipeline, options);
|
|
137
|
+
function render(pieces) {
|
|
138
|
+
let out = "";
|
|
139
|
+
for (const piece of pieces) {
|
|
140
|
+
if (typeof piece === "string") {
|
|
141
|
+
out += piece;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const replacement = pipeline.replace(piece.value, piece.context);
|
|
145
|
+
if (typeof replacement !== "string") {
|
|
146
|
+
void Promise.resolve(replacement).catch(() => void 0);
|
|
147
|
+
throw new chunkWLJN7GIS_cjs.AsyncStrategyError(piece.context.category);
|
|
148
|
+
}
|
|
149
|
+
out += replacement;
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
return Object.freeze({
|
|
154
|
+
push: (chunk) => render(buffer.advance(chunk, false)),
|
|
155
|
+
flush: () => render(buffer.advance("", true))
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function createAsyncChunkTransformer(pipeline, options = {}) {
|
|
159
|
+
const buffer = createBuffer(pipeline, options);
|
|
160
|
+
async function render(pieces) {
|
|
161
|
+
let out = "";
|
|
162
|
+
for (const piece of pieces) {
|
|
163
|
+
out += typeof piece === "string" ? piece : await pipeline.replace(piece.value, piece.context);
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
return Object.freeze({
|
|
168
|
+
push: (chunk) => render(buffer.advance(chunk, false)),
|
|
169
|
+
flush: () => render(buffer.advance("", true))
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function createPipelineStream(pipeline, options = {}) {
|
|
173
|
+
if (typeof TransformStream === "undefined") {
|
|
174
|
+
throw new chunkWLJN7GIS_cjs.ValidationError("TransformStream", "is not available in this environment");
|
|
175
|
+
}
|
|
176
|
+
const transformer = createAsyncChunkTransformer(pipeline, options);
|
|
177
|
+
return new TransformStream({
|
|
178
|
+
async transform(chunk, controller) {
|
|
179
|
+
const out = await transformer.push(chunk);
|
|
180
|
+
if (out.length > 0) controller.enqueue(out);
|
|
181
|
+
},
|
|
182
|
+
async flush(controller) {
|
|
183
|
+
const out = await transformer.flush();
|
|
184
|
+
if (out.length > 0) controller.enqueue(out);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
Object.defineProperty(exports, "bareSsnDetector", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
get: function () { return chunkIJAMLYOT_cjs.bareSsnDetector; }
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(exports, "builtinDetectors", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function () { return chunkIJAMLYOT_cjs.builtinDetectors; }
|
|
196
|
+
});
|
|
197
|
+
Object.defineProperty(exports, "compilePipeline", {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () { return chunkIJAMLYOT_cjs.compilePipeline; }
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperty(exports, "constant", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get: function () { return chunkIJAMLYOT_cjs.constant; }
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(exports, "createPipeline", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function () { return chunkIJAMLYOT_cjs.createPipeline; }
|
|
208
|
+
});
|
|
209
|
+
Object.defineProperty(exports, "creditCardDetector", {
|
|
210
|
+
enumerable: true,
|
|
211
|
+
get: function () { return chunkIJAMLYOT_cjs.creditCardDetector; }
|
|
212
|
+
});
|
|
213
|
+
Object.defineProperty(exports, "emailDetector", {
|
|
214
|
+
enumerable: true,
|
|
215
|
+
get: function () { return chunkIJAMLYOT_cjs.emailDetector; }
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(exports, "encryptWith", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
get: function () { return chunkIJAMLYOT_cjs.encryptWith; }
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(exports, "generalizeWith", {
|
|
222
|
+
enumerable: true,
|
|
223
|
+
get: function () { return chunkIJAMLYOT_cjs.generalizeWith; }
|
|
224
|
+
});
|
|
225
|
+
Object.defineProperty(exports, "hashWith", {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get: function () { return chunkIJAMLYOT_cjs.hashWith; }
|
|
228
|
+
});
|
|
229
|
+
Object.defineProperty(exports, "ibanDetector", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function () { return chunkIJAMLYOT_cjs.ibanDetector; }
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(exports, "ipv4Detector", {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: function () { return chunkIJAMLYOT_cjs.ipv4Detector; }
|
|
236
|
+
});
|
|
237
|
+
Object.defineProperty(exports, "ipv6Detector", {
|
|
238
|
+
enumerable: true,
|
|
239
|
+
get: function () { return chunkIJAMLYOT_cjs.ipv6Detector; }
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(exports, "maskWith", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function () { return chunkIJAMLYOT_cjs.maskWith; }
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(exports, "maskedCardDetector", {
|
|
246
|
+
enumerable: true,
|
|
247
|
+
get: function () { return chunkIJAMLYOT_cjs.maskedCardDetector; }
|
|
248
|
+
});
|
|
249
|
+
Object.defineProperty(exports, "obfuscatedEmailDetector", {
|
|
250
|
+
enumerable: true,
|
|
251
|
+
get: function () { return chunkIJAMLYOT_cjs.obfuscatedEmailDetector; }
|
|
252
|
+
});
|
|
253
|
+
Object.defineProperty(exports, "pseudonymizeWith", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function () { return chunkIJAMLYOT_cjs.pseudonymizeWith; }
|
|
256
|
+
});
|
|
257
|
+
Object.defineProperty(exports, "redactWith", {
|
|
258
|
+
enumerable: true,
|
|
259
|
+
get: function () { return chunkIJAMLYOT_cjs.redactWith; }
|
|
260
|
+
});
|
|
261
|
+
Object.defineProperty(exports, "resolveSpans", {
|
|
262
|
+
enumerable: true,
|
|
263
|
+
get: function () { return chunkIJAMLYOT_cjs.resolveSpans; }
|
|
264
|
+
});
|
|
265
|
+
Object.defineProperty(exports, "spanText", {
|
|
266
|
+
enumerable: true,
|
|
267
|
+
get: function () { return chunkIJAMLYOT_cjs.spanText; }
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(exports, "ssnDetector", {
|
|
270
|
+
enumerable: true,
|
|
271
|
+
get: function () { return chunkIJAMLYOT_cjs.ssnDetector; }
|
|
272
|
+
});
|
|
273
|
+
Object.defineProperty(exports, "strategyReplacer", {
|
|
274
|
+
enumerable: true,
|
|
275
|
+
get: function () { return chunkIJAMLYOT_cjs.strategyReplacer; }
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(exports, "synthesizeWith", {
|
|
278
|
+
enumerable: true,
|
|
279
|
+
get: function () { return chunkIJAMLYOT_cjs.synthesizeWith; }
|
|
280
|
+
});
|
|
281
|
+
Object.defineProperty(exports, "BUILTIN_CATEGORIES", {
|
|
282
|
+
enumerable: true,
|
|
283
|
+
get: function () { return chunk3CY6ATKS_cjs.BUILTIN_CATEGORIES; }
|
|
284
|
+
});
|
|
285
|
+
Object.defineProperty(exports, "LEGACY_AGGRESSIVE_DETECTORS", {
|
|
286
|
+
enumerable: true,
|
|
287
|
+
get: function () { return chunk3CY6ATKS_cjs.LEGACY_AGGRESSIVE_DETECTORS; }
|
|
288
|
+
});
|
|
289
|
+
Object.defineProperty(exports, "LEGACY_DETECTORS", {
|
|
290
|
+
enumerable: true,
|
|
291
|
+
get: function () { return chunk3CY6ATKS_cjs.LEGACY_DETECTORS; }
|
|
292
|
+
});
|
|
293
|
+
Object.defineProperty(exports, "addressDetector", {
|
|
294
|
+
enumerable: true,
|
|
295
|
+
get: function () { return chunk3CY6ATKS_cjs.addressDetector; }
|
|
296
|
+
});
|
|
297
|
+
Object.defineProperty(exports, "apiKeyDetector", {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
get: function () { return chunk3CY6ATKS_cjs.apiKeyDetector; }
|
|
300
|
+
});
|
|
301
|
+
Object.defineProperty(exports, "bankAccountDetector", {
|
|
302
|
+
enumerable: true,
|
|
303
|
+
get: function () { return chunk3CY6ATKS_cjs.bankAccountDetector; }
|
|
304
|
+
});
|
|
305
|
+
Object.defineProperty(exports, "caseNumberDetector", {
|
|
306
|
+
enumerable: true,
|
|
307
|
+
get: function () { return chunk3CY6ATKS_cjs.caseNumberDetector; }
|
|
308
|
+
});
|
|
309
|
+
Object.defineProperty(exports, "companyRegistrationDetector", {
|
|
310
|
+
enumerable: true,
|
|
311
|
+
get: function () { return chunk3CY6ATKS_cjs.companyRegistrationDetector; }
|
|
312
|
+
});
|
|
313
|
+
Object.defineProperty(exports, "cryptocurrencyDetector", {
|
|
314
|
+
enumerable: true,
|
|
315
|
+
get: function () { return chunk3CY6ATKS_cjs.cryptocurrencyDetector; }
|
|
316
|
+
});
|
|
317
|
+
Object.defineProperty(exports, "dateOfBirthDetector", {
|
|
318
|
+
enumerable: true,
|
|
319
|
+
get: function () { return chunk3CY6ATKS_cjs.dateOfBirthDetector; }
|
|
320
|
+
});
|
|
321
|
+
Object.defineProperty(exports, "defineDetector", {
|
|
322
|
+
enumerable: true,
|
|
323
|
+
get: function () { return chunk3CY6ATKS_cjs.defineDetector; }
|
|
324
|
+
});
|
|
325
|
+
Object.defineProperty(exports, "defineRegexDetector", {
|
|
326
|
+
enumerable: true,
|
|
327
|
+
get: function () { return chunk3CY6ATKS_cjs.defineRegexDetector; }
|
|
328
|
+
});
|
|
329
|
+
Object.defineProperty(exports, "driversLicenseDetector", {
|
|
330
|
+
enumerable: true,
|
|
331
|
+
get: function () { return chunk3CY6ATKS_cjs.driversLicenseDetector; }
|
|
332
|
+
});
|
|
333
|
+
Object.defineProperty(exports, "fromLegacyDetector", {
|
|
334
|
+
enumerable: true,
|
|
335
|
+
get: function () { return chunk3CY6ATKS_cjs.fromLegacyDetector; }
|
|
336
|
+
});
|
|
337
|
+
Object.defineProperty(exports, "healthInsuranceDetector", {
|
|
338
|
+
enumerable: true,
|
|
339
|
+
get: function () { return chunk3CY6ATKS_cjs.healthInsuranceDetector; }
|
|
340
|
+
});
|
|
341
|
+
Object.defineProperty(exports, "legacyCreditCardAggressiveDetector", {
|
|
342
|
+
enumerable: true,
|
|
343
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyCreditCardAggressiveDetector; }
|
|
344
|
+
});
|
|
345
|
+
Object.defineProperty(exports, "legacyCreditCardDetector", {
|
|
346
|
+
enumerable: true,
|
|
347
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyCreditCardDetector; }
|
|
348
|
+
});
|
|
349
|
+
Object.defineProperty(exports, "legacyEmailAggressiveDetector", {
|
|
350
|
+
enumerable: true,
|
|
351
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyEmailAggressiveDetector; }
|
|
352
|
+
});
|
|
353
|
+
Object.defineProperty(exports, "legacyEmailDetector", {
|
|
354
|
+
enumerable: true,
|
|
355
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyEmailDetector; }
|
|
356
|
+
});
|
|
357
|
+
Object.defineProperty(exports, "legacyIbanDetector", {
|
|
358
|
+
enumerable: true,
|
|
359
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyIbanDetector; }
|
|
360
|
+
});
|
|
361
|
+
Object.defineProperty(exports, "legacyIpv4Detector", {
|
|
362
|
+
enumerable: true,
|
|
363
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyIpv4Detector; }
|
|
364
|
+
});
|
|
365
|
+
Object.defineProperty(exports, "legacyIpv6Detector", {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function () { return chunk3CY6ATKS_cjs.legacyIpv6Detector; }
|
|
368
|
+
});
|
|
369
|
+
Object.defineProperty(exports, "legacySsnAggressiveDetector", {
|
|
370
|
+
enumerable: true,
|
|
371
|
+
get: function () { return chunk3CY6ATKS_cjs.legacySsnAggressiveDetector; }
|
|
372
|
+
});
|
|
373
|
+
Object.defineProperty(exports, "legacySsnDetector", {
|
|
374
|
+
enumerable: true,
|
|
375
|
+
get: function () { return chunk3CY6ATKS_cjs.legacySsnDetector; }
|
|
376
|
+
});
|
|
377
|
+
Object.defineProperty(exports, "licensePlateDetector", {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function () { return chunk3CY6ATKS_cjs.licensePlateDetector; }
|
|
380
|
+
});
|
|
381
|
+
Object.defineProperty(exports, "medicalRecordDetector", {
|
|
382
|
+
enumerable: true,
|
|
383
|
+
get: function () { return chunk3CY6ATKS_cjs.medicalRecordDetector; }
|
|
384
|
+
});
|
|
385
|
+
Object.defineProperty(exports, "nameAggressiveDetector", {
|
|
386
|
+
enumerable: true,
|
|
387
|
+
get: function () { return chunk3CY6ATKS_cjs.nameAggressiveDetector; }
|
|
388
|
+
});
|
|
389
|
+
Object.defineProperty(exports, "nameDetector", {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function () { return chunk3CY6ATKS_cjs.nameDetector; }
|
|
392
|
+
});
|
|
393
|
+
Object.defineProperty(exports, "nationalIdDetector", {
|
|
394
|
+
enumerable: true,
|
|
395
|
+
get: function () { return chunk3CY6ATKS_cjs.nationalIdDetector; }
|
|
396
|
+
});
|
|
397
|
+
Object.defineProperty(exports, "passportDetector", {
|
|
398
|
+
enumerable: true,
|
|
399
|
+
get: function () { return chunk3CY6ATKS_cjs.passportDetector; }
|
|
400
|
+
});
|
|
401
|
+
Object.defineProperty(exports, "phoneAggressiveDetector", {
|
|
402
|
+
enumerable: true,
|
|
403
|
+
get: function () { return chunk3CY6ATKS_cjs.phoneAggressiveDetector; }
|
|
404
|
+
});
|
|
405
|
+
Object.defineProperty(exports, "phoneDetector", {
|
|
406
|
+
enumerable: true,
|
|
407
|
+
get: function () { return chunk3CY6ATKS_cjs.phoneDetector; }
|
|
408
|
+
});
|
|
409
|
+
Object.defineProperty(exports, "prescriptionDetector", {
|
|
410
|
+
enumerable: true,
|
|
411
|
+
get: function () { return chunk3CY6ATKS_cjs.prescriptionDetector; }
|
|
412
|
+
});
|
|
413
|
+
Object.defineProperty(exports, "socialMediaDetector", {
|
|
414
|
+
enumerable: true,
|
|
415
|
+
get: function () { return chunk3CY6ATKS_cjs.socialMediaDetector; }
|
|
416
|
+
});
|
|
417
|
+
Object.defineProperty(exports, "taxIdDetector", {
|
|
418
|
+
enumerable: true,
|
|
419
|
+
get: function () { return chunk3CY6ATKS_cjs.taxIdDetector; }
|
|
420
|
+
});
|
|
421
|
+
Object.defineProperty(exports, "trackingNumberDetector", {
|
|
422
|
+
enumerable: true,
|
|
423
|
+
get: function () { return chunk3CY6ATKS_cjs.trackingNumberDetector; }
|
|
424
|
+
});
|
|
425
|
+
Object.defineProperty(exports, "urlDetector", {
|
|
426
|
+
enumerable: true,
|
|
427
|
+
get: function () { return chunk3CY6ATKS_cjs.urlDetector; }
|
|
428
|
+
});
|
|
429
|
+
Object.defineProperty(exports, "vinAggressiveDetector", {
|
|
430
|
+
enumerable: true,
|
|
431
|
+
get: function () { return chunk3CY6ATKS_cjs.vinAggressiveDetector; }
|
|
432
|
+
});
|
|
433
|
+
Object.defineProperty(exports, "vinDetector", {
|
|
434
|
+
enumerable: true,
|
|
435
|
+
get: function () { return chunk3CY6ATKS_cjs.vinDetector; }
|
|
436
|
+
});
|
|
437
|
+
exports.createAsyncChunkTransformer = createAsyncChunkTransformer;
|
|
438
|
+
exports.createChunkTransformer = createChunkTransformer;
|
|
439
|
+
exports.createPipelineStream = createPipelineStream;
|
|
440
|
+
//# sourceMappingURL=index.cjs.map
|
|
441
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/engine/stream.ts"],"names":["ValidationError","AsyncStrategyError"],"mappings":";;;;;;;;;;;;;;AA+BA,IAAM,cAAA,GAAiB,GAAA;AACvB,IAAM,aAAA,GAAgB,IAAA;AACtB,IAAM,mBAAA,GAAsB,IAAA;AAG5B,SAAS,YAAY,IAAA,EAAuB;AAC1C,EAAA,OAAO,IAAA,GAAO,MAAM,IAAA,GAAO,GAAA;AAC7B;AAMA,SAAS,YAAA,CAAa,IAAA,EAAc,GAAA,EAAa,KAAA,EAAuB;AACtE,EAAA,IAAI,GAAA,IAAO,IAAA,CAAK,MAAA,IAAU,CAAC,WAAA,CAAY,KAAK,UAAA,CAAW,GAAG,CAAC,CAAA,EAAG,OAAO,GAAA;AACrE,EAAA,IAAI,EAAA,GAAK,GAAA;AACT,EAAA,OAAO,EAAA,GAAK,SAAS,WAAA,CAAY,IAAA,CAAK,WAAW,EAAA,GAAK,CAAC,CAAC,CAAA,EAAG,EAAA,EAAA;AAC3D,EAAA,OAAO,EAAA,GAAK,KAAA,IAAS,CAAC,WAAA,CAAY,IAAA,CAAK,WAAW,EAAA,GAAK,CAAC,CAAC,CAAA,GAAI,EAAA,GAAK,GAAA;AACpE;AAUA,SAAS,aAAA,CAAc,UAAoB,OAAA,EAA+B;AACxE,EAAA,IAAI,OAAA,CAAQ,WAAW,MAAA,EAAW;AAChC,I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AACH;AAsBO,SAAS,oBAAA,CACd,QAAA,EACA,OAAA,GAAwB,EAAC,EACQ;AACjC,EAAA,IAAI,OAAO,oBAAoB,WAAA,EAAa;AAC1C,IAAA,MAAM,IAAID,iCAAA,CAAgB,iBAAA,EAAmB,sCAAsC,CAAA;AAAA,EACrF;AACA,EAAA,MAAM,WAAA,GAAc,2BAAA,CAA4B,QAAA,EAAU,OAAO,CAAA;AACjE,EAAA,OAAO,IAAI,eAAA,CAAgC;AAAA,IACzC,MAAM,SAAA,CAAU,KAAA,EAAO,UAAA,EAA2B;AAChD,MAAA,MAAM,GAAA,GAAM,MAAM,WAAA,CAAY,IAAA,CAAK,KAAK,CAAA;AACxC,MAAA,IAAI,GAAA,CAAI,MAAA,GAAS,CAAA,EAAG,UAAA,CAAW,QAAQ,GAAG,CAAA;AAAA,IAC5C,CAAA;AAAA,IACA,MAAM,MAAM,UAAA,EAA2B;AACrC,MAAA,MAAM,GAAA,GAAM,MAAM,WAAA,CAAY,KAAA,EAAM;AACpC,MAAA,IAAI,GAAA,CAAI,MAAA,GAAS,CAAA,EAAG,UAAA,CAAW,QAAQ,GAAG,CAAA;AAAA,IAC5C;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["/**\n * @module engine/stream\n * @description Chunk-boundary-safe transformation. Text may arrive split at\n * arbitrary positions — in the middle of an email address, a card number or a\n * surrogate pair — and the output is the same as if it had arrived in one\n * piece.\n *\n * The transformer keeps the last `window` characters unemitted until more\n * input arrives, and re-scans them together with a `window` of already\n * emitted text as left context. It never emits part of a detection that is\n * still growing, nor part of an unbroken run of printable ASCII characters (a\n * key, a token, a URL) of up to `tokenLimit` characters, because such a value\n * cannot be recognised from its beginning. Output therefore lags input by at\n * most `window + batch` characters plus the length of what is being held.\n *\n * The guarantee holds for detections (including the look-around their\n * patterns need) that fit in the window or contain no whitespace and fit in\n * `tokenLimit`; a longer detection that is split across chunks may be\n * replaced only from the point where it became visible.\n */\n\nimport { AsyncStrategyError, ValidationError } from \"../errors.js\";\nimport type {\n AsyncChunkTransformer,\n ChunkOptions,\n ChunkTransformer,\n DetectedSpan,\n Pipeline,\n ReplaceContext,\n} from \"./types.js\";\n\nconst DEFAULT_WINDOW = 256;\nconst DEFAULT_BATCH = 4096;\nconst DEFAULT_TOKEN_LIMIT = 8192;\n\n/** Printable ASCII other than the space: the characters keys, tokens and URLs are made of. */\nfunction isTokenCode(code: number): boolean {\n return code > 32 && code < 127;\n}\n\n/**\n * Move `cut` back to the start of the unbroken run of token characters it\n * falls in, unless the run began before `limit`.\n */\nfunction startOfToken(text: string, cut: number, limit: number): number {\n if (cut >= text.length || !isTokenCode(text.charCodeAt(cut))) return cut;\n let at = cut;\n while (at > limit && isTokenCode(text.charCodeAt(at - 1))) at--;\n return at > limit || !isTokenCode(text.charCodeAt(at - 1)) ? at : cut;\n}\n\n/** One piece of settled output: literal text or a value to replace. */\ntype Piece = string | { readonly value: string; readonly context: ReplaceContext };\n\ninterface Buffer {\n /** Feed more input (or `\"\"`), and return the pieces that are now settled. */\n readonly advance: (chunk: string, final: boolean) => Piece[];\n}\n\nfunction resolveWindow(pipeline: Pipeline, options: ChunkOptions): number {\n if (options.window !== undefined) {\n if (!Number.isInteger(options.window) || options.window < 1) {\n throw new ValidationError(\"window\", \"must be a positive integer\");\n }\n return options.window;\n }\n let window = 1;\n for (const detector of pipeline.detectors) {\n window = Math.max(window, detector.maxMatchLength ?? DEFAULT_WINDOW);\n }\n return window;\n}\n\nfunction createBuffer(pipeline: Pipeline, options: ChunkOptions): Buffer {\n const window = resolveWindow(pipeline, options);\n const batch = options.batch ?? DEFAULT_BATCH;\n if (!Number.isInteger(batch) || batch < 0) {\n throw new ValidationError(\"batch\", \"must be a non-negative integer\");\n }\n const tokenLimit = options.tokenLimit ?? DEFAULT_TOKEN_LIMIT;\n if (!Number.isInteger(tokenLimit) || tokenLimit < 0) {\n throw new ValidationError(\"tokenLimit\", \"must be a non-negative integer\");\n }\n\n /** Already emitted input kept as left context for the next scan. */\n let context = \"\";\n /** Input that has not been emitted yet. */\n let pending = \"\";\n /** Number of input characters that precede `context` in the stream. */\n let consumed = 0;\n /** Number of replacements made so far. */\n let ordinal = 0;\n /** Length `pending` must reach before the next scan. */\n let threshold = window + batch;\n\n /**\n * Scanning costs the same for a short text as for a window of it, so the\n * next scan waits for a batch of new input. While a long value is held back\n * the wait grows with it, which keeps the total work linear in the input.\n */\n function scheduleNextScan(): void {\n const held = pending.length;\n threshold = held + Math.max(batch, held > 2 * (window + batch) ? held >> 1 : 0);\n }\n\n function advance(chunk: string, final: boolean): Piece[] {\n if (typeof chunk !== \"string\") {\n throw new ValidationError(\"chunk\", \"must be a string\");\n }\n pending += chunk;\n if (!final && (chunk.length === 0 || pending.length < threshold)) return [];\n if (pending.length === 0) {\n reset();\n return [];\n }\n\n const text = context + pending;\n const offset = context.length;\n const spans = pipeline.scan(text);\n\n let cut = text.length;\n if (!final) {\n cut = text.length - window;\n // Never cut through a key or a token that is still arriving.\n cut = startOfToken(text, cut, Math.max(offset, cut - tokenLimit));\n // Never cut through a surrogate pair.\n const before = text.charCodeAt(cut - 1);\n if (before >= 0xd800 && before <= 0xdbff) cut--;\n // Never cut through a detection: hold it back until it is settled.\n for (const span of spans) {\n if (span.start >= cut) break;\n if (span.end > cut) {\n cut = span.start;\n break;\n }\n }\n if (cut <= offset) {\n scheduleNextScan();\n return [];\n }\n }\n\n const pieces: Piece[] = [];\n let cursor = offset;\n for (const span of spans) {\n if (span.end <= offset) continue;\n if (span.start >= cut) break;\n // A detection that begins in text already emitted can only be replaced from here on.\n const start = Math.max(span.start, offset);\n if (start > cursor) pieces.push(text.slice(cursor, start));\n pieces.push({\n value: text.slice(start, span.end),\n context: describe(span, start, span.start < offset),\n });\n cursor = span.end;\n }\n if (cut > cursor) pieces.push(text.slice(cursor, cut));\n\n if (final) {\n reset();\n return pieces;\n }\n const keepFrom = Math.max(0, cut - window);\n consumed += keepFrom;\n context = text.slice(keepFrom, cut);\n pending = text.slice(cut);\n scheduleNextScan();\n return pieces;\n }\n\n /** The end of the input: the next push starts a new text. */\n function reset(): void {\n context = \"\";\n pending = \"\";\n consumed = 0;\n ordinal = 0;\n threshold = window + batch;\n }\n\n function describe(span: DetectedSpan, start: number, clipped: boolean): ReplaceContext {\n return {\n category: span.category,\n detector: span.detector,\n confidence: span.confidence,\n start: consumed + start,\n end: consumed + span.end,\n ordinal: ordinal++,\n residual: span.residual || clipped,\n };\n }\n\n return { advance };\n}\n\n/**\n * Create a push-style transformer that accepts text in arbitrary chunks.\n *\n * @param pipeline - The pipeline to apply. Its replacers must be synchronous.\n * @param options - Hold-back window, scan batching and token limit.\n * @returns A {@link ChunkTransformer}. After `flush()` it is ready for a new\n * text; discard it after an error.\n * @throws {@link ValidationError} When `window`, `batch` or `tokenLimit` is invalid.\n *\n * @example\n * ```ts\n * import { compilePipeline, createChunkTransformer } from \"anonyma/engine\";\n *\n * const transformer = createChunkTransformer(compilePipeline());\n * let out = transformer.push(\"Contact alice@exam\");\n * out += transformer.push(\"ple.com today\");\n * out += transformer.flush();\n * // \"Contact [REDACTED] today\"\n * ```\n */\nexport function createChunkTransformer(\n pipeline: Pipeline,\n options: ChunkOptions = {},\n): ChunkTransformer {\n const buffer = createBuffer(pipeline, options);\n\n function render(pieces: Piece[]): string {\n let out = \"\";\n for (const piece of pieces) {\n if (typeof piece === \"string\") {\n out += piece;\n continue;\n }\n const replacement = pipeline.replace(piece.value, piece.context);\n if (typeof replacement !== \"string\") {\n void Promise.resolve(replacement).catch(() => undefined);\n throw new AsyncStrategyError(piece.context.category);\n }\n out += replacement;\n }\n return out;\n }\n\n return Object.freeze({\n push: (chunk: string): string => render(buffer.advance(chunk, false)),\n flush: (): string => render(buffer.advance(\"\", true)),\n });\n}\n\n/**\n * Create a push-style transformer for pipelines with asynchronous replacers.\n * Calls must not overlap: await each `push()` before the next one.\n *\n * @param pipeline - The pipeline to apply.\n * @param options - Hold-back window, scan batching and token limit.\n * @returns An {@link AsyncChunkTransformer}. After `flush()` it is ready for a\n * new text; discard it after an error.\n * @throws {@link ValidationError} When `window`, `batch` or `tokenLimit` is invalid.\n *\n * @example\n * ```ts\n * const transformer = createAsyncChunkTransformer(pipeline);\n * for await (const chunk of source) sink.write(await transformer.push(chunk));\n * sink.write(await transformer.flush());\n * ```\n */\nexport function createAsyncChunkTransformer(\n pipeline: Pipeline,\n options: ChunkOptions = {},\n): AsyncChunkTransformer {\n const buffer = createBuffer(pipeline, options);\n\n async function render(pieces: Piece[]): Promise<string> {\n let out = \"\";\n for (const piece of pieces) {\n out += typeof piece === \"string\" ? piece : await pipeline.replace(piece.value, piece.context);\n }\n return out;\n }\n\n return Object.freeze({\n push: (chunk: string): Promise<string> => render(buffer.advance(chunk, false)),\n flush: (): Promise<string> => render(buffer.advance(\"\", true)),\n });\n}\n\n/**\n * Create a WHATWG `TransformStream` that applies a pipeline to a stream of\n * string chunks. Unlike the 1.x `createAnonymizeStream()`, it detects values\n * that are split across chunk boundaries and emits plain strings.\n *\n * @param pipeline - The pipeline to apply. Replacers may be asynchronous.\n * @param options - Hold-back window, scan batching and token limit.\n * @returns A `TransformStream<string, string>`.\n * @throws {@link ValidationError} When `TransformStream` is unavailable or an option is invalid.\n *\n * @example\n * ```ts\n * import { compilePipeline, createPipelineStream } from \"anonyma/engine\";\n *\n * const scrubbed = response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(createPipelineStream(compilePipeline({ preset: \"gdpr\" })))\n * .pipeThrough(new TextEncoderStream());\n * ```\n */\nexport function createPipelineStream(\n pipeline: Pipeline,\n options: ChunkOptions = {},\n): TransformStream<string, string> {\n if (typeof TransformStream === \"undefined\") {\n throw new ValidationError(\"TransformStream\", \"is not available in this environment\");\n }\n const transformer = createAsyncChunkTransformer(pipeline, options);\n return new TransformStream<string, string>({\n async transform(chunk, controller): Promise<void> {\n const out = await transformer.push(chunk);\n if (out.length > 0) controller.enqueue(out);\n },\n async flush(controller): Promise<void> {\n const out = await transformer.flush();\n if (out.length > 0) controller.enqueue(out);\n },\n });\n}\n"]}
|