{"_id":"@archer-oss/dependency-checker-core","_rev":"1-71291b8828f2b7415a9771b826c8ea64","name":"@archer-oss/dependency-checker-core","dist-tags":{"latest":"1.1.4"},"versions":{"1.1.4":{"name":"@archer-oss/dependency-checker-core","version":"1.1.4","description":"Core logic for data management powered by dependencies","main":"dist/index.cjs.js","module":"dist/index.esm.js","typings":"dist/types/dependency-checker.d.ts","repository":{"type":"git","url":"git+ssh://git@gitlab.com/archer-oss/form-builder/dependency-checker-core.git"},"publishConfig":{"registry":"https://registry.npmjs.org/","tag":"latest","access":"public"},"author":{"name":"Sai Hari"},"license":"MIT","scripts":{"build":"npm-run-all --parallel build:app build:types","build:app":"rollup -c","build:types":"tsc -p tsconfig.build.json","format:files":"prettier --ignore-path .gitignore .","format:check":"npm run format:files -- --check","format":"npm run format:files -- --write","lint":"eslint .","test":"jest","typecheck":"tsc --noEmit --emitDeclarationOnly false","validate":"npm-run-all --parallel format:check lint test typecheck"},"dependencies":{"@babel/runtime":"^7.15.4"},"devDependencies":{"@archer-oss/dev-scripts":"^1.2.7","jest":"^27.3.0","typescript":"^4.4.4","prettier":"2.6.2"},"gitHead":"58df6b07d8a4ae7c0a0e48446bb626f962f6f203","bugs":{"url":"https://gitlab.com/archer-oss/form-builder/dependency-checker-core/issues"},"homepage":"https://gitlab.com/archer-oss/form-builder/dependency-checker-core#readme","_id":"@archer-oss/dependency-checker-core@1.1.4","_nodeVersion":"17.9.0","_npmVersion":"7.24.2","dist":{"integrity":"sha512-6x/nPwg7m8+vbs1BaIidTPEHS0imvMdXUvOcWXlUtGzQiURGiYSpSh27RVQkziIaJwLKRDqVz3HcXsBIiDxzsQ==","shasum":"bb4182d9f845a045a8f6abd5b914f918ae513650","tarball":"https://registry.npmjs.org/@archer-oss/dependency-checker-core/-/dependency-checker-core-1.1.4.tgz","fileCount":13,"unpackedSize":64146,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/WAroDWsDGrUK2IU0xnDrPVi5yuFiLPAjOqqkptN8FQIhANGLWmM9GSj6nUxxBkRG25fwvrALd4fY7S/Rm9ie7ddW"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXaOxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo+Og/9G9NwIcj5MLIThcnMVEmnmi2qnH+NZ/ijq5a0QEUHXOUOZ8qr\r\n88D+2iMLfsAbUyohWmvKg6Vgo6TZXhl9NG0GL7qUs/64YftUcrhn4oP+D7Lv\r\n3Edrjy9kStU93OUfNNgtXGOraW8j9voqhxYe7y8+aJtLrsQIc2StFFgkr0Gl\r\nV6chzLsFm/sGJyM1wQYHi5kxdKG+dYW1DbH2quuB2UWVzJytR3+GgJQK83HK\r\nvIoyg1xM22BEJMC+WAe2DJJoFJf9S2NOtTCEKbbGDfWXdKSQxBU9M2GeANnD\r\nEAqiZtojtQ8PhA1ha1p6tWD+5DRp4q0b2c5Rj14kYxLfwzHUdAaLrgXzuyGP\r\n0/qSbqGaCM1VXG3wi5ayA7btXJ6aD7a3feldTclwkWdoxSpjiYHbCvdQD1bI\r\np+canckRJLVQwpJEMCFT5/BnbQb0XxAbk8VuBZTWjHK/ZP2BGNi66NEM56FC\r\nHUP221ylKXi48LU45rriMpKJ0h9HQv6C5wQWMwGCEQpCPhUSM7ZekNaoCzv/\r\nENsyMRR/hPJeyvS1KTED8YiEgoQuhsMO4oYMYKiEY12jjZjJlv5kAXOP5zyF\r\n7owyH/8ILm0Vdzhq/XoqkbNMOWjSjfd/lGLBqp9FvKGHYOWHYtB1qNHIxwFC\r\nlrPX3FHdbY0+d7Y3ByLM9sxpRYau3TDYEo0=\r\n=/Y00\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"barkerd427","email":"barkerd427@gmail.com"},"directories":{},"maintainers":[{"name":"sai.hari","email":"sai.hari@archerirm.com"},{"name":"barkerd427","email":"barkerd427@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dependency-checker-core_1.1.4_1650303921261_0.21241659857571027"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-18T17:45:21.206Z","1.1.4":"2022-04-18T17:45:21.480Z","modified":"2022-04-19T15:05:14.725Z"},"maintainers":[{"email":"ryandoll@gmail.com","name":"ryandoll"},{"email":"sai.hari@archerirm.com","name":"sai.hari"},{"email":"barkerd427@gmail.com","name":"barkerd427"}],"description":"Core logic for data management powered by dependencies","homepage":"https://gitlab.com/archer-oss/form-builder/dependency-checker-core#readme","repository":{"type":"git","url":"git+ssh://git@gitlab.com/archer-oss/form-builder/dependency-checker-core.git"},"author":{"name":"Sai Hari"},"bugs":{"url":"https://gitlab.com/archer-oss/form-builder/dependency-checker-core/issues"},"license":"MIT","readme":"# dependency-checker-core\n\nPackage for core dependency checker logic used by higher level abstractions.\n\nGiven a set of data, meta data and dependencies, this package outputs the effects of applying the dependencies on the data.\n\n## Example\n\n```js\nconst data = {\n  A: {\n    firstName: 'Benjamin',\n    lastName: 'Test',\n    age: 120,\n  },\n  B: {\n    isCurious: true,\n  },\n};\n\nconst metaData = {\n  A: {},\n  B: {\n    shouldApplyEffects: true,\n  },\n};\n\nconst dependencies = {\n  A: [\n    {\n      key: 'B',\n      type: 'left out for brevity',\n      // data and metaData for \"B\"\n      cond: (data, metaData) => data.isCurious && metaData.shouldApplyEffects,\n      effects: {\n        lastName: 'Button',\n      },\n    },\n    {\n      key: 'A',\n      type: 'left out for brevity',\n      // data and metaData for \"A\"\n      cond: (data, metaData) => data.lastName === 'Button',\n      effects: {\n        age: 20,\n      },\n    },\n  ],\n};\n```\n\nThe output of applying the above dependencies to the above data and meta data is the following:\n\n```js\nconst updatedData = {\n  A: {\n    firstName: 'Benjamin',\n    lastName: 'Button',\n    age: 20,\n  },\n  B: {\n    isCurious: true,\n  },\n};\n```\n\n## Dependencies\n\n### Dependency Properties\n\nDependencies have the following properties:\n\n```js\nconst dependencies = {\n  // A list of dependencies for the item \"A\"\n  A: [\n    {\n      // the key that a given item is dependent on (i.e. \"A\" is dependent on \"B\")\n      key: 'B',\n      // A value used for TypeScript support that gives completion for the `data` and `metaData` below\n      type: 'some-type',\n      // A condition that gets the data and metaData for \"B\"\n      // If the condition evaluates to true then the effects\n      // are applied, otherwise the effects are ignored\n      cond: (data, metaData) => true,\n      // Properties which overwrite the data for \"A\"\n      // effects stack, so a dependency lower in the list\n      // with the same effect property will take precedence\n      effects: {},\n    },\n  ],\n};\n```\n\n### Dependency Stacking\n\nSince the dependencies are an array, you may be wondering what happens when two dependencies that update the same data property exist. In this case, the order of the dependencies comes into play with dependencies coming later in the list taking priority.\n\n### Dependency Chaining\n\nComplex dependency chains can be made between n-number of items. For example:\n\n```js\nconst dependencies = {\n  B: [\n    {\n      key: 'A',\n      type: 'some-type',\n      cond: () => true,\n      effects: {},\n    },\n  ],\n  C: [\n    {\n      key: 'B',\n      type: 'some-type',\n      cond: () => true,\n      effects: {},\n    },\n  ],\n};\n```\n\nIn this scenario, item \"B\" is dependent on item \"A\" and item \"C\" is dependent on item \"B\". If the item \"B\" dependency on item \"A\" evaluates to true, a recalculation of item \"C\" will be triggered since it's dependent on item \"B\".\n\n### Self Dependency\n\nItems can be dependent on themselves which can be useful for various things such as error handling. For example:\n\n```js\nconst dependencies = {\n  A: [\n    {\n      key: 'A',\n      type: 'some-type',\n      cond: (data) => data.value === \"I'm invalid\",\n      effects: {\n        error: true,\n      },\n    },\n  ],\n};\n```\n\n## Limitations\n\nAs of today, the dependency checker does not support circular dependencies, so \"A\" can't be dependent on \"B\" and \"B\" can't be dependent on \"A\" at the same time.\n","readmeFilename":"README.md"}