dcconcurrencymanager

1.0.2 • Public • Published

dc.ConcurrencyManager

Module for managing concurrency and outputting history.

Installing:

Clone the Repo

  git clone git@github.com:TRLX/dc.ConcurrencyManager.git 

Install modules

  npm install 

Run the module

  npm start 

Module will compare mock meeting data from ./testData folder. Folder consist of current and incoming folders which imitates user 1 ( dc.App ) and user 2 ( CRM ).

Usage:

accepts @current, @incomming and @include as parameters.

@current - Record to which changes should be compared. @incomming - Record of incomming changes @include - A field name which will be included in all output of changeds, regarding whether it has been changed or not e.g Id which is needed to identify repeater items.

Example output of diff process for Simple Cards:

// Compares two data set of simple cards and outputs updates as JSON object.
api.getSimpleCardDiff(current, head, 'id')

Output:

[ 
  { title: 'Mrs',
    fullName: 'Dito',
    homeAddress:
     { BuildingName: 'Dremm Town',
       Line1: '',
       CountryName: 'Kololand hohlandia' },
    currentValueOfTheProperty: { amountGBP: 2500000 } },
  { areYouASmoker: 'no',
    sufferingFromAnyMedicalConditions: 'no',
    sufferingFromAnyMedicalConditionsPleaseProvideDetails: ''},
  { areYouAUkTaxPayer: 'yes',
    pleaseGiveUsDetails: '',
    areYouDomiciliedInTheUK: 'no',
    countryOfResidence: 'Germany',
    whenDidYourUKResidencyBegin: '16 June 2009',
    isYourTaxStatusExpectedToChange: 'yes',
    isYourTaxStatusExpectedToChangeDetails: 'Mjhgfd' },
  {},
  {} 
 ]

Example output of diff process for Repeaterter Cards:

// Compares two data set of repeater cards and outputs updates as array JSON object, containing changed, deleted or created value with ID included.

api.getSimpleCardDiff(current, incomming, 'id')

OUTPUT:

[ { id: '1', __status: 'updated', nameOfTheCompany: 'Cvb' },
  undefined,
  undefined,
  { id: 'B1apGgV1H',
    __status: 'updated',
    amount:
     { amount: [Object], undefined: undefined, __status: 'updated' } },
  { id: 'SyPCMeNkH', __status: 'deleted' },
  { id: 'BkKkXgEJB', __status: 'deleted' },
  { id: 'BkqTFkV1H',
    __status: 'updated',
    policyAccountNumber: 'SAN36123728',
    repaymentMethod: 'Test Method',
    earlyRepaymentCharges: 'No' },
  { id: 'BJx0-XlN1S', __status: 'deleted' },
  { id: 'S1lqM7xEyH', __status: 'deleted' },
  { id: 'ryj2tkVyH', __status: 'deleted' } ]

__status describes the actions on field or repeater item In case when item is deleted from repeater, module will output:

id: 'BJx0-XlN1S'
__status: 'deleted'

Use the id to hook the record for full info in History UI.

In case of update value in the output will be

  { id: 'BkqTFkV1H',
    __status: 'updated',
    policyAccountNumber: 'SAN36123728',
    repaymentMethod: 'Test Method',
    earlyRepaymentCharges: 'No' }

Showing the ID of the repeater item ( for hooking and pulling any edditional information ) and ONLY the fields which has been modified.

Unit Testing

Module testing is done via Mocha and Chai. Each test is contained in tests folder, devided by simple and repeater cards.

Running tests

To Run test use npm with following command.

npm test

Currently there are:

  • Simple card tests
  • Repeater card tests
  • Utility testing

Next steps:

  • Output Changes as history
  • Implement tests for:
  1. Empty Records diff.
  2. Identical Records diff.
  3. Break down tests by cards.

Blocker Need clarificataion for following:

  1. what should output be if repeater item is deleted.
  2. what should output be if repeater item is created.

Readme

Keywords

none

Package Sidebar

Install

npm i dcconcurrencymanager

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

147 kB

Total Files

23

Last publish

Collaborators

  • trlxo9