euredact 0.5.1 → 0.7.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 (57) hide show
  1. package/NOTICE +11 -0
  2. package/README.md +658 -45
  3. package/dist/cjs/cache.js +2 -8
  4. package/dist/cjs/cloud/account.js +180 -0
  5. package/dist/cjs/cloud/batches.js +469 -0
  6. package/dist/cjs/cloud/client.js +131 -18
  7. package/dist/cjs/cloud/config.js +28 -2
  8. package/dist/cjs/cloud/errors.js +39 -2
  9. package/dist/cjs/cloud/index.js +16 -1
  10. package/dist/cjs/index.js +9 -1
  11. package/dist/cjs/platform.browser.js +98 -0
  12. package/dist/cjs/platform.js +140 -0
  13. package/dist/cjs/rules/bicGleif.js +57 -0
  14. package/dist/cjs/rules/bicRegistry.js +37 -11
  15. package/dist/cjs/rules/countries/index.js +138 -48
  16. package/dist/cjs/rules/cues.js +29 -9
  17. package/dist/cjs/rules/engine.js +14 -6
  18. package/dist/cjs/rules/suppressors.js +418 -23
  19. package/dist/cjs/rules/validators.js +103 -0
  20. package/dist/cjs/sdk.js +150 -44
  21. package/dist/cjs/types.js +4 -1
  22. package/dist/esm/cache.js +2 -8
  23. package/dist/esm/cloud/account.d.ts +155 -0
  24. package/dist/esm/cloud/account.js +175 -0
  25. package/dist/esm/cloud/batches.d.ts +166 -0
  26. package/dist/esm/cloud/batches.js +464 -0
  27. package/dist/esm/cloud/client.d.ts +90 -5
  28. package/dist/esm/cloud/client.js +126 -26
  29. package/dist/esm/cloud/config.d.ts +6 -0
  30. package/dist/esm/cloud/config.js +27 -2
  31. package/dist/esm/cloud/errors.d.ts +26 -1
  32. package/dist/esm/cloud/errors.js +35 -1
  33. package/dist/esm/cloud/index.d.ts +4 -2
  34. package/dist/esm/cloud/index.js +4 -2
  35. package/dist/esm/index.d.ts +2 -2
  36. package/dist/esm/index.js +1 -1
  37. package/dist/esm/platform.browser.d.ts +27 -0
  38. package/dist/esm/platform.browser.js +92 -0
  39. package/dist/esm/platform.d.ts +20 -0
  40. package/dist/esm/platform.js +101 -0
  41. package/dist/esm/rules/bicGleif.d.ts +4 -0
  42. package/dist/esm/rules/bicGleif.js +53 -0
  43. package/dist/esm/rules/bicRegistry.d.ts +25 -11
  44. package/dist/esm/rules/bicRegistry.js +36 -11
  45. package/dist/esm/rules/countries/index.js +138 -48
  46. package/dist/esm/rules/cues.d.ts +1 -1
  47. package/dist/esm/rules/cues.js +29 -9
  48. package/dist/esm/rules/engine.js +14 -6
  49. package/dist/esm/rules/suppressors.d.ts +1 -0
  50. package/dist/esm/rules/suppressors.js +417 -22
  51. package/dist/esm/rules/validators.d.ts +14 -0
  52. package/dist/esm/rules/validators.js +100 -0
  53. package/dist/esm/sdk.d.ts +63 -19
  54. package/dist/esm/sdk.js +148 -44
  55. package/dist/esm/types.d.ts +58 -2
  56. package/dist/esm/types.js +4 -1
  57. package/package.json +12 -4
@@ -280,12 +280,20 @@ class RuleEngine {
280
280
  if (this.matcher.validate(m)) {
281
281
  validated.push({ match: m, hasValidValidator: m.patternDef.validator !== null });
282
282
  }
283
- else if (m.patternDef.validator !== null && !m.patternDef.requiresContext) {
284
- failedSpans.push({ start: m.start, end: m.end, code: m.countryCode,
285
- etype: String(m.patternDef.entityType) });
286
- if (cues_js_1.RESCUE_TARGETS.has(String(m.patternDef.entityType))
287
- && (0, cues_js_1.cuedType)(text, m.start) === m.patternDef.entityType)
283
+ else if (m.patternDef.validator !== null) {
284
+ const cued = cues_js_1.RESCUE_TARGETS.has(String(m.patternDef.entityType))
285
+ && (0, cues_js_1.cuedType)(text, m.start) === m.patternDef.entityType;
286
+ if (!m.patternDef.requiresContext) {
287
+ failedSpans.push({ start: m.start, end: m.end, code: m.countryCode,
288
+ etype: String(m.patternDef.entityType) });
289
+ if (cued)
290
+ rescued.push(m);
291
+ }
292
+ else if (cued) {
293
+ // A label-gated pattern is rescued too, but only by a cue touching the
294
+ // value; it casts no demotion zone (rules-engine#75).
288
295
  rescued.push(m);
296
+ }
289
297
  }
290
298
  }
291
299
  // Evidence pass: work out which countries this document belongs to, from
@@ -495,7 +503,7 @@ class RuleEngine {
495
503
  // the value is filed as a Cypriot identity number. Dropping it also clears
496
504
  // outOfScope, which would otherwise claim the detection belongs to a
497
505
  // country the caller did not declare while naming no country at all.
498
- const retyped = (0, cues_js_1.retypedBy)(text, match.start, entityType, countryScores.get(match.countryCode) ?? 0);
506
+ const retyped = (0, cues_js_1.retypedBy)(text, match.start, entityType, countryScores.get(match.countryCode) ?? 0, match.countryCode);
499
507
  if (retyped !== null) {
500
508
  entityType = retyped;
501
509
  country = null;