@stll/anonymize-wasm 1.1.1 → 1.2.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/dist/wasm.d.mts CHANGED
@@ -35,6 +35,7 @@ type Entity = {
35
35
  text: string;
36
36
  score: number;
37
37
  source: DetectionSource;
38
+ sourceDetail?: "custom-deny-list" | "custom-regex";
38
39
  };
39
40
  /**
40
41
  * Entity after human review. Extends the base Entity
@@ -185,6 +186,27 @@ type DictionaryMeta = {
185
186
  category: DenyListCategory;
186
187
  country: string | null;
187
188
  };
189
+ /**
190
+ * Caller-supplied exact terms for deny-list matching.
191
+ * These entries are merged with the published deny-list
192
+ * dictionaries when `enableDenyList` is enabled.
193
+ */
194
+ type CustomDenyListEntry = {
195
+ value: string;
196
+ label: string;
197
+ variants?: readonly string[];
198
+ };
199
+ /**
200
+ * Caller-supplied regex detector. The pattern is passed
201
+ * to the underlying text-search regex engine, so use its
202
+ * supported regex syntax. Inline flags such as `(?i)` are
203
+ * accepted when supported by that engine.
204
+ */
205
+ type CustomRegexPattern = {
206
+ pattern: string;
207
+ label: string;
208
+ score?: number;
209
+ };
188
210
  /**
189
211
  * Pre-loaded dictionary data for dependency injection.
190
212
  * Consumers that want name/city/deny-list detection
@@ -248,6 +270,16 @@ type PipelineConfig = {
248
270
  denyListCountries?: string[];
249
271
  denyListRegions?: string[];
250
272
  denyListExcludeCategories?: string[];
273
+ /**
274
+ * Caller-owned exact terms to match through the
275
+ * deny-list layer. Requires `enableDenyList: true`.
276
+ */
277
+ customDenyList?: readonly CustomDenyListEntry[];
278
+ /**
279
+ * Caller-owned regex detectors. Requires
280
+ * `enableRegex: true`.
281
+ */
282
+ customRegexes?: readonly CustomRegexPattern[];
251
283
  enableGazetteer: boolean;
252
284
  enableNer: boolean;
253
285
  enableConfidenceBoost: boolean;
@@ -283,7 +315,8 @@ declare const DEFAULT_ENTITY_LABELS: readonly ["person", "organization", "phone
283
315
  //#region src/detectors/regex.d.ts
284
316
  type RegexMeta = {
285
317
  label: string;
286
- score: number; /** Post-match stdnum validator for confirmation. */
318
+ score: number;
319
+ sourceDetail?: Entity["sourceDetail"]; /** Post-match stdnum validator for confirmation. */
287
320
  validator?: Validator;
288
321
  };
289
322
  /** Flat pattern array for text-search. */
@@ -320,15 +353,16 @@ declare const CURRENCY_PATTERN_META: Readonly<RegexMeta>;
320
353
  declare const processRegexMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, meta_: readonly RegexMeta[]) => Entity[];
321
354
  //#endregion
322
355
  //#region src/detectors/deny-list.d.ts
323
- type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "dictionaries">;
356
+ type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "customDenyList" | "dictionaries">;
324
357
  /**
325
358
  * Source tag for each pattern in the automaton.
326
359
  * "deny-list" = standard deny list entry
360
+ * "custom-deny-list" = caller-owned exact term
327
361
  * "first-name" = name corpus first name
328
362
  * "surname" = name corpus surname
329
363
  * "title" = academic/professional title
330
364
  */
331
- type PatternSource = "deny-list" | "first-name" | "surname" | "title";
365
+ type PatternSource = "deny-list" | "custom-deny-list" | "first-name" | "surname" | "title";
332
366
  /**
333
367
  * Pre-built deny list data. Constructed once by
334
368
  * `buildDenyList`, reused across `processDenyListMatches`
@@ -342,7 +376,8 @@ type DenyListData = {
342
376
  * appears in multiple dictionaries (e.g., "Denver"
343
377
  * is both a person name and a city name).
344
378
  */
345
- labels: string[][]; /** Maps pattern index → original pattern text. */
379
+ labels: string[][]; /** Maps pattern index → labels contributed by custom entries. */
380
+ customLabels: string[][]; /** Maps pattern index → original pattern text. */
346
381
  originals: string[]; /** Maps pattern index → source types (plural). */
347
382
  sources: PatternSource[][];
348
383
  };
@@ -396,10 +431,12 @@ type GazetteerData = {
396
431
  isFuzzy: boolean[];
397
432
  };
398
433
  type UnifiedSearchInstance = {
399
- /** Regex + triggers + legal-forms. */tsRegex: TextSearch; /** Deny-list + street-types + gazetteer. */
434
+ /** Regex + triggers + legal-forms. */tsRegex: TextSearch; /** Caller-owned custom regexes, isolated for overlap preservation. */
435
+ tsCustomRegex: TextSearch; /** Deny-list + street-types + gazetteer. */
400
436
  tsLiterals: TextSearch;
401
437
  slices: {
402
438
  regex: PatternSlice;
439
+ customRegex: PatternSlice;
403
440
  legalForms: PatternSlice;
404
441
  triggers: PatternSlice;
405
442
  denyList: PatternSlice;
@@ -407,6 +444,7 @@ type UnifiedSearchInstance = {
407
444
  gazetteer: PatternSlice;
408
445
  };
409
446
  regexMeta: readonly RegexMeta[];
447
+ customRegexMeta: readonly RegexMeta[];
410
448
  triggerRules: readonly TriggerRule[];
411
449
  denyListData: DenyListData | null;
412
450
  gazetteerData: GazetteerData | null;
@@ -739,6 +777,7 @@ declare const detectNameCorpus: (fullText: string, ctx?: PipelineContext) => Ent
739
777
  //#region src/unified-search.d.ts
740
778
  type UnifiedResult = {
741
779
  /** All matches from both instances combined. */regexMatches: Match[];
780
+ customRegexMatches: Match[];
742
781
  literalMatches: Match[];
743
782
  };
744
783
  declare const runUnifiedSearch: (instance: UnifiedSearchInstance, fullText: string) => UnifiedResult;
@@ -996,5 +1035,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
996
1035
  */
997
1036
  declare const normalizeForSearch: (text: string) => string;
998
1037
  //#endregion
999
- export { type AnonymisationOperator, CURRENCY_PATTERN_META, type CountryCode, DATE_PATTERN_META, DEFAULT_ENTITY_LABELS, DEFAULT_OPERATOR_CONFIG, DETECTION_SOURCES, DETECTOR_PRIORITY, type DefinitionPattern, type DenyListCategory, type DenyListData, type DetectionSource, type Dictionaries, type DictionaryMeta, type DocumentZone, type Entity, type EntityResult, type GazetteerData, type GazetteerEntry, type HotwordRule, type NameCorpusData, type NerInferenceFn, OPERATOR_REGISTRY, OPERATOR_TYPES, type OperatorConfig, type OperatorType, type PipelineConfig, type PipelineContext, type PipelineOptions, REGEX_META, REGEX_PATTERNS, REGIONS, type RawInferenceResult, type RedactionResult, type RegexMeta, type RegionId, type ReviewDecision, type ReviewedEntity, type TriggerExtension, type TriggerGroupConfig, type TriggerRule, type TriggerStrategy, type TriggerValidation, type UnifiedResult, type UnifiedSearchInstance, ZONE_SCORE_ADJUSTMENTS, type ZoneSpan, applyHotwordRules, applyZoneAdjustments, boostNearMissEntities, buildDenyList, buildGazetteerPatterns, buildLegalFormPatterns, buildPlaceholderMap, buildStreetTypePatterns, buildTriggerPatterns, buildUnifiedSearch, chunkText, classifyZones, computeChunkOffsets, corefKey, createPipelineContext, deanonymise, decodeSpans, decodeTokenSpans, detectNameCorpus, ensureDenyListData, exportRedactionKey, extractDefinedTerms, filterFalsePositives, findCoreferenceSpans, getCurrencyPatterns, getDatePatterns, initHotwordRules, initNameCorpus, initZoneClassifier, levenshtein, mergeAndDedup, mergeChunkEntities, normalizeForSearch, prepareBatch, processAddressSeeds, processDenyListMatches, processGazetteerMatches, processLegalFormMatches, processRegexMatches, processTriggerMatches, propagateOrgNames, redactText, resolveCountries, resolveOperator, runPipeline, runUnifiedSearch, sanitizeEntities, tokenizeText };
1038
+ export { type AnonymisationOperator, CURRENCY_PATTERN_META, type CountryCode, type CustomDenyListEntry, type CustomRegexPattern, DATE_PATTERN_META, DEFAULT_ENTITY_LABELS, DEFAULT_OPERATOR_CONFIG, DETECTION_SOURCES, DETECTOR_PRIORITY, type DefinitionPattern, type DenyListCategory, type DenyListData, type DetectionSource, type Dictionaries, type DictionaryMeta, type DocumentZone, type Entity, type EntityResult, type GazetteerData, type GazetteerEntry, type HotwordRule, type NameCorpusData, type NerInferenceFn, OPERATOR_REGISTRY, OPERATOR_TYPES, type OperatorConfig, type OperatorType, type PipelineConfig, type PipelineContext, type PipelineOptions, REGEX_META, REGEX_PATTERNS, REGIONS, type RawInferenceResult, type RedactionResult, type RegexMeta, type RegionId, type ReviewDecision, type ReviewedEntity, type TriggerExtension, type TriggerGroupConfig, type TriggerRule, type TriggerStrategy, type TriggerValidation, type UnifiedResult, type UnifiedSearchInstance, ZONE_SCORE_ADJUSTMENTS, type ZoneSpan, applyHotwordRules, applyZoneAdjustments, boostNearMissEntities, buildDenyList, buildGazetteerPatterns, buildLegalFormPatterns, buildPlaceholderMap, buildStreetTypePatterns, buildTriggerPatterns, buildUnifiedSearch, chunkText, classifyZones, computeChunkOffsets, corefKey, createPipelineContext, deanonymise, decodeSpans, decodeTokenSpans, detectNameCorpus, ensureDenyListData, exportRedactionKey, extractDefinedTerms, filterFalsePositives, findCoreferenceSpans, getCurrencyPatterns, getDatePatterns, initHotwordRules, initNameCorpus, initZoneClassifier, levenshtein, mergeAndDedup, mergeChunkEntities, normalizeForSearch, prepareBatch, processAddressSeeds, processDenyListMatches, processGazetteerMatches, processLegalFormMatches, processRegexMatches, processTriggerMatches, propagateOrgNames, redactText, resolveCountries, resolveOperator, runPipeline, runUnifiedSearch, sanitizeEntities, tokenizeText };
1000
1039
  //# sourceMappingURL=wasm.d.mts.map