@stll/anonymize 2.0.1 → 2.0.2

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/dist/native.mjs CHANGED
@@ -1,4 +1,164 @@
1
1
  //#region src/native.ts
2
+ const CALLER_DETECTION_CONTRACT_VERSION = 2;
3
+ const callerDetectionRequestJson = (detections) => JSON.stringify({
4
+ version: 2,
5
+ detections: detections.map((detection) => ({
6
+ start: detection.start,
7
+ end: detection.end,
8
+ label: detection.label,
9
+ score: detection.score,
10
+ provider_id: detection.providerId,
11
+ detection_id: detection.detectionId
12
+ }))
13
+ });
14
+ var PreparedNativeRedactionSession = class {
15
+ #session;
16
+ constructor(session) {
17
+ this.#session = session;
18
+ }
19
+ sessionId() {
20
+ return this.#session.sessionId();
21
+ }
22
+ session_id() {
23
+ return this.sessionId();
24
+ }
25
+ mappingCount() {
26
+ return this.#session.mappingCount();
27
+ }
28
+ mapping_count() {
29
+ return this.mappingCount();
30
+ }
31
+ restoreText(fullText, observedAtEpochSeconds) {
32
+ if (observedAtEpochSeconds === void 0) {
33
+ const restore = this.#session.restoreText;
34
+ if (!restore) throw new Error("Native anonymize binding does not support session restoration");
35
+ return restore.call(this.#session, fullText);
36
+ }
37
+ const restore = this.#session.restoreTextAt;
38
+ if (!restore) throw new Error("Native anonymize binding does not support session restoration lifecycle controls");
39
+ return restore.call(this.#session, fullText, observedAtEpochSeconds);
40
+ }
41
+ restore_text(fullText, observedAtEpochSeconds) {
42
+ return this.restoreText(fullText, observedAtEpochSeconds);
43
+ }
44
+ toPlaintextJson() {
45
+ return this.#session.toPlaintextJson();
46
+ }
47
+ to_plaintext_json() {
48
+ return this.toPlaintextJson();
49
+ }
50
+ toPlaintextJsonAt(observedAtEpochSeconds) {
51
+ const serialize = this.#session.toPlaintextJsonAt;
52
+ if (!serialize) throw new Error("Native anonymize binding does not support session lifecycle controls");
53
+ return serialize.call(this.#session, observedAtEpochSeconds);
54
+ }
55
+ to_plaintext_json_at(observedAtEpochSeconds) {
56
+ return this.toPlaintextJsonAt(observedAtEpochSeconds);
57
+ }
58
+ toEncryptedArchive(key) {
59
+ const serialize = this.#session.toEncryptedArchive;
60
+ if (!serialize) throw new Error("Native anonymize binding does not support encrypted session archives");
61
+ return serialize.call(this.#session, key);
62
+ }
63
+ to_encrypted_archive(key) {
64
+ return this.toEncryptedArchive(key);
65
+ }
66
+ toEncryptedArchiveAt(key, observedAtEpochSeconds) {
67
+ const serialize = this.#session.toEncryptedArchiveAt;
68
+ if (!serialize) throw new Error("Native anonymize binding does not support encrypted session archives");
69
+ return serialize.call(this.#session, key, observedAtEpochSeconds);
70
+ }
71
+ to_encrypted_archive_at(key, observedAtEpochSeconds) {
72
+ return this.toEncryptedArchiveAt(key, observedAtEpochSeconds);
73
+ }
74
+ inspect(observedAtEpochSeconds) {
75
+ const inspect = this.#session.inspectJson;
76
+ if (!inspect) throw new Error("Native anonymize binding does not support session lifecycle controls");
77
+ const metadata = JSON.parse(inspect.call(this.#session, observedAtEpochSeconds));
78
+ return {
79
+ sessionId: metadata.session_id,
80
+ createdAtEpochSeconds: metadata.created_at_epoch_seconds,
81
+ expiresAtEpochSeconds: metadata.expires_at_epoch_seconds,
82
+ mappingCount: metadata.mapping_count,
83
+ status: metadata.status
84
+ };
85
+ }
86
+ delete() {
87
+ const deleteSession = this.#session.deleteJson;
88
+ if (!deleteSession) throw new Error("Native anonymize binding does not support session lifecycle controls");
89
+ const summary = JSON.parse(deleteSession.call(this.#session));
90
+ return {
91
+ sessionId: summary.session_id,
92
+ deletedMappingCount: summary.deleted_mapping_count
93
+ };
94
+ }
95
+ redactStaticEntities(fullText, operators) {
96
+ const result = JSON.parse(this.redact_text_json(fullText, operators));
97
+ return fromCanonicalStaticRedactionResult(result);
98
+ }
99
+ redactText(fullText, operators) {
100
+ return this.redactStaticEntities(fullText, operators);
101
+ }
102
+ redact_text(fullText, operators) {
103
+ return this.redactText(fullText, operators);
104
+ }
105
+ redactTextJson(fullText, operators) {
106
+ return this.redact_text_json(fullText, operators);
107
+ }
108
+ redact_text_json(fullText, operators) {
109
+ return this.#session.redactStaticEntitiesJson(fullText, toBindingOperatorConfig(operators));
110
+ }
111
+ redactStaticEntitiesAt(options) {
112
+ const result = JSON.parse(this.redactTextJsonAt(options));
113
+ return fromCanonicalStaticRedactionResult(result);
114
+ }
115
+ redactTextAt(options) {
116
+ return this.redactStaticEntitiesAt(options);
117
+ }
118
+ redact_text_at(options) {
119
+ return this.redactTextAt(options);
120
+ }
121
+ redact_static_entities_at(options) {
122
+ return this.redactStaticEntitiesAt(options);
123
+ }
124
+ redactTextJsonAt({ fullText, observedAtEpochSeconds, operators }) {
125
+ const redact = this.#session.redactStaticEntitiesJsonAt;
126
+ if (!redact) throw new Error("Native anonymize binding does not support session lifecycle controls");
127
+ return redact.call(this.#session, fullText, observedAtEpochSeconds, toBindingOperatorConfig(operators));
128
+ }
129
+ redact_text_json_at(options) {
130
+ return this.redactTextJsonAt(options);
131
+ }
132
+ planTextBatchWithCallerDetections({ inputs, operators, observedAtEpochSeconds }) {
133
+ const plan = this.#session.planStaticEntitiesWithCallerDetections;
134
+ if (!plan) throw new Error("Native anonymize binding does not support transactional caller-detection session plans");
135
+ const bindingOperators = toBindingOperatorConfig(operators);
136
+ return new PreparedNativeSessionRedactionPlan(plan.call(this.#session, {
137
+ inputs: inputs.map(({ detections, fullText }) => ({
138
+ fullText,
139
+ requestJson: callerDetectionRequestJson(detections)
140
+ })),
141
+ ...bindingOperators === void 0 ? {} : { operators: bindingOperators },
142
+ ...observedAtEpochSeconds === void 0 ? {} : { observedAtEpochSeconds }
143
+ }));
144
+ }
145
+ };
146
+ var PreparedNativeSessionRedactionPlan = class {
147
+ blocks;
148
+ #plan;
149
+ constructor(plan) {
150
+ this.#plan = plan;
151
+ const blocks = JSON.parse(plan.resultJson());
152
+ this.blocks = blocks.map(({ caller_entity_count, entity_count, replacements }) => ({
153
+ replacements,
154
+ entityCount: entity_count,
155
+ callerEntityCount: caller_entity_count
156
+ }));
157
+ }
158
+ commit() {
159
+ this.#plan.commit();
160
+ }
161
+ };
2
162
  var PreparedNativeAnonymizer = class {
3
163
  #prepared;
4
164
  constructor(prepared) {
@@ -27,6 +187,43 @@ var PreparedNativeAnonymizer = class {
27
187
  warm_lazy_regex_diagnostics_json() {
28
188
  return this.warmLazyRegexDiagnosticsJson();
29
189
  }
190
+ createRedactionSession(sessionId) {
191
+ const create = this.#prepared.createRedactionSession;
192
+ if (!create) throw new Error("Native anonymize binding does not support redaction sessions");
193
+ return new PreparedNativeRedactionSession(create.call(this.#prepared, sessionId));
194
+ }
195
+ create_redaction_session(sessionId) {
196
+ return this.createRedactionSession(sessionId);
197
+ }
198
+ createRedactionSessionWithLifecycle({ sessionId, createdAtEpochSeconds, expiresAtEpochSeconds }) {
199
+ const create = this.#prepared.createRedactionSessionWithLifecycle;
200
+ if (!create) throw new Error("Native anonymize binding does not support session lifecycle controls");
201
+ return new PreparedNativeRedactionSession(create.call(this.#prepared, sessionId, createdAtEpochSeconds, expiresAtEpochSeconds));
202
+ }
203
+ create_redaction_session_with_lifecycle(options) {
204
+ return this.createRedactionSessionWithLifecycle(options);
205
+ }
206
+ restoreRedactionSession(plaintextJson) {
207
+ const restore = this.#prepared.restoreRedactionSession;
208
+ if (!restore) throw new Error("Native anonymize binding does not support redaction sessions");
209
+ return new PreparedNativeRedactionSession(restore.call(this.#prepared, plaintextJson));
210
+ }
211
+ restore_redaction_session(plaintextJson) {
212
+ return this.restoreRedactionSession(plaintextJson);
213
+ }
214
+ restoreEncryptedRedactionSession({ archive, key, expectedSessionId, observedAtEpochSeconds }) {
215
+ const restore = this.#prepared.restoreEncryptedRedactionSession;
216
+ if (!restore) throw new Error("Native anonymize binding does not support encrypted session archives");
217
+ return new PreparedNativeRedactionSession(restore.call(this.#prepared, {
218
+ archive,
219
+ key,
220
+ expectedSessionId,
221
+ ...observedAtEpochSeconds === void 0 ? {} : { observedAtEpochSeconds }
222
+ }));
223
+ }
224
+ restore_encrypted_redaction_session(options) {
225
+ return this.restoreEncryptedRedactionSession(options);
226
+ }
30
227
  redactStaticEntities(fullText, operators) {
31
228
  return toNativeStaticRedactionResult(this.#prepared.redactStaticEntities(fullText, toBindingOperatorConfig(operators)));
32
229
  }
@@ -38,6 +235,32 @@ var PreparedNativeAnonymizer = class {
38
235
  if (this.#prepared.redactStaticEntitiesJson) return this.#prepared.redactStaticEntitiesJson(fullText, bindingOperators);
39
236
  return JSON.stringify(toBindingStaticRedactionResult(toNativeStaticRedactionResult(this.#prepared.redactStaticEntities(fullText, bindingOperators))));
40
237
  }
238
+ redactStaticEntitiesWithCallerDetections(fullText, options) {
239
+ if (!this.#prepared.redactStaticEntitiesWithCallerDetectionsJson) throw new Error("Native anonymize binding does not support caller detections");
240
+ const requestJson = callerDetectionRequestJson(options.detections);
241
+ const operators = toBindingOperatorConfig(options.operators);
242
+ const result = JSON.parse(this.#prepared.redactStaticEntitiesWithCallerDetectionsJson(fullText, {
243
+ requestJson,
244
+ ...operators ? { operators } : {}
245
+ }));
246
+ return fromCanonicalStaticRedactionResult(result);
247
+ }
248
+ redact_text_with_caller_detections(fullText, options) {
249
+ return this.redactStaticEntitiesWithCallerDetections(fullText, options);
250
+ }
251
+ redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(fullText, options) {
252
+ const redact = this.#prepared.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson;
253
+ if (!redact) return null;
254
+ const requestJson = callerDetectionRequestJson(options.detections);
255
+ const operators = toBindingOperatorConfig(options.operators);
256
+ return redact.call(this.#prepared, fullText, {
257
+ requestJson,
258
+ ...operators ? { operators } : {}
259
+ });
260
+ }
261
+ redact_static_entities_with_caller_detections_diagnostics_json(fullText, options) {
262
+ return this.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(fullText, options);
263
+ }
41
264
  redactTextJson(fullText, operators) {
42
265
  return this.redact_text_json(fullText, operators);
43
266
  }
@@ -93,6 +316,30 @@ var PreparedNativePipeline = class {
93
316
  warm_lazy_regex_diagnostics_json() {
94
317
  return this.warmLazyRegexDiagnosticsJson();
95
318
  }
319
+ createRedactionSession(sessionId) {
320
+ return this.#anonymizer.createRedactionSession(sessionId);
321
+ }
322
+ create_redaction_session(sessionId) {
323
+ return this.createRedactionSession(sessionId);
324
+ }
325
+ createRedactionSessionWithLifecycle(options) {
326
+ return this.#anonymizer.createRedactionSessionWithLifecycle(options);
327
+ }
328
+ create_redaction_session_with_lifecycle(options) {
329
+ return this.createRedactionSessionWithLifecycle(options);
330
+ }
331
+ restoreRedactionSession(plaintextJson) {
332
+ return this.#anonymizer.restoreRedactionSession(plaintextJson);
333
+ }
334
+ restore_redaction_session(plaintextJson) {
335
+ return this.restoreRedactionSession(plaintextJson);
336
+ }
337
+ restoreEncryptedRedactionSession(options) {
338
+ return this.#anonymizer.restoreEncryptedRedactionSession(options);
339
+ }
340
+ restore_encrypted_redaction_session(options) {
341
+ return this.restoreEncryptedRedactionSession(options);
342
+ }
96
343
  redactText(fullText, operators) {
97
344
  return this.#anonymizer.redactStaticEntities(fullText, operators);
98
345
  }
@@ -102,6 +349,18 @@ var PreparedNativePipeline = class {
102
349
  redact_text_json(fullText, operators) {
103
350
  return this.#anonymizer.redact_text_json(fullText, operators);
104
351
  }
352
+ redactTextWithCallerDetections(fullText, options) {
353
+ return this.#anonymizer.redactStaticEntitiesWithCallerDetections(fullText, options);
354
+ }
355
+ redact_text_with_caller_detections(fullText, options) {
356
+ return this.redactTextWithCallerDetections(fullText, options);
357
+ }
358
+ redactTextWithCallerDetectionsDiagnosticsJson(fullText, options) {
359
+ return this.#anonymizer.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(fullText, options);
360
+ }
361
+ redact_text_with_caller_detections_diagnostics_json(fullText, options) {
362
+ return this.redactTextWithCallerDetectionsDiagnosticsJson(fullText, options);
363
+ }
105
364
  redactTextJson(fullText, operators) {
106
365
  return this.redact_text_json(fullText, operators);
107
366
  }
@@ -180,6 +439,20 @@ const toNativeStaticRedactionResult = (result) => ({
180
439
  resolvedEntities: result.resolvedEntities.map(toNativePipelineEntity),
181
440
  redaction: toNativeRedactionResult(result.redaction)
182
441
  });
442
+ const fromCanonicalStaticRedactionResult = (result) => ({
443
+ resolvedEntities: result.resolved_entities.map(({ source_detail, provider_id, detection_id, ...entity }) => ({
444
+ ...entity,
445
+ ...source_detail ? { sourceDetail: source_detail } : {},
446
+ ...provider_id ? { providerId: provider_id } : {},
447
+ ...detection_id ? { detectionId: detection_id } : {}
448
+ })),
449
+ redaction: {
450
+ redactedText: result.redaction.redacted_text,
451
+ redactionMap: toRedactionMap(result.redaction.redaction_map),
452
+ operatorMap: toOperatorMap(result.redaction.operator_map),
453
+ entityCount: result.redaction.entity_count
454
+ }
455
+ });
183
456
  const toBindingStaticRedactionResult = (result) => ({
184
457
  resolved_entities: result.resolvedEntities.map(toBindingPipelineEntity),
185
458
  redaction: {
@@ -202,11 +475,15 @@ const toNativePipelineEntity = (entity) => ({
202
475
  text: entity.text,
203
476
  score: entity.score,
204
477
  source: entity.source,
205
- ...entity.sourceDetail ? { sourceDetail: entity.sourceDetail } : {}
478
+ ...entity.sourceDetail ? { sourceDetail: entity.sourceDetail } : {},
479
+ ...entity.providerId ? { providerId: entity.providerId } : {},
480
+ ...entity.detectionId ? { detectionId: entity.detectionId } : {}
206
481
  });
207
- const toBindingPipelineEntity = ({ sourceDetail, ...entity }) => ({
482
+ const toBindingPipelineEntity = ({ sourceDetail, providerId, detectionId, ...entity }) => ({
208
483
  ...entity,
209
- source_detail: sourceDetail ?? null
484
+ source_detail: sourceDetail ?? null,
485
+ provider_id: providerId ?? null,
486
+ detection_id: detectionId ?? null
210
487
  });
211
488
  const toNativeRedactionResult = (result) => ({
212
489
  redactedText: result.redactedText,
@@ -225,6 +502,6 @@ const toOperatorMap = (entries) => {
225
502
  return map;
226
503
  };
227
504
  //#endregion
228
- export { PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedSearch, assertNativeBindingVersion, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromPackage, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, getNativeBindingVersion, load_prepared_package, native_package_version, normalize_for_search, prepareNativeSearchPackage, prepare_search_package, redact_text, redact_text_json, redact_text_stream_json, summary_diagnostics_json };
505
+ export { CALLER_DETECTION_CONTRACT_VERSION, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, assertNativeBindingVersion, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromPackage, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, getNativeBindingVersion, load_prepared_package, native_package_version, normalize_for_search, prepareNativeSearchPackage, prepare_search_package, redact_text, redact_text_json, redact_text_stream_json, summary_diagnostics_json };
229
506
 
230
507
  //# sourceMappingURL=native.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["#prepared","#anonymizer"],"sources":["../src/native.ts"],"sourcesContent":["import type { NativePreparedSearchConfig } from \"./native-search-config\";\nimport type { OperatorType } from \"./types\";\n\nexport type { NativePreparedSearchConfig } from \"./native-search-config\";\n\ntype NativeBindingOperatorConfig = {\n operators?: Record<string, OperatorType>;\n redactString?: string;\n};\n\nexport type NativeDiagnosticsBatchCallback = (diagnosticsJson: string) => void;\nexport type NativeResultEventCallback = (eventJson: string) => void;\n\ntype NativeBindingRedactionEntry = {\n placeholder: string;\n original: string;\n};\n\ntype NativeBindingOperatorEntry = {\n placeholder: string;\n operator: OperatorType;\n};\n\ntype NativeBindingPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string | null;\n};\n\ntype NativeBindingRedactionResult = {\n redactedText: string;\n redactionMap: NativeBindingRedactionEntry[];\n operatorMap: NativeBindingOperatorEntry[];\n entityCount: number;\n};\n\ntype NativeBindingStaticRedactionResult = {\n resolvedEntities: NativeBindingPipelineEntity[];\n redaction: NativeBindingRedactionResult;\n};\n\ntype CanonicalPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n source_detail?: string | null;\n};\n\ntype CanonicalStaticRedactionResult = {\n resolved_entities: CanonicalPipelineEntity[];\n redaction: {\n redacted_text: string;\n redaction_map: NativeBindingRedactionEntry[];\n operator_map: NativeBindingOperatorEntry[];\n entity_count: number;\n };\n};\n\nexport type NativePreparedSearchBinding = {\n prepareDiagnosticsJson?: () => string;\n warmLazyRegex?: () => void;\n warm_lazy_regex?: () => void;\n warmLazyRegexDiagnosticsJson?: () => string;\n warm_lazy_regex_diagnostics_json?: () => string;\n redactStaticEntities: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => NativeBindingStaticRedactionResult;\n redactStaticEntitiesJson?: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesResultStreamJson?: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onEvent: NativeResultEventCallback,\n ) => string;\n redactStaticEntitiesDiagnosticsJson?: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesDiagnosticsStreamJson?: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onBatch: NativeDiagnosticsBatchCallback,\n ) => string;\n redactStaticEntitiesSummaryDiagnosticsJson?: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n};\n\nexport type NativeAnonymizeBinding = {\n normalizeForSearch: (text: string) => string;\n nativePackageVersion: () => string;\n NativePreparedSearch: {\n fromConfigJsonBytes: (\n configJson: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytes: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytesWithoutCache?: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytes?: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytesWithoutCache?: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n };\n prepareStaticSearchPackageBytes: (configJson: Uint8Array) => Uint8Array;\n prepareStaticSearchCompressedPackageBytes: (\n configJson: Uint8Array,\n ) => Uint8Array;\n // Rust config assembler (replaces the retired TypeScript config-assembly\n // layer). Takes the pipeline config plus out-of-band dictionaries and\n // gazetteer JSON and returns either the assembled config JSON or ready\n // package bytes. Optional so older bindings without the assembler still\n // satisfy the type; native-node loads them from the same `.node`.\n assembleStaticSearchConfigJson?: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchPackageBytes?: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchCompressedPackageBytes?: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n};\n\nexport type NativeOperatorConfig = {\n operators?: Record<string, OperatorType>;\n redactString?: string;\n};\n\nexport type NativePipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string;\n};\n\nexport type NativeRedactionResult = {\n redactedText: string;\n redactionMap: Map<string, string>;\n operatorMap: Map<string, OperatorType>;\n entityCount: number;\n};\n\nexport type NativeStaticRedactionResult = {\n resolvedEntities: NativePipelineEntity[];\n redaction: NativeRedactionResult;\n};\n\nexport type NativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n compressed?: boolean;\n};\n\nexport type NativeSearchPackageInput =\n | NativePreparedSearchConfig\n | string\n | Uint8Array;\n\nexport type SharedNativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n compressed?: boolean;\n};\n\nexport type SharedNativePreparedPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type SharedNativeRedactTextJsonOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n fullText: string;\n operators?: NativeOperatorConfig;\n};\n\nexport type SharedNativeRedactTextOptions = SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsJsonOptions =\n SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onBatch: NativeDiagnosticsBatchCallback;\n };\n\nexport type SharedNativeRedactTextStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onEvent: NativeResultEventCallback;\n };\n\nexport type NativeNormalizeOptions = {\n binding: NativeAnonymizeBinding;\n text: string;\n};\n\nexport type NativeAnonymizerFromConfigOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n};\n\nexport type NativeAnonymizerFromPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type NativePipelineFromPackageOptions =\n NativeAnonymizerFromPackageOptions;\n\nexport type NativeBindingVersionOptions = {\n binding: NativeAnonymizeBinding;\n expectedVersion: string;\n};\n\nexport class PreparedNativeAnonymizer {\n readonly #prepared: NativePreparedSearchBinding;\n\n constructor(prepared: NativePreparedSearchBinding) {\n this.#prepared = prepared;\n }\n\n prepareDiagnosticsJson(): string | null {\n return this.#prepared.prepareDiagnosticsJson?.() ?? null;\n }\n\n prepare_diagnostics_json(): string | null {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n if (this.#prepared.warmLazyRegex) {\n this.#prepared.warmLazyRegex();\n return;\n }\n this.#prepared.warm_lazy_regex?.();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string | null {\n if (this.#prepared.warmLazyRegexDiagnosticsJson) {\n return this.#prepared.warmLazyRegexDiagnosticsJson();\n }\n return this.#prepared.warm_lazy_regex_diagnostics_json?.() ?? null;\n }\n\n warm_lazy_regex_diagnostics_json(): string | null {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return toNativeStaticRedactionResult(\n this.#prepared.redactStaticEntities(\n fullText,\n toBindingOperatorConfig(operators),\n ),\n );\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n const bindingOperators = toBindingOperatorConfig(operators);\n if (this.#prepared.redactStaticEntitiesJson) {\n return this.#prepared.redactStaticEntitiesJson(\n fullText,\n bindingOperators,\n );\n }\n return JSON.stringify(\n toBindingStaticRedactionResult(\n toNativeStaticRedactionResult(\n this.#prepared.redactStaticEntities(fullText, bindingOperators),\n ),\n ),\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesResultStreamJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesResultStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onEvent,\n );\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactStaticEntitiesDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesDiagnosticsJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactStaticEntitiesDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesDiagnosticsStreamJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesDiagnosticsStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onBatch,\n );\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactStaticEntitiesSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesSummaryDiagnosticsJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactStaticEntitiesSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport class PreparedNativePipeline {\n readonly #anonymizer: PreparedNativeAnonymizer;\n\n constructor(anonymizer: PreparedNativeAnonymizer) {\n this.#anonymizer = anonymizer;\n }\n\n prepareDiagnosticsJson(): string | null {\n return this.#anonymizer.prepareDiagnosticsJson();\n }\n\n prepare_diagnostics_json(): string | null {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n this.#anonymizer.warmLazyRegex();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string | null {\n return this.#anonymizer.warmLazyRegexDiagnosticsJson();\n }\n\n warm_lazy_regex_diagnostics_json(): string | null {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#anonymizer.redact_text_json(fullText, operators);\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactTextDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.redactStaticEntitiesDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactTextSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport const encodeNativeSearchConfig = (\n config: NativePreparedSearchConfig,\n): Uint8Array => new TextEncoder().encode(JSON.stringify(config));\n\nexport const encodeNativeSearchConfigInput = (\n config: NativeSearchPackageInput,\n): Uint8Array => {\n if (typeof config === \"string\") {\n return new TextEncoder().encode(config);\n }\n if (config instanceof Uint8Array) {\n return config;\n }\n return encodeNativeSearchConfig(config);\n};\n\nexport const getNativeBindingVersion = (\n binding: NativeAnonymizeBinding,\n): string => binding.nativePackageVersion();\n\nexport const native_package_version = getNativeBindingVersion;\n\nexport const normalize_for_search = ({\n binding,\n text,\n}: NativeNormalizeOptions): string => binding.normalizeForSearch(text);\n\nexport const assertNativeBindingVersion = ({\n binding,\n expectedVersion,\n}: NativeBindingVersionOptions): void => {\n const actualVersion = getNativeBindingVersion(binding);\n if (actualVersion !== expectedVersion) {\n throw new Error(\n `Native anonymize binding version ${actualVersion} does not match ${expectedVersion}`,\n );\n }\n};\n\nexport const prepareNativeSearchPackage = ({\n binding,\n config,\n compressed = false,\n}: NativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfig(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const prepare_search_package = ({\n binding,\n config,\n compressed = false,\n}: SharedNativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfigInput(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const createNativeAnonymizerFromConfig = ({\n binding,\n config,\n}: NativeAnonymizerFromConfigOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfig(config),\n ),\n );\n\nexport const createNativeAnonymizerFromPackage = ({\n binding,\n packageBytes,\n}: NativeAnonymizerFromPackageOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromPreparedPackageBytes(packageBytes),\n );\n\nexport const load_prepared_package = ({\n binding,\n packageBytes,\n}: SharedNativePreparedPackageOptions): PreparedNativeAnonymizer =>\n createNativeAnonymizerFromPackage({ binding, packageBytes });\n\nexport const redact_text_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_json(fullText, operators);\n\nexport const redact_text = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextOptions): NativeStaticRedactionResult =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text(fullText, operators);\n\nexport const redact_text_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onEvent,\n}: SharedNativeRedactTextStreamJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_stream_json(fullText, onEvent, operators);\n\nexport const diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_json(fullText, operators);\n\nexport const diagnostics_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onBatch,\n}: SharedNativeDiagnosticsStreamJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_stream_json(fullText, onBatch, operators);\n\nexport const summary_diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).summary_diagnostics_json(fullText, operators);\n\nexport const createNativePipelineFromPackage = ({\n binding,\n packageBytes,\n}: NativePipelineFromPackageOptions): PreparedNativePipeline =>\n new PreparedNativePipeline(\n createNativeAnonymizerFromPackage({ binding, packageBytes }),\n );\n\nexport const PreparedSearch = PreparedNativeAnonymizer;\nexport type PreparedSearch = PreparedNativeAnonymizer;\nexport const PreparedAnonymizer = PreparedNativeAnonymizer;\nexport type PreparedAnonymizer = PreparedNativeAnonymizer;\n\nconst toBindingOperatorConfig = (\n config: NativeOperatorConfig | undefined,\n): NativeBindingOperatorConfig | undefined => {\n if (!config) {\n return undefined;\n }\n const bindingConfig: NativeBindingOperatorConfig = {};\n if (config.operators !== undefined) {\n bindingConfig.operators = config.operators;\n }\n if (config.redactString !== undefined) {\n bindingConfig.redactString = config.redactString;\n }\n return bindingConfig;\n};\n\nconst toNativeStaticRedactionResult = (\n result: NativeBindingStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolvedEntities.map(toNativePipelineEntity),\n redaction: toNativeRedactionResult(result.redaction),\n});\n\nconst toBindingStaticRedactionResult = (\n result: NativeStaticRedactionResult,\n): CanonicalStaticRedactionResult => ({\n resolved_entities: result.resolvedEntities.map(toBindingPipelineEntity),\n redaction: {\n redacted_text: result.redaction.redactedText,\n redaction_map: [...result.redaction.redactionMap.entries()].map(\n ([placeholder, original]) => ({ placeholder, original }),\n ),\n operator_map: [...result.redaction.operatorMap.entries()].map(\n ([placeholder, operator]) => ({ placeholder, operator }),\n ),\n entity_count: result.redaction.entityCount,\n },\n});\n\nconst toNativePipelineEntity = (\n entity: NativeBindingPipelineEntity,\n): NativePipelineEntity => ({\n start: entity.start,\n end: entity.end,\n label: entity.label,\n text: entity.text,\n score: entity.score,\n source: entity.source,\n ...(entity.sourceDetail ? { sourceDetail: entity.sourceDetail } : {}),\n});\n\nconst toBindingPipelineEntity = ({\n sourceDetail,\n ...entity\n}: NativePipelineEntity): CanonicalPipelineEntity => ({\n ...entity,\n source_detail: sourceDetail ?? null,\n});\n\nconst toNativeRedactionResult = (\n result: NativeBindingRedactionResult,\n): NativeRedactionResult => ({\n redactedText: result.redactedText,\n redactionMap: toRedactionMap(result.redactionMap),\n operatorMap: toOperatorMap(result.operatorMap),\n entityCount: result.entityCount,\n});\n\nconst toRedactionMap = (\n entries: readonly NativeBindingRedactionEntry[],\n): Map<string, string> => {\n const map = new Map<string, string>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.original);\n }\n return map;\n};\n\nconst toOperatorMap = (\n entries: readonly NativeBindingOperatorEntry[],\n): Map<string, OperatorType> => {\n const map = new Map<string, OperatorType>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.operator);\n }\n return map;\n};\n"],"mappings":";AA+OA,IAAa,2BAAb,MAAsC;CACpC;CAEA,YAAY,UAAuC;EACjD,KAAKA,YAAY;CACnB;CAEA,yBAAwC;EACtC,OAAO,KAAKA,UAAU,yBAAyB,KAAK;CACtD;CAEA,2BAA0C;EACxC,OAAO,KAAK,uBAAuB;CACrC;CAEA,gBAAsB;EACpB,IAAI,KAAKA,UAAU,eAAe;GAChC,KAAKA,UAAU,cAAc;GAC7B;EACF;EACA,KAAKA,UAAU,kBAAkB;CACnC;CAEA,kBAAwB;EACtB,KAAK,cAAc;CACrB;CAEA,+BAA8C;EAC5C,IAAI,KAAKA,UAAU,8BACjB,OAAO,KAAKA,UAAU,6BAA6B;EAErD,OAAO,KAAKA,UAAU,mCAAmC,KAAK;CAChE;CAEA,mCAAkD;EAChD,OAAO,KAAK,6BAA6B;CAC3C;CAEA,qBACE,UACA,WAC6B;EAC7B,OAAO,8BACL,KAAKA,UAAU,qBACb,UACA,wBAAwB,SAAS,CACnC,CACF;CACF;CAEA,YACE,UACA,WAC6B;EAC7B,OAAO,KAAK,qBAAqB,UAAU,SAAS;CACtD;CAEA,iBAAiB,UAAkB,WAA0C;EAC3E,MAAM,mBAAmB,wBAAwB,SAAS;EAC1D,IAAI,KAAKA,UAAU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AAU,YAAY,QAAQ,CAAC,CAAC,CAAC,KACvD,CAAC,aAAa,eAAe;GAAE;GAAa;EAAS,EACxD;EACA,cAAc,OAAO,UAAU;CACjC;AACF;AAEA,MAAM,0BACJ,YAC0B;CAC1B,OAAO,OAAO;CACd,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,MAAM,OAAO;CACb,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,GAAI,OAAO,eAAe,EAAE,cAAc,OAAO,aAAa,IAAI,CAAC;AACrE;AAEA,MAAM,2BAA2B,EAC/B,cACA,GAAG,cACiD;CACpD,GAAG;CACH,eAAe,gBAAgB;AACjC;AAEA,MAAM,2BACJ,YAC2B;CAC3B,cAAc,OAAO;CACrB,cAAc,eAAe,OAAO,YAAY;CAChD,aAAa,cAAc,OAAO,WAAW;CAC7C,aAAa,OAAO;AACtB;AAEA,MAAM,kBACJ,YACwB;CACxB,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT;AAEA,MAAM,iBACJ,YAC8B;CAC9B,MAAM,sBAAM,IAAI,IAA0B;CAC1C,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT"}
1
+ {"version":3,"file":"native.mjs","names":["#session","#plan","#prepared","#anonymizer"],"sources":["../src/native.ts"],"sourcesContent":["import type { NativePreparedSearchConfig } from \"./native-search-config\";\nimport type { OperatorSelection, OperatorType } from \"./types\";\n\nexport type { NativePreparedSearchConfig } from \"./native-search-config\";\n\ntype NativeBindingOperatorConfig = {\n operators?: Record<string, OperatorSelection>;\n redactString?: string;\n};\n\ntype NativeBindingCallerRedactionOptions = {\n requestJson: string;\n operators?: NativeBindingOperatorConfig;\n};\n\ntype NativeBindingSessionCallerRedactionInput = {\n fullText: string;\n requestJson: string;\n};\n\ntype NativeBindingSessionCallerRedactionPlanOptions = {\n inputs: NativeBindingSessionCallerRedactionInput[];\n operators?: NativeBindingOperatorConfig;\n observedAtEpochSeconds?: number;\n};\n\ntype NativeBindingOpenSessionArchiveOptions = {\n archive: Uint8Array;\n key: Uint8Array;\n expectedSessionId: string;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativeDiagnosticsBatchCallback = (diagnosticsJson: string) => void;\nexport type NativeResultEventCallback = (eventJson: string) => void;\n\ntype NativeBindingRedactionEntry = {\n placeholder: string;\n original: string;\n};\n\ntype NativeBindingOperatorEntry = {\n placeholder: string;\n operator: OperatorType;\n};\n\ntype NativeBindingPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string | null;\n providerId?: string | null;\n detectionId?: string | null;\n};\n\ntype NativeBindingRedactionResult = {\n redactedText: string;\n redactionMap: NativeBindingRedactionEntry[];\n operatorMap: NativeBindingOperatorEntry[];\n entityCount: number;\n};\n\ntype NativeBindingStaticRedactionResult = {\n resolvedEntities: NativeBindingPipelineEntity[];\n redaction: NativeBindingRedactionResult;\n};\n\ntype CanonicalPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n source_detail?: string | null;\n provider_id?: string | null;\n detection_id?: string | null;\n};\n\ntype CanonicalStaticRedactionResult = {\n resolved_entities: CanonicalPipelineEntity[];\n redaction: {\n redacted_text: string;\n redaction_map: NativeBindingRedactionEntry[];\n operator_map: NativeBindingOperatorEntry[];\n entity_count: number;\n };\n};\n\ntype CanonicalSessionMetadata = {\n session_id: string;\n created_at_epoch_seconds: number | null;\n expires_at_epoch_seconds: number | null;\n mapping_count: number;\n status: NativeSessionStatus;\n};\n\ntype CanonicalSessionDeletionSummary = {\n session_id: string;\n deleted_mapping_count: number;\n};\n\ntype CanonicalSessionRedactionPlanResult = {\n replacements: Array<{\n start: number;\n end: number;\n replacement: string;\n }>;\n entity_count: number;\n caller_entity_count: number;\n};\n\nexport type NativeSessionStatus =\n | \"active\"\n | \"not_yet_active\"\n | \"expired\"\n | \"deleted\";\n\nexport type NativeSessionLifecycle = {\n createdAtEpochSeconds: number;\n expiresAtEpochSeconds?: number;\n};\n\nexport type NativeSessionMetadata = {\n sessionId: string;\n createdAtEpochSeconds: number | null;\n expiresAtEpochSeconds: number | null;\n mappingCount: number;\n status: NativeSessionStatus;\n};\n\nexport type NativeSessionDeletionSummary = {\n sessionId: string;\n deletedMappingCount: number;\n};\n\nexport type NativeSessionRedactionAtOptions = {\n fullText: string;\n observedAtEpochSeconds: number;\n operators?: NativeOperatorConfig;\n};\n\nexport type NativeCreateSessionWithLifecycleOptions = NativeSessionLifecycle & {\n sessionId: string;\n};\n\nexport type NativeOpenSessionArchiveOptions = {\n archive: Uint8Array;\n key: Uint8Array;\n expectedSessionId: string;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativePreparedRedactionSessionBinding = {\n sessionId: () => string;\n mappingCount: () => number;\n restoreText?: (fullText: string) => string;\n restoreTextAt?: (fullText: string, observedAtEpochSeconds: number) => string;\n toPlaintextJson: () => string;\n toPlaintextJsonAt?: (observedAtEpochSeconds: number) => string;\n toEncryptedArchive?: (key: Uint8Array) => Uint8Array;\n toEncryptedArchiveAt?: (\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ) => Uint8Array;\n inspectJson?: (observedAtEpochSeconds?: number) => string;\n deleteJson?: () => string;\n redactStaticEntitiesJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesJsonAt?: (\n fullText: string,\n observedAtEpochSeconds: number,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n planStaticEntitiesWithCallerDetections?: (\n options: NativeBindingSessionCallerRedactionPlanOptions,\n ) => NativePreparedSessionRedactionPlanBinding;\n};\n\nexport type NativePreparedSessionRedactionPlanBinding = {\n resultJson: () => string;\n commit: () => void;\n};\n\nexport type NativePreparedSearchBinding = {\n prepareDiagnosticsJson?: () => string;\n warmLazyRegex?: () => void;\n warm_lazy_regex?: () => void;\n warmLazyRegexDiagnosticsJson?: () => string;\n warm_lazy_regex_diagnostics_json?: () => string;\n createRedactionSession?: (\n sessionId: string,\n ) => NativePreparedRedactionSessionBinding;\n createRedactionSessionWithLifecycle?: (\n sessionId: string,\n createdAtEpochSeconds: number,\n expiresAtEpochSeconds?: number,\n ) => NativePreparedRedactionSessionBinding;\n restoreRedactionSession?: (\n plaintextJson: string,\n ) => NativePreparedRedactionSessionBinding;\n restoreEncryptedRedactionSession?: (\n options: NativeBindingOpenSessionArchiveOptions,\n ) => NativePreparedRedactionSessionBinding;\n redactStaticEntities: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => NativeBindingStaticRedactionResult;\n redactStaticEntitiesJson?: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesWithCallerDetectionsJson?: (\n fullText: string,\n options: NativeBindingCallerRedactionOptions,\n ) => string;\n redactStaticEntitiesWithCallerDetectionsDiagnosticsJson?: (\n fullText: string,\n options: NativeBindingCallerRedactionOptions,\n ) => string;\n redactStaticEntitiesResultStreamJson?: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onEvent: NativeResultEventCallback,\n ) => string;\n redactStaticEntitiesDiagnosticsJson?: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesDiagnosticsStreamJson?: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onBatch: NativeDiagnosticsBatchCallback,\n ) => string;\n redactStaticEntitiesSummaryDiagnosticsJson?: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n};\n\nexport type NativeAnonymizeBinding = {\n normalizeForSearch: (text: string) => string;\n nativePackageVersion: () => string;\n NativePreparedSearch: {\n fromConfigJsonBytes: (\n configJson: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytes: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytesWithoutCache?: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytes?: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytesWithoutCache?: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n };\n prepareStaticSearchPackageBytes: (configJson: Uint8Array) => Uint8Array;\n prepareStaticSearchCompressedPackageBytes: (\n configJson: Uint8Array,\n ) => Uint8Array;\n // Rust config assembler (replaces the retired TypeScript config-assembly\n // layer). Takes the pipeline config plus out-of-band dictionaries and\n // gazetteer JSON and returns either the assembled config JSON or ready\n // package bytes. Optional so older bindings without the assembler still\n // satisfy the type; native-node loads them from the same `.node`.\n assembleStaticSearchConfigJson?: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchPackageBytes?: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchCompressedPackageBytes?: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n};\n\nexport type NativeOperatorConfig = {\n operators?: Record<string, OperatorSelection>;\n redactString?: string;\n};\n\nexport const CALLER_DETECTION_CONTRACT_VERSION = 2;\n\nexport type NativeCallerDetection = {\n start: number;\n end: number;\n label: string;\n score: number;\n providerId: string;\n detectionId: string;\n};\n\nexport type NativeCallerRedactionOptions = {\n detections: readonly NativeCallerDetection[];\n operators?: NativeOperatorConfig;\n};\n\nexport type NativeSessionCallerRedactionInput = {\n fullText: string;\n detections: readonly NativeCallerDetection[];\n};\n\nexport type NativeSessionCallerRedactionPlanOptions = {\n inputs: readonly NativeSessionCallerRedactionInput[];\n operators?: NativeOperatorConfig;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativeTextReplacement = {\n start: number;\n end: number;\n replacement: string;\n};\n\nexport type NativeSessionBlockRedactionPlan = {\n replacements: readonly NativeTextReplacement[];\n entityCount: number;\n callerEntityCount: number;\n};\n\nconst callerDetectionRequestJson = (\n detections: readonly NativeCallerDetection[],\n): string =>\n JSON.stringify({\n version: CALLER_DETECTION_CONTRACT_VERSION,\n detections: detections.map((detection) => ({\n start: detection.start,\n end: detection.end,\n label: detection.label,\n score: detection.score,\n provider_id: detection.providerId,\n detection_id: detection.detectionId,\n })),\n });\n\nexport type NativePipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string;\n providerId?: string;\n detectionId?: string;\n};\n\nexport type NativeRedactionResult = {\n redactedText: string;\n redactionMap: Map<string, string>;\n operatorMap: Map<string, OperatorType>;\n entityCount: number;\n};\n\nexport type NativeStaticRedactionResult = {\n resolvedEntities: NativePipelineEntity[];\n redaction: NativeRedactionResult;\n};\n\nexport type NativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n compressed?: boolean;\n};\n\nexport type NativeSearchPackageInput =\n | NativePreparedSearchConfig\n | string\n | Uint8Array;\n\nexport type SharedNativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n compressed?: boolean;\n};\n\nexport type SharedNativePreparedPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type SharedNativeRedactTextJsonOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n fullText: string;\n operators?: NativeOperatorConfig;\n};\n\nexport type SharedNativeRedactTextOptions = SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsJsonOptions =\n SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onBatch: NativeDiagnosticsBatchCallback;\n };\n\nexport type SharedNativeRedactTextStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onEvent: NativeResultEventCallback;\n };\n\nexport type NativeNormalizeOptions = {\n binding: NativeAnonymizeBinding;\n text: string;\n};\n\nexport type NativeAnonymizerFromConfigOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n};\n\nexport type NativeAnonymizerFromPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type NativePipelineFromPackageOptions =\n NativeAnonymizerFromPackageOptions;\n\nexport type NativeBindingVersionOptions = {\n binding: NativeAnonymizeBinding;\n expectedVersion: string;\n};\n\nexport class PreparedNativeRedactionSession {\n readonly #session: NativePreparedRedactionSessionBinding;\n\n constructor(session: NativePreparedRedactionSessionBinding) {\n this.#session = session;\n }\n\n sessionId(): string {\n return this.#session.sessionId();\n }\n\n session_id(): string {\n return this.sessionId();\n }\n\n mappingCount(): number {\n return this.#session.mappingCount();\n }\n\n mapping_count(): number {\n return this.mappingCount();\n }\n\n restoreText(fullText: string, observedAtEpochSeconds?: number): string {\n if (observedAtEpochSeconds === undefined) {\n const restore = this.#session.restoreText;\n if (!restore) {\n throw new Error(\n \"Native anonymize binding does not support session restoration\",\n );\n }\n return restore.call(this.#session, fullText);\n }\n const restore = this.#session.restoreTextAt;\n if (!restore) {\n throw new Error(\n \"Native anonymize binding does not support session restoration lifecycle controls\",\n );\n }\n return restore.call(this.#session, fullText, observedAtEpochSeconds);\n }\n\n restore_text(fullText: string, observedAtEpochSeconds?: number): string {\n return this.restoreText(fullText, observedAtEpochSeconds);\n }\n\n toPlaintextJson(): string {\n return this.#session.toPlaintextJson();\n }\n\n to_plaintext_json(): string {\n return this.toPlaintextJson();\n }\n\n toPlaintextJsonAt(observedAtEpochSeconds: number): string {\n const serialize = this.#session.toPlaintextJsonAt;\n if (!serialize) {\n throw new Error(\n \"Native anonymize binding does not support session lifecycle controls\",\n );\n }\n return serialize.call(this.#session, observedAtEpochSeconds);\n }\n\n to_plaintext_json_at(observedAtEpochSeconds: number): string {\n return this.toPlaintextJsonAt(observedAtEpochSeconds);\n }\n\n toEncryptedArchive(key: Uint8Array): Uint8Array {\n const serialize = this.#session.toEncryptedArchive;\n if (!serialize) {\n throw new Error(\n \"Native anonymize binding does not support encrypted session archives\",\n );\n }\n return serialize.call(this.#session, key);\n }\n\n to_encrypted_archive(key: Uint8Array): Uint8Array {\n return this.toEncryptedArchive(key);\n }\n\n toEncryptedArchiveAt(\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ): Uint8Array {\n const serialize = this.#session.toEncryptedArchiveAt;\n if (!serialize) {\n throw new Error(\n \"Native anonymize binding does not support encrypted session archives\",\n );\n }\n return serialize.call(this.#session, key, observedAtEpochSeconds);\n }\n\n to_encrypted_archive_at(\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ): Uint8Array {\n return this.toEncryptedArchiveAt(key, observedAtEpochSeconds);\n }\n\n inspect(observedAtEpochSeconds?: number): NativeSessionMetadata {\n const inspect = this.#session.inspectJson;\n if (!inspect) {\n throw new Error(\n \"Native anonymize binding does not support session lifecycle controls\",\n );\n }\n const metadata: CanonicalSessionMetadata = JSON.parse(\n inspect.call(this.#session, observedAtEpochSeconds),\n );\n return {\n sessionId: metadata.session_id,\n createdAtEpochSeconds: metadata.created_at_epoch_seconds,\n expiresAtEpochSeconds: metadata.expires_at_epoch_seconds,\n mappingCount: metadata.mapping_count,\n status: metadata.status,\n };\n }\n\n delete(): NativeSessionDeletionSummary {\n const deleteSession = this.#session.deleteJson;\n if (!deleteSession) {\n throw new Error(\n \"Native anonymize binding does not support session lifecycle controls\",\n );\n }\n const summary: CanonicalSessionDeletionSummary = JSON.parse(\n deleteSession.call(this.#session),\n );\n return {\n sessionId: summary.session_id,\n deletedMappingCount: summary.deleted_mapping_count,\n };\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.redact_text_json(fullText, operators),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#session.redactStaticEntitiesJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n redactStaticEntitiesAt(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.redactTextJsonAt(options),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redactTextAt(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesAt(options);\n }\n\n redact_text_at(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactTextAt(options);\n }\n\n redact_static_entities_at(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesAt(options);\n }\n\n redactTextJsonAt({\n fullText,\n observedAtEpochSeconds,\n operators,\n }: NativeSessionRedactionAtOptions): string {\n const redact = this.#session.redactStaticEntitiesJsonAt;\n if (!redact) {\n throw new Error(\n \"Native anonymize binding does not support session lifecycle controls\",\n );\n }\n return redact.call(\n this.#session,\n fullText,\n observedAtEpochSeconds,\n toBindingOperatorConfig(operators),\n );\n }\n\n redact_text_json_at(options: NativeSessionRedactionAtOptions): string {\n return this.redactTextJsonAt(options);\n }\n\n planTextBatchWithCallerDetections({\n inputs,\n operators,\n observedAtEpochSeconds,\n }: NativeSessionCallerRedactionPlanOptions): PreparedNativeSessionRedactionPlan {\n const plan = this.#session.planStaticEntitiesWithCallerDetections;\n if (!plan) {\n throw new Error(\n \"Native anonymize binding does not support transactional caller-detection session plans\",\n );\n }\n const bindingOperators = toBindingOperatorConfig(operators);\n const bindingPlan = plan.call(this.#session, {\n inputs: inputs.map(({ detections, fullText }) => ({\n fullText,\n requestJson: callerDetectionRequestJson(detections),\n })),\n ...(bindingOperators === undefined\n ? {}\n : { operators: bindingOperators }),\n ...(observedAtEpochSeconds === undefined\n ? {}\n : { observedAtEpochSeconds }),\n });\n return new PreparedNativeSessionRedactionPlan(bindingPlan);\n }\n}\n\nexport class PreparedNativeSessionRedactionPlan {\n readonly blocks: readonly NativeSessionBlockRedactionPlan[];\n readonly #plan: NativePreparedSessionRedactionPlanBinding;\n\n constructor(plan: NativePreparedSessionRedactionPlanBinding) {\n this.#plan = plan;\n const blocks: CanonicalSessionRedactionPlanResult[] = JSON.parse(\n plan.resultJson(),\n );\n this.blocks = blocks.map(\n ({ caller_entity_count, entity_count, replacements }) => ({\n replacements,\n entityCount: entity_count,\n callerEntityCount: caller_entity_count,\n }),\n );\n }\n\n commit(): void {\n this.#plan.commit();\n }\n}\n\nexport class PreparedNativeAnonymizer {\n readonly #prepared: NativePreparedSearchBinding;\n\n constructor(prepared: NativePreparedSearchBinding) {\n this.#prepared = prepared;\n }\n\n prepareDiagnosticsJson(): string | null {\n return this.#prepared.prepareDiagnosticsJson?.() ?? null;\n }\n\n prepare_diagnostics_json(): string | null {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n if (this.#prepared.warmLazyRegex) {\n this.#prepared.warmLazyRegex();\n return;\n }\n this.#prepared.warm_lazy_regex?.();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string | null {\n if (this.#prepared.warmLazyRegexDiagnosticsJson) {\n return this.#prepared.warmLazyRegexDiagnosticsJson();\n }\n return this.#prepared.warm_lazy_regex_diagnostics_json?.() ?? null;\n }\n\n warm_lazy_regex_diagnostics_json(): string | null {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n createRedactionSession(sessionId: string): PreparedNativeRedactionSession {\n const create = this.#prepared.createRedactionSession;\n if (!create) {\n throw new Error(\n \"Native anonymize binding does not support redaction sessions\",\n );\n }\n return new PreparedNativeRedactionSession(\n create.call(this.#prepared, sessionId),\n );\n }\n\n create_redaction_session(sessionId: string): PreparedNativeRedactionSession {\n return this.createRedactionSession(sessionId);\n }\n\n createRedactionSessionWithLifecycle({\n sessionId,\n createdAtEpochSeconds,\n expiresAtEpochSeconds,\n }: NativeCreateSessionWithLifecycleOptions): PreparedNativeRedactionSession {\n const create = this.#prepared.createRedactionSessionWithLifecycle;\n if (!create) {\n throw new Error(\n \"Native anonymize binding does not support session lifecycle controls\",\n );\n }\n return new PreparedNativeRedactionSession(\n create.call(\n this.#prepared,\n sessionId,\n createdAtEpochSeconds,\n expiresAtEpochSeconds,\n ),\n );\n }\n\n create_redaction_session_with_lifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.createRedactionSessionWithLifecycle(options);\n }\n\n restoreRedactionSession(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n const restore = this.#prepared.restoreRedactionSession;\n if (!restore) {\n throw new Error(\n \"Native anonymize binding does not support redaction sessions\",\n );\n }\n return new PreparedNativeRedactionSession(\n restore.call(this.#prepared, plaintextJson),\n );\n }\n\n restore_redaction_session(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.restoreRedactionSession(plaintextJson);\n }\n\n restoreEncryptedRedactionSession({\n archive,\n key,\n expectedSessionId,\n observedAtEpochSeconds,\n }: NativeOpenSessionArchiveOptions): PreparedNativeRedactionSession {\n const restore = this.#prepared.restoreEncryptedRedactionSession;\n if (!restore) {\n throw new Error(\n \"Native anonymize binding does not support encrypted session archives\",\n );\n }\n return new PreparedNativeRedactionSession(\n restore.call(this.#prepared, {\n archive,\n key,\n expectedSessionId,\n ...(observedAtEpochSeconds === undefined\n ? {}\n : { observedAtEpochSeconds }),\n }),\n );\n }\n\n restore_encrypted_redaction_session(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.restoreEncryptedRedactionSession(options);\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return toNativeStaticRedactionResult(\n this.#prepared.redactStaticEntities(\n fullText,\n toBindingOperatorConfig(operators),\n ),\n );\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n const bindingOperators = toBindingOperatorConfig(operators);\n if (this.#prepared.redactStaticEntitiesJson) {\n return this.#prepared.redactStaticEntitiesJson(\n fullText,\n bindingOperators,\n );\n }\n return JSON.stringify(\n toBindingStaticRedactionResult(\n toNativeStaticRedactionResult(\n this.#prepared.redactStaticEntities(fullText, bindingOperators),\n ),\n ),\n );\n }\n\n redactStaticEntitiesWithCallerDetections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n if (!this.#prepared.redactStaticEntitiesWithCallerDetectionsJson) {\n throw new Error(\n \"Native anonymize binding does not support caller detections\",\n );\n }\n const requestJson = callerDetectionRequestJson(options.detections);\n const operators = toBindingOperatorConfig(options.operators);\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.#prepared.redactStaticEntitiesWithCallerDetectionsJson(fullText, {\n requestJson,\n ...(operators ? { operators } : {}),\n }),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redact_text_with_caller_detections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesWithCallerDetections(fullText, options);\n }\n\n redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string | null {\n const redact =\n this.#prepared.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson;\n if (!redact) {\n return null;\n }\n const requestJson = callerDetectionRequestJson(options.detections);\n const operators = toBindingOperatorConfig(options.operators);\n return redact.call(this.#prepared, fullText, {\n requestJson,\n ...(operators ? { operators } : {}),\n });\n }\n\n redact_static_entities_with_caller_detections_diagnostics_json(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string | null {\n return this.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesResultStreamJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesResultStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onEvent,\n );\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactStaticEntitiesDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesDiagnosticsJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactStaticEntitiesDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesDiagnosticsStreamJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesDiagnosticsStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onBatch,\n );\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactStaticEntitiesSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n if (!this.#prepared.redactStaticEntitiesSummaryDiagnosticsJson) {\n return null;\n }\n return this.#prepared.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactStaticEntitiesSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport class PreparedNativePipeline {\n readonly #anonymizer: PreparedNativeAnonymizer;\n\n constructor(anonymizer: PreparedNativeAnonymizer) {\n this.#anonymizer = anonymizer;\n }\n\n prepareDiagnosticsJson(): string | null {\n return this.#anonymizer.prepareDiagnosticsJson();\n }\n\n prepare_diagnostics_json(): string | null {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n this.#anonymizer.warmLazyRegex();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string | null {\n return this.#anonymizer.warmLazyRegexDiagnosticsJson();\n }\n\n warm_lazy_regex_diagnostics_json(): string | null {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n createRedactionSession(sessionId: string): PreparedNativeRedactionSession {\n return this.#anonymizer.createRedactionSession(sessionId);\n }\n\n create_redaction_session(sessionId: string): PreparedNativeRedactionSession {\n return this.createRedactionSession(sessionId);\n }\n\n createRedactionSessionWithLifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.createRedactionSessionWithLifecycle(options);\n }\n\n create_redaction_session_with_lifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.createRedactionSessionWithLifecycle(options);\n }\n\n restoreRedactionSession(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.restoreRedactionSession(plaintextJson);\n }\n\n restore_redaction_session(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.restoreRedactionSession(plaintextJson);\n }\n\n restoreEncryptedRedactionSession(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.restoreEncryptedRedactionSession(options);\n }\n\n restore_encrypted_redaction_session(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.restoreEncryptedRedactionSession(options);\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#anonymizer.redact_text_json(fullText, operators);\n }\n\n redactTextWithCallerDetections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntitiesWithCallerDetections(\n fullText,\n options,\n );\n }\n\n redact_text_with_caller_detections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.redactTextWithCallerDetections(fullText, options);\n }\n\n redactTextWithCallerDetectionsDiagnosticsJson(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string | null {\n return this.#anonymizer.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redact_text_with_caller_detections_diagnostics_json(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string | null {\n return this.redactTextWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactTextDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.redactStaticEntitiesDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactTextSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.#anonymizer.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string | null {\n return this.redactTextSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport const encodeNativeSearchConfig = (\n config: NativePreparedSearchConfig,\n): Uint8Array => new TextEncoder().encode(JSON.stringify(config));\n\nexport const encodeNativeSearchConfigInput = (\n config: NativeSearchPackageInput,\n): Uint8Array => {\n if (typeof config === \"string\") {\n return new TextEncoder().encode(config);\n }\n if (config instanceof Uint8Array) {\n return config;\n }\n return encodeNativeSearchConfig(config);\n};\n\nexport const getNativeBindingVersion = (\n binding: NativeAnonymizeBinding,\n): string => binding.nativePackageVersion();\n\nexport const native_package_version = getNativeBindingVersion;\n\nexport const normalize_for_search = ({\n binding,\n text,\n}: NativeNormalizeOptions): string => binding.normalizeForSearch(text);\n\nexport const assertNativeBindingVersion = ({\n binding,\n expectedVersion,\n}: NativeBindingVersionOptions): void => {\n const actualVersion = getNativeBindingVersion(binding);\n if (actualVersion !== expectedVersion) {\n throw new Error(\n `Native anonymize binding version ${actualVersion} does not match ${expectedVersion}`,\n );\n }\n};\n\nexport const prepareNativeSearchPackage = ({\n binding,\n config,\n compressed = false,\n}: NativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfig(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const prepare_search_package = ({\n binding,\n config,\n compressed = false,\n}: SharedNativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfigInput(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const createNativeAnonymizerFromConfig = ({\n binding,\n config,\n}: NativeAnonymizerFromConfigOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfig(config),\n ),\n );\n\nexport const createNativeAnonymizerFromPackage = ({\n binding,\n packageBytes,\n}: NativeAnonymizerFromPackageOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromPreparedPackageBytes(packageBytes),\n );\n\nexport const load_prepared_package = ({\n binding,\n packageBytes,\n}: SharedNativePreparedPackageOptions): PreparedNativeAnonymizer =>\n createNativeAnonymizerFromPackage({ binding, packageBytes });\n\nexport const redact_text_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_json(fullText, operators);\n\nexport const redact_text = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextOptions): NativeStaticRedactionResult =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text(fullText, operators);\n\nexport const redact_text_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onEvent,\n}: SharedNativeRedactTextStreamJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_stream_json(fullText, onEvent, operators);\n\nexport const diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_json(fullText, operators);\n\nexport const diagnostics_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onBatch,\n}: SharedNativeDiagnosticsStreamJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_stream_json(fullText, onBatch, operators);\n\nexport const summary_diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string | null =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).summary_diagnostics_json(fullText, operators);\n\nexport const createNativePipelineFromPackage = ({\n binding,\n packageBytes,\n}: NativePipelineFromPackageOptions): PreparedNativePipeline =>\n new PreparedNativePipeline(\n createNativeAnonymizerFromPackage({ binding, packageBytes }),\n );\n\nexport const PreparedSearch = PreparedNativeAnonymizer;\nexport type PreparedSearch = PreparedNativeAnonymizer;\nexport const PreparedAnonymizer = PreparedNativeAnonymizer;\nexport type PreparedAnonymizer = PreparedNativeAnonymizer;\n\nconst toBindingOperatorConfig = (\n config: NativeOperatorConfig | undefined,\n): NativeBindingOperatorConfig | undefined => {\n if (!config) {\n return undefined;\n }\n const bindingConfig: NativeBindingOperatorConfig = {};\n if (config.operators !== undefined) {\n bindingConfig.operators = config.operators;\n }\n if (config.redactString !== undefined) {\n bindingConfig.redactString = config.redactString;\n }\n return bindingConfig;\n};\n\nconst toNativeStaticRedactionResult = (\n result: NativeBindingStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolvedEntities.map(toNativePipelineEntity),\n redaction: toNativeRedactionResult(result.redaction),\n});\n\nconst fromCanonicalStaticRedactionResult = (\n result: CanonicalStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolved_entities.map(\n ({ source_detail, provider_id, detection_id, ...entity }) => ({\n ...entity,\n ...(source_detail ? { sourceDetail: source_detail } : {}),\n ...(provider_id ? { providerId: provider_id } : {}),\n ...(detection_id ? { detectionId: detection_id } : {}),\n }),\n ),\n redaction: {\n redactedText: result.redaction.redacted_text,\n redactionMap: toRedactionMap(result.redaction.redaction_map),\n operatorMap: toOperatorMap(result.redaction.operator_map),\n entityCount: result.redaction.entity_count,\n },\n});\n\nconst toBindingStaticRedactionResult = (\n result: NativeStaticRedactionResult,\n): CanonicalStaticRedactionResult => ({\n resolved_entities: result.resolvedEntities.map(toBindingPipelineEntity),\n redaction: {\n redacted_text: result.redaction.redactedText,\n redaction_map: [...result.redaction.redactionMap.entries()].map(\n ([placeholder, original]) => ({ placeholder, original }),\n ),\n operator_map: [...result.redaction.operatorMap.entries()].map(\n ([placeholder, operator]) => ({ placeholder, operator }),\n ),\n entity_count: result.redaction.entityCount,\n },\n});\n\nconst toNativePipelineEntity = (\n entity: NativeBindingPipelineEntity,\n): NativePipelineEntity => ({\n start: entity.start,\n end: entity.end,\n label: entity.label,\n text: entity.text,\n score: entity.score,\n source: entity.source,\n ...(entity.sourceDetail ? { sourceDetail: entity.sourceDetail } : {}),\n ...(entity.providerId ? { providerId: entity.providerId } : {}),\n ...(entity.detectionId ? { detectionId: entity.detectionId } : {}),\n});\n\nconst toBindingPipelineEntity = ({\n sourceDetail,\n providerId,\n detectionId,\n ...entity\n}: NativePipelineEntity): CanonicalPipelineEntity => ({\n ...entity,\n source_detail: sourceDetail ?? null,\n provider_id: providerId ?? null,\n detection_id: detectionId ?? null,\n});\n\nconst toNativeRedactionResult = (\n result: NativeBindingRedactionResult,\n): NativeRedactionResult => ({\n redactedText: result.redactedText,\n redactionMap: toRedactionMap(result.redactionMap),\n operatorMap: toOperatorMap(result.operatorMap),\n entityCount: result.entityCount,\n});\n\nconst toRedactionMap = (\n entries: readonly NativeBindingRedactionEntry[],\n): Map<string, string> => {\n const map = new Map<string, string>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.original);\n }\n return map;\n};\n\nconst toOperatorMap = (\n entries: readonly NativeBindingOperatorEntry[],\n): Map<string, OperatorType> => {\n const map = new Map<string, OperatorType>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.operator);\n }\n return map;\n};\n"],"mappings":";AAwSA,MAAa,oCAAoC;AAuCjD,MAAM,8BACJ,eAEA,KAAK,UAAU;CACb,SAAA;CACA,YAAY,WAAW,KAAK,eAAe;EACzC,OAAO,UAAU;EACjB,KAAK,UAAU;EACf,OAAO,UAAU;EACjB,OAAO,UAAU;EACjB,aAAa,UAAU;EACvB,cAAc,UAAU;CAC1B,EAAE;AACJ,CAAC;AA6FH,IAAa,iCAAb,MAA4C;CAC1C;CAEA,YAAY,SAAgD;EAC1D,KAAKA,WAAW;CAClB;CAEA,YAAoB;EAClB,OAAO,KAAKA,SAAS,UAAU;CACjC;CAEA,aAAqB;EACnB,OAAO,KAAK,UAAU;CACxB;CAEA,eAAuB;EACrB,OAAO,KAAKA,SAAS,aAAa;CACpC;CAEA,gBAAwB;EACtB,OAAO,KAAK,aAAa;CAC3B;CAEA,YAAY,UAAkB,wBAAyC;EACrE,IAAI,2BAA2B,KAAA,GAAW;GACxC,MAAM,UAAU,KAAKA,SAAS;GAC9B,IAAI,CAAC,SACH,MAAM,IAAI,MACR,+DACF;GAEF,OAAO,QAAQ,KAAK,KAAKA,UAAU,QAAQ;EAC7C;E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Ac,eAAe;AAC/B;AAEA,MAAM,2BACJ,YAC2B;CAC3B,cAAc,OAAO;CACrB,cAAc,eAAe,OAAO,YAAY;CAChD,aAAa,cAAc,OAAO,WAAW;CAC7C,aAAa,OAAO;AACtB;AAEA,MAAM,kBACJ,YACwB;CACxB,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT;AAEA,MAAM,iBACJ,YAC8B;CAC9B,MAAM,sBAAM,IAAI,IAA0B;CAC1C,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { A as createNativePipelineFromPackage, B as prepare_search_package, C as SharedNativeRedactTextJsonOptions, D as assertNativeBindingVersion, E as SharedNativeSearchPackageOptions, F as getNativeBindingVersion, H as redact_text_json, I as load_prepared_package, L as native_package_version, M as diagnostics_stream_json, N as encodeNativeSearchConfig, O as createNativeAnonymizerFromConfig, P as encodeNativeSearchConfigInput, R as normalize_for_search, S as SharedNativePreparedPackageOptions, T as SharedNativeRedactTextStreamJsonOptions, U as redact_text_stream_json, V as redact_text, W as summary_diagnostics_json, _ as PreparedNativeAnonymizer, a as NativeDiagnosticsBatchCallback, b as SharedNativeDiagnosticsJsonOptions, c as NativePipelineEntity, d as NativeRedactionResult, f as NativeResultEventCallback, g as PreparedAnonymizer, h as NativeStaticRedactionResult, i as NativeBindingVersionOptions, j as diagnostics_json, k as createNativeAnonymizerFromPackage, l as NativePipelineFromPackageOptions, lt as NativePreparedSearchConfig, m as NativeSearchPackageOptions, n as NativeAnonymizerFromConfigOptions, o as NativeNormalizeOptions, p as NativeSearchPackageInput, r as NativeAnonymizerFromPackageOptions, s as NativeOperatorConfig, t as NativeAnonymizeBinding, u as NativePreparedSearchBinding, v as PreparedNativePipeline, w as SharedNativeRedactTextOptions, x as SharedNativeDiagnosticsStreamJsonOptions, y as PreparedSearch, z as prepareNativeSearchPackage } from "./native.mjs";
2
- export { NativeAnonymizeBinding, NativeAnonymizerFromConfigOptions, NativeAnonymizerFromPackageOptions, NativeBindingVersionOptions, NativeDiagnosticsBatchCallback, NativeNormalizeOptions, NativeOperatorConfig, NativePipelineEntity, NativePipelineFromPackageOptions, NativePreparedSearchBinding, type NativePreparedSearchConfig, NativeRedactionResult, NativeResultEventCallback, NativeSearchPackageInput, NativeSearchPackageOptions, NativeStaticRedactionResult, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedSearch, SharedNativeDiagnosticsJsonOptions, SharedNativeDiagnosticsStreamJsonOptions, SharedNativePreparedPackageOptions, SharedNativeRedactTextJsonOptions, SharedNativeRedactTextOptions, SharedNativeRedactTextStreamJsonOptions, SharedNativeSearchPackageOptions, assertNativeBindingVersion, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromPackage, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, getNativeBindingVersion, load_prepared_package, native_package_version, normalize_for_search, prepareNativeSearchPackage, prepare_search_package, redact_text, redact_text_json, redact_text_stream_json, summary_diagnostics_json };
1
+ import { $ as getNativeBindingVersion, A as NativeStaticRedactionResult, B as SharedNativePreparedPackageOptions, C as NativeSessionCallerRedactionInput, D as NativeSessionMetadata, Dt as NativePreparedSearchConfig, E as NativeSessionLifecycle, F as PreparedNativeRedactionSession, G as assertNativeBindingVersion, H as SharedNativeRedactTextOptions, I as PreparedNativeSessionRedactionPlan, J as createNativePipelineFromPackage, K as createNativeAnonymizerFromConfig, L as PreparedSearch, M as PreparedAnonymizer, N as PreparedNativeAnonymizer, O as NativeSessionRedactionAtOptions, P as PreparedNativePipeline, Q as encodeNativeSearchConfigInput, R as SharedNativeDiagnosticsJsonOptions, S as NativeSessionBlockRedactionPlan, T as NativeSessionDeletionSummary, U as SharedNativeRedactTextStreamJsonOptions, V as SharedNativeRedactTextJsonOptions, W as SharedNativeSearchPackageOptions, X as diagnostics_stream_json, Y as diagnostics_json, Z as encodeNativeSearchConfig, _ as NativePreparedSessionRedactionPlanBinding, a as NativeBindingVersionOptions, at as redact_text, b as NativeSearchPackageInput, c as NativeCreateSessionWithLifecycleOptions, ct as summary_diagnostics_json, d as NativeOpenSessionArchiveOptions, et as load_prepared_package, f as NativeOperatorConfig, g as NativePreparedSearchBinding, h as NativePreparedRedactionSessionBinding, i as NativeAnonymizerFromPackageOptions, it as prepare_search_package, j as NativeTextReplacement, k as NativeSessionStatus, l as NativeDiagnosticsBatchCallback, m as NativePipelineFromPackageOptions, n as NativeAnonymizeBinding, nt as normalize_for_search, o as NativeCallerDetection, ot as redact_text_json, p as NativePipelineEntity, q as createNativeAnonymizerFromPackage, r as NativeAnonymizerFromConfigOptions, rt as prepareNativeSearchPackage, s as NativeCallerRedactionOptions, st as redact_text_stream_json, t as CALLER_DETECTION_CONTRACT_VERSION, tt as native_package_version, u as NativeNormalizeOptions, v as NativeRedactionResult, w as NativeSessionCallerRedactionPlanOptions, x as NativeSearchPackageOptions, y as NativeResultEventCallback, z as SharedNativeDiagnosticsStreamJsonOptions } from "./native.mjs";
2
+ export { CALLER_DETECTION_CONTRACT_VERSION, NativeAnonymizeBinding, NativeAnonymizerFromConfigOptions, NativeAnonymizerFromPackageOptions, NativeBindingVersionOptions, NativeCallerDetection, NativeCallerRedactionOptions, NativeCreateSessionWithLifecycleOptions, NativeDiagnosticsBatchCallback, NativeNormalizeOptions, NativeOpenSessionArchiveOptions, NativeOperatorConfig, NativePipelineEntity, NativePipelineFromPackageOptions, NativePreparedRedactionSessionBinding, NativePreparedSearchBinding, type NativePreparedSearchConfig, NativePreparedSessionRedactionPlanBinding, NativeRedactionResult, NativeResultEventCallback, NativeSearchPackageInput, NativeSearchPackageOptions, NativeSessionBlockRedactionPlan, NativeSessionCallerRedactionInput, NativeSessionCallerRedactionPlanOptions, NativeSessionDeletionSummary, NativeSessionLifecycle, NativeSessionMetadata, NativeSessionRedactionAtOptions, NativeSessionStatus, NativeStaticRedactionResult, NativeTextReplacement, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, SharedNativeDiagnosticsJsonOptions, SharedNativeDiagnosticsStreamJsonOptions, SharedNativePreparedPackageOptions, SharedNativeRedactTextJsonOptions, SharedNativeRedactTextOptions, SharedNativeRedactTextStreamJsonOptions, SharedNativeSearchPackageOptions, assertNativeBindingVersion, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromPackage, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, getNativeBindingVersion, load_prepared_package, native_package_version, normalize_for_search, prepareNativeSearchPackage, prepare_search_package, redact_text, redact_text_json, redact_text_stream_json, summary_diagnostics_json };
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@stll/anonymize",
3
- "version": "2.0.1",
4
- "description": "Multi-layer PII detection and anonymization pipeline with regex, NER, deny lists, and coreference resolution",
3
+ "version": "2.0.2",
4
+ "description": "Deterministic PII detection and anonymization with regex, deny lists, and coreference resolution",
5
5
  "keywords": [
6
6
  "anonymization",
7
7
  "pii",
8
8
  "redaction",
9
- "ner",
10
9
  "pseudonymization",
11
10
  "gdpr",
12
11
  "privacy"
@@ -23,6 +22,11 @@
23
22
  "import": "./dist/constants.mjs",
24
23
  "default": "./dist/constants.mjs"
25
24
  },
25
+ "./capabilities": {
26
+ "types": "./dist/capabilities.d.mts",
27
+ "import": "./dist/capabilities.mjs",
28
+ "default": "./dist/capabilities.mjs"
29
+ },
26
30
  "./native": {
27
31
  "types": "./dist/native.d.mts",
28
32
  "import": "./dist/native.mjs",
@@ -54,7 +58,7 @@
54
58
  "url": "git+https://github.com/stella/anonymize.git"
55
59
  },
56
60
  "homepage": "https://github.com/stella/anonymize",
57
- "license": "MIT",
61
+ "license": "Apache-2.0",
58
62
  "scripts": {
59
63
  "build": "bun run build:native-wasm && tsdown && bun scripts/build-native-node.mjs && bun run build:wasm-assets",
60
64
  "prepublishOnly": "bun run build",
@@ -89,11 +93,11 @@
89
93
  }
90
94
  },
91
95
  "optionalDependencies": {
92
- "@stll/anonymize-darwin-arm64": "2.0.1",
93
- "@stll/anonymize-darwin-x64": "2.0.1",
94
- "@stll/anonymize-linux-arm64-gnu": "2.0.1",
95
- "@stll/anonymize-linux-x64-gnu": "2.0.1",
96
- "@stll/anonymize-win32-x64-msvc": "2.0.1"
96
+ "@stll/anonymize-darwin-arm64": "2.0.2",
97
+ "@stll/anonymize-darwin-x64": "2.0.2",
98
+ "@stll/anonymize-linux-arm64-gnu": "2.0.2",
99
+ "@stll/anonymize-linux-x64-gnu": "2.0.2",
100
+ "@stll/anonymize-win32-x64-msvc": "2.0.2"
97
101
  },
98
102
  "devDependencies": {
99
103
  "@napi-rs/cli": "^3.7.2",
@@ -101,9 +105,9 @@
101
105
  "@stll/text-search-wasm": "^1.0.7",
102
106
  "bun-types": "^1.3.14",
103
107
  "fast-check": "^4.8.0",
104
- "puppeteer-core": "25.2.1",
105
- "tsdown": "^0.22.3",
108
+ "puppeteer-core": "25.3.0",
109
+ "tsdown": "^0.22.4",
106
110
  "typescript": "^6.0.3",
107
- "vite": "^8.1.0"
111
+ "vite": "^8.1.3"
108
112
  }
109
113
  }