@stll/anonymize-wasm 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/address-boundaries.mjs +85 -0
  2. package/dist/address-boundaries.mjs.map +1 -0
  3. package/dist/address-prepositions.mjs +182 -0
  4. package/dist/address-prepositions.mjs.map +1 -0
  5. package/dist/address-street-types.mjs +162 -0
  6. package/dist/address-street-types.mjs.map +1 -0
  7. package/dist/allow-list.mjs +183 -0
  8. package/dist/allow-list.mjs.map +1 -0
  9. package/dist/amount-words.mjs +42 -0
  10. package/dist/amount-words.mjs.map +1 -0
  11. package/dist/coreference.cs.mjs +14 -0
  12. package/dist/coreference.cs.mjs.map +1 -0
  13. package/dist/coreference.de.mjs +14 -0
  14. package/dist/coreference.de.mjs.map +1 -0
  15. package/dist/coreference.en.mjs +14 -0
  16. package/dist/coreference.en.mjs.map +1 -0
  17. package/dist/coreference.sk.mjs +10 -0
  18. package/dist/coreference.sk.mjs.map +1 -0
  19. package/dist/currencies.mjs +231 -0
  20. package/dist/currencies.mjs.map +1 -0
  21. package/dist/date-months.mjs +618 -0
  22. package/dist/date-months.mjs.map +1 -0
  23. package/dist/generic-roles.mjs +65 -0
  24. package/dist/generic-roles.mjs.map +1 -0
  25. package/dist/hotword-rules.mjs +145 -0
  26. package/dist/hotword-rules.mjs.map +1 -0
  27. package/dist/legal-forms.mjs +2112 -0
  28. package/dist/legal-forms.mjs.map +1 -0
  29. package/dist/manifest.mjs +56 -0
  30. package/dist/manifest.mjs.map +1 -0
  31. package/dist/names-exclusions.mjs +191 -0
  32. package/dist/names-exclusions.mjs.map +1 -0
  33. package/dist/names-first.mjs +418 -0
  34. package/dist/names-first.mjs.map +1 -0
  35. package/dist/names-surnames.mjs +113 -0
  36. package/dist/names-surnames.mjs.map +1 -0
  37. package/dist/names-title-tokens.mjs +40 -0
  38. package/dist/names-title-tokens.mjs.map +1 -0
  39. package/dist/person-stopwords.mjs +69 -0
  40. package/dist/person-stopwords.mjs.map +1 -0
  41. package/dist/section-headings.mjs +52 -0
  42. package/dist/section-headings.mjs.map +1 -0
  43. package/dist/signing-clauses.mjs +78 -0
  44. package/dist/signing-clauses.mjs.map +1 -0
  45. package/dist/stopwords.mjs +9915 -0
  46. package/dist/stopwords.mjs.map +1 -0
  47. package/dist/triggers.cs.mjs +465 -0
  48. package/dist/triggers.cs.mjs.map +1 -0
  49. package/dist/triggers.de.mjs +139 -0
  50. package/dist/triggers.de.mjs.map +1 -0
  51. package/dist/triggers.en.mjs +72 -0
  52. package/dist/triggers.en.mjs.map +1 -0
  53. package/dist/triggers.es.mjs +57 -0
  54. package/dist/triggers.es.mjs.map +1 -0
  55. package/dist/triggers.fr.mjs +76 -0
  56. package/dist/triggers.fr.mjs.map +1 -0
  57. package/dist/triggers.global.mjs +34 -0
  58. package/dist/triggers.global.mjs.map +1 -0
  59. package/dist/triggers.hu.mjs +41 -0
  60. package/dist/triggers.hu.mjs.map +1 -0
  61. package/dist/triggers.it.mjs +52 -0
  62. package/dist/triggers.it.mjs.map +1 -0
  63. package/dist/triggers.pl.mjs +84 -0
  64. package/dist/triggers.pl.mjs.map +1 -0
  65. package/dist/triggers.ro.mjs +59 -0
  66. package/dist/triggers.ro.mjs.map +1 -0
  67. package/dist/triggers.sk.mjs +62 -0
  68. package/dist/triggers.sk.mjs.map +1 -0
  69. package/dist/triggers.sv.mjs +58 -0
  70. package/dist/triggers.sv.mjs.map +1 -0
  71. package/dist/vite.mjs +4 -2
  72. package/dist/vite.mjs.map +1 -1
  73. package/dist/wasm.d.mts +75 -11
  74. package/dist/wasm.mjs +635 -180
  75. package/dist/wasm.mjs.map +1 -1
  76. package/dist/year-words.mjs +62 -0
  77. package/dist/year-words.mjs.map +1 -0
  78. package/package.json +1 -5
package/dist/wasm.d.mts CHANGED
@@ -174,6 +174,59 @@ type RedactionResult = {
174
174
  * Configuration for the detection pipeline.
175
175
  */
176
176
  type DenyListCategory = "Names" | "Places" | "Addresses" | "Courts" | "Financial" | "Government" | "Healthcare" | "Education" | "Political" | "Organizations" | "International";
177
+ /**
178
+ * Metadata for a single dictionary entry in the
179
+ * deny-list system. Mirrors the shape from
180
+ * `@stll/anonymize-data` so consumers can pass
181
+ * pre-loaded data without the runtime dependency.
182
+ */
183
+ type DictionaryMeta = {
184
+ label: string;
185
+ category: DenyListCategory;
186
+ country: string | null;
187
+ };
188
+ /**
189
+ * Pre-loaded dictionary data for dependency injection.
190
+ * 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.
194
+ *
195
+ * All fields are optional. When a field is absent,
196
+ * the corresponding detection path is skipped (same
197
+ * behavior as when `@stll/anonymize-data` was not
198
+ * installed).
199
+ */
200
+ type Dictionaries = {
201
+ /**
202
+ * First names per language code (e.g., "cs", "de").
203
+ * Merged with legacy config names at init time.
204
+ */
205
+ firstNames?: Readonly<Record<string, readonly string[]>>;
206
+ /**
207
+ * Surnames per language code.
208
+ * Merged with legacy config names at init time.
209
+ */
210
+ surnames?: Readonly<Record<string, readonly string[]>>;
211
+ /**
212
+ * Pre-loaded deny-list dictionaries keyed by
213
+ * dictionary ID (e.g., "courts/CZ", "banks/DE").
214
+ * Each value is the array of terms for that
215
+ * dictionary.
216
+ */
217
+ denyList?: Readonly<Record<string, readonly string[]>>;
218
+ /**
219
+ * Metadata per dictionary ID. Required when
220
+ * `denyList` is provided so the pipeline knows
221
+ * labels, categories, and country filters.
222
+ */
223
+ denyListMeta?: Readonly<Record<string, DictionaryMeta>>;
224
+ /**
225
+ * Pre-loaded city names, already merged across
226
+ * all desired countries.
227
+ */
228
+ cities?: readonly string[];
229
+ };
177
230
  type PipelineConfig = {
178
231
  threshold: number;
179
232
  enableTriggerPhrases: boolean;
@@ -209,6 +262,13 @@ type PipelineConfig = {
209
262
  */
210
263
  labels: string[];
211
264
  workspaceId: string;
265
+ /**
266
+ * Pre-loaded dictionary data for name, deny-list,
267
+ * and city detection. When omitted, dictionary-based
268
+ * detection paths are skipped. Consumers load from
269
+ * `@stll/anonymize-data` and pass the data here.
270
+ */
271
+ dictionaries?: Dictionaries;
212
272
  };
213
273
  /**
214
274
  * Canonical entity labels used across the pipeline.
@@ -261,7 +321,7 @@ declare const CURRENCY_PATTERN_META: Readonly<RegexMeta>;
261
321
  declare const processRegexMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, meta_: readonly RegexMeta[]) => Entity[];
262
322
  //#endregion
263
323
  //#region src/detectors/deny-list.d.ts
264
- type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories">;
324
+ type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "dictionaries">;
265
325
  /**
266
326
  * Source tag for each pattern in the automaton.
267
327
  * "deny-list" = standard deny list entry
@@ -289,13 +349,13 @@ type DenyListData = {
289
349
  };
290
350
  /**
291
351
  * Resolve which dictionaries to load based on country
292
- * and category filters, load them, and build the deny
293
- * list data. The returned data provides PatternEntry[]
294
- * for the unified builder and parallel arrays for
352
+ * and category filters, then build the deny list data.
353
+ * The returned data provides PatternEntry[] for the
354
+ * unified builder and parallel arrays for
295
355
  * post-processing.
296
356
  *
297
- * Requires `@stll/anonymize-data` to be installed.
298
- * Returns null if the data package is not available.
357
+ * Dictionary data is injected via `config.dictionaries`.
358
+ * Returns null if no dictionaries are provided.
299
359
  */
300
360
  declare const buildDenyList: (config: DenyListConfig, ctx?: PipelineContext) => Promise<DenyListData | null>;
301
361
  /**
@@ -306,7 +366,7 @@ declare const buildDenyList: (config: DenyListConfig, ctx?: PipelineContext) =>
306
366
  * the search instance was built on a different context
307
367
  * (e.g. cachedSearch).
308
368
  */
309
- declare const ensureDenyListData: (ctx?: PipelineContext) => Promise<void>;
369
+ declare const ensureDenyListData: (ctx?: PipelineContext, dictionaries?: Dictionaries) => Promise<void>;
310
370
  /**
311
371
  * Process deny list matches from the unified search.
312
372
  * Receives all matches; filters to the deny list slice
@@ -647,14 +707,18 @@ declare const propagateOrgNames: (entities: Entity[], fullText: string) => Entit
647
707
  //#endregion
648
708
  //#region src/detectors/names.d.ts
649
709
  /**
650
- * Load name corpus data from per-language dictionary
651
- * files and legacy config files. Merges all sources.
710
+ * Load name corpus data from injected dictionaries
711
+ * and legacy config files. Merges all sources.
652
712
  *
653
713
  * Safe to call multiple times; only loads once per
654
714
  * context. Must be called before detectNameCorpus or
655
715
  * the getNameCorpus*() accessors are used.
716
+ *
717
+ * @param dictionaries Optional pre-loaded dictionaries
718
+ * with per-language first names and surnames. When
719
+ * omitted, only legacy config files are used.
656
720
  */
657
- declare const initNameCorpus: (ctx?: PipelineContext) => Promise<void>;
721
+ declare const initNameCorpus: (ctx?: PipelineContext, dictionaries?: Dictionaries) => Promise<void>;
658
722
  /**
659
723
  * Detect person names by looking up tokens against the
660
724
  * name corpus, then chaining adjacent name-like tokens.
@@ -933,5 +997,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
933
997
  */
934
998
  declare const normalizeForSearch: (text: string) => string;
935
999
  //#endregion
936
- 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 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
+ 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 };
937
1001
  //# sourceMappingURL=wasm.d.mts.map