From ecec61b278d200d5a067d95808f7c81534c6000f Mon Sep 17 00:00:00 2001 From: Frantz Arty Date: Wed, 19 Jan 2022 17:47:18 -0500 Subject: [PATCH] feat: add meta table --- .../Projects API.postman_collection.json | 473 ++++++++++++++++++ .../chia-localhost.postman_environment.json | 14 + .../20220119211024-create-meta-table.cjs | 13 + src/fullnode/datalayer.js | 47 ++ src/models/meta/index.js | 2 + src/models/meta/meta.mock.js | 8 + src/models/meta/meta.model.js | 16 + src/models/meta/meta.modeltypes.cjs | 14 + src/models/meta/meta.stub.json | 1 + 9 files changed, 588 insertions(+) create mode 100644 docs/postman/Projects API.postman_collection.json create mode 100644 docs/postman/chia-localhost.postman_environment.json create mode 100644 migrations/20220119211024-create-meta-table.cjs create mode 100644 src/fullnode/datalayer.js create mode 100644 src/models/meta/index.js create mode 100644 src/models/meta/meta.mock.js create mode 100644 src/models/meta/meta.model.js create mode 100644 src/models/meta/meta.modeltypes.cjs create mode 100644 src/models/meta/meta.stub.json diff --git a/docs/postman/Projects API.postman_collection.json b/docs/postman/Projects API.postman_collection.json new file mode 100644 index 00000000..d4b58c6a --- /dev/null +++ b/docs/postman/Projects API.postman_collection.json @@ -0,0 +1,473 @@ +{ + "info": { + "_postman_id": "b2e446e9-e882-48ff-9838-33a7b08b0af4", + "name": "Projects API", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "GET Projects", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "response": [ + { + "name": "GET Projects", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + }, + { + "name": "GET Projects with all projectsGetQuerySchema params", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{api_url_v1}}/projects?page=1&limit=10&search=skinte&columns=all&warehouseProjectId=da494c65-17ec-4694-85df-e44de2c77cf5", + "host": ["{{api_url_v1}}"], + "path": ["projects"], + "query": [ + { + "key": "page", + "value": "1" + }, + { + "key": "limit", + "value": "10" + }, + { + "key": "search", + "value": "skinte" + }, + { + "key": "columns", + "value": "all" + }, + { + "key": "warehouseProjectId", + "value": "da494c65-17ec-4694-85df-e44de2c77cf5" + } + ] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + }, + { + "name": "GET Projects with displayed columns (with paging)", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{api_url_v1}}/projects?page=1&limit=5&columns=organization&columns=warehouseProjectId&columns=currentRegistry&columns=registryOfOrigin&columns=originProjectId&columns=program&columns=projectName", + "host": ["{{api_url_v1}}"], + "path": ["projects"], + "query": [ + { + "key": "page", + "value": "1" + }, + { + "key": "limit", + "value": "5" + }, + { + "key": "columns", + "value": "organization" + }, + { + "key": "columns", + "value": "warehouseProjectId" + }, + { + "key": "columns", + "value": "currentRegistry" + }, + { + "key": "columns", + "value": "registryOfOrigin" + }, + { + "key": "columns", + "value": "originProjectId" + }, + { + "key": "columns", + "value": "program" + }, + { + "key": "columns", + "value": "projectName" + } + ] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + }, + { + "name": "GET Projects with displayed columns (without paging)", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{api_url_v1}}/projects?columns=organization&columns=warehouseProjectId&columns=currentRegistry&columns=registryOfOrigin&columns=originProjectId&columns=program&columns=projectName", + "host": ["{{api_url_v1}}"], + "path": ["projects"], + "query": [ + { + "key": "columns", + "value": "organization" + }, + { + "key": "columns", + "value": "warehouseProjectId" + }, + { + "key": "columns", + "value": "currentRegistry" + }, + { + "key": "columns", + "value": "registryOfOrigin" + }, + { + "key": "columns", + "value": "originProjectId" + }, + { + "key": "columns", + "value": "program" + }, + { + "key": "columns", + "value": "projectName" + } + ] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + }, + { + "name": "GET Projects with specific columns", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{api_url_v1}}/projects?page=1&limit=10&columns=warehouseProjectId&columns=projectId&columns=projectName&columns=projectType&columns=projectStatus", + "host": ["{{api_url_v1}}"], + "path": ["projects"], + "query": [ + { + "key": "page", + "value": "1" + }, + { + "key": "limit", + "value": "10" + }, + { + "key": "columns", + "value": "warehouseProjectId" + }, + { + "key": "columns", + "value": "projectId" + }, + { + "key": "columns", + "value": "projectName" + }, + { + "key": "columns", + "value": "projectType" + }, + { + "key": "columns", + "value": "projectStatus" + } + ] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + } + ] + }, + { + "name": "POST Projects", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"11954678-f7a5-47d2-94f8-f4f3138a529c\",\r\n \"program\": \"Eimbee\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"http://dailymotion.com/ligula/suspendisse/ornare/consequat/lectus/in.jpg?aliquam=consequat&lacus=nulla&morbi=nisl&quis=nunc&tortor=nisl&id=duis&nulla=bibendum&ultrices=felis&aliquet=sed&maecenas=interdum&leo=venenatis&odio=turpis&condimentum=enim&id=blandit&luctus=mi&nec=in&molestie=porttitor&sed=pede&justo=justo&pellentesque=eu&viverra=massa&pede=donec&ac=dapibus&diam=duis&cras=at&pellentesque=velit&volutpat=eu&dui=est&maecenas=congue&tristique=elementum&est=in&et=hac&tempus=habitasse&semper=platea&est=dictumst&quam=morbi&pharetra=vestibulum&magna=velit&ac=id&consequat=pretium&metus=iaculis&sapien=diam&ut=erat&nunc=fermentum&vestibulum=justo&ante=nec&ipsum=condimentum\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"projectType\": \"Topicshots\",\r\n \"coveredByNDC\": 0,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"I know many children ask for a pony, but I wanted a bicycle with rockets strapped to it.\",\r\n \"projectStatusDate\": \"2022-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 43,\r\n \"validationApproach\": \"He waited for the stop sign to turn to a go sign.\",\r\n \"validationDate\": \"2022-01-19\",\r\n \"projectTag\": \"Kaymbo\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"60\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "response": [ + { + "name": "POST Projects with projectsPostSchema", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"c9d147e2-bc07-4e68-a76d-43424fa8cd4e\",\r\n \"program\": \"Eimbee\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"http://dailymotion.com/ligula/suspendisse/ornare/consequat/lectus/in.jpg?aliquam=consequat&lacus=nulla&morbi=nisl&quis=nunc&tortor=nisl&id=duis&nulla=bibendum&ultrices=felis&aliquet=sed&maecenas=interdum&leo=venenatis&odio=turpis&condimentum=enim&id=blandit&luctus=mi&nec=in&molestie=porttitor&sed=pede&justo=justo&pellentesque=eu&viverra=massa&pede=donec&ac=dapibus&diam=duis&cras=at&pellentesque=velit&volutpat=eu&dui=est&maecenas=congue&tristique=elementum&est=in&et=hac&tempus=habitasse&semper=platea&est=dictumst&quam=morbi&pharetra=vestibulum&magna=velit&ac=id&consequat=pretium&metus=iaculis&sapien=diam&ut=erat&nunc=fermentum&vestibulum=justo&ante=nec&ipsum=condimentum\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"sector\": \"Viva\",\r\n \"projectType\": \"Topicshots\",\r\n \"coveredByNDC\": 0,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\",\r\n \"projectStatusDate\": \"2022-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 43,\r\n \"validationApproach\": \"Praesent in consequat urna\",\r\n \"validationDate\": \"2022-01-19\",\r\n \"projectTag\": \"Neque\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"223\",\r\n \"projectLocations\": [\r\n {\r\n \"id\": \"40ae83b1-b497-4f63-9b7d-874505b67662\",\r\n \"countryRegion\": \"United States\",\r\n \"country\": null,\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n }\r\n ],\r\n \"qualifications\": [\r\n {\r\n \"id\": \"702cafbb-c624-4273-9cdc-c617ad5675df\",\r\n \"qualificationId\": null,\r\n \"qualificationLink\": \"https://qualification.link/1\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"type\": \"basic type\",\r\n \"label\": \"qualification 1\",\r\n \"creditingPeriodStartDate\": null,\r\n \"creditingPeriodEndDate\": null,\r\n \"warehouseUnitId\": null,\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n }\r\n ],\r\n \"vintages\": [\r\n {\r\n \"id\": \"3d5a8ed2-e5a7-4275-a36e-3456812e39b7\",\r\n \"startDate\": null,\r\n \"endDate\": null,\r\n \"verificationApproach\": null,\r\n \"verificationDate\": null,\r\n \"verificationBody\": \"This is verified\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n },\r\n {\r\n \"id\": \"57c1859d-6aa4-4c57-9dfb-6438e0d4653e\",\r\n \"startDate\": null,\r\n \"endDate\": null,\r\n \"verificationApproach\": null,\r\n \"verificationDate\": null,\r\n \"verificationBody\": \"This is verified\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n },\r\n {\r\n \"id\": \"74887b22-da3b-4c2b-b945-670319193cdd\",\r\n \"startDate\": null,\r\n \"endDate\": null,\r\n \"verificationApproach\": null,\r\n \"verificationDate\": null,\r\n \"verificationBody\": \"This is verified\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n },\r\n {\r\n \"id\": \"7f7f23a5-3e1a-43b4-82d8-b4156b158f88\",\r\n \"startDate\": null,\r\n \"endDate\": null,\r\n \"verificationApproach\": null,\r\n \"verificationDate\": null,\r\n \"verificationBody\": \"This is verified\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n },\r\n {\r\n \"id\": \"a6745831-5d5e-45ed-b9fe-fd6aa129df25\",\r\n \"startDate\": null,\r\n \"endDate\": null,\r\n \"verificationApproach\": null,\r\n \"verificationDate\": null,\r\n \"verificationBody\": \"This is verified\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n }\r\n ],\r\n \"coBenefits\": [\r\n {\r\n \"id\": \"2995a129-1fad-4251-9942-7c6db2fbff74\",\r\n \"benefit\": \"TEST_COBENEFIT_4\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": null,\r\n \"updatedAt\": null\r\n },\r\n {\r\n \"id\": \"729c71bf-cc6e-4424-842f-54c2a490952a\",\r\n \"benefit\": \"TEST_COBENEFIT_3\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": null,\r\n \"updatedAt\": null\r\n },\r\n {\r\n \"id\": \"83913f9e-9876-4c4d-ac4c-10dd992d7d7f\",\r\n \"benefit\": \"TEST_COBENEFIT_5\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": null,\r\n \"updatedAt\": null\r\n },\r\n {\r\n \"id\": \"9506cf84-6f9e-437a-a099-9672e4737668\",\r\n \"benefit\": \"TEST_COBENEFIT_1\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": null,\r\n \"updatedAt\": null\r\n },\r\n {\r\n \"id\": \"f124ebef-6436-4cd4-abdd-c55e10f4d1a0\",\r\n \"benefit\": \"TEST_COBENEFIT_2\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": null,\r\n \"updatedAt\": null\r\n }\r\n ],\r\n \"relatedProjects\": [\r\n {\r\n \"id\": \"394e319e-a4d2-4ad8-a4b3-0d5b660dd8ec\",\r\n \"type\": \"Greenlam\",\r\n \"registry\": \"Ventosanzap\",\r\n \"note\": \"Donec dapibus.\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n },\r\n {\r\n \"id\": \"39b80025-1a2c-4cda-92aa-541e8e059258\",\r\n \"type\": \"Matsoft\",\r\n \"registry\": \"Sub-Ex\",\r\n \"note\": \"Cras pellentesque volutpat dui. Maecenas tristique, est et tempus semper, est quam pharetra magna, ac consequat metus sapien ut nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris viverra diam vitae quam. Suspendisse potenti.\",\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\",\r\n \"createdAt\": \"2022-01-19\",\r\n \"updatedAt\": \"2022-01-19\"\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": "" + }, + { + "name": "POST Projects with required params", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"c9d147e2-bc07-4e68-a76d-43424fa8cd4e\",\r\n \"program\": \"Eimbee\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"http://dailymotion.com/ligula/suspendisse/ornare/consequat/lectus/in.jpg?aliquam=consequat&lacus=nulla&morbi=nisl&quis=nunc&tortor=nisl&id=duis&nulla=bibendum&ultrices=felis&aliquet=sed&maecenas=interdum&leo=venenatis&odio=turpis&condimentum=enim&id=blandit&luctus=mi&nec=in&molestie=porttitor&sed=pede&justo=justo&pellentesque=eu&viverra=massa&pede=donec&ac=dapibus&diam=duis&cras=at&pellentesque=velit&volutpat=eu&dui=est&maecenas=congue&tristique=elementum&est=in&et=hac&tempus=habitasse&semper=platea&est=dictumst&quam=morbi&pharetra=vestibulum&magna=velit&ac=id&consequat=pretium&metus=iaculis&sapien=diam&ut=erat&nunc=fermentum&vestibulum=justo&ante=nec&ipsum=condimentum\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"sector\": \"Viva\",\r\n \"projectType\": \"Phasellus\",\r\n \"coveredByNDC\": 0,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"Nulla et mauris pulvinar, vulputate orci quis, porttitor felis.\",\r\n \"projectStatusDate\": \"2022-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 43,\r\n \"validationApproach\": \"Etiam at ex nisl\",\r\n \"validationDate\": \"2022-01-19\",\r\n \"projectTag\": \"Kaymbo\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"100\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": "" + }, + { + "name": "POST Projects missing required param \"sector\"", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"11954678-f7a5-47d2-94f8-f4f3138a529c\",\r\n \"program\": \"Eimbee\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"http://dailymotion.com/ligula/suspendisse/ornare/consequat/lectus/in.jpg?aliquam=consequat&lacus=nulla&morbi=nisl&quis=nunc&tortor=nisl&id=duis&nulla=bibendum&ultrices=felis&aliquet=sed&maecenas=interdum&leo=venenatis&odio=turpis&condimentum=enim&id=blandit&luctus=mi&nec=in&molestie=porttitor&sed=pede&justo=justo&pellentesque=eu&viverra=massa&pede=donec&ac=dapibus&diam=duis&cras=at&pellentesque=velit&volutpat=eu&dui=est&maecenas=congue&tristique=elementum&est=in&et=hac&tempus=habitasse&semper=platea&est=dictumst&quam=morbi&pharetra=vestibulum&magna=velit&ac=id&consequat=pretium&metus=iaculis&sapien=diam&ut=erat&nunc=fermentum&vestibulum=justo&ante=nec&ipsum=condimentum\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"projectType\": \"Topicshots\",\r\n \"coveredByNDC\": 0,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae\",\r\n \"projectStatusDate\": \"2022-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 43,\r\n \"validationApproach\": \"Quisque dignissim velit vel metus congue, et interdum nulla ullamcorper.\",\r\n \"validationDate\": \"2022-01-19\",\r\n \"projectTag\": \"Kaymbo\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"60\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + } + ] + }, + { + "name": "PUT Projects", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"c9d147e2-bc07-4e68-a76d-43424fa8cd4e\",\r\n \"program\": \"Eimbee\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"https://www.chia.net/technology/\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"sector\": \"Viva\",\r\n \"projectType\": \"Topicshots\",\r\n \"coveredByNDC\": 0,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"His son quipped that power bars were nothing more than adult candy bars.\",\r\n \"projectStatusDate\": \"2020-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 43,\r\n \"validationApproach\": \"This made him feel like an old-style rootbeer float smells.\",\r\n \"validationDate\": \"2022-03-22\",\r\n \"projectTag\": \"Kaymbo\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"60\",\r\n \"projectLocations\": [\r\n {\r\n \"id\": \"b41d0f89-2f71-4bde-b6d0-5cf77802c3fc\",\r\n \"countryRegion\": \"United States\",\r\n \"country\": null,\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n }\r\n ],\r\n \"relatedProjects\": [\r\n {\r\n \"id\": \"54171fde-bbad-4483-9908-79707912cc22\",\r\n \"type\": \"Greenlam\",\r\n \"registry\": \"Aerified\",\r\n \"note\": \"Nulla ut erat id mauris vulputate elementum. Nullam varius. Nulla facilisi. Cras non velit nec nisi vulputate nonummy. Maecenas tincidunt lacus at velit. Vivamus vel nulla eget eros elementum pellentesque. Quisque porta volutpat erat.\",\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n },\r\n {\r\n \"id\": \"aa537d7f-d693-4831-9d88-8a045eebef76\",\r\n \"type\": \"Lotstring\",\r\n \"registry\": \"Y-find\",\r\n \"note\": \"In hac habitasse platea dictumst. Morbi vestibulum, velit id pretium iaculis, diam erat fermentum justo, nec condimentum neque sapien placerat ante. Nulla justo. Aliquam quis turpis eget elit sodales scelerisque. Mauris sit amet eros. Suspendisse accumsan tortor quis turpis. Sed ante. Vivamus tortor. Duis mattis egestas metus.\",\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "response": [ + { + "name": "PUT Projects program, sector, methodologyVersion, projectStatusDate, validationDate", + "originalRequest": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"warehouseProjectId\": \"8a02a620-8be8-44f9-ba90-eff00ccc3a70\",\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"c9d147e2-bc07-4e68-a76d-43424fa8cd4e\",\r\n \"program\": \"Lorem\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"http://dailymotion.com/ligula/suspendisse/ornare/consequat/lectus/in.jpg?aliquam=consequat&lacus=nulla&morbi=nisl&quis=nunc&tortor=nisl&id=duis&nulla=bibendum&ultrices=felis&aliquet=sed&maecenas=interdum&leo=venenatis&odio=turpis&condimentum=enim&id=blandit&luctus=mi&nec=in&molestie=porttitor&sed=pede&justo=justo&pellentesque=eu&viverra=massa&pede=donec&ac=dapibus&diam=duis&cras=at&pellentesque=velit&volutpat=eu&dui=est&maecenas=congue&tristique=elementum&est=in&et=hac&tempus=habitasse&semper=platea&est=dictumst&quam=morbi&pharetra=vestibulum&magna=velit&ac=id&consequat=pretium&metus=iaculis&sapien=diam&ut=erat&nunc=fermentum&vestibulum=justo&ante=nec&ipsum=condimentum\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"sector\": \"Seven\",\r\n \"projectType\": \"Topicshots\",\r\n \"coveredByNDC\": 1,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"They desperately needed another drummer since the current one only knew how to play bongos.\",\r\n \"projectStatusDate\": \"2020-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 22,\r\n \"validationApproach\": \"The small white buoys marked the location of hundreds of crab pots.\",\r\n \"validationDate\": \"2022-03-22\",\r\n \"projectTag\": \"Kaymbo\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"60\",\r\n \"projectLocations\": [\r\n {\r\n \"id\": \"8f23fd77-d19f-4083-b7be-949288e88a36\",\r\n \"countryRegion\": \"China\",\r\n \"country\": null,\r\n \"warehouseProjectId\": \"8a02a620-8be8-44f9-ba90-eff00ccc3a70\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + }, + { + "name": "PUT Projects projectLink", + "originalRequest": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"originProjectId\": \"c5067a60-e329-4510-991c-b302fd00ec8d\",\r\n \"projectId\": \"c9d147e2-bc07-4e68-a76d-43424fa8cd4e\",\r\n \"program\": \"Eimbee\",\r\n \"projectName\": \"Zoomcast\",\r\n \"projectLink\": \"https://www.chia.net/technology/\",\r\n \"projectDeveloper\": \"Cogibox\",\r\n \"sector\": \"Viva\",\r\n \"projectType\": \"Topicshots\",\r\n \"coveredByNDC\": 0,\r\n \"NDCLinkage\": \"Shuffletag\",\r\n \"projectStatus\": \"His son quipped that power bars were nothing more than adult candy bars.\",\r\n \"projectStatusDate\": \"2020-01-19\",\r\n \"unitMetric\": \"Fuscia\",\r\n \"methodology\": \"Quatz\",\r\n \"methodologyVersion\": 43,\r\n \"validationApproach\": \"This made him feel like an old-style rootbeer float smells.\",\r\n \"validationDate\": \"2022-03-22\",\r\n \"projectTag\": \"Kaymbo\",\r\n \"estimatedAnnualAverageEmissionReduction\": \"60\",\r\n \"projectLocations\": [\r\n {\r\n \"id\": \"b41d0f89-2f71-4bde-b6d0-5cf77802c3fc\",\r\n \"countryRegion\": \"United States\",\r\n \"country\": null,\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n }\r\n ],\r\n \"relatedProjects\": [\r\n {\r\n \"id\": \"54171fde-bbad-4483-9908-79707912cc22\",\r\n \"type\": \"Greenlam\",\r\n \"registry\": \"Aerified\",\r\n \"note\": \"Nulla ut erat id mauris vulputate elementum. Nullam varius. Nulla facilisi. Cras non velit nec nisi vulputate nonummy. Maecenas tincidunt lacus at velit. Vivamus vel nulla eget eros elementum pellentesque. Quisque porta volutpat erat.\",\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n },\r\n {\r\n \"id\": \"aa537d7f-d693-4831-9d88-8a045eebef76\",\r\n \"type\": \"Lotstring\",\r\n \"registry\": \"Y-find\",\r\n \"note\": \"In hac habitasse platea dictumst. Morbi vestibulum, velit id pretium iaculis, diam erat fermentum justo, nec condimentum neque sapien placerat ante. Nulla justo. Aliquam quis turpis eget elit sodales scelerisque. Mauris sit amet eros. Suspendisse accumsan tortor quis turpis. Sed ante. Vivamus tortor. Duis mattis egestas metus.\",\r\n \"warehouseProjectId\": \"897891e2-cc66-4867-8da2-c17d69d018cb\",\r\n \"createdAt\": \"2022-01-18T00:05:45.701Z\",\r\n \"updatedAt\": \"2022-01-18T00:05:45.701Z\"\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + } + ] + }, + { + "name": "DELETE Projects", + "request": { + "method": "DELETE", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"warehouseProjectId\": \"81e05bfa-e93f-458f-b907-96bf170e52cd\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api_url_v1}}/projects", + "host": ["{{api_url_v1}}"], + "path": ["projects"] + } + }, + "response": [] + } + ], + "auth": { + "type": "basic", + "basic": [ + { + "key": "username", + "value": "", + "type": "string" + }, + { + "key": "password", + "value": "", + "type": "string" + } + ] + }, + "variable": [ + { + "key": "baseUrl", + "value": "localhost:3000", + "type": "string" + } + ] +} diff --git a/docs/postman/chia-localhost.postman_environment.json b/docs/postman/chia-localhost.postman_environment.json new file mode 100644 index 00000000..f620e809 --- /dev/null +++ b/docs/postman/chia-localhost.postman_environment.json @@ -0,0 +1,14 @@ +{ + "id": "e81565ef-0d7a-4335-8588-96e2cebe5541", + "name": "chia-localhost", + "values": [ + { + "key": "api_url_v1", + "value": "http://localhost:3001/v1", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2022-01-19T19:56:07.283Z", + "_postman_exported_using": "Postman/9.9.3" +} diff --git a/migrations/20220119211024-create-meta-table.cjs b/migrations/20220119211024-create-meta-table.cjs new file mode 100644 index 00000000..62258cbb --- /dev/null +++ b/migrations/20220119211024-create-meta-table.cjs @@ -0,0 +1,13 @@ +'use strict'; + +const modelTypes = require('../src/models/meta/meta.modeltypes.cjs'); + +module.exports = { + async up(queryInterface) { + await queryInterface.createTable('meta', modelTypes); + }, + + async down(queryInterface) { + await queryInterface.dropTable('meta'); + }, +}; diff --git a/src/fullnode/datalayer.js b/src/fullnode/datalayer.js new file mode 100644 index 00000000..41b377c6 --- /dev/null +++ b/src/fullnode/datalayer.js @@ -0,0 +1,47 @@ +import fs from 'fs'; +import path from 'path'; +import request from 'request'; + +process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; + +const certFile = path.resolve( + `${process.env.CHIA_ROOT}/config/ssl/data_layer/private_data_layer.crt`, +); +const keyFile = path.resolve( + `${process.env.CHIA_ROOT}/config/ssl/data_layer/private_data_layer.key`, +); + +const rpcUrl = process.env.DATALAYER_URL; + +const baseOptions = { + method: 'POST', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), +}; + +export const pushChangeListToDatalayer = (changeList) => { + return new Promise((resolve, reject) => { + const options = { + url: `${rpcUrl}/update_data_store`, + body: JSON.stringify({ + changelist: changeList, + id: 'c19cfd5a1f0a221976debcd1206daca0a07bf5e949949c2f30488562870a2fff', + }), + }; + + console.log(changeList); + + request( + Object.assign({}, baseOptions, options), + function (error, response) { + if (error) { + console.log('!!!!!!'); + reject(error); + return; + } + console.log(response.body); + resolve(response); + }, + ); + }); +}; diff --git a/src/models/meta/index.js b/src/models/meta/index.js new file mode 100644 index 00000000..dbd9578f --- /dev/null +++ b/src/models/meta/index.js @@ -0,0 +1,2 @@ +export * from './organizations.model.js'; +export * from './organizations.mock.js'; diff --git a/src/models/meta/meta.mock.js b/src/models/meta/meta.mock.js new file mode 100644 index 00000000..134af917 --- /dev/null +++ b/src/models/meta/meta.mock.js @@ -0,0 +1,8 @@ +import stub from './organizations.stub.json'; + +export const CoBenefitsMock = { + findAll: () => stub, + findOne: (id) => { + return stub.find((record) => record.id == id); + }, +}; diff --git a/src/models/meta/meta.model.js b/src/models/meta/meta.model.js new file mode 100644 index 00000000..0123f366 --- /dev/null +++ b/src/models/meta/meta.model.js @@ -0,0 +1,16 @@ +'use strict'; + +import Sequelize from 'sequelize'; +const { Model } = Sequelize; +import { sequelize } from '../database'; + +import ModelTypes from './meta.modeltypes.cjs'; + +class Meta extends Model {} + +Meta.init(ModelTypes, { + sequelize, + modelName: 'meta', +}); + +export { Meta }; diff --git a/src/models/meta/meta.modeltypes.cjs b/src/models/meta/meta.modeltypes.cjs new file mode 100644 index 00000000..28e9424a --- /dev/null +++ b/src/models/meta/meta.modeltypes.cjs @@ -0,0 +1,14 @@ +const Sequelize = require('sequelize'); + +module.exports = { + id: { + type: Sequelize.INTEGER, + primaryKey: true, + autoIncrement: true, + }, + meta_key: { + type: Sequelize.STRING, + unique: true, + }, + meta_value: Sequelize.STRING, +}; diff --git a/src/models/meta/meta.stub.json b/src/models/meta/meta.stub.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/src/models/meta/meta.stub.json @@ -0,0 +1 @@ +[]