@stll/anonymize-wasm 1.1.0 → 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
@@ -177,25 +178,45 @@ type DenyListCategory = "Names" | "Places" | "Addresses" | "Courts" | "Financial
177
178
  /**
178
179
  * Metadata for a single dictionary entry in the
179
180
  * deny-list system. Mirrors the shape from
180
- * `@stll/anonymize-data` so consumers can pass
181
- * pre-loaded data without the runtime dependency.
181
+ * the anonymize-data package so consumers can pass
182
+ * pre-loaded data without a runtime dependency.
182
183
  */
183
184
  type DictionaryMeta = {
184
185
  label: string;
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
191
- * import from `@stll/anonymize-data` themselves and
192
- * pass the data here; the anonymize package itself
193
- * has zero cross-package imports.
213
+ * load dictionaries themselves (e.g. from the
214
+ * anonymize-data package) and pass them here; the
215
+ * anonymize package has zero cross-package imports.
194
216
  *
195
217
  * All fields are optional. When a field is absent,
196
218
  * the corresponding detection path is skipped (same
197
- * behavior as when `@stll/anonymize-data` was not
198
- * installed).
219
+ * behavior as when no dictionaries are available).
199
220
  */
200
221
  type Dictionaries = {
201
222
  /**
@@ -249,6 +270,16 @@ type PipelineConfig = {
249
270
  denyListCountries?: string[];
250
271
  denyListRegions?: string[];
251
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[];
252
283
  enableGazetteer: boolean;
253
284
  enableNer: boolean;
254
285
  enableConfidenceBoost: boolean;
@@ -266,7 +297,7 @@ type PipelineConfig = {
266
297
  * Pre-loaded dictionary data for name, deny-list,
267
298
  * and city detection. When omitted, dictionary-based
268
299
  * detection paths are skipped. Consumers load from
269
- * `@stll/anonymize-data` and pass the data here.
300
+ * the anonymize-data package and pass the data here.
270
301
  */
271
302
  dictionaries?: Dictionaries;
272
303
  };
@@ -284,7 +315,8 @@ declare const DEFAULT_ENTITY_LABELS: readonly ["person", "organization", "phone
284
315
  //#region src/detectors/regex.d.ts
285
316
  type RegexMeta = {
286
317
  label: string;
287
- score: number; /** Post-match stdnum validator for confirmation. */
318
+ score: number;
319
+ sourceDetail?: Entity["sourceDetail"]; /** Post-match stdnum validator for confirmation. */
288
320
  validator?: Validator;
289
321
  };
290
322
  /** Flat pattern array for text-search. */
@@ -321,15 +353,16 @@ declare const CURRENCY_PATTERN_META: Readonly<RegexMeta>;
321
353
  declare const processRegexMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, meta_: readonly RegexMeta[]) => Entity[];
322
354
  //#endregion
323
355
  //#region src/detectors/deny-list.d.ts
324
- type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "dictionaries">;
356
+ type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "customDenyList" | "dictionaries">;
325
357
  /**
326
358
  * Source tag for each pattern in the automaton.
327
359
  * "deny-list" = standard deny list entry
360
+ * "custom-deny-list" = caller-owned exact term
328
361
  * "first-name" = name corpus first name
329
362
  * "surname" = name corpus surname
330
363
  * "title" = academic/professional title
331
364
  */
332
- type PatternSource = "deny-list" | "first-name" | "surname" | "title";
365
+ type PatternSource = "deny-list" | "custom-deny-list" | "first-name" | "surname" | "title";
333
366
  /**
334
367
  * Pre-built deny list data. Constructed once by
335
368
  * `buildDenyList`, reused across `processDenyListMatches`
@@ -343,7 +376,8 @@ type DenyListData = {
343
376
  * appears in multiple dictionaries (e.g., "Denver"
344
377
  * is both a person name and a city name).
345
378
  */
346
- 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. */
347
381
  originals: string[]; /** Maps pattern index → source types (plural). */
348
382
  sources: PatternSource[][];
349
383
  };
@@ -397,10 +431,12 @@ type GazetteerData = {
397
431
  isFuzzy: boolean[];
398
432
  };
399
433
  type UnifiedSearchInstance = {
400
- /** 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. */
401
436
  tsLiterals: TextSearch;
402
437
  slices: {
403
438
  regex: PatternSlice;
439
+ customRegex: PatternSlice;
404
440
  legalForms: PatternSlice;
405
441
  triggers: PatternSlice;
406
442
  denyList: PatternSlice;
@@ -408,6 +444,7 @@ type UnifiedSearchInstance = {
408
444
  gazetteer: PatternSlice;
409
445
  };
410
446
  regexMeta: readonly RegexMeta[];
447
+ customRegexMeta: readonly RegexMeta[];
411
448
  triggerRules: readonly TriggerRule[];
412
449
  denyListData: DenyListData | null;
413
450
  gazetteerData: GazetteerData | null;
@@ -740,6 +777,7 @@ declare const detectNameCorpus: (fullText: string, ctx?: PipelineContext) => Ent
740
777
  //#region src/unified-search.d.ts
741
778
  type UnifiedResult = {
742
779
  /** All matches from both instances combined. */regexMatches: Match[];
780
+ customRegexMatches: Match[];
743
781
  literalMatches: Match[];
744
782
  };
745
783
  declare const runUnifiedSearch: (instance: UnifiedSearchInstance, fullText: string) => UnifiedResult;
@@ -997,5 +1035,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
997
1035
  */
998
1036
  declare const normalizeForSearch: (text: string) => string;
999
1037
  //#endregion
1000
- 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 };
1001
1039
  //# sourceMappingURL=wasm.d.mts.map