{"_id":"@8baselabs/8base-utils","_rev":"3-ea85cc658214422fb0f70df45dece737","name":"@8baselabs/8base-utils","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@8baselabs/8base-utils","version":"0.0.1","description":"This is package to deal with common scenarios working with 8base platform","main":"lib/index.js","types":"./lib/index.d.ts","scripts":{"test":"jest --collect-coverage","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"eslint --fix"},"repository":{"type":"git","url":"git+https://github.com/8base-services/8base-utils.git"},"keywords":["8base"],"author":{"name":"8baselabs"},"license":"ISC","bugs":{"url":"https://github.com/8base-services/8base-utils/issues"},"homepage":"https://github.com/8base-services/8base-utils","devDependencies":{"@babel/core":"^7.9.6","@babel/preset-env":"^7.9.6","@babel/preset-typescript":"^7.9.0","@types/jest":"^25.2.1","@types/node":"^13.13.5","@typescript-eslint/eslint-plugin":"^2.31.0","@typescript-eslint/parser":"^2.31.0","babel-jest":"^26.0.1","eslint":"^7.0.0","eslint-config-prettier":"^6.11.0","eslint-plugin-jest":"^23.10.0","eslint-plugin-jsdoc":"^25.0.1","husky":"^4.2.5","jest":"^26.0.1","lint-staged":"^10.2.2","prettier":"^2.0.5","ts-jest":"^25.5.1","typescript":"^3.8.3"},"husky":{"hooks":{"pre-commit":"npx lint-staged","pre-push:":"npm test"}},"lint-staged":{"*.{js,ts}":["prettier --write","eslint --fix"]},"dependencies":{"@8baselabs/validation-utils":"^0.0.1"},"gitHead":"69d2e0757b361503a207af60c01ba03defb87e67","_id":"@8baselabs/8base-utils@0.0.1","_nodeVersion":"14.18.3","_npmVersion":"8.5.0","dist":{"integrity":"sha512-2zcgPqWKmUe1bUmxy10f9Xn6CUVj3c4chmBaDmh6vGp4ulPX2wp+vsZ2ozvoUTBO7yr1OCB43yvcmfpzvxbenw==","shasum":"e8d32e676e7f686500b4c8997ef0cfe86c09b81c","tarball":"https://registry.npmjs.org/@8baselabs/8base-utils/-/8base-utils-0.0.1.tgz","fileCount":2,"unpackedSize":6508,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID3Dvoup4Ovg0lYi9OpGFMV5H+0ioBKT0CGc1nvZzW9rAiA2uSuvkidFzUIT/gXjtTDaK6WbfAHphdl8Wz5XcMJmdw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRc8JACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrRqw//WQcPWXJB43a/Nk+TuHLwhO+yzl4pn2o7MArTas2CWD4aiw5b\r\nKB/qBv86XpyUw/XuFdSso00rti6ndIycD3EzUukjE/onTXRoOVA3gWlQ905N\r\nCW0s+GbJ3KUwmOA53cHsnd/Q9qdgWDtY5jKfPZ0hQuexdiCirB3MtbNDxfMH\r\nzBKRT/CINYhHsqeuiPy3qBmdlEo7i63+eY/PRkZeKOGuNzB/GlptRBOz63Hy\r\n6gf77USbYg3YJElD67+rr+ODk8ogONGF3dpIHOJuiJyF2h94M/QkBzY70/Kr\r\nnGPlAaK+XKm1Y540n+AmhibJcOFc5Q1sbRrZEpNLAVUDSZ6l+iE4KrgU1Ey8\r\nth10U+yadvgx6WmH1Ny+E5QNQo7vK4WILPKqO3y42feJOrVs9SmKg6t3x8A0\r\nOjs6xhxcpyzi8extMc24+jChINtI0R1HPRGNVDOczyAoup1/emH8bgGhf54K\r\nwzN8QIhZw1hzbhrzvFH7xY1bZRHNcJ247DpdpQuspu4jXi80AuxAQl83mGgJ\r\nmJ3JG8kHzTajCUtdko0cTYOELfeaJBvzTi+kKVaJ52mUhvtR4tEwU3og4xFk\r\n/JGpM1J2LMaElJ6gdYZUADPUJ0fbd49zyyW46KvvkPgVB39yxzrrOxWFmO9I\r\n0BapufhtZJ+Amm9ml/0oUavkA0s0IwR3sgs=\r\n=1eIj\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"8baselabsadmin","email":"8baselabsadmin@8baselabs.com"},"directories":{},"maintainers":[{"name":"8baselabsadmin","email":"8baselabsadmin@8baselabs.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/8base-utils_0.0.1_1648742153060_0.15948162592706483"},"_hasShrinkwrap":false},"0.0.2":{"name":"@8baselabs/8base-utils","version":"0.0.2","description":"This is package to deal with common scenarios working with 8base platform","main":"lib/index.js","types":"./lib/index.d.ts","scripts":{"test":"jest --collect-coverage","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"eslint --fix"},"repository":{"type":"git","url":"git+https://github.com/8base-services/8base-utils.git"},"keywords":["8base"],"author":{"name":"8baselabs"},"license":"ISC","bugs":{"url":"https://github.com/8base-services/8base-utils/issues"},"homepage":"https://github.com/8base-services/8base-utils","devDependencies":{"@babel/core":"^7.9.6","@babel/preset-env":"^7.9.6","@babel/preset-typescript":"^7.9.0","@types/jest":"^25.2.1","@types/node":"^13.13.5","@typescript-eslint/eslint-plugin":"^2.31.0","@typescript-eslint/parser":"^2.31.0","babel-jest":"^26.0.1","eslint":"^7.0.0","eslint-config-prettier":"^6.11.0","eslint-plugin-jest":"^23.10.0","eslint-plugin-jsdoc":"^25.0.1","husky":"^4.2.5","jest":"^26.0.1","lint-staged":"^10.2.2","prettier":"^2.0.5","ts-jest":"^25.5.1","typescript":"^3.8.3"},"husky":{"hooks":{"pre-commit":"npx lint-staged","pre-push:":"npm test"}},"lint-staged":{"*.{js,ts}":["prettier --write","eslint --fix"]},"dependencies":{"@8baselabs/validation-utils":"^0.0.1"},"gitHead":"69d2e0757b361503a207af60c01ba03defb87e67","_id":"@8baselabs/8base-utils@0.0.2","_nodeVersion":"14.18.3","_npmVersion":"8.5.0","dist":{"integrity":"sha512-ilDwsQ9A8NG7CdtpH7Z0uMwYaT6b/pUynpDoacTfzQe7IdERgLE7VS1MUvtmosDCgr3PoWWWGMiBxeFrQlKXgg==","shasum":"a1f90bbaedae05c42435e82624ac7ed529b46a8e","tarball":"https://registry.npmjs.org/@8baselabs/8base-utils/-/8base-utils-0.0.2.tgz","fileCount":16,"unpackedSize":29931,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIPTybHcJp2CMm9gilQ+e5bfXH9IYbOWi93OdwgOAxEQIhAJ3Q+Y8wf3vWfq/HB+YcGlx1S8UPdEL2qMuQPC9pyBav"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRgpIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGiBAAiA9yI1BZ3k/Wwxg8bfyhGlyH06VlqEDUWnMwEY4009jUFa3y\r\ncMa1BWIvfTTB1Cxu6R4/HRs/CVZlBjwOpCDAtUHZ2nNxy9+nlq9vpbpVQi5V\r\nsrrreKkq/tFRQTqyUh0U9imxIG5FnloXHiwaCrwidQYGw5rHKe9kHDRqQsFi\r\nTCfyTgCG8smQlX9SV9jyTJr3PGNmA0cTIGQgAEFmeXuxZe/3nTjJESImpCB5\r\nspiPZl5KiZ2vOxB3s1FR+31Ocfu25MEy5XRDAr7bNsN6u8gKPwb7hrCOP8TK\r\nuq1Cvpu6pEfbG7QoAx6K0fXh6Or9CQFavv5uicxO+gvygFhCMt2K8QhbZ8n7\r\nHkKaN7LRXx+lwZp132nTwQd8lnWgZ+VpBkltX44twMNFAnyszaz88IF50Iap\r\nDPE877c2QqDGu4E7OmGawTtNWia4fcslhGkFq7pJsk7qRQDX3dDKE19sA313\r\n/S3loajiSxiOQHuRpmrtSiS4sPra8f4xsb3kzQu0kYVPNs65TnLPKk43w6c1\r\njOzPQispSj4cprm1zF9f1F7cJxzVg+UAjbDfAA7jERFaaEPhLw3xzpDH82gY\r\n2XfzrEU2S0LQA8hVrKKUOWP2b2qC+qW/RPM2zB1RWi4Aa3GqlMXTF8fFLpve\r\nQQ0qovV0g+Eifir5O1IZBjXz//YpKg6Du9w=\r\n=H5U7\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"8baselabsadmin","email":"8baselabsadmin@8baselabs.com"},"directories":{},"maintainers":[{"name":"8baselabsadmin","email":"8baselabsadmin@8baselabs.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/8base-utils_0.0.2_1648757319762_0.09058372757334898"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-31T15:55:52.981Z","0.0.1":"2022-03-31T15:55:53.219Z","modified":"2023-02-06T11:21:35.751Z","0.0.2":"2022-03-31T20:08:40.410Z"},"maintainers":[{"email":"marcelo.garciaprieto@8baselabs.com","name":"magarciaprieto"},{"email":"ariel.deagustini@8baselabs.com","name":"ariel.deagustini.8baselabs"},{"email":"8baselabsadmin@8baselabs.com","name":"8baselabsadmin"}],"description":"This is package to deal with common scenarios working with 8base platform","homepage":"https://github.com/8base-services/8base-utils","keywords":["8base"],"repository":{"type":"git","url":"git+https://github.com/8base-services/8base-utils.git"},"author":{"name":"8baselabs"},"bugs":{"url":"https://github.com/8base-services/8base-utils/issues"},"license":"ISC","readme":"# 8base utils\n\nThis is a package for functions that are use full in common cases of working with the [8base.com](https://www.8base.com) platform.\n\n\n## Install\n\n`npm i --save @8baselabs/8base-utils`\n\n## API\n\n| Function   | Description   | \n| ------ | ------ | \n| [`normalize8baseReferenceConnect`](#normalize8baseReferenceConnect) | Updates an object to change a property with a 8base `connect` operation. | \n| [`normalize8baseDocumentCreate`](#normalize8baseDocumentCreate) | Updates an object to change a property with a 8base `create` operation for a file object. | \n| [`normalize8baseDocumentsCreate`](#normalize8baseDocumentsCreate) | Updates an object to change a property with a 8base `create` operation for a list of files objects. | \n| [`normalize8baseDocumentDeleteAndUpdate`](#normalize8baseDocumentDeleteAndUpdate) | Updates an object to change a property with a 8base `create` and/or `disconnect` operation for a list of files objects. | \n| [`normalize8baseDocumentsDeleteAndUpdate`](#normalize8baseDocumentsDeleteAndUpdate) | Updates an object to change a property with a 8base `create` and/or `disconnect` operation for a list of files objects. | \n\n\n### `normalize8baseReferenceConnect(data, key)`\n\n- Updates an object to change a property with a 8base `connect` operation.\n- If the value of the key is undefined or null, the property gets deleted from the object.\n- This function mutates the data object to reflect the change.\n- This function assumes that all 8base IDs are of type string.\n\nExample:\n\n\n```javascript\nimport {normalize8baseReferenceConnect} from \"@8baselabs/8base-utils\";\n\nconst issue = {name :\"Issues Name\", project: \"<Project ID>\"   };\n\nnormalize8baseReferenceConnect(issue, \"project\");\n\nconsole.log(issue);\n// {name :\"Issues Name\", project: {connect:{id: \"<Project ID>\"}}};\n\n``` \n\n\n### `normalize8baseDocumentCreate(data, key)`\n\n- Updates an object to change a property with a 8base `create` operation.\n- If the value of the key is undefined or null, the property gets deleted from the object.\n- This function mutates the data object to reflect the change.\n\nExample:\n\n\n```javascript\nimport {normalize8baseDocumentCreate} from \"@8baselabs/8base-utils\";\n\nconst issue = {name :\"Issues Name\", document: {fileId: \"<FILE-ID>\", filename:\"<FILENAME>\"}  };\n\nnormalize8baseDocumentCreate(issue, \"document\");\n\nconsole.log(issue);\n// {name :\"Issues Name\", document: {create:{fileId: \"<FILE-ID>\", filename:\"<FILENAME>\"}}};\n\n``` \n\n\n\n### `normalize8baseDocumentsCreate(data, key)`\n\n- Updates an object to change a property with a 8base `create` operation.\n- If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.\n- This function mutates the data object to reflect the change.\n\nExample:\n\n\n```javascript\nimport {normalize8baseDocumentsCreate} from \"@8baselabs/8base-utils\";\n\nconst issue = {name :\"Issues Name\", document: [{fileId: \"<FILE-ID1>\", filename:\"<FILENAME1>\"},{fileId: \"<FILE-ID2>\", filename:\"<FILENAME2>\"}]  };\n\nnormalize8baseDocumentsCreate(issue, \"document\");\n\nconsole.log(issue);\n// {name :\"Issues Name\", document: {create:[{fileId: \"<FILE-ID1>\",, filename:\"<FILENAME1>\"},{fileId: \"<FILE-ID2>\",, filename:\"<FILENAME2>\"}]}};\n\n``` \n\n\n\n\n### `normalize8baseDocumentDeleteAndUpdate(data, key, oldData)`\n\n- Helper to update or delete one document key from an Object.\n- Updates an object to change a property with a 8base `create` and/or `disconnect` operation.\n- If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.\n- This function mutates the data object to reflect the change.\n\nExample:\n\n\n```javascript\nimport {normalize8baseDocumentDeleteAndUpdate} from \"@8baselabs/8base-utils\";\n\nconst new12 = { a: { fileId: \"FILE-ID1\", filename:\"<FILENAME>\" } };\nconst old12 = {};\nnormalize8baseDocumentDeleteAndUpdate(new12, \"a\", old12);\nexpect(new12).toEqual({ a: { create: { fileId: \"FILE-ID1\", filename:\"<FILENAME>\" } } });\n\n``` \n\n\n\n\n### `normalize8baseDocumentsDeleteAndUpdate(data, key, oldData)`\n\n- Helper to change non null keys to 8base 'delete & create' reference for Documents Lists\n- Updates an object to change a property with a 8base `create` and/or `disconnect` operation.\n- If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.\n- This function mutates the data object to reflect the change.\n\nExample:\n\n\n```javascript\nimport {normalize8baseDocumentsDeleteAndUpdate} from \"@cob8baselabsuildlab/8base-utils\";\n\nconst new15 = { a: [{ fileId: \"FILE-ID1\", filename:\"<FILENAME1>\" }, { id: \"ID2\", fileId: \"FILE-ID2\", filename:\"<FILENAME2>\" }] };\nconst old15 = { a: [{ id: \"FILE-ID2\" }, { id: \"ID2\" }] };\nnormalize8baseDocumentsDeleteAndUpdate(new15, \"a\", old15);\nexpect(new15).toEqual({ a: { create: [{ fileId: \"FILE-ID1\", filename:\"<FILENAME1>\" }], disconnect: [{ id: \"FILE-ID2\" }] } });\n\n``` \n","readmeFilename":"README.md"}