Options
All
  • Public
  • Public/Protected
  • All
Menu

JS Lectern Client

Features:

  • Runs different restrictions validations: regex, range, scripts, required fields, type checks, etc.
  • Transforms the data from string to their proper type.
  • Report validation errors.
  • Fetch dictionaries from the configured lectern service.
  • Provide typed definitions for the dictionary object.
  • Analyze dictionary versions diff.

Usage examples:

to release new version

  • bump the version number

  • publish to npm and tag git: Jenkinsfile will do that when a commit is added to master. if you need to do that manually then run npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" && npm publish

Index

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

BatchProcessingResult

BatchProcessingResult: DeepReadonly<{ processedRecords: TypedDataRecord[]; validationErrors: SchemaValidationError[] }>

CodeListRestriction

CodeListRestriction: Array<string | number>

FieldChanges

FieldChanges: {} | Change

MetaChanges

MetaChanges: { core: { changedFromCore: string[]; changedToCore: string[] } }

Type declaration

  • core: { changedFromCore: string[]; changedToCore: string[] }
    • changedFromCore: string[]
    • changedToCore: string[]

MutableRecord

MutableRecord: {}

Type declaration

ProcessingFunction

ProcessingFunction: (schema: SchemaDefinition, rec: Readonly<DataRecord>, index: number) => any

Type declaration

RangeRestriction

RangeRestriction: { exclusiveMax?: undefined | number; exclusiveMin?: undefined | number; max?: undefined | number; min?: undefined | number }

Type declaration

  • Optional exclusiveMax?: undefined | number
  • Optional exclusiveMin?: undefined | number
  • Optional max?: undefined | number
  • Optional min?: undefined | number

RawMutableRecord

RawMutableRecord: {}

Type declaration

  • [key: string]: string | string[]

RegexChanges

RegexChanges: {}

Type declaration

RequiredChanges

RequiredChanges: {}

Type declaration

RestrictionChanges

RestrictionChanges: { codeList: {}; range: {}; regex: RegexChanges; required: RequiredChanges; script: ScriptChanges }

Type declaration

SchemaProcessingResult

SchemaProcessingResult: DeepReadonly<{ processedRecord: TypedDataRecord; validationErrors: SchemaValidationError[] }>

SchemaTypes

SchemaTypes: string | string[] | boolean | boolean[] | number | number[] | undefined

ScriptChanges

ScriptChanges: {}

Type declaration

Variables

Const F

F: deepFreeze = deepFreeze

Const INVALID_VALUE_ERROR_MESSAGE

INVALID_VALUE_ERROR_MESSAGE: "The value is not permissible for this field." = "The value is not permissible for this field."

Const L

L: Logger = loggerFor(__filename)

Const LOG_LEVEL

LOG_LEVEL: string = process.env.LOG_LEVEL || 'info'

align

align: align

Const availableCpus

availableCpus: number = Number(process.env.ALLOWED_CPUS) || cpuCount

combine

combine: combine

Const cpuCount

cpuCount: number = os.cpus().length

createLogger

createLogger: (options?: LoggerOptions) => Logger

Type declaration

    • (options?: LoggerOptions): Logger
    • Parameters

      • Optional options: LoggerOptions

      Returns Logger

format

format: format

Const fsPromises

fsPromises: promises = fs.promises

json

json: json

label

label: label

Const parentPort

parentPort: null | MessagePort = workerThreads.parentPort

Const pool

pool: StaticPool<unknown, unknown, any> = new StaticPool({size: availableCpus,task: __dirname + '/schema-worker.js',})

prettyPrint

prettyPrint: prettyPrint

Const service

service: "/home/ballabadi/dev/repos/overture/js-lectern-client/src/schema-functions" = require('./schema-functions')

simple

simple: simple

timestamp

timestamp: timestamp

transports

transports: Transports

Const tsNode

tsNode: "/home/ballabadi/dev/repos/overture/js-lectern-client/node_modules/ts-node/dist/index" = require('ts-node')

Const winstonLogger

winstonLogger: Logger = winston.createLogger(logConfiguration)

Const workerThreads

workerThreads: "worker_threads" = require('worker_threads')

Functions

Const analyzeChanges

Const categorizeFieldArrayDesignationChange

  • categorizeFieldArrayDesignationChange(analysis: ChangeAnalysis, field: string, changes: {} | Change): void

Const categorizeFieldChanges

Const categorizeMetaChagnes

Const categorizeRestrictionChanges

Const categorizerValueTypeChange

Const convertFromRawStrings

Const convertToArray

  • convertToArray<T>(val: T | T[]): T[]
  • Type parameters

    • T

    Parameters

    • val: T | T[]

    Returns T[]

convertToTrimmedString

  • convertToTrimmedString(val: unknown | undefined | string | number | boolean | null): string
  • Parameters

    • val: unknown | undefined | string | number | boolean | null

    Returns string

delay

  • delay<T>(milliseconds: number): (Anonymous function)

Const doRequest

  • doRequest(url: string): Promise<any>

Const fetchDiffAndAnalyze

  • fetchDiffAndAnalyze(serviceUrl: string, name: string, fromVersion: string, toVersion: string): Promise<ChangeAnalysis>

getRegexErrorMsg

  • getRegexErrorMsg(info: any): string

Const getSchemaFieldNamesWithPriority

Const getTypedValue

Const isAbsent

  • isAbsent(value: string | number | boolean | undefined): value is undefined
  • Parameters

    • value: string | number | boolean | undefined

    Returns value is undefined

isEmpty

  • isEmpty<TValue>(value: TValue | null | undefined): value is undefined
  • Type parameters

    • TValue

    Parameters

    • value: TValue | null | undefined

    Returns value is undefined

Const isEmptyString

  • isEmptyString(value: string): boolean

Const isFieldChange

  • isFieldChange(obj: any): obj is Change

Const isNestedChange

  • isNestedChange(obj: any): obj is {}

Const isNotAbsent

  • isNotAbsent(value: string | number | boolean | undefined): value is string | number | boolean
  • Parameters

    • value: string | number | boolean | undefined

    Returns value is string | number | boolean

Const isNotEmptyString

  • isNotEmptyString(value: string | undefined): value is string
  • Parameters

    • value: string | undefined

    Returns value is string

isNumber

  • isNumber(value: any): value is number

isNumberArray

  • isNumberArray(values: any): values is number[]
  • Parameters

    • values: any

    Returns values is number[]

Const isRestrictionChange

  • isRestrictionChange(obj: any): obj is {}

isString

  • isString(value: any): value is string

isStringArray

  • isStringArray(value: any | undefined | null): value is string[]
  • Parameters

    • value: any | undefined | null

    Returns value is string[]

Const isStringMatchRegex

  • isStringMatchRegex(expressions: RegExp[], value: string): boolean
  • Parameters

    • expressions: RegExp[]
    • value: string

    Returns boolean

isValueEqual

  • isValueEqual(value: any, other: any): boolean

isValueNotEqual

  • isValueNotEqual(value: any, other: any): boolean

loadDiffFromFile

  • loadDiffFromFile(schemaSvcBaseUrl: string, name: string, fromVersion: string, toVersion: string): Promise<any>
  • Parameters

    • schemaSvcBaseUrl: string
    • name: string
    • fromVersion: string
    • toVersion: string

    Returns Promise<any>

loadSchemaFromFile

  • loadSchemaFromFile(version: string, schemaSvcUrl: string, name: string): Promise<SchemasDictionary>

Const loggerFor

  • loggerFor(fileName: string): Logger

notEmpty

  • notEmpty<TValue>(value: TValue | null | undefined): value is TValue
  • Type parameters

    • TValue

    Parameters

    • value: TValue | null | undefined

    Returns value is TValue

Const populateDefaults

Const process

processProxy

  • processProxy(args: any): {}

Const processRecord

Const processRecords

Const schemaErrorMessage

  • schemaErrorMessage(errorType: string, errorData?: any): string

Const sleep

  • sleep(milliSeconds?: number): Promise<unknown>
  • Parameters

    • Default value milliSeconds: number = 2000

    Returns Promise<unknown>

toString

  • toString(obj: any): any

Const validate

Const validateAfterTypeConversion

Object literals

Const ERROR_MESSAGES

ERROR_MESSAGES: object

INVALID_BY_RANGE

  • INVALID_BY_RANGE(): string

INVALID_BY_REGEX

  • INVALID_BY_REGEX(errData: any): string

INVALID_BY_SCRIPT

  • INVALID_BY_SCRIPT(error: any): any

INVALID_ENUM_VALUE

  • INVALID_ENUM_VALUE(): string

INVALID_FIELD_VALUE_TYPE

  • INVALID_FIELD_VALUE_TYPE(): string

MISSING_REQUIRED_FIELD

  • MISSING_REQUIRED_FIELD(errorData: any): string

Const logConfiguration

logConfiguration: object

format

format: Format = combine(json(), simple(), timestamp())

level

level: string = LOG_LEVEL

transports

transports: ConsoleTransportInstance[] = [new winston.transports.Console()]

Const restClient

restClient: object

fetchDiff

  • fetchDiff(schemaSvcBaseUrl: string, name: string, fromVersion: string, toVersion: string): Promise<SchemasDictionaryDiffs>

fetchSchema

  • fetchSchema(schemaSvcUrl: string, name: string, version: string): Promise<SchemasDictionary>

Legend

  • Property
  • Method

Generated using TypeDoc