Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@qiwi/masker-common

qiwi930MIT2.0.1TypeScript support: included

Data masker common assets

readme

@qiwi/masker-common

Masker common components: interfaces, executor, utils

Install

yarn add @qiwi/masker-common

Usage

Context

export interface IEnrichedContext {
  value: any                // value to process
  _value?: any              // pipe result
  id: IContextId            // ctx unique key
  context: IEnrichedContext // ctx self ref
  parentId?: IContextId     // parent ctx id
  registry: IMaskerRegistry       // pipe registry attached to ctx
  execute: IEnrichedExecutor      // executor 
  sync: boolean                   // sync / async switch
  mode: IExecutionMode            // lagacy sync switch
  opts: IMaskerOpts               // current pipe options
  pipe?: IMaskerPipeNormalized              // current pipe ref
  pipeline: IMaskerPipelineNormalized       // actual pipeline
  originPipeline: IMaskerPipelineNormalized // origin pipeline
  [key: string]: any
}

createPipe()

Creates a pipe entity. Several pipes are combined into a pipeline to be processed by executor.

import {createPipe} from '@qiwi/masker-common'

const pipe = createPipe('foo', () => ({value: 'syncfoo'}), async () => ({value: 'asyncfoo'}))

pipe.name       // 'foo'
pipe.sync({})   // {value: 'syncfoo'}
await pipe({})  // {value: 'asyncfoo'}

getPipe()

Get pipe from registry.

import {getPipe, crearePipe as cp} from '@qiwi/masker-common'

const pipe = cp('foo', () => ({value: 'foo'}))
const registry = new Map()

registry.set('foo', pipe)
getPipe('foo', registry) // pipe

execute()

The pipeline executor. Transforms the target value (ctx) via the handlers queue. Provides both sync and async modes.

import {createPipe as cp, execute} from '@qiwi/masker-common'

const pipe1 = cp('pipe1', () => ({value: 'pipe1'}))
const pipe2 = cp('pipe2', ({value}) => ({value: value + 'pipe2'}))
const pipeline = [pipe1, pipe2]

const value = 'foobar'

// async
await execute({pipeline, value})        // {value: 'pipe1pipe2'}

// sync
execute({pipeline, value, sync: true})  // {value: 'pipe1pipe2'}
execute.sync({pipeline, value})         // {value: 'pipe1pipe2'}

License

MIT

changelog

@qiwi/masker-common 1.13.2 (2021-11-18)

Performance Improvements

Dependencies

  • @qiwi/masker-infra: upgraded to 1.0.5

@qiwi/masker-common 1.13.1 (2021-11-04)

Bug Fixes

  • update deps, fix some vuls (d303201)

Dependencies

  • @qiwi/masker-infra: upgraded to 1.0.4

@qiwi/masker-common 1.13.0 (2021-07-18)

Features

  • schema: use array for items props declaration (aa6cb13), closes #84

@qiwi/masker-common 1.12.1 (2021-07-11)

Bug Fixes

  • common: let exec path be self-invoked (12762b6)

Performance Improvements

  • common: remove redundant exec on pipeline ending (0a32b33)

@qiwi/masker-common 1.12.0 (2021-07-10)

Features

  • facade: add options to masker iface (1bb4137), closes #79

@qiwi/masker-common 1.11.0 (2021-07-09)

Bug Fixes

  • common: fix pipe opts resolver (0c20d21)

Features

  • facade: add masker factory (04bd90f), closes #64

@qiwi/masker-common 1.10.1 (2021-07-07)

Performance Improvements

@qiwi/masker-common 1.10.0 (2021-07-04)

Features

  • add debug pipe, optimize patchExecutor (1dc94b7), closes #54

@qiwi/masker-common 1.9.0 (2021-07-03)

Features

  • add error capture pipe/exec hook (dfe2143), closes #57

@qiwi/masker-common 1.8.1 (2021-06-27)

Bug Fixes

  • common: capture err from promisified sync exec (b819e45)

@qiwi/masker-common 1.8.0 (2021-06-26)

Features

  • common: pass pipe opts to exec (06484c1)
  • sensor: support configurable patterns (da29ffe)

@qiwi/masker-common 1.7.3 (2021-06-22)

Performance Improvements

  • package: update deps, fix vuls (18e2bb0)

Dependencies

  • @qiwi/masker-infra: upgraded to 1.0.3

@qiwi/masker-common 1.7.2 (2021-03-19)

Bug Fixes

  • fix docs build scripts (a9cc0d8)
  • deps: update dependency xregexp to v5 (8503374)
  • package: up deps, fix some vuls (7e1607b)

Performance Improvements

  • pkg: up deps, fix vulns (3af5c20)

Dependencies

  • @qiwi/masker-infra: upgraded to 1.0.2

@qiwi/masker-common 1.7.1 (2020-09-30)

Performance Improvements

  • common: util refactoring (7416312)

@qiwi/masker-common 1.7.0 (2020-09-30)

Features

  • provide key masking by schema (3f436cd)
  • separate values and keys directives (49ab10c)

Performance Improvements

Dependencies

  • @qiwi/masker-infra: upgraded to 1.0.1

@qiwi/masker-common 1.6.0 (2020-09-10)

Features

  • split: assign path to exec context (8488759)

@qiwi/masker-common 1.5.0 (2020-09-08)

Features

  • split: provide async flow for split pipe (e72604f)

@qiwi/masker-common 1.4.0 (2020-09-08)

Features

Dependencies

  • @qiwi/masker-infra: upgraded to 1.0.0

@qiwi/masker-common 1.3.2 (2020-07-30)

Performance Improvements

  • common: improve exec builder (b3ff519)

@qiwi/masker-common 1.3.1 (2020-07-30)

Performance Improvements

@qiwi/masker-common 1.3.0 (2020-07-30)

Features

  • common: apply pipeline normalizer to context (1be589e)

@qiwi/masker-common 1.2.0 (2020-07-23)

Features

  • inherit proto of input objects (0a0ebc3)

@qiwi/masker-common 1.1.0 (2020-06-30)

Features

  • plain: add plain masker fraft (9b320d5)

@qiwi/masker-common 1.0.0 (2020-06-24)

Features

  • common: add async schema processing (aa8c1d4)
  • common: add schema processing (sync) (8b6489b)
  • common: force masker pipe be named (66e7b75)
  • add schema building flow (7b3cd86)
  • common: add self-reference for shared context (874cc1b)
  • add sync pipeline executor (863fd04)
  • support async flow (6e4d7e3)
  • support pipe refs and pipe registries (5a6e834)